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