[Gurlchecker-commits] r722 - in trunk: . src ui

esaracco at users.labs.libre-entreprise.org esaracco at users.labs.libre-entreprise.org
Sun Jan 24 08:36:11 CET 2010


Author: esaracco
Date: 2010-01-24 07:36:11 +0000 (Sun, 24 Jan 2010)
New Revision: 722

Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/callbacks.c
   trunk/ui/gurlchecker.glade
Log:
Rewrote display filters event handlers to prevent submenu closure when a checkbox is toggled.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-01-23 18:10:14 UTC (rev 721)
+++ trunk/ChangeLog	2010-01-24 07:36:11 UTC (rev 722)
@@ -1,3 +1,10 @@
+2010-01-24 Emmanuel Saracco <esaracco at users.labs.libre-entreprise.org>
+
+	* GUI:
+
+	  - Rewrote display filters event handlers to prevent submenu closure
+	    when a checkbox is toggled.
+
 2010-01-23 Emmanuel Saracco <esaracco at users.labs.libre-entreprise.org>
 
 	* GUI:

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2010-01-23 18:10:14 UTC (rev 721)
+++ trunk/configure.in	2010-01-24 07:36:11 UTC (rev 722)
@@ -2,7 +2,7 @@
 AC_PREREQ(2.54)
 
 AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(gurlchecker, 0.11.2svn2010012301)
+AM_INIT_AUTOMAKE(gurlchecker, 0.11.2svn2010012400)
 AM_CONFIG_HEADER(config.h)
 AC_CONFIG_MACRO_DIR([m4])
 

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2010-01-23 18:10:14 UTC (rev 721)
+++ trunk/src/callbacks.c	2010-01-24 07:36:11 UTC (rev 722)
@@ -31,274 +31,195 @@
 
 #include "callbacks.h"
 
-void
-on_search_close_clicked (GtkButton * button, gpointer user_data)
-{
-  uc_search_set_exit (TRUE);
 
-  if (treestore_search != NULL)
-    g_object_unref (G_OBJECT (treestore_search)), treestore_search = NULL;
-
-  WSENS ("mwm_find", TRUE);
-  WSENS ("mwm_project", TRUE);
-  WSENS ("mw_bt_new", TRUE);
-  WSENS ("mw_bt_open", TRUE);
-}
-
-void
-on_view_link_content_activate (GtkMenuItem * menuitem, gpointer user_data)
+gboolean on_widget_deactivate_brelease_event (GtkWidget *widget,
+                                              GdkEvent *event,
+                                              gpointer user_data)
 {
-  uc_application_view_source_dialog_show ();
+  return (event->type == GDK_BUTTON_RELEASE);
 }
 
-void
-on_w3c_validate_activate (GtkMenuItem * menuitem, gpointer user_data)
-{
-  uc_application_w3c_validate ();
-}
 
-void
-on_quit_activate (GtkMenuItem * menuitem, gpointer user_data)
+gboolean on_display_checkbox_status_event (GtkWidget *widget, GdkEvent *event,
+                                           gpointer user_data)
 {
-  if (!uc_application_quit ())
-    gtk_exit (0);
-}
+  const gchar *wname = NULL;
+  UCDisplayStatus status;
 
-void
-on_about_activate (GtkMenuItem * menuitem, gpointer user_data)
-{
-  uc_application_about_dialog_show ();
-}
 
-
-void
-on_settings_activate (GtkMenuItem * menuitem, gpointer user_data)
-{
-  uc_application_settings_dialog_show ();
-}
-
-
-void
-on_display_badlinks_toggled (GtkCheckMenuItem *check, gpointer user_data)
-{
-  if (gtk_check_menu_item_get_active (check))
+  if (event->type == GDK_BUTTON_RELEASE)
   {
-    uc_application_reset_menu_types ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_STATUS_SET (UC_DISPLAY_STATUS_BADLINKS);
-  }
-  else
-    UC_DISPLAY_STATUS_UNSET (UC_DISPLAY_STATUS_BADLINKS);
+    wname = gtk_widget_get_name (widget);
 
-  uc_application_main_tree_apply_filters ("mwm_link_status");
-}
+    if (strcmp (wname, "mwm_display_goodlinks") == 0)
+      status = UC_DISPLAY_STATUS_GOODLINKS;
+    else if (strcmp (wname, "mwm_display_badlinks") == 0)
+      status = UC_DISPLAY_STATUS_BADLINKS;
+    else if (strcmp (wname, "mwm_display_timeouts") == 0)
+      status = UC_DISPLAY_STATUS_TIMEOUTS;
+    else if (strcmp (wname, "mwm_display_malformedlinks") == 0)
+      status = UC_DISPLAY_STATUS_MALFORMEDLINKS;
+    else if (strcmp (wname, "mwm_display_security_alerts") == 0)
+      status = UC_DISPLAY_STATUS_SECURITY_ALERTS;
+    else if (strcmp (wname, "mwm_display_w3c_alerts") == 0)
+      status = UC_DISPLAY_STATUS_W3C_ALERTS;
+    else
+      g_assert_not_reached ();
 
