[Epiphany] Toolbar editor patch take 2



So the crash was in the new libegg code, so I just back ported the patch
to the old code that was in epiphany.

Here's the new patch.

iain
-- 
Index: data/ui/epiphany-toolbar.xml.in
===================================================================
RCS file: /cvs/gnome/epiphany/data/ui/epiphany-toolbar.xml.in,v
retrieving revision 1.9
diff -u -p -r1.9 epiphany-toolbar.xml.in
--- data/ui/epiphany-toolbar.xml.in	7 Mar 2003 12:37:46 -0000	1.9
+++ data/ui/epiphany-toolbar.xml.in	10 Mar 2003 18:59:46 -0000
@@ -22,7 +22,7 @@
 	<toolitem verb="ToolbarGo"/>
 </available>
 <default>
-<toolbar>
+<toolbar name="MainToolbar" style="both" icon_size="large-toolbar">
 	<toolitem verb="NavigationBack"/>
 	<toolitem verb="NavigationForward"/>
 	<toolitem verb="ViewStop"/>
Index: lib/egg/egg-menu-merge.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/egg-menu-merge.c,v
retrieving revision 1.7
diff -u -p -r1.7 egg-menu-merge.c
--- lib/egg/egg-menu-merge.c	8 Feb 2003 19:38:36 -0000	1.7
+++ lib/egg/egg-menu-merge.c	10 Mar 2003 18:59:46 -0000
@@ -235,6 +235,8 @@ get_child_node(EggMenuMerge *self, GNode
 	  mnode = g_chunk_new0(EggMenuMergeNode, merge_node_chunk);
 	  mnode->type = node_type;
 	  mnode->name = g_strndup(childname, childname_length);
+	  mnode->icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
+	  mnode->style = GTK_TOOLBAR_BOTH;
 	  mnode->dirty = TRUE;
 
 	  if (top)
@@ -377,6 +379,62 @@ struct _ParseContext
   guint merge_id;
 };
 
