[balsa/gtk3] Add debugging code to check toolbar action names



commit 1a1bf82928a735df658dab01dec715c9c680cdbf
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Feb 18 17:57:42 2015 -0500

    Add debugging code to check toolbar action names
    
        * src/toolbar-prefs.c (customize_dialog_cb), (standard_button_cb),
        (create_toolbar_page), (tp_page_refresh_available),
        (tp_page_add_selected), (tp_page_remove_selected): conditionally
        compiled debug code to check for unimplemented action names.

 ChangeLog           |    7 +++++++
 src/toolbar-prefs.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b0765a5..4ef4e58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2015-02-18  Peter Bloomfield  <pbloomfield bellsouth net>
 
+       * src/toolbar-prefs.c (customize_dialog_cb), (standard_button_cb),
+       (create_toolbar_page), (tp_page_refresh_available),
+       (tp_page_add_selected), (tp_page_remove_selected): conditionally
+       compiled debug code to check for unimplemented action names.
+
+2015-02-18  Peter Bloomfield  <pbloomfield bellsouth net>
+
        Fix broken toolbar items
 
        * src/message-window.c: correct action names.
diff --git a/src/toolbar-prefs.c b/src/toolbar-prefs.c
index e7bbf4f..c00c3df 100644
--- a/src/toolbar-prefs.c
+++ b/src/toolbar-prefs.c
@@ -42,6 +42,9 @@
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #endif
 
+/* Uncomment the next line to check for invalid action names */
+/* #define BALSA_TOOLBAR_DEBUG_ACTIONS */
+
 /* Enumeration for GtkTreeModel columns. */
 enum {
     TP_TEXT_COLUMN,
@@ -93,7 +96,11 @@ static GtkWidget *create_toolbar_page(BalsaToolbarModel * model,
 static GtkWidget *tp_list_new(void);
 static gboolean tp_list_iter_is_first(GtkWidget * list, GtkTreeIter * iter);
 static gboolean tp_list_iter_is_last(GtkWidget * list, GtkTreeIter * iter);
+#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
 static void tp_page_refresh_available(ToolbarPage * page);
+#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+static void tp_page_refresh_available(ToolbarPage * page, GActionMap * map);
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
 static void tp_page_refresh_current(ToolbarPage * page);
 static void tp_page_refresh_preview(ToolbarPage * page);
 static void tp_page_swap_rows(ToolbarPage * page, gboolean forward);
@@ -156,6 +163,9 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
     model = balsa_window_get_toolbar_model();
     group = g_simple_action_group_new();
     balsa_window_add_action_entries(G_ACTION_MAP(group));
+#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
+    g_print("main window\n");
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     child = create_toolbar_page(model, G_ACTION_MAP(group));
     g_object_unref(group);
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child,
@@ -164,6 +174,9 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
     model = sendmsg_window_get_toolbar_model();
     group = g_simple_action_group_new();
     sendmsg_window_add_action_entries(G_ACTION_MAP(group));
+#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
+    g_print("compose window\n");
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     child = create_toolbar_page(model, G_ACTION_MAP(group));
     g_object_unref(group);
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child,
@@ -172,6 +185,9 @@ customize_dialog_cb(GtkWidget * widget, gpointer data)
     model = message_window_get_toolbar_model();
     group = g_simple_action_group_new();
     message_window_add_action_entries(G_ACTION_MAP(group));
+#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
+    g_print("message window\n");
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     child = create_toolbar_page(model, G_ACTION_MAP(group));
     g_object_unref(group);
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child,
@@ -277,7 +293,11 @@ standard_button_cb(GtkWidget *widget, ToolbarPage * page)
 {
     balsa_toolbar_model_clear(page->model);
     gtk_widget_set_sensitive(page->standard_button, FALSE);
+#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
     tp_page_refresh_available(page);
+#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+    tp_page_refresh_available(page, NULL);
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     tp_page_refresh_current(page);
     balsa_toolbar_model_changed(page->model);
 }
@@ -541,7 +561,11 @@ create_toolbar_page(BalsaToolbarModel * model, GActionMap * map)
     gtk_widget_set_sensitive(page->standard_button,
                              !balsa_toolbar_model_is_standard(model));
 
+#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
     tp_page_refresh_available(page);
+#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+    tp_page_refresh_available(page, map);
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     tp_page_refresh_current(page);
 
     return outer_box;
@@ -562,7 +586,11 @@ tp_find_icon(GArray * array, const gchar * icon)
 }
 
 static void
+#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
 tp_page_refresh_available(ToolbarPage * page)
+#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+tp_page_refresh_available(ToolbarPage * page, GActionMap * map)
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
 {
     GtkTreeSelection *selection =
         gtk_tree_view_get_selection(GTK_TREE_VIEW(page->available));
@@ -583,6 +611,17 @@ tp_page_refresh_available(ToolbarPage * page)
     gtk_list_store_clear(GTK_LIST_STORE(model));
 
     for (item = 0; item < toolbar_button_count; item++) {
+#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
+        if (map) {
+            if (item > 0) {
+                gchar *action;
+
+                action = g_hash_table_lookup(legal, toolbar_buttons[item].pixmap_id);
+                if (action && !g_action_map_lookup_action(map, action))
+                    g_print("undefined action: \"%s\"\n", action);
+            }
+        }
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
         if (item > 0
             && (!g_hash_table_lookup(legal,
                                      toolbar_buttons[item].pixmap_id)
@@ -839,7 +878,11 @@ tp_page_add_selected(ToolbarPage * page)
 
     gtk_widget_set_sensitive(page->standard_button, TRUE);
     tp_page_refresh_preview(page);
+#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
     tp_page_refresh_available(page);
+#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+    tp_page_refresh_available(page, NULL);
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     balsa_toolbar_model_changed(page->model);
 }
 
@@ -870,7 +913,11 @@ tp_page_remove_selected(ToolbarPage * page)
 
     gtk_widget_set_sensitive(page->standard_button, TRUE);
     tp_page_refresh_preview(page);
+#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
     tp_page_refresh_available(page);
+#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
+    tp_page_refresh_available(page, NULL);
+#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
     balsa_toolbar_model_changed(page->model);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]