pidgin/pidginui.c

Thu, 26 Oct 2023 22:24:08 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 26 Oct 2023 22:24:08 -0500
changeset 42435
ecf0fdfc8363
parent 42410
563e7a17c220
child 42475
ce06ca18db9b
permissions
-rw-r--r--

Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch

This should simplify the process of starting up the history API as it puts the
work into libpurple which will fallback to an in-memory history adapter if the
UI did not provide one.

Testing Done:
Ran the unit tests under valgrind.
Also sent some messages to the echo bot with Pidgin.

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

41867
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib.h>
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include <glib/gi18n.h>
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #define G_SETTINGS_ENABLE_BACKEND
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include <gio/gsettingsbackend.h>
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
42410
563e7a17c220 Fix possible clash of config headers
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42231
diff changeset
29 #include <purpleconfig.h>
41867
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 #include "pidginui.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 #include "gtkblist.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 #include "gtkconv.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 #include "gtkidle.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 #include "gtkmedia.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 #include "gtknotify.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 #include "gtkroomlist.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 #include "gtkrequest.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 #include "gtkwhiteboard.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 #include "gtkxfer.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 #include "pidgincore.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 #include "pidgindebug.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 #include "pidginprefs.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 #include "pidginprivate.h"
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 struct _PidginUi {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PurpleUi parent;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 };
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 G_DEFINE_TYPE(PidginUi, pidgin_ui, PURPLE_TYPE_UI)
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 /******************************************************************************
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 * Helpers
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 *****************************************************************************/
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 pidgin_ui_add_protocol_theme_paths(PurpleProtocol *protocol) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 GdkDisplay *display = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 GtkIconTheme *theme = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 const gchar *path = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 display = gdk_display_get_default();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 theme = gtk_icon_theme_get_for_display(display);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 path = purple_protocol_get_icon_search_path(protocol);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 if(path != NULL) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 gtk_icon_theme_add_search_path(theme, path);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 path = purple_protocol_get_icon_resource_path(protocol);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 if(path != NULL) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 gtk_icon_theme_add_resource_path(theme, path);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 /******************************************************************************
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 * Callbacks
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 *****************************************************************************/
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 pidgin_ui_protocol_foreach_theme_cb(PurpleProtocol *protocol,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 G_GNUC_UNUSED gpointer data)
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 pidgin_ui_add_protocol_theme_paths(protocol);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 pidgin_ui_protocol_registered_cb(G_GNUC_UNUSED PurpleProtocolManager *manager,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 PurpleProtocol *protocol)
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 pidgin_ui_add_protocol_theme_paths(protocol);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 /******************************************************************************
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 * PurpleUi Implementation
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 *****************************************************************************/
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 pidgin_ui_prefs_init(G_GNUC_UNUSED PurpleUi *ui) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 pidgin_prefs_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101
41873
98c20aec9aba Make PurpleUi.start return a gboolean and GError
Gary Kramlich <grim@reaperworld.com>
parents: 41867
diff changeset
102 static gboolean
42435
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
103 pidgin_ui_start(G_GNUC_UNUSED PurpleUi *ui, G_GNUC_UNUSED GError **error) {
41867
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 PurpleProtocolManager *protocol_manager = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 GdkDisplay *display = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GtkIconTheme *theme = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 gchar *path;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 pidgin_debug_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 display = gdk_display_get_default();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 theme = gtk_icon_theme_get_for_display(display);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 path = g_build_filename(PURPLE_DATADIR, "pidgin", "icons", NULL);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 gtk_icon_theme_add_search_path(theme, path);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 g_free(path);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 /* Add a callback for when a protocol is registered to add its icon paths
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 * if it was found after initial startup.
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 */
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 protocol_manager = purple_protocol_manager_get_default();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 g_signal_connect(protocol_manager, "registered",
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 G_CALLBACK(pidgin_ui_protocol_registered_cb), NULL);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 /* Add the icon paths for all the protocols that libpurple found at start
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 * up.
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 */
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 purple_protocol_manager_foreach(protocol_manager,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 pidgin_ui_protocol_foreach_theme_cb, NULL);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 /* Set the UI operation structures. */
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 purple_xfers_set_ui_ops(pidgin_xfers_get_ui_ops());
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 purple_blist_set_ui(PIDGIN_TYPE_BUDDY_LIST);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 purple_notify_set_ui_ops(pidgin_notify_get_ui_ops());
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 purple_request_set_ui_ops(pidgin_request_get_ui_ops());
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 purple_whiteboard_set_ui_ops(pidgin_whiteboard_get_ui_ops());
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 purple_idle_set_ui(pidgin_idle_new());
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 pidgin_request_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 pidgin_conversations_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 pidgin_commands_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 pidgin_xfers_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 pidgin_roomlist_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 pidgin_medias_init();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 pidgin_notify_init();
41873
98c20aec9aba Make PurpleUi.start return a gboolean and GError
Gary Kramlich <grim@reaperworld.com>
parents: 41867
diff changeset
146
98c20aec9aba Make PurpleUi.start return a gboolean and GError
Gary Kramlich <grim@reaperworld.com>
parents: 41867
diff changeset
147 return TRUE;
41867
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 pidgin_ui_stop(G_GNUC_UNUSED PurpleUi *ui) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 /* Be sure to close all windows that are not attached to anything
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 * (e.g., the debug window), or they may access things after they are
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 * shut down. */
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 pidgin_notify_uninit();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 pidgin_commands_uninit();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 pidgin_conversations_uninit();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 pidgin_request_uninit();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 pidgin_xfers_uninit();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 pidgin_debug_window_hide();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 pidgin_debug_uninit();
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 /* and end it all... */
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 g_application_quit(g_application_get_default());
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 static gpointer
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 pidgin_ui_get_settings_backend(G_GNUC_UNUSED PurpleUi *ui) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 GSettingsBackend *backend = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 char *config = NULL;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 config = g_build_filename(purple_config_dir(), "pidgin3.ini", NULL);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 backend = g_keyfile_settings_backend_new(config, "/", NULL);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 g_free(config);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 return backend;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
42435
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
180 static PurpleHistoryAdapter *
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
181 pidgin_ui_get_history_adapter(G_GNUC_UNUSED PurpleUi *ui) {
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
182 PurpleHistoryAdapter *adapter = NULL;
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
183 char *filename = NULL;
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
184
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
185 g_mkdir_with_parents(purple_config_dir(), 0700);
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
186
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
187 filename = g_build_filename(purple_config_dir(), "history.db", NULL);
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
188 adapter = purple_sqlite_history_adapter_new(filename);
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
189 g_free(filename);
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
190
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
191 return adapter;
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
192 }
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
193
41867
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 /******************************************************************************
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 * GObject Implementation
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 *****************************************************************************/
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 pidgin_ui_init(G_GNUC_UNUSED PidginUi *ui) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 static void
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 pidgin_ui_class_init(PidginUiClass *klass) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 PurpleUiClass *ui_class = PURPLE_UI_CLASS(klass);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 ui_class->prefs_init = pidgin_ui_prefs_init;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 ui_class->start = pidgin_ui_start;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 ui_class->stop = pidgin_ui_stop;
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 ui_class->get_settings_backend = pidgin_ui_get_settings_backend;
42435
ecf0fdfc8363 Add a get_history_adapter method to PurpleUi and implement in Pidgin and Finch
Gary Kramlich <grim@reaperworld.com>
parents: 42410
diff changeset
209 ui_class->get_history_adapter = pidgin_ui_get_history_adapter;
41867
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 }
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 /******************************************************************************
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 * Public UI
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 *****************************************************************************/
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 PurpleUi *
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 pidgin_ui_new(void) {
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 return g_object_new(
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 PIDGIN_TYPE_UI,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 "id", "pidgin3",
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 "name", PIDGIN_NAME,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 "version", VERSION,
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 "website", "https://pidgin.im",
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 "support-website", "https://pidgin.im/contact/",
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 "client-type", "pc",
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 NULL);
5375c1d58c50 Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 }

mercurial