Use fallbacks for all icons, we don't want "broken" icons

This commit is contained in:
Christian Dywan 2008-08-17 16:14:15 +02:00
parent 80251606ff
commit 85dea9aa44
5 changed files with 74 additions and 89 deletions

View file

@ -32,27 +32,37 @@
static void
stock_items_init (void)
{
static GtkStockItem items[] =
typedef struct
{
{ STOCK_BOOKMARKS },
{ STOCK_CONSOLE },
{ STOCK_EXTENSION },
{ STOCK_NEWS_FEED },
{ STOCK_LOCK_OPEN },
{ STOCK_LOCK_SECURE },
{ STOCK_LOCK_BROKEN },
{ STOCK_PAGE_HOLDER },
{ STOCK_SCRIPT },
{ STOCK_STYLE },
{ STOCK_TRANSFER },
{ STOCK_USER_TRASH },
gchar* stock_id;
gchar* label;
GdkModifierType modifier;
guint keyval;
gchar* fallback;
} FatStockItem;
{ STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, NULL },
{ STOCK_BOOKMARK_ADD, N_("_Add Bookmark"), 0, 0, NULL },
{ STOCK_FORM_FILL, N_("_Form Fill"), 0, 0, NULL },
{ STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, NULL },
{ STOCK_TAB_NEW, N_("New _Tab"), 0, 0, NULL },
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, NULL },
static FatStockItem items[] =
{
{ STOCK_EXTENSION, NULL, 0, 0, GTK_STOCK_CONVERT },
{ STOCK_NEWS_FEED, NULL, 0, 0, GTK_STOCK_INDEX },
{ STOCK_SCRIPT, NULL, 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_STYLE, NULL, 0, 0, GTK_STOCK_SELECT_COLOR },
{ STOCK_TRANSFER, NULL, 0, 0, GTK_STOCK_SAVE },
{ STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, GTK_STOCK_FILE },
{ STOCK_BOOKMARKS, N_("_Bookmarks"), 0, 0, GTK_STOCK_DIRECTORY },
{ STOCK_BOOKMARK_ADD, N_("_Add Bookmark"), 0, 0, GTK_STOCK_ADD },
{ STOCK_CONSOLE, N_("_Console"), 0, 0, GTK_STOCK_DIALOG_WARNING },
{ STOCK_EXTENSIONS, N_("_Extensions"), 0, 0, GTK_STOCK_CONVERT },
{ STOCK_HISTORY, N_("_History"), 0, 0, GTK_STOCK_SORT_ASCENDING },
{ STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, GTK_STOCK_HOME },
{ STOCK_PAGE_HOLDER, N_("_Pageholder"), 0, 0, GTK_STOCK_ORIENTATION_PORTRAIT },
{ STOCK_SCRIPTS, N_("_Userscripts"), 0, 0, GTK_STOCK_EXECUTE },
{ STOCK_STYLES, N_("User_styles"), 0, 0, GTK_STOCK_SELECT_COLOR },
{ STOCK_TAB_NEW, N_("New _Tab"), 0, 0, GTK_STOCK_ADD },
{ STOCK_TRANSFERS, N_("_Transfers"), 0, 0, GTK_STOCK_SAVE },
{ STOCK_USER_TRASH, N_("_Closed Tabs and Windows"), 0, 0, "gtk-undo-ltr" },
{ STOCK_WINDOW_NEW, N_("New _Window"), 0, 0, GTK_STOCK_ADD },
#if !GTK_CHECK_VERSION(2, 10, 0)
{ GTK_STOCK_SELECT_ALL, N_("Select _All"), 0, 0, NULL },
#endif
@ -61,6 +71,7 @@ stock_items_init (void)
{ GTK_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"), 0, 0, NULL },
#endif
};
GtkIconSource* icon_source;
GtkIconSet* icon_set;
GtkIconFactory* factory = gtk_icon_factory_new ();
@ -68,15 +79,21 @@ stock_items_init (void)
for (i = 0; i < (guint)G_N_ELEMENTS (items); i++)
{
icon_source = gtk_icon_source_new ();
gtk_icon_source_set_icon_name (icon_source, items[i].stock_id);
icon_set = gtk_icon_set_new ();
icon_source = gtk_icon_source_new ();
if (items[i].fallback)
{
gtk_icon_source_set_icon_name (icon_source, items[i].fallback);
items[i].fallback = NULL;
gtk_icon_set_add_source (icon_set, icon_source);
}
gtk_icon_source_set_icon_name (icon_source, items[i].stock_id);
gtk_icon_set_add_source (icon_set, icon_source);
gtk_icon_source_free (icon_source);
gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
gtk_icon_set_unref (icon_set);
}
gtk_stock_add_static (items, G_N_ELEMENTS (items));
gtk_stock_add ((GtkStockItem*)items, G_N_ELEMENTS (items));
gtk_icon_factory_add_default (factory);
g_object_unref (factory);
}

