aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-10-23 20:52:52 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-10-23 20:52:52 +0800
commit4d8e9ed180c6d1506905e14fcc9ba26a7c24db19 (patch)
treef290f8564850f2076c2eff75942076306953f963 /lib
parentd92e40e0fb9d3eaabb4984111887fa54b1aeb0d0 (diff)
downloadgsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.tar
gsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.tar.gz
gsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.tar.bz2
gsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.tar.lz
gsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.tar.xz
gsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.tar.zst
gsoc2013-epiphany-4d8e9ed180c6d1506905e14fcc9ba26a7c24db19.zip
Move the spinner in his own mini toolbar.
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.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/egg/egg-editable-toolbar.c110
-rwxr-xr-xlib/egg/egg-editable-toolbar.h3
2 files changed, 96 insertions, 17 deletions
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 */