Toolbars patch



Hi all,

A quick patch for hiding of individual toolbars. It's now in the View
menu where it belongs. See the screenshot at:
  http://home.exetel.com.au/harvey/epiphany/toolbars.jpg
The patch works, but I hope someone else can fix any minor niggles about
wording and/or UTF8 bugs.

Names for toolbars are derived directly from whichever widgets are on
the toolbars (left to right), and we manually ellipsize to a maximum of
25 characters. We can assign accelerators for toolbars if we like. For
example, Ctrl+Alt+n for the first n toolbars. I'll let people who know
more about the available set of accelerators decide this one.

Please note that there is a "Show Toolbars" option and then the
per-toolbar "Hide" options. I have a reason for this.
        In a user's mind they would assume that a more specific option
        overrides the less specific. We see this very often in
        computers. It would therefore be confusing to have "Show" for
        specific toolbars as it would not override the less specific
        option - the less specific option would be a pre-requisite. With
        my menu you choose to show the toolbars, and then override by
        hiding specific ones.
Meet me on #epiphany at sundown for any arguments. ;)

Regards,
Peter.

? lib/libephymisc_la-ephy-dbus.loT
Index: data/ui/epiphany-ui.xml
===================================================================
RCS file: /cvs/gnome/epiphany/data/ui/epiphany-ui.xml,v
retrieving revision 1.37
diff -u -d -r1.37 epiphany-ui.xml
--- data/ui/epiphany-ui.xml	11 Dec 2005 14:40:14 -0000	1.37
+++ data/ui/epiphany-ui.xml	30 Jan 2006 02:35:12 -0000
@@ -32,13 +32,16 @@
 	<separator name="EditSep3"/>
 	<menuitem name="EditPersonalDataMenu" action="EditPersonalData"/>
 <!--	<menuitem name="EditCertificatesMenu" action="EditCertificates"/> -->
-	<menuitem name="EditToolbarMenu" action="EditToolbar"/>
 	<menuitem name="EditPrefsMenu" action="EditPrefs"/> 
 </menu>
 
 <menu name="ViewMenu" action="View">
 	<placeholder name="ViewTogglesGroup" position="top">
+		<menu name="ToolbarMenu" action="Toolbar">
+		<menuitem name="ViewToolbarEditorMenu" action="ViewToolbarEditor"/>
 		<menuitem name="ViewToolbarMenu" action="ViewToolbar"/>
+		<separator name="ToolbarSep1"/>
+		</menu>
 		<menuitem name="ViewStatusbarMenu" action="ViewStatusbar"/>
 	</placeholder>
 	<separator name="ViewSep1"/>
@@ -163,6 +166,12 @@
 		<menuitem name="TabMoveRightENP" action="TabsMoveRight"/>
 	</placeholder>
         <menuitem name="TabDetachENP" action="TabsDetach"/>
+</popup>
+
+<popup name="ToolbarPopup">
+	<separator/>
+        <menuitem action="ViewToolbarEditor"/>
+	<separator/>
 </popup>
 
 <accelerator name="AlwaysStopAccel" action="ViewAlwaysStop"/>
Index: lib/egg/egg-editable-toolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/egg-editable-toolbar.c,v
retrieving revision 1.80
diff -u -d -r1.80 egg-editable-toolbar.c
--- lib/egg/egg-editable-toolbar.c	16 Jan 2006 23:51:41 -0000	1.80
+++ lib/egg/egg-editable-toolbar.c	30 Jan 2006 02:35:12 -0000
@@ -32,6 +32,7 @@
 #include <gtk/gtkdnd.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtkimage.h>
+#include <gtk/gtktoggleaction.h>
 #include <gtk/gtkcheckmenuitem.h>
 #include <gtk/gtkimagemenuitem.h>
 #include <gtk/gtkseparatormenuitem.h>
@@ -48,7 +49,6 @@
 
 static void egg_editable_toolbar_class_init	(EggEditableToolbarClass *klass);
 static void egg_editable_toolbar_init		(EggEditableToolbar *etoolbar);
-static void egg_editable_toolbar_finalize	(GObject *object);
 
 #define MIN_TOOLBAR_HEIGHT 20
 #define EGG_ITEM_NAME      "egg-item-name"
