nemiver r891 - in trunk: . po src/uicommon



Author: dodji
Date: Sat Jul 26 16:33:46 2008
New Revision: 891
URL: http://svn.gnome.org/viewvc/nemiver?rev=891&view=rev

Log:
[ui-utils] Allow a "do not ask me again" check button in some dialogs

	* src/uicommon/nmv-ui-utils.cc,h: add a new entry point to display
	"Yes/No/" question dialogs that have a "Do not ask me again" check
	button. For now, only "Yes/No" dialogs have that feature because I
	have not felt the need for other dialogs. The feature can easily be
	added to the other dialogs as well.

Modified:
   trunk/ChangeLog
   trunk/po/POTFILES.in
   trunk/src/uicommon/nmv-ui-utils.cc
   trunk/src/uicommon/nmv-ui-utils.h

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Sat Jul 26 16:33:46 2008
@@ -34,6 +34,7 @@
 src/persp/dbgperspective/nmv-var-inspector.cc
 src/persp/dbgperspective/nmv-var-inspector-dialog.cc
 src/uicommon/nmv-source-editor.cc
+src/uicommon/nmv-ui-utils.cc
 src/workbench/nmv-workbench.cc
 src/persp/dbgperspective/nmv-global-vars-inspector-dialog.cc
 src/persp/dbgperspective/nmv-set-breakpoint-dialog.cc

Modified: trunk/src/uicommon/nmv-ui-utils.cc
==============================================================================
--- trunk/src/uicommon/nmv-ui-utils.cc	(original)
+++ trunk/src/uicommon/nmv-ui-utils.cc	Sat Jul 26 16:33:46 2008
@@ -25,6 +25,7 @@
  */
 #include "common/nmv-exception.h"
 #include "nmv-ui-utils.h"
+#include <glib/gi18n.h>
 
 using namespace nemiver::common ;
 
@@ -53,6 +54,60 @@
         }
     }
 }
+
+/// A message dialog that allows the user to chose to not
+/// be shown that dialog again
+class DontShowAgainMsgDialog : public Gtk::MessageDialog {
+
+    DontShowAgainMsgDialog (const DontShowAgainMsgDialog&);
+    DontShowAgainMsgDialog& operator= (const DontShowAgainMsgDialog&);
+
+    Gtk::CheckButton *m_check_button;
+public:
+    explicit DontShowAgainMsgDialog (const Glib::ustring &a_message,
+                                     bool a_propose_dont_ask_again = false,
+                                     bool a_use_markup = false,
+                                     Gtk::MessageType a_type = Gtk::MESSAGE_INFO,
+                                     Gtk::ButtonsType a_buttons = Gtk::BUTTONS_OK,
+                                     bool a_modal = false) :
+        Gtk::MessageDialog (a_message,
+                            a_use_markup,
+                            a_type,
+                            a_buttons,
+                            a_modal),
+        m_check_button (0)
+    {
+        if (a_propose_dont_ask_again)
+            pack_dont_ask_me_again_question ();
+    }
+
+    void pack_dont_ask_me_again_question ()
+    {
+        RETURN_IF_FAIL (!m_check_button);
+
+        m_check_button =
+            Gtk::manage (new Gtk::CheckButton (_("Do not ask me again")));
+        RETURN_IF_FAIL (m_check_button);
+
+        Gtk::Alignment *align =
+            Gtk::manage (new Gtk::Alignment);
+        RETURN_IF_FAIL (align);
+
+        align->add (*m_check_button);
+        RETURN_IF_FAIL (get_vbox ());
+
+        align->show_all ();
+        get_vbox ()->pack_end (*align, true, true, 6);
+    }
+
+    bool dont_ask_this_again () const
+    {
+        if (!m_check_button)
+            return false;
+        return m_check_button->get_active ();
+    }
+};//end class DontShowAgainMsgDialog
+
 int
 display_info (const UString &a_message)
 {
@@ -87,10 +142,23 @@
 {
     Gtk::MessageDialog dialog (a_message, false,
                                Gtk::MESSAGE_QUESTION,
-                               Gtk::BUTTONS_YES_NO,
-                               true) ;
-    dialog.set_default_response (Gtk::RESPONSE_OK) ;
-    return dialog.run () ;
+                               Gtk::BUTTONS_YES_NO, true);
+    dialog.set_default_response (Gtk::RESPONSE_OK);
+    return dialog.run ();
+}
+
+int
+ask_yes_no_question (const UString &a_message,
+                     bool a_propose_dont_ask_again,
+                     bool &a_dont_ask_this_again)
+{
+    DontShowAgainMsgDialog dialog (a_message, a_propose_dont_ask_again,
+                                   false, Gtk::MESSAGE_QUESTION,
+                                   Gtk::BUTTONS_YES_NO, true);
+    dialog.set_default_response (Gtk::RESPONSE_OK);
+    int result = dialog.run ();
+    a_dont_ask_this_again = dialog.dont_ask_this_again ();
+    return result;
 }
 
 int
@@ -108,6 +176,7 @@
     return dialog.run () ;
 }
 
+
 }//end namespace ui_utils
 }//end namespace nemiver
 

Modified: trunk/src/uicommon/nmv-ui-utils.h
==============================================================================
--- trunk/src/uicommon/nmv-ui-utils.h	(original)
+++ trunk/src/uicommon/nmv-ui-utils.h	Sat Jul 26 16:33:46 2008
@@ -130,7 +130,11 @@
 
 NEMIVER_API int display_error (const common::UString &a_message) ;
 
-NEMIVER_API int ask_yes_no_question (const common::UString &a_message) ;
+NEMIVER_API int ask_yes_no_question (const common::UString &a_message);
+
+NEMIVER_API int ask_yes_no_question (const common::UString &a_message,
+                                     bool a_propose_dont_ask_question,
+                                     bool &a_dont_ask_this_again) ;
 
 NEMIVER_API int ask_yes_no_cancel_question (const common::UString &a_message) ;
 



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