sadrul.gtkblist-theme: daaa0f9c: Use stock-id in the status editor window...

sadrul at pidgin.im sadrul at pidgin.im
Thu Apr 23 01:11:05 EDT 2009


-----------------------------------------------------------------
Revision: daaa0f9cfbd6151bc6580adc608ad1a0d8223f16
Ancestor: e8add39c45fc2af07e37471d3a537eb2295a7543
Author: sadrul at pidgin.im
Date: 2009-04-23T05:08:06
Branch: im.pidgin.sadrul.gtkblist-theme
URL: http://d.pidgin.im/viewmtn/revision/info/daaa0f9cfbd6151bc6580adc608ad1a0d8223f16

Modified files:
        ChangeLog.API pidgin/gtkconv.c pidgin/gtksavedstatuses.c
        pidgin/gtkstatusbox.c pidgin/gtkutils.c pidgin/gtkutils.h

ChangeLog: 

Use stock-id in the status editor window too.

-------------- next part --------------
============================================================
--- ChangeLog.API	b01b7899304b552c681289ba7e7756d9f9d3f7c5
+++ ChangeLog.API	a555b10c153bfb9cf9bfebe3117274c33fb5ee7a
@@ -77,6 +77,10 @@ version 2.6.0 (??/??/2009):
 		* 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:
============================================================
--- pidgin/gtkconv.c	e74d72224a9f10b4fde6c341315070400ed21c4b
+++ pidgin/gtkconv.c	f25745c786be10b1ed0b45a725aa9fe096df5e3c
@@ -2534,27 +2534,7 @@ pidgin_conv_get_icon_stock(PurpleConvers
 			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;
 		}
============================================================
--- pidgin/gtksavedstatuses.c	377e0b29361893d9bfd3ad87f5d450c9b8e38020
+++ pidgin/gtksavedstatuses.c	9f925d89cc34991badad93f2bd8376d9f2738c57
@@ -1503,16 +1503,19 @@ edit_substatus(StatusEditor *status_edit
 	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 @@ edit_substatus(StatusEditor *status_edit
 	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 @@ edit_substatus(StatusEditor *status_edit
 			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 @@ static gboolean pidgin_status_menu_add_p
 {
 	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
 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 @@ GtkWidget *pidgin_status_menu(PurpleSave
 	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 @@ GtkWidget *pidgin_status_menu(PurpleSave
 	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);
============================================================
--- pidgin/gtkstatusbox.c	e5ca2e38c4b9197a3dd884a337647e671f13f693
+++ pidgin/gtkstatusbox.c	5137130d12461fca19cabc578d7546b7d777c88f
@@ -706,26 +706,7 @@ pidgin_status_box_refresh(PidginStatusBo
 			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) {
============================================================
--- pidgin/gtkutils.c	482fdd85462e0c0e92999c1b5ed0fa47a18d3c05
+++ pidgin/gtkutils.c	ec9736a1977e922a0478a5485e5b1016f6f201e4
@@ -1464,7 +1464,7 @@ static void dnd_image_ok_callback(_DndDa
 					  str);
 			g_free(str);
 
-			return;
+			break;
 		}
 
 		buddy = purple_find_buddy(data->account, data->who);
@@ -1494,7 +1494,7 @@ static void dnd_image_ok_callback(_DndDa
 			g_error_free(err);
 			g_free(str);
 
-			return;
+			break;
 		}
 		id = purple_imgstore_add_with_id(filedata, size, data->filename);
 
@@ -1738,6 +1738,35 @@ GdkPixbuf * pidgin_create_status_icon(Pu
 
 }
 
+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)
============================================================
--- pidgin/gtkutils.h	82dc4a2a8adc24202bf365942249c0a13e55639b
+++ pidgin/gtkutils.h	7570d2b3a4018b0dfd313d8fd5dbc3357c391f49
@@ -569,6 +569,16 @@ GdkPixbuf * pidgin_create_status_icon(Pu
  */
 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.


More information about the Commits mailing list