[gnome-system-monitor] Don't display an error dialog when open files regex is invalid or incomplete (because user is still



commit eac9360cded0a1c9f7af26469f4414959bc84b12
Author: BenoƮt Dejean <bdejean gmail com>
Date:   Sat Mar 14 22:38:49 2015 +0100

    Don't display an error dialog when open files regex is invalid or incomplete (because user is still 
typing). Instead, set the search entry style to error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746208.

 src/lsof.cpp |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/src/lsof.cpp b/src/lsof.cpp
index 7f0d179..6f161c1 100644
--- a/src/lsof.cpp
+++ b/src/lsof.cpp
@@ -89,6 +89,7 @@ namespace
         GtkLabel *count;
         GsmApplication *app;
         bool case_insensitive;
+        bool regex_error_displayed;
 
 
         GUI()
@@ -97,7 +98,8 @@ namespace
               window(NULL),
               count(NULL),
               app(NULL),
-              case_insensitive()
+              case_insensitive(),
+              regex_error_displayed(false)
         {
             procman_debug("New Lsof GUI %p", this);
         }
@@ -109,24 +111,6 @@ namespace
         }
 
 
-        void display_regex_error(const Glib::RegexError& error)
-        {
-            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
-                                          _("Error"),
-                                          _("'%s' is not a valid Perl regular expression."),
-                                          "%s");
-            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), 
error.what().c_str()));
-            g_free(msg);
-
-            Gtk::MessageDialog dialog(message,
-                                      true, // use markup
-                                      Gtk::MESSAGE_ERROR,
-                                      Gtk::BUTTONS_OK,
-                                      true); // modal
-            dialog.run();
-        }
-
-
         void update_count(unsigned count)
         {
             gchar *title;
@@ -151,6 +135,8 @@ namespace
             typedef std::set<string> MatchSet;
             typedef MatchSet::const_iterator iterator;
 
+            bool regex_error = false;
+
             gtk_list_store_clear(this->model);
             try {
                 Lsof lsof(this->pattern(), this->case_insensitive);
@@ -179,7 +165,16 @@ namespace
                 this->update_count(count);
             }
             catch (Glib::RegexError& error) {
-                this->display_regex_error(error);
+                regex_error = true;
+            }
+
+            if (regex_error && !this->regex_error_displayed) {
+                this->regex_error_displayed = true;
+                gtk_style_context_add_class(gtk_widget_get_style_context(GTK_WIDGET(entry)), "error");
+            }
+            else if (!regex_error && this->regex_error_displayed) {
+                this->regex_error_displayed = false;
+                gtk_style_context_remove_class(gtk_widget_get_style_context(GTK_WIDGET(entry)), "error");
             }
         }
 


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