changeset 26725:0011cd06990a

Use stock-id in the status editor window too.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 23 Apr 2009 05:08:06 +0000
parents 0e85e5698db4
children 18543445e929
files ChangeLog.API pidgin/gtkconv.c pidgin/gtksavedstatuses.c pidgin/gtkstatusbox.c pidgin/gtkutils.c pidgin/gtkutils.h
diffstat 6 files changed, 64 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Thu Apr 23 03:55:35 2009 +0000
+++ b/ChangeLog.API	Thu Apr 23 05:08:06 2009 +0000
@@ -77,6 +77,10 @@
 		* pidgin_sound_is_customized
 		* pidgin_utils_init, pidgin_utils_uninit
 		* pidgin_notify_pounce_add
+		* PidginBlistTheme, PidginBlistThemeLoader API
+		* PidginIconTheme, PidginStatusIconTheme, PidginIconThemeLoader
+		  API
+		* pidgin_stock_id_from_status_primitive
 
 	libgnt:
 		Added:
--- a/pidgin/gtkconv.c	Thu Apr 23 03:55:35 2009 +0000
+++ b/pidgin/gtkconv.c	Thu Apr 23 05:08:06 2009 +0000
@@ -2534,27 +2534,7 @@
 			PurpleStatus *active = purple_presence_get_active_status(p);
 			PurpleStatusType *type = purple_status_get_type(active);
 			PurpleStatusPrimitive prim = purple_status_type_get_primitive(type);
-
-			switch (prim) {
-				case PURPLE_STATUS_UNAVAILABLE:
-					stock = PIDGIN_STOCK_STATUS_BUSY;
-					break;
-				case PURPLE_STATUS_AWAY:
-					stock = PIDGIN_STOCK_STATUS_AWAY;
-					break;
-				case PURPLE_STATUS_EXTENDED_AWAY:
-					stock = PIDGIN_STOCK_STATUS_XA;
-					break;
-				case PURPLE_STATUS_INVISIBLE:
-					stock = PIDGIN_STOCK_STATUS_INVISIBLE;
-					break;
-				case PURPLE_STATUS_OFFLINE:
-					stock = PIDGIN_STOCK_STATUS_OFFLINE;
-					break;
-				default:
-					stock = PIDGIN_STOCK_STATUS_AVAILABLE;
-					break;
-			}
+			stock = pidgin_stock_id_from_status_primitive(prim);
 		} else {
 			stock = PIDGIN_STOCK_STATUS_PERSON;
 		}
--- a/pidgin/gtksavedstatuses.c	Thu Apr 23 03:55:35 2009 +0000
+++ b/pidgin/gtksavedstatuses.c	Thu Apr 23 05:08:06 2009 +0000
@@ -1503,16 +1503,19 @@
 	gtk_size_group_add_widget(sg, label);
 
 	dialog->model = gtk_list_store_new(SUBSTATUS_NUM_COLUMNS,
-									   GDK_TYPE_PIXBUF,
+									   G_TYPE_STRING,
 									   G_TYPE_STRING,
 									   G_TYPE_STRING);
 	combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(dialog->model));
 	dialog->box = GTK_COMBO_BOX(combo);
 
 	rend = GTK_CELL_RENDERER(gtk_cell_renderer_pixbuf_new());
+	g_object_set(G_OBJECT(rend),
+			"stock-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL),
+			NULL);
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, FALSE);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), rend,
-						"pixbuf", SUBSTATUS_COLUMN_ICON, NULL);
+						"stock-id", SUBSTATUS_COLUMN_ICON, NULL);
 
 	rend = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, TRUE);