View file

@ -25,31 +25,29 @@ KatzeXbelItem* bookmarks;
/* Custom stock items
We should distribute these
Names should match with epiphany and/ or xdg spec
NOTE: Those uncommented were replaced with remotely related icons
in order to reduce the amount of warnings */
Names should match with epiphany and/ or xdg spec */
#define STOCK_BOOKMARK GTK_STOCK_FILE /* "stock_bookmark" "bookmark-web" */
#define STOCK_BOOKMARK "stock_bookmark"
#define STOCK_BOOKMARKS "vcard"
#define STOCK_CONSOLE "terminal"
#define STOCK_EXTENSION GTK_STOCK_EXECUTE /* "extension" */
#define STOCK_FORM_FILL GTK_STOCK_JUSTIFY_FILL /* "insert-text" "form-fill" */
#define STOCK_EXTENSION "extension"
#define STOCK_EXTENSIONS "extension"
#define STOCK_HISTORY "document-open-recent"
#define STOCK_NEWS_FEED "news-feed"
#define STOCK_PAGE_HOLDER GTK_STOCK_CONVERT
#define STOCK_PAGE_HOLDER "page-holder"
#define STOCK_STYLE "gnome-settings-theme"
#define STOCK_STYLES "gnome-settings-theme"
#define STOCK_TRANSFER "package"
#define STOCK_TRANSFERS "package"
/* We assume that these legacy icon names are usually present */
#define STOCK_BOOKMARK_ADD "stock_add-bookmark"
#define STOCK_HOMEPAGE GTK_STOCK_HOME
#define STOCK_IMAGE "gnome-mime-image"
#define STOCK_LOCK_OPEN "stock_lock-open"
#define STOCK_LOCK_SECURE "stock_lock"
#define STOCK_LOCK_BROKEN "stock_lock-broken"
#define STOCK_NETWORK_OFFLINE "network-offline"
#define STOCK_SCRIPT "stock_script"
#define STOCK_SCRIPTS "stock_script"
#define STOCK_SEND "stock_mail-send"
#define STOCK_TAB_NEW "stock_new-tab"
#define STOCK_USER_TRASH "gnome-stock-trash"

View file