+    if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
+    {
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), TRUE);
+      uc_application_reset_menu_types ();
+      uc_application_reset_menu_protocols ();
+      UC_DISPLAY_STATUS_SET (status);
+    }
+    else
+    {
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), FALSE);
+      UC_DISPLAY_STATUS_UNSET (status);
+    }
+  
+    uc_application_main_tree_apply_filters ("mwm_link_status");
 
-void
-on_display_goodlinks_toggled (GtkCheckMenuItem *check, gpointer user_data)
-{
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_types ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_STATUS_SET (UC_DISPLAY_STATUS_GOODLINKS);
+    return TRUE;
   }
-  else
-    UC_DISPLAY_STATUS_UNSET (UC_DISPLAY_STATUS_GOODLINKS);
 
-  uc_application_main_tree_apply_filters ("mwm_link_status");
+  return FALSE;
 }
 
 
-void
-on_display_security_alerts_toggled (GtkCheckMenuItem *check, gpointer user_data)
+gboolean on_display_checkbox_type_event (GtkWidget *widget, GdkEvent *event,
+                                         gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_types ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_STATUS_SET (UC_DISPLAY_STATUS_SECURITY_ALERTS);
-  }
-  else
-    UC_DISPLAY_STATUS_UNSET (UC_DISPLAY_STATUS_SECURITY_ALERTS);
+  const gchar *wname = NULL;
+  UCDisplayType type;
 
-  uc_application_main_tree_apply_filters ("mwm_link_status");
-}
 
-
-void
-on_display_w3c_alerts_toggled (GtkCheckMenuItem *check, gpointer user_data)
-{
-  if (gtk_check_menu_item_get_active (check))
+  if (event->type == GDK_BUTTON_RELEASE)
   {
-    uc_application_reset_menu_types ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_STATUS_SET (UC_DISPLAY_STATUS_W3C_ALERTS);
-  }
-  else
-    UC_DISPLAY_STATUS_UNSET (UC_DISPLAY_STATUS_W3C_ALERTS);
+    wname = gtk_widget_get_name (widget);
 
-  uc_application_main_tree_apply_filters ("mwm_link_status");
-}
+    if (strcmp (wname, "mwm_document_type") == 0)
+      type = UC_DISPLAY_TYPE_HREF;
+    else if (strcmp (wname, "mwm_image_type") == 0)
+      type = UC_DISPLAY_TYPE_IMAGE;
+    else if (strcmp (wname, "mwm_frame_type") == 0)
+      type = UC_DISPLAY_TYPE_FRAME;
+    else if (strcmp (wname, "mwm_email_type") == 0)
+      type = UC_DISPLAY_TYPE_EMAIL;
+    else if (strcmp (wname, "mwm_stylesheet_type") == 0)
+      type = UC_DISPLAY_TYPE_CSS;
+    else
+      g_assert_not_reached ();
 
+    if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
+    {
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), TRUE);
+      uc_application_reset_menu_status ();
+      uc_application_reset_menu_protocols ();
+      UC_DISPLAY_TYPE_SET (type);
+    }
+    else
+    {
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), FALSE);
+      UC_DISPLAY_TYPE_UNSET (type);
+    }
+  
+    uc_application_main_tree_apply_filters ("mwm_link_type");
 
-void
-on_display_malformedlinks_toggled (GtkCheckMenuItem *check, gpointer user_data)
-{
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_types ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_STATUS_SET (UC_DISPLAY_STATUS_MALFORMEDLINKS);
+    return TRUE;
   }
-  else
-    UC_DISPLAY_STATUS_UNSET (UC_DISPLAY_STATUS_MALFORMEDLINKS);
 
-  uc_application_main_tree_apply_filters ("mwm_link_status");
+  return FALSE;
 }
 
 
