pidgin: 9d4f4577: Pull in GtkComboBox changes from GTK+3 b...
qulogic at pidgin.im
qulogic at pidgin.im
Sat Feb 20 02:13:12 EST 2010
-----------------------------------------------------------------
Revision: 9d4f4577f00074017bc7a68c5106ca0f0a2f8753
Ancestor: 302c560990dbae6b00f9ca0ef36b3c160b190bdb
Author: qulogic at pidgin.im
Date: 2010-02-19T07:29:30
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9d4f4577f00074017bc7a68c5106ca0f0a2f8753
Modified files:
pidgin/gtkprivacy.c pidgin/gtkrequest.c
pidgin/gtksavedstatuses.c pidgin/plugins/gestures/gestures.c
ChangeLog:
Pull in GtkComboBox changes from GTK+3 branch.
Refs #1332, since I seem to have just found it.
*** Plucked rev c27b04bb38032682dfa343b38090df1c6eea4edd (qulogic at pidgin.im):
Use GtkComboBox instead of GtkOptionMenu in the choice request field for
GTK+ 2.4 and up.
*** Plucked rev d440cb6510a85d0451248d51de56b02a3a60afd2 (qulogic at pidgin.im):
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
on GTK+ 2.4 and up.
*** Plucked rev c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61 (qulogic at pidgin.im):
Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+
2.4 and up.
*** Plucked rev fbe77efc06ba98af604ef878b97fd55924daa018 (qulogic at pidgin.im):
Replace GtkOptionMenu with GtkComboBox in the gestures plugin for GTK+ 2.4
and up. But that code's commented out, so this is totally untested.
*** Plucked rev 9d8f789a57f4477db7d3cfbb9752b7842ff790dd (qulogic at pidgin.im):
Add an enumeration to replace a couple hardcoded numbers in the combo box
code for saved statuses.
*** Plucked rev c27b04bb38032682dfa343b38090df1c6eea4edd (qulogic at pidgin.im):
Use GtkComboBox instead of GtkOptionMenu in the choice request field for
GTK+ 2.4 and up.
*** Plucked rev d440cb6510a85d0451248d51de56b02a3a60afd2 (qulogic at pidgin.im):
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
on GTK+ 2.4 and up.
*** Plucked rev c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61 (qulogic at pidgin.im):
Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+
2.4 and up.
*** Plucked rev fbe77efc06ba98af604ef878b97fd55924daa018 (qulogic at pidgin.im):
Replace GtkOptionMenu with GtkComboBox in the gestures plugin for GTK+ 2.4
and up. But that code's commented out, so this is totally untested.
*** Plucked rev 9d8f789a57f4477db7d3cfbb9752b7842ff790dd (qulogic at pidgin.im):
Add an enumeration to replace a couple hardcoded numbers in the combo box
code for saved statuses.
-------------- next part --------------
============================================================
--- pidgin/gtkprivacy.c 0539636ae120a83ed054e2fc0defb5fc235fd35a
+++ pidgin/gtkprivacy.c 2d3c230c4d7ca22a0ea4a76771096f567b100322
@@ -220,7 +220,11 @@ select_account_cb(GtkWidget *dropdown, P
for (i = 0; i < menu_entry_count; i++) {
if (menu_entries[i].num == account->perm_deny) {
+#if GTK_CHECK_VERSION(2,4,0)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i);
+#else
gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->type_menu), i);
+#endif
break;
}
}
@@ -233,10 +237,17 @@ select_account_cb(GtkWidget *dropdown, P
* TODO: Setting the permit/deny setting needs to go through privacy.c
* Even better: the privacy API needs to not suck.
*/
+#if GTK_CHECK_VERSION(2,4,0)
static void
+type_changed_cb(GtkComboBox *combo, PidginPrivacyDialog *dialog)
+{
+ int new_type = menu_entries[gtk_combo_box_get_active(combo)].num;
+#else
+static void
type_changed_cb(GtkOptionMenu *optmenu, PidginPrivacyDialog *dialog)
{
int new_type = menu_entries[gtk_option_menu_get_history(optmenu)].num;
+#endif
dialog->account->perm_deny = new_type;
serv_set_permit_deny(purple_account_get_connection(dialog->account));
@@ -343,7 +354,9 @@ privacy_dialog_new(void)
GtkWidget *button;
GtkWidget *dropdown;
GtkWidget *label;
+#if !GTK_CHECK_VERSION(2,4,0)
GtkWidget *menu;
+#endif
int selected = 0;
int i;
@@ -372,6 +385,24 @@ privacy_dialog_new(void)
dialog->account = pidgin_account_option_menu_get_selected(dropdown);
/* Add the drop-down list with the allow/block types. */
+#if GTK_CHECK_VERSION(2,4,0)
+ dialog->type_menu = gtk_combo_box_new_text();
+ gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0);
+ gtk_widget_show(dialog->type_menu);
+
+ for (i = 0; i < menu_entry_count; i++) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dialog->type_menu),
+ _(menu_entries[i].text));
+
+ if (menu_entries[i].num == dialog->account->perm_deny)
+ selected = i;
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), selected);
+
+ g_signal_connect(G_OBJECT(dialog->type_menu), "changed",
+ G_CALLBACK(type_changed_cb), dialog);
+#else
dialog->type_menu = gtk_option_menu_new();
gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0);
gtk_widget_show(dialog->type_menu);
@@ -391,6 +422,7 @@ privacy_dialog_new(void)
g_signal_connect(G_OBJECT(dialog->type_menu), "changed",
G_CALLBACK(type_changed_cb), dialog);
+#endif
/* Build the treeview for the allow list. */
dialog->allow_widget = build_allow_list(dialog);
@@ -421,7 +453,11 @@ privacy_dialog_new(void)
button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_CLOSE, G_CALLBACK(close_cb), dialog);
dialog->close_button = button;
+#if GTK_CHECK_VERSION(2,4,0)
+ type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog);
+#else
type_changed_cb(GTK_OPTION_MENU(dialog->type_menu), dialog);
+#endif
#if 0
if (dialog->account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) {
gtk_widget_show(dialog->allow_widget);
============================================================
--- pidgin/gtkrequest.c 42431ea66cfb270503dfb2b2b39cd38fba4ac2be
+++ pidgin/gtkrequest.c 530a9d904947b13764032c4c37fe4d5febeadbac
@@ -229,12 +229,21 @@ field_bool_cb(GtkToggleButton *button, P
gtk_toggle_button_get_active(button));
}
+#if GTK_CHECK_VERSION(2,4,0)
static void
+field_choice_menu_cb(GtkComboBox *menu, PurpleRequestField *field)
+{
+ purple_request_field_choice_set_value(field,
+ gtk_combo_box_get_active(menu));
+}
+#else
+static void
field_choice_menu_cb(GtkOptionMenu *menu, PurpleRequestField *field)
{
purple_request_field_choice_set_value(field,
gtk_option_menu_get_history(menu));
}
+#endif
static void
field_choice_option_cb(GtkRadioButton *button, PurpleRequestField *field)
@@ -928,6 +937,21 @@ create_choice_field(PurpleRequestField *
if (num_labels > 5)
{
+#if GTK_CHECK_VERSION(2,4,0)
+ widget = gtk_combo_box_new_text();
+
+ for (l = labels; l != NULL; l = l->next)
+ {
+ const char *text = l->data;
+ gtk_combo_box_append_text(GTK_COMBO_BOX(widget), text);
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ purple_request_field_choice_get_default_value(field));
+
+ g_signal_connect(G_OBJECT(widget), "changed",
+ G_CALLBACK(field_choice_menu_cb), field);
+#else
GtkWidget *menu;
GtkWidget *item;
@@ -952,6 +976,7 @@ create_choice_field(PurpleRequestField *
g_signal_connect(G_OBJECT(widget), "changed",
G_CALLBACK(field_choice_menu_cb), field);
+#endif
}
else
{
============================================================
--- pidgin/gtksavedstatuses.c 44ad5dbe9798630de0d19750221a90c84d08a762
+++ pidgin/gtksavedstatuses.c 0b280f63ea704e5c1598ed8c026c8c1a7698df04
@@ -118,7 +118,11 @@ typedef struct
gchar *original_title;
GtkEntry *title;
+#if GTK_CHECK_VERSION(2,4,0)
+ GtkComboBox *type;
+#else
GtkOptionMenu *type;
+#endif
GtkIMHtml *message;
} StatusEditor;
@@ -742,7 +746,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);
@@ -836,14 +844,72 @@ editor_title_changed_cb(GtkWidget *widge
gtk_widget_set_sensitive(GTK_WIDGET(dialog->save_button), (*text != '\0'));
}
+#if GTK_CHECK_VERSION(2,4,0)
+
+enum {
+ STATUS_MENU_STOCK_ICON,
+ STATUS_MENU_NAME,
+ STATUS_MENU_COUNT
+};
+
static GtkWidget *
+create_status_type_menu(PurpleStatusPrimitive type)
+{
+ int i;
+ GtkWidget *dropdown;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+
+ store = gtk_list_store_new(STATUS_MENU_COUNT, 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,
+ STATUS_MENU_STOCK_ICON, get_stock_icon_from_primitive(i),
+ STATUS_MENU_NAME, 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", STATUS_MENU_STOCK_ICON,
+ 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", STATUS_MENU_NAME,
+ 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);
@@ -888,6 +954,8 @@ create_status_type_menu(PurpleStatusPrim
return dropdown;
}
+#endif
+
static void edit_substatus(StatusEditor *status_editor, PurpleAccount *account);
static void
@@ -1153,7 +1221,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 */
============================================================
--- pidgin/plugins/gestures/gestures.c d91e43d58cec0aa90fbb3c982778604c40b6245f
+++ pidgin/plugins/gestures/gestures.c c16ac78591c42117a071097e73e63e7d9e65506b
@@ -145,7 +145,16 @@ new_conv_cb(PurpleConversation *conv)
}
#if 0
+#if GTK_CHECK_VERSION(2,4,0)
static void
+mouse_button_menu_cb(GtkComboBox *opt, gpointer data)
+{
+ int button = gtk_combo_box_get_active(opt);
+
+ gstroke_set_mouse_button(button + 2);
+}
+#else
+static void
mouse_button_menu_cb(GtkMenuItem *item, gpointer data)
{
int button = (int)data;
@@ -153,6 +162,7 @@ mouse_button_menu_cb(GtkMenuItem *item,
gstroke_set_mouse_button(button + 2);
}
#endif
+#endif
static void
toggle_draw_cb(GtkToggleButton *toggle, gpointer data)
@@ -220,8 +230,10 @@ get_config_frame(PurplePlugin *plugin)
GtkWidget *toggle;
#if 0
GtkWidget *opt;
+#if GTK_CHECK_VERSION(2,4,0)
GtkWidget *menu, *item;
#endif
+#endif
/* Outside container */
ret = gtk_vbox_new(FALSE, 18);
@@ -231,7 +243,20 @@ get_config_frame(PurplePlugin *plugin)
vbox = pidgin_make_frame(ret, _("Mouse Gestures Configuration"));
#if 0
+#if GTK_CHECK_VERSION(2,4,0)
/* Mouse button drop-down menu */
+ opt = gtk_combo_box_new_text();
+
+ gtk_combo_box_append_text(_("Middle mouse button"));
+ gtk_combo_box_append_text(_("Right mouse button"));
+ g_signal_connect(G_OBJECT(opt), "changed",
+ G_CALLBACK(mouse_button_menu_cb), NULL);
+
+ gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(opt),
+ gstroke_get_mouse_button() - 2);
+#else
+ /* Mouse button drop-down menu */
menu = gtk_menu_new();
opt = gtk_option_menu_new();
@@ -250,6 +275,7 @@ get_config_frame(PurplePlugin *plugin)
gtk_option_menu_set_history(GTK_OPTION_MENU(opt),
gstroke_get_mouse_button() - 2);
#endif
+#endif
/* "Visual gesture display" checkbox */
toggle = gtk_check_button_new_with_mnemonic(_("_Visual gesture display"));
More information about the Commits
mailing list