@@ -1574,8 +1577,8 @@
 	for (list = purple_account_get_status_types(account); list; list = list->next)
 	{
 		PurpleStatusType *status_type;
-		GdkPixbuf *pixbuf;
 		const char *id, *name;
+		PurpleStatusPrimitive prim;
 
 		status_type = list->data;
 
@@ -1588,17 +1591,15 @@
 			continue;
 
 		id = purple_status_type_get_id(status_type);
-		pixbuf = pidgin_create_status_icon(purple_status_type_get_primitive(status_type), combo, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
+		prim = purple_status_type_get_primitive(status_type);
 		name = purple_status_type_get_name(status_type);
 
 		gtk_list_store_append(dialog->model, &iter);
 		gtk_list_store_set(dialog->model, &iter,
-						   SUBSTATUS_COLUMN_ICON, pixbuf,
+						   SUBSTATUS_COLUMN_ICON, pidgin_stock_id_from_status_primitive(prim),
 						   SUBSTATUS_COLUMN_STATUS_ID, id,
 						   SUBSTATUS_COLUMN_STATUS_NAME, name,
 						   -1);
-		if (pixbuf != NULL)
-			g_object_unref(pixbuf);
 		if ((status_id != NULL) && !strcmp(status_id, id))
 		{
 			gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
@@ -1705,18 +1706,15 @@
 {
 	GtkTreeIter iter;
 	gboolean currently_selected = FALSE;
-	GdkPixbuf *pixbuf = pidgin_create_status_icon(primitive, w, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
 
 	gtk_list_store_append(model, &iter);
 	gtk_list_store_set(model, &iter,
 			   SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_PRIMITIVE,
-			   SS_MENU_ICON_COLUMN, pixbuf,
+			   SS_MENU_ICON_COLUMN, pidgin_stock_id_from_status_primitive(primitive),
 			   SS_MENU_TEXT_COLUMN, purple_primitive_get_name_from_type(primitive),
 			   SS_MENU_DATA_COLUMN, GINT_TO_POINTER(primitive),
 			   SS_MENU_EMBLEM_VISIBLE_COLUMN, FALSE,
 			   -1);
-	if (pixbuf != NULL)
-		g_object_unref(pixbuf);
 
 	if (purple_savedstatus_is_transient(current_status)
 			&& !purple_savedstatus_has_substatuses(current_status)
@@ -1730,23 +1728,20 @@
 pidgin_status_menu_update_iter(GtkWidget *combobox, GtkListStore *store, GtkTreeIter *iter,
 		PurpleSavedStatus *status)
 {
-	GdkPixbuf *pixbuf;
+	PurpleStatusPrimitive primitive;
 
 	if (store == NULL)
 		store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combobox)));
 
-	pixbuf = pidgin_create_status_icon(purple_savedstatus_get_type(status),
-			combobox, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
+	primitive = purple_savedstatus_get_type(status);
 	gtk_list_store_set(store, iter,
 			SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_SAVEDSTATUS,
-			SS_MENU_ICON_COLUMN, pixbuf,
+			SS_MENU_ICON_COLUMN, pidgin_stock_id_from_status_primitive(primitive),
 			SS_MENU_TEXT_COLUMN, purple_savedstatus_get_title(status),
 			SS_MENU_DATA_COLUMN, GINT_TO_POINTER(purple_savedstatus_get_creation_time(status)),
 			SS_MENU_EMBLEM_COLUMN, GTK_STOCK_SAVE,
 			SS_MENU_EMBLEM_VISIBLE_COLUMN, TRUE,
 			-1);
-	if (pixbuf)
-		g_object_unref(G_OBJECT(pixbuf));
 }
 
 static gboolean
@@ -1828,7 +1823,7 @@
 	GtkCellRenderer *icon_rend;
 	GtkCellRenderer *emblem_rend;
 
-	model = gtk_list_store_new(SS_MENU_NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF,
+	model = gtk_list_store_new(SS_MENU_NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING,
 				   G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
 	combobox = gtk_combo_box_new();
@@ -1875,10 +1870,13 @@
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), icon_rend, FALSE);
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), text_rend, TRUE);
 	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), emblem_rend, FALSE);
