Mercurial > pidgin.yaz
comparison src/gtkblist.c @ 11796:b9b7a010b043
[gaim-migrate @ 14087]
I need to sleep. This isn't finished. Hopefully someone will finish it before
I wake up.
Moved Preferences > Buddy List to Buddies menu.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 24 Oct 2005 08:06:34 +0000 |
parents | a9e9b76905b4 |
children | e6bbf34b2465 |
comparison
equal
deleted
inserted
replaced
11795:f48e2acaa5d2 | 11796:b9b7a010b043 |
---|---|
99 } GaimGtkJoinChatData; | 99 } GaimGtkJoinChatData; |
100 | 100 |
101 | 101 |
102 static GtkWidget *protomenu = NULL; | 102 static GtkWidget *protomenu = NULL; |
103 | 103 |
104 GSList *gaim_gtk_blist_sort_methods = NULL; | 104 static GList *gaim_gtk_blist_sort_methods = NULL; |
105 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; | 105 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; |
106 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); | 106 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); |
107 | 107 |
108 /* The functions we use for sorting aren't available in gtk 2.0.x, and | 108 /* The functions we use for sorting aren't available in gtk 2.0.x, and |
109 * segfault in 2.2.0. 2.2.1 is known to work, so I'll require that */ | 109 * segfault in 2.2.0. 2.2.1 is known to work, so I'll require that */ |
1306 | 1306 |
1307 /* Shift+F10 draws a context menu */ | 1307 /* Shift+F10 draws a context menu */ |
1308 handled = gaim_gtk_blist_show_context_menu(node, gaim_gtk_treeview_popup_menu_position_func, tv, 0, GDK_CURRENT_TIME); | 1308 handled = gaim_gtk_blist_show_context_menu(node, gaim_gtk_treeview_popup_menu_position_func, tv, 0, GDK_CURRENT_TIME); |
1309 | 1309 |
1310 return handled; | 1310 return handled; |
1311 } | |
1312 | |
1313 static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item) | |
1314 { | |
1315 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons", | |
1316 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
1311 } | 1317 } |
1312 | 1318 |
1313 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) | 1319 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) |
1314 { | 1320 { |
1315 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups", | 1321 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups", |
2326 { N_("/Buddies/Get User _Info..."), "<CTL>I", gaim_gtkdialogs_info, 0, "<StockItem>", GAIM_STOCK_INFO }, | 2332 { N_("/Buddies/Get User _Info..."), "<CTL>I", gaim_gtkdialogs_info, 0, "<StockItem>", GAIM_STOCK_INFO }, |
2327 { N_("/Buddies/View User _Log..."), "<CTL>L", gaim_gtkdialogs_log, 0, NULL }, | 2333 { N_("/Buddies/View User _Log..."), "<CTL>L", gaim_gtkdialogs_log, 0, NULL }, |
2328 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" }, | 2334 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" }, |
2329 { N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"}, | 2335 { N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"}, |
2330 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>"}, | 2336 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>"}, |
2337 { N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>"}, | |
2338 { N_("/Buddies/Sorting"), NULL, NULL, 0, "<Branch>" }, | |
2339 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" }, | |
2331 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, | 2340 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, |
2332 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD }, | 2341 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD }, |
2333 { N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD }, | 2342 { N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD }, |
2334 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" }, | 2343 { "/Buddies/sep3", NULL, NULL, 0, "<Separator>" }, |
2335 { N_("/Buddies/_Quit"), "<CTL>Q", gaim_core_quit, 0, "<StockItem>", GTK_STOCK_QUIT }, | 2344 { N_("/Buddies/_Quit"), "<CTL>Q", gaim_core_quit, 0, "<StockItem>", GTK_STOCK_QUIT }, |
2336 | 2345 |
2337 /* Tools */ | 2346 /* Tools */ |
2338 { N_("/_Tools"), NULL, NULL, 0, "<Branch>" }, | 2347 { N_("/_Tools"), NULL, NULL, 0, "<Branch>" }, |
2339 { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" }, | 2348 { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" }, |
3314 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); | 3323 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); |
3315 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), | 3324 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), |
3316 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); | 3325 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); |
3317 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), | 3326 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), |
3318 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | 3327 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); |
3328 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), | |
3329 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); | |
3319 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) | 3330 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) |
3320 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); | 3331 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); |
3321 | 3332 |
3322 /* Update some dynamic things */ | 3333 /* Update some dynamic things */ |
3323 update_menu_bar(gtkblist); | 3334 update_menu_bar(gtkblist); |
3324 gaim_gtk_blist_update_plugin_actions(); | 3335 gaim_gtk_blist_update_plugin_actions(); |
3336 gaim_gtk_blist_update_sort_methods(); | |
3325 | 3337 |
3326 /* OK... let's show this bad boy. */ | 3338 /* OK... let's show this bad boy. */ |
3327 if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) { | 3339 if (gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")) { |
3328 gaim_gtk_blist_refresh(list); | 3340 gaim_gtk_blist_refresh(list); |
3329 gaim_gtk_blist_restore_position(); | 3341 gaim_gtk_blist_restore_position(); |
4629 | 4641 |
4630 /********************************************************************* | 4642 /********************************************************************* |
4631 * Buddy List sorting functions * | 4643 * Buddy List sorting functions * |
4632 *********************************************************************/ | 4644 *********************************************************************/ |
4633 | 4645 |
4646 GList *gaim_gtk_blist_get_sort_methods() | |
4647 { | |
4648 return gaim_gtk_blist_sort_methods; | |
4649 } | |
4650 | |
4634 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) | 4651 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) |
4635 { | 4652 { |
4636 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); | 4653 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); |
4637 method->id = g_strdup(id); | 4654 method->id = g_strdup(id); |
4638 method->name = g_strdup(name); | 4655 method->name = g_strdup(name); |
4639 method->func = func; | 4656 method->func = func; |
4640 gaim_gtk_blist_sort_methods = g_slist_append(gaim_gtk_blist_sort_methods, method); | 4657 gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method); |
4658 gaim_gtk_blist_update_sort_methods(); | |
4641 } | 4659 } |
4642 | 4660 |
4643 void gaim_gtk_blist_sort_method_unreg(const char *id){ | 4661 void gaim_gtk_blist_sort_method_unreg(const char *id){ |
4644 GSList *l = gaim_gtk_blist_sort_methods; | 4662 GList *l = gaim_gtk_blist_sort_methods; |
4645 | 4663 |
4646 while(l) { | 4664 while(l) { |
4647 struct gaim_gtk_blist_sort_method *method = l->data; | 4665 struct gaim_gtk_blist_sort_method *method = l->data; |
4648 if(!strcmp(method->id, id)) { | 4666 if(!strcmp(method->id, id)) { |
4649 gaim_gtk_blist_sort_methods = g_slist_delete_link(gaim_gtk_blist_sort_methods, l); | 4667 gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l); |
4650 g_free(method->id); | 4668 g_free(method->id); |
4651 g_free(method->name); | 4669 g_free(method->name); |
4652 g_free(method); | 4670 g_free(method); |
4653 break; | 4671 break; |
4654 } | 4672 } |
4655 } | 4673 } |
4674 gaim_gtk_blist_update_sort_methods(); | |
4656 } | 4675 } |
4657 | 4676 |
4658 void gaim_gtk_blist_sort_method_set(const char *id){ | 4677 void gaim_gtk_blist_sort_method_set(const char *id){ |
4659 GSList *l = gaim_gtk_blist_sort_methods; | 4678 GList *l = gaim_gtk_blist_sort_methods; |
4660 | 4679 |
4661 if(!id) | 4680 if(!id) |
4662 id = "none"; | 4681 id = "none"; |
4663 | 4682 |
4664 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) | 4683 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) |
5114 | 5133 |
5115 build_plugin_actions(pluginmenu, plugin, NULL); | 5134 build_plugin_actions(pluginmenu, plugin, NULL); |
5116 | 5135 |
5117 } | 5136 } |
5118 } | 5137 } |
5138 | |
5139 void sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) | |
5140 { | |
5141 if (gtk_check_menu_item_get_active(checkmenuitem)) | |
5142 gaim_gtk_blist_sort_method_set(id); | |
5143 } | |
5144 | |
5145 void | |
5146 gaim_gtk_blist_update_sort_methods(void) | |
5147 { | |
5148 GtkWidget *menuitem = NULL, *activeitem = NULL; | |
5149 GaimGtkBlistSortMethod *method = NULL; | |
5150 GList *l; | |
5151 GSList *sl = NULL; | |
5152 GtkWidget *sortmenu; | |
5153 char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type"); | |
5154 | |
5155 if (gtkblist == NULL) | |
5156 return; | |
5157 | |
5158 sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sorting")); | |
5159 | |
5160 if (sortmenu == NULL) | |
5161 return; | |
5162 | |
5163 /* Clear the old menu */ | |
5164 for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) { | |
5165 menuitem = l->data; | |
5166 gtk_widget_destroy(GTK_WIDGET(menuitem)); | |
5167 } | |
5168 | |
5169 for (l = gaim_gtk_blist_sort_methods; l; l = l->next) { | |
5170 method = (GaimGtkBlistSortMethod *) l->data; | |
5171 menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name)); | |
5172 if (!strcmp(m, method->id)) | |
5173 activeitem = menuitem; | |
5174 sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); | |
5175 gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem); | |
5176 g_signal_connect(G_OBJECT(menuitem), "toggled", | |
5177 G_CALLBACK(sortmethod_act), method->id); | |
5178 gtk_widget_show(menuitem); | |
5179 } | |
5180 if (activeitem) | |
5181 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE); | |
5182 | |
5183 } |