Fri, 25 Mar 2022 02:56:25 -0500
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
This gives us a bit more control as we are always in control of the attributes,
so we don't need to modify the menu in place. This also made it trivial to add
the protocol icons which are very helpful when you have the same user name on
multiple protocols.
Testing Done:
Enabled and disabled two accounts a lot while under valgrind.
Reviewed at https://reviews.imfreedom.org/r/1366/
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Pidgin - Internet Messenger |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib/gi18n.h> |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
25 | #include "pidgininactiveaccountsmenu.h" |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
27 | struct _PidginInactiveAccountsMenu { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
28 | GMenuModel parent; |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
30 | GList *accounts; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
31 | }; |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
33 | G_DEFINE_TYPE(PidginInactiveAccountsMenu, pidgin_inactive_accounts_menu, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
34 | G_TYPE_MENU_MODEL) |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | /****************************************************************************** |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | * Callbacks |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | *****************************************************************************/ |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | static void |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
40 | pidgin_inactive_accounts_menu_refresh(PidginInactiveAccountsMenu *menu) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
41 | PurpleAccountManager *manager = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
42 | gint removed = 0, added = 0; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
43 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
44 | /* When refreshing we're always removing at least 1 item because of the |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
45 | * "no disabled accounts" item that we put in place when all accounts |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
46 | * are enabled. |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
47 | */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
48 | removed = MAX(1, g_list_length(menu->accounts)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
49 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
50 | /* Grab the manager and get all the disabled accounts. */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
51 | manager = purple_account_manager_get_default(); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
52 | g_list_free(menu->accounts); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
53 | menu->accounts = purple_account_manager_get_inactive(manager); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
54 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
55 | /* Similar to the aboved note about removed items, if every account is |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
56 | * enabled, we add an item saying "no disabled accounts". |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
57 | */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
58 | added = MAX(1, g_list_length(menu->accounts)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
59 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
60 | /* Tell any listeners that our menu has changed. */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
61 | g_menu_model_items_changed(G_MENU_MODEL(menu), 0, removed, added); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
62 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
63 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
64 | static void |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
65 | pidgin_inactive_accounts_menu_changed_cb(G_GNUC_UNUSED PurpleAccount *account, |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | gpointer data) |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | { |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
68 | PidginInactiveAccountsMenu *menu = data; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
69 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
70 | pidgin_inactive_accounts_menu_refresh(menu); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
71 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
72 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
73 | /****************************************************************************** |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
74 | * GMenuModel Implementation |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
75 | *****************************************************************************/ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
76 | static gboolean |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
77 | pidgin_inactive_accounts_menu_is_mutable(GMenuModel *model) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
78 | return TRUE; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
79 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
80 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
81 | static gboolean |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
82 | pidgin_inactive_accounts_menu_get_n_items(GMenuModel *model) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
83 | PidginInactiveAccountsMenu *menu = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
84 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
85 | menu = PIDGIN_INACTIVE_ACCOUNTS_MENU(model); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
86 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
87 | if(menu->accounts == NULL) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
88 | return 1; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
89 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
90 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
91 | return g_list_length(menu->accounts); |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | } |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | static void |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
95 | pidgin_inactive_accounts_menu_get_item_attributes(GMenuModel *model, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
96 | gint index, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
97 | GHashTable **attributes) |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | { |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
99 | PidginInactiveAccountsMenu *menu = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
100 | PurpleAccount *account = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
101 | PurpleProtocol *protocol = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
102 | GVariant *value = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
103 | const gchar *account_name = NULL, *protocol_name = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
104 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
105 | menu = PIDGIN_INACTIVE_ACCOUNTS_MENU(model); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
106 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
107 | /* Create our hash table of attributes to return. */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
108 | *attributes = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
109 | (GDestroyNotify)g_variant_unref); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
110 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
111 | /* If we don't have any disabled accounts, just return a single item, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
112 | * stating as much. |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
113 | */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
114 | if(menu->accounts == NULL) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
115 | value = g_variant_new_string(_("No disabled accounts")); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
116 | g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_LABEL, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
117 | g_variant_ref_sink(value)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
118 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
119 | value = g_variant_new_string("disabled"); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
120 | g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_ACTION, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
121 | g_variant_ref_sink(value)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
122 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
123 | return; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
124 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
125 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
126 | account = g_list_nth_data(menu->accounts, index); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
127 | if(account == NULL) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
128 | return; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
129 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
130 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
131 | account_name = purple_account_get_username(account); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
132 | protocol_name = purple_account_get_protocol_name(account); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
133 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
134 | /* translators: This format string is intended to contain the account |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
135 | * name followed by the protocol name to uniquely identify a specific |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
136 | * account. |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
137 | */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
138 | value = g_variant_new_printf(_("%s (%s)"), account_name, protocol_name); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
139 | g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_LABEL, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
140 | g_variant_ref_sink(value)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
141 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
142 | value = g_variant_new_string("app.enable-account"); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
143 | g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_ACTION, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
144 | g_variant_ref_sink(value)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
145 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
146 | value = g_variant_new_printf("%s", purple_account_get_id(account)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
147 | g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_TARGET, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
148 | g_variant_ref_sink(value)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
149 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
150 | protocol = purple_account_get_protocol(account); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
151 | if(protocol != NULL) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
152 | value = g_variant_new_printf("%s", purple_protocol_get_icon_name(protocol)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
153 | g_hash_table_insert(*attributes, G_MENU_ATTRIBUTE_ICON, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
154 | g_variant_ref_sink(value)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
155 | } |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | } |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | static void |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
159 | pidgin_inactive_accounts_menu_get_item_links(GMenuModel *model, gint index, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
160 | GHashTable **links) |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | { |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
162 | *links = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
163 | g_object_unref); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
164 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
165 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
166 | /****************************************************************************** |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
167 | * GObject Implementation |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
168 | *****************************************************************************/ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
169 | static void |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
170 | pidgin_inactive_accounts_menu_dispose(GObject *obj) { |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | purple_signals_disconnect_by_handle(obj); |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
172 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
173 | G_OBJECT_CLASS(pidgin_inactive_accounts_menu_parent_class)->dispose(obj); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
174 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
175 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
176 | static void |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
177 | pidgin_inactive_accounts_menu_constructed(GObject *obj) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
178 | G_OBJECT_CLASS(pidgin_inactive_accounts_menu_parent_class)->constructed(obj); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
179 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
180 | pidgin_inactive_accounts_menu_refresh(PIDGIN_INACTIVE_ACCOUNTS_MENU(obj)); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
181 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
182 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
183 | static void |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
184 | pidgin_inactive_accounts_menu_init(PidginInactiveAccountsMenu *menu) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
185 | gpointer handle = NULL; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
186 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
187 | /* Wire up the purple signals we care about. */ |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
188 | handle = purple_accounts_get_handle(); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
189 | purple_signal_connect(handle, "account-enabled", menu, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
190 | G_CALLBACK(pidgin_inactive_accounts_menu_changed_cb), |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
191 | menu); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
192 | purple_signal_connect(handle, "account-disabled", menu, |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
193 | G_CALLBACK(pidgin_inactive_accounts_menu_changed_cb), |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
194 | menu); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
195 | } |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
196 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
197 | static void |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
198 | pidgin_inactive_accounts_menu_class_init(PidginInactiveAccountsMenuClass *klass) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
199 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
200 | GMenuModelClass *model_class = G_MENU_MODEL_CLASS(klass); |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
201 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
202 | obj_class->constructed = pidgin_inactive_accounts_menu_constructed; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
203 | obj_class->dispose = pidgin_inactive_accounts_menu_dispose; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
204 | |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
205 | model_class->is_mutable = pidgin_inactive_accounts_menu_is_mutable; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
206 | model_class->get_n_items = pidgin_inactive_accounts_menu_get_n_items; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
207 | model_class->get_item_attributes = pidgin_inactive_accounts_menu_get_item_attributes; |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
208 | model_class->get_item_links = pidgin_inactive_accounts_menu_get_item_links; |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | } |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | /****************************************************************************** |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | * Public API |
|
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | *****************************************************************************/ |
|
41315
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
214 | GMenuModel * |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
215 | pidgin_inactive_accounts_menu_new(void) { |
|
1c9f47bbc031
Replace PidginAccountsDisabledMenu with PidginInactiveAccountsMenu which is a GMenuModel subclass.
Gary Kramlich <grim@reaperworld.com>
parents:
41298
diff
changeset
|
216 | return g_object_new(PIDGIN_TYPE_INACTIVE_ACCOUNTS_MENU, NULL); |
|
41298
6d816e02fd76
Create a menu controller that will keep a GMenu in sync with the disabled accounts in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | } |