libpurple/purplecommand.c

Mon, 30 Jun 2025 14:22:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 30 Jun 2025 14:22:13 -0500
changeset 43269
1523eab3b5a0
parent 43053
f2f944ac775c
permissions
-rw-r--r--

Update the flatpak to gnome 48 and to the matching birb version

The birb version was missed here when it was updated.

Testing Done:
Built the flatpak with the instructions in the readme.

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

42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * any later version.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * more details.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License along with
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <birb.h>
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "purplecommand.h"
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "util.h"
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PurpleCommand {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GObject parent;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 char *icon_name;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 GDateTime *last_used;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 char *name;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 int priority;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 char *source;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 char *summary;
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
38 PurpleTags *tags;
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 guint use_count;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 };
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 enum {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PROP_0,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_ICON_NAME,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PROP_LAST_USED,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PROP_NAME,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 PROP_PRIORITY,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PROP_SOURCE,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 PROP_SUMMARY,
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
50 PROP_TAGS,
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 PROP_USE_COUNT,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 N_PROPERTIES,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 };
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 enum {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 SIG_EXECUTED,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 N_SIGNALS,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 };
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 static guint signals[N_SIGNALS] = {0, };
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 /******************************************************************************
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 * Helpers
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 *****************************************************************************/
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 purple_command_set_name(PurpleCommand *command, const char *name) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 g_return_if_fail(!purple_strempty(name));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 if(g_set_str(&command->name, name)) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 g_object_notify_by_pspec(G_OBJECT(command), properties[PROP_NAME]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 purple_command_set_source(PurpleCommand *command, const char *source) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 g_return_if_fail(!purple_strempty(source));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 if(g_set_str(&command->source, source)) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_object_notify_by_pspec(G_OBJECT(command), properties[PROP_SOURCE]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 purple_command_set_priority(PurpleCommand *command, int priority) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 if(command->priority != priority) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 command->priority = priority;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 g_object_notify_by_pspec(G_OBJECT(command),
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 properties[PROP_PRIORITY]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 /******************************************************************************
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 * Default Handlers
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 *****************************************************************************/
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 purple_command_default_executed_handler(PurpleCommand *command,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 G_GNUC_UNUSED PurpleConversation *conversation,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 G_GNUC_UNUSED GStrv params)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 GDateTime *now = NULL;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GObject *obj = G_OBJECT(command);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 /* We're going to set multiple properties, so we need to freeze property
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 * notifications.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 g_object_freeze_notify(obj);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 /* We use local time as this should be user specific. */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 now = g_date_time_new_now_local();
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 purple_command_set_last_used(command, now);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 birb_date_time_clear(&now);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 if(command->use_count < G_MAXUINT32) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 purple_command_set_use_count(command, command->use_count + 1);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 g_object_thaw_notify(obj);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 /******************************************************************************
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 * GObject Implementation
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 *****************************************************************************/
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 G_DEFINE_FINAL_TYPE(PurpleCommand, purple_command, G_TYPE_OBJECT)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 purple_command_finalize(GObject *obj) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 PurpleCommand *command = PURPLE_COMMAND(obj);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 g_clear_pointer(&command->icon_name, g_free);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 birb_date_time_clear(&command->last_used);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 g_clear_pointer(&command->name, g_free);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 g_clear_pointer(&command->source, g_free);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 g_clear_pointer(&command->summary, g_free);
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
139 g_clear_object(&command->tags);
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 G_OBJECT_CLASS(purple_command_parent_class)->finalize(obj);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 purple_command_get_property(GObject *obj, guint param_id, GValue *value,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 GParamSpec *pspec)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 PurpleCommand *command = PURPLE_COMMAND(obj);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 switch(param_id) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 case PROP_ICON_NAME:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 g_value_set_string(value, purple_command_get_icon_name(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 case PROP_LAST_USED:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 g_value_set_boxed(value, purple_command_get_last_used(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 case PROP_NAME:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 g_value_set_string(value, purple_command_get_name(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 case PROP_PRIORITY:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 g_value_set_int(value, purple_command_get_priority(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 case PROP_SOURCE:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 g_value_set_string(value, purple_command_get_source(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 case PROP_SUMMARY:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 g_value_set_string(value, purple_command_get_summary(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 break;
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
169 case PROP_TAGS:
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
170 g_value_set_object(value, purple_command_get_tags(command));
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
171 break;
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 case PROP_USE_COUNT:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 g_value_set_uint(value, purple_command_get_use_count(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 default:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 purple_command_set_property(GObject *obj, guint param_id, const GValue *value,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 GParamSpec *pspec)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 PurpleCommand *command = PURPLE_COMMAND(obj);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 switch(param_id) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 case PROP_ICON_NAME:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 purple_command_set_icon_name(command, g_value_get_string(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 case PROP_LAST_USED:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 purple_command_set_last_used(command, g_value_get_boxed(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 case PROP_NAME:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 purple_command_set_name(command, g_value_get_string(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 case PROP_PRIORITY:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 purple_command_set_priority(command, g_value_get_int(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 case PROP_SOURCE:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 purple_command_set_source(command, g_value_get_string(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 case PROP_SUMMARY:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 purple_command_set_summary(command, g_value_get_string(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 case PROP_USE_COUNT:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 purple_command_set_use_count(command, g_value_get_uint(value));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 default:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 break;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 static void
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
216 purple_command_init(PurpleCommand *command) {
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
217 command->tags = purple_tags_new();
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 static void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 purple_command_class_init(PurpleCommandClass *klass) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 obj_class->finalize = purple_command_finalize;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 obj_class->get_property = purple_command_get_property;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 obj_class->set_property = purple_command_set_property;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 * PurpleCommand:icon-name:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 * The icon name for the command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 properties[PROP_ICON_NAME] = g_param_spec_string(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 "icon-name", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 * PurpleCommand:last-used:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 * The date time of when the command was last used.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 properties[PROP_LAST_USED] = g_param_spec_boxed(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 "last-used", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 G_TYPE_DATE_TIME,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 * PurpleCommand:name:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 * The name of the command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 * This is what the user would type after the prefix that the user
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 * interface is using. If the user interface is using `/`, then this would
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 * be `me` for the `/me` command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 properties[PROP_NAME] = g_param_spec_string(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 "name", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 * PurpleCommand:priority:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 * The priority for the command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 * If multiple commands have the same name, this will be used to determine
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 * which one to return or sort first. Higher values will have higher
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 * priority.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 properties[PROP_PRIORITY] = g_param_spec_int(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 "priority", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 G_MININT32, G_MAXINT32, 0,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 * PurpleCommand:source:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 * The source of the command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 * This is a user visible string that user interfaces can display to help
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 * users determine what this command is from. For example, this could be
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 * `IRC`, `XMPP`, `my cool plugin`, etc.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 properties[PROP_SOURCE] = g_param_spec_string(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 "source", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 * PurpleCommand:summary:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 * A summary of the command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 * This is a user visible string that user interfaces can display to help
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 * users determine what this command will do.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 properties[PROP_SUMMARY] = g_param_spec_string(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 "summary", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 /**
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
316 * PurpleCommand:tags:
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
317 *
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
318 * The [class@Tags] for the command.
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
319 *
43053
f2f944ac775c Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents: 42967
diff changeset
320 * These tags will be used with [property@Conversation:tags] in a call to
f2f944ac775c Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents: 42967
diff changeset
321 * [method@Tags.contains] to determine if the command is valid for a
f2f944ac775c Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents: 42967
diff changeset
322 * conversation. Likewise, if this doesn't contain any tags, it will match
f2f944ac775c Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents: 42967
diff changeset
323 * all conversations.
f2f944ac775c Implement Purple.CommandManager
Gary Kramlich <grim@reaperworld.com>
parents: 42967
diff changeset
324 *
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
325 * Since: 3.0
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
326 */
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
327 properties[PROP_TAGS] = g_param_spec_object(
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
328 "tags", NULL, NULL,
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
329 PURPLE_TYPE_TAGS,
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
330 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
331
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
332 /**
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 * PurpleCommand:use-count:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 * The count of how many times the command has been used.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 properties[PROP_USE_COUNT] = g_param_spec_uint(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 "use-count", NULL, NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 0, G_MAXUINT32, 0,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 /**
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 * PurpleCommand::executed:
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 * @command: The instance.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 * @conversation: (nullable): The conversation this command was run from.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 * @params: (nullable): The parameters passed to the command.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 * Emitted when [method@Command.execute] is called.
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 * Since: 3.0
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 */
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 signals[SIG_EXECUTED] = g_signal_new_class_handler(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 "executed",
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 G_OBJECT_CLASS_TYPE(klass),
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 G_SIGNAL_RUN_LAST,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 G_CALLBACK(purple_command_default_executed_handler),
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 NULL,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 G_TYPE_NONE,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 2,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 PURPLE_TYPE_CONVERSATION,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 G_TYPE_STRV);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 /******************************************************************************
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 * Public API
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 *****************************************************************************/
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 purple_command_execute(PurpleCommand *command,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 PurpleConversation *conversation, const char *params)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 GStrv paramsv = NULL;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 if(params != NULL) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 paramsv = g_strsplit(params, " ", -1);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 purple_command_executev(command, conversation, paramsv);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 g_clear_pointer(&paramsv, g_strfreev);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 purple_command_executev(PurpleCommand *command,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 PurpleConversation *conversation, GStrv params)
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 g_signal_emit(G_OBJECT(command), signals[SIG_EXECUTED], 0, conversation,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 params);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 const char *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 purple_command_get_icon_name(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 g_return_val_if_fail(PURPLE_IS_COMMAND(command), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 return command->icon_name;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 GDateTime *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 purple_command_get_last_used(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 g_return_val_if_fail(PURPLE_IS_COMMAND(command), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 return command->last_used;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 const char *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 purple_command_get_name(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 g_return_val_if_fail(PURPLE_IS_COMMAND(command), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 return command->name;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 int
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 purple_command_get_priority(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423 g_return_val_if_fail(PURPLE_IS_COMMAND(command), 0);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
425 return command->priority;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
426 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
427
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 const char *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 purple_command_get_source(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 g_return_val_if_fail(PURPLE_IS_COMMAND(command), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432 return command->source;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 const char *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 purple_command_get_summary(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 g_return_val_if_fail(PURPLE_IS_COMMAND(command), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439 return command->summary;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441
42967
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
442 PurpleTags *
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
443 purple_command_get_tags(PurpleCommand *command) {
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
444 g_return_val_if_fail(PURPLE_IS_COMMAND(command), NULL);
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
445
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
446 return command->tags;
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
447 }
9da19bb7e207 Add a tags property to Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents: 42964
diff changeset
448
42964
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449 guint
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 purple_command_get_use_count(PurpleCommand *command) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451 g_return_val_if_fail(PURPLE_IS_COMMAND(command), 0);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453 return command->use_count;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 PurpleCommand *
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 purple_command_new(const char *name, const char *source, int priority) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
458 g_return_val_if_fail(!purple_strempty(name), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 g_return_val_if_fail(!purple_strempty(source), NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 return g_object_new(
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 PURPLE_TYPE_COMMAND,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 "name", name,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 "source", source,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465 "priority", priority,
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 NULL);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
470 purple_command_set_icon_name(PurpleCommand *command, const char *icon_name) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
472
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
473 if(g_set_str(&command->icon_name, icon_name)) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
474 g_object_notify_by_pspec(G_OBJECT(command),
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 properties[PROP_ICON_NAME]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479 void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480 purple_command_set_last_used(PurpleCommand *command, GDateTime *last_used) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
482
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
483 if(birb_date_time_set(&command->last_used, last_used)) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
484 g_object_notify_by_pspec(G_OBJECT(command),
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
485 properties[PROP_LAST_USED]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
486 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
487 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
488
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
489 void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
490 purple_command_set_summary(PurpleCommand *command, const char *summary) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493 if(g_set_str(&command->summary, summary)) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
494 g_object_notify_by_pspec(G_OBJECT(command), properties[PROP_SUMMARY]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
495 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
496 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498 void
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
499 purple_command_set_use_count(PurpleCommand *command, guint use_count) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
500 g_return_if_fail(PURPLE_IS_COMMAND(command));
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
501
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
502 if(command->use_count != use_count) {
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
503 command->use_count = use_count;
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
504
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
505 g_object_notify_by_pspec(G_OBJECT(command),
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
506 properties[PROP_USE_COUNT]);
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
507 }
f0edc907e018 Implement Purple.Command
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508 }

mercurial