+static GtkToolbarStyle
+toolbar_style_from_string (const char *str)
+{
+  if (strcmp (str, "icons") == 0)
+  {
+    return GTK_TOOLBAR_ICONS;
+  }
+  else if (strcmp (str, "text") == 0)
+  {
+    return GTK_TOOLBAR_TEXT;
+  }
+  else if (strcmp (str, "both") == 0)
+  {
+    return GTK_TOOLBAR_BOTH;
+  }
+  else if (strcmp (str, "both_horiz") == 0)
+  {
+    return GTK_TOOLBAR_BOTH_HORIZ;
+  }
+  
+  g_warning ("Unknown GtkToolbarStyle: %s", str);
+  return GTK_TOOLBAR_BOTH;
+}
+
+static GtkIconSize
+icon_size_from_string (const char *str)
+{
+  if (strcmp (str, "menu") == 0)
+  {
+    return GTK_ICON_SIZE_MENU;
+  }
+  else if (strcmp (str, "small-toolbar") == 0)
+  {
+    return GTK_ICON_SIZE_SMALL_TOOLBAR;
+  }
+  else if (strcmp (str, "large-toolbar") == 0)
+  {
+    return GTK_ICON_SIZE_LARGE_TOOLBAR;
+  }
+  else if (strcmp (str, "button") == 0)
+  {
+    return GTK_ICON_SIZE_BUTTON;
+  }
+  else if (strcmp (str, "dnd") == 0)
+  {
+    return GTK_ICON_SIZE_DND;
+  }
+  else if (strcmp (str, "dialog") == 0)
+  {
+    return GTK_ICON_SIZE_DIALOG;
+  }
+  
+  g_warning ("Unknown GtkIconSize: %s", str);
+  return GTK_ICON_SIZE_LARGE_TOOLBAR;
+}
+
 static void
 start_element_handler (GMarkupParseContext *context,
 		       const gchar *element_name,
@@ -392,7 +450,9 @@ start_element_handler (GMarkupParseConte
   const gchar *node_name;
   GQuark verb_quark;
   gboolean top;
-
+  GtkIconSize icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
+  GtkToolbarStyle style = GTK_TOOLBAR_BOTH;
+  
   gboolean raise_error = TRUE;
   gchar *error_attr = NULL;
 
@@ -417,6 +477,14 @@ start_element_handler (GMarkupParseConte
 	{
 	  top = !strcmp(attribute_values[i], "top");
 	}
+      else if (!strcmp (attribute_names[i], "look"))
+        {
+	  style = toolbar_style_from_string (attribute_values[i]);
+	}
+      else if (!strcmp (attribute_names[i], "size"))
+        {
+	  icon_size = icon_size_from_string (attribute_values[i]);
+	}
     }
   /* if no verb, then set it to the node's name */
   if (verb_quark == 0)
@@ -484,6 +552,8 @@ start_element_handler (GMarkupParseConte
 
 	  egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
 						    ctx->merge_id, verb_quark);
+	  NODE_INFO(ctx->current)->icon_size = icon_size;
+	  NODE_INFO(ctx->current)->style = style;
 	  NODE_INFO(ctx->current)->dirty = TRUE;
 
 	  raise_error = FALSE;
@@ -987,7 +1057,8 @@ update_node (EggMenuMerge *self, GNode *
        * we don't have to do anything.
        */
       if (info->proxy != NULL &&
-	  action == info->action)
+	  action == info->action &&
+	  info->type != EGG_MENU_MERGE_TOOLBAR)
 	{
 	  goto recurse_children;
 	}
@@ -1073,6 +1144,9 @@ update_node (EggMenuMerge *self, GNode *
 	      gtk_widget_show (info->proxy);
 	      g_signal_emit (self, merge_signals[ADD_WIDGET], 0, info->proxy);
 	    }
+
+	  egg_toolbar_set_style (EGG_TOOLBAR (info->proxy), info->style);
+	  egg_toolbar_set_icon_size (EGG_TOOLBAR (info->proxy), info->icon_size);
 	  break;
 	case EGG_MENU_MERGE_MENU_PLACEHOLDER:
 	  /* create menu items for placeholders if necessary ... */
Index: lib/egg/egg-menu-merge.h
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/egg-menu-merge.h,v
retrieving revision 1.2
diff -u -p -r1.2 egg-menu-merge.h
--- lib/egg/egg-menu-merge.h	20 Jan 2003 18:57:16 -0000	1.2
+++ lib/egg/egg-menu-merge.h	10 Mar 2003 18:59:46 -0000
@@ -64,6 +64,9 @@ struct _EggMenuMergeNode {
 
   GList *uifiles;
 
+  GtkIconSize icon_size;
+  GtkToolbarStyle style;
+  
   guint dirty : 1;
 };
 
Index: lib/egg/eggtoolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/eggtoolbar.c,v
retrieving revision 1.7
diff -u -p -r1.7 eggtoolbar.c
--- lib/egg/eggtoolbar.c	7 Mar 2003 01:20:45 -0000	1.7
+++ lib/egg/eggtoolbar.c	10 Mar 2003 18:59:46 -0000
@@ -1508,6 +1508,7 @@ egg_toolbar_insert_tool_item (EggToolbar
   egg_tool_item_set_orientation (item, toolbar->orientation);
   egg_tool_item_set_toolbar_style (item, toolbar->style);
   egg_tool_item_set_relief_style (item, get_button_relief (toolbar));
+  egg_tool_item_set_icon_size (item, toolbar->icon_size);
   
   gtk_widget_set_parent (GTK_WIDGET (item), GTK_WIDGET (toolbar));
   GTK_WIDGET_UNSET_FLAGS (item, GTK_CAN_FOCUS);  
Index: lib/widgets/ephy-editable-toolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-editable-toolbar.c,v
retrieving revision 1.23
diff -u -p -r1.23 ephy-editable-toolbar.c
--- lib/widgets/ephy-editable-toolbar.c	8 Mar 2003 12:44:34 -0000	1.23
+++ lib/widgets/ephy-editable-toolbar.c	10 Mar 2003 18:59:47 -0000
@@ -93,7 +93,9 @@ struct EphyEditableToolbarPrivate
 	GtkWidget *editor;
 	GtkWidget *table;
 	GtkWidget *scrolled_window;
-
+	GtkWidget *option_menu;
+	GtkWidget *menu;
+	
 	GtkWidget *last_toolbar;
 
 	guint ui_id;
@@ -103,7 +105,7 @@ struct EphyEditableToolbarPrivate
 	gboolean edit_mode;
 
 	EphyToolbarsGroup *group;
-
+	
 	EggMenuMerge *popup_merge;
 	EggActionGroup *popup_action_group;
 
@@ -921,24 +923,92 @@ editor_close (EphyEditableToolbar *etool
 }
 
 static void
-editor_add_toolbar (EphyEditableToolbar *etoolbar)
+editor_real_add_toolbar (EphyEditableToolbar *etoolbar,
+			 const char *name)
 {
 	g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
 
-	ephy_toolbars_group_add_toolbar (etoolbar->priv->group);
+	ephy_toolbars_group_add_toolbar (etoolbar->priv->group, name);
 
 	etoolbar->priv->toolbars_dirty = TRUE;
 	queue_ui_update (etoolbar);
 }
 
 static void
+add_toolbar_response (GtkDialog *dialog,
+		      guint response_id,
+		      EphyEditableToolbar *etoolbar)
+{
+	GtkWidget *entry;
+
+	entry = g_object_get_data (G_OBJECT (dialog), "name-entry");
+	switch (response_id) {
+	case RESPONSE_ADD_TOOLBAR:
+		editor_real_add_toolbar (etoolbar,
+					 gtk_entry_get_text (GTK_ENTRY (entry)));
+		break;
+	default:
+		break;
+	}
+
+	gtk_grab_remove (GTK_WIDGET (dialog));
+	gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+editor_add_toolbar (EphyEditableToolbar *etoolbar,
+		    GtkWidget *window)
+{
+	GtkWidget *editor;
+	GtkWidget *vbox;
+	GtkWidget *label;
+	GtkWidget *entry;
+
+	editor = gtk_dialog_new ();
+	gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
+	gtk_window_set_default_size (GTK_WINDOW (editor), 350, 120);
+	gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (window));
+	gtk_window_set_title (GTK_WINDOW (editor), _("Add a New Toolbar"));
+
+	vbox = gtk_vbox_new (FALSE, 12);
+	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+	gtk_widget_show (vbox);
+	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editor)->vbox), vbox);
+
+	label = gtk_label_new (_("Enter a name for the new toolbar:"));
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+	gtk_widget_show (label);
+	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+	entry = gtk_entry_new ();
+	gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+	gtk_widget_show (entry);
+	gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
+
+	g_object_set_data (G_OBJECT (editor), "name-entry", entry);
+	
+	gtk_dialog_add_button (GTK_DIALOG (editor),
+			       GTK_STOCK_CANCEL,
+			       GTK_RESPONSE_CANCEL);
+	gtk_dialog_add_button (GTK_DIALOG (editor),
+			       _("Add Toolbar"),
+			       RESPONSE_ADD_TOOLBAR);
+	gtk_dialog_set_default_response (GTK_DIALOG (editor), RESPONSE_ADD_TOOLBAR);
+	
+	g_signal_connect (G_OBJECT (editor), "response",
+			  G_CALLBACK (add_toolbar_response), etoolbar);
+	gtk_widget_show (editor);
+	gtk_grab_add (editor);
+}
+
+static void
 dialog_response_cb (GtkDialog *dialog, gint response_id,
 		    EphyEditableToolbar *etoolbar)
 {
 	switch (response_id)
 	{
 		case RESPONSE_ADD_TOOLBAR:
-			editor_add_toolbar (etoolbar);
+			editor_add_toolbar (etoolbar, GTK_WIDGET (dialog));
 			break;
 		case GTK_RESPONSE_CLOSE:
 			editor_close (etoolbar);
@@ -947,53 +1017,369 @@ dialog_response_cb (GtkDialog *dialog, g
 }
 
 static void
+add_item_menu (EphyToolbarsToolbar *toolbar,
+	       gpointer data)
+{
+
+	GtkWidget *item;
+
+	item = gtk_menu_item_new_with_label (toolbar->name ? toolbar->name : toolbar->id);
+	g_object_set_data (G_OBJECT (item), "toolbar", toolbar);
+	gtk_widget_show (item);
+
+	gtk_menu_shell_append (GTK_MENU_SHELL (data), item);
+}
+
+static GtkWidget *
+make_option_menu (EphyEditableToolbar *etoolbar)
+{
+	GtkWidget *menu;
+
+	menu = gtk_menu_new ();
+	ephy_toolbars_group_foreach_toolbar (etoolbar->priv->group, add_item_menu, menu);
+	gtk_widget_show (menu);
+
+	return menu;
+}
+
+static GtkWidget *
+make_title_label (const char *text,
+		  double x_align)
+{
+	char *full_text;
+	GtkWidget *label;
+
+	full_text = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+	label = gtk_label_new (full_text);
+	g_free (full_text);
+
+	gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (label), x_align, 0.5);
+	
+	return label;
+}
+
+static void
+editor_response_cb (GtkDialog *dialog,
+		    guint respone_id,
+		    gpointer data)
+{
+	gtk_grab_remove (GTK_WIDGET (dialog));
+	gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static const char *style[4] = {
+	N_("Icons Only"),
+	N_("Text Only"),
+	N_("Both Icons and Text Vertically"),
+	N_("Both Icons and Text Horizontally")
+};
+
+static void
+item_activated (GtkWidget *item,
+		gpointer style)
+{
+	EphyToolbarsToolbar *toolbar;
+	EphyEditableToolbar *etoolbar;
+
+	etoolbar = g_object_get_data (G_OBJECT (item), "etoolbar");
+	toolbar = g_object_get_data (G_OBJECT (item), "toolbar");
+
+	ephy_toolbars_group_set_style (etoolbar->priv->group, toolbar,
+				       GPOINTER_TO_INT (style));
+}
+
+static GtkWidget *
+make_style_menu (EphyEditableToolbar *etoolbar,
+		 EphyToolbarsToolbar *toolbar)
+{
+	int i;
+	GtkWidget *menu;
+
+	menu = gtk_menu_new ();
+	
+	for (i = 0; i < 4; i++) {
+		GtkWidget *item;
+
+		item = gtk_menu_item_new_with_label (_(style[i]));
+		g_object_set_data (G_OBJECT (item), "etoolbar", etoolbar);
+		g_object_set_data (G_OBJECT (item), "toolbar", toolbar);
+		
+		g_signal_connect (G_OBJECT (item), "activate",
+				  G_CALLBACK (item_activated), GINT_TO_POINTER (i));
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		gtk_widget_show (item);
+	}
+
+	gtk_widget_show (menu);
+	return menu;
+}
+
+static void
+small_toggled (GtkToggleButton *tb,
+	       EphyToolbarsToolbar *toolbar)
+{
+	EphyEditableToolbar *etoolbar;
+
+	etoolbar = g_object_get_data (G_OBJECT (tb), "etoolbar");
+	if (gtk_toggle_button_get_active (tb)) {
+		ephy_toolbars_group_set_icon_size (etoolbar->priv->group,
+						   toolbar, GTK_ICON_SIZE_SMALL_TOOLBAR);
+	}
+}
+
+static void
+large_toggled (GtkToggleButton *tb,
+	       EphyToolbarsToolbar *toolbar)
+{
+	EphyEditableToolbar *etoolbar;
+
+	etoolbar = g_object_get_data (G_OBJECT (tb), "etoolbar");
+	if (gtk_toggle_button_get_active (tb)) {
+		ephy_toolbars_group_set_icon_size (etoolbar->priv->group,
+						   toolbar, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	}
+}
+
+static void
+edit_toolbar_props (GtkButton *button,
+		    EphyEditableToolbar *etoolbar)
+{
+	GtkWidget *editor;
+	GtkWidget *item;
+	EphyToolbarsToolbar *toolbar;
+	char *title;
+	int history;
+	GList *children;
+	GtkWidget *vbox;
+	GtkWidget *inner_vbox;
+	GtkWidget *inner_hbox;
+	GtkWidget *spacer_hbox;
+	GtkWidget *size_hbox;
+	GtkWidget *spacer;
+	GtkWidget *label;
+	GtkWidget *style;
+	GtkWidget *menu;
+	GtkWidget *image;
+	GtkWidget *small, *large;
+	
+	/* Get the toolbar */
+	history = gtk_option_menu_get_history (GTK_OPTION_MENU (etoolbar->priv->option_menu));
+	children = gtk_container_get_children (GTK_CONTAINER (etoolbar->priv->menu));
+	item = g_list_nth_data (children, history);
+	g_assert (GTK_IS_MENU_ITEM (item));
+	
+	toolbar = g_object_get_data (G_OBJECT (item), "toolbar");
+	
+	editor = gtk_dialog_new ();
+	gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
+	gtk_window_set_default_size (GTK_WINDOW (editor), 300, 200);
+	gtk_window_set_transient_for (GTK_WINDOW (editor),
+				      GTK_WINDOW (etoolbar->priv->editor));
+
+	title = g_strdup_printf (_("%s's Properties"), toolbar->name ? toolbar->name : toolbar->id);
+	gtk_window_set_title (GTK_WINDOW (editor), title);
+	g_free (title);
+
+	vbox = gtk_vbox_new (FALSE, 12);
+	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+	gtk_widget_show (vbox);
+	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editor)->vbox), vbox);
+
+	inner_hbox = gtk_hbox_new (FALSE, 6);
+	gtk_box_pack_start (GTK_BOX (vbox), inner_hbox, FALSE, FALSE, 0);
+	gtk_widget_show (inner_hbox);
+
+	label = make_title_label (_("Style:"), 0.0);
+	gtk_box_pack_start (GTK_BOX (inner_hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show (label);
+	
+	style = gtk_option_menu_new ();
+	gtk_box_pack_start (GTK_BOX (inner_hbox), style, TRUE, TRUE, 0);
+	gtk_widget_show (style);
+
+	menu = make_style_menu (etoolbar, toolbar);
+	gtk_option_menu_set_menu (GTK_OPTION_MENU (style), menu);
+	gtk_option_menu_set_history (GTK_OPTION_MENU (style), toolbar->style);
+	
+	inner_vbox = gtk_vbox_new (FALSE, 6);
+	gtk_box_pack_start (GTK_BOX (vbox), inner_vbox, FALSE, FALSE, 0);
+	gtk_widget_show (inner_vbox);
+
+	label = make_title_label (_("Icon Size:"), 0.0);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), label, FALSE, FALSE, 0);
+	gtk_widget_show (label);
+
+	spacer_hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), spacer_hbox, FALSE, FALSE, 0);
+	gtk_widget_show (spacer_hbox);
+
+	spacer = gtk_label_new ("    ");
+	gtk_box_pack_start (GTK_BOX (spacer_hbox), spacer, FALSE, FALSE, 0);
+	gtk_widget_show (spacer);
+
+	inner_vbox = gtk_vbox_new (FALSE, 6);
+	gtk_box_pack_start (GTK_BOX (spacer_hbox), inner_vbox, TRUE, TRUE, 0);
+	gtk_widget_show (inner_vbox);
+
+	small = gtk_radio_button_new (NULL);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), small, FALSE, FALSE, 0);
+	gtk_widget_show (small);
+
+	g_object_set_data (G_OBJECT (small), "etoolbar", etoolbar);
+	g_signal_connect (G_OBJECT (small), "toggled",
+			  G_CALLBACK (small_toggled), toolbar);
+
+	size_hbox = gtk_hbox_new (FALSE, 6);
+	gtk_container_add (GTK_CONTAINER (small), size_hbox);
+	gtk_widget_show (size_hbox);
+	
+	image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_SMALL_TOOLBAR);
+	gtk_box_pack_start (GTK_BOX (size_hbox), image, FALSE, FALSE, 0);
+	gtk_widget_show (image);
+
+	label = gtk_label_new_with_mnemonic (_("_Small"));
+	gtk_label_set_mnemonic_widget (GTK_LABEL (label), small);
+	gtk_box_pack_start (GTK_BOX (size_hbox), label, TRUE, TRUE, 0);
+	gtk_widget_show (label);
+
+	large = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (small));
+	gtk_box_pack_start (GTK_BOX (inner_vbox), large, FALSE, FALSE, 0);
+	gtk_widget_show (large);
+
+	g_object_set_data (G_OBJECT (large), "etoolbar", etoolbar);
+	g_signal_connect (G_OBJECT (large), "toggled",
+			  G_CALLBACK (large_toggled), toolbar);
+			
+	size_hbox = gtk_hbox_new (FALSE, 6);
+	gtk_container_add (GTK_CONTAINER (large), size_hbox);
+	gtk_widget_show (size_hbox);
+	
+	image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	gtk_box_pack_start (GTK_BOX (size_hbox), image, FALSE, FALSE, 0);
+	gtk_widget_show (image);
+
+	label = gtk_label_new_with_mnemonic (_("_Large"));
+	gtk_label_set_mnemonic_widget (GTK_LABEL (label), large);
+	gtk_box_pack_start (GTK_BOX (size_hbox), label, TRUE, TRUE, 0);
+	gtk_widget_show (label);
+
+	if (toolbar->icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR) {
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (large), TRUE);
+	}
+	gtk_dialog_add_button (GTK_DIALOG (editor),
+			       GTK_STOCK_HELP,
+			       GTK_RESPONSE_HELP);
+	gtk_dialog_add_button (GTK_DIALOG (editor),
+			       GTK_STOCK_CLOSE,
+			       GTK_RESPONSE_CLOSE);
+
+	g_signal_connect (G_OBJECT (editor), "response",
+			  G_CALLBACK (editor_response_cb), editor);
+	
+	gtk_grab_add (editor);
+	gtk_widget_show (editor);
+
+}
+
+static void
 setup_editor (EphyEditableToolbar *etoolbar, GtkWidget *window)
 {
 	GtkWidget *editor;
 	GtkWidget *scrolled_window;
 	GtkWidget *vbox;
-	GtkWidget *label_hbox;
-	GtkWidget *image;
 	GtkWidget *label;
-
+	GtkWidget *inner_vbox;
+	GtkWidget *spacer_hbox;
+	GtkWidget *inner_hbox;
+	GtkWidget *option_menu;
+	GtkWidget *button;
+	GtkWidget *menu;
+	GtkWidget *spacer;
+	
 	g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
 
-	editor = gtk_dialog_new (),
+	editor = gtk_dialog_new ();
 	gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
 	gtk_widget_set_size_request (GTK_WIDGET (editor), 500, 330);
 	gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (window));
