Tue, 07 Apr 2020 18:28:26 -0500
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
|
40363
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * pidgin |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * source distribution. |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "pidginbuddylistmenu.h" |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | struct _PidginBuddyListMenu { |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | GtkMenuBar parent; |
|
40368
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
27 | |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
28 | GtkWidget *sort_buddies; |
|
40379
c50c509dd028
Migrate the accounts menu to its own set of widgets
Gary Kramlich <grim@reaperworld.com>
parents:
40376
diff
changeset
|
29 | |
|
c50c509dd028
Migrate the accounts menu to its own set of widgets
Gary Kramlich <grim@reaperworld.com>
parents:
40376
diff
changeset
|
30 | GtkWidget *accounts; |
|
c50c509dd028
Migrate the accounts menu to its own set of widgets
Gary Kramlich <grim@reaperworld.com>
parents:
40376
diff
changeset
|
31 | GtkWidget *accounts_menu; |
|
c50c509dd028
Migrate the accounts menu to its own set of widgets
Gary Kramlich <grim@reaperworld.com>
parents:
40376
diff
changeset
|
32 | |
|
40373
5d2a493339f2
Add the new PidginPluginsMenu which manages itself when plugins and loaded/unloaded.
Gary Kramlich <grim@reaperworld.com>
parents:
40368
diff
changeset
|
33 | GtkWidget *plugins; |
|
40376
3e78021f32b2
Move the PidginPluginsMenu creation into the BuddyListMenu ui file
Gary Kramlich <grim@reaperworld.com>
parents:
40373
diff
changeset
|
34 | GtkWidget *plugins_menu; |
|
40383
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
35 | |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
36 | GtkWidget *menu_tray; |
|
40363
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | }; |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | /****************************************************************************** |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | * GObject Implementation |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | *****************************************************************************/ |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | G_DEFINE_TYPE(PidginBuddyListMenu, pidgin_buddy_list_menu, GTK_TYPE_MENU_BAR) |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | static void |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | pidgin_buddy_list_menu_init(PidginBuddyListMenu *menu) { |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | gtk_widget_init_template(GTK_WIDGET(menu)); |
|
40373
5d2a493339f2
Add the new PidginPluginsMenu which manages itself when plugins and loaded/unloaded.
Gary Kramlich <grim@reaperworld.com>
parents:
40368
diff
changeset
|
47 | |
|
40379
c50c509dd028
Migrate the accounts menu to its own set of widgets
Gary Kramlich <grim@reaperworld.com>
parents:
40376
diff
changeset
|
48 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->accounts), |
|
c50c509dd028
Migrate the accounts menu to its own set of widgets
Gary Kramlich <grim@reaperworld.com>
parents:
40376
diff
changeset
|
49 | menu->accounts_menu); |
|
40373
5d2a493339f2
Add the new PidginPluginsMenu which manages itself when plugins and loaded/unloaded.
Gary Kramlich <grim@reaperworld.com>
parents:
40368
diff
changeset
|
50 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->plugins), |
|
40376
3e78021f32b2
Move the PidginPluginsMenu creation into the BuddyListMenu ui file
Gary Kramlich <grim@reaperworld.com>
parents:
40373
diff
changeset
|
51 | menu->plugins_menu); |
|
40383
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
52 | |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
53 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu->menu_tray); |
|
40363
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | } |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | static void |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | pidgin_buddy_list_menu_class_init(PidginBuddyListMenuClass *klass) { |
|
40368
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
58 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
59 | |
|
40387
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
60 | gtk_widget_class_set_template_from_resource( |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
61 | widget_class, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
62 | "/im/pidgin/Pidgin/BuddyList/menu.ui" |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
63 | ); |
|
40368
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
64 | |
|
40387
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
65 | gtk_widget_class_bind_template_child(widget_class, PidginBuddyListMenu, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
66 | sort_buddies); |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
67 | gtk_widget_class_bind_template_child(widget_class, PidginBuddyListMenu, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
68 | accounts); |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
69 | gtk_widget_class_bind_template_child(widget_class, PidginBuddyListMenu, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
70 | accounts_menu); |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
71 | gtk_widget_class_bind_template_child(widget_class, PidginBuddyListMenu, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
72 | plugins); |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
73 | gtk_widget_class_bind_template_child(widget_class, PidginBuddyListMenu, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
74 | plugins_menu); |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
75 | gtk_widget_class_bind_template_child(widget_class, PidginBuddyListMenu, |
|
4cdb2a681dc1
use g_list_index instead of manually searching a list and a bunch of whitespace fixes
Gary Kramlich <grim@reaperworld.com>
parents:
40383
diff
changeset
|
76 | menu_tray); |
|
40363
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | } |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | /****************************************************************************** |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | * Public API |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | *****************************************************************************/ |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | GtkWidget * |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | pidgin_buddy_list_menu_new(void) { |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | return GTK_WIDGET(g_object_new(PIDGIN_TYPE_BUDDY_LIST_MENU, NULL)); |
|
c8b010d1d430
Start to migrate the buddy list from GtkActionEntry and UiManager to GActionEntry and a custom widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | } |
|
40368
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
86 | |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
87 | GtkWidget * |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
88 | pidgin_buddy_list_menu_get_sort_item(PidginBuddyListMenu *menu) { |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
89 | g_return_val_if_fail(PIDGIN_IS_BUDDY_LIST_MENU(menu), NULL); |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
90 | |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
91 | return menu->sort_buddies; |
|
cb9a81e8845a
Port the sort-method items to GMenu and GAction and display in the new menubar
Gary Kramlich <grim@reaperworld.com>
parents:
40363
diff
changeset
|
92 | } |
|
40383
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
93 | |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
94 | GtkWidget * |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
95 | pidgin_buddy_list_menu_get_menu_tray(PidginBuddyListMenu *menu) { |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
96 | g_return_val_if_fail(PIDGIN_IS_BUDDY_LIST_MENU(menu), NULL); |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
97 | |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
98 | return menu->menu_tray; |
|
dbc5c2d601ab
Move the menu trac to PidginBuddyListMenu
Gary Kramlich <grim@reaperworld.com>
parents:
40379
diff
changeset
|
99 | } |