@@ -62,6 +62,7 @@
   PROP_0,
   PROP_TOOLBARS_MODEL,
   PROP_UI_MANAGER,
+  PROP_VISIBILITY_PATH,
   PROP_SELECTED
 };
 
@@ -86,7 +87,12 @@
   GtkWidget *fixed_toolbar;
   
   GtkWidget *selected;
-  guint popup;
+  GtkActionGroup *actions;
+  guint popup_id;
+  
+  guint visibility_id;
+  char *visibility_path;
+  GPtrArray *visibility_actions;
 
   guint        dnd_pending;
   GtkToolbar  *dnd_toolbar;
@@ -121,7 +127,8 @@
 }
 
 static int
-get_dock_position (EggEditableToolbar *etoolbar, GtkWidget *dock)
+get_dock_position (EggEditableToolbar *etoolbar,
+                   GtkWidget *dock)
 {
   GList *l;
   int result;
@@ -273,39 +280,6 @@
 }
 
 static void
-set_dock_visible (EggEditableToolbar *etoolbar,
-                  GtkWidget          *dock,
-                  gboolean            visible)
-{
-  if (visible)
-    {
-      gtk_widget_show (dock);
-    }
-  else
-    {
-      gtk_widget_hide (dock);
-    }
-  
-  if (etoolbar->priv->save_hidden)
-    {
-      int position = get_dock_position (etoolbar, dock);
-      EggTbModelFlags flags = egg_toolbars_model_get_flags
-        (etoolbar->priv->model, position);
-      
-      if (visible)
-        {
-	  flags &= ~(EGG_TB_MODEL_HIDDEN);
-	}
-      else
-	{
-	  flags |=  (EGG_TB_MODEL_HIDDEN);
-	}
-      
-      egg_toolbars_model_set_flags (etoolbar->priv->model, position, flags);
-    }
-}
-
-static void
 move_item_cb (GtkAction          *action,
               EggEditableToolbar *etoolbar)
 {
@@ -366,7 +340,7 @@
                        gint                button_number,
                        EggEditableToolbar *etoolbar)
 {
-  if (etoolbar->priv->popup != 0)
+  if (etoolbar->priv->popup_id != 0)
     {
       GtkMenu *menu;
       egg_editable_toolbar_set_selected (etoolbar, toolbar);
@@ -382,7 +356,7 @@
                        GdkEventButton *event,
                        EggEditableToolbar *etoolbar)
 {
-  if (event->button == 3 && etoolbar->priv->popup != 0)
+  if (event->button == 3 && etoolbar->priv->popup_id != 0)
     {
       GtkMenu *menu;
       egg_editable_toolbar_set_selected (etoolbar, widget);
@@ -705,6 +679,158 @@
   }
 }
 
+static void
+toggled_visibility_cb (GtkToggleAction *action,
+		       EggEditableToolbar *etoolbar)
+{
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+  GtkWidget *dock;
+  EggTbModelFlags flags;
+  gboolean visible;
+  gint i;
+  
+  visible = !gtk_toggle_action_get_active (action);
+  for (i = 0; i < priv->visibility_actions->len; i++)
+    if (g_ptr_array_index (priv->visibility_actions, i) == action)
+      break;
+  
+  g_return_if_fail (i < priv->visibility_actions->len);
+  
+  dock = get_dock_nth (etoolbar, i);  
+  if (visible)
+    {
+      gtk_widget_show (dock);
+    }
+  else
+    {
+      gtk_widget_hide (dock);
+    }
+  
+  if (priv->save_hidden)
+    {      
+      flags = egg_toolbars_model_get_flags (priv->model, i);
+      
+      if (visible)
+        {
+	  flags &= ~(EGG_TB_MODEL_HIDDEN);
+	}
+      else
+	{
+	  flags |=  (EGG_TB_MODEL_HIDDEN);
+	}
+      
+      egg_toolbars_model_set_flags (priv->model, i, flags);
+    }
+}
+
+static void
+toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
+{
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+  gint n_toolbars, n_items, i, j, k;
+  
+  if (priv == NULL || priv->model == NULL || priv->manager == NULL ||
+      priv->visibility_path == NULL || priv->actions == NULL)
+    {
+      return;
+    }
+
+  if (priv->visibility_actions == NULL)
+    {
+      priv->visibility_actions = g_ptr_array_new ();
+    }
+  
+  if (priv->visibility_id != 0)
+    {
+      gtk_ui_manager_remove_ui (priv->manager, priv->visibility_id);
+    }  
+  
+  priv->visibility_id = gtk_ui_manager_new_merge_id (priv->manager);
+  
+  n_toolbars = egg_toolbars_model_n_toolbars (priv->model);
+  for (i = 0; i < n_toolbars; i++)
+    {
+      GtkToggleAction *action;
+      GString *string;
+      char action_name[40];
+      char *action_label;
+      char *tmp;
+      	
+      string = g_string_sized_new (0);
+      n_items = egg_toolbars_model_n_items (priv->model, i);
+      for (k = 0, j = 0; j < n_items; j++)
+        {
+          GValue value = { 0, };
+          GtkAction *action;
+          const char *name;
+
+          name = egg_toolbars_model_item_nth (priv->model, i, j);
+          if (name == NULL) continue;
+          action = find_action (etoolbar, name);
+          if (action == NULL) continue;
+
+          g_value_init (&value, G_TYPE_STRING);
+          g_object_get_property (G_OBJECT (action), "label", &value);
+          name = g_value_get_string (&value);
+          if (name == NULL) continue;
+	  
+	  k += g_utf8_strlen (name, -1) + 2;
+	  if (j > 0)
+	    {
+	      g_string_append (string, ", ");
+	      if (k > 25) break;
+	    }
+	  g_string_append (string, name);
+	}
+      if (j < n_items)
+        {
+	  g_string_append (string, " ...");
+        }
+      
+      tmp = g_string_free (string, FALSE);
+      for (j = 0, k = 0; tmp[j]; j++)
+      {
+	if (tmp[j] == '_') continue;
+	tmp[k] = tmp[j];
+	k++;
+      }
+      tmp[k] = 0;
+      action_label = g_strdup_printf (_("Hide â??%sâ??"), tmp);
+      g_free (tmp);
+      
+      sprintf(action_name, "ToolbarToggle%d", i);
+      
+      if (i >= priv->visibility_actions->len)
+        {
+	  action = gtk_toggle_action_new (action_name, action_label, NULL, NULL);
+	  g_ptr_array_add (priv->visibility_actions, action);
+	  g_signal_connect (action, "toggled",
+			    G_CALLBACK (toggled_visibility_cb), etoolbar);
+	  gtk_action_group_add_action (priv->actions, GTK_ACTION (action));
+	}
+      else
+        {
+	  action = g_ptr_array_index (priv->visibility_actions, i);
+	  g_object_set (action, "label", action_label, NULL);
+        }
+      
+      gtk_toggle_action_set_active (action, !GTK_WIDGET_VISIBLE
+				    (get_dock_nth (etoolbar, i)));
+      
+      gtk_ui_manager_add_ui (priv->manager, priv->visibility_id,
+			     priv->visibility_path, action_name, action_name,
+			     GTK_UI_MANAGER_MENUITEM, FALSE);
+      
+      g_free (action_label);
+    }
+  
+  while (i < priv->visibility_actions->len)
+    {
+      g_ptr_array_remove_index_fast (priv->visibility_actions, i);
+    }
+
+  gtk_ui_manager_ensure_update (priv->manager);
+}
 
 static GtkWidget *
 create_dock (EggEditableToolbar *etoolbar)
@@ -793,6 +919,8 @@
     {
       set_fixed_style (etoolbar, style);
     }
+
+  toolbar_visibility_refresh (etoolbar);
 }
 
 static void
