From e886e958845ad243debf35139ffa81be9aad3088 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 19 Sep 2003 08:50:56 +0000 Subject: Do not use .in for not to translate files. 2003-09-19 Marco Pesenti Gritti * data/ui/Makefile.am: * data/ui/epiphany-bookmark-editor-ui.xml.in: * data/ui/epiphany-fs-toolbar.xml: * data/ui/epiphany-history-window-ui.xml.in: * data/ui/epiphany-toolbar.xml.in: * data/ui/epiphany-ui.xml.in: Do not use .in for not to translate files. * lib/egg/egg-editable-toolbar.c: (create_toolbar), (toolbars_clean), (egg_editable_toolbar_construct), (egg_editable_toolbar_set_model), (egg_editable_toolbar_set_merge): * lib/egg/egg-toolbars-model.c: (parse_toolbars): Handle change of properties correctly. Add a toolbar style property in the xml. * src/bookmarks/ephy-bookmark-properties.c: (ephy_bookmark_properties_init): * src/bookmarks/ephy-bookmarks-editor.c: (ephy_bookmarks_editor_init): * src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize), (ephy_shell_get_toolbars_model): * src/ephy-shell.h: * src/ephy-window.c: (ephy_window_fullscreen), (ephy_window_unfullscreen): * src/toolbar.c: (bookmark_destroy_cb), (toolbar_ensure_action), (init_bookmarks_toolbar), (init_normal_mode), (init_fullscreen_mode), (window_state_event_cb), (toolbar_set_window), (toolbar_set_visibility): * src/toolbar.h: * src/window-commands.c: (toolbar_editor_response_cb), (window_cmd_edit_toolbar): Special, more compact, toolbar layout for fullscreen. --- ChangeLog | 38 ++++++++ data/ui/Makefile.am | 15 +-- data/ui/epiphany-bookmark-editor-ui.xml | 56 +++++++++++ data/ui/epiphany-fs-toolbar.xml | 10 ++ data/ui/epiphany-history-window-ui.xml | 40 ++++++++ data/ui/epiphany-toolbar.xml | 46 +++++++++ data/ui/epiphany-ui.xml | 159 ++++++++++++++++++++++++++++++++ lib/egg/egg-editable-toolbar.c | 68 ++++++++++---- lib/egg/egg-toolbars-model.c | 8 ++ src/ephy-shell.c | 43 +++++++-- src/ephy-shell.h | 3 +- src/ephy-window.c | 12 --- src/toolbar.c | 77 ++++++++++++---- src/toolbar.h | 1 + src/window-commands.c | 4 +- 15 files changed, 517 insertions(+), 63 deletions(-) create mode 100644 data/ui/epiphany-bookmark-editor-ui.xml create mode 100644 data/ui/epiphany-fs-toolbar.xml create mode 100644 data/ui/epiphany-history-window-ui.xml create mode 100644 data/ui/epiphany-toolbar.xml create mode 100644 data/ui/epiphany-ui.xml diff --git a/ChangeLog b/ChangeLog index 0e8dc12fe..28e34b52b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +2003-09-19 Marco Pesenti Gritti + + * data/ui/Makefile.am: + * data/ui/epiphany-bookmark-editor-ui.xml.in: + * data/ui/epiphany-fs-toolbar.xml: + * data/ui/epiphany-history-window-ui.xml.in: + * data/ui/epiphany-toolbar.xml.in: + * data/ui/epiphany-ui.xml.in: + + Do not use .in for not to translate files. + + * lib/egg/egg-editable-toolbar.c: (create_toolbar), + (toolbars_clean), (egg_editable_toolbar_construct), + (egg_editable_toolbar_set_model), (egg_editable_toolbar_set_merge): + * lib/egg/egg-toolbars-model.c: (parse_toolbars): + + Handle change of properties correctly. Add a toolbar + style property in the xml. + + * src/bookmarks/ephy-bookmark-properties.c: + (ephy_bookmark_properties_init): + * src/bookmarks/ephy-bookmarks-editor.c: + (ephy_bookmarks_editor_init): + * src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize), + (ephy_shell_get_toolbars_model): + * src/ephy-shell.h: + * src/ephy-window.c: (ephy_window_fullscreen), + (ephy_window_unfullscreen): + * src/toolbar.c: (bookmark_destroy_cb), (toolbar_ensure_action), + (init_bookmarks_toolbar), (init_normal_mode), + (init_fullscreen_mode), (window_state_event_cb), + (toolbar_set_window), (toolbar_set_visibility): + * src/toolbar.h: + * src/window-commands.c: (toolbar_editor_response_cb), + (window_cmd_edit_toolbar): + + Special, more compact, toolbar layout for fullscreen. + 2003-09-18 Marco Pesenti Gritti * src/ephy-favicon-action.c: (ephy_favicon_action_class_init): diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am index 76467e77c..a0123616d 100644 --- a/data/ui/Makefile.am +++ b/data/ui/Makefile.am @@ -1,12 +1,15 @@ uixmldir = $(pkgdatadir) -uixml_in_files = epiphany-ui.xml.in \ - epiphany-bookmark-editor-ui.xml.in \ - nautilus-epiphany-view.xml.in \ - epiphany-toolbar.xml.in \ - epiphany-history-window-ui.xml.in - +uixml_in_files = nautilus-epiphany-view.xml.in uixml_DATA = $(uixml_in_files:.xml.in=.xml) +xmldir = $(pkgdatadir) +xml_DATA = \ + epiphany-fs-toolbar.xml \ + epiphany-bookmark-editor-ui.xml \ + epiphany-ui.xml \ + epiphany-toolbar.xml \ + epiphany-history-window-ui.xml + @INTLTOOL_XML_RULE@ EXTRA_DIST = $(uixml_in_files) diff --git a/data/ui/epiphany-bookmark-editor-ui.xml b/data/ui/epiphany-bookmark-editor-ui.xml new file mode 100644 index 000000000..449229660 --- /dev/null +++ b/data/ui/epiphany-bookmark-editor-ui.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/ui/epiphany-fs-toolbar.xml b/data/ui/epiphany-fs-toolbar.xml new file mode 100644 index 000000000..2eec09e81 --- /dev/null +++ b/data/ui/epiphany-fs-toolbar.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/data/ui/epiphany-history-window-ui.xml b/data/ui/epiphany-history-window-ui.xml new file mode 100644 index 000000000..1d977b092 --- /dev/null +++ b/data/ui/epiphany-history-window-ui.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/ui/epiphany-toolbar.xml b/data/ui/epiphany-toolbar.xml new file mode 100644 index 000000000..6accae2fb --- /dev/null +++ b/data/ui/epiphany-toolbar.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml new file mode 100644 index 000000000..d4fbb636a --- /dev/null +++ b/data/ui/epiphany-ui.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index 85537c9bd..d69088200 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -309,6 +309,7 @@ create_toolbar (EggEditableToolbar *t) toolbar = gtk_toolbar_new (); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE); + gtk_widget_show (toolbar); gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP, dest_drag_types, n_dest_drag_types, @@ -482,24 +483,18 @@ item_removed_cb (EggToolbarsModel *model, } static void -egg_editable_toolbar_set_model (EggEditableToolbar *t, - EggToolbarsModel *model) +toolbars_clean (EggEditableToolbar *t) { - g_return_if_fail (IS_EGG_TOOLBARS_MODEL (model)); - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t)); + GList *children, *l; - t->priv->model = model; + children = gtk_container_get_children (GTK_CONTAINER (t)); - g_signal_connect_object (model, "item_added", - G_CALLBACK (item_added_cb), t, 0); - g_signal_connect_object (model, "item_removed", - G_CALLBACK (item_removed_cb), t, 0); - g_signal_connect_object (model, "toolbar_added", - G_CALLBACK (toolbar_added_cb), t, 0); - g_signal_connect_object (model, "toolbar_removed", - G_CALLBACK (toolbar_removed_cb), t, 0); - g_signal_connect_object (model, "toolbar_changed", - G_CALLBACK (toolbar_changed_cb), t, 0); + for (l = children; l != NULL; l = l->next) + { + gtk_widget_destroy (GTK_WIDGET (l->data)); + } + + g_list_free (children); } static void @@ -515,10 +510,17 @@ egg_editable_toolbar_construct (EggEditableToolbar *t) for (i = 0; i < n_toolbars; i++) { GtkWidget *toolbar; + EggTbModelFlags flags; toolbar = create_toolbar (t); gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0); + flags = egg_toolbars_model_get_flags (model, i); + if (flags & EGG_TB_MODEL_ICONS_ONLY) + { + gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); + } + n_items = egg_toolbars_model_n_items (model, i); for (l = 0; l < n_items; l++) { @@ -536,6 +538,32 @@ egg_editable_toolbar_construct (EggEditableToolbar *t) } } +static void +egg_editable_toolbar_set_model (EggEditableToolbar *t, + EggToolbarsModel *model) +{ + g_return_if_fail (IS_EGG_TOOLBARS_MODEL (model)); + g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t)); + + if (t->priv->model == model) return; + + t->priv->model = model; + + toolbars_clean (t); + egg_editable_toolbar_construct (t); + + g_signal_connect_object (model, "item_added", + G_CALLBACK (item_added_cb), t, 0); + g_signal_connect_object (model, "item_removed", + G_CALLBACK (item_removed_cb), t, 0); + g_signal_connect_object (model, "toolbar_added", + G_CALLBACK (toolbar_added_cb), t, 0); + g_signal_connect_object (model, "toolbar_removed", + G_CALLBACK (toolbar_removed_cb), t, 0); + g_signal_connect_object (model, "toolbar_changed", + G_CALLBACK (toolbar_changed_cb), t, 0); +} + static void egg_editable_toolbar_set_merge (EggEditableToolbar *t, GtkUIManager *merge) @@ -543,9 +571,15 @@ egg_editable_toolbar_set_merge (EggEditableToolbar *t, g_return_if_fail (GTK_IS_UI_MANAGER (merge)); g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t)); - t->priv->merge = merge; + if (t->priv->merge != merge) + { + t->priv->merge = merge; - egg_editable_toolbar_construct (t); + if (t->priv->model != NULL) + { + egg_editable_toolbar_construct (t); + } + } } static void diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c index 85ed145ab..fc74aa174 100755 --- a/lib/egg/egg-toolbars-model.c +++ b/lib/egg/egg-toolbars-model.c @@ -410,12 +410,20 @@ parse_toolbars (EggToolbarsModel *t, if (xmlStrEqual (child->name, "toolbar")) { xmlChar *name; + xmlChar *style; int position; name = xmlGetProp (child, "name"); position = egg_toolbars_model_add_toolbar (t, -1, name); xmlFree (name); + style = xmlGetProp (child, "style"); + if (style && strcmp (style, "icons-only") == 0) + { + egg_toolbars_model_set_flags (t, EGG_TB_MODEL_ICONS_ONLY, 0); + } + xmlFree (style); + parse_item_list (t, child->children, position); } diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 7e29fd293..2be34fdf6 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -69,6 +69,7 @@ struct EphyShellPrivate EphyAutocompletion *autocompletion; EphyBookmarks *bookmarks; EphyToolbarsModel *toolbars_model; + EggToolbarsModel *fs_toolbars_model; GtkWidget *bme; GtkWidget *history_window; GList *plugins; @@ -204,6 +205,7 @@ ephy_shell_init (EphyShell *gs) gs->priv->bme = NULL; gs->priv->history_window = NULL; gs->priv->toolbars_model = NULL; + gs->priv->fs_toolbars_model = NULL; gs->priv->plugins = NULL; ephy_shell = gs; @@ -263,6 +265,12 @@ ephy_shell_finalize (GObject *object) g_object_unref (G_OBJECT (gs->priv->toolbars_model)); } + LOG ("Unref fullscreen toolbars model") + if (gs->priv->fs_toolbars_model) + { + g_object_unref (G_OBJECT (gs->priv->fs_toolbars_model)); + } + LOG ("Unref session") if (gs->priv->session) { @@ -563,21 +571,38 @@ ephy_shell_get_bookmarks (EphyShell *gs) } GObject * -ephy_shell_get_toolbars_model (EphyShell *gs) +ephy_shell_get_toolbars_model (EphyShell *gs, gboolean fullscreen) { - if (gs->priv->toolbars_model == NULL) + if (fullscreen) { - EphyBookmarks *bookmarks; - - bookmarks = ephy_shell_get_bookmarks (gs); + if (gs->priv->fs_toolbars_model == NULL) + { + const char *xml; - gs->priv->toolbars_model = ephy_toolbars_model_new (bookmarks); + gs->priv->fs_toolbars_model = egg_toolbars_model_new (); + xml = ephy_file ("epiphany-fs-toolbar.xml"); + egg_toolbars_model_load (gs->priv->fs_toolbars_model, xml); + } - g_object_set (bookmarks, "toolbars_model", - gs->priv->toolbars_model, NULL); + return G_OBJECT (gs->priv->fs_toolbars_model); } + else + { + if (gs->priv->toolbars_model == NULL) + { + EphyBookmarks *bookmarks; + + bookmarks = ephy_shell_get_bookmarks (gs); - return G_OBJECT (gs->priv->toolbars_model); + gs->priv->toolbars_model = ephy_toolbars_model_new (bookmarks); + + g_object_set (bookmarks, "toolbars_model", + gs->priv->toolbars_model, NULL); + } + + + return G_OBJECT (gs->priv->toolbars_model); + } } static void diff --git a/src/ephy-shell.h b/src/ephy-shell.h index aad9f3808..6f0f1fd10 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -97,7 +97,8 @@ GObject *ephy_shell_get_autocompletion (EphyShell *gs); EphyBookmarks *ephy_shell_get_bookmarks (EphyShell *gs); -GObject *ephy_shell_get_toolbars_model (EphyShell *gs); +GObject *ephy_shell_get_toolbars_model (EphyShell *gs, + gboolean fullscreen); void ephy_shell_show_bookmarks_editor (EphyShell *gs, GtkWidget *parent); diff --git a/src/ephy-window.c b/src/ephy-window.c index f64f310be..1c6ebf531 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -42,7 +42,6 @@ #include "ephy-encoding-menu.h" #include "ephy-tabs-menu.h" #include "ephy-stock-icons.h" -#include "ephy-toolbars-model.h" #include "session.h" #include "ephy-favicon-cache.h" @@ -497,14 +496,9 @@ static void ephy_window_fullscreen (EphyWindow *window) { GtkWidget *popup, *button, *icon, *label, *hbox; - EphyToolbarsModel *tmodel; window->priv->is_fullscreen = TRUE; - tmodel = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); - ephy_toolbars_model_set_flag (tmodel, EGG_TB_MODEL_ICONS_ONLY); - popup = gtk_window_new (GTK_WINDOW_POPUP); window->priv->exit_fullscreen_popup = popup; @@ -541,14 +535,8 @@ ephy_window_fullscreen (EphyWindow *window) static void ephy_window_unfullscreen (EphyWindow *window) { - EphyToolbarsModel *tmodel; - window->priv->is_fullscreen = FALSE; - tmodel = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); - ephy_toolbars_model_unset_flag (tmodel, EGG_TB_MODEL_ICONS_ONLY); - g_signal_handlers_disconnect_by_func (G_OBJECT (gdk_screen_get_default ()), G_CALLBACK (size_changed_cb), window); diff --git a/src/toolbar.c b/src/toolbar.c index dc905c427..326a47f71 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -144,7 +144,7 @@ bookmark_destroy_cb (EphyNode *node, long id; model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); id = ephy_node_get_id (node); name = ephy_toolbars_model_get_action_name (model, id); @@ -167,7 +167,7 @@ toolbar_ensure_action (Toolbar *t, EphyNode *bmks, *topics; model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); bookmarks = ephy_shell_get_bookmarks (ephy_shell); bmks = ephy_bookmarks_get_bookmarks (bookmarks); topics = ephy_bookmarks_get_keywords (bookmarks); @@ -373,7 +373,7 @@ init_bookmarks_toolbar (Toolbar *t) int i, n_toolbars; model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); n_toolbars = egg_toolbars_model_n_toolbars (EGG_TOOLBARS_MODEL (model)); @@ -461,10 +461,61 @@ location_user_changed_cb (GtkWidget *entry, Toolbar *t) } static void -toolbar_set_window (Toolbar *t, EphyWindow *window) +init_normal_mode (Toolbar *t) { EphyToolbarsModel *model; + model = EPHY_TOOLBARS_MODEL + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); + g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_added", + G_CALLBACK (update_toolbar_remove_flag), + NULL); + g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_removed", + G_CALLBACK (update_toolbar_remove_flag), + NULL); + g_object_set (G_OBJECT (t), + "ToolbarsModel", model, + NULL); + init_bookmarks_toolbar (t); +} + +static void +init_fullscreen_mode (Toolbar *t) +{ + EggToolbarsModel *model; + + model = EGG_TOOLBARS_MODEL + (ephy_shell_get_toolbars_model (ephy_shell, TRUE)); + + g_object_set (G_OBJECT (t), + "ToolbarsModel", model, + NULL); +} + +static gboolean +window_state_event_cb (GtkWidget *widget, GdkEventWindowState *event, Toolbar *t) +{ + if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) + { + gboolean fullscreen; + + fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN; + if (fullscreen) + { + init_fullscreen_mode (t); + } + else + { + init_normal_mode (t); + } + } + + return FALSE; +} + +static void +toolbar_set_window (Toolbar *t, EphyWindow *window) +{ g_return_if_fail (t->priv->window == NULL); t->priv->window = window; @@ -473,24 +524,18 @@ toolbar_set_window (Toolbar *t, EphyWindow *window) toolbar_setup_actions (t); gtk_ui_manager_insert_action_group (t->priv->ui_merge, t->priv->action_group, 1); - g_signal_connect (t, "action_request", G_CALLBACK (action_request_cb), NULL); + g_signal_connect_object (window, "window-state-event", + G_CALLBACK (window_state_event_cb), + t, 0); - model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); - g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_added", - G_CALLBACK (update_toolbar_remove_flag), - NULL); - g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_removed", - G_CALLBACK (update_toolbar_remove_flag), - NULL); g_object_set (G_OBJECT (t), - "ToolbarsModel", model, "MenuMerge", t->priv->ui_merge, NULL); - init_bookmarks_toolbar (t); + + init_normal_mode (t); g_signal_connect_object (get_location_entry (t), "user_changed", G_CALLBACK (location_user_changed_cb), @@ -673,7 +718,7 @@ toolbar_set_visibility (Toolbar *t, int i, n_toolbars; model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); n_toolbars = egg_toolbars_model_n_toolbars (EGG_TOOLBARS_MODEL (model)); diff --git a/src/toolbar.h b/src/toolbar.h index 1ca62e439..a9d598ae8 100644 --- a/src/toolbar.h +++ b/src/toolbar.h @@ -71,6 +71,7 @@ void toolbar_update_navigation_actions (Toolbar *t, gboolean back, gboolean forward, gboolean up); + void toolbar_update_zoom (Toolbar *t, float zoom); diff --git a/src/window-commands.c b/src/window-commands.c index e922c3dbc..b111ef50f 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -663,7 +663,7 @@ toolbar_editor_response_cb (GtkDialog *dialog, break; case RESPONSE_ADD_TOOLBAR: model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); n = egg_toolbars_model_n_toolbars (EGG_TOOLBARS_MODEL (model)); egg_toolbars_model_add_toolbar (EGG_TOOLBARS_MODEL (model), n - 1, "UserCreated"); @@ -684,7 +684,7 @@ window_cmd_edit_toolbar (GtkAction *action, GtkWidget *dialog; model = EPHY_TOOLBARS_MODEL - (ephy_shell_get_toolbars_model (ephy_shell)); + (ephy_shell_get_toolbars_model (ephy_shell, FALSE)); t = ephy_window_get_toolbar (window); dialog = gtk_dialog_new (); -- cgit v1.2.3