| 69 |
69 |
| 70 /****************************************************************************** |
70 /****************************************************************************** |
| 71 * Structs |
71 * Structs |
| 72 *****************************************************************************/ |
72 *****************************************************************************/ |
| 73 |
73 |
| 74 typedef struct { |
|
| 75 GtkTreeModel *model; |
|
| 76 gint default_item; |
|
| 77 } AopMenu; |
|
| 78 |
|
| 79 typedef struct |
74 typedef struct |
| 80 { |
75 { |
| 81 GtkWidget *entry; |
76 GtkWidget *entry; |
| 82 GtkWidget *accountopt; |
77 GtkWidget *accountopt; |
| 83 |
78 |
| 84 PidginFilterBuddyCompletionEntryFunc filter_func; |
79 PidginFilterBuddyCompletionEntryFunc filter_func; |
| 85 gpointer filter_func_user_data; |
80 gpointer filter_func_user_data; |
| 86 |
81 |
| 87 GtkListStore *store; |
82 GtkListStore *store; |
| 88 } PidginCompletionData; |
83 } PidginCompletionData; |
| 89 |
|
| 90 struct _icon_chooser { |
|
| 91 GtkFileChooserNative *icon_filesel; |
|
| 92 |
|
| 93 void (*callback)(const char*,gpointer); |
|
| 94 gpointer data; |
|
| 95 }; |
|
| 96 |
84 |
| 97 /****************************************************************************** |
85 /****************************************************************************** |
| 98 * Code |
86 * Code |
| 99 *****************************************************************************/ |
87 *****************************************************************************/ |
| 100 |
88 |
| 104 GtkWidget *vbox, *vbox2, *hbox; |
92 GtkWidget *vbox, *vbox2, *hbox; |
| 105 GtkLabel *label; |
93 GtkLabel *label; |
| 106 char *labeltitle; |
94 char *labeltitle; |
| 107 |
95 |
| 108 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); |
96 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); |
| 109 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0); |
97 gtk_box_append(GTK_BOX(parent), vbox); |
| 110 gtk_widget_show(vbox); |
|
| 111 |
98 |
| 112 label = GTK_LABEL(gtk_label_new(NULL)); |
99 label = GTK_LABEL(gtk_label_new(NULL)); |
| 113 |
100 |
| 114 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title); |
101 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title); |
| 115 gtk_label_set_markup(label, labeltitle); |
102 gtk_label_set_markup(label, labeltitle); |
| 116 g_free(labeltitle); |
103 g_free(labeltitle); |
| 117 |
104 |
| 118 gtk_label_set_xalign(GTK_LABEL(label), 0); |
105 gtk_label_set_xalign(GTK_LABEL(label), 0); |
| 119 gtk_label_set_yalign(GTK_LABEL(label), 0); |
106 gtk_label_set_yalign(GTK_LABEL(label), 0); |
| 120 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0); |
107 gtk_box_append(GTK_BOX(vbox), GTK_WIDGET(label)); |
| 121 gtk_widget_show(GTK_WIDGET(label)); |
|
| 122 pidgin_set_accessible_label(vbox, label); |
108 pidgin_set_accessible_label(vbox, label); |
| 123 |
109 |
| 124 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); |
110 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); |
| 125 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); |
111 gtk_box_append(GTK_BOX (vbox), hbox); |
| 126 gtk_widget_show(hbox); |
|
| 127 |
112 |
| 128 label = GTK_LABEL(gtk_label_new(" ")); |
113 label = GTK_LABEL(gtk_label_new(" ")); |
| 129 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0); |
114 gtk_box_append(GTK_BOX(hbox), GTK_WIDGET(label)); |
| 130 gtk_widget_show(GTK_WIDGET(label)); |
|
| 131 |
115 |
| 132 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); |
116 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); |
| 133 gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0); |
117 gtk_box_append(GTK_BOX(hbox), vbox2); |
| 134 gtk_widget_show(vbox2); |
|
| 135 |
118 |
| 136 g_object_set_data(G_OBJECT(vbox2), "main-vbox", vbox); |
119 g_object_set_data(G_OBJECT(vbox2), "main-vbox", vbox); |
| 137 |
120 |
| 138 return vbox2; |
121 return vbox2; |
| 139 } |
122 } |
| 865 GtkWidget *hbox; |
848 GtkWidget *hbox; |
| 866 GtkWidget *label = NULL; |
849 GtkWidget *label = NULL; |
| 867 |
850 |
| 868 if (widget_label) { |
851 if (widget_label) { |
| 869 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); |
852 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); |
| 870 gtk_widget_show(hbox); |
853 gtk_box_append(vbox, hbox); |
| 871 gtk_box_pack_start(vbox, hbox, FALSE, FALSE, 0); |
|
| 872 |
854 |
| 873 label = gtk_label_new_with_mnemonic(widget_label); |
855 label = gtk_label_new_with_mnemonic(widget_label); |
| 874 gtk_widget_show(label); |
|
| 875 if (sg) { |
856 if (sg) { |
| 876 gtk_label_set_xalign(GTK_LABEL(label), 0); |
857 gtk_label_set_xalign(GTK_LABEL(label), 0); |
| 877 gtk_size_group_add_widget(sg, label); |
858 gtk_size_group_add_widget(sg, label); |
| 878 } |
859 } |
| 879 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
860 gtk_box_append(GTK_BOX(hbox), label); |
| |
861 |
| |
862 gtk_widget_set_hexpand(widget, expand); |
| |
863 gtk_widget_set_halign(widget, GTK_ALIGN_FILL); |
| |
864 gtk_box_append(GTK_BOX(hbox), widget); |
| 880 } else { |
865 } else { |
| |
866 gtk_widget_set_vexpand(widget, expand); |
| |
867 gtk_widget_set_valign(widget, GTK_ALIGN_FILL); |
| |
868 gtk_box_append(vbox, widget); |
| |
869 |
| 881 hbox = GTK_WIDGET(vbox); |
870 hbox = GTK_WIDGET(vbox); |
| 882 } |
871 } |
| 883 |
872 |
| 884 gtk_widget_show(widget); |
|
| 885 gtk_box_pack_start(GTK_BOX(hbox), widget, expand, TRUE, 0); |
|
| 886 if (label) { |
873 if (label) { |
| 887 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget); |
874 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget); |
| 888 pidgin_set_accessible_label(widget, GTK_LABEL(label)); |
875 pidgin_set_accessible_label(widget, GTK_LABEL(label)); |
| 889 } |
876 } |
| 890 |
877 |
| 893 return hbox; |
880 return hbox; |
| 894 } |
881 } |
| 895 |
882 |
| 896 gboolean pidgin_auto_parent_window(GtkWidget *widget) |
883 gboolean pidgin_auto_parent_window(GtkWidget *widget) |
| 897 { |
884 { |
| 898 #if 0 |
|
| 899 /* This looks at the most recent window that received focus, and makes |
|
| 900 * that the parent window. */ |
|
| 901 #ifndef _WIN32 |
|
| 902 static GdkAtom _WindowTime = GDK_NONE; |
|
| 903 static GdkAtom _Cardinal = GDK_NONE; |
|
| 904 GList *windows = NULL; |
|
| 905 GtkWidget *parent = NULL; |
|
| 906 time_t window_time = 0; |
|
| 907 |
|
| 908 windows = gtk_window_list_toplevels(); |
|
| 909 |
|
| 910 if (_WindowTime == GDK_NONE) { |
|
| 911 _WindowTime = gdk_x11_xatom_to_atom(gdk_x11_get_xatom_by_name("_NET_WM_USER_TIME")); |
|
| 912 } |
|
| 913 if (_Cardinal == GDK_NONE) { |
|
| 914 _Cardinal = gdk_atom_intern("CARDINAL", FALSE); |
|
| 915 } |
|
| 916 |
|
| 917 while (windows) { |
|
| 918 GtkWidget *window = windows->data; |
|
| 919 guchar *data = NULL; |
|
| 920 int al = 0; |
|
| 921 time_t value; |
|
| 922 |
|
| 923 windows = g_list_delete_link(windows, windows); |
|
| 924 |
|
| 925 if (window == widget || |
|
| 926 !gtk_widget_get_visible(window)) |
|
| 927 continue; |
|
| 928 |
|
| 929 if (!gdk_property_get(window->window, _WindowTime, _Cardinal, 0, sizeof(time_t), FALSE, |
|
| 930 NULL, NULL, &al, &data)) |
|
| 931 continue; |
|
| 932 value = *(time_t *)data; |
|
| 933 if (window_time < value) { |
|
| 934 window_time = value; |
|
| 935 parent = window; |
|
| 936 } |
|
| 937 g_free(data); |
|
| 938 } |
|
| 939 if (windows) |
|
| 940 g_list_free(windows); |
|
| 941 if (parent) { |
|
| 942 if (!gtk_get_current_event() && gtk_window_has_toplevel_focus(GTK_WINDOW(parent))) { |
|
| 943 /* The window is in focus, and the new window was not triggered by a keypress/click |
|
| 944 * event. So do not set it transient, to avoid focus stealing and all that. |
|
| 945 */ |
|
| 946 return FALSE; |
|
| 947 } |
|
| 948 gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent)); |
|
| 949 return TRUE; |
|
| 950 } |
|
| 951 return FALSE; |
|
| 952 #endif |
|
| 953 #else |
|
| 954 /* This finds the currently active window and makes that the parent window. */ |
885 /* This finds the currently active window and makes that the parent window. */ |
| 955 GList *windows = NULL; |
886 GList *windows = NULL; |
| 956 GtkWindow *parent = NULL; |
887 GtkWindow *parent = NULL; |
| 957 GdkEvent *event = gtk_get_current_event(); |
|
| 958 GdkWindow *menu = NULL; |
|
| 959 gpointer parent_from; |
888 gpointer parent_from; |
| 960 PurpleNotifyType notify_type; |
889 PurpleNotifyType notify_type; |
| 961 |
890 |
| 962 parent_from = g_object_get_data(G_OBJECT(widget), "pidgin-parent-from"); |
891 parent_from = g_object_get_data(G_OBJECT(widget), "pidgin-parent-from"); |
| 963 if (purple_request_is_valid_ui_handle(parent_from, NULL)) { |
892 if (purple_request_is_valid_ui_handle(parent_from, NULL)) { |
| 973 gtk_window_set_transient_for(GTK_WINDOW(widget), |
902 gtk_window_set_transient_for(GTK_WINDOW(widget), |
| 974 gtk_window_get_transient_for(GTK_WINDOW(parent_from))); |
903 gtk_window_get_transient_for(GTK_WINDOW(parent_from))); |
| 975 return TRUE; |
904 return TRUE; |
| 976 } |
905 } |
| 977 |
906 |
| 978 if (event == NULL) |
|
| 979 /* The window was not triggered by a user action. */ |
|
| 980 return FALSE; |
|
| 981 |
|
| 982 /* We need to special case events from a popup menu. */ |
|
| 983 if (event->type == GDK_BUTTON_RELEASE) { |
|
| 984 /* XXX: Neither of the following works: |
|
| 985 menu = event->button.window; |
|
| 986 menu = gdk_window_get_parent(event->button.window); |
|
| 987 menu = gdk_window_get_toplevel(event->button.window); |
|
| 988 */ |
|
| 989 } else if (event->type == GDK_KEY_PRESS) |
|
| 990 menu = event->key.window; |
|
| 991 |
|
| 992 windows = gtk_window_list_toplevels(); |
907 windows = gtk_window_list_toplevels(); |
| 993 while (windows) { |
908 while (windows) { |
| 994 GtkWindow *window = GTK_WINDOW(windows->data); |
909 GtkWindow *window = GTK_WINDOW(windows->data); |
| 995 windows = g_list_delete_link(windows, windows); |
910 windows = g_list_delete_link(windows, windows); |
| 996 |
911 |