pidgin/pidgincontactlist.c

Mon, 21 Mar 2022 20:25:43 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 21 Mar 2022 20:25:43 -0500
changeset 41306
8befd71928c2
parent 41222
1b47017cdfd0
child 41414
b76bc2b4d7cc
permissions
-rw-r--r--

Create a new status manager that's built in glade

Behavorial Changes:

* Confirmation dialog for remove has been removed.
* Remove button is disabled if the currently selected status is the active
status. Previously this scenario was silently ignored after confirmation.

Errata:

It is possible to open multiple modify windows for a status. Previously the
editor was reaching into the manager and controlling this pointer. I was going
to fix this, but the editor isn't a widget yet and I don't like doing duplicate
work.

Testing Done:
Basically tried everything I could think of with editing and selecting and so on.

Bugs closed: PIDGIN-17590

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

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;
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
37
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
38 GtkWidget *plugins;
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
39 GtkWidget *plugins_menu;
40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 };
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 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
43 GTK_TYPE_APPLICATION_WINDOW)
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 /******************************************************************************
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 * GObject Implementation
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 *****************************************************************************/
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 static void
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 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
50 GSimpleActionGroup *group = NULL;
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 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
53
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 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
55 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
56
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 group = pidgin_action_group_new();
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 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
59 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
60
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
61 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
62 contact_list->accounts_menu);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
63 gtk_menu_item_set_submenu(GTK_MENU_ITEM(contact_list->plugins),
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
64 contact_list->plugins_menu);
40600
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
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 static void
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 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
69 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
70
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 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
72 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
73 "/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
74 );
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 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
77
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
78 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
79 menu_bar);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
80 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
81 sort_buddies);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
82 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
83 accounts);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
84 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
85 accounts_menu);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
86 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
87 plugins);
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
88 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
89 plugins_menu);
40600
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
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 /******************************************************************************
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 * Public API
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 GtkWidget *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 pidgin_contact_list_new(void) {
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 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
98 }
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 GtkWidget *
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 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
102 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
103
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 return contact_list->vbox;
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }
40728
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
106
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
107 GtkWidget *
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
108 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
109 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
110
2dbfbaeefe40 Merge PidginBuddyListMenu with PidginContactList which fixes all of the accelerators as well.
Gary Kramlich <grim@reaperworld.com>
parents: 40600
diff changeset
111 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
112 }

mercurial