aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rwxr-xr-xlib/egg/egg-editable-toolbar.c40
-rwxr-xr-xlib/egg/egg-editable-toolbar.h3
-rwxr-xr-xlib/egg/egg-toolbar-editor.c25
-rwxr-xr-xlib/egg/egg-toolbars-model.c50
-rwxr-xr-xlib/egg/egg-toolbars-model.h10
-rw-r--r--lib/egg/eggtoolbar.c2
-rw-r--r--src/ephy-shell.c22
-rwxr-xr-xsrc/ephy-toolbars-model.c13
-rwxr-xr-xsrc/ephy-toolbars-model.h3
-rwxr-xr-xsrc/toolbar.c36
11 files changed, 169 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 30773c4dd..41719809f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2003-04-27 Marco Pesenti Gritti <marco@it.gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c:
+ * lib/egg/egg-editable-toolbar.h:
+ * lib/egg/egg-toolbar-editor.c:
+ * lib/egg/egg-toolbars-model.c:
+ * lib/egg/egg-toolbars-model.h:
+ * lib/egg/eggtoolbar.c:
+
+ update
+
+ * src/ephy-shell.c: (save_toolbars),
+ (ephy_shell_get_toolbars_model):
+ * src/ephy-toolbars-model.c: (impl_add_item),
+ (ephy_toolbars_model_class_init):
+ * src/ephy-toolbars-model.h:
+ * src/toolbar.c: (action_request_cb), (init_bookmarks_toolbar),
+ (toolbar_set_window):
+
+ Load the toolbars model in EphyShell so bookmarks editor
+ alone can use it.
+ Update the actions on a new editable toolbar signal,
+ actions are per toolbar, not per model.
+
2003-04-27 David Bordoley <bordoley@msu.edu>
* lib/egg/egg-editable-toolbar.c:
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index ff7b78266..574869ed1 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -29,6 +29,8 @@ static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass);
static void egg_editable_toolbar_init (EggEditableToolbar *t);
static void egg_editable_toolbar_finalize (GObject *object);
+#define MIN_TOOLBAR_HEIGHT 20
+
static GtkTargetEntry source_drag_types[] = {
{EGG_TOOLBAR_ITEM_TYPE, 0, 0},
};
@@ -46,6 +48,14 @@ enum
PROP_MENU_MERGE
};
+enum
+{
+ ACTION_REQUEST,
+ LAST_SIGNAL
+};
+
+static guint egg_editable_toolbar_signals[LAST_SIGNAL] = { 0 };
+
static GObjectClass *parent_class = NULL;
struct EggEditableToolbarPrivate
@@ -243,6 +253,9 @@ popup_toolbar_context_menu_cb (GtkWidget *toolbar,
if (t->priv->edit_mode)
{
+ EggTbModelFlags flags;
+ int position;
+
t->priv->selected_toolbar = toolbar;
menu = gtk_menu_new ();
@@ -257,8 +270,17 @@ popup_toolbar_context_menu_cb (GtkWidget *toolbar,
G_CALLBACK (remove_toolbar_cb),
t);
+ position = get_toolbar_position (t, toolbar);
+ flags = egg_toolbars_model_get_flags (t->priv->model, position);
+ if (flags && EGG_TB_MODEL_NOT_REMOVABLE)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
+ }
+
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 2,
gtk_get_current_event_time ());
+
+ t->priv->selected_toolbar = NULL;
}
}
@@ -301,6 +323,8 @@ create_item (EggEditableToolbar *t,
}
else
{
+ g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST],
+ 0, action_name);
action = find_action (t, action_name);
item = egg_action_create_tool_item (action);
}
@@ -330,7 +354,7 @@ toolbar_added_cb (EggToolbarsModel *model,
GtkWidget *toolbar;
toolbar = create_toolbar (t);
- gtk_widget_set_size_request (toolbar, -1, 20);
+ gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
/* FIXME reorder to match position */
@@ -379,6 +403,7 @@ item_removed_cb (EggToolbarsModel *model,
if (egg_toolbars_model_n_items (model, toolbar_position) == 0)
{
+ gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
egg_toolbars_model_remove_toolbar (model, toolbar_position);
}
}
@@ -428,6 +453,11 @@ egg_editable_toolbar_construct (EggEditableToolbar *t)
egg_toolbar_insert (EGG_TOOLBAR (toolbar),
EGG_TOOL_ITEM (item), l);
}
+
+ if (n_items == 0)
+ {
+ gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
+ }
}
}
@@ -492,6 +522,14 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
object_class->set_property = egg_editable_toolbar_set_property;
object_class->get_property = egg_editable_toolbar_get_property;
+ egg_editable_toolbar_signals[ACTION_REQUEST] =
+ g_signal_new ("action_request",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggEditableToolbarClass, action_request),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
g_object_class_install_property (object_class,
PROP_MENU_MERGE,
g_param_spec_object ("MenuMerge",
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index 5a73d4205..a46b513f7 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -50,6 +50,9 @@ struct EggEditableToolbar
struct EggEditableToolbarClass
{
GtkVBoxClass parent_class;
+
+ void (* action_request) (EggEditableToolbar *etoolbar,
+ char *action_name);
};
GType egg_editable_toolbar_get_type (void);
diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c
index b957875ad..aa047c195 100755
--- a/lib/egg/egg-toolbar-editor.c
+++ b/lib/egg/egg-toolbar-editor.c
@@ -60,6 +60,7 @@ struct EggToolbarEditorPrivate
GtkWidget *table;
GtkWidget *scrolled_window;
+ GList *default_actions_list;
GList *actions_list;
};
@@ -247,8 +248,12 @@ editor_drag_data_received_cb (GtkWidget *widget,
action = find_action (editor, (const char *)selection_data->data);
g_return_if_fail (action != NULL);
- editor->priv->actions_list = g_list_append
- (editor->priv->actions_list, action);
+
+ if (g_list_find (editor->priv->default_actions_list, action))
+ {
+ editor->priv->actions_list = g_list_append
+ (editor->priv->actions_list, action);
+ }
update_editor_sheet (editor);
}
@@ -504,6 +509,7 @@ egg_toolbar_editor_init (EggToolbarEditor *t)
t->priv = g_new0 (EggToolbarEditorPrivate, 1);
t->priv->merge = NULL;
+ t->priv->default_actions_list = NULL;
t->priv->actions_list = NULL;
setup_editor (t);
@@ -518,8 +524,8 @@ egg_toolbar_editor_add_action (EggToolbarEditor *editor,
action = find_action (editor, action_name);
g_return_if_fail (action != NULL);
- editor->priv->actions_list = g_list_append
- (editor->priv->actions_list, action);
+ editor->priv->default_actions_list = g_list_append
+ (editor->priv->default_actions_list, action);
}
static void
@@ -569,7 +575,7 @@ egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
xmlDocPtr doc;
xmlNodePtr root;
xmlNodePtr child;
- GList *l, *tmp;
+ GList *l;
doc = xmlParseFile (xml_file);
root = xmlDocGetRootElement (doc);
@@ -587,18 +593,17 @@ egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
xmlFreeDoc (doc);
/* Remove the already used items */
- tmp = g_list_copy (editor->priv->actions_list);
- for (l = editor->priv->actions_list; l != NULL; l = l->next)
+ editor->priv->actions_list = g_list_copy (editor->priv->default_actions_list);
+ for (l = editor->priv->default_actions_list; l != NULL; l = l->next)
{
EggAction *action = EGG_ACTION (l->data);
if (model_has_action (editor->priv->model, action))
{
- tmp = g_list_remove (tmp, action);
+ editor->priv->actions_list = g_list_remove
+ (editor->priv->actions_list, action);
}
}
- g_list_free (editor->priv->actions_list);
- editor->priv->actions_list = tmp;
update_editor_sheet (editor);
}
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index 8d92da83a..e2a8ce9fb 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -38,6 +38,7 @@ enum
typedef struct
{
char *name;
+ EggTbModelFlags flags;
} EggToolbarsToolbar;
typedef struct
@@ -145,6 +146,7 @@ toolbars_toolbar_new (const char *name)
toolbar = g_new0 (EggToolbarsToolbar, 1);
toolbar->name = g_strdup (name);
+ toolbar->flags = 0;
return toolbar;
}
@@ -182,6 +184,37 @@ free_item_node (EggToolbarsItem *item)
g_free (item);
}
+EggTbModelFlags
+egg_toolbars_model_get_flags (EggToolbarsModel *t,
+ int toolbar_position)
+{
+ GNode *toolbar_node;
+ EggToolbarsToolbar *toolbar;
+
+ toolbar_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ g_return_val_if_fail (toolbar_node != NULL, -1);
+
+ toolbar = toolbar_node->data;
+
+ return toolbar->flags;
+}
+
+void
+egg_toolbars_model_set_flags (EggToolbarsModel *t,
+ EggTbModelFlags flags,
+ int toolbar_position)
+{
+ GNode *toolbar_node;
+ EggToolbarsToolbar *toolbar;
+
+ toolbar_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ g_return_if_fail (toolbar_node != NULL);
+
+ toolbar = toolbar_node->data;
+
+ toolbar->flags = flags;
+}
+
void
egg_toolbars_model_add_separator (EggToolbarsModel *t,
int toolbar_position,
@@ -402,16 +435,23 @@ egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
int position)
{
GNode *node;
+ EggTbModelFlags flags;
g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
- node = g_node_nth_child (t->priv->toolbars, position);
- g_return_if_fail (node != NULL);
+ flags = egg_toolbars_model_get_flags (t, position);
- free_toolbar_node (node->data);
- g_node_destroy (node);
+ if (!(flags && EGG_TB_MODEL_NOT_REMOVABLE))
+ {
+ node = g_node_nth_child (t->priv->toolbars, position);
+ g_return_if_fail (node != NULL);
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[TOOLBAR_REMOVED], 0, position);
+ free_toolbar_node (node->data);
+ g_node_destroy (node);
+
+ g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[TOOLBAR_REMOVED],
+ 0, position);
+ }
}
void
diff --git a/lib/egg/egg-toolbars-model.h b/lib/egg/egg-toolbars-model.h
index 16e3865a0..4d0e82937 100755
--- a/lib/egg/egg-toolbars-model.h
+++ b/lib/egg/egg-toolbars-model.h
@@ -37,6 +37,11 @@ typedef struct EggToolbarsModelClass EggToolbarsModelClass;
typedef struct EggToolbarsModel EggToolbarsModel;
typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
+typedef enum
+{
+ EGG_TB_MODEL_NOT_REMOVABLE = 1
+} EggTbModelFlags;
+
struct EggToolbarsModel
{
GObject parent_object;
@@ -76,6 +81,11 @@ void egg_toolbars_model_save (EggToolbarsModel *t,
const char *xml_file);
int egg_toolbars_model_add_toolbar (EggToolbarsModel *t,
const char *name);
+EggTbModelFlags egg_toolbars_model_get_flags (EggToolbarsModel *t,
+ int toolbar_position);
+void egg_toolbars_model_set_flags (EggToolbarsModel *t,
+ EggTbModelFlags flags,
+ int toolbar_position);
void egg_toolbars_model_add_separator (EggToolbarsModel *t,
int toolbar_position,
int position);
diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c
index cccf43ac0..d24f5f81b 100644
--- a/lib/egg/eggtoolbar.c
+++ b/lib/egg/eggtoolbar.c
@@ -37,7 +37,7 @@
#include "eggmarshalers.h"
#include <gtk/gtkmain.h>
-#define DEFAULT_IPADDING 0
+#define DEFAULT_IPADDING 1
#define DEFAULT_SPACE_SIZE 5
#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 1975d0f7c..1e4bed077 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -287,7 +287,7 @@ save_toolbars (EggToolbarsModel *model)
char *xml_file;
xml_file = g_build_filename (ephy_dot_dir (),
- "toolbar.xml",
+ "ephy-toolbar.xml",
NULL);
egg_toolbars_model_save (model, xml_file);
g_free (xml_file);
@@ -654,7 +654,27 @@ ephy_shell_get_toolbars_model (EphyShell *gs)
{
if (gs->priv->toolbars_model == NULL)
{
+ char *xml_file;
+ EggToolbarsModel *model;
+
gs->priv->toolbars_model = ephy_toolbars_model_new ();
+ model = EGG_TOOLBARS_MODEL (gs->priv->toolbars_model);
+
+ xml_file = g_build_filename (ephy_dot_dir (),
+ "ephy-toolbar.xml",
+ NULL);
+ if (g_file_test (xml_file, G_FILE_TEST_EXISTS))
+ {
+ egg_toolbars_model_load (model, xml_file);
+ }
+ else
+ {
+ const char *default_xml;
+
+ default_xml = ephy_file ("epiphany-toolbar.xml");
+ egg_toolbars_model_load (model, default_xml);
+ }
+ g_free (xml_file);
}
return gs->priv->toolbars_model;
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index 99d55c295..8c3bc19fc 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -34,8 +34,6 @@ enum
LAST_SIGNAL
};
-static guint ephy_toolbars_model_signals[LAST_SIGNAL] = { 0 };
-
static GObjectClass *parent_class = NULL;
struct EphyToolbarsModelPrivate
@@ -108,9 +106,6 @@ impl_add_item (EggToolbarsModel *t,
res = action_name ? action_name : name;
- g_signal_emit (G_OBJECT (t),
- ephy_toolbars_model_signals[ACTION_ADDED], 0, res);
-
EGG_TOOLBARS_MODEL_CLASS (parent_class)->add_item
(t, toolbar_position, position, type, res);
@@ -130,14 +125,6 @@ ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
object_class->finalize = ephy_toolbars_model_finalize;
etm_class->add_item = impl_add_item;
-
- ephy_toolbars_model_signals[ACTION_ADDED] =
- g_signal_new ("action_added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyToolbarsModelClass, action_added),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h
index dd84859f2..0f1de55ad 100755
--- a/src/ephy-toolbars-model.h
+++ b/src/ephy-toolbars-model.h
@@ -44,9 +44,6 @@ struct EphyToolbarsModel
struct EphyToolbarsModelClass
{
EggToolbarsModelClass parent_class;
-
- void (* action_added) (EggToolbarsModel *group,
- char *action_name);
};
GType ephy_toolbars_model_get_type (void);
diff --git a/src/toolbar.c b/src/toolbar.c
index 4f4203874..631bc94c2 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -311,11 +311,11 @@ toolbar_setup_actions (Toolbar *t)
}
static void
-action_added_cb (EphyToolbarsModel *model,
- char *action_name,
- Toolbar *t)
+action_request_cb (EggEditableToolbar *etoolbar,
+ char *action_name,
+ gpointer data)
{
- toolbar_ensure_action (t, action_name);
+ toolbar_ensure_action (TOOLBAR (etoolbar), action_name);
}
static void
@@ -342,6 +342,9 @@ init_bookmarks_toolbar (Toolbar *t)
(EGG_EDITABLE_TOOLBAR (t),
drag_targets, n_drag_targets,
t_name);
+ egg_toolbars_model_set_flags
+ (EGG_TOOLBARS_MODEL (model),
+ i, EGG_TB_MODEL_NOT_REMOVABLE);
}
}
}
@@ -350,7 +353,6 @@ static void
toolbar_set_window (Toolbar *t, EphyWindow *window)
{
EphyToolbarsModel *model;
- char *xml_file;
g_return_if_fail (t->priv->window == NULL);
@@ -361,27 +363,11 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
egg_menu_merge_insert_action_group (t->priv->ui_merge,
t->priv->action_group, 1);
- model = ephy_shell_get_toolbars_model (ephy_shell);
- g_return_if_fail (model != NULL);
- g_signal_connect_object (model, "action_added",
- G_CALLBACK (action_added_cb),
- t, 0);
-
- xml_file = g_build_filename (ephy_dot_dir (),
- "toolbar.xml",
- NULL);
- if (g_file_test (xml_file, G_FILE_TEST_EXISTS))
- {
- egg_toolbars_model_load
- (EGG_TOOLBARS_MODEL (model), xml_file);
- }
- else
- {
- egg_toolbars_model_load (EGG_TOOLBARS_MODEL (model),
- ephy_file ("epiphany-toolbar.xml"));
- }
- g_free (xml_file);
+ g_signal_connect (t, "action_request",
+ G_CALLBACK (action_request_cb),
+ NULL);
+ model = ephy_shell_get_toolbars_model (ephy_shell);
g_object_set (G_OBJECT (t),
"ToolbarsModel", model,
"MenuMerge", t->priv->ui_merge,