allow prompts to have titles specified. show a prompt when there are syntax errors...
authorDana Jansens <danakj@orodu.net>
Sun, 2 Mar 2008 22:12:11 +0000 (17:12 -0500)
committerDana Jansens <danakj@orodu.net>
Sun, 2 Mar 2008 22:12:11 +0000 (17:12 -0500)
openbox/actions/execute.c
openbox/actions/exit.c
openbox/actions/session.c
openbox/client.c
openbox/openbox.c
openbox/prompt.c
openbox/prompt.h

index 636dbeb..cb3ab24 100644 (file)
@@ -130,7 +130,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         };
 
         ocp = dup_options(options);
         };
 
         ocp = dup_options(options);
-        p = prompt_new(o->prompt, answers, 2, 0, 0,
+        p = prompt_new(o->prompt, _("Execute"), answers, 2, 0, 0,
                        prompt_cb, prompt_cleanup, ocp);
         prompt_show(p, NULL, FALSE);
 
                        prompt_cb, prompt_cleanup, ocp);
         prompt_show(p, NULL, FALSE);
 
index 67545cd..875a181 100644 (file)
@@ -54,6 +54,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         };
 
         p = prompt_new(_("Are you sure you want to exit Openbox?"),
         };
 
         p = prompt_new(_("Are you sure you want to exit Openbox?"),
+                       _("Exit Openbox"),
                        answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
         prompt_show(p, NULL, FALSE);
     }
                        answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
         prompt_show(p, NULL, FALSE);
     }
index ef1497c..8fb4f4d 100644 (file)
@@ -64,7 +64,7 @@ static gboolean logout_func(ObActionsData *data, gpointer options)
         };
 
         o2 = g_memdup(o, sizeof(Options));
         };
 
         o2 = g_memdup(o, sizeof(Options));
-        p = prompt_new(_("Are you sure you want to log out?"),
+        p = prompt_new(_("Are you sure you want to log out?"), NULL,
                        answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2);
         prompt_show(p, NULL, FALSE);
     }
                        answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2);
         prompt_show(p, NULL, FALSE);
     }
index 44b1287..82976f6 100644 (file)
@@ -3460,7 +3460,7 @@ static void client_prompt_kill(ObClient *self)
         answers[0].text = _("Cancel");  /* "no" */
         answers[1].text = y;            /* "yes" */
 
         answers[0].text = _("Cancel");  /* "no" */
         answers[1].text = y;            /* "yes" */
 
