[libdazzle] shortcuts: add a bunch of tracing
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] shortcuts: add a bunch of tracing
- Date: Sat, 17 Jun 2017 08:13:16 +0000 (UTC)
commit 966ab1740247e72f1d8d3f9c42542b8efcf41bce
Author: Christian Hergert <chergert redhat com>
Date: Sat Jun 17 01:12:55 2017 -0700
shortcuts: add a bunch of tracing
Tracking bugs down in this stuff can be an exercise in printf(), so these
debug macros make things easier when the project is configured with
-Denable_tracing=true.
src/shortcuts/dzl-shortcut-manager.c | 58 ++++++++++++++++++++++++++++-----
src/shortcuts/dzl-shortcut-theme.c | 20 +++++++++--
2 files changed, 65 insertions(+), 13 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-manager.c b/src/shortcuts/dzl-shortcut-manager.c
index 6ef8523..1f93e24 100644
--- a/src/shortcuts/dzl-shortcut-manager.c
+++ b/src/shortcuts/dzl-shortcut-manager.c
@@ -20,6 +20,8 @@
#include <glib/gi18n.h>
+#include "dzl-debug.h"
+
#include "shortcuts/dzl-shortcut-controller.h"
#include "shortcuts/dzl-shortcut-label.h"
#include "shortcuts/dzl-shortcut-manager.h"
@@ -155,9 +157,14 @@ dzl_shortcut_manager_reload (DzlShortcutManager *self,
DzlShortcutTheme *theme = NULL;
guint previous_len;
+ DZL_ENTRY;
+
g_assert (DZL_IS_SHORTCUT_MANAGER (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+ DZL_TRACE_MSG ("reloading shortcuts, current theme is ā%sā",
+ priv->theme ? dzl_shortcut_theme_get_name (priv->theme) : "internal");
+
/*
* If there is a queued reload when we get here, just remove it. When called
* from a queued callback, this will already be zeroed.
@@ -218,6 +225,9 @@ dzl_shortcut_manager_reload (DzlShortcutManager *self,
dzl_shortcut_manager_load_directory (self, directory, cancellable);
}
+ DZL_TRACE_MSG ("Attempting to reset theme to %s",
+ theme_name ?: parent_theme_name ?: "internal");
+
/* Now try to reapply the same theme if we can find it. */
if (theme_name != NULL)
{
@@ -236,6 +246,8 @@ dzl_shortcut_manager_reload (DzlShortcutManager *self,
/* Notify possibly changed properties */
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_THEME]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_THEME_NAME]);
+
+ DZL_EXIT;
}
static gboolean
@@ -256,6 +268,8 @@ dzl_shortcut_manager_queue_reload (DzlShortcutManager *self)
{
DzlShortcutManagerPrivate *priv = dzl_shortcut_manager_get_instance_private (self);
+ DZL_ENTRY;
+
g_assert (DZL_IS_SHORTCUT_MANAGER (self));
if (priv->reload_handler == 0)
@@ -270,6 +284,8 @@ dzl_shortcut_manager_queue_reload (DzlShortcutManager *self)
g_object_ref (self),
g_object_unref);
}
+
+ DZL_EXIT;
}
static void
@@ -413,15 +429,19 @@ dzl_shortcut_manager_load_directory (DzlShortcutManager *self,
g_autoptr(GDir) dir = NULL;
const gchar *name;
+ DZL_ENTRY;
+
g_assert (DZL_IS_SHORTCUT_MANAGER (self));
g_assert (directory != NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+ DZL_TRACE_MSG ("directory = %s", directory);
+
if (!g_file_test (directory, G_FILE_TEST_IS_DIR))
- return;
+ DZL_EXIT;
if (NULL == (dir = g_dir_open (directory, 0, NULL)))
- return;
+ DZL_EXIT;
while (NULL != (name = g_dir_read_name (dir)))
{
@@ -436,8 +456,11 @@ dzl_shortcut_manager_load_directory (DzlShortcutManager *self,
_dzl_shortcut_theme_set_manager (theme, self);
dzl_shortcut_manager_merge (self, theme);
}
- else g_warning ("%s", local_error->message);
+ else
+ g_warning ("%s", local_error->message);
}
+
+ DZL_EXIT;
}
static void
@@ -447,11 +470,15 @@ dzl_shortcut_manager_load_resources (DzlShortcutManager *self,
{
g_auto(GStrv) children = NULL;
+ DZL_ENTRY;
+
g_assert (DZL_IS_SHORTCUT_MANAGER (self));
g_assert (resource_dir != NULL);
g_assert (g_str_has_prefix (resource_dir, "resource://"));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+ DZL_TRACE_MSG ("resource_dir = %s", resource_dir);
+
if (g_str_has_prefix (resource_dir, "resource://"))
resource_dir += strlen ("resource://");
@@ -483,6 +510,8 @@ dzl_shortcut_manager_load_resources (DzlShortcutManager *self,
g_warning ("%s", local_error->message);
}
}
+
+ DZL_EXIT;
}
static gboolean
@@ -577,6 +606,8 @@ dzl_shortcut_manager_set_theme (DzlShortcutManager *self,
{
DzlShortcutManagerPrivate *priv = dzl_shortcut_manager_get_instance_private (self);
+ DZL_ENTRY;
+
g_return_if_fail (DZL_IS_SHORTCUT_MANAGER (self));
g_return_if_fail (DZL_IS_SHORTCUT_THEME (theme));
@@ -600,6 +631,9 @@ dzl_shortcut_manager_set_theme (DzlShortcutManager *self,
_dzl_shortcut_theme_attach (priv->theme);
}
+ DZL_TRACE_MSG ("theme set to ā%sā",
+ theme ? dzl_shortcut_theme_get_name (theme) : "internal");
+
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_THEME]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_THEME_NAME]);
}
@@ -628,6 +662,8 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
GtkWidget *focus;
GdkModifierType modifier;
+ DZL_ENTRY;
+
g_return_val_if_fail (!self || DZL_IS_SHORTCUT_MANAGER (self), FALSE);
g_return_val_if_fail (!toplevel || GTK_IS_WINDOW (toplevel), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -647,7 +683,7 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
}
if (event->type != GDK_KEY_PRESS)
- return GDK_EVENT_PROPAGATE;
+ DZL_RETURN (GDK_EVENT_PROPAGATE);
g_assert (DZL_IS_SHORTCUT_MANAGER (self));
g_assert (GTK_IS_WINDOW (toplevel));
@@ -679,7 +715,7 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
* Now try to activate the event using the controller.
*/
if (dzl_shortcut_controller_handle_event (controller, event))
- return GDK_EVENT_STOP;
+ DZL_RETURN (GDK_EVENT_STOP);
}
/*
@@ -705,7 +741,7 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
GtkBindingSet *set = g_ptr_array_index (sets, i);
if (gtk_binding_set_activate (set, event->keyval, modifier, G_OBJECT (widget)))
- return GDK_EVENT_STOP;
+ DZL_RETURN (GDK_EVENT_STOP);
}
}
@@ -718,14 +754,14 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
GtkBindingSet *set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (widget));
if (gtk_binding_set_activate (set, event->keyval, modifier, G_OBJECT (widget)))
- return GDK_EVENT_STOP;
+ DZL_RETURN (GDK_EVENT_STOP);
}
}
widget = gtk_widget_get_parent (widget);
}
- return GDK_EVENT_PROPAGATE;
+ DZL_RETURN (GDK_EVENT_PROPAGATE);
}
const gchar *
@@ -1305,6 +1341,8 @@ dzl_shortcut_manager_merge (DzlShortcutManager *self,
DzlShortcutTheme *base_layer;
const gchar *name;
+ DZL_ENTRY;
+
g_return_if_fail (DZL_IS_SHORTCUT_MANAGER (self));
g_return_if_fail (DZL_IS_SHORTCUT_THEME (theme));
@@ -1320,7 +1358,7 @@ dzl_shortcut_manager_merge (DzlShortcutManager *self,
if (dzl_str_empty0 (name))
{
g_warning ("Attempt to merge theme with empty name");
- return;
+ DZL_EXIT;
}
base_layer = dzl_shortcut_manager_get_theme_by_name (self, name);
@@ -1360,4 +1398,6 @@ dzl_shortcut_manager_merge (DzlShortcutManager *self,
* the intenral structures.
*/
_dzl_shortcut_theme_merge (base_layer, theme);
+
+ DZL_EXIT;
}
diff --git a/src/shortcuts/dzl-shortcut-theme.c b/src/shortcuts/dzl-shortcut-theme.c
index fece545..844dc82 100644
--- a/src/shortcuts/dzl-shortcut-theme.c
+++ b/src/shortcuts/dzl-shortcut-theme.c
@@ -20,6 +20,8 @@
#include <string.h>
+#include "dzl-debug.h"
+
#include "shortcuts/dzl-shortcut-private.h"
#include "shortcuts/dzl-shortcut-chord.h"
#include "shortcuts/dzl-shortcut-theme.h"
@@ -849,9 +851,12 @@ _dzl_shortcut_theme_attach (DzlShortcutTheme *self)
g_hash_table_iter_init (&iter, priv->resource_providers);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&provider))
- gtk_style_context_add_provider_for_screen (screen,
- provider,
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ {
+ DZL_TRACE_MSG ("adding CSS provider %p", provider);
+ gtk_style_context_add_provider_for_screen (screen,
+ provider,
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
}
}
@@ -860,6 +865,8 @@ _dzl_shortcut_theme_detach (DzlShortcutTheme *self)
{
DzlShortcutThemePrivate *priv = dzl_shortcut_theme_get_instance_private (self);
+ DZL_ENTRY;
+
g_return_if_fail (DZL_IS_SHORTCUT_THEME (self));
if (priv->resource_providers != NULL)
@@ -870,6 +877,11 @@ _dzl_shortcut_theme_detach (DzlShortcutTheme *self)
g_hash_table_iter_init (&iter, priv->resource_providers);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&provider))
- gtk_style_context_remove_provider_for_screen (screen, provider);
+ {
+ DZL_TRACE_MSG ("removing CSS provider %p", provider);
+ gtk_style_context_remove_provider_for_screen (screen, provider);
+ }
}
+
+ DZL_EXIT;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]