-	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), icon_rend, "pixbuf", SS_MENU_ICON_COLUMN, NULL);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), icon_rend, "stock-id", SS_MENU_ICON_COLUMN, NULL);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), text_rend, "markup", SS_MENU_TEXT_COLUMN, NULL);
 	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), emblem_rend,
 					"stock-id", SS_MENU_EMBLEM_COLUMN, "visible", SS_MENU_EMBLEM_VISIBLE_COLUMN, NULL);
+	g_object_set(G_OBJECT(icon_rend),
+			"stock-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL),
+			NULL);
 
 	gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index);
 	g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback);
--- a/pidgin/gtkstatusbox.c	Thu Apr 23 03:55:35 2009 +0000
+++ b/pidgin/gtkstatusbox.c	Thu Apr 23 05:08:06 2009 +0000
@@ -706,26 +706,7 @@
 			prim = purple_savedstatus_get_type(saved_status);
 	    }
 
-		switch (prim) {
-			case PURPLE_STATUS_UNAVAILABLE:
-				stock = PIDGIN_STOCK_STATUS_BUSY;
-				break;
-			case PURPLE_STATUS_AWAY:
-				stock = PIDGIN_STOCK_STATUS_AWAY;
-				break;
-			case PURPLE_STATUS_EXTENDED_AWAY:
-				stock = PIDGIN_STOCK_STATUS_XA;
-				break;
-			case PURPLE_STATUS_INVISIBLE:
-				stock = PIDGIN_STOCK_STATUS_INVISIBLE;
-				break;
-			case PURPLE_STATUS_OFFLINE:
-				stock = PIDGIN_STOCK_STATUS_OFFLINE;
-				break;
-			default:
-				stock = PIDGIN_STOCK_STATUS_AVAILABLE;
-				break;
-		}
+		stock = pidgin_stock_id_from_status_primitive(prim);
 	}
 
 	if (status_box->account != NULL) {
--- a/pidgin/gtkutils.c	Thu Apr 23 03:55:35 2009 +0000
+++ b/pidgin/gtkutils.c	Thu Apr 23 05:08:06 2009 +0000
@@ -1464,7 +1464,7 @@
 					  str);
 			g_free(str);
 
-			return;
+			break;
 		}
 
 		buddy = purple_find_buddy(data->account, data->who);
@@ -1494,7 +1494,7 @@
 			g_error_free(err);
 			g_free(str);
 
-			return;
+			break;
 		}
 		id = purple_imgstore_add_with_id(filedata, size, data->filename);
 
@@ -1738,6 +1738,35 @@
 
 }
 
+const char *
+pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim)
+{
+	const char *stock = NULL;
+	switch (prim) {
+		case PURPLE_STATUS_UNSET:
+			stock = NULL;
+			break;
+		case PURPLE_STATUS_UNAVAILABLE:
+			stock = PIDGIN_STOCK_STATUS_BUSY;
+			break;
+		case PURPLE_STATUS_AWAY:
+			stock = PIDGIN_STOCK_STATUS_AWAY;
+			break;
+		case PURPLE_STATUS_EXTENDED_AWAY:
+			stock = PIDGIN_STOCK_STATUS_XA;
+			break;
+		case PURPLE_STATUS_INVISIBLE:
+			stock = PIDGIN_STOCK_STATUS_INVISIBLE;
+			break;
+		case PURPLE_STATUS_OFFLINE:
+			stock = PIDGIN_STOCK_STATUS_OFFLINE;
+			break;
+		default:
+			stock = PIDGIN_STOCK_STATUS_AVAILABLE;
+			break;
+	}
+	return stock;
+}
 
 GdkPixbuf *
 pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size)
--- a/pidgin/gtkutils.h	Thu Apr 23 03:55:35 2009 +0000
+++ b/pidgin/gtkutils.h	Thu Apr 23 05:08:06 2009 +0000
@@ -569,6 +569,16 @@
  */
 GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size);
 
+/**
+ * Returns an appropriate stock-id for a status primitive.
+ *
+ * @param prim   The status primitive
+ *
+ * @return The stock-id
+ *
+ * @since 2.6.0
+ */
+const char *pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim);
 
 /**
  * Append a PurpleMenuAction to a menu.