[frogr] Allow enabling/disabling tooltips in the main window



commit 70914d446bc907c58a38d8b71723363c3cc8bfd1
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Fri Apr 22 22:15:29 2011 +0200

    Allow enabling/disabling tooltips in the main window

 src/frogr-config.c          |   31 +++++++++++++++++++++++++++++++
 src/frogr-config.h          |    4 ++++
 src/frogr-main-view.c       |   15 ++++++++++++++-
 src/frogr-settings-dialog.c |   33 ++++++++++++++++++++++++++++-----
 4 files changed, 77 insertions(+), 6 deletions(-)
---
diff --git a/src/frogr-config.c b/src/frogr-config.c
index 5c4b7ac..414d61b 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -60,6 +60,7 @@ struct _FrogrConfigPrivate
 
   gboolean tags_autocompletion;
   gboolean remove_file_extensions;
+  gboolean enable_tooltips;
 
   gboolean use_proxy;
   gchar *proxy_host;
@@ -226,6 +227,16 @@ _load_settings (FrogrConfig *self, const gchar *config_dir)
               xmlFree (content);
             }
 
+          if (!xmlStrcmp (node->name, (const xmlChar*) "enable-tooltips"))
+            {
+              xmlChar *content = NULL;
+
+              content = xmlNodeGetContent (node);
+              priv->enable_tooltips = !xmlStrcmp (content, (const xmlChar*) "1");
+
+              xmlFree (content);
+            }
+
           if (!xmlStrcmp (node->name, (const xmlChar*) "default-visibility"))
             _load_visibility_xml (self, xml, node);
 
@@ -548,6 +559,7 @@ _save_settings (FrogrConfig *self)
   /* Other stuff */
   _xml_add_string_child (root, "tags-autocompletion", priv->tags_autocompletion ? "1" : "0");
   _xml_add_string_child (root, "remove-file-extensions", priv->remove_file_extensions ? "1" : "0");
+  _xml_add_string_child (root, "enable-tooltips", priv->enable_tooltips ? "1" : "0");
 
   /* Use proxy */
   node = xmlNewNode (NULL, (const xmlChar*) "http-proxy");
@@ -773,6 +785,7 @@ frogr_config_init (FrogrConfig *self)
   priv->content_type = FSP_CONTENT_TYPE_PHOTO;
   priv->tags_autocompletion = TRUE;
   priv->remove_file_extensions = TRUE;
+  priv->enable_tooltips = TRUE;
   priv->use_proxy = FALSE;
   priv->proxy_host = NULL;
   priv->proxy_port = NULL;
@@ -1072,6 +1085,24 @@ frogr_config_get_remove_file_extensions (FrogrConfig *self)
 }
 
 void
