cpw.qulogic.gtk3: c32e5aff: Replace GtkOptionMenu with GtkComboBox i...

qulogic at pidgin.im qulogic at pidgin.im
Fri Apr 10 03:36:08 EDT 2009


-----------------------------------------------------------------
Revision: c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61
Ancestor: d440cb6510a85d0451248d51de56b02a3a60afd2
Author: qulogic at pidgin.im
Date: 2009-04-09T04:18:50
Branch: im.pidgin.cpw.qulogic.gtk3
URL: http://d.pidgin.im/viewmtn/revision/info/c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61

Modified files:
        pidgin/gtksavedstatuses.c

ChangeLog: 

Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+
2.4 and up.

-------------- next part --------------
============================================================
--- pidgin/gtksavedstatuses.c	377e0b29361893d9bfd3ad87f5d450c9b8e38020
+++ pidgin/gtksavedstatuses.c	2cc68b1023ead8a745014ea0f67b8dbffa80e95f
@@ -119,7 +119,11 @@ typedef struct
 
 	gchar *original_title;
 	GtkEntry *title;
+#if GTK_CHECK_VERSION(2,4,0)
+	GtkComboBox *type;
+#else
 	GtkOptionMenu *type;
+#endif
 	GtkIMHtml *message;
 } StatusEditor;
 
@@ -795,7 +799,11 @@ status_editor_ok_cb(GtkButton *button, g
 		return;
 	}
 
+#if GTK_CHECK_VERSION(2,4,0)
+	type = gtk_combo_box_get_active(dialog->type) + (PURPLE_STATUS_UNSET + 1);
+#else
 	type = gtk_option_menu_get_history(dialog->type) + (PURPLE_STATUS_UNSET + 1);
+#endif
 	message = gtk_imhtml_get_markup(dialog->message);
 	unformatted = purple_markup_strip_html(message);
 
@@ -889,14 +897,66 @@ editor_title_changed_cb(GtkWidget *widge
 	gtk_widget_set_sensitive(GTK_WIDGET(dialog->save_button), (*text != '\0'));
 }
 
+#if GTK_CHECK_VERSION(2,4,0)
+
 static GtkWidget *
+create_status_type_menu(PurpleStatusPrimitive type)
+{
+	int i;
+	GtkWidget *dropdown;
+	GtkListStore *store;
+	GtkTreeIter iter;
+	GtkCellRenderer *renderer;
+
+	store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+
+	for (i = PURPLE_STATUS_UNSET + 1; i < PURPLE_STATUS_NUM_PRIMITIVES; i++)
+	{
+		if (i == PURPLE_STATUS_MOBILE || i == PURPLE_STATUS_TUNE)
+			/*
+			 * Special-case these.  They're intended to be independent
+			 * status types, so don't show them in the list.
+			 */
+			continue;
+
+		gtk_list_store_append(store, &iter);
+		/* TODO: how's this get the right size (since it seems to work fine)? */
+		gtk_list_store_set(store, &iter,
+		                   0, get_stock_icon_from_primitive(i),
+		                   1, purple_primitive_get_name_from_type(i),
+		                   -1);
+	}
+
+	dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+
+	renderer = gtk_cell_renderer_pixbuf_new();
+	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, FALSE);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
+	                               "stock-id", 0,
+	                               NULL);
+
+	renderer = gtk_cell_renderer_text_new();
+	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, TRUE);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer,
+	                               "text", 1,
+	                               NULL);
+
+	gtk_combo_box_set_active(GTK_COMBO_BOX(dropdown),
+	                         type - (PURPLE_STATUS_UNSET + 1));
+
+	return dropdown;
+}
+
+#else
+
+static GtkWidget *
 create_stock_item(const gchar *str, const gchar *icon)
 {
 	GtkWidget *menuitem = gtk_menu_item_new();
 	GtkWidget *label = gtk_label_new_with_mnemonic(str);
 	GtkWidget *hbox = gtk_hbox_new(FALSE, 4);
 	GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
-	GtkWidget *image = gtk_image_new_from_stock(icon, icon_size);;
+	GtkWidget *image = gtk_image_new_from_stock(icon, icon_size);
 
 	gtk_widget_show(label);
 	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
@@ -941,6 +1001,8 @@ create_status_type_menu(PurpleStatusPrim
 	return dropdown;
 }
 
+#endif
+
 static void edit_substatus(StatusEditor *status_editor, PurpleAccount *account);
 
 static void
@@ -1206,7 +1268,11 @@ pidgin_status_editor_show(gboolean edit,
 		dropdown = create_status_type_menu(purple_savedstatus_get_type(saved_status));
 	else
 		dropdown = create_status_type_menu(PURPLE_STATUS_AWAY);
+#if GTK_CHECK_VERSION(2,4,0)
+	dialog->type = GTK_COMBO_BOX(dropdown);
+#else
 	dialog->type = GTK_OPTION_MENU(dropdown);
+#endif
 	pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Status:"), sg, dropdown, TRUE, NULL);
 
 	/* Status message */


More information about the Commits mailing list