pidgin/pidgincontactlist.c

Fri, 27 May 2022 14:52:34 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 27 May 2022 14:52:34 -0500
changeset 41414
b76bc2b4d7cc
parent 41222
1b47017cdfd0
permissions
-rw-r--r--

Convert plugin actions to GMenu and GAction

Also ported the idle maker plugin to the new api.

Testing Done:
Made sure all of the actions for the idle maker plugin worked.

Reviewed at https://reviews.imfreedom.org/r/1408/

40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidgincontactlist.h"
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "pidginactiongroup.h"
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 struct _PidginContactList {
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 GtkApplicationWindow parent;
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GtkWidget *vbox;
40728
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
31
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
32 GtkWidget *menu_bar;
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
33 GtkWidget *sort_buddies;
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
34
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
35 GtkWidget *accounts;
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
36 GtkWidget *accounts_menu;
40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 };
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 G_DEFINE_TYPE(PidginContactList, pidgin_contact_list,
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 GTK_TYPE_APPLICATION_WINDOW)
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 /******************************************************************************
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 * GObject Implementation
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 *****************************************************************************/
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 static void
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 pidgin_contact_list_init(PidginContactList *contact_list) {
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 GSimpleActionGroup *group = NULL;
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 gtk_widget_init_template(GTK_WIDGET(contact_list));
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 gtk_window_set_application(GTK_WINDOW(contact_list),
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 GTK_APPLICATION(g_application_get_default()));
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 group = pidgin_action_group_new();
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 gtk_widget_insert_action_group(GTK_WIDGET(contact_list), "blist",
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 G_ACTION_GROUP(group));
40728
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
57
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
58 gtk_menu_item_set_submenu(GTK_MENU_ITEM(contact_list->accounts),
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
59 contact_list->accounts_menu);
40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 }
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 static void
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 pidgin_contact_list_class_init(PidginContactListClass *klass) {
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 gtk_widget_class_set_template_from_resource(
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 widget_class,
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 40728
diff changeset
68 "/im/pidgin/Pidgin3/BuddyList/window.ui"
40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 );
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 gtk_widget_class_bind_template_child(widget_class, PidginContactList, vbox);
40728
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
72
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
73 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
74 menu_bar);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
75 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
76 sort_buddies);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
77 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
78 accounts);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
79 gtk_widget_class_bind_template_child(widget_class, PidginContactList,
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
80 accounts_menu);
40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 }
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 /******************************************************************************
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 * Public API
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 *****************************************************************************/
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 GtkWidget *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 pidgin_contact_list_new(void) {
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CONTACT_LIST, NULL));
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 }
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 GtkWidget *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 pidgin_contact_list_get_vbox(PidginContactList *contact_list) {
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 g_return_val_if_fail(PIDGIN_IS_CONTACT_LIST(contact_list), NULL);
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 return contact_list->vbox;
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
40728
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
97
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
98 GtkWidget *
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
99 pidgin_contact_list_get_menu_sort_item(PidginContactList *contact_list) {
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
100 g_return_val_if_fail(PIDGIN_IS_CONTACT_LIST(contact_list), NULL);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
101
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
102 return contact_list->sort_buddies;
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
103 }

mercurial