all: Add debug topics.
Favorites and status icon debugging messages can get overwhelming,
so this lets one choose only those messages pertaining to whatever
is being debugged.
Similar to nemo, to get a list of topics you can do:
XAPP_DEBUG=help <xapp_program>
To enable these topics:
XAPP_DEBUG=StatusIcon <xapp_program>
Note you probably also need to enable the debugging log level as
well, something like:
XAPP_DEBUG=StatusIcon G_MESSAGES_DEBUG=all <xapp_program>
Note: xapp-sn-watcher has a gsettings key to set G_MESSAGES_DEBUG.
Michael Webster
3 years ago
0 | 0 | #include "xapp-favorites.h" |
1 | 1 | #include "favorite-vfs-file-enumerator.h" |
2 | 2 | #include "favorite-vfs-file.h" |
3 | ||
4 | #define DEBUG_FLAG XAPP_DEBUG_FAVORITE_VFS | |
5 | #include "xapp-debug.h" | |
3 | 6 | |
4 | 7 | typedef struct |
5 | 8 | { |
0 | 0 | #include "xapp-favorites.h" |
1 | 1 | #include "favorite-vfs-file.h" |
2 | 2 | #include "favorite-vfs-file-monitor.h" |
3 | ||
4 | #define DEBUG_FLAG XAPP_DEBUG_FAVORITE_VFS | |
5 | #include "xapp-debug.h" | |
3 | 6 | |
4 | 7 | typedef struct |
5 | 8 | { |
53 | 56 | // FavoriteVfsFileMonitor *monitor = FAVORITE_VFS_FILE_MONITOR (user_data); |
54 | 57 | // FavoriteVfsFileMonitorPrivate *priv = favorite_vfs_file_monitor_get_instance_private (monitor); |
55 | 58 | |
56 | // g_debug ("real file changed: %s: %d", g_file_get_uri (file), event_type); | |
59 | // DEBUG ("real file changed: %s: %d", g_file_get_uri (file), event_type); | |
57 | 60 | |
58 | 61 | // switch (event_type) |
59 | 62 | // { |
62 | 65 | // { |
63 | 66 | // gchar *uri = g_file_get_uri (file); |
64 | 67 | |
65 | // g_debug ("Deleted: %s\n", uri); | |
68 | // DEBUG ("Deleted: %s\n", uri); | |
66 | 69 | |
67 | 70 | // xapp_favorites_remove (xapp_favorites_get_default (), uri); |
68 | 71 | // g_free (uri); |
74 | 77 | // { |
75 | 78 | // gchar *uri = g_file_get_uri (file); |
76 | 79 | |
77 | // g_debug ("Renamed: %s\n", uri); | |
80 | // DEBUG ("Renamed: %s\n", uri); | |
78 | 81 | |
79 | 82 | // rename_favorite (file, other_file); |
80 | 83 | // } |
98 | 101 | // uri = path_to_fav_uri (info->display_name); |
99 | 102 | // fav_file = g_file_new_for_uri (uri); |
100 | 103 | |
101 | // g_debug ("Changed: %s", uri); | |
104 | // DEBUG ("Changed: %s", uri); | |
102 | 105 | // g_free (uri); |
103 | 106 | |
104 | 107 | // g_file_monitor_emit_event (G_FILE_MONITOR (monitor), |
166 | 169 | GFile *real_file; |
167 | 170 | GError *error; |
168 | 171 | |
169 | g_debug ("Monitoring real file: %s\n", info->uri); | |
172 | DEBUG ("Monitoring real file: %s\n", info->uri); | |
170 | 173 | |
171 | 174 | error = NULL; |
172 | 175 | real_file = g_file_new_for_uri (info->uri); |
3 | 3 | #include "favorite-vfs-file.h" |
4 | 4 | #include "favorite-vfs-file-enumerator.h" |
5 | 5 | #include "favorite-vfs-file-monitor.h" |
6 | ||
7 | #define DEBUG_FLAG XAPP_DEBUG_FAVORITE_VFS | |
8 | #include "xapp-debug.h" | |
6 | 9 | |
7 | 10 | #define FAVORITES_SCHEMA "org.x.apps.favorites" |
8 | 11 | #define FAVORITE_DCONF_METADATA_KEY "root-metadata" |
1379 | 1382 | |
1380 | 1383 | new_file = g_object_new (FAVORITE_TYPE_VFS_FILE, NULL); |
1381 | 1384 | |
1382 | g_debug ("FavoriteVfsFile new for uri: %s", uri); | |
1385 | DEBUG ("FavoriteVfsFile new for uri: %s", uri); | |
1383 | 1386 | |
1384 | 1387 | FavoriteVfsFilePrivate *priv = favorite_vfs_file_get_instance_private (FAVORITE_VFS_FILE (new_file)); |
1385 | 1388 |
15 | 15 | 'favorite-vfs-file.c', |
16 | 16 | 'favorite-vfs-file-enumerator.c', |
17 | 17 | 'favorite-vfs-file-monitor.c' |
18 | ] | |
19 | ||
20 | xapp_debug = [ | |
21 | 'xapp-debug.h', | |
22 | 'xapp-debug.c' | |
18 | 23 | ] |
19 | 24 | |
20 | 25 | xapp_headers = [ |
94 | 99 | ) |
95 | 100 | |
96 | 101 | libxapp = library('xapp', |
97 | sources : xapp_headers + xapp_sources + xapp_enums + dbus_headers + favorite_vfs_sources, | |
102 | sources : xapp_headers + xapp_sources + xapp_enums + dbus_headers + favorite_vfs_sources + xapp_debug, | |
98 | 103 | include_directories: [top_inc], |
99 | 104 | version: meson.project_version(), |
100 | 105 | soversion: '1', |
0 | /* | |
1 | * xapp-debug: debug loggers for xapp | |
2 | * | |
3 | * Copyright (C) 2007 Collabora Ltd. | |
4 | * Copyright (C) 2007 Nokia Corporation | |
5 | * Copyright (C) 2010 Red Hat, Inc. | |
6 | * | |
7 | * This library is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2.1 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This library is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * Lesser General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public | |
18 | * License along with this library; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | * | |
21 | * Copied from nemo | |
22 | */ | |
23 | ||
24 | #include <stdarg.h> | |
25 | ||
26 | #include <glib.h> | |
27 | ||
28 | #include "xapp-debug.h" | |
29 | ||
30 | static DebugFlags flags = 0; | |
31 | static gboolean initialized = FALSE; | |
32 | ||
33 | static GDebugKey keys[] = { | |
34 | { "GtkWindow", XAPP_DEBUG_WINDOW }, | |
35 | { "Favorites", XAPP_DEBUG_FAVORITES }, | |
36 | { "FavoriteVfs", XAPP_DEBUG_FAVORITE_VFS }, | |
37 | { "StatusIcon", XAPP_DEBUG_STATUS_ICON }, | |
38 | { "SnWatcher", XAPP_DEBUG_SN_WATCHER }, | |
39 | { "GtkModule", XAPP_DEBUG_MODULE}, | |
40 | { 0, } | |
41 | }; | |
42 | ||
43 | static void | |
44 | xapp_debug_set_flags_from_env (void) | |
45 | { | |
46 | guint nkeys; | |
47 | const gchar *flags_string; | |
48 | ||
49 | for (nkeys = 0; keys[nkeys].value; nkeys++); | |
50 | ||
51 | flags_string = g_getenv ("XAPP_DEBUG"); | |
52 | ||
53 | if (flags_string) | |
54 | xapp_debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); | |
55 | ||
56 | initialized = TRUE; | |
57 | } | |
58 | ||
59 | void | |
60 | xapp_debug_set_flags (DebugFlags new_flags) | |
61 | { | |
62 | flags |= new_flags; | |
63 | initialized = TRUE; | |
64 | } | |
65 | ||
66 | gboolean | |
67 | xapp_debug_flag_is_set (DebugFlags flag) | |
68 | { | |
69 | return flag & flags; | |
70 | } | |
71 | ||
72 | void | |
73 | xapp_debug (DebugFlags flag, | |
74 | const gchar *format, | |
75 | ...) | |
76 | { | |
77 | va_list args; | |
78 | va_start (args, format); | |
79 | xapp_debug_valist (flag, format, args); | |
80 | va_end (args); | |
81 | } | |
82 | ||
83 | void | |
84 | xapp_debug_valist (DebugFlags flag, | |
85 | const gchar *format, | |
86 | va_list args) | |
87 | { | |
88 | if (G_UNLIKELY(!initialized)) | |
89 | xapp_debug_set_flags_from_env (); | |
90 | ||
91 | if (flag & flags) | |
92 | g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); | |
93 | } | |
94 |
0 | /* | |
1 | * xapp-debug: debug loggers for xapp | |
2 | * | |
3 | * Copyright (C) 2007 Collabora Ltd. | |
4 | * Copyright (C) 2007 Nokia Corporation | |
5 | * Copyright (C) 2010 Red Hat, Inc. | |
6 | * | |
7 | * This library is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2.1 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This library is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * Lesser General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public | |
18 | * License along with this library; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | * | |
21 | * Copied from nemo | |
22 | */ | |
23 | ||
24 | #ifndef __XAPP_DEBUG_H__ | |
25 | #define __XAPP_DEBUG_H__ | |
26 | ||
27 | #include <config.h> | |
28 | #include <glib.h> | |
29 | ||
30 | G_BEGIN_DECLS | |
31 | ||
32 | typedef enum | |
33 | { | |
34 | XAPP_DEBUG_WINDOW = 1 << 1, | |
35 | XAPP_DEBUG_FAVORITES = 1 << 2, | |
36 | XAPP_DEBUG_FAVORITE_VFS = 1 << 3, | |
37 | XAPP_DEBUG_STATUS_ICON = 1 << 4, | |
38 | XAPP_DEBUG_SN_WATCHER = 1 << 5, | |
39 | XAPP_DEBUG_MODULE = 1 << 6 | |
40 | } DebugFlags; | |
41 | ||
42 | void xapp_debug_set_flags (DebugFlags flags); | |
43 | gboolean xapp_debug_flag_is_set (DebugFlags flag); | |
44 | ||
45 | void xapp_debug_valist (DebugFlags flag, | |
46 | const gchar *format, va_list args); | |
47 | ||
48 | void xapp_debug (DebugFlags flag, const gchar *format, ...) | |
49 | G_GNUC_PRINTF (2, 3); | |
50 | ||
51 | #ifdef DEBUG_FLAG | |
52 | ||
53 | #define DEBUG(format, ...) \ | |
54 | xapp_debug (DEBUG_FLAG, "%s: %s: " format, G_STRFUNC, G_STRLOC, \ | |
55 | ##__VA_ARGS__) | |
56 | ||
57 | #define DEBUGGING xapp_debug_flag_is_set(DEBUG_FLAG) | |
58 | ||
59 | #endif /* DEBUG_FLAG */ | |
60 | ||
61 | #else /* ENABLE_DEBUG */ | |
62 | ||
63 | #ifdef DEBUG_FLAG | |
64 | ||
65 | #define DEBUG(format, ...) \ | |
66 | G_STMT_START { } G_STMT_END | |
67 | ||
68 | #define DEBUGGING 0 | |
69 | ||
70 | #endif /* DEBUG_FLAG */ | |
71 | ||
72 | G_END_DECLS | |
73 | ||
74 | #endif /* __XAPP_DEBUG_H__ */ |
18 | 18 | #include "xapp-favorites.h" |
19 | 19 | #include "favorite-vfs-file.h" |
20 | 20 | |
21 | #define DEBUG_FLAG XAPP_DEBUG_FAVORITES | |
22 | #include "xapp-debug.h" | |
23 | ||
21 | 24 | #define FAVORITES_SCHEMA "org.x.apps.favorites" |
22 | 25 | #define FAVORITES_KEY "list" |
23 | 26 | #define SETTINGS_DELIMITER "::" |
55 | 58 | XAppFavoriteInfo * |
56 | 59 | xapp_favorite_info_copy (const XAppFavoriteInfo *info) |
57 | 60 | { |
58 | // g_debug ("XAppFavoriteInfo: copy"); | |
61 | // DEBUG ("XAppFavoriteInfo: copy"); | |
59 | 62 | g_return_val_if_fail (info != NULL, NULL); |
60 | 63 | |
61 | 64 | XAppFavoriteInfo *_info = g_slice_dup (XAppFavoriteInfo, info); |
77 | 80 | void |
78 | 81 | xapp_favorite_info_free (XAppFavoriteInfo *info) |
79 | 82 | { |
80 | g_debug ("XAppFavoriteInfo free (%s)", info->uri); | |
83 | DEBUG ("XAppFavoriteInfo free (%s)", info->uri); | |
81 | 84 | g_return_if_fail (info != NULL); |
82 | 85 | |
83 | 86 | g_free (info->uri); |
124 | 127 | XAppFavorites *favorites = XAPP_FAVORITES (data); |
125 | 128 | |
126 | 129 | XAppFavoritesPrivate *priv = xapp_favorites_get_instance_private (favorites); |
127 | g_debug ("XAppFavorites: list updated, emitting changed signal"); | |
130 | DEBUG ("XAppFavorites: list updated, emitting changed signal"); | |
128 | 131 | |
129 | 132 | priv->changed_timer_id = 0; |
130 | 133 | g_signal_emit (favorites, signals[CHANGED], 0); |
203 | 206 | GFileInfo *info; |
204 | 207 | GFile *file; |
205 | 208 | |
206 | g_debug ("Sync metadata: %s - Favorite? %d", uri, is_favorite); | |
209 | DEBUG ("Sync metadata: %s - Favorite? %d", uri, is_favorite); | |
207 | 210 | |
208 | 211 | info = g_file_info_new (); |
209 | 212 | |
263 | 266 | g_settings_set_strv (priv->settings, FAVORITES_KEY, (const gchar* const*) new_settings); |
264 | 267 | g_signal_handler_unblock (priv->settings, priv->settings_listener_id); |
265 | 268 | |
266 | g_debug ("XAppFavorites: store_favorites: favorites saved"); | |
269 | DEBUG ("XAppFavorites: store_favorites: favorites saved"); | |
267 | 270 | |
268 | 271 | g_strfreev (new_settings); |
269 | 272 | } |
306 | 309 | |
307 | 310 | g_strfreev (raw_list); |
308 | 311 | |
309 | g_debug ("XAppFavorites: load_favorite: favorites loaded (%d)", i); | |
312 | DEBUG ("XAppFavorites: load_favorite: favorites loaded (%d)", i); | |
310 | 313 | |
311 | 314 | if (signal_changed) |
312 | 315 | { |
403 | 406 | |
404 | 407 | g_return_if_fail (real_uri != NULL); |
405 | 408 | |
406 | g_debug ("XAppFavorites: remove favorite: %s", real_uri); | |
409 | DEBUG ("XAppFavorites: remove favorite: %s", real_uri); | |
407 | 410 | |
408 | 411 | // It may be orphaned for some reason.. even if it's not in gsettings, still try |
409 | 412 | // to remove the favorite attribute. |
411 | 414 | |
412 | 415 | if (!g_hash_table_remove (priv->infos, real_uri)) |
413 | 416 | { |
414 | g_debug ("XAppFavorites: remove_favorite: could not find favorite for uri '%s'", real_uri); | |
417 | DEBUG ("XAppFavorites: remove_favorite: could not find favorite for uri '%s'", real_uri); | |
415 | 418 | g_free (real_uri); |
416 | 419 | return; |
417 | 420 | } |
595 | 598 | // Check if it's there again, in case it was added while we were getting mimetype. |
596 | 599 | if (g_hash_table_contains (priv->infos, uri)) |
597 | 600 | { |
598 | g_debug ("XAppFavorites: favorite for '%s' exists, ignoring", uri); | |
601 | DEBUG ("XAppFavorites: favorite for '%s' exists, ignoring", uri); | |
599 | 602 | return; |
600 | 603 | } |
601 | 604 | |
610 | 613 | |
611 | 614 | g_hash_table_insert (priv->infos, (gpointer) g_strdup (uri), (gpointer) info); |
612 | 615 | |
613 | g_debug ("XAppFavorites: added favorite: %s", uri); | |
616 | DEBUG ("XAppFavorites: added favorite: %s", uri); | |
614 | 617 | |
615 | 618 | deduplicate_display_names (favorites, priv->infos); |
616 | 619 | |
643 | 646 | |
644 | 647 | if (error) |
645 | 648 | { |
646 | g_debug ("XAppFavorites: problem trying to figure out content type for uri '%s': %s", | |
649 | DEBUG ("XAppFavorites: problem trying to figure out content type for uri '%s': %s", | |
647 | 650 | uri, error->message); |
648 | 651 | g_error_free (error); |
649 | 652 | } |
680 | 683 | |
681 | 684 | if (g_hash_table_contains (priv->infos, uri)) |
682 | 685 | { |
683 | g_debug ("XAppFavorites: favorite for '%s' exists, ignoring", uri); | |
686 | DEBUG ("XAppFavorites: favorite for '%s' exists, ignoring", uri); | |
684 | 687 | return; |
685 | 688 | } |
686 | 689 | |
710 | 713 | { |
711 | 714 | XAppFavoritesPrivate *priv = xapp_favorites_get_instance_private (favorites); |
712 | 715 | |
713 | g_debug ("XAppFavorites: init:"); | |
716 | DEBUG ("XAppFavorites: init:"); | |
714 | 717 | |
715 | 718 | priv->settings = g_settings_new (FAVORITES_SCHEMA); |
716 | 719 | priv->settings_listener_id = g_signal_connect (priv->settings, |
727 | 730 | XAppFavorites *favorites = XAPP_FAVORITES (object); |
728 | 731 | XAppFavoritesPrivate *priv = xapp_favorites_get_instance_private (favorites); |
729 | 732 | |
730 | g_debug ("XAppFavorites dispose (%p)", object); | |
733 | DEBUG ("XAppFavorites dispose (%p)", object); | |
731 | 734 | |
732 | 735 | g_clear_object (&priv->settings); |
733 | 736 | g_clear_pointer (&priv->infos, g_hash_table_destroy); |
738 | 741 | static void |
739 | 742 | xapp_favorites_finalize (GObject *object) |
740 | 743 | { |
741 | g_debug ("XAppFavorites finalize (%p)", object); | |
744 | DEBUG ("XAppFavorites finalize (%p)", object); | |
742 | 745 | |
743 | 746 | G_OBJECT_CLASS (xapp_favorites_parent_class)->finalize (object); |
744 | 747 | } |
848 | 851 | ret = g_list_reverse (data.items); |
849 | 852 | |
850 | 853 | gchar *typestring = mimetypes ? g_strjoinv (", ", (gchar **) mimetypes) : NULL; |
851 | g_debug ("XAppFavorites: get_favorites returning list for mimetype '%s' (%d items)", | |
854 | DEBUG ("XAppFavorites: get_favorites returning list for mimetype '%s' (%d items)", | |
852 | 855 | typestring, g_list_length (ret)); |
853 | 856 | g_free (typestring); |
854 | 857 | |
872 | 875 | |
873 | 876 | n = g_hash_table_size (priv->infos); |
874 | 877 | |
875 | g_debug ("XAppFavorites: get_n_favorites returning number of items: %d.", n); | |
878 | DEBUG ("XAppFavorites: get_n_favorites returning number of items: %d.", n); | |
876 | 879 | |
877 | 880 | return n; |
878 | 881 | } |
1010 | 1013 | { |
1011 | 1014 | if (error) |
1012 | 1015 | { |
1013 | g_debug ("XAppFavorites: launch: error opening uri '%s': %s", uri, error->message); | |
1016 | DEBUG ("XAppFavorites: launch: error opening uri '%s': %s", uri, error->message); | |
1014 | 1017 | g_error_free (error); |
1015 | 1018 | } |
1016 | 1019 | } |
10 | 10 | #include <gdk/gdkx.h> |
11 | 11 | #include "xapp-gtk-window.h" |
12 | 12 | |
13 | #define DEBUG_FLAG XAPP_DEBUG_WINDOW | |
14 | #include "xapp-debug.h" | |
15 | ||
13 | 16 | #define ICON_NAME_HINT "_NET_WM_XAPP_ICON_NAME" |
14 | 17 | #define PROGRESS_HINT "_NET_WM_XAPP_PROGRESS" |
15 | 18 | #define PROGRESS_PULSE_HINT "_NET_WM_XAPP_PROGRESS_PULSE" |
71 | 74 | if (g_once_init_enter (&once_init_value)) |
72 | 75 | { |
73 | 76 | running_x11 = GDK_IS_X11_DISPLAY(gdk_display_get_default()); |
74 | g_debug ("XAppGtkWindow: is_x11_session: %s\n", running_x11 ? "TRUE" : "FALSE"); | |
77 | DEBUG ("XAppGtkWindow: is_x11_session: %s\n", running_x11 ? "TRUE" : "FALSE"); | |
75 | 78 | |
76 | 79 | g_once_init_leave (&once_init_value, 1); |
77 | 80 | } |
2 | 2 | |
3 | 3 | #include "xapp-favorites.h" |
4 | 4 | #include "favorite-vfs-file.h" |
5 | ||
6 | #define DEBUG_FLAG XAPP_DEBUG_MODULE | |
7 | #include "xapp-debug.h" | |
5 | 8 | |
6 | 9 | #define ICON_OVERRIDE_VAR "XAPP_FORCE_GTKWINDOW_ICON" |
7 | 10 | |
56 | 59 | |
57 | 60 | if (anti_recursion_ptr && anti_recursion_ptr == gtk_window_get_icon (window)) |
58 | 61 | { |
59 | g_debug ("Window icon notify received, but anti-recurse pointer hasn't changed, returning."); | |
62 | DEBUG ("Window icon notify received, but anti-recurse pointer hasn't changed, returning."); | |
60 | 63 | return; |
61 | 64 | } |
62 | 65 | |
64 | 67 | { |
65 | 68 | gboolean clear_pixbuf = FALSE; |
66 | 69 | |
67 | g_debug ("Window icon changed, forcing back to '%s'", forced_icon_str); | |
70 | DEBUG ("Window icon changed, forcing back to '%s'", forced_icon_str); | |
68 | 71 | |
69 | 72 | g_signal_handlers_block_by_func (G_OBJECT (window), window_icon_changed, window); |
70 | 73 | |
102 | 105 | |
103 | 106 | already_applied = 1; |
104 | 107 | |
105 | g_debug ("Realize overridden window (%p).", widget); | |
108 | DEBUG ("Realize overridden window (%p).", widget); | |
106 | 109 | |
107 | 110 | const gchar *env_icon = g_getenv (ICON_OVERRIDE_VAR); |
108 | 111 | |
121 | 124 | { |
122 | 125 | (* original_window_unrealize) (widget); |
123 | 126 | |
124 | g_debug ("Unrealize overridden window (%p).", widget); | |
127 | DEBUG ("Unrealize overridden window (%p).", widget); | |
125 | 128 | |
126 | 129 | g_signal_handlers_disconnect_by_func (widget, window_icon_changed, widget); |
127 | 130 | } |
134 | 137 | // I don't think these guards are necessary. This should only run once, but better off safe. |
135 | 138 | if (!applied) |
136 | 139 | { |
137 | g_debug ("XAPP_FORCE_GTKWINDOW_ICON found in environment, overriding the window icon with its contents"); | |
140 | DEBUG ("XAPP_FORCE_GTKWINDOW_ICON found in environment, overriding the window icon with its contents"); | |
138 | 141 | |
139 | 142 | applied = TRUE; |
140 | 143 | |
155 | 158 | |
156 | 159 | if (!applied) |
157 | 160 | { |
158 | g_debug ("Adding a Favorites shortcut to GtkPlacesSideBars"); | |
161 | DEBUG ("Adding a Favorites shortcut to GtkPlacesSideBars"); | |
159 | 162 | |
160 | 163 | applied = TRUE; |
161 | 164 | |
168 | 171 | } |
169 | 172 | |
170 | 173 | G_MODULE_EXPORT void gtk_module_init (gint *argc, gchar ***argv[]) { |
171 | g_debug ("Initializing XApp GtkModule"); | |
174 | DEBUG ("Initializing XApp GtkModule"); | |
172 | 175 | // This won't instantiate XAppFavorites but will register the uri so |
173 | 176 | // it can be used by apps (like pix which doesn't use the favorites api, |
174 | 177 | // but just adds favorites:/// to its sidebar.) |
15 | 15 | #include "xapp-status-icon.h" |
16 | 16 | #include "xapp-status-icon-monitor.h" |
17 | 17 | #include "xapp-statusicon-interface.h" |
18 | ||
19 | #define DEBUG_FLAG XAPP_DEBUG_STATUS_ICON | |
20 | #include "xapp-debug.h" | |
18 | 21 | |
19 | 22 | #define MONITOR_NAME "org.x.StatusIconMonitor" |
20 | 23 | |
84 | 87 | "name", &name, |
85 | 88 | NULL); |
86 | 89 | |
87 | g_debug("XAppStatusIconMonitor: app name owner changed - name '%s' is now %s)", | |
90 | DEBUG("App name owner changed - name '%s' is now %s)", | |
88 | 91 | name, owner != NULL ? "owned" : "unowned"); |
89 | 92 | |
90 | 93 | if (owner == NULL) |
153 | 156 | |
154 | 157 | g_object_get (obj_mgr, "name", &name, NULL); |
155 | 158 | |
156 | g_debug("XAppStatusIconMonitor: Object manager added for new bus name: '%s'", name); | |
159 | DEBUG("Object manager added for new bus name: '%s'", name); | |
157 | 160 | |
158 | 161 | g_signal_connect (obj_mgr, |
159 | 162 | "notify::name-owner", |
210 | 213 | } |
211 | 214 | else |
212 | 215 | { |
213 | g_debug ("XAppStatusIconMonitor: adding object manager failed, bus name '%s' is invalid", name); | |
216 | DEBUG ("Adding object manager failed, bus name '%s' is invalid", name); | |
214 | 217 | } |
215 | 218 | |
216 | 219 | g_strfreev (name_parts); |
247 | 250 | /* the '.' at the end so we don't catch ourselves in this */ |
248 | 251 | if (g_str_has_prefix (str, STATUS_ICON_MATCH)) |
249 | 252 | { |
250 | g_debug ("XAppStatusIconMonitor: found new status icon app: %s", str); | |
253 | DEBUG ("Found new status icon app: %s", str); | |
251 | 254 | add_object_manager_for_name (self, str); |
252 | 255 | } |
253 | 256 | } |
261 | 264 | { |
262 | 265 | XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); |
263 | 266 | |
264 | g_debug("XAppStatusIconMonitor: looking for status icon apps on the bus"); | |
267 | DEBUG("Looking for status icon apps on the bus"); | |
265 | 268 | |
266 | 269 | /* If there are no monitors (applets) already running when this is set up, |
267 | 270 | * this won't find anything. The XAppStatusIcons will be in fallback mode, |
314 | 317 | const gchar *old_owner; |
315 | 318 | const gchar *new_owner; |
316 | 319 | |
317 | g_debug("XAppStatusIconMonitor: NameOwnerChanged signal received: %s)", sender_name); | |
320 | DEBUG ("NameOwnerChanged signal received: %s)", sender_name); | |
318 | 321 | |
319 | 322 | g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner); |
320 | 323 | |
329 | 332 | { |
330 | 333 | XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); |
331 | 334 | |
332 | g_debug ("XAppStatusIconMonitor: Adding NameOwnerChanged listener for status icon apps"); | |
335 | DEBUG ("Adding NameOwnerChanged listener for status icon apps"); | |
333 | 336 | |
334 | 337 | priv->listener_id = g_dbus_connection_signal_subscribe (priv->connection, |
335 | 338 | "org.freedesktop.DBus", |
361 | 364 | { |
362 | 365 | XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); |
363 | 366 | |
364 | g_debug ("XAppStatusIconMonitor: Name owned on bus: %s", name); | |
367 | DEBUG ("Name owned on bus: %s", name); | |
365 | 368 | |
366 | 369 | add_name_listener (self); |
367 | 370 | find_and_add_icons (self); |
376 | 379 | XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (user_data); |
377 | 380 | XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); |
378 | 381 | |
379 | g_debug ("XAppStatusIconMonitor: Connected to bus: %s", name); | |
382 | DEBUG ("Connected to bus: %s", name); | |
380 | 383 | |
381 | 384 | priv->connection = connection; |
382 | 385 | } |
392 | 395 | owned_name = g_strdup_printf ("%s.%s_%d", MONITOR_NAME, valid_app_name, unique_id++); |
393 | 396 | g_free (valid_app_name); |
394 | 397 | |
395 | g_debug ("XAppStatusIconMonitor: Attempting to own name on bus: %s", owned_name); | |
398 | DEBUG ("Attempting to own name on bus: %s", owned_name); | |
396 | 399 | |
397 | 400 | priv->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, |
398 | 401 | owned_name, |
423 | 426 | XAppStatusIconMonitor *self = XAPP_STATUS_ICON_MONITOR (object); |
424 | 427 | XAppStatusIconMonitorPrivate *priv = xapp_status_icon_monitor_get_instance_private (self); |
425 | 428 | |
426 | g_debug ("XAppStatusIconMonitor dispose (%p)", object); | |
429 | DEBUG ("XAppStatusIconMonitor dispose (%p)", object); | |
427 | 430 | |
428 | 431 | if (priv->connection != NULL) |
429 | 432 | { |
454 | 457 | static void |
455 | 458 | xapp_status_icon_monitor_finalize (GObject *object) |
456 | 459 | { |
457 | g_debug ("XAppStatusIconMonitor finalize (%p)", object); | |
460 | DEBUG ("XAppStatusIconMonitor finalize (%p)", object); | |
458 | 461 | |
459 | 462 | G_OBJECT_CLASS (xapp_status_icon_monitor_parent_class)->dispose (object); |
460 | 463 | } |
15 | 15 | #include "xapp-status-icon.h" |
16 | 16 | #include "xapp-statusicon-interface.h" |
17 | 17 | #include "xapp-enums.h" |
18 | ||
19 | #define DEBUG_FLAG XAPP_DEBUG_STATUS_ICON | |
20 | #include "xapp-debug.h" | |
18 | 21 | |
19 | 22 | #define FDO_DBUS_NAME "org.freedesktop.DBus" |
20 | 23 | #define FDO_DBUS_PATH "/org/freedesktop/DBus" |
270 | 273 | g_return_if_fail (XAPP_IS_STATUS_ICON (user_data)); |
271 | 274 | XAppStatusIcon *icon = XAPP_STATUS_ICON (user_data); |
272 | 275 | |
273 | g_debug ("XAppStatusIcon: Primary menu unmapped"); | |
276 | DEBUG ("Primary menu unmapped"); | |
274 | 277 | |
275 | 278 | if (icon->priv->state == XAPP_STATUS_ICON_STATE_NATIVE) |
276 | 279 | { |
287 | 290 | g_return_if_fail (XAPP_IS_STATUS_ICON (user_data)); |
288 | 291 | XAppStatusIcon *icon = XAPP_STATUS_ICON (user_data); |
289 | 292 | |
290 | g_debug ("XAppStatusIcon: Secondary menu unmapped"); | |
293 | DEBUG ("Secondary menu unmapped"); | |
291 | 294 | |
292 | 295 | if (icon->priv->state == XAPP_STATUS_ICON_STATE_NATIVE) |
293 | 296 | { |
311 | 314 | GdkRectangle win_rect; |
312 | 315 | GdkGravity rect_anchor, menu_anchor; |
313 | 316 | |
314 | g_debug ("XAppStatusIcon: Popup menu on behalf of application"); | |
317 | DEBUG ("Popup menu on behalf of application"); | |
315 | 318 | |
316 | 319 | if (!gtk_widget_get_realized (GTK_WIDGET (menu))) |
317 | 320 | { |
438 | 441 | |
439 | 442 | if (g_strcmp0 (name, "ButtonPress") == 0) |
440 | 443 | { |
441 | g_debug ("XAppStatusIcon: received ButtonPress from monitor %s: " | |
444 | DEBUG ("Received ButtonPress from monitor %s: " | |
442 | 445 | "pos:%d,%d , button: %s , time: %u , orientation: %s", |
443 | 446 | g_dbus_method_invocation_get_sender (invocation), |
444 | 447 | x, y, button_to_str (button), _time, panel_position_to_str (panel_position)); |
445 | 448 | |
446 | 449 | if (should_send_activate (icon, button)) |
447 | 450 | { |
448 | g_debug ("XAppStatusIcon: native sending 'activate' for %s button", button_to_str (button)); | |
451 | DEBUG ("Native sending 'activate' for %s button", button_to_str (button)); | |
449 | 452 | g_signal_emit (icon, signals[ACTIVATE], 0, |
450 | 453 | button, |
451 | 454 | _time); |
465 | 468 | else |
466 | 469 | if (g_strcmp0 (name, "ButtonRelease") == 0) |
467 | 470 | { |
468 | g_debug ("XAppStatusIcon: received ButtonRelease from monitor %s: " | |
471 | DEBUG ("Received ButtonRelease from monitor %s: " | |
469 | 472 | "pos:%d,%d , button: %s , time: %u , orientation: %s", |
470 | 473 | g_dbus_method_invocation_get_sender (invocation), |
471 | 474 | x, y, button_to_str (button), _time, panel_position_to_str (panel_position)); |
508 | 511 | guint _time, |
509 | 512 | XAppStatusIcon *icon) |
510 | 513 | { |
511 | g_debug ("XAppStatusIcon: received Scroll from monitor %s: " | |
514 | DEBUG ("Received Scroll from monitor %s: " | |
512 | 515 | "delta: %d , direction: %s , time: %u", |
513 | 516 | g_dbus_method_invocation_get_sender (invocation), |
514 | 517 | delta, direction_to_str (direction), _time); |
605 | 608 | button = event->button.button; |
606 | 609 | _time = event->button.time; |
607 | 610 | |
608 | g_debug ("XAppStatusIcon: GtkStatusIcon button-press-event with %s button", button_to_str (button)); | |
611 | DEBUG ("GtkStatusIcon button-press-event with %s button", button_to_str (button)); | |
609 | 612 | |
610 | 613 | /* We always send 'activate' for a button that has no corresponding menu, |
611 | 614 | * and for middle clicks. */ |
612 | 615 | if (should_send_activate (icon, button)) |
613 | 616 | { |
614 | g_debug ("XAppStatusIcon: GtkStatusIcon activated by %s button", button_to_str (button)); | |
617 | DEBUG ("GtkStatusIcon activated by %s button", button_to_str (button)); | |
615 | 618 | |
616 | 619 | g_signal_emit (icon, signals[ACTIVATE], 0, |
617 | 620 | button, |
649 | 652 | button = event->button.button; |
650 | 653 | _time = event->button.time; |
651 | 654 | |
652 | g_debug ("XAppStatusIcon: GtkStatusIcon button-release-event with %s button", button_to_str (button)); | |
655 | DEBUG ("GtkStatusIcon button-release-event with %s button", button_to_str (button)); | |
653 | 656 | |
654 | 657 | /* Native icons can have two menus, so we must determine which to use based |
655 | 658 | * on the gtk icon event's button. */ |
664 | 667 | |
665 | 668 | if (menu_to_use) |
666 | 669 | { |
667 | g_debug ("XAppStatusIcon: GtkStatusIcon popup menu for %s button", button_to_str (button)); | |
670 | DEBUG ("GtkStatusIcon popup menu for %s button", button_to_str (button)); | |
668 | 671 | |
669 | 672 | popup_menu (icon, |
670 | 673 | GTK_MENU (menu_to_use), |
694 | 697 | gpointer user_data) |
695 | 698 | { |
696 | 699 | XAppStatusIcon *self = XAPP_STATUS_ICON (user_data); |
697 | g_debug("XAppStatusIcon: NameOwnerChanged signal received, refreshing icon"); | |
700 | DEBUG("NameOwnerChanged signal received, refreshing icon"); | |
698 | 701 | |
699 | 702 | refresh_icon (self); |
700 | 703 | } |
702 | 705 | static void |
703 | 706 | add_name_listener (XAppStatusIcon *self) |
704 | 707 | { |
705 | g_debug ("XAppStatusIcon: Adding NameOwnerChanged listener for status monitors"); | |
708 | DEBUG ("Adding NameOwnerChanged listener for status monitors"); | |
706 | 709 | |
707 | 710 | self->priv->listener_id = g_dbus_connection_signal_subscribe (self->priv->connection, |
708 | 711 | FDO_DBUS_NAME, |
762 | 765 | |
763 | 766 | sync_skeleton (self); |
764 | 767 | |
765 | g_debug ("XAppStatusIcon: name acquired on dbus, syncing icon properties. State is now: %s", | |
768 | DEBUG ("Name acquired on dbus, syncing icon properties. State is now: %s", | |
766 | 769 | state_to_str (self->priv->state)); |
767 | 770 | g_signal_emit (self, signals[STATE_CHANGED], 0, self->priv->state); |
768 | 771 | } |
784 | 787 | obj_server_finalized (gpointer data, |
785 | 788 | GObject *object) |
786 | 789 | { |
787 | g_debug ("XAppStatusIcon: Final icon removed, clearing object manager (%s)", g_get_prgname ()); | |
790 | DEBUG ("Final icon removed, clearing object manager (%s)", g_get_prgname ()); | |
788 | 791 | |
789 | 792 | if (name_owner_id > 0) |
790 | 793 | { |
800 | 803 | { |
801 | 804 | if (obj_server == NULL) |
802 | 805 | { |
803 | g_debug ("XAppStatusIcon: New object manager for (%s)", g_get_prgname ()); | |
806 | DEBUG ("New object manager for (%s)", g_get_prgname ()); | |
804 | 807 | |
805 | 808 | obj_server = g_dbus_object_manager_server_new (ICON_BASE_PATH); |
806 | 809 | g_dbus_object_manager_server_set_connection (obj_server, self->priv->connection); |
876 | 879 | |
877 | 880 | if (name_owner_id == 0) |
878 | 881 | { |
879 | g_debug ("XAppStatusIcon: Attempting to own name on bus '%s'", owner_name); | |
882 | DEBUG ("Attempting to own name on bus '%s'", owner_name); | |
880 | 883 | name_owner_id = g_bus_own_name_on_connection (self->priv->connection, |
881 | 884 | owner_name, |
882 | 885 | G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE, |
939 | 942 | priv->state = XAPP_STATUS_ICON_STATE_NO_SUPPORT; |
940 | 943 | } |
941 | 944 | |
942 | g_debug ("XAppStatusIcon fallback icon embedded_changed. State is now %s", | |
945 | DEBUG ("Fallback icon embedded_changed. State is now %s", | |
943 | 946 | state_to_str (priv->state)); |
944 | 947 | g_signal_emit (self, signals[STATE_CHANGED], 0, priv->state); |
945 | 948 | } |
949 | 952 | { |
950 | 953 | XAppStatusIconPrivate *priv = self->priv; |
951 | 954 | |
952 | g_debug ("XAppStatusIcon: falling back to GtkStatusIcon"); | |
955 | DEBUG ("Falling back to GtkStatusIcon"); | |
953 | 956 | |
954 | 957 | remove_icon_path_from_bus (self); |
955 | 958 | |
1001 | 1004 | } |
1002 | 1005 | else |
1003 | 1006 | { |
1004 | g_debug ("XAppStatusIcon: attempt to ListNames cancelled"); | |
1007 | DEBUG ("Attempt to ListNames cancelled"); | |
1005 | 1008 | } |
1006 | 1009 | |
1007 | 1010 | g_error_free (error); |
1016 | 1019 | { |
1017 | 1020 | if (g_str_has_prefix (str, STATUS_ICON_MONITOR_MATCH)) |
1018 | 1021 | { |
1019 | g_debug ("XAppStatusIcon: Discovered active status monitor (%s)", str); | |
1022 | DEBUG ("Discovered active status monitor (%s)", str); | |
1020 | 1023 | found = TRUE; |
1021 | 1024 | } |
1022 | 1025 | } |
1047 | 1050 | look_for_status_applet (XAppStatusIcon *self) |
1048 | 1051 | { |
1049 | 1052 | // Check that there is at least one applet on DBUS |
1050 | g_debug("XAppStatusIcon: Looking for status monitors"); | |
1053 | DEBUG("Looking for status monitors"); | |
1051 | 1054 | |
1052 | 1055 | cancellable_reset (self); |
1053 | 1056 | |
1112 | 1115 | } |
1113 | 1116 | else |
1114 | 1117 | { |
1115 | g_debug ("XAppStatusIcon: Cancelled session bus acquire"); | |
1118 | DEBUG ("Cancelled session bus acquire"); | |
1116 | 1119 | } |
1117 | 1120 | |
1118 | 1121 | g_error_free (error); |
1127 | 1130 | { |
1128 | 1131 | if (self->priv->connection == NULL) |
1129 | 1132 | { |
1130 | g_debug ("XAppStatusIcon: Connecting to session bus"); | |
1133 | DEBUG ("Connecting to session bus"); | |
1131 | 1134 | |
1132 | 1135 | cancellable_reset (self); |
1133 | 1136 | |
1216 | 1219 | self->priv->icon_size = FALLBACK_ICON_SIZE; |
1217 | 1220 | self->priv->icon_name = g_strdup (" "); |
1218 | 1221 | |
1219 | g_debug ("XAppStatusIcon: init: application name: '%s'", self->priv->name); | |
1222 | DEBUG ("Init: application name: '%s'", self->priv->name); | |
1220 | 1223 | |
1221 | 1224 | // Default to visible (the same behavior as GtkStatusIcon) |
1222 | 1225 | self->priv->visible = TRUE; |
1234 | 1237 | const gchar *path; |
1235 | 1238 | path = g_dbus_object_get_object_path (G_DBUS_OBJECT (self->priv->object_skeleton)); |
1236 | 1239 | |
1237 | g_debug ("XAppStatusIcon: removing interface at path '%s'", path); | |
1240 | DEBUG ("Removing interface at path '%s'", path); | |
1238 | 1241 | |
1239 | 1242 | g_dbus_object_manager_server_unexport (obj_server, path); |
1240 | 1243 | self->priv->interface_skeleton = NULL; |
1249 | 1252 | { |
1250 | 1253 | XAppStatusIcon *self = XAPP_STATUS_ICON (object); |
1251 | 1254 | |
1252 | g_debug ("XAppStatusIcon dispose (%p)", object); | |
1255 | DEBUG ("XAppStatusIcon dispose (%p)", object); | |
1253 | 1256 | |
1254 | 1257 | g_free (self->priv->name); |
1255 | 1258 | g_free (self->priv->icon_name); |
1286 | 1289 | static void |
1287 | 1290 | xapp_status_icon_finalize (GObject *object) |
1288 | 1291 | { |
1289 | g_debug ("XAppStatusIcon finalize (%p)", object); | |
1292 | DEBUG ("XAppStatusIcon finalize (%p)", object); | |
1290 | 1293 | |
1291 | 1294 | g_clear_object (&XAPP_STATUS_ICON (object)->priv->cancellable); |
1292 | 1295 | |
1521 | 1524 | g_clear_pointer (&icon->priv->name, g_free); |
1522 | 1525 | icon->priv->name = g_strdup (name); |
1523 | 1526 | |
1524 | g_debug ("XAppStatusIcon set_name: %s", name); | |
1527 | DEBUG ("set_name: %s", name); | |
1525 | 1528 | |
1526 | 1529 | if (icon->priv->interface_skeleton) |
1527 | 1530 | { |
1560 | 1563 | g_clear_pointer (&icon->priv->icon_name, g_free); |
1561 | 1564 | icon->priv->icon_name = g_strdup (icon_name); |
1562 | 1565 | |
1563 | g_debug ("XAppStatusIcon set_icon_name: %s", icon_name); | |
1566 | DEBUG ("set_icon_name: %s", icon_name); | |
1564 | 1567 | |
1565 | 1568 | if (icon->priv->interface_skeleton) |
1566 | 1569 | { |
1587 | 1590 | |
1588 | 1591 | if (icon->priv->interface_skeleton == NULL) |
1589 | 1592 | { |
1590 | g_debug ("XAppStatusIcon get_icon_size: %d (fallback)", FALLBACK_ICON_SIZE); | |
1593 | DEBUG ("get_icon_size: %d (fallback)", FALLBACK_ICON_SIZE); | |
1591 | 1594 | |
1592 | 1595 | return FALLBACK_ICON_SIZE; |
1593 | 1596 | } |
1596 | 1599 | |
1597 | 1600 | size = xapp_status_icon_interface_get_icon_size (icon->priv->interface_skeleton); |
1598 | 1601 | |
1599 | g_debug ("XAppStatusIcon get_icon_size: %d", size); | |
1602 | DEBUG ("get_icon_size: %d", size); | |
1600 | 1603 | |
1601 | 1604 | return size; |
1602 | 1605 | } |
1623 | 1626 | g_clear_pointer (&icon->priv->tooltip_text, g_free); |
1624 | 1627 | icon->priv->tooltip_text = g_strdup (tooltip_text); |
1625 | 1628 | |
1626 | g_debug ("XAppStatusIcon set_tooltip_text: %s", tooltip_text); | |
1629 | DEBUG ("set_tooltip_text: %s", tooltip_text); | |
1627 | 1630 | |
1628 | 1631 | if (icon->priv->interface_skeleton) |
1629 | 1632 | { |
1655 | 1658 | g_clear_pointer (&icon->priv->label, g_free); |
1656 | 1659 | icon->priv->label = g_strdup (label); |
1657 | 1660 | |
1658 | g_debug ("XAppStatusIcon set_label: '%s'", label); | |
1661 | DEBUG ("set_label: '%s'", label); | |
1659 | 1662 | |
1660 | 1663 | if (icon->priv->interface_skeleton) |
1661 | 1664 | { |
1684 | 1687 | |
1685 | 1688 | icon->priv->visible = visible; |
1686 | 1689 | |
1687 | g_debug ("XAppStatusIcon set_visible: %s", visible ? "TRUE" : "FALSE"); | |
1690 | DEBUG ("set_visible: %s", visible ? "TRUE" : "FALSE"); | |
1688 | 1691 | |
1689 | 1692 | if (icon->priv->interface_skeleton) |
1690 | 1693 | { |
1709 | 1712 | { |
1710 | 1713 | g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), FALSE); |
1711 | 1714 | |
1712 | g_debug ("XAppStatusIcon get_visible: %s", icon->priv->visible ? "TRUE" : "FALSE"); | |
1715 | DEBUG ("get_visible: %s", icon->priv->visible ? "TRUE" : "FALSE"); | |
1713 | 1716 | |
1714 | 1717 | return icon->priv->visible; |
1715 | 1718 | } |
1774 | 1777 | |
1775 | 1778 | g_clear_object (&icon->priv->primary_menu); |
1776 | 1779 | |
1777 | g_debug ("XAppStatusIcon set_primary_menu: %p", menu); | |
1780 | DEBUG ("set_primary_menu: %p", menu); | |
1778 | 1781 | |
1779 | 1782 | if (menu) |
1780 | 1783 | { |
1798 | 1801 | { |
1799 | 1802 | g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), NULL); |
1800 | 1803 | |
1801 | g_debug ("XAppStatusIcon get_menu: %p", icon->priv->primary_menu); | |
1804 | DEBUG ("get_menu: %p", icon->priv->primary_menu); | |
1802 | 1805 | |
1803 | 1806 | return icon->priv->primary_menu; |
1804 | 1807 | } |
1826 | 1829 | |
1827 | 1830 | g_clear_object (&icon->priv->secondary_menu); |
1828 | 1831 | |
1829 | g_debug ("XAppStatusIcon set_secondary_menu: %p", menu); | |
1832 | DEBUG ("set_secondary_menu: %p", menu); | |
1830 | 1833 | |
1831 | 1834 | if (menu) |
1832 | 1835 | { |
1850 | 1853 | { |
1851 | 1854 | g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), NULL); |
1852 | 1855 | |
1853 | g_debug ("XAppStatusIcon get_menu: %p", icon->priv->secondary_menu); | |
1856 | DEBUG ("get_menu: %p", icon->priv->secondary_menu); | |
1854 | 1857 | |
1855 | 1858 | return icon->priv->secondary_menu; |
1856 | 1859 | } |
1906 | 1909 | { |
1907 | 1910 | g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), XAPP_STATUS_ICON_STATE_NO_SUPPORT); |
1908 | 1911 | |
1909 | g_debug ("XAppStatusIcon get_state: %s", state_to_str (icon->priv->state)); | |
1912 | DEBUG ("get_state: %s", state_to_str (icon->priv->state)); | |
1910 | 1913 | |
1911 | 1914 | return icon->priv->state; |
1912 | 1915 | } |
1929 | 1932 | g_return_if_fail (XAPP_IS_STATUS_ICON (icon)); |
1930 | 1933 | gchar *old_meta; |
1931 | 1934 | |
1932 | g_debug ("XAppStatusIcon set_metadata: '%s'", metadata); | |
1935 | DEBUG ("set_metadata: '%s'", metadata); | |
1933 | 1936 | |
1934 | 1937 | if (g_strcmp0 (metadata, icon->priv->metadata) == 0) |
1935 | 1938 | { |
1962 | 1965 | GError *error; |
1963 | 1966 | gboolean found; |
1964 | 1967 | |
1965 | g_debug("XAppStatusIcon: any_monitors: Looking for status monitors"); | |
1968 | DEBUG("Looking for status monitors"); | |
1966 | 1969 | |
1967 | 1970 | error = NULL; |
1968 | 1971 | found = FALSE; |
1996 | 1999 | { |
1997 | 2000 | if (g_str_has_prefix (str, STATUS_ICON_MONITOR_MATCH)) |
1998 | 2001 | { |
1999 | g_debug ("XAppStatusIcon: any_monitors: discovered active status monitor (%s)", str); | |
2002 | DEBUG ("Discovered active status monitor (%s)", str); | |
2000 | 2003 | |
2001 | 2004 | found = TRUE; |
2002 | 2005 | |
2014 | 2017 | |
2015 | 2018 | if (error) |
2016 | 2019 | { |
2017 | g_warning ("XAppStatusIcon: any_monitors: Unable to check for monitors: %s", error->message); | |
2020 | g_warning ("Unable to check for monitors: %s", error->message); | |
2018 | 2021 | g_error_free (error); |
2019 | 2022 | } |
2020 | 2023 | |
2021 | g_debug ("XAppStatusIcon: any_monitors: %s", found ? "TRUE" : "FALSE"); | |
2024 | DEBUG ("Monitors found: %s", found ? "TRUE" : "FALSE"); | |
2022 | 2025 | |
2023 | 2026 | return found; |
2024 | 2027 | } |
15 | 15 | |
16 | 16 | #include "sn-item-interface.h" |
17 | 17 | #include "sn-item.h" |
18 | ||
19 | #define DEBUG_FLAG XAPP_DEBUG_SN_WATCHER | |
20 | #include <libxapp/xapp-debug.h> | |
18 | 21 | |
19 | 22 | #define FALLBACK_ICON_SIZE 24 |
20 | 23 | |
162 | 165 | sn_item_dispose (GObject *object) |
163 | 166 | { |
164 | 167 | SnItem *item = SN_ITEM (object); |
165 | g_debug ("SnItem dispose (%p)", object); | |
168 | DEBUG ("SnItem dispose (%p)", object); | |
166 | 169 | |
167 | 170 | if (item->png_path != NULL) |
168 | 171 | { |
195 | 198 | static void |
196 | 199 | sn_item_finalize (GObject *object) |
197 | 200 | { |
198 | g_debug ("SnItem finalize (%p)", object); | |
201 | DEBUG ("SnItem finalize (%p)", object); | |
199 | 202 | |
200 | 203 | G_OBJECT_CLASS (sn_item_parent_class)->finalize (object); |
201 | 204 | } |
375 | 378 | cairo_surface_t *surface; |
376 | 379 | gchar *filename, *save_filename; |
377 | 380 | |
378 | g_debug ("Trying to use icon pixmap for %s", | |
381 | DEBUG ("Trying to use icon pixmap for %s", | |
379 | 382 | item->sortable_name); |
380 | 383 | |
381 | 384 | surface = NULL; |
412 | 415 | cairo_status_t status = CAIRO_STATUS_SUCCESS; |
413 | 416 | status = cairo_surface_write_to_png (surface, save_filename); |
414 | 417 | |
415 | g_debug ("Saving tmp image file for '%s' to '%s'", item->sortable_name, save_filename); | |
418 | DEBUG ("Saving tmp image file for '%s' to '%s'", item->sortable_name, save_filename); | |
416 | 419 | |
417 | 420 | if (status != CAIRO_STATUS_SUCCESS) |
418 | 421 | { |
424 | 427 | return; |
425 | 428 | } |
426 | 429 | |
427 | g_debug ("No pixmaps to use"); | |
430 | DEBUG ("No pixmaps to use"); | |
428 | 431 | xapp_status_icon_set_icon_name (item->status_icon, "image-missing"); |
429 | 432 | } |
430 | 433 | |
491 | 494 | const gchar *icon_theme_path, |
492 | 495 | const gchar *icon_name) |
493 | 496 | { |
494 | g_debug ("Checking for icon name for %s - theme path: '%s', icon name: '%s'", | |
497 | DEBUG ("Checking for icon name for %s - theme path: '%s', icon name: '%s'", | |
495 | 498 | item->sortable_name, |
496 | 499 | icon_theme_path, |
497 | 500 | icon_name); |
580 | 583 | new_props->menu_path)); |
581 | 584 | g_object_ref_sink (item->menu); |
582 | 585 | |
583 | g_debug ("New menu for '%s'", item->sortable_name); | |
586 | DEBUG ("New menu for '%s'", item->sortable_name); | |
584 | 587 | |
585 | 588 | if (item->is_ai && !item->should_activate) |
586 | 589 | { |
633 | 636 | new_props->tooltip_body); |
634 | 637 | |
635 | 638 | xapp_status_icon_set_tooltip_text (item->status_icon, text); |
636 | g_debug ("Tooltip text for '%s' from ToolTip: %s", | |
639 | DEBUG ("Tooltip text for '%s' from ToolTip: %s", | |
637 | 640 | item->sortable_name, |
638 | 641 | text); |
639 | 642 | |
641 | 644 | } |
642 | 645 | else |
643 | 646 | { |
644 | g_debug ("Tooltip text for '%s' from ToolTip: %s", | |
647 | DEBUG ("Tooltip text for '%s' from ToolTip: %s", | |
645 | 648 | item->sortable_name, |
646 | 649 | new_props->tooltip_heading); |
647 | 650 | |
659 | 662 | capped_string = capitalize (new_props->title); |
660 | 663 | xapp_status_icon_set_tooltip_text (item->status_icon, capped_string); |
661 | 664 | |
662 | g_debug ("Tooltip text for '%s' from Title: %s", | |
665 | DEBUG ("Tooltip text for '%s' from Title: %s", | |
663 | 666 | item->sortable_name, |
664 | 667 | capped_string); |
665 | 668 | |
690 | 693 | xapp_status_icon_set_visible (item->status_icon, TRUE); |
691 | 694 | } |
692 | 695 | |
693 | g_debug ("Status for '%s' is now '%s'", item->sortable_name, new_props->status); | |
696 | DEBUG ("Status for '%s' is now '%s'", item->sortable_name, new_props->status); | |
694 | 697 | } |
695 | 698 | |
696 | 699 | static gchar * |
1105 | 1108 | return; |
1106 | 1109 | } |
1107 | 1110 | |
1108 | g_debug ("Sort name for '%s' is '%s'", | |
1111 | DEBUG ("Sort name for '%s' is '%s'", | |
1109 | 1112 | g_dbus_proxy_get_name (G_DBUS_PROXY (item->sn_item_proxy)), |
1110 | 1113 | sortable_name); |
1111 | 1114 |
3 | 3 | |
4 | 4 | #include <libxapp/xapp-status-icon.h> |
5 | 5 | #include <libxapp/xapp-util.h> |
6 | ||
7 | #define DEBUG_FLAG XAPP_DEBUG_SN_WATCHER | |
8 | #include <libxapp/xapp-debug.h> | |
9 | ||
6 | 10 | #include <glib-unix.h> |
7 | 11 | |
8 | 12 | #include "sn-watcher-interface.h" |
9 | 13 | #include "sn-item-interface.h" |
10 | 14 | #include "sn-item.h" |
11 | 15 | |
16 | ||
12 | 17 | #define XAPP_TYPE_SN_WATCHER xapp_sn_watcher_get_type () |
13 | 18 | G_DECLARE_FINAL_TYPE (XAppSnWatcher, xapp_sn_watcher, XAPP, SN_WATCHER, GtkApplication) |
14 | 19 | |
55 | 60 | { |
56 | 61 | if (watcher->shutdown_pending) |
57 | 62 | { |
58 | g_debug ("A monitor appeared on the bus, cancelling shutdown\n"); | |
63 | DEBUG ("A monitor appeared on the bus, cancelling shutdown\n"); | |
59 | 64 | |
60 | 65 | watcher->shutdown_pending = FALSE; |
61 | 66 | g_application_hold (G_APPLICATION (watcher)); |
91 | 96 | |
92 | 97 | if (g_str_has_prefix (key, name)) |
93 | 98 | { |
94 | g_debug ("Client %s has exited, removing status icon", key); | |
99 | DEBUG ("Client %s has exited, removing status icon", key); | |
95 | 100 | g_hash_table_remove (watcher->items, key); |
96 | 101 | |
97 | 102 | update_published_items (watcher); |
109 | 114 | { |
110 | 115 | if (g_str_has_prefix (name, STATUS_ICON_MONITOR_PREFIX)) |
111 | 116 | { |
112 | g_debug ("Lost a monitor, checking for any more"); | |
117 | DEBUG ("Lost a monitor, checking for any more"); | |
113 | 118 | |
114 | 119 | if (xapp_status_icon_any_monitors ()) |
115 | 120 | { |
116 | g_debug ("Still have a monitor, continuing"); | |
121 | DEBUG ("Still have a monitor, continuing"); | |
117 | 122 | |
118 | 123 | return; |
119 | 124 | } |
120 | 125 | else |
121 | 126 | { |
122 | g_debug ("Lost our last monitor, starting countdown\n"); | |
127 | DEBUG ("Lost our last monitor, starting countdown\n"); | |
123 | 128 | |
124 | 129 | if (!watcher->shutdown_pending) |
125 | 130 | { |
153 | 158 | |
154 | 159 | g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner); |
155 | 160 | |
156 | g_debug("XAppSnWatcher: NameOwnerChanged signal received (n: %s, old: %s, new: %s", name, old_owner, new_owner); | |
161 | DEBUG("NameOwnerChanged signal received (n: %s, old: %s, new: %s", name, old_owner, new_owner); | |
157 | 162 | |
158 | 163 | if (!name) |
159 | 164 | { |
173 | 178 | static void |
174 | 179 | add_name_listener (XAppSnWatcher *watcher) |
175 | 180 | { |
176 | g_debug ("XAppSnWatcher: Adding NameOwnerChanged listener for status monitor existence"); | |
181 | DEBUG ("Adding NameOwnerChanged listener for status monitor existence"); | |
177 | 182 | |
178 | 183 | watcher->name_listener_id = g_dbus_connection_signal_subscribe (watcher->connection, |
179 | 184 | FDO_DBUS_NAME, |
194 | 199 | { |
195 | 200 | XAppSnWatcher *watcher = XAPP_SN_WATCHER (user_data); |
196 | 201 | |
197 | g_debug ("Lost StatusNotifierWatcher name (maybe something replaced us), exiting immediately"); | |
202 | DEBUG ("Lost StatusNotifierWatcher name (maybe something replaced us), exiting immediately"); | |
198 | 203 | g_application_quit (G_APPLICATION (watcher)); |
199 | 204 | } |
200 | 205 | |
205 | 210 | { |
206 | 211 | XAppSnWatcher *watcher = XAPP_SN_WATCHER (user_data); |
207 | 212 | |
208 | g_debug ("Name acquired on dbus"); | |
213 | DEBUG ("Name acquired on dbus"); | |
209 | 214 | sn_watcher_interface_set_protocol_version (watcher->skeleton, 0); |
210 | 215 | sn_watcher_interface_set_is_status_notifier_host_registered (watcher->skeleton, |
211 | 216 | watcher->advertise_host); |
288 | 293 | |
289 | 294 | temp_key = g_strdup_printf ("%s%s", temp_bname, temp_path); |
290 | 295 | |
291 | g_debug ("Key: '%s', busname '%s', path '%s'", temp_key, temp_bname, temp_path); | |
296 | DEBUG ("Key: '%s', busname '%s', path '%s'", temp_key, temp_bname, temp_path); | |
292 | 297 | |
293 | 298 | *key = temp_key; |
294 | 299 | *bus_name = temp_bname; |
356 | 361 | { |
357 | 362 | if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) |
358 | 363 | { |
359 | g_debug ("Could not create new status notifier proxy item for item at %s: %s", | |
364 | DEBUG ("Could not create new status notifier proxy item for item at %s: %s", | |
360 | 365 | data->bus_name, error->message); |
361 | 366 | } |
362 | 367 | |
411 | 416 | { |
412 | 417 | NewSnProxyData *data; |
413 | 418 | error = NULL; |
414 | // g_debug ("Key: '%s'", key); | |
419 | // DEBUG ("Key: '%s'", key); | |
415 | 420 | |
416 | 421 | data = g_slice_new0 (NewSnProxyData); |
417 | 422 | data->watcher = watcher; |
455 | 460 | |
456 | 461 | watcher->skeleton = sn_watcher_interface_skeleton_new (); |
457 | 462 | |
458 | g_debug ("XAppSnWatcher: exporting StatusNotifierWatcher dbus interface to %s", NOTIFICATION_WATCHER_PATH); | |
463 | DEBUG ("Exporting StatusNotifierWatcher dbus interface to %s", NOTIFICATION_WATCHER_PATH); | |
459 | 464 | |
460 | 465 | g_signal_connect (watcher->skeleton, |
461 | 466 | "handle-register-status-notifier-item", |
485 | 490 | static gboolean |
486 | 491 | on_interrupt (XAppSnWatcher *watcher) |
487 | 492 | { |
488 | g_debug ("SIGINT - shutting down immediately"); | |
493 | DEBUG ("SIGINT - shutting down immediately"); | |
489 | 494 | |
490 | 495 | g_application_quit (G_APPLICATION (watcher)); |
491 | 496 | return FALSE; |
494 | 499 | static void |
495 | 500 | continue_startup (XAppSnWatcher *watcher) |
496 | 501 | { |
497 | g_debug ("Trying to acquire session bus connection"); | |
502 | DEBUG ("Trying to acquire session bus connection"); | |
498 | 503 | |
499 | 504 | g_unix_signal_add (SIGINT, (GSourceFunc) on_interrupt, watcher); |
500 | 505 | g_application_hold (G_APPLICATION (watcher)); |
572 | 577 | } |
573 | 578 | else |
574 | 579 | { |
575 | g_debug ("No active monitors, exiting in 30s"); | |
580 | DEBUG ("No active monitors, exiting in 30s"); | |
576 | 581 | watcher->shutdown_pending = TRUE; |
577 | 582 | } |
578 | 583 | } |
701 | 706 | |
702 | 707 | if (!should_start) |
703 | 708 | { |
704 | g_debug ("XDG_CURRENT_DESKTOP is '%s' - not starting XApp's StatusNotifierWatcher service." | |
709 | DEBUG ("XDG_CURRENT_DESKTOP is '%s' - not starting XApp's StatusNotifierWatcher service." | |
705 | 710 | "If you want to change this, add your desktop's name to the dconf org.x.apps.statusicon " |
706 | 711 | "'status-notifier-enabled-desktops' setting key.", current_desktop); |
707 | 712 | exit(0); |