Wed, 29 Mar 2023 23:33:48 -0500
Use Adwaita widgets in status editor
The `PidginStatusChooser` is also changed from a `GtkDropDown` to a `AdwComboRow` as everything that uses it is now in an `AdwPreferencesGroup`.
Also simplifies a bit of the status editor by using responses instead of widgets.
Testing Done:
Compiled and opened Statuses, modified an existing one and confirmed the dialog was reloaded correctly and appeared to work.
Reviewed at https://reviews.imfreedom.org/r/2396/
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Pidgin - Internet Messenger |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <talkatu/talkatu.h> |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "pidginstatuseditor.h" |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "pidginstatusprimitivechooser.h" |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | enum { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | PROP_0, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | PROP_STATUS, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | N_PROPERTIES |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | }; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | enum { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | RESPONSE_USE, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | RESPONSE_SAVE |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | }; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | struct _PidginStatusEditor { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | GtkDialog parent; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PurpleSavedStatus *status; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | GtkTextBuffer *buffer; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | GtkWidget *title; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | GtkWidget *primitive; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | }; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | G_DEFINE_TYPE(PidginStatusEditor, pidgin_status_editor, GTK_TYPE_DIALOG) |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | /****************************************************************************** |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | * Helpers |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | *****************************************************************************/ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | pidgin_status_editor_set_status(PidginStatusEditor *editor, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | PurpleSavedStatus *status) |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | PurpleStatusPrimitive primitive; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | PidginStatusPrimitiveChooser *chooser = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | const gchar *title = NULL, *message = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | editor->status = status; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | if(editor->status != NULL) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | title = purple_savedstatus_get_title(editor->status); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | primitive = purple_savedstatus_get_primitive_type(editor->status); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | message = purple_savedstatus_get_message(editor->status); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | } else { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | primitive = PURPLE_STATUS_AWAY; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | if(title == NULL) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | title = ""; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | if(message == NULL) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | message = ""; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | |
|
41544
53ba39406c86
Port PidginStatusEditor to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
83 | gtk_editable_set_text(GTK_EDITABLE(editor->title), title); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | chooser = PIDGIN_STATUS_PRIMITIVE_CHOOSER(editor->primitive); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | pidgin_status_primitive_chooser_set_selected(chooser, primitive); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | talkatu_markup_set_html(TALKATU_BUFFER(editor->buffer), message, -1); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | g_object_notify_by_pspec(G_OBJECT(editor), properties[PROP_STATUS]); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | pidgin_status_editor_save_status(PidginStatusEditor *editor) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | PidginStatusPrimitiveChooser *chooser = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | PurpleStatusPrimitive primitive; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | gchar *message = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | const gchar *title = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | |
|
41544
53ba39406c86
Port PidginStatusEditor to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
98 | title = gtk_editable_get_text(GTK_EDITABLE(editor->title)); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | chooser = PIDGIN_STATUS_PRIMITIVE_CHOOSER(editor->primitive); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | primitive = pidgin_status_primitive_chooser_get_selected(chooser); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | message = talkatu_markup_get_html(editor->buffer, NULL); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | if(editor->status == NULL) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | editor->status = purple_savedstatus_new(title, primitive); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | } else { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | const gchar *current_title = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | /* purple_savedstatus_set_title throws a warning if you try to save a |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | * status with an existing title, which means we can't just save the |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | * title if it hasn't changed. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | */ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | current_title = purple_savedstatus_get_title(editor->status); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | if(!purple_strequal(title, current_title)) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | purple_savedstatus_set_title(editor->status, title); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | purple_savedstatus_set_primitive_type(editor->status, primitive); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | purple_savedstatus_set_message(editor->status, message); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | g_free(message); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | /****************************************************************************** |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | * Callbacks |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | *****************************************************************************/ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | pidgin_status_editor_response_cb(GtkDialog *dialog, gint response_id, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | gpointer data) |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | PidginStatusEditor *editor = data; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | switch(response_id) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | case RESPONSE_USE: |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | pidgin_status_editor_save_status(editor); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | purple_savedstatus_activate(editor->status); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | break; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | case RESPONSE_SAVE: |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | pidgin_status_editor_save_status(editor); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | break; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | |
|
41544
53ba39406c86
Port PidginStatusEditor to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
146 | gtk_window_destroy(GTK_WINDOW(dialog)); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | static void |
|
41947
7b3312d0760c
Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41544
diff
changeset
|
150 | pidgin_status_editor_title_changed_cb(G_GNUC_UNUSED GtkEditable *editable, |
|
7b3312d0760c
Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41544
diff
changeset
|
151 | gpointer data) |
|
7b3312d0760c
Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41544
diff
changeset
|
152 | { |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | PidginStatusEditor *editor = data; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | gboolean title_changed = FALSE, sensitive = FALSE; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | const gchar *title = NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | |
|
41544
53ba39406c86
Port PidginStatusEditor to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
157 | title = gtk_editable_get_text(GTK_EDITABLE(editor->title)); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | if(editor->status != NULL) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | /* If we're editing a status, check if the title is the same. */ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | title_changed = !purple_strequal(title, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | purple_savedstatus_get_title(editor->status)); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | } else { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | /* If this is a new status, check if the title is empty or not. */ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | title_changed = !purple_strequal(title, ""); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | if(title_changed) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | gboolean duplicated = purple_savedstatus_find(title) != NULL; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | if(duplicated) { |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
172 | gtk_dialog_set_response_sensitive(GTK_DIALOG(editor), |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
173 | RESPONSE_USE, FALSE); |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
174 | gtk_dialog_set_response_sensitive(GTK_DIALOG(editor), |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
175 | RESPONSE_SAVE, FALSE); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | return; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | sensitive = !purple_strequal(title, ""); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | |
|
42189
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
183 | gtk_dialog_set_response_sensitive(GTK_DIALOG(editor), RESPONSE_USE, |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
184 | sensitive); |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
185 | gtk_dialog_set_response_sensitive(GTK_DIALOG(editor), RESPONSE_SAVE, |
|
4784cd60a1f8
Use Adwaita widgets in status editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41947
diff
changeset
|
186 | sensitive); |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | /****************************************************************************** |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | * GObject Implementation |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | *****************************************************************************/ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | pidgin_status_editor_get_property(GObject *obj, guint param_id, GValue *value, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | GParamSpec *pspec) |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | PidginStatusEditor *editor = PIDGIN_STATUS_EDITOR(obj); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | switch(param_id) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | case PROP_STATUS: |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | g_value_set_pointer(value, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | pidgin_status_editor_get_status(editor)); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | break; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | default: |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | break; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | pidgin_status_editor_set_property(GObject *obj, guint param_id, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | const GValue *value, GParamSpec *pspec) |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | PidginStatusEditor *editor = PIDGIN_STATUS_EDITOR(obj); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | switch(param_id) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | case PROP_STATUS: |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | pidgin_status_editor_set_status(editor, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | g_value_get_pointer(value)); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | break; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | default: |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | break; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | pidgin_status_editor_init(PidginStatusEditor *manager) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | gtk_widget_init_template(GTK_WIDGET(manager)); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | static void |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | pidgin_status_editor_class_init(PidginStatusEditorClass *klass) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | obj_class->get_property = pidgin_status_editor_get_property; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | obj_class->set_property = pidgin_status_editor_set_property; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | /** |
|
41479
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41356
diff
changeset
|
240 | * PidginStatusEditor:status: |
|
41356
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | * The [type@Purple.SavedStatus] that this editor is responsible for. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | * This may be %NULL if it is creating a new status. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | * Since: 3.0.0. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | */ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | /* we don't used boxed here because of the way status are currently |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | * managed. |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | */ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | properties[PROP_STATUS] = g_param_spec_pointer( |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | "status", "status", |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | "The saved status we're editing", |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | gtk_widget_class_set_template_from_resource( |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | widget_class, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | "/im/pidgin/Pidgin3/Status/editor.ui" |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | ); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | gtk_widget_class_bind_template_child(widget_class, PidginStatusEditor, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | buffer); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | gtk_widget_class_bind_template_child(widget_class, PidginStatusEditor, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | title); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | gtk_widget_class_bind_template_child(widget_class, PidginStatusEditor, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | primitive); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | gtk_widget_class_bind_template_callback(widget_class, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | pidgin_status_editor_response_cb); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | gtk_widget_class_bind_template_callback(widget_class, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | pidgin_status_editor_title_changed_cb); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | /****************************************************************************** |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | * Public API |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | *****************************************************************************/ |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | GtkWidget * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | pidgin_status_editor_new(PurpleSavedStatus *status) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | return g_object_new( |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | PIDGIN_TYPE_STATUS_EDITOR, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | "status", status, |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | NULL); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | } |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | PurpleSavedStatus * |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | pidgin_status_editor_get_status(PidginStatusEditor *editor) { |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | g_return_val_if_fail(PIDGIN_IS_STATUS_EDITOR(editor), NULL); |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | return editor->status; |
|
9753153c49fc
Add a new templated PidginStatusEditor and wire it up.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | } |