pidgin/pidginstatusprimitivechooser.c

Wed, 24 Aug 2022 21:18:06 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 24 Aug 2022 21:18:06 -0500
branch
gtk4
changeset 41583
853b74b4a222
parent 41356
9753153c49fc
child 41925
103594fbcf6b
permissions
-rw-r--r--

Remove the custom css setup for now as it's throwing a GWarning and we need to plan this out more.

Testing Done:
Ran and verified the warning was gone.

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

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
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <pidgin/pidginstatusprimitivechooser.h>
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PidginStatusPrimitiveChooser {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GtkComboBox parent;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 };
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 G_DEFINE_TYPE(PidginStatusPrimitiveChooser, pidgin_status_primitive_chooser,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GTK_TYPE_COMBO_BOX)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 /******************************************************************************
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 * GObject Implementation
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 *****************************************************************************/
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 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
38 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
39 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 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
43 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
44
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 /* Widget template */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 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
47 widget_class, "/im/pidgin/Pidgin3/statusprimitivechooser.ui");
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 /******************************************************************************
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 * Public API
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 GtkWidget *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 pidgin_status_primitive_chooser_new(void) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 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
56 }
41356
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
57
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
58 PurpleStatusPrimitive
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
59 pidgin_status_primitive_chooser_get_selected(PidginStatusPrimitiveChooser *chooser) {
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
60 const gchar *active_id = NULL;
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
61
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
62 g_return_val_if_fail(PIDGIN_IS_STATUS_PRIMITIVE_CHOOSER(chooser),
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
63 PURPLE_STATUS_UNSET);
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
64
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
65 active_id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(chooser));
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
66
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
67 return purple_primitive_get_type_from_id(active_id);
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
68 }
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
69
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
70 void
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
71 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
72 PurpleStatusPrimitive primitive)
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
73 {
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
74 const gchar *active_id = NULL;
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
75
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
76 g_return_if_fail(PIDGIN_IS_STATUS_PRIMITIVE_CHOOSER(chooser));
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
77
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
78 active_id = purple_primitive_get_id_from_type(primitive);
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 gtk_combo_box_set_active_id(GTK_COMBO_BOX(chooser), active_id);
9753153c49fc Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents: 41268
diff changeset
81 }

mercurial