-void
-on_display_timeouts_toggled (GtkCheckMenuItem *check, gpointer user_data)
+gboolean on_display_checkbox_protocol_event (GtkWidget *widget, GdkEvent *event,
+                                             gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_types ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_STATUS_SET (UC_DISPLAY_STATUS_TIMEOUTS);
-  }
-  else
-    UC_DISPLAY_STATUS_UNSET (UC_DISPLAY_STATUS_TIMEOUTS);
+  const gchar *wname = NULL;
+  UCDisplayProto proto;
 
-  uc_application_main_tree_apply_filters ("mwm_link_status");
-}
 
-
-void
-on_display_documents_toggled (GtkCheckMenuItem *check, gpointer user_data)
-{
-  if (gtk_check_menu_item_get_active (check))
+  if (event->type == GDK_BUTTON_RELEASE)
   {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_TYPE_SET (UC_DISPLAY_TYPE_HREF);
-  }
-  else
-    UC_DISPLAY_TYPE_UNSET (UC_DISPLAY_TYPE_HREF);
+    wname = gtk_widget_get_name (widget);
 
-  uc_application_main_tree_apply_filters ("mwm_link_type");
-}
+    if (strcmp (wname, "mwm_http_protocol") == 0)
+      proto = UC_DISPLAY_PROTO_HTTP;
+    else if (strcmp (wname, "mwm_https_protocol") == 0)
+      proto = UC_DISPLAY_PROTO_HTTPS;
+    else if (strcmp (wname, "mwm_ftp_protocol") == 0)
+      proto = UC_DISPLAY_PROTO_FTP;
+    else
+      g_assert_not_reached ();
 
+    if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
+    {
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), TRUE);
+      uc_application_reset_menu_status ();
+      uc_application_reset_menu_types ();
+      UC_DISPLAY_TYPE_SET (proto);
+    }
+    else
+    {
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), FALSE);
+      UC_DISPLAY_TYPE_UNSET (proto);
+    }
+  
+    uc_application_main_tree_apply_filters ("mwm_protocol");
 
-void
-on_display_images_toggled (GtkCheckMenuItem *check, gpointer user_data)
-{
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_TYPE_SET (UC_DISPLAY_TYPE_IMAGE);
+    return TRUE;
   }
-  else
-    UC_DISPLAY_TYPE_UNSET (UC_DISPLAY_TYPE_IMAGE);
 
-  uc_application_main_tree_apply_filters ("mwm_link_type");
+  return FALSE;
 }
 
 
 void
-on_display_frames_toggled (GtkCheckMenuItem *check, gpointer user_data)
+on_search_close_clicked (GtkButton * button, gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_TYPE_SET (UC_DISPLAY_TYPE_FRAME);
-  }
-  else
-    UC_DISPLAY_TYPE_UNSET (UC_DISPLAY_TYPE_FRAME);
+  uc_search_set_exit (TRUE);
 
-  uc_application_main_tree_apply_filters ("mwm_link_type");
+  if (treestore_search != NULL)
+    g_object_unref (G_OBJECT (treestore_search)), treestore_search = NULL;
+
+  WSENS ("mwm_find", TRUE);
+  WSENS ("mwm_project", TRUE);
+  WSENS ("mw_bt_new", TRUE);
+  WSENS ("mw_bt_open", TRUE);
 }
 
-
 void
-on_display_emails_toggled (GtkCheckMenuItem *check, gpointer user_data)
+on_view_link_content_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_TYPE_SET (UC_DISPLAY_TYPE_EMAIL);
-  }
-  else
-    UC_DISPLAY_TYPE_UNSET (UC_DISPLAY_TYPE_EMAIL);
-
-  uc_application_main_tree_apply_filters ("mwm_link_type");
+  uc_application_view_source_dialog_show ();
 }
 
-
 void
-on_display_css_toggled (GtkCheckMenuItem *check, gpointer user_data)
+on_w3c_validate_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_protocols ();
-    UC_DISPLAY_TYPE_SET (UC_DISPLAY_TYPE_CSS);
-  }
-  else
-    UC_DISPLAY_TYPE_UNSET (UC_DISPLAY_TYPE_CSS);
-
-  uc_application_main_tree_apply_filters ("mwm_link_type");
+  uc_application_w3c_validate ();
 }
 
-
 void
-on_display_http_toggled (GtkCheckMenuItem *check, gpointer user_data)
+on_quit_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_types ();
-    UC_DISPLAY_PROTO_SET (UC_DISPLAY_PROTO_HTTP);
-  }
-  else
-    UC_DISPLAY_PROTO_UNSET (UC_DISPLAY_PROTO_HTTP);
-
-  uc_application_main_tree_apply_filters ("mwm_protocol");
+  if (!uc_application_quit ())
+    gtk_exit (0);
 }
 
-
 void
