[gtranslator] Update toolbar editor
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtranslator] Update toolbar editor
- Date: Wed, 27 Jan 2010 18:17:01 +0000 (UTC)
commit 187b48efda2c5244ba8fdf8930b778996077bac9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Jan 27 19:16:44 2010 +0100
Update toolbar editor
src/toolbareditor/egg-editable-toolbar.c | 928 +++++++++++++++---------------
src/toolbareditor/egg-editable-toolbar.h | 69 ++--
src/toolbareditor/egg-toolbar-editor.c | 256 +++++----
src/toolbareditor/egg-toolbar-editor.h | 17 +-
src/toolbareditor/egg-toolbars-model.c | 564 +++++++++---------
src/toolbareditor/egg-toolbars-model.h | 179 ++++---
6 files changed, 1012 insertions(+), 1001 deletions(-)
---
diff --git a/src/toolbareditor/egg-editable-toolbar.c b/src/toolbareditor/egg-editable-toolbar.c
index e2eea43..0719788 100644
--- a/src/toolbareditor/egg-editable-toolbar.c
+++ b/src/toolbareditor/egg-editable-toolbar.c
@@ -29,7 +29,7 @@
#include <glib/gi18n.h>
#include <string.h>
-static GdkPixbuf *new_separator_pixbuf (void);
+static GdkPixbuf * new_separator_pixbuf (void);
#define MIN_TOOLBAR_HEIGHT 20
#define EGG_ITEM_NAME "egg-item-name"
@@ -76,15 +76,16 @@ struct _EggEditableToolbarPrivate
char *popup_path;
- guint dnd_pending;
- GtkToolbar *dnd_toolbar;
+ guint dnd_pending;
+ GtkToolbar *dnd_toolbar;
GtkToolItem *dnd_toolitem;
};
G_DEFINE_TYPE (EggEditableToolbar, egg_editable_toolbar, GTK_TYPE_VBOX);
static int
-get_dock_position (EggEditableToolbar * etoolbar, GtkWidget * dock)
+get_dock_position (EggEditableToolbar *etoolbar,
+ GtkWidget *dock)
{
GList *l;
int result;
@@ -97,13 +98,13 @@ get_dock_position (EggEditableToolbar * etoolbar, GtkWidget * dock)
}
static int
-get_toolbar_position (EggEditableToolbar * etoolbar, GtkWidget * toolbar)
+get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
{
return get_dock_position (etoolbar, toolbar->parent);
}
static int
-get_n_toolbars (EggEditableToolbar * etoolbar)
+get_n_toolbars (EggEditableToolbar *etoolbar)
{
GList *l;
int result;
@@ -116,7 +117,8 @@ get_n_toolbars (EggEditableToolbar * etoolbar)
}
static GtkWidget *
-get_dock_nth (EggEditableToolbar * etoolbar, int position)
+get_dock_nth (EggEditableToolbar *etoolbar,
+ int position)
{
GList *l;
GtkWidget *result;
@@ -129,7 +131,8 @@ get_dock_nth (EggEditableToolbar * etoolbar, int position)
}
static GtkWidget *
-get_toolbar_nth (EggEditableToolbar * etoolbar, int position)
+get_toolbar_nth (EggEditableToolbar *etoolbar,
+ int position)
{
GList *l;
GtkWidget *dock;
@@ -146,7 +149,8 @@ get_toolbar_nth (EggEditableToolbar * etoolbar, int position)
}
static GtkAction *
-find_action (EggEditableToolbar * etoolbar, const char *name)
+find_action (EggEditableToolbar *etoolbar,
+ const char *name)
{
GList *l;
GtkAction *action = NULL;
@@ -168,8 +172,9 @@ find_action (EggEditableToolbar * etoolbar, const char *name)
}
static void
-drag_data_delete_cb (GtkWidget * widget,
- GdkDragContext * context, EggEditableToolbar * etoolbar)
+drag_data_delete_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ EggEditableToolbar *etoolbar)
{
int pos, toolbar_pos;
@@ -181,12 +186,14 @@ drag_data_delete_cb (GtkWidget * widget,
GTK_TOOL_ITEM (widget));
toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
- egg_toolbars_model_remove_item (etoolbar->priv->model, toolbar_pos, pos);
+ egg_toolbars_model_remove_item (etoolbar->priv->model,
+ toolbar_pos, pos);
}
static void
-drag_begin_cb (GtkWidget * widget,
- GdkDragContext * context, EggEditableToolbar * etoolbar)
+drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ EggEditableToolbar *etoolbar)
{
GtkAction *action;
gint flags;
@@ -199,8 +206,7 @@ drag_begin_cb (GtkWidget * widget,
action = gtk_widget_get_action (widget);
#endif
- if (action == NULL)
- return;
+ if (action == NULL) return;
flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model,
gtk_action_get_name (action));
@@ -208,13 +214,15 @@ drag_begin_cb (GtkWidget * widget,
{
flags &= ~EGG_TB_MODEL_NAME_USED;
egg_toolbars_model_set_name_flags (etoolbar->priv->model,
- gtk_action_get_name (action), flags);
+ gtk_action_get_name (action),
+ flags);
}
}
static void
-drag_end_cb (GtkWidget * widget,
- GdkDragContext * context, EggEditableToolbar * etoolbar)
+drag_end_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ EggEditableToolbar *etoolbar)
{
GtkAction *action;
gint flags;
@@ -229,14 +237,12 @@ drag_end_cb (GtkWidget * widget,
action = gtk_widget_get_action (widget);
#endif
- if (action == NULL)
- return;
+ if (action == NULL) return;
flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model,
- gtk_action_get_name
- (action));
+ gtk_action_get_name (action));
if (!(flags & EGG_TB_MODEL_NAME_INFINITE))
- {
+ {
flags |= EGG_TB_MODEL_NAME_USED;
egg_toolbars_model_set_name_flags (etoolbar->priv->model,
gtk_action_get_name (action),
@@ -246,10 +252,12 @@ drag_end_cb (GtkWidget * widget,
}
static void
-drag_data_get_cb (GtkWidget * widget,
- GdkDragContext * context,
- GtkSelectionData * selection_data,
- guint info, guint32 time, EggEditableToolbar * etoolbar)
+drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EggEditableToolbar *etoolbar)
{
EggToolbarsModel *model;
const char *name;
@@ -261,31 +269,26 @@ drag_data_get_cb (GtkWidget * widget,
name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
if (name == NULL)
{
- name =
- g_object_get_data (G_OBJECT (gtk_widget_get_parent (widget)),
- EGG_ITEM_NAME);
+ name = g_object_get_data (G_OBJECT (gtk_widget_get_parent (widget)), EGG_ITEM_NAME);
g_return_if_fail (name != NULL);
}
data = egg_toolbars_model_get_data (model, selection_data->target, name);
if (data != NULL)
{
- gtk_selection_data_set (selection_data, selection_data->target, 8,
- (unsigned char *) data, strlen (data));
+ gtk_selection_data_set (selection_data, selection_data->target, 8, (unsigned char *)data, strlen (data));
g_free (data);
}
}
static void
-move_item_cb (GtkAction * action, EggEditableToolbar * etoolbar)
+move_item_cb (GtkAction *action,
+ EggEditableToolbar *etoolbar)
{
- GtkWidget *toolitem =
- gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar),
- GTK_TYPE_TOOL_ITEM);
- GtkTargetList *list =
- gtk_target_list_new (dest_drag_types, G_N_ELEMENTS (dest_drag_types));
+ GtkWidget *toolitem = gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar), GTK_TYPE_TOOL_ITEM);
+ GtkTargetList *list = gtk_target_list_new (dest_drag_types, G_N_ELEMENTS (dest_drag_types));
- GdkEvent *realevent = gtk_get_current_event ();
+ GdkEvent *realevent = gtk_get_current_event();
GdkEventMotion event;
event.type = GDK_MOTION_NOTIFY;
event.window = realevent->any.window;
@@ -296,23 +299,23 @@ move_item_cb (GtkAction * action, EggEditableToolbar * etoolbar)
gdk_event_get_coords (realevent, &event.x, &event.y);
gdk_event_get_root_coords (realevent, &event.x_root, &event.y_root);
- gtk_drag_begin (toolitem, list, GDK_ACTION_MOVE, 1, (GdkEvent *) & event);
+ gtk_drag_begin (toolitem, list, GDK_ACTION_MOVE, 1, (GdkEvent *)&event);
gtk_target_list_unref (list);
}
static void
-remove_item_cb (GtkAction * action, EggEditableToolbar * etoolbar)
+remove_item_cb (GtkAction *action,
+ EggEditableToolbar *etoolbar)
{
- GtkWidget *toolitem =
- gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar),
- GTK_TYPE_TOOL_ITEM);
+ GtkWidget *toolitem = gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar), GTK_TYPE_TOOL_ITEM);
int pos, toolbar_pos;
toolbar_pos = get_toolbar_position (etoolbar, toolitem->parent);
pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolitem->parent),
GTK_TOOL_ITEM (toolitem));
- egg_toolbars_model_remove_item (etoolbar->priv->model, toolbar_pos, pos);
+ egg_toolbars_model_remove_item (etoolbar->priv->model,
+ toolbar_pos, pos);
if (egg_toolbars_model_n_items (etoolbar->priv->model, toolbar_pos) == 0)
{
@@ -321,7 +324,8 @@ remove_item_cb (GtkAction * action, EggEditableToolbar * etoolbar)
}
static void
-remove_toolbar_cb (GtkAction * action, EggEditableToolbar * etoolbar)
+remove_toolbar_cb (GtkAction *action,
+ EggEditableToolbar *etoolbar)
{
GtkWidget *selected = egg_editable_toolbar_get_selected (etoolbar);
GtkWidget *toolbar = gtk_widget_get_ancestor (selected, GTK_TYPE_TOOLBAR);
@@ -332,17 +336,19 @@ remove_toolbar_cb (GtkAction * action, EggEditableToolbar * etoolbar)
}
static void
-popup_context_deactivate (GtkMenuShell * menu, EggEditableToolbar * etoolbar)
+popup_context_deactivate (GtkMenuShell *menu,
+ EggEditableToolbar *etoolbar)
{
egg_editable_toolbar_set_selected (etoolbar, NULL);
g_object_notify (G_OBJECT (etoolbar), "selected");
}
static void
-popup_context_menu_cb (GtkWidget * toolbar,
- gint x,
- gint y,
- gint button_number, EggEditableToolbar * etoolbar)
+popup_context_menu_cb (GtkWidget *toolbar,
+ gint x,
+ gint y,
+ gint button_number,
+ EggEditableToolbar *etoolbar)
{
if (etoolbar->priv->popup_path != NULL)
{
@@ -352,11 +358,9 @@ popup_context_menu_cb (GtkWidget * toolbar,
g_object_notify (G_OBJECT (etoolbar), "selected");
menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager,
- etoolbar->priv->
- popup_path));
+ etoolbar->priv->popup_path));
g_return_if_fail (menu != NULL);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_number,
- gtk_get_current_event_time ());
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button_number, gtk_get_current_event_time ());
g_signal_connect_object (menu, "selection-done",
G_CALLBACK (popup_context_deactivate),
etoolbar, 0);
@@ -364,8 +368,9 @@ popup_context_menu_cb (GtkWidget * toolbar,
}
static gboolean
-button_press_event_cb (GtkWidget * widget,
- GdkEventButton * event, EggEditableToolbar * etoolbar)
+button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ EggEditableToolbar *etoolbar)
{
if (event->button == 3 && etoolbar->priv->popup_path != NULL)
{
@@ -375,11 +380,9 @@ button_press_event_cb (GtkWidget * widget,
g_object_notify (G_OBJECT (etoolbar), "selected");
menu = GTK_MENU (gtk_ui_manager_get_widget (etoolbar->priv->manager,
- etoolbar->priv->
- popup_path));
+ etoolbar->priv->popup_path));
g_return_val_if_fail (menu != NULL, FALSE);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button,
- event->time);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
g_signal_connect_object (menu, "selection-done",
G_CALLBACK (popup_context_deactivate),
etoolbar, 0);
@@ -391,7 +394,7 @@ button_press_event_cb (GtkWidget * widget,
}
static void
-configure_item_sensitivity (GtkToolItem * item, EggEditableToolbar * etoolbar)
+configure_item_sensitivity (GtkToolItem *item, EggEditableToolbar *etoolbar)
{
GtkAction *action;
char *name;
@@ -411,7 +414,8 @@ configure_item_sensitivity (GtkToolItem * item, EggEditableToolbar * etoolbar)
}
static void
-configure_item_cursor (GtkToolItem * item, EggEditableToolbar * etoolbar)
+configure_item_cursor (GtkToolItem *item,
+ EggEditableToolbar *etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
GtkWidget *widget = GTK_WIDGET (item);
@@ -419,92 +423,89 @@ configure_item_cursor (GtkToolItem * item, EggEditableToolbar * etoolbar)
if (widget->window != NULL)
{
if (priv->edit_mode > 0)
- {
- GdkCursor *cursor;
+ {
+ GdkCursor *cursor;
GdkScreen *screen;
- GdkPixbuf *pixbuf = NULL;
+ GdkPixbuf *pixbuf = NULL;
screen = gtk_widget_get_screen (GTK_WIDGET (etoolbar));
- cursor =
- gdk_cursor_new_for_display (gdk_screen_get_display (screen),
- GDK_HAND2);
- gdk_window_set_cursor (widget->window, cursor);
- gdk_cursor_unref (cursor);
-
- gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
- G_N_ELEMENTS (dest_drag_types),
- GDK_ACTION_MOVE);
- if (GTK_IS_SEPARATOR_TOOL_ITEM (item))
- {
- pixbuf = new_separator_pixbuf ();
- }
- else
- {
- char *icon_name = NULL;
- char *stock_id = NULL;
- GtkAction *action;
- char *name;
-
- name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
- action = name ? find_action (etoolbar, name) : NULL;
-
- if (action)
- {
- g_object_get (action,
- "icon-name", &icon_name,
- "stock-id", &stock_id, NULL);
- }
- if (icon_name)
- {
- GdkScreen *screen;
- GtkIconTheme *icon_theme;
- GtkSettings *settings;
- gint width, height;
-
- screen = gtk_widget_get_screen (widget);
- icon_theme = gtk_icon_theme_get_for_screen (screen);
- settings = gtk_settings_get_for_screen (screen);
-
- if (!gtk_icon_size_lookup_for_settings (settings,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- &width, &height))
- {
- width = height = 24;
- }
-
- pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
- MIN (width, height), 0,
- NULL);
- }
- else if (stock_id)
- {
- pixbuf = gtk_widget_render_icon (widget, stock_id,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- NULL);
- }
- g_free (icon_name);
- g_free (stock_id);
- }
-
- if (G_UNLIKELY (!pixbuf))
- {
- return;
- }
- gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
- g_object_unref (pixbuf);
-
- }
+ cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen),
+ GDK_HAND2);
+ gdk_window_set_cursor (widget->window, cursor);
+ gdk_cursor_unref (cursor);
+
+ gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
+ G_N_ELEMENTS (dest_drag_types), GDK_ACTION_MOVE);
+ if (GTK_IS_SEPARATOR_TOOL_ITEM (item))
+ {
+ pixbuf = new_separator_pixbuf ();
+ }
+ else
+ {
+ char *icon_name=NULL;
+ char *stock_id=NULL;
+ GtkAction *action;
+ char *name;
+
+ name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
+ action = name ? find_action (etoolbar, name) : NULL;
+
+ if (action)
+ {
+ g_object_get (action,
+ "icon-name", &icon_name,
+ "stock-id", &stock_id,
+ NULL);
+ }
+ if (icon_name)
+ {
+ GdkScreen *screen;
+ GtkIconTheme *icon_theme;
+ GtkSettings *settings;
+ gint width, height;
+
+ screen = gtk_widget_get_screen (widget);
+ icon_theme = gtk_icon_theme_get_for_screen (screen);
+ settings = gtk_settings_get_for_screen (screen);
+
+ if (!gtk_icon_size_lookup_for_settings (settings,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ &width, &height))
+ {
+ width = height = 24;
+ }
+
+ pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
+ MIN (width, height), 0, NULL);
+ }
+ else if (stock_id)
+ {
+ pixbuf = gtk_widget_render_icon (widget, stock_id,
+ GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
+ }
+ g_free (icon_name);
+ g_free (stock_id);
+ }
+
+ if (G_UNLIKELY (!pixbuf))
+ {
+ return;
+ }
+ gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
+ g_object_unref (pixbuf);
+
+ }
else
- {
- gdk_window_set_cursor (GTK_WIDGET (item)->window, NULL);
- }
+ {
+ gdk_window_set_cursor (GTK_WIDGET(item)->window, NULL);
+ }
}
}
static void
-configure_item_tooltip (GtkToolItem * item)
+configure_item_tooltip (GtkToolItem *item)
{
GtkAction *action;
@@ -522,25 +523,29 @@ configure_item_tooltip (GtkToolItem * item)
static void
-connect_widget_signals (GtkWidget * proxy, EggEditableToolbar * etoolbar)
+connect_widget_signals (GtkWidget *proxy, EggEditableToolbar *etoolbar)
{
if (GTK_IS_CONTAINER (proxy))
{
- gtk_container_forall (GTK_CONTAINER (proxy),
- (GtkCallback) connect_widget_signals,
- (gpointer) etoolbar);
+ gtk_container_forall (GTK_CONTAINER (proxy),
+ (GtkCallback) connect_widget_signals,
+ (gpointer) etoolbar);
}
if (GTK_IS_TOOL_ITEM (proxy))
{
g_signal_connect_object (proxy, "drag_begin",
- G_CALLBACK (drag_begin_cb), etoolbar, 0);
+ G_CALLBACK (drag_begin_cb),
+ etoolbar, 0);
g_signal_connect_object (proxy, "drag_end",
- G_CALLBACK (drag_end_cb), etoolbar, 0);
+ G_CALLBACK (drag_end_cb),
+ etoolbar, 0);
g_signal_connect_object (proxy, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), etoolbar, 0);
+ G_CALLBACK (drag_data_get_cb),
+ etoolbar, 0);
g_signal_connect_object (proxy, "drag_data_delete",
- G_CALLBACK (drag_data_delete_cb), etoolbar, 0);
+ G_CALLBACK (drag_data_delete_cb),
+ etoolbar, 0);
}
if (GTK_IS_BUTTON (proxy) || GTK_IS_TOOL_ITEM (proxy))
@@ -552,8 +557,9 @@ connect_widget_signals (GtkWidget * proxy, EggEditableToolbar * etoolbar)
}
static void
-action_sensitive_cb (GtkAction * action,
- GParamSpec * pspec, GtkToolItem * item)
+action_sensitive_cb (GtkAction *action,
+ GParamSpec *pspec,
+ GtkToolItem *item)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR
(gtk_widget_get_ancestor (GTK_WIDGET (item), EGG_TYPE_EDITABLE_TOOLBAR));
@@ -565,7 +571,8 @@ action_sensitive_cb (GtkAction * action,
}
static GtkToolItem *
-create_item_from_action (EggEditableToolbar * etoolbar, const char *name)
+create_item_from_action (EggEditableToolbar *etoolbar,
+ const char *name)
{
GtkToolItem *item;
@@ -578,8 +585,7 @@ create_item_from_action (EggEditableToolbar * etoolbar, const char *name)
else
{
GtkAction *action = find_action (etoolbar, name);
- if (action == NULL)
- return NULL;
+ if (action == NULL) return NULL;
item = GTK_TOOL_ITEM (gtk_action_create_tool_item (action));
@@ -587,43 +593,43 @@ create_item_from_action (EggEditableToolbar * etoolbar, const char *name)
* such demand may have been made yet, so do it ourselves.
*/
gtk_action_set_accel_group
- (action, gtk_ui_manager_get_accel_group (etoolbar->priv->manager));
+ (action, gtk_ui_manager_get_accel_group(etoolbar->priv->manager));
g_signal_connect_object (action, "notify::sensitive",
- G_CALLBACK (action_sensitive_cb), item, 0);
+ G_CALLBACK (action_sensitive_cb), item, 0);
}
gtk_widget_show (GTK_WIDGET (item));
g_object_set_data_full (G_OBJECT (item), EGG_ITEM_NAME,
- g_strdup (name), g_free);
+ g_strdup (name), g_free);
return item;
}
static GtkToolItem *
-create_item_from_position (EggEditableToolbar * etoolbar,
- int toolbar_position, int position)
+create_item_from_position (EggEditableToolbar *etoolbar,
+ int toolbar_position,
+ int position)
{
GtkToolItem *item;
const char *name;
- name =
- egg_toolbars_model_item_nth (etoolbar->priv->model, toolbar_position,
- position);
+ name = egg_toolbars_model_item_nth (etoolbar->priv->model, toolbar_position, position);
item = create_item_from_action (etoolbar, name);
return item;
}
static void
-toolbar_drag_data_received_cb (GtkToolbar * toolbar,
- GdkDragContext * context,
- gint x,
- gint y,
- GtkSelectionData * selection_data,
- guint info,
- guint time, EggEditableToolbar * etoolbar)
+toolbar_drag_data_received_cb (GtkToolbar *toolbar,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ EggEditableToolbar *etoolbar)
{
/* This function can be called for two reasons
*
@@ -637,7 +643,7 @@ toolbar_drag_data_received_cb (GtkToolbar * toolbar,
*/
GdkAtom type = selection_data->type;
- const char *data = (char *) selection_data->data;
+ const char *data = (char *)selection_data->data;
int ipos = -1;
char *name = NULL;
@@ -647,15 +653,11 @@ toolbar_drag_data_received_cb (GtkToolbar * toolbar,
if (selection_data->length >= 0)
{
ipos = gtk_toolbar_get_drop_index (toolbar, x, y);
- name =
- egg_toolbars_model_get_name (etoolbar->priv->model, type, data,
- FALSE);
+ name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, FALSE);
if (name != NULL)
{
- used =
- ((egg_toolbars_model_get_name_flags (etoolbar->priv->model, name)
- & EGG_TB_MODEL_NAME_USED) != 0);
- }
+ used = ((egg_toolbars_model_get_name_flags (etoolbar->priv->model, name) & EGG_TB_MODEL_NAME_USED) != 0);
+ }
}
/* If we just want a highlight item, then . */
@@ -664,13 +666,11 @@ toolbar_drag_data_received_cb (GtkToolbar * toolbar,
etoolbar->priv->dnd_pending--;
if (name != NULL && etoolbar->priv->dnd_toolbar == toolbar && !used)
- {
- etoolbar->priv->dnd_toolitem =
- create_item_from_action (etoolbar, name);
- gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
- etoolbar->priv->dnd_toolitem,
- ipos);
- }
+ {
+ etoolbar->priv->dnd_toolitem = create_item_from_action (etoolbar, name);
+ gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
+ etoolbar->priv->dnd_toolitem, ipos);
+ }
}
else
{
@@ -680,35 +680,32 @@ toolbar_drag_data_received_cb (GtkToolbar * toolbar,
/* If we don't have a name to use yet, try to create one. */
if (name == NULL && selection_data->length >= 0)
- {
- name =
- egg_toolbars_model_get_name (etoolbar->priv->model, type, data,
- TRUE);
- }
+ {
+ name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, TRUE);
+ }
if (name != NULL && !used)
- {
- gint tpos = get_toolbar_position (etoolbar, GTK_WIDGET (toolbar));
- egg_toolbars_model_add_item (etoolbar->priv->model, tpos, ipos,
- name);
- gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE,
- time);
- }
+ {
+ gint tpos = get_toolbar_position (etoolbar, GTK_WIDGET (toolbar));
+ egg_toolbars_model_add_item (etoolbar->priv->model, tpos, ipos, name);
+ gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time);
+ }
else
- {
- gtk_drag_finish (context, FALSE, context->action == GDK_ACTION_MOVE,
- time);
- }
+ {
+ gtk_drag_finish (context, FALSE, context->action == GDK_ACTION_MOVE, time);
+ }
}
g_free (name);
}
static gboolean
-toolbar_drag_drop_cb (GtkToolbar * toolbar,
- GdkDragContext * context,
- gint x,
- gint y, guint time, EggEditableToolbar * etoolbar)
+toolbar_drag_drop_cb (GtkToolbar *toolbar,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ EggEditableToolbar *etoolbar)
{
GdkAtom target;
@@ -723,13 +720,14 @@ toolbar_drag_drop_cb (GtkToolbar * toolbar,
}
static gboolean
-toolbar_drag_motion_cb (GtkToolbar * toolbar,
- GdkDragContext * context,
- gint x,
- gint y, guint time, EggEditableToolbar * etoolbar)
-{
- GdkAtom target =
- gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL);
+toolbar_drag_motion_cb (GtkToolbar *toolbar,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time,
+ EggEditableToolbar *etoolbar)
+{
+ GdkAtom target = gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL);
if (target == GDK_NONE)
{
gdk_drag_status (context, 0, time);
@@ -748,11 +746,9 @@ toolbar_drag_motion_cb (GtkToolbar * toolbar,
/* If a highlight item is available, use it. */
else if (etoolbar->priv->dnd_toolitem)
{
- gint ipos =
- gtk_toolbar_get_drop_index (etoolbar->priv->dnd_toolbar, x, y);
+ gint ipos = gtk_toolbar_get_drop_index (etoolbar->priv->dnd_toolbar, x, y);
gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
- etoolbar->priv->dnd_toolitem,
- ipos);
+ etoolbar->priv->dnd_toolitem, ipos);
}
gdk_drag_status (context, context->suggested_action, time);
@@ -761,9 +757,10 @@ toolbar_drag_motion_cb (GtkToolbar * toolbar,
}
static void
-toolbar_drag_leave_cb (GtkToolbar * toolbar,
- GdkDragContext * context,
- guint time, EggEditableToolbar * etoolbar)
+toolbar_drag_leave_cb (GtkToolbar *toolbar,
+ GdkDragContext *context,
+ guint time,
+ EggEditableToolbar *etoolbar)
{
gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0);
@@ -776,7 +773,8 @@ toolbar_drag_leave_cb (GtkToolbar * toolbar,
}
static void
-configure_drag_dest (EggEditableToolbar * etoolbar, GtkToolbar * toolbar)
+configure_drag_dest (EggEditableToolbar *etoolbar,
+ GtkToolbar *toolbar)
{
EggToolbarsItemType *type;
GtkTargetList *targets;
@@ -791,17 +789,17 @@ configure_drag_dest (EggEditableToolbar * etoolbar, GtkToolbar * toolbar)
targets = gtk_drag_dest_get_target_list (GTK_WIDGET (toolbar));
list = egg_toolbars_model_get_types (etoolbar->priv->model);
while (list)
- {
- type = list->data;
- if (type->new_name != NULL || type->get_name != NULL)
- gtk_target_list_add (targets, type->type, 0, 0);
- list = list->next;
- }
+ {
+ type = list->data;
+ if (type->new_name != NULL || type->get_name != NULL)
+ gtk_target_list_add (targets, type->type, 0, 0);
+ list = list->next;
+ }
}
static void
-toggled_visibility_cb (GtkToggleAction * action,
- EggEditableToolbar * etoolbar)
+toggled_visibility_cb (GtkToggleAction *action,
+ EggEditableToolbar *etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
GtkWidget *dock;
@@ -831,12 +829,12 @@ toggled_visibility_cb (GtkToggleAction * action,
flags = egg_toolbars_model_get_flags (priv->model, i);
if (visible)
- {
+ {
flags &= ~(EGG_TB_MODEL_HIDDEN);
}
else
{
- flags |= (EGG_TB_MODEL_HIDDEN);
+ flags |= (EGG_TB_MODEL_HIDDEN);
}
egg_toolbars_model_set_flags (priv->model, i, flags);
@@ -844,7 +842,7 @@ toggled_visibility_cb (GtkToggleAction * action,
}
static void
-toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
+toolbar_visibility_refresh (EggEditableToolbar *etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
gint n_toolbars, n_items, i, j, k;
@@ -882,25 +880,23 @@ toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
string = g_string_sized_new (0);
n_items = egg_toolbars_model_n_items (priv->model, i);
for (k = 0, j = 0; j < n_items; j++)
- {
- GValue value = { 0, };
- GtkAction *action;
- const char *name;
-
- name = egg_toolbars_model_item_nth (priv->model, i, j);
- if (name == NULL)
- continue;
- action = find_action (etoolbar, name);
- if (action == NULL)
- continue;
-
- g_value_init (&value, G_TYPE_STRING);
- g_object_get_property (G_OBJECT (action), "label", &value);
- name = g_value_get_string (&value);
- if (name == NULL)
+ {
+ GValue value = { 0, };
+ GtkAction *action;
+ const char *name;
+
+ name = egg_toolbars_model_item_nth (priv->model, i, j);
+ if (name == NULL) continue;
+ action = find_action (etoolbar, name);
+ if (action == NULL) continue;
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (action), "label", &value);
+ name = g_value_get_string (&value);
+ if (name == NULL)
{
- g_value_unset (&value);
- continue;
+ g_value_unset (&value);
+ continue;
}
k += g_utf8_strlen (name, -1) + 2;
if (j > 0)
@@ -916,18 +912,17 @@ toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
g_value_unset (&value);
}
if (j < n_items)
- {
+ {
g_string_append (string, " ...");
- }
+ }
tmp = g_string_free (string, FALSE);
for (j = 0, k = 0; tmp[j]; j++)
- {
- if (tmp[j] == '_')
- continue;
- tmp[k] = tmp[j];
- k++;
- }
+ {
+ if (tmp[j] == '_') continue;
+ tmp[k] = tmp[j];
+ k++;
+ }
tmp[k] = 0;
/* Translaters: This string is for a toggle to display a toolbar.
* The name of the toolbar is automatically computed from the widgets
@@ -939,12 +934,11 @@ toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
action_label = g_strdup_printf (_("Show â??_%sâ??"), tmp);
g_free (tmp);
- sprintf (action_name, "ToolbarToggle%d", i);
+ sprintf(action_name, "ToolbarToggle%d", i);
if (i >= priv->visibility_actions->len)
- {
- action =
- gtk_toggle_action_new (action_name, action_label, NULL, NULL);
+ {
+ action = gtk_toggle_action_new (action_name, action_label, NULL, NULL);
g_ptr_array_add (priv->visibility_actions, action);
g_signal_connect_object (action, "toggled",
G_CALLBACK (toggled_visibility_cb),
@@ -952,24 +946,22 @@ toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
gtk_action_group_add_action (priv->actions, GTK_ACTION (action));
}
else
- {
+ {
action = g_ptr_array_index (priv->visibility_actions, i);
g_object_set (action, "label", action_label, NULL);
- }
+ }
- gtk_action_set_visible (GTK_ACTION (action),
- (egg_toolbars_model_get_flags (priv->model, i) &
- EGG_TB_MODEL_NOT_REMOVABLE) == 0);
+ gtk_action_set_visible (GTK_ACTION (action), (egg_toolbars_model_get_flags (priv->model, i)
+ & EGG_TB_MODEL_NOT_REMOVABLE) == 0);
gtk_action_set_sensitive (GTK_ACTION (action), showing);
gtk_toggle_action_set_active (action, GTK_WIDGET_VISIBLE
(get_dock_nth (etoolbar, i)));
- for (list = priv->visibility_paths; list != NULL;
- list = g_list_next (list))
- {
+ for (list = priv->visibility_paths; list != NULL; list = g_list_next (list))
+ {
gtk_ui_manager_add_ui (priv->manager, priv->visibility_id,
- (const char *) list->data, action_name,
- action_name, GTK_UI_MANAGER_MENUITEM, FALSE);
+ (const char *)list->data, action_name, action_name,
+ GTK_UI_MANAGER_MENUITEM, FALSE);
}
g_free (action_label);
@@ -987,7 +979,7 @@ toolbar_visibility_refresh (EggEditableToolbar * etoolbar)
}
static GtkWidget *
-create_dock (EggEditableToolbar * etoolbar)
+create_dock (EggEditableToolbar *etoolbar)
{
GtkWidget *toolbar, *hbox;
@@ -1016,24 +1008,24 @@ create_dock (EggEditableToolbar * etoolbar)
}
static void
-set_fixed_style (EggEditableToolbar * t, GtkToolbarStyle style)
+set_fixed_style (EggEditableToolbar *t, GtkToolbarStyle style)
{
g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
gtk_toolbar_set_style (GTK_TOOLBAR (t->priv->fixed_toolbar),
- style ==
- GTK_TOOLBAR_ICONS ? GTK_TOOLBAR_BOTH_HORIZ : style);
+ style == GTK_TOOLBAR_ICONS ? GTK_TOOLBAR_BOTH_HORIZ : style);
}
static void
-unset_fixed_style (EggEditableToolbar * t)
+unset_fixed_style (EggEditableToolbar *t)
{
g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
gtk_toolbar_unset_style (GTK_TOOLBAR (t->priv->fixed_toolbar));
}
static void
-toolbar_changed_cb (EggToolbarsModel * model,
- int position, EggEditableToolbar * etoolbar)
+toolbar_changed_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *etoolbar)
{
GtkWidget *toolbar;
EggTbModelFlags flags;
@@ -1043,30 +1035,30 @@ toolbar_changed_cb (EggToolbarsModel * model,
toolbar = get_toolbar_nth (etoolbar, position);
if (flags & EGG_TB_MODEL_ICONS)
- {
- style = GTK_TOOLBAR_ICONS;
- }
+ {
+ style = GTK_TOOLBAR_ICONS;
+ }
else if (flags & EGG_TB_MODEL_TEXT)
- {
- style = GTK_TOOLBAR_TEXT;
- }
+ {
+ style = GTK_TOOLBAR_TEXT;
+ }
else if (flags & EGG_TB_MODEL_BOTH)
- {
- style = GTK_TOOLBAR_BOTH;
- }
+ {
+ style = GTK_TOOLBAR_BOTH;
+ }
else if (flags & EGG_TB_MODEL_BOTH_HORIZ)
- {
- style = GTK_TOOLBAR_BOTH_HORIZ;
- }
+ {
+ style = GTK_TOOLBAR_BOTH_HORIZ;
+ }
else
- {
- gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
- if (position == 0 && etoolbar->priv->fixed_toolbar)
- {
- unset_fixed_style (etoolbar);
- }
- return;
- }
+ {
+ gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
+ if (position == 0 && etoolbar->priv->fixed_toolbar)
+ {
+ unset_fixed_style (etoolbar);
+ }
+ return;
+ }
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
if (position == 0 && etoolbar->priv->fixed_toolbar)
@@ -1078,7 +1070,7 @@ toolbar_changed_cb (EggToolbarsModel * model,
}
static void
-unparent_fixed (EggEditableToolbar * etoolbar)
+unparent_fixed (EggEditableToolbar *etoolbar)
{
GtkWidget *toolbar, *dock;
g_return_if_fail (GTK_IS_TOOLBAR (etoolbar->priv->fixed_toolbar));
@@ -1093,11 +1085,10 @@ unparent_fixed (EggEditableToolbar * etoolbar)
}
static void
-update_fixed (EggEditableToolbar * etoolbar)
+update_fixed (EggEditableToolbar *etoolbar)
{
GtkWidget *toolbar, *dock;
- if (!etoolbar->priv->fixed_toolbar)
- return;
+ if (!etoolbar->priv->fixed_toolbar) return;
toolbar = etoolbar->priv->fixed_toolbar;
dock = get_dock_nth (etoolbar, 0);
@@ -1114,14 +1105,14 @@ update_fixed (EggEditableToolbar * etoolbar)
}
static void
-toolbar_added_cb (EggToolbarsModel * model,
- int position, EggEditableToolbar * etoolbar)
+toolbar_added_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *etoolbar)
{
GtkWidget *dock;
dock = create_dock (etoolbar);
- if ((egg_toolbars_model_get_flags (model, position) & EGG_TB_MODEL_HIDDEN)
- == 0)
+ if ((egg_toolbars_model_get_flags (model, position) & EGG_TB_MODEL_HIDDEN) == 0)
gtk_widget_show (dock);
gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
@@ -1138,8 +1129,9 @@ toolbar_added_cb (EggToolbarsModel * model,
}
static void
-toolbar_removed_cb (EggToolbarsModel * model,
- int position, EggEditableToolbar * etoolbar)
+toolbar_removed_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *etoolbar)
{
GtkWidget *dock;
@@ -1157,8 +1149,10 @@ toolbar_removed_cb (EggToolbarsModel * model,
}
static void
-item_added_cb (EggToolbarsModel * model,
- int tpos, int ipos, EggEditableToolbar * etoolbar)
+item_added_cb (EggToolbarsModel *model,
+ int tpos,
+ int ipos,
+ EggEditableToolbar *etoolbar)
{
GtkWidget *dock;
GtkWidget *toolbar;
@@ -1166,8 +1160,7 @@ item_added_cb (EggToolbarsModel * model,
toolbar = get_toolbar_nth (etoolbar, tpos);
item = create_item_from_position (etoolbar, tpos, ipos);
- if (item == NULL)
- return;
+ if (item == NULL) return;
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, ipos);
@@ -1184,9 +1177,10 @@ item_added_cb (EggToolbarsModel * model,
}
static void
-item_removed_cb (EggToolbarsModel * model,
- int toolbar_position,
- int position, EggEditableToolbar * etoolbar)
+item_removed_cb (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ EggEditableToolbar *etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1195,7 +1189,7 @@ item_removed_cb (EggToolbarsModel * model,
toolbar = get_toolbar_nth (etoolbar, toolbar_position);
item = GTK_WIDGET (gtk_toolbar_get_nth_item
- (GTK_TOOLBAR (toolbar), position));
+ (GTK_TOOLBAR (toolbar), position));
g_return_if_fail (item != NULL);
if (item == priv->selected)
@@ -1209,7 +1203,7 @@ item_removed_cb (EggToolbarsModel * model,
}
static void
-egg_editable_toolbar_build (EggEditableToolbar * etoolbar)
+egg_editable_toolbar_build (EggEditableToolbar *etoolbar)
{
int i, l, n_items, n_toolbars;
EggToolbarsModel *model = etoolbar->priv->model;
@@ -1224,51 +1218,50 @@ egg_editable_toolbar_build (EggEditableToolbar * etoolbar)
GtkWidget *toolbar, *dock;
dock = create_dock (etoolbar);
- if ((egg_toolbars_model_get_flags (model, i) & EGG_TB_MODEL_HIDDEN) ==
- 0)
- gtk_widget_show (dock);
+ if ((egg_toolbars_model_get_flags (model, i) & EGG_TB_MODEL_HIDDEN) == 0)
+ gtk_widget_show (dock);
gtk_box_pack_start (GTK_BOX (etoolbar), dock, TRUE, TRUE, 0);
toolbar = get_toolbar_nth (etoolbar, i);
n_items = egg_toolbars_model_n_items (model, i);
for (l = 0; l < n_items; l++)
- {
- GtkToolItem *item;
+ {
+ GtkToolItem *item;
- item = create_item_from_position (etoolbar, i, l);
- if (item)
- {
+ item = create_item_from_position (etoolbar, i, l);
+ if (item)
+ {
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, l);
- connect_widget_signals (GTK_WIDGET (item), etoolbar);
+ connect_widget_signals (GTK_WIDGET (item), etoolbar);
configure_item_tooltip (item);
- configure_item_sensitivity (item, etoolbar);
- }
- else
- {
- egg_toolbars_model_remove_item (model, i, l);
- l--;
- n_items--;
- }
- }
+ configure_item_sensitivity (item, etoolbar);
+ }
+ else
+ {
+ egg_toolbars_model_remove_item (model, i, l);
+ l--;
+ n_items--;
+ }
+ }
if (n_items == 0)
- {
- gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
- }
+ {
+ gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
+ }
}
update_fixed (etoolbar);
/* apply styles */
- for (i = 0; i < n_toolbars; i++)
+ for (i = 0; i < n_toolbars; i ++)
{
toolbar_changed_cb (model, i, etoolbar);
}
}
static void
-egg_editable_toolbar_disconnect_model (EggEditableToolbar * toolbar)
+egg_editable_toolbar_disconnect_model (EggEditableToolbar *toolbar)
{
EggToolbarsModel *model = toolbar->priv->model;
@@ -1285,7 +1278,7 @@ egg_editable_toolbar_disconnect_model (EggEditableToolbar * toolbar)
}
static void
-egg_editable_toolbar_deconstruct (EggEditableToolbar * toolbar)
+egg_editable_toolbar_deconstruct (EggEditableToolbar *toolbar)
{
EggToolbarsModel *model = toolbar->priv->model;
GList *children;
@@ -1294,8 +1287,8 @@ egg_editable_toolbar_deconstruct (EggEditableToolbar * toolbar)
if (toolbar->priv->fixed_toolbar)
{
- unset_fixed_style (toolbar);
- unparent_fixed (toolbar);
+ unset_fixed_style (toolbar);
+ unparent_fixed (toolbar);
}
children = gtk_container_get_children (GTK_CONTAINER (toolbar));
@@ -1304,13 +1297,12 @@ egg_editable_toolbar_deconstruct (EggEditableToolbar * toolbar)
}
void
-egg_editable_toolbar_set_model (EggEditableToolbar * etoolbar,
- EggToolbarsModel * model)
+egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar,
+ EggToolbarsModel *model)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
- if (priv->model == model)
- return;
+ if (priv->model == model) return;
if (priv->model)
{
@@ -1339,7 +1331,7 @@ egg_editable_toolbar_set_model (EggEditableToolbar * etoolbar,
}
static void
-egg_editable_toolbar_init (EggEditableToolbar * etoolbar)
+egg_editable_toolbar_init (EggEditableToolbar *etoolbar)
{
EggEditableToolbarPrivate *priv;
@@ -1352,7 +1344,7 @@ egg_editable_toolbar_init (EggEditableToolbar * etoolbar)
}
static void
-egg_editable_toolbar_dispose (GObject * object)
+egg_editable_toolbar_dispose (GObject *object)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1378,7 +1370,7 @@ egg_editable_toolbar_dispose (GObject * object)
if (priv->manager != NULL)
{
if (priv->visibility_id)
- {
+ {
gtk_ui_manager_remove_ui (priv->manager, priv->visibility_id);
priv->visibility_id = 0;
}
@@ -1398,77 +1390,65 @@ egg_editable_toolbar_dispose (GObject * object)
}
static void
-egg_editable_toolbar_set_ui_manager (EggEditableToolbar * etoolbar,
- GtkUIManager * manager)
+egg_editable_toolbar_set_ui_manager (EggEditableToolbar *etoolbar,
+ GtkUIManager *manager)
{
static const GtkActionEntry actions[] = {
- {"MoveToolItem", STOCK_DRAG_MODE, N_("_Move on Toolbar"), NULL,
- N_("Move the selected item on the toolbar"), G_CALLBACK (move_item_cb)},
- {"RemoveToolItem", GTK_STOCK_REMOVE, N_("_Remove from Toolbar"), NULL,
- N_("Remove the selected item from the toolbar"),
- G_CALLBACK (remove_item_cb)},
- {"RemoveToolbar", GTK_STOCK_DELETE, N_("_Delete Toolbar"), NULL,
- N_("Remove the selected toolbar"), G_CALLBACK (remove_toolbar_cb)},
+ { "MoveToolItem", STOCK_DRAG_MODE, N_("_Move on Toolbar"), NULL,
+ N_("Move the selected item on the toolbar"), G_CALLBACK (move_item_cb) },
+ { "RemoveToolItem", GTK_STOCK_REMOVE, N_("_Remove from Toolbar"), NULL,
+ N_("Remove the selected item from the toolbar"), G_CALLBACK (remove_item_cb) },
+ { "RemoveToolbar", GTK_STOCK_DELETE, N_("_Delete Toolbar"), NULL,
+ N_("Remove the selected toolbar"), G_CALLBACK (remove_toolbar_cb) },
};
etoolbar->priv->manager = g_object_ref (manager);
etoolbar->priv->actions = gtk_action_group_new ("ToolbarActions");
- gtk_action_group_set_translation_domain (etoolbar->priv->actions,
- GETTEXT_PACKAGE);
+ gtk_action_group_set_translation_domain (etoolbar->priv->actions, GETTEXT_PACKAGE);
gtk_action_group_add_actions (etoolbar->priv->actions, actions,
- G_N_ELEMENTS (actions), etoolbar);
+ G_N_ELEMENTS (actions), etoolbar);
gtk_ui_manager_insert_action_group (manager, etoolbar->priv->actions, -1);
g_object_unref (etoolbar->priv->actions);
toolbar_visibility_refresh (etoolbar);
}
-GtkWidget *
-egg_editable_toolbar_get_selected (EggEditableToolbar * etoolbar)
+GtkWidget * egg_editable_toolbar_get_selected (EggEditableToolbar *etoolbar)
{
return etoolbar->priv->selected;
}
void
-egg_editable_toolbar_set_selected (EggEditableToolbar * etoolbar,
- GtkWidget * widget)
+egg_editable_toolbar_set_selected (EggEditableToolbar *etoolbar,
+ GtkWidget *widget)
{
GtkWidget *toolbar, *toolitem;
gboolean editable;
etoolbar->priv->selected = widget;
- toolbar =
- (widget != NULL) ? gtk_widget_get_ancestor (widget,
- GTK_TYPE_TOOLBAR) : NULL;
- toolitem =
- (widget != NULL) ? gtk_widget_get_ancestor (widget,
- GTK_TYPE_TOOL_ITEM) : NULL;
+ toolbar = (widget != NULL) ? gtk_widget_get_ancestor (widget, GTK_TYPE_TOOLBAR) : NULL;
+ toolitem = (widget != NULL) ? gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM) : NULL;
- if (toolbar != NULL)
+ if(toolbar != NULL)
{
gint tpos = get_toolbar_position (etoolbar, toolbar);
- editable =
- ((egg_toolbars_model_get_flags (etoolbar->priv->model, tpos) &
- EGG_TB_MODEL_NOT_EDITABLE) == 0);
+ editable = ((egg_toolbars_model_get_flags (etoolbar->priv->model, tpos) & EGG_TB_MODEL_NOT_EDITABLE) == 0);
}
else
{
editable = FALSE;
}
- gtk_action_set_visible (find_action (etoolbar, "RemoveToolbar"),
- (toolbar != NULL)
- && (etoolbar->priv->edit_mode > 0));
- gtk_action_set_visible (find_action (etoolbar, "RemoveToolItem"),
- (toolitem != NULL) && editable);
- gtk_action_set_visible (find_action (etoolbar, "MoveToolItem"),
- (toolitem != NULL) && editable);
+ gtk_action_set_visible (find_action (etoolbar, "RemoveToolbar"), (toolbar != NULL) && (etoolbar->priv->edit_mode > 0));
+ gtk_action_set_visible (find_action (etoolbar, "RemoveToolItem"), (toolitem != NULL) && editable);
+ gtk_action_set_visible (find_action (etoolbar, "MoveToolItem"), (toolitem != NULL) && editable);
}
static void
-set_edit_mode (EggEditableToolbar * etoolbar, gboolean mode)
+set_edit_mode (EggEditableToolbar *etoolbar,
+ gboolean mode)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
int i, l, n_items;
@@ -1487,52 +1467,51 @@ set_edit_mode (EggEditableToolbar * etoolbar, gboolean mode)
if (i == 0)
{
- for (i = get_n_toolbars (etoolbar) - 1; i >= 0; i--)
- {
- GtkWidget *toolbar;
+ for (i = get_n_toolbars (etoolbar)-1; i >= 0; i--)
+ {
+ GtkWidget *toolbar;
- toolbar = get_toolbar_nth (etoolbar, i);
- n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
+ toolbar = get_toolbar_nth (etoolbar, i);
+ n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
- if (n_items == 0 && priv->edit_mode == 0)
- {
- egg_toolbars_model_remove_toolbar (priv->model, i);
- }
- else
- {
- for (l = 0; l < n_items; l++)
- {
- GtkToolItem *item;
+ if (n_items == 0 && priv->edit_mode == 0)
+ {
+ egg_toolbars_model_remove_toolbar (priv->model, i);
+ }
+ else
+ {
+ for (l = 0; l < n_items; l++)
+ {
+ GtkToolItem *item;
- item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
+ item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
- configure_item_cursor (item, etoolbar);
- configure_item_sensitivity (item, etoolbar);
- }
- }
- }
+ configure_item_cursor (item, etoolbar);
+ configure_item_sensitivity (item, etoolbar);
+ }
+ }
+ }
}
}
static void
-egg_editable_toolbar_set_property (GObject * object,
- guint prop_id,
- const GValue * value, GParamSpec * pspec)
+egg_editable_toolbar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
switch (prop_id)
{
case PROP_UI_MANAGER:
- egg_editable_toolbar_set_ui_manager (etoolbar,
- g_value_get_object (value));
+ egg_editable_toolbar_set_ui_manager (etoolbar, g_value_get_object (value));
break;
case PROP_TOOLBARS_MODEL:
egg_editable_toolbar_set_model (etoolbar, g_value_get_object (value));
break;
case PROP_SELECTED:
- egg_editable_toolbar_set_selected (etoolbar,
- g_value_get_object (value));
+ egg_editable_toolbar_set_selected (etoolbar, g_value_get_object (value));
break;
case PROP_POPUP_PATH:
etoolbar->priv->popup_path = g_strdup (g_value_get_string (value));
@@ -1547,9 +1526,10 @@ egg_editable_toolbar_set_property (GObject * object,
}
static void
-egg_editable_toolbar_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec)
+egg_editable_toolbar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (object);
@@ -1565,7 +1545,7 @@ egg_editable_toolbar_get_property (GObject * object,
g_value_set_object (value, etoolbar->priv->selected);
break;
case PROP_EDIT_MODE:
- g_value_set_boolean (value, etoolbar->priv->edit_mode > 0);
+ g_value_set_boolean (value, etoolbar->priv->edit_mode>0);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1574,7 +1554,7 @@ egg_editable_toolbar_get_property (GObject * object,
}
static void
-egg_editable_toolbar_class_init (EggEditableToolbarClass * klass)
+egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1596,27 +1576,21 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass * klass)
"UI-Mmanager",
"UI Manager",
GTK_TYPE_UI_MANAGER,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_TOOLBARS_MODEL,
- g_param_spec_object ("model", "Model",
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class,
+ PROP_TOOLBARS_MODEL,
+ g_param_spec_object ("model",
+ "Model",
"Toolbars Model",
EGG_TYPE_TOOLBARS_MODEL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class, PROP_SELECTED,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (object_class,
+ PROP_SELECTED,
g_param_spec_object ("selected",
"Selected",
"Selected toolitem",
GTK_TYPE_TOOL_ITEM,
- G_PARAM_READABLE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_POPUP_PATH,
@@ -1624,10 +1598,7 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass * klass)
"popup-path",
"popup-path",
NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_EDIT_MODE,
@@ -1635,35 +1606,35 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass * klass)
"Edit-Mode",
"Edit Mode",
FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB));
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
g_type_class_add_private (object_class, sizeof (EggEditableToolbarPrivate));
}
GtkWidget *
-egg_editable_toolbar_new (GtkUIManager * manager, const char *popup_path)
+egg_editable_toolbar_new (GtkUIManager *manager,
+ const char *popup_path)
{
- return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
- "ui-manager", manager,
- "popup-path", popup_path, NULL));
+ return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
+ "ui-manager", manager,
+ "popup-path", popup_path,
+ NULL));
}
GtkWidget *
-egg_editable_toolbar_new_with_model (GtkUIManager * manager,
- EggToolbarsModel * model,
- const char *popup_path)
+egg_editable_toolbar_new_with_model (GtkUIManager *manager,
+ EggToolbarsModel *model,
+ const char *popup_path)
{
return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
- "ui-manager", manager,
- "model", model,
- "popup-path", popup_path, NULL));
+ "ui-manager", manager,
+ "model", model,
+ "popup-path", popup_path,
+ NULL));
}
gboolean
-egg_editable_toolbar_get_edit_mode (EggEditableToolbar * etoolbar)
+egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1671,7 +1642,7 @@ egg_editable_toolbar_get_edit_mode (EggEditableToolbar * etoolbar)
}
void
-egg_editable_toolbar_set_edit_mode (EggEditableToolbar * etoolbar,
+egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
gboolean mode)
{
set_edit_mode (etoolbar, mode);
@@ -1679,15 +1650,16 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar * etoolbar,
}
void
-egg_editable_toolbar_add_visibility (EggEditableToolbar * etoolbar,
+egg_editable_toolbar_add_visibility (EggEditableToolbar *etoolbar,
const char *path)
{
etoolbar->priv->visibility_paths = g_list_prepend
- (etoolbar->priv->visibility_paths, g_strdup (path));
+ (etoolbar->priv->visibility_paths, g_strdup (path));
}
void
-egg_editable_toolbar_show (EggEditableToolbar * etoolbar, const char *name)
+egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
+ const char *name)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
EggToolbarsModel *model = priv->model;
@@ -1700,14 +1672,15 @@ egg_editable_toolbar_show (EggEditableToolbar * etoolbar, const char *name)
toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
if (strcmp (toolbar_name, name) == 0)
- {
- gtk_widget_show (get_dock_nth (etoolbar, i));
- }
+ {
+ gtk_widget_show (get_dock_nth (etoolbar, i));
+ }
}
}
void
-egg_editable_toolbar_hide (EggEditableToolbar * etoolbar, const char *name)
+egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
+ const char *name)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
EggToolbarsModel *model = priv->model;
@@ -1720,15 +1693,15 @@ egg_editable_toolbar_hide (EggEditableToolbar * etoolbar, const char *name)
toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
if (strcmp (toolbar_name, name) == 0)
- {
- gtk_widget_hide (get_dock_nth (etoolbar, i));
- }
+ {
+ gtk_widget_hide (get_dock_nth (etoolbar, i));
+ }
}
}
void
-egg_editable_toolbar_set_fixed (EggEditableToolbar * etoolbar,
- GtkToolbar * toolbar)
+egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
+ GtkToolbar *toolbar)
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
@@ -1755,7 +1728,8 @@ egg_editable_toolbar_set_fixed (EggEditableToolbar * etoolbar,
#define DEFAULT_ICON_WIDTH 0
static void
-fake_expose_widget (GtkWidget * widget, GdkPixmap * pixmap)
+fake_expose_widget (GtkWidget *widget,
+ GdkPixmap *pixmap)
{
GdkWindow *tmp_window;
GdkEventExpose event;
@@ -1769,7 +1743,7 @@ fake_expose_widget (GtkWidget * widget, GdkPixmap * pixmap)
tmp_window = widget->window;
widget->window = pixmap;
- gtk_widget_send_expose (widget, (GdkEvent *) & event);
+ gtk_widget_send_expose (widget, (GdkEvent *) &event);
widget->window = tmp_window;
}
@@ -1779,7 +1753,7 @@ fake_expose_widget (GtkWidget * widget, GdkPixmap * pixmap)
* with large toolbar icons.
*/
static GdkPixbuf *
-new_pixbuf_from_widget (GtkWidget * widget)
+new_pixbuf_from_widget (GtkWidget *widget)
{
GtkWidget *window;
GdkPixbuf *pixbuf;
@@ -1795,9 +1769,10 @@ new_pixbuf_from_widget (GtkWidget * widget)
screen = gtk_widget_get_screen (widget);
- if (!gtk_icon_size_lookup_for_settings
- (gtk_settings_get_for_screen (screen), GTK_ICON_SIZE_LARGE_TOOLBAR,
- NULL, &icon_height))
+ if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ NULL,
+ &icon_height))
{
icon_height = DEFAULT_ICON_HEIGHT;
}
@@ -1816,7 +1791,7 @@ new_pixbuf_from_widget (GtkWidget * widget)
* This is needed mostly for pixmap based themes.
*/
gtk_window_set_default_size (GTK_WINDOW (window), icon_width, icon_height);
- gtk_window_get_size (GTK_WINDOW (window), &icon_width, &icon_height);
+ gtk_window_get_size (GTK_WINDOW (window),&icon_width, &icon_height);
gtk_widget_size_request (window, &requisition);
allocation.x = 0;
@@ -1829,8 +1804,7 @@ new_pixbuf_from_widget (GtkWidget * widget)
/* Create a pixmap */
visual = gtk_widget_get_visual (window);
pixmap = gdk_pixmap_new (NULL, icon_width, icon_height, visual->depth);
- gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap),
- gtk_widget_get_colormap (window));
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gtk_widget_get_colormap (window));
/* Draw the window */
gtk_widget_ensure_style (window);
@@ -1840,10 +1814,8 @@ new_pixbuf_from_widget (GtkWidget * widget)
fake_expose_widget (window, pixmap);
fake_expose_widget (widget, pixmap);
- pixbuf =
- gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
- gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width,
- icon_height);
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
+ gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width, icon_height);
gtk_widget_destroy (window);
@@ -1862,7 +1834,7 @@ new_separator_pixbuf (void)
}
static void
-update_separator_image (GtkImage * image)
+update_separator_image (GtkImage *image)
{
GdkPixbuf *pixbuf = new_separator_pixbuf ();
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
@@ -1870,7 +1842,9 @@ update_separator_image (GtkImage * image)
}
static gboolean
-style_set_cb (GtkWidget * widget, GtkStyle * previous_style, GtkImage * image)
+style_set_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ GtkImage *image)
{
update_separator_image (image);
@@ -1889,7 +1863,7 @@ _egg_editable_toolbar_new_separator_image (void)
}
EggToolbarsModel *
-egg_editable_toolbar_get_model (EggEditableToolbar * etoolbar)
+egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar)
{
return etoolbar->priv->model;
}
diff --git a/src/toolbareditor/egg-editable-toolbar.h b/src/toolbareditor/egg-editable-toolbar.h
index 29d9d91..12ce2aa 100644
--- a/src/toolbareditor/egg-editable-toolbar.h
+++ b/src/toolbareditor/egg-editable-toolbar.h
@@ -27,21 +27,23 @@
#include <gtk/gtk.h>
G_BEGIN_DECLS
+
#define EGG_TYPE_EDITABLE_TOOLBAR (egg_editable_toolbar_get_type ())
#define EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbar))
#define EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarClass))
#define EGG_IS_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_EDITABLE_TOOLBAR))
#define EGG_IS_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_EDITABLE_TOOLBAR))
#define EGG_EDITABLE_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarClass))
-typedef struct _EggEditableToolbar EggEditableToolbar;
+
+typedef struct _EggEditableToolbar EggEditableToolbar;
typedef struct _EggEditableToolbarPrivate EggEditableToolbarPrivate;
-typedef struct _EggEditableToolbarClass EggEditableToolbarClass;
+typedef struct _EggEditableToolbarClass EggEditableToolbarClass;
struct _EggEditableToolbar
{
GtkVBox parent_object;
- /*< private > */
+ /*< private >*/
EggEditableToolbarPrivate *priv;
};
@@ -49,42 +51,41 @@ struct _EggEditableToolbarClass
{
GtkVBoxClass parent_class;
- void (*action_request) (EggEditableToolbar * etoolbar,
- const char *action_name);
+ void (* action_request) (EggEditableToolbar *etoolbar,
+ const char *action_name);
};
-GType egg_editable_toolbar_get_type (void);
-GtkWidget *egg_editable_toolbar_new (GtkUIManager * manager,
- const char *visibility_path);
-GtkWidget *egg_editable_toolbar_new_with_model (GtkUIManager * manager,
- EggToolbarsModel * model,
- const char *visibility_path);
-void egg_editable_toolbar_set_model (EggEditableToolbar * etoolbar,
- EggToolbarsModel * model);
-EggToolbarsModel *egg_editable_toolbar_get_model (EggEditableToolbar *
- etoolbar);
-GtkUIManager *egg_editable_toolbar_get_manager (EggEditableToolbar *
- etoolbar);
-void egg_editable_toolbar_set_edit_mode (EggEditableToolbar * etoolbar,
- gboolean mode);
-gboolean egg_editable_toolbar_get_edit_mode (EggEditableToolbar * etoolbar);
-void egg_editable_toolbar_show (EggEditableToolbar * etoolbar,
- const char *name);
-void egg_editable_toolbar_hide (EggEditableToolbar * etoolbar,
- const char *name);
-void egg_editable_toolbar_set_fixed (EggEditableToolbar * etoolbar,
- GtkToolbar * fixed_toolbar);
-
-GtkWidget *egg_editable_toolbar_get_selected (EggEditableToolbar * etoolbar);
-void egg_editable_toolbar_set_selected (EggEditableToolbar * etoolbar,
- GtkWidget * widget);
-
-void egg_editable_toolbar_add_visibility (EggEditableToolbar * etoolbar,
- const char *path);
+GType egg_editable_toolbar_get_type (void);
+GtkWidget *egg_editable_toolbar_new (GtkUIManager *manager,
+ const char *visibility_path);
+GtkWidget *egg_editable_toolbar_new_with_model (GtkUIManager *manager,
+ EggToolbarsModel *model,
+ const char *visibility_path);
+void egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar,
+ EggToolbarsModel *model);
+EggToolbarsModel *egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar);
+GtkUIManager *egg_editable_toolbar_get_manager (EggEditableToolbar *etoolbar);
+void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
+ gboolean mode);
+gboolean egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar);
+void egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
+ const char *name);
+void egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
+ const char *name);
+void egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
+ GtkToolbar *fixed_toolbar);
+
+GtkWidget * egg_editable_toolbar_get_selected (EggEditableToolbar *etoolbar);
+void egg_editable_toolbar_set_selected (EggEditableToolbar *etoolbar,
+ GtkWidget *widget);
+
+void egg_editable_toolbar_add_visibility (EggEditableToolbar *etoolbar,
+ const char *path);
/* Private Functions */
-GtkWidget *_egg_editable_toolbar_new_separator_image (void);
+GtkWidget *_egg_editable_toolbar_new_separator_image (void);
G_END_DECLS
+
#endif
diff --git a/src/toolbareditor/egg-toolbar-editor.c b/src/toolbareditor/egg-toolbar-editor.c
index 4184703..1c375e5 100644
--- a/src/toolbareditor/egg-toolbar-editor.c
+++ b/src/toolbareditor/egg-toolbar-editor.c
@@ -37,8 +37,8 @@ static const GtkTargetEntry source_drag_types[] = {
};
-static void egg_toolbar_editor_finalize (GObject * object);
-static void update_editor_sheet (EggToolbarEditor * editor);
+static void egg_toolbar_editor_finalize (GObject *object);
+static void update_editor_sheet (EggToolbarEditor *editor);
enum
{
@@ -52,7 +52,7 @@ enum
SIGNAL_HANDLER_ITEM_ADDED,
SIGNAL_HANDLER_ITEM_REMOVED,
SIGNAL_HANDLER_TOOLBAR_REMOVED,
- SIGNAL_HANDLER_LIST_SIZE /* Array size */
+ SIGNAL_HANDLER_LIST_SIZE /* Array size */
};
#define EGG_TOOLBAR_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditorPrivate))
@@ -64,31 +64,33 @@ struct EggToolbarEditorPrivate
GtkWidget *table;
GtkWidget *scrolled_window;
- GList *actions_list;
- GList *factory_list;
+ GList *actions_list;
+ GList *factory_list;
/* These handlers need to be sanely disconnected when switching models */
- gulong sig_handlers[SIGNAL_HANDLER_LIST_SIZE];
+ gulong sig_handlers[SIGNAL_HANDLER_LIST_SIZE];
};
G_DEFINE_TYPE (EggToolbarEditor, egg_toolbar_editor, GTK_TYPE_VBOX);
static gint
-compare_items (gconstpointer a, gconstpointer b)
+compare_items (gconstpointer a,
+ gconstpointer b)
{
const GtkWidget *item1 = a;
const GtkWidget *item2 = b;
char *key1 = g_object_get_data (G_OBJECT (item1),
- "egg-collate-key");
+ "egg-collate-key");
char *key2 = g_object_get_data (G_OBJECT (item2),
- "egg-collate-key");
+ "egg-collate-key");
return strcmp (key1, key2);
}
static GtkAction *
-find_action (EggToolbarEditor * t, const char *name)
+find_action (EggToolbarEditor *t,
+ const char *name)
{
GList *l;
GtkAction *action = NULL;
@@ -111,8 +113,8 @@ find_action (EggToolbarEditor * t, const char *name)
}
static void
-egg_toolbar_editor_set_ui_manager (EggToolbarEditor * t,
- GtkUIManager * manager)
+egg_toolbar_editor_set_ui_manager (EggToolbarEditor *t,
+ GtkUIManager *manager)
{
g_return_if_fail (GTK_IS_UI_MANAGER (manager));
@@ -120,21 +122,24 @@ egg_toolbar_editor_set_ui_manager (EggToolbarEditor * t,
}
static void
-item_added_or_removed_cb (EggToolbarsModel * model,
- int tpos, int ipos, EggToolbarEditor * editor)
+item_added_or_removed_cb (EggToolbarsModel *model,
+ int tpos,
+ int ipos,
+ EggToolbarEditor *editor)
{
update_editor_sheet (editor);
}
static void
-toolbar_removed_cb (EggToolbarsModel * model,
- int position, EggToolbarEditor * editor)
+toolbar_removed_cb (EggToolbarsModel *model,
+ int position,
+ EggToolbarEditor *editor)
{
update_editor_sheet (editor);
}
static void
-egg_toolbar_editor_disconnect_model (EggToolbarEditor * t)
+egg_toolbar_editor_disconnect_model (EggToolbarEditor *t)
{
EggToolbarEditorPrivate *priv = t->priv;
EggToolbarsModel *model = priv->model;
@@ -146,19 +151,20 @@ egg_toolbar_editor_disconnect_model (EggToolbarEditor * t)
handler = priv->sig_handlers[i];
if (handler != 0)
- {
+ {
if (g_signal_handler_is_connected (model, handler))
{
g_signal_handler_disconnect (model, handler);
}
priv->sig_handlers[i] = 0;
- }
+ }
}
}
void
-egg_toolbar_editor_set_model (EggToolbarEditor * t, EggToolbarsModel * model)
+egg_toolbar_editor_set_model (EggToolbarEditor *t,
+ EggToolbarsModel *model)
{
EggToolbarEditorPrivate *priv;
@@ -169,8 +175,7 @@ egg_toolbar_editor_set_model (EggToolbarEditor * t, EggToolbarsModel * model)
if (priv->model)
{
- if (G_UNLIKELY (priv->model == model))
- return;
+ if (G_UNLIKELY (priv->model == model)) return;
egg_toolbar_editor_disconnect_model (t);
g_object_unref (priv->model);
@@ -192,9 +197,10 @@ egg_toolbar_editor_set_model (EggToolbarEditor * t, EggToolbarsModel * model)
}
static void
-egg_toolbar_editor_set_property (GObject * object,
- guint prop_id,
- const GValue * value, GParamSpec * pspec)
+egg_toolbar_editor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
@@ -210,9 +216,10 @@ egg_toolbar_editor_set_property (GObject * object,
}
static void
-egg_toolbar_editor_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec)
+egg_toolbar_editor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
@@ -228,7 +235,7 @@ egg_toolbar_editor_get_property (GObject * object,
}
static void
-egg_toolbar_editor_class_init (EggToolbarEditorClass * klass)
+egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -242,26 +249,22 @@ egg_toolbar_editor_class_init (EggToolbarEditorClass * klass)
"UI-Manager",
"UI Manager",
GTK_TYPE_UI_MANAGER,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB |
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_TOOLBARS_MODEL,
- g_param_spec_object ("model", "Model",
- "Toolbars Model",
- EGG_TYPE_TOOLBARS_MODEL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME |
- G_PARAM_STATIC_NICK |
- G_PARAM_STATIC_BLURB |
- G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class,
+ PROP_TOOLBARS_MODEL,
+ g_param_spec_object ("model",
+ "Model",
+ "Toolbars Model",
+ EGG_TYPE_TOOLBARS_MODEL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
+ G_PARAM_CONSTRUCT));
g_type_class_add_private (object_class, sizeof (EggToolbarEditorPrivate));
}
static void
-egg_toolbar_editor_finalize (GObject * object)
+egg_toolbar_editor_finalize (GObject *object)
{
EggToolbarEditor *editor = EGG_TOOLBAR_EDITOR (object);
@@ -283,30 +286,36 @@ egg_toolbar_editor_finalize (GObject * object)
}
GtkWidget *
-egg_toolbar_editor_new (GtkUIManager * manager, EggToolbarsModel * model)
+egg_toolbar_editor_new (GtkUIManager *manager,
+ EggToolbarsModel *model)
{
return GTK_WIDGET (g_object_new (EGG_TYPE_TOOLBAR_EDITOR,
"ui-manager", manager,
- "model", model, NULL));
+ "model", model,
+ NULL));
}
static void
-drag_begin_cb (GtkWidget * widget, GdkDragContext * context)
+drag_begin_cb (GtkWidget *widget,
+ GdkDragContext *context)
{
gtk_widget_hide (widget);
}
static void
-drag_end_cb (GtkWidget * widget, GdkDragContext * context)
+drag_end_cb (GtkWidget *widget,
+ GdkDragContext *context)
{
gtk_widget_show (widget);
}
static void
-drag_data_get_cb (GtkWidget * widget,
- GdkDragContext * context,
- GtkSelectionData * selection_data,
- guint info, guint32 time, EggToolbarEditor * editor)
+drag_data_get_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ EggToolbarEditor *editor)
{
const char *target;
@@ -318,7 +327,7 @@ drag_data_get_cb (GtkWidget * widget,
}
static gchar *
-elide_underscores (const gchar * original)
+elide_underscores (const gchar *original)
{
gchar *q, *result;
const gchar *p;
@@ -344,7 +353,7 @@ elide_underscores (const gchar * original)
}
static void
-set_drag_cursor (GtkWidget * widget)
+set_drag_cursor (GtkWidget *widget)
{
GdkCursor *cursor;
GdkScreen *screen;
@@ -358,7 +367,7 @@ set_drag_cursor (GtkWidget * widget)
}
static void
-event_box_realize_cb (GtkWidget * widget, GtkImage * icon)
+event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
{
GtkImageType type;
@@ -372,7 +381,7 @@ event_box_realize_cb (GtkWidget * widget, GtkImage * icon)
gtk_image_get_stock (icon, &stock_id, NULL);
pixbuf = gtk_widget_render_icon (widget, stock_id,
- GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
+ GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
g_object_unref (pixbuf);
}
@@ -391,16 +400,16 @@ event_box_realize_cb (GtkWidget * widget, GtkImage * icon)
settings = gtk_settings_get_for_screen (screen);
if (!gtk_icon_size_lookup_for_settings (settings,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
&width, &height))
- {
+ {
width = height = 24;
}
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
- MIN (width, height), 0, NULL);
+ MIN (width, height), 0, NULL);
if (G_UNLIKELY (!pixbuf))
- return;
+ return;
gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
g_object_unref (pixbuf);
@@ -414,9 +423,10 @@ event_box_realize_cb (GtkWidget * widget, GtkImage * icon)
}
static GtkWidget *
-editor_create_item (EggToolbarEditor * editor,
- GtkImage * icon,
- const char *label_text, GdkDragAction action)
+editor_create_item (EggToolbarEditor *editor,
+ GtkImage *icon,
+ const char *label_text,
+ GdkDragAction action)
{
GtkWidget *event_box;
GtkWidget *vbox;
@@ -428,19 +438,18 @@ editor_create_item (EggToolbarEditor * editor,
gtk_widget_show (event_box);
gtk_drag_source_set (event_box,
GDK_BUTTON1_MASK,
- source_drag_types, G_N_ELEMENTS (source_drag_types),
- action);
- g_signal_connect (event_box, "drag_data_get", G_CALLBACK (drag_data_get_cb),
- editor);
+ source_drag_types, G_N_ELEMENTS (source_drag_types), action);
+ g_signal_connect (event_box, "drag_data_get",
+ G_CALLBACK (drag_data_get_cb), editor);
g_signal_connect_after (event_box, "realize",
- G_CALLBACK (event_box_realize_cb), icon);
+ G_CALLBACK (event_box_realize_cb), icon);
if (action == GDK_ACTION_MOVE)
{
g_signal_connect (event_box, "drag_begin",
- G_CALLBACK (drag_begin_cb), NULL);
+ G_CALLBACK (drag_begin_cb), NULL);
g_signal_connect (event_box, "drag_end",
- G_CALLBACK (drag_end_cb), NULL);
+ G_CALLBACK (drag_end_cb), NULL);
}
vbox = gtk_vbox_new (0, FALSE);
@@ -459,8 +468,9 @@ editor_create_item (EggToolbarEditor * editor,
}
static GtkWidget *
-editor_create_item_from_name (EggToolbarEditor * editor,
- const char *name, GdkDragAction drag_action)
+editor_create_item_from_name (EggToolbarEditor *editor,
+ const char * name,
+ GdkDragAction drag_action)
{
GtkWidget *item;
const char *item_name;
@@ -476,7 +486,7 @@ editor_create_item_from_name (EggToolbarEditor * editor,
item_name = g_strdup (name);
collate_key = g_utf8_collate_key (short_label, -1);
item = editor_create_item (editor, GTK_IMAGE (icon),
- short_label, drag_action);
+ short_label, drag_action);
}
else
{
@@ -488,21 +498,23 @@ editor_create_item_from_name (EggToolbarEditor * editor,
g_return_val_if_fail (action != NULL, NULL);
g_object_get (action,
- "icon-name", &icon_name,
- "stock-id", &stock_id, "short-label", &short_label, NULL);
+ "icon-name", &icon_name,
+ "stock-id", &stock_id,
+ "short-label", &short_label,
+ NULL);
/* This is a workaround to catch named icons. */
if (icon_name)
- icon = gtk_image_new_from_icon_name (icon_name,
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ icon = gtk_image_new_from_icon_name (icon_name,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
else
- icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
- GTK_ICON_SIZE_LARGE_TOOLBAR);
+ icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
item_name = g_strdup (name);
collate_key = g_utf8_collate_key (short_label, -1);
item = editor_create_item (editor, GTK_IMAGE (icon),
- short_label, drag_action);
+ short_label, drag_action);
g_free (short_label);
g_free (stock_id);
@@ -510,15 +522,15 @@ editor_create_item_from_name (EggToolbarEditor * editor,
}
g_object_set_data_full (G_OBJECT (item), "egg-collate-key",
- (gpointer) collate_key, g_free);
+ (gpointer) collate_key, g_free);
g_object_set_data_full (G_OBJECT (item), "egg-item-name",
- (gpointer) item_name, g_free);
+ (gpointer) item_name, g_free);
return item;
}
static gint
-append_table (GtkTable * table, GList * items, gint y, gint width)
+append_table (GtkTable *table, GList *items, gint y, gint width)
{
if (items != NULL)
{
@@ -530,33 +542,32 @@ append_table (GtkTable * table, GList * items, gint y, gint width)
gtk_table_resize (table, height, width);
if (y > 0)
- {
- item = gtk_hseparator_new ();
- alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), item);
- gtk_widget_show (alignment);
- gtk_widget_show (item);
-
- gtk_table_attach_defaults (table, alignment, 0, width, y - 1,
- y + 1);
- }
+ {
+ item = gtk_hseparator_new ();
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), item);
+ gtk_widget_show (alignment);
+ gtk_widget_show (item);
- for (; items != NULL; items = items->next)
- {
- item = items->data;
- alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), item);
- gtk_widget_show (alignment);
- gtk_widget_show (item);
+ gtk_table_attach_defaults (table, alignment, 0, width, y-1, y+1);
+ }
- if (x >= width)
- {
- x = 0;
- y++;
- }
- gtk_table_attach_defaults (table, alignment, x, x + 1, y, y + 1);
- x++;
- }
+ for (; items != NULL; items = items->next)
+ {
+ item = items->data;
+ alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), item);
+ gtk_widget_show (alignment);
+ gtk_widget_show (item);
+
+ if (x >= width)
+ {
+ x = 0;
+ y++;
+ }
+ gtk_table_attach_defaults (table, alignment, x, x+1, y, y+1);
+ x++;
+ }
y++;
}
@@ -564,7 +575,7 @@ append_table (GtkTable * table, GList * items, gint y, gint width)
}
static void
-update_editor_sheet (EggToolbarEditor * editor)
+update_editor_sheet (EggToolbarEditor *editor)
{
gint y;
GPtrArray *items;
@@ -582,7 +593,7 @@ update_editor_sheet (EggToolbarEditor * editor)
gtk_widget_show (table);
gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL,
dest_drag_types, G_N_ELEMENTS (dest_drag_types),
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
/* Build two lists of items (one for copying, one for moving). */
items = egg_toolbars_model_get_name_avail (editor->priv->model);
@@ -597,17 +608,17 @@ update_editor_sheet (EggToolbarEditor * editor)
flags = egg_toolbars_model_get_name_flags (editor->priv->model, name);
if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
- {
- item = editor_create_item_from_name (editor, name, GDK_ACTION_MOVE);
- if (item != NULL)
- to_move = g_list_insert_sorted (to_move, item, compare_items);
- }
+ {
+ item = editor_create_item_from_name (editor, name, GDK_ACTION_MOVE);
+ if (item != NULL)
+ to_move = g_list_insert_sorted (to_move, item, compare_items);
+ }
else
- {
- item = editor_create_item_from_name (editor, name, GDK_ACTION_COPY);
- if (item != NULL)
- to_copy = g_list_insert_sorted (to_copy, item, compare_items);
- }
+ {
+ item = editor_create_item_from_name (editor, name, GDK_ACTION_COPY);
+ if (item != NULL)
+ to_copy = g_list_insert_sorted (to_copy, item, compare_items);
+ }
}
/* Add them to the sheet. */
@@ -624,7 +635,7 @@ update_editor_sheet (EggToolbarEditor * editor)
if (viewport)
{
gtk_container_remove (GTK_CONTAINER (viewport),
- GTK_BIN (viewport)->child);
+ GTK_BIN (viewport)->child);
}
/* Add table to window. */
@@ -634,7 +645,7 @@ update_editor_sheet (EggToolbarEditor * editor)
}
static void
-setup_editor (EggToolbarEditor * editor)
+setup_editor (EggToolbarEditor *editor)
{
GtkWidget *scrolled_window;
@@ -648,7 +659,7 @@ setup_editor (EggToolbarEditor * editor)
}
static void
-egg_toolbar_editor_init (EggToolbarEditor * t)
+egg_toolbar_editor_init (EggToolbarEditor *t)
{
t->priv = EGG_TOOLBAR_EDITOR_GET_PRIVATE (t);
@@ -657,3 +668,4 @@ egg_toolbar_editor_init (EggToolbarEditor * t)
setup_editor (t);
}
+
diff --git a/src/toolbareditor/egg-toolbar-editor.h b/src/toolbareditor/egg-toolbar-editor.h
index 1784f4c..ba6e1a9 100644
--- a/src/toolbareditor/egg-toolbar-editor.h
+++ b/src/toolbareditor/egg-toolbar-editor.h
@@ -23,7 +23,9 @@
#include "egg-toolbars-model.h"
-G_BEGIN_DECLS typedef struct EggToolbarEditorClass EggToolbarEditorClass;
+G_BEGIN_DECLS
+
+typedef struct EggToolbarEditorClass EggToolbarEditorClass;
#define EGG_TYPE_TOOLBAR_EDITOR (egg_toolbar_editor_get_type ())
#define EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditor))
@@ -40,7 +42,7 @@ struct EggToolbarEditor
{
GtkVBox parent_object;
- /*< private > */
+ /*< private >*/
EggToolbarEditorPrivate *priv;
};
@@ -50,11 +52,12 @@ struct EggToolbarEditorClass
};
-GType egg_toolbar_editor_get_type (void);
-GtkWidget *egg_toolbar_editor_new (GtkUIManager * manager,
- EggToolbarsModel * model);
-void egg_toolbar_editor_set_model (EggToolbarEditor * t,
- EggToolbarsModel * model);
+GType egg_toolbar_editor_get_type (void);
+GtkWidget *egg_toolbar_editor_new (GtkUIManager *manager,
+ EggToolbarsModel *model);
+void egg_toolbar_editor_set_model (EggToolbarEditor *t,
+ EggToolbarsModel *model);
G_END_DECLS
+
#endif
diff --git a/src/toolbareditor/egg-toolbars-model.c b/src/toolbareditor/egg-toolbars-model.c
index 6c10a6a..c2e8c17 100644
--- a/src/toolbareditor/egg-toolbars-model.c
+++ b/src/toolbareditor/egg-toolbars-model.c
@@ -30,7 +30,7 @@
#include <libxml/tree.h>
#include <gdk/gdk.h>
-static void egg_toolbars_model_finalize (GObject * object);
+static void egg_toolbars_model_finalize (GObject *object);
enum
{
@@ -65,7 +65,9 @@ struct EggToolbarsModelPrivate
};
G_DEFINE_TYPE (EggToolbarsModel, egg_toolbars_model, G_TYPE_OBJECT)
- static xmlDocPtr egg_toolbars_model_to_xml (EggToolbarsModel * model)
+
+static xmlDocPtr
+egg_toolbars_model_to_xml (EggToolbarsModel *model)
{
GNode *l1, *l2, *tl;
GList *l3;
@@ -76,70 +78,56 @@ G_DEFINE_TYPE (EggToolbarsModel, egg_toolbars_model, G_TYPE_OBJECT)
tl = model->priv->toolbars;
xmlIndentTreeOutput = TRUE;
- doc = xmlNewDoc ((const xmlChar *) "1.0");
- doc->children =
- xmlNewDocNode (doc, NULL, (const xmlChar *) "toolbars", NULL);
+ doc = xmlNewDoc ((const xmlChar*) "1.0");
+ doc->children = xmlNewDocNode (doc, NULL, (const xmlChar*) "toolbars", NULL);
for (l1 = tl->children; l1 != NULL; l1 = l1->next)
{
xmlNodePtr tnode;
EggToolbarsToolbar *toolbar = l1->data;
- tnode =
- xmlNewChild (doc->children, NULL, (const xmlChar *) "toolbar", NULL);
- xmlSetProp (tnode, (const xmlChar *) "name",
- (const xmlChar *) toolbar->name);
- xmlSetProp (tnode, (const xmlChar *) "hidden",
- (toolbar->
- flags & EGG_TB_MODEL_HIDDEN) ? (const xmlChar *) "true"
- : (const xmlChar *) "false");
- xmlSetProp (tnode, (const xmlChar *) "editable",
- (toolbar->
- flags & EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar *)
- "false" : (const xmlChar *) "true");
+ tnode = xmlNewChild (doc->children, NULL, (const xmlChar*) "toolbar", NULL);
+ xmlSetProp (tnode, (const xmlChar*) "name", (const xmlChar*) toolbar->name);
+ xmlSetProp (tnode, (const xmlChar*) "hidden",
+ (toolbar->flags&EGG_TB_MODEL_HIDDEN) ? (const xmlChar*) "true" : (const xmlChar*) "false");
+ xmlSetProp (tnode, (const xmlChar*) "editable",
+ (toolbar->flags&EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar*) "false" : (const xmlChar*) "true");
for (l2 = l1->children; l2 != NULL; l2 = l2->next)
{
xmlNodePtr node;
EggToolbarsItem *item = l2->data;
- if (strcmp (item->name, "_separator") == 0)
- {
- node =
- xmlNewChild (tnode, NULL, (const xmlChar *) "separator",
- NULL);
- continue;
- }
-
- node =
- xmlNewChild (tnode, NULL, (const xmlChar *) "toolitem", NULL);
- xmlSetProp (node, (const xmlChar *) "name",
- (const xmlChar *) item->name);
-
- /* Add 'data' nodes for each data type which can be written out for this
- * item. Only write types which can be used to restore the data. */
- for (l3 = model->priv->types; l3 != NULL; l3 = l3->next)
- {
- EggToolbarsItemType *type = l3->data;
- if (type->get_name != NULL && type->get_data != NULL)
- {
- xmlNodePtr dnode;
- char *tmp;
-
- tmp = type->get_data (type, item->name);
- if (tmp != NULL)
- {
- dnode =
- xmlNewTextChild (node, NULL, (const xmlChar *) "data",
- (const xmlChar *) tmp);
- g_free (tmp);
-
- tmp = gdk_atom_name (type->type);
- xmlSetProp (dnode, (const xmlChar *) "type",
- (const xmlChar *) tmp);
- g_free (tmp);
- }
- }
+ if (strcmp (item->name, "_separator") == 0)
+ {
+ node = xmlNewChild (tnode, NULL, (const xmlChar*) "separator", NULL);
+ continue;
+ }
+
+ node = xmlNewChild (tnode, NULL, (const xmlChar*) "toolitem", NULL);
+ xmlSetProp (node, (const xmlChar*) "name", (const xmlChar*) item->name);
+
+ /* Add 'data' nodes for each data type which can be written out for this
+ * item. Only write types which can be used to restore the data. */
+ for (l3 = model->priv->types; l3 != NULL; l3 = l3->next)
+ {
+ EggToolbarsItemType *type = l3->data;
+ if (type->get_name != NULL && type->get_data != NULL)
+ {
+ xmlNodePtr dnode;
+ char *tmp;
+
+ tmp = type->get_data (type, item->name);
+ if (tmp != NULL)
+ {
+ dnode = xmlNewTextChild (node, NULL, (const xmlChar*) "data", (const xmlChar*) tmp);
+ g_free (tmp);
+
+ tmp = gdk_atom_name (type->type);
+ xmlSetProp (dnode, (const xmlChar*) "type", (const xmlChar*) tmp);
+ g_free (tmp);
+ }
+ }
}
}
}
@@ -150,62 +138,63 @@ G_DEFINE_TYPE (EggToolbarsModel, egg_toolbars_model, G_TYPE_OBJECT)
static gboolean
safe_save_xml (const char *xml_file, xmlDocPtr doc)
{
- char *tmp_file;
- char *old_file;
- gboolean old_exist;
- gboolean retval = TRUE;
+ char *tmp_file;
+ char *old_file;
+ gboolean old_exist;
+ gboolean retval = TRUE;
- tmp_file = g_strconcat (xml_file, ".tmp", NULL);
- old_file = g_strconcat (xml_file, ".old", NULL);
+ tmp_file = g_strconcat (xml_file, ".tmp", NULL);
+ old_file = g_strconcat (xml_file, ".old", NULL);
- if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
- {
- g_warning ("Failed to write XML data to %s", tmp_file);
- goto failed;
- }
+ if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
+ {
+ g_warning ("Failed to write XML data to %s", tmp_file);
+ goto failed;
+ }
- old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
+ old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
- if (old_exist)
- {
- if (rename (xml_file, old_file) < 0)
+ if (old_exist)
{
- g_warning ("Failed to rename %s to %s", xml_file, old_file);
- retval = FALSE;
- goto failed;
+ if (rename (xml_file, old_file) < 0)
+ {
+ g_warning ("Failed to rename %s to %s", xml_file, old_file);
+ retval = FALSE;
+ goto failed;
+ }
}
- }
- if (rename (tmp_file, xml_file) < 0)
- {
- g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
-
- if (rename (old_file, xml_file) < 0)
+ if (rename (tmp_file, xml_file) < 0)
{
- g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
+ g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
+
+ if (rename (old_file, xml_file) < 0)
+ {
+ g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
+ }
+ retval = FALSE;
+ goto failed;
}
- retval = FALSE;
- goto failed;
- }
- if (old_exist)
- {
- if (unlink (old_file) < 0)
+ if (old_exist)
{
- g_warning ("Failed to delete old file %s", old_file);
+ if (unlink (old_file) < 0)
+ {
+ g_warning ("Failed to delete old file %s", old_file);
+ }
}
- }
-failed:
- g_free (old_file);
- g_free (tmp_file);
+ failed:
+ g_free (old_file);
+ g_free (tmp_file);
- return retval;
+ return retval;
}
void
-egg_toolbars_model_save_toolbars (EggToolbarsModel * model,
- const char *xml_file, const char *version)
+egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
+ const char *xml_file,
+ const char *version)
{
xmlDocPtr doc;
xmlNodePtr root;
@@ -214,24 +203,25 @@ egg_toolbars_model_save_toolbars (EggToolbarsModel * model,
doc = egg_toolbars_model_to_xml (model);
root = xmlDocGetRootElement (doc);
- xmlSetProp (root, (const xmlChar *) "version", (const xmlChar *) version);
+ xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) version);
safe_save_xml (xml_file, doc);
xmlFreeDoc (doc);
}
static gboolean
-is_unique (EggToolbarsModel * model, EggToolbarsItem * idata)
+is_unique (EggToolbarsModel *model,
+ EggToolbarsItem *idata)
{
EggToolbarsItem *idata2;
GNode *toolbar, *item;
- for (toolbar = g_node_first_child (model->priv->toolbars);
- toolbar != NULL; toolbar = g_node_next_sibling (toolbar))
+ for(toolbar = g_node_first_child (model->priv->toolbars);
+ toolbar != NULL; toolbar = g_node_next_sibling (toolbar))
{
- for (item = g_node_first_child (toolbar);
- item != NULL; item = g_node_next_sibling (item))
- {
+ for(item = g_node_first_child (toolbar);
+ item != NULL; item = g_node_next_sibling (item))
+ {
idata2 = item->data;
if (idata != idata2 && strcmp (idata->name, idata2->name) == 0)
@@ -257,7 +247,7 @@ toolbar_node_new (const char *name)
}
static GNode *
-item_node_new (const char *name, EggToolbarsModel * model)
+item_node_new (const char *name, EggToolbarsModel *model)
{
EggToolbarsItem *item;
int flags;
@@ -267,8 +257,7 @@ item_node_new (const char *name, EggToolbarsModel * model)
item = g_new (EggToolbarsItem, 1);
item->name = g_strdup (name);
- flags =
- GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
+ flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
g_hash_table_insert (model->priv->flags,
g_strdup (item->name),
@@ -278,13 +267,12 @@ item_node_new (const char *name, EggToolbarsModel * model)
}
static void
-item_node_free (GNode * item_node, EggToolbarsModel * model)
+item_node_free (GNode *item_node, EggToolbarsModel *model)
{
EggToolbarsItem *item = item_node->data;
int flags;
- flags =
- GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
+ flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name));
if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0 && is_unique (model, item))
g_hash_table_insert (model->priv->flags,
g_strdup (item->name),
@@ -297,12 +285,12 @@ item_node_free (GNode * item_node, EggToolbarsModel * model)
}
static void
-toolbar_node_free (GNode * toolbar_node, EggToolbarsModel * model)
+toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
{
EggToolbarsToolbar *toolbar = toolbar_node->data;
g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
- (GNodeForeachFunc) item_node_free, model);
+ (GNodeForeachFunc) item_node_free, model);
g_free (toolbar->name);
g_free (toolbar);
@@ -311,7 +299,8 @@ toolbar_node_free (GNode * toolbar_node, EggToolbarsModel * model)
}
EggTbModelFlags
-egg_toolbars_model_get_flags (EggToolbarsModel * model, int toolbar_position)
+egg_toolbars_model_get_flags (EggToolbarsModel *model,
+ int toolbar_position)
{
GNode *toolbar_node;
EggToolbarsToolbar *toolbar;
@@ -325,8 +314,9 @@ egg_toolbars_model_get_flags (EggToolbarsModel * model, int toolbar_position)
}
void
-egg_toolbars_model_set_flags (EggToolbarsModel * model,
- int toolbar_position, EggTbModelFlags flags)
+egg_toolbars_model_set_flags (EggToolbarsModel *model,
+ int toolbar_position,
+ EggTbModelFlags flags)
{
GNode *toolbar_node;
EggToolbarsToolbar *toolbar;
@@ -344,18 +334,18 @@ egg_toolbars_model_set_flags (EggToolbarsModel * model,
char *
-egg_toolbars_model_get_data (EggToolbarsModel * model,
- GdkAtom type, const char *name)
+egg_toolbars_model_get_data (EggToolbarsModel *model,
+ GdkAtom type,
+ const char *name)
{
EggToolbarsItemType *t;
char *data = NULL;
GList *l;
- if (type == GDK_NONE
- || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
+ if (type == GDK_NONE || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
{
g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (*name != 0, NULL);
+ g_return_val_if_fail (*name != 0, NULL);
return strdup (name);
}
@@ -363,26 +353,26 @@ egg_toolbars_model_get_data (EggToolbarsModel * model,
{
t = l->data;
if (t->type == type && t->get_data != NULL)
- {
- data = t->get_data (t, name);
- if (data != NULL)
- break;
- }
+ {
+ data = t->get_data (t, name);
+ if (data != NULL) break;
+ }
}
return data;
}
char *
-egg_toolbars_model_get_name (EggToolbarsModel * model,
- GdkAtom type, const char *data, gboolean create)
+egg_toolbars_model_get_name (EggToolbarsModel *model,
+ GdkAtom type,
+ const char *data,
+ gboolean create)
{
EggToolbarsItemType *t;
char *name = NULL;
GList *l;
- if (type == GDK_NONE
- || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
+ if (type == GDK_NONE || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
{
g_return_val_if_fail (data, NULL);
g_return_val_if_fail (*data, NULL);
@@ -392,30 +382,32 @@ egg_toolbars_model_get_name (EggToolbarsModel * model,
if (create)
{
for (l = model->priv->types; name == NULL && l != NULL; l = l->next)
- {
- t = l->data;
- if (t->type == type && t->new_name != NULL)
- name = t->new_name (t, data);
- }
+ {
+ t = l->data;
+ if (t->type == type && t->new_name != NULL)
+ name = t->new_name (t, data);
+ }
return name;
}
else
{
for (l = model->priv->types; name == NULL && l != NULL; l = l->next)
- {
- t = l->data;
- if (t->type == type && t->get_name != NULL)
- name = t->get_name (t, data);
- }
+ {
+ t = l->data;
+ if (t->type == type && t->get_name != NULL)
+ name = t->get_name (t, data);
+ }
return name;
}
}
static gboolean
-impl_add_item (EggToolbarsModel * model,
- int toolbar_position, int position, const char *name)
+impl_add_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ const char *name)
{
GNode *parent_node;
GNode *child_node;
@@ -437,17 +429,19 @@ impl_add_item (EggToolbarsModel * model,
}
gboolean
-egg_toolbars_model_add_item (EggToolbarsModel * model,
- int toolbar_position,
- int position, const char *name)
+egg_toolbars_model_add_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ const char *name)
{
EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (model);
return klass->add_item (model, toolbar_position, position, name);
}
int
-egg_toolbars_model_add_toolbar (EggToolbarsModel * model,
- int position, const char *name)
+egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
+ int position,
+ const char *name)
{
GNode *node;
int real_position;
@@ -459,33 +453,34 @@ egg_toolbars_model_add_toolbar (EggToolbarsModel * model,
real_position = g_node_child_position (model->priv->toolbars, node);
- g_signal_emit (G_OBJECT (model), signals[TOOLBAR_ADDED], 0, real_position);
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_ADDED],
+ 0, real_position);
return g_node_child_position (model->priv->toolbars, node);
}
static char *
-parse_data_list (EggToolbarsModel * model, xmlNodePtr child, gboolean create)
+parse_data_list (EggToolbarsModel *model,
+ xmlNodePtr child,
+ gboolean create)
{
char *name = NULL;
while (child && name == NULL)
{
- if (xmlStrEqual (child->name, (const xmlChar *) "data"))
- {
- xmlChar *type = xmlGetProp (child, (const xmlChar *) "type");
- xmlChar *data = xmlNodeGetContent (child);
+ if (xmlStrEqual (child->name, (const xmlChar*) "data"))
+ {
+ xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
+ xmlChar *data = xmlNodeGetContent (child);
- if (type != NULL)
- {
- GdkAtom atom = gdk_atom_intern ((const char *) type, TRUE);
- name =
- egg_toolbars_model_get_name (model, atom, (const char *) data,
- create);
- }
+ if (type != NULL)
+ {
+ GdkAtom atom = gdk_atom_intern ((const char*) type, TRUE);
+ name = egg_toolbars_model_get_name (model, atom, (const char*) data, create);
+ }
- xmlFree (type);
- xmlFree (data);
- }
+ xmlFree (type);
+ xmlFree (data);
+ }
child = child->next;
}
@@ -494,54 +489,51 @@ parse_data_list (EggToolbarsModel * model, xmlNodePtr child, gboolean create)
}
static void
-parse_item_list (EggToolbarsModel * model, xmlNodePtr child, int position)
+parse_item_list (EggToolbarsModel *model,
+ xmlNodePtr child,
+ int position)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar *) "toolitem"))
+ if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
{
- char *name;
-
- /* Try to get the name using the data elements first,
- as they are more 'portable' or 'persistent'. */
- name = parse_data_list (model, child->children, FALSE);
- if (name == NULL)
- {
- name = parse_data_list (model, child->children, TRUE);
- }
-
- /* If that fails, try to use the name. */
- if (name == NULL)
- {
- xmlChar *type = xmlGetProp (child, (const xmlChar *) "type");
- xmlChar *data = xmlGetProp (child, (const xmlChar *) "name");
- GdkAtom atom =
- type ? gdk_atom_intern ((const char *) type, TRUE) : GDK_NONE;
-
- /* If an old format, try to use it. */
- name =
- egg_toolbars_model_get_name (model, atom, (const char *) data,
- FALSE);
- if (name == NULL)
- {
- name =
- egg_toolbars_model_get_name (model, atom,
- (const char *) data, TRUE);
- }
-
- xmlFree (type);
- xmlFree (data);
- }
-
- if (name != NULL)
- {
- egg_toolbars_model_add_item (model, position, -1, name);
- g_free (name);
- }
+ char *name;
+
+ /* Try to get the name using the data elements first,
+ as they are more 'portable' or 'persistent'. */
+ name = parse_data_list (model, child->children, FALSE);
+ if (name == NULL)
+ {
+ name = parse_data_list (model, child->children, TRUE);
+ }
+
+ /* If that fails, try to use the name. */
+ if (name == NULL)
+ {
+ xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
+ xmlChar *data = xmlGetProp (child, (const xmlChar*) "name");
+ GdkAtom atom = type ? gdk_atom_intern ((const char*) type, TRUE) : GDK_NONE;
+
+ /* If an old format, try to use it. */
+ name = egg_toolbars_model_get_name (model, atom, (const char*) data, FALSE);
+ if (name == NULL)
+ {
+ name = egg_toolbars_model_get_name (model, atom, (const char*) data, TRUE);
+ }
+
+ xmlFree (type);
+ xmlFree (data);
+ }
+
+ if (name != NULL)
+ {
+ egg_toolbars_model_add_item (model, position, -1, name);
+ g_free (name);
+ }
}
- else if (xmlStrEqual (child->name, (const xmlChar *) "separator"))
+ else if (xmlStrEqual (child->name, (const xmlChar*) "separator"))
{
- egg_toolbars_model_add_item (model, position, -1, "_separator");
+ egg_toolbars_model_add_item (model, position, -1, "_separator");
}
child = child->next;
@@ -549,38 +541,38 @@ parse_item_list (EggToolbarsModel * model, xmlNodePtr child, int position)
}
static void
-parse_toolbars (EggToolbarsModel * model, xmlNodePtr child)
+parse_toolbars (EggToolbarsModel *model,
+ xmlNodePtr child)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar *) "toolbar"))
+ if (xmlStrEqual (child->name, (const xmlChar*) "toolbar"))
{
xmlChar *string;
int position;
- EggTbModelFlags flags;
+ EggTbModelFlags flags;
- string = xmlGetProp (child, (const xmlChar *) "name");
- position =
- egg_toolbars_model_add_toolbar (model, -1, (const char *) string);
- flags = egg_toolbars_model_get_flags (model, position);
+ string = xmlGetProp (child, (const xmlChar*) "name");
+ position = egg_toolbars_model_add_toolbar (model, -1, (const char*) string);
+ flags = egg_toolbars_model_get_flags (model, position);
xmlFree (string);
- string = xmlGetProp (child, (const xmlChar *) "editable");
- if (string && xmlStrEqual (string, (const xmlChar *) "false"))
- flags |= EGG_TB_MODEL_NOT_EDITABLE;
+ string = xmlGetProp (child, (const xmlChar*) "editable");
+ if (string && xmlStrEqual (string, (const xmlChar*) "false"))
+ flags |= EGG_TB_MODEL_NOT_EDITABLE;
xmlFree (string);
- string = xmlGetProp (child, (const xmlChar *) "hidden");
- if (string && xmlStrEqual (string, (const xmlChar *) "true"))
- flags |= EGG_TB_MODEL_HIDDEN;
+ string = xmlGetProp (child, (const xmlChar*) "hidden");
+ if (string && xmlStrEqual (string, (const xmlChar*) "true"))
+ flags |= EGG_TB_MODEL_HIDDEN;
xmlFree (string);
- string = xmlGetProp (child, (const xmlChar *) "style");
- if (string && xmlStrEqual (string, (const xmlChar *) "icons-only"))
- flags |= EGG_TB_MODEL_ICONS;
+ string = xmlGetProp (child, (const xmlChar*) "style");
+ if (string && xmlStrEqual (string, (const xmlChar*) "icons-only"))
+ flags |= EGG_TB_MODEL_ICONS;
xmlFree (string);
- egg_toolbars_model_set_flags (model, position, flags);
+ egg_toolbars_model_set_flags (model, position, flags);
parse_item_list (model, child->children, position);
}
@@ -590,7 +582,7 @@ parse_toolbars (EggToolbarsModel * model, xmlNodePtr child)
}
gboolean
-egg_toolbars_model_load_toolbars (EggToolbarsModel * model,
+egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
const char *xml_file)
{
xmlDocPtr doc;
@@ -598,15 +590,14 @@ egg_toolbars_model_load_toolbars (EggToolbarsModel * model,
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
- if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS))
- return FALSE;
+ if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
doc = xmlParseFile (xml_file);
if (doc == NULL)
- {
- g_warning ("Failed to load XML data from %s", xml_file);
- return FALSE;
- }
+ {
+ g_warning ("Failed to load XML data from %s", xml_file);
+ return FALSE;
+ }
root = xmlDocGetRootElement (doc);
parse_toolbars (model, root->children);
@@ -617,21 +608,22 @@ egg_toolbars_model_load_toolbars (EggToolbarsModel * model,
}
static void
-parse_available_list (EggToolbarsModel * model, xmlNodePtr child)
+parse_available_list (EggToolbarsModel *model,
+ xmlNodePtr child)
{
gint flags;
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar *) "toolitem"))
+ if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
{
xmlChar *name;
- name = xmlGetProp (child, (const xmlChar *) "name");
+ name = xmlGetProp (child, (const xmlChar*) "name");
flags = egg_toolbars_model_get_name_flags
- (model, (const char *) name);
+ (model, (const char*)name);
egg_toolbars_model_set_name_flags
- (model, (const char *) name, flags | EGG_TB_MODEL_NAME_KNOWN);
+ (model, (const char*)name, flags | EGG_TB_MODEL_NAME_KNOWN);
xmlFree (name);
}
child = child->next;
@@ -639,11 +631,12 @@ parse_available_list (EggToolbarsModel * model, xmlNodePtr child)
}
static void
-parse_names (EggToolbarsModel * model, xmlNodePtr child)
+parse_names (EggToolbarsModel *model,
+ xmlNodePtr child)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar *) "available"))
+ if (xmlStrEqual (child->name, (const xmlChar*) "available"))
{
parse_available_list (model, child->children);
}
@@ -653,22 +646,22 @@ parse_names (EggToolbarsModel * model, xmlNodePtr child)
}
gboolean
-egg_toolbars_model_load_names (EggToolbarsModel * model, const char *xml_file)
+egg_toolbars_model_load_names (EggToolbarsModel *model,
+ const char *xml_file)
{
xmlDocPtr doc;
xmlNodePtr root;
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
- if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS))
- return FALSE;
+ if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
doc = xmlParseFile (xml_file);
if (doc == NULL)
- {
- g_warning ("Failed to load XML data from %s", xml_file);
- return FALSE;
- }
+ {
+ g_warning ("Failed to load XML data from %s", xml_file);
+ return FALSE;
+ }
root = xmlDocGetRootElement (doc);
parse_names (model, root->children);
@@ -679,10 +672,10 @@ egg_toolbars_model_load_names (EggToolbarsModel * model, const char *xml_file)
}
static void
-egg_toolbars_model_class_init (EggToolbarsModelClass * klass)
+egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- volatile GType flags_type; /* work around gcc's optimiser */
+ volatile GType flags_type; /* work around gcc's optimiser */
/* make sure the flags type is known */
flags_type = EGG_TYPE_TB_MODEL_FLAGS;
@@ -731,25 +724,24 @@ egg_toolbars_model_class_init (EggToolbarsModelClass * klass)
}
static void
-egg_toolbars_model_init (EggToolbarsModel * model)
+egg_toolbars_model_init (EggToolbarsModel *model)
{
- model->priv = EGG_TOOLBARS_MODEL_GET_PRIVATE (model);
+ model->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (model);
model->priv->toolbars = g_node_new (NULL);
- model->priv->flags =
- g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ model->priv->flags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
egg_toolbars_model_set_name_flags (model, "_separator",
EGG_TB_MODEL_NAME_KNOWN |
EGG_TB_MODEL_NAME_INFINITE);
}
static void
-egg_toolbars_model_finalize (GObject * object)
+egg_toolbars_model_finalize (GObject *object)
{
EggToolbarsModel *model = EGG_TOOLBARS_MODEL (object);
g_node_children_foreach (model->priv->toolbars, G_TRAVERSE_ALL,
- (GNodeForeachFunc) toolbar_node_free, model);
+ (GNodeForeachFunc) toolbar_node_free, model);
g_node_destroy (model->priv->toolbars);
g_hash_table_destroy (model->priv->flags);
@@ -763,7 +755,8 @@ egg_toolbars_model_new (void)
}
void
-egg_toolbars_model_remove_toolbar (EggToolbarsModel * model, int position)
+egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
+ int position)
{
GNode *node;
EggTbModelFlags flags;
@@ -779,13 +772,15 @@ egg_toolbars_model_remove_toolbar (EggToolbarsModel * model, int position)
toolbar_node_free (node, model);
- g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED], 0, position);
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED],
+ 0, position);
}
}
void
-egg_toolbars_model_remove_item (EggToolbarsModel * model,
- int toolbar_position, int position)
+egg_toolbars_model_remove_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position)
{
GNode *node, *toolbar;
@@ -804,10 +799,11 @@ egg_toolbars_model_remove_item (EggToolbarsModel * model,
}
void
-egg_toolbars_model_move_item (EggToolbarsModel * model,
- int toolbar_position,
- int position,
- int new_toolbar_position, int new_position)
+egg_toolbars_model_move_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ int new_toolbar_position,
+ int new_position)
{
GNode *node, *toolbar, *new_toolbar;
@@ -816,8 +812,7 @@ egg_toolbars_model_move_item (EggToolbarsModel * model,
toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_if_fail (toolbar != NULL);
- new_toolbar =
- g_node_nth_child (model->priv->toolbars, new_toolbar_position);
+ new_toolbar = g_node_nth_child (model->priv->toolbars, new_toolbar_position);
g_return_if_fail (new_toolbar != NULL);
node = g_node_nth_child (toolbar, position);
@@ -835,7 +830,8 @@ egg_toolbars_model_move_item (EggToolbarsModel * model,
}
void
-egg_toolbars_model_delete_item (EggToolbarsModel * model, const char *name)
+egg_toolbars_model_delete_item (EggToolbarsModel *model,
+ const char *name)
{
EggToolbarsItem *idata;
EggToolbarsToolbar *tdata;
@@ -854,20 +850,21 @@ egg_toolbars_model_delete_item (EggToolbarsModel * model, const char *name)
/* Don't delete toolbars that were already empty */
if (item == NULL)
- {
+ {
toolbar = g_node_next_sibling (toolbar);
continue;
- }
+ }
while (item != NULL)
- {
+ {
next = g_node_next_sibling (item);
idata = item->data;
if (strcmp (idata->name, name) == 0)
{
item_node_free (item, model);
g_signal_emit (G_OBJECT (model),
- signals[ITEM_REMOVED], 0, tpos, ipos);
+ signals[ITEM_REMOVED],
+ 0, tpos, ipos);
}
else
{
@@ -875,28 +872,31 @@ egg_toolbars_model_delete_item (EggToolbarsModel * model, const char *name)
}
item = next;
- }
+ }
next = g_node_next_sibling (toolbar);
tdata = toolbar->data;
if (!(tdata->flags & EGG_TB_MODEL_NOT_REMOVABLE) &&
g_node_first_child (toolbar) == NULL)
- {
+ {
toolbar_node_free (toolbar, model);
- g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED], 0, tpos);
- }
+ g_signal_emit (G_OBJECT (model),
+ signals[TOOLBAR_REMOVED],
+ 0, tpos);
+ }
else
- {
+ {
tpos++;
- }
+ }
toolbar = next;
}
}
int
-egg_toolbars_model_n_items (EggToolbarsModel * model, int toolbar_position)
+egg_toolbars_model_n_items (EggToolbarsModel *model,
+ int toolbar_position)
{
GNode *toolbar;
@@ -907,8 +907,9 @@ egg_toolbars_model_n_items (EggToolbarsModel * model, int toolbar_position)
}
const char *
-egg_toolbars_model_item_nth (EggToolbarsModel * model,
- int toolbar_position, int position)
+egg_toolbars_model_item_nth (EggToolbarsModel *model,
+ int toolbar_position,
+ int position)
{
GNode *toolbar;
GNode *item;
@@ -925,13 +926,14 @@ egg_toolbars_model_item_nth (EggToolbarsModel * model,
}
int
-egg_toolbars_model_n_toolbars (EggToolbarsModel * model)
+egg_toolbars_model_n_toolbars (EggToolbarsModel *model)
{
return g_node_n_children (model->priv->toolbars);
}
const char *
-egg_toolbars_model_toolbar_nth (EggToolbarsModel * model, int position)
+egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
+ int position)
{
GNode *toolbar;
EggToolbarsToolbar *tdata;
@@ -945,27 +947,27 @@ egg_toolbars_model_toolbar_nth (EggToolbarsModel * model, int position)
}
GList *
-egg_toolbars_model_get_types (EggToolbarsModel * model)
+egg_toolbars_model_get_types (EggToolbarsModel *model)
{
return model->priv->types;
}
void
-egg_toolbars_model_set_types (EggToolbarsModel * model, GList * types)
+egg_toolbars_model_set_types (EggToolbarsModel *model, GList *types)
{
model->priv->types = types;
}
static void
-fill_avail_array (gpointer key, gpointer value, GPtrArray * array)
+fill_avail_array (gpointer key, gpointer value, GPtrArray *array)
{
int flags = GPOINTER_TO_INT (value);
if ((flags & EGG_TB_MODEL_NAME_KNOWN) && !(flags & EGG_TB_MODEL_NAME_USED))
- g_ptr_array_add (array, key);
+ g_ptr_array_add (array, key);
}
GPtrArray *
-egg_toolbars_model_get_name_avail (EggToolbarsModel * model)
+egg_toolbars_model_get_name_avail (EggToolbarsModel *model)
{
GPtrArray *array = g_ptr_array_new ();
g_hash_table_foreach (model->priv->flags, (GHFunc) fill_avail_array, array);
@@ -973,15 +975,13 @@ egg_toolbars_model_get_name_avail (EggToolbarsModel * model)
}
gint
-egg_toolbars_model_get_name_flags (EggToolbarsModel * model, const char *name)
+egg_toolbars_model_get_name_flags (EggToolbarsModel *model, const char *name)
{
return GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, name));
}
void
-egg_toolbars_model_set_name_flags (EggToolbarsModel * model, const char *name,
- gint flags)
+egg_toolbars_model_set_name_flags (EggToolbarsModel *model, const char *name, gint flags)
{
- g_hash_table_insert (model->priv->flags, g_strdup (name),
- GINT_TO_POINTER (flags));
+ g_hash_table_insert (model->priv->flags, g_strdup (name), GINT_TO_POINTER (flags));
}
diff --git a/src/toolbareditor/egg-toolbars-model.h b/src/toolbareditor/egg-toolbars-model.h
index 8ea7b94..5c02b0a 100644
--- a/src/toolbareditor/egg-toolbars-model.h
+++ b/src/toolbareditor/egg-toolbars-model.h
@@ -26,43 +26,45 @@
#include <gdk/gdk.h>
G_BEGIN_DECLS
+
#define EGG_TYPE_TOOLBARS_MODEL (egg_toolbars_model_get_type ())
#define EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModel))
#define EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
#define EGG_IS_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOLBARS_MODEL))
#define EGG_IS_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TOOLBARS_MODEL))
#define EGG_TOOLBARS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
-typedef struct EggToolbarsModel EggToolbarsModel;
-typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
-typedef struct EggToolbarsModelClass EggToolbarsModelClass;
+
+typedef struct EggToolbarsModel EggToolbarsModel;
+typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
+typedef struct EggToolbarsModelClass EggToolbarsModelClass;
#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
typedef enum
{
- EGG_TB_MODEL_NOT_REMOVABLE = 1 << 0,
- EGG_TB_MODEL_NOT_EDITABLE = 1 << 1,
- EGG_TB_MODEL_BOTH = 1 << 2,
- EGG_TB_MODEL_BOTH_HORIZ = 1 << 3,
- EGG_TB_MODEL_ICONS = 1 << 4,
- EGG_TB_MODEL_TEXT = 1 << 5,
- EGG_TB_MODEL_STYLES_MASK = 0x3C,
+ EGG_TB_MODEL_NOT_REMOVABLE = 1 << 0,
+ EGG_TB_MODEL_NOT_EDITABLE = 1 << 1,
+ EGG_TB_MODEL_BOTH = 1 << 2,
+ EGG_TB_MODEL_BOTH_HORIZ = 1 << 3,
+ EGG_TB_MODEL_ICONS = 1 << 4,
+ EGG_TB_MODEL_TEXT = 1 << 5,
+ EGG_TB_MODEL_STYLES_MASK = 0x3C,
EGG_TB_MODEL_ACCEPT_ITEMS_ONLY = 1 << 6,
- EGG_TB_MODEL_HIDDEN = 1 << 7
+ EGG_TB_MODEL_HIDDEN = 1 << 7
} EggTbModelFlags;
typedef enum
{
- EGG_TB_MODEL_NAME_USED = 1 << 0,
- EGG_TB_MODEL_NAME_INFINITE = 1 << 1,
- EGG_TB_MODEL_NAME_KNOWN = 1 << 2
+ EGG_TB_MODEL_NAME_USED = 1 << 0,
+ EGG_TB_MODEL_NAME_INFINITE = 1 << 1,
+ EGG_TB_MODEL_NAME_KNOWN = 1 << 2
} EggTbModelNameFlags;
struct EggToolbarsModel
{
GObject parent_object;
- /*< private > */
+ /*< private >*/
EggToolbarsModelPrivate *priv;
};
@@ -71,18 +73,24 @@ struct EggToolbarsModelClass
GObjectClass parent_class;
/* Signals */
- void (*item_added) (EggToolbarsModel * model,
- int toolbar_position, int position);
- void (*item_removed) (EggToolbarsModel * model,
- int toolbar_position, int position);
- void (*toolbar_added) (EggToolbarsModel * model, int position);
- void (*toolbar_changed) (EggToolbarsModel * model, int position);
- void (*toolbar_removed) (EggToolbarsModel * model, int position);
+ void (* item_added) (EggToolbarsModel *model,
+ int toolbar_position,
+ int position);
+ void (* item_removed) (EggToolbarsModel *model,
+ int toolbar_position,
+ int position);
+ void (* toolbar_added) (EggToolbarsModel *model,
+ int position);
+ void (* toolbar_changed) (EggToolbarsModel *model,
+ int position);
+ void (* toolbar_removed) (EggToolbarsModel *model,
+ int position);
/* Virtual Table */
- gboolean (*add_item) (EggToolbarsModel * t,
- int toolbar_position,
- int position, const char *name);
+ gboolean (* add_item) (EggToolbarsModel *t,
+ int toolbar_position,
+ int position,
+ const char *name);
};
typedef struct EggToolbarsItemType EggToolbarsItemType;
@@ -91,79 +99,92 @@ struct EggToolbarsItemType
{
GdkAtom type;
- gboolean (*has_data) (EggToolbarsItemType * type, const char *name);
- char *(*get_data) (EggToolbarsItemType * type, const char *name);
+ gboolean (* has_data) (EggToolbarsItemType *type,
+ const char *name);
+ char * (* get_data) (EggToolbarsItemType *type,
+ const char *name);
- char *(*new_name) (EggToolbarsItemType * type, const char *data);
- char *(*get_name) (EggToolbarsItemType * type, const char *data);
+ char * (* new_name) (EggToolbarsItemType *type,
+ const char *data);
+ char * (* get_name) (EggToolbarsItemType *type,
+ const char *data);
};
-GType egg_tb_model_flags_get_type (void);
-GType egg_toolbars_model_get_type (void);
-EggToolbarsModel *egg_toolbars_model_new (void);
-gboolean egg_toolbars_model_load_names (EggToolbarsModel * model,
- const char *xml_file);
-gboolean egg_toolbars_model_load_toolbars (EggToolbarsModel * model,
- const char *xml_file);
-void egg_toolbars_model_save_toolbars (EggToolbarsModel * model,
- const char *xml_file,
- const char *version);
+GType egg_tb_model_flags_get_type (void);
+GType egg_toolbars_model_get_type (void);
+EggToolbarsModel *egg_toolbars_model_new (void);
+gboolean egg_toolbars_model_load_names (EggToolbarsModel *model,
+ const char *xml_file);
+gboolean egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
+ const char *xml_file);
+void egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
+ const char *xml_file,
+ const char *version);
/* Functions for manipulating the types of portable data this toolbar understands. */
-GList *egg_toolbars_model_get_types (EggToolbarsModel * model);
-void egg_toolbars_model_set_types (EggToolbarsModel * model, GList * types);
+GList * egg_toolbars_model_get_types (EggToolbarsModel *model);
+void egg_toolbars_model_set_types (EggToolbarsModel *model,
+ GList *types);
/* Functions for converting between name and portable data. */
-char *egg_toolbars_model_get_name (EggToolbarsModel * model,
- GdkAtom type,
- const char *data, gboolean create);
-char *egg_toolbars_model_get_data (EggToolbarsModel * model,
- GdkAtom type, const char *name);
+char * egg_toolbars_model_get_name (EggToolbarsModel *model,
+ GdkAtom type,
+ const char *data,
+ gboolean create);
+char * egg_toolbars_model_get_data (EggToolbarsModel *model,
+ GdkAtom type,
+ const char *name);
/* Functions for retrieving what items are available for adding to the toolbars. */
-GPtrArray *egg_toolbars_model_get_name_avail (EggToolbarsModel * model);
-gint egg_toolbars_model_get_name_flags (EggToolbarsModel * model,
- const char *name);
-void egg_toolbars_model_set_name_flags (EggToolbarsModel * model,
- const char *name, gint flags);
+GPtrArray * egg_toolbars_model_get_name_avail (EggToolbarsModel *model);
+gint egg_toolbars_model_get_name_flags (EggToolbarsModel *model,
+ const char *name);
+void egg_toolbars_model_set_name_flags (EggToolbarsModel *model,
+ const char *name,
+ gint flags);
/* Functions for manipulating flags on individual toolbars. */
-EggTbModelFlags egg_toolbars_model_get_flags (EggToolbarsModel * model,
- int toolbar_position);
-void egg_toolbars_model_set_flags (EggToolbarsModel * model,
- int toolbar_position,
- EggTbModelFlags flags);
+EggTbModelFlags egg_toolbars_model_get_flags (EggToolbarsModel *model,
+ int toolbar_position);
+void egg_toolbars_model_set_flags (EggToolbarsModel *model,
+ int toolbar_position,
+ EggTbModelFlags flags);
/* Functions for adding and removing toolbars. */
-int egg_toolbars_model_add_toolbar (EggToolbarsModel * model,
- int position, const char *name);
-void egg_toolbars_model_remove_toolbar (EggToolbarsModel * model,
- int position);
+int egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
+ int position,
+ const char *name);
+void egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
+ int position);
/* Functions for adding, removing and moving items. */
-gboolean egg_toolbars_model_add_item (EggToolbarsModel * model,
- int toolbar_position,
- int position, const char *name);
-void egg_toolbars_model_remove_item (EggToolbarsModel * model,
- int toolbar_position, int position);
-void egg_toolbars_model_move_item (EggToolbarsModel * model,
- int toolbar_position,
- int position,
- int new_toolbar_position,
- int new_position);
-void egg_toolbars_model_delete_item (EggToolbarsModel * model,
- const char *name);
+gboolean egg_toolbars_model_add_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ const char *name);
+void egg_toolbars_model_remove_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position);
+void egg_toolbars_model_move_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ int new_toolbar_position,
+ int new_position);
+void egg_toolbars_model_delete_item (EggToolbarsModel *model,
+ const char *name);
/* Functions for accessing the names of items. */
-int egg_toolbars_model_n_items (EggToolbarsModel * model,
- int toolbar_position);
-const char *egg_toolbars_model_item_nth (EggToolbarsModel * model,
- int toolbar_position, int position);
+int egg_toolbars_model_n_items (EggToolbarsModel *model,
+ int toolbar_position);
+const char * egg_toolbars_model_item_nth (EggToolbarsModel *model,
+ int toolbar_position,
+ int position);
/* Functions for accessing the names of toolbars. */
-int egg_toolbars_model_n_toolbars (EggToolbarsModel * model);
-const char *egg_toolbars_model_toolbar_nth (EggToolbarsModel * model,
- int position);
+int egg_toolbars_model_n_toolbars (EggToolbarsModel *model);
+const char *egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
+ int position);
G_END_DECLS
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]