+frogr_config_set_enable_tooltips (FrogrConfig *self, gboolean value)
+{
+  g_return_if_fail (FROGR_IS_CONFIG (self));
+
+  FrogrConfigPrivate * priv = FROGR_CONFIG_GET_PRIVATE (self);
+  priv->enable_tooltips = value;
+}
+
+gboolean
+frogr_config_get_enable_tooltips (FrogrConfig *self)
+{
+  g_return_val_if_fail (FROGR_IS_CONFIG (self), FALSE);
+
+  FrogrConfigPrivate *priv = FROGR_CONFIG_GET_PRIVATE (self);
+  return priv->enable_tooltips;
+}
+
+void
 frogr_config_set_use_proxy (FrogrConfig *self, gboolean value)
 {
   g_return_if_fail (FROGR_IS_CONFIG (self));
diff --git a/src/frogr-config.h b/src/frogr-config.h
index 1b6ea96..14d8ad3 100644
--- a/src/frogr-config.h
+++ b/src/frogr-config.h
@@ -110,6 +110,10 @@ void frogr_config_set_remove_file_extensions (FrogrConfig *self, gboolean value)
 
 gboolean frogr_config_get_remove_file_extensions (FrogrConfig *self);
 
+void frogr_config_set_enable_tooltips (FrogrConfig *self, gboolean value);
+
+gboolean frogr_config_get_enable_tooltips (FrogrConfig *self);
+
 void frogr_config_set_use_proxy (FrogrConfig *self, gboolean value);
 
 gboolean frogr_config_get_use_proxy (FrogrConfig *self);
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index ba5d0bf..018953b 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -23,6 +23,7 @@
 #include "frogr-main-view.h"
 
 #include "frogr-account.h"
+#include "frogr-config.h"
 #include "frogr-controller.h"
 #include "frogr-global-defs.h"
 #include "frogr-main-view-model.h"
@@ -67,6 +68,7 @@ G_DEFINE_TYPE (FrogrMainView, frogr_main_view, G_TYPE_OBJECT)
 typedef struct _FrogrMainViewPrivate {
   FrogrMainViewModel *model;
   FrogrController *controller;
+  FrogrConfig *config;
   GtkWindow *window;
 
   GtkWidget *menu_bar;
@@ -814,6 +816,10 @@ _on_icon_view_query_tooltip (GtkWidget *icon_view,
   self = FROGR_MAIN_VIEW (data);
   priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
 
+  /* Disabled by configuration */
+  if (!frogr_config_get_enable_tooltips (priv->config))
+    return FALSE;
+
   /* Check whether we're asking for a tooltip over a picture */
   gtk_icon_view_convert_widget_to_bin_window_coords (GTK_ICON_VIEW (icon_view),
                                                      x, y, &bw_x, &bw_y);
@@ -1474,6 +1480,12 @@ _frogr_main_view_dispose (GObject *object)
       priv->controller = NULL;
     }
 
+  if (priv->config)
+    {
+      g_object_unref (priv->config);
+      priv->config = NULL;
+    }
+
   if (priv->tree_model)
     {
       g_object_unref (priv->tree_model);
@@ -1529,9 +1541,10 @@ frogr_main_view_init (FrogrMainView *self)
   GtkWidget *main_vbox;
 #endif
 
-  /* Init model and controller */
+  /* Init model, controller and configuration */
   priv->model = frogr_main_view_model_new ();
   priv->controller = g_object_ref (frogr_controller_get_instance ());
+  priv->config = g_object_ref (frogr_config_get_instance ());
 
   /* Init main model's state description */
   _update_state_description (self);
diff --git a/src/frogr-settings-dialog.c b/src/frogr-settings-dialog.c
index 821e451..a347695 100644
--- a/src/frogr-settings-dialog.c
+++ b/src/frogr-settings-dialog.c
@@ -55,6 +55,7 @@ typedef struct _FrogrSettingsDialogPrivate {
   GtkWidget *restricted_rb;
   GtkWidget *tags_autocompletion_cb;
   GtkWidget *remove_file_extensions_cb;
+  GtkWidget *enable_tooltips_cb;
 
   GtkWidget *use_proxy_cb;
   GtkWidget *proxy_host_label;
@@ -72,6 +73,7 @@ typedef struct _FrogrSettingsDialogPrivate {
   gboolean show_in_search;
   gboolean tags_autocompletion;
   gboolean remove_file_extensions;
+  gboolean enable_tooltips;
   FspSafetyLevel safety_level;
   FspContentType content_type;
 
@@ -286,7 +288,15 @@ _add_general_page (FrogrSettingsDialog *self, GtkNotebook *notebook)
 
   box1 = gtk_vbox_new (FALSE, 6);
 
-  cbutton = gtk_check_button_new_with_mnemonic (_("Ena_ble tags auto-completion"));
+  cbutton = gtk_check_button_new_with_mnemonic (_("Enable Tooltips in Main Window"));
+  gtk_box_pack_start (GTK_BOX (box1), cbutton, FALSE, FALSE, 0);
+  priv->enable_tooltips_cb = cbutton;
+
+  g_signal_connect (G_OBJECT (priv->enable_tooltips_cb), "toggled",
+                    G_CALLBACK (_on_button_toggled),
+                    self);
+
+  cbutton = gtk_check_button_new_with_mnemonic (_("Ena_ble Tags Auto-Completion"));
   gtk_box_pack_start (GTK_BOX (box1), cbutton, FALSE, FALSE, 0);
   priv->tags_autocompletion_cb = cbutton;
 
@@ -294,16 +304,16 @@ _add_general_page (FrogrSettingsDialog *self, GtkNotebook *notebook)
                     G_CALLBACK (_on_button_toggled),
                     self);
 
-  cbutton = gtk_check_button_new_with_mnemonic (_("Remo_ve file extensions from names before upload"));
+  cbutton = gtk_check_button_new_with_mnemonic (_("Remo_ve File Extensions from Picture Titles"));
   gtk_box_pack_start (GTK_BOX (box1), cbutton, FALSE, FALSE, 0);
   priv->remove_file_extensions_cb = cbutton;
 
-  gtk_box_pack_start (GTK_BOX (vbox), box1, FALSE, FALSE, 0);
-
   g_signal_connect (G_OBJECT (priv->remove_file_extensions_cb), "toggled",
                     G_CALLBACK (_on_button_toggled),
                     self);
 
+  gtk_box_pack_start (GTK_BOX (vbox), box1, FALSE, FALSE, 0);
+
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
   gtk_notebook_append_page (notebook, vbox, gtk_label_new_with_mnemonic (_("_General")));
 }
@@ -434,6 +444,7 @@ _fill_dialog_with_data (FrogrSettingsDialog *self)
   priv->safety_level = frogr_config_get_default_safety_level (priv->config);
   priv->tags_autocompletion = frogr_config_get_tags_autocompletion (priv->config);
   priv->remove_file_extensions = frogr_config_get_remove_file_extensions (priv->config);
+  priv->enable_tooltips = frogr_config_get_enable_tooltips (priv->config);
   priv->use_proxy = frogr_config_get_use_proxy (priv->config);
 
   g_free (priv->proxy_host);
@@ -489,6 +500,9 @@ _fill_dialog_with_data (FrogrSettingsDialog *self)
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->remove_file_extensions_cb),
                                 priv->remove_file_extensions);
 
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enable_tooltips_cb),
+                                priv->enable_tooltips);
+
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_proxy_cb),
                                 priv->use_proxy);
   if (priv->proxy_host)