@@ -850,6 +978,8 @@
   gtk_widget_show_all (dock);
   
   update_fixed (etoolbar);
+
+  toolbar_visibility_refresh (etoolbar);
 }
 
 static void
@@ -858,7 +988,6 @@
 	            EggEditableToolbar *etoolbar)
 {
   GtkWidget *dock;
-  int i;
 
   if (position == 0 && etoolbar->priv->fixed_toolbar != NULL)
     {
@@ -868,19 +997,9 @@
   dock = get_dock_nth (etoolbar, position);
   gtk_widget_destroy (dock);
 
-  dock = NULL;
-  for (i = egg_toolbars_model_n_toolbars (model)-1; i >= 0; i--)
-    {
-      dock = get_dock_nth (etoolbar, i);
-      if (GTK_WIDGET_VISIBLE (dock)) break;
-    }
-      
-  if (i < 0 && dock != NULL)
-    {
-      set_dock_visible (etoolbar, dock, TRUE);
-    }
-    
   update_fixed (etoolbar);
+  
+  toolbar_visibility_refresh (etoolbar);
 }
 
 static void
@@ -906,6 +1025,8 @@
   dock = get_dock_nth (etoolbar, tpos);
   gtk_widget_set_size_request (dock, -1, -1);
   gtk_widget_queue_resize_no_redraw (dock);
+
+  toolbar_visibility_refresh (etoolbar);
 }
 
 static void
