aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-01-10 08:23:14 +0800
committerChristian Persch <chpe@src.gnome.org>2005-01-10 08:23:14 +0800
commit46c10af32a80037c438c3c54f455a1db43a93e25 (patch)
tree1cdc8ed5fb94a1a1c99314581ef0fe7379e47388
parent0db1c0f440d4388e7000eaa6aa2ea8e53776aded (diff)
downloadgsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.tar
gsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.tar.gz
gsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.tar.bz2
gsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.tar.lz
gsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.tar.xz
gsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.tar.zst
gsoc2013-epiphany-46c10af32a80037c438c3c54f455a1db43a93e25.zip
A src/ephy-toolbar-editor.c: A src/ephy-toolbar-editor.h:
2005-01-10 Christian Persch <chpe@cvs.gnome.org> * data/epiphany.schemas.in: * lib/ephy-prefs.h: * src/Makefile.am: * src/ephy-notebook.c: (tab_label_style_set_cb): * src/ephy-shell.c: (ephy_shell_finalize), (toolbar_style_notifier), (ephy_shell_get_toolbars_model): A src/ephy-toolbar-editor.c: A src/ephy-toolbar-editor.h: * src/window-commands.c: (window_cmd_edit_toolbar): Move toolbar editor dialogue into its own class, and implement a toolbar style override there. Fixes bug #102520.
-rw-r--r--ChangeLog15
-rw-r--r--data/epiphany.schemas.in13
-rw-r--r--lib/ephy-prefs.h1
-rw-r--r--src/Makefile.am3
-rw-r--r--src/ephy-notebook.c3
-rw-r--r--src/ephy-shell.c50
-rw-r--r--src/ephy-toolbar-editor.c416
-rw-r--r--src/ephy-toolbar-editor.h60
-rw-r--r--src/window-commands.c96
9 files changed, 560 insertions, 97 deletions
diff --git a/ChangeLog b/ChangeLog
index 836517dec..63129cb6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2005-01-10 Christian Persch <chpe@cvs.gnome.org>
+ * data/epiphany.schemas.in:
+ * lib/ephy-prefs.h:
+ * src/Makefile.am:
+ * src/ephy-notebook.c: (tab_label_style_set_cb):
+ * src/ephy-shell.c: (ephy_shell_finalize),
+ (toolbar_style_notifier), (ephy_shell_get_toolbars_model):
+ A src/ephy-toolbar-editor.c:
+ A src/ephy-toolbar-editor.h:
+ * src/window-commands.c: (window_cmd_edit_toolbar):
+
+ Move toolbar editor dialogue into its own class, and implement a
+ toolbar style override there. Fixes bug #102520.
+
+2005-01-10 Christian Persch <chpe@cvs.gnome.org>
+
* lib/egg/egg-editable-toolbar.c: (toolbar_changed_cb),
(egg_editable_toolbar_construct):
* lib/egg/egg-toolbars-model.c: (parse_toolbars):
diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in
index b3282a896..6f175b15d 100644
--- a/data/epiphany.schemas.in
+++ b/data/epiphany.schemas.in
@@ -157,6 +157,19 @@
pointed to by the currently selected text.</long>
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/epiphany/general/toolbar_style</key>
+ <applyto>/apps/epiphany/general/toolbar_style</applyto>
+ <owner>epiphany</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Toolbar style</short>
+ <long>Toolbar style. Allowed values are "" (use GNOME default style),
+ "both" (text and icons), "both-horiz" (text besides icons),
+ "icons", and "text".</long>
+ </locale>
+ </schema>
<schema>
<key>/schemas/apps/epiphany/general/show_toolbars</key>
<applyto>/apps/epiphany/general/show_toolbars</applyto>
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 905459faa..550dc7c9c 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -33,6 +33,7 @@ G_BEGIN_DECLS
#define CONF_WINDOWS_SHOW_BOOKMARKS_BAR "/apps/epiphany/general/show_bookmarks_bar"
#define CONF_WINDOWS_SHOW_STATUSBAR "/apps/epiphany/general/show_statusbar"
#define CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL "/apps/epiphany/general/middle_click_open_url"
+#define CONF_INTERFACE_TOOLBAR_STYLE "/apps/epiphany/general/toolbar_style"
#define CONF_AUTO_DOWNLOADS "/apps/epiphany/general/automatic_downloads"
#define CONF_DESKTOP_IS_HOME_DIR "/apps/nautilus/preferences/desktop_is_home_dir"
diff --git a/src/Makefile.am b/src/Makefile.am
index d865eec3d..c75e08c6d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,6 +38,7 @@ NOINST_H_FILES = \
ephy-navigation-action.h \
ephy-tabs-menu.h \
ephy-toolbars-model.h \
+ ephy-toolbar-editor.h \
pdm-dialog.h \
popup-commands.h \
prefs-dialog.h \
@@ -79,6 +80,7 @@ libephymain_la_SOURCES = \
ephy-tab.h \
ephy-tabs-menu.c \
ephy-toolbars-model.c \
+ ephy-toolbar-editor.c \
ephy-window.c \
pdm-dialog.c \
popup-commands.c \
@@ -91,6 +93,7 @@ libephymain_la_SOURCES = \
libephymain_la_CPPFLAGS = \
-I$(top_builddir)/lib \
+ -I$(top_builddir)/lib/egg \
-I$(top_builddir)/embed \
-I$(top_srcdir)/embed \
-I$(top_srcdir)/lib \
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index ff96589fb..0f73b586a 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -841,9 +841,6 @@ tab_label_style_set_cb (GtkWidget *label,
char_width = pango_font_metrics_get_approximate_digit_width (metrics);
pango_font_metrics_unref (metrics);
- LOG ("tab_label_size_request_cb label %p char_width %d total %d",
- label, char_width, TAB_WIDTH_N_CHARS * PANGO_PIXELS (char_width))
-
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (label),
GTK_ICON_SIZE_MENU, &w, &h);
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 333213721..806e49776 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -40,6 +40,7 @@
#include "ephy-session.h"
#include "downloader-view.h"
#include "egg-toolbars-model.h"
+#include "eggtypebuiltins.h"
#include "ephy-toolbars-model.h"
#include "ephy-automation.h"
#include "print-dialog.h"
@@ -69,6 +70,7 @@ struct _EphyShellPrivate
EphySession *session;
EphyBookmarks *bookmarks;
EggToolbarsModel *toolbars_model;
+ guint toolbar_style_notifier_id;
EggToolbarsModel *fs_toolbars_model;
EphyExtensionsManager *extensions_manager;
GObject *dbus_service;
@@ -434,6 +436,10 @@ ephy_shell_finalize (GObject *object)
LOG ("Unref toolbars model")
if (shell->priv->toolbars_model)
+ if (shell->priv->toolbar_style_notifier_id != 0)
+ {
+ eel_gconf_notification_remove (shell->priv->toolbar_style_notifier_id);
+ }
{
g_object_unref (shell->priv->toolbars_model);
}
@@ -647,6 +653,44 @@ ephy_shell_get_bookmarks (EphyShell *shell)
return shell->priv->bookmarks;
}
+static void
+toolbar_style_notifier (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ EphyShell *shell)
+{
+ EggToolbarsModel *model = shell->priv->toolbars_model;
+ GFlagsClass *flags_class;
+ const GFlagsValue *value;
+ EggTbModelFlags flags, new_flags = 0;
+ char *pref;
+ int i, n_toolbars;
+
+ g_return_if_fail (model != NULL);
+
+ pref = eel_gconf_get_string (CONF_INTERFACE_TOOLBAR_STYLE);
+ if (pref != NULL)
+ {
+ flags_class = g_type_class_ref (EGG_TYPE_TB_MODEL_FLAGS);
+ value = g_flags_get_value_by_nick (flags_class, pref);
+ if (value != NULL)
+ {
+ new_flags = value->value;
+ }
+ g_type_class_unref (flags_class);
+ }
+ new_flags &= EGG_TB_MODEL_STYLES_MASK;
+
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+ for (i = 0; i < n_toolbars; i++)
+ {
+ flags = egg_toolbars_model_get_flags (model, i);
+ flags &= ~EGG_TB_MODEL_STYLES_MASK;
+ flags |= new_flags;
+ egg_toolbars_model_set_flags (model, i, new_flags);
+ }
+}
+
GObject *
ephy_shell_get_toolbars_model (EphyShell *shell, gboolean fullscreen)
{
@@ -689,6 +733,12 @@ ephy_shell_get_toolbars_model (EphyShell *shell, gboolean fullscreen)
/* ok, now we can load the model */
ephy_toolbars_model_load
(EPHY_TOOLBARS_MODEL (shell->priv->toolbars_model));
+
+ toolbar_style_notifier (NULL, 0, NULL, shell);
+ shell->priv->toolbar_style_notifier_id = eel_gconf_notification_add
+ (CONF_INTERFACE_TOOLBAR_STYLE,
+ (GConfClientNotifyFunc) toolbar_style_notifier, shell);
+
}
return G_OBJECT (shell->priv->toolbars_model);
diff --git a/src/ephy-toolbar-editor.c b/src/ephy-toolbar-editor.c
new file mode 100644
index 000000000..fd015ef5d
--- /dev/null
+++ b/src/ephy-toolbar-editor.c
@@ -0,0 +1,416 @@
+/*
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003-2005 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "config.h"
+
+#include "ephy-toolbar-editor.h"
+#include "ephy-gui.h"
+#include "ephy-prefs.h"
+#include "ephy-state.h"
+#include "ephy-file-helpers.h"
+#include "ephy-shell.h"
+#include "eggtypebuiltins.h"
+#include "egg-toolbars-model.h"
+#include "egg-editable-toolbar.h"
+#include "egg-toolbar-editor.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-debug.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtktreemodel.h>
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkcelllayout.h>
+#include <gtk/gtkcombobox.h>
+#include <gtk/gtkuimanager.h>
+#include <gtk/gtkstock.h>
+#include <string.h>
+
+#define DATA_KEY "EphyToolbarEditor"
+
+#define EPHY_TOOLBAR_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOOLBAR_EDITOR, EphyToolbarEditorPrivate))
+
+struct _EphyToolbarEditorPrivate
+{
+ EggToolbarsModel *model;
+ EphyWindow *window;
+};
+
+enum
+{
+ RESPONSE_ADD_TOOLBAR = 1
+};
+
+enum
+{
+ COL_TEXT,
+ COL_FLAGS,
+ COL_IS_SEP
+};
+
+static const struct
+{
+ const char *text;
+ EggTbModelFlags flags;
+}
+toolbar_styles [] =
+{
+ { /* Translators: The text before the "|" is context to help you decide on
+ * the correct translation. You MUST OMIT it in the translated string. */
+ N_("toolbar style|Default"), 0 },
+ { NULL /* separator row */, 0 },
+ { /* Translators: The text before the "|" is context to help you decide on
+ * the correct translation. You MUST OMIT it in the translated string. *
+ * Translators: translate the same as in gnome-control-center */
+ N_("toolbar style|Text below icons"), EGG_TB_MODEL_BOTH },
+ { /* Translators: The text before the "|" is context to help you decide on
+ * the correct translation. You MUST OMIT it in the translated string. *
+ * Translators: translate the same as in gnome-control-center */
+ N_("toolbar style|Text beside icons"), EGG_TB_MODEL_BOTH_HORIZ },
+ { /* Translators: The text before the "|" is context to help you decide on
+ * the correct translation. You MUST OMIT it in the translated string. *
+ * Translators: translate the same as in gnome-control-center */
+ N_("toolbar style|Icons only"), EGG_TB_MODEL_ICONS },
+ { /* Translators: The text before the "|" is context to help you decide on
+ * the correct translation. You MUST OMIT it in the translated string. *
+ * Translators: translate the same as in gnome-control-center */
+ N_("toolbar style|Text only"), EGG_TB_MODEL_TEXT }
+};
+
+enum
+{
+ PROP_0,
+ PROP_WINDOW
+};
+
+static GObjectClass *parent_class = NULL;
+
+static gboolean
+row_is_separator (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ gboolean is_sep;
+ gtk_tree_model_get (model, iter, COL_IS_SEP, &is_sep, -1);
+ return is_sep;
+}
+
+static void
+combo_changed_cb (GtkComboBox *combo,
+ GtkListStore *store)
+{
+ GtkTreeIter iter;
+ EggTbModelFlags flags;
+ GFlagsClass *flags_class;
+ const GFlagsValue *value;
+ const char *pref = "";
+
+ if (!gtk_combo_box_get_active_iter (combo, &iter)) return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COL_FLAGS, &flags, -1);
+
+ flags_class = g_type_class_ref (EGG_TYPE_TB_MODEL_FLAGS);
+ value = g_flags_get_first_value (flags_class, flags);
+ if (value != NULL)
+ {
+ pref = value->value_nick;
+ }
+
+ eel_gconf_set_string (CONF_INTERFACE_TOOLBAR_STYLE, pref);
+
+ g_type_class_unref (flags_class);
+}
+
+
+static void
+ephy_toolbar_editor_response (GtkDialog *dialog,
+ gint response_id)
+{
+ EphyToolbarEditorPrivate *priv = EPHY_TOOLBAR_EDITOR (dialog)->priv;
+
+ switch (response_id)
+ {
+ case GTK_RESPONSE_CLOSE:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+ case RESPONSE_ADD_TOOLBAR:
+ egg_toolbars_model_add_toolbar (priv->model, -1, "UserCreated");
+ break;
+ case GTK_RESPONSE_HELP:
+ ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "to-edit-toolbars");
+ break;
+ }
+}
+
+static void
+ephy_toolbar_editor_init (EphyToolbarEditor *editor)
+{
+ editor->priv = EPHY_TOOLBAR_EDITOR_GET_PRIVATE (editor);
+
+ editor->priv->model = EGG_TOOLBARS_MODEL
+ (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
+}
+
+static GObject *
+ephy_toolbar_editor_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
+
+{
+ GObject *object;
+ EphyToolbarEditorPrivate *priv;
+ GtkWidget *dialog, *editor, *toolbar, *vbox, *hbox, *label, *combo;
+ GtkUIManager *manager;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ GFlagsClass *flags_class;
+ const GFlagsValue *value;
+ EggTbModelFlags flags = 0;
+ char *pref;
+ int i;
+
+ object = parent_class->constructor (type, n_construct_properties,
+ construct_params);
+
+ dialog = GTK_WIDGET (object);
+ priv = EPHY_TOOLBAR_EDITOR (object)->priv;
+
+ toolbar = ephy_window_get_toolbar (priv->window);
+
+ vbox = GTK_DIALOG (dialog)->vbox;
+ gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 18);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Toolbar Editor"));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (priv->window));
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
+
+ manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (priv->window));
+ editor = egg_toolbar_editor_new (manager, priv->model);
+ egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
+ ephy_file ("epiphany-toolbar.xml"));
+ gtk_container_set_border_width (GTK_CONTAINER (EGG_TOOLBAR_EDITOR (editor)), 5);
+ gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
+ gtk_box_pack_start (GTK_BOX (vbox), editor, TRUE, TRUE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_set_spacing (GTK_BOX (editor), 18);
+ gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
+
+ /* translators: translate the same as in gnome-control-center */
+ label = gtk_label_new_with_mnemonic (_("Toolbar _button labels:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+
+ store = gtk_list_store_new (3, G_TYPE_STRING, EGG_TYPE_TB_MODEL_FLAGS,
+ G_TYPE_BOOLEAN);
+
+ for (i = 0; i < G_N_ELEMENTS (toolbar_styles); i++)
+ {
+ const char *text = toolbar_styles[i].text;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_TEXT, text ? Q_(text) : NULL,
+ COL_FLAGS, toolbar_styles[i].flags,
+ COL_IS_SEP, toolbar_styles[i].text == NULL,
+ -1);
+ }
+
+ combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
+ "text", COL_TEXT, NULL);
+ gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
+ (GtkTreeViewRowSeparatorFunc) row_is_separator,
+ NULL, NULL);
+
+ gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+ gtk_widget_show_all (hbox);
+
+ /* get active from pref */
+ pref = eel_gconf_get_string (CONF_INTERFACE_TOOLBAR_STYLE);
+ if (pref != NULL)
+ {
+ flags_class = g_type_class_ref (EGG_TYPE_TB_MODEL_FLAGS);
+ value = g_flags_get_value_by_nick (flags_class, pref);
+ if (value != NULL)
+ {
+ flags = value->value;
+ }
+ g_type_class_unref (flags_class);
+ }
+ g_free (pref);
+
+ /* this will set i to 0 if the style is unknown or default */
+ for (i = G_N_ELEMENTS (toolbar_styles) - 1; i > 0; i--)
+ {
+ if (flags & toolbar_styles[i].flags) break;
+ }
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i);
+ g_signal_connect (combo, "changed",
+ G_CALLBACK (combo_changed_cb), store);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ _("_Add a New Toolbar"), RESPONSE_ADD_TOOLBAR);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_HELP, GTK_RESPONSE_HELP);
+
+ gtk_widget_show (editor);
+
+ ephy_state_add_window (dialog, "toolbar_editor",
+ 500, 330, FALSE,
+ EPHY_STATE_WINDOW_SAVE_SIZE);
+ gtk_widget_show (dialog);
+
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (toolbar), TRUE);
+ egg_editable_toolbar_set_edit_mode
+ (EGG_EDITABLE_TOOLBAR (ephy_window_get_bookmarksbar (priv->window)), TRUE);
+
+ return object;
+}
+
+static void
+ephy_toolbar_editor_finalize (GObject *object)
+{
+ EphyToolbarEditor *editor = EPHY_TOOLBAR_EDITOR (object);
+ EphyToolbarEditorPrivate *priv = editor->priv;
+
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR
+ (ephy_window_get_toolbar (priv->window)), FALSE);
+ egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR
+ (ephy_window_get_bookmarksbar (priv->window)), FALSE);
+
+ g_object_set_data (G_OBJECT (priv->window), DATA_KEY, NULL);
+
+ parent_class->finalize (object);
+}
+
+static void
+ephy_toolbar_editor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ /* no readable properties */
+ g_assert_not_reached ();
+}
+
+static void
+ephy_toolbar_editor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyToolbarEditorPrivate *priv = EPHY_TOOLBAR_EDITOR (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ priv->window = g_value_get_object (value);
+ break;
+ }
+}
+
+static void
+ephy_toolbar_editor_class_init (EphyToolbarEditorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->constructor = ephy_toolbar_editor_constructor;
+ object_class->finalize = ephy_toolbar_editor_finalize;
+ object_class->get_property = ephy_toolbar_editor_get_property;
+ object_class->set_property = ephy_toolbar_editor_set_property;
+
+ dialog_class->response = ephy_toolbar_editor_response;
+
+ g_object_class_install_property (object_class,
+ PROP_WINDOW,
+ g_param_spec_object ("window",
+ "Window",
+ "Parent window",
+ EPHY_TYPE_WINDOW,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (object_class, sizeof (EphyToolbarEditorPrivate));
+}
+
+GType
+ephy_toolbar_editor_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyToolbarEditorClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) ephy_toolbar_editor_class_init,
+ NULL,
+ NULL,
+ sizeof (EphyToolbarEditor),
+ 0,
+ (GInstanceInitFunc) ephy_toolbar_editor_init
+ };
+
+ type = g_type_register_static (GTK_TYPE_DIALOG,
+ "EphyToolbarEditor",
+ &our_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget *
+ephy_toolbar_editor_show (EphyWindow *window)
+{
+ GtkWidget *dialog;
+
+ dialog = GTK_WIDGET (g_object_get_data (G_OBJECT (window), DATA_KEY));
+ if (dialog == NULL)
+ {
+ dialog = g_object_new (EPHY_TYPE_TOOLBAR_EDITOR,
+ "window", window,
+ NULL);
+
+ g_object_set_data (G_OBJECT (window), DATA_KEY, dialog);
+ }
+
+ gtk_window_present (GTK_WINDOW (dialog));
+
+ return dialog;
+}
diff --git a/src/ephy-toolbar-editor.h b/src/ephy-toolbar-editor.h
new file mode 100644
index 000000000..effd647b4
--- /dev/null
+++ b/src/ephy-toolbar-editor.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003-2005 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_TOOLBAR_EDITOR_H
+#define EPHY_TOOLBAR_EDITOR_H
+
+#include <gtk/gtkdialog.h>
+#include "ephy-window.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_TOOLBAR_EDITOR (ephy_toolbar_editor_get_type ())
+#define EPHY_TOOLBAR_EDITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_TOOLBAR_EDITOR, EphyToolbarEditor))
+#define EPHY_TOOLBAR_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_TOOLBAR_EDITOR, EphyToolbarEditorClass))
+#define EPHY_IS_TOOLBAR_EDITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_TOOLBAR_EDITOR))
+#define EPHY_IS_TOOLBAR_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_TOOLBAR_EDITOR))
+#define EPHY_TOOLBAR_EDITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_TOOLBAR_EDITOR, EphyToolbarEditorClass))
+
+typedef struct _EphyToolbarEditor EphyToolbarEditor;
+typedef struct _EphyToolbarEditorPrivate EphyToolbarEditorPrivate;
+typedef struct _EphyToolbarEditorClass EphyToolbarEditorClass;
+
+struct _EphyToolbarEditor
+{
+ GtkDialog parent_instance;
+
+ /*< private >*/
+ EphyToolbarEditorPrivate *priv;
+};
+
+struct _EphyToolbarEditorClass
+{
+ GtkDialogClass parent_class;
+};
+
+GType ephy_toolbar_editor_get_type (void);
+
+GtkWidget *ephy_toolbar_editor_show (EphyWindow *window);
+
+G_END_DECLS
+
+#endif /* !EPHY_TOOLBAR_EDITOR_H */
diff --git a/src/window-commands.c b/src/window-commands.c
index 6d1334a6d..c38ccde97 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -43,9 +43,7 @@
#include "ephy-gui.h"
#include "ephy-zoom.h"
#include "ephy-notebook.h"
-#include "egg-toolbars-model.h"
-#include "egg-editable-toolbar.h"
-#include "egg-toolbar-editor.h"
+#include "ephy-toolbar-editor.h"
#include <string.h>
#include <glib.h>
@@ -60,12 +58,6 @@
#include <gtk/gtktoggleaction.h>
#include <glib/gi18n.h>
-#define TOOLBAR_EDITOR_KEY "EphyToolbarEditor"
-enum
-{
- RESPONSE_ADD_TOOLBAR
-};
-
void
window_cmd_edit_find (GtkAction *action,
EphyWindow *window)
@@ -768,95 +760,11 @@ window_cmd_edit_prefs (GtkAction *action,
ephy_dialog_show (dialog);
}
-static void
-toolbar_editor_destroy_cb (GtkWidget *tbe,
- EphyWindow *window)
-{
- egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR
- (ephy_window_get_toolbar (window)), FALSE);
- egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR
- (ephy_window_get_bookmarksbar (window)), FALSE);
-
- g_object_set_data (G_OBJECT (window), TOOLBAR_EDITOR_KEY, NULL);
-}
-
-static void
-toolbar_editor_response_cb (GtkDialog *dialog,
- gint response_id,
- EggToolbarsModel *model)
-{
- switch (response_id)
- {
- case GTK_RESPONSE_CLOSE:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- break;
- case RESPONSE_ADD_TOOLBAR:
- egg_toolbars_model_add_toolbar (model, -1, "UserCreated");
- break;
- case GTK_RESPONSE_HELP:
- ephy_gui_help (GTK_WINDOW (dialog), "epiphany", "to-edit-toolbars");
- break;
- }
-}
-
void
window_cmd_edit_toolbar (GtkAction *action,
EphyWindow *window)
{
- GtkWidget *editor, *dialog, *toolbar;
- EggToolbarsModel *model;
-
- dialog = GTK_WIDGET (g_object_get_data (G_OBJECT (window), TOOLBAR_EDITOR_KEY));
- if (dialog != NULL)
- {
- gtk_window_present (GTK_WINDOW (dialog));
- return;
- }
-
- model = EGG_TOOLBARS_MODEL
- (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- toolbar = ephy_window_get_toolbar (window);
-
- dialog = gtk_dialog_new ();
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Toolbar Editor"));
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
- gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
-
- editor = egg_toolbar_editor_new (GTK_UI_MANAGER (ephy_window_get_ui_manager (window)), model);
- egg_toolbar_editor_load_actions (EGG_TOOLBAR_EDITOR (editor),
- ephy_file ("epiphany-toolbar.xml"));
- gtk_container_set_border_width (GTK_CONTAINER (EGG_TOOLBAR_EDITOR (editor)), 5);
- gtk_box_set_spacing (GTK_BOX (EGG_TOOLBAR_EDITOR (editor)), 5);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), editor);
- g_signal_connect (editor, "destroy",
- G_CALLBACK (toolbar_editor_destroy_cb), window);
- gtk_widget_show (editor);
-
- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
-
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)), 5);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- _("_Add a New Toolbar"), RESPONSE_ADD_TOOLBAR);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_HELP, GTK_RESPONSE_HELP);
-
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (toolbar_editor_response_cb), model);
- ephy_state_add_window (dialog, "toolbar_editor",
- 500, 330, FALSE,
- EPHY_STATE_WINDOW_SAVE_SIZE);
- gtk_widget_show (dialog);
-
- egg_editable_toolbar_set_edit_mode (EGG_EDITABLE_TOOLBAR (toolbar), TRUE);
- egg_editable_toolbar_set_edit_mode
- (EGG_EDITABLE_TOOLBAR (ephy_window_get_bookmarksbar (window)), TRUE);
-
- g_object_set_data (G_OBJECT (window), TOOLBAR_EDITOR_KEY, dialog);
+ ephy_toolbar_editor_show (window);
}
void