-	gtk_window_set_title (GTK_WINDOW (editor), "Toolbar editor");
+	gtk_window_set_title (GTK_WINDOW (editor), _("Toolbar editor"));
 	etoolbar->priv->editor = editor;
 
 	vbox = gtk_vbox_new (FALSE, 12);
 	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
 	gtk_widget_show (vbox);
 	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editor)->vbox), vbox);
+
+	inner_vbox = gtk_vbox_new (FALSE, 6);
+	gtk_box_pack_start (GTK_BOX (vbox), inner_vbox, FALSE, FALSE, 0);
+	gtk_widget_show (inner_vbox);
+
+	label = make_title_label (_("Toolbars:"), 0.0);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), label, FALSE, FALSE, 0);
+	gtk_widget_show (label);
+
+	spacer_hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), spacer_hbox, FALSE, FALSE, 0);
+	gtk_widget_show (spacer_hbox);
+
+	spacer = gtk_label_new ("    ");
+	gtk_box_pack_start (GTK_BOX (spacer_hbox), spacer, FALSE, FALSE, 0);
+	gtk_widget_show (spacer);
+
+	inner_hbox = gtk_hbox_new (FALSE, 6);
+	gtk_box_pack_start (GTK_BOX (spacer_hbox), inner_hbox, TRUE, TRUE, 0);
+	gtk_widget_show (inner_hbox);
+	
+	option_menu = gtk_option_menu_new ();
+	etoolbar->priv->option_menu = option_menu;
+	gtk_box_pack_start (GTK_BOX (inner_hbox), option_menu, TRUE, TRUE, 0);
+	gtk_widget_show (option_menu);
+
+	menu = make_option_menu (etoolbar);
+	gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
+	etoolbar->priv->menu = menu;
+	
+	button = gtk_button_new_with_mnemonic (_("_Edit Toolbar Properties..."));
+	g_signal_connect (G_OBJECT (button), "clicked",
+			  G_CALLBACK (edit_toolbar_props), etoolbar);
+	
+	gtk_box_pack_start (GTK_BOX (inner_hbox), button, FALSE, FALSE, 0);
+	gtk_widget_show (button);
+
+	inner_vbox = gtk_vbox_new (FALSE, 6);
+	gtk_box_pack_start (GTK_BOX (vbox), inner_vbox, TRUE, TRUE, 0);
+	gtk_widget_show (inner_vbox);
+
+	label = make_title_label (_("Drag Tools In and Out of the Toolbars:"), 0.0);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), label, FALSE, FALSE, 0);
+	gtk_widget_show (label);
+
+	spacer_hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (inner_vbox), spacer_hbox, TRUE, TRUE, 0);
+	gtk_widget_show (spacer_hbox);
+
+	spacer = gtk_label_new ("    ");
+	gtk_box_pack_start (GTK_BOX (spacer_hbox), spacer, FALSE, FALSE, 0);
+	gtk_widget_show (spacer);
+
 	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
 	etoolbar->priv->scrolled_window = scrolled_window;
 	gtk_widget_show (scrolled_window);
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
 					GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-	gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