@ -72,8 +72,6 @@ struct _MidoriBrowser
GtkWidget* statusbar;
GtkWidget* progressbar;
const gchar* stock_news_feed;
gchar* statusbar_text;
MidoriWebSettings* settings;
GList* tab_titles;
@ -290,7 +288,7 @@ _midori_browser_update_interface (MidoriBrowser* browser)
/* if (web_view && midori_web_view_get_news_feeds (MIDORI_WEB_VIEW (web_view)))
gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (
gtk_bin_get_child (GTK_BIN (browser->location))),
GTK_ICON_ENTRY_SECONDARY, browser->stock_news_feed);
GTK_ICON_ENTRY_SECONDARY, STOCK_NEWS_FEED);
else
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (
gtk_bin_get_child (GTK_BIN (browser->location))),
@ -487,7 +485,7 @@ midori_web_view_news_feed_ready_cb (MidoriWebView* web_view,
MidoriBrowser* browser)
{
midori_location_action_set_secondary_icon (MIDORI_LOCATION_ACTION (
_action_by_name (browser, "Location")), browser->stock_news_feed);
_action_by_name (browser, "Location")), STOCK_NEWS_FEED);
}
static gboolean
@ -2081,7 +2079,7 @@ _action_location_secondary_icon_released (GtkAction* action,
menuitem = gtk_image_menu_item_new_with_label (title);
/* FIXME: Get the real icon */
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (
menuitem), gtk_image_new_from_stock (browser->stock_news_feed,
menuitem), gtk_image_new_from_stock (STOCK_NEWS_FEED,
GTK_ICON_SIZE_MENU));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_object_set_data (G_OBJECT (menuitem), "uri", (gchar*)uri);
@ -2813,7 +2811,7 @@ static const GtkActionEntry entries[] = {
N_("Open in Page_holder..."), "",
N_("Open the current page in the pageholder"), G_CALLBACK (_action_open_in_panel_activate) },
{ "Trash", STOCK_USER_TRASH,
N_("Closed Tabs and Windows"), "",
NULL, "",
/* N_("Reopen a previously closed tab or window"), G_CALLBACK (_action_trash_activate) }, */
N_("Reopen a previously closed tab or window"), NULL },
{ "TrashEmpty", GTK_STOCK_CLEAR,
@ -3090,10 +3088,6 @@ midori_browser_realize_cb (GtkStyle* style,
gtk_window_set_icon_name (GTK_WINDOW (browser), "midori");
else
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
if (gtk_icon_theme_has_icon (icon_theme, STOCK_NEWS_FEED))
browser->stock_news_feed = STOCK_NEWS_FEED;
else
browser->stock_news_feed = GTK_STOCK_INDEX;
}
}
@ -3170,8 +3164,6 @@ midori_browser_init (MidoriBrowser* browser)
GtkToolItem* toolitem;
GtkRcStyle* rcstyle;
browser->stock_news_feed = GTK_STOCK_INDEX;
/* Setup the window metrics */
g_signal_connect (browser, "realize",
G_CALLBACK (midori_browser_realize_cb), browser);
@ -3233,7 +3225,7 @@ midori_browser_init (MidoriBrowser* browser)
"stock-id", GTK_STOCK_JUMP_TO,
"tooltip", _("Open a particular location"),
/* FIXME: Due to a bug in GtkIconEntry we need to set an initial icon */
"secondary-icon", browser->stock_news_feed,
"secondary-icon", STOCK_NEWS_FEED,
NULL);
g_object_connect (action,
"signal::activate",
@ -3454,14 +3446,14 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show_all (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
box, toolbar,
STOCK_BOOKMARKS, _("Bookmarks"), _("_Bookmarks"));
STOCK_BOOKMARKS, _("Bookmarks"));
/* Transfers */
GtkWidget* panel = midori_web_view_new ();
gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, NULL,
STOCK_TRANSFER, _("Transfers"), _("_Transfers"));
STOCK_TRANSFERS, _("Transfers"));
/* Console */
browser->panel_console = midori_console_new ();
@ -3470,14 +3462,14 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
browser->panel_console, toolbar,
STOCK_CONSOLE, _("Console"), _("_Console"));
STOCK_CONSOLE, _("Console"));
/* History */
panel = midori_web_view_new ();
gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, NULL,
STOCK_HISTORY, _("History"), _("_History"));
STOCK_HISTORY, _("History"));
/* Pageholder */
browser->panel_pageholder = g_object_new (MIDORI_TYPE_WEB_VIEW,
@ -3486,7 +3478,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (browser->panel_pageholder);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
browser->panel_pageholder, NULL,
STOCK_PAGE_HOLDER, _("Pageholder"), _("_Pageholder"));
STOCK_PAGE_HOLDER, _("Pageholder"));
/* Userscripts */
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_SCRIPTS);
@ -3495,7 +3487,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, toolbar,
STOCK_SCRIPT, _("Userscripts"), _("_Userscripts"));
STOCK_SCRIPTS, _("Userscripts"));
/* Userstyles */
/*panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_STYLES);
gtk_widget_show (panel);
@ -3503,7 +3495,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, toolbar,
STOCK_STYLE, _("Userstyles"), _("_Userstyles"));*/
STOCK_STYLES, _("Userstyles"));*/
/* Extensions */
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_EXTENSIONS);
@ -3512,7 +3504,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, toolbar,
STOCK_EXTENSION, _("Extensions"), _("_Extensions"));
STOCK_EXTENSIONS, _("Extensions"));
/* Notebook, containing all web_views */
browser->notebook = gtk_notebook_new ();

