diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-01-30 05:06:40 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-01-30 05:06:40 +0800 |
commit | dff9e866bb4f2fc18074d5c638733ee860746f9b (patch) | |
tree | 654f9332e949ce91c5d2f5c9a61280c874ce0ab5 /lib | |
parent | ec52d432955e2e2d5467a8da01c8ce929388325c (diff) | |
download | gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.gz gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.bz2 gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.lz gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.xz gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.tar.zst gsoc2013-epiphany-dff9e866bb4f2fc18074d5c638733ee860746f9b.zip |
Complete (or nearly) toolbar editor implementation. Bookmarks are
2003-01-29 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/ephy-bonobo-extensions.c: (ephy_bonobo_clear_path),
(ephy_bonobo_replace_path):
* lib/ephy-bonobo-extensions.h:
* lib/ephy-marshal.list:
* lib/ephy-string.c: (ephy_str_to_int):
* lib/ephy-string.h:
* lib/widgets/ephy-editable-toolbar.c: (impl_get_action),
(add_action), (parse_item_list), (add_toolbar), (parse_toolbars),
(load_defaults), (load_toolbar), (drag_data_received_cb),
(setup_toolbar_drag), (ensure_toolbars_min_size), (do_merge),
(ephy_editable_toolbar_class_init), (editor_get_dimensions),
(hide_editor), (editor_close_cb), (editor_add_toolbar_cb),
(editor_drag_data_received_cb), (editor_drag_data_delete_cb),
(setup_editor), (button_press_cb), (show_editor),
(ephy_editable_toolbar_edit), (ephy_editable_toolbar_get_action):
* lib/widgets/ephy-editable-toolbar.h:
* src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_bookmark_id):
* src/bookmarks/ephy-bookmarks.h:
* src/session.c: (session_load):
* src/toolbar.c: (go_location_cb), (toolbar_get_action),
(toolbar_class_init), (toolbar_init):
Complete (or nearly) toolbar editor implementation.
Bookmarks are implemented too, but some minor problems
are stopping them to work.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-bonobo-extensions.c | 622 | ||||
-rw-r--r-- | lib/ephy-bonobo-extensions.h | 76 | ||||
-rw-r--r-- | lib/ephy-string.c | 4 | ||||
-rw-r--r-- | lib/ephy-string.h | 2 | ||||
-rwxr-xr-x | lib/widgets/ephy-editable-toolbar.c | 376 | ||||
-rwxr-xr-x | lib/widgets/ephy-editable-toolbar.h | 18 |
6 files changed, 312 insertions, 786 deletions
diff --git a/lib/ephy-bonobo-extensions.c b/lib/ephy-bonobo-extensions.c index efc43ed60..590be941c 100644 --- a/lib/ephy-bonobo-extensions.c +++ b/lib/ephy-bonobo-extensions.c @@ -39,67 +39,6 @@ #include <libgnomevfs/gnome-vfs-utils.h> #include <bonobo/bonobo-control.h> -typedef enum { - NUMBERED_MENU_ITEM_PLAIN, - NUMBERED_MENU_ITEM_TOGGLE, - NUMBERED_MENU_ITEM_RADIO -} NumberedMenuItemType; - -void -ephy_bonobo_set_accelerator (BonoboUIComponent *ui, - const char *path, - const char *accelerator) -{ - if (bonobo_ui_component_get_container (ui)) /* should not do this here... */ - { - bonobo_ui_component_set_prop (ui, path, "accel", accelerator, NULL); - } -} - -void -ephy_bonobo_set_label (BonoboUIComponent *ui, - const char *path, - const char *label) -{ - if (bonobo_ui_component_get_container (ui)) /* should not do this here... */ - { - bonobo_ui_component_set_prop (ui, path, "label", label, NULL); - } -} - -void -ephy_bonobo_set_tip (BonoboUIComponent *ui, - const char *path, - const char *tip) -{ - if (bonobo_ui_component_get_container (ui)) /* should not do this here... */ - { - bonobo_ui_component_set_prop (ui, path, "tip", tip, NULL); - } -} - -void -ephy_bonobo_set_sensitive (BonoboUIComponent *ui, - const char *path, - gboolean sensitive) -{ - if (bonobo_ui_component_get_container (ui)) /* should not do this here... */ - { - bonobo_ui_component_set_prop (ui, path, "sensitive", sensitive ? "1" : "0", NULL); - } -} - -void -ephy_bonobo_set_toggle_state (BonoboUIComponent *ui, - const char *path, - gboolean state) -{ - if (bonobo_ui_component_get_container (ui)) /* should not do this here... */ - { - bonobo_ui_component_set_prop (ui, path, "state", state ? "1" : "0", NULL); - } -} - void ephy_bonobo_set_hidden (BonoboUIComponent *ui, const char *path, @@ -111,535 +50,16 @@ ephy_bonobo_set_hidden (BonoboUIComponent *ui, } } -char * -ephy_bonobo_get_label (BonoboUIComponent *ui, - const char *path) -{ - if (bonobo_ui_component_get_container (ui)) /* should not do this here... */ - { - return bonobo_ui_component_get_prop (ui, path, "label", NULL); - } - else - { - return NULL; - } -} - -gboolean -ephy_bonobo_get_hidden (BonoboUIComponent *ui, - const char *path) -{ - char *value; - gboolean hidden; - CORBA_Environment ev; - - g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - - CORBA_exception_init (&ev); - value = bonobo_ui_component_get_prop (ui, path, "hidden", &ev); - CORBA_exception_free (&ev); - - if (value == NULL) { - /* No hidden attribute means not hidden. */ - hidden = FALSE; - } else { - /* Anything other than "0" counts as TRUE */ - hidden = strcmp (value, "0") != 0; - g_free (value); - } - - return hidden; -} - -static char * -get_numbered_menu_item_name (guint index) -{ - return g_strdup_printf ("%u", index); -} - -char * -ephy_bonobo_get_numbered_menu_item_path (BonoboUIComponent *ui, - const char *container_path, - guint index) -{ - char *item_name; - char *item_path; - - g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), NULL); - g_return_val_if_fail (container_path != NULL, NULL); - - item_name = get_numbered_menu_item_name (index); - item_path = g_strconcat (container_path, "/", item_name, NULL); - g_free (item_name); - - return item_path; -} - -char * -ephy_bonobo_get_numbered_menu_item_command (BonoboUIComponent *ui, - const char *container_path, - guint index) -{ - char *command_name; - char *path; - - g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), NULL); - g_return_val_if_fail (container_path != NULL, NULL); - - path = ephy_bonobo_get_numbered_menu_item_path (ui, container_path, index); - command_name = gnome_vfs_escape_string (path); - g_free (path); - - return command_name; -} - -guint -ephy_bonobo_get_numbered_menu_item_index_from_command (const char *command) -{ - char *path; - char *index_string; - int index; - gboolean got_index; - - path = gnome_vfs_unescape_string (command, NULL); - index_string = strrchr (path, '/'); - - if (index_string == NULL) { - got_index = FALSE; - } else { - got_index = ephy_str_to_int (index_string + 1, &index); - } - g_free (path); - - g_return_val_if_fail (got_index, 0); - - return index; -} - -char * -ephy_bonobo_get_numbered_menu_item_container_path_from_command (const char *command) -{ - char *path; - char *index_string; - char *container_path; - - path = gnome_vfs_unescape_string (command, NULL); - index_string = strrchr (path, '/'); - - container_path = index_string == NULL - ? NULL - : g_strndup (path, index_string - path); - g_free (path); - - return container_path; -} - -static char * -ephy_bonobo_add_numbered_menu_item_internal (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - NumberedMenuItemType type, - GdkPixbuf *pixbuf, - const char *radio_group_name) -{ - char *xml_item, *xml_command; - char *command_name; - char *item_name, *pixbuf_data; - char *path; - - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (container_path != NULL); - g_assert (label != NULL); - g_assert (type == NUMBERED_MENU_ITEM_PLAIN || pixbuf == NULL); - g_assert (type == NUMBERED_MENU_ITEM_RADIO || radio_group_name == NULL); - g_assert (type != NUMBERED_MENU_ITEM_RADIO || radio_group_name != NULL); - - item_name = get_numbered_menu_item_name (index); - command_name = ephy_bonobo_get_numbered_menu_item_command - (ui, container_path, index); - - switch (type) { - case NUMBERED_MENU_ITEM_TOGGLE: - xml_item = g_strdup_printf ("<menuitem name=\"%s\" id=\"%s\" type=\"toggle\"/>\n", - item_name, command_name); - break; - case NUMBERED_MENU_ITEM_RADIO: - xml_item = g_strdup_printf ("<menuitem name=\"%s\" id=\"%s\" " - "type=\"radio\" group=\"%s\"/>\n", - item_name, command_name, radio_group_name); - break; - case NUMBERED_MENU_ITEM_PLAIN: - if (pixbuf != NULL) { - pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf); - xml_item = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\" " - "pixtype=\"pixbuf\" pixname=\"%s\"/>\n", - item_name, command_name, pixbuf_data); - g_free (pixbuf_data); - } else { - xml_item = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\"/>\n", - item_name, command_name); - } - break; - default: - g_assert_not_reached (); - xml_item = NULL; /* keep compiler happy */ - } - - g_free (item_name); - - bonobo_ui_component_set (ui, container_path, xml_item, NULL); - - g_free (xml_item); - - path = ephy_bonobo_get_numbered_menu_item_path (ui, container_path, index); - ephy_bonobo_set_label (ui, path, label); - g_free (path); - - /* Make the command node here too, so callers can immediately set - * properties on it (otherwise it doesn't get created until some - * time later). - */ - xml_command = g_strdup_printf ("<cmd name=\"%s\"/>\n", command_name); - bonobo_ui_component_set (ui, "/commands", xml_command, NULL); - g_free (xml_command); - - g_free (command_name); - - return item_name; -} - -/* Add a menu item specified by number into a given path. Used for - * dynamically creating a related series of menu items. Each index - * must be unique (normal use is to call this in a loop, and - * increment the index for each item). - */ -void -ephy_bonobo_add_numbered_menu_item (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - GdkPixbuf *pixbuf) -{ - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (container_path != NULL); - g_return_if_fail (label != NULL); - - ephy_bonobo_add_numbered_menu_item_internal (ui, container_path, index, label, - NUMBERED_MENU_ITEM_PLAIN, pixbuf, NULL); -} - -/* Add a menu item specified by number into a given path. Used for - * dynamically creating a related series of toggle menu items. Each index - * must be unique (normal use is to call this in a loop, and - * increment the index for each item). - */ -void -ephy_bonobo_add_numbered_toggle_menu_item (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label) -{ - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (container_path != NULL); - g_return_if_fail (label != NULL); - - ephy_bonobo_add_numbered_menu_item_internal (ui, container_path, index, label, - NUMBERED_MENU_ITEM_TOGGLE, NULL, NULL); -} - -/* Add a menu item specified by number into a given path. Used for - * dynamically creating a related series of radio menu items. Each index - * must be unique (normal use is to call this in a loop, and - * increment the index for each item). - */ -void -ephy_bonobo_add_numbered_radio_menu_item (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - const char *radio_group_name) -{ - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (container_path != NULL); - g_return_if_fail (label != NULL); - - ephy_bonobo_add_numbered_menu_item_internal (ui, container_path, index, label, - NUMBERED_MENU_ITEM_RADIO, NULL, radio_group_name); -} - -void -ephy_bonobo_add_numbered_submenu (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - GdkPixbuf *pixbuf) -{ - char *xml_string, *item_name, *pixbuf_data, *submenu_path, *command_name; - - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (container_path != NULL); - g_return_if_fail (label != NULL); - g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf)); - - item_name = get_numbered_menu_item_name (index); - command_name = ephy_bonobo_get_numbered_menu_item_command (ui, container_path, index); - - if (pixbuf != NULL) { - pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf); - xml_string = g_strdup_printf ("<submenu name=\"%s\" pixtype=\"pixbuf\" pixname=\"%s\" " - "verb=\"%s\"/>\n", - item_name, pixbuf_data, command_name); - g_free (pixbuf_data); - } else { - xml_string = g_strdup_printf ("<submenu name=\"%s\" verb=\"%s\"/>\n", item_name, - command_name); - } - - bonobo_ui_component_set (ui, container_path, xml_string, NULL); - - g_free (xml_string); - - submenu_path = ephy_bonobo_get_numbered_menu_item_path (ui, container_path, index); - ephy_bonobo_set_label (ui, submenu_path, label); - g_free (submenu_path); - - g_free (item_name); - g_free (command_name); -} - -void -ephy_bonobo_add_numbered_submenu_no_verb (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - GdkPixbuf *pixbuf) -{ - char *xml_string, *item_name, *pixbuf_data, *submenu_path; - - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (container_path != NULL); - g_return_if_fail (label != NULL); - g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf)); - - item_name = get_numbered_menu_item_name (index); - - if (pixbuf != NULL) { - pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf); - xml_string = g_strdup_printf ("<submenu name=\"%s\" pixtype=\"pixbuf\" pixname=\"%s\" " - "/>\n", - item_name, pixbuf_data); - g_free (pixbuf_data); - } else { - xml_string = g_strdup_printf ("<submenu name=\"%s\"/>\n", item_name); - } - - bonobo_ui_component_set (ui, container_path, xml_string, NULL); - - g_free (xml_string); - - submenu_path = ephy_bonobo_get_numbered_menu_item_path (ui, container_path, index); - ephy_bonobo_set_label (ui, submenu_path, label); - g_free (submenu_path); - - g_free (item_name); -} - -void -ephy_bonobo_add_submenu (BonoboUIComponent *ui, - const char *path, - const char *label, - GdkPixbuf *pixbuf) -{ - char *xml_string, *name, *pixbuf_data, *submenu_path; - - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (path != NULL); - g_return_if_fail (label != NULL); - g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf)); - - /* Labels may contain characters that are illegal in names. So - * we create the name by URI-encoding the label. - */ - name = gnome_vfs_escape_string (label); - - if (pixbuf != NULL) { - pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf); - xml_string = g_strdup_printf ("<submenu name=\"%s\" pixtype=\"pixbuf\" pixname=\"%s\"/>\n", - name, pixbuf_data); - g_free (pixbuf_data); - } else { - xml_string = g_strdup_printf ("<submenu name=\"%s\"/>\n", name); - } - - bonobo_ui_component_set (ui, path, xml_string, NULL); - - g_free (xml_string); - - submenu_path = g_strconcat (path, "/", name, NULL); - ephy_bonobo_set_label (ui, submenu_path, label); - g_free (submenu_path); - - g_free (name); -} - -void -ephy_bonobo_add_menu_separator (BonoboUIComponent *ui, const char *path) -{ - static gint hack = 0; - gchar *xml; - - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (path != NULL); - - xml = g_strdup_printf ("<separator name=\"sep%d\"/>", ++hack); - bonobo_ui_component_set (ui, path, xml, NULL); - g_free (xml); -} - static void -remove_commands (BonoboUIComponent *ui, const char *container_path) +ephy_bonobo_clear_path (BonoboUIComponent *uic, + const gchar *path) { - BonoboUINode *path_node; - BonoboUINode *child_node; - char *verb_name; - char *id_name; - - path_node = bonobo_ui_component_get_tree (ui, container_path, TRUE, NULL); - if (path_node == NULL) { - return; - } - - bonobo_ui_component_freeze (ui, NULL); - - for (child_node = bonobo_ui_node_children (path_node); - child_node != NULL; - child_node = bonobo_ui_node_next (child_node)) { - verb_name = bonobo_ui_node_get_attr (child_node, "verb"); - if (verb_name != NULL) { - bonobo_ui_component_remove_verb (ui, verb_name); - bonobo_ui_node_free_string (verb_name); - } else { - /* Only look for an id if there's no verb */ - id_name = bonobo_ui_node_get_attr (child_node, "id"); - if (id_name != NULL) { - bonobo_ui_component_remove_listener (ui, id_name); - bonobo_ui_node_free_string (id_name); - } - } + if (bonobo_ui_component_path_exists (uic, path, NULL)) + { + char *remove_wildcard = g_strdup_printf ("%s/*", path); + bonobo_ui_component_rm (uic, remove_wildcard, NULL); + g_free (remove_wildcard); } - - bonobo_ui_component_thaw (ui, NULL); - - bonobo_ui_node_free (path_node); -} - -/** - * ephy_bonobo_remove_menu_items_and_verbs - * - * Removes all menu items contained in a menu or placeholder, and - * their verbs. - * - * @uih: The BonoboUIHandler for this menu item. - * @container_path: The standard bonobo-style path specifier for this placeholder or submenu. - */ -void -ephy_bonobo_remove_menu_items_and_commands (BonoboUIComponent *ui, - const char *container_path) -{ - char *remove_wildcard; - - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (container_path != NULL); - - remove_commands (ui, container_path); - - /* For speed, remove menu items themselves all in one fell swoop, - * though we removed the verbs one-by-one. - */ - remove_wildcard = g_strdup_printf ("%s/*", container_path); - bonobo_ui_component_rm (ui, remove_wildcard, NULL); - g_free (remove_wildcard); -} - -/* Call to set the user-visible label of a menu item to a string - * containing an underscore accelerator. The underscore is stripped - * off before setting the label of the command, because pop-up menu - * and toolbar button labels shouldn't have the underscore. - */ -void -ephy_bonobo_set_label_for_menu_item_and_command (BonoboUIComponent *ui, - const char *menu_item_path, - const char *command_path, - const char *label_with_underscore) -{ - char *label_no_underscore; - - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui)); - g_return_if_fail (menu_item_path != NULL); - g_return_if_fail (command_path != NULL); - g_return_if_fail (label_with_underscore != NULL); - - label_no_underscore = ephy_str_strip_chr (label_with_underscore, '_'); - ephy_bonobo_set_label (ui, - menu_item_path, - label_with_underscore); - ephy_bonobo_set_label (ui, - command_path, - label_no_underscore); - - g_free (label_no_underscore); -} - -gchar * -ephy_bonobo_add_dockitem (BonoboUIComponent *uic, - const char *name, - int band_num) -{ - gchar *xml; - gchar *sname; - gchar *path; - - sname = gnome_vfs_escape_string (name); - xml = g_strdup_printf ("<dockitem name=\"%s\" band_num=\"%d\" " - "config=\"0\" behavior=\"exclusive\"/>", - sname, band_num); - path = g_strdup_printf ("/%s", sname); - bonobo_ui_component_set (uic, "", xml, NULL); - - g_free (sname); - g_free (xml); - return path; -} - -BonoboControl * -ephy_bonobo_add_numbered_control (BonoboUIComponent *uic, GtkWidget *w, - guint index, const char *container_path) -{ - BonoboControl *control; - char *xml_string, *item_name, *control_path; - - g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (uic), NULL); - g_return_val_if_fail (container_path != NULL, NULL); - - item_name = get_numbered_menu_item_name (index); - xml_string = g_strdup_printf ("<control name=\"%s\"/>", item_name); - - bonobo_ui_component_set (uic, container_path, xml_string, NULL); - - g_free (xml_string); - - control_path = ephy_bonobo_get_numbered_menu_item_path (uic, container_path, index); - - control = bonobo_control_new (w); - bonobo_ui_component_object_set (uic, control_path, BONOBO_OBJREF (control), NULL); - bonobo_object_unref (control); - - g_free (control_path); - g_free (item_name); - - return control; } void @@ -665,31 +85,3 @@ ephy_bonobo_replace_path (BonoboUIComponent *uic, const gchar *path_src, g_free (path_dst_folder); bonobo_ui_node_free (node); } - -void -ephy_bonobo_clear_path (BonoboUIComponent *uic, - const gchar *path) -{ - if (bonobo_ui_component_path_exists (uic, path, NULL)) - { - char *remove_wildcard = g_strdup_printf ("%s/*", path); - bonobo_ui_component_rm (uic, remove_wildcard, NULL); - g_free (remove_wildcard); - } -} - -void -ephy_bonobo_add_numbered_widget (BonoboUIComponent *uic, GtkWidget *w, - guint index, const char *container_path) -{ - gchar *path = ephy_bonobo_get_numbered_menu_item_path (uic, container_path, index); - gchar *item_name = get_numbered_menu_item_name (index); - gchar *xml_string = g_strdup_printf ("<control name=\"%s\"/>", item_name); - - bonobo_ui_component_set (uic, container_path, xml_string, NULL); - bonobo_ui_component_widget_set (uic, path, w, NULL); - - g_free (path); - g_free (item_name); - g_free (xml_string); -} diff --git a/lib/ephy-bonobo-extensions.h b/lib/ephy-bonobo-extensions.h index be090711d..7e840f49f 100644 --- a/lib/ephy-bonobo-extensions.h +++ b/lib/ephy-bonobo-extensions.h @@ -37,87 +37,11 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <gtk/gtkwidget.h> -void ephy_bonobo_set_accelerator (BonoboUIComponent *ui, - const char *path, - const char *accelerator); -char *ephy_bonobo_get_label (BonoboUIComponent *ui, - const char *path); -void ephy_bonobo_set_label (BonoboUIComponent *ui, - const char *path, - const char *label); -void ephy_bonobo_set_tip (BonoboUIComponent *ui, - const char *path, - const char *tip); -void ephy_bonobo_set_sensitive (BonoboUIComponent *ui, - const char *path, - gboolean sensitive); -void ephy_bonobo_set_toggle_state (BonoboUIComponent *ui, - const char *path, - gboolean state); void ephy_bonobo_set_hidden (BonoboUIComponent *ui, const char *path, gboolean hidden); -gboolean ephy_bonobo_get_hidden (BonoboUIComponent *ui, - const char *path); -void ephy_bonobo_add_numbered_menu_item (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - GdkPixbuf *pixbuf); -void ephy_bonobo_add_numbered_toggle_menu_item (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label); -void ephy_bonobo_add_numbered_radio_menu_item (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - const char *radio_group_name); -char *ephy_bonobo_get_numbered_menu_item_command (BonoboUIComponent *ui, - const char *container_path, - guint index); -char *ephy_bonobo_get_numbered_menu_item_path (BonoboUIComponent *ui, - const char *container_path, - guint index); -guint ephy_bonobo_get_numbered_menu_item_index_from_command (const char *command); -char *ephy_bonobo_get_numbered_menu_item_container_path_from_command (const char *command); -void ephy_bonobo_add_submenu (BonoboUIComponent *ui, - const char *container_path, - const char *label, - GdkPixbuf *pixbuf); -void ephy_bonobo_add_numbered_submenu (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - GdkPixbuf *pixbuf); -void ephy_bonobo_add_numbered_submenu_no_verb (BonoboUIComponent *ui, - const char *container_path, - guint index, - const char *label, - GdkPixbuf *pixbuf); -void ephy_bonobo_add_menu_separator (BonoboUIComponent *ui, - const char *path); -void ephy_bonobo_remove_menu_items_and_commands (BonoboUIComponent *ui, - const char *container_path); -void ephy_bonobo_set_label_for_menu_item_and_command (BonoboUIComponent *ui, - const char *menu_item_path, - const char *command_path, - const char *label_with_underscore); -void ephy_bonobo_set_icon (BonoboUIComponent *ui, - const char *path, - const char *icon_relative_path); -gchar *ephy_bonobo_add_dockitem (BonoboUIComponent *uic, - const char *name, - int band_num); -BonoboControl *ephy_bonobo_add_numbered_control (BonoboUIComponent *uic, - GtkWidget *w, guint index, - const char *path); -void ephy_bonobo_clear_path (BonoboUIComponent *uic, - const gchar *path); void ephy_bonobo_replace_path (BonoboUIComponent *uic, const gchar *path_src, const char *path_dst); -void ephy_bonobo_add_numbered_widget (BonoboUIComponent *uic, GtkWidget *w, - guint index, const char *container_path); #endif /* EPHY_BONOBO_EXTENSIONS_H */ diff --git a/lib/ephy-string.c b/lib/ephy-string.c index 391b275f8..ca32e824c 100644 --- a/lib/ephy-string.c +++ b/lib/ephy-string.c @@ -138,9 +138,9 @@ ephy_string_time_to_string (GDate *t, } gboolean -ephy_str_to_int (const char *string, int *integer) +ephy_str_to_int (const char *string, gulong *integer) { - long result; + gulong result; char *parse_end; /* Check for the case of an empty string. */ diff --git a/lib/ephy-string.h b/lib/ephy-string.h index 3c57d08de..97e15e756 100644 --- a/lib/ephy-string.h +++ b/lib/ephy-string.h @@ -33,7 +33,7 @@ gchar *ephy_string_time_to_string (GDate *t, const char *format); gboolean ephy_str_to_int (const char *string, - int *integer); + gulong *integer); char *ephy_str_strip_chr (const char *source, char remove_this); diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c index 5cfc21aff..f6b6f8f7f 100755 --- a/lib/widgets/ephy-editable-toolbar.c +++ b/lib/widgets/ephy-editable-toolbar.c @@ -20,9 +20,12 @@ #include "ephy-editable-toolbar.h" #include "ephy-file-helpers.h" #include "ephy-debug.h" +#include "ephy-dnd.h" #include "eggtoolitem.h" +#include "eggtoolbar.h" #include <libxml/parser.h> +#include <libgnome/gnome-i18n.h> #include <string.h> /* This is copied from gtkscrollbarwindow.c */ @@ -32,9 +35,18 @@ (GTK_SCROLLED_WINDOW_GET_CLASS (w)->scrollbar_spacing >= 0 ? \ GTK_SCROLLED_WINDOW_GET_CLASS (w)->scrollbar_spacing : DEFAULT_SCROLLBAR_SPACING) -static GtkTargetEntry drag_types [] = +static GtkTargetEntry dest_drag_types [] = { - { "EPHY_TOOLBAR_BUTTON", 0, 0 } + { "EPHY_TOOLBAR_BUTTON", 0, 0 }, + /* FIXME generic way to add types */ + { EPHY_DND_URL_TYPE, 0, EPHY_DND_URL } +}; + +static GtkTargetEntry source_drag_types [] = +{ + { "EPHY_TOOLBAR_BUTTON", 0, 0 }, + /* FIXME generic way to add types */ + { EPHY_DND_URL_TYPE, 0, EPHY_DND_URL } }; static void ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass); @@ -42,6 +54,7 @@ static void ephy_editable_toolbar_init (EphyEditableToolbar *t); static void ephy_editable_toolbar_finalize (GObject *object); static void do_merge (EphyEditableToolbar *t); +static void setup_editor (EphyEditableToolbar *etoolbar); enum { @@ -49,16 +62,8 @@ enum PROP_MENU_MERGE }; -enum -{ - REQUEST_ACTION, - LAST_SIGNAL -}; - static GObjectClass *parent_class = NULL; -static gint EphyEditableToolbarSignals[LAST_SIGNAL]; - struct EphyEditableToolbarPrivate { EggMenuMerge *merge; @@ -68,6 +73,9 @@ struct EphyEditableToolbarPrivate GtkWidget *editor; GtkWidget *table; + GtkWidget *label_zone; + GtkWidget *action_zone; + GtkWidget *scrolled_window; guint ui_id; gboolean ui_dirty; @@ -173,10 +181,32 @@ find_node_from_action (EphyEditableToolbar *t, EggAction *action) return NULL; } +static EggAction * +impl_get_action (EphyEditableToolbar *etoolbar, + const char *type, + const char *name) +{ + EggAction *action; + + LOG ("Getting an action"); + + if (type == NULL) + { + action = find_action (etoolbar, name); + } + else + { + action = NULL; + } + + return action; +} + static void add_action (EphyEditableToolbar *t, GNode *parent, GNode *sibling, + const char *type, const char *name) { EggAction *action = NULL; @@ -184,13 +214,10 @@ add_action (EphyEditableToolbar *t, ItemNode *item; GNode *node; - action = find_action (t, name); separator = (strcmp (name, "separator") == 0); - - if (!action && !separator) + if (!separator) { - g_signal_emit (t, EphyEditableToolbarSignals[REQUEST_ACTION], 0, name); - action = find_action (t, name); + action = ephy_editable_toolbar_get_action (t, type, name); } item = item_node_new (action, separator); @@ -211,35 +238,43 @@ parse_item_list (EphyEditableToolbar *t, xmlChar *verb; verb = xmlGetProp (child, "verb"); - add_action (t, parent, NULL, verb); + add_action (t, parent, NULL, NULL, verb); xmlFree (verb); } else if (xmlStrEqual (child->name, "separator")) { - add_action (t, parent, NULL, "separator"); + add_action (t, parent, NULL, NULL, "separator"); } child = child->next; } } +static GNode * +add_toolbar (EphyEditableToolbar *t) +{ + ToolbarNode *toolbar; + GNode *node; + + toolbar = toolbar_node_new (); + node = g_node_new (toolbar); + g_node_append (t->priv->toolbars, node); + + return node; +} + static void parse_toolbars (EphyEditableToolbar *t, - xmlNodePtr child, - GNode *toolbars) + xmlNodePtr child) { while (child) { if (xmlStrEqual (child->name, "toolbar")) { - ToolbarNode *toolbar; GNode *node; - toolbar = toolbar_node_new (); - node = g_node_new (toolbar); - g_node_append (toolbars, node); - + node = add_toolbar (t); parse_item_list (t, child->children, node); } @@ -275,8 +310,7 @@ load_defaults (EphyEditableToolbar *t) t->priv->toolbars == NULL) { t->priv->toolbars = g_node_new (NULL); - parse_toolbars (t, child->children, - t->priv->toolbars); + parse_toolbars (t, child->children); } child = child->next; @@ -298,8 +332,7 @@ load_toolbar (EphyEditableToolbar *t) root = xmlDocGetRootElement (doc); t->priv->toolbars = g_node_new (NULL); - parse_toolbars (t, root->children, - t->priv->toolbars); + parse_toolbars (t, root->children); } static xmlDocPtr @@ -418,13 +451,24 @@ drag_data_received_cb (GtkWidget *widget, guint time_, EphyEditableToolbar *etoolbar) { + GNode *toolbar; GNode *parent; GNode *sibling; - sibling = (GNode *)g_object_get_data (G_OBJECT (widget), "item_node"); - parent = sibling->parent; + toolbar = (GNode *)g_object_get_data (G_OBJECT (widget), "toolbar_node"); + + if (!toolbar) + { + sibling = (GNode *)g_object_get_data (G_OBJECT (widget), "item_node"); + parent = sibling->parent; + } + else + { + sibling = NULL; + parent = toolbar; + } - add_action (etoolbar, parent, sibling, selection_data->data); + add_action (etoolbar, parent, sibling, NULL, selection_data->data); queue_ui_update (etoolbar); } @@ -468,16 +512,33 @@ setup_toolbar_drag (EphyEditableToolbar *etoolbar, GNode *toolbars) { GNode *l1, *l2; int k = 0; + char path[255]; for (l1 = toolbars->children; l1 != NULL; l1 = l1->next) { int i = 0; + GtkWidget *toolbar; + + sprintf (path, "/Toolbar%d", k); + toolbar = egg_menu_merge_get_widget (etoolbar->priv->merge, path); + g_object_set_data (G_OBJECT (toolbar), "toolbar_node", l1); + + if (!g_object_get_data (G_OBJECT (toolbar), "drag_dest_set")) + { + LOG ("Setup drag dest for toolbar %s", path) + g_object_set_data (G_OBJECT (toolbar), "drag_dest_set", + GINT_TO_POINTER (TRUE)); + gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_ALL, + dest_drag_types, 2, GDK_ACTION_MOVE); + g_signal_connect (toolbar, "drag_data_received", + G_CALLBACK (drag_data_received_cb), + etoolbar); + } for (l2 = l1->children; l2 != NULL; l2 = l2->next) { ItemNode *node = (ItemNode *) (l2->data); GtkWidget *toolitem; - char path[255]; const char *type; if (node->separator) @@ -502,7 +563,7 @@ setup_toolbar_drag (EphyEditableToolbar *etoolbar, GNode *toolbars) g_object_set_data (G_OBJECT (toolitem), "drag_dest_set", GINT_TO_POINTER (TRUE)); gtk_drag_dest_set (toolitem, GTK_DEST_DEFAULT_ALL, - drag_types, 1, GDK_ACTION_MOVE); + dest_drag_types, 2, GDK_ACTION_MOVE); g_signal_connect (toolitem, "drag_data_received", G_CALLBACK (drag_data_received_cb), etoolbar); @@ -523,6 +584,33 @@ setup_toolbar_drag (EphyEditableToolbar *etoolbar, GNode *toolbars) } static void +ensure_toolbars_min_size (EphyEditableToolbar *t) +{ + GNode *n; + int i = 0; + + for (n = t->priv->toolbars->children; n != NULL; n = n->next) + { + GtkWidget *toolbar; + char path[255]; + + sprintf (path, "/Toolbar%d", i); + toolbar = egg_menu_merge_get_widget (t->priv->merge, path); + + if (g_node_n_children (n) == 0) + { + gtk_widget_set_size_request (toolbar, -1, 20); + } + else + { + gtk_widget_set_size_request (toolbar, -1, -1); + } + + i++; + } +} + +static void do_merge (EphyEditableToolbar *t) { char *str; @@ -549,6 +637,8 @@ do_merge (EphyEditableToolbar *t) setup_toolbar_drag (t, t->priv->toolbars); + ensure_toolbars_min_size (t); + g_free (str); } @@ -604,19 +694,10 @@ ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass) parent_class = g_type_class_peek_parent (klass); object_class->finalize = ephy_editable_toolbar_finalize; - object_class->set_property = ephy_editable_toolbar_set_property; object_class->get_property = ephy_editable_toolbar_get_property; - EphyEditableToolbarSignals[REQUEST_ACTION] = - g_signal_new - ("request_action", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP, - G_STRUCT_OFFSET (EphyEditableToolbarClass, request_action), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); + klass->get_action = impl_get_action; g_object_class_install_property (object_class, PROP_MENU_MERGE, @@ -685,40 +766,42 @@ ephy_editable_toolbar_new (EggMenuMerge *merge) } static void -editor_get_dimensions (GtkWidget *window, GtkWidget *toolbar, GtkWidget *table, +editor_get_dimensions (EphyEditableToolbar *etoolbar, GtkWidget *toolbar, int *x, int *y, int *width, int *height) { GtkBin *popwin; GtkWidget *widget; - GtkScrolledWindow *popup; - GtkRequisition table_requisition; - int real_height; - int real_width; + GtkWidget *table; + GtkWidget *label_zone; + GtkWidget *action_zone; + GtkWidget *popup; + GtkRequisition requisition; int avail_height; int avail_width; int work_height; int work_width; widget = toolbar; - popup = GTK_SCROLLED_WINDOW (GTK_BIN (window)->child); - popwin = GTK_BIN (window); - - gdk_window_get_origin (widget->window, x, y); - real_height = MIN (widget->requisition.height, - widget->allocation.height); - real_width = MIN (widget->requisition.width, - widget->allocation.width); - *y += real_height; + popup = etoolbar->priv->scrolled_window; + popwin = GTK_BIN (etoolbar->priv->editor); + table = etoolbar->priv->table; + action_zone = etoolbar->priv->action_zone; + label_zone = etoolbar->priv->label_zone; + + gdk_window_get_origin (toolbar->window, x, y); + + *y += toolbar->allocation.y + toolbar->allocation.height; + avail_height = gdk_screen_height () - *y; avail_width = gdk_screen_width () - *x; - gtk_widget_size_request (table, &table_requisition); + gtk_widget_size_request (table, &requisition); - *width = MIN (avail_width, table_requisition.width); - *height = MIN (avail_height, table_requisition.height); + *width = MIN (avail_width, requisition.width); + *height = MIN (avail_height, requisition.height); work_width = (2 * popwin->child->style->xthickness + - 2 * GTK_CONTAINER (window)->border_width + + 2 * GTK_CONTAINER (popwin)->border_width + 2 * GTK_CONTAINER (popwin->child)->border_width + 2 * GTK_CONTAINER (popup)->border_width + 2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width + @@ -726,14 +809,21 @@ editor_get_dimensions (GtkWidget *window, GtkWidget *toolbar, GtkWidget *table, *width += work_width; work_height = (2 * popwin->child->style->ythickness + - 2 * GTK_CONTAINER (window)->border_width + + 2 * GTK_CONTAINER (popwin)->border_width + 2 * GTK_CONTAINER (popwin->child)->border_width + 2 * GTK_CONTAINER (popup)->border_width + 2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width + 2 * GTK_BIN (popup)->child->style->ythickness); *height += work_height; - *x = *x + (real_width/2 - *width/2); + gtk_widget_size_request (label_zone, &requisition); + *height += requisition.height; + gtk_widget_size_request (action_zone, &requisition); + *height += requisition.height; + /* Vbox spacing */ + *height += 2 * 12; + + *x += (toolbar->allocation.x + toolbar->allocation.width)/2 - (*width / 2); } static GList * @@ -758,39 +848,140 @@ build_to_drag_actions_list (EphyEditableToolbar *etoolbar) } static void +hide_editor (EphyEditableToolbar *etoolbar) +{ + gtk_grab_remove (GTK_WIDGET (etoolbar->priv->editor)); + gtk_widget_hide (GTK_WIDGET (etoolbar->priv->editor)); +} + +static void +editor_close_cb (GtkWidget *button, EphyEditableToolbar *etoolbar) +{ + hide_editor (etoolbar); +} + +static void +editor_add_toolbar_cb (GtkWidget *button, EphyEditableToolbar *etoolbar) +{ + add_toolbar (etoolbar); + queue_ui_update (etoolbar); +} + +static void +editor_drag_data_received_cb (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time_, + EphyEditableToolbar *etoolbar) +{ + setup_editor (etoolbar); +} + +static void +editor_drag_data_delete_cb (GtkWidget *widget, + GdkDragContext *context, + EphyEditableToolbar *etoolbar) +{ + setup_editor (etoolbar); +} + +static void setup_editor (EphyEditableToolbar *etoolbar) { GList *l; GList *to_drag; int x, y, height, width; + GtkWidget *table; + GtkWidget *viewport; + GtkWidget *last_toolbar; + GtkWidget *editor; + char path[255]; if (etoolbar->priv->editor == NULL) { GtkWidget *editor; GtkWidget *scrolled_window; - GtkWidget *table; + GtkWidget *vbox; + GtkWidget *label_hbox; + GtkWidget *image; + GtkWidget *label; + GtkWidget *bbox; + GtkWidget *button; editor = gtk_window_new (GTK_WINDOW_POPUP); gtk_container_set_border_width (GTK_CONTAINER (editor), 12); + vbox = gtk_vbox_new (FALSE, 12); + gtk_widget_show (vbox); + gtk_container_add (GTK_CONTAINER (editor), vbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); + etoolbar->priv->scrolled_window = scrolled_window; gtk_widget_show (scrolled_window); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (editor), scrolled_window); - table = gtk_table_new (0, 0, TRUE); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); - gtk_table_set_row_spacings (GTK_TABLE (table), 12); - gtk_widget_show (table); - gtk_scrolled_window_add_with_viewport - (GTK_SCROLLED_WINDOW (scrolled_window), table); + gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0); + label_hbox = gtk_hbox_new (FALSE, 6); + etoolbar->priv->label_zone = label_hbox; + 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.\n" + "Drag an item 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); + bbox = gtk_hbutton_box_new (); + gtk_box_set_spacing (GTK_BOX (bbox), 10); + etoolbar->priv->action_zone = bbox; + gtk_widget_show (bbox); + gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), + GTK_BUTTONBOX_END); + gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); + button = gtk_button_new_from_stock (GTK_STOCK_ADD); + gtk_widget_show (button); + gtk_button_set_label (GTK_BUTTON (button), _("Add Toolbar")); + g_signal_connect (button, "clicked", + G_CALLBACK (editor_add_toolbar_cb), + etoolbar); + gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); + button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); + gtk_widget_show (button); + g_signal_connect (button, "clicked", + G_CALLBACK (editor_close_cb), + etoolbar); + gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); etoolbar->priv->editor = editor; - etoolbar->priv->table = table; } + viewport = GTK_BIN (etoolbar->priv->scrolled_window)->child; + if (viewport) + { + table = GTK_BIN (viewport)->child; + gtk_container_remove (GTK_CONTAINER (viewport), table); + } + table = gtk_table_new (0, 0, TRUE); + etoolbar->priv->table = table; + gtk_container_set_border_width (GTK_CONTAINER (table), 12); + gtk_table_set_col_spacings (GTK_TABLE (table), 12); + gtk_table_set_row_spacings (GTK_TABLE (table), 12); + gtk_widget_show (table); + gtk_scrolled_window_add_with_viewport + (GTK_SCROLLED_WINDOW (etoolbar->priv->scrolled_window), table); + gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL, + dest_drag_types, 2, GDK_ACTION_MOVE); + g_signal_connect (table, "drag_data_received", + G_CALLBACK (editor_drag_data_received_cb), + etoolbar); + to_drag = build_to_drag_actions_list (etoolbar); x = y = 0; @@ -811,11 +1002,14 @@ setup_editor (EphyEditableToolbar *etoolbar) gtk_widget_show (event_box); gtk_drag_source_set (event_box, GDK_BUTTON1_MASK, - drag_types, 1, + source_drag_types, 1, GDK_ACTION_MOVE); g_signal_connect (event_box, "drag_data_get", G_CALLBACK (drag_data_get_cb), etoolbar); + g_signal_connect (event_box, "drag_data_delete", + G_CALLBACK (editor_drag_data_delete_cb), + etoolbar); g_object_set_data (G_OBJECT (event_box), "egg-action", action); @@ -844,6 +1038,16 @@ setup_editor (EphyEditableToolbar *etoolbar) } } + sprintf (path, "/Toolbar%d", g_node_n_children (etoolbar->priv->toolbars) - 1); + last_toolbar = egg_menu_merge_get_widget (etoolbar->priv->merge, path); + g_assert (EGG_IS_TOOLBAR (last_toolbar)); + + editor_get_dimensions (etoolbar, last_toolbar, + &x, &y, &width, &height); + editor = etoolbar->priv->editor; + gtk_widget_set_size_request (GTK_WIDGET (editor), width, height); + gtk_window_move (GTK_WINDOW (editor), x, y); + g_list_free (to_drag); } @@ -864,7 +1068,7 @@ button_press_cb (GtkWidget *w, { case GDK_BUTTON_PRESS: gtk_drag_begin (toolitem, - gtk_target_list_new (drag_types, 1), + gtk_target_list_new (source_drag_types, 1), GDK_ACTION_MOVE, 1, event); return TRUE; default: @@ -875,17 +1079,12 @@ button_press_cb (GtkWidget *w, } static void -show_editor (EphyEditableToolbar *etoolbar, GtkWidget *toolbar) +show_editor (EphyEditableToolbar *etoolbar) { GtkWidget *editor = etoolbar->priv->editor; - int x, y, width, height; g_return_if_fail (editor != NULL); - editor_get_dimensions (GTK_WIDGET (editor), toolbar, - etoolbar->priv->table, &x, &y, &width, &height); - gtk_widget_set_size_request (GTK_WIDGET (editor), width, height); - gtk_window_move (GTK_WINDOW (editor), x, y); gtk_widget_show (GTK_WIDGET (editor)); gtk_grab_add (editor); @@ -910,13 +1109,16 @@ set_all_actions_sensitive (EphyEditableToolbar *etoolbar) void ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar) { - GtkWidget *last_toolbar; - char path[255]; - - sprintf (path, "/Toolbar%d", g_node_n_children (etoolbar->priv->toolbars) - 1); - last_toolbar = egg_menu_merge_get_widget (etoolbar->priv->merge, path); - set_all_actions_sensitive (etoolbar); setup_editor (etoolbar); - show_editor (etoolbar, last_toolbar); + show_editor (etoolbar); +} + +EggAction * +ephy_editable_toolbar_get_action (EphyEditableToolbar *etoolbar, + const char *type, + const char *name) +{ + EphyEditableToolbarClass *klass = EPHY_EDITABLE_TOOLBAR_GET_CLASS (etoolbar); + return klass->get_action (etoolbar, type, name); } diff --git a/lib/widgets/ephy-editable-toolbar.h b/lib/widgets/ephy-editable-toolbar.h index 6ece8d4c5..10d633a50 100755 --- a/lib/widgets/ephy-editable-toolbar.h +++ b/lib/widgets/ephy-editable-toolbar.h @@ -32,6 +32,8 @@ typedef struct EphyEditableToolbarClass EphyEditableToolbarClass; #define EPHY_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_EDITABLE_TOOLBAR_TYPE, EphyEditableToolbarClass)) #define IS_EPHY_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_EDITABLE_TOOLBAR_TYPE)) #define IS_EPHY_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_EDITABLE_TOOLBAR_TYPE)) +#define EPHY_EDITABLE_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_EDITABLE_TOOLBAR_TYPE, EphyEditableToolbarClass)) + typedef struct EphyEditableToolbar EphyEditableToolbar; typedef struct EphyEditableToolbarPrivate EphyEditableToolbarPrivate; @@ -46,15 +48,21 @@ struct EphyEditableToolbarClass { GObjectClass parent_class; - void (* request_action) (EphyEditableToolbar *etoolbar, - const char *action_name); + EggAction * (* get_action) (EphyEditableToolbar *etoolbar, + const char *type, + const char *name); }; -GType ephy_editable_toolbar_get_type (void); +GType ephy_editable_toolbar_get_type (void); + +EphyEditableToolbar *ephy_editable_toolbar_new (EggMenuMerge *merge); + +void ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar); -EphyEditableToolbar *ephy_editable_toolbar_new (EggMenuMerge *merge); +EggAction *ephy_editable_toolbar_get_action (EphyEditableToolbar *etoolbar, + const char *type, + const char *name); -void ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar); G_END_DECLS |