gimp r25940 - in trunk: . plug-ins/help-browser



Author: neo
Date: Thu Jun 12 22:25:13 2008
New Revision: 25940
URL: http://svn.gnome.org/viewvc/gimp?rev=25940&view=rev

Log:
2008-06-13  Sven Neumann  <sven gimp org>

	* plug-ins/help-browser/dialog.c: added a toggle action to
	show/hide the index sidebar, bound to Ctrl-I.



Modified:
   trunk/ChangeLog
   trunk/plug-ins/help-browser/dialog.c

Modified: trunk/plug-ins/help-browser/dialog.c
==============================================================================
--- trunk/plug-ins/help-browser/dialog.c	(original)
+++ trunk/plug-ins/help-browser/dialog.c	Thu Jun 12 22:25:13 2008
@@ -66,10 +66,11 @@
 
 typedef struct
 {
-  gint     width;
-  gint     height;
-  gint     paned_position;
-  gdouble  zoom;
+  gint      width;
+  gint      height;
+  gint      paned_position;
+  gboolean  show_index;
+  gdouble   zoom;
 } DialogData;
 
 enum
@@ -92,6 +93,10 @@
                                           gpointer           data);
 static void       home_callback          (GtkAction         *action,
                                           gpointer           data);
+static void       copy_location_callback (GtkAction         *action,
+                                          gpointer           data);
+static void       show_index_callback    (GtkAction         *action,
+                                          gpointer           data);
 static void       zoom_in_callback       (GtkAction         *action,
                                           gpointer           data);
 static void       zoom_out_callback      (GtkAction         *action,
@@ -100,8 +105,6 @@
                                           gpointer           data);
 static void       website_callback       (GtkAction         *action,
                                           gpointer           data);
-static void       copy_location_callback (GtkAction         *action,
-                                          gpointer           data);
 
 static void       update_actions         (void);
 
@@ -138,6 +141,7 @@
 static GHashTable   *uri_hash_table = NULL;
 
 static GtkWidget    *view           = NULL;
+static GtkWidget    *sidebar        = NULL;
 static GtkWidget    *tree_view      = NULL;
 static GtkUIManager *ui_manager     = NULL;
 static GtkWidget    *button_prev    = NULL;
@@ -158,7 +162,7 @@
   GtkWidget   *button;
   GtkToolItem *item;
   GtkAction   *action;
-  DialogData   data = { 720, 560, 240, 1.0 };
+  DialogData   data = { 720, 560, 240, TRUE, 1.0 };
 
   gimp_ui_init ("helpbrowser", TRUE);
 
@@ -227,7 +231,11 @@
                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   gtk_paned_add1 (GTK_PANED (paned), scrolled);
   gtk_paned_set_position (GTK_PANED (paned), data.paned_position);
-  gtk_widget_show (scrolled);
+
+  sidebar = scrolled;
+
+  if (data.show_index)
+    gtk_widget_show (sidebar);
 
   tree_view = gtk_tree_view_new ();
   gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
@@ -565,13 +573,29 @@
     }
   };
 
+  static const GtkToggleActionEntry toggle_actions[] =
+  {
+    {
+      "show-index", NULL,
+      N_("S_how Index"), "<control>I",
+      N_("Toggle the visibility of the sidebar"),
+      G_CALLBACK (show_index_callback), FALSE
+    }
+  };
+
   GtkUIManager   *ui_manager = gtk_ui_manager_new ();
   GtkActionGroup *group      = gtk_action_group_new ("Actions");
   GtkAction      *action;
   GError         *error      = NULL;
 
   gtk_action_group_set_translation_domain (group, NULL);
-  gtk_action_group_add_actions (group, actions, G_N_ELEMENTS (actions), NULL);
+  gtk_action_group_add_actions (group,
+                                actions, G_N_ELEMENTS (actions),
+                                NULL);
+  gtk_action_group_add_toggle_actions (group,
+                                       toggle_actions,
+                                       G_N_ELEMENTS (toggle_actions),
+                                       NULL);
 
   action = gimp_throbber_action_new ("website",
                                      "docs.gimp.org",
@@ -621,6 +645,7 @@
                                      "    <separator />"
                                      "    <menuitem action=\"home\" />"
                                      "    <menuitem action=\"copy-location\" />"
+                                     "    <menuitem action=\"show-index\" />"
 #ifdef HAVE_WEBKIT_ZOOM_API
                                      "    <separator />"
                                      "    <menuitem action=\"zoom-in\" />"
@@ -693,9 +718,10 @@
 copy_location_callback (GtkAction *action,
                         gpointer   data)
 {
-  WebKitWebFrame *frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
+  WebKitWebFrame *frame;
   const gchar    *uri;
 
+  frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
   uri = webkit_web_frame_get_uri (frame);
 
   if (uri)
@@ -709,6 +735,20 @@
 }
 
 static void
+show_index_callback (GtkAction *action,
+                     gpointer   data)
+{
+  if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+    {
+      gtk_widget_show (sidebar);
+    }
+  else
+    {
+      gtk_widget_hide (sidebar);
+    }
+}
+
+static void
 zoom_in_callback (GtkAction *action,
                   gpointer   data)
 {
@@ -839,6 +879,12 @@
 
   frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
   gtk_action_set_sensitive (action, webkit_web_frame_get_uri (frame) != NULL);
+
+  /*  update the show-index action  */
+  action = gtk_ui_manager_get_action (ui_manager,
+                                      "/ui/help-browser-popup/show-index");
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                GTK_WIDGET_VISIBLE (sidebar));
 }
 
 static void
@@ -876,11 +922,12 @@
 dialog_unmap (GtkWidget *window,
               GtkWidget *paned)
 {
-  DialogData  data;
+  DialogData data;
 
   gtk_window_get_size (GTK_WINDOW (window), &data.width, &data.height);
 
   data.paned_position = gtk_paned_get_position (GTK_PANED (paned));
+  data.show_index     = GTK_WIDGET_VISIBLE (sidebar);
 
 #ifdef HAVE_WEBKIT_ZOOM_API
   data.zoom = (view ?



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