-        self->kill_prompt = prompt_new(m, answers,
+        self->kill_prompt = prompt_new(m, NULL, answers,
                                        sizeof(answers)/sizeof(answers[0]),
                                        OB_KILL_RESULT_NO, /* default = no */
                                        OB_KILL_RESULT_NO, /* cancel = no */
                                        sizeof(answers)/sizeof(answers[0]),
                                        OB_KILL_RESULT_NO, /* default = no */
                                        OB_KILL_RESULT_NO, /* cancel = no */
index 4354928..7221556 100644 (file)
@@ -229,6 +229,8 @@ gint main(gint argc, gchar **argv)
 
     if (screen_annex()) { /* it will be ours! */
         do {
 
     if (screen_annex()) { /* it will be ours! */
         do {
+            ObPrompt *xmlprompt = NULL;
+
             modkeys_startup(reconfigure);
 
             /* get the keycodes for keys we use */
             modkeys_startup(reconfigure);
 
             /* get the keycodes for keys we use */
@@ -376,7 +378,8 @@ gint main(gint argc, gchar **argv)
                     gchar *m;
 
                     m = g_strdup_printf(_("One or more XML syntax errors were found while parsing the Openbox configuration files.  See stdout for more information.  The last error seen was in file \"%s\" line %d, with message: %s"), e->file, e->line, e->message);
                     gchar *m;
 
                     m = g_strdup_printf(_("One or more XML syntax errors were found while parsing the Openbox configuration files.  See stdout for more information.  The last error seen was in file \"%s\" line %d, with message: %s"), e->file, e->line, e->message);
-                    prompt_show_message(m, _("Close"));
+                    xmlprompt =
+                        prompt_show_message(m, _("Openbox Syntax Error"), _("Close"));
                     g_free(m);
                     xmlResetError(e);
                 }
                     g_free(m);
                     xmlResetError(e);
                 }
@@ -386,6 +389,11 @@ gint main(gint argc, gchar **argv)
             ob_set_state(reconfigure ?
                          OB_STATE_RECONFIGURING : OB_STATE_EXITING);
 
             ob_set_state(reconfigure ?
                          OB_STATE_RECONFIGURING : OB_STATE_EXITING);
 
+            if (xmlprompt) {
+                prompt_unref(xmlprompt);
+                xmlprompt = NULL;
+            }
+
             if (!reconfigure) {
                 dock_remove_all();
                 client_unmanage_all();
             if (!reconfigure) {
                 dock_remove_all();
                 client_unmanage_all();
index e57b141..f531b70 100644 (file)
@@ -140,7 +140,7 @@ void prompt_shutdown(gboolean reconfig)
     RrAppearanceFree(prompt_a_msg);
 }
 
     RrAppearanceFree(prompt_a_msg);
 }
 
-ObPrompt* prompt_new(const gchar *msg,
+ObPrompt* prompt_new(const gchar *msg, const gchar *title,
                      const ObPromptAnswer *answers, gint n_answers,
                      gint default_result, gint cancel_result,
                      ObPromptCallback func, ObPromptCleanup cleanup,
                      const ObPromptAnswer *answers, gint n_answers,
                      gint default_result, gint cancel_result,
                      ObPromptCallback func, ObPromptCleanup cleanup,
@@ -172,6 +172,10 @@ ObPrompt* prompt_new(const gchar *msg,
     PROP_SET32(self->super.window, net_wm_window_type, atom,
                prop_atoms.net_wm_window_type_dialog);
 
     PROP_SET32(self->super.window, net_wm_window_type, atom,
                prop_atoms.net_wm_window_type_dialog);
 
+    /* set the window's title */
+    if (title)
+        PROP_SETS(self->super.window, net_wm_name, title);
+
     /* listen for key presses on the window */
     self->event_mask = KeyPressMask;
 
     /* listen for key presses on the window */
     self->event_mask = KeyPressMask;
 
@@ -624,16 +628,18 @@ static void prompt_show_message_cleanup(ObPrompt *p, gpointer data)
     prompt_unref(p);
 }
 
     prompt_unref(p);
 }
 
-void prompt_show_message(const gchar *msg, const gchar *answer)
+ObPrompt* prompt_show_message(const gchar *msg, const gchar *title,
+                              const gchar *answer)
 {
     ObPrompt *p;
     ObPromptAnswer ans[] = {
         { answer, 0 }
     };
 
 {
     ObPrompt *p;
     ObPromptAnswer ans[] = {
         { answer, 0 }
     };
 
-    p = prompt_new(msg, ans, 1, 0, 0,
+    p = prompt_new(msg, title, ans, 1, 0, 0,
                    prompt_show_message_cb, prompt_show_message_cleanup, NULL);
     prompt_show(p, NULL, FALSE);
                    prompt_show_message_cb, prompt_show_message_cleanup, NULL);
     prompt_show(p, NULL, FALSE);
+    return p;
 }
 
 static void prompt_run_callback(ObPrompt *self, gint result)
 }
 
 static void prompt_run_callback(ObPrompt *self, gint result)
index 007dae9..ef19990 100644 (file)
@@ -100,7 +100,7 @@ void prompt_shutdown(gboolean reconfig);
          callback function returns TRUE.
   @param data User defined data which will be passed to the callback
 */
          callback function returns TRUE.
   @param data User defined data which will be passed to the callback
 */
-ObPrompt* prompt_new(const gchar *msg,
+ObPrompt* prompt_new(const gchar *msg, const gchar *title,
                      const ObPromptAnswer *answers, gint n_answers,
                      gint default_result, gint cancel_result,
                      ObPromptCallback func, ObPromptCleanup cleanup,
                      const ObPromptAnswer *answers, gint n_answers,
                      gint default_result, gint cancel_result,
                      ObPromptCallback func, ObPromptCleanup cleanup,
@@ -116,6 +116,7 @@ gboolean prompt_key_event(ObPrompt *self, XEvent *e);
 gboolean prompt_mouse_event(ObPrompt *self, XEvent *e);
 void prompt_cancel(ObPrompt *self);
 
 gboolean prompt_mouse_event(ObPrompt *self, XEvent *e);
 void prompt_cancel(ObPrompt *self);
 
-void prompt_show_message(const gchar *msg, const gchar *answer);
+ObPrompt* prompt_show_message(const gchar *msg, const gchar *title,
+                              const gchar *answer);
 
 #endif
 
 #endif