@@ -914,6 +1035,8 @@
 	         int                 position,
 	         EggEditableToolbar *etoolbar)
 {
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+  
   GtkWidget *toolbar;
   GtkWidget *item;
 
@@ -921,11 +1044,19 @@
   item = GTK_WIDGET (gtk_toolbar_get_nth_item
 	(GTK_TOOLBAR (toolbar), position));
   g_return_if_fail (item != NULL);
+
+  if (item == priv->selected)
+    {
+      /* FIXME */
+    }
+
   gtk_container_remove (GTK_CONTAINER (toolbar), item);
+
+  toolbar_visibility_refresh (etoolbar);
 }
 
 static void
-egg_editable_toolbar_construct (EggEditableToolbar *etoolbar)
+egg_editable_toolbar_build (EggEditableToolbar *etoolbar)
 {
   int i, l, n_items, n_toolbars;
   EggToolbarsModel *model = etoolbar->priv->model;
@@ -1018,44 +1149,98 @@
 }
 
 void
-egg_editable_toolbar_set_model (EggEditableToolbar *toolbar,
+egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar,
 				EggToolbarsModel   *model)
 {
-  g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
-  g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar));
-  g_return_if_fail (toolbar->priv->manager);
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
 
-  if (toolbar->priv->model == model) return;
+  if (priv->model == model) return;
 
-  if (toolbar->priv->model)
+  if (priv->model)
     {
-      egg_editable_toolbar_disconnect_model (toolbar);
-      egg_editable_toolbar_deconstruct (toolbar);
+      egg_editable_toolbar_disconnect_model (etoolbar);
+      egg_editable_toolbar_deconstruct (etoolbar);
 
-      g_object_unref (toolbar->priv->model);
+      g_object_unref (priv->model);
     }
 
-  toolbar->priv->model = g_object_ref (model);
+  priv->model = g_object_ref (model);
 
