Thu, 16 Nov 2023 23:44:39 -0600
Depend on GPlugin 0.42.1
Testing Done:
Ran `ninja turtles` without issues and noted that the ircv3 introspection was successful.
Reviewed at https://reviews.imfreedom.org/r/2827/
|
41268
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Pidgin - Internet Messenger |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
42339
66b84a5e957d
Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents:
42198
diff
changeset
|
23 | #include "pidginstatusprimitivechooser.h" |
|
41268
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
42339
66b84a5e957d
Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents:
42198
diff
changeset
|
25 | #include "pidginiconname.h" |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
26 | |
|
41268
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | struct _PidginStatusPrimitiveChooser { |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
28 | AdwComboRow parent; |
|
41268
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | }; |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | G_DEFINE_TYPE(PidginStatusPrimitiveChooser, pidgin_status_primitive_chooser, |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
32 | ADW_TYPE_COMBO_ROW) |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
33 | |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
34 | /****************************************************************************** |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
35 | * Callbacks |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
36 | *****************************************************************************/ |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
37 | static PurpleStatusPrimitive |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
38 | pidgin_status_primitive_chooser_primitive_cb(G_GNUC_UNUSED GObject *self, |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
39 | GtkStringObject *object, |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
40 | G_GNUC_UNUSED gpointer data) |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
41 | { |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
42 | PurpleStatusPrimitive primitive = PURPLE_STATUS_UNSET; |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
43 | |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
44 | if(GTK_IS_STRING_OBJECT(object)) { |
|
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
45 | const char *value = gtk_string_object_get_string(object); |
|
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
46 | primitive = purple_primitive_get_type_from_id(value); |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
47 | } |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
48 | |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
49 | return primitive; |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
50 | } |
|
41268
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | /****************************************************************************** |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | * GObject Implementation |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | *****************************************************************************/ |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | static void |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | pidgin_status_primitive_chooser_init(PidginStatusPrimitiveChooser *chooser) { |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | gtk_widget_init_template(GTK_WIDGET(chooser)); |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | } |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | static void |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | pidgin_status_primitive_chooser_class_init(PidginStatusPrimitiveChooserClass *klass) { |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | /* Widget template */ |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | gtk_widget_class_set_template_from_resource( |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | widget_class, "/im/pidgin/Pidgin3/statusprimitivechooser.ui"); |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
67 | |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
68 | gtk_widget_class_bind_template_callback(widget_class, |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
69 | pidgin_status_primitive_chooser_primitive_cb); |
|
41268
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | } |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | /****************************************************************************** |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | * Public API |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | *****************************************************************************/ |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | GtkWidget * |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | pidgin_status_primitive_chooser_new(void) { |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | return g_object_new(PIDGIN_TYPE_STATUS_PRIMITIVE_CHOOSER, NULL); |
|
4adf517478fc
Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | } |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
79 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
80 | PurpleStatusPrimitive |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
81 | pidgin_status_primitive_chooser_get_selected(PidginStatusPrimitiveChooser *chooser) { |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
82 | GtkStringObject *selected = NULL; |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
83 | const char *value = NULL; |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
84 | |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
85 | g_return_val_if_fail(PIDGIN_IS_STATUS_PRIMITIVE_CHOOSER(chooser), |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
86 | PURPLE_STATUS_UNSET); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
87 | |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
88 | selected = adw_combo_row_get_selected_item(ADW_COMBO_ROW(chooser)); |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
89 | value = gtk_string_object_get_string(selected); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
90 | |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
91 | return purple_primitive_get_type_from_id(value); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
92 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
93 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
94 | void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
95 | pidgin_status_primitive_chooser_set_selected(PidginStatusPrimitiveChooser *chooser, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
96 | PurpleStatusPrimitive primitive) |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
97 | { |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
98 | GListModel *model = NULL; |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
99 | GtkStringList *list = NULL; |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
100 | |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
101 | g_return_if_fail(PIDGIN_IS_STATUS_PRIMITIVE_CHOOSER(chooser)); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
102 | |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
103 | model = adw_combo_row_get_model(ADW_COMBO_ROW(chooser)); |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
104 | list = GTK_STRING_LIST(model); |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
105 | for(guint i = 0; i < g_list_model_get_n_items(model); i++) { |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
106 | PurpleStatusPrimitive candidate = PURPLE_STATUS_UNSET; |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
107 | const char *value = NULL; |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
108 | |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
109 | value = gtk_string_list_get_string(list, i); |
|
42198
4df23def5fe0
Add a widget for displaying statuses
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42189
diff
changeset
|
110 | candidate = purple_primitive_get_type_from_id(value); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
111 | |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
112 | if(primitive == candidate) { |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
113 | adw_combo_row_set_selected(ADW_COMBO_ROW(chooser), i); |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41925
diff
changeset
|
114 | break; |
|
41925
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
115 | } |
|
103594fbcf6b
Convert PidginStatusPrimitiveChooser to a GtkDropDown
Gary Kramlich <grim@reaperworld.com>
parents:
41356
diff
changeset
|
116 | } |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
41268
diff
changeset
|
117 | } |