pidgin/pidginnotificationlink.c

Sat, 09 Aug 2025 18:12:31 +0800

author
Gong Zhile <gongzl@stu.hebust.edu.cn>
date
Sat, 09 Aug 2025 18:12:31 +0800
branch
gir-dependency
changeset 43305
4ede49515766
parent 42951
37816f063275
permissions
-rw-r--r--

Add builtin library dependency for introspection

Without specifying, gir defaults to the system pidgin/purple libraries by default,
which fails the build when new symbols were added and gir failed to link for them.

42951
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidgin/pidginnotificationlink.h"
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PidginNotificationLink {
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 PidginNotification parent;
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 };
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 G_DEFINE_FINAL_TYPE(PidginNotificationLink, pidgin_notification_link,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PIDGIN_TYPE_NOTIFICATION)
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 /******************************************************************************
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 * Actions
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 *****************************************************************************/
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 static void
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 pidgin_notification_link_open_uri(GtkWidget *self,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 G_GNUC_UNUSED const char *action_name,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 G_GNUC_UNUSED GVariant *parameter)
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 {
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PidginNotification *pidgin_notification = PIDGIN_NOTIFICATION(self);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PurpleNotification *purple_notification = NULL;
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PurpleNotificationLink *link = NULL;
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 PurpleUi *ui = NULL;
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 const char *uri = NULL;
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 purple_notification = pidgin_notification_get_notification(pidgin_notification);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 purple_notification_set_read(purple_notification, TRUE);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 link = PURPLE_NOTIFICATION_LINK(purple_notification);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 uri = purple_notification_link_get_link_uri(link);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 ui = purple_core_get_ui();
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 purple_ui_open_uri(ui, uri, NULL, NULL, NULL);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 }
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 /******************************************************************************
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 * GObject Implementation
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 *****************************************************************************/
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 static void
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 pidgin_notification_link_init(PidginNotificationLink *notification) {
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 gtk_widget_init_template(GTK_WIDGET(notification));
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 }
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 static void
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 pidgin_notification_link_class_init(PidginNotificationLinkClass *klass) {
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 gtk_widget_class_set_template_from_resource(
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 widget_class,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 "/im/pidgin/Pidgin3/notificationlink.ui"
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 );
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 gtk_widget_class_install_action(widget_class, "uri.open",
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 NULL,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 pidgin_notification_link_open_uri);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 }
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 /******************************************************************************
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 * API
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 *****************************************************************************/
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 GtkWidget *
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 pidgin_notification_link_new(PurpleNotification *notification) {
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 g_return_val_if_fail(PURPLE_IS_NOTIFICATION_LINK(notification),
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 NULL);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 return g_object_new(
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 PIDGIN_TYPE_NOTIFICATION_LINK,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 "notification", notification,
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 NULL);
37816f063275 Create Pidgin.NotificationLink for displaying Purple.NotificationLink's
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }

mercurial