aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--data/ui/epiphany-toolbar.xml2
-rwxr-xr-xlib/egg/egg-editable-toolbar.c110
-rwxr-xr-xlib/egg/egg-editable-toolbar.h3
-rw-r--r--src/Makefile.am2
-rw-r--r--src/ephy-spinner-action.c220
-rw-r--r--src/ephy-spinner-action.h48
-rwxr-xr-xsrc/toolbar.c25
8 files changed, 117 insertions, 309 deletions
diff --git a/ChangeLog b/ChangeLog
index 5947ac08d..b023193db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-10-23 Marco Pesenti Gritti <marco@gnome.org>
+
+ * data/ui/epiphany-toolbar.xml:
+ * lib/egg/egg-editable-toolbar.c: (get_toolbar_position),
+ (get_dock_nth), (get_toolbar_nth), (create_dock), (update_fixed),
+ (toolbar_added_cb), (toolbar_removed_cb),
+ (egg_editable_toolbar_construct), (egg_editable_toolbar_init),
+ (egg_editable_toolbar_finalize), (egg_editable_toolbar_show),
+ (egg_editable_toolbar_hide), (egg_editable_toolbar_set_fixed):
+ * lib/egg/egg-editable-toolbar.h:
+ * src/Makefile.am:
+ * src/toolbar.c: (toolbar_setup_actions), (toolbar_init),
+ (toolbar_spinner_start), (toolbar_spinner_stop):
+
+ Move the spinner in his own mini toolbar.
+
2003-10-23 Xan Lopez <xan@masilla.org>
* embed/mozilla/EphyEventListener.cpp:
diff --git a/data/ui/epiphany-toolbar.xml b/data/ui/epiphany-toolbar.xml
index 6accae2fb..030f2e987 100644
--- a/data/ui/epiphany-toolbar.xml
+++ b/data/ui/epiphany-toolbar.xml
@@ -18,7 +18,6 @@
<toolitem name="EditFind"/>
<toolitem name="Favicon"/>
<toolitem name="Location"/>
- <toolitem name="Spinner"/>
<toolitem name="ToolbarGo"/>
<toolitem name="Zoom"/>
</available>
@@ -33,7 +32,6 @@
<toolitem name="GoBookmarks"/>
<separator/>
<toolitem name="EditFind"/>
- <toolitem name="Spinner"/>
</toolbar>
<toolbar name="EntryToolbar">
<toolitem name="Favicon"/>
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 8e76a57e2..bb42190e3 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -24,6 +24,7 @@
#include <gtk/gtkwindow.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkdnd.h>
+#include <gtk/gtkhbox.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkimagemenuitem.h>
#include <gtk/gtkmenu.h>
@@ -74,6 +75,7 @@ struct EggEditableToolbarPrivate
gboolean edit_mode;
GtkWidget *selected_toolbar;
GtkWidget *dragged_item;
+ GtkWidget *fixed;
};
GType
@@ -110,7 +112,7 @@ get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
int result;
l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
- result = g_list_index (l, toolbar);
+ result = g_list_index (l, toolbar->parent);
g_list_free (l);
return result;
@@ -130,8 +132,8 @@ get_n_toolbars (EggEditableToolbar *etoolbar)
}
static GtkWidget *
-get_toolbar_nth (EggEditableToolbar *etoolbar,
- int position)
+get_dock_nth (EggEditableToolbar *etoolbar,
+ int position)
{
GList *l;
GtkWidget *result;
@@ -143,6 +145,23 @@ get_toolbar_nth (EggEditableToolbar *etoolbar,
return result;
}
+static GtkWidget *
+get_toolbar_nth (EggEditableToolbar *etoolbar,
+ int position)
+{
+ GList *l;
+ GtkWidget *dock;
+ GtkWidget *result;
+
+ dock = get_dock_nth (etoolbar, position);
+
+ l = gtk_container_get_children (GTK_CONTAINER (dock));
+ result = GTK_WIDGET (l->data);
+ g_list_free (l);
+
+ return result;
+}
+
static GtkAction *
find_action (EggEditableToolbar *t,
const char *name)
@@ -545,12 +564,17 @@ toolbar_drag_leave_cb (GtkToolbar *toolbar,
}
static GtkWidget *
-create_toolbar (EggEditableToolbar *t)
+create_dock (EggEditableToolbar *t)
{
- GtkWidget *toolbar;
+ GtkWidget *toolbar, *hbox;
+
+ hbox = gtk_hbox_new (0, FALSE);
toolbar = gtk_toolbar_new ();
gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
+ gtk_widget_show (toolbar);
+
+ gtk_box_pack_start (GTK_BOX (hbox), toolbar, TRUE, TRUE, 0);
gtk_widget_show (toolbar);
gtk_drag_dest_set (toolbar, 0,
@@ -569,7 +593,7 @@ create_toolbar (EggEditableToolbar *t)
g_signal_connect (toolbar, "popup_context_menu",
G_CALLBACK (popup_toolbar_context_menu_cb), t);
- return toolbar;
+ return hbox;
}
static void
@@ -594,17 +618,37 @@ toolbar_changed_cb (EggToolbarsModel *model,
}
static void
+update_fixed (EggEditableToolbar *t)
+{
+ GtkWidget *fixed, *dock;
+
+ g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
+
+ fixed = t->priv->fixed;
+ dock = get_dock_nth (t, 0);
+
+ if (dock && fixed && fixed->parent == NULL)
+ {
+ gtk_box_pack_end (GTK_BOX (dock), fixed, FALSE, TRUE, 0);
+ }
+}
+
+static void
toolbar_added_cb (EggToolbarsModel *model,
int position,
EggEditableToolbar *t)
{
- GtkWidget *toolbar;
+ GtkWidget *dock;
+
+ dock = create_dock (t);
+
+ gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
- toolbar = create_toolbar (t);
- gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
- gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (t), dock, TRUE, TRUE, 0);
- gtk_box_reorder_child (GTK_BOX (t), toolbar, position);
+ gtk_box_reorder_child (GTK_BOX (t), dock, position);
+
+ update_fixed (t);
}
static void
@@ -615,7 +659,9 @@ toolbar_removed_cb (EggToolbarsModel *model,
GtkWidget *toolbar;
toolbar = get_toolbar_nth (t, position);
- gtk_widget_destroy (toolbar);
+ gtk_widget_destroy (toolbar->parent);
+
+ update_fixed (t);
}
static void
@@ -683,11 +729,12 @@ egg_editable_toolbar_construct (EggEditableToolbar *t)
for (i = 0; i < n_toolbars; i++)
{
- GtkWidget *toolbar;
+ GtkWidget *toolbar, *dock;
EggTbModelFlags flags;
- toolbar = create_toolbar (t);
- gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
+ dock = create_dock (t);
+ gtk_box_pack_start (GTK_BOX (t), dock, TRUE, TRUE, 0);
+ toolbar = get_toolbar_nth (t, i);
flags = egg_toolbars_model_get_flags (model, i);
if (flags & EGG_TB_MODEL_ICONS_ONLY)
@@ -710,6 +757,8 @@ egg_editable_toolbar_construct (EggEditableToolbar *t)
gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
}
}
+
+ update_fixed (t);
}
static void
@@ -836,6 +885,7 @@ egg_editable_toolbar_init (EggEditableToolbar *t)
t->priv->merge = NULL;
t->priv->edit_mode = FALSE;
+ t->priv->fixed = NULL;
}
static void
@@ -846,6 +896,11 @@ egg_editable_toolbar_finalize (GObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (object));
+ if (t->priv->fixed)
+ {
+ g_object_unref (t->priv->fixed);
+ }
+
g_free (t->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -933,7 +988,7 @@ egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
if (strcmp (toolbar_name, name) == 0)
{
- gtk_widget_show (get_toolbar_nth (etoolbar, i));
+ gtk_widget_show (get_dock_nth (etoolbar, i));
}
}
}
@@ -955,12 +1010,33 @@ egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
if (strcmp (toolbar_name, name) == 0)
{
- gtk_widget_hide (get_toolbar_nth (etoolbar, i));
+ gtk_widget_hide (get_dock_nth (etoolbar, i));
}
}
}
void
+egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
+ GtkWidget *fixed)
+{
+ GtkWidget *toolbar;
+ GtkToolItem *item;
+
+ toolbar = gtk_toolbar_new ();
+ gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
+ gtk_widget_show (toolbar);
+
+ item = gtk_tool_item_new ();
+ gtk_widget_show (GTK_WIDGET (item));
+ gtk_container_add (GTK_CONTAINER (item), fixed);
+
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
+ etoolbar->priv->fixed = g_object_ref (toolbar);
+
+ update_fixed (etoolbar);
+}
+
+void
egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar,
const GtkTargetEntry *targets,
gint n_targets,
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index 577d6ab93..e361b83c5 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -67,6 +67,9 @@ void egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar,
const GtkTargetEntry *targets,
gint n_targets,
const char *toolbar_name);
+void egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
+ GtkWidget *fixed);
+
/* Private Functions */
diff --git a/src/Makefile.am b/src/Makefile.am
index 7703b6b4c..cbe0fcb79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -59,7 +59,6 @@ NOINST_H_FILES = \
ephy-location-action.h \
ephy-navigation-action.h \
ephy-plugin.h \
- ephy-spinner-action.h \
ephy-tabs-menu.h \
ephy-toolbars-model.h \
language-editor.h \
@@ -96,7 +95,6 @@ epiphany_bin_SOURCES = \
ephy-notebook.c \
ephy-plugin.c \
ephy-shell.c \
- ephy-spinner-action.c \
ephy-tab.c \
ephy-tab.h \
ephy-tabs-menu.c \
diff --git a/src/ephy-spinner-action.c b/src/ephy-spinner-action.c
deleted file mode 100644
index be69ce9b5..000000000
--- a/src/ephy-spinner-action.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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 "ephy-spinner-action.h"
-#include "ephy-spinner.h"
-
-#include <gtk/gtktoolitem.h>
-#include <gtk/gtktoolbar.h>
-
-static void ephy_spinner_action_init (EphySpinnerAction *action);
-static void ephy_spinner_action_class_init (EphySpinnerActionClass *class);
-
-#define EPHY_SPINNER_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SPINNER_ACTION, EphySpinnerActionPrivate))
-
-struct EphySpinnerActionPrivate
-{
- gboolean throbbing;
-};
-
-enum
-{
- PROP_0,
- PROP_THROBBING
-};
-
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_spinner_action_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EphySpinnerActionClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) ephy_spinner_action_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (EphySpinnerAction),
- 0, /* n_preallocs */
- (GInstanceInitFunc) ephy_spinner_action_init,
- };
-
- type = g_type_register_static (GTK_TYPE_ACTION,
- "EphySpinnerAction",
- &type_info, 0);
- }
- return type;
-}
-
-static void
-ephy_spinner_action_sync_throbbing (GtkAction *action, GParamSpec *pspec,
- GtkWidget *proxy)
-{
- EphySpinner *spinner;
-
- spinner = EPHY_SPINNER (g_object_get_data (G_OBJECT (proxy), "spinner"));
-
- if (EPHY_SPINNER_ACTION (action)->priv->throbbing)
- {
- ephy_spinner_start (spinner);
- }
- else
- {
- ephy_spinner_stop (spinner);
- }
-}
-
-static GtkWidget *
-create_tool_item (GtkAction *action)
-{
- GtkWidget *item;
- GtkWidget *spinner;
-
- item = GTK_WIDGET (gtk_tool_item_new ());
-
- spinner = ephy_spinner_new ();
- gtk_widget_show (spinner);
- gtk_container_add (GTK_CONTAINER (item), spinner);
- gtk_tool_item_set_pack_end (GTK_TOOL_ITEM (item), TRUE);
- gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (item), FALSE);
- g_object_set_data (G_OBJECT (item), "spinner", spinner);
-
- return item;
-}
-
-static void
-toolbar_style_sync (GtkToolbar *toolbar,
- GtkToolbarStyle style,
- GtkWidget *proxy)
-{
- gboolean small;
- EphySpinner *spinner;
-
- spinner = EPHY_SPINNER (g_object_get_data (G_OBJECT (proxy), "spinner"));
-
- small = (style != GTK_TOOLBAR_BOTH);
- ephy_spinner_set_small_mode (EPHY_SPINNER (spinner), small);
-}
-
-static void
-item_parent_set_cb (GtkWidget *item, GtkWidget *previous_parent)
-{
- GtkToolbar *toolbar;
- GtkToolbarStyle style;
-
- if (item->parent == NULL) return;
-
- toolbar = GTK_TOOLBAR (item->parent);
-
- g_signal_connect_object (toolbar, "style_changed",
- G_CALLBACK (toolbar_style_sync),
- item, 0);
-
- style = gtk_toolbar_get_style (toolbar);
- toolbar_style_sync (toolbar, style, item);
-}
-
-static void
-connect_proxy (GtkAction *action, GtkWidget *proxy)
-{
- g_signal_connect_object (action, "notify::throbbing",
- G_CALLBACK (ephy_spinner_action_sync_throbbing),
- proxy, 0);
- g_signal_connect_object (proxy, "parent_set",
- G_CALLBACK (item_parent_set_cb),
- proxy, 0);
-
- (* GTK_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
-}
-
-static void
-ephy_spinner_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphySpinnerAction *spin;
-
- spin = EPHY_SPINNER_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_THROBBING:
- spin->priv->throbbing = g_value_get_boolean (value);
- g_object_notify(object, "throbbing");
- break;
- }
-}
-
-static void
-ephy_spinner_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphySpinnerAction *spin;
-
- spin = EPHY_SPINNER_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_THROBBING:
- g_value_set_boolean (value, spin->priv->throbbing);
- break;
- }
-}
-
-static void
-ephy_spinner_action_class_init (EphySpinnerActionClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GtkActionClass *action_class = GTK_ACTION_CLASS (class);
-
- parent_class = g_type_class_peek_parent (class);
-
- action_class->toolbar_item_type = EPHY_TYPE_SPINNER;
- action_class->create_tool_item = create_tool_item;
- action_class->connect_proxy = connect_proxy;
-
- object_class->set_property = ephy_spinner_action_set_property;
- object_class->get_property = ephy_spinner_action_get_property;
-
- g_object_class_install_property (object_class,
- PROP_THROBBING,
- g_param_spec_boolean ("throbbing",
- "Throbbing",
- "Throbbing",
- FALSE,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof(EphySpinnerActionPrivate));
-}
-
-static void
-ephy_spinner_action_init (EphySpinnerAction *action)
-{
- action->priv = EPHY_SPINNER_ACTION_GET_PRIVATE (action);
-}
diff --git a/src/ephy-spinner-action.h b/src/ephy-spinner-action.h
deleted file mode 100644
index 339596c66..000000000
--- a/src/ephy-spinner-action.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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.
- */
-
-#ifndef EPHY_SPINNER_ACTION_H
-#define EPHY_SPINNER_ACTION_H
-
-#include <gtk/gtkaction.h>
-
-#define EPHY_TYPE_SPINNER_ACTION (ephy_spinner_action_get_type ())
-#define EPHY_SPINNER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_SPINNER_ACTION, EphySpinnerAction))
-#define EPHY_SPINNER_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_SPINNER_ACTION, EphySpinnerActionClass))
-#define EPHY_IS_SPINNER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_SPINNER_ACTION))
-#define EPHY_IS_SPINNER_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_SPINNER_ACTION))
-#define EPHY_SPINNER_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_SPINNER_ACTION, EphySpinnerActionClass))
-
-typedef struct _EphySpinnerAction EphySpinnerAction;
-typedef struct _EphySpinnerActionClass EphySpinnerActionClass;
-typedef struct EphySpinnerActionPrivate EphySpinnerActionPrivate;
-
-struct _EphySpinnerAction
-{
- GtkAction parent;
- EphySpinnerActionPrivate *priv;
-};
-
-struct _EphySpinnerActionClass
-{
- GtkActionClass parent_class;
-};
-
-GType ephy_spinner_action_get_type (void);
-
-#endif
diff --git a/src/toolbar.c b/src/toolbar.c
index 025938e34..bcb5a5611 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -29,7 +29,6 @@
#include "ephy-location-entry.h"
#include "ephy-dnd.h"
#include "ephy-spinner.h"
-#include "ephy-spinner-action.h"
#include "ephy-location-action.h"
#include "ephy-favicon-action.h"
#include "ephy-topic-action.h"
@@ -326,13 +325,6 @@ toolbar_setup_actions (Toolbar *t)
gtk_action_group_add_action (t->priv->action_group, action);
g_object_unref (action);
- action = g_object_new (EPHY_TYPE_SPINNER_ACTION,
- "name", "Spinner",
- "label", _("Spinner"),
- NULL);
- gtk_action_group_add_action (t->priv->action_group, action);
- g_object_unref (action);
-
/* FIXME: I'm still waiting for the exact term to
* user here from the docs team.
*/
@@ -539,6 +531,11 @@ toolbar_init (Toolbar *t)
t->priv->ui_merge = NULL;
t->priv->visibility = TRUE;
t->priv->updating_address = FALSE;
+
+ t->priv->spinner = ephy_spinner_new ();
+ gtk_widget_show (t->priv->spinner);
+ egg_editable_toolbar_set_fixed (EGG_EDITABLE_TOOLBAR (t),
+ t->priv->spinner);
}
static void
@@ -577,23 +574,11 @@ toolbar_activate_location (Toolbar *t)
void
toolbar_spinner_start (Toolbar *t)
{
- GtkActionGroup *action_group;
- GtkAction *action;
-
- action_group = t->priv->action_group;
- action = gtk_action_group_get_action (action_group, "Spinner");
- g_object_set (action, "throbbing", TRUE, NULL);
}
void
toolbar_spinner_stop (Toolbar *t)
{
- GtkActionGroup *action_group;
- GtkAction *action;
-
- action_group = t->priv->action_group;
- action = gtk_action_group_get_action (action_group, "Spinner");
- g_object_set (action, "throbbing", FALSE, NULL);
}
void