ToggleDebug action which toggles --debug while running.
authorMikael Magnusson <mikachu@comhem.se>
Thu, 26 Jul 2007 19:09:50 +0000 (21:09 +0200)
committerMikael Magnusson <mikachu@comhem.se>
Wed, 16 Jan 2008 06:19:10 +0000 (07:19 +0100)
Makefile.am
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/toggledebug.c [new file with mode: 0644]
openbox/debug.c

index 34ee07e44ec2ad77446df83e792231e6be1f4bf5..4252b4e5f931cc5d77186d6948c86e431cbc6b32 100644 (file)
@@ -185,6 +185,7 @@ openbox_openbox_SOURCES = \
        openbox/actions/shade.c \
        openbox/actions/showdesktop.c \
        openbox/actions/showmenu.c \
+       openbox/actions/toggledebug.c \
        openbox/actions/unfocus.c \
        openbox/actions.c \
        openbox/actions.h \
index 06858c05e693c4602581f8f1a368b53fd21e2190..db37840bded1c862e8879ee7b759b076ba8cefc1 100644 (file)
@@ -38,4 +38,5 @@ void action_all_startup()
     action_growtoedge_startup();
     action_if_startup();
     action_focustobottom_startup();
+    action_toggledebug_startup();
 }
index 5f3f573f247a967e3c1e19f3b5c85b29a8584b7b..95b69e1fe73a2130e424046e3b904bd6303542c7 100644 (file)
@@ -39,5 +39,6 @@ void action_movetoedge_startup();
 void action_growtoedge_startup();
 void action_if_startup();
 void action_focustobottom_startup();
+void action_toggledebug_startup();
 
 #endif
diff --git a/openbox/actions/toggledebug.c b/openbox/actions/toggledebug.c
new file mode 100644 (file)
index 0000000..4942d72
--- /dev/null
@@ -0,0 +1,24 @@
+#include "openbox/actions.h"
+#include "openbox/stacking.h"
+#include "openbox/debug.h"
+
+static gboolean run_func(ObActionsData *data, gpointer options);
+extern gboolean debug_show;
+
+void action_toggledebug_startup(void)
+{
+    actions_register("toggledebug",
+                     NULL, NULL,
+                     run_func,
+                     NULL, NULL);
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+    if (debug_show) ob_debug("Debug output turned %s\n", "off");
+    ob_debug_show_output(!debug_show);
+    if (debug_show) ob_debug("Debug output turned %s\n", "on");
+
+    return FALSE;
+}
index 0fceba489d64e90c79178b041830d7e9b1c07f2f..faabc63cfda3a5c42b42286bcf8d6d78d977b210 100644 (file)
 #include <stdarg.h>
 #include <stdio.h>
 
-static gboolean show;
+gboolean debug_show;
 
 void ob_debug_show_output(gboolean enable)
 {
-    show = enable;
+    debug_show = enable;
 }
 
 void ob_debug(const gchar *a, ...)
 {
     va_list vl;
 
-    if (show) {
+    if (debug_show) {
         fprintf(stderr, "DEBUG: ");
         va_start(vl, a);
         vfprintf(stderr, a, vl);
@@ -56,7 +56,7 @@ void ob_debug_type(ObDebugType type, const gchar *a, ...)
 
     g_assert(type < OB_DEBUG_TYPE_NUM);
 
-    if (show && enabled_types[type]) {
+    if (debug_show && enabled_types[type]) {
         switch (type) {
         case OB_DEBUG_FOCUS:
             fprintf(stderr, "FOCUS: ");