-	label_hbox = gtk_hbox_new (FALSE, 6);
-	gtk_widget_show (label_hbox);
-	gtk_box_pack_start (GTK_BOX (vbox), label_hbox, FALSE, FALSE, 0);
-	image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
-	gtk_widget_show (image);
-	gtk_box_pack_start (GTK_BOX (label_hbox), image, FALSE, FALSE, 0);
-	label = gtk_label_new (_("Drag an item onto the toolbars above to add it, "
-				 "from the toolbars in the items table to remove it."));
-	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-	gtk_widget_show (label);
-	gtk_box_pack_start (GTK_BOX (label_hbox), label, FALSE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (spacer_hbox), scrolled_window, TRUE, TRUE, 0);
 
 	gtk_dialog_add_button (GTK_DIALOG (editor),
-			       _("Add Toolbar"),
+			       _("Add a New Toolbar..."),
 			       RESPONSE_ADD_TOOLBAR);
 	gtk_dialog_add_button (GTK_DIALOG (editor),
 			       GTK_STOCK_CLOSE,
 			       GTK_RESPONSE_CLOSE);
-
+	gtk_dialog_add_button (GTK_DIALOG (editor),
+			       GTK_STOCK_HELP,
+			       GTK_RESPONSE_HELP);
+	
 	g_signal_connect (editor, "response",
 			  G_CALLBACK (dialog_response_cb),
 			  etoolbar);