View file

@ -337,21 +337,12 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
* @panel: a #MidoriPanel
* @child: the child widget
* @toolbar: a toolbar widget, or %NULL
* @icon: a stock ID or icon name, or %NULL
* @label: a string to use as the label, or %NULL
* @mnemonic: a string to use as a mnemonic, or %NULL
* @stock_id: a stock ID
* @label: a string to use as the label
*
* Appends a new page to the panel. If @toolbar is specified it will
* be packaged above @child.
*
* If @icon is an icon name, the according image is used as an
* icon for this page.
*
* If @label is given, it is used as the label of this page.
*
* If @mnemonic is given, it is used in labels with mnemonics
* such as menu items. See gtk_label_new_with_mnemonic().
*
* In the case of an error, -1 is returned.
*
* Return value: the index of the new page, or -1
@ -360,16 +351,13 @@ gint
midori_panel_append_page (MidoriPanel* panel,
GtkWidget* child,
GtkWidget* toolbar,
const gchar* icon,
const gchar* label,
const gchar* mnemonic)
const gchar* stock_id,
const gchar* label)
{
GtkWidget* scrolled;
GtkWidget* widget;
GObjectClass* gobject_class;
guint n;
const gchar* text;
const gchar* text_mnemonic;
GtkToolItem* toolitem;
GtkWidget* image;
GtkWidget* menuitem;
@ -377,6 +365,8 @@ midori_panel_append_page (MidoriPanel* panel,
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
g_return_val_if_fail (GTK_IS_WIDGET (child), -1);
g_return_val_if_fail (!toolbar || GTK_IS_WIDGET (toolbar), -1);
g_return_val_if_fail (stock_id != NULL, -1);
g_return_val_if_fail (label != NULL, -1);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
@ -403,19 +393,14 @@ midori_panel_append_page (MidoriPanel* panel,
n = midori_panel_page_num (panel, child);
text = label ? label : _("Untitled");
text_mnemonic = mnemonic ? mnemonic : _("_Untitled");
g_object_set_data (G_OBJECT (child), "label", (gchar*)text);
g_object_set_data (G_OBJECT (child), "label", (gchar*)label);
toolitem = gtk_radio_tool_button_new (panel->group);
panel->group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (
toolitem));
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), text);
if (icon)
{
image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_BUTTON);
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
}
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolitem), image);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), label);
g_object_set_data (G_OBJECT (toolitem), "page", child);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_menu_item_activate_cb), panel);
@ -424,14 +409,8 @@ midori_panel_append_page (MidoriPanel* panel,
if (panel->menu)
{
menuitem = gtk_image_menu_item_new_with_mnemonic (text_mnemonic);
if (icon)
{
image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
image);
}
gtk_widget_show_all (menuitem);
menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
gtk_widget_show (menuitem);
g_object_set_data (G_OBJECT (menuitem), "page", child);
g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
g_signal_connect (menuitem, "activate",

View file

@ -57,9 +57,8 @@ gint
midori_panel_append_page (MidoriPanel* panel,
GtkWidget* child,
GtkWidget* toolbar,
const gchar* icon,
const gchar* label,
const gchar* mnemonic);
const gchar* stock_id,
const gchar* label);
gint
midori_panel_get_current_page (MidoriPanel* panel);