-  egg_editable_toolbar_construct (toolbar);
+  egg_editable_toolbar_build (etoolbar);
+
+  toolbar_visibility_refresh (etoolbar);
 
   g_signal_connect (model, "item_added",
-		    G_CALLBACK (item_added_cb), toolbar);
+		    G_CALLBACK (item_added_cb), etoolbar);
   g_signal_connect (model, "item_removed",
-		    G_CALLBACK (item_removed_cb), toolbar);
+		    G_CALLBACK (item_removed_cb), etoolbar);
   g_signal_connect (model, "toolbar_added",
-		    G_CALLBACK (toolbar_added_cb), toolbar);
+		    G_CALLBACK (toolbar_added_cb), etoolbar);
   g_signal_connect (model, "toolbar_removed",
-		    G_CALLBACK (toolbar_removed_cb), toolbar);
+		    G_CALLBACK (toolbar_removed_cb), etoolbar);
   g_signal_connect (model, "toolbar_changed",
-		    G_CALLBACK (toolbar_changed_cb), toolbar);
+		    G_CALLBACK (toolbar_changed_cb), etoolbar);
+}
+
+static void
+egg_editable_toolbar_init (EggEditableToolbar *etoolbar)
+{
+  EggEditableToolbarPrivate *priv;
+
+  priv = etoolbar->priv = EGG_EDITABLE_TOOLBAR_GET_PRIVATE (etoolbar);
+
+  priv->save_hidden = TRUE;
+}
+
+static void
+egg_editable_toolbar_dispose (GObject *object)
+{
+  EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+
+  if (priv->fixed_toolbar != NULL)
+    {
+      g_object_unref (priv->fixed_toolbar);
+      priv->fixed_toolbar = NULL;
+    }
+
+  if (priv->manager != NULL)
+    {
+      if (priv->popup_id)
+        {
+	  gtk_ui_manager_remove_ui (priv->manager,
+				    priv->popup_id);
+	  priv->popup_id = 0;
+	}
+      
+      if (priv->visibility_id)
+        {
+	  gtk_ui_manager_remove_ui (priv->manager,
+				    priv->visibility_id);
+	  priv->visibility_id = 0;
+	}
+      
+      g_object_unref (priv->manager);
+      priv->manager = NULL;
+    }
+
+  if (priv->model)
+    {
+      egg_editable_toolbar_disconnect_model (etoolbar);
+      g_object_unref (priv->model);
+      priv->model = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
 static void
 egg_editable_toolbar_set_ui_manager (EggEditableToolbar *etoolbar,
 				     GtkUIManager       *manager)
 {
-  GtkActionGroup *group = gtk_action_group_new ("ToolbarActions");
+  g_object_ref (manager);
+  
+  etoolbar->priv->actions = gtk_action_group_new ("ToolbarActions");
   GtkActionEntry actions[] = {
     { "MoveToolItem", NULL, _("_Move on Toolbar"), NULL,
       _("Move the selected item on the toolbar"), G_CALLBACK (move_item_cb) },
@@ -1064,17 +1249,19 @@
     { "RemoveToolbar", GTK_STOCK_REMOVE, _("_Remove Toolbar"), NULL,
       _("Remove the selected toolbar"), G_CALLBACK (remove_toolbar_cb) },
   };
-  gtk_action_group_add_actions (group, actions, 3, etoolbar);
-  
-  gtk_ui_manager_insert_action_group (manager, group, 0);
+  gtk_action_group_add_actions (etoolbar->priv->actions, actions, 3, etoolbar);
+
+  gtk_ui_manager_insert_action_group (manager, etoolbar->priv->actions, 0);
 
   etoolbar->priv->manager = g_object_ref (manager);
-  etoolbar->priv->popup = gtk_ui_manager_add_ui_from_string (manager, 
+  etoolbar->priv->popup_id = gtk_ui_manager_add_ui_from_string (manager, 
      "<popup name=\"ToolbarPopup\">"
      "<menuitem action=\"MoveToolItem\"/>"
      "<menuitem action=\"RemoveToolItem\"/>"							     
      "<menuitem action=\"RemoveToolbar\"/>"
      "</popup>", -1, NULL);  
+  
+  toolbar_visibility_refresh (etoolbar);
 }
 
 GtkWidget * egg_editable_toolbar_get_selected (EggEditableToolbar   *etoolbar)
@@ -1096,6 +1283,8 @@
   gtk_action_set_visible (find_action (etoolbar, "RemoveToolbar"), toolbar && (etoolbar->priv->edit_mode > 0));
   gtk_action_set_visible (find_action (etoolbar, "RemoveToolItem"), toolitem);
   gtk_action_set_visible (find_action (etoolbar, "MoveToolItem"), toolitem);
+  
+  toolbar_visibility_refresh (etoolbar);
 }
 
 static void
@@ -1117,6 +1306,9 @@
     case PROP_SELECTED:
       egg_editable_toolbar_set_selected (etoolbar, g_value_get_object (value));
       break;
+    case PROP_VISIBILITY_PATH:
+      etoolbar->priv->visibility_path = g_strdup (g_value_get_string (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1155,7 +1347,7 @@
 
   parent_class = g_type_class_peek_parent (klass);
 
-  object_class->finalize = egg_editable_toolbar_finalize;
+  object_class->dispose = egg_editable_toolbar_dispose;
   object_class->set_property = egg_editable_toolbar_set_property;
   object_class->get_property = egg_editable_toolbar_get_property;
 
@@ -1189,87 +1381,65 @@
 							GTK_TYPE_TOOL_ITEM,
 							G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
-  g_type_class_add_private (object_class, sizeof (EggEditableToolbarPrivate));
-}
-
-static void
-egg_editable_toolbar_init (EggEditableToolbar *etoolbar)
-{
-  etoolbar->priv = EGG_EDITABLE_TOOLBAR_GET_PRIVATE (etoolbar);
-  etoolbar->priv->save_hidden = TRUE;
-}
-
-static void
-egg_editable_toolbar_finalize (GObject *object)
-{
-  EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
-
-  if (etoolbar->priv->fixed_toolbar)
-    {
-      g_object_unref (etoolbar->priv->fixed_toolbar);
-    }
-
-  if (etoolbar->priv->manager)
-    {
-      if (etoolbar->priv->popup)
-      {
-	gtk_ui_manager_remove_ui (etoolbar->priv->manager,
-				  etoolbar->priv->popup);
-      }
-      
-      g_object_unref (etoolbar->priv->manager);
-    }
-
-  if (etoolbar->priv->model)
-    {
-      egg_editable_toolbar_disconnect_model (etoolbar);
-      g_object_unref (etoolbar->priv->model);
-    }
+  g_object_class_install_property (object_class,
+				   PROP_VISIBILITY_PATH,
+				   g_param_spec_string ("visibility-path",
+							"visibility-path",
+							"visibility-path",
+							NULL,
+							G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  g_type_class_add_private (object_class, sizeof (EggEditableToolbarPrivate));
 }
 
 GtkWidget *
-egg_editable_toolbar_new (GtkUIManager     *manager)
+egg_editable_toolbar_new (GtkUIManager *manager,
+                          const char *visibility_path)
 {
-  return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
-				   "ui-manager", manager,
-				   NULL));
+    return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
+                                     "ui-manager", manager,
+                                     "visibility-path", visibility_path,
+                                     NULL));
 }
 
 GtkWidget *
-egg_editable_toolbar_new_with_model (GtkUIManager     *manager,
-				     EggToolbarsModel *model)
+egg_editable_toolbar_new_with_model (GtkUIManager *manager,
+ 				     EggToolbarsModel *model,
+                                     const char *visibility_path)
 {
   return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
-				   "ui-manager", manager,
-				   "model", model,
+                                   "ui-manager", manager,
+                                   "model", model,
+                                   "visibility-path", visibility_path,
 				   NULL));
 }
 
 gboolean
 egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar)
 {
-	return (etoolbar->priv->edit_mode > 0);
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+
+  return priv->edit_mode > 0;
 }
 
 void
 egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
