aboutsummaryrefslogtreecommitdiffstats
path: root/lib/egg
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-04-27 19:49:19 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-04-27 19:49:19 +0800
commit3d8e5e157f5a740d1f8005383597b13eca6725d4 (patch)
tree4f177ebc3431969e0a50ce2d3aab0ec6db79254a /lib/egg
parent34c164d7175456a25362d00981d1cc38a339baf2 (diff)
downloadgsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.tar
gsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.tar.gz
gsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.tar.bz2
gsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.tar.lz
gsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.tar.xz
gsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.tar.zst
gsoc2013-epiphany-3d8e5e157f5a740d1f8005383597b13eca6725d4.zip
update
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.
Diffstat (limited to 'lib/egg')
-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
6 files changed, 113 insertions, 17 deletions
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