# HG changeset patch # User Elliott Sales de Andrade # Date 1266564570 0 # Node ID 93876452633b8d61962f7ce7eb78c13307f2096b # Parent fa8a25b46252ed353941fe9ba63894d73ca37606 Pull in GtkComboBox changes from GTK+3 branch. Refs #1332, since I seem to have just found it. *** Plucked rev c27b04bb38032682dfa343b38090df1c6eea4edd (qulogic@pidgin.im): Use GtkComboBox instead of GtkOptionMenu in the choice request field for GTK+ 2.4 and up. *** Plucked rev d440cb6510a85d0451248d51de56b02a3a60afd2 (qulogic@pidgin.im): Replace the GtkOptionMenu with a GtkComboBox for the privacy options list on GTK+ 2.4 and up. *** Plucked rev c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61 (qulogic@pidgin.im): Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+ 2.4 and up. *** Plucked rev fbe77efc06ba98af604ef878b97fd55924daa018 (qulogic@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@pidgin.im): Add an enumeration to replace a couple hardcoded numbers in the combo box code for saved statuses. *** Plucked rev c27b04bb38032682dfa343b38090df1c6eea4edd (qulogic@pidgin.im): Use GtkComboBox instead of GtkOptionMenu in the choice request field for GTK+ 2.4 and up. *** Plucked rev d440cb6510a85d0451248d51de56b02a3a60afd2 (qulogic@pidgin.im): Replace the GtkOptionMenu with a GtkComboBox for the privacy options list on GTK+ 2.4 and up. *** Plucked rev c32e5afffcda0d82fe8b69752ae91ce3dc3bcc61 (qulogic@pidgin.im): Replace GtkOptionMenu with GtkComboBox in the saved status editor for GTK+ 2.4 and up. *** Plucked rev fbe77efc06ba98af604ef878b97fd55924daa018 (qulogic@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@pidgin.im): Add an enumeration to replace a couple hardcoded numbers in the combo box code for saved statuses. diff -r fa8a25b46252 -r 93876452633b pidgin/gtkprivacy.c --- a/pidgin/gtkprivacy.c Fri Feb 19 05:26:00 2010 +0000 +++ b/pidgin/gtkprivacy.c Fri Feb 19 07:29:30 2010 +0000 @@ -220,7 +220,11 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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); diff -r fa8a25b46252 -r 93876452633b pidgin/gtkrequest.c --- a/pidgin/gtkrequest.c Fri Feb 19 05:26:00 2010 +0000 +++ b/pidgin/gtkrequest.c Fri Feb 19 07:29:30 2010 +0000 @@ -229,12 +229,21 @@ 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 @@ 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 @@ g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(field_choice_menu_cb), field); +#endif } else { diff -r fa8a25b46252 -r 93876452633b pidgin/gtksavedstatuses.c --- a/pidgin/gtksavedstatuses.c Fri Feb 19 05:26:00 2010 +0000 +++ b/pidgin/gtksavedstatuses.c Fri Feb 19 07:29:30 2010 +0000 @@ -118,7 +118,11 @@ 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 @@ 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,6 +844,64 @@ 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) { @@ -843,7 +909,7 @@ 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 @@ return dropdown; } +#endif + static void edit_substatus(StatusEditor *status_editor, PurpleAccount *account); static void @@ -1153,7 +1221,11 @@ 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 */ diff -r fa8a25b46252 -r 93876452633b pidgin/plugins/gestures/gestures.c --- a/pidgin/plugins/gestures/gestures.c Fri Feb 19 05:26:00 2010 +0000 +++ b/pidgin/plugins/gestures/gestures.c Fri Feb 19 07:29:30 2010 +0000 @@ -145,6 +145,15 @@ } #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) { @@ -153,6 +162,7 @@ gstroke_set_mouse_button(button + 2); } #endif +#endif static void toggle_draw_cb(GtkToggleButton *toggle, gpointer data) @@ -220,8 +230,10 @@ 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,6 +243,19 @@ 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 @@ 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"));