-				    gboolean            mode)
+				    gboolean mode)
 {
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
   int i, l, n_items;
 
-  i = etoolbar->priv->edit_mode;
+  i = priv->edit_mode;
   if (mode)
     {
-      etoolbar->priv->edit_mode++;
+      priv->edit_mode++;
     }
   else
     {
-      g_return_if_fail (etoolbar->priv->edit_mode > 0);
-      etoolbar->priv->edit_mode--;
+      g_return_if_fail (priv->edit_mode > 0);
+      priv->edit_mode--;
     }
-  i *= etoolbar->priv->edit_mode;
+  i *= priv->edit_mode;
   
   if (i == 0)
     {
@@ -1280,9 +1450,9 @@
           toolbar = get_toolbar_nth (etoolbar, i);
           n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
 
-          if (n_items == 0 && etoolbar->priv->edit_mode == 0)
+          if (n_items == 0 && priv->edit_mode == 0)
             {
-              egg_toolbars_model_remove_toolbar (etoolbar->priv->model, i);
+              egg_toolbars_model_remove_toolbar (priv->model, i);
             }
           else
             {          
@@ -1302,12 +1472,11 @@
 
 void
 egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
-			   const char         *name)
+			   const char *name)
 {
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+  EggToolbarsModel *model = priv->model;
   int i, n_toolbars;
-  EggToolbarsModel *model = etoolbar->priv->model;
-
-  g_return_if_fail (model != NULL);
 
   n_toolbars = egg_toolbars_model_n_toolbars (model);
   for (i = 0; i < n_toolbars; i++)
@@ -1316,20 +1485,19 @@
 
       toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
       if (strcmp (toolbar_name, name) == 0)
-      {
-        gtk_widget_show (get_dock_nth (etoolbar, i));
-      }
+        {
+          gtk_widget_show (get_dock_nth (etoolbar, i));
+        }
     }
 }
 
 void
 egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
