changeset 25117:0bbfb20bad19

Clean up status icon themes a bit
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Fri, 08 Aug 2008 20:47:15 +0000
parents 2753d96ed2bb
children f76e9db37141
files pidgin/Makefile.am pidgin/gtkblist.c pidgin/gtkicon-loader.c pidgin/gtkicon-theme.c pidgin/gtkprefs.c pidgin/gtkstatus-icon-theme.c pidgin/gtkstatus-icon-theme.h pidgin/pidginstock.c pidgin/pidginstock.h
diffstat 9 files changed, 177 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/Makefile.am	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/Makefile.am	Fri Aug 08 20:47:15 2008 +0000
@@ -120,6 +120,7 @@
 	gtksourceiter.c \
 	gtksourceundomanager.c \
 	gtksourceview-marshal.c \
+	gtkstatus-icon-theme.c \
 	gtkstatusbox.c \
 	gtkthemes.c \
 	gtkutils.c \
@@ -177,6 +178,7 @@
 	gtksourceiter.h \
 	gtksourceundomanager.h \
 	gtksourceview-marshal.h \
+	gtkstatus-icon-theme.h \
 	gtkstatusbox.h \
 	pidginstock.h \
 	gtkthemes.h \
--- a/pidgin/gtkblist.c	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/gtkblist.c	Fri Aug 08 20:47:15 2008 +0000
@@ -5386,7 +5386,7 @@
 
 	priv->current_theme = PIDGIN_BLIST_THEME(purple_theme_manager_find_theme(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/blist/theme"), "blist"));
 
-	pidgin_stock_load_status_icon_theme(PIDGIN_ICON_THEME(purple_theme_manager_find_theme(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/icon/status/theme"), "status_icon")));
+	pidgin_stock_load_status_icon_theme(PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/icon/status/theme"), "status-icon")));
 
 	gtkblist->empty_avatar = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 32, 32);
 	gdk_pixbuf_fill(gtkblist->empty_avatar, 0x00000000);
--- a/pidgin/gtkicon-loader.c	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/gtkicon-loader.c	Fri Aug 08 20:47:15 2008 +0000
@@ -22,7 +22,7 @@
  */
 
 #include "gtkicon-loader.h"
-#include "gtkicon-theme.h"
+#include "gtkstatus-icon-theme.h"
 
 #include "xmlnode.h"
 
@@ -54,7 +54,7 @@
 	/* Build the xml tree */
 	filename_full = g_build_filename(dir, filename, NULL);
 
-	root_node = xmlnode_from_file(dir, filename, "icon themes", "icon-loader");
+	root_node = xmlnode_from_file(dir, filename, "status icon themes", "icon-loader");
 	g_return_val_if_fail(root_node != NULL, NULL);
 
 	/* Parse the tree */	
@@ -62,8 +62,8 @@
 	data = xmlnode_get_data(sub_node);
 
 	if (xmlnode_get_attrib(root_node, "name") != NULL) {
-		theme = g_object_new(PIDGIN_TYPE_ICON_THEME,
-				    "type", "icon",
+		theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME,
+				    "type", "status-icon",
 				    "name", xmlnode_get_attrib(root_node, "name"),
 				    "author", xmlnode_get_attrib(root_node, "author"),
 				    "image", xmlnode_get_attrib(root_node, "image"),
--- a/pidgin/gtkicon-theme.c	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/gtkicon-theme.c	Fri Aug 08 20:47:15 2008 +0000
@@ -44,42 +44,9 @@
 
 static GObjectClass *parent_class = NULL;
 
-static const GtkStockItem stock_icons[] =
-{
-    { PIDGIN_STOCK_TRAY_AVAILABLE,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_INVISIBLE,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_AWAY,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_BUSY,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_XA,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_OFFLINE,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_CONNECT,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_PENDING,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_TRAY_EMAIL,		"",     0, 0, NULL },
-
-    { PIDGIN_STOCK_STATUS_AVAILABLE,    "",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_AVAILABLE_I,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_AWAY,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_AWAY_I,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_BUSY,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_BUSY_I,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_CHAT,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_INVISIBLE,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_XA,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_XA_I,		"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_LOGIN,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_LOGOUT,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_OFFLINE,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_OFFLINE_I,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_PERSON,	"",     0, 0, NULL },
-    { PIDGIN_STOCK_STATUS_MESSAGE,	"",     0, 0, NULL }
-};
-
-
-
 /******************************************************************************
  * Enums
  *****************************************************************************/
-
 /******************************************************************************
  * GObject Stuff                                                              
  *****************************************************************************/
@@ -141,7 +108,7 @@
     };
     type = g_type_register_static (PURPLE_TYPE_THEME,
                                    "PidginIconTheme",
-                                   &info, 0 /*G_TYPE_FLAG_ABSTRACT*/);
+                                   &info, G_TYPE_FLAG_ABSTRACT);
   }
   return type;
 }
--- a/pidgin/gtkprefs.c	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/gtkprefs.c	Fri Aug 08 20:47:15 2008 +0000
@@ -44,12 +44,12 @@
 #include "gtkconv.h"
 #include "gtkdebug.h"
 #include "gtkdialogs.h"
-#include "gtkicon-theme.h"
 #include "gtkimhtml.h"
 #include "gtkimhtmltoolbar.h"
 #include "gtkprefs.h"
 #include "gtksavedstatuses.h"
 #include "gtksound.h"
+#include "gtkstatus-icon-theme.h"
 #include "gtkthemes.h"
 #include "gtkutils.h"
 #include "pidginstock.h"
@@ -614,13 +614,13 @@
 			g_free(image_full);
 		} else pixbuf = NULL; 
 
-		gtk_list_store_append (prefs_sound_themes, &iter);
-		gtk_list_store_set (prefs_sound_themes, &iter, 0, pixbuf, 2, purple_theme_get_name(theme), -1);
+		gtk_list_store_append(prefs_sound_themes, &iter);
+		gtk_list_store_set(prefs_sound_themes, &iter, 0, pixbuf, 2, purple_theme_get_name(theme), -1);
 
 		if (pixbuf != NULL)
 			gdk_pixbuf_unref(pixbuf);
 
-	} else if (PIDGIN_IS_BLIST_THEME(theme) || PIDGIN_IS_ICON_THEME(theme)){
+	} else if (PIDGIN_IS_BLIST_THEME(theme) || PIDGIN_IS_STATUS_ICON_THEME(theme)){
 		GtkListStore *store;
 
 		if (PIDGIN_IS_BLIST_THEME(theme)) 
@@ -640,8 +640,8 @@
 		markup = g_strdup_printf("<b>%s</b>%s%s\n<span foreground='dim grey'>%s</span>", name, author != NULL ? " - " : "",
 					 author != NULL ? author : "", description != NULL ? description : "");
 
-		gtk_list_store_append (store, &iter);
-		gtk_list_store_set (store, &iter, 0, pixbuf, 1, markup, 2, name, -1);
+		gtk_list_store_append(store, &iter);
+		gtk_list_store_set(store, &iter, 0, pixbuf, 1, markup, 2, name, -1);
 
 		g_free(markup);
 		if (pixbuf != NULL)
@@ -1152,14 +1152,14 @@
 static void
 prefs_set_status_icon_theme_cb(GtkComboBox *combo_box, gpointer user_data)
 {
-	PidginIconTheme *theme;
+	PidginStatusIconTheme *theme;
 	GtkTreeIter iter;
 	gchar *name = NULL;
 	
 	g_return_if_fail(gtk_combo_box_get_active_iter(combo_box, &iter));
 	gtk_tree_model_get(GTK_TREE_MODEL(prefs_status_icon_themes), &iter, 2, &name, -1);
 
-	theme = PIDGIN_ICON_THEME(purple_theme_manager_find_theme(name, "icon"));
+	theme = PIDGIN_STATUS_ICON_THEME(purple_theme_manager_find_theme(name, "status-icon"));
 	g_free(name);
 
 	pidgin_stock_load_status_icon_theme(theme);
@@ -1189,7 +1189,7 @@
 	g_signal_connect(G_OBJECT(combo_box), "changed", (GCallback)prefs_set_blist_theme_cb, NULL);
 
 	/* Status Icon Themes */
-	combo_box = prefs_build_theme_combo_box(prefs_status_icon_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/icon/theme"));
+	combo_box = prefs_build_theme_combo_box(prefs_status_icon_themes, purple_prefs_get_string(PIDGIN_PREFS_ROOT "/icon/status/theme"));
 	gtk_box_pack_start(GTK_BOX (vbox), combo_box, FALSE, FALSE, 0);
 	g_signal_connect(G_OBJECT(combo_box), "changed", (GCallback)prefs_set_status_icon_theme_cb, NULL);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/gtkstatus-icon-theme.c	Fri Aug 08 20:47:15 2008 +0000
@@ -0,0 +1,78 @@
+/*
+ * Status Icon Themes for Pidgin
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ *
+ */
+
+#include "gtkstatus-icon-theme.h"
+
+/******************************************************************************
+ * Structs
+ *****************************************************************************/
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static GObjectClass *parent_class = NULL;
+/******************************************************************************
+ * Enums
+ *****************************************************************************/
+/******************************************************************************
+ * GObject Stuff                                                              
+ *****************************************************************************/
+
+static void 
+pidgin_status_icon_theme_finalize (GObject *obj)
+{
+	parent_class->finalize (obj);
+}
+
+static void
+pidgin_status_icon_theme_class_init (PidginStatusIconThemeClass *klass)
+{
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
+	parent_class = g_type_class_peek_parent(klass);
+
+        obj_class->finalize = pidgin_status_icon_theme_finalize;
+}
+
+GType 
+pidgin_status_icon_theme_get_type (void)
+{
+  static GType type = 0;
+  if (type == 0) {
+    static const GTypeInfo info = {
+      sizeof (PidginStatusIconThemeClass),
+      NULL,   /* base_init */
+      NULL,   /* base_finalize */
+      (GClassInitFunc)pidgin_status_icon_theme_class_init,   /* class_init */
+      NULL,   /* class_finalize */
+      NULL,   /* class_data */
+      sizeof (PidginStatusIconTheme),
+      0,      /* n_preallocs */
+      NULL,
+      NULL,   /* value table */
+    };
+    type = g_type_register_static (PIDGIN_TYPE_ICON_THEME,
+                                   "PidginStatusIconTheme",
+                                   &info, 0);
+  }
+  return type;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/gtkstatus-icon-theme.h	Fri Aug 08 20:47:15 2008 +0000
@@ -0,0 +1,71 @@
+/**
+ * @file status_icon-theme.h  Pidgin Icon Theme  Class API
+ */
+
+/* pidgin
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#ifndef _PIDGIN_STATUS_ICON_THEME_H_
+#define _PIDGIN_STATUS_ICON_THEME_H_
+
+#include <glib-object.h>
+#include "gtkicon-theme.h"
+
+/**
+ * extends PidginIconTheme (gtkicon-theme.h)
+ * A pidgin status icon theme.
+ * This object represents a Pidgin status icon theme.
+ *
+ * PidginStatusIconTheme is a PidginIconTheme Object.
+ */
+typedef struct _PidginStatusIconTheme        PidginStatusIconTheme;
+typedef struct _PidginStatusIconThemeClass   PidginStatusIconThemeClass;
+
+#define PIDGIN_TYPE_STATUS_ICON_THEME		  	(pidgin_status_icon_theme_get_type ())
+#define PIDGIN_STATUS_ICON_THEME(obj)		  	(G_TYPE_CHECK_INSTANCE_CAST ((obj), PIDGIN_TYPE_STATUS_ICON_THEME, PidginStatusIconTheme))
+#define PIDGIN_STATUS_ICON_THEME_CLASS(klass)	  	(G_TYPE_CHECK_CLASS_CAST ((klass), PIDGIN_TYPE_STATUS_ICON_THEME, PidginStatusIconThemeClass))
+#define PIDGIN_IS_STATUS_ICON_THEME(obj)	  	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIDGIN_TYPE_STATUS_ICON_THEME))
+#define PIDGIN_IS_STATUS_ICON_THEME_CLASS(klass) 	(G_TYPE_CHECK_CLASS_TYPE ((klass), PIDGIN_TYPE_STATUS_ICON_THEME))
+#define PIDGIN_STATUS_ICON_THEME_GET_CLASS(obj)  	(G_TYPE_INSTANCE_GET_CLASS ((obj), PIDGIN_TYPE_STATUS_ICON_THEME, PidginStatusIconThemeClass))
+
+struct _PidginStatusIconTheme
+{
+	PidginIconTheme parent;
+};
+
+struct _PidginStatusIconThemeClass
+{
+	PidginIconThemeClass parent_class;
+};
+
+/**************************************************************************/
+/** @name Pidgin Status Icon Theme API                                          */
+/**************************************************************************/
+G_BEGIN_DECLS
+
+/**
+ * GObject foo.
+ * @internal.
+ */
+GType pidgin_status_icon_theme_get_type(void);
+
+G_END_DECLS
+#endif /* _PIDGIN_STATUS_ICON_THEME_H_ */
--- a/pidgin/pidginstock.c	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/pidginstock.c	Fri Aug 08 20:47:15 2008 +0000
@@ -263,7 +263,7 @@
 }
 
 static gchar *
-find_icon_file(PidginIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl)
+find_icon_file(PidginStatusIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl)
 {
 	const gchar *file, *dir;
 	gchar *file_full = NULL;
@@ -288,7 +288,7 @@
 }
 
 static void
-add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginIconTheme *theme,
+add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginStatusIconTheme *theme,
 		const char *size, SizedStockIcon sized_icon, gboolean translucent)
 {
 	char *filename;
@@ -348,7 +348,7 @@
  *****************************************************************************/
 
 void
-pidgin_stock_load_status_icon_theme(PidginIconTheme *theme)
+pidgin_stock_load_status_icon_theme(PidginStatusIconTheme *theme)
 {
 	GtkIconFactory *icon_factory;
 	gint i;
@@ -356,7 +356,11 @@
 	GtkIconSet *translucent = NULL;
 	GtkWidget *win;
 
-	g_return_if_fail(stock_initted);
+	if (theme != NULL)
+		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/icon/status/theme", 
+				purple_theme_get_name(PURPLE_THEME(theme)));
+	else purple_prefs_set_string(PIDGIN_PREFS_ROOT "/icon/status/theme", "");
+
 	
 	icon_factory = gtk_icon_factory_new();
 
@@ -411,7 +415,7 @@
 	stock_initted = TRUE;
 
 	/* Setup the theme */
-	purple_theme_manager_register_type(g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "icon", NULL));
+	purple_theme_manager_register_type(g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "status-icon", NULL));
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/icon/status");
 	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/icon/status/theme", "");
 
--- a/pidgin/pidginstock.h	Fri Aug 08 16:45:21 2008 +0000
+++ b/pidgin/pidginstock.h	Fri Aug 08 20:47:15 2008 +0000
@@ -24,7 +24,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 #include <gtk/gtkstock.h>
-#include "gtkicon-theme.h"
+#include "gtkstatus-icon-theme.h"
 
 #ifndef _PIDGIN_STOCK_H_
 #define _PIDGIN_STOCK_H_
@@ -161,7 +161,7 @@
  * 
  * @param theme		the theme to load, or null to load all the default icons
  */
-void pidgin_stock_load_status_icon_theme(PidginIconTheme *theme);
+void pidgin_stock_load_status_icon_theme(PidginStatusIconTheme *theme);
 
 /**
  * Sets up the purple stock repository.