diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2002-12-31 21:52:44 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2002-12-31 21:52:44 +0800 |
commit | 6afec98b2cc4c33cd4128d045035a0ec7d43629c (patch) | |
tree | fbca72a16cc232b59b16adbe365f29f8bba1b010 /lib/toolbar/ephy-toolbar-item-factory.c | |
parent | beec33b028bdeb5f0da6ed51305f32e3b8041f6e (diff) | |
download | gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.tar gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.tar.gz gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.tar.bz2 gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.tar.lz gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.tar.xz gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.tar.zst gsoc2013-epiphany-6afec98b2cc4c33cd4128d045035a0ec7d43629c.zip |
Resync with galeon.
2002-12-31 Marco Pesenti Gritti <marco@it.gnome.org>
* embed/mozilla/FilePicker.cpp:
* embed/mozilla/FilePicker.h:
* embed/mozilla/mozilla-embed-shell.cpp:
Resync with galeon.
* data/epiphany.schemas.in:
* lib/ephy-bonobo-extensions.c: (ephy_bonobo_add_numbered_widget):
* lib/ephy-bonobo-extensions.h:
* lib/toolbar/Makefile.am:
* lib/toolbar/ephy-tbi-std-toolitem.c:
(ephy_tbi_std_toolitem_init),
(ephy_tbi_std_toolitem_get_icon_impl),
(ephy_tbi_std_toolitem_get_name_human_impl),
(ephy_tbi_std_toolitem_to_string_impl),
(ephy_tbi_std_toolitem_add_to_bonobo_tb_impl),
(ephy_tbi_std_toolitem_parse_properties_impl),
(ephy_tbi_std_toolitem_set_item):
* lib/toolbar/ephy-tbi-std-toolitem.h:
* lib/toolbar/ephy-toolbar-item-factory.c:
(ephy_tb_item_factory_init),
(ephy_toolbar_item_create_from_string),
(ephy_toolbar_item_register_type):
* lib/toolbar/ephy-toolbar-item-factory.h:
* src/Makefile.am:
* src/toolbar.c: (toolbar_class_init), (toolbar_set_property),
(toolbar_get_widgets), (toolbar_init), (toolbar_finalize),
(toolbar_navigation_button_set_sensitive),
(toolbar_button_set_sensitive):
* src/window-commands.c:
Resync with galeon. Now we use a widget for navigation
buttons.
Diffstat (limited to 'lib/toolbar/ephy-toolbar-item-factory.c')
-rw-r--r-- | lib/toolbar/ephy-toolbar-item-factory.c | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/lib/toolbar/ephy-toolbar-item-factory.c b/lib/toolbar/ephy-toolbar-item-factory.c index 1637100ae..60cfbbc41 100644 --- a/lib/toolbar/ephy-toolbar-item-factory.c +++ b/lib/toolbar/ephy-toolbar-item-factory.c @@ -35,26 +35,42 @@ //#define DEBUG_MSG(x) g_print x #define DEBUG_MSG(x) -typedef EphyTbItem *(EphyTbItemConstructor) (void); - typedef struct { const char *type_name; - EphyTbItemConstructor *constructor; + EphyTbItemConstructor constructor; } EphyTbItemTypeInfo; -static EphyTbItemTypeInfo ephy_tb_item_known_types[] = +static EphyTbItemTypeInfo ephy_tb_item_default_types[] = { - { "std_toolitem", (EphyTbItemConstructor *) ephy_tbi_std_toolitem_new }, - { "navigation_history", (EphyTbItemConstructor *) ephy_tbi_navigation_history_new }, - { "zoom", (EphyTbItemConstructor *) ephy_tbi_zoom_new }, - { "location", (EphyTbItemConstructor *) ephy_tbi_location_new }, - { "spinner", (EphyTbItemConstructor *) ephy_tbi_spinner_new }, - { "favicon", (EphyTbItemConstructor *) ephy_tbi_favicon_new }, - { "separator", (EphyTbItemConstructor *) ephy_tbi_separator_new }, + { "std_toolitem", (EphyTbItemConstructor) ephy_tbi_std_toolitem_new }, + { "navigation_history", (EphyTbItemConstructor) ephy_tbi_navigation_history_new }, + { "zoom", (EphyTbItemConstructor) ephy_tbi_zoom_new }, + { "location", (EphyTbItemConstructor) ephy_tbi_location_new }, + { "spinner", (EphyTbItemConstructor) ephy_tbi_spinner_new }, + { "favicon", (EphyTbItemConstructor) ephy_tbi_favicon_new }, + { "separator", (EphyTbItemConstructor) ephy_tbi_separator_new }, { NULL, NULL } }; +static GHashTable *ephy_tb_item_known_types = NULL; + +static void +ephy_tb_item_factory_init (void) +{ + if (ephy_tb_item_known_types == NULL) + { + int i; + ephy_tb_item_known_types = g_hash_table_new (g_str_hash, g_str_equal); + + for (i = 0; ephy_tb_item_default_types[i].type_name; ++i) + { + ephy_toolbar_item_register_type (ephy_tb_item_default_types[i].type_name, + ephy_tb_item_default_types[i].constructor); + } + } +} + EphyTbItem * ephy_toolbar_item_create_from_string (const gchar *str) { @@ -66,7 +82,9 @@ ephy_toolbar_item_create_from_string (const gchar *str) const gchar *lpar; const gchar *rpar; const gchar *eq; - int i; + EphyTbItemConstructor constructor; + + ephy_tb_item_factory_init (); rest = str; @@ -104,21 +122,20 @@ ephy_toolbar_item_create_from_string (const gchar *str) props = NULL; } - DEBUG_MSG (("ephytoolbar_item_create_from_string id=%s type=%s props=%s\n", id, type, props)); + DEBUG_MSG (("ephy_toolbar_item_create_from_string id=%s type=%s props=%s\n", id, type, props)); + + constructor = g_hash_table_lookup (ephy_tb_item_known_types, type); - for (i = 0; ephy_tb_item_known_types[i].type_name; ++i) + if (constructor) { - if (!strcmp (type, ephy_tb_item_known_types[i].type_name)) + ret = constructor (); + if (id) + { + ephy_tb_item_set_id (ret, id); + } + if (props) { - ret = ephy_tb_item_known_types[i].constructor (); - if (id) - { - ephy_tb_item_set_id (ret, id); - } - if (props) - { - ephy_tb_item_parse_properties (ret, props); - } + ephy_tb_item_parse_properties (ret, props); } } @@ -143,16 +160,9 @@ ephy_toolbar_item_create_from_string (const gchar *str) return ret; } -GSList * -ephy_toolbar_list_item_types (void) +void +ephy_toolbar_item_register_type (const gchar *type, EphyTbItemConstructor constructor) { - int i; - GSList *ret = NULL; - for (i = 0; ephy_tb_item_known_types[i].type_name; ++i) - { - ret = g_slist_prepend (ret, - (gchar *) ephy_tb_item_known_types[i].type_name); - } - return ret; + ephy_tb_item_factory_init (); + g_hash_table_insert (ephy_tb_item_known_types, g_strdup (type), constructor); } - |