[Epiphany] Toolbar Editor
- From: iain <iain prettypeople org>
- To: epiphany mozdev org
- Subject: [Epiphany] Toolbar Editor
- Date: 09 Mar 2003 18:05:21 +0000
Here's the toolbar editor patch I've been working on.
It also includes a few changes to the libegg code that I will submit to
the libegg bugzilla once I make them final.
Things it adds.
Ability to set the style and icon size on toolbars, either in the XML
code (for programmers) and via the UI (for the users).
Marco pointed out that the ability to set the size for toolbars
individually might not be incredibly useful for Epiphany, but that it
could be useful in applications that have lots of toolbars.
In the XML what used to be
<toolbar>
<toolitem verb="ZoomIn"/>
<toolitem verb="ZoomOut"/>
</toolbar>
becomes
<toolbar name="Zoombar" style="icons" icon_size="small-toolbar">
<toolitem verb="ZoomIn"/>
<toolitem verb="ZoomOut"/>
</toolbar>
Where name is the user viewable string that the user sees when editting
a toolbar, the style is one of
"icons", "text", "both" or "horizontal" corresponding to the settings in
GtkToolbarStyle
and icon_size is one of
"menu", "small-toolbar", "large-toolbar", "button", "dnd" or "dialog"
Again corresponding to GtkIconSize.
Note: From the editor you can only set the size to be "small-toolbar" or
"large-toolbar". I thought exposing the other sizes might be a bit of
overkill?
Note 2: If your xml file doesn't have a name for the toolbars, the names
are taken from the toolbar ID which is "Toolbar%d", so it doesn't look
too terrible.
It also adds a dialog that asks for a Toolbar name when you click "Add a
New Toolbar". All details are saved properly.
As for libegg it adds code to handle more properties in <dockitem>
adding the "look" and "size" properties which correspond to the settings
above. The "look" property came from the old BonoboUI code, and used
both_horiz instead of horizontal. The BonoboUI code didn't have the size
property.
things that still need to be done:
1) When a toolbar is added, add it to the menu.
2) When a toolbar is removed, remove it from the menu.
3) Marco suggested to add a "Remove Toolbar" button?
4) Marco also suggested to not use the Help icon but I forgot to
change that before I made the patch, will change it before I
commit/make another patch.
5) When the "Add new toolbar" dialog appears, should there be options
to set the style/icon-size, or should we just take them from the
Gnome defaults(*)
6) How about having the ability to hide toolbars?
I think thats it.
http://www.prettypeople.org/~iain/tbe-iain.png has a screenshot of this.
iain
(*) Are there Gnome defaults for this?
--
Index: lib/egg/egg-menu-merge.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/egg-menu-merge.c,v
retrieving revision 1.7
diff -U2 -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 9 Mar 2003 17:44:30 -0000
@@ -32,8 +32,8 @@
static guint egg_menu_merge_next_merge_id (EggMenuMerge *self);
-static void egg_menu_merge_node_prepend_uierence (EggMenuMergeNode *node,
+static void egg_menu_merge_node_prepend_ui_reference (EggMenuMergeNode *node,
guint merge_id,
GQuark action_quark);
-static void egg_menu_merge_node_remove_uierence (EggMenuMergeNode *node,
+static void egg_menu_merge_node_remove_ui_reference (EggMenuMergeNode *node,
guint merge_id);
@@ -48,10 +48,8 @@
static GMemChunk *merge_node_chunk = NULL;
-static GObjectClass *parent_class = NULL;
-
GType
egg_menu_merge_get_type (void)
{
- static GType type = 0;
+ static GtkType type = 0;
if (!type)
@@ -79,26 +77,6 @@
static void
-egg_menu_merge_finalize (GObject *object)
-{
- EggMenuMerge *self = EGG_MENU_MERGE (object);
-
- if (self->update_tag != 0)
- {
- self->update_tag = g_idle_remove_by_data (self);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
egg_menu_merge_class_init (EggMenuMergeClass *class)
{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- object_class = G_OBJECT_CLASS(class);
-
- object_class->finalize = egg_menu_merge_finalize;
-
if (!merge_node_chunk)
merge_node_chunk = g_mem_chunk_create(EggMenuMergeNode, 64,
@@ -142,8 +120,8 @@
node = get_child_node(self, NULL, "Root", 4,
EGG_MENU_MERGE_ROOT, TRUE, FALSE);
- egg_menu_merge_node_prepend_uierence(NODE_INFO(node), merge_id, 0);
+ egg_menu_merge_node_prepend_ui_reference(NODE_INFO(node), merge_id, 0);
node = get_child_node(self, self->root_node, "popups", 6,
EGG_MENU_MERGE_POPUPS, TRUE, FALSE);
- egg_menu_merge_node_prepend_uierence(NODE_INFO(node), merge_id, 0);
+ egg_menu_merge_node_prepend_ui_reference(NODE_INFO(node), merge_id, 0);
}
@@ -194,6 +172,4 @@
node = egg_menu_merge_get_node(self, path, EGG_MENU_MERGE_UNDECIDED, FALSE);
- g_return_val_if_fail (node != NULL, NULL);
-
return NODE_INFO(node)->proxy;
}
@@ -223,6 +199,13 @@
if (NODE_INFO(child)->type == EGG_MENU_MERGE_UNDECIDED)
NODE_INFO(child)->type = node_type;
-
-
+
+#ifdef WANT_CRAP_SPEW
+ /* warn about type mismatch */
+ if (NODE_INFO(child)->type != EGG_MENU_MERGE_UNDECIDED &&
+ NODE_INFO(child)->type != node_type)
+ g_warning("node type doesn't match %d (%s is type %d)",
+ node_type, NODE_INFO(child)->name,
+ NODE_INFO(child)->type);
+#endif
return child;
}
@@ -316,5 +299,5 @@
static void
-egg_menu_merge_node_prepend_uierence (EggMenuMergeNode *node,
+egg_menu_merge_node_prepend_ui_reference (EggMenuMergeNode *node,
guint merge_id, GQuark action_quark)
{
@@ -332,5 +315,5 @@
static void
-egg_menu_merge_node_remove_uierence (EggMenuMergeNode *node,
+egg_menu_merge_node_remove_ui_reference (EggMenuMergeNode *node,
guint merge_id)
{
@@ -378,4 +361,60 @@
};
+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,
@@ -393,5 +432,7 @@
GQuark verb_quark;
gboolean top;
-
+ GtkIconSize icon_size;
+ GtkToolbarStyle style;
+
gboolean raise_error = TRUE;
gchar *error_attr = NULL;
@@ -418,5 +459,16 @@
top = !strcmp(attribute_values[i], "top");
}
+ else if (!strcmp(attribute_names[i], "look"))
+ {
+ g_print ("Found look\n");
+ style = toolbar_style_from_string (attribute_values[i]);
+ }
+ else if (!strcmp(attribute_names[i], "size"))
+ {
+ g_print ("found size\n");
+ icon_size = icon_size_from_string (attribute_values[i]);
+ }
}
+
/* if no verb, then set it to the node's name */
if (verb_quark == 0)
@@ -432,5 +484,5 @@
raise_error = FALSE;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
}
@@ -447,5 +499,5 @@
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -465,5 +517,5 @@
NODE_INFO(node)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (node),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark);
NODE_INFO(node)->dirty = TRUE;
@@ -483,8 +535,10 @@
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
-
+ NODE_INFO(ctx->current)->icon_size = icon_size;
+ NODE_INFO(ctx->current)->style = style;
+
raise_error = FALSE;
}
@@ -499,5 +553,5 @@
TRUE, FALSE);
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -515,5 +569,5 @@
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -535,5 +589,5 @@
TRUE, top);
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -553,5 +607,5 @@
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -575,5 +629,5 @@
NODE_INFO(node)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (node),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark);
NODE_INFO(node)->dirty = TRUE;
@@ -595,5 +649,5 @@
NODE_INFO(node)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (node),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark);
NODE_INFO(node)->dirty = TRUE;
@@ -691,5 +745,5 @@
ParseContext *ctx = user_data;
EggMenuMerge *self = ctx->self;
- g_print ("Cleanup ui\n");
+
ctx->current = NULL;
/* should also walk through the tree and get rid of nodes related to
@@ -768,5 +822,5 @@
guint merge_id = GPOINTER_TO_UINT (user_data);
- egg_menu_merge_node_remove_uierence (NODE_INFO (node), merge_id);
+ egg_menu_merge_node_remove_ui_reference (NODE_INFO (node), merge_id);
return FALSE; /* continue */
@@ -954,4 +1008,15 @@
info = NODE_INFO(node);
+#ifdef WANT_CRAP_SPEW
+ g_print("update_node name=%s dirty=%d (", info->name, info->dirty);
+ for (tmp = info->uifiles; tmp != NULL; tmp = tmp->next)
+ {
+ NodeUIReference *ref = tmp->data;
+ g_print("%s:%u", g_quark_to_string(ref->action_quark), ref->merge_id);
+ if (tmp->next)
+ g_print(", ");
+ }
+ g_print(")\n");
+#endif
if (NODE_INFO(node)->dirty)
{
@@ -986,16 +1051,19 @@
/* If the widget already has a proxy and the action hasn't changed, then
* we don't have to do anything.
+ * If the item is a toolbar, then we need to check it again, in case
+ * the style or size have changed.
*/
if (info->proxy != NULL &&
- action == info->action)
+ action == info->action &&
+ info->type != EGG_MENU_MERGE_TOOLBAR)
{
goto recurse_children;
}
-/* if (info->action)
- g_object_unref (info->action);*/
+ if (info->action)
+ g_object_unref (info->action);
info->action = action;
-/* if (info->action)
- g_object_ref (info->action);*/
+ if (info->action)
+ g_object_ref (info->action);
switch (info->type)
@@ -1034,10 +1102,7 @@
parent = node->parent;
-
- if (parent && NODE_INFO (parent)->type == EGG_MENU_MERGE_POPUPS)
- {
- info->proxy = gtk_menu_new();
- }
- else if (find_menu_position(node, &menushell, &pos))
+ if (parent && NODE_INFO (parent)->type == EGG_MENU_MERGE_POPUPS) {
+ info->proxy = gtk_menu_new ();
+ } else if (find_menu_position(node, &menushell, &pos))
{
GtkWidget *menu;
@@ -1074,4 +1139,9 @@
g_signal_emit (self, merge_signals[ADD_WIDGET], 0, info->proxy);
}
+
+ g_print ("info->icon_size = %d\n", info->icon_size);
+ 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:
@@ -1291,4 +1361,6 @@
* is created and added to the parent container).
*/
+
+ g_message("do_updates");
update_node (self, self->root_node);
Index: lib/egg/egg-menu-merge.h
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/egg-menu-merge.h,v
retrieving revision 1.2
diff -U2 -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 9 Mar 2003 17:44:30 -0000
@@ -65,4 +65,7 @@
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 -U2 -r1.7 eggtoolbar.c
--- lib/egg/eggtoolbar.c 7 Mar 2003 01:20:45 -0000 1.7
+++ lib/egg/eggtoolbar.c 9 Mar 2003 17:44:31 -0000
@@ -1509,4 +1509,5 @@
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));
Index: lib/widgets/ephy-editable-toolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-editable-toolbar.c,v
retrieving revision 1.23
diff -U2 -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 9 Mar 2003 17:44:31 -0000
@@ -94,5 +94,7 @@
GtkWidget *table;
GtkWidget *scrolled_window;
-
+ GtkWidget *option_menu;
+ GtkWidget *menu;
+
GtkWidget *last_toolbar;
@@ -104,5 +106,5 @@
EphyToolbarsGroup *group;
-
+
EggMenuMerge *popup_merge;
EggActionGroup *popup_action_group;
@@ -922,9 +924,10 @@
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;
@@ -933,4 +936,71 @@
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)
@@ -939,5 +1009,5 @@
{
case RESPONSE_ADD_TOOLBAR:
- editor_add_toolbar (etoolbar);
+ editor_add_toolbar (etoolbar, GTK_WIDGET (dialog));
break;
case GTK_RESPONSE_CLOSE:
@@ -948,4 +1018,270 @@
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)
{
@@ -953,15 +1289,20 @@
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;
@@ -970,4 +1311,57 @@
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;
@@ -975,24 +1369,16 @@
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),
Index: lib/widgets/ephy-spinner.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-spinner.c,v
retrieving revision 1.9
diff -U2 -r1.9 ephy-spinner.c
--- lib/widgets/ephy-spinner.c 9 Mar 2003 00:32:34 -0000 1.9
+++ lib/widgets/ephy-spinner.c 9 Mar 2003 17:44:31 -0000
@@ -247,4 +247,5 @@
EphySpinner *spinner;
GdkPixbuf *pixbuf;
+ GdkGC *gc;
int x_offset, y_offset, width, height;
GdkRectangle pix_area, dest;
@@ -278,12 +279,11 @@
}
- 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 -U2 -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 9 Mar 2003 17:44:31 -0000
@@ -45,4 +45,21 @@
};
+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)
@@ -91,7 +108,14 @@
{
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)
{
@@ -135,4 +159,9 @@
toolbar->id = g_strdup_printf ("Toolbar%d", id);
+ /* 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++;
@@ -164,4 +193,5 @@
g_free (toolbar->id);
+ g_free (toolbar->name);
g_free (toolbar);
}
@@ -251,6 +281,63 @@
}
+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;
@@ -258,4 +345,31 @@
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);
@@ -265,13 +379,18 @@
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);
@@ -290,7 +409,9 @@
{
GNode *node;
-
- node = add_toolbar (t);
+
+ node = add_toolbar (t, child);
+
parse_item_list (t, child->children, node);
+
}
@@ -382,5 +503,7 @@
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)
@@ -530,4 +653,26 @@
}
+ 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);
Index: lib/widgets/ephy-toolbars-group.h
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-toolbars-group.h,v
retrieving revision 1.3
diff -U2 -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 9 Mar 2003 17:44:31 -0000
@@ -41,4 +41,7 @@
{
char *id;
+ char *name;
+ GtkToolbarStyle style;
+ GtkIconSize icon_size;
} EphyToolbarsToolbar;
@@ -77,5 +80,6 @@
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,
@@ -106,4 +110,12 @@
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]