-			   const char         *name)
+			   const char *name)
 {
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
+  EggToolbarsModel *model = priv->model;
   int i, n_toolbars;
-  EggToolbarsModel *model = etoolbar->priv->model;
-
-  g_return_if_fail (model != NULL);
 
   n_toolbars = egg_toolbars_model_n_toolbars (model);
   for (i = 0; i < n_toolbars; i++)
@@ -1345,28 +1513,29 @@
 }
 
 void
-egg_editable_toolbar_set_fixed (EggEditableToolbar *toolbar,
-				GtkToolbar         *fixed_toolbar)
+egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
+				GtkToolbar *toolbar)
 {
-  g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar));
-  g_return_if_fail (!fixed_toolbar || GTK_IS_TOOLBAR (fixed_toolbar));
+  EggEditableToolbarPrivate *priv = etoolbar->priv;
 
-  if (toolbar->priv->fixed_toolbar)
+  g_return_if_fail (!toolbar || GTK_IS_TOOLBAR (toolbar));
+
+  if (priv->fixed_toolbar)
     {
-      unparent_fixed (toolbar);
-      g_object_unref (toolbar->priv->fixed_toolbar);
-      toolbar->priv->fixed_toolbar = NULL;
+      unparent_fixed (etoolbar);
+      g_object_unref (priv->fixed_toolbar);
+      priv->fixed_toolbar = NULL;
     }
 
-  if (fixed_toolbar)
+  if (toolbar)
     {
-      toolbar->priv->fixed_toolbar = GTK_WIDGET (fixed_toolbar);
-      gtk_toolbar_set_show_arrow (fixed_toolbar, FALSE);
-      g_object_ref (fixed_toolbar);
-      gtk_object_sink (GTK_OBJECT (fixed_toolbar));
+      priv->fixed_toolbar = GTK_WIDGET (toolbar);
+      gtk_toolbar_set_show_arrow (toolbar, FALSE);
+      g_object_ref (toolbar);
+      gtk_object_sink (GTK_OBJECT (toolbar));
     }
 
-  update_fixed (toolbar);
+  update_fixed (etoolbar);
 }
 
 #define DEFAULT_ICON_HEIGHT 20
Index: lib/egg/egg-editable-toolbar.h
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/egg-editable-toolbar.h,v
retrieving revision 1.20
diff -u -d -r1.20 egg-editable-toolbar.h
--- lib/egg/egg-editable-toolbar.h	16 Jan 2006 22:45:04 -0000	1.20
+++ lib/egg/egg-editable-toolbar.h	30 Jan 2006 02:35:12 -0000
@@ -61,9 +61,11 @@
 };
 
 GType               egg_editable_toolbar_get_type        (void);
-GtkWidget	   *egg_editable_toolbar_new		 (GtkUIManager         *manager);
+GtkWidget	   *egg_editable_toolbar_new		 (GtkUIManager         *manager,
+							  const char           *visibility_path);
 GtkWidget	   *egg_editable_toolbar_new_with_model	 (GtkUIManager         *manager,
-							  EggToolbarsModel     *model);
+							  EggToolbarsModel     *model,
+							  const char           *visibility_path);
 void		    egg_editable_toolbar_set_model       (EggEditableToolbar   *etoolbar,
 							  EggToolbarsModel     *model);
 EggToolbarsModel   *egg_editable_toolbar_get_model       (EggEditableToolbar   *etoolbar);
@@ -75,17 +77,12 @@
 							  const char           *name);
 void		    egg_editable_toolbar_hide		 (EggEditableToolbar   *etoolbar,
 							  const char           *name);
