GIcon for MIME icons, findbar and security
This commit is contained in:
parent
83609a1a88
commit
015c6e8428
3 changed files with 52 additions and 100 deletions
|
@ -1692,53 +1692,39 @@ midori_location_action_set_security_hint (MidoriLocationAction* location_action,
|
||||||
if (GTK_IS_TOOL_ITEM (proxies->data))
|
if (GTK_IS_TOOL_ITEM (proxies->data))
|
||||||
{
|
{
|
||||||
GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
|
GtkWidget* entry = midori_location_action_entry_for_proxy (proxies->data);
|
||||||
GdkScreen* screen = gtk_widget_get_screen (entry);
|
|
||||||
GtkIconTheme* icon_theme = gtk_icon_theme_get_for_screen (screen);
|
|
||||||
|
|
||||||
if (hint == MIDORI_SECURITY_UNKNOWN)
|
if (hint == MIDORI_SECURITY_UNKNOWN)
|
||||||
{
|
{
|
||||||
#if !GTK_CHECK_VERSION (3, 0, 0)
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
||||||
|
gchar* icon_names[] = { "channel-insecure-symbolic", "lock-insecure", "dialog-information", NULL };
|
||||||
|
gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY,
|
||||||
|
g_themed_icon_new_from_names (icon_names, -1));
|
||||||
|
#else
|
||||||
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_INFO);
|
||||||
#endif
|
#endif
|
||||||
#if !HAVE_HILDON
|
|
||||||
if (gtk_icon_theme_has_icon (icon_theme, "channel-insecure-symbolic"))
|
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
|
|
||||||
GTK_ICON_ENTRY_PRIMARY, "channel-insecure-symbolic");
|
|
||||||
else if (gtk_icon_theme_has_icon (icon_theme, "lock-insecure"))
|
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
|
|
||||||
GTK_ICON_ENTRY_PRIMARY, "lock-insecure");
|
|
||||||
else
|
|
||||||
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
|
|
||||||
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_INFO);
|
|
||||||
gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry),
|
gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry),
|
||||||
GTK_ICON_ENTRY_PRIMARY, _("Not verified"));
|
GTK_ICON_ENTRY_PRIMARY, _("Not verified"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (hint == MIDORI_SECURITY_TRUSTED)
|
else if (hint == MIDORI_SECURITY_TRUSTED)
|
||||||
{
|
{
|
||||||
#if !GTK_CHECK_VERSION (3, 0, 0)
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
||||||
|
gchar* icon_names[] = { "channel-secure-symbolic", "lock-secure", "locked", NULL };
|
||||||
|
gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY,
|
||||||
|
g_themed_icon_new_from_names (icon_names, -1));
|
||||||
|
#else
|
||||||
|
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION);
|
||||||
#endif
|
#endif
|
||||||
#if !HAVE_HILDON
|
|
||||||
if (gtk_icon_theme_has_icon (icon_theme, "channel-secure-symbolic"))
|
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
|
|
||||||
GTK_ICON_ENTRY_PRIMARY, "channel-secure-symbolic");
|
|
||||||
else if (gtk_icon_theme_has_icon (icon_theme, "lock-secure"))
|
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
|
|
||||||
GTK_ICON_ENTRY_PRIMARY, "lock-secure");
|
|
||||||
else
|
|
||||||
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
|
|
||||||
GTK_ICON_ENTRY_PRIMARY, GTK_STOCK_DIALOG_AUTHENTICATION);
|
|
||||||
gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry),
|
gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry),
|
||||||
GTK_ICON_ENTRY_PRIMARY, _("Verified and encrypted connection"));
|
GTK_ICON_ENTRY_PRIMARY, _("Verified and encrypted connection"));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (hint == MIDORI_SECURITY_NONE)
|
else if (hint == MIDORI_SECURITY_NONE)
|
||||||
{
|
{
|
||||||
if (gtk_icon_theme_has_icon (icon_theme, "text-html-symbolic"))
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
|
gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY,
|
||||||
GTK_ICON_ENTRY_PRIMARY, "text-html-symbolic");
|
g_themed_icon_new_with_default_fallbacks ("text-html-symbolic"));
|
||||||
else
|
#else
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry),
|
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, STOCK_URL);
|
||||||
GTK_ICON_ENTRY_PRIMARY, STOCK_URL);
|
#endif
|
||||||
gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry),
|
gtk_icon_entry_set_tooltip (GTK_ICON_ENTRY (entry),
|
||||||
GTK_ICON_ENTRY_PRIMARY, _("Open, unencrypted connection"));
|
GTK_ICON_ENTRY_PRIMARY, _("Open, unencrypted connection"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -718,67 +718,39 @@ midori_view_apply_icon (MidoriView* view,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
midori_view_mime_icon (MidoriView* view,
|
|
||||||
GtkIconTheme* icon_theme,
|
|
||||||
const gchar* format,
|
|
||||||
const gchar* part1,
|
|
||||||
const gchar* part2)
|
|
||||||
{
|
|
||||||
gchar* icon_name;
|
|
||||||
GdkPixbuf* icon;
|
|
||||||
|
|
||||||
icon_name = part2 ? g_strdup_printf (format, part1, part2)
|
|
||||||
: g_strdup_printf (format, part1);
|
|
||||||
if (!(icon = gtk_icon_theme_load_icon (icon_theme, icon_name, 16, 0, NULL)))
|
|
||||||
{
|
|
||||||
g_free (icon_name);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_ref (icon);
|
|
||||||
midori_view_apply_icon (view, icon, icon_name);
|
|
||||||
g_free (icon_name);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_view_unset_icon (MidoriView* view)
|
midori_view_unset_icon (MidoriView* view)
|
||||||
{
|
{
|
||||||
GdkScreen* screen;
|
GdkScreen* screen;
|
||||||
GtkIconTheme* theme;
|
GtkIconTheme* icon_theme;
|
||||||
gchar** parts = NULL;
|
GIcon* icon;
|
||||||
GdkPixbuf* icon;
|
gchar** icon_names;
|
||||||
|
GdkPixbuf* pixbuf = NULL;
|
||||||
|
|
||||||
if (!((screen = gtk_widget_get_screen (view->web_view))
|
if (!((screen = gtk_widget_get_screen (view->web_view))
|
||||||
&& (theme = gtk_icon_theme_get_for_screen (screen))))
|
&& (icon_theme = gtk_icon_theme_get_for_screen (screen))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(view->mime_type
|
if (view->mime_type != NULL)
|
||||||
&& (parts = g_strsplit (view->mime_type, "/", 2))
|
|
||||||
&& (*parts && parts[1])))
|
|
||||||
{
|
{
|
||||||
icon = gtk_widget_render_icon (view->web_view,
|
gchar* content_type = g_content_type_from_mime_type (view->mime_type);
|
||||||
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
icon = g_content_type_get_icon (content_type);
|
||||||
midori_view_apply_icon (view, icon, GTK_STOCK_FILE);
|
g_free (content_type);
|
||||||
goto free_parts;
|
g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
icon = g_themed_icon_new ("text-html");
|
||||||
|
|
||||||
if (midori_view_mime_icon (view, theme, "%s-%s", *parts, parts[1]))
|
if ((icon_names = (gchar**)g_themed_icon_get_names (G_THEMED_ICON (icon))))
|
||||||
goto free_parts;
|
while (*icon_names)
|
||||||
if (midori_view_mime_icon (view, theme, "gnome-mime-%s-%s", *parts, parts[1]))
|
{
|
||||||
goto free_parts;
|
if ((pixbuf = gtk_icon_theme_load_icon (icon_theme, *icon_names, 16, 0, NULL)))
|
||||||
if (midori_view_mime_icon (view, theme, "%s-x-generic", *parts, NULL))
|
break;
|
||||||
goto free_parts;
|
icon_names++;
|
||||||
if (midori_view_mime_icon (view, theme, "gnome-mime-%s-x-generic", *parts, NULL))
|
}
|
||||||
goto free_parts;
|
g_object_unref (icon);
|
||||||
|
|
||||||
icon = gtk_widget_render_icon (view->web_view,
|
midori_view_apply_icon (view, pixbuf, GTK_STOCK_FILE);
|
||||||
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
|
||||||
midori_view_apply_icon (view, icon, GTK_STOCK_FILE);
|
|
||||||
|
|
||||||
free_parts:
|
|
||||||
g_strfreev (parts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !WEBKIT_CHECK_VERSION (1, 8, 0)
|
#if !WEBKIT_CHECK_VERSION (1, 8, 0)
|
||||||
|
@ -3012,7 +2984,7 @@ webkit_web_view_download_requested_cb (GtkWidget* web_view,
|
||||||
description = g_content_type_get_description (content_type);
|
description = g_content_type_get_description (content_type);
|
||||||
#if GTK_CHECK_VERSION (2, 14, 0)
|
#if GTK_CHECK_VERSION (2, 14, 0)
|
||||||
icon = g_content_type_get_icon (content_type);
|
icon = g_content_type_get_icon (content_type);
|
||||||
g_themed_icon_append_name (G_THEMED_ICON (icon), "document-x-generic");
|
g_themed_icon_append_name (G_THEMED_ICON (icon), "text-html");
|
||||||
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
|
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
|
||||||
g_object_unref (icon);
|
g_object_unref (icon);
|
||||||
gtk_widget_show (image);
|
gtk_widget_show (image);
|
||||||
|
|
|
@ -50,27 +50,21 @@ midori_findbar_set_icon (MidoriFindbar* findbar,
|
||||||
GtkIconEntryPosition icon_pos,
|
GtkIconEntryPosition icon_pos,
|
||||||
const gchar* icon_name)
|
const gchar* icon_name)
|
||||||
{
|
{
|
||||||
#if !HAVE_HILDON
|
if (icon_name != NULL)
|
||||||
GdkScreen* screen = gtk_widget_get_screen (findbar->find_text);
|
|
||||||
GtkIconTheme* icon_theme = gtk_icon_theme_get_for_screen (screen);
|
|
||||||
gchar* symbolic_icon_name;
|
|
||||||
|
|
||||||
if (icon_name == NULL)
|
|
||||||
{
|
{
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text),
|
#if GTK_CHECK_VERSION (2, 16, 0)
|
||||||
icon_pos, NULL);
|
gchar* symbolic_icon_name = g_strconcat (icon_name, "-symbolic", NULL);
|
||||||
return;
|
gtk_entry_set_icon_from_gicon (GTK_ENTRY (findbar->find_text), icon_pos,
|
||||||
}
|
g_themed_icon_new_with_default_fallbacks (symbolic_icon_name));
|
||||||
|
g_free (symbolic_icon_name);
|
||||||
symbolic_icon_name = g_strconcat (icon_name, "-symbolic", NULL);
|
#else
|
||||||
if (gtk_icon_theme_has_icon (icon_theme, symbolic_icon_name))
|
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text),
|
|
||||||
icon_pos, symbolic_icon_name);
|
|
||||||
else
|
|
||||||
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text),
|
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text),
|
||||||
icon_pos, icon_name);
|
icon_pos, icon_name);
|
||||||
g_free (symbolic_icon_name);
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gtk_icon_entry_set_icon_from_icon_name (GTK_ICON_ENTRY (findbar->find_text),
|
||||||
|
icon_pos, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue