SF.net SVN: geany-plugins:[333] trunk/geanysendmail/src/geanysendmail.c
frlan at users.sourceforge.net
frlan at xxxxx
Sun Dec 7 20:50:43 UTC 2008
Revision: 333
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=333&view=rev
Author: frlan
Date: 2008-12-07 20:50:42 +0000 (Sun, 07 Dec 2008)
Log Message:
-----------
GeanySendMail: Applied a patch by Enrico to improve handling of icons and solves a compiling error.
Modified Paths:
--------------
trunk/geanysendmail/src/geanysendmail.c
Modified: trunk/geanysendmail/src/geanysendmail.c
===================================================================
--- trunk/geanysendmail/src/geanysendmail.c 2008-12-06 17:25:41 UTC (rev 332)
+++ trunk/geanysendmail/src/geanysendmail.c 2008-12-07 20:50:42 UTC (rev 333)
@@ -197,31 +197,41 @@
send_as_attachment(NULL, NULL);
}
-#if GTK_CHECK_VERSION(2, 12, 0)
-#define ICON_LOOKUP_MODE GTK_ICON_LOOKUP_GENERIC_FALLBACK
-#else
-#define ICON_LOOKUP_MODE GTK_ICON_LOOKUP_USE_BUILTIN
-#endif
+#define GEANYSENDMAIL_STOCK_MAIL "geanysendmail-mail"
-void show_icon()
+static void add_stock_item(void)
{
- GdkPixbuf *mailbutton_pb = NULL;
- GtkWidget *icon = NULL;
- GtkIconSize size = geany_data->toolbar_prefs->icon_size;
+ GtkIconSet *icon_set;
+ GtkIconFactory *factory = gtk_icon_factory_new();
+ GtkIconTheme *theme = gtk_icon_theme_get_default();
+ GtkStockItem item = { GEANYSENDMAIL_STOCK_MAIL, _("Mail"), 0, 0, GETTEXT_PACKAGE };
- mailbutton_pb = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
- "mail-message-new", size, ICON_LOOKUP_MODE, NULL);
-
- /* Fallback if icon is not part of theme */
- if (mailbutton_pb == NULL)
+ if (gtk_icon_theme_has_icon(theme, "mail-message-new"))
{
- mailbutton_pb = gdk_pixbuf_new_from_inline(-1, mail_pixbuf, FALSE, NULL);
+ GtkIconSource *icon_source = gtk_icon_source_new();
+ icon_set = gtk_icon_set_new();
+ gtk_icon_source_set_icon_name(icon_source, "mail-message-new");
+ gtk_icon_set_add_source(icon_set, icon_source);
+ gtk_icon_source_free(icon_source);
}
+ else
+ {
+ GdkPixbuf *pb = gdk_pixbuf_new_from_inline(-1, mail_pixbuf, FALSE, NULL);
+ icon_set = gtk_icon_set_new_from_pixbuf(pb);
+ g_object_unref(pb);
+ }
+ gtk_icon_factory_add(factory, item.stock_id, icon_set);
+ gtk_stock_add(&item, 1);
+ gtk_icon_factory_add_default(factory);
- icon = gtk_image_new_from_pixbuf(mailbutton_pb);
- g_object_unref(mailbutton_pb);
+ g_object_unref(factory);
+ gtk_icon_set_unref(icon_set);
+}
- mailbutton = (GtkWidget*) gtk_tool_button_new (icon, _("Mail"));
+
+void show_icon()
+{
+ mailbutton = GTK_WIDGET(gtk_tool_button_new_from_stock(GEANYSENDMAIL_STOCK_MAIL));
plugin_add_toolbar_item(geany_plugin, GTK_TOOL_ITEM(mailbutton));
ui_add_document_sensitive(mailbutton);
g_signal_connect (G_OBJECT(mailbutton), "clicked", G_CALLBACK(send_as_attachment), NULL);
@@ -384,6 +394,7 @@
tooltips = gtk_tooltips_new();
+ add_stock_item();
if (icon_in_toolbar == TRUE)
{
show_icon();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Plugins-Commits
mailing list