Index: lib/widgets/ephy-spinner.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-spinner.c,v
retrieving revision 1.9
diff -u -p -r1.9 ephy-spinner.c
--- lib/widgets/ephy-spinner.c	9 Mar 2003 00:32:34 -0000	1.9
+++ lib/widgets/ephy-spinner.c	10 Mar 2003 18:59:47 -0000
@@ -246,6 +246,7 @@ ephy_spinner_expose (GtkWidget *widget, 
 {
 	EphySpinner *spinner;
 	GdkPixbuf *pixbuf;
+	GdkGC *gc;
 	int x_offset, y_offset, width, height;
 	GdkRectangle pix_area, dest;
 
@@ -277,14 +278,13 @@ ephy_spinner_expose (GtkWidget *widget, 
 		return FALSE;
 	}
 
-	gdk_pixbuf_render_to_drawable_alpha (
-		pixbuf, widget->window,
-		dest.x - x_offset, dest.y - y_offset,
-		dest.x, dest.y,
-		dest.width, dest.height,
-		GDK_PIXBUF_ALPHA_BILEVEL, 128,
-		GDK_RGB_DITHER_MAX,
-		0, 0);
+	gc = gdk_gc_new (widget->window);
+	gdk_draw_pixbuf (widget->window, gc, pixbuf,
+			 dest.x - x_offset, dest.y - y_offset,
+			 dest.x, dest.y,
+			 dest.width, dest.height,
+			 GDK_RGB_DITHER_MAX, 0, 0);
+	g_object_unref (gc);
 
 	g_object_unref (pixbuf);
 
Index: lib/widgets/ephy-toolbars-group.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-toolbars-group.c,v
retrieving revision 1.9
diff -u -p -r1.9 ephy-toolbars-group.c
--- lib/widgets/ephy-toolbars-group.c	27 Feb 2003 13:11:49 -0000	1.9
+++ lib/widgets/ephy-toolbars-group.c	10 Mar 2003 18:59:47 -0000
@@ -44,6 +44,23 @@ struct EphyToolbarsGroupPrivate
 	char *user;
 };
 
+static const char *toolbar_style[4] = {
+	"icons",
+	"text",
+	"both",
+	"both_horiz"
+};
+
+static const char *toolbar_icon_size[7] = {
+	"Unknown", /* Shouldn't occur but we need it to match the rest up */
+	"menu",
+	"small-toolbar",
+	"large-toolbar",
+	"button",
+	"dnd",
+	"dialog"
+};
+
 GType
 ephy_toolbars_group_get_type (void)
 {
@@ -90,9 +107,16 @@ ephy_toolbars_group_to_xml (EphyToolbars
 	for (l1 = tl->children; l1 != NULL; l1 = l1->next)
 	{
 		xmlNodePtr tnode;
-
+		EphyToolbarsToolbar *toolbar = l1->data;
+		
 		tnode = xmlNewChild (doc->children, NULL, "toolbar", NULL);
+		if (toolbar->name != NULL)
+		{
+			xmlSetProp (tnode, "name", toolbar->name);
+		}
 
+		xmlSetProp (tnode, "style", toolbar_style[toolbar->style]);
+		xmlSetProp (tnode, "icon_size", toolbar_icon_size[toolbar->icon_size]);
 		for (l2 = l1->children; l2 != NULL; l2 = l2->next)
 		{
 			xmlNodePtr node;
@@ -133,7 +157,13 @@ toolbars_toolbar_new (void)
 
 	toolbar = g_new0 (EphyToolbarsToolbar, 1);
 	toolbar->id = g_strdup_printf ("Toolbar%d", id);
-
+	toolbar->name = NULL;
+	
+	/* Should these be taken from the Gnome defaults?
+	   Are there Gnome defaults? */
+	toolbar->style = GTK_TOOLBAR_BOTH;
+	toolbar->icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
+	
 	id++;
 
 	return toolbar;
@@ -163,6 +193,7 @@ free_toolbar_node (EphyToolbarsToolbar *
 	g_return_if_fail (toolbar != NULL);
 
 	g_free (toolbar->id);
+	g_free (toolbar->name);
 	g_free (toolbar);
 }
 
@@ -250,13 +281,97 @@ parse_item_list (EphyToolbarsGroup *t,
 	}
 }
 
+static GtkToolbarStyle
+toolbar_style_from_string (const char *str)
+{
+	if (strcmp (str, "icons") == 0)
+	{
+		return GTK_TOOLBAR_ICONS;
+	}
+	else if (strcmp (str, "text") == 0)
+	{
+		return GTK_TOOLBAR_TEXT;
+	}
+	else if (strcmp (str, "both") == 0)
+	{
+		return GTK_TOOLBAR_BOTH;
+	}
+	else if (strcmp (str, "horizontal") == 0)
+	{
+		return GTK_TOOLBAR_BOTH_HORIZ;
+	}
+
+	g_warning ("Unknown GtkToolbarStyle: %s", str);
+	return GTK_TOOLBAR_BOTH;
+}
+
+static GtkIconSize
+icon_size_from_string (const char *str)
+{
+	if (strcmp (str, "menu") == 0)
+	{
+		return GTK_ICON_SIZE_MENU;
+	}
+	else if (strcmp (str, "small-toolbar") == 0)
+	{
+		return GTK_ICON_SIZE_SMALL_TOOLBAR;
+	}
+	else if (strcmp (str, "large-toolbar") == 0)
+	{
+		return GTK_ICON_SIZE_LARGE_TOOLBAR;
+	}
+	else if (strcmp (str, "button") == 0)
+	{
+		return GTK_ICON_SIZE_BUTTON;
+	}
+	else if (strcmp (str, "dnd") == 0)
+	{
+		return GTK_ICON_SIZE_DND;
+	}
+	else if (strcmp (str, "dialog") == 0)
+	{
+		return GTK_ICON_SIZE_DIALOG;
+	}
+
+	g_warning ("Unknown GtkIconSize: %s", str);
+	return GTK_ICON_SIZE_LARGE_TOOLBAR;
+}
+
 static GNode *
-add_toolbar (EphyToolbarsGroup *t)
+add_toolbar (EphyToolbarsGroup *t,
+	     xmlNodePtr child)
 {
 	EphyToolbarsToolbar *toolbar;
 	GNode *node;
 
 	toolbar = toolbars_toolbar_new ();
+
+	if (child != NULL) {
+		xmlChar *prop;
+
+		/* Toolbar name */
+		prop = xmlGetProp (child, "name");
+		if (prop)
+		{
+			toolbar->name = g_strdup (prop);
+ 			xmlFree (prop);
+		}
+
+		prop = xmlGetProp (child, "style");
+		if (prop)
+		{
+			toolbar->style = toolbar_style_from_string (prop);
+ 			xmlFree (prop);
+		}
+
+		prop = xmlGetProp (child, "icon_size");
+		if (prop)
+		{
+			toolbar->icon_size = icon_size_from_string (prop);
+ 			xmlFree (prop);
+		}
+	}		
+	
 	node = g_node_new (toolbar);
 	g_node_append (t->priv->toolbars, node);
 
@@ -264,15 +379,20 @@ add_toolbar (EphyToolbarsGroup *t)
 }
 
 EphyToolbarsToolbar *
-ephy_toolbars_group_add_toolbar (EphyToolbarsGroup *t)
+ephy_toolbars_group_add_toolbar (EphyToolbarsGroup *t,
+				 const char *name)
 {
 	GNode *node;
-
+	EphyToolbarsToolbar *toolbar;
+	
 	g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (t), NULL);
 
-	node = add_toolbar (t);
+	node = add_toolbar (t, NULL);
 	g_return_val_if_fail (node != NULL, NULL);
 
+	toolbar = node->data;
+	toolbar->name = g_strdup (name);
+	
 	toolbars_group_save (t);
 
 	g_signal_emit (G_OBJECT (t), ephy_toolbars_group_signals[CHANGED], 0);
@@ -289,9 +409,11 @@ parse_toolbars (EphyToolbarsGroup *t,
 		if (xmlStrEqual (child->name, "toolbar"))
 		{
 			GNode *node;
-
-			node = add_toolbar (t);
+			
+			node = add_toolbar (t, child);
+			
 			parse_item_list (t, child->children, node);
+
 		}
 
 		child = child->next;
@@ -381,7 +503,9 @@ ephy_toolbars_group_to_string (EphyToolb
 		EphyToolbarsToolbar *toolbar = l1->data;
 
 		g_string_append_printf
-			(s, "<dockitem name=\"%s\">\n", toolbar->id);
+			(s, "<dockitem name=\"%s\" look=\"%s\" size=\"%s\">\n",
+			 toolbar->id, toolbar_style[toolbar->style],
+			 toolbar_icon_size[toolbar->icon_size]);
 
 		for (l2 = l1->children; l2 != NULL; l2 = l2->next)
 		{
@@ -529,6 +653,28 @@ ephy_toolbars_group_remove_item	(EphyToo
 		g_node_destroy (toolbar);
 	}
 
+	toolbars_group_save (t);
+
+	g_signal_emit (G_OBJECT (t), ephy_toolbars_group_signals[CHANGED], 0);
+}
+
+void
+ephy_toolbars_group_set_icon_size (EphyToolbarsGroup *t,
+				   EphyToolbarsToolbar *toolbar,
+				   GtkIconSize icon_size)
+{
+	toolbar->icon_size = icon_size;
+	toolbars_group_save (t);
+
+	g_signal_emit (G_OBJECT (t), ephy_toolbars_group_signals[CHANGED], 0);
+}
+
+void
+ephy_toolbars_group_set_style (EphyToolbarsGroup *t,
+			       EphyToolbarsToolbar *toolbar,
+			       GtkToolbarStyle style)
+{
+	toolbar->style = style;
 	toolbars_group_save (t);
 
 	g_signal_emit (G_OBJECT (t), ephy_toolbars_group_signals[CHANGED], 0);
Index: lib/widgets/ephy-toolbars-group.h
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-toolbars-group.h,v
retrieving revision 1.3
diff -u -p -r1.3 ephy-toolbars-group.h
--- lib/widgets/ephy-toolbars-group.h	21 Feb 2003 16:40:34 -0000	1.3
+++ lib/widgets/ephy-toolbars-group.h	10 Mar 2003 18:59:47 -0000
@@ -40,6 +40,9 @@ typedef struct EphyToolbarsGroupPrivate 
 typedef struct
 {
 	char *id;
+	char *name;
+	GtkToolbarStyle style;
+	GtkIconSize icon_size;
 } EphyToolbarsToolbar;
 
 typedef struct
@@ -76,7 +79,8 @@ void			ephy_toolbars_group_set_source		(
 								 const char *defaults,
 								 const char *user);
 
-EphyToolbarsToolbar    *ephy_toolbars_group_add_toolbar		(EphyToolbarsGroup *t);
+EphyToolbarsToolbar    *ephy_toolbars_group_add_toolbar		(EphyToolbarsGroup *t,
+								 const char *name);
 
 void			ephy_toolbars_group_add_item		(EphyToolbarsGroup *t,
 								 EphyToolbarsToolbar *parent,
@@ -105,6 +109,14 @@ char		       *ephy_toolbars_group_to_str
 
 char		       *ephy_toolbars_group_get_path		(EphyToolbarsGroup *t,
 								 gpointer item);
+
+void			ephy_toolbars_group_set_icon_size 	(EphyToolbarsGroup *t,
+								 EphyToolbarsToolbar *toolbar,
+								 GtkIconSize icon_size);
+
+void			ephy_toolbars_group_set_style		(EphyToolbarsGroup *t,
+								 EphyToolbarsToolbar *toolbar,
+								 GtkToolbarStyle style);
 
 G_END_DECLS
 
Index: src/bookmarks/ephy-bookmarks-editor.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-editor.c,v
retrieving revision 1.20
diff -u -p -r1.20 ephy-bookmarks-editor.c
--- src/bookmarks/ephy-bookmarks-editor.c	9 Mar 2003 01:09:05 -0000	1.20
+++ src/bookmarks/ephy-bookmarks-editor.c	10 Mar 2003 18:59:47 -0000
@@ -276,9 +276,9 @@ ephy_bookmarks_editor_finalize (GObject 
 
 	g_object_unref (G_OBJECT (editor->priv->bookmarks_filter));
 
-	g_object_unref (editor->priv->action_group);
 	egg_menu_merge_remove_action_group (editor->priv->ui_merge,
 					    editor->priv->action_group);
+	g_object_unref (editor->priv->action_group);
 	g_object_unref (editor->priv->ui_merge);
 
 	g_free (editor->priv);


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