Mercurial > pidgin.yaz
comparison pidgin/gtksavedstatuses.c @ 29804:93876452633b
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.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 19 Feb 2010 07:29:30 +0000 |
parents | e6395be20517 |
children | ded4c63c39a9 |
comparison
equal
deleted
inserted
replaced
29800:fa8a25b46252 | 29804:93876452633b |
---|---|
116 GtkButton *saveanduse_button; | 116 GtkButton *saveanduse_button; |
117 GtkButton *save_button; | 117 GtkButton *save_button; |
118 | 118 |
119 gchar *original_title; | 119 gchar *original_title; |
120 GtkEntry *title; | 120 GtkEntry *title; |
121 #if GTK_CHECK_VERSION(2,4,0) | |
122 GtkComboBox *type; | |
123 #else | |
121 GtkOptionMenu *type; | 124 GtkOptionMenu *type; |
125 #endif | |
122 GtkIMHtml *message; | 126 GtkIMHtml *message; |
123 } StatusEditor; | 127 } StatusEditor; |
124 | 128 |
125 typedef struct | 129 typedef struct |
126 { | 130 { |
740 purple_notify_error(status_window, NULL, _("Title already in use. You must " | 744 purple_notify_error(status_window, NULL, _("Title already in use. You must " |
741 "choose a unique title."), NULL); | 745 "choose a unique title."), NULL); |
742 return; | 746 return; |
743 } | 747 } |
744 | 748 |
749 #if GTK_CHECK_VERSION(2,4,0) | |
750 type = gtk_combo_box_get_active(dialog->type) + (PURPLE_STATUS_UNSET + 1); | |
751 #else | |
745 type = gtk_option_menu_get_history(dialog->type) + (PURPLE_STATUS_UNSET + 1); | 752 type = gtk_option_menu_get_history(dialog->type) + (PURPLE_STATUS_UNSET + 1); |
753 #endif | |
746 message = gtk_imhtml_get_markup(dialog->message); | 754 message = gtk_imhtml_get_markup(dialog->message); |
747 unformatted = purple_markup_strip_html(message); | 755 unformatted = purple_markup_strip_html(message); |
748 | 756 |
749 /* | 757 /* |
750 * If we're editing an old status, then lookup the old status. | 758 * If we're editing an old status, then lookup the old status. |
834 | 842 |
835 gtk_widget_set_sensitive(GTK_WIDGET(dialog->saveanduse_button), (*text != '\0')); | 843 gtk_widget_set_sensitive(GTK_WIDGET(dialog->saveanduse_button), (*text != '\0')); |
836 gtk_widget_set_sensitive(GTK_WIDGET(dialog->save_button), (*text != '\0')); | 844 gtk_widget_set_sensitive(GTK_WIDGET(dialog->save_button), (*text != '\0')); |
837 } | 845 } |
838 | 846 |
839 static GtkWidget * | 847 #if GTK_CHECK_VERSION(2,4,0) |
840 create_stock_item(const gchar *str, const gchar *icon) | 848 |
841 { | 849 enum { |
842 GtkWidget *menuitem = gtk_menu_item_new(); | 850 STATUS_MENU_STOCK_ICON, |
843 GtkWidget *label = gtk_label_new_with_mnemonic(str); | 851 STATUS_MENU_NAME, |
844 GtkWidget *hbox = gtk_hbox_new(FALSE, 4); | 852 STATUS_MENU_COUNT |
845 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); | 853 }; |
846 GtkWidget *image = gtk_image_new_from_stock(icon, icon_size);; | |
847 | |
848 gtk_widget_show(label); | |
849 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
850 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
851 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | |
852 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
853 | |
854 gtk_container_add(GTK_CONTAINER(menuitem), hbox); | |
855 | |
856 return menuitem; | |
857 } | |
858 | 854 |
859 static GtkWidget * | 855 static GtkWidget * |
860 create_status_type_menu(PurpleStatusPrimitive type) | 856 create_status_type_menu(PurpleStatusPrimitive type) |
861 { | 857 { |
862 int i; | 858 int i; |
863 GtkWidget *dropdown; | 859 GtkWidget *dropdown; |
864 GtkWidget *menu; | 860 GtkListStore *store; |
865 GtkWidget *item; | 861 GtkTreeIter iter; |
866 | 862 GtkCellRenderer *renderer; |
867 dropdown = gtk_option_menu_new(); | 863 |
868 menu = gtk_menu_new(); | 864 store = gtk_list_store_new(STATUS_MENU_COUNT, G_TYPE_STRING, G_TYPE_STRING); |
869 | 865 |
870 for (i = PURPLE_STATUS_UNSET + 1; i < PURPLE_STATUS_NUM_PRIMITIVES; i++) | 866 for (i = PURPLE_STATUS_UNSET + 1; i < PURPLE_STATUS_NUM_PRIMITIVES; i++) |
871 { | 867 { |
872 if (i == PURPLE_STATUS_MOBILE || i == PURPLE_STATUS_TUNE) | 868 if (i == PURPLE_STATUS_MOBILE || i == PURPLE_STATUS_TUNE) |
873 /* | 869 /* |
874 * Special-case these. They're intended to be independent | 870 * Special-case these. They're intended to be independent |
875 * status types, so don't show them in the list. | 871 * status types, so don't show them in the list. |
876 */ | 872 */ |
877 continue; | 873 continue; |
878 | 874 |
875 gtk_list_store_append(store, &iter); | |
876 /* TODO: how's this get the right size (since it seems to work fine)? */ | |
877 gtk_list_store_set(store, &iter, | |
878 STATUS_MENU_STOCK_ICON, get_stock_icon_from_primitive(i), | |
879 STATUS_MENU_NAME, purple_primitive_get_name_from_type(i), | |
880 -1); | |
881 } | |
882 | |
883 dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); | |
884 | |
885 renderer = gtk_cell_renderer_pixbuf_new(); | |
886 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, FALSE); | |
887 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer, | |
888 "stock-id", STATUS_MENU_STOCK_ICON, | |
889 NULL); | |
890 | |
891 renderer = gtk_cell_renderer_text_new(); | |
892 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown), renderer, TRUE); | |
893 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown), renderer, | |
894 "text", STATUS_MENU_NAME, | |
895 NULL); | |
896 | |
897 gtk_combo_box_set_active(GTK_COMBO_BOX(dropdown), | |
898 type - (PURPLE_STATUS_UNSET + 1)); | |
899 | |
900 return dropdown; | |
901 } | |
902 | |
903 #else | |
904 | |
905 static GtkWidget * | |
906 create_stock_item(const gchar *str, const gchar *icon) | |
907 { | |
908 GtkWidget *menuitem = gtk_menu_item_new(); | |
909 GtkWidget *label = gtk_label_new_with_mnemonic(str); | |
910 GtkWidget *hbox = gtk_hbox_new(FALSE, 4); | |
911 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); | |
912 GtkWidget *image = gtk_image_new_from_stock(icon, icon_size); | |
913 | |
914 gtk_widget_show(label); | |
915 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
916 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
917 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | |
918 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
919 | |
920 gtk_container_add(GTK_CONTAINER(menuitem), hbox); | |
921 | |
922 return menuitem; | |
923 } | |
924 | |
925 static GtkWidget * | |
926 create_status_type_menu(PurpleStatusPrimitive type) | |
927 { | |
928 int i; | |
929 GtkWidget *dropdown; | |
930 GtkWidget *menu; | |
931 GtkWidget *item; | |
932 | |
933 dropdown = gtk_option_menu_new(); | |
934 menu = gtk_menu_new(); | |
935 | |
936 for (i = PURPLE_STATUS_UNSET + 1; i < PURPLE_STATUS_NUM_PRIMITIVES; i++) | |
937 { | |
938 if (i == PURPLE_STATUS_MOBILE || i == PURPLE_STATUS_TUNE) | |
939 /* | |
940 * Special-case these. They're intended to be independent | |
941 * status types, so don't show them in the list. | |
942 */ | |
943 continue; | |
944 | |
879 item = create_stock_item(purple_primitive_get_name_from_type(i), | 945 item = create_stock_item(purple_primitive_get_name_from_type(i), |
880 get_stock_icon_from_primitive(i)); | 946 get_stock_icon_from_primitive(i)); |
881 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | 947 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
882 } | 948 } |
883 | 949 |
885 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu); | 951 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu); |
886 gtk_widget_show_all(menu); | 952 gtk_widget_show_all(menu); |
887 | 953 |
888 return dropdown; | 954 return dropdown; |
889 } | 955 } |
956 | |
957 #endif | |
890 | 958 |
891 static void edit_substatus(StatusEditor *status_editor, PurpleAccount *account); | 959 static void edit_substatus(StatusEditor *status_editor, PurpleAccount *account); |
892 | 960 |
893 static void | 961 static void |
894 edit_substatus_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data) | 962 edit_substatus_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data) |
1151 /* Status type */ | 1219 /* Status type */ |
1152 if (saved_status != NULL) | 1220 if (saved_status != NULL) |
1153 dropdown = create_status_type_menu(purple_savedstatus_get_type(saved_status)); | 1221 dropdown = create_status_type_menu(purple_savedstatus_get_type(saved_status)); |
1154 else | 1222 else |
1155 dropdown = create_status_type_menu(PURPLE_STATUS_AWAY); | 1223 dropdown = create_status_type_menu(PURPLE_STATUS_AWAY); |
1224 #if GTK_CHECK_VERSION(2,4,0) | |
1225 dialog->type = GTK_COMBO_BOX(dropdown); | |
1226 #else | |
1156 dialog->type = GTK_OPTION_MENU(dropdown); | 1227 dialog->type = GTK_OPTION_MENU(dropdown); |
1228 #endif | |
1157 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Status:"), sg, dropdown, TRUE, NULL); | 1229 pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Status:"), sg, dropdown, TRUE, NULL); |
1158 | 1230 |
1159 /* Status message */ | 1231 /* Status message */ |
1160 frame = pidgin_create_imhtml(TRUE, &text, &toolbar, NULL); | 1232 frame = pidgin_create_imhtml(TRUE, &text, &toolbar, NULL); |
1161 dialog->message = GTK_IMHTML(text); | 1233 dialog->message = GTK_IMHTML(text); |