-on_display_https_toggled (GtkCheckMenuItem *check, gpointer user_data)
+on_about_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_types ();
-    UC_DISPLAY_PROTO_SET (UC_DISPLAY_PROTO_HTTPS);
-  }
-  else
-    UC_DISPLAY_PROTO_UNSET (UC_DISPLAY_PROTO_HTTPS);
-
-  uc_application_main_tree_apply_filters ("mwm_protocol");
+  uc_application_about_dialog_show ();
 }
 
 
 void
-on_display_ftp_toggled (GtkCheckMenuItem *check, gpointer user_data)
+on_settings_activate (GtkMenuItem * menuitem, gpointer user_data)
 {
-  if (gtk_check_menu_item_get_active (check))
-  {
-    uc_application_reset_menu_status ();
-    uc_application_reset_menu_types ();
-    UC_DISPLAY_PROTO_SET (UC_DISPLAY_PROTO_FTP);
-  }
-  else
-    UC_DISPLAY_PROTO_UNSET (UC_DISPLAY_PROTO_FTP);
-
-  uc_application_main_tree_apply_filters ("mwm_protocol");
+  uc_application_settings_dialog_show ();
 }
 
 

Modified: trunk/ui/gurlchecker.glade
===================================================================
--- trunk/ui/gurlchecker.glade	2010-01-23 18:10:14 UTC (rev 721)
+++ trunk/ui/gurlchecker.glade	2010-01-24 07:36:11 UTC (rev 722)
@@ -5402,18 +5402,19 @@
                             <property name="use_underline">True</property>
                             <child>
                               <widget class="GtkMenu" id="mwm_link_status_menu">
+                                <signal name="event" handler="on_widget_deactivate_brelease_event"/>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_display_security_alerts">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Security alerts</property>
-                                    <signal name="toggled" handler="on_display_security_alerts_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_status_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_display_w3c_alerts">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">W3C alerts</property>
-                                    <signal name="toggled" handler="on_display_w3c_alerts_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_status_event"/>
                                   </widget>
                                 </child>
                                 <child>
@@ -5425,28 +5426,28 @@
                                   <widget class="GtkCheckMenuItem" id="mwm_display_goodlinks">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Good links</property>
-                                    <signal name="toggled" handler="on_display_goodlinks_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_status_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_display_badlinks">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Bad links</property>
-                                    <signal name="toggled" handler="on_display_badlinks_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_status_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_display_malformedlinks">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Malformed links</property>
-                                    <signal name="toggled" handler="on_display_malformedlinks_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_status_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_display_timeouts">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Timeouts</property>
-                                    <signal name="toggled" handler="on_display_timeouts_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_status_event"/>
                                   </widget>
                                 </child>
                               </widget>
@@ -5460,39 +5461,40 @@
                             <property name="use_underline">True</property>
                             <child>
                               <widget class="GtkMenu" id="mwm_link_type_menu">
+                                <signal name="event" handler="on_widget_deactivate_brelease_event"/>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_document_type">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Document</property>
-                                    <signal name="toggled" handler="on_display_documents_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_type_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_image_type">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Image</property>
-                                    <signal name="toggled" handler="on_display_images_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_type_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_frame_type">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Frame</property>
-                                    <signal name="toggled" handler="on_display_frames_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_type_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_email_type">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">E-Mail</property>
-                                    <signal name="toggled" handler="on_display_emails_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_type_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_stylesheet_type">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">Stylesheet</property>
-                                    <signal name="toggled" handler="on_display_css_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_type_event"/>
                                   </widget>
                                 </child>
                               </widget>
@@ -5506,25 +5508,26 @@
                             <property name="use_underline">True</property>
                             <child>
                               <widget class="GtkMenu" id="mwm_protocol_menu">
+                                <signal name="event" handler="on_widget_deactivate_brelease_event"/>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_http_protocol">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">HTTP</property>
-                                    <signal name="toggled" handler="on_display_http_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_protocol_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_https_protocol">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">HTTPS</property>
-                                    <signal name="toggled" handler="on_display_https_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_protocol_event"/>
                                   </widget>
                                 </child>
                                 <child>
                                   <widget class="GtkCheckMenuItem" id="mwm_ftp_protocol">
                                     <property name="visible">True</property>
                                     <property name="label" translatable="yes">FTP</property>
-                                    <signal name="toggled" handler="on_display_ftp_toggled"/>
+                                    <signal name="event" handler="on_display_checkbox_protocol_event"/>
                                   </widget>
                                 </child>
                               </widget>



More information about the Gurlchecker-commits mailing list