@@ -524,6 +538,7 @@ _save_data (FrogrSettingsDialog *self)
 
   frogr_config_set_tags_autocompletion (priv->config, priv->tags_autocompletion);
   frogr_config_set_remove_file_extensions (priv->config, priv->remove_file_extensions);
+  frogr_config_set_enable_tooltips (priv->config, priv->enable_tooltips);
 
   frogr_config_set_use_proxy (priv->config, priv->use_proxy);
 
@@ -658,7 +673,13 @@ _on_button_toggled (GtkToggleButton *button, gpointer data)
   if (GTK_WIDGET (button) == priv->remove_file_extensions_cb)
     {
       priv->remove_file_extensions = active;
-      DEBUG ("Remo_ve file extensions before upload set to %s", active ? "TRUE" : "FALSE");
+      DEBUG ("Remove file extensions before upload set to %s", active ? "TRUE" : "FALSE");
+    }
+
+  if (GTK_WIDGET (button) == priv->enable_tooltips_cb)
+    {
+      priv->enable_tooltips = active;
+      DEBUG ("Enable Tooltips in Main Window set to %s", active ? "TRUE" : "FALSE");
     }
 
   if (GTK_WIDGET (button) == priv->use_proxy_cb)
@@ -785,6 +806,7 @@ frogr_settings_dialog_init (FrogrSettingsDialog *self)
   priv->restricted_rb = NULL;
   priv->tags_autocompletion_cb = NULL;
   priv->remove_file_extensions_cb = NULL;
+  priv->enable_tooltips_cb = NULL;
   priv->use_proxy_cb = NULL;
   priv->proxy_host_label = NULL;
   priv->proxy_host_entry = NULL;
@@ -802,6 +824,7 @@ frogr_settings_dialog_init (FrogrSettingsDialog *self)
   priv->content_type = FSP_CONTENT_TYPE_NONE;
   priv->tags_autocompletion = FALSE;
   priv->remove_file_extensions = FALSE;
+  priv->enable_tooltips = FALSE;
   priv->use_proxy = FALSE;
   priv->proxy_host = NULL;
   priv->proxy_port = NULL;



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