-void		    egg_editable_toolbar_set_drag_dest   (EggEditableToolbar   *etoolbar,
-							  const GtkTargetEntry *targets,
-							  gint                  n_targets,
-							  const char           *toolbar_name);
 void		    egg_editable_toolbar_set_fixed       (EggEditableToolbar   *etoolbar,
 							  GtkToolbar           *fixed_toolbar);
 
 GtkWidget *         egg_editable_toolbar_get_selected    (EggEditableToolbar   *etoolbar);
 void                egg_editable_toolbar_set_selected    (EggEditableToolbar   *etoolbar,
 							  GtkWidget            *widget);
-
 
 /* Private Functions */
 
Index: src/ephy-lockdown.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-lockdown.c,v
retrieving revision 1.10
diff -u -d -r1.10 ephy-lockdown.c
--- src/ephy-lockdown.c	23 Jan 2006 21:34:58 -0000	1.10
+++ src/ephy-lockdown.c	30 Jan 2006 02:35:13 -0000
@@ -193,7 +193,7 @@
 	ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled || !writable);
 
 	disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_TOOLBAR_EDITING);
-	action = gtk_action_group_get_action (action_group, "EditToolbar");
+	action = gtk_action_group_get_action (action_group, "ViewToolbarEditor");
 	ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
 
 	fullscreen = eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN);
Index: src/ephy-toolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-toolbar.c,v
retrieving revision 1.28
diff -u -d -r1.28 ephy-toolbar.c
--- src/ephy-toolbar.c	12 Nov 2005 20:48:16 -0000	1.28
+++ src/ephy-toolbar.c	30 Jan 2006 02:35:13 -0000
@@ -739,5 +739,6 @@
 	return EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR,
 					   "window", window,
 					   "ui-manager", ephy_window_get_ui_manager (window),
+					   "visibility-path", "/menubar/ViewMenu/ViewTogglesGroup/ToolbarMenu",
 					   NULL));
 }
Index: src/ephy-window.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-window.c,v
retrieving revision 1.340
diff -u -d -r1.340 ephy-window.c
--- src/ephy-window.c	21 Jan 2006 23:54:23 -0000	1.340
+++ src/ephy-window.c	30 Jan 2006 02:35:13 -0000
@@ -120,6 +120,7 @@
 	{ "Tools", NULL, N_("T_ools") },
 	{ "Tabs", NULL, N_("_Tabs") },
 	{ "Help", NULL, N_("_Help") },
+	{ "Toolbar", NULL, N_("_Toolbars") },
 	{ "PopupAction", NULL, "" },
 	{ "NotebookPopupAction", NULL, "" },
 
@@ -190,15 +191,15 @@
 	  N_("Manage Certificates"),
 	  G_CALLBACK (window_cmd_edit_certificates) },
 #endif
-	{ "EditToolbar", NULL, N_("T_oolbars"), NULL,
-	  N_("Customize toolbars"),
-	  G_CALLBACK (window_cmd_edit_toolbar) },
 	{ "EditPrefs", GTK_STOCK_PREFERENCES, N_("P_references"), NULL,
 	  N_("Configure the web browser"),
 	  G_CALLBACK (window_cmd_edit_prefs) },
 
 	/* View menu */
 
+	{ "ViewToolbarEditor", NULL, N_("_Customize Toolbars..."), NULL,
+	  N_("Customize toolbars"),
+	  G_CALLBACK (window_cmd_edit_toolbar) },
 	{ "ViewStop", GTK_STOCK_STOP, N_("_Stop"), "Escape",
 	  N_("Stop current data transfer"),
 	  G_CALLBACK (window_cmd_view_stop) },
@@ -279,7 +280,7 @@
 
 	/* View Menu */
 
-	{ "ViewToolbar", NULL, N_("_Toolbar"), "<shift><control>T",
+	{ "ViewToolbar", NULL, N_("_Show Toolbars"), "<shift><control>T",
 	  N_("Show or hide toolbar"),
 	  G_CALLBACK (ephy_window_view_toolbar_cb), TRUE },
 	{ "ViewStatusbar", NULL, N_("St_atusbar"), NULL,


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