[glade3] * ALL SOURCE FILES: Removed 8-space indentation, reformatted all code with: indent \ --braces-a
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3] * ALL SOURCE FILES: Removed 8-space indentation, reformatted all code with: indent \ --braces-a
- Date: Thu, 30 Dec 2010 11:14:30 +0000 (UTC)
commit bc939d5ff620e650ad4ff19b7b8387b44478d36e
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu Dec 30 20:19:58 2010 +0900
* ALL SOURCE FILES: Removed 8-space indentation, reformatted all code with:
indent \
--braces-after-if-line \
--case-brace-indentation0 \
--case-indentation2 \
--braces-after-struct-decl-line \
--line-length80 --no-tabs \
--dont-line-up-parentheses \
--continuation-indentation4 \
--continue-at-parentheses \
--honour-newlines --tab-size8 --indent-level2 -nbbo
ChangeLog | 12 +
gladeui/glade-accumulators.c | 100 +-
gladeui/glade-accumulators.h | 1 -
gladeui/glade-app.c | 2014 ++--
gladeui/glade-app.h | 1 -
gladeui/glade-base-editor.c | 3462 +++---
gladeui/glade-base-editor.h | 1 -
gladeui/glade-builtins.c | 734 +-
gladeui/glade-builtins.h | 1 -
gladeui/glade-catalog.c | 1127 +-
gladeui/glade-catalog.h | 1 -
gladeui/glade-cell-renderer-icon.c | 177 +-
gladeui/glade-cell-renderer-icon.h | 1 -
gladeui/glade-clipboard.c | 249 +-
gladeui/glade-clipboard.h | 1 -
gladeui/glade-command.c | 3219 +++---
gladeui/glade-command.h | 1 -
gladeui/glade-cursor.c | 262 +-
gladeui/glade-cursor.h | 1 -
gladeui/glade-debug.c | 27 +-
gladeui/glade-debug.h | 1 -
gladeui/glade-design-layout.c | 1281 +-
gladeui/glade-design-view.c | 325 +-
gladeui/glade-displayable-values.c | 198 +-
gladeui/glade-displayable-values.h | 1 -
gladeui/glade-editable.c | 49 +-
gladeui/glade-editable.h | 1 -
gladeui/glade-editor-property.c | 5030 ++++----
gladeui/glade-editor-property.h | 1 -
gladeui/glade-editor-table.c | 538 +-
gladeui/glade-editor-table.h | 1 -
gladeui/glade-editor.c | 2057 ++--
gladeui/glade-editor.h | 1 -
gladeui/glade-fixed.c | 1769 ++--
gladeui/glade-fixed.h | 1 -
gladeui/glade-id-allocator.c | 201 +-
gladeui/glade-id-allocator.h | 1 -
gladeui/glade-inspector.c | 1250 +-
gladeui/glade-inspector.h | 1 -
gladeui/glade-name-context.c | 306 +-
gladeui/glade-name-context.h | 1 -
gladeui/glade-named-icon-chooser-dialog.c | 2808 +++---
gladeui/glade-palette.c | 1208 +-
gladeui/glade-palette.h | 1 -
gladeui/glade-parameter.c | 285 +-
gladeui/glade-parameter.h | 1 -
gladeui/glade-placeholder.c | 690 +-
gladeui/glade-placeholder.h | 1 -
gladeui/glade-popup.c | 1228 +-
gladeui/glade-popup.h | 1 -
gladeui/glade-previewer.c | 516 +-
gladeui/glade-project.c | 6773 ++++++------
gladeui/glade-project.h | 1 -
gladeui/glade-property-class.c | 2734 +++---
gladeui/glade-property-class.h | 1 -
gladeui/glade-property.c | 1751 ++--
gladeui/glade-property.h | 1 -
gladeui/glade-signal-editor.c | 2794 +++---
gladeui/glade-signal-editor.h | 1 -
gladeui/glade-signal.c | 252 +-
gladeui/glade-signal.h | 1 -
gladeui/glade-utils.c | 2504 ++--
gladeui/glade-utils.h | 1 -
gladeui/glade-widget-action.c | 326 +-
gladeui/glade-widget-action.h | 1 -
gladeui/glade-widget-adaptor.c | 5530 +++++-----
gladeui/glade-widget-adaptor.h | 1 -
gladeui/glade-widget.c | 5519 +++++-----
gladeui/glade-widget.h | 1 -
gladeui/glade-xml-utils.c | 1039 +-
gladeui/glade-xml-utils.h | 1 -
gladeui/glade.h | 1 -
gladeui/icon-naming-spec.c | 57 +-
plugins/gtk+/glade-accels.c | 1339 ++--
plugins/gtk+/glade-accels.h | 1 -
plugins/gtk+/glade-activatable-editor.c | 623 +-
plugins/gtk+/glade-activatable-editor.h | 1 -
plugins/gtk+/glade-attributes.c | 1898 ++--
plugins/gtk+/glade-attributes.h | 1 -
plugins/gtk+/glade-button-editor.c | 825 +-
plugins/gtk+/glade-button-editor.h | 1 -
plugins/gtk+/glade-cell-renderer-editor.c | 941 +-
plugins/gtk+/glade-cell-renderer-editor.h | 1 -
plugins/gtk+/glade-column-types.c | 1378 ++--
plugins/gtk+/glade-column-types.h | 1 -
plugins/gtk+/glade-entry-editor.c | 1212 ++-
plugins/gtk+/glade-entry-editor.h | 1 -
plugins/gtk+/glade-gtk.c |18267 +++++++++++++++--------------
plugins/gtk+/glade-gtk.h | 1 -
plugins/gtk+/glade-icon-factory-editor.c | 252 +-
plugins/gtk+/glade-icon-factory-editor.h | 1 -
plugins/gtk+/glade-icon-sources.c | 1689 ++--
plugins/gtk+/glade-icon-sources.h | 1 -
plugins/gtk+/glade-image-editor.c | 616 +-
plugins/gtk+/glade-image-editor.h | 1 -
plugins/gtk+/glade-image-item-editor.c | 633 +-
plugins/gtk+/glade-image-item-editor.h | 1 -
plugins/gtk+/glade-label-editor.c | 1157 +-
plugins/gtk+/glade-label-editor.h | 1 -
plugins/gtk+/glade-model-data.c | 1992 ++--
plugins/gtk+/glade-model-data.h | 1 -
plugins/gtk+/glade-store-editor.c | 311 +-
plugins/gtk+/glade-store-editor.h | 1 -
plugins/gtk+/glade-text-button.c | 147 +-
plugins/gtk+/glade-text-button.h | 1 -
plugins/gtk+/glade-tool-button-editor.c | 764 +-
plugins/gtk+/glade-tool-button-editor.h | 1 -
plugins/gtk+/glade-treeview-editor.c | 350 +-
plugins/gtk+/glade-treeview-editor.h | 1 -
plugins/python/glade-python.c | 158 +-
src/glade-close-button.c | 61 +-
src/glade-window.c | 5461 +++++-----
src/glade-window.h | 1 -
src/main.c | 255 +-
114 files changed, 50670 insertions(+), 50113 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fb6bff0..5a231fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,18 @@
(i.e. from ${prefix}/share/glade3/catalogs instead of ${prefix}/share/glade/catalogs
which is the new path).
+ * ALL SOURCE FILES: Removed 8-space indentation, reformatted all code with:
+ indent \
+ --braces-after-if-line \
+ --case-brace-indentation0 \
+ --case-indentation2 \
+ --braces-after-struct-decl-line \
+ --line-length80 --no-tabs \
+ --dont-line-up-parentheses \
+ --continuation-indentation4 \
+ --continue-at-parentheses \
+ --honour-newlines --tab-size8 --indent-level2 -nbbo
+
2010-12-29 Javier Jardón <jjardon gnome org>
* configure.ac: Use upstream gettext
diff --git a/gladeui/glade-accumulators.c b/gladeui/glade-accumulators.c
index 3120813..aa3574c 100644
--- a/gladeui/glade-accumulators.c
+++ b/gladeui/glade-accumulators.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-clipboard.c - An object for handling Cut/Copy/Paste.
*
@@ -31,73 +30,70 @@
gboolean
-glade_single_object_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
+glade_single_object_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu,
+ const GValue * handler_return, gpointer dummy)
{
- GObject *object = g_value_get_object (handler_return);
- g_value_set_object (return_accu, object);
-
- return (object == NULL);
+ GObject *object = g_value_get_object (handler_return);
+ g_value_set_object (return_accu, object);
+
+ return (object == NULL);
}
gboolean
-glade_integer_handled_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
+glade_integer_handled_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu,
+ const GValue * handler_return,
+ gpointer dummy)
{
- gboolean continue_emission;
- gint retval;
-
- retval = g_value_get_int (handler_return);
- g_value_set_int (return_accu, retval >> 1);
- continue_emission = !(retval & 1);
-
- return continue_emission;
+ gboolean continue_emission;
+ gint retval;
+
+ retval = g_value_get_int (handler_return);
+ g_value_set_int (return_accu, retval >> 1);
+ continue_emission = !(retval & 1);
+
+ return continue_emission;
}
/* From gtkmain.c */
gboolean
-glade_boolean_handled_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
+glade_boolean_handled_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu,
+ const GValue * handler_return,
+ gpointer dummy)
{
- gboolean continue_emission;
- gboolean signal_handled;
-
- signal_handled = g_value_get_boolean (handler_return);
- g_value_set_boolean (return_accu, signal_handled);
- continue_emission = !signal_handled;
-
- return continue_emission;
+ gboolean continue_emission;
+ gboolean signal_handled;
+
+ signal_handled = g_value_get_boolean (handler_return);
+ g_value_set_boolean (return_accu, signal_handled);
+ continue_emission = !signal_handled;
+
+ return continue_emission;
}
gboolean
-glade_string_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
+glade_string_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu,
+ const GValue * handler_return, gpointer dummy)
{
- const gchar *handler_str;
-
- g_free ((void *)g_value_get_string (return_accu));
-
- handler_str = g_value_get_string (handler_return);
- g_value_set_string (return_accu, handler_str);
-
- return (handler_str == NULL);
+ const gchar *handler_str;
+
+ g_free ((void *) g_value_get_string (return_accu));
+
+ handler_str = g_value_get_string (handler_return);
+ g_value_set_string (return_accu, handler_str);
+
+ return (handler_str == NULL);
}
gboolean
-glade_stop_emission_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
+glade_stop_emission_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu,
+ const GValue * handler_return, gpointer dummy)
{
- g_value_copy (handler_return, return_accu);
-
- return FALSE;
+ g_value_copy (handler_return, return_accu);
+
+ return FALSE;
}
diff --git a/gladeui/glade-accumulators.h b/gladeui/glade-accumulators.h
index 2bce930..e951475 100644
--- a/gladeui/glade-accumulators.h
+++ b/gladeui/glade-accumulators.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_ACCUMULATORS_H__
#define __GLADE_ACCUMULATORS_H__
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index 796aa99..b26e158 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -58,53 +57,53 @@
enum
{
- UPDATE_UI,
- SIGNAL_EDITOR_CREATED,
- LAST_SIGNAL
+ UPDATE_UI,
+ SIGNAL_EDITOR_CREATED,
+ LAST_SIGNAL
};
enum
{
- PROP_0,
- PROP_ACTIVE_PROJECT,
- PROP_POINTER_MODE
+ PROP_0,
+ PROP_ACTIVE_PROJECT,
+ PROP_POINTER_MODE
};
struct _GladeAppPrivate
{
- GtkWidget *window;
-
- GladePalette *palette; /* See glade-palette */
- GladeProject *active_project; /* Currently active project (if there is at least one
- * project; then this is always valid) */
- GladeEditor *editor; /* See glade-editor */
- GladeClipboard *clipboard; /* See glade-clipboard */
- GList *catalogs; /* See glade-catalog */
-
- GList *projects; /* The list of Projects */
-
- GKeyFile *config;/* The configuration file */
-
- GtkWindow *transient_parent; /* If set by glade_app_set_transient_parent(); this
- * will be used as the transient parent of all toplevel
- * GladeWidgets.
- */
- GtkAccelGroup *accel_group; /* Default acceleration group for this app */
- GList *undo_list, *redo_list; /* Lists of buttons to refresh in update-ui signal */
-
- GladePointerMode pointer_mode; /* Current mode for the pointer in the workspace */
-
- guint selection_changed_id; /* for queue_selection_changed() */
+ GtkWidget *window;
+
+ GladePalette *palette; /* See glade-palette */
+ GladeProject *active_project; /* Currently active project (if there is at least one
+ * project; then this is always valid) */
+ GladeEditor *editor; /* See glade-editor */
+ GladeClipboard *clipboard; /* See glade-clipboard */
+ GList *catalogs; /* See glade-catalog */
+
+ GList *projects; /* The list of Projects */
+
+ GKeyFile *config; /* The configuration file */
+
+ GtkWindow *transient_parent; /* If set by glade_app_set_transient_parent(); this
+ * will be used as the transient parent of all toplevel
+ * GladeWidgets.
+ */
+ GtkAccelGroup *accel_group; /* Default acceleration group for this app */
+ GList *undo_list, *redo_list; /* Lists of buttons to refresh in update-ui signal */
+
+ GladePointerMode pointer_mode; /* Current mode for the pointer in the workspace */
+
+ guint selection_changed_id; /* for queue_selection_changed() */
};
static guint glade_app_signals[LAST_SIGNAL] = { 0 };
/* installation paths */
static gchar *catalogs_dir = NULL;
-static gchar *modules_dir = NULL;
-static gchar *pixmaps_dir = NULL;
-static gchar *locale_dir = NULL;
-static gchar *bin_dir = NULL;
+static gchar *modules_dir = NULL;
+static gchar *pixmaps_dir = NULL;
+static gchar *locale_dir = NULL;
+static gchar *bin_dir = NULL;
static GladeApp *singleton_app = NULL;
static gboolean check_initialised = FALSE;
@@ -117,21 +116,19 @@ G_DEFINE_TYPE (GladeApp, glade_app, G_TYPE_OBJECT);
GType
glade_pointer_mode_get_type (void)
{
- static GType etype = 0;
+ static GType etype = 0;
- if (etype == 0)
- {
- static const GEnumValue values[] =
- {
- { GLADE_POINTER_SELECT, "select", "Select widgets" },
- { GLADE_POINTER_ADD_WIDGET, "add", "Add widgets" },
- { GLADE_POINTER_DRAG_RESIZE, "drag-resize", "Drag and resize widgets" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static ("GladePointerMode",
- values);
- }
- return etype;
+ if (etype == 0)
+ {
+ static const GEnumValue values[] = {
+ {GLADE_POINTER_SELECT, "select", "Select widgets"},
+ {GLADE_POINTER_ADD_WIDGET, "add", "Add widgets"},
+ {GLADE_POINTER_DRAG_RESIZE, "drag-resize", "Drag and resize widgets"},
+ {0, NULL, NULL}
+ };
+ etype = g_enum_register_static ("GladePointerMode", values);
+ }
+ return etype;
}
@@ -139,223 +136,221 @@ glade_pointer_mode_get_type (void)
* GObjectClass *
*****************************************************************/
static GObject *
-glade_app_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- GObject *object;
-
- /* singleton */
- if (!singleton_app)
- {
- object = G_OBJECT_CLASS (glade_app_parent_class)->constructor (type,
- n_construct_properties,
- construct_properties);
- singleton_app = GLADE_APP (object);
- }
- else
- {
- g_object_ref (singleton_app);
- }
-
- return G_OBJECT (singleton_app);
+glade_app_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
+{
+ GObject *object;
+
+ /* singleton */
+ if (!singleton_app)
+ {
+ object = G_OBJECT_CLASS (glade_app_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties);
+ singleton_app = GLADE_APP (object);
+ }
+ else
+ {
+ g_object_ref (singleton_app);
+ }
+
+ return G_OBJECT (singleton_app);
}
static void
-glade_app_dispose (GObject *app)
-{
- GladeAppPrivate *priv = GLADE_APP_GET_PRIVATE (app);
-
- if (priv->editor)
- {
- g_object_unref (priv->editor);
- priv->editor = NULL;
- }
- if (priv->palette)
- {
- g_object_unref (priv->palette);
- priv->palette = NULL;
- }
- if (priv->clipboard)
- {
- gtk_widget_destroy (GTK_WIDGET (priv->clipboard->view));
- priv->clipboard = NULL;
- }
- /* FIXME: Remove projects */
-
- if (priv->config)
- {
- g_key_file_free (priv->config);
- priv->config = NULL;
- }
-
- G_OBJECT_CLASS (glade_app_parent_class)->dispose (app);
+glade_app_dispose (GObject * app)
+{
+ GladeAppPrivate *priv = GLADE_APP_GET_PRIVATE (app);
+
+ if (priv->editor)
+ {
+ g_object_unref (priv->editor);
+ priv->editor = NULL;
+ }
+ if (priv->palette)
+ {
+ g_object_unref (priv->palette);
+ priv->palette = NULL;
+ }
+ if (priv->clipboard)
+ {
+ gtk_widget_destroy (GTK_WIDGET (priv->clipboard->view));
+ priv->clipboard = NULL;
+ }
+ /* FIXME: Remove projects */
+
+ if (priv->config)
+ {
+ g_key_file_free (priv->config);
+ priv->config = NULL;
+ }
+
+ G_OBJECT_CLASS (glade_app_parent_class)->dispose (app);
}
static void
-glade_app_finalize (GObject *app)
+glade_app_finalize (GObject * app)
{
- g_free (catalogs_dir);
- g_free (modules_dir);
- g_free (pixmaps_dir);
- g_free (locale_dir);
- g_free (bin_dir);
+ g_free (catalogs_dir);
+ g_free (modules_dir);
+ g_free (pixmaps_dir);
+ g_free (locale_dir);
+ g_free (bin_dir);
- singleton_app = NULL;
- check_initialised = FALSE;
+ singleton_app = NULL;
+ check_initialised = FALSE;
- G_OBJECT_CLASS (glade_app_parent_class)->finalize (app);
+ G_OBJECT_CLASS (glade_app_parent_class)->finalize (app);
}
static void
-glade_app_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id)
- {
- case PROP_ACTIVE_PROJECT:
- glade_app_set_project (g_value_get_object (value));
- break;
- case PROP_POINTER_MODE:
- glade_app_set_pointer_mode (g_value_get_enum (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID
- (object, property_id, pspec);
- break;
- }
+glade_app_set_property (GObject * object,
+ guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ switch (property_id)
+ {
+ case PROP_ACTIVE_PROJECT:
+ glade_app_set_project (g_value_get_object (value));
+ break;
+ case PROP_POINTER_MODE:
+ glade_app_set_pointer_mode (g_value_get_enum (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-glade_app_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+glade_app_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec)
{
- GladeApp *app = GLADE_APP (object);
+ GladeApp *app = GLADE_APP (object);
- switch (property_id)
- {
- case PROP_ACTIVE_PROJECT:
- g_value_set_object (value, app->priv->active_project);
- break;
- case PROP_POINTER_MODE:
- g_value_set_enum (value, app->priv->pointer_mode);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
- break;
- }
+ switch (property_id)
+ {
+ case PROP_ACTIVE_PROJECT:
+ g_value_set_object (value, app->priv->active_project);
+ break;
+ case PROP_POINTER_MODE:
+ g_value_set_enum (value, app->priv->pointer_mode);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
/*****************************************************************
* GladeAppClass *
*****************************************************************/
static void
-glade_app_refresh_undo_redo_button (GladeApp *app,
- GtkWidget *button,
- gboolean undo)
+glade_app_refresh_undo_redo_button (GladeApp * app,
+ GtkWidget * button, gboolean undo)
{
- GladeCommand *command = NULL;
- GladeProject *project;
- gchar *desc;
+ GladeCommand *command = NULL;
+ GladeProject *project;
+ gchar *desc;
- if ((project = glade_app_get_project ()) != NULL)
- {
- if (undo)
- command = glade_project_next_undo_item (project);
- else
- command = glade_project_next_redo_item (project);
- }
+ if ((project = glade_app_get_project ()) != NULL)
+ {
+ if (undo)
+ command = glade_project_next_undo_item (project);
+ else
+ command = glade_project_next_redo_item (project);
+ }
- /* Change tooltips */
- desc = g_strdup_printf ((undo) ? _("Undo: %s") : _("Redo: %s"),
- command ? command->description : _("the last action"));
- gtk_widget_set_tooltip_text (button, desc);
- g_free (desc);
+ /* Change tooltips */
+ desc = g_strdup_printf ((undo) ? _("Undo: %s") : _("Redo: %s"),
+ command ? command->
+ description : _("the last action"));
+ gtk_widget_set_tooltip_text (button, desc);
+ g_free (desc);
- /* Set sensitivity on the button */
- gtk_widget_set_sensitive (button, command != NULL);
+ /* Set sensitivity on the button */
+ gtk_widget_set_sensitive (button, command != NULL);
}
static void
-glade_app_update_ui_default (GladeApp *app)
+glade_app_update_ui_default (GladeApp * app)
{
- GList *list;
-
- for (list = app->priv->undo_list; list; list = list->next)
- if (list->data)
- glade_app_refresh_undo_redo_button (app, list->data, TRUE);
+ GList *list;
- for (list = app->priv->redo_list; list; list = list->next)
- if (list->data)
- glade_app_refresh_undo_redo_button (app, list->data, FALSE);
+ for (list = app->priv->undo_list; list; list = list->next)
+ if (list->data)
+ glade_app_refresh_undo_redo_button (app, list->data, TRUE);
+
+ for (list = app->priv->redo_list; list; list = list->next)
+ if (list->data)
+ glade_app_refresh_undo_redo_button (app, list->data, FALSE);
}
static void
-glade_app_signal_editor_created_default (GladeApp *app, GladeSignalEditor *signal_editor)
+glade_app_signal_editor_created_default (GladeApp * app,
+ GladeSignalEditor * signal_editor)
{
- glade_signal_editor_construct_signals_list (signal_editor);
+ glade_signal_editor_construct_signals_list (signal_editor);
}
static GKeyFile *
-glade_app_config_load (GladeApp *app)
+glade_app_config_load (GladeApp * app)
{
- GKeyFile *config = g_key_file_new ();
- gchar *filename;
+ GKeyFile *config = g_key_file_new ();
+ gchar *filename;
+
+ filename =
+ g_build_filename (g_get_user_config_dir (), GLADE_CONFIG_FILENAME, NULL);
- filename = g_build_filename (g_get_user_config_dir (), GLADE_CONFIG_FILENAME, NULL);
+ g_key_file_load_from_file (config, filename, G_KEY_FILE_NONE, NULL);
- g_key_file_load_from_file (config, filename, G_KEY_FILE_NONE, NULL);
-
- g_free (filename);
-
- return config;
+ g_free (filename);
+
+ return config;
}
const gchar *
glade_app_get_catalogs_dir (void)
{
- glade_init_check ();
-
- return catalogs_dir;
+ glade_init_check ();
+
+ return catalogs_dir;
}
const gchar *
glade_app_get_modules_dir (void)
{
- glade_init_check ();
+ glade_init_check ();
- return modules_dir;
+ return modules_dir;
}
const gchar *
glade_app_get_pixmaps_dir (void)
{
- glade_init_check ();
+ glade_init_check ();
- return pixmaps_dir;
+ return pixmaps_dir;
}
const gchar *
glade_app_get_locale_dir (void)
{
- glade_init_check ();
-
- return locale_dir;
+ glade_init_check ();
+
+ return locale_dir;
}
const gchar *
glade_app_get_bin_dir (void)
{
- glade_init_check ();
-
- return bin_dir;
+ glade_init_check ();
+
+ return bin_dir;
}
@@ -364,132 +359,132 @@ static void
build_package_paths (void)
{
#if defined (G_OS_WIN32) || (defined (MAC_INTEGRATION) && defined (MAC_BUNDLE))
- gchar *prefix;
+ gchar *prefix;
# ifdef G_OS_WIN32
- prefix = g_win32_get_package_installation_directory_of_module (NULL);
+ prefix = g_win32_get_package_installation_directory_of_module (NULL);
# else // defined (MAC_INTEGRATION) && defined (MAC_BUNDLE)
- IgeMacBundle *bundle = ige_mac_bundle_get_default ();
+ IgeMacBundle *bundle = ige_mac_bundle_get_default ();
- prefix = g_build_filename (ige_mac_bundle_get_path (bundle), "Contents", "Resources", NULL);
-# endif
+ prefix =
+ g_build_filename (ige_mac_bundle_get_path (bundle), "Contents",
+ "Resources", NULL);
+# endif
- pixmaps_dir = g_build_filename (prefix, "share", PACKAGE, "pixmaps", NULL);
- catalogs_dir = g_build_filename (prefix, "share", PACKAGE, "catalogs", NULL);
- modules_dir = g_build_filename (prefix, "lib", PACKAGE, "modules", NULL);
- locale_dir = g_build_filename (prefix, "share", "locale", NULL);
- bin_dir = g_build_filename (prefix, "bin", NULL);
+ pixmaps_dir = g_build_filename (prefix, "share", PACKAGE, "pixmaps", NULL);
+ catalogs_dir = g_build_filename (prefix, "share", PACKAGE, "catalogs", NULL);
+ modules_dir = g_build_filename (prefix, "lib", PACKAGE, "modules", NULL);
+ locale_dir = g_build_filename (prefix, "share", "locale", NULL);
+ bin_dir = g_build_filename (prefix, "bin", NULL);
- g_free (prefix);
+ g_free (prefix);
#else
- catalogs_dir = g_strdup (GLADE_CATALOGSDIR);
- modules_dir = g_strdup (GLADE_MODULESDIR);
- pixmaps_dir = g_strdup (GLADE_PIXMAPSDIR);
- locale_dir = g_strdup (GLADE_LOCALEDIR);
- bin_dir = g_strdup (GLADE_BINDIR);
+ catalogs_dir = g_strdup (GLADE_CATALOGSDIR);
+ modules_dir = g_strdup (GLADE_MODULESDIR);
+ pixmaps_dir = g_strdup (GLADE_PIXMAPSDIR);
+ locale_dir = g_strdup (GLADE_LOCALEDIR);
+ bin_dir = g_strdup (GLADE_BINDIR);
#endif
}
/* initialization function for libgladeui (not GladeApp) */
static void
glade_init_check (void)
-{
- if (check_initialised)
- return;
+{
+ if (check_initialised)
+ return;
- /* Make sure path accessors work on osx */
- g_type_init ();
+ /* Make sure path accessors work on osx */
+ g_type_init ();
- build_package_paths ();
+ build_package_paths ();
- bindtextdomain (GETTEXT_PACKAGE, locale_dir);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ bindtextdomain (GETTEXT_PACKAGE, locale_dir);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- check_initialised = TRUE;
+ check_initialised = TRUE;
}
static void
-glade_app_init (GladeApp *app)
-{
- static gboolean initialized = FALSE;
-
- app->priv = GLADE_APP_GET_PRIVATE (app);
-
- singleton_app = app;
-
- glade_init_check ();
-
- if (!initialized)
- {
- gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
- pixmaps_dir);
-
- glade_cursor_init ();
-
- initialized = TRUE;
- }
-
- app->priv->accel_group = NULL;
-
- /* Initialize app objects */
- app->priv->catalogs = (GList *) glade_catalog_load_all ();
-
- /* Create palette */
- app->priv->palette = (GladePalette *) glade_palette_new (app->priv->catalogs);
- g_object_ref_sink (app->priv->palette);
-
- /* Create Editor */
- app->priv->editor = GLADE_EDITOR (glade_editor_new ());
- g_object_ref_sink (G_OBJECT (app->priv->editor));
-
- glade_editor_refresh (app->priv->editor);
-
- /* Create clipboard */
- app->priv->clipboard = glade_clipboard_new ();
-
- /* Load the configuration file */
- app->priv->config = glade_app_config_load (app);
-
- /* Undo/Redo button list */
- app->priv->undo_list = app->priv->redo_list = NULL;
+glade_app_init (GladeApp * app)
+{
+ static gboolean initialized = FALSE;
+
+ app->priv = GLADE_APP_GET_PRIVATE (app);
+
+ singleton_app = app;
+
+ glade_init_check ();
+
+ if (!initialized)
+ {
+ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+ pixmaps_dir);
+
+ glade_cursor_init ();
+
+ initialized = TRUE;
+ }
+
+ app->priv->accel_group = NULL;
+
+ /* Initialize app objects */
+ app->priv->catalogs = (GList *) glade_catalog_load_all ();
+
+ /* Create palette */
+ app->priv->palette = (GladePalette *) glade_palette_new (app->priv->catalogs);
+ g_object_ref_sink (app->priv->palette);
+
+ /* Create Editor */
+ app->priv->editor = GLADE_EDITOR (glade_editor_new ());
+ g_object_ref_sink (G_OBJECT (app->priv->editor));
+
+ glade_editor_refresh (app->priv->editor);
+
+ /* Create clipboard */
+ app->priv->clipboard = glade_clipboard_new ();
+
+ /* Load the configuration file */
+ app->priv->config = glade_app_config_load (app);
+
+ /* Undo/Redo button list */
+ app->priv->undo_list = app->priv->redo_list = NULL;
}
static void
glade_app_class_init (GladeAppClass * klass)
{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = glade_app_constructor;
- object_class->dispose = glade_app_dispose;
- object_class->finalize = glade_app_finalize;
- object_class->get_property = glade_app_get_property;
- object_class->set_property = glade_app_set_property;
-
- klass->update_ui_signal = glade_app_update_ui_default;
- klass->signal_editor_created = glade_app_signal_editor_created_default;
- klass->show_properties = NULL;
- klass->hide_properties = NULL;
-
- /**
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = glade_app_constructor;
+ object_class->dispose = glade_app_dispose;
+ object_class->finalize = glade_app_finalize;
+ object_class->get_property = glade_app_get_property;
+ object_class->set_property = glade_app_set_property;
+
+ klass->update_ui_signal = glade_app_update_ui_default;
+ klass->signal_editor_created = glade_app_signal_editor_created_default;
+ klass->show_properties = NULL;
+ klass->hide_properties = NULL;
+
+ /**
* GladeApp::update-ui:
* @gladeapp: the #GladeApp which received the signal.
*
* Emitted when a project name changes or a cut/copy/paste/delete occurred.
*/
- glade_app_signals[UPDATE_UI] =
- g_signal_new ("update-ui",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GladeAppClass,
- update_ui_signal),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
+ glade_app_signals[UPDATE_UI] =
+ g_signal_new ("update-ui",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GladeAppClass,
+ update_ui_signal),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ /**
* GladeApp::signal-editor-created:
* @gladeapp: the #GladeApp which received the signal.
* @signal_editor: the new #GladeSignalEditor.
@@ -499,61 +494,56 @@ glade_app_class_init (GladeAppClass * klass)
* Connect your handler before the default handler for setting a custom column or renderer
* and after it for connecting to the tree view signals
*/
- glade_app_signals[SIGNAL_EDITOR_CREATED] =
- g_signal_new ("signal-editor-created",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeAppClass,
- signal_editor_created),
- NULL, NULL,
- glade_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
-
- g_object_class_install_property
- (object_class, PROP_ACTIVE_PROJECT,
- g_param_spec_object
- ("active-project", _("Active Project"),
- _("The active project"),
- GLADE_TYPE_PROJECT, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_POINTER_MODE,
- g_param_spec_enum
- ("pointer-mode", _("Pointer Mode"),
- _("Current mode for the pointer in the workspace"),
- GLADE_TYPE_POINTER_MODE,
- GLADE_POINTER_SELECT,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (klass, sizeof (GladeAppPrivate));
+ glade_app_signals[SIGNAL_EDITOR_CREATED] =
+ g_signal_new ("signal-editor-created",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeAppClass,
+ signal_editor_created),
+ NULL, NULL,
+ glade_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+ g_object_class_install_property
+ (object_class, PROP_ACTIVE_PROJECT,
+ g_param_spec_object
+ ("active-project", _("Active Project"),
+ _("The active project"), GLADE_TYPE_PROJECT, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_POINTER_MODE,
+ g_param_spec_enum
+ ("pointer-mode", _("Pointer Mode"),
+ _("Current mode for the pointer in the workspace"),
+ GLADE_TYPE_POINTER_MODE, GLADE_POINTER_SELECT, G_PARAM_READWRITE));
+
+ g_type_class_add_private (klass, sizeof (GladeAppPrivate));
}
/*****************************************************************
* Public API *
*****************************************************************/
static void
-on_project_selection_changed_cb (GladeProject *project, GladeApp *app)
+on_project_selection_changed_cb (GladeProject * project, GladeApp * app)
{
- GList *list;
- gint num;
+ GList *list;
+ gint num;
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GLADE_IS_APP (app));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_APP (app));
- /* Only update the editor if the selection has changed on
- * the currently active project.
- */
- if (app->priv->editor &&
- (project == glade_app_get_project ()))
- {
- list = glade_project_selection_get (project);
- num = g_list_length (list);
- if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
- glade_editor_load_widget (app->priv->editor,
- glade_widget_get_from_gobject (list->data));
- else
- glade_editor_load_widget (app->priv->editor, NULL);
- }
+ /* Only update the editor if the selection has changed on
+ * the currently active project.
+ */
+ if (app->priv->editor && (project == glade_app_get_project ()))
+ {
+ list = glade_project_selection_get (project);
+ num = g_list_length (list);
+ if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
+ glade_editor_load_widget (app->priv->editor,
+ glade_widget_get_from_gobject (list->data));
+ else
+ glade_editor_load_widget (app->priv->editor, NULL);
+ }
}
/**
@@ -566,279 +556,278 @@ on_project_selection_changed_cb (GladeProject *project, GladeApp *app)
gint
glade_app_config_save ()
{
- GIOChannel *channel;
- GIOStatus status;
- gchar *data=NULL, *filename;
- const gchar *config_dir = g_get_user_config_dir ();
- GError *error = NULL;
- gsize size, written, bytes_written = 0;
- static gboolean error_shown = FALSE;
- GladeApp *app;
-
- /* If we had any errors; wait untill next session to retry.
- */
- if (error_shown) return -1;
-
- app = glade_app_get ();
-
- /* Just in case... try to create the config directory */
- if (g_file_test (config_dir, G_FILE_TEST_IS_DIR) == FALSE)
- {
- if (g_file_test (config_dir, G_FILE_TEST_EXISTS))
- {
- /* Config dir exists but is not a directory */
- glade_util_ui_message
- (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Trying to save private data to %s directory "
- "but it is a regular file.\n"
- "No private data will be saved in this session"),
- config_dir);
- error_shown = TRUE;
- return -1;
- }
- else if (g_mkdir (config_dir, S_IRWXU) != 0)
- {
- /* Doesnt exist; failed to create */
- glade_util_ui_message
- (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Failed to create directory %s to save private data.\n"
- "No private data will be saved in this session"), config_dir);
- error_shown = TRUE;
- return -1;
- }
- }
-
- filename = g_build_filename (config_dir, GLADE_CONFIG_FILENAME, NULL);
-
- if ((channel = g_io_channel_new_file (filename, "w", &error)) != NULL)
- {
- if ((data = g_key_file_to_data (app->priv->config, &size, &error)) != NULL)
- {
-
- /* Implement loop here */
- while ((status = g_io_channel_write_chars
- (channel,
- data + bytes_written, /* Offset of write */
- size - bytes_written, /* Size left to write */
- &written, &error)) != G_IO_STATUS_ERROR &&
- (bytes_written + written) < size)
- bytes_written += written;
-
- if (status == G_IO_STATUS_ERROR)
- {
- glade_util_ui_message
- (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error writing private data to %s (%s).\n"
- "No private data will be saved in this session"),
- filename, error->message);
- error_shown = TRUE;
- }
- g_free (data);
- }
- else
- {
- glade_util_ui_message
- (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error serializing configuration data to save (%s).\n"
- "No private data will be saved in this session"),
- error->message);
- error_shown = TRUE;
- }
- g_io_channel_shutdown(channel, TRUE, NULL);
- g_io_channel_unref (channel);
- }
- else
- {
- glade_util_ui_message
- (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error opening %s to write private data (%s).\n"
- "No private data will be saved in this session"),
- filename, error->message);
- error_shown = TRUE;
- }
- g_free (filename);
-
- if (error)
- {
- g_error_free (error);
- return -1;
- }
- return 0;
+ GIOChannel *channel;
+ GIOStatus status;
+ gchar *data = NULL, *filename;
+ const gchar *config_dir = g_get_user_config_dir ();
+ GError *error = NULL;
+ gsize size, written, bytes_written = 0;
+ static gboolean error_shown = FALSE;
+ GladeApp *app;
+
+ /* If we had any errors; wait untill next session to retry.
+ */
+ if (error_shown)
+ return -1;
+
+ app = glade_app_get ();
+
+ /* Just in case... try to create the config directory */
+ if (g_file_test (config_dir, G_FILE_TEST_IS_DIR) == FALSE)
+ {
+ if (g_file_test (config_dir, G_FILE_TEST_EXISTS))
+ {
+ /* Config dir exists but is not a directory */
+ glade_util_ui_message
+ (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Trying to save private data to %s directory "
+ "but it is a regular file.\n"
+ "No private data will be saved in this session"), config_dir);
+ error_shown = TRUE;
+ return -1;
+ }
+ else if (g_mkdir (config_dir, S_IRWXU) != 0)
+ {
+ /* Doesnt exist; failed to create */
+ glade_util_ui_message
+ (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Failed to create directory %s to save private data.\n"
+ "No private data will be saved in this session"), config_dir);
+ error_shown = TRUE;
+ return -1;
+ }
+ }
+
+ filename = g_build_filename (config_dir, GLADE_CONFIG_FILENAME, NULL);
+
+ if ((channel = g_io_channel_new_file (filename, "w", &error)) != NULL)
+ {
+ if ((data =
+ g_key_file_to_data (app->priv->config, &size, &error)) != NULL)
+ {
+
+ /* Implement loop here */
+ while ((status = g_io_channel_write_chars (channel, data + bytes_written, /* Offset of write */
+ size - bytes_written, /* Size left to write */
+ &written,
+ &error)) !=
+ G_IO_STATUS_ERROR && (bytes_written + written) < size)
+ bytes_written += written;
+
+ if (status == G_IO_STATUS_ERROR)
+ {
+ glade_util_ui_message
+ (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error writing private data to %s (%s).\n"
+ "No private data will be saved in this session"),
+ filename, error->message);
+ error_shown = TRUE;
+ }
+ g_free (data);
+ }
+ else
+ {
+ glade_util_ui_message
+ (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error serializing configuration data to save (%s).\n"
+ "No private data will be saved in this session"),
+ error->message);
+ error_shown = TRUE;
+ }
+ g_io_channel_shutdown (channel, TRUE, NULL);
+ g_io_channel_unref (channel);
+ }
+ else
+ {
+ glade_util_ui_message
+ (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error opening %s to write private data (%s).\n"
+ "No private data will be saved in this session"),
+ filename, error->message);
+ error_shown = TRUE;
+ }
+ g_free (filename);
+
+ if (error)
+ {
+ g_error_free (error);
+ return -1;
+ }
+ return 0;
}
void
-glade_app_set_transient_parent (GtkWindow *parent)
+glade_app_set_transient_parent (GtkWindow * parent)
{
- GladeApp *app;
-
- g_return_if_fail (GTK_IS_WINDOW (parent));
+ GladeApp *app;
- app = glade_app_get ();
- app->priv->transient_parent = parent;
+ g_return_if_fail (GTK_IS_WINDOW (parent));
+
+ app = glade_app_get ();
+ app->priv->transient_parent = parent;
}
GtkWindow *
glade_app_get_transient_parent (void)
{
- GtkWindow *parent;
- GladeApp *app = glade_app_get ();
+ GtkWindow *parent;
+ GladeApp *app = glade_app_get ();
+
+ parent = app->priv->transient_parent;
- parent = app->priv->transient_parent;
-
- return parent;
+ return parent;
}
GladeApp *
glade_app_get (void)
{
- if (!singleton_app)
- g_critical ("No available GladeApp");
- return singleton_app;
+ if (!singleton_app)
+ g_critical ("No available GladeApp");
+ return singleton_app;
}
void
glade_app_update_ui (void)
{
- GladeApp *app = glade_app_get ();
+ GladeApp *app = glade_app_get ();
- g_signal_emit (G_OBJECT (app),
- glade_app_signals[UPDATE_UI], 0);
+ g_signal_emit (G_OBJECT (app), glade_app_signals[UPDATE_UI], 0);
}
void
-glade_app_set_window (GtkWidget *window)
+glade_app_set_window (GtkWidget * window)
{
- GladeApp *app = glade_app_get ();
+ GladeApp *app = glade_app_get ();
- app->priv->window = window;
+ app->priv->window = window;
}
GladeCatalog *
-glade_app_get_catalog (const gchar *name)
+glade_app_get_catalog (const gchar * name)
{
- GladeApp *app = glade_app_get ();
- GList *list;
- GladeCatalog *catalog;
+ GladeApp *app = glade_app_get ();
+ GList *list;
+ GladeCatalog *catalog;
- g_return_val_if_fail (name && name[0], NULL);
+ g_return_val_if_fail (name && name[0], NULL);
- for (list = app->priv->catalogs; list; list = list->next)
- {
- catalog = list->data;
- if (!strcmp (glade_catalog_get_name (catalog), name))
- return catalog;
- }
- return NULL;
+ for (list = app->priv->catalogs; list; list = list->next)
+ {
+ catalog = list->data;
+ if (!strcmp (glade_catalog_get_name (catalog), name))
+ return catalog;
+ }
+ return NULL;
}
gboolean
-glade_app_get_catalog_version (const gchar *name, gint *major, gint *minor)
+glade_app_get_catalog_version (const gchar * name, gint * major, gint * minor)
{
- GladeCatalog *catalog = glade_app_get_catalog (name);
+ GladeCatalog *catalog = glade_app_get_catalog (name);
+
+ g_return_val_if_fail (catalog != NULL, FALSE);
- g_return_val_if_fail (catalog != NULL, FALSE);
+ if (major)
+ *major = glade_catalog_get_major_version (catalog);
+ if (minor)
+ *minor = glade_catalog_get_minor_version (catalog);
- if (major)
- *major = glade_catalog_get_major_version (catalog);
- if (minor)
- *minor = glade_catalog_get_minor_version (catalog);
-
- return TRUE;
+ return TRUE;
}
GList *
glade_app_get_catalogs (void)
{
- GladeApp *app = glade_app_get ();
+ GladeApp *app = glade_app_get ();
- return app->priv->catalogs;
+ return app->priv->catalogs;
}
GtkWidget *
glade_app_get_window (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->window;
+ GladeApp *app = glade_app_get ();
+ return app->priv->window;
}
GladeEditor *
glade_app_get_editor (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->editor;
+ GladeApp *app = glade_app_get ();
+ return app->priv->editor;
}
GladePalette *
glade_app_get_palette (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->palette;
+ GladeApp *app = glade_app_get ();
+ return app->priv->palette;
}
GladeClipboard *
glade_app_get_clipboard (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->clipboard;
+ GladeApp *app = glade_app_get ();
+ return app->priv->clipboard;
}
GladeProject *
glade_app_get_project (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->active_project;
+ GladeApp *app = glade_app_get ();
+ return app->priv->active_project;
}
GladeProject *
glade_app_check_get_project (void)
{
- if (singleton_app)
- return glade_app_get_project ();
- return NULL;
+ if (singleton_app)
+ return glade_app_get_project ();
+ return NULL;
}
GList *
glade_app_get_projects (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->projects;
+ GladeApp *app = glade_app_get ();
+ return app->priv->projects;
}
GKeyFile *
glade_app_get_config (void)
{
- GladeApp *app = glade_app_get ();
- return app->priv->config;
+ GladeApp *app = glade_app_get ();
+ return app->priv->config;
}
gboolean
-glade_app_is_project_loaded (const gchar *project_path)
+glade_app_is_project_loaded (const gchar * project_path)
{
- GladeApp *app;
- GList *list;
- gboolean loaded = FALSE;
+ GladeApp *app;
+ GList *list;
+ gboolean loaded = FALSE;
- if (project_path == NULL)
- return FALSE;
+ if (project_path == NULL)
+ return FALSE;
- app = glade_app_get ();
+ app = glade_app_get ();
- for (list = app->priv->projects; list; list = list->next)
- {
- GladeProject *cur_project = GLADE_PROJECT (list->data);
+ for (list = app->priv->projects; list; list = list->next)
+ {
+ GladeProject *cur_project = GLADE_PROJECT (list->data);
- if ((loaded = glade_project_get_path (cur_project) &&
- (strcmp (glade_project_get_path (cur_project), project_path) == 0)))
- break;
- }
+ if ((loaded = glade_project_get_path (cur_project) &&
+ (strcmp (glade_project_get_path (cur_project), project_path) == 0)))
+ break;
+ }
- return loaded;
+ return loaded;
}
/**
@@ -849,150 +838,151 @@ glade_app_is_project_loaded (const gchar *project_path)
*
* Returns: A #GladeProject, or NULL if no such open project was found
*/
-GladeProject*
-glade_app_get_project_by_path (const gchar *project_path)
+GladeProject *
+glade_app_get_project_by_path (const gchar * project_path)
{
- GladeApp *app;
- GList *l;
- gchar *canonical_path;
+ GladeApp *app;
+ GList *l;
+ gchar *canonical_path;
- if (project_path == NULL)
- return NULL;
+ if (project_path == NULL)
+ return NULL;
- app = glade_app_get ();
+ app = glade_app_get ();
- canonical_path = glade_util_canonical_path (project_path);
+ canonical_path = glade_util_canonical_path (project_path);
- for (l = app->priv->projects; l; l = l->next)
- {
- GladeProject *project = (GladeProject *) l->data;
+ for (l = app->priv->projects; l; l = l->next)
+ {
+ GladeProject *project = (GladeProject *) l->data;
- if (glade_project_get_path (project) && strcmp (canonical_path, glade_project_get_path (project)) == 0) {
- g_free (canonical_path);
- return project;
- }
- }
+ if (glade_project_get_path (project) &&
+ strcmp (canonical_path, glade_project_get_path (project)) == 0)
+ {
+ g_free (canonical_path);
+ return project;
+ }
+ }
- g_free (canonical_path);
+ g_free (canonical_path);
- return NULL;
+ return NULL;
}
void
glade_app_show_properties (gboolean raise)
{
- GladeApp *app = glade_app_get ();
+ GladeApp *app = glade_app_get ();
- if (GLADE_APP_GET_CLASS (app)->show_properties)
- GLADE_APP_GET_CLASS (app)->show_properties (app, raise);
- else
- g_critical ("%s not implemented\n", G_STRFUNC);
+ if (GLADE_APP_GET_CLASS (app)->show_properties)
+ GLADE_APP_GET_CLASS (app)->show_properties (app, raise);
+ else
+ g_critical ("%s not implemented\n", G_STRFUNC);
}
void
glade_app_hide_properties (void)
{
- GladeApp *app = glade_app_get ();
+ GladeApp *app = glade_app_get ();
- if (GLADE_APP_GET_CLASS (app)->hide_properties)
- GLADE_APP_GET_CLASS (app)->hide_properties (app);
- else
- g_critical ("%s not implemented\n", G_STRFUNC);
+ if (GLADE_APP_GET_CLASS (app)->hide_properties)
+ GLADE_APP_GET_CLASS (app)->hide_properties (app);
+ else
+ g_critical ("%s not implemented\n", G_STRFUNC);
}
void
-glade_app_add_project (GladeProject *project)
-{
- GladeApp *app;
- GladeDesignView *view;
- GladeDesignLayout *layout;
-
- g_return_if_fail (GLADE_IS_PROJECT (project));
-
- app = glade_app_get ();
-
- /* If the project was previously loaded, don't re-load */
- if (g_list_find (app->priv->projects, project) != NULL)
- {
- glade_app_set_project (project);
- return;
- }
-
- /* Take a reference for GladeApp here... */
- app->priv->projects = g_list_append (app->priv->projects,
- g_object_ref (project));
-
- /* connect to the project signals so that the editor can be updated */
- g_signal_connect (G_OBJECT (project), "selection_changed",
- G_CALLBACK (on_project_selection_changed_cb), app);
-
-
- glade_app_set_project (project);
-
- /* Select the first window in the project */
- if (g_list_length (app->priv->projects) == 1 ||
- !(view = glade_design_view_get_from_project (project)) ||
- !(layout = glade_design_view_get_layout (view)) ||
- !gtk_bin_get_child (GTK_BIN (layout)))
- {
- const GList *node;
- for (node = glade_project_get_objects (project);
- node != NULL;
- node = g_list_next (node))
- {
- GObject *obj = G_OBJECT (node->data);
-
- if (GTK_IS_WIDGET (obj) &&
- gtk_widget_get_has_window (GTK_WIDGET (obj)))
- {
- glade_project_selection_set (project, obj, TRUE);
- glade_widget_show (glade_widget_get_from_gobject (obj));
- break;
- }
- }
- }
-
- /* XXX I think the palette & editor should detect this by itself */
- gtk_widget_set_sensitive (GTK_WIDGET (app->priv->palette), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (app->priv->editor), TRUE);
+glade_app_add_project (GladeProject * project)
+{
+ GladeApp *app;
+ GladeDesignView *view;
+ GladeDesignLayout *layout;
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+
+ app = glade_app_get ();
+
+ /* If the project was previously loaded, don't re-load */
+ if (g_list_find (app->priv->projects, project) != NULL)
+ {
+ glade_app_set_project (project);
+ return;
+ }
+
+ /* Take a reference for GladeApp here... */
+ app->priv->projects = g_list_append (app->priv->projects,
+ g_object_ref (project));
+
+ /* connect to the project signals so that the editor can be updated */
+ g_signal_connect (G_OBJECT (project), "selection_changed",
+ G_CALLBACK (on_project_selection_changed_cb), app);
+
+
+ glade_app_set_project (project);
+
+ /* Select the first window in the project */
+ if (g_list_length (app->priv->projects) == 1 ||
+ !(view = glade_design_view_get_from_project (project)) ||
+ !(layout = glade_design_view_get_layout (view)) ||
+ !gtk_bin_get_child (GTK_BIN (layout)))
+ {
+ const GList *node;
+ for (node = glade_project_get_objects (project);
+ node != NULL; node = g_list_next (node))
+ {
+ GObject *obj = G_OBJECT (node->data);
+
+ if (GTK_IS_WIDGET (obj) &&
+ gtk_widget_get_has_window (GTK_WIDGET (obj)))
+ {
+ glade_project_selection_set (project, obj, TRUE);
+ glade_widget_show (glade_widget_get_from_gobject (obj));
+ break;
+ }
+ }
+ }
+
+ /* XXX I think the palette & editor should detect this by itself */
+ gtk_widget_set_sensitive (GTK_WIDGET (app->priv->palette), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (app->priv->editor), TRUE);
}
void
-glade_app_remove_project (GladeProject *project)
+glade_app_remove_project (GladeProject * project)
{
- GladeApp *app;
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ GladeApp *app;
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- app = glade_app_get ();
+ app = glade_app_get ();
- app->priv->projects = g_list_remove (app->priv->projects, project);
+ app->priv->projects = g_list_remove (app->priv->projects, project);
- /* this is needed to prevent clearing the selection of a closed project
- */
- app->priv->active_project = NULL;
-
- /* If no more projects */
- if (app->priv->projects == NULL)
- {
- /* XXX I think the palette & editor should detect this. */
- gtk_widget_set_sensitive (GTK_WIDGET (app->priv->palette), FALSE);
-
- /* set loaded widget to NULL first so that we dont mess
- * around with sensitivity of the editor children.
- */
- glade_editor_load_widget (app->priv->editor, NULL);
- gtk_widget_set_sensitive (GTK_WIDGET (app->priv->editor), FALSE);
- }
- else
- glade_app_set_project (g_list_last (app->priv->projects)->data);
-
- /* Its safe to just release the project as the project emits a
- * "close" signal and everyone is responsable for cleaning up at
- * that point.
- */
- g_object_unref (project);
+ /* this is needed to prevent clearing the selection of a closed project
+ */
+ app->priv->active_project = NULL;
+
+ /* If no more projects */
+ if (app->priv->projects == NULL)
+ {
+ /* XXX I think the palette & editor should detect this. */
+ gtk_widget_set_sensitive (GTK_WIDGET (app->priv->palette), FALSE);
+
+ /* set loaded widget to NULL first so that we dont mess
+ * around with sensitivity of the editor children.
+ */
+ glade_editor_load_widget (app->priv->editor, NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (app->priv->editor), FALSE);
+ }
+ else
+ glade_app_set_project (g_list_last (app->priv->projects)->data);
+
+ /* Its safe to just release the project as the project emits a
+ * "close" signal and everyone is responsable for cleaning up at
+ * that point.
+ */
+ g_object_unref (project);
}
@@ -1003,38 +993,38 @@ glade_app_remove_project (GladeProject *project)
* Sets the active project in the #GladeApp to @project.
*/
void
-glade_app_set_project (GladeProject *project)
+glade_app_set_project (GladeProject * project)
{
- GladeApp *app = glade_app_get();
+ GladeApp *app = glade_app_get ();
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ if (app->priv->active_project == project)
+ return;
- if (app->priv->active_project == project)
- return;
+ if (!g_list_find (app->priv->projects, project))
+ {
+ g_warning ("Could not set project because it could not "
+ " be found in the app->priv->project list\n");
+ return;
+ }
- if (!g_list_find (app->priv->projects, project))
- {
- g_warning ("Could not set project because it could not "
- " be found in the app->priv->project list\n");
- return;
- }
+ /* clear the selection in the previous project */
+ if (app->priv->active_project)
+ glade_project_selection_clear (app->priv->active_project, FALSE);
- /* clear the selection in the previous project */
- if (app->priv->active_project)
- glade_project_selection_clear (app->priv->active_project, FALSE);
+ app->priv->active_project = project;
- app->priv->active_project = project;
+ /* (XXX really ?) trigger the selection changed signal to update the editor */
+ glade_project_selection_changed (project);
- /* (XXX really ?) trigger the selection changed signal to update the editor */
- glade_project_selection_changed (project);
-
- /* refresh palette for active project */
- glade_palette_refresh (glade_app_get_palette ());
+ /* refresh palette for active project */
+ glade_palette_refresh (glade_app_get_palette ());
- /* Update UI */
- glade_app_update_ui ();
+ /* Update UI */
+ glade_app_update_ui ();
- g_object_notify (G_OBJECT (app), "active-project");
+ g_object_notify (G_OBJECT (app), "active-project");
}
@@ -1047,11 +1037,11 @@ glade_app_set_project (GladeProject *project)
void
glade_app_set_pointer_mode (GladePointerMode mode)
{
- GladeApp *app = glade_app_get();
+ GladeApp *app = glade_app_get ();
- app->priv->pointer_mode = mode;
+ app->priv->pointer_mode = mode;
- g_object_notify (G_OBJECT (app), "pointer-mode");
+ g_object_notify (G_OBJECT (app), "pointer-mode");
}
@@ -1065,9 +1055,9 @@ glade_app_set_pointer_mode (GladePointerMode mode)
GladePointerMode
glade_app_get_pointer_mode (void)
{
- GladeApp *app = glade_app_get();
+ GladeApp *app = glade_app_get ();
- return app->priv->pointer_mode;
+ return app->priv->pointer_mode;
}
/**
@@ -1081,34 +1071,33 @@ glade_app_get_pointer_mode (void)
void
glade_app_command_copy (void)
{
- GladeApp *app;
- GList *widgets = NULL, *list;
- GladeWidget *widget;
- gboolean failed = FALSE;
+ GladeApp *app;
+ GList *widgets = NULL, *list;
+ GladeWidget *widget;
+ gboolean failed = FALSE;
- app = glade_app_get();
- if (app->priv->active_project == NULL ||
- glade_project_is_loading (app->priv->active_project))
- return;
+ app = glade_app_get ();
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
+ return;
- for (list = glade_app_get_selection ();
- list && list->data; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
- widgets = g_list_prepend (widgets, widget);
- }
+ for (list = glade_app_get_selection (); list && list->data; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
+ widgets = g_list_prepend (widgets, widget);
+ }
- if (failed == FALSE && widgets != NULL)
- {
- glade_command_copy (widgets);
- glade_app_update_ui ();
- }
- else if (widgets == NULL)
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("No widget selected."));
+ if (failed == FALSE && widgets != NULL)
+ {
+ glade_command_copy (widgets);
+ glade_app_update_ui ();
+ }
+ else if (widgets == NULL)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL, _("No widget selected."));
- if (widgets) g_list_free (widgets);
+ if (widgets)
+ g_list_free (widgets);
}
@@ -1123,34 +1112,33 @@ glade_app_command_copy (void)
void
glade_app_command_cut (void)
{
- GladeApp *app;
- GList *widgets = NULL, *list;
- GladeWidget *widget;
- gboolean failed = FALSE;
-
- app = glade_app_get();
- if (app->priv->active_project == NULL ||
- glade_project_is_loading (app->priv->active_project))
- return;
-
- for (list = glade_app_get_selection ();
- list && list->data; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
- widgets = g_list_prepend (widgets, widget);
- }
-
- if (failed == FALSE && widgets != NULL)
- {
- glade_command_cut (widgets);
- glade_app_update_ui ();
- }
- else if (widgets == NULL)
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("No widget selected."));
-
- if (widgets) g_list_free (widgets);
+ GladeApp *app;
+ GList *widgets = NULL, *list;
+ GladeWidget *widget;
+ gboolean failed = FALSE;
+
+ app = glade_app_get ();
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
+ return;
+
+ for (list = glade_app_get_selection (); list && list->data; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
+ widgets = g_list_prepend (widgets, widget);
+ }
+
+ if (failed == FALSE && widgets != NULL)
+ {
+ glade_command_cut (widgets);
+ glade_app_update_ui ();
+ }
+ else if (widgets == NULL)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL, _("No widget selected."));
+
+ if (widgets)
+ g_list_free (widgets);
}
@@ -1162,130 +1150,131 @@ glade_app_command_cut (void)
* selection (the project must have only one object selected).
*/
void
-glade_app_command_paste (GladePlaceholder *placeholder)
-{
- GladeApp *app;
- GladeClipboard *clipboard;
- GList *list;
- GladeWidget *widget = NULL, *parent;
- gint placeholder_relations = 0;
- GladeFixed *fixed = NULL;
-
- app = glade_app_get();
- if (app->priv->active_project == NULL ||
- glade_project_is_loading (app->priv->active_project))
- return;
-
- if (placeholder)
- {
- if (glade_placeholder_get_project (placeholder) == NULL ||
- glade_project_is_loading (glade_placeholder_get_project (placeholder)))
- return;
- }
-
- list = glade_project_selection_get (app->priv->active_project);
- clipboard = glade_app_get_clipboard ();
-
- /* If there is a selection, paste in to the selected widget, otherwise
- * paste into the placeholder's parent, or at the toplevel
- */
- parent = list ? glade_widget_get_from_gobject (list->data) :
- (placeholder) ? glade_placeholder_get_parent (placeholder) : NULL;
-
- widget = clipboard->selection ? clipboard->selection->data : NULL;
-
- /* Ignore parent argument if we are pasting a toplevel
- */
- if (g_list_length (clipboard->selection) == 1 &&
- widget && GWA_IS_TOPLEVEL (widget->adaptor))
- parent = NULL;
-
- if (parent && GLADE_IS_FIXED (parent)) fixed = GLADE_FIXED (parent);
-
- /* Check if parent is actually a container of any sort */
- if (parent &&
- !glade_widget_adaptor_is_container (parent->adaptor))
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("Unable to paste to the selected parent"));
- return;
- }
-
- /* Check if selection is good */
- if ((list = glade_app_get_selection ()) != NULL)
- {
- if (g_list_length (list) != 1)
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("Unable to paste to multiple widgets"));
-
- return;
- }
-
- }
-
- /* Abort operation when adding a non scrollable widget to any kind of GtkScrolledWindow. */
- if (parent && widget &&
- glade_util_check_and_warn_scrollable (parent, widget->adaptor, glade_app_get_window()))
- return;
-
- /* Check if we have anything to paste */
- if (g_list_length (clipboard->selection) == 0)
- {
- glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
- _("No widget selected on the clipboard"));
-
- return;
- }
-
- /* Check that we have compatible heirarchies */
- for (list = clipboard->selection;
- list && list->data; list = list->next)
- {
- widget = list->data;
-
- if (!GWA_IS_TOPLEVEL (widget->adaptor) && parent)
- {
- /* Count placeholder relations
- */
- if (glade_widget_placeholder_relation (parent, widget))
- placeholder_relations++;
- }
- }
-
- g_assert (widget);
-
- /* A GladeFixed that doesnt use placeholders can only paste one
- * at a time
- */
- if (GTK_IS_WIDGET (widget->object) &&
- gtk_widget_is_toplevel (GTK_WIDGET (widget->object)) == FALSE &&
- parent && fixed && !GWA_USE_PLACEHOLDERS (parent->adaptor) &&
- g_list_length (clipboard->selection) != 1)
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_INFO, NULL,
- _("Only one widget can be pasted at a "
- "time to this container"));
- return;
- }
-
- /* Check that enough placeholders are available */
- if (parent &&
- GWA_USE_PLACEHOLDERS (parent->adaptor) &&
- glade_util_count_placeholders (parent) < placeholder_relations)
- {
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_INFO, NULL,
- _("Insufficient amount of placeholders in "
- "target container"));
- return;
- }
-
- glade_command_paste (clipboard->selection, parent, placeholder);
- glade_app_update_ui ();
+glade_app_command_paste (GladePlaceholder * placeholder)
+{
+ GladeApp *app;
+ GladeClipboard *clipboard;
+ GList *list;
+ GladeWidget *widget = NULL, *parent;
+ gint placeholder_relations = 0;
+ GladeFixed *fixed = NULL;
+
+ app = glade_app_get ();
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
+ return;
+
+ if (placeholder)
+ {
+ if (glade_placeholder_get_project (placeholder) == NULL ||
+ glade_project_is_loading (glade_placeholder_get_project
+ (placeholder)))
+ return;
+ }
+
+ list = glade_project_selection_get (app->priv->active_project);
+ clipboard = glade_app_get_clipboard ();
+
+ /* If there is a selection, paste in to the selected widget, otherwise
+ * paste into the placeholder's parent, or at the toplevel
+ */
+ parent = list ? glade_widget_get_from_gobject (list->data) :
+ (placeholder) ? glade_placeholder_get_parent (placeholder) : NULL;
+
+ widget = clipboard->selection ? clipboard->selection->data : NULL;
+
+ /* Ignore parent argument if we are pasting a toplevel
+ */
+ if (g_list_length (clipboard->selection) == 1 &&
+ widget && GWA_IS_TOPLEVEL (widget->adaptor))
+ parent = NULL;
+
+ if (parent && GLADE_IS_FIXED (parent))
+ fixed = GLADE_FIXED (parent);
+
+ /* Check if parent is actually a container of any sort */
+ if (parent && !glade_widget_adaptor_is_container (parent->adaptor))
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Unable to paste to the selected parent"));
+ return;
+ }
+
+ /* Check if selection is good */
+ if ((list = glade_app_get_selection ()) != NULL)
+ {
+ if (g_list_length (list) != 1)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Unable to paste to multiple widgets"));
+
+ return;
+ }
+
+ }
+
+ /* Abort operation when adding a non scrollable widget to any kind of GtkScrolledWindow. */
+ if (parent && widget &&
+ glade_util_check_and_warn_scrollable (parent, widget->adaptor,
+ glade_app_get_window ()))
+ return;
+
+ /* Check if we have anything to paste */
+ if (g_list_length (clipboard->selection) == 0)
+ {
+ glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
+ _("No widget selected on the clipboard"));
+
+ return;
+ }
+
+ /* Check that we have compatible heirarchies */
+ for (list = clipboard->selection; list && list->data; list = list->next)
+ {
+ widget = list->data;
+
+ if (!GWA_IS_TOPLEVEL (widget->adaptor) && parent)
+ {
+ /* Count placeholder relations
+ */
+ if (glade_widget_placeholder_relation (parent, widget))
+ placeholder_relations++;
+ }
+ }
+
+ g_assert (widget);
+
+ /* A GladeFixed that doesnt use placeholders can only paste one
+ * at a time
+ */
+ if (GTK_IS_WIDGET (widget->object) &&
+ gtk_widget_is_toplevel (GTK_WIDGET (widget->object)) == FALSE &&
+ parent && fixed && !GWA_USE_PLACEHOLDERS (parent->adaptor) &&
+ g_list_length (clipboard->selection) != 1)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Only one widget can be pasted at a "
+ "time to this container"));
+ return;
+ }
+
+ /* Check that enough placeholders are available */
+ if (parent &&
+ GWA_USE_PLACEHOLDERS (parent->adaptor) &&
+ glade_util_count_placeholders (parent) < placeholder_relations)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Insufficient amount of placeholders in "
+ "target container"));
+ return;
+ }
+
+ glade_command_paste (clipboard->selection, parent, placeholder);
+ glade_app_update_ui ();
}
@@ -1297,34 +1286,33 @@ glade_app_command_paste (GladePlaceholder *placeholder)
void
glade_app_command_delete (void)
{
- GladeApp *app;
- GList *widgets = NULL, *list;
- GladeWidget *widget;
- gboolean failed = FALSE;
-
- app = glade_app_get();
- if (app->priv->active_project == NULL ||
- glade_project_is_loading (app->priv->active_project))
- return;
-
- for (list = glade_app_get_selection ();
- list && list->data; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
- widgets = g_list_prepend (widgets, widget);
- }
-
- if (failed == FALSE && widgets != NULL)
- {
- glade_command_delete (widgets);
- glade_app_update_ui ();
- }
- else if (widgets == NULL)
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("No widget selected."));
-
- if (widgets) g_list_free (widgets);
+ GladeApp *app;
+ GList *widgets = NULL, *list;
+ GladeWidget *widget;
+ gboolean failed = FALSE;
+
+ app = glade_app_get ();
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
+ return;
+
+ for (list = glade_app_get_selection (); list && list->data; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
+ widgets = g_list_prepend (widgets, widget);
+ }
+
+ if (failed == FALSE && widgets != NULL)
+ {
+ glade_command_delete (widgets);
+ glade_app_update_ui ();
+ }
+ else if (widgets == NULL)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL, _("No widget selected."));
+
+ if (widgets)
+ g_list_free (widgets);
}
/**
@@ -1335,46 +1323,46 @@ glade_app_command_delete (void)
void
glade_app_command_delete_clipboard (void)
{
- GladeClipboard *clipboard;
+ GladeClipboard *clipboard;
- clipboard = glade_app_get_clipboard ();
+ clipboard = glade_app_get_clipboard ();
- if (clipboard->selection == NULL)
- {
- glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
- _("No widget selected on the clipboard"));
- return;
- }
+ if (clipboard->selection == NULL)
+ {
+ glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
+ _("No widget selected on the clipboard"));
+ return;
+ }
- glade_command_delete (clipboard->selection);
- glade_app_update_ui ();
+ glade_command_delete (clipboard->selection);
+ glade_app_update_ui ();
}
void
glade_app_command_undo (void)
{
- GladeApp *app = glade_app_get();
- if (app->priv->active_project)
- {
- glade_project_undo (app->priv->active_project);
- glade_editor_refresh (app->priv->editor);
- /* Update UI. */
- glade_app_update_ui ();
- }
+ GladeApp *app = glade_app_get ();
+ if (app->priv->active_project)
+ {
+ glade_project_undo (app->priv->active_project);
+ glade_editor_refresh (app->priv->editor);
+ /* Update UI. */
+ glade_app_update_ui ();
+ }
}
void
glade_app_command_redo (void)
{
- GladeApp *app = glade_app_get();
- if (app->priv->active_project)
- {
- glade_project_redo (app->priv->active_project);
- glade_editor_refresh (app->priv->editor);
- /* Update UI. */
- glade_app_update_ui ();
- }
+ GladeApp *app = glade_app_get ();
+ if (app->priv->active_project)
+ {
+ glade_project_redo (app->priv->active_project);
+ glade_editor_refresh (app->priv->editor);
+ /* Update UI. */
+ glade_app_update_ui ();
+ }
}
/*
@@ -1385,68 +1373,63 @@ glade_app_command_redo (void)
* from the plugin backend.
*/
void
-glade_app_set_accel_group (GtkAccelGroup *accel_group)
+glade_app_set_accel_group (GtkAccelGroup * accel_group)
{
- GladeApp *app;
- g_return_if_fail(GTK_IS_ACCEL_GROUP (accel_group));
+ GladeApp *app;
+ g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
- app = glade_app_get ();
-
- app->priv->accel_group = accel_group;
+ app = glade_app_get ();
+
+ app->priv->accel_group = accel_group;
}
GtkAccelGroup *
glade_app_get_accel_group (void)
{
- return glade_app_get()->priv->accel_group;
+ return glade_app_get ()->priv->accel_group;
}
static gboolean
-glade_app_undo_button_destroyed (GtkWidget *button, GladeApp *app)
+glade_app_undo_button_destroyed (GtkWidget * button, GladeApp * app)
{
- app->priv->undo_list = g_list_remove (app->priv->undo_list, button);
- return FALSE;
+ app->priv->undo_list = g_list_remove (app->priv->undo_list, button);
+ return FALSE;
}
static gboolean
-glade_app_redo_button_destroyed (GtkWidget *button, GladeApp *app)
+glade_app_redo_button_destroyed (GtkWidget * button, GladeApp * app)
{
- app->priv->redo_list = g_list_remove (app->priv->redo_list, button);
- return FALSE;
+ app->priv->redo_list = g_list_remove (app->priv->redo_list, button);
+ return FALSE;
}
static GtkWidget *
-glade_app_undo_redo_button_new (GladeApp *app, gboolean undo)
-{
- GtkWidget *button;
-
- button = gtk_button_new_from_stock ((undo) ?
- GTK_STOCK_UNDO :
- GTK_STOCK_REDO);
-
- g_signal_connect_swapped (button, "clicked",
- (undo) ? G_CALLBACK (glade_app_command_undo) :
- G_CALLBACK (glade_app_command_redo),
- app);
-
- if (undo)
- {
- app->priv->undo_list = g_list_prepend (app->priv->undo_list, button);
- g_signal_connect (button, "destroy",
- G_CALLBACK (glade_app_undo_button_destroyed),
- app);
- }
- else
- {
- app->priv->redo_list = g_list_prepend (app->priv->redo_list, button);
- g_signal_connect (button, "destroy",
- G_CALLBACK (glade_app_redo_button_destroyed),
- app);
- }
-
- glade_app_refresh_undo_redo_button (app, button, undo);
-
- return button;
+glade_app_undo_redo_button_new (GladeApp * app, gboolean undo)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_from_stock ((undo) ? GTK_STOCK_UNDO : GTK_STOCK_REDO);
+
+ g_signal_connect_swapped (button, "clicked",
+ (undo) ? G_CALLBACK (glade_app_command_undo) :
+ G_CALLBACK (glade_app_command_redo), app);
+
+ if (undo)
+ {
+ app->priv->undo_list = g_list_prepend (app->priv->undo_list, button);
+ g_signal_connect (button, "destroy",
+ G_CALLBACK (glade_app_undo_button_destroyed), app);
+ }
+ else
+ {
+ app->priv->redo_list = g_list_prepend (app->priv->redo_list, button);
+ g_signal_connect (button, "destroy",
+ G_CALLBACK (glade_app_redo_button_destroyed), app);
+ }
+
+ glade_app_refresh_undo_redo_button (app, button, undo);
+
+ return button;
}
/*
@@ -1458,8 +1441,8 @@ glade_app_undo_redo_button_new (GladeApp *app, gboolean undo)
GtkWidget *
glade_app_undo_button_new (void)
{
- GladeApp *app = glade_app_get();
- return glade_app_undo_redo_button_new (app, TRUE);
+ GladeApp *app = glade_app_get ();
+ return glade_app_undo_redo_button_new (app, TRUE);
}
/*
@@ -1471,146 +1454,135 @@ glade_app_undo_button_new (void)
GtkWidget *
glade_app_redo_button_new (void)
{
- GladeApp *app = glade_app_get();
- return glade_app_undo_redo_button_new (app, FALSE);
+ GladeApp *app = glade_app_get ();
+ return glade_app_undo_redo_button_new (app, FALSE);
}
-GList*
+GList *
glade_app_get_selection (void)
{
- GList *selection = NULL, *list;
- GladeProject *project;
+ GList *selection = NULL, *list;
+ GladeProject *project;
- for (list = glade_app_get_projects ();
- list && list->data; list = list->next)
- {
- /* Only one project may have selection at a time
- */
- project = list->data;
- if (glade_project_selection_get (project))
- {
- selection = glade_project_selection_get (project);
- break;
- }
- }
- return selection;
+ for (list = glade_app_get_projects (); list && list->data; list = list->next)
+ {
+ /* Only one project may have selection at a time
+ */
+ project = list->data;
+ if (glade_project_selection_get (project))
+ {
+ selection = glade_project_selection_get (project);
+ break;
+ }
+ }
+ return selection;
}
gboolean
-glade_app_is_selected (GObject *object)
+glade_app_is_selected (GObject * object)
{
- return (g_list_find (glade_app_get_selection (), object) != NULL);
+ return (g_list_find (glade_app_get_selection (), object) != NULL);
}
void
-glade_app_selection_set (GObject *object,
- gboolean emit_signal)
-{
- GList *list;
- GladeProject *project;
-
- for (list = glade_app_get_projects ();
- list && list->data; list = list->next)
- {
- project = list->data;
- if (glade_project_has_object (project, object))
- glade_project_selection_set (project,
- object,
- emit_signal);
- else
- glade_project_selection_clear (project, emit_signal);
- }
-
- /* Instead of calling selection_set after all
- * the selection_clear calls (lazy).
- */
- if (GTK_IS_WIDGET (object))
- glade_util_add_selection (GTK_WIDGET (object));
+glade_app_selection_set (GObject * object, gboolean emit_signal)
+{
+ GList *list;
+ GladeProject *project;
+
+ for (list = glade_app_get_projects (); list && list->data; list = list->next)
+ {
+ project = list->data;
+ if (glade_project_has_object (project, object))
+ glade_project_selection_set (project, object, emit_signal);
+ else
+ glade_project_selection_clear (project, emit_signal);
+ }
+
+ /* Instead of calling selection_set after all
+ * the selection_clear calls (lazy).
+ */
+ if (GTK_IS_WIDGET (object))
+ glade_util_add_selection (GTK_WIDGET (object));
}
void
-glade_app_selection_add (GObject *object,
- gboolean emit_signal)
+glade_app_selection_add (GObject * object, gboolean emit_signal)
{
- GList *list;
- GladeWidget *widget = glade_widget_get_from_gobject (object),
- *selected;
- GladeProject *project = glade_widget_get_project (widget);
+ GList *list;
+ GladeWidget *widget = glade_widget_get_from_gobject (object), *selected;
+ GladeProject *project = glade_widget_get_project (widget);
- /* Ignore request if the there is a selection
- * from another project.
- */
- if ((list = glade_app_get_selection ()) != NULL)
- {
- selected = glade_widget_get_from_gobject (list->data);
- if (glade_widget_get_project (selected) != project)
- return;
- }
- glade_project_selection_add (project, object, emit_signal);
+ /* Ignore request if the there is a selection
+ * from another project.
+ */
+ if ((list = glade_app_get_selection ()) != NULL)
+ {
+ selected = glade_widget_get_from_gobject (list->data);
+ if (glade_widget_get_project (selected) != project)
+ return;
+ }
+ glade_project_selection_add (project, object, emit_signal);
}
void
-glade_app_selection_remove (GObject *object,
- gboolean emit_signal)
+glade_app_selection_remove (GObject * object, gboolean emit_signal)
{
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- GladeProject *project = glade_widget_get_project (widget);;
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ GladeProject *project = glade_widget_get_project (widget);;
- glade_project_selection_remove (project, object, emit_signal);
+ glade_project_selection_remove (project, object, emit_signal);
}
void
-glade_app_selection_clear (gboolean emit_signal)
+glade_app_selection_clear (gboolean emit_signal)
{
- GList *list;
- GladeProject *project;
+ GList *list;
+ GladeProject *project;
- glade_util_clear_selection ();
- for (list = glade_app_get_projects ();
- list && list->data; list = list->next)
- {
- project = list->data;
- glade_project_selection_clear (project, emit_signal);
- }
+ glade_util_clear_selection ();
+ for (list = glade_app_get_projects (); list && list->data; list = list->next)
+ {
+ project = list->data;
+ glade_project_selection_clear (project, emit_signal);
+ }
}
void
glade_app_selection_changed (void)
{
- GList *list;
- GladeProject *project;
+ GList *list;
+ GladeProject *project;
- for (list = glade_app_get_projects ();
- list && list->data; list = list->next)
- {
- project = list->data;
- glade_project_selection_changed (project);
- }
+ for (list = glade_app_get_projects (); list && list->data; list = list->next)
+ {
+ project = list->data;
+ glade_project_selection_changed (project);
+ }
}
static gboolean
-selection_change_idle (GladeApp *app)
+selection_change_idle (GladeApp * app)
{
- glade_app_selection_changed ();
- app->priv->selection_changed_id = 0;
- return FALSE;
+ glade_app_selection_changed ();
+ app->priv->selection_changed_id = 0;
+ return FALSE;
}
void
glade_app_queue_selection_changed (void)
{
- GladeApp *app = glade_app_get ();
+ GladeApp *app = glade_app_get ();
- if (app->priv->selection_changed_id == 0)
- app->priv->selection_changed_id =
- g_idle_add ((GSourceFunc)selection_change_idle, app);
+ if (app->priv->selection_changed_id == 0)
+ app->priv->selection_changed_id =
+ g_idle_add ((GSourceFunc) selection_change_idle, app);
}
-GladeApp*
+GladeApp *
glade_app_new (void)
{
- return g_object_new (GLADE_TYPE_APP, NULL);
+ return g_object_new (GLADE_TYPE_APP, NULL);
}
-
diff --git a/gladeui/glade-app.h b/gladeui/glade-app.h
index 6570baa..3498e1c 100644
--- a/gladeui/glade-app.h
+++ b/gladeui/glade-app.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
diff --git a/gladeui/glade-base-editor.c b/gladeui/glade-base-editor.c
index a2000a8..a46e1c9 100644
--- a/gladeui/glade-base-editor.c
+++ b/gladeui/glade-base-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2006 Juan Pablo Ugarte.
*
@@ -43,1434 +42,1431 @@
typedef enum
{
- GLADE_BASE_EDITOR_GTYPE,
- GLADE_BASE_EDITOR_CLASS_NAME,
- GLADE_BASE_EDITOR_TYPES_N_COLUMNS
-}GladeBaseEditorChildEnum;
+ GLADE_BASE_EDITOR_GTYPE,
+ GLADE_BASE_EDITOR_CLASS_NAME,
+ GLADE_BASE_EDITOR_TYPES_N_COLUMNS
+} GladeBaseEditorChildEnum;
typedef enum
{
- GLADE_BASE_EDITOR_GWIDGET,
- GLADE_BASE_EDITOR_OBJECT,
- GLADE_BASE_EDITOR_TYPE_NAME,
- GLADE_BASE_EDITOR_NAME,
- GLADE_BASE_EDITOR_CHILD_TYPES,
- GLADE_BASE_EDITOR_N_COLUMNS
-}GladeBaseEditorEnum;
-
-typedef struct {
- GType parent_type;
- GtkTreeModel *children;
+ GLADE_BASE_EDITOR_GWIDGET,
+ GLADE_BASE_EDITOR_OBJECT,
+ GLADE_BASE_EDITOR_TYPE_NAME,
+ GLADE_BASE_EDITOR_NAME,
+ GLADE_BASE_EDITOR_CHILD_TYPES,
+ GLADE_BASE_EDITOR_N_COLUMNS
+} GladeBaseEditorEnum;
+
+typedef struct
+{
+ GType parent_type;
+ GtkTreeModel *children;
} ChildTypeTab;
struct _GladeBaseEditorPrivate
{
- GladeWidget *gcontainer; /* The container we are editing */
-
- /* Editor UI */
- GtkWidget *paned, *table, *treeview, *main_scroll, *notebook;
- GtkWidget *remove_button;
- GladeSignalEditor *signal_editor;
-
- GList *child_types;
-
- GtkTreeModel *model;
- GladeProject *project;
-
- /* Add button data */
- GType add_type;
- gboolean add_as_child;
-
- /* Temporal variables */
- GtkTreeIter iter; /* used in idle functions */
- gint row;
-
- gboolean updating_treeview;
-
- guint properties_idle;
+ GladeWidget *gcontainer; /* The container we are editing */
+
+ /* Editor UI */
+ GtkWidget *paned, *table, *treeview, *main_scroll, *notebook;
+ GtkWidget *remove_button;
+ GladeSignalEditor *signal_editor;
+
+ GList *child_types;
+
+ GtkTreeModel *model;
+ GladeProject *project;
+
+ /* Add button data */
+ GType add_type;
+ gboolean add_as_child;
+
+ /* Temporal variables */
+ GtkTreeIter iter; /* used in idle functions */
+ gint row;
+
+ gboolean updating_treeview;
+
+ guint properties_idle;
};
-enum {
- SIGNAL_CHILD_SELECTED,
- SIGNAL_CHANGE_TYPE,
- SIGNAL_GET_DISPLAY_NAME,
- SIGNAL_BUILD_CHILD,
- SIGNAL_DELETE_CHILD,
- SIGNAL_MOVE_CHILD,
- LAST_SIGNAL
+enum
+{
+ SIGNAL_CHILD_SELECTED,
+ SIGNAL_CHANGE_TYPE,
+ SIGNAL_GET_DISPLAY_NAME,
+ SIGNAL_BUILD_CHILD,
+ SIGNAL_DELETE_CHILD,
+ SIGNAL_MOVE_CHILD,
+ LAST_SIGNAL
};
-enum {
- PROP_0,
- PROP_CONTAINER,
+enum
+{
+ PROP_0,
+ PROP_CONTAINER,
};
-static guint glade_base_editor_signals [LAST_SIGNAL] = { 0 };
+static guint glade_base_editor_signals[LAST_SIGNAL] = { 0 };
+
static GtkVBoxClass *parent_class = NULL;
-static void glade_base_editor_set_container (GladeBaseEditor *editor,
- GObject *container);
-static void glade_base_editor_block_callbacks (GladeBaseEditor *editor,
- gboolean block);
+static void glade_base_editor_set_container (GladeBaseEditor * editor,
+ GObject * container);
+static void glade_base_editor_block_callbacks (GladeBaseEditor * editor,
+ gboolean block);
static void
-reset_child_types (GladeBaseEditor *editor)
+reset_child_types (GladeBaseEditor * editor)
{
- GList *l;
- ChildTypeTab *tab;
+ GList *l;
+ ChildTypeTab *tab;
- for (l = editor->priv->child_types; l; l = l->next)
- {
- tab = l->data;
- g_object_unref (tab->children);
- g_free (tab);
- }
- g_list_free (editor->priv->child_types);
- editor->priv->child_types = NULL;
+ for (l = editor->priv->child_types; l; l = l->next)
+ {
+ tab = l->data;
+ g_object_unref (tab->children);
+ g_free (tab);
+ }
+ g_list_free (editor->priv->child_types);
+ editor->priv->child_types = NULL;
}
static gint
-sort_type_by_hierarchy (ChildTypeTab *a, ChildTypeTab *b)
+sort_type_by_hierarchy (ChildTypeTab * a, ChildTypeTab * b)
{
- if (g_type_is_a (a->parent_type, b->parent_type))
- return -1;
-
- return 1;
+ if (g_type_is_a (a->parent_type, b->parent_type))
+ return -1;
+
+ return 1;
}
static GtkTreeModel *
-get_children_model_for_type (GladeBaseEditor *editor, GType type)
+get_children_model_for_type (GladeBaseEditor * editor, GType type)
{
- GList *l;
- for (l = editor->priv->child_types; l; l = l->next)
- {
- ChildTypeTab *tab = l->data;
- if (g_type_is_a (type, tab->parent_type))
- return tab->children;
- }
- return NULL;
+ GList *l;
+ for (l = editor->priv->child_types; l; l = l->next)
+ {
+ ChildTypeTab *tab = l->data;
+ if (g_type_is_a (type, tab->parent_type))
+ return tab->children;
+ }
+ return NULL;
}
static GtkTreeModel *
-get_children_model_for_child_type (GladeBaseEditor *editor, GType type)
+get_children_model_for_child_type (GladeBaseEditor * editor, GType type)
{
- GList *l;
- GtkTreeModel *model = NULL;
+ GList *l;
+ GtkTreeModel *model = NULL;
- /* Get deep derived classes first and work up the sorted heirarchy */
- for (l = g_list_last (editor->priv->child_types); model == NULL && l; l = l->prev)
- {
- ChildTypeTab *tab = l->data;
- GtkTreeIter iter;
- GType iter_type;
+ /* Get deep derived classes first and work up the sorted heirarchy */
+ for (l = g_list_last (editor->priv->child_types); model == NULL && l;
+ l = l->prev)
+ {
+ ChildTypeTab *tab = l->data;
+ GtkTreeIter iter;
+ GType iter_type;
- if (!gtk_tree_model_get_iter_first (tab->children, &iter))
- continue;
+ if (!gtk_tree_model_get_iter_first (tab->children, &iter))
+ continue;
- do
- {
- gtk_tree_model_get (tab->children, &iter,
- GLADE_BASE_EDITOR_GTYPE, &iter_type,
- -1);
+ do
+ {
+ gtk_tree_model_get (tab->children, &iter,
+ GLADE_BASE_EDITOR_GTYPE, &iter_type, -1);
- /* Find exact match types in this case */
- if (iter_type == type)
- model = tab->children;
+ /* Find exact match types in this case */
+ if (iter_type == type)
+ model = tab->children;
- } while (model == NULL &&
- gtk_tree_model_iter_next (tab->children, &iter));
- }
+ }
+ while (model == NULL && gtk_tree_model_iter_next (tab->children, &iter));
+ }
- return model;
+ return model;
}
static gboolean
-glade_base_editor_get_type_info (GladeBaseEditor *e,
- GtkTreeIter *retiter,
- GType child_type,
- ...)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GType type;
-
- model = get_children_model_for_child_type (e, child_type);
-
- if (!model || gtk_tree_model_get_iter_first (model, &iter) == FALSE)
- return FALSE;
-
- do
- {
- gtk_tree_model_get (model, &iter,
- GLADE_BASE_EDITOR_GTYPE, &type,
- -1);
-
- if (child_type == type)
- {
- va_list args;
- va_start (args, child_type);
- gtk_tree_model_get_valist (model, &iter, args);
- va_end (args);
- if (retiter) *retiter = iter;
- return TRUE;
- }
- } while (gtk_tree_model_iter_next (model, &iter));
-
- return FALSE;
+glade_base_editor_get_type_info (GladeBaseEditor * e,
+ GtkTreeIter * retiter, GType child_type, ...)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GType type;
+
+ model = get_children_model_for_child_type (e, child_type);
+
+ if (!model || gtk_tree_model_get_iter_first (model, &iter) == FALSE)
+ return FALSE;
+
+ do
+ {
+ gtk_tree_model_get (model, &iter, GLADE_BASE_EDITOR_GTYPE, &type, -1);
+
+ if (child_type == type)
+ {
+ va_list args;
+ va_start (args, child_type);
+ gtk_tree_model_get_valist (model, &iter, args);
+ va_end (args);
+ if (retiter)
+ *retiter = iter;
+ return TRUE;
+ }
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
+
+ return FALSE;
}
static gchar *
-glade_base_editor_get_display_name (GladeBaseEditor *editor,
- GladeWidget *gchild)
+glade_base_editor_get_display_name (GladeBaseEditor * editor,
+ GladeWidget * gchild)
{
- gchar *retval;
- g_signal_emit (editor,
- glade_base_editor_signals[SIGNAL_GET_DISPLAY_NAME],
- 0, gchild, &retval);
- return retval;
+ gchar *retval;
+ g_signal_emit (editor,
+ glade_base_editor_signals[SIGNAL_GET_DISPLAY_NAME],
+ 0, gchild, &retval);
+ return retval;
}
static void
-glade_base_editor_fill_store_real (GladeBaseEditor *e,
- GladeWidget *gwidget,
- GtkTreeIter *parent)
-{
- GObject *object = glade_widget_get_object (gwidget);
- GList *children, *l;
- GladeWidget *gparent = NULL;
- GtkTreeIter iter;
-
- if (parent)
- gtk_tree_model_get (e->priv->model, parent,
- GLADE_BASE_EDITOR_GWIDGET, &gparent,
- -1);
-
-
- children = glade_widget_adaptor_get_children (gwidget->adaptor, object);
-
- for (l = children; l; l = l->next)
- {
- GObject *child = (GObject*)l->data;
- GladeWidget *gchild;
-
- if (child && (gchild = glade_widget_get_from_gobject (child)))
- {
- gchar *type_name = NULL, *name;
-
-
- /* Have to check parents here for compatibility (could be the parenting menuitem of this menu
- * supports a menuitem...) */
- if (glade_base_editor_get_type_info (e, NULL,
- G_OBJECT_TYPE (child),
- GLADE_BASE_EDITOR_CLASS_NAME, &type_name,
- -1))
- {
- gtk_tree_store_append (GTK_TREE_STORE (e->priv->model), &iter, parent);
-
- name = glade_base_editor_get_display_name (e, gchild);
-
- gtk_tree_store_set (GTK_TREE_STORE (e->priv->model), &iter,
- GLADE_BASE_EDITOR_GWIDGET, gchild,
- GLADE_BASE_EDITOR_OBJECT, child,
- GLADE_BASE_EDITOR_TYPE_NAME, type_name,
- GLADE_BASE_EDITOR_NAME, name,
- GLADE_BASE_EDITOR_CHILD_TYPES,
- get_children_model_for_child_type (e, G_OBJECT_TYPE (child)),
- -1);
-
- glade_base_editor_fill_store_real (e, gchild, &iter);
-
- g_free (name);
- g_free (type_name);
- }
- else
- glade_base_editor_fill_store_real (e, gchild, parent);
-
- }
- }
-
- g_list_free (children);
+glade_base_editor_fill_store_real (GladeBaseEditor * e,
+ GladeWidget * gwidget, GtkTreeIter * parent)
+{
+ GObject *object = glade_widget_get_object (gwidget);
+ GList *children, *l;
+ GladeWidget *gparent = NULL;
+ GtkTreeIter iter;
+
+ if (parent)
+ gtk_tree_model_get (e->priv->model, parent,
+ GLADE_BASE_EDITOR_GWIDGET, &gparent, -1);
+
+
+ children = glade_widget_adaptor_get_children (gwidget->adaptor, object);
+
+ for (l = children; l; l = l->next)
+ {
+ GObject *child = (GObject *) l->data;
+ GladeWidget *gchild;
+
+ if (child && (gchild = glade_widget_get_from_gobject (child)))
+ {
+ gchar *type_name = NULL, *name;
+
+
+ /* Have to check parents here for compatibility (could be the parenting menuitem of this menu
+ * supports a menuitem...) */
+ if (glade_base_editor_get_type_info (e, NULL,
+ G_OBJECT_TYPE (child),
+ GLADE_BASE_EDITOR_CLASS_NAME,
+ &type_name, -1))
+ {
+ gtk_tree_store_append (GTK_TREE_STORE (e->priv->model), &iter,
+ parent);
+
+ name = glade_base_editor_get_display_name (e, gchild);
+
+ gtk_tree_store_set (GTK_TREE_STORE (e->priv->model), &iter,
+ GLADE_BASE_EDITOR_GWIDGET, gchild,
+ GLADE_BASE_EDITOR_OBJECT, child,
+ GLADE_BASE_EDITOR_TYPE_NAME, type_name,
+ GLADE_BASE_EDITOR_NAME, name,
+ GLADE_BASE_EDITOR_CHILD_TYPES,
+ get_children_model_for_child_type (e,
+ G_OBJECT_TYPE
+ (child)),
+ -1);
+
+ glade_base_editor_fill_store_real (e, gchild, &iter);
+
+ g_free (name);
+ g_free (type_name);
+ }
+ else
+ glade_base_editor_fill_store_real (e, gchild, parent);
+
+ }
+ }
+
+ g_list_free (children);
}
static void
-glade_base_editor_fill_store (GladeBaseEditor *e)
+glade_base_editor_fill_store (GladeBaseEditor * e)
{
- gtk_tree_store_clear (GTK_TREE_STORE (e->priv->model));
- gtk_tree_view_set_model (GTK_TREE_VIEW (e->priv->treeview), NULL);
- glade_base_editor_fill_store_real (e, e->priv->gcontainer, NULL);
- gtk_tree_view_set_model (GTK_TREE_VIEW (e->priv->treeview), e->priv->model);
+ gtk_tree_store_clear (GTK_TREE_STORE (e->priv->model));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (e->priv->treeview), NULL);
+ glade_base_editor_fill_store_real (e, e->priv->gcontainer, NULL);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (e->priv->treeview), e->priv->model);
- gtk_tree_view_expand_all (GTK_TREE_VIEW (e->priv->treeview));
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (e->priv->treeview));
}
static gboolean
-glade_base_editor_get_child_selected (GladeBaseEditor *e, GtkTreeIter *iter)
+glade_base_editor_get_child_selected (GladeBaseEditor * e, GtkTreeIter * iter)
{
- GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (e->priv->treeview));
- return gtk_tree_selection_get_selected (sel, NULL, iter);
+ GtkTreeSelection *sel =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (e->priv->treeview));
+ return gtk_tree_selection_get_selected (sel, NULL, iter);
}
/* Forward declaration for glade_base_editor_project_widget_name_changed */
static void
-glade_base_editor_project_widget_name_changed (GladeProject *project,
- GladeWidget *widget,
- GladeBaseEditor *editor);
+glade_base_editor_project_widget_name_changed (GladeProject * project,
+ GladeWidget * widget,
+ GladeBaseEditor * editor);
static GladeWidget *
-glade_base_editor_delegate_build_child (GladeBaseEditor *editor,
- GladeWidget *parent,
- GType type)
+glade_base_editor_delegate_build_child (GladeBaseEditor * editor,
+ GladeWidget * parent, GType type)
{
- GladeWidget *child = NULL;
- g_signal_emit (editor, glade_base_editor_signals[SIGNAL_BUILD_CHILD],
- 0, parent, type, &child);
- return child;
+ GladeWidget *child = NULL;
+ g_signal_emit (editor, glade_base_editor_signals[SIGNAL_BUILD_CHILD],
+ 0, parent, type, &child);
+ return child;
}
static gboolean
-glade_base_editor_delegate_delete_child (GladeBaseEditor *editor,
- GladeWidget *parent,
- GladeWidget *child)
+glade_base_editor_delegate_delete_child (GladeBaseEditor * editor,
+ GladeWidget * parent,
+ GladeWidget * child)
{
- gboolean retval;
+ gboolean retval;
- g_signal_emit (editor, glade_base_editor_signals[SIGNAL_DELETE_CHILD],
- 0, parent, child, &retval);
+ g_signal_emit (editor, glade_base_editor_signals[SIGNAL_DELETE_CHILD],
+ 0, parent, child, &retval);
- return retval;
+ return retval;
}
static void
-glade_base_editor_name_activate (GtkEntry *entry, GladeWidget *gchild)
+glade_base_editor_name_activate (GtkEntry * entry, GladeWidget * gchild)
{
- const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
- GladeBaseEditor *editor = g_object_get_data (G_OBJECT (entry), "editor");
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
+ GladeBaseEditor *editor = g_object_get_data (G_OBJECT (entry), "editor");
- if (strcmp (glade_widget_get_name (gchild), text))
- {
- g_signal_handlers_block_by_func (gchild->project,
- glade_base_editor_project_widget_name_changed,
- editor);
- glade_command_set_name (gchild, text);
- g_signal_handlers_unblock_by_func (gchild->project,
- glade_base_editor_project_widget_name_changed,
- editor);
- }
+ if (strcmp (glade_widget_get_name (gchild), text))
+ {
+ g_signal_handlers_block_by_func (gchild->project,
+ glade_base_editor_project_widget_name_changed,
+ editor);
+ glade_command_set_name (gchild, text);
+ g_signal_handlers_unblock_by_func (gchild->project,
+ glade_base_editor_project_widget_name_changed,
+ editor);
+ }
}
static void
-glade_base_editor_remove_widget (GtkWidget *widget, gpointer container)
+glade_base_editor_remove_widget (GtkWidget * widget, gpointer container)
{
- gtk_container_remove (GTK_CONTAINER (container), widget);
+ gtk_container_remove (GTK_CONTAINER (container), widget);
}
static void
-glade_base_editor_table_attach (GladeBaseEditor *e,
- GtkWidget *child1,
- GtkWidget *child2)
-{
- GtkGrid *table = GTK_GRID (e->priv->table);
- gint row = e->priv->row;
-
- if (child1)
- {
- gtk_grid_attach (table, child1, 0, row, 1, 1);
- gtk_widget_set_hexpand (child1, TRUE);
- gtk_widget_show (child1);
- }
-
- if (child2)
- {
- gtk_grid_attach (table, child2, 1, row, 1, 1);
- gtk_widget_show (child2);
- }
-
- e->priv->row++;
+glade_base_editor_table_attach (GladeBaseEditor * e,
+ GtkWidget * child1, GtkWidget * child2)
+{
+ GtkGrid *table = GTK_GRID (e->priv->table);
+ gint row = e->priv->row;
+
+ if (child1)
+ {
+ gtk_grid_attach (table, child1, 0, row, 1, 1);
+ gtk_widget_set_hexpand (child1, TRUE);
+ gtk_widget_show (child1);
+ }
+
+ if (child2)
+ {
+ gtk_grid_attach (table, child2, 1, row, 1, 1);
+ gtk_widget_show (child2);
+ }
+
+ e->priv->row++;
}
static void
-glade_base_editor_clear (GladeBaseEditor *editor)
+glade_base_editor_clear (GladeBaseEditor * editor)
{
- GladeBaseEditorPrivate *e = editor->priv;
- gtk_container_foreach (GTK_CONTAINER (e->table),
- glade_base_editor_remove_widget, e->table);
- e->row = 0;
- gtk_widget_set_sensitive (e->remove_button, FALSE);
- glade_signal_editor_load_widget (e->signal_editor, NULL);
+ GladeBaseEditorPrivate *e = editor->priv;
+ gtk_container_foreach (GTK_CONTAINER (e->table),
+ glade_base_editor_remove_widget, e->table);
+ e->row = 0;
+ gtk_widget_set_sensitive (e->remove_button, FALSE);
+ glade_signal_editor_load_widget (e->signal_editor, NULL);
}
static void
-glade_base_editor_treeview_cursor_changed (GtkTreeView *treeview,
- GladeBaseEditor *editor)
+glade_base_editor_treeview_cursor_changed (GtkTreeView * treeview,
+ GladeBaseEditor * editor)
{
- GladeBaseEditorPrivate *e = editor->priv;
- GtkTreeIter iter;
- GObject *child;
- GladeWidget *gchild;
+ GladeBaseEditorPrivate *e = editor->priv;
+ GtkTreeIter iter;
+ GObject *child;
+ GladeWidget *gchild;
- g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
+ g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
- if (!glade_base_editor_get_child_selected (editor, &iter))
- return;
+ if (!glade_base_editor_get_child_selected (editor, &iter))
+ return;
- glade_base_editor_clear (editor);
- gtk_widget_set_sensitive (e->remove_button, TRUE);
-
- gtk_tree_model_get (e->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &gchild,
- GLADE_BASE_EDITOR_OBJECT, &child,
- -1);
+ glade_base_editor_clear (editor);
+ gtk_widget_set_sensitive (e->remove_button, TRUE);
- /* Emit child-selected signal and let the user add the properties */
- g_signal_emit (editor, glade_base_editor_signals[SIGNAL_CHILD_SELECTED],
- 0, gchild);
+ gtk_tree_model_get (e->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gchild,
+ GLADE_BASE_EDITOR_OBJECT, &child, -1);
- /* Update Signal Editor */
- glade_signal_editor_load_widget (e->signal_editor, gchild);
+ /* Emit child-selected signal and let the user add the properties */
+ g_signal_emit (editor, glade_base_editor_signals[SIGNAL_CHILD_SELECTED],
+ 0, gchild);
+
+ /* Update Signal Editor */
+ glade_signal_editor_load_widget (e->signal_editor, gchild);
}
static gboolean
glade_base_editor_update_properties_idle (gpointer data)
{
- GladeBaseEditor *editor = (GladeBaseEditor *)data;
- glade_base_editor_treeview_cursor_changed
- (GTK_TREE_VIEW (editor->priv->treeview), editor);
- editor->priv->properties_idle = 0;
- return FALSE;
+ GladeBaseEditor *editor = (GladeBaseEditor *) data;
+ glade_base_editor_treeview_cursor_changed
+ (GTK_TREE_VIEW (editor->priv->treeview), editor);
+ editor->priv->properties_idle = 0;
+ return FALSE;
}
/* XXX Can we make it crisper by removing this idle ?? */
-static void
-glade_base_editor_update_properties (GladeBaseEditor *editor)
+static void
+glade_base_editor_update_properties (GladeBaseEditor * editor)
{
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
- if (!editor->priv->properties_idle)
- editor->priv->properties_idle =
- g_idle_add (glade_base_editor_update_properties_idle, editor);
+ if (!editor->priv->properties_idle)
+ editor->priv->properties_idle =
+ g_idle_add (glade_base_editor_update_properties_idle, editor);
}
static void
-glade_base_editor_set_cursor (GladeBaseEditor *e, GtkTreeIter *iter)
-{
- GtkTreePath *path;
- GtkTreeIter real_iter;
-
- if (iter == NULL &&
- glade_base_editor_get_child_selected (e, &real_iter))
- iter = &real_iter;
-
- if (iter && (path = gtk_tree_model_get_path (e->priv->model, iter)))
- {
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (e->priv->treeview), path, NULL, FALSE);
- gtk_tree_path_free (path);
- }
+glade_base_editor_set_cursor (GladeBaseEditor * e, GtkTreeIter * iter)
+{
+ GtkTreePath *path;
+ GtkTreeIter real_iter;
+
+ if (iter == NULL && glade_base_editor_get_child_selected (e, &real_iter))
+ iter = &real_iter;
+
+ if (iter && (path = gtk_tree_model_get_path (e->priv->model, iter)))
+ {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (e->priv->treeview), path, NULL,
+ FALSE);
+ gtk_tree_path_free (path);
+ }
}
static gboolean
-glade_base_editor_find_child_real (GladeBaseEditor *e,
- GladeWidget *gchild,
- GtkTreeIter *iter)
-{
- GtkTreeModel *model = e->priv->model;
- GtkTreeIter child_iter;
- GladeWidget *child;
-
- do
- {
- gtk_tree_model_get (model, iter, GLADE_BASE_EDITOR_GWIDGET, &child, -1);
-
- if (child == gchild) return TRUE;
-
- if (gtk_tree_model_iter_children (model, &child_iter, iter))
- if (glade_base_editor_find_child_real (e, gchild, &child_iter))
- {
- *iter = child_iter;
- return TRUE;
- }
- }
- while (gtk_tree_model_iter_next (model, iter));
-
- return FALSE;
+glade_base_editor_find_child_real (GladeBaseEditor * e,
+ GladeWidget * gchild, GtkTreeIter * iter)
+{
+ GtkTreeModel *model = e->priv->model;
+ GtkTreeIter child_iter;
+ GladeWidget *child;
+
+ do
+ {
+ gtk_tree_model_get (model, iter, GLADE_BASE_EDITOR_GWIDGET, &child, -1);
+
+ if (child == gchild)
+ return TRUE;
+
+ if (gtk_tree_model_iter_children (model, &child_iter, iter))
+ if (glade_base_editor_find_child_real (e, gchild, &child_iter))
+ {
+ *iter = child_iter;
+ return TRUE;
+ }
+ }
+ while (gtk_tree_model_iter_next (model, iter));
+
+ return FALSE;
}
static gboolean
-glade_base_editor_find_child (GladeBaseEditor *e,
- GladeWidget *child,
- GtkTreeIter *iter)
+glade_base_editor_find_child (GladeBaseEditor * e,
+ GladeWidget * child, GtkTreeIter * iter)
{
- if (gtk_tree_model_get_iter_first (e->priv->model, iter))
- return glade_base_editor_find_child_real (e, child, iter);
-
- return FALSE;
+ if (gtk_tree_model_get_iter_first (e->priv->model, iter))
+ return glade_base_editor_find_child_real (e, child, iter);
+
+ return FALSE;
}
static void
-glade_base_editor_select_child (GladeBaseEditor *e,
- GladeWidget *child)
+glade_base_editor_select_child (GladeBaseEditor * e, GladeWidget * child)
{
- GtkTreeIter iter;
-
- if (glade_base_editor_find_child (e, child, &iter))
- glade_base_editor_set_cursor (e, &iter);
+ GtkTreeIter iter;
+
+ if (glade_base_editor_find_child (e, child, &iter))
+ glade_base_editor_set_cursor (e, &iter);
}
static void
-glade_base_editor_child_change_type (GladeBaseEditor *editor,
- GtkTreeIter *iter,
- GType type)
-{
- GladeWidget *gchild, *gparent;
- GObject *child;
- gchar *class_name;
- gboolean retval;
-
- glade_base_editor_block_callbacks (editor, TRUE);
-
- /* Get old widget data */
- gtk_tree_model_get (editor->priv->model, iter,
- GLADE_BASE_EDITOR_GWIDGET, &gchild,
- GLADE_BASE_EDITOR_OBJECT, &child,
- -1);
-
- if (type == G_OBJECT_TYPE (child)) return;
-
- if (!gchild || !gchild->parent)
- return;
-
- gparent = gchild->parent;
-
- /* Start of glade-command */
-
- if (glade_base_editor_get_type_info (editor, NULL,
- type,
- GLADE_BASE_EDITOR_CLASS_NAME, &class_name,
- -1))
- {
- glade_command_push_group (_("Setting object type on %s to %s"),
- glade_widget_get_name (gchild),
- class_name);
- g_free (class_name);
- }
- else return;
-
- g_signal_emit (editor,
- glade_base_editor_signals [SIGNAL_CHANGE_TYPE],
- 0, gchild, type, &retval);
-
- /* End of glade-command */
- glade_command_pop_group ();
-
- /* Update properties */
- glade_base_editor_update_properties (editor);
-
- glade_base_editor_block_callbacks (editor, FALSE);
+glade_base_editor_child_change_type (GladeBaseEditor * editor,
+ GtkTreeIter * iter, GType type)
+{
+ GladeWidget *gchild, *gparent;
+ GObject *child;
+ gchar *class_name;
+ gboolean retval;
+
+ glade_base_editor_block_callbacks (editor, TRUE);
+
+ /* Get old widget data */
+ gtk_tree_model_get (editor->priv->model, iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gchild,
+ GLADE_BASE_EDITOR_OBJECT, &child, -1);
+
+ if (type == G_OBJECT_TYPE (child))
+ return;
+
+ if (!gchild || !gchild->parent)
+ return;
+
+ gparent = gchild->parent;
+
+ /* Start of glade-command */
+
+ if (glade_base_editor_get_type_info (editor, NULL,
+ type,
+ GLADE_BASE_EDITOR_CLASS_NAME,
+ &class_name, -1))
+ {
+ glade_command_push_group (_("Setting object type on %s to %s"),
+ glade_widget_get_name (gchild), class_name);
+ g_free (class_name);
+ }
+ else
+ return;
+
+ g_signal_emit (editor,
+ glade_base_editor_signals[SIGNAL_CHANGE_TYPE],
+ 0, gchild, type, &retval);
+
+ /* End of glade-command */
+ glade_command_pop_group ();
+
+ /* Update properties */
+ glade_base_editor_update_properties (editor);
+
+ glade_base_editor_block_callbacks (editor, FALSE);
}
static void
-glade_base_editor_type_changed (GtkComboBox *widget, GladeBaseEditor *e)
+glade_base_editor_type_changed (GtkComboBox * widget, GladeBaseEditor * e)
{
- GtkTreeIter iter, combo_iter;
- GType type;
-
- if (!glade_base_editor_get_child_selected (e, &iter))
- return;
-
- gtk_combo_box_get_active_iter (widget, &combo_iter);
-
- gtk_tree_model_get (gtk_combo_box_get_model (widget), &combo_iter,
- GLADE_BASE_EDITOR_GTYPE, &type, -1);
+ GtkTreeIter iter, combo_iter;
+ GType type;
+
+ if (!glade_base_editor_get_child_selected (e, &iter))
+ return;
+
+ gtk_combo_box_get_active_iter (widget, &combo_iter);
- glade_base_editor_child_change_type (e, &iter, type);
+ gtk_tree_model_get (gtk_combo_box_get_model (widget), &combo_iter,
+ GLADE_BASE_EDITOR_GTYPE, &type, -1);
+
+ glade_base_editor_child_change_type (e, &iter, type);
}
static void
-glade_base_editor_child_type_edited (GtkCellRendererText *cell,
- const gchar *path_string,
- const gchar *new_text,
- GladeBaseEditor *editor)
-{
- GladeBaseEditorPrivate *e = editor->priv;
- GtkTreeModel *child_class;
- GtkTreePath *path;
- GtkTreeIter iter, combo_iter;
- GType type;
- gchar *type_name;
-
- path = gtk_tree_path_new_from_string (path_string);
- gtk_tree_model_get_iter (e->model, &iter, path);
- gtk_tree_model_get (e->model, &iter,
- GLADE_BASE_EDITOR_CLASS_NAME, &type_name,
- GLADE_BASE_EDITOR_CHILD_TYPES, &child_class,
- -1);
-
- if (strcmp (type_name, new_text) == 0)
- {
- g_free (type_name);
- return;
- }
-
- /* Lookup GType */
- if (!gtk_tree_model_get_iter_first (child_class, &combo_iter))
- return;
-
- do
- {
- gtk_tree_model_get (child_class, &combo_iter,
- GLADE_BASE_EDITOR_GTYPE, &type,
- GLADE_BASE_EDITOR_CLASS_NAME, &type_name,
- -1);
-
- if (strcmp (type_name, new_text) == 0) break;
-
- g_free (type_name);
- } while (gtk_tree_model_iter_next (child_class, &combo_iter));
-
- glade_base_editor_child_change_type (editor, &iter, type);
+glade_base_editor_child_type_edited (GtkCellRendererText * cell,
+ const gchar * path_string,
+ const gchar * new_text,
+ GladeBaseEditor * editor)
+{
+ GladeBaseEditorPrivate *e = editor->priv;
+ GtkTreeModel *child_class;
+ GtkTreePath *path;
+ GtkTreeIter iter, combo_iter;
+ GType type;
+ gchar *type_name;
+
+ path = gtk_tree_path_new_from_string (path_string);
+ gtk_tree_model_get_iter (e->model, &iter, path);
+ gtk_tree_model_get (e->model, &iter,
+ GLADE_BASE_EDITOR_CLASS_NAME, &type_name,
+ GLADE_BASE_EDITOR_CHILD_TYPES, &child_class, -1);
+
+ if (strcmp (type_name, new_text) == 0)
+ {
+ g_free (type_name);
+ return;
+ }
+
+ /* Lookup GType */
+ if (!gtk_tree_model_get_iter_first (child_class, &combo_iter))
+ return;
+
+ do
+ {
+ gtk_tree_model_get (child_class, &combo_iter,
+ GLADE_BASE_EDITOR_GTYPE, &type,
+ GLADE_BASE_EDITOR_CLASS_NAME, &type_name, -1);
+
+ if (strcmp (type_name, new_text) == 0)
+ break;
+
+ g_free (type_name);
+ }
+ while (gtk_tree_model_iter_next (child_class, &combo_iter));
+
+ glade_base_editor_child_change_type (editor, &iter, type);
}
static void
-glade_base_editor_reorder_children (GladeBaseEditor *editor, GtkTreeIter *child)
+glade_base_editor_reorder_children (GladeBaseEditor * editor,
+ GtkTreeIter * child)
{
- GtkTreeModel *model = editor->priv->model;
- GladeWidget *gchild;
- GladeProperty *property;
- GtkTreeIter parent, iter;
- gint position = 0;
+ GtkTreeModel *model = editor->priv->model;
+ GladeWidget *gchild;
+ GladeProperty *property;
+ GtkTreeIter parent, iter;
+ gint position = 0;
+
+ if (gtk_tree_model_iter_parent (model, &parent, child))
+ gtk_tree_model_iter_children (model, &iter, &parent);
+ else
+ gtk_tree_model_get_iter_first (model, &iter);
- if (gtk_tree_model_iter_parent (model, &parent, child))
- gtk_tree_model_iter_children (model, &iter, &parent);
- else
- gtk_tree_model_get_iter_first (model, &iter);
+ do
+ {
+ gtk_tree_model_get (model, &iter, GLADE_BASE_EDITOR_GWIDGET, &gchild, -1);
- do
- {
- gtk_tree_model_get (model, &iter, GLADE_BASE_EDITOR_GWIDGET, &gchild, -1);
-
- if ((property = glade_widget_get_property (gchild, "position")) != NULL)
- glade_command_set_property (property, position);
- position++;
- } while (gtk_tree_model_iter_next (model, &iter));
+ if ((property = glade_widget_get_property (gchild, "position")) != NULL)
+ glade_command_set_property (property, position);
+ position++;
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
}
static void
-glade_base_editor_add_child (GladeBaseEditor *editor,
- GType type,
- gboolean as_child)
-{
- GladeBaseEditorPrivate *e = editor->priv;
- GtkTreeIter iter, new_iter;
- GladeWidget *gparent, *gchild_new;
- gchar *name, *class_name;
- gboolean selected_iter;
-
- glade_base_editor_block_callbacks (editor, TRUE);
-
- gparent = e->gcontainer;
-
- if ((selected_iter = glade_base_editor_get_child_selected (editor, &iter)))
- {
-
- if (as_child)
- gtk_tree_model_get (e->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &gparent,
- -1);
- else if (gtk_tree_model_iter_parent (e->model, &new_iter, &iter))
- {
- gtk_tree_model_get (e->model, &new_iter,
- GLADE_BASE_EDITOR_GWIDGET, &gparent,
- -1);
- }
- }
-
- if (!glade_base_editor_get_type_info (editor, NULL, type,
- GLADE_BASE_EDITOR_CLASS_NAME, &class_name,
- -1))
- return;
-
- glade_command_push_group (_("Add a %s to %s"), class_name,
- glade_widget_get_name (gparent));
-
- /* Build Child */
- gchild_new = glade_base_editor_delegate_build_child (editor, gparent, type);
-
- if (gchild_new == NULL)
- {
- glade_command_pop_group ();
- return;
- }
-
- if (selected_iter)
- {
- if (as_child)
- gtk_tree_store_append (GTK_TREE_STORE (editor->priv->model), &new_iter, &iter);
- else
- gtk_tree_store_insert_after (GTK_TREE_STORE (editor->priv->model), &new_iter,
- NULL, &iter);
- }
- else
- gtk_tree_store_append (GTK_TREE_STORE (editor->priv->model), &new_iter, NULL);
-
- name = glade_base_editor_get_display_name (editor, gchild_new);
-
- gtk_tree_store_set (GTK_TREE_STORE (editor->priv->model), &new_iter,
- GLADE_BASE_EDITOR_GWIDGET, gchild_new,
- GLADE_BASE_EDITOR_OBJECT, glade_widget_get_object (gchild_new),
- GLADE_BASE_EDITOR_TYPE_NAME, class_name,
- GLADE_BASE_EDITOR_NAME, name,
- GLADE_BASE_EDITOR_CHILD_TYPES,
- get_children_model_for_type (editor, G_OBJECT_TYPE (gparent->object)),
- -1);
-
- glade_base_editor_reorder_children (editor, &new_iter);
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (e->treeview));
- glade_base_editor_set_cursor (editor, &new_iter);
-
- glade_command_pop_group ();
-
- glade_base_editor_block_callbacks (editor, FALSE);
-
- g_free (name);
- g_free (class_name);
+glade_base_editor_add_child (GladeBaseEditor * editor,
+ GType type, gboolean as_child)
+{
+ GladeBaseEditorPrivate *e = editor->priv;
+ GtkTreeIter iter, new_iter;
+ GladeWidget *gparent, *gchild_new;
+ gchar *name, *class_name;
+ gboolean selected_iter;
+
+ glade_base_editor_block_callbacks (editor, TRUE);
+
+ gparent = e->gcontainer;
+
+ if ((selected_iter = glade_base_editor_get_child_selected (editor, &iter)))
+ {
+
+ if (as_child)
+ gtk_tree_model_get (e->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gparent, -1);
+ else if (gtk_tree_model_iter_parent (e->model, &new_iter, &iter))
+ {
+ gtk_tree_model_get (e->model, &new_iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gparent, -1);
+ }
+ }
+
+ if (!glade_base_editor_get_type_info (editor, NULL, type,
+ GLADE_BASE_EDITOR_CLASS_NAME,
+ &class_name, -1))
+ return;
+
+ glade_command_push_group (_("Add a %s to %s"), class_name,
+ glade_widget_get_name (gparent));
+
+ /* Build Child */
+ gchild_new = glade_base_editor_delegate_build_child (editor, gparent, type);
+
+ if (gchild_new == NULL)
+ {
+ glade_command_pop_group ();
+ return;
+ }
+
+ if (selected_iter)
+ {
+ if (as_child)
+ gtk_tree_store_append (GTK_TREE_STORE (editor->priv->model), &new_iter,
+ &iter);
+ else
+ gtk_tree_store_insert_after (GTK_TREE_STORE (editor->priv->model),
+ &new_iter, NULL, &iter);
+ }
+ else
+ gtk_tree_store_append (GTK_TREE_STORE (editor->priv->model), &new_iter,
+ NULL);
+
+ name = glade_base_editor_get_display_name (editor, gchild_new);
+
+ gtk_tree_store_set (GTK_TREE_STORE (editor->priv->model), &new_iter,
+ GLADE_BASE_EDITOR_GWIDGET, gchild_new,
+ GLADE_BASE_EDITOR_OBJECT,
+ glade_widget_get_object (gchild_new),
+ GLADE_BASE_EDITOR_TYPE_NAME, class_name,
+ GLADE_BASE_EDITOR_NAME, name,
+ GLADE_BASE_EDITOR_CHILD_TYPES,
+ get_children_model_for_type (editor,
+ G_OBJECT_TYPE (gparent->
+ object)), -1);
+
+ glade_base_editor_reorder_children (editor, &new_iter);
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (e->treeview));
+ glade_base_editor_set_cursor (editor, &new_iter);
+
+ glade_command_pop_group ();
+
+ glade_base_editor_block_callbacks (editor, FALSE);
+
+ g_free (name);
+ g_free (class_name);
}
static void
-glade_base_editor_add_item_activate (GtkMenuItem *menuitem, GladeBaseEditor *e)
+glade_base_editor_add_item_activate (GtkMenuItem * menuitem,
+ GladeBaseEditor * e)
{
- GObject *item = G_OBJECT (menuitem);
- GType type = GPOINTER_TO_INT (g_object_get_data (item, "object_type"));
- gboolean as_child = GPOINTER_TO_INT (g_object_get_data (item, "object_as_child"));
-
- glade_base_editor_add_child (e, type, as_child);
+ GObject *item = G_OBJECT (menuitem);
+ GType type = GPOINTER_TO_INT (g_object_get_data (item, "object_type"));
+ gboolean as_child =
+ GPOINTER_TO_INT (g_object_get_data (item, "object_as_child"));
+
+ glade_base_editor_add_child (e, type, as_child);
}
static GtkWidget *
-glade_base_editor_popup (GladeBaseEditor *editor,
- GladeWidget *widget)
-{
- GtkWidget *popup, *item;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GType iter_type;
- gchar *label;
- gchar *class_name;
-
- if ((model = get_children_model_for_child_type (editor, G_OBJECT_TYPE (widget->object))) == NULL)
- model = get_children_model_for_type (editor, G_OBJECT_TYPE (editor->priv->gcontainer->object));
-
- g_assert (model);
-
- popup = gtk_menu_new ();
-
- if (gtk_tree_model_get_iter_first (model, &iter))
- do
- {
- gtk_tree_model_get (model, &iter,
- GLADE_BASE_EDITOR_GTYPE, &iter_type,
- GLADE_BASE_EDITOR_CLASS_NAME, &class_name,
- -1);
-
- label = g_strdup_printf (_("Add %s item"), class_name);
-
- item = gtk_menu_item_new_with_label (label);
- gtk_widget_show (item);
-
- g_object_set_data (G_OBJECT (item), "object_type",
- GINT_TO_POINTER (iter_type));
-
- g_object_set_data (G_OBJECT (item), "object_as_child",
- GINT_TO_POINTER (FALSE));
-
- g_signal_connect (item, "activate",
- G_CALLBACK (glade_base_editor_add_item_activate), editor);
- gtk_menu_shell_append (GTK_MENU_SHELL (popup), item);
-
- g_free (label);
- g_free (class_name);
-
- } while (gtk_tree_model_iter_next (model, &iter));
-
-
- if ((model = get_children_model_for_type (editor, G_OBJECT_TYPE (widget->object))) &&
- gtk_tree_model_get_iter_first (model, &iter))
- do
- {
- gtk_tree_model_get (model, &iter,
- GLADE_BASE_EDITOR_GTYPE, &iter_type,
- GLADE_BASE_EDITOR_CLASS_NAME, &class_name,
- -1);
-
- label = g_strdup_printf (_("Add child %s item"), class_name);
-
- item = gtk_menu_item_new_with_label (label);
- gtk_widget_show (item);
-
- g_object_set_data (G_OBJECT (item), "object_type",
- GINT_TO_POINTER (iter_type));
-
- g_object_set_data (G_OBJECT (item), "object_as_child",
- GINT_TO_POINTER (TRUE));
-
- g_signal_connect (item, "activate",
- G_CALLBACK (glade_base_editor_add_item_activate), editor);
- gtk_menu_shell_append (GTK_MENU_SHELL (popup), item);
-
- g_free (label);
- g_free (class_name);
-
- } while (gtk_tree_model_iter_next (model, &iter));
-
- return popup;
+glade_base_editor_popup (GladeBaseEditor * editor, GladeWidget * widget)
+{
+ GtkWidget *popup, *item;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GType iter_type;
+ gchar *label;
+ gchar *class_name;
+
+ if ((model =
+ get_children_model_for_child_type (editor,
+ G_OBJECT_TYPE (widget->object))) ==
+ NULL)
+ model =
+ get_children_model_for_type (editor,
+ G_OBJECT_TYPE (editor->priv->gcontainer->
+ object));
+
+ g_assert (model);
+
+ popup = gtk_menu_new ();
+
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ do
+ {
+ gtk_tree_model_get (model, &iter,
+ GLADE_BASE_EDITOR_GTYPE, &iter_type,
+ GLADE_BASE_EDITOR_CLASS_NAME, &class_name, -1);
+
+ label = g_strdup_printf (_("Add %s item"), class_name);
+
+ item = gtk_menu_item_new_with_label (label);
+ gtk_widget_show (item);
+
+ g_object_set_data (G_OBJECT (item), "object_type",
+ GINT_TO_POINTER (iter_type));
+
+ g_object_set_data (G_OBJECT (item), "object_as_child",
+ GINT_TO_POINTER (FALSE));
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (glade_base_editor_add_item_activate),
+ editor);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup), item);
+
+ g_free (label);
+ g_free (class_name);
+
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
+
+
+ if ((model =
+ get_children_model_for_type (editor, G_OBJECT_TYPE (widget->object))) &&
+ gtk_tree_model_get_iter_first (model, &iter))
+ do
+ {
+ gtk_tree_model_get (model, &iter,
+ GLADE_BASE_EDITOR_GTYPE, &iter_type,
+ GLADE_BASE_EDITOR_CLASS_NAME, &class_name, -1);
+
+ label = g_strdup_printf (_("Add child %s item"), class_name);
+
+ item = gtk_menu_item_new_with_label (label);
+ gtk_widget_show (item);
+
+ g_object_set_data (G_OBJECT (item), "object_type",
+ GINT_TO_POINTER (iter_type));
+
+ g_object_set_data (G_OBJECT (item), "object_as_child",
+ GINT_TO_POINTER (TRUE));
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (glade_base_editor_add_item_activate),
+ editor);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup), item);
+
+ g_free (label);
+ g_free (class_name);
+
+ }
+ while (gtk_tree_model_iter_next (model, &iter));
+
+ return popup;
}
static gint
-glade_base_editor_popup_handler (GtkWidget *treeview,
- GdkEventButton *event,
- GladeBaseEditor *e)
+glade_base_editor_popup_handler (GtkWidget * treeview,
+ GdkEventButton * event, GladeBaseEditor * e)
{
- GtkTreePath *path;
- GtkWidget *popup;
+ GtkTreePath *path;
+ GtkWidget *popup;
- if (glade_popup_is_popup_event (event))
- {
- if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
- (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL))
- {
- GtkTreeIter iter;
- GladeWidget *gwidget;
+ if (glade_popup_is_popup_event (event))
+ {
+ if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
+ (gint) event->x, (gint) event->y,
+ &path, NULL, NULL, NULL))
+ {
+ GtkTreeIter iter;
+ GladeWidget *gwidget;
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview), path, NULL, FALSE);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview), path, NULL,
+ FALSE);
- gtk_tree_model_get_iter (e->priv->model, &iter, path);
- gtk_tree_model_get (e->priv->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &gwidget,
- -1);
+ gtk_tree_model_get_iter (e->priv->model, &iter, path);
+ gtk_tree_model_get (e->priv->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gwidget, -1);
-
- popup = glade_base_editor_popup (e, gwidget);
- gtk_tree_path_free (path);
+ popup = glade_base_editor_popup (e, gwidget);
- gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
- event->button, event->time);
- }
- return TRUE;
- }
+ gtk_tree_path_free (path);
- return FALSE;
+ gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+ }
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
-glade_base_editor_add_activate (GtkButton *button, GladeBaseEditor *e)
+glade_base_editor_add_activate (GtkButton * button, GladeBaseEditor * e)
{
- if (e->priv->add_type)
- glade_base_editor_add_child (e, e->priv->add_type, e->priv->add_as_child);
+ if (e->priv->add_type)
+ glade_base_editor_add_child (e, e->priv->add_type, e->priv->add_as_child);
}
static void
-glade_base_editor_delete_child (GladeBaseEditor *e)
+glade_base_editor_delete_child (GladeBaseEditor * e)
{
- GladeWidget *child, *gparent;
- GtkTreeIter iter, parent;
+ GladeWidget *child, *gparent;
+ GtkTreeIter iter, parent;
+
+ if (!glade_base_editor_get_child_selected (e, &iter))
+ return;
+
+ gtk_tree_model_get (e->priv->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &child, -1);
- if (!glade_base_editor_get_child_selected (e, &iter)) return;
+ if (gtk_tree_model_iter_parent (e->priv->model, &parent, &iter))
+ gtk_tree_model_get (e->priv->model, &parent,
+ GLADE_BASE_EDITOR_GWIDGET, &gparent, -1);
+ else
+ gparent = e->priv->gcontainer;
- gtk_tree_model_get (e->priv->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &child, -1);
-
- if (gtk_tree_model_iter_parent (e->priv->model, &parent, &iter))
- gtk_tree_model_get (e->priv->model, &parent,
- GLADE_BASE_EDITOR_GWIDGET, &gparent,
- -1);
- else
- gparent = e->priv->gcontainer;
-
- glade_command_push_group (_("Delete %s child from %s"),
- glade_widget_get_name (child),
- glade_widget_get_name (gparent));
-
- /* Emit delete-child signal */
- glade_base_editor_delegate_delete_child (e, gparent, child);
+ glade_command_push_group (_("Delete %s child from %s"),
+ glade_widget_get_name (child),
+ glade_widget_get_name (gparent));
- glade_command_pop_group ();
+ /* Emit delete-child signal */
+ glade_base_editor_delegate_delete_child (e, gparent, child);
+
+ glade_command_pop_group ();
}
static gboolean
-glade_base_editor_treeview_key_press_event (GtkWidget *widget,
- GdkEventKey *event,
- GladeBaseEditor *e)
+glade_base_editor_treeview_key_press_event (GtkWidget * widget,
+ GdkEventKey * event,
+ GladeBaseEditor * e)
{
- if (event->keyval == GDK_KEY_Delete)
- glade_base_editor_delete_child (e);
-
- return FALSE;
+ if (event->keyval == GDK_KEY_Delete)
+ glade_base_editor_delete_child (e);
+
+ return FALSE;
}
static void
-glade_base_editor_delete_activate (GtkButton *button, GladeBaseEditor *e)
+glade_base_editor_delete_activate (GtkButton * button, GladeBaseEditor * e)
{
- glade_base_editor_delete_child (e);
+ glade_base_editor_delete_child (e);
}
static gboolean
-glade_base_editor_is_child (GladeBaseEditor *e,
- GladeWidget *gchild,
- gboolean valid_type)
-{
- GladeWidget *gcontainer = gchild->parent;
-
- if (!gcontainer)
- return FALSE;
-
- if (valid_type)
- {
- GObject *child = glade_widget_get_object (gchild);
-
- if (gchild->internal ||
- glade_base_editor_get_type_info (e, NULL,
- G_OBJECT_TYPE (child),
- -1) == FALSE)
- return FALSE;
-
- gcontainer = e->priv->gcontainer;
- }
- else
- {
- GtkTreeIter iter;
- if (glade_base_editor_get_child_selected (e, &iter))
- gtk_tree_model_get (e->priv->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &gcontainer,
- -1);
- else
- return FALSE;
- }
-
- while ((gchild = glade_widget_get_parent (gchild)))
- if (gchild == gcontainer) return TRUE;
-
- return FALSE;
+glade_base_editor_is_child (GladeBaseEditor * e,
+ GladeWidget * gchild, gboolean valid_type)
+{
+ GladeWidget *gcontainer = gchild->parent;
+
+ if (!gcontainer)
+ return FALSE;
+
+ if (valid_type)
+ {
+ GObject *child = glade_widget_get_object (gchild);
+
+ if (gchild->internal ||
+ glade_base_editor_get_type_info (e, NULL,
+ G_OBJECT_TYPE (child), -1) == FALSE)
+ return FALSE;
+
+ gcontainer = e->priv->gcontainer;
+ }
+ else
+ {
+ GtkTreeIter iter;
+ if (glade_base_editor_get_child_selected (e, &iter))
+ gtk_tree_model_get (e->priv->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gcontainer, -1);
+ else
+ return FALSE;
+ }
+
+ while ((gchild = glade_widget_get_parent (gchild)))
+ if (gchild == gcontainer)
+ return TRUE;
+
+ return FALSE;
}
static gboolean
glade_base_editor_update_treeview_idle (gpointer data)
{
- GladeBaseEditor *e = ((GladeBaseEditor *) data);
- GList *selection = glade_project_selection_get (e->priv->project);
-
- glade_base_editor_block_callbacks (e, TRUE);
-
- glade_base_editor_fill_store (e);
- glade_base_editor_clear (e);
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (e->priv->treeview));
-
- if (selection)
- {
- GladeWidget *widget = glade_widget_get_from_gobject (G_OBJECT (selection->data));
- if (glade_base_editor_is_child (e, widget, TRUE))
- glade_base_editor_select_child (e, widget);
- }
-
- e->priv->updating_treeview = FALSE;
- glade_base_editor_block_callbacks (e, FALSE);
-
- return FALSE;
+ GladeBaseEditor *e = ((GladeBaseEditor *) data);
+ GList *selection = glade_project_selection_get (e->priv->project);
+
+ glade_base_editor_block_callbacks (e, TRUE);
+
+ glade_base_editor_fill_store (e);
+ glade_base_editor_clear (e);
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (e->priv->treeview));
+
+ if (selection)
+ {
+ GladeWidget *widget =
+ glade_widget_get_from_gobject (G_OBJECT (selection->data));
+ if (glade_base_editor_is_child (e, widget, TRUE))
+ glade_base_editor_select_child (e, widget);
+ }
+
+ e->priv->updating_treeview = FALSE;
+ glade_base_editor_block_callbacks (e, FALSE);
+
+ return FALSE;
}
static void
-glade_base_editor_project_widget_name_changed (GladeProject *project,
- GladeWidget *widget,
- GladeBaseEditor *editor)
+glade_base_editor_project_widget_name_changed (GladeProject * project,
+ GladeWidget * widget,
+ GladeBaseEditor * editor)
{
- GladeWidget *selected_child;
- GtkTreeIter iter;
+ GladeWidget *selected_child;
+ GtkTreeIter iter;
- if (glade_base_editor_get_child_selected (editor, &iter))
- {
- gtk_tree_model_get (editor->priv->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &selected_child,
- -1);
- if (widget == selected_child)
- glade_base_editor_update_properties (editor);
+ if (glade_base_editor_get_child_selected (editor, &iter))
+ {
+ gtk_tree_model_get (editor->priv->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &selected_child, -1);
+ if (widget == selected_child)
+ glade_base_editor_update_properties (editor);
- g_object_unref (G_OBJECT (selected_child));
- }
+ g_object_unref (G_OBJECT (selected_child));
+ }
}
static void
-glade_base_editor_project_closed (GladeProject *project, GladeBaseEditor *e)
+glade_base_editor_project_closed (GladeProject * project, GladeBaseEditor * e)
{
- glade_base_editor_set_container (e, NULL);
+ glade_base_editor_set_container (e, NULL);
}
static void
-glade_base_editor_reorder (GladeBaseEditor *editor, GtkTreeIter *iter)
-{
- GladeBaseEditorPrivate *e = editor->priv;
- GladeWidget *gchild, *gparent;
- GtkTreeIter parent_iter;
- gboolean retval;
-
- glade_command_push_group (_("Reorder %s's children"),
- glade_widget_get_name (e->gcontainer));
-
- gtk_tree_model_get (e->model, iter,
- GLADE_BASE_EDITOR_GWIDGET, &gchild, -1);
- g_object_unref (G_OBJECT (gchild));
-
- if (gtk_tree_model_iter_parent (e->model, &parent_iter, iter))
- {
- gtk_tree_model_get (e->model, &parent_iter,
- GLADE_BASE_EDITOR_GWIDGET, &gparent,
- -1);
- g_object_unref (G_OBJECT (gparent));
- }
- else
- gparent = e->gcontainer;
-
- g_signal_emit (editor, glade_base_editor_signals [SIGNAL_MOVE_CHILD],
- 0, gparent, gchild, &retval);
-
- if (retval)
- glade_base_editor_reorder_children (editor, iter);
- else
- {
- glade_base_editor_clear (editor);
- glade_base_editor_fill_store (editor);
- glade_base_editor_find_child (editor, gchild, &editor->priv->iter);
- }
-
- glade_command_pop_group ();
-}
-
-static gboolean
+glade_base_editor_reorder (GladeBaseEditor * editor, GtkTreeIter * iter)
+{
+ GladeBaseEditorPrivate *e = editor->priv;
+ GladeWidget *gchild, *gparent;
+ GtkTreeIter parent_iter;
+ gboolean retval;
+
+ glade_command_push_group (_("Reorder %s's children"),
+ glade_widget_get_name (e->gcontainer));
+
+ gtk_tree_model_get (e->model, iter, GLADE_BASE_EDITOR_GWIDGET, &gchild, -1);
+ g_object_unref (G_OBJECT (gchild));
+
+ if (gtk_tree_model_iter_parent (e->model, &parent_iter, iter))
+ {
+ gtk_tree_model_get (e->model, &parent_iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gparent, -1);
+ g_object_unref (G_OBJECT (gparent));
+ }
+ else
+ gparent = e->gcontainer;
+
+ g_signal_emit (editor, glade_base_editor_signals[SIGNAL_MOVE_CHILD],
+ 0, gparent, gchild, &retval);
+
+ if (retval)
+ glade_base_editor_reorder_children (editor, iter);
+ else
+ {
+ glade_base_editor_clear (editor);
+ glade_base_editor_fill_store (editor);
+ glade_base_editor_find_child (editor, gchild, &editor->priv->iter);
+ }
+
+ glade_command_pop_group ();
+}
+
+static gboolean
glade_base_editor_drag_and_drop_idle (gpointer data)
{
- GladeBaseEditor *e = (GladeBaseEditor *) data;
-
- glade_base_editor_reorder (e, &e->priv->iter);
- gtk_tree_view_expand_all (GTK_TREE_VIEW (e->priv->treeview));
- glade_base_editor_set_cursor (e, &e->priv->iter);
- glade_base_editor_block_callbacks (e, FALSE);
-
- return FALSE;
+ GladeBaseEditor *e = (GladeBaseEditor *) data;
+
+ glade_base_editor_reorder (e, &e->priv->iter);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (e->priv->treeview));
+ glade_base_editor_set_cursor (e, &e->priv->iter);
+ glade_base_editor_block_callbacks (e, FALSE);
+
+ return FALSE;
}
static void
-glade_base_editor_row_inserted (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- GladeBaseEditor *e)
+glade_base_editor_row_inserted (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, GladeBaseEditor * e)
{
- e->priv->iter = *iter;
- glade_base_editor_block_callbacks (e, TRUE);
- g_idle_add (glade_base_editor_drag_and_drop_idle, e);
+ e->priv->iter = *iter;
+ glade_base_editor_block_callbacks (e, TRUE);
+ g_idle_add (glade_base_editor_drag_and_drop_idle, e);
}
static void
-glade_base_editor_project_remove_widget (GladeProject *project,
- GladeWidget *widget,
- GladeBaseEditor *e)
-{
- if (widget == e->priv->gcontainer)
- {
- glade_base_editor_set_container (e, NULL);
- return;
- }
-
- if (glade_base_editor_is_child (e, widget, TRUE))
- {
- GtkTreeIter iter;
- if (glade_base_editor_find_child (e, widget, &iter))
- {
- gtk_tree_store_remove (GTK_TREE_STORE (e->priv->model), &iter);
- glade_base_editor_clear (e);
- }
- }
-
- if (widget->internal &&
- glade_base_editor_is_child (e, widget, FALSE))
- glade_base_editor_update_properties (e);
+glade_base_editor_project_remove_widget (GladeProject * project,
+ GladeWidget * widget,
+ GladeBaseEditor * e)
+{
+ if (widget == e->priv->gcontainer)
+ {
+ glade_base_editor_set_container (e, NULL);
+ return;
+ }
+
+ if (glade_base_editor_is_child (e, widget, TRUE))
+ {
+ GtkTreeIter iter;
+ if (glade_base_editor_find_child (e, widget, &iter))
+ {
+ gtk_tree_store_remove (GTK_TREE_STORE (e->priv->model), &iter);
+ glade_base_editor_clear (e);
+ }
+ }
+
+ if (widget->internal && glade_base_editor_is_child (e, widget, FALSE))
+ glade_base_editor_update_properties (e);
}
static void
-glade_base_editor_project_add_widget (GladeProject *project,
- GladeWidget *widget,
- GladeBaseEditor *e)
-{
- if (e->priv->updating_treeview) return;
-
- if (glade_base_editor_is_child (e, widget, TRUE))
- {
- e->priv->updating_treeview = TRUE;
- g_idle_add (glade_base_editor_update_treeview_idle, e);
- }
-
- if (widget->internal &&
- glade_base_editor_is_child (e, widget, FALSE))
- glade_base_editor_update_properties (e);
+glade_base_editor_project_add_widget (GladeProject * project,
+ GladeWidget * widget, GladeBaseEditor * e)
+{
+ if (e->priv->updating_treeview)
+ return;
+
+ if (glade_base_editor_is_child (e, widget, TRUE))
+ {
+ e->priv->updating_treeview = TRUE;
+ g_idle_add (glade_base_editor_update_treeview_idle, e);
+ }
+
+ if (widget->internal && glade_base_editor_is_child (e, widget, FALSE))
+ glade_base_editor_update_properties (e);
}
static gboolean
-glade_base_editor_update_display_name (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
-{
- GladeBaseEditor *editor = (GladeBaseEditor *) data;
- GladeWidget *gchild;
- gchar *name;
-
- gtk_tree_model_get (model, iter,
- GLADE_BASE_EDITOR_GWIDGET, &gchild,
- -1);
-
- name = glade_base_editor_get_display_name (editor, gchild);
-
- gtk_tree_store_set (GTK_TREE_STORE (editor->priv->model), iter,
- GLADE_BASE_EDITOR_NAME, name,
- -1);
- g_free (name);
- g_object_unref (G_OBJECT (gchild));
-
- return FALSE;
+glade_base_editor_update_display_name (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, gpointer data)
+{
+ GladeBaseEditor *editor = (GladeBaseEditor *) data;
+ GladeWidget *gchild;
+ gchar *name;
+
+ gtk_tree_model_get (model, iter, GLADE_BASE_EDITOR_GWIDGET, &gchild, -1);
+
+ name = glade_base_editor_get_display_name (editor, gchild);
+
+ gtk_tree_store_set (GTK_TREE_STORE (editor->priv->model), iter,
+ GLADE_BASE_EDITOR_NAME, name, -1);
+ g_free (name);
+ g_object_unref (G_OBJECT (gchild));
+
+ return FALSE;
}
static void
-glade_base_editor_project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean forward,
- GladeBaseEditor *editor)
+glade_base_editor_project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean forward, GladeBaseEditor * editor)
{
- gtk_tree_model_foreach (editor->priv->model,
- glade_base_editor_update_display_name,
- editor);
+ gtk_tree_model_foreach (editor->priv->model,
+ glade_base_editor_update_display_name, editor);
}
static void
-glade_base_editor_project_disconnect (GladeBaseEditor *editor)
+glade_base_editor_project_disconnect (GladeBaseEditor * editor)
{
- GladeBaseEditorPrivate *e = editor->priv;
-
- if (e->project == NULL) return;
+ GladeBaseEditorPrivate *e = editor->priv;
+
+ if (e->project == NULL)
+ return;
+
+ g_signal_handlers_disconnect_by_func (e->project,
+ glade_base_editor_project_closed,
+ editor);
+
+ g_signal_handlers_disconnect_by_func (e->project,
+ glade_base_editor_project_remove_widget,
+ editor);
- g_signal_handlers_disconnect_by_func (e->project,
- glade_base_editor_project_closed, editor);
-
- g_signal_handlers_disconnect_by_func (e->project,
- glade_base_editor_project_remove_widget, editor);
-
- g_signal_handlers_disconnect_by_func (e->project,
- glade_base_editor_project_add_widget, editor);
-
- g_signal_handlers_disconnect_by_func (e->project,
- glade_base_editor_project_widget_name_changed, editor);
-
- g_signal_handlers_disconnect_by_func (e->project,
- glade_base_editor_project_changed, editor);
+ g_signal_handlers_disconnect_by_func (e->project,
+ glade_base_editor_project_add_widget,
+ editor);
+ g_signal_handlers_disconnect_by_func (e->project,
+ glade_base_editor_project_widget_name_changed,
+ editor);
- if (e->properties_idle)
- g_source_remove (e->properties_idle);
- e->properties_idle = 0;
+ g_signal_handlers_disconnect_by_func (e->project,
+ glade_base_editor_project_changed,
+ editor);
+
+
+ if (e->properties_idle)
+ g_source_remove (e->properties_idle);
+ e->properties_idle = 0;
}
static void
-glade_base_editor_set_container (GladeBaseEditor *editor,
- GObject *container)
-{
- GladeBaseEditorPrivate *e = editor->priv;
-
- glade_base_editor_project_disconnect (editor);
-
- if (container == NULL)
- {
- reset_child_types (editor);
-
- e->gcontainer = NULL;
- e->project = NULL;
- glade_base_editor_block_callbacks (editor, TRUE);
- glade_base_editor_clear (editor);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (editor->priv->treeview), NULL);
- gtk_tree_store_clear (GTK_TREE_STORE (editor->priv->model));
- gtk_tree_view_set_model (GTK_TREE_VIEW (editor->priv->treeview), editor->priv->model);
-
- gtk_widget_set_sensitive (e->paned, FALSE);
- glade_base_editor_block_callbacks (editor, FALSE);
-
- glade_signal_editor_load_widget (e->signal_editor, NULL);
-
- g_object_notify (G_OBJECT (editor), "container");
- return;
- }
-
- gtk_widget_set_sensitive (e->paned, TRUE);
-
- e->gcontainer = glade_widget_get_from_gobject (container);
-
- e->project = glade_widget_get_project (e->gcontainer);
-
- g_signal_connect (e->project, "close",
- G_CALLBACK (glade_base_editor_project_closed),
- editor);
-
- g_signal_connect (e->project, "remove-widget",
- G_CALLBACK (glade_base_editor_project_remove_widget),
- editor);
-
- g_signal_connect (e->project, "add-widget",
- G_CALLBACK (glade_base_editor_project_add_widget),
- editor);
-
- g_signal_connect (e->project, "widget-name-changed",
- G_CALLBACK (glade_base_editor_project_widget_name_changed),
- editor);
-
- g_signal_connect (e->project, "changed",
- G_CALLBACK (glade_base_editor_project_changed),
- editor);
-
- g_object_notify (G_OBJECT (editor), "container");
+glade_base_editor_set_container (GladeBaseEditor * editor, GObject * container)
+{
+ GladeBaseEditorPrivate *e = editor->priv;
+
+ glade_base_editor_project_disconnect (editor);
+
+ if (container == NULL)
+ {
+ reset_child_types (editor);
+
+ e->gcontainer = NULL;
+ e->project = NULL;
+ glade_base_editor_block_callbacks (editor, TRUE);
+ glade_base_editor_clear (editor);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (editor->priv->treeview), NULL);
+ gtk_tree_store_clear (GTK_TREE_STORE (editor->priv->model));
+ gtk_tree_view_set_model (GTK_TREE_VIEW (editor->priv->treeview),
+ editor->priv->model);
+
+ gtk_widget_set_sensitive (e->paned, FALSE);
+ glade_base_editor_block_callbacks (editor, FALSE);
+
+ glade_signal_editor_load_widget (e->signal_editor, NULL);
+
+ g_object_notify (G_OBJECT (editor), "container");
+ return;
+ }
+
+ gtk_widget_set_sensitive (e->paned, TRUE);
+
+ e->gcontainer = glade_widget_get_from_gobject (container);
+
+ e->project = glade_widget_get_project (e->gcontainer);
+
+ g_signal_connect (e->project, "close",
+ G_CALLBACK (glade_base_editor_project_closed), editor);
+
+ g_signal_connect (e->project, "remove-widget",
+ G_CALLBACK (glade_base_editor_project_remove_widget),
+ editor);
+
+ g_signal_connect (e->project, "add-widget",
+ G_CALLBACK (glade_base_editor_project_add_widget), editor);
+
+ g_signal_connect (e->project, "widget-name-changed",
+ G_CALLBACK (glade_base_editor_project_widget_name_changed),
+ editor);
+
+ g_signal_connect (e->project, "changed",
+ G_CALLBACK (glade_base_editor_project_changed), editor);
+
+ g_object_notify (G_OBJECT (editor), "container");
}
/*************************** GladeBaseEditor Class ****************************/
static void
-glade_base_editor_finalize (GObject *object)
+glade_base_editor_finalize (GObject * object)
{
- GladeBaseEditor *cobj = GLADE_BASE_EDITOR (object);
+ GladeBaseEditor *cobj = GLADE_BASE_EDITOR (object);
- g_free (cobj->priv);
+ g_free (cobj->priv);
- G_OBJECT_CLASS(parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-glade_base_editor_dispose (GObject *object)
+glade_base_editor_dispose (GObject * object)
{
- GladeBaseEditor *cobj = GLADE_BASE_EDITOR (object);
+ GladeBaseEditor *cobj = GLADE_BASE_EDITOR (object);
- reset_child_types (cobj);
+ reset_child_types (cobj);
- glade_base_editor_project_disconnect (cobj);
- cobj->priv->project = NULL;
+ glade_base_editor_project_disconnect (cobj);
+ cobj->priv->project = NULL;
- G_OBJECT_CLASS(parent_class)->dispose (object);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-glade_base_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_base_editor_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeBaseEditor *editor = GLADE_BASE_EDITOR (object);
+ GladeBaseEditor *editor = GLADE_BASE_EDITOR (object);
- switch (prop_id)
- {
- case PROP_CONTAINER:
- glade_base_editor_set_container (editor, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_CONTAINER:
+ glade_base_editor_set_container (editor, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_base_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_base_editor_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GladeBaseEditor *editor = GLADE_BASE_EDITOR (object);
+ GladeBaseEditor *editor = GLADE_BASE_EDITOR (object);
- switch (prop_id)
- {
- case PROP_CONTAINER:
- g_value_set_object (value, editor->priv->gcontainer->object);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_CONTAINER:
+ g_value_set_object (value, editor->priv->gcontainer->object);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/* Default handlers */
static gboolean
-glade_base_editor_change_type (GladeBaseEditor *editor,
- GladeWidget *gchild,
- GType type)
-{
- GladeWidget *parent, *gchild_new;
- GList *children, *l;
- GObject *child, *child_new;
- GtkTreeIter iter;
- gchar *name, *class_name;
-
- parent = glade_widget_get_parent (gchild);
-
- if (glade_base_editor_get_type_info (editor, NULL, type,
- GLADE_BASE_EDITOR_CLASS_NAME, &class_name,
- -1) == FALSE)
- return TRUE;
-
- child = glade_widget_get_object (gchild);
- name = g_strdup (glade_widget_get_name (gchild));
- glade_base_editor_find_child (editor, gchild, &iter);
-
- /* Create new widget */
- gchild_new = glade_base_editor_delegate_build_child (editor, parent, type);
-
- child_new = glade_widget_get_object (gchild_new);
-
- /* Cut and Paste childrens */
- if ((children = glade_widget_get_children (gchild)) != NULL)
- {
- GList *gchildren = NULL;
-
- l = children;
- while (l)
- {
- GladeWidget *w = glade_widget_get_from_gobject (l->data);
-
- if (w && !w->internal)
- gchildren = g_list_prepend (gchildren, w);
-
- l= g_list_next (l);
- }
-
- if (gchildren)
- {
- glade_command_dnd (gchildren, gchild_new, NULL);
-
- g_list_free (children);
- g_list_free (gchildren);
- }
- }
-
- /* Copy properties */
- glade_widget_copy_properties (gchild_new, gchild, TRUE, TRUE);
-
- /* Delete old widget */
- glade_base_editor_delegate_delete_child (editor, parent, gchild);
-
- /* Apply packing properties to the new object
- *
- * No need to use GladeCommand here on the newly created widget,
- * they just become the initial state for this object.
- */
- l = gchild->packing_properties;
- while (l)
- {
- GladeProperty *orig_prop = (GladeProperty *) l->data;
- GladeProperty *dup_prop = glade_widget_get_property (gchild_new,
- orig_prop->klass->id);
- glade_property_set_value (dup_prop, orig_prop->value);
- l = g_list_next (l);
- }
-
- /* Set the name */
- glade_command_set_name (gchild_new, name);
-
- if (GTK_IS_WIDGET (child_new))
- gtk_widget_show_all (GTK_WIDGET (child_new));
-
- gtk_tree_store_set (GTK_TREE_STORE (editor->priv->model), &iter,
- GLADE_BASE_EDITOR_GWIDGET, gchild_new,
- GLADE_BASE_EDITOR_OBJECT, child_new,
- GLADE_BASE_EDITOR_TYPE_NAME, class_name,
- -1);
- g_free (class_name);
- g_free (name);
-
- return TRUE;
+glade_base_editor_change_type (GladeBaseEditor * editor,
+ GladeWidget * gchild, GType type)
+{
+ GladeWidget *parent, *gchild_new;
+ GList *children, *l;
+ GObject *child, *child_new;
+ GtkTreeIter iter;
+ gchar *name, *class_name;
+
+ parent = glade_widget_get_parent (gchild);
+
+ if (glade_base_editor_get_type_info (editor, NULL, type,
+ GLADE_BASE_EDITOR_CLASS_NAME,
+ &class_name, -1) == FALSE)
+ return TRUE;
+
+ child = glade_widget_get_object (gchild);
+ name = g_strdup (glade_widget_get_name (gchild));
+ glade_base_editor_find_child (editor, gchild, &iter);
+
+ /* Create new widget */
+ gchild_new = glade_base_editor_delegate_build_child (editor, parent, type);
+
+ child_new = glade_widget_get_object (gchild_new);
+
+ /* Cut and Paste childrens */
+ if ((children = glade_widget_get_children (gchild)) != NULL)
+ {
+ GList *gchildren = NULL;
+
+ l = children;
+ while (l)
+ {
+ GladeWidget *w = glade_widget_get_from_gobject (l->data);
+
+ if (w && !w->internal)
+ gchildren = g_list_prepend (gchildren, w);
+
+ l = g_list_next (l);
+ }
+
+ if (gchildren)
+ {
+ glade_command_dnd (gchildren, gchild_new, NULL);
+
+ g_list_free (children);
+ g_list_free (gchildren);
+ }
+ }
+
+ /* Copy properties */
+ glade_widget_copy_properties (gchild_new, gchild, TRUE, TRUE);
+
+ /* Delete old widget */
+ glade_base_editor_delegate_delete_child (editor, parent, gchild);
+
+ /* Apply packing properties to the new object
+ *
+ * No need to use GladeCommand here on the newly created widget,
+ * they just become the initial state for this object.
+ */
+ l = gchild->packing_properties;
+ while (l)
+ {
+ GladeProperty *orig_prop = (GladeProperty *) l->data;
+ GladeProperty *dup_prop = glade_widget_get_property (gchild_new,
+ orig_prop->klass->
+ id);
+ glade_property_set_value (dup_prop, orig_prop->value);
+ l = g_list_next (l);
+ }
+
+ /* Set the name */
+ glade_command_set_name (gchild_new, name);
+
+ if (GTK_IS_WIDGET (child_new))
+ gtk_widget_show_all (GTK_WIDGET (child_new));
+
+ gtk_tree_store_set (GTK_TREE_STORE (editor->priv->model), &iter,
+ GLADE_BASE_EDITOR_GWIDGET, gchild_new,
+ GLADE_BASE_EDITOR_OBJECT, child_new,
+ GLADE_BASE_EDITOR_TYPE_NAME, class_name, -1);
+ g_free (class_name);
+ g_free (name);
+
+ return TRUE;
}
static gchar *
-glade_base_editor_get_display_name_impl (GladeBaseEditor *editor,
- GladeWidget *gchild)
+glade_base_editor_get_display_name_impl (GladeBaseEditor * editor,
+ GladeWidget * gchild)
{
- return g_strdup (glade_widget_get_name (gchild));
+ return g_strdup (glade_widget_get_name (gchild));
}
static GladeWidget *
-glade_base_editor_build_child (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GType type)
+glade_base_editor_build_child (GladeBaseEditor * editor,
+ GladeWidget * gparent, GType type)
{
- return glade_command_create (glade_widget_adaptor_get_by_type (type),
- gparent, NULL,
- glade_widget_get_project (gparent));
+ return glade_command_create (glade_widget_adaptor_get_by_type (type),
+ gparent, NULL,
+ glade_widget_get_project (gparent));
}
static gboolean
-glade_base_editor_move_child (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GladeWidget *gchild)
+glade_base_editor_move_child (GladeBaseEditor * editor,
+ GladeWidget * gparent, GladeWidget * gchild)
{
- GList list = {0, };
+ GList list = { 0, };
- if (gparent != glade_widget_get_parent (gchild))
- {
- list.data = gchild;
- glade_command_dnd (&list, gparent, NULL);
- }
+ if (gparent != glade_widget_get_parent (gchild))
+ {
+ list.data = gchild;
+ glade_command_dnd (&list, gparent, NULL);
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_base_editor_delete_child_impl (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GladeWidget *gchild)
+glade_base_editor_delete_child_impl (GladeBaseEditor * editor,
+ GladeWidget * gparent,
+ GladeWidget * gchild)
{
- GList list = {0, };
+ GList list = { 0, };
- list.data = gchild;
- glade_command_delete (&list);
-
- return TRUE;
+ list.data = gchild;
+ glade_command_delete (&list);
+
+ return TRUE;
}
static void
-glade_base_editor_class_init (GladeBaseEditorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- parent_class = g_type_class_peek_parent(klass);
-
- object_class->finalize = glade_base_editor_finalize;
- object_class->dispose = glade_base_editor_dispose;
- object_class->set_property = glade_base_editor_set_property;
- object_class->get_property = glade_base_editor_get_property;
-
- klass->change_type = glade_base_editor_change_type;
- klass->get_display_name = glade_base_editor_get_display_name_impl;
- klass->build_child = glade_base_editor_build_child;
- klass->delete_child = glade_base_editor_delete_child_impl;
- klass->move_child = glade_base_editor_move_child;
-
- g_object_class_install_property (object_class, PROP_CONTAINER,
- g_param_spec_object
- ("container", _("Container"),
- _("The container object this editor is currently editing"),
- G_TYPE_OBJECT, G_PARAM_READWRITE));
-
- /**
+glade_base_editor_class_init (GladeBaseEditorClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = glade_base_editor_finalize;
+ object_class->dispose = glade_base_editor_dispose;
+ object_class->set_property = glade_base_editor_set_property;
+ object_class->get_property = glade_base_editor_get_property;
+
+ klass->change_type = glade_base_editor_change_type;
+ klass->get_display_name = glade_base_editor_get_display_name_impl;
+ klass->build_child = glade_base_editor_build_child;
+ klass->delete_child = glade_base_editor_delete_child_impl;
+ klass->move_child = glade_base_editor_move_child;
+
+ g_object_class_install_property (object_class, PROP_CONTAINER,
+ g_param_spec_object
+ ("container", _("Container"),
+ _
+ ("The container object this editor is currently editing"),
+ G_TYPE_OBJECT, G_PARAM_READWRITE));
+
+ /**
* GladeBaseEditor::child-selected:
* @gladebaseeditor: the #GladeBaseEditor which received the signal.
* @gchild: the selected #GladeWidget.
@@ -1481,18 +1477,15 @@ glade_base_editor_class_init (GladeBaseEditorClass *klass)
* You can also add labels with glade_base_editor_add_label to make the
* editor look pretty.
*/
- glade_base_editor_signals [SIGNAL_CHILD_SELECTED] =
- g_signal_new ("child-selected",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeBaseEditorClass, child_selected),
- NULL, NULL,
- glade_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- G_TYPE_OBJECT);
-
- /**
+ glade_base_editor_signals[SIGNAL_CHILD_SELECTED] =
+ g_signal_new ("child-selected",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeBaseEditorClass, child_selected),
+ NULL, NULL,
+ glade_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+ /**
* GladeBaseEditor::child-change-type:
* @gladebaseeditor: the #GladeBaseEditor which received the signal.
* @child: the #GObject being changed.
@@ -1500,18 +1493,16 @@ glade_base_editor_class_init (GladeBaseEditorClass *klass)
*
* Returns: TRUE to stop signal emision.
*/
- glade_base_editor_signals [SIGNAL_CHANGE_TYPE] =
- g_signal_new ("change-type",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeBaseEditorClass, change_type),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__OBJECT_UINT,
- G_TYPE_BOOLEAN,
- 2,
- G_TYPE_OBJECT, G_TYPE_UINT);
-
- /**
+ glade_base_editor_signals[SIGNAL_CHANGE_TYPE] =
+ g_signal_new ("change-type",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeBaseEditorClass, change_type),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__OBJECT_UINT,
+ G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_UINT);
+
+ /**
* GladeBaseEditor::get-display-name:
* @gladebaseeditor: the #GladeBaseEditor which received the signal.
* @gchild: the child to get display name string to show in @gladebaseeditor
@@ -1519,18 +1510,16 @@ glade_base_editor_class_init (GladeBaseEditorClass *klass)
*
* Returns: a newly allocated string.
*/
- glade_base_editor_signals [SIGNAL_GET_DISPLAY_NAME] =
- g_signal_new ("get-display-name",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeBaseEditorClass, get_display_name),
- glade_string_accumulator, NULL,
- glade_marshal_STRING__OBJECT,
- G_TYPE_STRING,
- 1,
- G_TYPE_OBJECT);
-
- /**
+ glade_base_editor_signals[SIGNAL_GET_DISPLAY_NAME] =
+ g_signal_new ("get-display-name",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeBaseEditorClass, get_display_name),
+ glade_string_accumulator, NULL,
+ glade_marshal_STRING__OBJECT,
+ G_TYPE_STRING, 1, G_TYPE_OBJECT);
+
+ /**
* GladeBaseEditor::build-child:
* @gladebaseeditor: the #GladeBaseEditor which received the signal.
* @gparent: the parent of the new child
@@ -1541,35 +1530,31 @@ glade_base_editor_class_init (GladeBaseEditorClass *klass)
*
* Returns: the newly created #GladeWidget or NULL if child cant be created
*/
- glade_base_editor_signals [SIGNAL_BUILD_CHILD] =
- g_signal_new ("build-child",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeBaseEditorClass, build_child),
- glade_stop_emission_accumulator, NULL,
- glade_marshal_OBJECT__OBJECT_UINT,
- G_TYPE_OBJECT,
- 2,
- G_TYPE_OBJECT, G_TYPE_UINT);
-
- /**
+ glade_base_editor_signals[SIGNAL_BUILD_CHILD] =
+ g_signal_new ("build-child",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeBaseEditorClass, build_child),
+ glade_stop_emission_accumulator, NULL,
+ glade_marshal_OBJECT__OBJECT_UINT,
+ G_TYPE_OBJECT, 2, G_TYPE_OBJECT, G_TYPE_UINT);
+
+ /**
* GladeBaseEditor::delete-child:
* @gladebaseeditor: the #GladeBaseEditor which received the signal.
* @gparent: the parent
* @gchild: the child to delete
*/
- glade_base_editor_signals [SIGNAL_DELETE_CHILD] =
- g_signal_new ("delete-child",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeBaseEditorClass, delete_child),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__OBJECT_OBJECT,
- G_TYPE_BOOLEAN,
- 2,
- G_TYPE_OBJECT, G_TYPE_OBJECT);
-
- /**
+ glade_base_editor_signals[SIGNAL_DELETE_CHILD] =
+ g_signal_new ("delete-child",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeBaseEditorClass, delete_child),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__OBJECT_OBJECT,
+ G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
+
+ /**
* GladeBaseEditor::move-child:
* @gladebaseeditor: the #GladeBaseEditor which received the signal.
* @gparent: the new parent of @gchild
@@ -1579,233 +1564,258 @@ glade_base_editor_class_init (GladeBaseEditorClass *klass)
*
* Returns: wheater child has been sucessfully moved or not.
*/
- glade_base_editor_signals [SIGNAL_MOVE_CHILD] =
- g_signal_new ("move-child",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeBaseEditorClass, move_child),
- glade_stop_emission_accumulator, NULL,
- glade_marshal_BOOLEAN__OBJECT_OBJECT,
- G_TYPE_BOOLEAN,
- 2,
- G_TYPE_OBJECT, G_TYPE_OBJECT);
+ glade_base_editor_signals[SIGNAL_MOVE_CHILD] =
+ g_signal_new ("move-child",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeBaseEditorClass, move_child),
+ glade_stop_emission_accumulator, NULL,
+ glade_marshal_BOOLEAN__OBJECT_OBJECT,
+ G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
}
static void
-glade_base_editor_block_callbacks (GladeBaseEditor *editor, gboolean block)
-{
- GladeBaseEditorPrivate *e = editor->priv;
- if (block)
- {
- g_signal_handlers_block_by_func (e->model, glade_base_editor_row_inserted, editor);
- if (e->project)
- {
- g_signal_handlers_block_by_func (e->project, glade_base_editor_project_remove_widget, editor);
- g_signal_handlers_block_by_func (e->project, glade_base_editor_project_add_widget, editor);
- g_signal_handlers_block_by_func (e->project, glade_base_editor_project_changed, editor);
- }
- }
- else
- {
- g_signal_handlers_unblock_by_func (e->model, glade_base_editor_row_inserted, editor);
- if (e->project)
- {
- g_signal_handlers_unblock_by_func (e->project, glade_base_editor_project_remove_widget, editor);
- g_signal_handlers_unblock_by_func (e->project, glade_base_editor_project_add_widget, editor);
- g_signal_handlers_unblock_by_func (e->project, glade_base_editor_project_changed, editor);
- }
- }
+glade_base_editor_block_callbacks (GladeBaseEditor * editor, gboolean block)
+{
+ GladeBaseEditorPrivate *e = editor->priv;
+ if (block)
+ {
+ g_signal_handlers_block_by_func (e->model, glade_base_editor_row_inserted,
+ editor);
+ if (e->project)
+ {
+ g_signal_handlers_block_by_func (e->project,
+ glade_base_editor_project_remove_widget,
+ editor);
+ g_signal_handlers_block_by_func (e->project,
+ glade_base_editor_project_add_widget,
+ editor);
+ g_signal_handlers_block_by_func (e->project,
+ glade_base_editor_project_changed,
+ editor);
+ }
+ }
+ else
+ {
+ g_signal_handlers_unblock_by_func (e->model,
+ glade_base_editor_row_inserted,
+ editor);
+ if (e->project)
+ {
+ g_signal_handlers_unblock_by_func (e->project,
+ glade_base_editor_project_remove_widget,
+ editor);
+ g_signal_handlers_unblock_by_func (e->project,
+ glade_base_editor_project_add_widget,
+ editor);
+ g_signal_handlers_unblock_by_func (e->project,
+ glade_base_editor_project_changed,
+ editor);
+ }
+ }
}
static void
-glade_base_editor_realize_callback (GtkWidget *widget, gpointer user_data)
+glade_base_editor_realize_callback (GtkWidget * widget, gpointer user_data)
{
- GladeBaseEditor *editor = GLADE_BASE_EDITOR (widget);
-
- glade_base_editor_block_callbacks (editor, TRUE);
+ GladeBaseEditor *editor = GLADE_BASE_EDITOR (widget);
- glade_base_editor_fill_store (editor);
- gtk_tree_view_expand_all (GTK_TREE_VIEW (editor->priv->treeview));
-
- glade_base_editor_block_callbacks (editor, FALSE);
+ glade_base_editor_block_callbacks (editor, TRUE);
+
+ glade_base_editor_fill_store (editor);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (editor->priv->treeview));
+
+ glade_base_editor_block_callbacks (editor, FALSE);
}
-static void
-glade_base_editor_switch_page (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- GladeBaseEditor *editor)
+static void
+glade_base_editor_switch_page (GtkNotebook * notebook,
+ GtkWidget * page,
+ guint page_num, GladeBaseEditor * editor)
{
- GladeBaseEditorPrivate *e = editor->priv;
+ GladeBaseEditorPrivate *e = editor->priv;
- if (page_num == 0)
- glade_signal_editor_load_widget (e->signal_editor, e->gcontainer);
- else
- {
- GtkTreeIter iter;
- GladeWidget *gchild = NULL;
+ if (page_num == 0)
+ glade_signal_editor_load_widget (e->signal_editor, e->gcontainer);
+ else
+ {
+ GtkTreeIter iter;
+ GladeWidget *gchild = NULL;
- if (glade_base_editor_get_child_selected (editor, &iter))
- {
- gtk_tree_model_get (e->model, &iter,
- GLADE_BASE_EDITOR_GWIDGET, &gchild,
- -1);
- g_object_unref (G_OBJECT (gchild));
- }
+ if (glade_base_editor_get_child_selected (editor, &iter))
+ {
+ gtk_tree_model_get (e->model, &iter,
+ GLADE_BASE_EDITOR_GWIDGET, &gchild, -1);
+ g_object_unref (G_OBJECT (gchild));
+ }
- if (gchild)
- glade_signal_editor_load_widget (e->signal_editor, gchild);
- else
- glade_signal_editor_load_widget (e->signal_editor, NULL);
- }
+ if (gchild)
+ glade_signal_editor_load_widget (e->signal_editor, gchild);
+ else
+ glade_signal_editor_load_widget (e->signal_editor, NULL);
+ }
}
static void
-glade_base_editor_init (GladeBaseEditor *editor)
-{
- GladeBaseEditorPrivate *e;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkWidget *paned, *hbox, *vbox, *tree_vbox, *scroll, *button_table, *button, *label;
-
- gtk_box_set_spacing (GTK_BOX (editor), 8);
-
- e = editor->priv = g_new0(GladeBaseEditorPrivate, 1);
-
- /* Paned */
- e->paned = paned = gtk_vpaned_new ();
- gtk_widget_show (paned);
- gtk_box_pack_start (GTK_BOX (editor), e->paned, TRUE, TRUE, 0);
-
- /* Notebook */
- e->notebook = gtk_notebook_new ();
- gtk_widget_show (e->notebook);
- gtk_paned_pack1 (GTK_PANED (paned), e->notebook, TRUE, FALSE);
-
- /* ScrolledWindow */
- e->main_scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (e->main_scroll);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (e->main_scroll), GTK_SHADOW_NONE);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (e->main_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- label = gtk_label_new (_("General"));
- gtk_widget_show (label);
- gtk_notebook_append_page (GTK_NOTEBOOK (e->notebook), e->main_scroll, label);
-
- /* Hbox */
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_widget_show (hbox);
-
- label = gtk_label_new (_("Hierarchy"));
- gtk_widget_show (label);
- gtk_notebook_append_page (GTK_NOTEBOOK (e->notebook), hbox, label);
-
- /* TreeView Vbox */
- tree_vbox = gtk_vbox_new (FALSE, 8);
- gtk_widget_show (tree_vbox);
- gtk_box_pack_start (GTK_BOX (hbox), tree_vbox, FALSE, TRUE, 0);
-
- /* ScrolledWindow */
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (scroll);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_NONE);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
- gtk_box_pack_start (GTK_BOX (tree_vbox), scroll, TRUE, TRUE, 0);
-
- /* TreeView */
- e->treeview = gtk_tree_view_new ();
- gtk_widget_show (e->treeview);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (e->treeview), TRUE);
- gtk_tree_view_set_reorderable (GTK_TREE_VIEW (e->treeview), TRUE);
-
- gtk_widget_add_events (e->treeview, GDK_KEY_PRESS_MASK);
- g_signal_connect (e->treeview, "key-press-event",
- G_CALLBACK (glade_base_editor_treeview_key_press_event), editor);
-
- g_signal_connect (e->treeview, "cursor-changed",
- G_CALLBACK (glade_base_editor_treeview_cursor_changed), editor);
-
- g_signal_connect (e->treeview, "button-press-event",
- G_CALLBACK (glade_base_editor_popup_handler), editor);
-
-
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Label"), renderer,
- "text", GLADE_BASE_EDITOR_NAME, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (e->treeview), column);
-
- renderer = gtk_cell_renderer_combo_new ();
- g_object_set (renderer,
- "has-entry", FALSE,
- "text-column", GLADE_BASE_EDITOR_CLASS_NAME,
- "editable", TRUE,
- NULL);
-
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (glade_base_editor_child_type_edited), editor);
-
- column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer,
- "text", GLADE_BASE_EDITOR_TYPE_NAME,
- "model", GLADE_BASE_EDITOR_CHILD_TYPES,
- NULL);
-
- gtk_tree_view_append_column (GTK_TREE_VIEW (e->treeview), column);
-
- gtk_container_add (GTK_CONTAINER (scroll), e->treeview);
-
- /* Add/Remove buttons */
- button_table = gtk_table_new (1, 2, TRUE);
- gtk_widget_show (button_table);
- gtk_table_set_col_spacings (GTK_TABLE (button_table), 8);
- gtk_box_pack_start (GTK_BOX (tree_vbox), button_table, FALSE, TRUE, 0);
-
- button = gtk_button_new_from_stock (GTK_STOCK_ADD);
- gtk_widget_show (button);
- g_signal_connect (button, "clicked",
- G_CALLBACK (glade_base_editor_add_activate), editor);
- gtk_table_attach_defaults (GTK_TABLE (button_table), button, 0, 1, 0, 1);
-
- e->remove_button = button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
- gtk_widget_show (button);
- g_signal_connect (button, "clicked",
- G_CALLBACK (glade_base_editor_delete_activate), editor);
- gtk_table_attach_defaults (GTK_TABLE (button_table), button, 1, 2, 0, 1);
-
- /* Properties Vbox */
- vbox = gtk_vbox_new (FALSE, 8);
- gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
- /* ScrolledWindow */
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (scroll);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_NONE);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
-
- /* Tables */
- e->table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (e->table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_column_spacing (GTK_GRID (e->table), 4);
- gtk_grid_set_row_spacing (GTK_GRID (e->table), 4);
- gtk_widget_show (e->table);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), e->table);
-
- /* Signal Editor */
- e->signal_editor = glade_signal_editor_new (NULL);
- gtk_widget_show (GTK_WIDGET(e->signal_editor));
- gtk_widget_set_size_request (GTK_WIDGET(e->signal_editor), -1, 96);
- gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET(e->signal_editor), FALSE, FALSE);
-
- /* Update the treeview on realize event */
- g_signal_connect (editor, "realize",
- G_CALLBACK (glade_base_editor_realize_callback),
- NULL);
-
- g_signal_connect (G_OBJECT (e->notebook), "switch-page",
- G_CALLBACK (glade_base_editor_switch_page), editor);
+glade_base_editor_init (GladeBaseEditor * editor)
+{
+ GladeBaseEditorPrivate *e;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkWidget *paned, *hbox, *vbox, *tree_vbox, *scroll, *button_table, *button,
+ *label;
+
+ gtk_box_set_spacing (GTK_BOX (editor), 8);
+
+ e = editor->priv = g_new0 (GladeBaseEditorPrivate, 1);
+
+ /* Paned */
+ e->paned = paned = gtk_vpaned_new ();
+ gtk_widget_show (paned);
+ gtk_box_pack_start (GTK_BOX (editor), e->paned, TRUE, TRUE, 0);
+
+ /* Notebook */
+ e->notebook = gtk_notebook_new ();
+ gtk_widget_show (e->notebook);
+ gtk_paned_pack1 (GTK_PANED (paned), e->notebook, TRUE, FALSE);
+
+ /* ScrolledWindow */
+ e->main_scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (e->main_scroll);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (e->main_scroll),
+ GTK_SHADOW_NONE);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (e->main_scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ label = gtk_label_new (_("General"));
+ gtk_widget_show (label);
+ gtk_notebook_append_page (GTK_NOTEBOOK (e->notebook), e->main_scroll, label);
+
+ /* Hbox */
+ hbox = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (hbox);
+
+ label = gtk_label_new (_("Hierarchy"));
+ gtk_widget_show (label);
+ gtk_notebook_append_page (GTK_NOTEBOOK (e->notebook), hbox, label);
+
+ /* TreeView Vbox */
+ tree_vbox = gtk_vbox_new (FALSE, 8);
+ gtk_widget_show (tree_vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), tree_vbox, FALSE, TRUE, 0);
+
+ /* ScrolledWindow */
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scroll);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_NONE);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+ gtk_box_pack_start (GTK_BOX (tree_vbox), scroll, TRUE, TRUE, 0);
+
+ /* TreeView */
+ e->treeview = gtk_tree_view_new ();
+ gtk_widget_show (e->treeview);
+ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (e->treeview), TRUE);
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (e->treeview), TRUE);
+
+ gtk_widget_add_events (e->treeview, GDK_KEY_PRESS_MASK);
+ g_signal_connect (e->treeview, "key-press-event",
+ G_CALLBACK (glade_base_editor_treeview_key_press_event),
+ editor);
+
+ g_signal_connect (e->treeview, "cursor-changed",
+ G_CALLBACK (glade_base_editor_treeview_cursor_changed),
+ editor);
+
+ g_signal_connect (e->treeview, "button-press-event",
+ G_CALLBACK (glade_base_editor_popup_handler), editor);
+
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Label"), renderer,
+ "text",
+ GLADE_BASE_EDITOR_NAME,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (e->treeview), column);
+
+ renderer = gtk_cell_renderer_combo_new ();
+ g_object_set (renderer,
+ "has-entry", FALSE,
+ "text-column", GLADE_BASE_EDITOR_CLASS_NAME,
+ "editable", TRUE, NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (glade_base_editor_child_type_edited), editor);
+
+ column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer,
+ "text",
+ GLADE_BASE_EDITOR_TYPE_NAME,
+ "model",
+ GLADE_BASE_EDITOR_CHILD_TYPES,
+ NULL);
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (e->treeview), column);
+
+ gtk_container_add (GTK_CONTAINER (scroll), e->treeview);
+
+ /* Add/Remove buttons */
+ button_table = gtk_table_new (1, 2, TRUE);
+ gtk_widget_show (button_table);
+ gtk_table_set_col_spacings (GTK_TABLE (button_table), 8);
+ gtk_box_pack_start (GTK_BOX (tree_vbox), button_table, FALSE, TRUE, 0);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_ADD);
+ gtk_widget_show (button);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_base_editor_add_activate), editor);
+ gtk_table_attach_defaults (GTK_TABLE (button_table), button, 0, 1, 0, 1);
+
+ e->remove_button = button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+ gtk_widget_show (button);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_base_editor_delete_activate), editor);
+ gtk_table_attach_defaults (GTK_TABLE (button_table), button, 1, 2, 0, 1);
+
+ /* Properties Vbox */
+ vbox = gtk_vbox_new (FALSE, 8);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ /* ScrolledWindow */
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scroll);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_NONE);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
+
+ /* Tables */
+ e->table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (e->table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_column_spacing (GTK_GRID (e->table), 4);
+ gtk_grid_set_row_spacing (GTK_GRID (e->table), 4);
+ gtk_widget_show (e->table);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
+ e->table);
+
+ /* Signal Editor */
+ e->signal_editor = glade_signal_editor_new (NULL);
+ gtk_widget_show (GTK_WIDGET (e->signal_editor));
+ gtk_widget_set_size_request (GTK_WIDGET (e->signal_editor), -1, 96);
+ gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (e->signal_editor), FALSE,
+ FALSE);
+
+ /* Update the treeview on realize event */
+ g_signal_connect (editor, "realize",
+ G_CALLBACK (glade_base_editor_realize_callback), NULL);
+
+ g_signal_connect (G_OBJECT (e->notebook), "switch-page",
+ G_CALLBACK (glade_base_editor_switch_page), editor);
}
@@ -1813,26 +1823,27 @@ glade_base_editor_init (GladeBaseEditor *editor)
GType
glade_base_editor_get_type ()
{
- static GType type = 0;
+ static GType type = 0;
- if(type == 0) {
- static const GTypeInfo our_info = {
- sizeof (GladeBaseEditorClass),
- NULL,
- NULL,
- (GClassInitFunc)glade_base_editor_class_init,
- NULL,
- NULL,
- sizeof (GladeBaseEditor),
- 0,
- (GInstanceInitFunc)glade_base_editor_init,
- };
+ if (type == 0)
+ {
+ static const GTypeInfo our_info = {
+ sizeof (GladeBaseEditorClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) glade_base_editor_class_init,
+ NULL,
+ NULL,
+ sizeof (GladeBaseEditor),
+ 0,
+ (GInstanceInitFunc) glade_base_editor_init,
+ };
- type = g_type_register_static (GTK_TYPE_VBOX, "GladeBaseEditor",
- &our_info, 0);
- }
+ type = g_type_register_static (GTK_TYPE_VBOX, "GladeBaseEditor",
+ &our_info, 0);
+ }
- return type;
+ return type;
}
/**
@@ -1850,82 +1861,82 @@ glade_base_editor_get_type ()
* Returns: a new GladeBaseEditor.
*/
GladeBaseEditor *
-glade_base_editor_new (GObject *container,
- GladeEditable *main_editable,
- ...)
-{
- ChildTypeTab *child_type;
- GladeWidget *gcontainer;
- GladeBaseEditor *editor;
- GladeBaseEditorPrivate *e;
- GtkTreeIter iter;
- GType iter_type;
- gchar *name;
- va_list args;
-
- g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
-
- gcontainer = glade_widget_get_from_gobject (container);
- g_return_val_if_fail (GLADE_IS_WIDGET (gcontainer), NULL);
-
-
- editor = GLADE_BASE_EDITOR (g_object_new (GLADE_TYPE_BASE_EDITOR, NULL));
- e = editor->priv;
-
- /* Store */
- e->model = (GtkTreeModel *)gtk_tree_store_new (GLADE_BASE_EDITOR_N_COLUMNS,
- G_TYPE_OBJECT,
- G_TYPE_OBJECT,
- G_TYPE_STRING,
- G_TYPE_STRING,
- GTK_TYPE_TREE_MODEL);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (e->treeview), e->model);
- gtk_tree_view_expand_all (GTK_TREE_VIEW (e->treeview));
-
- g_signal_connect (e->model, "row-inserted",
- G_CALLBACK (glade_base_editor_row_inserted),
- editor);
-
- /* Invent one if not provided */
- if (!main_editable)
- main_editable = glade_widget_adaptor_create_editable (gcontainer->adaptor, GLADE_PAGE_GENERAL);
-
- glade_editable_load (main_editable, gcontainer);
- gtk_widget_show (GTK_WIDGET (main_editable));
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (e->main_scroll), GTK_WIDGET (main_editable));
-
- child_type = g_new0 (ChildTypeTab, 1);
- child_type->parent_type = G_OBJECT_TYPE (container);
- child_type->children = (GtkTreeModel *)gtk_list_store_new (GLADE_BASE_EDITOR_TYPES_N_COLUMNS,
- G_TYPE_GTYPE, G_TYPE_STRING);
-
- va_start (args, main_editable);
- while ((name = va_arg (args, gchar *)))
- {
- iter_type = va_arg (args, GType);
-
- gtk_list_store_append (GTK_LIST_STORE (child_type->children), &iter);
- gtk_list_store_set (GTK_LIST_STORE (child_type->children), &iter,
- GLADE_BASE_EDITOR_GTYPE, iter_type,
- GLADE_BASE_EDITOR_CLASS_NAME, name,
- -1);
-
- if (editor->priv->add_type == 0)
- {
- editor->priv->add_type = iter_type;
- editor->priv->add_as_child = FALSE;
- }
- }
- va_end (args);
-
- e->child_types = g_list_prepend (e->child_types, child_type);
-
- glade_base_editor_set_container (editor, container);
-
- glade_signal_editor_load_widget (e->signal_editor, e->gcontainer);
-
- return editor;
+glade_base_editor_new (GObject * container, GladeEditable * main_editable, ...)
+{
+ ChildTypeTab *child_type;
+ GladeWidget *gcontainer;
+ GladeBaseEditor *editor;
+ GladeBaseEditorPrivate *e;
+ GtkTreeIter iter;
+ GType iter_type;
+ gchar *name;
+ va_list args;
+
+ g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
+
+ gcontainer = glade_widget_get_from_gobject (container);
+ g_return_val_if_fail (GLADE_IS_WIDGET (gcontainer), NULL);
+
+
+ editor = GLADE_BASE_EDITOR (g_object_new (GLADE_TYPE_BASE_EDITOR, NULL));
+ e = editor->priv;
+
+ /* Store */
+ e->model = (GtkTreeModel *) gtk_tree_store_new (GLADE_BASE_EDITOR_N_COLUMNS,
+ G_TYPE_OBJECT,
+ G_TYPE_OBJECT,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ GTK_TYPE_TREE_MODEL);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (e->treeview), e->model);
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (e->treeview));
+
+ g_signal_connect (e->model, "row-inserted",
+ G_CALLBACK (glade_base_editor_row_inserted), editor);
+
+ /* Invent one if not provided */
+ if (!main_editable)
+ main_editable =
+ glade_widget_adaptor_create_editable (gcontainer->adaptor,
+ GLADE_PAGE_GENERAL);
+
+ glade_editable_load (main_editable, gcontainer);
+ gtk_widget_show (GTK_WIDGET (main_editable));
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (e->main_scroll),
+ GTK_WIDGET (main_editable));
+
+ child_type = g_new0 (ChildTypeTab, 1);
+ child_type->parent_type = G_OBJECT_TYPE (container);
+ child_type->children =
+ (GtkTreeModel *) gtk_list_store_new (GLADE_BASE_EDITOR_TYPES_N_COLUMNS,
+ G_TYPE_GTYPE, G_TYPE_STRING);
+
+ va_start (args, main_editable);
+ while ((name = va_arg (args, gchar *)))
+ {
+ iter_type = va_arg (args, GType);
+
+ gtk_list_store_append (GTK_LIST_STORE (child_type->children), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (child_type->children), &iter,
+ GLADE_BASE_EDITOR_GTYPE, iter_type,
+ GLADE_BASE_EDITOR_CLASS_NAME, name, -1);
+
+ if (editor->priv->add_type == 0)
+ {
+ editor->priv->add_type = iter_type;
+ editor->priv->add_as_child = FALSE;
+ }
+ }
+ va_end (args);
+
+ e->child_types = g_list_prepend (e->child_types, child_type);
+
+ glade_base_editor_set_container (editor, container);
+
+ glade_signal_editor_load_widget (e->signal_editor, e->gcontainer);
+
+ return editor;
}
@@ -1943,34 +1954,36 @@ glade_base_editor_new (GObject *container,
*
*/
void
-glade_base_editor_append_types (GladeBaseEditor *editor, GType parent_type, ...)
-{
- ChildTypeTab *child_type;
- GtkTreeIter iter;
- gchar *name;
- va_list args;
-
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
- g_return_if_fail (get_children_model_for_type (editor, parent_type) == NULL);
-
- child_type = g_new0 (ChildTypeTab, 1);
- child_type->parent_type = parent_type;
- child_type->children = (GtkTreeModel *)gtk_list_store_new (GLADE_BASE_EDITOR_TYPES_N_COLUMNS,
- G_TYPE_GTYPE, G_TYPE_STRING);
-
- va_start (args, parent_type);
- while ((name = va_arg (args, gchar *)))
- {
- gtk_list_store_append (GTK_LIST_STORE (child_type->children), &iter);
- gtk_list_store_set (GTK_LIST_STORE (child_type->children), &iter,
- GLADE_BASE_EDITOR_GTYPE, va_arg (args, GType),
- GLADE_BASE_EDITOR_CLASS_NAME, name,
- -1);
- }
- va_end (args);
-
- editor->priv->child_types = g_list_insert_sorted (editor->priv->child_types, child_type,
- (GCompareFunc)sort_type_by_hierarchy);
+glade_base_editor_append_types (GladeBaseEditor * editor, GType parent_type,
+ ...)
+{
+ ChildTypeTab *child_type;
+ GtkTreeIter iter;
+ gchar *name;
+ va_list args;
+
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+ g_return_if_fail (get_children_model_for_type (editor, parent_type) == NULL);
+
+ child_type = g_new0 (ChildTypeTab, 1);
+ child_type->parent_type = parent_type;
+ child_type->children =
+ (GtkTreeModel *) gtk_list_store_new (GLADE_BASE_EDITOR_TYPES_N_COLUMNS,
+ G_TYPE_GTYPE, G_TYPE_STRING);
+
+ va_start (args, parent_type);
+ while ((name = va_arg (args, gchar *)))
+ {
+ gtk_list_store_append (GTK_LIST_STORE (child_type->children), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (child_type->children), &iter,
+ GLADE_BASE_EDITOR_GTYPE, va_arg (args, GType),
+ GLADE_BASE_EDITOR_CLASS_NAME, name, -1);
+ }
+ va_end (args);
+
+ editor->priv->child_types =
+ g_list_insert_sorted (editor->priv->child_types, child_type,
+ (GCompareFunc) sort_type_by_hierarchy);
}
/**
@@ -1983,55 +1996,59 @@ glade_base_editor_append_types (GladeBaseEditor *editor, GType parent_type, ...)
* NOTE: This function is intended to be used in "child-selected" callbacks
*/
void
-glade_base_editor_add_default_properties (GladeBaseEditor *editor,
- GladeWidget *gchild)
-{
- GtkTreeIter combo_iter;
- GtkWidget *label, *entry;
- GtkTreeModel *child_class;
- GtkCellRenderer *renderer;
- GObject *child;
-
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
- g_return_if_fail (GLADE_IS_WIDGET (gchild));
- g_return_if_fail (GLADE_IS_WIDGET (gchild->parent));
-
- child = glade_widget_get_object (gchild);
-
- child_class = get_children_model_for_child_type (editor, G_OBJECT_TYPE (child));
-
- /* Name */
- label = gtk_label_new (_("Name:"));
- gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
-
- entry = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (entry), glade_widget_get_name (gchild));
- g_object_set_data (G_OBJECT (entry), "editor", editor);
- g_signal_connect (entry, "activate", G_CALLBACK (glade_base_editor_name_activate), gchild);
- g_signal_connect (entry, "changed", G_CALLBACK (glade_base_editor_name_activate), gchild);
- glade_base_editor_table_attach (editor, label, entry);
-
- if (child_class && gtk_tree_model_iter_n_children (child_class, NULL) > 1)
- {
- /* Type */
- label = gtk_label_new (_("Type:"));
- gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
-
- entry = gtk_combo_box_new ();
- gtk_combo_box_set_model (GTK_COMBO_BOX (entry), child_class);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (entry), renderer, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (entry), renderer, "text",
- GLADE_BASE_EDITOR_CLASS_NAME, NULL);
-
- if (glade_base_editor_get_type_info (editor, &combo_iter,
- G_OBJECT_TYPE (child), -1))
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (entry), &combo_iter);
-
- g_signal_connect (entry, "changed", G_CALLBACK (glade_base_editor_type_changed), editor);
- glade_base_editor_table_attach (editor, label, entry);
- }
+glade_base_editor_add_default_properties (GladeBaseEditor * editor,
+ GladeWidget * gchild)
+{
+ GtkTreeIter combo_iter;
+ GtkWidget *label, *entry;
+ GtkTreeModel *child_class;
+ GtkCellRenderer *renderer;
+ GObject *child;
+
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_WIDGET (gchild));
+ g_return_if_fail (GLADE_IS_WIDGET (gchild->parent));
+
+ child = glade_widget_get_object (gchild);
+
+ child_class =
+ get_children_model_for_child_type (editor, G_OBJECT_TYPE (child));
+
+ /* Name */
+ label = gtk_label_new (_("Name:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (entry), glade_widget_get_name (gchild));
+ g_object_set_data (G_OBJECT (entry), "editor", editor);
+ g_signal_connect (entry, "activate",
+ G_CALLBACK (glade_base_editor_name_activate), gchild);
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (glade_base_editor_name_activate), gchild);
+ glade_base_editor_table_attach (editor, label, entry);
+
+ if (child_class && gtk_tree_model_iter_n_children (child_class, NULL) > 1)
+ {
+ /* Type */
+ label = gtk_label_new (_("Type:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
+
+ entry = gtk_combo_box_new ();
+ gtk_combo_box_set_model (GTK_COMBO_BOX (entry), child_class);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (entry), renderer, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (entry), renderer, "text",
+ GLADE_BASE_EDITOR_CLASS_NAME, NULL);
+
+ if (glade_base_editor_get_type_info (editor, &combo_iter,
+ G_OBJECT_TYPE (child), -1))
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (entry), &combo_iter);
+
+ g_signal_connect (entry, "changed",
+ G_CALLBACK (glade_base_editor_type_changed), editor);
+ glade_base_editor_table_attach (editor, label, entry);
+ }
}
/**
@@ -2046,31 +2063,30 @@ glade_base_editor_add_default_properties (GladeBaseEditor *editor,
* NOTE: This function is intended to be used in "child-selected" callbacks
*/
void
-glade_base_editor_add_properties (GladeBaseEditor *editor,
- GladeWidget *gchild,
- gboolean packing,
- ...)
-{
- GladeEditorProperty *eprop;
- va_list args;
- gchar *property;
-
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
- g_return_if_fail (GLADE_IS_WIDGET (gchild));
-
- va_start (args, packing);
- property = va_arg (args, gchar *);
-
- while (property)
- {
- eprop = glade_widget_create_editor_property (gchild, property, packing, TRUE);
- if (eprop)
- glade_base_editor_table_attach (editor,
- GLADE_EDITOR_PROPERTY (eprop)->item_label,
- GTK_WIDGET (eprop));
- property = va_arg (args, gchar *);
- }
- va_end (args);
+glade_base_editor_add_properties (GladeBaseEditor * editor,
+ GladeWidget * gchild, gboolean packing, ...)
+{
+ GladeEditorProperty *eprop;
+ va_list args;
+ gchar *property;
+
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_WIDGET (gchild));
+
+ va_start (args, packing);
+ property = va_arg (args, gchar *);
+
+ while (property)
+ {
+ eprop =
+ glade_widget_create_editor_property (gchild, property, packing, TRUE);
+ if (eprop)
+ glade_base_editor_table_attach (editor,
+ GLADE_EDITOR_PROPERTY (eprop)->
+ item_label, GTK_WIDGET (eprop));
+ property = va_arg (args, gchar *);
+ }
+ va_end (args);
}
@@ -2085,27 +2101,27 @@ glade_base_editor_add_properties (GladeBaseEditor *editor,
* NOTE: This function is intended to be used in "child-selected" callbacks
*/
void
-glade_base_editor_add_editable (GladeBaseEditor *editor,
- GladeWidget *gchild,
- GladeEditorPageType page)
+glade_base_editor_add_editable (GladeBaseEditor * editor,
+ GladeWidget * gchild, GladeEditorPageType page)
{
- GladeEditable *editable;
- gint row;
-
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
- g_return_if_fail (GLADE_IS_WIDGET (gchild));
+ GladeEditable *editable;
+ gint row;
+
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_WIDGET (gchild));
- editable = glade_widget_adaptor_create_editable (gchild->adaptor, page);
- glade_editable_set_show_name (editable, FALSE);
- glade_editable_load (editable, gchild);
- gtk_widget_show (GTK_WIDGET (editable));
+ editable = glade_widget_adaptor_create_editable (gchild->adaptor, page);
+ glade_editable_set_show_name (editable, FALSE);
+ glade_editable_load (editable, gchild);
+ gtk_widget_show (GTK_WIDGET (editable));
- row = editor->priv->row;
+ row = editor->priv->row;
- gtk_grid_attach (GTK_GRID (editor->priv->table), GTK_WIDGET (editable), 0, row, 2, 1);
- gtk_widget_set_hexpand (GTK_WIDGET (editable), TRUE);
+ gtk_grid_attach (GTK_GRID (editor->priv->table), GTK_WIDGET (editable), 0,
+ row, 2, 1);
+ gtk_widget_set_hexpand (GTK_WIDGET (editable), TRUE);
- editor->priv->row++;
+ editor->priv->row++;
}
@@ -2121,28 +2137,28 @@ glade_base_editor_add_editable (GladeBaseEditor *editor,
* NOTE: This function is intended to be used in "child-selected" callbacks
*/
void
-glade_base_editor_add_label (GladeBaseEditor *editor, gchar *str)
-{
- GtkWidget *label;
- gchar *markup;
- gint row;
-
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
- g_return_if_fail (str != NULL);
-
- label = gtk_label_new (NULL);
- markup = g_strdup_printf ("<span rise=\"-20000\"><b>%s</b></span>", str);
- row = editor->priv->row;
-
- gtk_label_set_markup (GTK_LABEL (label), markup);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
- gtk_misc_set_padding (GTK_MISC (label), 0, 6);
-
- gtk_grid_attach (GTK_GRID (editor->priv->table), label, 0, row, 2, 1);
- gtk_widget_show (label);
- editor->priv->row++;
-
- g_free (markup);
+glade_base_editor_add_label (GladeBaseEditor * editor, gchar * str)
+{
+ GtkWidget *label;
+ gchar *markup;
+ gint row;
+
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+ g_return_if_fail (str != NULL);
+
+ label = gtk_label_new (NULL);
+ markup = g_strdup_printf ("<span rise=\"-20000\"><b>%s</b></span>", str);
+ row = editor->priv->row;
+
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+ gtk_misc_set_padding (GTK_MISC (label), 0, 6);
+
+ gtk_grid_attach (GTK_GRID (editor->priv->table), label, 0, row, 2, 1);
+ gtk_widget_show (label);
+ editor->priv->row++;
+
+ g_free (markup);
}
/**
@@ -2153,32 +2169,32 @@ glade_base_editor_add_label (GladeBaseEditor *editor, gchar *str)
* Shows/hide @editor 's signal editor
*/
void
-glade_base_editor_set_show_signal_editor (GladeBaseEditor *editor, gboolean val)
+glade_base_editor_set_show_signal_editor (GladeBaseEditor * editor,
+ gboolean val)
{
- g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
-
- if (val)
- gtk_widget_show (GTK_WIDGET(editor->priv->signal_editor));
- else
- gtk_widget_hide (GTK_WIDGET(editor->priv->signal_editor));
+ g_return_if_fail (GLADE_IS_BASE_EDITOR (editor));
+
+ if (val)
+ gtk_widget_show (GTK_WIDGET (editor->priv->signal_editor));
+ else
+ gtk_widget_hide (GTK_WIDGET (editor->priv->signal_editor));
}
/* Convenience functions */
static void
-glade_base_editor_help (GtkButton *button, gchar *markup)
+glade_base_editor_help (GtkButton * button, gchar * markup)
{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (glade_app_get_transient_parent (),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, " ");
-
- gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (glade_app_get_transient_parent (),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, " ");
+
+ gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
/**
@@ -2190,66 +2206,66 @@ glade_base_editor_help (GtkButton *button, gchar *markup)
* This convenience function create a new dialog window and packs @editor in it.
*
* Returns: the newly created window
- */
+ */
GtkWidget *
-glade_base_editor_pack_new_window (GladeBaseEditor *editor,
- gchar *title,
- gchar *help_markup)
-{
- GtkWidget *window, *buttonbox, *button;
- gchar *real_title;
-
- g_return_val_if_fail (GLADE_IS_BASE_EDITOR (editor), NULL);
-
- /* Window */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
-
- if (title)
- {
- real_title = g_strdup_printf ("%s - %s", title,
- glade_widget_get_name (editor->priv->gcontainer));
- gtk_window_set_title (GTK_WINDOW (window), real_title);
- g_free (real_title);
- }
-
- g_signal_connect_swapped (G_OBJECT (editor), "notify::container",
- G_CALLBACK (gtk_widget_destroy), window);
-
- /* Button Box */
- buttonbox = gtk_hbutton_box_new ();
- gtk_widget_show (buttonbox);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox), GTK_BUTTONBOX_END);
- gtk_box_set_spacing (GTK_BOX (buttonbox), 8);
- gtk_box_pack_start (GTK_BOX (editor), buttonbox, FALSE, TRUE, 0);
-
- button = gtk_button_new_from_stock (GTK_STOCK_HELP);
- gtk_widget_show (button);
- g_signal_connect (button, "clicked",
- G_CALLBACK (glade_base_editor_help),
- help_markup ? help_markup :
- _("<big><b>Tips:</b></big>\n"
- " * Right-click over the treeview to add items.\n"
- " * Press Delete to remove the selected item.\n"
- " * Drag & Drop to reorder.\n"
- " * Type column is editable."));
- gtk_container_add (GTK_CONTAINER (buttonbox), button);
- gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (buttonbox), button, TRUE);
-
- if (glade_app_get_accel_group ())
- {
- gtk_window_add_accel_group (GTK_WINDOW (window),
- glade_app_get_accel_group ());
- g_signal_connect (G_OBJECT (window), "key-press-event",
- G_CALLBACK (glade_utils_hijack_key_press), NULL);
- }
-
- gtk_widget_show_all (GTK_WIDGET (editor));
-
- gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
-
- gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
-
- return window;
+glade_base_editor_pack_new_window (GladeBaseEditor * editor,
+ gchar * title, gchar * help_markup)
+{
+ GtkWidget *window, *buttonbox, *button;
+ gchar *real_title;
+
+ g_return_val_if_fail (GLADE_IS_BASE_EDITOR (editor), NULL);
+
+ /* Window */
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ if (title)
+ {
+ real_title = g_strdup_printf ("%s - %s", title,
+ glade_widget_get_name (editor->priv->
+ gcontainer));
+ gtk_window_set_title (GTK_WINDOW (window), real_title);
+ g_free (real_title);
+ }
+
+ g_signal_connect_swapped (G_OBJECT (editor), "notify::container",
+ G_CALLBACK (gtk_widget_destroy), window);
+
+ /* Button Box */
+ buttonbox = gtk_hbutton_box_new ();
+ gtk_widget_show (buttonbox);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbox), GTK_BUTTONBOX_END);
+ gtk_box_set_spacing (GTK_BOX (buttonbox), 8);
+ gtk_box_pack_start (GTK_BOX (editor), buttonbox, FALSE, TRUE, 0);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_HELP);
+ gtk_widget_show (button);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_base_editor_help),
+ help_markup ? help_markup :
+ _("<big><b>Tips:</b></big>\n"
+ " * Right-click over the treeview to add items.\n"
+ " * Press Delete to remove the selected item.\n"
+ " * Drag & Drop to reorder.\n"
+ " * Type column is editable."));
+ gtk_container_add (GTK_CONTAINER (buttonbox), button);
+ gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (buttonbox), button, TRUE);
+
+ if (glade_app_get_accel_group ())
+ {
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ glade_app_get_accel_group ());
+ g_signal_connect (G_OBJECT (window), "key-press-event",
+ G_CALLBACK (glade_utils_hijack_key_press), NULL);
+ }
+
+ gtk_widget_show_all (GTK_WIDGET (editor));
+
+ gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
+
+ return window;
}
diff --git a/gladeui/glade-base-editor.h b/gladeui/glade-base-editor.h
index e761e53..c412172 100644
--- a/gladeui/glade-base-editor.h
+++ b/gladeui/glade-base-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2006 Juan Pablo Ugarte.
*
diff --git a/gladeui/glade-builtins.c b/gladeui/glade-builtins.c
index eab06e4..62f8b5b 100644
--- a/gladeui/glade-builtins.c
+++ b/gladeui/glade-builtins.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-clipboard.c - An object for handling Cut/Copy/Paste.
*
@@ -34,47 +33,47 @@
#include "glade-displayable-values.h"
-struct _GladeParamSpecObjects {
- GParamSpec parent_instance;
-
- GType type; /* Object or interface type accepted
- * in this object list.
- */
+struct _GladeParamSpecObjects
+{
+ GParamSpec parent_instance;
+
+ GType type; /* Object or interface type accepted
+ * in this object list.
+ */
};
-typedef struct _GladeStockItem {
- gchar *value_name;
- gchar *value_nick;
- gchar *clean_name;
- gint value;
+typedef struct _GladeStockItem
+{
+ gchar *value_name;
+ gchar *value_nick;
+ gchar *clean_name;
+ gint value;
} GladeStockItem;
/************************************************************
* Auto-generate the enum type for stock properties *
************************************************************/
-
+
/* Hard-coded list of stock images (and displayable translations) from gtk+ that are not stock "items" */
-static const gchar *builtin_stock_images[] =
-{
- "gtk-dialog-authentication", /* GTK_STOCK_DIALOG_AUTHENTICATION */
- "gtk-dnd", /* GTK_STOCK_DND */
- "gtk-dnd-multiple", /* GTK_STOCK_DND_MULTIPLE */
- "gtk-color-picker", /* GTK_STOCK_COLOR_PICKER */
- "gtk-directory", /* GTK_STOCK_DIRECTORY */
- "gtk-file", /* GTK_STOCK_FILE */
- "gtk-missing-image" /* GTK_STOCK_MISSING_IMAGE */
+static const gchar *builtin_stock_images[] = {
+ "gtk-dialog-authentication", /* GTK_STOCK_DIALOG_AUTHENTICATION */
+ "gtk-dnd", /* GTK_STOCK_DND */
+ "gtk-dnd-multiple", /* GTK_STOCK_DND_MULTIPLE */
+ "gtk-color-picker", /* GTK_STOCK_COLOR_PICKER */
+ "gtk-directory", /* GTK_STOCK_DIRECTORY */
+ "gtk-file", /* GTK_STOCK_FILE */
+ "gtk-missing-image" /* GTK_STOCK_MISSING_IMAGE */
};
-static const gchar *builtin_stock_displayables[] =
-{
- N_("Authentication"), /* GTK_STOCK_DIALOG_AUTHENTICATION */
- N_("DnD"), /* GTK_STOCK_DND */
- N_("DnD Multiple"), /* GTK_STOCK_DND_MULTIPLE */
- N_("Color Picker"), /* GTK_STOCK_COLOR_PICKER */
- N_("Directory"), /* GTK_STOCK_DIRECTORY */
- N_("File"), /* GTK_STOCK_FILE */
- N_("Missing Image") /* GTK_STOCK_MISSING_IMAGE */
+static const gchar *builtin_stock_displayables[] = {
+ N_("Authentication"), /* GTK_STOCK_DIALOG_AUTHENTICATION */
+ N_("DnD"), /* GTK_STOCK_DND */
+ N_("DnD Multiple"), /* GTK_STOCK_DND_MULTIPLE */
+ N_("Color Picker"), /* GTK_STOCK_COLOR_PICKER */
+ N_("Directory"), /* GTK_STOCK_DIRECTORY */
+ N_("File"), /* GTK_STOCK_FILE */
+ N_("Missing Image") /* GTK_STOCK_MISSING_IMAGE */
};
static GSList *stock_prefixs = NULL;
@@ -83,254 +82,266 @@ static gboolean stock_prefixs_done = FALSE;
/* FIXME: func needs documentation
*/
void
-glade_standard_stock_append_prefix (const gchar *prefix)
+glade_standard_stock_append_prefix (const gchar * prefix)
{
- if (stock_prefixs_done)
- {
- g_warning ("glade_standard_stock_append_prefix should be used in catalog init-function");
- return;
- }
-
- stock_prefixs = g_slist_append (stock_prefixs, g_strdup (prefix));
+ if (stock_prefixs_done)
+ {
+ g_warning
+ ("glade_standard_stock_append_prefix should be used in catalog init-function");
+ return;
+ }
+
+ stock_prefixs = g_slist_append (stock_prefixs, g_strdup (prefix));
}
static GladeStockItem *
-new_from_values (const gchar *name, const gchar *nick, gint value)
+new_from_values (const gchar * name, const gchar * nick, gint value)
{
- GladeStockItem *new_gsi = NULL;
- gchar *clean_name;
- size_t len = 0;
- guint i = 0;
- guint j = 0;
-
- new_gsi = (GladeStockItem *) g_malloc0 (sizeof(GladeStockItem));
-
- new_gsi->value_name = g_strdup (name);
- new_gsi->value_nick = g_strdup (nick);
- new_gsi->value = value;
-
-
- clean_name = g_strdup (name);
- len = strlen (clean_name);
-
- while (i+j <= len)
- {
- if (clean_name[i+j] == '_')
- j++;
-
- clean_name[i] = clean_name[i+j];
- i++;
- }
-
- new_gsi->clean_name = g_utf8_collate_key (clean_name, i - j);
-
- g_free (clean_name);
-
- return new_gsi;
+ GladeStockItem *new_gsi = NULL;
+ gchar *clean_name;
+ size_t len = 0;
+ guint i = 0;
+ guint j = 0;
+
+ new_gsi = (GladeStockItem *) g_malloc0 (sizeof (GladeStockItem));
+
+ new_gsi->value_name = g_strdup (name);
+ new_gsi->value_nick = g_strdup (nick);
+ new_gsi->value = value;
+
+
+ clean_name = g_strdup (name);
+ len = strlen (clean_name);
+
+ while (i + j <= len)
+ {
+ if (clean_name[i + j] == '_')
+ j++;
+
+ clean_name[i] = clean_name[i + j];
+ i++;
+ }
+
+ new_gsi->clean_name = g_utf8_collate_key (clean_name, i - j);
+
+ g_free (clean_name);
+
+ return new_gsi;
}
static gint
compare_two_gsi (gconstpointer a, gconstpointer b)
{
- GladeStockItem *gsi1 = (GladeStockItem *) a;
- GladeStockItem *gsi2 = (GladeStockItem *) b;
+ GladeStockItem *gsi1 = (GladeStockItem *) a;
+ GladeStockItem *gsi2 = (GladeStockItem *) b;
- return strcmp (gsi1->clean_name, gsi2->clean_name);
+ return strcmp (gsi1->clean_name, gsi2->clean_name);
}
static GArray *
list_stock_items (gboolean include_images)
{
- GtkStockItem item;
- GSList *l = NULL, *stock_list = NULL, *p = NULL;
- gchar *stock_id = NULL, *prefix = NULL;
- gint stock_enum = 0, i = 0;
- GEnumValue value;
- GArray *values = NULL;
- GladeStockItem *gsi;
- GSList *gsi_list = NULL;
- GSList *gsi_list_list = NULL;
-
- stock_list = g_slist_reverse (gtk_stock_list_ids ());
-
- values = g_array_sized_new (TRUE, TRUE, sizeof (GEnumValue),
- g_slist_length (stock_list));
-
- /* We want gtk+ stock items to appear first */
- if ((stock_prefixs && strcmp (stock_prefixs->data, "gtk-")) ||
- stock_prefixs == NULL)
- stock_prefixs = g_slist_prepend (stock_prefixs, g_strdup ("gtk-"));
-
- for (p = stock_prefixs; p; p = g_slist_next (p))
- {
- prefix = p->data;
-
- for (l = stock_list; l; l = g_slist_next (l))
- {
- stock_id = l->data;
- if (g_str_has_prefix (stock_id, prefix) == FALSE ||
- gtk_stock_lookup (stock_id, &item) == FALSE )
- continue;
-
- gsi = new_from_values (item.label, stock_id, stock_enum++ );
- gsi_list = g_slist_insert_sorted (gsi_list, gsi, (GCompareFunc) compare_two_gsi);
- }
-
- gsi_list_list = g_slist_append (gsi_list_list, gsi_list);
- gsi_list = NULL;
-
- /* Images are appended after the gtk+ group of items */
- if (include_images && !strcmp (prefix, "gtk-"))
- {
- for (i = 0; i < G_N_ELEMENTS (builtin_stock_images); i++)
- {
- gsi = new_from_values (builtin_stock_images[i], builtin_stock_images[i], stock_enum++);
- gsi_list = g_slist_insert_sorted (gsi_list, gsi, (GCompareFunc) compare_two_gsi);
- }
- gsi_list_list = g_slist_append (gsi_list_list, gsi_list);
- gsi_list = NULL;
- }
- }
-
- for (p = gsi_list_list; p; p = g_slist_next (p))
- {
-
- for (l = (GSList *) p->data; l; l = g_slist_next (l))
- {
- gsi = (GladeStockItem *) l->data;
- value.value = gsi->value;
- value.value_name = g_strdup (gsi->value_name);
- value.value_nick = g_strdup (gsi->value_nick);
- values = g_array_append_val (values, value);
-
- g_free (gsi->value_nick);
- g_free (gsi->value_name);
- g_free (gsi->clean_name);
- g_free (gsi);
- }
- g_slist_free ((GSList *) p->data);
- }
-
- g_slist_free (gsi_list_list);
-
- stock_prefixs_done = TRUE;
- g_slist_free (stock_list);
-
- return values;
+ GtkStockItem item;
+ GSList *l = NULL, *stock_list = NULL, *p = NULL;
+ gchar *stock_id = NULL, *prefix = NULL;
+ gint stock_enum = 0, i = 0;
+ GEnumValue value;
+ GArray *values = NULL;
+ GladeStockItem *gsi;
+ GSList *gsi_list = NULL;
+ GSList *gsi_list_list = NULL;
+
+ stock_list = g_slist_reverse (gtk_stock_list_ids ());
+
+ values = g_array_sized_new (TRUE, TRUE, sizeof (GEnumValue),
+ g_slist_length (stock_list));
+
+ /* We want gtk+ stock items to appear first */
+ if ((stock_prefixs && strcmp (stock_prefixs->data, "gtk-")) ||
+ stock_prefixs == NULL)
+ stock_prefixs = g_slist_prepend (stock_prefixs, g_strdup ("gtk-"));
+
+ for (p = stock_prefixs; p; p = g_slist_next (p))
+ {
+ prefix = p->data;
+
+ for (l = stock_list; l; l = g_slist_next (l))
+ {
+ stock_id = l->data;
+ if (g_str_has_prefix (stock_id, prefix) == FALSE ||
+ gtk_stock_lookup (stock_id, &item) == FALSE)
+ continue;
+
+ gsi = new_from_values (item.label, stock_id, stock_enum++);
+ gsi_list =
+ g_slist_insert_sorted (gsi_list, gsi,
+ (GCompareFunc) compare_two_gsi);
+ }
+
+ gsi_list_list = g_slist_append (gsi_list_list, gsi_list);
+ gsi_list = NULL;
+
+ /* Images are appended after the gtk+ group of items */
+ if (include_images && !strcmp (prefix, "gtk-"))
+ {
+ for (i = 0; i < G_N_ELEMENTS (builtin_stock_images); i++)
+ {
+ gsi =
+ new_from_values (builtin_stock_images[i],
+ builtin_stock_images[i], stock_enum++);
+ gsi_list =
+ g_slist_insert_sorted (gsi_list, gsi,
+ (GCompareFunc) compare_two_gsi);
+ }
+ gsi_list_list = g_slist_append (gsi_list_list, gsi_list);
+ gsi_list = NULL;
+ }
+ }
+
+ for (p = gsi_list_list; p; p = g_slist_next (p))
+ {
+
+ for (l = (GSList *) p->data; l; l = g_slist_next (l))
+ {
+ gsi = (GladeStockItem *) l->data;
+ value.value = gsi->value;
+ value.value_name = g_strdup (gsi->value_name);
+ value.value_nick = g_strdup (gsi->value_nick);
+ values = g_array_append_val (values, value);
+
+ g_free (gsi->value_nick);
+ g_free (gsi->value_name);
+ g_free (gsi->clean_name);
+ g_free (gsi);
+ }
+ g_slist_free ((GSList *) p->data);
+ }
+
+ g_slist_free (gsi_list_list);
+
+ stock_prefixs_done = TRUE;
+ g_slist_free (stock_list);
+
+ return values;
}
static gchar *
-clean_stock_name (const gchar *name)
+clean_stock_name (const gchar * name)
{
- gchar *clean_name, *str;
- size_t len = 0;
- guint i = 0;
- guint j = 0;
-
- g_assert (name && name[0]);
-
- str = g_strdup (name);
- len = strlen (str);
-
- while (i+j <= len)
- {
- if (str[i+j] == '_')
- j++;
-
- str[i] = str[i+j];
- i++;
- }
- clean_name = g_strndup (str, i - j);
- g_free (str);
-
- return clean_name;
+ gchar *clean_name, *str;
+ size_t len = 0;
+ guint i = 0;
+ guint j = 0;
+
+ g_assert (name && name[0]);
+
+ str = g_strdup (name);
+ len = strlen (str);
+
+ while (i + j <= len)
+ {
+ if (str[i + j] == '_')
+ j++;
+
+ str[i] = str[i + j];
+ i++;
+ }
+ clean_name = g_strndup (str, i - j);
+ g_free (str);
+
+ return clean_name;
}
GType
glade_standard_stock_get_type (void)
{
- static GType etype = 0;
-
- if (etype == 0) {
- GArray *values = list_stock_items (FALSE);
- gint i, n_values = values->len;
- GEnumValue *enum_values = (GEnumValue *)values->data;
- GtkStockItem item;
-
- etype = g_enum_register_static ("GladeStock",
- (GEnumValue *)g_array_free (values, FALSE));
-
- /* Register displayable by GType, i.e. after the types been created. */
- for (i = 0; i < n_values; i++)
- {
- if (gtk_stock_lookup (enum_values[i].value_nick, &item))
- {
- gchar *clean_name = clean_stock_name (item.label);
- glade_register_translated_value (etype, enum_values[i].value_nick, clean_name);
- g_free (clean_name);
- }
- }
- }
- return etype;
+ static GType etype = 0;
+
+ if (etype == 0)
+ {
+ GArray *values = list_stock_items (FALSE);
+ gint i, n_values = values->len;
+ GEnumValue *enum_values = (GEnumValue *) values->data;
+ GtkStockItem item;
+
+ etype = g_enum_register_static ("GladeStock",
+ (GEnumValue *) g_array_free (values,
+ FALSE));
+
+ /* Register displayable by GType, i.e. after the types been created. */
+ for (i = 0; i < n_values; i++)
+ {
+ if (gtk_stock_lookup (enum_values[i].value_nick, &item))
+ {
+ gchar *clean_name = clean_stock_name (item.label);
+ glade_register_translated_value (etype, enum_values[i].value_nick,
+ clean_name);
+ g_free (clean_name);
+ }
+ }
+ }
+ return etype;
}
GType
glade_standard_stock_image_get_type (void)
{
- static GType etype = 0;
-
- if (etype == 0) {
- GArray *values = list_stock_items (TRUE);
- gint i, n_values = values->len;
- GEnumValue *enum_values = (GEnumValue *)values->data;
- GtkStockItem item;
-
- etype = g_enum_register_static ("GladeStockImage",
- (GEnumValue *)g_array_free (values, FALSE));
-
- /* Register displayable by GType, i.e. after the types been created. */
- for (i = 0; i < n_values; i++)
- {
- if (gtk_stock_lookup (enum_values[i].value_nick, &item))
- {
- gchar *clean_name = clean_stock_name (item.label);
-
- /* These are translated, we just cut out the mnemonic underscores */
- glade_register_translated_value (etype, enum_values[i].value_nick, clean_name);
- g_free (clean_name);
- }
- }
-
- for (i = 0; i < G_N_ELEMENTS (builtin_stock_images); i++)
- {
- /* these ones are translated from glade3 */
- glade_register_displayable_value (etype,
- builtin_stock_images[i], GETTEXT_PACKAGE,
- builtin_stock_displayables[i]);
- }
- }
- return etype;
+ static GType etype = 0;
+
+ if (etype == 0)
+ {
+ GArray *values = list_stock_items (TRUE);
+ gint i, n_values = values->len;
+ GEnumValue *enum_values = (GEnumValue *) values->data;
+ GtkStockItem item;
+
+ etype = g_enum_register_static ("GladeStockImage",
+ (GEnumValue *) g_array_free (values,
+ FALSE));
+
+ /* Register displayable by GType, i.e. after the types been created. */
+ for (i = 0; i < n_values; i++)
+ {
+ if (gtk_stock_lookup (enum_values[i].value_nick, &item))
+ {
+ gchar *clean_name = clean_stock_name (item.label);
+
+ /* These are translated, we just cut out the mnemonic underscores */
+ glade_register_translated_value (etype, enum_values[i].value_nick,
+ clean_name);
+ g_free (clean_name);
+ }
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (builtin_stock_images); i++)
+ {
+ /* these ones are translated from glade3 */
+ glade_register_displayable_value (etype,
+ builtin_stock_images[i],
+ GETTEXT_PACKAGE,
+ builtin_stock_displayables[i]);
+ }
+ }
+ return etype;
}
GParamSpec *
glade_standard_stock_spec (void)
{
- return g_param_spec_enum ("stock", _("Stock"),
- _("A builtin stock item"),
- GLADE_TYPE_STOCK,
- 0, G_PARAM_READWRITE);
+ return g_param_spec_enum ("stock", _("Stock"),
+ _("A builtin stock item"),
+ GLADE_TYPE_STOCK, 0, G_PARAM_READWRITE);
}
GParamSpec *
glade_standard_stock_image_spec (void)
{
- return g_param_spec_enum ("stock-image", _("Stock Image"),
- _("A builtin stock image"),
- GLADE_TYPE_STOCK_IMAGE,
- 0, G_PARAM_READWRITE);
+ return g_param_spec_enum ("stock-image", _("Stock Image"),
+ _("A builtin stock image"),
+ GLADE_TYPE_STOCK_IMAGE, 0, G_PARAM_READWRITE);
}
/****************************************************************
@@ -340,14 +351,13 @@ glade_standard_stock_image_spec (void)
GType
glade_glist_get_type (void)
{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static
- ("GladeGList",
- (GBoxedCopyFunc) g_list_copy,
- (GBoxedFreeFunc) g_list_free);
- return type_id;
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static
+ ("GladeGList",
+ (GBoxedCopyFunc) g_list_copy, (GBoxedFreeFunc) g_list_free);
+ return type_id;
}
/****************************************************************
@@ -356,65 +366,62 @@ glade_glist_get_type (void)
* for any object list property) *
****************************************************************/
static void
-param_objects_init (GParamSpec *pspec)
+param_objects_init (GParamSpec * pspec)
{
- GladeParamSpecObjects *ospec = GLADE_PARAM_SPEC_OBJECTS (pspec);
- ospec->type = G_TYPE_OBJECT;
+ GladeParamSpecObjects *ospec = GLADE_PARAM_SPEC_OBJECTS (pspec);
+ ospec->type = G_TYPE_OBJECT;
}
static void
-param_objects_set_default (GParamSpec *pspec,
- GValue *value)
+param_objects_set_default (GParamSpec * pspec, GValue * value)
{
- if (value->data[0].v_pointer != NULL)
- {
- g_free (value->data[0].v_pointer);
- }
- value->data[0].v_pointer = NULL;
+ if (value->data[0].v_pointer != NULL)
+ {
+ g_free (value->data[0].v_pointer);
+ }
+ value->data[0].v_pointer = NULL;
}
static gboolean
-param_objects_validate (GParamSpec *pspec,
- GValue *value)
+param_objects_validate (GParamSpec * pspec, GValue * value)
{
- GladeParamSpecObjects *ospec = GLADE_PARAM_SPEC_OBJECTS (pspec);
- GList *objects, *list, *toremove = NULL;
- GObject *object;
-
- objects = value->data[0].v_pointer;
-
- for (list = objects; list; list = list->next)
- {
- object = list->data;
-
- if (G_TYPE_IS_INTERFACE (ospec->type) &&
- glade_util_class_implements_interface
- (G_OBJECT_TYPE (object), ospec->type) == FALSE)
- toremove = g_list_prepend (toremove, object);
- else if (G_TYPE_IS_INTERFACE (ospec->type) == FALSE &&
- g_type_is_a (G_OBJECT_TYPE (object),
- ospec->type) == FALSE)
- toremove = g_list_prepend (toremove, object);
-
-
- }
-
- for (list = toremove; list; list = list->next)
- {
- object = list->data;
- objects = g_list_remove (objects, object);
- }
- if (toremove) g_list_free (toremove);
-
- value->data[0].v_pointer = objects;
-
- return toremove != NULL;
+ GladeParamSpecObjects *ospec = GLADE_PARAM_SPEC_OBJECTS (pspec);
+ GList *objects, *list, *toremove = NULL;
+ GObject *object;
+
+ objects = value->data[0].v_pointer;
+
+ for (list = objects; list; list = list->next)
+ {
+ object = list->data;
+
+ if (G_TYPE_IS_INTERFACE (ospec->type) &&
+ glade_util_class_implements_interface
+ (G_OBJECT_TYPE (object), ospec->type) == FALSE)
+ toremove = g_list_prepend (toremove, object);
+ else if (G_TYPE_IS_INTERFACE (ospec->type) == FALSE &&
+ g_type_is_a (G_OBJECT_TYPE (object), ospec->type) == FALSE)
+ toremove = g_list_prepend (toremove, object);
+
+
+ }
+
+ for (list = toremove; list; list = list->next)
+ {
+ object = list->data;
+ objects = g_list_remove (objects, object);
+ }
+ if (toremove)
+ g_list_free (toremove);
+
+ value->data[0].v_pointer = objects;
+
+ return toremove != NULL;
}
static gint
-param_objects_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
+param_objects_values_cmp (GParamSpec * pspec,
+ const GValue * value1, const GValue * value2)
{
guint8 *p1 = value1->data[0].v_pointer;
guint8 *p2 = value2->data[0].v_pointer;
@@ -427,55 +434,53 @@ param_objects_values_cmp (GParamSpec *pspec,
GType
glade_param_objects_get_type (void)
{
- static GType objects_type = 0;
-
- if (objects_type == 0)
- {
- static /* const */ GParamSpecTypeInfo pspec_info = {
- sizeof (GladeParamSpecObjects), /* instance_size */
- 16, /* n_preallocs */
- param_objects_init, /* instance_init */
- 0xdeadbeef, /* value_type, assigned further down */
- NULL, /* finalize */
- param_objects_set_default, /* value_set_default */
- param_objects_validate, /* value_validate */
- param_objects_values_cmp, /* values_cmp */
- };
- pspec_info.value_type = GLADE_TYPE_GLIST;
-
- objects_type = g_param_type_register_static
- ("GladeParamObjects", &pspec_info);
- }
- return objects_type;
+ static GType objects_type = 0;
+
+ if (objects_type == 0)
+ {
+ static /* const */ GParamSpecTypeInfo pspec_info = {
+ sizeof (GladeParamSpecObjects), /* instance_size */
+ 16, /* n_preallocs */
+ param_objects_init, /* instance_init */
+ 0xdeadbeef, /* value_type, assigned further down */
+ NULL, /* finalize */
+ param_objects_set_default, /* value_set_default */
+ param_objects_validate, /* value_validate */
+ param_objects_values_cmp, /* values_cmp */
+ };
+ pspec_info.value_type = GLADE_TYPE_GLIST;
+
+ objects_type = g_param_type_register_static
+ ("GladeParamObjects", &pspec_info);
+ }
+ return objects_type;
}
GParamSpec *
-glade_param_spec_objects (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GType accepted_type,
- GParamFlags flags)
+glade_param_spec_objects (const gchar * name,
+ const gchar * nick,
+ const gchar * blurb,
+ GType accepted_type, GParamFlags flags)
{
GladeParamSpecObjects *pspec;
pspec = g_param_spec_internal (GLADE_TYPE_PARAM_OBJECTS,
- name, nick, blurb, flags);
-
+ name, nick, blurb, flags);
+
pspec->type = accepted_type;
return G_PARAM_SPEC (pspec);
}
void
-glade_param_spec_objects_set_type (GladeParamSpecObjects *pspec,
- GType type)
+glade_param_spec_objects_set_type (GladeParamSpecObjects * pspec, GType type)
{
- pspec->type = type;
+ pspec->type = type;
}
GType
-glade_param_spec_objects_get_type (GladeParamSpecObjects *pspec)
+glade_param_spec_objects_get_type (GladeParamSpecObjects * pspec)
{
- return pspec->type;
+ return pspec->type;
}
/* This was developed for the purpose of holding a list
@@ -485,29 +490,29 @@ glade_param_spec_objects_get_type (GladeParamSpecObjects *pspec)
GParamSpec *
glade_standard_objects_spec (void)
{
- return glade_param_spec_objects ("objects", _("Objects"),
- _("A list of objects"),
- G_TYPE_OBJECT,
- G_PARAM_READWRITE);
+ return glade_param_spec_objects ("objects", _("Objects"),
+ _("A list of objects"),
+ G_TYPE_OBJECT, G_PARAM_READWRITE);
}
/* Pixbuf Type */
GParamSpec *
glade_standard_pixbuf_spec (void)
{
- return g_param_spec_object ("pixbuf", _("Image File Name"),
- _("Enter a filename, relative path or full path to "
- "load the image"), GDK_TYPE_PIXBUF,
- G_PARAM_READWRITE);
+ return g_param_spec_object ("pixbuf", _("Image File Name"),
+ _
+ ("Enter a filename, relative path or full path to "
+ "load the image"), GDK_TYPE_PIXBUF,
+ G_PARAM_READWRITE);
}
/* GdkColor */
GParamSpec *
glade_standard_gdkcolor_spec (void)
{
- return g_param_spec_boxed ("gdkcolor", _("GdkColor"),
- _("A GDK color value"), GDK_TYPE_COLOR,
- G_PARAM_READWRITE);
+ return g_param_spec_boxed ("gdkcolor", _("GdkColor"),
+ _("A GDK color value"), GDK_TYPE_COLOR,
+ G_PARAM_READWRITE);
}
/****************************************************************
@@ -516,71 +521,66 @@ glade_standard_gdkcolor_spec (void)
GParamSpec *
glade_standard_int_spec (void)
{
- return g_param_spec_int ("int", _("Integer"),
- _("An integer value"),
- G_MININT, G_MAXINT,
- 0, G_PARAM_READWRITE);
+ return g_param_spec_int ("int", _("Integer"),
+ _("An integer value"),
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE);
}
GParamSpec *
glade_standard_uint_spec (void)
{
- return g_param_spec_uint ("uint", _("Unsigned Integer"),
- _("An unsigned integer value"),
- 0, G_MAXUINT, 0, G_PARAM_READWRITE);
+ return g_param_spec_uint ("uint", _("Unsigned Integer"),
+ _("An unsigned integer value"),
+ 0, G_MAXUINT, 0, G_PARAM_READWRITE);
}
GParamSpec *
glade_standard_string_spec (void)
{
- return g_param_spec_string ("string", _("String"),
- _("An entry"), "",
- G_PARAM_READWRITE);
+ return g_param_spec_string ("string", _("String"),
+ _("An entry"), "", G_PARAM_READWRITE);
}
GParamSpec *
glade_standard_strv_spec (void)
{
- return g_param_spec_boxed ("strv", _("Strv"),
- _("String array"),
- G_TYPE_STRV,
- G_PARAM_READWRITE);
+ return g_param_spec_boxed ("strv", _("Strv"),
+ _("String array"), G_TYPE_STRV, G_PARAM_READWRITE);
}
GParamSpec *
glade_standard_float_spec (void)
{
- return g_param_spec_float ("float", _("Float"),
- _("A floating point entry"),
- 0.0F, G_MAXFLOAT, 0.0F,
- G_PARAM_READWRITE);
+ return g_param_spec_float ("float", _("Float"),
+ _("A floating point entry"),
+ 0.0F, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE);
}
GParamSpec *
glade_standard_boolean_spec (void)
{
- return g_param_spec_boolean ("boolean", _("Boolean"),
- _("A boolean value"), FALSE,
- G_PARAM_READWRITE);
+ return g_param_spec_boolean ("boolean", _("Boolean"),
+ _("A boolean value"), FALSE, G_PARAM_READWRITE);
}
GType
glade_item_appearance_get_type (void)
{
- static GType etype = 0;
+ static GType etype = 0;
- if (etype == 0)
- {
- static const GEnumValue values[] = {
- { GLADE_ITEM_ICON_AND_LABEL, "GLADE_ITEM_ICON_AND_LABEL", "icon-and-label" },
- { GLADE_ITEM_ICON_ONLY, "GLADE_ITEM_ICON_ONLY", "icon-only" },
- { GLADE_ITEM_LABEL_ONLY, "GLADE_ITEM_LABEL_ONLY", "label-only" },
- { 0, NULL, NULL }
- };
+ if (etype == 0)
+ {
+ static const GEnumValue values[] = {
+ {GLADE_ITEM_ICON_AND_LABEL, "GLADE_ITEM_ICON_AND_LABEL",
+ "icon-and-label"},
+ {GLADE_ITEM_ICON_ONLY, "GLADE_ITEM_ICON_ONLY", "icon-only"},
+ {GLADE_ITEM_LABEL_ONLY, "GLADE_ITEM_LABEL_ONLY", "label-only"},
+ {0, NULL, NULL}
+ };
- etype = g_enum_register_static ("GladeItemAppearance", values);
+ etype = g_enum_register_static ("GladeItemAppearance", values);
- }
+ }
- return etype;
+ return etype;
}
diff --git a/gladeui/glade-builtins.h b/gladeui/glade-builtins.h
index 72a66a3..16723ad 100644
--- a/gladeui/glade-builtins.h
+++ b/gladeui/glade-builtins.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_BUILTINS_H__
#define __GLADE_BUILTINS_H__
diff --git a/gladeui/glade-catalog.c b/gladeui/glade-catalog.c
index 09a6c3b..83e69e1 100644
--- a/gladeui/glade-catalog.c
+++ b/gladeui/glade-catalog.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2004 Imendio AB
@@ -35,69 +34,67 @@
struct _GladeCatalog
{
- guint16 major_version; /* The catalog version */
- guint16 minor_version;
+ guint16 major_version; /* The catalog version */
+ guint16 minor_version;
- GList *targetable_versions; /* list of suitable version targets */
+ GList *targetable_versions; /* list of suitable version targets */
- gchar *library; /* Library name for backend support */
+ gchar *library; /* Library name for backend support */
- gchar *name; /* Symbolic catalog name */
+ gchar *name; /* Symbolic catalog name */
- gchar *dep_catalog; /* Symbolic name of the catalog that
- * this catalog depends on */
+ gchar *dep_catalog; /* Symbolic name of the catalog that
+ * this catalog depends on */
- gchar *domain; /* The domain to be used to translate
- * strings from this catalog (otherwise this
- * defaults to the library name)
- */
-
- gchar *book; /* Devhelp search domain
- */
+ gchar *domain; /* The domain to be used to translate
+ * strings from this catalog (otherwise this
+ * defaults to the library name)
+ */
- gchar *icon_prefix; /* the prefix for icons */
+ gchar *book; /* Devhelp search domain
+ */
- GList *widget_groups; /* List of widget groups (palette) */
- GList *adaptors; /* List of widget class adaptors (all) */
+ gchar *icon_prefix; /* the prefix for icons */
- GladeXmlContext *context;/* Xml context is stored after open
- * before classes are loaded */
-
- GModule *module;
-
- gchar *init_function_name;/* Catalog's init function name */
- GladeCatalogInitFunc init_function;
+ GList *widget_groups; /* List of widget groups (palette) */
+ GList *adaptors; /* List of widget class adaptors (all) */
+
+ GladeXmlContext *context; /* Xml context is stored after open
+ * before classes are loaded */
+
+ GModule *module;
+
+ gchar *init_function_name; /* Catalog's init function name */
+ GladeCatalogInitFunc init_function;
};
struct _GladeWidgetGroup
{
- gchar *name; /* Group name */
- gchar *title; /* Group name in the palette */
+ gchar *name; /* Group name */
+ gchar *title; /* Group name in the palette */
- gboolean expanded; /* Whether group is expanded in the palette */
+ gboolean expanded; /* Whether group is expanded in the palette */
- GList *adaptors; /* List of class adaptors in the palette */
+ GList *adaptors; /* List of class adaptors in the palette */
};
-static void catalog_load (GladeCatalog *catalog);
-
-static GladeCatalog *catalog_open (const gchar *filename);
+static void catalog_load (GladeCatalog * catalog);
-static GList *catalog_sort (GList *catalogs);
+static GladeCatalog *catalog_open (const gchar * filename);
-static gboolean catalog_load_classes (GladeCatalog *catalog,
+static GList *catalog_sort (GList * catalogs);
- GladeXmlNode *widgets_node);
-
-static gboolean catalog_load_group (GladeCatalog *catalog,
+static gboolean catalog_load_classes (GladeCatalog * catalog,
+ GladeXmlNode * widgets_node);
- GladeXmlNode *group_node);
+static gboolean catalog_load_group (GladeCatalog * catalog,
+ GladeXmlNode * group_node);
-static void widget_group_destroy (GladeWidgetGroup *group);
+static void widget_group_destroy (GladeWidgetGroup * group);
-static void catalog_destroy (GladeCatalog *catalog);
+static void catalog_destroy (GladeCatalog * catalog);
-static void module_close (GModule *module);
+static void module_close (GModule * module);
/* List of catalogs successfully loaded.
@@ -105,666 +102,666 @@ static void module_close (GModule *module);
static GList *loaded_catalogs = NULL;
static gboolean
-catalog_get_function (GladeCatalog *catalog,
- const gchar *symbol_name,
- gpointer *symbol_ptr)
+catalog_get_function (GladeCatalog * catalog,
+ const gchar * symbol_name, gpointer * symbol_ptr)
{
- if (catalog->module == NULL)
- catalog->module = glade_util_load_library (catalog->library);
-
- if (catalog->module)
- return g_module_symbol (catalog->module, symbol_name, symbol_ptr);
+ if (catalog->module == NULL)
+ catalog->module = glade_util_load_library (catalog->library);
- return FALSE;
+ if (catalog->module)
+ return g_module_symbol (catalog->module, symbol_name, symbol_ptr);
+
+ return FALSE;
}
static GladeCatalog *
catalog_allocate (void)
{
- GladeCatalog *catalog;
-
- catalog = g_slice_new0 (GladeCatalog);
-
- catalog->library = NULL;
- catalog->name = NULL;
- catalog->dep_catalog = NULL;
- catalog->domain = NULL;
- catalog->book = NULL;
- catalog->icon_prefix = NULL;
- catalog->init_function_name = NULL;
- catalog->module = NULL;
-
- catalog->context = NULL;
- catalog->adaptors = NULL;
- catalog->widget_groups = NULL;
-
- return catalog;
+ GladeCatalog *catalog;
+
+ catalog = g_slice_new0 (GladeCatalog);
+
+ catalog->library = NULL;
+ catalog->name = NULL;
+ catalog->dep_catalog = NULL;
+ catalog->domain = NULL;
+ catalog->book = NULL;
+ catalog->icon_prefix = NULL;
+ catalog->init_function_name = NULL;
+ catalog->module = NULL;
+
+ catalog->context = NULL;
+ catalog->adaptors = NULL;
+ catalog->widget_groups = NULL;
+
+ return catalog;
}
static GladeCatalog *
-catalog_open (const gchar *filename)
+catalog_open (const gchar * filename)
{
- GladeTargetableVersion *version;
- GladeCatalog *catalog;
- GladeXmlContext *context;
- GladeXmlDoc *doc;
- GladeXmlNode *root;
-
- /* get the context & root node of the catalog file */
- context = glade_xml_context_new_from_path (filename,
- NULL,
- GLADE_TAG_GLADE_CATALOG);
- if (!context)
- {
- g_warning ("Couldn't open catalog [%s].", filename);
- return NULL;
- }
-
- doc = glade_xml_context_get_doc (context);
- root = glade_xml_doc_get_root (doc);
-
- if (!glade_xml_node_verify (root, GLADE_TAG_GLADE_CATALOG))
- {
- g_warning ("Catalog root node is not '%s', skipping %s",
- GLADE_TAG_GLADE_CATALOG, filename);
- glade_xml_context_free (context);
- return NULL;
- }
-
- catalog = catalog_allocate ();
- catalog->context = context;
- catalog->name = glade_xml_get_property_string (root, GLADE_TAG_NAME);
-
- if (!catalog->name)
- {
- g_warning ("Couldn't find required property 'name' in catalog root node");
- catalog_destroy (catalog);
- return NULL;
- }
-
-
- glade_xml_get_property_version (root, GLADE_TAG_VERSION,
- &catalog->major_version,
- &catalog->minor_version);
-
- /* Make one default suitable target */
- version = g_new (GladeTargetableVersion, 1);
- version->major = catalog->major_version;
- version->minor = catalog->minor_version;
-
- catalog->targetable_versions =
- glade_xml_get_property_targetable_versions
- (root, GLADE_TAG_TARGETABLE);
-
- catalog->targetable_versions = g_list_prepend (catalog->targetable_versions, version);
-
- catalog->library = glade_xml_get_property_string (root, GLADE_TAG_LIBRARY);
- catalog->dep_catalog = glade_xml_get_property_string (root, GLADE_TAG_DEPENDS);
- catalog->domain = glade_xml_get_property_string (root, GLADE_TAG_DOMAIN);
- catalog->book = glade_xml_get_property_string (root, GLADE_TAG_BOOK);
- catalog->icon_prefix = glade_xml_get_property_string (root, GLADE_TAG_ICON_PREFIX);
- catalog->init_function_name = glade_xml_get_value_string (root, GLADE_TAG_INIT_FUNCTION);
-
- if (!catalog->domain)
- catalog->domain = g_strdup (catalog->library);
-
- /* catalog->icon_prefix defaults to catalog->name */
- if (!catalog->icon_prefix)
- catalog->icon_prefix = g_strdup (catalog->name);
-
- if (catalog->init_function_name)
- catalog_get_function (catalog, catalog->init_function_name,
- (gpointer) &catalog->init_function);
-
- return catalog;
+ GladeTargetableVersion *version;
+ GladeCatalog *catalog;
+ GladeXmlContext *context;
+ GladeXmlDoc *doc;
+ GladeXmlNode *root;
+
+ /* get the context & root node of the catalog file */
+ context = glade_xml_context_new_from_path (filename,
+ NULL, GLADE_TAG_GLADE_CATALOG);
+ if (!context)
+ {
+ g_warning ("Couldn't open catalog [%s].", filename);
+ return NULL;
+ }
+
+ doc = glade_xml_context_get_doc (context);
+ root = glade_xml_doc_get_root (doc);
+
+ if (!glade_xml_node_verify (root, GLADE_TAG_GLADE_CATALOG))
+ {
+ g_warning ("Catalog root node is not '%s', skipping %s",
+ GLADE_TAG_GLADE_CATALOG, filename);
+ glade_xml_context_free (context);
+ return NULL;
+ }
+
+ catalog = catalog_allocate ();
+ catalog->context = context;
+ catalog->name = glade_xml_get_property_string (root, GLADE_TAG_NAME);
+
+ if (!catalog->name)
+ {
+ g_warning ("Couldn't find required property 'name' in catalog root node");
+ catalog_destroy (catalog);
+ return NULL;
+ }
+
+
+ glade_xml_get_property_version (root, GLADE_TAG_VERSION,
+ &catalog->major_version,
+ &catalog->minor_version);
+
+ /* Make one default suitable target */
+ version = g_new (GladeTargetableVersion, 1);
+ version->major = catalog->major_version;
+ version->minor = catalog->minor_version;
+
+ catalog->targetable_versions =
+ glade_xml_get_property_targetable_versions (root, GLADE_TAG_TARGETABLE);
+
+ catalog->targetable_versions =
+ g_list_prepend (catalog->targetable_versions, version);
+
+ catalog->library = glade_xml_get_property_string (root, GLADE_TAG_LIBRARY);
+ catalog->dep_catalog =
+ glade_xml_get_property_string (root, GLADE_TAG_DEPENDS);
+ catalog->domain = glade_xml_get_property_string (root, GLADE_TAG_DOMAIN);
+ catalog->book = glade_xml_get_property_string (root, GLADE_TAG_BOOK);
+ catalog->icon_prefix =
+ glade_xml_get_property_string (root, GLADE_TAG_ICON_PREFIX);
+ catalog->init_function_name =
+ glade_xml_get_value_string (root, GLADE_TAG_INIT_FUNCTION);
+
+ if (!catalog->domain)
+ catalog->domain = g_strdup (catalog->library);
+
+ /* catalog->icon_prefix defaults to catalog->name */
+ if (!catalog->icon_prefix)
+ catalog->icon_prefix = g_strdup (catalog->name);
+
+ if (catalog->init_function_name)
+ catalog_get_function (catalog, catalog->init_function_name,
+ (gpointer) & catalog->init_function);
+
+ return catalog;
}
static void
-catalog_load (GladeCatalog *catalog)
+catalog_load (GladeCatalog * catalog)
{
- GladeXmlDoc *doc;
- GladeXmlNode *root;
- GladeXmlNode *node;
-
- g_return_if_fail (catalog->context != NULL);
-
- doc = glade_xml_context_get_doc (catalog->context);
- root = glade_xml_doc_get_root (doc);
- node = glade_xml_node_get_children (root);
-
- for (; node; node = glade_xml_node_next (node))
- {
- const gchar *node_name;
-
- node_name = glade_xml_node_get_name (node);
- if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASSES) == 0)
- {
- catalog_load_classes (catalog, node);
- }
- else if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_GROUP) == 0)
- {
- catalog_load_group (catalog, node);
- }
- else
- continue;
- }
-
- catalog->widget_groups = g_list_reverse (catalog->widget_groups);
- catalog->context =
- (glade_xml_context_free (catalog->context), NULL);
-
- return;
+ GladeXmlDoc *doc;
+ GladeXmlNode *root;
+ GladeXmlNode *node;
+
+ g_return_if_fail (catalog->context != NULL);
+
+ doc = glade_xml_context_get_doc (catalog->context);
+ root = glade_xml_doc_get_root (doc);
+ node = glade_xml_node_get_children (root);
+
+ for (; node; node = glade_xml_node_next (node))
+ {
+ const gchar *node_name;
+
+ node_name = glade_xml_node_get_name (node);
+ if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASSES) == 0)
+ {
+ catalog_load_classes (catalog, node);
+ }
+ else if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_GROUP) == 0)
+ {
+ catalog_load_group (catalog, node);
+ }
+ else
+ continue;
+ }
+
+ catalog->widget_groups = g_list_reverse (catalog->widget_groups);
+ catalog->context = (glade_xml_context_free (catalog->context), NULL);
+
+ return;
}
static gint
-catalog_find_by_name (GladeCatalog *catalog, const gchar *name)
+catalog_find_by_name (GladeCatalog * catalog, const gchar * name)
{
- return strcmp (catalog->name, name);
+ return strcmp (catalog->name, name);
}
static GList *
-catalog_sort (GList *catalogs)
+catalog_sort (GList * catalogs)
{
- GList *l, *node, *sorted = NULL, *sort;
- GladeCatalog *catalog, *cat;
-
- /* Add all dependant catalogs to the sorted list first */
- for (l = catalogs; l; l = l->next)
- {
- catalog = l->data;
- sort = NULL;
-
- /* itterate ascending through dependancy hierarchy */
- while (catalog->dep_catalog) {
- node = g_list_find_custom
- (catalogs, catalog->dep_catalog,
- (GCompareFunc)catalog_find_by_name);
-
- if (!node || (cat = node->data) == NULL)
- {
- g_critical ("Catalog %s depends on catalog %s, not found",
- catalog->name, catalog->dep_catalog);
- break;
- }
-
- /* Prepend to sort list */
- if (g_list_find (sort, cat) == NULL &&
- g_list_find (sorted, cat) == NULL)
- sort = g_list_prepend (sort, cat);
-
- catalog = cat;
- }
- sorted = g_list_concat (sorted, sort);
- }
-
- /* Append all independant catalogs after */
- for (l = catalogs; l; l = l->next)
- if (g_list_find (sorted, l->data) == NULL)
- sorted = g_list_append (sorted, l->data);
-
- g_list_free (catalogs);
- return sorted;
+ GList *l, *node, *sorted = NULL, *sort;
+ GladeCatalog *catalog, *cat;
+
+ /* Add all dependant catalogs to the sorted list first */
+ for (l = catalogs; l; l = l->next)
+ {
+ catalog = l->data;
+ sort = NULL;
+
+ /* itterate ascending through dependancy hierarchy */
+ while (catalog->dep_catalog)
+ {
+ node = g_list_find_custom
+ (catalogs, catalog->dep_catalog,
+ (GCompareFunc) catalog_find_by_name);
+
+ if (!node || (cat = node->data) == NULL)
+ {
+ g_critical ("Catalog %s depends on catalog %s, not found",
+ catalog->name, catalog->dep_catalog);
+ break;
+ }
+
+ /* Prepend to sort list */
+ if (g_list_find (sort, cat) == NULL &&
+ g_list_find (sorted, cat) == NULL)
+ sort = g_list_prepend (sort, cat);
+
+ catalog = cat;
+ }
+ sorted = g_list_concat (sorted, sort);
+ }
+
+ /* Append all independant catalogs after */
+ for (l = catalogs; l; l = l->next)
+ if (g_list_find (sorted, l->data) == NULL)
+ sorted = g_list_append (sorted, l->data);
+
+ g_list_free (catalogs);
+ return sorted;
}
static GHashTable *modules = NULL;
static GModule *
-catalog_load_library (GladeCatalog *catalog)
+catalog_load_library (GladeCatalog * catalog)
{
- GModule *module;
-
- if (modules == NULL)
- modules = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) module_close);
-
- if (catalog->library == NULL)
- return NULL;
-
- if ((module = g_hash_table_lookup (modules, catalog->library)))
- return module;
-
- if ((module = glade_util_load_library (catalog->library)))
- g_hash_table_insert (modules, g_strdup (catalog->library), module);
- else
- g_warning ("Failed to load external library '%s'",
- catalog->library);
-
- return module;
+ GModule *module;
+
+ if (modules == NULL)
+ modules = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) module_close);
+
+ if (catalog->library == NULL)
+ return NULL;
+
+ if ((module = g_hash_table_lookup (modules, catalog->library)))
+ return module;
+
+ if ((module = glade_util_load_library (catalog->library)))
+ g_hash_table_insert (modules, g_strdup (catalog->library), module);
+ else
+ g_warning ("Failed to load external library '%s'", catalog->library);
+
+ return module;
}
static gboolean
-catalog_load_classes (GladeCatalog *catalog, GladeXmlNode *widgets_node)
+catalog_load_classes (GladeCatalog * catalog, GladeXmlNode * widgets_node)
{
- GladeXmlNode *node;
- GModule *module = catalog_load_library (catalog);
-
- node = glade_xml_node_get_children (widgets_node);
- for (; node; node = glade_xml_node_next (node))
- {
- const gchar *node_name, *domain;
- GladeWidgetAdaptor *adaptor;
-
- node_name = glade_xml_node_get_name (node);
- if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASS) != 0)
- continue;
-
- domain = catalog->domain ? catalog->domain : catalog->library;
-
- adaptor = glade_widget_adaptor_from_catalog (catalog, node, module);
-
- catalog->adaptors = g_list_prepend (catalog->adaptors, adaptor);
- }
-
- return TRUE;
+ GladeXmlNode *node;
+ GModule *module = catalog_load_library (catalog);
+
+ node = glade_xml_node_get_children (widgets_node);
+ for (; node; node = glade_xml_node_next (node))
+ {
+ const gchar *node_name, *domain;
+ GladeWidgetAdaptor *adaptor;
+
+ node_name = glade_xml_node_get_name (node);
+ if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASS) != 0)
+ continue;
+
+ domain = catalog->domain ? catalog->domain : catalog->library;
+
+ adaptor = glade_widget_adaptor_from_catalog (catalog, node, module);
+
+ catalog->adaptors = g_list_prepend (catalog->adaptors, adaptor);
+ }
+
+ return TRUE;
}
static gboolean
-catalog_load_group (GladeCatalog *catalog, GladeXmlNode *group_node)
+catalog_load_group (GladeCatalog * catalog, GladeXmlNode * group_node)
{
- GladeWidgetGroup *group;
- GladeXmlNode *node;
- char *title, *translated_title;
-
- group = g_slice_new0 (GladeWidgetGroup);
-
- group->name = glade_xml_get_property_string (group_node,
- GLADE_TAG_NAME);
-
- if (!group->name)
- {
- g_warning ("Required property 'name' not found in group node");
- widget_group_destroy (group);
- return FALSE;
- }
-
- title = glade_xml_get_property_string (group_node,
- GLADE_TAG_TITLE);
- if (!title)
- {
- g_warning ("Required property 'title' not found in group node");
- widget_group_destroy (group);
- return FALSE;
- }
-
- /* by default, group is expanded in palette */
- group->expanded = TRUE;
-
- /* Translate it */
- translated_title = dgettext (catalog->domain,
- title);
- if (translated_title != title)
+ GladeWidgetGroup *group;
+ GladeXmlNode *node;
+ char *title, *translated_title;
+
+ group = g_slice_new0 (GladeWidgetGroup);
+
+ group->name = glade_xml_get_property_string (group_node, GLADE_TAG_NAME);
+
+ if (!group->name)
+ {
+ g_warning ("Required property 'name' not found in group node");
+ widget_group_destroy (group);
+ return FALSE;
+ }
+
+ title = glade_xml_get_property_string (group_node, GLADE_TAG_TITLE);
+ if (!title)
+ {
+ g_warning ("Required property 'title' not found in group node");
+ widget_group_destroy (group);
+ return FALSE;
+ }
+
+ /* by default, group is expanded in palette */
+ group->expanded = TRUE;
+
+ /* Translate it */
+ translated_title = dgettext (catalog->domain, title);
+ if (translated_title != title)
+ {
+ group->title = g_strdup (translated_title);
+ g_free (title);
+ }
+ else
+ {
+ group->title = title;
+ }
+
+ group->adaptors = NULL;
+
+ node = glade_xml_node_get_children (group_node);
+ for (; node; node = glade_xml_node_next (node))
+ {
+ const gchar *node_name;
+ GladeWidgetAdaptor *adaptor;
+ gchar *name;
+
+ node_name = glade_xml_node_get_name (node);
+
+ if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASS_REF) == 0)
{
- group->title = g_strdup (translated_title);
- g_free (title);
+ if ((name =
+ glade_xml_get_property_string (node, GLADE_TAG_NAME)) == NULL)
+ {
+ g_warning ("Couldn't find required property on %s",
+ GLADE_TAG_GLADE_WIDGET_CLASS);
+ continue;
+ }
+
+ if ((adaptor = glade_widget_adaptor_get_by_name (name)) == NULL)
+ {
+ g_warning ("Tried to include undefined widget "
+ "class '%s' in a widget group", name);
+ g_free (name);
+ continue;
+ }
+ g_free (name);
+
+ group->adaptors = g_list_prepend (group->adaptors, adaptor);
+
}
- else
+ else if (strcmp (node_name, GLADE_TAG_DEFAULT_PALETTE_STATE) == 0)
{
- group->title = title;
+ group->expanded =
+ glade_xml_get_property_boolean
+ (node, GLADE_TAG_EXPANDED, group->expanded);
}
+ }
- group->adaptors = NULL;
-
- node = glade_xml_node_get_children (group_node);
- for (; node; node = glade_xml_node_next (node))
- {
- const gchar *node_name;
- GladeWidgetAdaptor *adaptor;
- gchar *name;
-
- node_name = glade_xml_node_get_name (node);
-
- if (strcmp (node_name, GLADE_TAG_GLADE_WIDGET_CLASS_REF) == 0)
- {
- if ((name =
- glade_xml_get_property_string (node, GLADE_TAG_NAME)) == NULL)
- {
- g_warning ("Couldn't find required property on %s",
- GLADE_TAG_GLADE_WIDGET_CLASS);
- continue;
- }
-
- if ((adaptor = glade_widget_adaptor_get_by_name (name)) == NULL)
- {
- g_warning ("Tried to include undefined widget "
- "class '%s' in a widget group", name);
- g_free (name);
- continue;
- }
- g_free (name);
-
- group->adaptors = g_list_prepend (group->adaptors, adaptor);
-
- }
- else if (strcmp (node_name, GLADE_TAG_DEFAULT_PALETTE_STATE) == 0)
- {
- group->expanded =
- glade_xml_get_property_boolean
- (node, GLADE_TAG_EXPANDED, group->expanded);
- }
- }
-
- group->adaptors = g_list_reverse (group->adaptors);
-
- catalog->widget_groups = g_list_prepend (catalog->widget_groups, group);
-
- return TRUE;
+ group->adaptors = g_list_reverse (group->adaptors);
+
+ catalog->widget_groups = g_list_prepend (catalog->widget_groups, group);
+
+ return TRUE;
}
static GList *
-catalogs_from_path (GList *catalogs, const gchar *path)
+catalogs_from_path (GList * catalogs, const gchar * path)
{
- GladeCatalog *catalog;
- GDir *dir;
- GError *error = NULL;
- const gchar *filename;
-
- if ((dir = g_dir_open (path, 0, &error)) != NULL)
- {
- while ((filename = g_dir_read_name (dir)))
- {
- gchar *catalog_filename;
-
- if (!g_str_has_suffix (filename, ".xml"))
- continue;
-
- catalog_filename = g_build_filename (path, filename, NULL);
- catalog = catalog_open (catalog_filename);
- g_free (catalog_filename);
-
- if (catalog)
- {
- /* Verify that we are not loading the same catalog twice !
- */
- if (!g_list_find_custom (catalogs, catalog->name,
- (GCompareFunc)catalog_find_by_name))
- catalogs = g_list_prepend (catalogs, catalog);
- else
- catalog_destroy (catalog);
- }
- else
- g_warning ("Unable to open the catalog file %s.\n", filename);
- }
- }
- else
- g_warning ("Failed to open catalog directory '%s': %s", path, error->message);
-
-
- return catalogs;
+ GladeCatalog *catalog;
+ GDir *dir;
+ GError *error = NULL;
+ const gchar *filename;
+
+ if ((dir = g_dir_open (path, 0, &error)) != NULL)
+ {
+ while ((filename = g_dir_read_name (dir)))
+ {
+ gchar *catalog_filename;
+
+ if (!g_str_has_suffix (filename, ".xml"))
+ continue;
+
+ catalog_filename = g_build_filename (path, filename, NULL);
+ catalog = catalog_open (catalog_filename);
+ g_free (catalog_filename);
+
+ if (catalog)
+ {
+ /* Verify that we are not loading the same catalog twice !
+ */
+ if (!g_list_find_custom (catalogs, catalog->name,
+ (GCompareFunc) catalog_find_by_name))
+ catalogs = g_list_prepend (catalogs, catalog);
+ else
+ catalog_destroy (catalog);
+ }
+ else
+ g_warning ("Unable to open the catalog file %s.\n", filename);
+ }
+ }
+ else
+ g_warning ("Failed to open catalog directory '%s': %s", path,
+ error->message);
+
+
+ return catalogs;
}
const GList *
glade_catalog_load_all (void)
{
- GList *catalogs = NULL, *l, *adaptors;
- GladeCatalog *catalog;
- const gchar *search_path;
- gchar **split;
- GString *icon_warning = NULL;
- gint i;
-
-
- /* Make sure we don't init the catalogs twice */
- if (loaded_catalogs)
- return loaded_catalogs;
-
- /* First load catalogs from user specified directories ... */
- if ((search_path = g_getenv (GLADE_ENV_CATALOG_PATH)) != NULL)
- {
- if ((split = g_strsplit (search_path, ":", 0)) != NULL)
- {
- for (i = 0; split[i] != NULL; i++)
- catalogs = catalogs_from_path (catalogs, split[i]);
-
- g_strfreev (split);
- }
- }
-
- /* ... Then load catalogs from standard install directory */
- catalogs = catalogs_from_path (catalogs, glade_app_get_catalogs_dir ());
-
- /* Catalogs need dependancies, most catalogs depend on
- * the gtk+ catalog, but some custom toolkits may depend
- * on the gnome catalog for instance.
- */
- catalogs = catalog_sort (catalogs);
-
- /* After sorting, execute init function and then load */
- for (l = catalogs; l; l = l->next)
- {
- catalog = l->data;
- if (catalog->init_function)
- catalog->init_function (catalog->name);
- }
-
- for (l = catalogs; l; l = l->next)
- {
- catalog = l->data;
- catalog_load (catalog);
- }
-
- /* Print a summery of widget adaptors missing icons.
- */
- adaptors = glade_widget_adaptor_list_adaptors ();
- for (l = adaptors; l; l = l->next)
- {
- GladeWidgetAdaptor *adaptor = l->data;
-
- if (adaptor->missing_icon)
- {
- if (!icon_warning)
- icon_warning = g_string_new ("Glade needs artwork; "
- "a default icon will be used for "
- "the following classes:");
-
- g_string_append_printf (icon_warning, "\n\t%s\tneeds an icon named '%s'",
- adaptor->name, adaptor->missing_icon);
- }
-
- }
- g_list_free (adaptors);
-
- if (icon_warning)
- {
- g_message ("%s", icon_warning->str);
- g_string_free (icon_warning, TRUE);
- }
-
- loaded_catalogs = catalogs;
-
- return loaded_catalogs;
+ GList *catalogs = NULL, *l, *adaptors;
+ GladeCatalog *catalog;
+ const gchar *search_path;
+ gchar **split;
+ GString *icon_warning = NULL;
+ gint i;
+
+
+ /* Make sure we don't init the catalogs twice */
+ if (loaded_catalogs)
+ return loaded_catalogs;
+
+ /* First load catalogs from user specified directories ... */
+ if ((search_path = g_getenv (GLADE_ENV_CATALOG_PATH)) != NULL)
+ {
+ if ((split = g_strsplit (search_path, ":", 0)) != NULL)
+ {
+ for (i = 0; split[i] != NULL; i++)
+ catalogs = catalogs_from_path (catalogs, split[i]);
+
+ g_strfreev (split);
+ }
+ }
+
+ /* ... Then load catalogs from standard install directory */
+ catalogs = catalogs_from_path (catalogs, glade_app_get_catalogs_dir ());
+
+ /* Catalogs need dependancies, most catalogs depend on
+ * the gtk+ catalog, but some custom toolkits may depend
+ * on the gnome catalog for instance.
+ */
+ catalogs = catalog_sort (catalogs);
+
+ /* After sorting, execute init function and then load */
+ for (l = catalogs; l; l = l->next)
+ {
+ catalog = l->data;
+ if (catalog->init_function)
+ catalog->init_function (catalog->name);
+ }
+
+ for (l = catalogs; l; l = l->next)
+ {
+ catalog = l->data;
+ catalog_load (catalog);
+ }
+
+ /* Print a summery of widget adaptors missing icons.
+ */
+ adaptors = glade_widget_adaptor_list_adaptors ();
+ for (l = adaptors; l; l = l->next)
+ {
+ GladeWidgetAdaptor *adaptor = l->data;
+
+ if (adaptor->missing_icon)
+ {
+ if (!icon_warning)
+ icon_warning = g_string_new ("Glade needs artwork; "
+ "a default icon will be used for "
+ "the following classes:");
+
+ g_string_append_printf (icon_warning,
+ "\n\t%s\tneeds an icon named '%s'",
+ adaptor->name, adaptor->missing_icon);
+ }
+
+ }
+ g_list_free (adaptors);
+
+ if (icon_warning)
+ {
+ g_message ("%s", icon_warning->str);
+ g_string_free (icon_warning, TRUE);
+ }
+
+ loaded_catalogs = catalogs;
+
+ return loaded_catalogs;
}
G_CONST_RETURN gchar *
-glade_catalog_get_name (GladeCatalog *catalog)
+glade_catalog_get_name (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->name;
+ return catalog->name;
}
G_CONST_RETURN gchar *
-glade_catalog_get_book (GladeCatalog *catalog)
+glade_catalog_get_book (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->book;
+ return catalog->book;
}
G_CONST_RETURN gchar *
-glade_catalog_get_domain (GladeCatalog *catalog)
+glade_catalog_get_domain (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->domain;
+ return catalog->domain;
}
G_CONST_RETURN gchar *
-glade_catalog_get_icon_prefix (GladeCatalog *catalog)
+glade_catalog_get_icon_prefix (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->icon_prefix;
+ return catalog->icon_prefix;
}
guint16
-glade_catalog_get_major_version (GladeCatalog *catalog)
+glade_catalog_get_major_version (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), 0);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), 0);
- return catalog->major_version;
+ return catalog->major_version;
}
guint16
-glade_catalog_get_minor_version (GladeCatalog *catalog)
+glade_catalog_get_minor_version (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), 0);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), 0);
- return catalog->minor_version;
+ return catalog->minor_version;
}
GList *
-glade_catalog_get_targets (GladeCatalog *catalog)
+glade_catalog_get_targets (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->targetable_versions;
+ return catalog->targetable_versions;
}
GList *
-glade_catalog_get_widget_groups (GladeCatalog *catalog)
+glade_catalog_get_widget_groups (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->widget_groups;
+ return catalog->widget_groups;
}
GList *
-glade_catalog_get_adaptors (GladeCatalog *catalog)
+glade_catalog_get_adaptors (GladeCatalog * catalog)
{
- g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
+ g_return_val_if_fail (GLADE_IS_CATALOG (catalog), NULL);
- return catalog->adaptors;
+ return catalog->adaptors;
}
gboolean
-glade_catalog_is_loaded (const gchar *name)
+glade_catalog_is_loaded (const gchar * name)
{
- GList *l;
-
- g_return_val_if_fail (name != NULL, FALSE);
- g_assert (loaded_catalogs != NULL);
-
- for (l = loaded_catalogs; l; l = l->next)
- {
- GladeCatalog *catalog = GLADE_CATALOG (l->data);
- if (strcmp (catalog->name, name) == 0)
- return TRUE;
- }
-
- return FALSE;
+ GList *l;
+
+ g_return_val_if_fail (name != NULL, FALSE);
+ g_assert (loaded_catalogs != NULL);
+
+ for (l = loaded_catalogs; l; l = l->next)
+ {
+ GladeCatalog *catalog = GLADE_CATALOG (l->data);
+ if (strcmp (catalog->name, name) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
-catalog_destroy (GladeCatalog *catalog)
+catalog_destroy (GladeCatalog * catalog)
{
- g_return_if_fail (GLADE_IS_CATALOG (catalog));
-
- g_free (catalog->name);
- g_free (catalog->library);
- g_free (catalog->dep_catalog);
- g_free (catalog->domain);
- g_free (catalog->book);
- g_free (catalog->icon_prefix);
- g_free (catalog->init_function_name);
-
- if (catalog->adaptors)
- {
- g_list_free (catalog->adaptors);
- }
-
- if (catalog->widget_groups)
- {
- g_list_foreach (catalog->widget_groups, (GFunc) widget_group_destroy, NULL);
- g_list_free (catalog->widget_groups);
- }
-
- if (catalog->context)
- glade_xml_context_free (catalog->context);
-
- g_slice_free (GladeCatalog, catalog);
+ g_return_if_fail (GLADE_IS_CATALOG (catalog));
+
+ g_free (catalog->name);
+ g_free (catalog->library);
+ g_free (catalog->dep_catalog);
+ g_free (catalog->domain);
+ g_free (catalog->book);
+ g_free (catalog->icon_prefix);
+ g_free (catalog->init_function_name);
+
+ if (catalog->adaptors)
+ {
+ g_list_free (catalog->adaptors);
+ }
+
+ if (catalog->widget_groups)
+ {
+ g_list_foreach (catalog->widget_groups, (GFunc) widget_group_destroy,
+ NULL);
+ g_list_free (catalog->widget_groups);
+ }
+
+ if (catalog->context)
+ glade_xml_context_free (catalog->context);
+
+ g_slice_free (GladeCatalog, catalog);
}
-static void
-module_close (GModule *module)
+static void
+module_close (GModule * module)
{
- g_module_close (module);
+ g_module_close (module);
}
void
glade_catalog_destroy_all (void)
-{
- /* close catalogs */
- if (loaded_catalogs)
- {
- GList *l;
- for (l = loaded_catalogs; l; l = l->next)
- catalog_destroy (GLADE_CATALOG (l->data));
- g_list_free (loaded_catalogs);
- loaded_catalogs = NULL;
- }
-
- /* close plugin modules */
- if (modules)
- {
- g_hash_table_destroy (modules);
- modules = NULL;
- }
+{
+ /* close catalogs */
+ if (loaded_catalogs)
+ {
+ GList *l;
+ for (l = loaded_catalogs; l; l = l->next)
+ catalog_destroy (GLADE_CATALOG (l->data));
+ g_list_free (loaded_catalogs);
+ loaded_catalogs = NULL;
+ }
+
+ /* close plugin modules */
+ if (modules)
+ {
+ g_hash_table_destroy (modules);
+ modules = NULL;
+ }
}
const gchar *
-glade_widget_group_get_name (GladeWidgetGroup *group)
+glade_widget_group_get_name (GladeWidgetGroup * group)
{
- g_return_val_if_fail (group != NULL, NULL);
+ g_return_val_if_fail (group != NULL, NULL);
- return group->name;
+ return group->name;
}
const gchar *
-glade_widget_group_get_title (GladeWidgetGroup *group)
+glade_widget_group_get_title (GladeWidgetGroup * group)
{
- g_return_val_if_fail (group != NULL, NULL);
+ g_return_val_if_fail (group != NULL, NULL);
- return group->title;
+ return group->title;
}
gboolean
-glade_widget_group_get_expanded (GladeWidgetGroup *group)
+glade_widget_group_get_expanded (GladeWidgetGroup * group)
{
- g_return_val_if_fail (group != NULL, FALSE);
+ g_return_val_if_fail (group != NULL, FALSE);
- return group->expanded;
+ return group->expanded;
}
const GList *
-glade_widget_group_get_adaptors (GladeWidgetGroup *group)
+glade_widget_group_get_adaptors (GladeWidgetGroup * group)
{
- g_return_val_if_fail (group != NULL, NULL);
+ g_return_val_if_fail (group != NULL, NULL);
- return group->adaptors;
+ return group->adaptors;
}
static void
-widget_group_destroy (GladeWidgetGroup *group)
+widget_group_destroy (GladeWidgetGroup * group)
{
- g_return_if_fail (GLADE_IS_WIDGET_GROUP (group));
-
- g_free (group->name);
- g_free (group->title);
- g_list_free (group->adaptors);
+ g_return_if_fail (GLADE_IS_WIDGET_GROUP (group));
+
+ g_free (group->name);
+ g_free (group->title);
+ g_list_free (group->adaptors);
- g_slice_free (GladeWidgetGroup, group);
+ g_slice_free (GladeWidgetGroup, group);
}
diff --git a/gladeui/glade-catalog.h b/gladeui/glade-catalog.h
index 6c812fc..4e15da6 100644
--- a/gladeui/glade-catalog.h
+++ b/gladeui/glade-catalog.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2004 Imendio AB
diff --git a/gladeui/glade-cell-renderer-icon.c b/gladeui/glade-cell-renderer-icon.c
index 5d1a60f..a4ea913 100644
--- a/gladeui/glade-cell-renderer-icon.c
+++ b/gladeui/glade-cell-renderer-icon.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -24,28 +23,32 @@
#include "glade-cell-renderer-icon.h"
#include "glade-marshallers.h"
-static void glade_cell_renderer_icon_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void glade_cell_renderer_icon_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static gboolean glade_cell_renderer_icon_activate (GtkCellRenderer *cell,
- GdkEvent *event,
- GtkWidget *widget,
- const gchar *path,
- const GdkRectangle *background_area,
- const GdkRectangle *cell_area,
- GtkCellRendererState flags);
-
-enum {
+static void glade_cell_renderer_icon_get_property (GObject * object,
+ guint param_id,
+ GValue * value,
+ GParamSpec * pspec);
+static void glade_cell_renderer_icon_set_property (GObject * object,
+ guint param_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static gboolean glade_cell_renderer_icon_activate (GtkCellRenderer * cell,
+ GdkEvent * event,
+ GtkWidget * widget,
+ const gchar * path,
+ const GdkRectangle *
+ background_area,
+ const GdkRectangle *
+ cell_area,
+ GtkCellRendererState flags);
+
+enum
+{
ACTIVATE,
LAST_SIGNAL
};
-enum {
+enum
+{
PROP_0,
PROP_ACTIVATABLE,
PROP_ACTIVE,
@@ -54,19 +57,20 @@ enum {
static guint icon_cell_signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (GladeCellRendererIcon, glade_cell_renderer_icon, GTK_TYPE_CELL_RENDERER_PIXBUF)
-
-static void
-glade_cell_renderer_icon_init (GladeCellRendererIcon *cellicon)
+G_DEFINE_TYPE (GladeCellRendererIcon, glade_cell_renderer_icon,
+ GTK_TYPE_CELL_RENDERER_PIXBUF)
+ static void glade_cell_renderer_icon_init (GladeCellRendererIcon *
+ cellicon)
{
cellicon->activatable = TRUE;
cellicon->active = FALSE;
- g_object_set (G_OBJECT (cellicon), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
+ g_object_set (G_OBJECT (cellicon), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
+ NULL);
}
static void
-glade_cell_renderer_icon_class_init (GladeCellRendererIconClass *class)
+glade_cell_renderer_icon_class_init (GladeCellRendererIconClass * class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
@@ -75,74 +79,73 @@ glade_cell_renderer_icon_class_init (GladeCellRendererIconClass *class)
object_class->set_property = glade_cell_renderer_icon_set_property;
cell_class->activate = glade_cell_renderer_icon_activate;
-
+
g_object_class_install_property (object_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active", "Icon state",
- "The icon state of the button",
- FALSE,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
-
+ PROP_ACTIVE,
+ g_param_spec_boolean ("active", "Icon state",
+ "The icon state of the button",
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
g_object_class_install_property (object_class,
- PROP_ACTIVATABLE,
- g_param_spec_boolean ("activatable", "Activatable",
- "The icon button can be activated",
- TRUE,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
-
+ PROP_ACTIVATABLE,
+ g_param_spec_boolean ("activatable",
+ "Activatable",
+ "The icon button can be activated",
+ TRUE,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
icon_cell_signals[ACTIVATE] =
- g_signal_new ("activate",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeCellRendererIconClass, activate),
- NULL, NULL,
- glade_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
+ g_signal_new ("activate",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeCellRendererIconClass, activate),
+ NULL, NULL,
+ glade_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
-glade_cell_renderer_icon_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
+glade_cell_renderer_icon_get_property (GObject * object,
+ guint param_id,
+ GValue * value, GParamSpec * pspec)
{
GladeCellRendererIcon *cellicon = GLADE_CELL_RENDERER_ICON (object);
-
+
switch (param_id)
{
- case PROP_ACTIVE:
- g_value_set_boolean (value, cellicon->active);
- break;
- case PROP_ACTIVATABLE:
- g_value_set_boolean (value, cellicon->activatable);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
+ case PROP_ACTIVE:
+ g_value_set_boolean (value, cellicon->active);
+ break;
+ case PROP_ACTIVATABLE:
+ g_value_set_boolean (value, cellicon->activatable);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
}
}
static void
-glade_cell_renderer_icon_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_cell_renderer_icon_set_property (GObject * object,
+ guint param_id,
+ const GValue * value, GParamSpec * pspec)
{
GladeCellRendererIcon *cellicon = GLADE_CELL_RENDERER_ICON (object);
switch (param_id)
{
- case PROP_ACTIVE:
- cellicon->active = g_value_get_boolean (value);
- break;
- case PROP_ACTIVATABLE:
- cellicon->activatable = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
+ case PROP_ACTIVE:
+ cellicon->active = g_value_get_boolean (value);
+ break;
+ case PROP_ACTIVATABLE:
+ cellicon->activatable = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
}
}
@@ -153,16 +156,16 @@ glade_cell_renderer_icon_new (void)
}
static gint
-glade_cell_renderer_icon_activate (GtkCellRenderer *cell,
- GdkEvent *event,
- GtkWidget *widget,
- const gchar *path,
- const GdkRectangle *background_area,
- const GdkRectangle *cell_area,
- GtkCellRendererState flags)
+glade_cell_renderer_icon_activate (GtkCellRenderer * cell,
+ GdkEvent * event,
+ GtkWidget * widget,
+ const gchar * path,
+ const GdkRectangle * background_area,
+ const GdkRectangle * cell_area,
+ GtkCellRendererState flags)
{
GladeCellRendererIcon *cellicon;
-
+
cellicon = GLADE_CELL_RENDERER_ICON (cell);
if (cellicon->activatable)
{
@@ -174,7 +177,7 @@ glade_cell_renderer_icon_activate (GtkCellRenderer *cell,
}
gboolean
-glade_cell_renderer_icon_get_active (GladeCellRendererIcon *icon)
+glade_cell_renderer_icon_get_active (GladeCellRendererIcon * icon)
{
g_return_val_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon), FALSE);
@@ -182,8 +185,8 @@ glade_cell_renderer_icon_get_active (GladeCellRendererIcon *icon)
}
void
-glade_cell_renderer_icon_set_active (GladeCellRendererIcon *icon,
- gboolean setting)
+glade_cell_renderer_icon_set_active (GladeCellRendererIcon * icon,
+ gboolean setting)
{
g_return_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon));
@@ -191,7 +194,7 @@ glade_cell_renderer_icon_set_active (GladeCellRendererIcon *icon,
}
gboolean
-glade_cell_renderer_icon_get_activatable (GladeCellRendererIcon *icon)
+glade_cell_renderer_icon_get_activatable (GladeCellRendererIcon * icon)
{
g_return_val_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon), FALSE);
@@ -199,8 +202,8 @@ glade_cell_renderer_icon_get_activatable (GladeCellRendererIcon *icon)
}
void
-glade_cell_renderer_icon_set_activatable (GladeCellRendererIcon *icon,
- gboolean setting)
+glade_cell_renderer_icon_set_activatable (GladeCellRendererIcon * icon,
+ gboolean setting)
{
g_return_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon));
diff --git a/gladeui/glade-cell-renderer-icon.h b/gladeui/glade-cell-renderer-icon.h
index 58aa31d..aad3069 100644
--- a/gladeui/glade-cell-renderer-icon.h
+++ b/gladeui/glade-cell-renderer-icon.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2010 Tristan Van Berkom.
*
diff --git a/gladeui/glade-clipboard.c b/gladeui/glade-clipboard.c
index e847312..4df38fc 100644
--- a/gladeui/glade-clipboard.c
+++ b/gladeui/glade-clipboard.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-clipboard.c - An object for handling Cut/Copy/Paste.
*
@@ -43,90 +42,89 @@
enum
{
- PROP_0,
- PROP_HAS_SELECTION
+ PROP_0,
+ PROP_HAS_SELECTION
};
static void
-glade_project_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_project_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GladeClipboard *clipboard = GLADE_CLIPBOARD (object);
-
- switch (prop_id)
- {
- case PROP_HAS_SELECTION:
- g_value_set_boolean (value, clipboard->has_selection);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeClipboard *clipboard = GLADE_CLIPBOARD (object);
+
+ switch (prop_id)
+ {
+ case PROP_HAS_SELECTION:
+ g_value_set_boolean (value, clipboard->has_selection);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_clipboard_class_init (GladeClipboardClass *klass)
+glade_clipboard_class_init (GladeClipboardClass * klass)
{
- GObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = glade_project_get_property;
+ object_class->get_property = glade_project_get_property;
- g_object_class_install_property (object_class,
- PROP_HAS_SELECTION,
- g_param_spec_boolean ("has-selection",
- "Has Selection",
- "Whether clipboard has a selection of items to paste",
- FALSE,
- G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_HAS_SELECTION,
+ g_param_spec_boolean ("has-selection",
+ "Has Selection",
+ "Whether clipboard has a selection of items to paste",
+ FALSE,
+ G_PARAM_READABLE));
}
static void
-glade_clipboard_init (GladeClipboard *clipboard)
+glade_clipboard_init (GladeClipboard * clipboard)
{
- clipboard->widgets = NULL;
- clipboard->selection = NULL;
- clipboard->has_selection = FALSE;
+ clipboard->widgets = NULL;
+ clipboard->selection = NULL;
+ clipboard->has_selection = FALSE;
}
GType
glade_clipboard_get_type (void)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (GladeClipboardClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) glade_clipboard_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (GladeClipboard),
- 0,
- (GInstanceInitFunc) glade_clipboard_init
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "GladeClipboard", &info, 0);
- }
-
- return type;
+ static GType type = 0;
+
+ if (!type)
+ {
+ static const GTypeInfo info = {
+ sizeof (GladeClipboardClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) glade_clipboard_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GladeClipboard),
+ 0,
+ (GInstanceInitFunc) glade_clipboard_init
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT, "GladeClipboard", &info, 0);
+ }
+
+ return type;
}
static void
-glade_clipboard_set_has_selection (GladeClipboard *clipboard, gboolean has_selection)
+glade_clipboard_set_has_selection (GladeClipboard * clipboard,
+ gboolean has_selection)
{
- g_assert (GLADE_IS_CLIPBOARD (clipboard));
+ g_assert (GLADE_IS_CLIPBOARD (clipboard));
- if (clipboard->has_selection != has_selection)
- {
- clipboard->has_selection = has_selection;
- g_object_notify (G_OBJECT (clipboard), "has-selection");
- }
+ if (clipboard->has_selection != has_selection)
+ {
+ clipboard->has_selection = has_selection;
+ g_object_notify (G_OBJECT (clipboard), "has-selection");
+ }
}
@@ -137,11 +135,11 @@ glade_clipboard_set_has_selection (GladeClipboard *clipboard, gboolean has_sele
* Returns: TRUE if this clipboard has selected items to paste.
*/
gboolean
-glade_clipboard_get_has_selection (GladeClipboard *clipboard)
+glade_clipboard_get_has_selection (GladeClipboard * clipboard)
{
- g_assert (GLADE_IS_CLIPBOARD (clipboard));
+ g_assert (GLADE_IS_CLIPBOARD (clipboard));
- return clipboard->has_selection;
+ return clipboard->has_selection;
}
@@ -153,7 +151,7 @@ glade_clipboard_get_has_selection (GladeClipboard *clipboard)
GladeClipboard *
glade_clipboard_new (void)
{
- return GLADE_CLIPBOARD (g_object_new (GLADE_TYPE_CLIPBOARD, NULL));
+ return GLADE_CLIPBOARD (g_object_new (GLADE_TYPE_CLIPBOARD, NULL));
}
/**
@@ -165,28 +163,27 @@ glade_clipboard_new (void)
* This increases the reference count of each #GladeWidget in @widgets.
*/
void
-glade_clipboard_add (GladeClipboard *clipboard, GList *widgets)
+glade_clipboard_add (GladeClipboard * clipboard, GList * widgets)
{
- GladeWidget *widget;
- GList *list;
-
- /*
- * Clear selection for the new widgets.
- */
- glade_clipboard_selection_clear (clipboard);
-
- /*
- * Add the widgets to the list of children.
- */
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = list->data;
- clipboard->widgets =
- g_list_prepend (clipboard->widgets,
- g_object_ref (G_OBJECT (widget)));
-
- glade_clipboard_selection_add (clipboard, widget);
- }
+ GladeWidget *widget;
+ GList *list;
+
+ /*
+ * Clear selection for the new widgets.
+ */
+ glade_clipboard_selection_clear (clipboard);
+
+ /*
+ * Add the widgets to the list of children.
+ */
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = list->data;
+ clipboard->widgets =
+ g_list_prepend (clipboard->widgets, g_object_ref (G_OBJECT (widget)));
+
+ glade_clipboard_selection_add (clipboard, widget);
+ }
}
@@ -198,64 +195,58 @@ glade_clipboard_add (GladeClipboard *clipboard, GList *widgets)
* Removes @widgets from @clipboard.
*/
void
-glade_clipboard_remove (GladeClipboard *clipboard, GList *widgets)
+glade_clipboard_remove (GladeClipboard * clipboard, GList * widgets)
{
- GladeWidget *widget;
- GList *list;
-
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = list->data;
-
- clipboard->widgets =
- g_list_remove (clipboard->widgets, widget);
- glade_clipboard_selection_remove (clipboard, widget);
-
- g_object_unref (G_OBJECT (widget));
- }
-
- /*
- * Only default selection if nescisary
- */
- if ((g_list_length (clipboard->selection) < 1) &&
- (list = g_list_first (clipboard->widgets)) != NULL)
- {
- glade_clipboard_selection_add
- (clipboard, GLADE_WIDGET (list->data));
- }
+ GladeWidget *widget;
+ GList *list;
+
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = list->data;
+
+ clipboard->widgets = g_list_remove (clipboard->widgets, widget);
+ glade_clipboard_selection_remove (clipboard, widget);
+
+ g_object_unref (G_OBJECT (widget));
+ }
+
+ /*
+ * Only default selection if nescisary
+ */
+ if ((g_list_length (clipboard->selection) < 1) &&
+ (list = g_list_first (clipboard->widgets)) != NULL)
+ {
+ glade_clipboard_selection_add (clipboard, GLADE_WIDGET (list->data));
+ }
}
void
-glade_clipboard_selection_add (GladeClipboard *clipboard,
- GladeWidget *widget)
+glade_clipboard_selection_add (GladeClipboard * clipboard, GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- clipboard->selection =
- g_list_prepend (clipboard->selection, widget);
+ g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ clipboard->selection = g_list_prepend (clipboard->selection, widget);
- glade_clipboard_set_has_selection (clipboard, TRUE);
+ glade_clipboard_set_has_selection (clipboard, TRUE);
}
void
-glade_clipboard_selection_remove (GladeClipboard *clipboard,
- GladeWidget *widget)
+glade_clipboard_selection_remove (GladeClipboard * clipboard,
+ GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- clipboard->selection =
- g_list_remove (clipboard->selection, widget);
+ g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ clipboard->selection = g_list_remove (clipboard->selection, widget);
- if (g_list_length (clipboard->selection) == 0)
- glade_clipboard_set_has_selection (clipboard, FALSE);
+ if (g_list_length (clipboard->selection) == 0)
+ glade_clipboard_set_has_selection (clipboard, FALSE);
}
void
-glade_clipboard_selection_clear (GladeClipboard *clipboard)
+glade_clipboard_selection_clear (GladeClipboard * clipboard)
{
- g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
- clipboard->selection =
- (g_list_free (clipboard->selection), NULL);
+ g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
+ clipboard->selection = (g_list_free (clipboard->selection), NULL);
- glade_clipboard_set_has_selection (clipboard, FALSE);
+ glade_clipboard_set_has_selection (clipboard, FALSE);
}
diff --git a/gladeui/glade-clipboard.h b/gladeui/glade-clipboard.h
index f6ae5cc..21371d4 100644
--- a/gladeui/glade-clipboard.h
+++ b/gladeui/glade-clipboard.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_CLIPBOARD_H__
#define __GLADE_CLIPBOARD_H__
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index ab0636c..4ef6e20 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2002 JoaquÃn Cuenca Abela
*
@@ -57,31 +56,32 @@
* untill they are added to a container; in which case it belongs to GTK+
* and the backend (but I prefer to think of it as the backend).
*/
-typedef struct {
- GladeWidget *widget;
- GladeWidget *parent;
- GladeProject *project;
- GList *reffed;
- GladePlaceholder *placeholder;
- gboolean props_recorded;
- GList *pack_props;
- gchar *special_type;
- gulong handler_id;
+typedef struct
+{
+ GladeWidget *widget;
+ GladeWidget *parent;
+ GladeProject *project;
+ GList *reffed;
+ GladePlaceholder *placeholder;
+ gboolean props_recorded;
+ GList *pack_props;
+ gchar *special_type;
+ gulong handler_id;
} CommandData;
static GObjectClass *parent_class = NULL;
/* Group description used for the current group
*/
-static gchar *gc_group_description = NULL;
+static gchar *gc_group_description = NULL;
/* Use an id to avoid grouping together consecutive groups
*/
-static gint gc_group_id = 1;
+static gint gc_group_id = 1;
/* Groups can be grouped together, push/pop must balance (duh!)
*/
-static gint gc_group_depth = 0;
+static gint gc_group_depth = 0;
#define MAKE_TYPE(func, type, parent) \
@@ -112,50 +112,48 @@ func ## _get_type (void) \
} \
static void
-glade_command_finalize (GObject *obj)
+glade_command_finalize (GObject * obj)
{
- GladeCommand *cmd = (GladeCommand *) obj;
- g_return_if_fail (cmd != NULL);
+ GladeCommand *cmd = (GladeCommand *) obj;
+ g_return_if_fail (cmd != NULL);
- if (cmd->description)
- g_free (cmd->description);
+ if (cmd->description)
+ g_free (cmd->description);
- /* Call the base class dtor */
- (* G_OBJECT_CLASS (parent_class)->finalize) (obj);
+ /* Call the base class dtor */
+ (*G_OBJECT_CLASS (parent_class)->finalize) (obj);
}
static gboolean
-glade_command_unifies_impl (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_unifies_impl (GladeCommand * this_cmd, GladeCommand * other_cmd)
{
- return FALSE;
+ return FALSE;
}
static void
-glade_command_collapse_impl (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_collapse_impl (GladeCommand * this_cmd, GladeCommand * other_cmd)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
static void
-glade_command_class_init (GladeCommandClass *klass)
+glade_command_class_init (GladeCommandClass * klass)
{
- GObjectClass* object_class;
+ GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ object_class = G_OBJECT_CLASS (klass);
+ parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = glade_command_finalize;
+ object_class->finalize = glade_command_finalize;
- klass->undo = NULL;
- klass->execute = NULL;
- klass->unifies = glade_command_unifies_impl;
- klass->collapse = glade_command_collapse_impl;
+ klass->undo = NULL;
+ klass->execute = NULL;
+ klass->unifies = glade_command_unifies_impl;
+ klass->collapse = glade_command_collapse_impl;
}
/* compose the _get_type function for GladeCommand */
MAKE_TYPE (glade_command, GladeCommand, G_TYPE_OBJECT)
-
-
#define GLADE_MAKE_COMMAND(type, func) \
static gboolean \
func ## _undo (GladeCommand *me); \
@@ -183,8 +181,6 @@ typedef struct { \
GladeCommandClass cmd; \
} type ## Class; \
static MAKE_TYPE(func, type, GLADE_TYPE_COMMAND)
-
-
/**
* glade_command_execute:
* @command: A #GladeCommand
@@ -193,11 +189,11 @@ static MAKE_TYPE(func, type, GLADE_TYPE_COMMAND)
*
* Returns: whether the command was successfully executed
*/
-gboolean
-glade_command_execute (GladeCommand *command)
+ gboolean
+glade_command_execute (GladeCommand * command)
{
- g_return_val_if_fail (GLADE_IS_COMMAND (command), FALSE);
- return GLADE_COMMAND_GET_CLASS (command)->execute (command);
+ g_return_val_if_fail (GLADE_IS_COMMAND (command), FALSE);
+ return GLADE_COMMAND_GET_CLASS (command)->execute (command);
}
@@ -210,10 +206,10 @@ glade_command_execute (GladeCommand *command)
* Returns: whether the command was successfully reversed
*/
gboolean
-glade_command_undo (GladeCommand *command)
+glade_command_undo (GladeCommand * command)
{
- g_return_val_if_fail (GLADE_IS_COMMAND (command), FALSE);
- return GLADE_COMMAND_GET_CLASS (command)->undo (command);
+ g_return_val_if_fail (GLADE_IS_COMMAND (command), FALSE);
+ return GLADE_COMMAND_GET_CLASS (command)->undo (command);
}
/**
@@ -227,18 +223,17 @@ glade_command_undo (GladeCommand *command)
* Returns: whether they can be unified.
*/
gboolean
-glade_command_unifies (GladeCommand *command,
- GladeCommand *other)
+glade_command_unifies (GladeCommand * command, GladeCommand * other)
{
- g_return_val_if_fail (command, FALSE);
+ g_return_val_if_fail (command, FALSE);
- /* Cannot unify with a part of a command group.
- * Unify atomic commands only
- */
- if (command->group_id != 0 || (other && other->group_id != 0))
- return FALSE;
+ /* Cannot unify with a part of a command group.
+ * Unify atomic commands only
+ */
+ if (command->group_id != 0 || (other && other->group_id != 0))
+ return FALSE;
- return GLADE_COMMAND_GET_CLASS (command)->unifies (command, other);
+ return GLADE_COMMAND_GET_CLASS (command)->unifies (command, other);
}
/**
@@ -250,11 +245,10 @@ glade_command_unifies (GladeCommand *command,
* covers both commands and @other can be dispensed with.
*/
void
-glade_command_collapse (GladeCommand *command,
- GladeCommand *other)
+glade_command_collapse (GladeCommand * command, GladeCommand * other)
{
- g_return_if_fail (command);
- GLADE_COMMAND_GET_CLASS (command)->collapse (command, other);
+ g_return_if_fail (command);
+ GLADE_COMMAND_GET_CLASS (command)->collapse (command, other);
}
/**
@@ -267,20 +261,20 @@ glade_command_collapse (GladeCommand *command,
* Marks the begining of a group.
*/
void
-glade_command_push_group (const gchar *fmt, ...)
+glade_command_push_group (const gchar * fmt, ...)
{
- va_list args;
+ va_list args;
- g_return_if_fail (fmt);
+ g_return_if_fail (fmt);
- /* Only use the description for the first group.
- */
- if (gc_group_depth++ == 0)
- {
- va_start (args, fmt);
- gc_group_description = g_strdup_vprintf (fmt, args);
- va_end (args);
- }
+ /* Only use the description for the first group.
+ */
+ if (gc_group_depth++ == 0)
+ {
+ va_start (args, fmt);
+ gc_group_description = g_strdup_vprintf (fmt, args);
+ va_end (args);
+ }
}
/**
@@ -291,33 +285,32 @@ glade_command_push_group (const gchar *fmt, ...)
void
glade_command_pop_group (void)
{
- if (gc_group_depth-- == 1)
- {
- gc_group_description = (g_free (gc_group_description), NULL);
- gc_group_id++;
- }
+ if (gc_group_depth-- == 1)
+ {
+ gc_group_description = (g_free (gc_group_description), NULL);
+ gc_group_id++;
+ }
- if (gc_group_depth < 0)
- g_critical ("Unbalanced group stack detected in %s\n",
- G_STRFUNC);
+ if (gc_group_depth < 0)
+ g_critical ("Unbalanced group stack detected in %s\n", G_STRFUNC);
}
gint
glade_command_get_group_depth (void)
{
- return gc_group_depth;
+ return gc_group_depth;
}
static void
-glade_command_check_group (GladeCommand *cmd)
+glade_command_check_group (GladeCommand * cmd)
{
- g_return_if_fail (GLADE_IS_COMMAND (cmd));
- if (gc_group_description)
- {
- cmd->description =
- (g_free (cmd->description), g_strdup (gc_group_description));
- cmd->group_id = gc_group_id;
- }
+ g_return_if_fail (GLADE_IS_COMMAND (cmd));
+ if (gc_group_description)
+ {
+ cmd->description =
+ (g_free (cmd->description), g_strdup (gc_group_description));
+ cmd->group_id = gc_group_id;
+ }
}
/**************************************************/
@@ -327,11 +320,12 @@ glade_command_check_group (GladeCommand *cmd)
/* create a new GladeCommandSetProperty class. Objects of this class will
* encapsulate a "set property" operation */
-typedef struct {
- GladeCommand parent;
- gboolean set_once;
- gboolean undo;
- GList *sdata;
+typedef struct
+{
+ GladeCommand parent;
+ gboolean set_once;
+ gboolean undo;
+ GList *sdata;
} GladeCommandSetProperty;
/* standard macros */
@@ -344,9 +338,9 @@ GLADE_MAKE_COMMAND (GladeCommandSetProperty, glade_command_set_property);
/* Undo the last "set property command" */
static gboolean
-glade_command_set_property_undo (GladeCommand *cmd)
+glade_command_set_property_undo (GladeCommand * cmd)
{
- return glade_command_set_property_execute (cmd);
+ return glade_command_set_property_execute (cmd);
}
/*
@@ -354,389 +348,394 @@ glade_command_set_property_undo (GladeCommand *cmd)
* this function cmd will point to the undo action
*/
static gboolean
-glade_command_set_property_execute (GladeCommand *cmd)
+glade_command_set_property_execute (GladeCommand * cmd)
{
- GladeCommandSetProperty* me = (GladeCommandSetProperty*) cmd;
- GList *l;
- gboolean success;
- gboolean retval = FALSE;
+ GladeCommandSetProperty *me = (GladeCommandSetProperty *) cmd;
+ GList *l;
+ gboolean success;
+ gboolean retval = FALSE;
+
+ g_return_val_if_fail (me != NULL, FALSE);
- g_return_val_if_fail (me != NULL, FALSE);
+ if (me->set_once != FALSE)
+ glade_property_push_superuser ();
- if (me->set_once != FALSE)
- glade_property_push_superuser ();
+ for (l = me->sdata; l; l = l->next)
+ {
+ GValue new_value = { 0, };
+ GCSetPropData *sdata = l->data;
- for (l = me->sdata; l; l = l->next)
- {
- GValue new_value = { 0, };
- GCSetPropData *sdata = l->data;
+ g_value_init (&new_value, G_VALUE_TYPE (sdata->new_value));
- g_value_init (&new_value, G_VALUE_TYPE (sdata->new_value));
-
- if (me->undo)
- g_value_copy (sdata->old_value, &new_value);
- else
- g_value_copy (sdata->new_value, &new_value);
+ if (me->undo)
+ g_value_copy (sdata->old_value, &new_value);
+ else
+ g_value_copy (sdata->new_value, &new_value);
#if 0
- {
- gchar *str =
- glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (sdata->property->klass->handle),
- sdata->property->klass, &new_value);
-
- g_print ("Setting %s property of %s to %s (sumode: %d)\n",
- sdata->property->klass->id,
- sdata->property->widget->name,
- str, glade_property_superuser ());
-
- g_free (str);
- }
+ {
+ gchar *str =
+ glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (sdata->property->klass->handle),
+ sdata->property->klass, &new_value);
+
+ g_print ("Setting %s property of %s to %s (sumode: %d)\n",
+ sdata->property->klass->id,
+ sdata->property->widget->name,
+ str, glade_property_superuser ());
+
+ g_free (str);
+ }
#endif
- /* Packing properties need to be refreshed here since
- * they are reset when they get added to containers.
- */
- if (sdata->property->klass->packing)
- {
- GladeProperty *tmp_prop;
+ /* Packing properties need to be refreshed here since
+ * they are reset when they get added to containers.
+ */
+ if (sdata->property->klass->packing)
+ {
+ GladeProperty *tmp_prop;
- tmp_prop = glade_widget_get_pack_property
- (sdata->property->widget, sdata->property->klass->id);
+ tmp_prop = glade_widget_get_pack_property
+ (sdata->property->widget, sdata->property->klass->id);
- if (sdata->property != tmp_prop)
- {
- g_object_unref (sdata->property);
- sdata->property = g_object_ref (tmp_prop);
-
- }
- }
+ if (sdata->property != tmp_prop)
+ {
+ g_object_unref (sdata->property);
+ sdata->property = g_object_ref (tmp_prop);
- success = glade_property_set_value (sdata->property, &new_value);
- retval = retval || success;
+ }
+ }
- if (!me->set_once && success)
- {
- /* If some verify functions didnt pass on
- * the first go.. we need to record the actual
- * properties here.
- */
- g_value_copy (sdata->property->value,
- sdata->new_value);
- }
+ success = glade_property_set_value (sdata->property, &new_value);
+ retval = retval || success;
+ if (!me->set_once && success)
+ {
+ /* If some verify functions didnt pass on
+ * the first go.. we need to record the actual
+ * properties here.
+ */
+ g_value_copy (sdata->property->value, sdata->new_value);
+ }
- g_value_unset (&new_value);
+ g_value_unset (&new_value);
- }
- if (me->set_once != FALSE)
- glade_property_pop_superuser ();
+ }
- me->set_once = TRUE;
- me->undo = !me->undo;
+ if (me->set_once != FALSE)
+ glade_property_pop_superuser ();
- return retval;
+ me->set_once = TRUE;
+ me->undo = !me->undo;
+
+ return retval;
}
static void
-glade_command_set_property_finalize (GObject *obj)
+glade_command_set_property_finalize (GObject * obj)
{
- GladeCommandSetProperty *me;
- GList *l;
+ GladeCommandSetProperty *me;
+ GList *l;
+
+ me = GLADE_COMMAND_SET_PROPERTY (obj);
- me = GLADE_COMMAND_SET_PROPERTY (obj);
+ for (l = me->sdata; l; l = l->next)
+ {
+ GCSetPropData *sdata = l->data;
- for (l = me->sdata; l; l = l->next)
- {
- GCSetPropData *sdata = l->data;
-
- if (sdata->property)
- g_object_unref (G_OBJECT (sdata->property));
+ if (sdata->property)
+ g_object_unref (G_OBJECT (sdata->property));
- if (sdata->old_value)
- {
- if (G_VALUE_TYPE (sdata->old_value) != 0)
- g_value_unset (sdata->old_value);
- g_free (sdata->old_value);
- }
- if (G_VALUE_TYPE (sdata->new_value) != 0)
- g_value_unset (sdata->new_value);
- g_free (sdata->new_value);
+ if (sdata->old_value)
+ {
+ if (G_VALUE_TYPE (sdata->old_value) != 0)
+ g_value_unset (sdata->old_value);
+ g_free (sdata->old_value);
+ }
+ if (G_VALUE_TYPE (sdata->new_value) != 0)
+ g_value_unset (sdata->new_value);
+ g_free (sdata->new_value);
- }
- glade_command_finalize (obj);
+ }
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_set_property_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
-{
- GladeCommandSetProperty *cmd1, *cmd2;
- GCSetPropData *pdata1, *pdata2;
- GList *list, *l;
-
- if (!other_cmd)
- {
- if (GLADE_IS_COMMAND_SET_PROPERTY (this_cmd))
- {
- cmd1 = (GladeCommandSetProperty*) this_cmd;
-
- for (list = cmd1->sdata; list; list = list->next)
- {
- pdata1 = list->data;
-
- if (glade_property_class_compare (pdata1->property->klass,
- pdata1->old_value,
- pdata1->new_value))
- return FALSE;
- }
- return TRUE;
-
- }
- return FALSE;
- }
-
- if (GLADE_IS_COMMAND_SET_PROPERTY (this_cmd) &&
- GLADE_IS_COMMAND_SET_PROPERTY (other_cmd))
- {
- cmd1 = (GladeCommandSetProperty*) this_cmd;
- cmd2 = (GladeCommandSetProperty*) other_cmd;
-
- if (g_list_length (cmd1->sdata) !=
- g_list_length (cmd2->sdata))
- return FALSE;
-
- for (list = cmd1->sdata; list; list = list->next)
- {
- pdata1 = list->data;
- for (l = cmd2->sdata; l; l = l->next)
- {
- pdata2 = l->data;
-
- if (pdata1->property->widget == pdata2->property->widget &&
- glade_property_class_match (pdata1->property->klass,
- pdata2->property->klass))
- break;
- }
-
- /* If both lists are the same length, and one class type
- * is not found in the other list, then we cant unify.
- */
- if (l == NULL)
- return FALSE;
-
- }
-
- return TRUE;
- }
- return FALSE;
+glade_command_set_property_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
+{
+ GladeCommandSetProperty *cmd1, *cmd2;
+ GCSetPropData *pdata1, *pdata2;
+ GList *list, *l;
+
+ if (!other_cmd)
+ {
+ if (GLADE_IS_COMMAND_SET_PROPERTY (this_cmd))
+ {
+ cmd1 = (GladeCommandSetProperty *) this_cmd;
+
+ for (list = cmd1->sdata; list; list = list->next)
+ {
+ pdata1 = list->data;
+
+ if (glade_property_class_compare (pdata1->property->klass,
+ pdata1->old_value,
+ pdata1->new_value))
+ return FALSE;
+ }
+ return TRUE;
+
+ }
+ return FALSE;
+ }
+
+ if (GLADE_IS_COMMAND_SET_PROPERTY (this_cmd) &&
+ GLADE_IS_COMMAND_SET_PROPERTY (other_cmd))
+ {
+ cmd1 = (GladeCommandSetProperty *) this_cmd;
+ cmd2 = (GladeCommandSetProperty *) other_cmd;
+
+ if (g_list_length (cmd1->sdata) != g_list_length (cmd2->sdata))
+ return FALSE;
+
+ for (list = cmd1->sdata; list; list = list->next)
+ {
+ pdata1 = list->data;
+ for (l = cmd2->sdata; l; l = l->next)
+ {
+ pdata2 = l->data;
+
+ if (pdata1->property->widget == pdata2->property->widget &&
+ glade_property_class_match (pdata1->property->klass,
+ pdata2->property->klass))
+ break;
+ }
+
+ /* If both lists are the same length, and one class type
+ * is not found in the other list, then we cant unify.
+ */
+ if (l == NULL)
+ return FALSE;
+
+ }
+
+ return TRUE;
+ }
+ return FALSE;
}
static void
-glade_command_set_property_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
-{
- GladeCommandSetProperty *cmd1, *cmd2;
- GCSetPropData *pdata1, *pdata2;
- GList *list, *l;
-
- g_return_if_fail (GLADE_IS_COMMAND_SET_PROPERTY (this_cmd) &&
- GLADE_IS_COMMAND_SET_PROPERTY (other_cmd));
-
- cmd1 = (GladeCommandSetProperty*) this_cmd;
- cmd2 = (GladeCommandSetProperty*) other_cmd;
-
-
- for (list = cmd1->sdata; list; list = list->next)
- {
- pdata1 = list->data;
- for (l = cmd2->sdata; l; l = l->next)
- {
- pdata2 = l->data;
-
- if (glade_property_class_match (pdata1->property->klass,
- pdata2->property->klass))
- {
- /* Merge the GCSetPropData structs manually here
- */
- g_value_copy (pdata2->new_value, pdata1->new_value);
- break;
- }
- }
- }
-
- /* Set the description
- */
- g_free (this_cmd->description);
- this_cmd->description = other_cmd->description;
- other_cmd->description = NULL;
-
- glade_app_update_ui ();
-}
+glade_command_set_property_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
+{
+ GladeCommandSetProperty *cmd1, *cmd2;
+ GCSetPropData *pdata1, *pdata2;
+ GList *list, *l;
+ g_return_if_fail (GLADE_IS_COMMAND_SET_PROPERTY (this_cmd) &&
+ GLADE_IS_COMMAND_SET_PROPERTY (other_cmd));
-#define MAX_UNDO_MENU_ITEM_VALUE_LEN 10
-static gchar *
-glade_command_set_property_description (GladeCommandSetProperty *me)
-{
- GCSetPropData *sdata;
- gchar *description = NULL;
- gchar *value_name;
+ cmd1 = (GladeCommandSetProperty *) this_cmd;
+ cmd2 = (GladeCommandSetProperty *) other_cmd;
+
+
+ for (list = cmd1->sdata; list; list = list->next)
+ {
+ pdata1 = list->data;
+ for (l = cmd2->sdata; l; l = l->next)
+ {
+ pdata2 = l->data;
- g_assert (me->sdata);
+ if (glade_property_class_match (pdata1->property->klass,
+ pdata2->property->klass))
+ {
+ /* Merge the GCSetPropData structs manually here
+ */
+ g_value_copy (pdata2->new_value, pdata1->new_value);
+ break;
+ }
+ }
+ }
- if (g_list_length (me->sdata) > 1)
- description = g_strdup_printf (_("Setting multiple properties"));
- else
- {
- sdata = me->sdata->data;
- value_name = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (sdata->property->klass->handle),
- sdata->property->klass, sdata->new_value);
+ /* Set the description
+ */
+ g_free (this_cmd->description);
+ this_cmd->description = other_cmd->description;
+ other_cmd->description = NULL;
- g_assert (sdata->property->klass->name);
- g_assert (sdata->property->widget->name);
+ glade_app_update_ui ();
+}
- if (!value_name || strlen (value_name) > MAX_UNDO_MENU_ITEM_VALUE_LEN
- || strchr (value_name, '_')) {
- description = g_strdup_printf (_("Setting %s of %s"),
- sdata->property->klass->name,
- sdata->property->widget->name);
- } else {
- description = g_strdup_printf (_("Setting %s of %s to %s"),
- sdata->property->klass->name,
- sdata->property->widget->name,
- value_name);
- }
- g_free (value_name);
- }
- return description;
+#define MAX_UNDO_MENU_ITEM_VALUE_LEN 10
+static gchar *
+glade_command_set_property_description (GladeCommandSetProperty * me)
+{
+ GCSetPropData *sdata;
+ gchar *description = NULL;
+ gchar *value_name;
+
+ g_assert (me->sdata);
+
+ if (g_list_length (me->sdata) > 1)
+ description = g_strdup_printf (_("Setting multiple properties"));
+ else
+ {
+ sdata = me->sdata->data;
+ value_name = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (sdata->property->klass->handle),
+ sdata->property->klass, sdata->new_value);
+
+ g_assert (sdata->property->klass->name);
+ g_assert (sdata->property->widget->name);
+
+ if (!value_name || strlen (value_name) > MAX_UNDO_MENU_ITEM_VALUE_LEN
+ || strchr (value_name, '_'))
+ {
+ description = g_strdup_printf (_("Setting %s of %s"),
+ sdata->property->klass->name,
+ sdata->property->widget->name);
+ }
+ else
+ {
+ description = g_strdup_printf (_("Setting %s of %s to %s"),
+ sdata->property->klass->name,
+ sdata->property->widget->name,
+ value_name);
+ }
+ g_free (value_name);
+ }
+
+ return description;
}
void
-glade_command_set_properties_list (GladeProject *project, GList *props)
+glade_command_set_properties_list (GladeProject * project, GList * props)
{
- GladeCommandSetProperty *me;
- GladeCommand *cmd;
- GCSetPropData *sdata;
- GList *list;
- gboolean success;
- gboolean multiple;
+ GladeCommandSetProperty *me;
+ GladeCommand *cmd;
+ GCSetPropData *sdata;
+ GList *list;
+ gboolean success;
+ gboolean multiple;
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (props);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (props);
- me = (GladeCommandSetProperty*) g_object_new (GLADE_COMMAND_SET_PROPERTY_TYPE, NULL);
- cmd = GLADE_COMMAND (me);
+ me = (GladeCommandSetProperty *)
+ g_object_new (GLADE_COMMAND_SET_PROPERTY_TYPE, NULL);
+ cmd = GLADE_COMMAND (me);
- /* Ref all props */
- for (list = props; list; list = list->next)
- {
- sdata = list->data;
- g_object_ref (G_OBJECT (sdata->property));
- }
+ /* Ref all props */
+ for (list = props; list; list = list->next)
+ {
+ sdata = list->data;
+ g_object_ref (G_OBJECT (sdata->property));
+ }
- me->sdata = props;
- cmd->description =
- glade_command_set_property_description (me);
+ me->sdata = props;
+ cmd->description = glade_command_set_property_description (me);
- multiple = g_list_length (me->sdata) > 1;
- if (multiple)
- glade_command_push_group (cmd->description);
+ multiple = g_list_length (me->sdata) > 1;
+ if (multiple)
+ glade_command_push_group (cmd->description);
- glade_command_check_group (GLADE_COMMAND (me));
+ glade_command_check_group (GLADE_COMMAND (me));
- /* Push onto undo stack only if it executes successfully. */
- success = glade_command_set_property_execute (GLADE_COMMAND (me));
-
- if (success)
- glade_project_push_undo (GLADE_PROJECT (project),
- GLADE_COMMAND (me));
- else
- /* No leaks on my shift! */
- g_object_unref (G_OBJECT (me));
-
- if (multiple)
- glade_command_pop_group ();
+ /* Push onto undo stack only if it executes successfully. */
+ success = glade_command_set_property_execute (GLADE_COMMAND (me));
+
+ if (success)
+ glade_project_push_undo (GLADE_PROJECT (project), GLADE_COMMAND (me));
+ else
+ /* No leaks on my shift! */
+ g_object_unref (G_OBJECT (me));
+
+ if (multiple)
+ glade_command_pop_group ();
}
void
-glade_command_set_properties (GladeProperty *property, const GValue *old_value, const GValue *new_value, ...)
-{
- GCSetPropData *sdata;
- GladeProperty *prop;
- GValue *ovalue, *nvalue;
- GList *list = NULL;
- va_list vl;
-
- g_return_if_fail (GLADE_IS_PROPERTY (property));
-
- /* Add first set */
- sdata = g_new (GCSetPropData, 1);
- sdata->property = property;
- sdata->old_value = g_new0 (GValue, 1);
- sdata->new_value = g_new0 (GValue, 1);
- g_value_init (sdata->old_value, G_VALUE_TYPE (old_value));
- g_value_init (sdata->new_value, G_VALUE_TYPE (new_value));
- g_value_copy (old_value, sdata->old_value);
- g_value_copy (new_value, sdata->new_value);
- list = g_list_prepend (list, sdata);
-
- va_start (vl, new_value);
- while ((prop = va_arg (vl, GladeProperty *)) != NULL)
- {
- ovalue = va_arg (vl, GValue *);
- nvalue = va_arg (vl, GValue *);
-
- g_assert (GLADE_IS_PROPERTY (prop));
- g_assert (G_IS_VALUE (ovalue));
- g_assert (G_IS_VALUE (nvalue));
-
- sdata = g_new (GCSetPropData, 1);
- sdata->property = g_object_ref (G_OBJECT (prop));
- sdata->old_value = g_new0 (GValue, 1);
- sdata->new_value = g_new0 (GValue, 1);
- g_value_init (sdata->old_value, G_VALUE_TYPE (ovalue));
- g_value_init (sdata->new_value, G_VALUE_TYPE (nvalue));
- g_value_copy (ovalue, sdata->old_value);
- g_value_copy (nvalue, sdata->new_value);
- list = g_list_prepend (list, sdata);
- }
- va_end (vl);
-
- glade_command_set_properties_list (property->widget->project, list);
+glade_command_set_properties (GladeProperty * property,
+ const GValue * old_value,
+ const GValue * new_value, ...)
+{
+ GCSetPropData *sdata;
+ GladeProperty *prop;
+ GValue *ovalue, *nvalue;
+ GList *list = NULL;
+ va_list vl;
+
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+
+ /* Add first set */
+ sdata = g_new (GCSetPropData, 1);
+ sdata->property = property;
+ sdata->old_value = g_new0 (GValue, 1);
+ sdata->new_value = g_new0 (GValue, 1);
+ g_value_init (sdata->old_value, G_VALUE_TYPE (old_value));
+ g_value_init (sdata->new_value, G_VALUE_TYPE (new_value));
+ g_value_copy (old_value, sdata->old_value);
+ g_value_copy (new_value, sdata->new_value);
+ list = g_list_prepend (list, sdata);
+
+ va_start (vl, new_value);
+ while ((prop = va_arg (vl, GladeProperty *)) != NULL)
+ {
+ ovalue = va_arg (vl, GValue *);
+ nvalue = va_arg (vl, GValue *);
+
+ g_assert (GLADE_IS_PROPERTY (prop));
+ g_assert (G_IS_VALUE (ovalue));
+ g_assert (G_IS_VALUE (nvalue));
+
+ sdata = g_new (GCSetPropData, 1);
+ sdata->property = g_object_ref (G_OBJECT (prop));
+ sdata->old_value = g_new0 (GValue, 1);
+ sdata->new_value = g_new0 (GValue, 1);
+ g_value_init (sdata->old_value, G_VALUE_TYPE (ovalue));
+ g_value_init (sdata->new_value, G_VALUE_TYPE (nvalue));
+ g_value_copy (ovalue, sdata->old_value);
+ g_value_copy (nvalue, sdata->new_value);
+ list = g_list_prepend (list, sdata);
+ }
+ va_end (vl);
+
+ glade_command_set_properties_list (property->widget->project, list);
}
void
-glade_command_set_property_value (GladeProperty *property, const GValue* pvalue)
+glade_command_set_property_value (GladeProperty * property,
+ const GValue * pvalue)
{
- /* Dont generate undo/redo items for unchanging property values.
- */
- if (glade_property_equals_value (property, pvalue))
- return;
+ /* Dont generate undo/redo items for unchanging property values.
+ */
+ if (glade_property_equals_value (property, pvalue))
+ return;
- glade_command_set_properties (property, property->value, pvalue, NULL);
+ glade_command_set_properties (property, property->value, pvalue, NULL);
}
void
-glade_command_set_property (GladeProperty *property, ...)
+glade_command_set_property (GladeProperty * property, ...)
{
- GValue *value;
- va_list args;
-
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ GValue *value;
+ va_list args;
+
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- va_start (args, property);
- value = glade_property_class_make_gvalue_from_vl (property->klass, args);
- va_end (args);
-
- glade_command_set_property_value (property, value);
+ va_start (args, property);
+ value = glade_property_class_make_gvalue_from_vl (property->klass, args);
+ va_end (args);
+
+ glade_command_set_property_value (property, value);
}
/**************************************************/
@@ -745,12 +744,13 @@ glade_command_set_property (GladeProperty *property, ...)
/* create a new GladeCommandSetName class. Objects of this class will
* encapsulate a "set name" operation */
-typedef struct {
- GladeCommand parent;
+typedef struct
+{
+ GladeCommand parent;
- GladeWidget *widget;
- gchar *old_name;
- gchar *name;
+ GladeWidget *widget;
+ gchar *old_name;
+ gchar *name;
} GladeCommandSetName;
/* standard macros */
@@ -763,9 +763,9 @@ GLADE_MAKE_COMMAND (GladeCommandSetName, glade_command_set_name);
/* Undo the last "set name command" */
static gboolean
-glade_command_set_name_undo (GladeCommand *cmd)
+glade_command_set_name_undo (GladeCommand * cmd)
{
- return glade_command_set_name_execute (cmd);
+ return glade_command_set_name_execute (cmd);
}
/*
@@ -773,105 +773,111 @@ glade_command_set_name_undo (GladeCommand *cmd)
* function cmd will point to the undo action
*/
static gboolean
-glade_command_set_name_execute (GladeCommand *cmd)
+glade_command_set_name_execute (GladeCommand * cmd)
{
- GladeCommandSetName* me = GLADE_COMMAND_SET_NAME (cmd);
- char* tmp;
+ GladeCommandSetName *me = GLADE_COMMAND_SET_NAME (cmd);
+ char *tmp;
+
+ g_return_val_if_fail (me != NULL, TRUE);
+ g_return_val_if_fail (me->widget != NULL, TRUE);
+ g_return_val_if_fail (me->name != NULL, TRUE);
- g_return_val_if_fail (me != NULL, TRUE);
- g_return_val_if_fail (me->widget != NULL, TRUE);
- g_return_val_if_fail (me->name != NULL, TRUE);
+ glade_project_set_widget_name (me->widget->project, me->widget, me->name);
- glade_project_set_widget_name (me->widget->project,
- me->widget, me->name);
-
- tmp = me->old_name;
- me->old_name = me->name;
- me->name = tmp;
+ tmp = me->old_name;
+ me->old_name = me->name;
+ me->name = tmp;
- return TRUE;
+ return TRUE;
}
static void
-glade_command_set_name_finalize (GObject *obj)
+glade_command_set_name_finalize (GObject * obj)
{
- GladeCommandSetName* me;
+ GladeCommandSetName *me;
- g_return_if_fail (GLADE_IS_COMMAND_SET_NAME (obj));
+ g_return_if_fail (GLADE_IS_COMMAND_SET_NAME (obj));
- me = GLADE_COMMAND_SET_NAME (obj);
+ me = GLADE_COMMAND_SET_NAME (obj);
- g_free (me->old_name);
- g_free (me->name);
+ g_free (me->old_name);
+ g_free (me->name);
- glade_command_finalize (obj);
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_set_name_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_set_name_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- GladeCommandSetName *cmd1;
- GladeCommandSetName *cmd2;
+ GladeCommandSetName *cmd1;
+ GladeCommandSetName *cmd2;
- if (GLADE_IS_COMMAND_SET_NAME (this_cmd) && GLADE_IS_COMMAND_SET_NAME (other_cmd))
- {
- cmd1 = GLADE_COMMAND_SET_NAME (this_cmd);
- cmd2 = GLADE_COMMAND_SET_NAME (other_cmd);
+ if (GLADE_IS_COMMAND_SET_NAME (this_cmd) &&
+ GLADE_IS_COMMAND_SET_NAME (other_cmd))
+ {
+ cmd1 = GLADE_COMMAND_SET_NAME (this_cmd);
+ cmd2 = GLADE_COMMAND_SET_NAME (other_cmd);
- return (cmd1->widget == cmd2->widget);
- }
+ return (cmd1->widget == cmd2->widget);
+ }
- return FALSE;
+ return FALSE;
}
static void
-glade_command_set_name_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_set_name_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- GladeCommandSetName *nthis = GLADE_COMMAND_SET_NAME (this_cmd);
- GladeCommandSetName *nother = GLADE_COMMAND_SET_NAME (other_cmd);
+ GladeCommandSetName *nthis = GLADE_COMMAND_SET_NAME (this_cmd);
+ GladeCommandSetName *nother = GLADE_COMMAND_SET_NAME (other_cmd);
- g_return_if_fail (GLADE_IS_COMMAND_SET_NAME (this_cmd) && GLADE_IS_COMMAND_SET_NAME (other_cmd));
+ g_return_if_fail (GLADE_IS_COMMAND_SET_NAME (this_cmd) &&
+ GLADE_IS_COMMAND_SET_NAME (other_cmd));
- g_free (nthis->old_name);
- nthis->old_name = nother->old_name;
- nother->old_name = NULL;
+ g_free (nthis->old_name);
+ nthis->old_name = nother->old_name;
+ nother->old_name = NULL;
- g_free (this_cmd->description);
- this_cmd->description = g_strdup_printf (_("Renaming %s to %s"), nthis->name, nthis->old_name);
+ g_free (this_cmd->description);
+ this_cmd->description =
+ g_strdup_printf (_("Renaming %s to %s"), nthis->name, nthis->old_name);
- glade_app_update_ui ();
+ glade_app_update_ui ();
}
/* this function takes the ownership of name */
void
-glade_command_set_name (GladeWidget *widget, const gchar* name)
+glade_command_set_name (GladeWidget * widget, const gchar * name)
{
- GladeCommandSetName *me;
- GladeCommand *cmd;
+ GladeCommandSetName *me;
+ GladeCommand *cmd;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (name != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (name != NULL);
- /* Dont spam the queue with false name changes.
- */
- if (!strcmp (widget->name, name))
- return;
+ /* Dont spam the queue with false name changes.
+ */
+ if (!strcmp (widget->name, name))
+ return;
- me = g_object_new (GLADE_COMMAND_SET_NAME_TYPE, NULL);
- cmd = GLADE_COMMAND (me);
+ me = g_object_new (GLADE_COMMAND_SET_NAME_TYPE, NULL);
+ cmd = GLADE_COMMAND (me);
- me->widget = widget;
- me->name = g_strdup (name);
- me->old_name = g_strdup (widget->name);
+ me->widget = widget;
+ me->name = g_strdup (name);
+ me->old_name = g_strdup (widget->name);
- cmd->description = g_strdup_printf (_("Renaming %s to %s"), me->old_name, me->name);
+ cmd->description =
+ g_strdup_printf (_("Renaming %s to %s"), me->old_name, me->name);
- glade_command_check_group (GLADE_COMMAND (me));
+ glade_command_check_group (GLADE_COMMAND (me));
- if (glade_command_set_name_execute (GLADE_COMMAND (me)))
- glade_project_push_undo (GLADE_PROJECT (widget->project), GLADE_COMMAND (me));
- else
- g_object_unref (G_OBJECT (me));
+ if (glade_command_set_name_execute (GLADE_COMMAND (me)))
+ glade_project_push_undo (GLADE_PROJECT (widget->project),
+ GLADE_COMMAND (me));
+ else
+ g_object_unref (G_OBJECT (me));
}
/******************************************************************************
@@ -882,12 +888,13 @@ glade_command_set_name (GladeWidget *widget, const gchar* name)
*
*****************************************************************************/
-typedef struct {
- GladeCommand parent;
- GladeProject *project;
- GList *widgets;
- gboolean add;
- gboolean from_clipboard;
+typedef struct
+{
+ GladeCommand parent;
+ GladeProject *project;
+ GList *widgets;
+ gboolean add;
+ gboolean from_clipboard;
} GladeCommandAddRemove;
@@ -898,55 +905,55 @@ GLADE_MAKE_COMMAND (GladeCommandAddRemove, glade_command_add_remove);
#define GLADE_IS_COMMAND_ADD_REMOVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GLADE_COMMAND_ADD_REMOVE_TYPE))
#define GLADE_IS_COMMAND_ADD_REMOVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_ADD_REMOVE_TYPE))
-static void
-glade_command_placeholder_destroyed (GtkWidget *object, CommandData *cdata)
+static void
+glade_command_placeholder_destroyed (GtkWidget * object, CommandData * cdata)
{
- if (GTK_WIDGET (cdata->placeholder) == object)
- {
- cdata->placeholder = NULL;
- cdata->handler_id = 0;
- }
+ if (GTK_WIDGET (cdata->placeholder) == object)
+ {
+ cdata->placeholder = NULL;
+ cdata->handler_id = 0;
+ }
}
static void
-glade_command_placeholder_connect (CommandData *cdata,
- GladePlaceholder *placeholder)
+glade_command_placeholder_connect (CommandData * cdata,
+ GladePlaceholder * placeholder)
{
- g_assert (cdata && cdata->placeholder == NULL);
+ g_assert (cdata && cdata->placeholder == NULL);
- /* Something like a no-op with no placeholder */
- if ((cdata->placeholder = placeholder) == NULL)
- return;
+ /* Something like a no-op with no placeholder */
+ if ((cdata->placeholder = placeholder) == NULL)
+ return;
- cdata->handler_id = g_signal_connect
- (placeholder, "destroy",
- G_CALLBACK (glade_command_placeholder_destroyed), cdata);
+ cdata->handler_id = g_signal_connect
+ (placeholder, "destroy",
+ G_CALLBACK (glade_command_placeholder_destroyed), cdata);
}
static GList *
-get_all_parentless_reffed_widgets (GList *reffed, GladeWidget *widget)
+get_all_parentless_reffed_widgets (GList * reffed, GladeWidget * widget)
{
- GList *children, *l, *list;
- GladeWidget *child;
+ GList *children, *l, *list;
+ GladeWidget *child;
- if ((list = glade_widget_get_parentless_reffed_widgets (widget)) != NULL)
- reffed = g_list_concat (reffed, list);
+ if ((list = glade_widget_get_parentless_reffed_widgets (widget)) != NULL)
+ reffed = g_list_concat (reffed, list);
- children = glade_widget_adaptor_get_children (widget->adaptor,
- widget->object);
+ children = glade_widget_adaptor_get_children (widget->adaptor,
+ widget->object);
- for (l = children; l; l = l->next)
- {
- if ((child = glade_widget_get_from_gobject (l->data)) != NULL)
- {
- reffed = get_all_parentless_reffed_widgets (reffed, child);
- }
- }
+ for (l = children; l; l = l->next)
+ {
+ if ((child = glade_widget_get_from_gobject (l->data)) != NULL)
+ {
+ reffed = get_all_parentless_reffed_widgets (reffed, child);
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- return reffed;
+ return reffed;
}
/**
@@ -964,160 +971,160 @@ get_all_parentless_reffed_widgets (GList *reffed, GladeWidget *widget)
*
*/
static void
-glade_command_add (GList *widgets,
- GladeWidget *parent,
- GladePlaceholder *placeholder,
- gboolean pasting)
-{
- GladeCommandAddRemove *me;
- CommandData *cdata;
- GladeWidget *widget = NULL;
- GList *l, *list, *children, *placeholders = NULL;
- GtkWidget *child;
-
- g_return_if_fail (widgets && widgets->data);
- g_return_if_fail (parent == NULL || GLADE_IS_WIDGET (parent));
-
- me = g_object_new (GLADE_COMMAND_ADD_REMOVE_TYPE, NULL);
- me->add = TRUE;
- me->from_clipboard = pasting;
-
- /* Things can go wrong in this function if the dataset is inacurate,
- * we make no real attempt here to recover, just g_critical() and
- * fix the bugs as they pop up.
- */
- widget = GLADE_WIDGET (widgets->data);
- if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
- me->project = glade_placeholder_get_project (placeholder);
- else
- me->project = glade_app_get_project();
-
- GLADE_COMMAND (me)->description =
- g_strdup_printf (_("Add %s"), g_list_length (widgets) == 1 ?
- widget->name : _("multiple"));
-
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = list->data;
- cdata = g_new0 (CommandData, 1);
- if (widget->internal)
- g_critical ("Internal widget in Add");
-
- /* Widget */
- cdata->widget = g_object_ref (G_OBJECT (widget));
-
- /* Parentless ref */
- if ((cdata->reffed = get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
- g_list_foreach (cdata->reffed, (GFunc)g_object_ref, NULL);
-
- /* Parent */
- if (parent == NULL)
- cdata->parent = glade_widget_get_parent (widget);
- else if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
- cdata->parent = glade_placeholder_get_parent (placeholder);
- else if (GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
- cdata->parent = parent;
-
- /* Placeholder */
- if (placeholder != NULL && g_list_length (widgets) == 1)
- {
- glade_command_placeholder_connect (cdata, placeholder);
- }
- else if (cdata->parent &&
- glade_widget_placeholder_relation (cdata->parent, widget))
- {
- GtkContainer *cont = GTK_CONTAINER (cdata->parent->object);
-
- child = glade_util_get_placeholder_from_pointer (cont);
- if (child && g_list_find (placeholders, child) == NULL)
- {
- placeholders = g_list_append (placeholders, child);
- glade_command_placeholder_connect
- (cdata, GLADE_PLACEHOLDER (child));
- }
- else if ((children = glade_widget_adaptor_get_children
- (cdata->parent->adaptor, cdata->parent->object)) != NULL)
- {
- for (l = children; l && l->data; l = l->next)
- {
- child = l->data;
-
- /* Find a placeholder for this child */
- if (GLADE_IS_PLACEHOLDER (child) &&
- g_list_find (placeholders, child) == NULL)
- {
- placeholders = g_list_append (placeholders, child);
- glade_command_placeholder_connect
- (cdata, GLADE_PLACEHOLDER (child));
- break;
- }
- }
- g_list_free (children);
- }
- }
-
- /*
- * Save a copy of the original project so we can forward that to glade-project,
- * who'll copy in any resource files needed by any properties that are getting
- * cross-project pasted.
- */
- cdata->project = cdata->widget->project;
-
- me->widgets = g_list_prepend (me->widgets, cdata);
- }
-
- glade_command_check_group (GLADE_COMMAND (me));
-
- /*
- * Push it onto the undo stack only on success
- */
- if (glade_command_add_remove_execute (GLADE_COMMAND (me)))
- glade_project_push_undo (glade_app_get_project(), GLADE_COMMAND (me));
- else
- g_object_unref (G_OBJECT (me));
-
- if (placeholders)
- g_list_free (placeholders);
-
-} /* end of glade_command_add() */
+glade_command_add (GList * widgets,
+ GladeWidget * parent,
+ GladePlaceholder * placeholder, gboolean pasting)
+{
+ GladeCommandAddRemove *me;
+ CommandData *cdata;
+ GladeWidget *widget = NULL;
+ GList *l, *list, *children, *placeholders = NULL;
+ GtkWidget *child;
+
+ g_return_if_fail (widgets && widgets->data);
+ g_return_if_fail (parent == NULL || GLADE_IS_WIDGET (parent));
+
+ me = g_object_new (GLADE_COMMAND_ADD_REMOVE_TYPE, NULL);
+ me->add = TRUE;
+ me->from_clipboard = pasting;
+
+ /* Things can go wrong in this function if the dataset is inacurate,
+ * we make no real attempt here to recover, just g_critical() and
+ * fix the bugs as they pop up.
+ */
+ widget = GLADE_WIDGET (widgets->data);
+ if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
+ me->project = glade_placeholder_get_project (placeholder);
+ else
+ me->project = glade_app_get_project ();
+
+ GLADE_COMMAND (me)->description =
+ g_strdup_printf (_("Add %s"), g_list_length (widgets) == 1 ?
+ widget->name : _("multiple"));
+
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = list->data;
+ cdata = g_new0 (CommandData, 1);
+ if (widget->internal)
+ g_critical ("Internal widget in Add");
+
+ /* Widget */
+ cdata->widget = g_object_ref (G_OBJECT (widget));
+
+ /* Parentless ref */
+ if ((cdata->reffed =
+ get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
+ g_list_foreach (cdata->reffed, (GFunc) g_object_ref, NULL);
+
+ /* Parent */
+ if (parent == NULL)
+ cdata->parent = glade_widget_get_parent (widget);
+ else if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
+ cdata->parent = glade_placeholder_get_parent (placeholder);
+ else if (GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
+ cdata->parent = parent;
+
+ /* Placeholder */
+ if (placeholder != NULL && g_list_length (widgets) == 1)
+ {
+ glade_command_placeholder_connect (cdata, placeholder);
+ }
+ else if (cdata->parent &&
+ glade_widget_placeholder_relation (cdata->parent, widget))
+ {
+ GtkContainer *cont = GTK_CONTAINER (cdata->parent->object);
+
+ child = glade_util_get_placeholder_from_pointer (cont);
+ if (child && g_list_find (placeholders, child) == NULL)
+ {
+ placeholders = g_list_append (placeholders, child);
+ glade_command_placeholder_connect
+ (cdata, GLADE_PLACEHOLDER (child));
+ }
+ else if ((children = glade_widget_adaptor_get_children
+ (cdata->parent->adaptor, cdata->parent->object)) != NULL)
+ {
+ for (l = children; l && l->data; l = l->next)
+ {
+ child = l->data;
+
+ /* Find a placeholder for this child */
+ if (GLADE_IS_PLACEHOLDER (child) &&
+ g_list_find (placeholders, child) == NULL)
+ {
+ placeholders = g_list_append (placeholders, child);
+ glade_command_placeholder_connect
+ (cdata, GLADE_PLACEHOLDER (child));
+ break;
+ }
+ }
+ g_list_free (children);
+ }
+ }
+
+ /*
+ * Save a copy of the original project so we can forward that to glade-project,
+ * who'll copy in any resource files needed by any properties that are getting
+ * cross-project pasted.
+ */
+ cdata->project = cdata->widget->project;
+
+ me->widgets = g_list_prepend (me->widgets, cdata);
+ }
+
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ /*
+ * Push it onto the undo stack only on success
+ */
+ if (glade_command_add_remove_execute (GLADE_COMMAND (me)))
+ glade_project_push_undo (glade_app_get_project (), GLADE_COMMAND (me));
+ else
+ g_object_unref (G_OBJECT (me));
+
+ if (placeholders)
+ g_list_free (placeholders);
+
+} /* end of glade_command_add() */
static void
-glade_command_delete_prop_refs (GladeWidget *widget)
+glade_command_delete_prop_refs (GladeWidget * widget)
{
- GladeProperty *property;
+ GladeProperty *property;
- while (widget->prop_refs)
- {
- property = GLADE_PROPERTY (widget->prop_refs->data);
- glade_command_set_property (property, NULL);
- }
+ while (widget->prop_refs)
+ {
+ property = GLADE_PROPERTY (widget->prop_refs->data);
+ glade_command_set_property (property, NULL);
+ }
}
-static void glade_command_remove (GList *widgets);
+static void glade_command_remove (GList * widgets);
static void
-glade_command_remove_locked (GladeWidget *widget, GList *reffed)
+glade_command_remove_locked (GladeWidget * widget, GList * reffed)
{
- GList list = { 0, }, *widgets, *l;
- GladeWidget *locked;
+ GList list = { 0, }, *widgets, *l;
+ GladeWidget *locked;
- widgets = g_list_copy (widget->locked_widgets);
+ widgets = g_list_copy (widget->locked_widgets);
- for (l = widget->locked_widgets; l; l = l->next)
- {
- locked = l->data;
- list.data = locked;
+ for (l = widget->locked_widgets; l; l = l->next)
+ {
+ locked = l->data;
+ list.data = locked;
- if (g_list_find (reffed, locked))
- continue;
+ if (g_list_find (reffed, locked))
+ continue;
- glade_command_unlock_widget (locked);
- glade_command_remove (&list);
- }
+ glade_command_unlock_widget (locked);
+ glade_command_remove (&list);
+ }
- g_list_free (widgets);
+ g_list_free (widgets);
}
/**
@@ -1128,306 +1135,313 @@ glade_command_remove_locked (GladeWidget *widget, GList *reffed)
* Performs a remove command on all widgets in @widgets from @parent.
*/
static void
-glade_command_remove (GList *widgets)
-{
- GladeCommandAddRemove *me;
- GladeWidget *widget = NULL;
- CommandData *cdata;
- GtkWidget *placeholder;
- GList *list, *l;
-
- g_return_if_fail (widgets != NULL);
-
- me = g_object_new (GLADE_COMMAND_ADD_REMOVE_TYPE, NULL);
- me->add = FALSE;
- me->from_clipboard = FALSE;
-
- /* internal children cannot be deleted. Notify the user. */
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = list->data;
- if (widget->internal)
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_WARN, NULL,
- _("You cannot remove a widget internal to a composite widget."));
- return;
- }
- if (widget->lock)
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_WARN, NULL,
- _("%s is locked by %s, edit %s first."),
- widget->name, widget->lock->name, widget->lock->name);
- return;
- }
- }
-
- me->project = glade_widget_get_project (widget);
- GLADE_COMMAND (me)->description = g_strdup ("dummy");
-
- if (g_list_length (widgets) == 1)
- glade_command_push_group (_("Remove %s"),
- GLADE_WIDGET (widgets->data)->name);
- else
- glade_command_push_group (_("Remove multiple"));
-
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = list->data;
-
- cdata = g_new0 (CommandData, 1);
- cdata->widget = g_object_ref (G_OBJECT (widget));
- cdata->parent = glade_widget_get_parent (widget);
- cdata->project = glade_widget_get_project (widget);
-
- if ((cdata->reffed = get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
- g_list_foreach (cdata->reffed, (GFunc)g_object_ref, NULL);
-
- /* Undoably unset any object properties that may point to the removed object */
- glade_command_delete_prop_refs (widget);
-
- /* Undoably unlock and remove any widgets locked by this widget */
- glade_command_remove_locked (widget, cdata->reffed);
-
- if (widget->internal)
- g_critical ("Internal widget in Remove");
-
- if (widget->lock)
- g_critical ("Locked widget in Remove");
-
- if (cdata->parent != NULL &&
- glade_widget_placeholder_relation
- (cdata->parent, cdata->widget))
- {
- placeholder = glade_placeholder_new ();
- glade_command_placeholder_connect
- (cdata, GLADE_PLACEHOLDER (placeholder));
- }
- me->widgets = g_list_prepend (me->widgets, cdata);
-
- /* Dont record props in create_execute (whether or not we actually
- * record any props here
- */
- cdata->props_recorded = TRUE;
-
- /* Record packing props if not deleted from the clipboard */
- if (me->from_clipboard == FALSE)
- {
- for (l = widget->packing_properties; l; l = l->next)
- cdata->pack_props =
- g_list_prepend (cdata->pack_props,
- glade_property_dup (GLADE_PROPERTY (l->data),
- cdata->widget));
- }
- }
-
- g_assert (widget);
-
- glade_command_check_group (GLADE_COMMAND (me));
-
- if (glade_command_add_remove_execute (GLADE_COMMAND (me)))
- glade_project_push_undo (GLADE_PROJECT (widget->project), GLADE_COMMAND (me));
- else
- g_object_unref (G_OBJECT (me));
-
- glade_command_pop_group ();
-} /* end of glade_command_remove() */
+glade_command_remove (GList * widgets)
+{
+ GladeCommandAddRemove *me;
+ GladeWidget *widget = NULL;
+ CommandData *cdata;
+ GtkWidget *placeholder;
+ GList *list, *l;
+
+ g_return_if_fail (widgets != NULL);
+
+ me = g_object_new (GLADE_COMMAND_ADD_REMOVE_TYPE, NULL);
+ me->add = FALSE;
+ me->from_clipboard = FALSE;
+
+ /* internal children cannot be deleted. Notify the user. */
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = list->data;
+ if (widget->internal)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_WARN, NULL,
+ _
+ ("You cannot remove a widget internal to a composite widget."));
+ return;
+ }
+ if (widget->lock)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_WARN, NULL,
+ _("%s is locked by %s, edit %s first."),
+ widget->name, widget->lock->name,
+ widget->lock->name);
+ return;
+ }
+ }
+
+ me->project = glade_widget_get_project (widget);
+ GLADE_COMMAND (me)->description = g_strdup ("dummy");
+
+ if (g_list_length (widgets) == 1)
+ glade_command_push_group (_("Remove %s"),
+ GLADE_WIDGET (widgets->data)->name);
+ else
+ glade_command_push_group (_("Remove multiple"));
+
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = list->data;
+
+ cdata = g_new0 (CommandData, 1);
+ cdata->widget = g_object_ref (G_OBJECT (widget));
+ cdata->parent = glade_widget_get_parent (widget);
+ cdata->project = glade_widget_get_project (widget);
+
+ if ((cdata->reffed =
+ get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
+ g_list_foreach (cdata->reffed, (GFunc) g_object_ref, NULL);
+
+ /* Undoably unset any object properties that may point to the removed object */
+ glade_command_delete_prop_refs (widget);
+
+ /* Undoably unlock and remove any widgets locked by this widget */
+ glade_command_remove_locked (widget, cdata->reffed);
+
+ if (widget->internal)
+ g_critical ("Internal widget in Remove");
+
+ if (widget->lock)
+ g_critical ("Locked widget in Remove");
+
+ if (cdata->parent != NULL &&
+ glade_widget_placeholder_relation (cdata->parent, cdata->widget))
+ {
+ placeholder = glade_placeholder_new ();
+ glade_command_placeholder_connect
+ (cdata, GLADE_PLACEHOLDER (placeholder));
+ }
+ me->widgets = g_list_prepend (me->widgets, cdata);
+
+ /* Dont record props in create_execute (whether or not we actually
+ * record any props here
+ */
+ cdata->props_recorded = TRUE;
+
+ /* Record packing props if not deleted from the clipboard */
+ if (me->from_clipboard == FALSE)
+ {
+ for (l = widget->packing_properties; l; l = l->next)
+ cdata->pack_props =
+ g_list_prepend (cdata->pack_props,
+ glade_property_dup (GLADE_PROPERTY (l->data),
+ cdata->widget));
+ }
+ }
+
+ g_assert (widget);
+
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ if (glade_command_add_remove_execute (GLADE_COMMAND (me)))
+ glade_project_push_undo (GLADE_PROJECT (widget->project),
+ GLADE_COMMAND (me));
+ else
+ g_object_unref (G_OBJECT (me));
+
+ glade_command_pop_group ();
+} /* end of glade_command_remove() */
static void
-glade_command_transfer_props (GladeWidget *gnew, GList *saved_props)
+glade_command_transfer_props (GladeWidget * gnew, GList * saved_props)
{
- GList *l;
+ GList *l;
- for (l = saved_props; l; l = l->next)
- {
- GladeProperty *prop, *sprop = l->data;
-
- prop = glade_widget_get_pack_property (gnew, sprop->klass->id);
+ for (l = saved_props; l; l = l->next)
+ {
+ GladeProperty *prop, *sprop = l->data;
- if (prop && sprop->klass->transfer_on_paste &&
- glade_property_class_match (prop->klass, sprop->klass))
- glade_property_set_value (prop, sprop->value);
- }
+ prop = glade_widget_get_pack_property (gnew, sprop->klass->id);
+
+ if (prop && sprop->klass->transfer_on_paste &&
+ glade_property_class_match (prop->klass, sprop->klass))
+ glade_property_set_value (prop, sprop->value);
+ }
}
static gboolean
-glade_command_add_execute (GladeCommandAddRemove *me)
-{
- GladeProject *active_project = glade_app_get_project (), *add_project;
- CommandData *cdata;
- GList *list, *l, *saved_props;
- gchar *special_child_type;
-
- if (me->widgets)
- {
- /* XXX FIXME: Selection here should be specific to the project
- * related to this command
- */
- glade_app_selection_clear (FALSE);
-
- for (list = me->widgets; list && list->data; list = list->next)
- {
- cdata = list->data;
- saved_props = NULL;
-
- if (cdata->parent != NULL)
- {
- /* Prepare special-child-type for the paste. */
- if (me->from_clipboard)
- {
- if (cdata->props_recorded == FALSE)
- {
- /* Clear it the first time */
- g_object_set_data (cdata->widget->object,
- "special-child-type", NULL);
- }
- else
- {
- g_object_set_data_full (cdata->widget->object,
- "special-child-type",
- g_strdup (cdata->special_type),
- g_free);
- }
-
- /* Only transfer properties when they are from the clipboard,
- * otherwise prioritize packing defaults.
- */
- saved_props =
- glade_widget_dup_properties (cdata->widget,
- cdata->widget->packing_properties,
- FALSE, FALSE, FALSE);
-
- glade_widget_set_packing_properties (cdata->widget, cdata->parent);
- }
-
- /* glade_command_paste ganauntees that if
- * there we are pasting to a placeholder,
- * there is only one widget.
- */
- if (cdata->placeholder)
- {
- glade_widget_replace
- (cdata->parent,
- G_OBJECT (cdata->placeholder),
- cdata->widget->object);
- }
- else
- {
- glade_widget_add_child (cdata->parent,
- cdata->widget,
- cdata->props_recorded == FALSE);
- }
-
-
- glade_command_transfer_props (cdata->widget, saved_props);
-
- if (saved_props)
- {
- g_list_foreach (saved_props, (GFunc)g_object_unref, NULL);
- g_list_free (saved_props);
- }
-
- /* Now that we've added, apply any packing props if nescisary. */
- for (l = cdata->pack_props; l; l = l->next)
- {
- GValue value = { 0, };
- GladeProperty *saved_prop = l->data;
- GladeProperty *widget_prop =
- glade_widget_get_pack_property (cdata->widget,
- saved_prop->klass->id);
-
- glade_property_get_value (saved_prop, &value);
- glade_property_set_value (widget_prop, &value);
- g_value_unset (&value);
- }
-
- if (cdata->props_recorded == FALSE)
- {
- /* Save the packing properties after the initial paste.
- * (this will be the defaults returned by the container
- * implementation after initially adding them).
- *
- * Otherwise this recorded marker was set when cutting
- */
- g_assert (cdata->pack_props == NULL);
- for (l = cdata->widget->packing_properties;
- l; l = l->next)
- cdata->pack_props =
- g_list_prepend
- (cdata->pack_props,
- glade_property_dup
- (GLADE_PROPERTY (l->data),
- cdata->widget));
-
-
- /* Record the special-type here after replacing */
- if ((special_child_type =
- g_object_get_data (cdata->widget->object,
- "special-child-type")) != NULL)
- {
- g_free (cdata->special_type);
- cdata->special_type = g_strdup (special_child_type);
- }
-
- /* Mark the properties as recorded */
- cdata->props_recorded = TRUE;
- }
- }
-
- /* Toplevels get pasted to the active project */
- add_project = (me->from_clipboard && cdata->widget->parent == NULL) ?
- active_project : me->project;
-
- glade_project_add_object (add_project, cdata->project, cdata->widget->object);
-
- for (l = cdata->reffed; l; l = l->next)
- {
- GladeWidget *reffed = l->data;
- glade_project_add_object (add_project, cdata->project, reffed->object);
- }
-
- glade_app_selection_add(cdata->widget->object, FALSE);
-
- glade_widget_show (cdata->widget);
- }
- glade_app_queue_selection_changed ();
- }
- return TRUE;
-
-} /* end of glade_command_add_execute() */
+glade_command_add_execute (GladeCommandAddRemove * me)
+{
+ GladeProject *active_project = glade_app_get_project (), *add_project;
+ CommandData *cdata;
+ GList *list, *l, *saved_props;
+ gchar *special_child_type;
+
+ if (me->widgets)
+ {
+ /* XXX FIXME: Selection here should be specific to the project
+ * related to this command
+ */
+ glade_app_selection_clear (FALSE);
+
+ for (list = me->widgets; list && list->data; list = list->next)
+ {
+ cdata = list->data;
+ saved_props = NULL;
+
+ if (cdata->parent != NULL)
+ {
+ /* Prepare special-child-type for the paste. */
+ if (me->from_clipboard)
+ {
+ if (cdata->props_recorded == FALSE)
+ {
+ /* Clear it the first time */
+ g_object_set_data (cdata->widget->object,
+ "special-child-type", NULL);
+ }
+ else
+ {
+ g_object_set_data_full (cdata->widget->object,
+ "special-child-type",
+ g_strdup (cdata->special_type),
+ g_free);
+ }
+
+ /* Only transfer properties when they are from the clipboard,
+ * otherwise prioritize packing defaults.
+ */
+ saved_props =
+ glade_widget_dup_properties (cdata->widget,
+ cdata->widget->
+ packing_properties, FALSE,
+ FALSE, FALSE);
+
+ glade_widget_set_packing_properties (cdata->widget,
+ cdata->parent);
+ }
+
+ /* glade_command_paste ganauntees that if
+ * there we are pasting to a placeholder,
+ * there is only one widget.
+ */
+ if (cdata->placeholder)
+ {
+ glade_widget_replace
+ (cdata->parent,
+ G_OBJECT (cdata->placeholder), cdata->widget->object);
+ }
+ else
+ {
+ glade_widget_add_child (cdata->parent,
+ cdata->widget,
+ cdata->props_recorded == FALSE);
+ }
+
+
+ glade_command_transfer_props (cdata->widget, saved_props);
+
+ if (saved_props)
+ {
+ g_list_foreach (saved_props, (GFunc) g_object_unref, NULL);
+ g_list_free (saved_props);
+ }
+
+ /* Now that we've added, apply any packing props if nescisary. */
+ for (l = cdata->pack_props; l; l = l->next)
+ {
+ GValue value = { 0, };
+ GladeProperty *saved_prop = l->data;
+ GladeProperty *widget_prop =
+ glade_widget_get_pack_property (cdata->widget,
+ saved_prop->klass->id);
+
+ glade_property_get_value (saved_prop, &value);
+ glade_property_set_value (widget_prop, &value);
+ g_value_unset (&value);
+ }
+
+ if (cdata->props_recorded == FALSE)
+ {
+ /* Save the packing properties after the initial paste.
+ * (this will be the defaults returned by the container
+ * implementation after initially adding them).
+ *
+ * Otherwise this recorded marker was set when cutting
+ */
+ g_assert (cdata->pack_props == NULL);
+ for (l = cdata->widget->packing_properties; l; l = l->next)
+ cdata->pack_props =
+ g_list_prepend
+ (cdata->pack_props,
+ glade_property_dup
+ (GLADE_PROPERTY (l->data), cdata->widget));
+
+
+ /* Record the special-type here after replacing */
+ if ((special_child_type =
+ g_object_get_data (cdata->widget->object,
+ "special-child-type")) != NULL)
+ {
+ g_free (cdata->special_type);
+ cdata->special_type = g_strdup (special_child_type);
+ }
+
+ /* Mark the properties as recorded */
+ cdata->props_recorded = TRUE;
+ }
+ }
+
+ /* Toplevels get pasted to the active project */
+ add_project = (me->from_clipboard && cdata->widget->parent == NULL) ?
+ active_project : me->project;
+
+ glade_project_add_object (add_project, cdata->project,
+ cdata->widget->object);
+
+ for (l = cdata->reffed; l; l = l->next)
+ {
+ GladeWidget *reffed = l->data;
+ glade_project_add_object (add_project, cdata->project,
+ reffed->object);
+ }
+
+ glade_app_selection_add (cdata->widget->object, FALSE);
+
+ glade_widget_show (cdata->widget);
+ }
+ glade_app_queue_selection_changed ();
+ }
+ return TRUE;
+
+} /* end of glade_command_add_execute() */
static gboolean
-glade_command_remove_execute (GladeCommandAddRemove *me)
+glade_command_remove_execute (GladeCommandAddRemove * me)
{
- CommandData *cdata;
- GladeWidget *reffed;
- GList *list, *l;
+ CommandData *cdata;
+ GladeWidget *reffed;
+ GList *list, *l;
+
+ for (list = me->widgets; list && list->data; list = list->next)
+ {
+ cdata = list->data;
- for (list = me->widgets; list && list->data; list = list->next)
- {
- cdata = list->data;
+ glade_project_remove_object (GLADE_PROJECT (cdata->widget->project),
+ cdata->widget->object);
- glade_project_remove_object(GLADE_PROJECT (cdata->widget->project), cdata->widget->object);
-
- for (l = cdata->reffed; l; l = l->next)
- {
- reffed = l->data;
- glade_project_remove_object(GLADE_PROJECT (cdata->widget->project), reffed->object);
- }
+ for (l = cdata->reffed; l; l = l->next)
+ {
+ reffed = l->data;
+ glade_project_remove_object (GLADE_PROJECT (cdata->widget->project),
+ reffed->object);
+ }
- if (cdata->parent)
- {
- if (cdata->placeholder)
- glade_widget_replace(cdata->parent, cdata->widget->object, G_OBJECT (cdata->placeholder));
- else
- glade_widget_remove_child (cdata->parent, cdata->widget);
- }
+ if (cdata->parent)
+ {
+ if (cdata->placeholder)
+ glade_widget_replace (cdata->parent, cdata->widget->object,
+ G_OBJECT (cdata->placeholder));
+ else
+ glade_widget_remove_child (cdata->parent, cdata->widget);
+ }
- glade_widget_hide (cdata->widget);
- }
+ glade_widget_hide (cdata->widget);
+ }
- return TRUE;
+ return TRUE;
}
/*
@@ -1435,72 +1449,73 @@ glade_command_remove_execute (GladeCommandAddRemove *me)
* function cmd will point to the undo action
*/
static gboolean
-glade_command_add_remove_execute (GladeCommand *cmd)
+glade_command_add_remove_execute (GladeCommand * cmd)
{
- GladeCommandAddRemove *me = (GladeCommandAddRemove*) cmd;
- gboolean retval;
+ GladeCommandAddRemove *me = (GladeCommandAddRemove *) cmd;
+ gboolean retval;
- if (me->add)
- retval = glade_command_add_execute (me);
- else
- retval = glade_command_remove_execute (me);
+ if (me->add)
+ retval = glade_command_add_execute (me);
+ else
+ retval = glade_command_remove_execute (me);
- me->add = !me->add;
+ me->add = !me->add;
- return retval;
+ return retval;
}
static gboolean
-glade_command_add_remove_undo (GladeCommand *cmd)
+glade_command_add_remove_undo (GladeCommand * cmd)
{
- return glade_command_add_remove_execute (cmd);
+ return glade_command_add_remove_execute (cmd);
}
static void
-glade_command_add_remove_finalize (GObject *obj)
+glade_command_add_remove_finalize (GObject * obj)
{
- GladeCommandAddRemove *cmd;
- CommandData *cdata;
- GList *list;
+ GladeCommandAddRemove *cmd;
+ CommandData *cdata;
+ GList *list;
- g_return_if_fail (GLADE_IS_COMMAND_ADD_REMOVE (obj));
+ g_return_if_fail (GLADE_IS_COMMAND_ADD_REMOVE (obj));
- cmd = GLADE_COMMAND_ADD_REMOVE (obj);
+ cmd = GLADE_COMMAND_ADD_REMOVE (obj);
- for (list = cmd->widgets; list && list->data; list = list->next)
- {
- cdata = list->data;
-
- if (cdata->placeholder)
- {
- if (cdata->handler_id)
- g_signal_handler_disconnect (cdata->placeholder,
- cdata->handler_id);
- if (g_object_is_floating (G_OBJECT (cdata->placeholder)))
- gtk_widget_destroy (GTK_WIDGET (cdata->placeholder));
- }
+ for (list = cmd->widgets; list && list->data; list = list->next)
+ {
+ cdata = list->data;
- if (cdata->widget)
- g_object_unref (G_OBJECT (cdata->widget));
+ if (cdata->placeholder)
+ {
+ if (cdata->handler_id)
+ g_signal_handler_disconnect (cdata->placeholder, cdata->handler_id);
+ if (g_object_is_floating (G_OBJECT (cdata->placeholder)))
+ gtk_widget_destroy (GTK_WIDGET (cdata->placeholder));
+ }
- g_list_foreach (cdata->reffed, (GFunc)g_object_unref, NULL);
- g_list_free (cdata->reffed);
- }
- g_list_free (cmd->widgets);
-
- glade_command_finalize (obj);
+ if (cdata->widget)
+ g_object_unref (G_OBJECT (cdata->widget));
+
+ g_list_foreach (cdata->reffed, (GFunc) g_object_unref, NULL);
+ g_list_free (cdata->reffed);
+ }
+ g_list_free (cmd->widgets);
+
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_add_remove_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_add_remove_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- return FALSE;
+ return FALSE;
}
static void
-glade_command_add_remove_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_add_remove_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
/******************************************************************************
@@ -1511,14 +1526,16 @@ glade_command_add_remove_collapse (GladeCommand *this_cmd, GladeCommand *other_c
*
*****************************************************************************/
-typedef struct {
- GladeCommand parent;
- GList *widgets;
- gboolean add;
+typedef struct
+{
+ GladeCommand parent;
+ GList *widgets;
+ gboolean add;
} GladeCommandClipboardAddRemove;
-GLADE_MAKE_COMMAND (GladeCommandClipboardAddRemove, glade_command_clipboard_add_remove);
+GLADE_MAKE_COMMAND (GladeCommandClipboardAddRemove,
+ glade_command_clipboard_add_remove);
#define GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE (glade_command_clipboard_add_remove_get_type ())
#define GLADE_COMMAND_CLIPBOARD_ADD_REMOVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, GladeCommandClipboardAddRemove))
#define GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, GladeCommandClipboardAddRemoveClass))
@@ -1526,48 +1543,50 @@ GLADE_MAKE_COMMAND (GladeCommandClipboardAddRemove, glade_command_clipboard_add_
#define GLADE_IS_COMMAND_CLIPBOARD_ADD_REMOVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE))
static void
-glade_command_clipboard_add_remove_common (GList *widgets, gboolean add)
-{
- GladeCommandClipboardAddRemove *me;
- GladeWidget *widget = NULL;
- GList *list;
-
- g_return_if_fail(widgets && widgets->data);
-
- me = g_object_new(GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, NULL);
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = g_object_ref(G_OBJECT(list->data));
- me->widgets = g_list_prepend (me->widgets, widget);
- }
- me->add = add;
- if (add)
- {
- if (g_list_length (widgets) == 1)
- GLADE_COMMAND(me)->description = g_strdup_printf (_("Clipboard add %s"),
- widget->name);
- else
- GLADE_COMMAND(me)->description = g_strdup (_("Clipboard add multiple"));
- }
- else
- {
- if (g_list_length (widgets) == 1)
- GLADE_COMMAND(me)->description = g_strdup_printf (_("Clipboard remove %s"),
- widget->name);
- else
- GLADE_COMMAND(me)->description = g_strdup (_("Clipboard remove multiple"));
- }
-
- glade_command_check_group(GLADE_COMMAND(me));
-
- if (glade_command_clipboard_add_remove_execute(GLADE_COMMAND(me)))
- {
- glade_project_push_undo(glade_app_get_project(), GLADE_COMMAND(me));
- }
- else
- {
- g_object_unref(G_OBJECT(me));
- }
+glade_command_clipboard_add_remove_common (GList * widgets, gboolean add)
+{
+ GladeCommandClipboardAddRemove *me;
+ GladeWidget *widget = NULL;
+ GList *list;
+
+ g_return_if_fail (widgets && widgets->data);
+
+ me = g_object_new (GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, NULL);
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = g_object_ref (G_OBJECT (list->data));
+ me->widgets = g_list_prepend (me->widgets, widget);
+ }
+ me->add = add;
+ if (add)
+ {
+ if (g_list_length (widgets) == 1)
+ GLADE_COMMAND (me)->description =
+ g_strdup_printf (_("Clipboard add %s"), widget->name);
+ else
+ GLADE_COMMAND (me)->description =
+ g_strdup (_("Clipboard add multiple"));
+ }
+ else
+ {
+ if (g_list_length (widgets) == 1)
+ GLADE_COMMAND (me)->description =
+ g_strdup_printf (_("Clipboard remove %s"), widget->name);
+ else
+ GLADE_COMMAND (me)->description =
+ g_strdup (_("Clipboard remove multiple"));
+ }
+
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ if (glade_command_clipboard_add_remove_execute (GLADE_COMMAND (me)))
+ {
+ glade_project_push_undo (glade_app_get_project (), GLADE_COMMAND (me));
+ }
+ else
+ {
+ g_object_unref (G_OBJECT (me));
+ }
}
/**
@@ -1577,9 +1596,9 @@ glade_command_clipboard_add_remove_common (GList *widgets, gboolean add)
* Performs an add command on all widgets in @widgets to the clipboard.
*/
static void
-glade_command_clipboard_add(GList *widgets)
+glade_command_clipboard_add (GList * widgets)
{
- glade_command_clipboard_add_remove_common(widgets, TRUE);
+ glade_command_clipboard_add_remove_common (widgets, TRUE);
}
/**
@@ -1588,103 +1607,105 @@ glade_command_clipboard_add(GList *widgets)
*
* Performs a remove command on all widgets in @widgets from the clipboard.
*/
-
+
/* not used anywhere */
#if 0
static void
-glade_command_clipboard_remove (GList *widgets)
+glade_command_clipboard_remove (GList * widgets)
{
- glade_command_clipboard_add_remove_common(widgets, FALSE);
+ glade_command_clipboard_add_remove_common (widgets, FALSE);
}
#endif
static gboolean
-glade_command_clipboard_add_execute (GladeCommandClipboardAddRemove *me)
+glade_command_clipboard_add_execute (GladeCommandClipboardAddRemove * me)
{
- GList *list, *widgets = NULL;
+ GList *list, *widgets = NULL;
+
+ for (list = me->widgets; list && list->data; list = list->next)
+ {
+ widgets = g_list_prepend (widgets, list->data);
+ }
+ if (widgets)
+ {
+ glade_clipboard_add (glade_app_get_clipboard (), widgets);
+ g_list_free (widgets);
+ }
- for (list = me->widgets; list && list->data; list = list->next)
- {
- widgets = g_list_prepend(widgets, list->data);
- }
- if (widgets)
- {
- glade_clipboard_add(glade_app_get_clipboard(), widgets);
- g_list_free(widgets);
- }
-
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_command_clipboard_remove_execute (GladeCommandClipboardAddRemove *me)
+glade_command_clipboard_remove_execute (GladeCommandClipboardAddRemove * me)
{
- GList *list, *widgets = NULL;
+ GList *list, *widgets = NULL;
- for (list = me->widgets; list && list->data; list = list->next)
- {
- widgets = g_list_prepend(widgets, list->data);
- }
- if (widgets)
- {
- glade_clipboard_remove(glade_app_get_clipboard(), widgets);
- g_list_free(widgets);
- }
+ for (list = me->widgets; list && list->data; list = list->next)
+ {
+ widgets = g_list_prepend (widgets, list->data);
+ }
+ if (widgets)
+ {
+ glade_clipboard_remove (glade_app_get_clipboard (), widgets);
+ g_list_free (widgets);
+ }
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_command_clipboard_add_remove_execute (GladeCommand *cmd)
+glade_command_clipboard_add_remove_execute (GladeCommand * cmd)
{
- GladeCommandClipboardAddRemove *me = (GladeCommandClipboardAddRemove*) cmd;
- gboolean retval;
+ GladeCommandClipboardAddRemove *me = (GladeCommandClipboardAddRemove *) cmd;
+ gboolean retval;
- if (me->add)
- retval = glade_command_clipboard_add_execute (me);
- else
- retval = glade_command_clipboard_remove_execute (me);
+ if (me->add)
+ retval = glade_command_clipboard_add_execute (me);
+ else
+ retval = glade_command_clipboard_remove_execute (me);
- me->add = !me->add;
+ me->add = !me->add;
- return retval;
+ return retval;
}
static gboolean
-glade_command_clipboard_add_remove_undo (GladeCommand *cmd)
+glade_command_clipboard_add_remove_undo (GladeCommand * cmd)
{
- return glade_command_clipboard_add_remove_execute (cmd);
+ return glade_command_clipboard_add_remove_execute (cmd);
}
static void
-glade_command_clipboard_add_remove_finalize (GObject *obj)
+glade_command_clipboard_add_remove_finalize (GObject * obj)
{
- GladeCommandClipboardAddRemove *cmd;
- GList *list;
+ GladeCommandClipboardAddRemove *cmd;
+ GList *list;
+
+ g_return_if_fail (GLADE_IS_COMMAND_CLIPBOARD_ADD_REMOVE (obj));
- g_return_if_fail (GLADE_IS_COMMAND_CLIPBOARD_ADD_REMOVE (obj));
+ cmd = GLADE_COMMAND_CLIPBOARD_ADD_REMOVE (obj);
- cmd = GLADE_COMMAND_CLIPBOARD_ADD_REMOVE (obj);
+ for (list = cmd->widgets; list && list->data; list = list->next)
+ if (list->data)
+ g_object_unref (G_OBJECT (list->data));
+ g_list_free (cmd->widgets);
- for (list = cmd->widgets; list && list->data; list = list->next)
- if (list->data)
- g_object_unref(G_OBJECT(list->data));
- g_list_free (cmd->widgets);
-
- glade_command_finalize (obj);
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_clipboard_add_remove_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_clipboard_add_remove_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- return FALSE;
+ return FALSE;
}
static void
-glade_command_clipboard_add_remove_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_clipboard_add_remove_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
/******************************************************************************
@@ -1706,32 +1727,32 @@ glade_command_clipboard_add_remove_collapse (GladeCommand *this_cmd, GladeComman
*
* Returns: the newly created widget.
*/
-GladeWidget*
-glade_command_create(GladeWidgetAdaptor *adaptor, GladeWidget *parent, GladePlaceholder *placeholder, GladeProject *project)
-{
- GladeWidget *widget;
- GList *widgets = NULL;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
-
- /* attempt to create the widget -- widget may be null, e.g. the user clicked cancel on a query */
- widget = glade_widget_adaptor_create_widget(adaptor, TRUE,
- "parent", parent,
- "project", project,
- NULL);
- if (widget == NULL)
- {
- return NULL;
- }
- widgets = g_list_prepend(widgets, widget);
- glade_command_push_group(_("Create %s"), widget->name);
- glade_command_add(widgets, parent, placeholder, FALSE);
- glade_command_pop_group();
-
- g_list_free(widgets);
-
- return widget;
+GladeWidget *
+glade_command_create (GladeWidgetAdaptor * adaptor, GladeWidget * parent,
+ GladePlaceholder * placeholder, GladeProject * project)
+{
+ GladeWidget *widget;
+ GList *widgets = NULL;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+
+ /* attempt to create the widget -- widget may be null, e.g. the user clicked cancel on a query */
+ widget = glade_widget_adaptor_create_widget (adaptor, TRUE,
+ "parent", parent,
+ "project", project, NULL);
+ if (widget == NULL)
+ {
+ return NULL;
+ }
+ widgets = g_list_prepend (widgets, widget);
+ glade_command_push_group (_("Create %s"), widget->name);
+ glade_command_add (widgets, parent, placeholder, FALSE);
+ glade_command_pop_group ();
+
+ g_list_free (widgets);
+
+ return widget;
}
/**
@@ -1741,16 +1762,18 @@ glade_command_create(GladeWidgetAdaptor *adaptor, GladeWidget *parent, GladePlac
* Performs a delete command on the list of widgets.
*/
void
-glade_command_delete(GList *widgets)
+glade_command_delete (GList * widgets)
{
- GladeWidget *widget;
-
- g_return_if_fail (widgets != NULL);
+ GladeWidget *widget;
+
+ g_return_if_fail (widgets != NULL);
- widget = widgets->data;
- glade_command_push_group(_("Delete %s"), g_list_length (widgets) == 1 ? widget->name : _("multiple"));
- glade_command_remove(widgets);
- glade_command_pop_group();
+ widget = widgets->data;
+ glade_command_push_group (_("Delete %s"),
+ g_list_length (widgets) ==
+ 1 ? widget->name : _("multiple"));
+ glade_command_remove (widgets);
+ glade_command_pop_group ();
}
/**
@@ -1760,21 +1783,24 @@ glade_command_delete(GList *widgets)
* Removes the list of widgets and adds them to the clipboard.
*/
void
-glade_command_cut(GList *widgets)
+glade_command_cut (GList * widgets)
{
- GladeWidget *widget;
- GList *l;
-
- g_return_if_fail (widgets != NULL);
+ GladeWidget *widget;
+ GList *l;
- for (l = widgets; l; l = l->next)
- g_object_set_data (G_OBJECT (l->data), "glade-command-was-cut", GINT_TO_POINTER (TRUE));
-
- widget = widgets->data;
- glade_command_push_group(_("Cut %s"), g_list_length (widgets) == 1 ? widget->name : _("multiple"));
- glade_command_remove(widgets);
- glade_command_clipboard_add(widgets);
- glade_command_pop_group();
+ g_return_if_fail (widgets != NULL);
+
+ for (l = widgets; l; l = l->next)
+ g_object_set_data (G_OBJECT (l->data), "glade-command-was-cut",
+ GINT_TO_POINTER (TRUE));
+
+ widget = widgets->data;
+ glade_command_push_group (_("Cut %s"),
+ g_list_length (widgets) ==
+ 1 ? widget->name : _("multiple"));
+ glade_command_remove (widgets);
+ glade_command_clipboard_add (widgets);
+ glade_command_pop_group ();
}
/**
@@ -1784,82 +1810,85 @@ glade_command_cut(GList *widgets)
* Copies the list of widgets and adds them to the clipboard.
*/
void
-glade_command_copy(GList *widgets)
-{
- GList *list, *copied_widgets = NULL;
- GladeWidget *copied_widget = NULL;
-
- g_return_if_fail (widgets != NULL);
-
- for (list = widgets; list && list->data; list = list->next)
- {
- copied_widget = glade_widget_dup(list->data, FALSE);
- copied_widgets = g_list_prepend(copied_widgets, copied_widget);
- }
- glade_command_push_group(_("Copy %s"), g_list_length (widgets) == 1 ? copied_widget->name : _("multiple"));
- glade_command_clipboard_add(copied_widgets);
- glade_command_pop_group();
-
- if (copied_widgets)
- g_list_free(copied_widgets);
+glade_command_copy (GList * widgets)
+{
+ GList *list, *copied_widgets = NULL;
+ GladeWidget *copied_widget = NULL;
+
+ g_return_if_fail (widgets != NULL);
+
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ copied_widget = glade_widget_dup (list->data, FALSE);
+ copied_widgets = g_list_prepend (copied_widgets, copied_widget);
+ }
+ glade_command_push_group (_("Copy %s"),
+ g_list_length (widgets) ==
+ 1 ? copied_widget->name : _("multiple"));
+ glade_command_clipboard_add (copied_widgets);
+ glade_command_pop_group ();
+
+ if (copied_widgets)
+ g_list_free (copied_widgets);
}
#if 0
static void
-glade_command_break_references_for_widget (GladeWidget *widget, GList *widgets)
-{
- GList *l, *children;
-
- for (l = widget->properties; l; l = l->next)
- {
- property = l->data;
-
- if (glade_property_class_is_object (property->klass) &&
- property->klass->parentless_widget == FALSE)
- {
- GList *obj_list;
- GObject *reffed_obj = NULL;
- GladeWidget *reffed_widget;
-
- if (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec))
- {
- glade_property_get (property, &obj_list);
-
- }
- else
- {
- glade_property_get (property, &reffed_obj);
- }
- }
- }
-
- children = glade_widget_adaptor_get_children (widget->adaptor,
- widget->object);
-
- for (l = children; l; l = l->next)
- {
- if ((child = glade_widget_get_from_gobject (l->data)) != NULL)
- glade_command_break_references_for_widget (child, widgets);
- }
-
- g_list_free (children);
+glade_command_break_references_for_widget (GladeWidget * widget,
+ GList * widgets)
+{
+ GList *l, *children;
+
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
+
+ if (glade_property_class_is_object (property->klass) &&
+ property->klass->parentless_widget == FALSE)
+ {
+ GList *obj_list;
+ GObject *reffed_obj = NULL;
+ GladeWidget *reffed_widget;
+
+ if (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec))
+ {
+ glade_property_get (property, &obj_list);
+
+ }
+ else
+ {
+ glade_property_get (property, &reffed_obj);
+ }
+ }
+ }
+
+ children = glade_widget_adaptor_get_children (widget->adaptor,
+ widget->object);
+
+ for (l = children; l; l = l->next)
+ {
+ if ((child = glade_widget_get_from_gobject (l->data)) != NULL)
+ glade_command_break_references_for_widget (child, widgets);
+ }
+
+ g_list_free (children);
}
static void
-glade_command_break_references (GladeProject *project, GList *widgets)
+glade_command_break_references (GladeProject * project, GList * widgets)
{
- GList *list;
- GladeWidget *widget;
+ GList *list;
+ GladeWidget *widget;
- for (list = widgets; list && list->data; list = list->next)
- {
- widget = l->data;
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ widget = l->data;
- if (project == widget->project)
- continue;
+ if (project == widget->project)
+ continue;
- glade_command_break_references_for_widget (widget, widgets);
- }
+ glade_command_break_references_for_widget (widget, widgets);
+ }
}
@@ -1876,15 +1905,16 @@ glade_command_break_references (GladeProject *project, GList *widgets)
* will be used when pasting toplevel objects).
*/
void
-glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *placeholder)
+glade_command_paste (GList * widgets, GladeWidget * parent,
+ GladePlaceholder * placeholder)
{
- GList *list, *copied_widgets = NULL;
- GladeWidget *copied_widget = NULL;
+ GList *list, *copied_widgets = NULL;
+ GladeWidget *copied_widget = NULL;
/* GladeProject *target_project; */
- gboolean exact;
-
- g_return_if_fail (widgets != NULL);
-
+ gboolean exact;
+
+ g_return_if_fail (widgets != NULL);
+
/* if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE) */
/* target_project = glade_placeholder_get_project (placeholder); */
/* else if (parent && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE) */
@@ -1892,26 +1922,30 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
/* else */
/* target_project = glade_app_get_project(); */
- for (list = widgets; list && list->data; list = list->next)
- {
- exact = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (list->data), "glade-command-was-cut"));
+ for (list = widgets; list && list->data; list = list->next)
+ {
+ exact =
+ GPOINTER_TO_INT (g_object_get_data
+ (G_OBJECT (list->data), "glade-command-was-cut"));
- copied_widget = glade_widget_dup(list->data, exact);
- copied_widgets = g_list_prepend(copied_widgets, copied_widget);
- }
+ copied_widget = glade_widget_dup (list->data, exact);
+ copied_widgets = g_list_prepend (copied_widgets, copied_widget);
+ }
- glade_command_push_group(_("Paste %s"), g_list_length (widgets) == 1 ? copied_widget->name : _("multiple"));
+ glade_command_push_group (_("Paste %s"),
+ g_list_length (widgets) ==
+ 1 ? copied_widget->name : _("multiple"));
- /* When pasting widgets across projects, we nullify the property references that
- * are not satisfied by the paste list.
- */
+ /* When pasting widgets across projects, we nullify the property references that
+ * are not satisfied by the paste list.
+ */
- glade_command_add(copied_widgets, parent, placeholder, TRUE);
- glade_command_pop_group();
-
- if (copied_widgets)
- g_list_free(copied_widgets);
+ glade_command_add (copied_widgets, parent, placeholder, TRUE);
+ glade_command_pop_group ();
+
+ if (copied_widgets)
+ g_list_free (copied_widgets);
}
/**
@@ -1925,18 +1959,21 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
* parent; the active project will be used when pasting toplevel objects).
*/
void
-glade_command_dnd(GList *widgets, GladeWidget *parent, GladePlaceholder *placeholder)
+glade_command_dnd (GList * widgets, GladeWidget * parent,
+ GladePlaceholder * placeholder)
{
- GladeWidget *widget;
-
- g_return_if_fail (widgets != NULL);
-
- widget = widgets->data;
- glade_command_push_group(_("Drag-n-Drop from %s to %s"),
- parent->name, g_list_length (widgets) == 1 ? widget->name : _("multiple"));
- glade_command_remove(widgets);
- glade_command_add(widgets, parent, placeholder, TRUE);
- glade_command_pop_group();
+ GladeWidget *widget;
+
+ g_return_if_fail (widgets != NULL);
+
+ widget = widgets->data;
+ glade_command_push_group (_("Drag-n-Drop from %s to %s"),
+ parent->name,
+ g_list_length (widgets) ==
+ 1 ? widget->name : _("multiple"));
+ glade_command_remove (widgets);
+ glade_command_add (widgets, parent, placeholder, TRUE);
+ glade_command_pop_group ();
}
/*********************************************************/
@@ -1945,21 +1982,23 @@ glade_command_dnd(GList *widgets, GladeWidget *parent, GladePlaceholder *placeho
/* create a new GladeCommandAddRemoveChangeSignal class. Objects of this class will
* encapsulate an "add or remove signal handler" operation */
-typedef enum {
- GLADE_ADD,
- GLADE_REMOVE,
- GLADE_CHANGE
+typedef enum
+{
+ GLADE_ADD,
+ GLADE_REMOVE,
+ GLADE_CHANGE
} GladeAddType;
-typedef struct {
- GladeCommand parent;
+typedef struct
+{
+ GladeCommand parent;
- GladeWidget *widget;
+ GladeWidget *widget;
- GladeSignal *signal;
- GladeSignal *new_signal;
+ GladeSignal *signal;
+ GladeSignal *new_signal;
- GladeAddType type;
+ GladeAddType type;
} GladeCommandAddSignal;
/* standard macros */
@@ -1971,100 +2010,99 @@ GLADE_MAKE_COMMAND (GladeCommandAddSignal, glade_command_add_signal);
#define GLADE_IS_COMMAND_ADD_SIGNAL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_ADD_SIGNAL_TYPE))
static void
-glade_command_add_signal_finalize (GObject *obj)
+glade_command_add_signal_finalize (GObject * obj)
{
- GladeCommandAddSignal *cmd = GLADE_COMMAND_ADD_SIGNAL (obj);
+ GladeCommandAddSignal *cmd = GLADE_COMMAND_ADD_SIGNAL (obj);
- g_object_unref (cmd->widget);
+ g_object_unref (cmd->widget);
- if (cmd->signal)
- glade_signal_free (cmd->signal);
- if (cmd->new_signal)
- glade_signal_free (cmd->new_signal);
+ if (cmd->signal)
+ glade_signal_free (cmd->signal);
+ if (cmd->new_signal)
+ glade_signal_free (cmd->new_signal);
- glade_command_finalize (obj);
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_add_signal_undo (GladeCommand *this_cmd)
+glade_command_add_signal_undo (GladeCommand * this_cmd)
{
- return glade_command_add_signal_execute (this_cmd);
+ return glade_command_add_signal_execute (this_cmd);
}
static gboolean
-glade_command_add_signal_execute (GladeCommand *this_cmd)
-{
- GladeCommandAddSignal *cmd = GLADE_COMMAND_ADD_SIGNAL (this_cmd);
- GladeSignal *temp;
-
- switch (cmd->type)
- {
- case GLADE_ADD:
- glade_widget_add_signal_handler (cmd->widget, cmd->signal);
- cmd->type = GLADE_REMOVE;
- break;
- case GLADE_REMOVE:
- glade_widget_remove_signal_handler (cmd->widget, cmd->signal);
- cmd->type = GLADE_ADD;
- break;
- case GLADE_CHANGE:
- glade_widget_change_signal_handler (cmd->widget,
- cmd->signal,
- cmd->new_signal);
- temp = cmd->signal;
- cmd->signal = cmd->new_signal;
- cmd->new_signal = temp;
- break;
- default:
- break;
- }
- return TRUE;
+glade_command_add_signal_execute (GladeCommand * this_cmd)
+{
+ GladeCommandAddSignal *cmd = GLADE_COMMAND_ADD_SIGNAL (this_cmd);
+ GladeSignal *temp;
+
+ switch (cmd->type)
+ {
+ case GLADE_ADD:
+ glade_widget_add_signal_handler (cmd->widget, cmd->signal);
+ cmd->type = GLADE_REMOVE;
+ break;
+ case GLADE_REMOVE:
+ glade_widget_remove_signal_handler (cmd->widget, cmd->signal);
+ cmd->type = GLADE_ADD;
+ break;
+ case GLADE_CHANGE:
+ glade_widget_change_signal_handler (cmd->widget,
+ cmd->signal, cmd->new_signal);
+ temp = cmd->signal;
+ cmd->signal = cmd->new_signal;
+ cmd->new_signal = temp;
+ break;
+ default:
+ break;
+ }
+ return TRUE;
}
static gboolean
-glade_command_add_signal_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_add_signal_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- return FALSE;
+ return FALSE;
}
static void
-glade_command_add_signal_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_add_signal_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- g_return_if_reached ();
+ g_return_if_reached ();
}
static void
-glade_command_add_remove_change_signal (GladeWidget *glade_widget,
- const GladeSignal *signal,
- const GladeSignal *new_signal,
- GladeAddType type)
-{
- GladeCommandAddSignal *me = GLADE_COMMAND_ADD_SIGNAL
- (g_object_new (GLADE_COMMAND_ADD_SIGNAL_TYPE, NULL));
- GladeCommand *cmd = GLADE_COMMAND (me);
-
- /* we can only add/remove a signal to a widget that has been wrapped by a GladeWidget */
- g_assert (glade_widget != NULL);
- g_assert (glade_widget->project != NULL);
-
- me->widget = g_object_ref(glade_widget);
- me->type = type;
- me->signal = glade_signal_clone (signal);
- me->new_signal = new_signal ?
- glade_signal_clone (new_signal) : NULL;
-
- cmd->description =
- g_strdup_printf (type == GLADE_ADD ? _("Add signal handler %s") :
- type == GLADE_REMOVE ? _("Remove signal handler %s") :
- _("Change signal handler %s"),
- signal->handler);
-
- glade_command_check_group (GLADE_COMMAND (me));
-
- if (glade_command_add_signal_execute (cmd))
- glade_project_push_undo (GLADE_PROJECT (glade_widget->project), cmd);
- else
- g_object_unref (G_OBJECT (me));
+glade_command_add_remove_change_signal (GladeWidget * glade_widget,
+ const GladeSignal * signal,
+ const GladeSignal * new_signal,
+ GladeAddType type)
+{
+ GladeCommandAddSignal *me = GLADE_COMMAND_ADD_SIGNAL
+ (g_object_new (GLADE_COMMAND_ADD_SIGNAL_TYPE, NULL));
+ GladeCommand *cmd = GLADE_COMMAND (me);
+
+ /* we can only add/remove a signal to a widget that has been wrapped by a GladeWidget */
+ g_assert (glade_widget != NULL);
+ g_assert (glade_widget->project != NULL);
+
+ me->widget = g_object_ref (glade_widget);
+ me->type = type;
+ me->signal = glade_signal_clone (signal);
+ me->new_signal = new_signal ? glade_signal_clone (new_signal) : NULL;
+
+ cmd->description =
+ g_strdup_printf (type == GLADE_ADD ? _("Add signal handler %s") :
+ type == GLADE_REMOVE ? _("Remove signal handler %s") :
+ _("Change signal handler %s"), signal->handler);
+
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ if (glade_command_add_signal_execute (cmd))
+ glade_project_push_undo (GLADE_PROJECT (glade_widget->project), cmd);
+ else
+ g_object_unref (G_OBJECT (me));
}
/**
@@ -2075,10 +2113,11 @@ glade_command_add_remove_change_signal (GladeWidget *glade_widget,
* TODO: write me
*/
void
-glade_command_add_signal (GladeWidget *glade_widget, const GladeSignal *signal)
+glade_command_add_signal (GladeWidget * glade_widget,
+ const GladeSignal * signal)
{
- glade_command_add_remove_change_signal
- (glade_widget, signal, NULL, GLADE_ADD);
+ glade_command_add_remove_change_signal
+ (glade_widget, signal, NULL, GLADE_ADD);
}
/**
@@ -2089,10 +2128,11 @@ glade_command_add_signal (GladeWidget *glade_widget, const GladeSignal *signal)
* TODO: write me
*/
void
-glade_command_remove_signal (GladeWidget *glade_widget, const GladeSignal *signal)
+glade_command_remove_signal (GladeWidget * glade_widget,
+ const GladeSignal * signal)
{
- glade_command_add_remove_change_signal
- (glade_widget, signal, NULL, GLADE_REMOVE);
+ glade_command_add_remove_change_signal
+ (glade_widget, signal, NULL, GLADE_REMOVE);
}
/**
@@ -2104,12 +2144,12 @@ glade_command_remove_signal (GladeWidget *glade_widget, const GladeSignal *signa
* TODO: write me
*/
void
-glade_command_change_signal (GladeWidget *glade_widget,
- const GladeSignal *old_signal,
- const GladeSignal *new_signal)
+glade_command_change_signal (GladeWidget * glade_widget,
+ const GladeSignal * old_signal,
+ const GladeSignal * new_signal)
{
- glade_command_add_remove_change_signal
- (glade_widget, old_signal, new_signal, GLADE_CHANGE);
+ glade_command_add_remove_change_signal
+ (glade_widget, old_signal, new_signal, GLADE_CHANGE);
}
/******************************************************************************
@@ -2120,15 +2160,16 @@ glade_command_change_signal (GladeWidget *glade_widget,
*
*****************************************************************************/
-typedef struct {
- GladeCommand parent;
- GladeProperty *property;
- gboolean translatable;
- gchar *context;
- gchar *comment;
- gboolean old_translatable;
- gchar *old_context;
- gchar *old_comment;
+typedef struct
+{
+ GladeCommand parent;
+ GladeProperty *property;
+ gboolean translatable;
+ gchar *context;
+ gchar *comment;
+ gboolean old_translatable;
+ gchar *old_context;
+ gchar *old_comment;
} GladeCommandSetI18n;
@@ -2140,96 +2181,100 @@ GLADE_MAKE_COMMAND (GladeCommandSetI18n, glade_command_set_i18n);
#define GLADE_IS_COMMAND_SET_I18N_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_SET_I18N_TYPE))
static gboolean
-glade_command_set_i18n_execute(GladeCommand *cmd)
-{
- GladeCommandSetI18n *me = (GladeCommandSetI18n *)cmd;
- gboolean temp_translatable;
- gchar *temp_context;
- gchar *temp_comment;
-
- /* sanity check */
- g_return_val_if_fail (me != NULL, TRUE);
- g_return_val_if_fail (me->property != NULL, TRUE);
-
- /* set the new values in the property */
- glade_property_i18n_set_translatable(me->property, me->translatable);
- glade_property_i18n_set_context(me->property, me->context);
- glade_property_i18n_set_comment(me->property, me->comment);
-
- /* swap the current values with the old values to prepare for undo */
- temp_translatable = me->translatable;
- temp_context = me->context;
- temp_comment = me->comment;
- me->translatable = me->old_translatable;
- me->context = me->old_context;
- me->comment = me->old_comment;
- me->old_translatable = temp_translatable;
- me->old_context = temp_context;
- me->old_comment = temp_comment;
-
- return TRUE;
+glade_command_set_i18n_execute (GladeCommand * cmd)
+{
+ GladeCommandSetI18n *me = (GladeCommandSetI18n *) cmd;
+ gboolean temp_translatable;
+ gchar *temp_context;
+ gchar *temp_comment;
+
+ /* sanity check */
+ g_return_val_if_fail (me != NULL, TRUE);
+ g_return_val_if_fail (me->property != NULL, TRUE);
+
+ /* set the new values in the property */
+ glade_property_i18n_set_translatable (me->property, me->translatable);
+ glade_property_i18n_set_context (me->property, me->context);
+ glade_property_i18n_set_comment (me->property, me->comment);
+
+ /* swap the current values with the old values to prepare for undo */
+ temp_translatable = me->translatable;
+ temp_context = me->context;
+ temp_comment = me->comment;
+ me->translatable = me->old_translatable;
+ me->context = me->old_context;
+ me->comment = me->old_comment;
+ me->old_translatable = temp_translatable;
+ me->old_context = temp_context;
+ me->old_comment = temp_comment;
+
+ return TRUE;
}
static gboolean
-glade_command_set_i18n_undo(GladeCommand *cmd)
+glade_command_set_i18n_undo (GladeCommand * cmd)
{
- return glade_command_set_i18n_execute(cmd);
+ return glade_command_set_i18n_execute (cmd);
}
static void
-glade_command_set_i18n_finalize(GObject *obj)
+glade_command_set_i18n_finalize (GObject * obj)
{
- GladeCommandSetI18n *me;
-
- g_return_if_fail(GLADE_IS_COMMAND_SET_I18N(obj));
+ GladeCommandSetI18n *me;
+
+ g_return_if_fail (GLADE_IS_COMMAND_SET_I18N (obj));
- me = GLADE_COMMAND_SET_I18N(obj);
- g_free (me->context);
- g_free (me->comment);
- g_free (me->old_context);
- g_free (me->old_comment);
-
- glade_command_finalize(obj);
+ me = GLADE_COMMAND_SET_I18N (obj);
+ g_free (me->context);
+ g_free (me->comment);
+ g_free (me->old_context);
+ g_free (me->old_comment);
+
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_set_i18n_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_set_i18n_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- GladeCommandSetI18n *cmd1;
- GladeCommandSetI18n *cmd2;
+ GladeCommandSetI18n *cmd1;
+ GladeCommandSetI18n *cmd2;
- if (GLADE_IS_COMMAND_SET_I18N (this_cmd) && GLADE_IS_COMMAND_SET_I18N (other_cmd))
- {
- cmd1 = GLADE_COMMAND_SET_I18N (this_cmd);
- cmd2 = GLADE_COMMAND_SET_I18N (other_cmd);
+ if (GLADE_IS_COMMAND_SET_I18N (this_cmd) &&
+ GLADE_IS_COMMAND_SET_I18N (other_cmd))
+ {
+ cmd1 = GLADE_COMMAND_SET_I18N (this_cmd);
+ cmd2 = GLADE_COMMAND_SET_I18N (other_cmd);
- return (cmd1->property == cmd2->property);
- }
+ return (cmd1->property == cmd2->property);
+ }
- return FALSE;
+ return FALSE;
}
static void
-glade_command_set_i18n_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_set_i18n_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- /* this command is the one that will be used for an undo of the sequence of like commands */
- GladeCommandSetI18n *this = GLADE_COMMAND_SET_I18N (this_cmd);
-
- /* the other command contains the values that will be used for a redo */
- GladeCommandSetI18n *other = GLADE_COMMAND_SET_I18N (other_cmd);
+ /* this command is the one that will be used for an undo of the sequence of like commands */
+ GladeCommandSetI18n *this = GLADE_COMMAND_SET_I18N (this_cmd);
+
+ /* the other command contains the values that will be used for a redo */
+ GladeCommandSetI18n *other = GLADE_COMMAND_SET_I18N (other_cmd);
- g_return_if_fail (GLADE_IS_COMMAND_SET_I18N (this_cmd) && GLADE_IS_COMMAND_SET_I18N (other_cmd));
+ g_return_if_fail (GLADE_IS_COMMAND_SET_I18N (this_cmd) &&
+ GLADE_IS_COMMAND_SET_I18N (other_cmd));
- /* adjust this command to contain, as its old values, the other command's current values */
- this->old_translatable = other->old_translatable;
- g_free (this->old_context);
- g_free (this->old_comment);
- this->old_context = other->old_context;
- this->old_comment = other->old_comment;
- other->old_context = NULL;
- other->old_comment = NULL;
+ /* adjust this command to contain, as its old values, the other command's current values */
+ this->old_translatable = other->old_translatable;
+ g_free (this->old_context);
+ g_free (this->old_comment);
+ this->old_context = other->old_context;
+ this->old_comment = other->old_comment;
+ other->old_context = NULL;
+ other->old_comment = NULL;
- glade_app_update_ui ();
+ glade_app_update_ui ();
}
/**
@@ -2242,43 +2287,43 @@ glade_command_set_i18n_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd
* Sets the i18n data on the property.
*/
void
-glade_command_set_i18n (GladeProperty *property,
- gboolean translatable,
- const gchar *context,
- const gchar *comment)
-{
- GladeCommandSetI18n *me;
-
- g_return_if_fail(property);
-
- /* check that something changed before continuing with the command */
- if (translatable == property->i18n_translatable &&
- !g_strcmp0 (property->i18n_context, context) &&
- !g_strcmp0 (property->i18n_comment, comment))
- return;
-
- /* load up the command */
- me = g_object_new(GLADE_COMMAND_SET_I18N_TYPE, NULL);
- me->property = property;
- me->translatable = translatable;
- me->context = g_strdup(context);
- me->comment = g_strdup(comment);
- me->old_translatable = property->i18n_translatable;
- me->old_context = g_strdup(property->i18n_context);
- me->old_comment = g_strdup(property->i18n_comment);
- GLADE_COMMAND(me)->description = g_strdup_printf(_("Setting i18n metadata"));;
-
- glade_command_check_group(GLADE_COMMAND(me));
-
- /* execute the command and push it on the stack if successful */
- if (glade_command_set_i18n_execute(GLADE_COMMAND(me)))
- {
- glade_project_push_undo(glade_app_get_project(), GLADE_COMMAND(me));
- }
- else
- {
- g_object_unref(G_OBJECT(me));
- }
+glade_command_set_i18n (GladeProperty * property,
+ gboolean translatable,
+ const gchar * context, const gchar * comment)
+{
+ GladeCommandSetI18n *me;
+
+ g_return_if_fail (property);
+
+ /* check that something changed before continuing with the command */
+ if (translatable == property->i18n_translatable &&
+ !g_strcmp0 (property->i18n_context, context) &&
+ !g_strcmp0 (property->i18n_comment, comment))
+ return;
+
+ /* load up the command */
+ me = g_object_new (GLADE_COMMAND_SET_I18N_TYPE, NULL);
+ me->property = property;
+ me->translatable = translatable;
+ me->context = g_strdup (context);
+ me->comment = g_strdup (comment);
+ me->old_translatable = property->i18n_translatable;
+ me->old_context = g_strdup (property->i18n_context);
+ me->old_comment = g_strdup (property->i18n_comment);
+ GLADE_COMMAND (me)->description =
+ g_strdup_printf (_("Setting i18n metadata"));;
+
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ /* execute the command and push it on the stack if successful */
+ if (glade_command_set_i18n_execute (GLADE_COMMAND (me)))
+ {
+ glade_project_push_undo (glade_app_get_project (), GLADE_COMMAND (me));
+ }
+ else
+ {
+ g_object_unref (G_OBJECT (me));
+ }
}
@@ -2290,11 +2335,12 @@ glade_command_set_i18n (GladeProperty *property,
*
*****************************************************************************/
-typedef struct {
- GladeCommand parent;
- GladeProject *project;
- GladeNamingPolicy policy;
- GladeNamingPolicy old_policy;
+typedef struct
+{
+ GladeCommand parent;
+ GladeProject *project;
+ GladeNamingPolicy policy;
+ GladeNamingPolicy old_policy;
} GladeCommandSetPolicy;
@@ -2306,63 +2352,66 @@ GLADE_MAKE_COMMAND (GladeCommandSetPolicy, glade_command_set_policy);
#define GLADE_IS_COMMAND_SET_POLICY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_SET_POLICY_TYPE))
static gboolean
-glade_command_set_policy_execute(GladeCommand *cmd)
+glade_command_set_policy_execute (GladeCommand * cmd)
{
- GladeCommandSetPolicy *me = (GladeCommandSetPolicy *)cmd;
- GladeNamingPolicy policy;
+ GladeCommandSetPolicy *me = (GladeCommandSetPolicy *) cmd;
+ GladeNamingPolicy policy;
+
+ /* sanity check */
+ g_return_val_if_fail (me != NULL, TRUE);
+ g_return_val_if_fail (me->project != NULL, TRUE);
- /* sanity check */
- g_return_val_if_fail (me != NULL, TRUE);
- g_return_val_if_fail (me->project != NULL, TRUE);
+ /* set the new policy */
+ glade_project_set_naming_policy (me->project, me->policy);
- /* set the new policy */
- glade_project_set_naming_policy (me->project, me->policy);
+ /* swap the current values with the old values to prepare for undo */
+ policy = me->policy;
+ me->policy = me->old_policy;
+ me->old_policy = policy;
- /* swap the current values with the old values to prepare for undo */
- policy = me->policy;
- me->policy = me->old_policy;
- me->old_policy = policy;
-
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_command_set_policy_undo(GladeCommand *cmd)
+glade_command_set_policy_undo (GladeCommand * cmd)
{
- return glade_command_set_policy_execute(cmd);
+ return glade_command_set_policy_execute (cmd);
}
static void
-glade_command_set_policy_finalize(GObject *obj)
+glade_command_set_policy_finalize (GObject * obj)
{
/* GladeCommandSetPolicy *me; */
-
- g_return_if_fail(GLADE_IS_COMMAND_SET_POLICY(obj));
-
- glade_command_finalize(obj);
+
+ g_return_if_fail (GLADE_IS_COMMAND_SET_POLICY (obj));
+
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_set_policy_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_set_policy_unifies (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
/* GladeCommandSetPolicy *cmd1; */
/* GladeCommandSetPolicy *cmd2; */
- return FALSE;
+ return FALSE;
}
static void
-glade_command_set_policy_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_set_policy_collapse (GladeCommand * this_cmd,
+ GladeCommand * other_cmd)
{
- /* this command is the one that will be used for an undo of the sequence of like commands */
- //GladeCommandSetPolicy *this = GLADE_COMMAND_SET_POLICY (this_cmd);
-
- /* the other command contains the values that will be used for a redo */
- //GladeCommandSetPolicy *other = GLADE_COMMAND_SET_POLICY (other_cmd);
+ /* this command is the one that will be used for an undo of the sequence of like commands */
+ //GladeCommandSetPolicy *this = GLADE_COMMAND_SET_POLICY (this_cmd);
+
+ /* the other command contains the values that will be used for a redo */
+ //GladeCommandSetPolicy *other = GLADE_COMMAND_SET_POLICY (other_cmd);
- g_return_if_fail (GLADE_IS_COMMAND_SET_POLICY (this_cmd) && GLADE_IS_COMMAND_SET_POLICY (other_cmd));
+ g_return_if_fail (GLADE_IS_COMMAND_SET_POLICY (this_cmd) &&
+ GLADE_IS_COMMAND_SET_POLICY (other_cmd));
- /* no unify/collapse */
+ /* no unify/collapse */
}
/**
@@ -2373,49 +2422,49 @@ glade_command_set_policy_collapse (GladeCommand *this_cmd, GladeCommand *other_c
* Sets the naming policy of a project
*/
void
-glade_command_set_project_naming_policy (GladeProject *project,
- GladeNamingPolicy policy)
-
+glade_command_set_project_naming_policy (GladeProject * project,
+ GladeNamingPolicy policy)
{
- GladeCommandSetPolicy *me;
-
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ GladeCommandSetPolicy *me;
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+
+ if (glade_project_get_naming_policy (project) != policy)
+ {
+ gchar *prj_name = glade_project_get_name (project);
+ glade_command_push_group (_("Setting %s to use a %s naming policy"),
+ prj_name,
+ policy == GLADE_POLICY_PROJECT_WIDE ?
+ "project wide" : "toplevel contextual");
+ g_free (prj_name);
- if (glade_project_get_naming_policy (project) != policy)
- {
- gchar *prj_name = glade_project_get_name (project);
- glade_command_push_group (_("Setting %s to use a %s naming policy"),
- prj_name,
- policy == GLADE_POLICY_PROJECT_WIDE ?
- "project wide" : "toplevel contextual");
- g_free (prj_name);
+ /* load up the command */
+ me = g_object_new (GLADE_COMMAND_SET_POLICY_TYPE, NULL);
+ me->project = project;
+ me->policy = policy;
+ me->old_policy = glade_project_get_naming_policy (project);
- /* load up the command */
- me = g_object_new(GLADE_COMMAND_SET_POLICY_TYPE, NULL);
- me->project = project;
- me->policy = policy;
- me->old_policy = glade_project_get_naming_policy (project);
+ GLADE_COMMAND (me)->description = g_strdup_printf ("dummy string");
- GLADE_COMMAND(me)->description = g_strdup_printf("dummy string");
-
- glade_command_check_group(GLADE_COMMAND(me));
-
- /* execute the command and push it on the stack if successful
- * this sets the actual policy
- */
- if (glade_command_set_policy_execute(GLADE_COMMAND(me)))
- {
- glade_project_push_undo(glade_app_get_project(), GLADE_COMMAND(me));
- }
- else
- {
- g_object_unref(G_OBJECT(me));
- }
+ glade_command_check_group (GLADE_COMMAND (me));
- glade_command_pop_group ();
+ /* execute the command and push it on the stack if successful
+ * this sets the actual policy
+ */
+ if (glade_command_set_policy_execute (GLADE_COMMAND (me)))
+ {
+ glade_project_push_undo (glade_app_get_project (),
+ GLADE_COMMAND (me));
+ }
+ else
+ {
+ g_object_unref (G_OBJECT (me));
+ }
- glade_editor_refresh (glade_app_get_editor ());
- }
+ glade_command_pop_group ();
+
+ glade_editor_refresh (glade_app_get_editor ());
+ }
}
@@ -2426,11 +2475,12 @@ glade_command_set_project_naming_policy (GladeProject *project,
*
*****************************************************************************/
-typedef struct {
- GladeCommand parent;
- GladeWidget *widget;
- GladeWidget *locked;
- gboolean locking;
+typedef struct
+{
+ GladeCommand parent;
+ GladeWidget *widget;
+ GladeWidget *locked;
+ gboolean locking;
} GladeCommandLock;
@@ -2442,60 +2492,61 @@ GLADE_MAKE_COMMAND (GladeCommandLock, glade_command_lock);
#define GLADE_IS_COMMAND_LOCK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_LOCK_TYPE))
static gboolean
-glade_command_lock_execute(GladeCommand *cmd)
+glade_command_lock_execute (GladeCommand * cmd)
{
- GladeCommandLock *me = (GladeCommandLock *)cmd;
+ GladeCommandLock *me = (GladeCommandLock *) cmd;
+
+ /* set the new policy */
+ if (me->locking)
+ glade_widget_lock (me->widget, me->locked);
+ else
+ glade_widget_unlock (me->locked);
- /* set the new policy */
- if (me->locking)
- glade_widget_lock (me->widget, me->locked);
- else
- glade_widget_unlock (me->locked);
+ /* swap the current values with the old values to prepare for undo */
+ me->locking = !me->locking;
- /* swap the current values with the old values to prepare for undo */
- me->locking = !me->locking;
-
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_command_lock_undo(GladeCommand *cmd)
+glade_command_lock_undo (GladeCommand * cmd)
{
- return glade_command_lock_execute(cmd);
+ return glade_command_lock_execute (cmd);
}
static void
-glade_command_lock_finalize(GObject *obj)
+glade_command_lock_finalize (GObject * obj)
{
- GladeCommandLock *me = (GladeCommandLock *)obj;
-
- g_object_unref (me->widget);
- g_object_unref (me->locked);
-
- glade_command_finalize(obj);
+ GladeCommandLock *me = (GladeCommandLock *) obj;
+
+ g_object_unref (me->widget);
+ g_object_unref (me->locked);
+
+ glade_command_finalize (obj);
}
static gboolean
-glade_command_lock_unifies (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_lock_unifies (GladeCommand * this_cmd, GladeCommand * other_cmd)
{
/* GladeCommandLock *cmd1; */
/* GladeCommandLock *cmd2; */
- /* No point here, this command undoubtedly always runs in groups */
- return FALSE;
+ /* No point here, this command undoubtedly always runs in groups */
+ return FALSE;
}
static void
-glade_command_lock_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
+glade_command_lock_collapse (GladeCommand * this_cmd, GladeCommand * other_cmd)
{
- /* this command is the one that will be used for an undo of the sequence of like commands */
- //GladeCommandLock *this = GLADE_COMMAND_LOCK (this_cmd);
-
- /* the other command contains the values that will be used for a redo */
- //GladeCommandLock *other = GLADE_COMMAND_LOCK (other_cmd);
+ /* this command is the one that will be used for an undo of the sequence of like commands */
+ //GladeCommandLock *this = GLADE_COMMAND_LOCK (this_cmd);
+
+ /* the other command contains the values that will be used for a redo */
+ //GladeCommandLock *other = GLADE_COMMAND_LOCK (other_cmd);
- g_return_if_fail (GLADE_IS_COMMAND_LOCK (this_cmd) && GLADE_IS_COMMAND_LOCK (other_cmd));
+ g_return_if_fail (GLADE_IS_COMMAND_LOCK (this_cmd) &&
+ GLADE_IS_COMMAND_LOCK (other_cmd));
- /* no unify/collapse */
+ /* no unify/collapse */
}
/**
@@ -2508,34 +2559,33 @@ glade_command_lock_collapse (GladeCommand *this_cmd, GladeCommand *other_cmd)
* be removed from the project until unlocked.
*/
void
-glade_command_lock_widget (GladeWidget *widget,
- GladeWidget *locked)
-
+glade_command_lock_widget (GladeWidget * widget, GladeWidget * locked)
{
- GladeCommandLock *me;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (locked));
- g_return_if_fail (locked->lock == NULL);
+ GladeCommandLock *me;
+
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (locked));
+ g_return_if_fail (locked->lock == NULL);
+
+ /* load up the command */
+ me = g_object_new (GLADE_COMMAND_LOCK_TYPE, NULL);
+ me->widget = g_object_ref (widget);
+ me->locked = g_object_ref (locked);
+ me->locking = TRUE;
- /* load up the command */
- me = g_object_new(GLADE_COMMAND_LOCK_TYPE, NULL);
- me->widget = g_object_ref (widget);
- me->locked = g_object_ref (locked);
- me->locking = TRUE;
+ GLADE_COMMAND (me)->description =
+ g_strdup_printf (_("Locking %s by widget %s"), locked->name,
+ widget->name);
- GLADE_COMMAND(me)->description = g_strdup_printf(_("Locking %s by widget %s"),
- locked->name, widget->name);
-
- glade_command_check_group(GLADE_COMMAND(me));
-
- /* execute the command and push it on the stack if successful
- * this sets the actual policy
- */
- if (glade_command_lock_execute(GLADE_COMMAND(me)))
- glade_project_push_undo(glade_app_get_project(), GLADE_COMMAND(me));
- else
- g_object_unref(G_OBJECT(me));
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ /* execute the command and push it on the stack if successful
+ * this sets the actual policy
+ */
+ if (glade_command_lock_execute (GLADE_COMMAND (me)))
+ glade_project_push_undo (glade_app_get_project (), GLADE_COMMAND (me));
+ else
+ g_object_unref (G_OBJECT (me));
}
@@ -2549,31 +2599,30 @@ glade_command_lock_widget (GladeWidget *widget,
*
*/
void
-glade_command_unlock_widget (GladeWidget *widget)
-
+glade_command_unlock_widget (GladeWidget * widget)
{
- GladeCommandLock *me;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (widget->lock));
+ GladeCommandLock *me;
- /* load up the command */
- me = g_object_new(GLADE_COMMAND_LOCK_TYPE, NULL);
- me->widget = g_object_ref (widget->lock);
- me->locked = g_object_ref (widget);
- me->locking = FALSE;
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget->lock));
- GLADE_COMMAND(me)->description = g_strdup_printf(_("Unlocking %s"), widget->name);
-
- glade_command_check_group(GLADE_COMMAND(me));
-
- /* execute the command and push it on the stack if successful
- * this sets the actual policy
- */
- if (glade_command_lock_execute(GLADE_COMMAND(me)))
- glade_project_push_undo(glade_app_get_project(), GLADE_COMMAND(me));
- else
- g_object_unref(G_OBJECT(me));
+ /* load up the command */
+ me = g_object_new (GLADE_COMMAND_LOCK_TYPE, NULL);
+ me->widget = g_object_ref (widget->lock);
+ me->locked = g_object_ref (widget);
+ me->locking = FALSE;
-}
+ GLADE_COMMAND (me)->description =
+ g_strdup_printf (_("Unlocking %s"), widget->name);
+ glade_command_check_group (GLADE_COMMAND (me));
+
+ /* execute the command and push it on the stack if successful
+ * this sets the actual policy
+ */
+ if (glade_command_lock_execute (GLADE_COMMAND (me)))
+ glade_project_push_undo (glade_app_get_project (), GLADE_COMMAND (me));
+ else
+ g_object_unref (G_OBJECT (me));
+
+}
diff --git a/gladeui/glade-command.h b/gladeui/glade-command.h
index e4c67e5..269a12a 100644
--- a/gladeui/glade-command.h
+++ b/gladeui/glade-command.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_COMMAND_H__
#define __GLADE_COMMAND_H__
diff --git a/gladeui/glade-cursor.c b/gladeui/glade-cursor.c
index a08c00b..647efdd 100644
--- a/gladeui/glade-cursor.c
+++ b/gladeui/glade-cursor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -35,53 +34,51 @@
static GladeCursor *cursor = NULL;
static void
-set_cursor_recurse (GtkWidget *widget,
- GdkCursor *gdk_cursor)
+set_cursor_recurse (GtkWidget * widget, GdkCursor * gdk_cursor)
{
- GList *children, *list;
-
- if (!gtk_widget_get_visible (widget) ||
- !gtk_widget_get_realized (widget))
- return;
-
- gdk_window_set_cursor (gtk_widget_get_window (widget), gdk_cursor);
-
- if (GTK_IS_CONTAINER (widget) &&
- (children =
- glade_util_container_get_all_children (GTK_CONTAINER (widget))) != NULL)
- {
- for (list = children; list; list = list->next)
- {
- set_cursor_recurse (GTK_WIDGET (list->data), gdk_cursor);
- }
- g_list_free (children);
- }
+ GList *children, *list;
+
+ if (!gtk_widget_get_visible (widget) || !gtk_widget_get_realized (widget))
+ return;
+
+ gdk_window_set_cursor (gtk_widget_get_window (widget), gdk_cursor);
+
+ if (GTK_IS_CONTAINER (widget) &&
+ (children =
+ glade_util_container_get_all_children (GTK_CONTAINER (widget))) != NULL)
+ {
+ for (list = children; list; list = list->next)
+ {
+ set_cursor_recurse (GTK_WIDGET (list->data), gdk_cursor);
+ }
+ g_list_free (children);
+ }
}
static void
-set_cursor (GdkCursor *gdk_cursor)
+set_cursor (GdkCursor * gdk_cursor)
{
- GladeProject *project;
- GList *list, *projects;
-
- for (projects = glade_app_get_projects ();
- projects; projects = projects->next)
- {
- project = projects->data;
-
- for (list = (GList *) glade_project_get_objects (project);
- list; list = list->next)
- {
- GObject *object = list->data;
-
- if (GTK_IS_WIDGET (object) &&
- gtk_widget_get_has_window (GTK_WIDGET (object)))
- {
- set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
- }
- }
- }
+ GladeProject *project;
+ GList *list, *projects;
+
+ for (projects = glade_app_get_projects ();
+ projects; projects = projects->next)
+ {
+ project = projects->data;
+
+ for (list = (GList *) glade_project_get_objects (project);
+ list; list = list->next)
+ {
+ GObject *object = list->data;
+
+ if (GTK_IS_WIDGET (object) &&
+ gtk_widget_get_has_window (GTK_WIDGET (object)))
+ {
+ set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
+ }
+ }
+ }
}
/**
@@ -93,62 +90,63 @@ set_cursor (GdkCursor *gdk_cursor)
* (also sets the cursor on all visible project widgets)
*/
void
-glade_cursor_set (GdkWindow *window, GladeCursorType type)
+glade_cursor_set (GdkWindow * window, GladeCursorType type)
{
- GladeWidgetAdaptor *adaptor;
- GdkCursor *the_cursor = NULL;
- g_return_if_fail (cursor != NULL);
-
- switch (type) {
- case GLADE_CURSOR_SELECTOR:
- the_cursor = cursor->selector;
- break;
- case GLADE_CURSOR_ADD_WIDGET:
- if ((adaptor =
- glade_palette_get_current_item (glade_app_get_palette ())) != NULL)
- {
- g_object_get (adaptor, "cursor", &the_cursor, NULL);
-
- if (the_cursor == NULL)
- the_cursor = cursor->add_widget;
-
- }
- else
- the_cursor = cursor->add_widget;
- break;
- case GLADE_CURSOR_RESIZE_TOP_LEFT:
- the_cursor = cursor->resize_top_left;
- break;
- case GLADE_CURSOR_RESIZE_TOP_RIGHT:
- the_cursor = cursor->resize_top_right;
- break;
- case GLADE_CURSOR_RESIZE_BOTTOM_LEFT:
- the_cursor = cursor->resize_bottom_left;
- break;
- case GLADE_CURSOR_RESIZE_BOTTOM_RIGHT:
- the_cursor = cursor->resize_bottom_right;
- break;
- case GLADE_CURSOR_RESIZE_LEFT:
- the_cursor = cursor->resize_left;
- break;
- case GLADE_CURSOR_RESIZE_RIGHT:
- the_cursor = cursor->resize_right;
- break;
- case GLADE_CURSOR_RESIZE_TOP:
- the_cursor = cursor->resize_top;
- break;
- case GLADE_CURSOR_RESIZE_BOTTOM:
- the_cursor = cursor->resize_bottom;
- break;
- case GLADE_CURSOR_DRAG:
- the_cursor = cursor->drag;
- break;
- default:
- break;
- }
-
- set_cursor (cursor->selector);
- gdk_window_set_cursor (window, the_cursor);
+ GladeWidgetAdaptor *adaptor;
+ GdkCursor *the_cursor = NULL;
+ g_return_if_fail (cursor != NULL);
+
+ switch (type)
+ {
+ case GLADE_CURSOR_SELECTOR:
+ the_cursor = cursor->selector;
+ break;
+ case GLADE_CURSOR_ADD_WIDGET:
+ if ((adaptor =
+ glade_palette_get_current_item (glade_app_get_palette ())) != NULL)
+ {
+ g_object_get (adaptor, "cursor", &the_cursor, NULL);
+
+ if (the_cursor == NULL)
+ the_cursor = cursor->add_widget;
+
+ }
+ else
+ the_cursor = cursor->add_widget;
+ break;
+ case GLADE_CURSOR_RESIZE_TOP_LEFT:
+ the_cursor = cursor->resize_top_left;
+ break;
+ case GLADE_CURSOR_RESIZE_TOP_RIGHT:
+ the_cursor = cursor->resize_top_right;
+ break;
+ case GLADE_CURSOR_RESIZE_BOTTOM_LEFT:
+ the_cursor = cursor->resize_bottom_left;
+ break;
+ case GLADE_CURSOR_RESIZE_BOTTOM_RIGHT:
+ the_cursor = cursor->resize_bottom_right;
+ break;
+ case GLADE_CURSOR_RESIZE_LEFT:
+ the_cursor = cursor->resize_left;
+ break;
+ case GLADE_CURSOR_RESIZE_RIGHT:
+ the_cursor = cursor->resize_right;
+ break;
+ case GLADE_CURSOR_RESIZE_TOP:
+ the_cursor = cursor->resize_top;
+ break;
+ case GLADE_CURSOR_RESIZE_BOTTOM:
+ the_cursor = cursor->resize_bottom;
+ break;
+ case GLADE_CURSOR_DRAG:
+ the_cursor = cursor->drag;
+ break;
+ default:
+ break;
+ }
+
+ set_cursor (cursor->selector);
+ gdk_window_set_cursor (window, the_cursor);
}
/**
@@ -159,43 +157,45 @@ glade_cursor_set (GdkWindow *window, GladeCursorType type)
void
glade_cursor_init (void)
{
- gchar *path;
- GError *error = NULL;
-
- cursor = g_new0 (GladeCursor, 1);
-
- cursor->selector = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
- cursor->add_widget = gdk_cursor_new (GDK_PLUS);
- cursor->resize_top_left = gdk_cursor_new (GDK_TOP_LEFT_CORNER);
- cursor->resize_top_right = gdk_cursor_new (GDK_TOP_RIGHT_CORNER);
- cursor->resize_bottom_left = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER);
- cursor->resize_bottom_right = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
- cursor->resize_left = gdk_cursor_new (GDK_LEFT_SIDE);
- cursor->resize_right = gdk_cursor_new (GDK_RIGHT_SIDE);
- cursor->resize_top = gdk_cursor_new (GDK_TOP_SIDE);
- cursor->resize_bottom = gdk_cursor_new (GDK_BOTTOM_SIDE);
- cursor->drag = gdk_cursor_new (GDK_FLEUR);
- cursor->add_widget_pixbuf = NULL;
-
- /* load "add" cursor pixbuf */
- path = g_build_filename (glade_app_get_pixmaps_dir (), ADD_PIXBUF_FILENAME, NULL);
-
- cursor->add_widget_pixbuf = gdk_pixbuf_new_from_file (path, &error);
-
- if (cursor->add_widget_pixbuf == NULL)
- {
- g_critical (_("Unable to load image (%s)"), error->message);
-
- g_error_free (error);
- error = NULL;
- }
- g_free (path);
+ gchar *path;
+ GError *error = NULL;
+
+ cursor = g_new0 (GladeCursor, 1);
+
+ cursor->selector = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
+ cursor->add_widget = gdk_cursor_new (GDK_PLUS);
+ cursor->resize_top_left = gdk_cursor_new (GDK_TOP_LEFT_CORNER);
+ cursor->resize_top_right = gdk_cursor_new (GDK_TOP_RIGHT_CORNER);
+ cursor->resize_bottom_left = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER);
+ cursor->resize_bottom_right = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
+ cursor->resize_left = gdk_cursor_new (GDK_LEFT_SIDE);
+ cursor->resize_right = gdk_cursor_new (GDK_RIGHT_SIDE);
+ cursor->resize_top = gdk_cursor_new (GDK_TOP_SIDE);
+ cursor->resize_bottom = gdk_cursor_new (GDK_BOTTOM_SIDE);
+ cursor->drag = gdk_cursor_new (GDK_FLEUR);
+ cursor->add_widget_pixbuf = NULL;
+
+ /* load "add" cursor pixbuf */
+ path =
+ g_build_filename (glade_app_get_pixmaps_dir (), ADD_PIXBUF_FILENAME,
+ NULL);
+
+ cursor->add_widget_pixbuf = gdk_pixbuf_new_from_file (path, &error);
+
+ if (cursor->add_widget_pixbuf == NULL)
+ {
+ g_critical (_("Unable to load image (%s)"), error->message);
+
+ g_error_free (error);
+ error = NULL;
+ }
+ g_free (path);
}
-const GdkPixbuf*
+const GdkPixbuf *
glade_cursor_get_add_widget_pixbuf (void)
{
- g_return_val_if_fail (cursor != NULL, NULL);
+ g_return_val_if_fail (cursor != NULL, NULL);
- return cursor->add_widget_pixbuf;
+ return cursor->add_widget_pixbuf;
}
diff --git a/gladeui/glade-cursor.h b/gladeui/glade-cursor.h
index b56cfba..992dcfa 100644
--- a/gladeui/glade-cursor.h
+++ b/gladeui/glade-cursor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_CURSOR_H__
#define __GLADE_CURSOR_H__
diff --git a/gladeui/glade-debug.c b/gladeui/glade-debug.c
index 007eb94..38ba3b5 100644
--- a/gladeui/glade-debug.c
+++ b/gladeui/glade-debug.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003 Joaquin Cuenca Abela
*
@@ -36,21 +35,20 @@
static void
glade_log_handler (const char *domain,
- GLogLevelFlags level,
- const char *message,
- gpointer data)
+ GLogLevelFlags level, const char *message, gpointer data)
{
- static volatile int want_breakpoint = 0;
+ static volatile int want_breakpoint = 0;
- g_log_default_handler (domain, level, message, data);
- if (want_breakpoint && ((level & (G_LOG_LEVEL_CRITICAL /* | G_LOG_LEVEL_WARNING */)) != 0))
- G_BREAKPOINT ();
+ g_log_default_handler (domain, level, message, data);
+ if (want_breakpoint &&
+ ((level & (G_LOG_LEVEL_CRITICAL /* | G_LOG_LEVEL_WARNING */ )) != 0))
+ G_BREAKPOINT ();
}
static void
glade_set_log_handler (const char *domain)
{
- g_log_set_handler (domain, G_LOG_LEVEL_MASK, glade_log_handler, NULL);
+ g_log_set_handler (domain, G_LOG_LEVEL_MASK, glade_log_handler, NULL);
}
/**
@@ -62,10 +60,9 @@ glade_set_log_handler (const char *domain)
void
glade_setup_log_handlers ()
{
- glade_set_log_handler ("");
- glade_set_log_handler ("GLib");
- glade_set_log_handler ("GLib-GObject");
- glade_set_log_handler ("Gtk");
- glade_set_log_handler ("Gdk");
+ glade_set_log_handler ("");
+ glade_set_log_handler ("GLib");
+ glade_set_log_handler ("GLib-GObject");
+ glade_set_log_handler ("Gtk");
+ glade_set_log_handler ("Gdk");
}
-
diff --git a/gladeui/glade-debug.h b/gladeui/glade-debug.h
index cde6d9c..4fc00df 100644
--- a/gladeui/glade-debug.h
+++ b/gladeui/glade-debug.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_DEBUG_H__
#define __GLADE_DEBUG_H__
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index ff98064..29eedee 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-design-layout.c
*
@@ -39,12 +38,12 @@
#define OUTLINE_WIDTH 4
#define PADDING 12
-typedef enum
+typedef enum
{
- ACTIVITY_NONE,
- ACTIVITY_RESIZE_WIDTH,
- ACTIVITY_RESIZE_HEIGHT,
- ACTIVITY_RESIZE_WIDTH_AND_HEIGHT
+ ACTIVITY_NONE,
+ ACTIVITY_RESIZE_WIDTH,
+ ACTIVITY_RESIZE_HEIGHT,
+ ACTIVITY_RESIZE_WIDTH_AND_HEIGHT
} Activity;
#define ACTIVITY_STR(act) \
@@ -52,600 +51,609 @@ typedef enum
(act) == ACTIVITY_RESIZE_WIDTH ? "resize width" : \
(act) == ACTIVITY_RESIZE_HEIGHT ? "resize height" : "resize width & height")
-typedef enum
+typedef enum
{
- REGION_INSIDE,
- REGION_EAST,
- REGION_SOUTH,
- REGION_SOUTH_EAST,
- REGION_WEST_OF_SOUTH_EAST,
- REGION_NORTH_OF_SOUTH_EAST,
- REGION_OUTSIDE
+ REGION_INSIDE,
+ REGION_EAST,
+ REGION_SOUTH,
+ REGION_SOUTH_EAST,
+ REGION_WEST_OF_SOUTH_EAST,
+ REGION_NORTH_OF_SOUTH_EAST,
+ REGION_OUTSIDE
} PointerRegion;
enum
{
- WIDGET_EVENT,
- LAST_SIGNAL
+ WIDGET_EVENT,
+ LAST_SIGNAL
};
struct _GladeDesignLayoutPrivate
{
- GdkWindow *event_window;
-
- GdkCursor *cursor_resize_bottom;
- GdkCursor *cursor_resize_right;
- GdkCursor *cursor_resize_bottom_right;
-
- /* state machine */
- Activity activity; /* the current activity */
- GtkRequisition *current_size_request;
- gint dx; /* child.width - event.pointer.x */
- gint dy; /* child.height - event.pointer.y */
- gint new_width; /* user's new requested width */
- gint new_height; /* user's new requested height */
+ GdkWindow *event_window;
+
+ GdkCursor *cursor_resize_bottom;
+ GdkCursor *cursor_resize_right;
+ GdkCursor *cursor_resize_bottom_right;
+
+ /* state machine */
+ Activity activity; /* the current activity */
+ GtkRequisition *current_size_request;
+ gint dx; /* child.width - event.pointer.x */
+ gint dy; /* child.height - event.pointer.y */
+ gint new_width; /* user's new requested width */
+ gint new_height; /* user's new requested height */
};
-static guint glade_design_layout_signals[LAST_SIGNAL] = {0};
+static guint glade_design_layout_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GladeDesignLayout, glade_design_layout, GTK_TYPE_BIN)
-
-static PointerRegion
-glade_design_layout_get_pointer_region (GladeDesignLayout *layout, gint x, gint y)
+ static PointerRegion
+ glade_design_layout_get_pointer_region (GladeDesignLayout * layout,
+ gint x, gint y)
{
- GladeDesignLayoutPrivate *priv;
- GtkAllocation child_allocation;
- PointerRegion region = REGION_INSIDE;
-
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
-
- gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (layout)), &child_allocation);
-
- if ((x >= (child_allocation.x + child_allocation.width)) &&
- (x < (child_allocation.x + child_allocation.width + OUTLINE_WIDTH)))
- {
- if ((y < (child_allocation.y + child_allocation.height - OUTLINE_WIDTH)) &&
- (y >= child_allocation.y - OUTLINE_WIDTH))
- region = REGION_EAST;
-
- else if ((y < (child_allocation.y + child_allocation.height)) &&
- (y >= (child_allocation.y + child_allocation.height - OUTLINE_WIDTH)))
- region = REGION_NORTH_OF_SOUTH_EAST;
-
- else if ((y < (child_allocation.y + child_allocation.height + OUTLINE_WIDTH)) &&
- (y >= (child_allocation.y + child_allocation.height)))
- region = REGION_SOUTH_EAST;
- }
- else if ((y >= (child_allocation.y + child_allocation.height)) &&
- (y < (child_allocation.y + child_allocation.height + OUTLINE_WIDTH)))
- {
- if ((x < (child_allocation.x + child_allocation.width - OUTLINE_WIDTH)) &&
- (x >= child_allocation.x - OUTLINE_WIDTH))
- region = REGION_SOUTH;
-
- else if ((x < (child_allocation.x + child_allocation.width)) &&
- (x >= (child_allocation.x + child_allocation.width - OUTLINE_WIDTH)))
- region = REGION_WEST_OF_SOUTH_EAST;
-
- else if ((x < (child_allocation.x + child_allocation.width + OUTLINE_WIDTH)) &&
- (x >= (child_allocation.x + child_allocation.width)))
- region = REGION_SOUTH_EAST;
- }
-
- if (x < PADDING || y < PADDING ||
- x >= (child_allocation.x + child_allocation.width + OUTLINE_WIDTH) ||
- y >= (child_allocation.y + child_allocation.height + OUTLINE_WIDTH))
- region = REGION_OUTSIDE;
-
- return region;
+ GladeDesignLayoutPrivate *priv;
+ GtkAllocation child_allocation;
+ PointerRegion region = REGION_INSIDE;
+
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
+
+ gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (layout)),
+ &child_allocation);
+
+ if ((x >= (child_allocation.x + child_allocation.width)) &&
+ (x < (child_allocation.x + child_allocation.width + OUTLINE_WIDTH)))
+ {
+ if ((y < (child_allocation.y + child_allocation.height - OUTLINE_WIDTH))
+ && (y >= child_allocation.y - OUTLINE_WIDTH))
+ region = REGION_EAST;
+
+ else if ((y < (child_allocation.y + child_allocation.height)) &&
+ (y >=
+ (child_allocation.y + child_allocation.height - OUTLINE_WIDTH)))
+ region = REGION_NORTH_OF_SOUTH_EAST;
+
+ else if ((y <
+ (child_allocation.y + child_allocation.height + OUTLINE_WIDTH))
+ && (y >= (child_allocation.y + child_allocation.height)))
+ region = REGION_SOUTH_EAST;
+ }
+ else if ((y >= (child_allocation.y + child_allocation.height)) &&
+ (y < (child_allocation.y + child_allocation.height + OUTLINE_WIDTH)))
+ {
+ if ((x < (child_allocation.x + child_allocation.width - OUTLINE_WIDTH)) &&
+ (x >= child_allocation.x - OUTLINE_WIDTH))
+ region = REGION_SOUTH;
+
+ else if ((x < (child_allocation.x + child_allocation.width)) &&
+ (x >=
+ (child_allocation.x + child_allocation.width - OUTLINE_WIDTH)))
+ region = REGION_WEST_OF_SOUTH_EAST;
+
+ else if ((x <
+ (child_allocation.x + child_allocation.width + OUTLINE_WIDTH))
+ && (x >= (child_allocation.x + child_allocation.width)))
+ region = REGION_SOUTH_EAST;
+ }
+
+ if (x < PADDING || y < PADDING ||
+ x >= (child_allocation.x + child_allocation.width + OUTLINE_WIDTH) ||
+ y >= (child_allocation.y + child_allocation.height + OUTLINE_WIDTH))
+ region = REGION_OUTSIDE;
+
+ return region;
}
static gboolean
-glade_design_layout_leave_notify_event (GtkWidget *widget, GdkEventCrossing *ev)
+glade_design_layout_leave_notify_event (GtkWidget * widget,
+ GdkEventCrossing * ev)
{
- GtkWidget *child;
- GladeDesignLayoutPrivate *priv;
+ GtkWidget *child;
+ GladeDesignLayoutPrivate *priv;
+
+ if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+ return FALSE;
- if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
- return FALSE;
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ if (priv->activity == ACTIVITY_NONE)
+ gdk_window_set_cursor (priv->event_window, NULL);
- if (priv->activity == ACTIVITY_NONE)
- gdk_window_set_cursor (priv->event_window, NULL);
-
- return FALSE;
+ return FALSE;
}
static void
-glade_design_layout_update_child (GladeDesignLayout *layout,
- GtkWidget *child,
- GtkAllocation *allocation)
+glade_design_layout_update_child (GladeDesignLayout * layout,
+ GtkWidget * child, GtkAllocation * allocation)
{
- GladeDesignLayoutPrivate *priv;
- GladeWidget *gchild;
+ GladeDesignLayoutPrivate *priv;
+ GladeWidget *gchild;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
- /* Update GladeWidget metadata */
- gchild = glade_widget_get_from_gobject (child);
- g_object_set (gchild,
- "toplevel-width", allocation->width,
- "toplevel-height", allocation->height,
- NULL);
+ /* Update GladeWidget metadata */
+ gchild = glade_widget_get_from_gobject (child);
+ g_object_set (gchild,
+ "toplevel-width", allocation->width,
+ "toplevel-height", allocation->height, NULL);
- gtk_widget_size_allocate (child, allocation);
- gtk_widget_queue_resize (GTK_WIDGET (layout));
+ gtk_widget_size_allocate (child, allocation);
+ gtk_widget_queue_resize (GTK_WIDGET (layout));
}
static gboolean
-glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
+glade_design_layout_motion_notify_event (GtkWidget * widget,
+ GdkEventMotion * ev)
{
- GtkWidget *child;
- GladeDesignLayoutPrivate *priv;
- GladeWidget *child_glade_widget;
- PointerRegion region;
- GtkAllocation allocation;
- gint x, y;
- gint new_width, new_height;
-
- if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
- return FALSE;
-
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
-
- gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
-
- child_glade_widget = glade_widget_get_from_gobject (child);
- gtk_widget_get_allocation (child, &allocation);
-
- if (priv->activity == ACTIVITY_RESIZE_WIDTH)
- {
- new_width = x - priv->dx - PADDING - OUTLINE_WIDTH;
-
- if (new_width < priv->current_size_request->width)
- new_width = priv->current_size_request->width;
-
- allocation.width = new_width;
-
- glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
- child, &allocation);
- }
- else if (priv->activity == ACTIVITY_RESIZE_HEIGHT)
- {
- new_height = y - priv->dy - PADDING - OUTLINE_WIDTH;
-
- if (new_height < priv->current_size_request->height)
- new_height = priv->current_size_request->height;
-
- allocation.height = new_height;
-
- glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
- child, &allocation);
- }
- else if (priv->activity == ACTIVITY_RESIZE_WIDTH_AND_HEIGHT)
- {
- new_width = x - priv->dx - PADDING - OUTLINE_WIDTH;
- new_height = y - priv->dy - PADDING - OUTLINE_WIDTH;
-
- if (new_width < priv->current_size_request->width)
- new_width = priv->current_size_request->width;
- if (new_height < priv->current_size_request->height)
- new_height = priv->current_size_request->height;
-
-
- allocation.height = new_height;
- allocation.width = new_width;
-
- glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
- child, &allocation);
- }
- else
- {
- region = glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x, y);
-
- if (region == REGION_EAST)
- gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
-
- else if (region == REGION_SOUTH)
- gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom);
-
- else if (region == REGION_SOUTH_EAST ||
- region == REGION_WEST_OF_SOUTH_EAST ||
- region == REGION_NORTH_OF_SOUTH_EAST)
- gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
-
- else if (region == REGION_OUTSIDE)
- gdk_window_set_cursor (priv->event_window, NULL);
- }
-
- return FALSE;
+ GtkWidget *child;
+ GladeDesignLayoutPrivate *priv;
+ GladeWidget *child_glade_widget;
+ PointerRegion region;
+ GtkAllocation allocation;
+ gint x, y;
+ gint new_width, new_height;
+
+ if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+ return FALSE;
+
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+
+ gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
+
+ child_glade_widget = glade_widget_get_from_gobject (child);
+ gtk_widget_get_allocation (child, &allocation);
+
+ if (priv->activity == ACTIVITY_RESIZE_WIDTH)
+ {
+ new_width = x - priv->dx - PADDING - OUTLINE_WIDTH;
+
+ if (new_width < priv->current_size_request->width)
+ new_width = priv->current_size_request->width;
+
+ allocation.width = new_width;
+
+ glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
+ child, &allocation);
+ }
+ else if (priv->activity == ACTIVITY_RESIZE_HEIGHT)
+ {
+ new_height = y - priv->dy - PADDING - OUTLINE_WIDTH;
+
+ if (new_height < priv->current_size_request->height)
+ new_height = priv->current_size_request->height;
+
+ allocation.height = new_height;
+
+ glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
+ child, &allocation);
+ }
+ else if (priv->activity == ACTIVITY_RESIZE_WIDTH_AND_HEIGHT)
+ {
+ new_width = x - priv->dx - PADDING - OUTLINE_WIDTH;
+ new_height = y - priv->dy - PADDING - OUTLINE_WIDTH;
+
+ if (new_width < priv->current_size_request->width)
+ new_width = priv->current_size_request->width;
+ if (new_height < priv->current_size_request->height)
+ new_height = priv->current_size_request->height;
+
+
+ allocation.height = new_height;
+ allocation.width = new_width;
+
+ glade_design_layout_update_child (GLADE_DESIGN_LAYOUT (widget),
+ child, &allocation);
+ }
+ else
+ {
+ region =
+ glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget),
+ x, y);
+
+ if (region == REGION_EAST)
+ gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
+
+ else if (region == REGION_SOUTH)
+ gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom);
+
+ else if (region == REGION_SOUTH_EAST ||
+ region == REGION_WEST_OF_SOUTH_EAST ||
+ region == REGION_NORTH_OF_SOUTH_EAST)
+ gdk_window_set_cursor (priv->event_window,
+ priv->cursor_resize_bottom_right);
+
+ else if (region == REGION_OUTSIDE)
+ gdk_window_set_cursor (priv->event_window, NULL);
+ }
+
+ return FALSE;
}
static gboolean
-glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
+glade_design_layout_button_press_event (GtkWidget * widget, GdkEventButton * ev)
{
- GtkWidget *child;
- GtkAllocation child_allocation;
- PointerRegion region;
- GladeDesignLayoutPrivate *priv;
- gint x, y;
-
- if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
- return FALSE;
-
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
-
- gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
- region = glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x, y);
-
- if (((GdkEventButton *) ev)->button == 1)
- {
- gtk_widget_get_allocation (child, &child_allocation);
- priv->dx = x - (child_allocation.x + child_allocation.width);
- priv->dy = y - (child_allocation.y + child_allocation.height);
-
- if (region == REGION_EAST)
- {
- priv->activity = ACTIVITY_RESIZE_WIDTH;
- gdk_window_set_cursor (priv->event_window,
- priv->cursor_resize_right);
- }
- if (region == REGION_SOUTH)
- {
- priv->activity = ACTIVITY_RESIZE_HEIGHT;
- gdk_window_set_cursor (priv->event_window,
- priv->cursor_resize_bottom);
- }
- if (region == REGION_SOUTH_EAST)
- {
- priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
- gdk_window_set_cursor (priv->event_window,
- priv->cursor_resize_bottom_right);
- }
- if (region == REGION_WEST_OF_SOUTH_EAST)
- {
- priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
- gdk_window_set_cursor (priv->event_window,
- priv->cursor_resize_bottom_right);
- }
- if (region == REGION_NORTH_OF_SOUTH_EAST)
- {
- priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
- gdk_window_set_cursor (priv->event_window,
- priv->cursor_resize_bottom_right);
- }
- }
-
- return FALSE;
+ GtkWidget *child;
+ GtkAllocation child_allocation;
+ PointerRegion region;
+ GladeDesignLayoutPrivate *priv;
+ gint x, y;
+
+ if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+ return FALSE;
+
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+
+ gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
+ region =
+ glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x,
+ y);
+
+ if (((GdkEventButton *) ev)->button == 1)
+ {
+ gtk_widget_get_allocation (child, &child_allocation);
+ priv->dx = x - (child_allocation.x + child_allocation.width);
+ priv->dy = y - (child_allocation.y + child_allocation.height);
+
+ if (region == REGION_EAST)
+ {
+ priv->activity = ACTIVITY_RESIZE_WIDTH;
+ gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
+ }
+ if (region == REGION_SOUTH)
+ {
+ priv->activity = ACTIVITY_RESIZE_HEIGHT;
+ gdk_window_set_cursor (priv->event_window,
+ priv->cursor_resize_bottom);
+ }
+ if (region == REGION_SOUTH_EAST)
+ {
+ priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
+ gdk_window_set_cursor (priv->event_window,
+ priv->cursor_resize_bottom_right);
+ }
+ if (region == REGION_WEST_OF_SOUTH_EAST)
+ {
+ priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
+ gdk_window_set_cursor (priv->event_window,
+ priv->cursor_resize_bottom_right);
+ }
+ if (region == REGION_NORTH_OF_SOUTH_EAST)
+ {
+ priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
+ gdk_window_set_cursor (priv->event_window,
+ priv->cursor_resize_bottom_right);
+ }
+ }
+
+ return FALSE;
}
static gboolean
-glade_design_layout_button_release_event (GtkWidget *widget, GdkEventButton *ev)
+glade_design_layout_button_release_event (GtkWidget * widget,
+ GdkEventButton * ev)
{
- GladeDesignLayoutPrivate *priv;
- GtkWidget *child;
+ GladeDesignLayoutPrivate *priv;
+ GtkWidget *child;
- if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
- return FALSE;
+ if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+ return FALSE;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- priv->activity = ACTIVITY_NONE;
- gdk_window_set_cursor (priv->event_window, NULL);
+ priv->activity = ACTIVITY_NONE;
+ gdk_window_set_cursor (priv->event_window, NULL);
- return FALSE;
+ return FALSE;
}
static void
-glade_design_layout_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
+glade_design_layout_get_preferred_height (GtkWidget * widget,
+ gint * minimum, gint * natural)
{
- GladeDesignLayoutPrivate *priv;
- GtkWidget *child;
- GladeWidget *gchild;
- gint child_height = 0;
- guint border_width = 0;
+ GladeDesignLayoutPrivate *priv;
+ GtkWidget *child;
+ GladeWidget *gchild;
+ gint child_height = 0;
+ guint border_width = 0;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- *minimum = 0;
- *natural = 0;
+ *minimum = 0;
+ *natural = 0;
- child = gtk_bin_get_child (GTK_BIN (widget));
+ child = gtk_bin_get_child (GTK_BIN (widget));
- if (child && gtk_widget_get_visible (child))
- {
- gchild = glade_widget_get_from_gobject (child);
- g_assert (gchild);
+ if (child && gtk_widget_get_visible (child))
+ {
+ gchild = glade_widget_get_from_gobject (child);
+ g_assert (gchild);
- gtk_widget_get_preferred_height (child, minimum, natural);
+ gtk_widget_get_preferred_height (child, minimum, natural);
- g_object_get (gchild,
- "toplevel-height", &child_height,
- NULL);
-
- child_height = MAX (child_height, *minimum);
+ g_object_get (gchild, "toplevel-height", &child_height, NULL);
- *minimum = MAX (*minimum,
- 2 * PADDING + child_height + 2 * OUTLINE_WIDTH);
- *natural = MAX (*natural,
- 2 * PADDING + child_height + 2 * OUTLINE_WIDTH);
-
- }
+ child_height = MAX (child_height, *minimum);
- *minimum += border_width * 2;
- *natural += border_width * 2;
+ *minimum = MAX (*minimum, 2 * PADDING + child_height + 2 * OUTLINE_WIDTH);
+ *natural = MAX (*natural, 2 * PADDING + child_height + 2 * OUTLINE_WIDTH);
+
+ }
+
+ *minimum += border_width * 2;
+ *natural += border_width * 2;
}
-
+
static void
-glade_design_layout_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
+glade_design_layout_get_preferred_width (GtkWidget * widget,
+ gint * minimum, gint * natural)
{
- GladeDesignLayoutPrivate *priv;
- GtkWidget *child;
- GladeWidget *gchild;
- gint child_width = 0;
- guint border_width = 0;
-
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
-
- *minimum = 0;
- *natural = 0;
-
- child = gtk_bin_get_child (GTK_BIN (widget));
-
- if (child && gtk_widget_get_visible (child))
- {
- gchild = glade_widget_get_from_gobject (child);
- g_assert (gchild);
-
- gtk_widget_get_preferred_width (child, minimum, natural);
-
- g_object_get (gchild,
- "toplevel-width", &child_width,
- NULL);
-
- child_width = MAX (child_width, *minimum);
-
- *minimum = MAX (*minimum,
- 2 * PADDING + child_width + 2 * OUTLINE_WIDTH);
- *natural = MAX (*natural,
- 2 * PADDING + child_width + 2 * OUTLINE_WIDTH);
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- *minimum += border_width * 2;
- *natural += border_width * 2;
+ GladeDesignLayoutPrivate *priv;
+ GtkWidget *child;
+ GladeWidget *gchild;
+ gint child_width = 0;
+ guint border_width = 0;
+
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+
+ *minimum = 0;
+ *natural = 0;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ if (child && gtk_widget_get_visible (child))
+ {
+ gchild = glade_widget_get_from_gobject (child);
+ g_assert (gchild);
+
+ gtk_widget_get_preferred_width (child, minimum, natural);
+
+ g_object_get (gchild, "toplevel-width", &child_width, NULL);
+
+ child_width = MAX (child_width, *minimum);
+
+ *minimum = MAX (*minimum, 2 * PADDING + child_width + 2 * OUTLINE_WIDTH);
+ *natural = MAX (*natural, 2 * PADDING + child_width + 2 * OUTLINE_WIDTH);
+ }
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ *minimum += border_width * 2;
+ *natural += border_width * 2;
}
static void
-glade_design_layout_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+glade_design_layout_size_allocate (GtkWidget * widget,
+ GtkAllocation * allocation)
{
- GladeDesignLayoutPrivate *priv;
- GladeWidget *gchild;
- GtkAllocation child_allocation;
- GtkWidget *child;
- gint border_width;
- gint child_width = 0;
- gint child_height = 0;
+ GladeDesignLayoutPrivate *priv;
+ GladeWidget *gchild;
+ GtkAllocation child_allocation;
+ GtkWidget *child;
+ gint border_width;
+ gint child_width = 0;
+ gint child_height = 0;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- gtk_widget_set_allocation (widget, allocation);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ gtk_widget_set_allocation (widget, allocation);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (priv->event_window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (priv->event_window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
- child = gtk_bin_get_child (GTK_BIN (widget));
-
- if (child && gtk_widget_get_visible (child))
- {
- GtkRequisition requisition;
+ child = gtk_bin_get_child (GTK_BIN (widget));
- gchild = glade_widget_get_from_gobject (child);
- g_assert (gchild);
+ if (child && gtk_widget_get_visible (child))
+ {
+ GtkRequisition requisition;
- g_object_get (gchild,
- "toplevel-width", &child_width,
- "toplevel-height", &child_height,
- NULL);
+ gchild = glade_widget_get_from_gobject (child);
+ g_assert (gchild);
- gtk_widget_get_preferred_size (child, &requisition, NULL);
+ g_object_get (gchild,
+ "toplevel-width", &child_width,
+ "toplevel-height", &child_height, NULL);
- child_allocation.x = allocation->x + border_width + PADDING + OUTLINE_WIDTH;
- child_allocation.y = allocation->y + border_width + PADDING + OUTLINE_WIDTH;
+ gtk_widget_get_preferred_size (child, &requisition, NULL);
- child_allocation.width = MAX (requisition.width, child_width);
- child_allocation.height = MAX (requisition.height, child_height);
+ child_allocation.x =
+ allocation->x + border_width + PADDING + OUTLINE_WIDTH;
+ child_allocation.y =
+ allocation->y + border_width + PADDING + OUTLINE_WIDTH;
- gtk_widget_size_allocate (child, &child_allocation);
- }
+ child_allocation.width = MAX (requisition.width, child_width);
+ child_allocation.height = MAX (requisition.height, child_height);
+
+ gtk_widget_size_allocate (child, &child_allocation);
+ }
}
static void
-glade_design_layout_add (GtkContainer *container, GtkWidget *widget)
+glade_design_layout_add (GtkContainer * container, GtkWidget * widget)
{
- GladeDesignLayout *layout;
- GtkWidget *parent;
+ GladeDesignLayout *layout;
+ GtkWidget *parent;
+
+ layout = GLADE_DESIGN_LAYOUT (container);
+ parent = GTK_WIDGET (container);
- layout = GLADE_DESIGN_LAYOUT (container);
- parent = GTK_WIDGET (container);
+ layout->priv->current_size_request->width = 0;
+ layout->priv->current_size_request->height = 0;
- layout->priv->current_size_request->width = 0;
- layout->priv->current_size_request->height = 0;
-
- /* XXX I guess we need to queue these up until the design-layout actually gets an allocation */
- gtk_widget_set_parent_window (widget, gtk_widget_get_window (parent));
+ /* XXX I guess we need to queue these up until the design-layout actually gets an allocation */
+ gtk_widget_set_parent_window (widget, gtk_widget_get_window (parent));
- GTK_CONTAINER_CLASS (glade_design_layout_parent_class)->add (container, widget);
+ GTK_CONTAINER_CLASS (glade_design_layout_parent_class)->add (container,
+ widget);
- gtk_widget_queue_draw (GTK_WIDGET (container));
+ gtk_widget_queue_draw (GTK_WIDGET (container));
}
static void
-glade_design_layout_remove (GtkContainer *container, GtkWidget *widget)
+glade_design_layout_remove (GtkContainer * container, GtkWidget * widget)
{
- /* Make sure toplevels dont "pop out" of the workspace */
- gtk_widget_hide (widget);
- GTK_CONTAINER_CLASS (glade_design_layout_parent_class)->remove (container, widget);
+ /* Make sure toplevels dont "pop out" of the workspace */
+ gtk_widget_hide (widget);
+ GTK_CONTAINER_CLASS (glade_design_layout_parent_class)->remove (container,
+ widget);
- gtk_widget_queue_draw (GTK_WIDGET (container));
+ gtk_widget_queue_draw (GTK_WIDGET (container));
}
static void
-glade_design_layout_dispose (GObject *object)
+glade_design_layout_dispose (GObject * object)
{
- GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (object);
-
- if (priv->cursor_resize_bottom != NULL) {
- gdk_cursor_unref (priv->cursor_resize_bottom);
- priv->cursor_resize_bottom = NULL;
- }
- if (priv->cursor_resize_right != NULL) {
- gdk_cursor_unref (priv->cursor_resize_right);
- priv->cursor_resize_right = NULL;
- }
- if (priv->cursor_resize_bottom_right != NULL) {
- gdk_cursor_unref (priv->cursor_resize_bottom_right);
- priv->cursor_resize_bottom_right = NULL;
- }
-
- G_OBJECT_CLASS (glade_design_layout_parent_class)->dispose (object);
+ GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (object);
+
+ if (priv->cursor_resize_bottom != NULL)
+ {
+ gdk_cursor_unref (priv->cursor_resize_bottom);
+ priv->cursor_resize_bottom = NULL;
+ }
+ if (priv->cursor_resize_right != NULL)
+ {
+ gdk_cursor_unref (priv->cursor_resize_right);
+ priv->cursor_resize_right = NULL;
+ }
+ if (priv->cursor_resize_bottom_right != NULL)
+ {
+ gdk_cursor_unref (priv->cursor_resize_bottom_right);
+ priv->cursor_resize_bottom_right = NULL;
+ }
+
+ G_OBJECT_CLASS (glade_design_layout_parent_class)->dispose (object);
}
static void
-glade_design_layout_finalize (GObject *object)
+glade_design_layout_finalize (GObject * object)
{
- GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (object);
+ GladeDesignLayoutPrivate *priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (object);
+
+ g_slice_free (GtkRequisition, priv->current_size_request);
- g_slice_free (GtkRequisition, priv->current_size_request);
-
- G_OBJECT_CLASS (glade_design_layout_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_design_layout_parent_class)->finalize (object);
}
static inline void
-draw_frame (GtkWidget *widget,
- cairo_t *cr,
- int x, int y, int w, int h)
-{
- cairo_set_line_width (cr, OUTLINE_WIDTH);
- cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
-
- gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);
-
- /* rectangle */
- cairo_move_to (cr, x, y);
- cairo_rel_line_to (cr, 0, h);
- cairo_rel_line_to (cr, w, 0);
- cairo_rel_line_to (cr, 0, -h);
- cairo_close_path (cr);
- cairo_stroke (cr);
-
+draw_frame (GtkWidget * widget, cairo_t * cr, int x, int y, int w, int h)
+{
+ cairo_set_line_width (cr, OUTLINE_WIDTH);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+
+ gdk_cairo_set_source_color (cr,
+ >k_widget_get_style (widget)->
+ bg[GTK_STATE_SELECTED]);
+
+ /* rectangle */
+ cairo_move_to (cr, x, y);
+ cairo_rel_line_to (cr, 0, h);
+ cairo_rel_line_to (cr, w, 0);
+ cairo_rel_line_to (cr, 0, -h);
+ cairo_close_path (cr);
+ cairo_stroke (cr);
+
#if 0
- /* shadow effect */
- cairo_set_source_rgba (cr, 0, 0, 0, 0.04);
-
- cairo_move_to (cr, x + OUTLINE_WIDTH, y + h + OUTLINE_WIDTH);
- cairo_rel_line_to (cr, w, 0);
- cairo_rel_line_to (cr, 0, -h);
- cairo_stroke (cr);
+ /* shadow effect */
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.04);
+
+ cairo_move_to (cr, x + OUTLINE_WIDTH, y + h + OUTLINE_WIDTH);
+ cairo_rel_line_to (cr, w, 0);
+ cairo_rel_line_to (cr, 0, -h);
+ cairo_stroke (cr);
#endif
}
static gboolean
-glade_design_layout_draw (GtkWidget *widget, cairo_t *cr)
+glade_design_layout_draw (GtkWidget * widget, cairo_t * cr)
{
- if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
- {
- GtkStyle *style;
- GtkWidget *child;
- GdkWindow *window;
- gint border_width;
- gint width, height;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- window = gtk_widget_get_window (widget);
- style = gtk_widget_get_style (widget);
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
-
- child = gtk_bin_get_child (GTK_BIN (widget));
-
- /* draw a white widget background */
- glade_utils_cairo_draw_rectangle (cr,
- &style->base [gtk_widget_get_state (widget)],
- TRUE,
- border_width,
- border_width,
- width - 2 * border_width,
- height - 2 * border_width);
-
- if (child && gtk_widget_get_visible (child))
- {
- GtkAllocation child_allocation;
-
- gtk_widget_get_allocation (child, &child_allocation);
-
- /* draw frame */
- draw_frame (widget, cr,
- child_allocation.x - OUTLINE_WIDTH,
- child_allocation.y - OUTLINE_WIDTH,
- child_allocation.width + 2 * OUTLINE_WIDTH,
- child_allocation.height + 2 * OUTLINE_WIDTH);
- }
- }
-
- return GTK_WIDGET_CLASS (glade_design_layout_parent_class)->draw (widget, cr);
+ if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
+ {
+ GtkStyle *style;
+ GtkWidget *child;
+ GdkWindow *window;
+ gint border_width;
+ gint width, height;
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ window = gtk_widget_get_window (widget);
+ style = gtk_widget_get_style (widget);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ /* draw a white widget background */
+ glade_utils_cairo_draw_rectangle (cr,
+ &style->
+ base[gtk_widget_get_state (widget)],
+ TRUE, border_width, border_width,
+ width - 2 * border_width,
+ height - 2 * border_width);
+
+ if (child && gtk_widget_get_visible (child))
+ {
+ GtkAllocation child_allocation;
+
+ gtk_widget_get_allocation (child, &child_allocation);
+
+ /* draw frame */
+ draw_frame (widget, cr,
+ child_allocation.x - OUTLINE_WIDTH,
+ child_allocation.y - OUTLINE_WIDTH,
+ child_allocation.width + 2 * OUTLINE_WIDTH,
+ child_allocation.height + 2 * OUTLINE_WIDTH);
+ }
+ }
+
+ return GTK_WIDGET_CLASS (glade_design_layout_parent_class)->draw (widget, cr);
}
-typedef struct {
- GtkWidget *toplevel;
- gint x;
- gint y;
- GtkWidget *placeholder;
- GladeWidget *gwidget;
+typedef struct
+{
+ GtkWidget *toplevel;
+ gint x;
+ gint y;
+ GtkWidget *placeholder;
+ GladeWidget *gwidget;
} GladeFindInContainerData;
static void
-glade_design_layout_find_inside_container (GtkWidget *widget, GladeFindInContainerData *data)
+glade_design_layout_find_inside_container (GtkWidget * widget,
+ GladeFindInContainerData * data)
{
- GtkAllocation allocation;
- gint x;
- gint y;
-
- if (data->gwidget || !gtk_widget_get_mapped (widget))
- return;
-
- gtk_widget_translate_coordinates (data->toplevel, widget, data->x, data->y, &x, &y);
- gtk_widget_get_allocation (widget, &allocation);
-
- if (x >= 0 && x < allocation.width &&
- y >= 0 && y < allocation.height)
- {
- if (GLADE_IS_PLACEHOLDER (widget))
- data->placeholder = widget;
- else
- {
- if (GTK_IS_CONTAINER (widget))
- gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback)
- glade_design_layout_find_inside_container, data);
-
- if (!data->gwidget)
- data->gwidget = glade_widget_get_from_gobject (widget);
- }
- }
+ GtkAllocation allocation;
+ gint x;
+ gint y;
+
+ if (data->gwidget || !gtk_widget_get_mapped (widget))
+ return;
+
+ gtk_widget_translate_coordinates (data->toplevel, widget, data->x, data->y,
+ &x, &y);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (x >= 0 && x < allocation.width && y >= 0 && y < allocation.height)
+ {
+ if (GLADE_IS_PLACEHOLDER (widget))
+ data->placeholder = widget;
+ else
+ {
+ if (GTK_IS_CONTAINER (widget))
+ gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback)
+ glade_design_layout_find_inside_container,
+ data);
+
+ if (!data->gwidget)
+ data->gwidget = glade_widget_get_from_gobject (widget);
+ }
+ }
}
/**
@@ -661,198 +669,194 @@ glade_design_layout_find_inside_container (GtkWidget *widget, GladeFindInContain
* Returns: Whether or not the event was handled by the retrieved #GladeWidget
*/
gboolean
-glade_design_layout_widget_event (GladeDesignLayout *layout,
- GladeWidget *event_gwidget,
- GdkEvent *event)
+glade_design_layout_widget_event (GladeDesignLayout * layout,
+ GladeWidget * event_gwidget, GdkEvent * event)
{
- GladeFindInContainerData data = { 0, };
- gboolean retval;
+ GladeFindInContainerData data = { 0, };
+ gboolean retval;
- data.toplevel = GTK_WIDGET (layout);
- gtk_widget_get_pointer (GTK_WIDGET (layout), &data.x, &data.y);
+ data.toplevel = GTK_WIDGET (layout);
+ gtk_widget_get_pointer (GTK_WIDGET (layout), &data.x, &data.y);
- glade_design_layout_find_inside_container (gtk_bin_get_child (GTK_BIN (layout)), &data);
+ glade_design_layout_find_inside_container (gtk_bin_get_child
+ (GTK_BIN (layout)), &data);
- /* First try a placeholder */
- if (data.placeholder && event->type != GDK_EXPOSE)
- {
- retval = gtk_widget_event (data.placeholder, event);
+ /* First try a placeholder */
+ if (data.placeholder && event->type != GDK_EXPOSE)
+ {
+ retval = gtk_widget_event (data.placeholder, event);
- if (retval)
- return retval;
- }
+ if (retval)
+ return retval;
+ }
- /* Then we try a GladeWidget */
- if (data.gwidget)
- {
- g_signal_emit_by_name (layout, "widget-event",
- data.gwidget, event, &retval);
+ /* Then we try a GladeWidget */
+ if (data.gwidget)
+ {
+ g_signal_emit_by_name (layout, "widget-event",
+ data.gwidget, event, &retval);
- if (retval)
- return retval;
- }
+ if (retval)
+ return retval;
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
-glade_design_layout_widget_event_impl (GladeProject *project,
- GladeWidget *gwidget,
- GdkEvent *event)
+glade_design_layout_widget_event_impl (GladeProject * project,
+ GladeWidget * gwidget, GdkEvent * event)
{
- if (glade_widget_event (gwidget, event))
- return GLADE_WIDGET_EVENT_STOP_EMISSION |
- GLADE_WIDGET_EVENT_RETURN_TRUE;
- else
- return 0;
+ if (glade_widget_event (gwidget, event))
+ return GLADE_WIDGET_EVENT_STOP_EMISSION | GLADE_WIDGET_EVENT_RETURN_TRUE;
+ else
+ return 0;
}
static void
-glade_design_layout_realize (GtkWidget *widget)
+glade_design_layout_realize (GtkWidget * widget)
{
- GladeDesignLayoutPrivate *priv;
- GtkAllocation allocation;
- GtkStyle *style;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.event_mask =
- gtk_widget_get_events (widget) |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK;
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gtk_widget_get_parent_window (widget);
- gtk_widget_set_window (widget, g_object_ref (window));
-
- priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (priv->event_window, widget);
-
- gtk_widget_style_attach (widget);
- style = gtk_widget_get_style (widget);
- gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+ GladeDesignLayoutPrivate *priv;
+ GtkAllocation allocation;
+ GtkStyle *style;
+ GdkWindow *window;
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.wclass = GDK_INPUT_ONLY;
+ attributes.event_mask =
+ gtk_widget_get_events (widget) |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, g_object_ref (window));
+
+ priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (priv->event_window, widget);
+
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, window, GTK_STATE_NORMAL);
}
static void
-glade_design_layout_unrealize (GtkWidget *widget)
+glade_design_layout_unrealize (GtkWidget * widget)
{
- GladeDesignLayoutPrivate *priv;
+ GladeDesignLayoutPrivate *priv;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- if (priv->event_window)
- {
- gdk_window_set_user_data (priv->event_window, NULL);
- gdk_window_destroy (priv->event_window);
- priv->event_window = NULL;
- }
+ if (priv->event_window)
+ {
+ gdk_window_set_user_data (priv->event_window, NULL);
+ gdk_window_destroy (priv->event_window);
+ priv->event_window = NULL;
+ }
- GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unrealize (widget);
+ GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unrealize (widget);
}
static void
-glade_design_layout_map (GtkWidget *widget)
+glade_design_layout_map (GtkWidget * widget)
{
- GladeDesignLayoutPrivate *priv;
+ GladeDesignLayoutPrivate *priv;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- if (priv->event_window)
- gdk_window_show (priv->event_window);
+ if (priv->event_window)
+ gdk_window_show (priv->event_window);
- GTK_WIDGET_CLASS (glade_design_layout_parent_class)->map (widget);
+ GTK_WIDGET_CLASS (glade_design_layout_parent_class)->map (widget);
}
static void
-glade_design_layout_unmap (GtkWidget *widget)
+glade_design_layout_unmap (GtkWidget * widget)
{
- GladeDesignLayoutPrivate *priv;
+ GladeDesignLayoutPrivate *priv;
- priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+ priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
- GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unmap (widget);
+ GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unmap (widget);
- if (priv->event_window)
- gdk_window_hide (priv->event_window);
+ if (priv->event_window)
+ gdk_window_hide (priv->event_window);
}
static void
-glade_design_layout_init (GladeDesignLayout *layout)
+glade_design_layout_init (GladeDesignLayout * layout)
{
- GladeDesignLayoutPrivate *priv;
+ GladeDesignLayoutPrivate *priv;
- layout->priv = priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
+ layout->priv = priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
- priv->activity = ACTIVITY_NONE;
+ priv->activity = ACTIVITY_NONE;
- priv->current_size_request = g_slice_new0 (GtkRequisition);
+ priv->current_size_request = g_slice_new0 (GtkRequisition);
- priv->cursor_resize_bottom = gdk_cursor_new (GDK_BOTTOM_SIDE);
- priv->cursor_resize_right = gdk_cursor_new (GDK_RIGHT_SIDE);
- priv->cursor_resize_bottom_right = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
+ priv->cursor_resize_bottom = gdk_cursor_new (GDK_BOTTOM_SIDE);
+ priv->cursor_resize_right = gdk_cursor_new (GDK_RIGHT_SIDE);
+ priv->cursor_resize_bottom_right = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
- priv->new_width = -1;
- priv->new_height = -1;
+ priv->new_width = -1;
+ priv->new_height = -1;
- gtk_widget_set_has_window (GTK_WIDGET (layout), FALSE);
+ gtk_widget_set_has_window (GTK_WIDGET (layout), FALSE);
}
static void
-glade_design_layout_class_init (GladeDesignLayoutClass *klass)
+glade_design_layout_class_init (GladeDesignLayoutClass * klass)
{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
-
- object_class->dispose = glade_design_layout_dispose;
- object_class->finalize = glade_design_layout_finalize;
-
- container_class->add = glade_design_layout_add;
- container_class->remove = glade_design_layout_remove;
-
- widget_class->map = glade_design_layout_map;
- widget_class->unmap = glade_design_layout_unmap;
- widget_class->realize = glade_design_layout_realize;
- widget_class->unrealize = glade_design_layout_unrealize;
- widget_class->motion_notify_event = glade_design_layout_motion_notify_event;
- widget_class->leave_notify_event = glade_design_layout_leave_notify_event;
- widget_class->button_press_event = glade_design_layout_button_press_event;
- widget_class->button_release_event = glade_design_layout_button_release_event;
- widget_class->draw = glade_design_layout_draw;
- widget_class->get_preferred_height = glade_design_layout_get_preferred_height;
- widget_class->get_preferred_width = glade_design_layout_get_preferred_width;
- widget_class->size_allocate = glade_design_layout_size_allocate;
-
- klass->widget_event = glade_design_layout_widget_event_impl;
-
-
- /**
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+ container_class = GTK_CONTAINER_CLASS (klass);
+
+ object_class->dispose = glade_design_layout_dispose;
+ object_class->finalize = glade_design_layout_finalize;
+
+ container_class->add = glade_design_layout_add;
+ container_class->remove = glade_design_layout_remove;
+
+ widget_class->map = glade_design_layout_map;
+ widget_class->unmap = glade_design_layout_unmap;
+ widget_class->realize = glade_design_layout_realize;
+ widget_class->unrealize = glade_design_layout_unrealize;
+ widget_class->motion_notify_event = glade_design_layout_motion_notify_event;
+ widget_class->leave_notify_event = glade_design_layout_leave_notify_event;
+ widget_class->button_press_event = glade_design_layout_button_press_event;
+ widget_class->button_release_event = glade_design_layout_button_release_event;
+ widget_class->draw = glade_design_layout_draw;
+ widget_class->get_preferred_height = glade_design_layout_get_preferred_height;
+ widget_class->get_preferred_width = glade_design_layout_get_preferred_width;
+ widget_class->size_allocate = glade_design_layout_size_allocate;
+
+ klass->widget_event = glade_design_layout_widget_event_impl;
+
+
+ /**
* GladeDesignLayout::widget-event:
* @glade_design_layout: the #GladeDesignLayout containing the #GladeWidget.
* @signal_editor: the #GladeWidget which received the signal.
@@ -868,24 +872,23 @@ glade_design_layout_class_init (GladeDesignLayoutClass *klass)
* #GLADE_WIDGET_EVENT_RETURN_TRUE flag in the last handler
* to stop propagating of the event to the appropriate widget.
*/
- glade_design_layout_signals[WIDGET_EVENT] =
- g_signal_new ("widget-event",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeDesignLayoutClass, widget_event),
- glade_integer_handled_accumulator, NULL,
- glade_marshal_INT__OBJECT_BOXED,
- G_TYPE_INT,
- 2,
- GLADE_TYPE_WIDGET,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- g_type_class_add_private (object_class, sizeof (GladeDesignLayoutPrivate));
+ glade_design_layout_signals[WIDGET_EVENT] =
+ g_signal_new ("widget-event",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeDesignLayoutClass, widget_event),
+ glade_integer_handled_accumulator, NULL,
+ glade_marshal_INT__OBJECT_BOXED,
+ G_TYPE_INT,
+ 2,
+ GLADE_TYPE_WIDGET,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ g_type_class_add_private (object_class, sizeof (GladeDesignLayoutPrivate));
}
-GtkWidget*
+GtkWidget *
glade_design_layout_new (void)
{
- return g_object_new (GLADE_TYPE_DESIGN_LAYOUT, NULL);
+ return g_object_new (GLADE_TYPE_DESIGN_LAYOUT, NULL);
}
-
diff --git a/gladeui/glade-design-view.c b/gladeui/glade-design-view.c
index e75b51f..e291ad1 100644
--- a/gladeui/glade-design-view.c
+++ b/gladeui/glade-design-view.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-design-view.c
*
@@ -31,7 +30,7 @@
* Use this widget to embed the currently active #GtkWindow
* in a given #GladeProject.
*/
-
+
#include "config.h"
#include "glade.h"
@@ -48,223 +47,235 @@
enum
{
- PROP_0,
- PROP_PROJECT,
+ PROP_0,
+ PROP_PROJECT,
};
struct _GladeDesignViewPrivate
{
- GtkWidget *layout;
+ GtkWidget *layout;
- GladeProject *project;
+ GladeProject *project;
- GtkWidget *scrolled_window;
+ GtkWidget *scrolled_window;
- GtkWidget *progress;
- GtkWidget *progress_window;
+ GtkWidget *progress;
+ GtkWidget *progress_window;
};
static GtkVBoxClass *parent_class = NULL;
-G_DEFINE_TYPE(GladeDesignView, glade_design_view, GTK_TYPE_VBOX)
-
-
-static void
-glade_design_view_parse_began (GladeProject *project,
- GladeDesignView *view)
+G_DEFINE_TYPE (GladeDesignView, glade_design_view, GTK_TYPE_VBOX)
+ static void
+ glade_design_view_parse_began (GladeProject * project,
+ GladeDesignView * view)
{
- gtk_widget_hide (view->priv->scrolled_window);
- gtk_widget_show (view->priv->progress_window);
+ gtk_widget_hide (view->priv->scrolled_window);
+ gtk_widget_show (view->priv->progress_window);
}
static void
-glade_design_view_parse_finished (GladeProject *project,
- GladeDesignView *view)
+glade_design_view_parse_finished (GladeProject * project,
+ GladeDesignView * view)
{
- gtk_widget_hide (view->priv->progress_window);
- gtk_widget_show (view->priv->scrolled_window);
+ gtk_widget_hide (view->priv->progress_window);
+ gtk_widget_show (view->priv->scrolled_window);
}
static void
-glade_design_view_load_progress (GladeProject *project,
- gint total,
- gint step,
- GladeDesignView *view)
+glade_design_view_load_progress (GladeProject * project,
+ gint total, gint step, GladeDesignView * view)
{
- gchar *path;
- gchar *str;
-
- path = glade_utils_replace_home_dir_with_tilde (glade_project_get_path (project));
- str = g_strdup_printf (_("Loading %s: loaded %d of %d objects"), path, step, total);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (view->priv->progress), str);
- g_free (str);
- g_free (path);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (view->priv->progress), step * 1.0 / total);
+ gchar *path;
+ gchar *str;
+
+ path =
+ glade_utils_replace_home_dir_with_tilde (glade_project_get_path
+ (project));
+ str =
+ g_strdup_printf (_("Loading %s: loaded %d of %d objects"), path, step,
+ total);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (view->priv->progress), str);
+ g_free (str);
+ g_free (path);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (view->priv->progress),
+ step * 1.0 / total);
}
static void
-glade_design_view_set_project (GladeDesignView *view, GladeProject *project)
+glade_design_view_set_project (GladeDesignView * view, GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- view->priv->project = project;
+ view->priv->project = project;
- g_signal_connect (project, "parse-began", G_CALLBACK (glade_design_view_parse_began), view);
- g_signal_connect (project, "parse-finished", G_CALLBACK (glade_design_view_parse_finished), view);
- g_signal_connect (project, "load-progress", G_CALLBACK (glade_design_view_load_progress), view);
+ g_signal_connect (project, "parse-began",
+ G_CALLBACK (glade_design_view_parse_began), view);
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (glade_design_view_parse_finished), view);
+ g_signal_connect (project, "load-progress",
+ G_CALLBACK (glade_design_view_load_progress), view);
- g_object_set_data (G_OBJECT (view->priv->project), GLADE_DESIGN_VIEW_KEY, view);
+ g_object_set_data (G_OBJECT (view->priv->project), GLADE_DESIGN_VIEW_KEY,
+ view);
}
-static void
-glade_design_view_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+static void
+glade_design_view_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- switch (prop_id)
- {
- case PROP_PROJECT:
- glade_design_view_set_project (GLADE_DESIGN_VIEW (object), g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id)
+ {
+ case PROP_PROJECT:
+ glade_design_view_set_project (GLADE_DESIGN_VIEW (object),
+ g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-glade_design_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_design_view_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- switch (prop_id)
- {
- case PROP_PROJECT:
- g_value_set_object (value, GLADE_DESIGN_VIEW (object)->priv->project);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_PROJECT:
+ g_value_set_object (value, GLADE_DESIGN_VIEW (object)->priv->project);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_design_view_init (GladeDesignView *view)
+glade_design_view_init (GladeDesignView * view)
{
- GtkWidget *viewport, *filler, *align;
-
- view->priv = GLADE_DESIGN_VIEW_GET_PRIVATE (view);
-
- view->priv->project = NULL;
- view->priv->layout = glade_design_layout_new ();
-
- view->priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->priv->scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->priv->scrolled_window),
- GTK_SHADOW_IN);
-
- viewport = gtk_viewport_new (NULL, NULL);
- gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
- gtk_container_add (GTK_CONTAINER (viewport), view->priv->layout);
- gtk_container_add (GTK_CONTAINER (view->priv->scrolled_window), viewport);
-
- gtk_widget_show (view->priv->scrolled_window);
- gtk_widget_show (viewport);
- gtk_widget_show (view->priv->layout);
-
- gtk_box_pack_start (GTK_BOX (view), view->priv->scrolled_window, TRUE, TRUE, 0);
-
- /* The progress window */
- view->priv->progress_window = gtk_vbox_new (FALSE, 0);
- filler = gtk_label_new (NULL);
- gtk_widget_show (filler);
- gtk_box_pack_start (GTK_BOX (view->priv->progress_window), filler, TRUE, TRUE, 0);
-
- align = gtk_alignment_new (0.5, 0.5, 0.75, 1.0);
- gtk_widget_show (align);
- gtk_box_pack_start (GTK_BOX (view->priv->progress_window), align, FALSE, TRUE, 0);
-
- view->priv->progress = gtk_progress_bar_new ();
- gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (view->priv->progress), TRUE);
- gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (view->priv->progress), PANGO_ELLIPSIZE_END);
- gtk_widget_show (view->priv->progress);
- gtk_container_add (GTK_CONTAINER (align), view->priv->progress);
-
- filler = gtk_label_new (NULL);
- gtk_widget_show (filler);
- gtk_box_pack_start (GTK_BOX (view->priv->progress_window), filler, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (view), view->priv->progress_window, TRUE, TRUE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (view), 0);
+ GtkWidget *viewport, *filler, *align;
+
+ view->priv = GLADE_DESIGN_VIEW_GET_PRIVATE (view);
+
+ view->priv->project = NULL;
+ view->priv->layout = glade_design_layout_new ();
+
+ view->priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
+ (view->priv->scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
+ (view->priv->scrolled_window),
+ GTK_SHADOW_IN);
+
+ viewport = gtk_viewport_new (NULL, NULL);
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
+ gtk_container_add (GTK_CONTAINER (viewport), view->priv->layout);
+ gtk_container_add (GTK_CONTAINER (view->priv->scrolled_window), viewport);
+
+ gtk_widget_show (view->priv->scrolled_window);
+ gtk_widget_show (viewport);
+ gtk_widget_show (view->priv->layout);
+
+ gtk_box_pack_start (GTK_BOX (view), view->priv->scrolled_window, TRUE, TRUE,
+ 0);
+
+ /* The progress window */
+ view->priv->progress_window = gtk_vbox_new (FALSE, 0);
+ filler = gtk_label_new (NULL);
+ gtk_widget_show (filler);
+ gtk_box_pack_start (GTK_BOX (view->priv->progress_window), filler, TRUE, TRUE,
+ 0);
+
+ align = gtk_alignment_new (0.5, 0.5, 0.75, 1.0);
+ gtk_widget_show (align);
+ gtk_box_pack_start (GTK_BOX (view->priv->progress_window), align, FALSE, TRUE,
+ 0);
+
+ view->priv->progress = gtk_progress_bar_new ();
+ gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (view->priv->progress),
+ TRUE);
+ gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (view->priv->progress),
+ PANGO_ELLIPSIZE_END);
+ gtk_widget_show (view->priv->progress);
+ gtk_container_add (GTK_CONTAINER (align), view->priv->progress);
+
+ filler = gtk_label_new (NULL);
+ gtk_widget_show (filler);
+ gtk_box_pack_start (GTK_BOX (view->priv->progress_window), filler, TRUE, TRUE,
+ 0);
+ gtk_box_pack_start (GTK_BOX (view), view->priv->progress_window, TRUE, TRUE,
+ 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (view), 0);
}
static void
-glade_design_view_class_init (GladeDesignViewClass *klass)
+glade_design_view_class_init (GladeDesignViewClass * klass)
{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- parent_class = g_type_class_peek_parent (klass);
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->get_property = glade_design_view_get_property;
- object_class->set_property = glade_design_view_set_property;
-
- g_object_class_install_property (object_class,
- PROP_PROJECT,
- g_param_spec_object ("project",
- "Project",
- "The project for this view",
- GLADE_TYPE_PROJECT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_type_class_add_private (object_class, sizeof (GladeDesignViewPrivate));
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ parent_class = g_type_class_peek_parent (klass);
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->get_property = glade_design_view_get_property;
+ object_class->set_property = glade_design_view_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_PROJECT,
+ g_param_spec_object ("project",
+ "Project",
+ "The project for this view",
+ GLADE_TYPE_PROJECT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (object_class, sizeof (GladeDesignViewPrivate));
}
-GladeProject*
-glade_design_view_get_project (GladeDesignView *view)
+GladeProject *
+glade_design_view_get_project (GladeDesignView * view)
{
- g_return_val_if_fail (GLADE_IS_DESIGN_VIEW (view), NULL);
-
- return view->priv->project;
+ g_return_val_if_fail (GLADE_IS_DESIGN_VIEW (view), NULL);
+
+ return view->priv->project;
}
GtkWidget *
-glade_design_view_new (GladeProject *project)
+glade_design_view_new (GladeProject * project)
{
- GladeDesignView *view;
+ GladeDesignView *view;
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- view = g_object_new (GLADE_TYPE_DESIGN_VIEW,
- "project", project,
- NULL);
+ view = g_object_new (GLADE_TYPE_DESIGN_VIEW, "project", project, NULL);
- return GTK_WIDGET (view);
+ return GTK_WIDGET (view);
}
GladeDesignView *
-glade_design_view_get_from_project (GladeProject *project)
+glade_design_view_get_from_project (GladeProject * project)
{
- gpointer p;
-
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
-
- p = g_object_get_data (G_OBJECT (project), GLADE_DESIGN_VIEW_KEY);
-
- return (p != NULL) ? GLADE_DESIGN_VIEW (p) : NULL;
+ gpointer p;
+
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+
+ p = g_object_get_data (G_OBJECT (project), GLADE_DESIGN_VIEW_KEY);
+
+ return (p != NULL) ? GLADE_DESIGN_VIEW (p) : NULL;
}
GladeDesignLayout *
-glade_design_view_get_layout (GladeDesignView *view)
+glade_design_view_get_layout (GladeDesignView * view)
{
- return GLADE_DESIGN_LAYOUT (view->priv->layout);
+ return GLADE_DESIGN_LAYOUT (view->priv->layout);
}
diff --git a/gladeui/glade-displayable-values.c b/gladeui/glade-displayable-values.c
index fe6de98..4f9046b 100644
--- a/gladeui/glade-displayable-values.c
+++ b/gladeui/glade-displayable-values.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-name-context.c
*
@@ -34,151 +33,152 @@
#include "glade-displayable-values.h"
-typedef struct {
- gchar *value;
- gchar *string;
+typedef struct
+{
+ gchar *value;
+ gchar *string;
} ValueTab;
static GHashTable *values_hash = NULL;
static gint
-find_by_value (ValueTab *a, const gchar *b)
+find_by_value (ValueTab * a, const gchar * b)
{
- return strcmp (a->value, b);
+ return strcmp (a->value, b);
}
static gint
-find_by_displayable (ValueTab *a, const gchar *b)
+find_by_displayable (ValueTab * a, const gchar * b)
{
- return strcmp (a->string, b);
+ return strcmp (a->string, b);
}
void
-glade_register_displayable_value (GType type,
- const gchar *value,
- const gchar *domain,
- const gchar *string)
+glade_register_displayable_value (GType type,
+ const gchar * value,
+ const gchar * domain, const gchar * string)
{
- g_return_if_fail (value && value[0]);
- g_return_if_fail (domain && domain[0]);
- g_return_if_fail (string && string[0]);
+ g_return_if_fail (value && value[0]);
+ g_return_if_fail (domain && domain[0]);
+ g_return_if_fail (string && string[0]);
- glade_register_translated_value (type, value, dgettext (domain, string));
+ glade_register_translated_value (type, value, dgettext (domain, string));
}
void
-glade_register_translated_value (GType type,
- const gchar *value,
- const gchar *string)
+glade_register_translated_value (GType type,
+ const gchar * value, const gchar * string)
{
- ValueTab *tab;
- gpointer klass;
- GList *values;
-
- g_return_if_fail (value && value[0]);
- g_return_if_fail (string && string[0]);
- klass = g_type_class_ref (type);
- g_return_if_fail (klass != NULL);
-
- if (!values_hash)
- values_hash = g_hash_table_new (NULL, NULL);
-
- tab = g_new0 (ValueTab, 1);
- tab->value = g_strdup (value);
- tab->string = g_strdup (string);
-
- if ((values =
- g_hash_table_lookup (values_hash, klass)) != NULL)
- {
- if (!g_list_find_custom (values, tab->value, (GCompareFunc)find_by_value))
- values = g_list_append (values, tab);
- else
- {
- g_warning ("Already registered displayable value %s for %s (type %s)",
- tab->string, tab->value, g_type_name (type));
- g_free (tab->string);
- g_free (tab->value);
- g_free (tab);
- }
- }
- else
- {
- values = g_list_append (NULL, tab);
- g_hash_table_insert (values_hash, klass, values);
- }
- g_type_class_unref (klass);
+ ValueTab *tab;
+ gpointer klass;
+ GList *values;
+
+ g_return_if_fail (value && value[0]);
+ g_return_if_fail (string && string[0]);
+ klass = g_type_class_ref (type);
+ g_return_if_fail (klass != NULL);
+
+ if (!values_hash)
+ values_hash = g_hash_table_new (NULL, NULL);
+
+ tab = g_new0 (ValueTab, 1);
+ tab->value = g_strdup (value);
+ tab->string = g_strdup (string);
+
+ if ((values = g_hash_table_lookup (values_hash, klass)) != NULL)
+ {
+ if (!g_list_find_custom
+ (values, tab->value, (GCompareFunc) find_by_value))
+ values = g_list_append (values, tab);
+ else
+ {
+ g_warning ("Already registered displayable value %s for %s (type %s)",
+ tab->string, tab->value, g_type_name (type));
+ g_free (tab->string);
+ g_free (tab->value);
+ g_free (tab);
+ }
+ }
+ else
+ {
+ values = g_list_append (NULL, tab);
+ g_hash_table_insert (values_hash, klass, values);
+ }
+ g_type_class_unref (klass);
}
gboolean
glade_type_has_displayable_values (GType type)
{
- gboolean has;
- gpointer klass = g_type_class_ref (type);
+ gboolean has;
+ gpointer klass = g_type_class_ref (type);
- has = values_hash && g_hash_table_lookup (values_hash, klass) != NULL;
+ has = values_hash && g_hash_table_lookup (values_hash, klass) != NULL;
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
- return has;
+ return has;
}
G_CONST_RETURN gchar *
-glade_get_displayable_value (GType type,
- const gchar *value)
+glade_get_displayable_value (GType type, const gchar * value)
{
- ValueTab *tab;
- gpointer klass;
- GList *values, *tab_iter;
- gchar *displayable = NULL;
+ ValueTab *tab;
+ gpointer klass;
+ GList *values, *tab_iter;
+ gchar *displayable = NULL;
- g_return_val_if_fail (value && value[0], NULL);
+ g_return_val_if_fail (value && value[0], NULL);
- if (!values_hash)
- return NULL;
+ if (!values_hash)
+ return NULL;
- klass = g_type_class_ref (type);
+ klass = g_type_class_ref (type);
- g_return_val_if_fail (klass != NULL, NULL);
+ g_return_val_if_fail (klass != NULL, NULL);
- if ((values = g_hash_table_lookup (values_hash, klass)) != NULL &&
- (tab_iter = g_list_find_custom (values, value, (GCompareFunc)find_by_value)) != NULL)
- {
- tab = tab_iter->data;
- displayable = tab->string;
- }
- g_type_class_unref (klass);
+ if ((values = g_hash_table_lookup (values_hash, klass)) != NULL &&
+ (tab_iter =
+ g_list_find_custom (values, value,
+ (GCompareFunc) find_by_value)) != NULL)
+ {
+ tab = tab_iter->data;
+ displayable = tab->string;
+ }
+ g_type_class_unref (klass);
- return displayable;
+ return displayable;
}
G_CONST_RETURN gchar *
-glade_get_value_from_displayable (GType type,
- const gchar *displayable)
+glade_get_value_from_displayable (GType type, const gchar * displayable)
{
- ValueTab *tab;
- gpointer klass;
- GList *values, *tab_iter;
- gchar *value = NULL;
+ ValueTab *tab;
+ gpointer klass;
+ GList *values, *tab_iter;
+ gchar *value = NULL;
+
+ g_return_val_if_fail (displayable && displayable[0], NULL);
- g_return_val_if_fail (displayable && displayable[0], NULL);
+ if (!values_hash)
+ return NULL;
- if (!values_hash)
- return NULL;
-
- klass = g_type_class_ref (type);
+ klass = g_type_class_ref (type);
- g_return_val_if_fail (klass != NULL, NULL);
+ g_return_val_if_fail (klass != NULL, NULL);
- if ((values = g_hash_table_lookup (values_hash, klass)) != NULL &&
- (tab_iter = g_list_find_custom (values, displayable, (GCompareFunc)find_by_displayable)) != NULL)
- {
- tab = tab_iter->data;
- value = tab->value;
- }
- g_type_class_unref (klass);
+ if ((values = g_hash_table_lookup (values_hash, klass)) != NULL &&
+ (tab_iter =
+ g_list_find_custom (values, displayable,
+ (GCompareFunc) find_by_displayable)) != NULL)
+ {
+ tab = tab_iter->data;
+ value = tab->value;
+ }
+ g_type_class_unref (klass);
- return value;
+ return value;
}
diff --git a/gladeui/glade-displayable-values.h b/gladeui/glade-displayable-values.h
index e521bc9..13ad4f0 100644
--- a/gladeui/glade-displayable-values.h
+++ b/gladeui/glade-displayable-values.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_DISAPLAYABLE_VALUES_H__
#define __GLADE_DISAPLAYABLE_VALUES_H__
diff --git a/gladeui/glade-editable.c b/gladeui/glade-editable.c
index fbdf6fb..62c81a2 100644
--- a/gladeui/glade-editable.c
+++ b/gladeui/glade-editable.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-editable.c
*
@@ -38,8 +37,8 @@
static void
glade_editable_class_init (gpointer g_iface)
-{
- /* */
+{
+ /* */
}
GType
@@ -49,10 +48,11 @@ glade_editable_get_type (void)
if (!editable_type)
editable_type =
- g_type_register_static_simple (G_TYPE_INTERFACE, "GladeEditable",
- sizeof (GladeEditableIface),
- (GClassInitFunc) glade_editable_class_init,
- 0, NULL, (GTypeFlags)0);
+ g_type_register_static_simple (G_TYPE_INTERFACE, "GladeEditable",
+ sizeof (GladeEditableIface),
+ (GClassInitFunc)
+ glade_editable_class_init, 0, NULL,
+ (GTypeFlags) 0);
return editable_type;
}
@@ -67,20 +67,19 @@ glade_editable_get_type (void)
* until its loaded with another widget or %NULL)
*/
void
-glade_editable_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_editable_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeEditableIface *iface;
- g_return_if_fail (GLADE_IS_EDITABLE (editable));
- g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
+ GladeEditableIface *iface;
+ g_return_if_fail (GLADE_IS_EDITABLE (editable));
+ g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
- iface = GLADE_EDITABLE_GET_IFACE (editable);
+ iface = GLADE_EDITABLE_GET_IFACE (editable);
- if (iface->load)
- iface->load (editable, widget);
- else
- g_critical ("No GladeEditable::load() support on type %s",
- G_OBJECT_TYPE_NAME (editable));
+ if (iface->load)
+ iface->load (editable, widget);
+ else
+ g_critical ("No GladeEditable::load() support on type %s",
+ G_OBJECT_TYPE_NAME (editable));
}
@@ -95,15 +94,13 @@ glade_editable_load (GladeEditable *editable,
* to its embedded editable.
*/
void
-glade_editable_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_editable_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeEditableIface *iface;
- g_return_if_fail (GLADE_IS_EDITABLE (editable));
+ GladeEditableIface *iface;
+ g_return_if_fail (GLADE_IS_EDITABLE (editable));
- iface = GLADE_EDITABLE_GET_IFACE (editable);
+ iface = GLADE_EDITABLE_GET_IFACE (editable);
- if (iface->set_show_name)
- iface->set_show_name (editable, show_name);
+ if (iface->set_show_name)
+ iface->set_show_name (editable, show_name);
}
-
diff --git a/gladeui/glade-editable.h b/gladeui/glade-editable.h
index 77ce45f..385290c 100644
--- a/gladeui/glade-editable.h
+++ b/gladeui/glade-editable.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_EDITABLE_H__
#define __GLADE_EDITABLE_H__
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index f9334a7..8eeff62 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -51,22 +50,24 @@
#include "glade-displayable-values.h"
#include "glade-named-icon-chooser-dialog.h"
-enum {
- PROP_0,
- PROP_PROPERTY_CLASS,
- PROP_USE_COMMAND
+enum
+{
+ PROP_0,
+ PROP_PROPERTY_CLASS,
+ PROP_USE_COMMAND
};
-enum {
- CHANGED,
- COMMIT,
- LAST_SIGNAL
+enum
+{
+ CHANGED,
+ COMMIT,
+ LAST_SIGNAL
};
-static GtkTableClass *table_class;
-static GladeEditorPropertyClass *editor_property_class;
+static GtkTableClass *table_class;
+static GladeEditorPropertyClass *editor_property_class;
-static guint glade_eprop_signals[LAST_SIGNAL] = { 0, };
+static guint glade_eprop_signals[LAST_SIGNAL] = { 0, };
#define GLADE_PROPERTY_TABLE_ROW_SPACING 2
#define FLAGS_COLUMN_SETTING 0
@@ -78,456 +79,447 @@ static guint glade_eprop_signals[LAST_SIGNAL] = { 0, };
*******************************************************************************/
/* declare this forwardly for the finalize routine */
-static void glade_editor_property_load_common (GladeEditorProperty *eprop,
- GladeProperty *property);
+static void glade_editor_property_load_common (GladeEditorProperty * eprop,
+ GladeProperty * property);
static void
-glade_editor_property_commit_common (GladeEditorProperty *eprop,
- GValue *value)
-{
- if (eprop->use_command == FALSE)
- glade_property_set_value (eprop->property, value);
- else
- glade_command_set_property_value (eprop->property, value);
-
- /* If the value was denied by a verify function, we'll have to
- * reload the real value.
- */
- if (glade_property_class_compare (eprop->property->klass,
- eprop->property->value, value) != 0)
- GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->load (eprop, eprop->property);
- else
- /* publish a value change to those interested */
- g_signal_emit (G_OBJECT (eprop), glade_eprop_signals[CHANGED], 0, eprop->property);
+glade_editor_property_commit_common (GladeEditorProperty * eprop,
+ GValue * value)
+{
+ if (eprop->use_command == FALSE)
+ glade_property_set_value (eprop->property, value);
+ else
+ glade_command_set_property_value (eprop->property, value);
+
+ /* If the value was denied by a verify function, we'll have to
+ * reload the real value.
+ */
+ if (glade_property_class_compare (eprop->property->klass,
+ eprop->property->value, value) != 0)
+ GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->load (eprop, eprop->property);
+ else
+ /* publish a value change to those interested */
+ g_signal_emit (G_OBJECT (eprop), glade_eprop_signals[CHANGED], 0,
+ eprop->property);
}
void
-glade_editor_property_commit_no_callback (GladeEditorProperty *eprop,
- GValue *value)
+glade_editor_property_commit_no_callback (GladeEditorProperty * eprop,
+ GValue * value)
{
- g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
+ g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
- g_signal_handler_block (G_OBJECT (eprop->property), eprop->changed_id);
- eprop->committing = TRUE;
- glade_editor_property_commit (eprop, value);
- eprop->committing = FALSE;
- g_signal_handler_unblock (G_OBJECT (eprop->property), eprop->changed_id);
+ g_signal_handler_block (G_OBJECT (eprop->property), eprop->changed_id);
+ eprop->committing = TRUE;
+ glade_editor_property_commit (eprop, value);
+ eprop->committing = FALSE;
+ g_signal_handler_unblock (G_OBJECT (eprop->property), eprop->changed_id);
}
static void
-glade_editor_property_tooltip_cb (GladeProperty *property,
- const gchar *tooltip,
- const gchar *insensitive,
- const gchar *support,
- GladeEditorProperty *eprop)
+glade_editor_property_tooltip_cb (GladeProperty * property,
+ const gchar * tooltip,
+ const gchar * insensitive,
+ const gchar * support,
+ GladeEditorProperty * eprop)
{
- const gchar *choice_tooltip;
+ const gchar *choice_tooltip;
- if (glade_property_get_sensitive (property))
- choice_tooltip = tooltip;
- else
- choice_tooltip = insensitive;
+ if (glade_property_get_sensitive (property))
+ choice_tooltip = tooltip;
+ else
+ choice_tooltip = insensitive;
- gtk_widget_set_tooltip_text (eprop->input, choice_tooltip);
- gtk_widget_set_tooltip_text (eprop->label, choice_tooltip);
- gtk_widget_set_tooltip_text (eprop->warning, support);
+ gtk_widget_set_tooltip_text (eprop->input, choice_tooltip);
+ gtk_widget_set_tooltip_text (eprop->label, choice_tooltip);
+ gtk_widget_set_tooltip_text (eprop->warning, support);
}
static void
-glade_editor_property_sensitivity_cb (GladeProperty *property,
- GParamSpec *pspec,
- GladeEditorProperty *eprop)
+glade_editor_property_sensitivity_cb (GladeProperty * property,
+ GParamSpec * pspec,
+ GladeEditorProperty * eprop)
{
- gboolean sensitive = glade_property_get_sensitive (eprop->property);
- gboolean support_sensitive = (eprop->property->state & GLADE_STATE_SUPPORT_DISABLED) == 0;
+ gboolean sensitive = glade_property_get_sensitive (eprop->property);
+ gboolean support_sensitive =
+ (eprop->property->state & GLADE_STATE_SUPPORT_DISABLED) == 0;
- gtk_widget_set_sensitive (eprop->input, sensitive && support_sensitive &&
- glade_property_get_enabled (property));
- if (eprop->check)
- gtk_widget_set_sensitive (eprop->check, sensitive && support_sensitive);
+ gtk_widget_set_sensitive (eprop->input, sensitive && support_sensitive &&
+ glade_property_get_enabled (property));
+ if (eprop->check)
+ gtk_widget_set_sensitive (eprop->check, sensitive && support_sensitive);
}
static void
-glade_editor_property_value_changed_cb (GladeProperty *property,
- GValue *old_value,
- GValue *value,
- GladeEditorProperty *eprop)
+glade_editor_property_value_changed_cb (GladeProperty * property,
+ GValue * old_value,
+ GValue * value,
+ GladeEditorProperty * eprop)
{
- g_assert (eprop->property == property);
- glade_editor_property_load (eprop, eprop->property);
+ g_assert (eprop->property == property);
+ glade_editor_property_load (eprop, eprop->property);
}
static void
-glade_editor_property_fix_label (GladeEditorProperty *eprop)
+glade_editor_property_fix_label (GladeEditorProperty * eprop)
{
- gchar *text = NULL;
+ gchar *text = NULL;
- if (!eprop->property)
- return;
+ if (!eprop->property)
+ return;
- /* refresh label */
- if ((eprop->property->state & GLADE_STATE_CHANGED) != 0)
- text = g_strdup_printf ("<b>%s:</b>", eprop->klass->name);
- else
- text = g_strdup_printf ("%s:", eprop->klass->name);
- gtk_label_set_markup (GTK_LABEL (eprop->label), text);
- g_free (text);
+ /* refresh label */
+ if ((eprop->property->state & GLADE_STATE_CHANGED) != 0)
+ text = g_strdup_printf ("<b>%s:</b>", eprop->klass->name);
+ else
+ text = g_strdup_printf ("%s:", eprop->klass->name);
+ gtk_label_set_markup (GTK_LABEL (eprop->label), text);
+ g_free (text);
- /* refresh icon */
- if ((eprop->property->state & GLADE_STATE_UNSUPPORTED) != 0)
- gtk_widget_show (eprop->warning);
- else
- gtk_widget_hide (eprop->warning);
+ /* refresh icon */
+ if ((eprop->property->state & GLADE_STATE_UNSUPPORTED) != 0)
+ gtk_widget_show (eprop->warning);
+ else
+ gtk_widget_hide (eprop->warning);
- /* check sensitivity */
- glade_editor_property_sensitivity_cb (eprop->property, NULL, eprop);
+ /* check sensitivity */
+ glade_editor_property_sensitivity_cb (eprop->property, NULL, eprop);
}
static void
-glade_editor_property_state_cb (GladeProperty *property,
- GParamSpec *pspec,
- GladeEditorProperty *eprop)
+glade_editor_property_state_cb (GladeProperty * property,
+ GParamSpec * pspec, GladeEditorProperty * eprop)
{
- glade_editor_property_fix_label (eprop);
+ glade_editor_property_fix_label (eprop);
}
static void
-glade_editor_property_enabled_cb (GladeProperty *property,
- GParamSpec *pspec,
- GladeEditorProperty *eprop)
+glade_editor_property_enabled_cb (GladeProperty * property,
+ GParamSpec * pspec,
+ GladeEditorProperty * eprop)
{
- gboolean enabled;
- g_assert (eprop->property == property);
+ gboolean enabled;
+ g_assert (eprop->property == property);
- if (eprop->klass->optional)
- {
- enabled = glade_property_get_enabled (property);
+ if (eprop->klass->optional)
+ {
+ enabled = glade_property_get_enabled (property);
- /* sensitive = enabled && support enabled && sensitive */
- if (enabled == FALSE)
- gtk_widget_set_sensitive (eprop->input, FALSE);
- else if (glade_property_get_sensitive (property) ||
- (property->state & GLADE_STATE_SUPPORT_DISABLED) != 0)
- gtk_widget_set_sensitive (eprop->input, TRUE);
+ /* sensitive = enabled && support enabled && sensitive */
+ if (enabled == FALSE)
+ gtk_widget_set_sensitive (eprop->input, FALSE);
+ else if (glade_property_get_sensitive (property) ||
+ (property->state & GLADE_STATE_SUPPORT_DISABLED) != 0)
+ gtk_widget_set_sensitive (eprop->input, TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eprop->check), enabled);
- }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eprop->check), enabled);
+ }
}
static void
-glade_editor_property_enabled_toggled_cb (GtkWidget *check,
- GladeEditorProperty *eprop)
+glade_editor_property_enabled_toggled_cb (GtkWidget * check,
+ GladeEditorProperty * eprop)
{
- glade_property_set_enabled (eprop->property,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
+ glade_property_set_enabled (eprop->property,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (check)));
}
static gboolean
-glade_editor_property_button_pressed (GtkWidget *widget,
- GdkEventButton *event,
- GladeEditorProperty *eprop)
+glade_editor_property_button_pressed (GtkWidget * widget,
+ GdkEventButton * event,
+ GladeEditorProperty * eprop)
{
- if (glade_popup_is_popup_event (event))
- {
- glade_popup_property_pop (eprop->property, event);
- return TRUE;
- }
- return FALSE;
+ if (glade_popup_is_popup_event (event))
+ {
+ glade_popup_property_pop (eprop->property, event);
+ return TRUE;
+ }
+ return FALSE;
}
static GObject *
-glade_editor_property_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+glade_editor_property_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
{
- GObject *obj;
- GladeEditorProperty *eprop;
- GtkWidget *hbox;
+ GObject *obj;
+ GladeEditorProperty *eprop;
+ GtkWidget *hbox;
- /* Invoke parent constructor (eprop->klass should be resolved by this point) . */
- obj = G_OBJECT_CLASS (table_class)->constructor
- (type, n_construct_properties, construct_properties);
-
- eprop = GLADE_EDITOR_PROPERTY (obj);
+ /* Invoke parent constructor (eprop->klass should be resolved by this point) . */
+ obj = G_OBJECT_CLASS (table_class)->constructor
+ (type, n_construct_properties, construct_properties);
- /* Create hbox and possibly check button
- */
- if (eprop->klass->optional)
- {
- eprop->check = gtk_check_button_new ();
- gtk_widget_show (eprop->check);
- gtk_box_pack_start (GTK_BOX (eprop), eprop->check, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (eprop->check), "toggled",
- G_CALLBACK (glade_editor_property_enabled_toggled_cb), eprop);
- }
+ eprop = GLADE_EDITOR_PROPERTY (obj);
- /* Create the class specific input widget and add it */
- eprop->input = GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->create_input (eprop);
- gtk_widget_set_hexpand (eprop->input, TRUE);
- gtk_widget_show (eprop->input);
+ /* Create hbox and possibly check button
+ */
+ if (eprop->klass->optional)
+ {
+ eprop->check = gtk_check_button_new ();
+ gtk_widget_show (eprop->check);
+ gtk_box_pack_start (GTK_BOX (eprop), eprop->check, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (eprop->check), "toggled",
+ G_CALLBACK (glade_editor_property_enabled_toggled_cb),
+ eprop);
+ }
- /* Create the warning icon */
- eprop->warning = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_no_show_all (eprop->warning, TRUE);
+ /* Create the class specific input widget and add it */
+ eprop->input = GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->create_input (eprop);
+ gtk_widget_set_hexpand (eprop->input, TRUE);
+ gtk_widget_show (eprop->input);
- /* Create & setup label */
- eprop->item_label = gtk_event_box_new ();
- eprop->label = gtk_label_new (NULL);
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (eprop->item_label), FALSE);
+ /* Create the warning icon */
+ eprop->warning = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_set_no_show_all (eprop->warning, TRUE);
- hbox = gtk_hbox_new (FALSE, 4);
+ /* Create & setup label */
+ eprop->item_label = gtk_event_box_new ();
+ eprop->label = gtk_label_new (NULL);
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (eprop->item_label), FALSE);
- gtk_label_set_line_wrap (GTK_LABEL (eprop->label), TRUE);
- gtk_label_set_width_chars (GTK_LABEL (eprop->label), 10);
- gtk_label_set_line_wrap_mode (GTK_LABEL (eprop->label), PANGO_WRAP_WORD_CHAR);
+ hbox = gtk_hbox_new (FALSE, 4);
- gtk_misc_set_alignment (GTK_MISC (eprop->label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (eprop->label), TRUE);
+ gtk_label_set_width_chars (GTK_LABEL (eprop->label), 10);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (eprop->label), PANGO_WRAP_WORD_CHAR);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->label, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->warning, FALSE, FALSE, 0);
- gtk_container_add (GTK_CONTAINER (eprop->item_label), hbox);
- gtk_widget_show_all (eprop->item_label);
+ gtk_misc_set_alignment (GTK_MISC (eprop->label), 0.0, 0.5);
- glade_editor_property_fix_label (eprop);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->warning, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (eprop->item_label), hbox);
+ gtk_widget_show_all (eprop->item_label);
- gtk_box_pack_start (GTK_BOX (eprop), eprop->input, TRUE, TRUE, 0);
+ glade_editor_property_fix_label (eprop);
- g_signal_connect (G_OBJECT (eprop->item_label), "button-press-event",
- G_CALLBACK (glade_editor_property_button_pressed), eprop);
- g_signal_connect (G_OBJECT (eprop->input), "button-press-event",
- G_CALLBACK (glade_editor_property_button_pressed), eprop);
+ gtk_box_pack_start (GTK_BOX (eprop), eprop->input, TRUE, TRUE, 0);
- return obj;
+ g_signal_connect (G_OBJECT (eprop->item_label), "button-press-event",
+ G_CALLBACK (glade_editor_property_button_pressed), eprop);
+ g_signal_connect (G_OBJECT (eprop->input), "button-press-event",
+ G_CALLBACK (glade_editor_property_button_pressed), eprop);
+
+ return obj;
}
static void
-glade_editor_property_finalize (GObject *object)
+glade_editor_property_finalize (GObject * object)
{
- GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (object);
+ GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (object);
- /* detatch from loaded property */
- glade_editor_property_load_common (eprop, NULL);
+ /* detatch from loaded property */
+ glade_editor_property_load_common (eprop, NULL);
- G_OBJECT_CLASS (table_class)->finalize (object);
+ G_OBJECT_CLASS (table_class)->finalize (object);
}
static void
-glade_editor_property_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (object);
-
- switch (prop_id)
- {
- case PROP_PROPERTY_CLASS:
- eprop->klass = g_value_get_pointer (value);
- break;
- case PROP_USE_COMMAND:
- eprop->use_command = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_editor_property_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (object);
+
+ switch (prop_id)
+ {
+ case PROP_PROPERTY_CLASS:
+ eprop->klass = g_value_get_pointer (value);
+ break;
+ case PROP_USE_COMMAND:
+ eprop->use_command = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_editor_property_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (object);
-
- switch (prop_id)
- {
- case PROP_PROPERTY_CLASS:
- g_value_set_pointer (value, eprop->klass);
- break;
- case PROP_USE_COMMAND:
- g_value_set_boolean (value, eprop->use_command);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_editor_property_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (object);
+
+ switch (prop_id)
+ {
+ case PROP_PROPERTY_CLASS:
+ g_value_set_pointer (value, eprop->klass);
+ break;
+ case PROP_USE_COMMAND:
+ g_value_set_boolean (value, eprop->use_command);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_eprop_property_finalized (GladeEditorProperty *eprop,
- GladeProperty *where_property_was)
+glade_eprop_property_finalized (GladeEditorProperty * eprop,
+ GladeProperty * where_property_was)
{
- eprop->tooltip_id = 0;
- eprop->sensitive_id = 0;
- eprop->changed_id = 0;
- eprop->enabled_id = 0;
- eprop->state_id = 0;
- eprop->property = NULL;
+ eprop->tooltip_id = 0;
+ eprop->sensitive_id = 0;
+ eprop->changed_id = 0;
+ eprop->enabled_id = 0;
+ eprop->state_id = 0;
+ eprop->property = NULL;
- glade_editor_property_load (eprop, NULL);
+ glade_editor_property_load (eprop, NULL);
}
static void
-glade_editor_property_load_common (GladeEditorProperty *eprop,
- GladeProperty *property)
-{
- /* NOTE THIS CODE IS FINALIZE SAFE */
-
- /* disconnect anything from previously loaded property */
- if (eprop->property != property && eprop->property != NULL)
- {
- if (eprop->tooltip_id > 0)
- g_signal_handler_disconnect (eprop->property,
- eprop->tooltip_id);
- if (eprop->sensitive_id > 0)
- g_signal_handler_disconnect (eprop->property,
- eprop->sensitive_id);
- if (eprop->changed_id > 0)
- g_signal_handler_disconnect (eprop->property,
- eprop->changed_id);
- if (eprop->state_id > 0)
- g_signal_handler_disconnect (eprop->property,
- eprop->state_id);
- if (eprop->enabled_id > 0)
- g_signal_handler_disconnect (eprop->property,
- eprop->enabled_id);
-
- eprop->tooltip_id = 0;
- eprop->sensitive_id = 0;
- eprop->changed_id = 0;
- eprop->enabled_id = 0;
- eprop->state_id = 0;
-
- /* Unref it here */
- g_object_weak_unref (G_OBJECT (eprop->property),
- (GWeakNotify)glade_eprop_property_finalized,
- eprop);
-
-
- /* For a reason I cant quite tell yet, this is the only
- * safe way to nullify the property member of the eprop
- * without leeking signal connections to properties :-/
- */
- if (property == NULL)
- {
- eprop->property = NULL;
- }
- }
-
- /* Connect new stuff, deal with tooltip
- */
- if (eprop->property != property && property != NULL)
- {
- eprop->property = property;
-
- eprop->tooltip_id =
- g_signal_connect (G_OBJECT (eprop->property),
- "tooltip-changed",
- G_CALLBACK (glade_editor_property_tooltip_cb),
- eprop);
- eprop->sensitive_id =
- g_signal_connect (G_OBJECT (eprop->property),
- "notify::sensitive",
- G_CALLBACK (glade_editor_property_sensitivity_cb),
- eprop);
- eprop->changed_id =
- g_signal_connect (G_OBJECT (eprop->property),
- "value-changed",
- G_CALLBACK (glade_editor_property_value_changed_cb),
- eprop);
- eprop->enabled_id =
- g_signal_connect (G_OBJECT (eprop->property),
- "notify::enabled",
- G_CALLBACK (glade_editor_property_enabled_cb),
- eprop);
- eprop->state_id =
- g_signal_connect (G_OBJECT (eprop->property),
- "notify::state",
- G_CALLBACK (glade_editor_property_state_cb),
- eprop);
-
-
- /* In query dialogs when the user hits cancel,
- * these babies go away (so better stay protected).
- */
- g_object_weak_ref (G_OBJECT (eprop->property),
- (GWeakNotify)glade_eprop_property_finalized,
- eprop);
-
- /* Load initial tooltips
- */
- glade_editor_property_tooltip_cb
- (property,
- property->klass->tooltip,
- property->insensitive_tooltip,
- property->support_warning,
- eprop);
-
- /* Load initial enabled state
- */
- glade_editor_property_enabled_cb (property, NULL, eprop);
-
- /* Load initial sensitive state.
- */
- glade_editor_property_sensitivity_cb (property, NULL, eprop);
-
- /* Load intial label state
- */
- glade_editor_property_state_cb (property, NULL, eprop);
- }
+glade_editor_property_load_common (GladeEditorProperty * eprop,
+ GladeProperty * property)
+{
+ /* NOTE THIS CODE IS FINALIZE SAFE */
+
+ /* disconnect anything from previously loaded property */
+ if (eprop->property != property && eprop->property != NULL)
+ {
+ if (eprop->tooltip_id > 0)
+ g_signal_handler_disconnect (eprop->property, eprop->tooltip_id);
+ if (eprop->sensitive_id > 0)
+ g_signal_handler_disconnect (eprop->property, eprop->sensitive_id);
+ if (eprop->changed_id > 0)
+ g_signal_handler_disconnect (eprop->property, eprop->changed_id);
+ if (eprop->state_id > 0)
+ g_signal_handler_disconnect (eprop->property, eprop->state_id);
+ if (eprop->enabled_id > 0)
+ g_signal_handler_disconnect (eprop->property, eprop->enabled_id);
+
+ eprop->tooltip_id = 0;
+ eprop->sensitive_id = 0;
+ eprop->changed_id = 0;
+ eprop->enabled_id = 0;
+ eprop->state_id = 0;
+
+ /* Unref it here */
+ g_object_weak_unref (G_OBJECT (eprop->property),
+ (GWeakNotify) glade_eprop_property_finalized, eprop);
+
+
+ /* For a reason I cant quite tell yet, this is the only
+ * safe way to nullify the property member of the eprop
+ * without leeking signal connections to properties :-/
+ */
+ if (property == NULL)
+ {
+ eprop->property = NULL;
+ }
+ }
+
+ /* Connect new stuff, deal with tooltip
+ */
+ if (eprop->property != property && property != NULL)
+ {
+ eprop->property = property;
+
+ eprop->tooltip_id =
+ g_signal_connect (G_OBJECT (eprop->property),
+ "tooltip-changed",
+ G_CALLBACK (glade_editor_property_tooltip_cb),
+ eprop);
+ eprop->sensitive_id =
+ g_signal_connect (G_OBJECT (eprop->property),
+ "notify::sensitive",
+ G_CALLBACK (glade_editor_property_sensitivity_cb),
+ eprop);
+ eprop->changed_id =
+ g_signal_connect (G_OBJECT (eprop->property),
+ "value-changed",
+ G_CALLBACK (glade_editor_property_value_changed_cb),
+ eprop);
+ eprop->enabled_id =
+ g_signal_connect (G_OBJECT (eprop->property),
+ "notify::enabled",
+ G_CALLBACK (glade_editor_property_enabled_cb),
+ eprop);
+ eprop->state_id =
+ g_signal_connect (G_OBJECT (eprop->property),
+ "notify::state",
+ G_CALLBACK (glade_editor_property_state_cb), eprop);
+
+
+ /* In query dialogs when the user hits cancel,
+ * these babies go away (so better stay protected).
+ */
+ g_object_weak_ref (G_OBJECT (eprop->property),
+ (GWeakNotify) glade_eprop_property_finalized, eprop);
+
+ /* Load initial tooltips
+ */
+ glade_editor_property_tooltip_cb
+ (property,
+ property->klass->tooltip,
+ property->insensitive_tooltip, property->support_warning, eprop);
+
+ /* Load initial enabled state
+ */
+ glade_editor_property_enabled_cb (property, NULL, eprop);
+
+ /* Load initial sensitive state.
+ */
+ glade_editor_property_sensitivity_cb (property, NULL, eprop);
+
+ /* Load intial label state
+ */
+ glade_editor_property_state_cb (property, NULL, eprop);
+ }
}
static void
-glade_editor_property_init (GladeEditorProperty *eprop)
+glade_editor_property_init (GladeEditorProperty * eprop)
{
}
static void
-glade_editor_property_class_init (GladeEditorPropertyClass *eprop_class)
+glade_editor_property_class_init (GladeEditorPropertyClass * eprop_class)
{
- GObjectClass *object_class;
- g_return_if_fail (eprop_class != NULL);
+ GObjectClass *object_class;
+ g_return_if_fail (eprop_class != NULL);
- /* Both parent classes assigned here.
- */
- editor_property_class = eprop_class;
- table_class = g_type_class_peek_parent (eprop_class);
- object_class = G_OBJECT_CLASS (eprop_class);
-
- /* GObjectClass */
- object_class->constructor = glade_editor_property_constructor;
- object_class->finalize = glade_editor_property_finalize;
- object_class->get_property = glade_editor_property_get_property;
- object_class->set_property = glade_editor_property_set_property;
-
- /* Class methods */
- eprop_class->load = glade_editor_property_load_common;
- eprop_class->commit = glade_editor_property_commit_common;
- eprop_class->create_input = NULL;
-
-
- /**
+ /* Both parent classes assigned here.
+ */
+ editor_property_class = eprop_class;
+ table_class = g_type_class_peek_parent (eprop_class);
+ object_class = G_OBJECT_CLASS (eprop_class);
+
+ /* GObjectClass */
+ object_class->constructor = glade_editor_property_constructor;
+ object_class->finalize = glade_editor_property_finalize;
+ object_class->get_property = glade_editor_property_get_property;
+ object_class->set_property = glade_editor_property_set_property;
+
+ /* Class methods */
+ eprop_class->load = glade_editor_property_load_common;
+ eprop_class->commit = glade_editor_property_commit_common;
+ eprop_class->create_input = NULL;
+
+
+ /**
* GladeEditorProperty::value-changed:
* @gladeeditorproperty: the #GladeEditorProperty which changed value
* @arg1: the #GladeProperty that's value changed.
*
* Emitted when a contained property changes value
*/
- glade_eprop_signals[CHANGED] =
- g_signal_new ("value-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeEditorPropertyClass, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GLADE_TYPE_PROPERTY);
-
- /**
+ glade_eprop_signals[CHANGED] =
+ g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeEditorPropertyClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GLADE_TYPE_PROPERTY);
+
+ /**
* GladeEditorProperty::commit:
* @gladeeditorproperty: the #GladeEditorProperty which changed value
* @arg1: the new #GValue to commit.
@@ -535,66 +527,65 @@ glade_editor_property_class_init (GladeEditorPropertyClass *eprop_class)
* Emitted when a property's value is committed, can be useful to serialize
* commands before and after the property's commit command from custom editors.
*/
- glade_eprop_signals[COMMIT] =
- g_signal_new ("commit",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeEditorPropertyClass, commit),
- NULL, NULL,
- glade_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- /* Properties */
- g_object_class_install_property
- (object_class, PROP_PROPERTY_CLASS,
- g_param_spec_pointer
- ("property-class", _("Property Class"),
- _("The GladePropertyClass this GladeEditorProperty was created for"),
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_USE_COMMAND,
- g_param_spec_boolean
- ("use-command", _("Use Command"),
- _("Whether we should use the command API for the undo/redo stack"),
- FALSE, G_PARAM_READWRITE));
+ glade_eprop_signals[COMMIT] =
+ g_signal_new ("commit",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeEditorPropertyClass, commit),
+ NULL, NULL,
+ glade_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_PROPERTY_CLASS,
+ g_param_spec_pointer
+ ("property-class", _("Property Class"),
+ _("The GladePropertyClass this GladeEditorProperty was created for"),
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_USE_COMMAND,
+ g_param_spec_boolean
+ ("use-command", _("Use Command"),
+ _("Whether we should use the command API for the undo/redo stack"),
+ FALSE, G_PARAM_READWRITE));
}
GType
glade_editor_property_get_type (void)
{
- static GType property_type = 0;
-
- if (!property_type)
- {
- static const GTypeInfo property_info =
- {
- sizeof (GladeEditorPropertyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) glade_editor_property_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (GladeEditorProperty),
- 0, /* n_preallocs */
- (GInstanceInitFunc) glade_editor_property_init,
- };
- property_type =
- g_type_register_static (GTK_TYPE_HBOX,
- "GladeEditorProperty",
- &property_info, 0);
- }
- return property_type;
+ static GType property_type = 0;
+
+ if (!property_type)
+ {
+ static const GTypeInfo property_info = {
+ sizeof (GladeEditorPropertyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) glade_editor_property_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (GladeEditorProperty),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) glade_editor_property_init,
+ };
+ property_type =
+ g_type_register_static (GTK_TYPE_HBOX,
+ "GladeEditorProperty", &property_info, 0);
+ }
+ return property_type;
}
/*******************************************************************************
GladeEditorPropertyNumericClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *spin;
+ GtkWidget *spin;
} GladeEPropNumeric;
GLADE_MAKE_EPROP (GladeEPropNumeric, glade_eprop_numeric)
@@ -603,118 +594,120 @@ GLADE_MAKE_EPROP (GladeEPropNumeric, glade_eprop_numeric)
#define GLADE_IS_EPROP_NUMERIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_NUMERIC))
#define GLADE_IS_EPROP_NUMERIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_NUMERIC))
#define GLADE_EPROP_NUMERIC_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_NUMERIC, GladeEPropNumericClass))
-
-static void
-glade_eprop_numeric_finalize (GObject *object)
+ static void glade_eprop_numeric_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_numeric_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- gfloat val = 0.0F;
- GladeEPropNumeric *eprop_numeric = GLADE_EPROP_NUMERIC (eprop);
-
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- if (property)
- {
- if (G_IS_PARAM_SPEC_INT(eprop->klass->pspec))
- val = (gfloat) g_value_get_int (property->value);
- else if (G_IS_PARAM_SPEC_UINT(eprop->klass->pspec))
- val = (gfloat) g_value_get_uint (property->value);
- else if (G_IS_PARAM_SPEC_LONG(eprop->klass->pspec))
- val = (gfloat) g_value_get_long (property->value);
- else if (G_IS_PARAM_SPEC_ULONG(eprop->klass->pspec))
- val = (gfloat) g_value_get_ulong (property->value);
- else if (G_IS_PARAM_SPEC_INT64(eprop->klass->pspec))
- val = (gfloat) g_value_get_int64 (property->value);
- else if (G_IS_PARAM_SPEC_UINT64(eprop->klass->pspec))
- val = (gfloat) g_value_get_uint64 (property->value);
- else if (G_IS_PARAM_SPEC_DOUBLE(eprop->klass->pspec))
- val = (gfloat) g_value_get_double (property->value);
- else if (G_IS_PARAM_SPEC_FLOAT(eprop->klass->pspec))
- val = g_value_get_float (property->value);
- else
- g_warning ("Unsupported type %s\n",
- g_type_name(G_PARAM_SPEC_TYPE (eprop->klass->pspec)));
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_numeric->spin), val);
- }
+glade_eprop_numeric_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ gfloat val = 0.0F;
+ GladeEPropNumeric *eprop_numeric = GLADE_EPROP_NUMERIC (eprop);
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
+
+ if (property)
+ {
+ if (G_IS_PARAM_SPEC_INT (eprop->klass->pspec))
+ val = (gfloat) g_value_get_int (property->value);
+ else if (G_IS_PARAM_SPEC_UINT (eprop->klass->pspec))
+ val = (gfloat) g_value_get_uint (property->value);
+ else if (G_IS_PARAM_SPEC_LONG (eprop->klass->pspec))
+ val = (gfloat) g_value_get_long (property->value);
+ else if (G_IS_PARAM_SPEC_ULONG (eprop->klass->pspec))
+ val = (gfloat) g_value_get_ulong (property->value);
+ else if (G_IS_PARAM_SPEC_INT64 (eprop->klass->pspec))
+ val = (gfloat) g_value_get_int64 (property->value);
+ else if (G_IS_PARAM_SPEC_UINT64 (eprop->klass->pspec))
+ val = (gfloat) g_value_get_uint64 (property->value);
+ else if (G_IS_PARAM_SPEC_DOUBLE (eprop->klass->pspec))
+ val = (gfloat) g_value_get_double (property->value);
+ else if (G_IS_PARAM_SPEC_FLOAT (eprop->klass->pspec))
+ val = g_value_get_float (property->value);
+ else
+ g_warning ("Unsupported type %s\n",
+ g_type_name (G_PARAM_SPEC_TYPE (eprop->klass->pspec)));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_numeric->spin), val);
+ }
}
static void
-glade_eprop_numeric_changed (GtkWidget *spin,
- GladeEditorProperty *eprop)
-{
- GValue val = { 0, };
-
- if (eprop->loading) return;
-
- g_value_init (&val, eprop->klass->pspec->value_type);
-
- if (G_IS_PARAM_SPEC_INT(eprop->klass->pspec))
- g_value_set_int (&val, gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_UINT(eprop->klass->pspec))
- g_value_set_uint (&val, gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_LONG(eprop->klass->pspec))
- g_value_set_long (&val, (glong)gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_ULONG(eprop->klass->pspec))
- g_value_set_ulong (&val, (gulong)gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_INT64(eprop->klass->pspec))
- g_value_set_int64 (&val, (gint64)gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_UINT64(eprop->klass->pspec))
- g_value_set_uint64 (&val, (guint64)gtk_spin_button_get_value_as_int
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_FLOAT(eprop->klass->pspec))
- g_value_set_float (&val, (gfloat) gtk_spin_button_get_value
- (GTK_SPIN_BUTTON (spin)));
- else if (G_IS_PARAM_SPEC_DOUBLE(eprop->klass->pspec))
- g_value_set_double (&val, gtk_spin_button_get_value
- (GTK_SPIN_BUTTON (spin)));
- else
- g_warning ("Unsupported type %s\n",
- g_type_name(G_PARAM_SPEC_TYPE (eprop->klass->pspec)));
-
- glade_editor_property_commit_no_callback (eprop, &val);
- g_value_unset (&val);
+glade_eprop_numeric_changed (GtkWidget * spin, GladeEditorProperty * eprop)
+{
+ GValue val = { 0, };
+
+ if (eprop->loading)
+ return;
+
+ g_value_init (&val, eprop->klass->pspec->value_type);
+
+ if (G_IS_PARAM_SPEC_INT (eprop->klass->pspec))
+ g_value_set_int (&val, gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_UINT (eprop->klass->pspec))
+ g_value_set_uint (&val, gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_LONG (eprop->klass->pspec))
+ g_value_set_long (&val, (glong) gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_ULONG (eprop->klass->pspec))
+ g_value_set_ulong (&val, (gulong) gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_INT64 (eprop->klass->pspec))
+ g_value_set_int64 (&val, (gint64) gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_UINT64 (eprop->klass->pspec))
+ g_value_set_uint64 (&val, (guint64) gtk_spin_button_get_value_as_int
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_FLOAT (eprop->klass->pspec))
+ g_value_set_float (&val, (gfloat) gtk_spin_button_get_value
+ (GTK_SPIN_BUTTON (spin)));
+ else if (G_IS_PARAM_SPEC_DOUBLE (eprop->klass->pspec))
+ g_value_set_double (&val, gtk_spin_button_get_value
+ (GTK_SPIN_BUTTON (spin)));
+ else
+ g_warning ("Unsupported type %s\n",
+ g_type_name (G_PARAM_SPEC_TYPE (eprop->klass->pspec)));
+
+ glade_editor_property_commit_no_callback (eprop, &val);
+ g_value_unset (&val);
}
static GtkWidget *
-glade_eprop_numeric_create_input (GladeEditorProperty *eprop)
+glade_eprop_numeric_create_input (GladeEditorProperty * eprop)
{
- GladeEPropNumeric *eprop_numeric = GLADE_EPROP_NUMERIC (eprop);
- GtkAdjustment *adjustment;
+ GladeEPropNumeric *eprop_numeric = GLADE_EPROP_NUMERIC (eprop);
+ GtkAdjustment *adjustment;
- adjustment = glade_property_class_make_adjustment (eprop->klass);
- eprop_numeric->spin = gtk_spin_button_new (adjustment, 4,
- G_IS_PARAM_SPEC_FLOAT (eprop->klass->pspec) ||
- G_IS_PARAM_SPEC_DOUBLE (eprop->klass->pspec)
- ? 2 : 0);
- gtk_widget_show (eprop_numeric->spin);
-
- g_signal_connect (G_OBJECT (eprop_numeric->spin), "value_changed",
- G_CALLBACK (glade_eprop_numeric_changed),
- eprop);
+ adjustment = glade_property_class_make_adjustment (eprop->klass);
+ eprop_numeric->spin = gtk_spin_button_new (adjustment, 4,
+ G_IS_PARAM_SPEC_FLOAT (eprop->
+ klass->
+ pspec) ||
+ G_IS_PARAM_SPEC_DOUBLE (eprop->
+ klass->
+ pspec) ? 2
+ : 0);
+ gtk_widget_show (eprop_numeric->spin);
- return eprop_numeric->spin;
+ g_signal_connect (G_OBJECT (eprop_numeric->spin), "value_changed",
+ G_CALLBACK (glade_eprop_numeric_changed), eprop);
+
+ return eprop_numeric->spin;
}
/*******************************************************************************
GladeEditorPropertyEnumClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *combo_box;
+ GtkWidget *combo_box;
} GladeEPropEnum;
GLADE_MAKE_EPROP (GladeEPropEnum, glade_eprop_enum)
@@ -723,123 +716,122 @@ GLADE_MAKE_EPROP (GladeEPropEnum, glade_eprop_enum)
#define GLADE_IS_EPROP_ENUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_ENUM))
#define GLADE_IS_EPROP_ENUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_ENUM))
#define GLADE_EPROP_ENUM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_ENUM, GladeEPropEnumClass))
-
-
-static void
-glade_eprop_enum_finalize (GObject *object)
+ static void glade_eprop_enum_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_enum_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeEPropEnum *eprop_enum = GLADE_EPROP_ENUM (eprop);
- GEnumClass *eclass;
- guint i;
- gint value;
-
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- if (property)
- {
- eclass = g_type_class_ref (eprop->klass->pspec->value_type);
- value = g_value_get_enum (property->value);
-
- for (i = 0; i < eclass->n_values; i++)
- if (eclass->values[i].value == value)
- break;
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_enum->combo_box),
- i < eclass->n_values ? i : 0);
- g_type_class_unref (eclass);
- }
+glade_eprop_enum_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ GladeEPropEnum *eprop_enum = GLADE_EPROP_ENUM (eprop);
+ GEnumClass *eclass;
+ guint i;
+ gint value;
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
+
+ if (property)
+ {
+ eclass = g_type_class_ref (eprop->klass->pspec->value_type);
+ value = g_value_get_enum (property->value);
+
+ for (i = 0; i < eclass->n_values; i++)
+ if (eclass->values[i].value == value)
+ break;
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_enum->combo_box),
+ i < eclass->n_values ? i : 0);
+ g_type_class_unref (eclass);
+ }
}
static void
-glade_eprop_enum_changed (GtkWidget *combo_box,
- GladeEditorProperty *eprop)
+glade_eprop_enum_changed (GtkWidget * combo_box, GladeEditorProperty * eprop)
{
- gint ival;
- GValue val = { 0, };
- GladeProperty *property;
- GtkTreeModel *tree_model;
- GtkTreeIter iter;
+ gint ival;
+ GValue val = { 0, };
+ GladeProperty *property;
+ GtkTreeModel *tree_model;
+ GtkTreeIter iter;
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- tree_model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter);
- gtk_tree_model_get (tree_model, &iter, 1, &ival, -1);
+ tree_model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter);
+ gtk_tree_model_get (tree_model, &iter, 1, &ival, -1);
- property = eprop->property;
+ property = eprop->property;
- g_value_init (&val, eprop->klass->pspec->value_type);
- g_value_set_enum (&val, ival);
+ g_value_init (&val, eprop->klass->pspec->value_type);
+ g_value_set_enum (&val, ival);
- glade_editor_property_commit_no_callback (eprop, &val);
- g_value_unset (&val);
+ glade_editor_property_commit_no_callback (eprop, &val);
+ g_value_unset (&val);
}
static GtkWidget *
-glade_eprop_enum_create_input (GladeEditorProperty *eprop)
+glade_eprop_enum_create_input (GladeEditorProperty * eprop)
{
- GladeEPropEnum *eprop_enum = GLADE_EPROP_ENUM (eprop);
- GladePropertyClass *klass;
- GEnumClass *eclass;
- GtkListStore *list_store;
- GtkTreeIter iter;
- GtkCellRenderer *cell_renderer;
- guint i;
-
- klass = eprop->klass;
- eclass = g_type_class_ref (klass->pspec->value_type);
+ GladeEPropEnum *eprop_enum = GLADE_EPROP_ENUM (eprop);
+ GladePropertyClass *klass;
+ GEnumClass *eclass;
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+ GtkCellRenderer *cell_renderer;
+ guint i;
- list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
+ klass = eprop->klass;
+ eclass = g_type_class_ref (klass->pspec->value_type);
- gtk_tree_model_get_iter_first (GTK_TREE_MODEL(list_store), &iter);
+ list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
- for (i = 0; i < eclass->n_values; i++)
- {
- const gchar *value_name =
- glade_get_displayable_value (klass->pspec->value_type,
- eclass->values[i].value_nick);
- if (value_name == NULL) value_name = eclass->values[i].value_nick;
-
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter, 0, value_name, 1,
- eclass->values[i].value, -1);
- }
+ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter);
- eprop_enum->combo_box = gtk_combo_box_new_with_model
- (GTK_TREE_MODEL (list_store));
+ for (i = 0; i < eclass->n_values; i++)
+ {
+ const gchar *value_name =
+ glade_get_displayable_value (klass->pspec->value_type,
+ eclass->values[i].value_nick);
+ if (value_name == NULL)
+ value_name = eclass->values[i].value_nick;
- cell_renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (eprop_enum->combo_box),
- cell_renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (eprop_enum->combo_box),
- cell_renderer, "text", 0);
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter, 0, value_name, 1,
+ eclass->values[i].value, -1);
+ }
- g_signal_connect (G_OBJECT (eprop_enum->combo_box), "changed",
- G_CALLBACK (glade_eprop_enum_changed), eprop);
+ eprop_enum->combo_box = gtk_combo_box_new_with_model
+ (GTK_TREE_MODEL (list_store));
- gtk_widget_show_all (eprop_enum->combo_box);
+ cell_renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (eprop_enum->combo_box),
+ cell_renderer, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (eprop_enum->combo_box),
+ cell_renderer, "text", 0);
- g_type_class_unref (eclass);
+ g_signal_connect (G_OBJECT (eprop_enum->combo_box), "changed",
+ G_CALLBACK (glade_eprop_enum_changed), eprop);
- return eprop_enum->combo_box;
+ gtk_widget_show_all (eprop_enum->combo_box);
+
+ g_type_class_unref (eclass);
+
+ return eprop_enum->combo_box;
}
/*******************************************************************************
GladeEditorPropertyFlagsClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkTreeModel *model;
- GtkWidget *entry;
+ GtkTreeModel *model;
+ GtkWidget *entry;
} GladeEPropFlags;
GLADE_MAKE_EPROP (GladeEPropFlags, glade_eprop_flags)
@@ -848,289 +840,281 @@ GLADE_MAKE_EPROP (GladeEPropFlags, glade_eprop_flags)
#define GLADE_IS_EPROP_FLAGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_FLAGS))
#define GLADE_IS_EPROP_FLAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_FLAGS))
#define GLADE_EPROP_FLAGS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_FLAGS, GladeEPropFlagsClass))
-
-static void
-glade_eprop_flags_finalize (GObject *object)
+ static void glade_eprop_flags_finalize (GObject * object)
{
- GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS(object);
+ GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS (object);
- g_object_unref (G_OBJECT (eprop_flags->model));
+ g_object_unref (G_OBJECT (eprop_flags->model));
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_flags_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS (eprop);
- GFlagsClass *klass;
- guint flag_num, value;
- GString *string = g_string_new (NULL);
-
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- gtk_list_store_clear(GTK_LIST_STORE(eprop_flags->model));
-
- if (property)
- {
- /* Populate the model with the flags. */
- klass = g_type_class_ref (G_VALUE_TYPE (property->value));
- value = g_value_get_flags (property->value);
-
- /* Step through each of the flags in the class. */
- for (flag_num = 0; flag_num < klass->n_values; flag_num++) {
- GtkTreeIter iter;
- guint mask;
- gboolean setting;
- const gchar *value_name;
-
- mask = klass->values[flag_num].value;
- setting = ((value & mask) == mask) ? TRUE : FALSE;
-
- value_name = glade_get_displayable_value
- (eprop->klass->pspec->value_type, klass->values[flag_num].value_nick);
-
- if (value_name == NULL) value_name = klass->values[flag_num].value_name;
-
- /* Setup string for property label */
- if (setting)
- {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, value_name);
- }
-
- /* Add a row to represent the flag. */
- gtk_list_store_append (GTK_LIST_STORE(eprop_flags->model), &iter);
- gtk_list_store_set (GTK_LIST_STORE(eprop_flags->model), &iter,
- FLAGS_COLUMN_SETTING,
- setting,
- FLAGS_COLUMN_SYMBOL,
- value_name,
- -1);
-
- }
- g_type_class_unref(klass);
- }
-
- gtk_entry_set_text (GTK_ENTRY (eprop_flags->entry), string->str);
-
- g_string_free (string, TRUE);
+glade_eprop_flags_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS (eprop);
+ GFlagsClass *klass;
+ guint flag_num, value;
+ GString *string = g_string_new (NULL);
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
+
+ gtk_list_store_clear (GTK_LIST_STORE (eprop_flags->model));
+
+ if (property)
+ {
+ /* Populate the model with the flags. */
+ klass = g_type_class_ref (G_VALUE_TYPE (property->value));
+ value = g_value_get_flags (property->value);
+
+ /* Step through each of the flags in the class. */
+ for (flag_num = 0; flag_num < klass->n_values; flag_num++)
+ {
+ GtkTreeIter iter;
+ guint mask;
+ gboolean setting;
+ const gchar *value_name;
+
+ mask = klass->values[flag_num].value;
+ setting = ((value & mask) == mask) ? TRUE : FALSE;
+
+ value_name = glade_get_displayable_value
+ (eprop->klass->pspec->value_type,
+ klass->values[flag_num].value_nick);
+
+ if (value_name == NULL)
+ value_name = klass->values[flag_num].value_name;
+
+ /* Setup string for property label */
+ if (setting)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, value_name);
+ }
+
+ /* Add a row to represent the flag. */
+ gtk_list_store_append (GTK_LIST_STORE (eprop_flags->model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (eprop_flags->model), &iter,
+ FLAGS_COLUMN_SETTING,
+ setting, FLAGS_COLUMN_SYMBOL, value_name, -1);
+
+ }
+ g_type_class_unref (klass);
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (eprop_flags->entry), string->str);
+
+ g_string_free (string, TRUE);
}
static void
-flag_toggled_direct (GtkCellRendererToggle *cell,
- gchar *path_string,
- GladeEditorProperty *eprop)
+flag_toggled_direct (GtkCellRendererToggle * cell,
+ gchar * path_string, GladeEditorProperty * eprop)
{
- GtkTreeIter iter;
- guint new_value = 0;
- gboolean selected;
- guint value = 0;
- gint flag_num = 0;
- GFlagsClass *klass;
+ GtkTreeIter iter;
+ guint new_value = 0;
+ gboolean selected;
+ guint value = 0;
+ gint flag_num = 0;
+ GFlagsClass *klass;
- GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS(eprop);
+ GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS (eprop);
- if (!eprop->property)
- return ;
+ if (!eprop->property)
+ return;
- klass = g_type_class_ref (G_VALUE_TYPE (eprop->property->value));
- value = g_value_get_flags (eprop->property->value);
+ klass = g_type_class_ref (G_VALUE_TYPE (eprop->property->value));
+ value = g_value_get_flags (eprop->property->value);
- gtk_tree_model_get_iter_from_string (eprop_flags->model, &iter, path_string);
+ gtk_tree_model_get_iter_from_string (eprop_flags->model, &iter, path_string);
- gtk_tree_model_get (eprop_flags->model, &iter,
- FLAGS_COLUMN_SETTING, &selected,
- -1);
+ gtk_tree_model_get (eprop_flags->model, &iter,
+ FLAGS_COLUMN_SETTING, &selected, -1);
- selected = selected ? FALSE : TRUE;
+ selected = selected ? FALSE : TRUE;
- gtk_list_store_set (GTK_LIST_STORE (eprop_flags->model), &iter,
- FLAGS_COLUMN_SETTING, selected,
- -1);
+ gtk_list_store_set (GTK_LIST_STORE (eprop_flags->model), &iter,
+ FLAGS_COLUMN_SETTING, selected, -1);
- gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_flags->model), &iter);
+ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_flags->model), &iter);
- /* Step through each of the flags in the class, checking if
- the corresponding toggle in the dialog is selected, If it
- is, OR the flags' mask with the new value. */
- for (flag_num = 0; flag_num < klass->n_values; flag_num++) {
- gboolean setting;
+ /* Step through each of the flags in the class, checking if
+ the corresponding toggle in the dialog is selected, If it
+ is, OR the flags' mask with the new value. */
+ for (flag_num = 0; flag_num < klass->n_values; flag_num++)
+ {
+ gboolean setting;
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_flags->model), &iter,
- FLAGS_COLUMN_SETTING, &setting,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_flags->model), &iter,
+ FLAGS_COLUMN_SETTING, &setting, -1);
- if (setting)
- new_value |= klass->values[flag_num].value;
+ if (setting)
+ new_value |= klass->values[flag_num].value;
- gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_flags->model),
- &iter);
- }
+ gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_flags->model), &iter);
+ }
- /* If the new_value is different from the old value, we need
- to update the property. */
- if (new_value != value) {
- GValue val = { 0, };
+ /* If the new_value is different from the old value, we need
+ to update the property. */
+ if (new_value != value)
+ {
+ GValue val = { 0, };
- g_value_init (&val, G_VALUE_TYPE (eprop->property->value));
- g_value_set_flags (&val, new_value);
+ g_value_init (&val, G_VALUE_TYPE (eprop->property->value));
+ g_value_set_flags (&val, new_value);
- glade_editor_property_commit_no_callback (eprop, &val);
- g_value_unset (&val);
- }
+ glade_editor_property_commit_no_callback (eprop, &val);
+ g_value_unset (&val);
+ }
}
-static GtkWidget*
-glade_eprop_flags_create_treeview(GladeEditorProperty *eprop)
+static GtkWidget *
+glade_eprop_flags_create_treeview (GladeEditorProperty * eprop)
{
- GtkWidget *scrolled_window;
- GtkWidget *tree_view;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GladeEPropFlags *eprop_flags=GLADE_EPROP_FLAGS(eprop);
- if (!eprop_flags->model)
- eprop_flags->model = GTK_TREE_MODEL(gtk_list_store_new (2, G_TYPE_BOOLEAN,
- G_TYPE_STRING));
+ GtkWidget *scrolled_window;
+ GtkWidget *tree_view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS (eprop);
+ if (!eprop_flags->model)
+ eprop_flags->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_BOOLEAN,
+ G_TYPE_STRING));
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_IN);
+ gtk_widget_show (scrolled_window);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_SHADOW_IN);
- gtk_widget_show (scrolled_window);
-
- tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (eprop_flags->model));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
- gtk_widget_show (tree_view);
- gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
+ tree_view =
+ gtk_tree_view_new_with_model (GTK_TREE_MODEL (eprop_flags->model));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
+ gtk_widget_show (tree_view);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
- column = gtk_tree_view_column_new ();
+ column = gtk_tree_view_column_new ();
- renderer = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "active", FLAGS_COLUMN_SETTING,
- NULL);
+ renderer = gtk_cell_renderer_toggle_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "active", FLAGS_COLUMN_SETTING, NULL);
- g_signal_connect (renderer, "toggled",
- G_CALLBACK (flag_toggled_direct), eprop);
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (flag_toggled_direct), eprop);
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", FLAGS_COLUMN_SYMBOL,
- NULL);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", FLAGS_COLUMN_SYMBOL, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
- return scrolled_window;
+ return scrolled_window;
}
static void
-glade_eprop_flags_show_dialog (GtkWidget *button,
- GladeEditorProperty *eprop)
-{
- GtkWidget *dialog;
- GtkWidget *view;
- GtkWidget *label;
- GtkWidget *vbox;
- GtkWidget *content_area;
- GtkWidget *action_area;
-
- dialog = gtk_dialog_new_with_buttons (_("Select Fields"),
- GTK_WINDOW (gtk_widget_get_toplevel (button)),
- GTK_DIALOG_MODAL,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
-
- /* HIG spacings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-
- view = glade_eprop_flags_create_treeview (eprop);
-
- label = gtk_label_new_with_mnemonic (_("_Select individual fields:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), gtk_bin_get_child (GTK_BIN (view)));
-
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), view, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
-
- gtk_widget_show (label);
- gtk_widget_show (view);
- gtk_widget_show (vbox);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+glade_eprop_flags_show_dialog (GtkWidget * button, GladeEditorProperty * eprop)
+{
+ GtkWidget *dialog;
+ GtkWidget *view;
+ GtkWidget *label;
+ GtkWidget *vbox;
+ GtkWidget *content_area;
+ GtkWidget *action_area;
+
+ dialog = gtk_dialog_new_with_buttons (_("Select Fields"),
+ GTK_WINDOW (gtk_widget_get_toplevel
+ (button)), GTK_DIALOG_MODAL,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ NULL);
+
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
+
+ /* HIG spacings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ view = glade_eprop_flags_create_treeview (eprop);
+
+ label = gtk_label_new_with_mnemonic (_("_Select individual fields:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label),
+ gtk_bin_get_child (GTK_BIN (view)));
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), view, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+
+ gtk_widget_show (label);
+ gtk_widget_show (view);
+ gtk_widget_show (vbox);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
}
static GtkWidget *
-glade_eprop_flags_create_input (GladeEditorProperty *eprop)
+glade_eprop_flags_create_input (GladeEditorProperty * eprop)
{
- GtkWidget *vbox, *hbox, *button, *widget;
- GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS(eprop);
+ GtkWidget *vbox, *hbox, *button, *widget;
+ GladeEPropFlags *eprop_flags = GLADE_EPROP_FLAGS (eprop);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ vbox = gtk_vbox_new (FALSE, 0);
- hbox = gtk_hbox_new (FALSE, 0);
- vbox = gtk_vbox_new (FALSE, 0);
-
- widget = glade_eprop_flags_create_treeview (eprop);
+ widget = glade_eprop_flags_create_treeview (eprop);
- eprop_flags->entry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (eprop_flags->entry), FALSE);
+ eprop_flags->entry = gtk_entry_new ();
+ gtk_editable_set_editable (GTK_EDITABLE (eprop_flags->entry), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), eprop_flags->entry, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), eprop_flags->entry, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
- button = gtk_button_new_with_label ("...");
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("...");
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- gtk_widget_show_all (hbox);
+ gtk_widget_show_all (hbox);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_flags_show_dialog),
- eprop);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_flags_show_dialog), eprop);
- return hbox;
+ return hbox;
}
/*******************************************************************************
GladeEditorPropertyColorClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *cbutton;
- GtkWidget *entry;
+ GtkWidget *cbutton;
+ GtkWidget *entry;
} GladeEPropColor;
GLADE_MAKE_EPROP (GladeEPropColor, glade_eprop_color)
@@ -1139,104 +1123,100 @@ GLADE_MAKE_EPROP (GladeEPropColor, glade_eprop_color)
#define GLADE_IS_EPROP_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_COLOR))
#define GLADE_IS_EPROP_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_COLOR))
#define GLADE_EPROP_COLOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_COLOR, GladeEPropColorClass))
-
-
-static void
-glade_eprop_color_finalize (GObject *object)
+ static void glade_eprop_color_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_color_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
- GdkColor *color;
- gchar *text;
-
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- if (property)
- {
- if ((text = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
- eprop->klass, property->value)) != NULL)
- {
- gtk_entry_set_text (GTK_ENTRY (eprop_color->entry), text);
- g_free (text);
- }
- else
- gtk_entry_set_text (GTK_ENTRY (eprop_color->entry), "");
-
- if ((color = g_value_get_boxed (property->value)) != NULL)
- gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton),
- color);
- else
- {
- GdkColor black = { 0, };
-
- /* Manually fill it with black for an NULL value.
- */
- if (gdk_color_parse("Black", &black))
- gtk_color_button_set_color
- (GTK_COLOR_BUTTON (eprop_color->cbutton),
- &black);
- }
- }
+glade_eprop_color_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
+ GdkColor *color;
+ gchar *text;
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
+
+ if (property)
+ {
+ if ((text = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
+ eprop->klass, property->value)) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (eprop_color->entry), text);
+ g_free (text);
+ }
+ else
+ gtk_entry_set_text (GTK_ENTRY (eprop_color->entry), "");
+
+ if ((color = g_value_get_boxed (property->value)) != NULL)
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton),
+ color);
+ else
+ {
+ GdkColor black = { 0, };
+
+ /* Manually fill it with black for an NULL value.
+ */
+ if (gdk_color_parse ("Black", &black))
+ gtk_color_button_set_color
+ (GTK_COLOR_BUTTON (eprop_color->cbutton), &black);
+ }
+ }
}
static void
-glade_eprop_color_changed (GtkWidget *button,
- GladeEditorProperty *eprop)
+glade_eprop_color_changed (GtkWidget * button, GladeEditorProperty * eprop)
{
- GdkColor color = { 0, };
- GValue value = { 0, };
+ GdkColor color = { 0, };
+ GValue value = { 0, };
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
- g_value_init (&value, GDK_TYPE_COLOR);
- g_value_set_boxed (&value, &color);
+ g_value_init (&value, GDK_TYPE_COLOR);
+ g_value_set_boxed (&value, &color);
- glade_editor_property_commit_no_callback (eprop, &value);
- g_value_unset (&value);
+ glade_editor_property_commit_no_callback (eprop, &value);
+ g_value_unset (&value);
}
static GtkWidget *
-glade_eprop_color_create_input (GladeEditorProperty *eprop)
+glade_eprop_color_create_input (GladeEditorProperty * eprop)
{
- GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
- GtkWidget *hbox;
+ GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
+ GtkWidget *hbox;
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
- eprop_color->entry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (eprop_color->entry), FALSE);
- gtk_widget_show (eprop_color->entry);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_color->entry, TRUE, TRUE, 0);
+ eprop_color->entry = gtk_entry_new ();
+ gtk_editable_set_editable (GTK_EDITABLE (eprop_color->entry), FALSE);
+ gtk_widget_show (eprop_color->entry);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_color->entry, TRUE, TRUE, 0);
- eprop_color->cbutton = gtk_color_button_new ();
- gtk_widget_show (eprop_color->cbutton);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_color->cbutton, FALSE, FALSE, 0);
+ eprop_color->cbutton = gtk_color_button_new ();
+ gtk_widget_show (eprop_color->cbutton);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_color->cbutton, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (eprop_color->cbutton), "color-set",
- G_CALLBACK (glade_eprop_color_changed),
- eprop);
+ g_signal_connect (G_OBJECT (eprop_color->cbutton), "color-set",
+ G_CALLBACK (glade_eprop_color_changed), eprop);
- return hbox;
+ return hbox;
}
/*******************************************************************************
GladeEditorPropertyNamedIconClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *entry;
- gchar *current_context;
+ GtkWidget *entry;
+ gchar *current_context;
} GladeEPropNamedIcon;
GLADE_MAKE_EPROP (GladeEPropNamedIcon, glade_eprop_named_icon)
@@ -1245,196 +1225,197 @@ GLADE_MAKE_EPROP (GladeEPropNamedIcon, glade_eprop_named_icon)
#define GLADE_IS_EPROP_NAMED_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_NAMED_ICON))
#define GLADE_IS_EPROP_NAMED_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_NAMED_ICON))
#define GLADE_EPROP_NAMED_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_NAMED_ICON, GladeEPropNamedIconClass))
-
-
-static void
-glade_eprop_named_icon_finalize (GObject *object)
+ static void glade_eprop_named_icon_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_named_icon_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_eprop_named_icon_load (GladeEditorProperty * eprop,
+ GladeProperty * property)
{
- GladeEPropNamedIcon *eprop_named_icon = GLADE_EPROP_NAMED_ICON (eprop);
- GtkEntry *entry;
- const gchar *text;
+ GladeEPropNamedIcon *eprop_named_icon = GLADE_EPROP_NAMED_ICON (eprop);
+ GtkEntry *entry;
+ const gchar *text;
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
+
+ if (property == NULL)
+ return;
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- if (property == NULL)
- return;
-
- entry = GTK_ENTRY (eprop_named_icon->entry);
- text = g_value_get_string (property->value);
+ entry = GTK_ENTRY (eprop_named_icon->entry);
+ text = g_value_get_string (property->value);
- gtk_entry_set_text (entry, text ? text : "");
+ gtk_entry_set_text (entry, text ? text : "");
}
static void
-glade_eprop_named_icon_changed_common (GladeEditorProperty *eprop,
- const gchar *text,
- gboolean use_command)
+glade_eprop_named_icon_changed_common (GladeEditorProperty * eprop,
+ const gchar * text, gboolean use_command)
{
- GValue *val;
- gchar *prop_text;
+ GValue *val;
+ gchar *prop_text;
- val = g_new0 (GValue, 1);
-
- g_value_init (val, G_TYPE_STRING);
+ val = g_new0 (GValue, 1);
- glade_property_get (eprop->property, &prop_text);
+ g_value_init (val, G_TYPE_STRING);
- /* Here we try not to modify the project state by not
- * modifying a null value for an unchanged property.
- */
- if (prop_text == NULL &&
- text && text[0] == '\0')
- g_value_set_string (val, NULL);
- else if (text == NULL &&
- prop_text && prop_text == '\0')
- g_value_set_string (val, "");
- else
- g_value_set_string (val, text);
+ glade_property_get (eprop->property, &prop_text);
+
+ /* Here we try not to modify the project state by not
+ * modifying a null value for an unchanged property.
+ */
+ if (prop_text == NULL && text && text[0] == '\0')
+ g_value_set_string (val, NULL);
+ else if (text == NULL && prop_text && prop_text == '\0')
+ g_value_set_string (val, "");
+ else
+ g_value_set_string (val, text);
- glade_editor_property_commit (eprop, val);
- g_value_unset (val);
- g_free (val);
+ glade_editor_property_commit (eprop, val);
+ g_value_unset (val);
+ g_free (val);
}
static void
-glade_eprop_named_icon_changed (GtkWidget *entry,
- GladeEditorProperty *eprop)
+glade_eprop_named_icon_changed (GtkWidget * entry, GladeEditorProperty * eprop)
{
- gchar *text;
+ gchar *text;
+
+ if (eprop->loading)
+ return;
- if (eprop->loading)
- return;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- glade_eprop_named_icon_changed_common (eprop, text, eprop->use_command);
-
- g_free (text);
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ glade_eprop_named_icon_changed_common (eprop, text, eprop->use_command);
+
+ g_free (text);
}
static gboolean
-glade_eprop_named_icon_focus_out (GtkWidget *entry,
- GdkEventFocus *event,
- GladeEditorProperty *eprop)
+glade_eprop_named_icon_focus_out (GtkWidget * entry,
+ GdkEventFocus * event,
+ GladeEditorProperty * eprop)
{
- glade_eprop_named_icon_changed (entry, eprop);
- return FALSE;
+ glade_eprop_named_icon_changed (entry, eprop);
+ return FALSE;
}
-static void
-glade_eprop_named_icon_activate (GtkEntry *entry,
- GladeEPropNamedIcon *eprop)
+static void
+glade_eprop_named_icon_activate (GtkEntry * entry, GladeEPropNamedIcon * eprop)
{
- glade_eprop_named_icon_changed (GTK_WIDGET (entry), GLADE_EDITOR_PROPERTY (eprop));
+ glade_eprop_named_icon_changed (GTK_WIDGET (entry),
+ GLADE_EDITOR_PROPERTY (eprop));
}
static void
-chooser_response (GladeNamedIconChooserDialog *dialog,
- gint response_id,
- GladeEPropNamedIcon *eprop)
-{
- gchar *icon_name;
-
- switch (response_id) {
-
- case GTK_RESPONSE_OK:
-
- g_free (eprop->current_context);
- eprop->current_context = glade_named_icon_chooser_dialog_get_context (dialog);
- icon_name = glade_named_icon_chooser_dialog_get_icon_name (dialog);
-
- gtk_entry_set_text (GTK_ENTRY (eprop->entry), icon_name);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
- g_free (icon_name);
-
- glade_eprop_named_icon_changed (eprop->entry, GLADE_EDITOR_PROPERTY (eprop));
-
- break;
-
- case GTK_RESPONSE_CANCEL:
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
- break;
-
- case GTK_RESPONSE_HELP:
-
- break;
-
- case GTK_RESPONSE_DELETE_EVENT:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- }
+chooser_response (GladeNamedIconChooserDialog * dialog,
+ gint response_id, GladeEPropNamedIcon * eprop)
+{
+ gchar *icon_name;
+
+ switch (response_id)
+ {
+
+ case GTK_RESPONSE_OK:
+
+ g_free (eprop->current_context);
+ eprop->current_context =
+ glade_named_icon_chooser_dialog_get_context (dialog);
+ icon_name = glade_named_icon_chooser_dialog_get_icon_name (dialog);
+
+ gtk_entry_set_text (GTK_ENTRY (eprop->entry), icon_name);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ g_free (icon_name);
+
+ glade_eprop_named_icon_changed (eprop->entry,
+ GLADE_EDITOR_PROPERTY (eprop));
+
+ break;
+
+ case GTK_RESPONSE_CANCEL:
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+
+ case GTK_RESPONSE_HELP:
+
+ break;
+
+ case GTK_RESPONSE_DELETE_EVENT:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
}
static void
-glade_eprop_named_icon_show_chooser_dialog (GtkWidget *button,
- GladeEditorProperty *eprop)
+glade_eprop_named_icon_show_chooser_dialog (GtkWidget * button,
+ GladeEditorProperty * eprop)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- dialog = glade_named_icon_chooser_dialog_new (_("Select Named Icon"),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (eprop))),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ dialog = glade_named_icon_chooser_dialog_new (_("Select Named Icon"),
+ GTK_WINDOW
+ (gtk_widget_get_toplevel
+ (GTK_WIDGET (eprop))),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
- glade_named_icon_chooser_dialog_set_context (GLADE_NAMED_ICON_CHOOSER_DIALOG (dialog), GLADE_EPROP_NAMED_ICON (eprop)->current_context);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- glade_named_icon_chooser_dialog_set_icon_name (GLADE_NAMED_ICON_CHOOSER_DIALOG (dialog),
- gtk_entry_get_text (GTK_ENTRY (GLADE_EPROP_NAMED_ICON (eprop)->entry)));
+ glade_named_icon_chooser_dialog_set_context (GLADE_NAMED_ICON_CHOOSER_DIALOG
+ (dialog),
+ GLADE_EPROP_NAMED_ICON (eprop)->
+ current_context);
+ glade_named_icon_chooser_dialog_set_icon_name (GLADE_NAMED_ICON_CHOOSER_DIALOG
+ (dialog),
+ gtk_entry_get_text (GTK_ENTRY
+ (GLADE_EPROP_NAMED_ICON
+ (eprop)->
+ entry)));
- g_signal_connect (dialog, "response",
- G_CALLBACK (chooser_response),
- eprop);
- gtk_widget_show (dialog);
+ g_signal_connect (dialog, "response", G_CALLBACK (chooser_response), eprop);
+
+ gtk_widget_show (dialog);
}
static GtkWidget *
-glade_eprop_named_icon_create_input (GladeEditorProperty *eprop)
+glade_eprop_named_icon_create_input (GladeEditorProperty * eprop)
{
- GladeEPropNamedIcon *eprop_named_icon = GLADE_EPROP_NAMED_ICON (eprop);
- GtkWidget *hbox;
- GtkWidget *button;
+ GladeEPropNamedIcon *eprop_named_icon = GLADE_EPROP_NAMED_ICON (eprop);
+ GtkWidget *hbox;
+ GtkWidget *button;
+
+ hbox = gtk_hbox_new (FALSE, 0);
+
+ eprop_named_icon->entry = gtk_entry_new ();
+ gtk_widget_show (eprop_named_icon->entry);
- hbox = gtk_hbox_new (FALSE, 0);
+ eprop_named_icon->current_context = NULL;
- eprop_named_icon->entry = gtk_entry_new ();
- gtk_widget_show (eprop_named_icon->entry);
-
- eprop_named_icon->current_context = NULL;
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_named_icon->entry, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_named_icon->entry, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (eprop_named_icon->entry), "activate",
+ G_CALLBACK (glade_eprop_named_icon_activate), eprop);
- g_signal_connect (G_OBJECT (eprop_named_icon->entry), "activate",
- G_CALLBACK (glade_eprop_named_icon_activate),
- eprop);
-
- g_signal_connect (G_OBJECT (eprop_named_icon->entry), "focus-out-event",
- G_CALLBACK (glade_eprop_named_icon_focus_out),
- eprop);
+ g_signal_connect (G_OBJECT (eprop_named_icon->entry), "focus-out-event",
+ G_CALLBACK (glade_eprop_named_icon_focus_out), eprop);
- button = gtk_button_new_with_label ("\342\200\246");
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (button, "clicked",
- G_CALLBACK (glade_eprop_named_icon_show_chooser_dialog),
- eprop);
+ button = gtk_button_new_with_label ("\342\200\246");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eprop_named_icon_show_chooser_dialog),
+ eprop);
- return hbox;
+ return hbox;
}
@@ -1442,11 +1423,12 @@ glade_eprop_named_icon_create_input (GladeEditorProperty *eprop)
/*******************************************************************************
GladeEditorPropertyTextClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *text_entry;
- GtkTreeModel *store;
+ GtkWidget *text_entry;
+ GtkTreeModel *store;
} GladeEPropText;
GLADE_MAKE_EPROP (GladeEPropText, glade_eprop_text)
@@ -1455,155 +1437,157 @@ GLADE_MAKE_EPROP (GladeEPropText, glade_eprop_text)
#define GLADE_IS_EPROP_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_TEXT))
#define GLADE_IS_EPROP_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_TEXT))
#define GLADE_EPROP_TEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_TEXT, GladeEPropTextClass))
-
-static void
-glade_eprop_text_finalize (GObject *object)
+ static void glade_eprop_text_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_text_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeEPropText *eprop_text = GLADE_EPROP_TEXT (eprop);
-
- /* Chain up first */
- editor_property_class->load (eprop, property);
-
- if (property == NULL) return;
-
- if (GTK_IS_COMBO_BOX (eprop_text->text_entry))
- {
- if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (eprop_text->text_entry)))
- {
- const gchar *text = g_value_get_string (property->value);
- if (!text) text = "";
- gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (eprop_text->text_entry))), text);
- }
- else
- {
- const gchar *text = g_value_get_string (property->value);
- gint value = text ?
- glade_utils_enum_value_from_string (GLADE_TYPE_STOCK, text) : 0;
-
- /* Set active iter... */
- gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_text->text_entry), value);
- }
- }
- else if (GTK_IS_ENTRY (eprop_text->text_entry))
- {
- GtkEntry *entry = GTK_ENTRY (eprop_text->text_entry);
- const gchar *text = NULL;
-
- if (G_VALUE_TYPE (property->value) == G_TYPE_STRING)
- text = g_value_get_string (property->value);
- else if (G_VALUE_TYPE (property->value) == GDK_TYPE_PIXBUF)
- {
- GObject *object = g_value_get_object (property->value);
- if (object)
- text = g_object_get_data (object, "GladeFileName");
- }
- gtk_entry_set_text (entry, text ? text : "");
- }
- else if (GTK_IS_TEXT_VIEW (eprop_text->text_entry))
- {
- GtkTextBuffer *buffer;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (eprop_text->text_entry));
-
- if (G_VALUE_HOLDS (property->value, G_TYPE_STRV) ||
- G_VALUE_HOLDS (property->value, G_TYPE_VALUE_ARRAY))
- {
- gchar *text = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, property->value);
- gtk_text_buffer_set_text (buffer, text ? text : "", -1);
- g_free (text);
- }
- else
- {
- const gchar *text = g_value_get_string (property->value);
- gtk_text_buffer_set_text (buffer, text ? text : "", -1);
- }
- }
- else
- {
- g_warning ("BUG! Invalid Text Widget type.");
- }
+glade_eprop_text_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ GladeEPropText *eprop_text = GLADE_EPROP_TEXT (eprop);
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
+
+ if (property == NULL)
+ return;
+
+ if (GTK_IS_COMBO_BOX (eprop_text->text_entry))
+ {
+ if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (eprop_text->text_entry)))
+ {
+ const gchar *text = g_value_get_string (property->value);
+ if (!text)
+ text = "";
+ gtk_entry_set_text (GTK_ENTRY
+ (gtk_bin_get_child
+ (GTK_BIN (eprop_text->text_entry))), text);
+ }
+ else
+ {
+ const gchar *text = g_value_get_string (property->value);
+ gint value = text ?
+ glade_utils_enum_value_from_string (GLADE_TYPE_STOCK, text) : 0;
+
+ /* Set active iter... */
+ gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_text->text_entry),
+ value);
+ }
+ }
+ else if (GTK_IS_ENTRY (eprop_text->text_entry))
+ {
+ GtkEntry *entry = GTK_ENTRY (eprop_text->text_entry);
+ const gchar *text = NULL;
+
+ if (G_VALUE_TYPE (property->value) == G_TYPE_STRING)
+ text = g_value_get_string (property->value);
+ else if (G_VALUE_TYPE (property->value) == GDK_TYPE_PIXBUF)
+ {
+ GObject *object = g_value_get_object (property->value);
+ if (object)
+ text = g_object_get_data (object, "GladeFileName");
+ }
+ gtk_entry_set_text (entry, text ? text : "");
+ }
+ else if (GTK_IS_TEXT_VIEW (eprop_text->text_entry))
+ {
+ GtkTextBuffer *buffer;
+
+ buffer =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (eprop_text->text_entry));
+
+ if (G_VALUE_HOLDS (property->value, G_TYPE_STRV) ||
+ G_VALUE_HOLDS (property->value, G_TYPE_VALUE_ARRAY))
+ {
+ gchar *text = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle),
+ property->klass, property->value);
+ gtk_text_buffer_set_text (buffer, text ? text : "", -1);
+ g_free (text);
+ }
+ else
+ {
+ const gchar *text = g_value_get_string (property->value);
+ gtk_text_buffer_set_text (buffer, text ? text : "", -1);
+ }
+ }
+ else
+ {
+ g_warning ("BUG! Invalid Text Widget type.");
+ }
}
static void
-glade_eprop_text_changed_common (GladeEditorProperty *eprop,
- const gchar *text,
- gboolean use_command)
-{
- GValue *val;
- gchar *prop_text;
-
- if (eprop->property->klass->pspec->value_type == G_TYPE_STRV ||
- eprop->property->klass->pspec->value_type == G_TYPE_VALUE_ARRAY ||
- eprop->property->klass->pspec->value_type == GDK_TYPE_PIXBUF)
- {
- val = glade_property_class_make_gvalue_from_string
- (eprop->property->klass, text,
- eprop->property->widget->project, eprop->property->widget);
- }
- else
- {
- val = g_new0 (GValue, 1);
-
- g_value_init (val, G_TYPE_STRING);
-
- glade_property_get (eprop->property, &prop_text);
-
- /* Here we try not to modify the project state by not
- * modifying a null value for an unchanged property.
- */
- if (prop_text == NULL &&
- text && text[0] == '\0')
- g_value_set_string (val, NULL);
- else if (text == NULL &&
- prop_text && prop_text == '\0')
- g_value_set_string (val, "");
- else
- g_value_set_string (val, text);
- }
-
- glade_editor_property_commit_no_callback (eprop, val);
- g_value_unset (val);
- g_free (val);
+glade_eprop_text_changed_common (GladeEditorProperty * eprop,
+ const gchar * text, gboolean use_command)
+{
+ GValue *val;
+ gchar *prop_text;
+
+ if (eprop->property->klass->pspec->value_type == G_TYPE_STRV ||
+ eprop->property->klass->pspec->value_type == G_TYPE_VALUE_ARRAY ||
+ eprop->property->klass->pspec->value_type == GDK_TYPE_PIXBUF)
+ {
+ val = glade_property_class_make_gvalue_from_string
+ (eprop->property->klass, text,
+ eprop->property->widget->project, eprop->property->widget);
+ }
+ else
+ {
+ val = g_new0 (GValue, 1);
+
+ g_value_init (val, G_TYPE_STRING);
+
+ glade_property_get (eprop->property, &prop_text);
+
+ /* Here we try not to modify the project state by not
+ * modifying a null value for an unchanged property.
+ */
+ if (prop_text == NULL && text && text[0] == '\0')
+ g_value_set_string (val, NULL);
+ else if (text == NULL && prop_text && prop_text == '\0')
+ g_value_set_string (val, "");
+ else
+ g_value_set_string (val, text);
+ }
+
+ glade_editor_property_commit_no_callback (eprop, val);
+ g_value_unset (val);
+ g_free (val);
}
static void
-glade_eprop_text_changed (GtkWidget *entry,
- GladeEditorProperty *eprop)
+glade_eprop_text_changed (GtkWidget * entry, GladeEditorProperty * eprop)
{
- gchar *text;
+ gchar *text;
+
+ if (eprop->loading)
+ return;
+
+ text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+ glade_eprop_text_changed_common (eprop, text, eprop->use_command);
- if (eprop->loading) return;
-
- text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
- glade_eprop_text_changed_common (eprop, text, eprop->use_command);
-
- g_free (text);
+ g_free (text);
}
static void
-glade_eprop_text_buffer_changed (GtkTextBuffer *buffer,
- GladeEditorProperty *eprop)
+glade_eprop_text_buffer_changed (GtkTextBuffer * buffer,
+ GladeEditorProperty * eprop)
{
- gchar *text;
- GtkTextIter start, end;
-
- if (eprop->loading) return;
+ gchar *text;
+ GtkTextIter start, end;
- gtk_text_buffer_get_start_iter (buffer, &start);
- gtk_text_buffer_get_end_iter (buffer, &end);
+ if (eprop->loading)
+ return;
- text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
- glade_eprop_text_changed_common (eprop, text, eprop->use_command);
- g_free (text);
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ gtk_text_buffer_get_end_iter (buffer, &end);
+
+ text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ glade_eprop_text_changed_common (eprop, text, eprop->use_command);
+ g_free (text);
}
/**
@@ -1619,492 +1603,501 @@ glade_eprop_text_buffer_changed (GtkTextBuffer *buffer,
* Returns: %TRUE if OK was selected.
*/
gboolean
-glade_editor_property_show_i18n_dialog (GtkWidget *parent,
- gchar **text,
- gchar **context,
- gchar **comment,
- gboolean *translatable)
-{
- GtkWidget *dialog;
- GtkWidget *vbox, *hbox;
- GtkWidget *label;
- GtkWidget *sw;
- GtkWidget *alignment;
- GtkWidget *text_view, *comment_view, *context_view;
- GtkTextBuffer *text_buffer, *comment_buffer, *context_buffer = NULL;
- GtkWidget *translatable_button;
- GtkWidget *content_area, *action_area;
- gint res;
-
- g_return_val_if_fail (text && context && comment && translatable, FALSE);
-
- dialog = gtk_dialog_new_with_buttons (_("Edit Text"),
- parent ? GTK_WINDOW (gtk_widget_get_toplevel (parent)) : NULL,
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CANCEL,
- -1);
-
- /* HIG spacings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
-
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- gtk_widget_show (vbox);
-
- gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
-
- /* Text */
- label = gtk_label_new_with_mnemonic (_("_Text:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- text_view = gtk_text_view_new ();
- gtk_widget_show (text_view);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), text_view);
-
- gtk_container_add (GTK_CONTAINER (sw), text_view);
-
- text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
-
- if (*text)
- {
- gtk_text_buffer_set_text (text_buffer,
- *text,
- -1);
- }
-
- /* Translatable and context prefix. */
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
-
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- /* Translatable */
- translatable_button = gtk_check_button_new_with_mnemonic (_("T_ranslatable"));
- gtk_widget_show (translatable_button);
- gtk_box_pack_start (GTK_BOX (hbox), translatable_button, FALSE, FALSE, 0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (translatable_button), *translatable);
- gtk_widget_set_tooltip_text (translatable_button,
- _("Whether this property is translatable"));
-
-
- /* Context. */
- alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
- gtk_widget_show (alignment);
-
- label = gtk_label_new_with_mnemonic (_("Conte_xt for translation:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_container_add (GTK_CONTAINER (alignment), label);
- gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
- gtk_widget_set_tooltip_text (alignment,
- "XXX Some explanation about translation context please ???");
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- context_view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (context_view), GTK_WRAP_WORD);
- gtk_widget_show (context_view);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), context_view);
-
- gtk_container_add (GTK_CONTAINER (sw), context_view);
-
- context_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (context_view));
-
- if (*context)
- {
- gtk_text_buffer_set_text (context_buffer,
- *context,
- -1);
- }
-
- /* Comments. */
- alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
- gtk_widget_show (alignment);
-
- label = gtk_label_new_with_mnemonic (_("Co_mments for translators:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_container_add (GTK_CONTAINER (alignment), label);
- gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- comment_view = gtk_text_view_new ();
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (comment_view), GTK_WRAP_WORD);
- gtk_widget_show (comment_view);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), comment_view);
-
- gtk_container_add (GTK_CONTAINER (sw), comment_view);
-
- comment_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view));
-
- if (*comment)
- {
- gtk_text_buffer_set_text (comment_buffer,
- *comment,
- -1);
- }
-
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK) {
- GtkTextIter start, end;
-
- g_free ((gpointer)*text);
- g_free ((gpointer)*context);
- g_free ((gpointer)*comment);
-
- /* get the new values for translatable, has_context, and comment */
- *translatable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (translatable_button));
-
- /* Comment */
- gtk_text_buffer_get_bounds (comment_buffer, &start, &end);
- *comment = gtk_text_buffer_get_text (comment_buffer, &start, &end, TRUE);
- if (*comment[0] == '\0')
- {
- g_free (*comment);
- *comment = NULL;
- }
-
- /* Text */
- gtk_text_buffer_get_bounds (text_buffer, &start, &end);
- *text = gtk_text_buffer_get_text (text_buffer, &start, &end, TRUE);
- if (*text[0] == '\0')
- {
- g_free (*text);
- *text = NULL;
- }
-
- /* Context */
- gtk_text_buffer_get_bounds (context_buffer, &start, &end);
- *context = gtk_text_buffer_get_text (context_buffer, &start, &end, TRUE);
- if (*context[0] == '\0')
- {
- g_free (*context);
- *context = NULL;
- }
-
- gtk_widget_destroy (dialog);
- return TRUE;
- }
-
- gtk_widget_destroy (dialog);
- return FALSE;
+glade_editor_property_show_i18n_dialog (GtkWidget * parent,
+ gchar ** text,
+ gchar ** context,
+ gchar ** comment,
+ gboolean * translatable)
+{
+ GtkWidget *dialog;
+ GtkWidget *vbox, *hbox;
+ GtkWidget *label;
+ GtkWidget *sw;
+ GtkWidget *alignment;
+ GtkWidget *text_view, *comment_view, *context_view;
+ GtkTextBuffer *text_buffer, *comment_buffer, *context_buffer = NULL;
+ GtkWidget *translatable_button;
+ GtkWidget *content_area, *action_area;
+ gint res;
+
+ g_return_val_if_fail (text && context && comment && translatable, FALSE);
+
+ dialog = gtk_dialog_new_with_buttons (_("Edit Text"),
+ parent ?
+ GTK_WINDOW (gtk_widget_get_toplevel
+ (parent)) : NULL,
+ GTK_DIALOG_MODAL, GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL, GTK_STOCK_OK,
+ GTK_RESPONSE_OK, NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL, -1);
+
+ /* HIG spacings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
+
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_widget_show (vbox);
+
+ gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+
+ /* Text */
+ label = gtk_label_new_with_mnemonic (_("_Text:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ text_view = gtk_text_view_new ();
+ gtk_widget_show (text_view);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), text_view);
+
+ gtk_container_add (GTK_CONTAINER (sw), text_view);
+
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
+
+ if (*text)
+ {
+ gtk_text_buffer_set_text (text_buffer, *text, -1);
+ }
+
+ /* Translatable and context prefix. */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+ /* Translatable */
+ translatable_button = gtk_check_button_new_with_mnemonic (_("T_ranslatable"));
+ gtk_widget_show (translatable_button);
+ gtk_box_pack_start (GTK_BOX (hbox), translatable_button, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (translatable_button),
+ *translatable);
+ gtk_widget_set_tooltip_text (translatable_button,
+ _("Whether this property is translatable"));
+
+
+ /* Context. */
+ alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
+ gtk_widget_show (alignment);
+
+ label = gtk_label_new_with_mnemonic (_("Conte_xt for translation:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_container_add (GTK_CONTAINER (alignment), label);
+ gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
+ gtk_widget_set_tooltip_text (alignment,
+ "XXX Some explanation about translation context please ???");
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ context_view = gtk_text_view_new ();
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (context_view), GTK_WRAP_WORD);
+ gtk_widget_show (context_view);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), context_view);
+
+ gtk_container_add (GTK_CONTAINER (sw), context_view);
+
+ context_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (context_view));
+
+ if (*context)
+ {
+ gtk_text_buffer_set_text (context_buffer, *context, -1);
+ }
+
+ /* Comments. */
+ alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 0, 0, 0);
+ gtk_widget_show (alignment);
+
+ label = gtk_label_new_with_mnemonic (_("Co_mments for translators:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_container_add (GTK_CONTAINER (alignment), label);
+ gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ comment_view = gtk_text_view_new ();
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (comment_view), GTK_WRAP_WORD);
+ gtk_widget_show (comment_view);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), comment_view);
+
+ gtk_container_add (GTK_CONTAINER (sw), comment_view);
+
+ comment_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view));
+
+ if (*comment)
+ {
+ gtk_text_buffer_set_text (comment_buffer, *comment, -1);
+ }
+
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+ GtkTextIter start, end;
+
+ g_free ((gpointer) * text);
+ g_free ((gpointer) * context);
+ g_free ((gpointer) * comment);
+
+ /* get the new values for translatable, has_context, and comment */
+ *translatable =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (translatable_button));
+
+ /* Comment */
+ gtk_text_buffer_get_bounds (comment_buffer, &start, &end);
+ *comment = gtk_text_buffer_get_text (comment_buffer, &start, &end, TRUE);
+ if (*comment[0] == '\0')
+ {
+ g_free (*comment);
+ *comment = NULL;
+ }
+
+ /* Text */
+ gtk_text_buffer_get_bounds (text_buffer, &start, &end);
+ *text = gtk_text_buffer_get_text (text_buffer, &start, &end, TRUE);
+ if (*text[0] == '\0')
+ {
+ g_free (*text);
+ *text = NULL;
+ }
+
+ /* Context */
+ gtk_text_buffer_get_bounds (context_buffer, &start, &end);
+ *context = gtk_text_buffer_get_text (context_buffer, &start, &end, TRUE);
+ if (*context[0] == '\0')
+ {
+ g_free (*context);
+ *context = NULL;
+ }
+
+ gtk_widget_destroy (dialog);
+ return TRUE;
+ }
+
+ gtk_widget_destroy (dialog);
+ return FALSE;
}
static void
-glade_eprop_text_show_i18n_dialog (GtkWidget *entry,
- GladeEditorProperty *eprop)
+glade_eprop_text_show_i18n_dialog (GtkWidget * entry,
+ GladeEditorProperty * eprop)
{
- gchar *text = g_value_dup_string (eprop->property->value);
- gchar *context = g_strdup (glade_property_i18n_get_context (eprop->property));
- gchar *comment = g_strdup (glade_property_i18n_get_comment (eprop->property));
- gboolean translatable = glade_property_i18n_get_translatable (eprop->property);
+ gchar *text = g_value_dup_string (eprop->property->value);
+ gchar *context = g_strdup (glade_property_i18n_get_context (eprop->property));
+ gchar *comment = g_strdup (glade_property_i18n_get_comment (eprop->property));
+ gboolean translatable =
+ glade_property_i18n_get_translatable (eprop->property);
- if (glade_editor_property_show_i18n_dialog (entry, &text, &context, &comment, &translatable))
- {
- glade_command_set_i18n (eprop->property, translatable, context, comment);
- glade_eprop_text_changed_common (eprop, text, eprop->use_command);
+ if (glade_editor_property_show_i18n_dialog
+ (entry, &text, &context, &comment, &translatable))
+ {
+ glade_command_set_i18n (eprop->property, translatable, context, comment);
+ glade_eprop_text_changed_common (eprop, text, eprop->use_command);
- glade_editor_property_load (eprop, eprop->property);
+ glade_editor_property_load (eprop, eprop->property);
- g_free (text);
- g_free (context);
- g_free (comment);
- }
+ g_free (text);
+ g_free (context);
+ g_free (comment);
+ }
}
gboolean
-glade_editor_property_show_resource_dialog (GladeProject *project, GtkWidget *parent, gchar **filename)
+glade_editor_property_show_resource_dialog (GladeProject * project,
+ GtkWidget * parent,
+ gchar ** filename)
{
- GtkWidget *dialog;
- GtkWidget *action_area;
- gchar *folder;
+ GtkWidget *dialog;
+ GtkWidget *action_area;
+ gchar *folder;
+
+ g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
+ dialog =
+ gtk_file_chooser_dialog_new (_
+ ("Select a file from the project resource directory"),
+ parent ?
+ GTK_WINDOW (gtk_widget_get_toplevel (parent))
+ : NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
- dialog = gtk_file_chooser_dialog_new (_("Select a file from the project resource directory"),
- parent ? GTK_WINDOW (gtk_widget_get_toplevel (parent)) : NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL, -1);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CANCEL,
- -1);
+ /* HIG spacings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); /* 2 * 5 + 2 = 12 */
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
- /* HIG spacings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); /* 2 * 5 + 2 = 12 */
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
+ folder = glade_project_resource_fullpath (project, ".");
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), folder);
+ g_free (folder);
- folder = glade_project_resource_fullpath (project, ".");
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), folder);
- g_free (folder);
-
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
- {
- gchar *name;
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ {
+ gchar *name;
- name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- *filename = name ? g_path_get_basename (name) : NULL;
+ *filename = name ? g_path_get_basename (name) : NULL;
- g_free (name);
- gtk_widget_destroy (dialog);
- return TRUE;
- }
+ g_free (name);
+ gtk_widget_destroy (dialog);
+ return TRUE;
+ }
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (dialog);
- return FALSE;
+ return FALSE;
}
static void
-glade_eprop_text_show_resource_dialog (GtkWidget *entry,
- GladeEditorProperty *eprop)
+glade_eprop_text_show_resource_dialog (GtkWidget * entry,
+ GladeEditorProperty * eprop)
{
- GladeProject *project = eprop->property->widget->project;
- gchar *text = NULL;
+ GladeProject *project = eprop->property->widget->project;
+ gchar *text = NULL;
- if (glade_editor_property_show_resource_dialog (project, entry, &text))
- {
- glade_eprop_text_changed_common (eprop, text, eprop->use_command);
+ if (glade_editor_property_show_resource_dialog (project, entry, &text))
+ {
+ glade_eprop_text_changed_common (eprop, text, eprop->use_command);
- glade_editor_property_load (eprop, eprop->property);
+ glade_editor_property_load (eprop, eprop->property);
- g_free (text);
- }
+ g_free (text);
+ }
}
-enum {
- COMBO_COLUMN_TEXT = 0,
- COMBO_COLUMN_PIXBUF,
- COMBO_LAST_COLUMN
+enum
+{
+ COMBO_COLUMN_TEXT = 0,
+ COMBO_COLUMN_PIXBUF,
+ COMBO_LAST_COLUMN
};
static GtkListStore *
glade_eprop_text_create_store (GType enum_type)
{
- GtkListStore *store;
- GtkTreeIter iter;
- GEnumClass *eclass;
- guint i;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GEnumClass *eclass;
+ guint i;
- eclass = g_type_class_ref (enum_type);
+ eclass = g_type_class_ref (enum_type);
- store = gtk_list_store_new (COMBO_LAST_COLUMN,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- for (i = 0; i < eclass->n_values; i++)
- {
- const gchar *displayable = glade_get_displayable_value (enum_type, eclass->values[i].value_nick);
- if (!displayable)
- displayable = eclass->values[i].value_nick;
+ store = gtk_list_store_new (COMBO_LAST_COLUMN, G_TYPE_STRING, G_TYPE_STRING);
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COMBO_COLUMN_TEXT, displayable,
- COMBO_COLUMN_PIXBUF, eclass->values[i].value_nick,
- -1);
- }
+ for (i = 0; i < eclass->n_values; i++)
+ {
+ const gchar *displayable =
+ glade_get_displayable_value (enum_type, eclass->values[i].value_nick);
+ if (!displayable)
+ displayable = eclass->values[i].value_nick;
- g_type_class_unref (eclass);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COMBO_COLUMN_TEXT, displayable,
+ COMBO_COLUMN_PIXBUF, eclass->values[i].value_nick,
+ -1);
+ }
- return store;
+ g_type_class_unref (eclass);
+
+ return store;
}
static void
-eprop_text_stock_changed (GtkComboBox *combo,
- GladeEditorProperty *eprop)
-{
- GladeEPropText *eprop_text = GLADE_EPROP_TEXT (eprop);
- GtkTreeIter iter;
- gchar *text = NULL;
- const gchar *str;
-
- if (eprop->loading) return;
-
- if (gtk_combo_box_get_active_iter (combo, &iter))
- {
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_text->store), &iter,
- COMBO_COLUMN_PIXBUF, &text,
- -1);
- glade_eprop_text_changed_common (eprop, text, eprop->use_command);
- g_free (text);
- }
- else if (gtk_combo_box_get_has_entry (combo))
- {
- str = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo))));
- glade_eprop_text_changed_common (eprop, str, eprop->use_command);
- }
+eprop_text_stock_changed (GtkComboBox * combo, GladeEditorProperty * eprop)
+{
+ GladeEPropText *eprop_text = GLADE_EPROP_TEXT (eprop);
+ GtkTreeIter iter;
+ gchar *text = NULL;
+ const gchar *str;
+
+ if (eprop->loading)
+ return;
+
+ if (gtk_combo_box_get_active_iter (combo, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_text->store), &iter,
+ COMBO_COLUMN_PIXBUF, &text, -1);
+ glade_eprop_text_changed_common (eprop, text, eprop->use_command);
+ g_free (text);
+ }
+ else if (gtk_combo_box_get_has_entry (combo))
+ {
+ str =
+ gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo))));
+ glade_eprop_text_changed_common (eprop, str, eprop->use_command);
+ }
}
static GtkWidget *
-glade_eprop_text_create_input (GladeEditorProperty *eprop)
-{
- GladeEPropText *eprop_text = GLADE_EPROP_TEXT (eprop);
- GladePropertyClass *klass;
- GtkWidget *hbox;
-
- klass = eprop->klass;
-
- hbox = gtk_hbox_new (FALSE, 0);
-
- if (klass->stock || klass->stock_icon)
- {
- GtkCellRenderer *renderer;
- GtkWidget *child;
- GtkWidget *combo = gtk_combo_box_new_with_entry ();
-
- eprop_text->store = (GtkTreeModel *)
- glade_eprop_text_create_store (klass->stock ? GLADE_TYPE_STOCK :
- GLADE_TYPE_STOCK_IMAGE);
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (eprop_text->store));
-
- /* let the comboboxentry prepend its intrusive cell first... */
- gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combo),
- COMBO_COLUMN_TEXT);
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
- gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo), renderer, 0);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
- "stock-id", COMBO_COLUMN_PIXBUF,
- NULL);
-
- /* Dont allow custom items where an actual GTK+ stock item is expected
- * (i.e. real items come with labels) */
- child = gtk_bin_get_child (GTK_BIN (combo));
- if (klass->stock)
- gtk_editable_set_editable (GTK_EDITABLE (child), FALSE);
- else
- gtk_editable_set_editable (GTK_EDITABLE (child), TRUE);
-
- gtk_widget_show (combo);
- gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (eprop_text_stock_changed), eprop);
-
-
- eprop_text->text_entry = combo;
- }
- else if (klass->visible_lines > 1 ||
- klass->pspec->value_type == G_TYPE_STRV ||
- klass->pspec->value_type == G_TYPE_VALUE_ARRAY)
- {
- GtkWidget *swindow;
- GtkTextBuffer *buffer;
-
- swindow = gtk_scrolled_window_new (NULL, NULL);
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow), GTK_SHADOW_IN);
-
- eprop_text->text_entry = gtk_text_view_new ();
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (eprop_text->text_entry));
-
- gtk_container_add (GTK_CONTAINER (swindow), eprop_text->text_entry);
- gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (swindow), TRUE, TRUE, 0);
-
- gtk_widget_show_all (swindow);
-
- g_signal_connect (G_OBJECT (buffer), "changed",
- G_CALLBACK (glade_eprop_text_buffer_changed),
- eprop);
-
- } else {
- eprop_text->text_entry = gtk_entry_new ();
- gtk_widget_show (eprop_text->text_entry);
-
- gtk_box_pack_start (GTK_BOX (hbox), eprop_text->text_entry, TRUE, TRUE, 0);
-
- g_signal_connect (G_OBJECT (eprop_text->text_entry), "changed",
- G_CALLBACK (glade_eprop_text_changed),
- eprop);
-
- if (klass->pspec->value_type == GDK_TYPE_PIXBUF)
- {
- GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
- GtkWidget *button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), image);
-
- g_signal_connect (button, "clicked",
- G_CALLBACK (glade_eprop_text_show_resource_dialog),
- eprop);
-
- gtk_widget_show_all (button);
-
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- }
- }
-
- if (klass->translatable) {
- GtkWidget *button = gtk_button_new_with_label ("\342\200\246");
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (button, "clicked",
- G_CALLBACK (glade_eprop_text_show_i18n_dialog),
- eprop);
- }
- return hbox;
+glade_eprop_text_create_input (GladeEditorProperty * eprop)
+{
+ GladeEPropText *eprop_text = GLADE_EPROP_TEXT (eprop);
+ GladePropertyClass *klass;
+ GtkWidget *hbox;
+
+ klass = eprop->klass;
+
+ hbox = gtk_hbox_new (FALSE, 0);
+
+ if (klass->stock || klass->stock_icon)
+ {
+ GtkCellRenderer *renderer;
+ GtkWidget *child;
+ GtkWidget *combo = gtk_combo_box_new_with_entry ();
+
+ eprop_text->store = (GtkTreeModel *)
+ glade_eprop_text_create_store (klass->stock ? GLADE_TYPE_STOCK :
+ GLADE_TYPE_STOCK_IMAGE);
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo),
+ GTK_TREE_MODEL (eprop_text->store));
+
+ /* let the comboboxentry prepend its intrusive cell first... */
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combo),
+ COMBO_COLUMN_TEXT);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo), renderer, 0);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
+ "stock-id", COMBO_COLUMN_PIXBUF, NULL);
+
+ /* Dont allow custom items where an actual GTK+ stock item is expected
+ * (i.e. real items come with labels) */
+ child = gtk_bin_get_child (GTK_BIN (combo));
+ if (klass->stock)
+ gtk_editable_set_editable (GTK_EDITABLE (child), FALSE);
+ else
+ gtk_editable_set_editable (GTK_EDITABLE (child), TRUE);
+
+ gtk_widget_show (combo);
+ gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (eprop_text_stock_changed), eprop);
+
+
+ eprop_text->text_entry = combo;
+ }
+ else if (klass->visible_lines > 1 ||
+ klass->pspec->value_type == G_TYPE_STRV ||
+ klass->pspec->value_type == G_TYPE_VALUE_ARRAY)
+ {
+ GtkWidget *swindow;
+ GtkTextBuffer *buffer;
+
+ swindow = gtk_scrolled_window_new (NULL, NULL);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
+ GTK_SHADOW_IN);
+
+ eprop_text->text_entry = gtk_text_view_new ();
+ buffer =
+ gtk_text_view_get_buffer (GTK_TEXT_VIEW (eprop_text->text_entry));
+
+ gtk_container_add (GTK_CONTAINER (swindow), eprop_text->text_entry);
+ gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (swindow), TRUE, TRUE, 0);
+
+ gtk_widget_show_all (swindow);
+
+ g_signal_connect (G_OBJECT (buffer), "changed",
+ G_CALLBACK (glade_eprop_text_buffer_changed), eprop);
+
+ }
+ else
+ {
+ eprop_text->text_entry = gtk_entry_new ();
+ gtk_widget_show (eprop_text->text_entry);
+
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_text->text_entry, TRUE, TRUE,
+ 0);
+
+ g_signal_connect (G_OBJECT (eprop_text->text_entry), "changed",
+ G_CALLBACK (glade_eprop_text_changed), eprop);
+
+ if (klass->pspec->value_type == GDK_TYPE_PIXBUF)
+ {
+ GtkWidget *image =
+ gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
+ GtkWidget *button = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (button), image);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eprop_text_show_resource_dialog),
+ eprop);
+
+ gtk_widget_show_all (button);
+
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ }
+ }
+
+ if (klass->translatable)
+ {
+ GtkWidget *button = gtk_button_new_with_label ("\342\200\246");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eprop_text_show_i18n_dialog), eprop);
+ }
+ return hbox;
}
/*******************************************************************************
GladeEditorPropertyBoolClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *toggle;
+ GtkWidget *toggle;
} GladeEPropBool;
GLADE_MAKE_EPROP (GladeEPropBool, glade_eprop_bool)
@@ -2113,79 +2106,78 @@ GLADE_MAKE_EPROP (GladeEPropBool, glade_eprop_bool)
#define GLADE_IS_EPROP_BOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_BOOL))
#define GLADE_IS_EPROP_BOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_BOOL))
#define GLADE_EPROP_BOOL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_BOOL, GladeEPropBoolClass))
-
-static void
-glade_eprop_bool_finalize (GObject *object)
+ static void glade_eprop_bool_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_bool_load (GladeEditorProperty *eprop, GladeProperty *property)
+glade_eprop_bool_load (GladeEditorProperty * eprop, GladeProperty * property)
{
- GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
- GtkWidget *label;
- gboolean state;
+ GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
+ GtkWidget *label;
+ gboolean state;
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
- /* Chain up first */
- editor_property_class->load (eprop, property);
+ if (property)
+ {
+ state = g_value_get_boolean (property->value);
- if (property)
- {
- state = g_value_get_boolean (property->value);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eprop_bool->toggle), state);
-
- label = gtk_bin_get_child (GTK_BIN (eprop_bool->toggle));
- gtk_label_set_text (GTK_LABEL (label), state ? _("Yes") : _("No"));
- }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eprop_bool->toggle),
+ state);
+
+ label = gtk_bin_get_child (GTK_BIN (eprop_bool->toggle));
+ gtk_label_set_text (GTK_LABEL (label), state ? _("Yes") : _("No"));
+ }
}
static void
-glade_eprop_bool_changed (GtkWidget *button,
- GladeEditorProperty *eprop)
+glade_eprop_bool_changed (GtkWidget * button, GladeEditorProperty * eprop)
{
- GtkWidget *label;
- gboolean state;
- GValue val = { 0, };
+ GtkWidget *label;
+ gboolean state;
+ GValue val = { 0, };
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
- label = gtk_bin_get_child (GTK_BIN (button));
- gtk_label_set_text (GTK_LABEL (label), state ? _("Yes") : _("No"));
+ state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+ label = gtk_bin_get_child (GTK_BIN (button));
+ gtk_label_set_text (GTK_LABEL (label), state ? _("Yes") : _("No"));
- g_value_init (&val, G_TYPE_BOOLEAN);
- g_value_set_boolean (&val, state);
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, state);
- glade_editor_property_commit_no_callback (eprop, &val);
+ glade_editor_property_commit_no_callback (eprop, &val);
- g_value_unset (&val);
+ g_value_unset (&val);
}
static GtkWidget *
-glade_eprop_bool_create_input (GladeEditorProperty *eprop)
+glade_eprop_bool_create_input (GladeEditorProperty * eprop)
{
- GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
+ GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
- eprop_bool->toggle = gtk_toggle_button_new_with_label (_("No"));
+ eprop_bool->toggle = gtk_toggle_button_new_with_label (_("No"));
- g_signal_connect (G_OBJECT (eprop_bool->toggle), "toggled",
- G_CALLBACK (glade_eprop_bool_changed),
- eprop);
+ g_signal_connect (G_OBJECT (eprop_bool->toggle), "toggled",
+ G_CALLBACK (glade_eprop_bool_changed), eprop);
- return eprop_bool->toggle;
+ return eprop_bool->toggle;
}
/*******************************************************************************
GladeEditorPropertyUnicharClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
- GtkWidget *entry;
+ GtkWidget *entry;
} GladeEPropUnichar;
GLADE_MAKE_EPROP (GladeEPropUnichar, glade_eprop_unichar)
@@ -2194,139 +2186,139 @@ GLADE_MAKE_EPROP (GladeEPropUnichar, glade_eprop_unichar)
#define GLADE_IS_EPROP_UNICHAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_UNICHAR))
#define GLADE_IS_EPROP_UNICHAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_UNICHAR))
#define GLADE_EPROP_UNICHAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_UNICHAR, GladeEPropUnicharClass))
-
-static void
-glade_eprop_unichar_finalize (GObject *object)
+ static void glade_eprop_unichar_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_unichar_load (GladeEditorProperty *eprop, GladeProperty *property)
+glade_eprop_unichar_load (GladeEditorProperty * eprop, GladeProperty * property)
{
- GladeEPropUnichar *eprop_unichar = GLADE_EPROP_UNICHAR (eprop);
+ GladeEPropUnichar *eprop_unichar = GLADE_EPROP_UNICHAR (eprop);
+
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
- /* Chain up first */
- editor_property_class->load (eprop, property);
+ if (property && GTK_IS_ENTRY (eprop_unichar->entry))
+ {
+ GtkEntry *entry = GTK_ENTRY (eprop_unichar->entry);
+ gchar utf8st[8];
+ gint n;
- if (property && GTK_IS_ENTRY (eprop_unichar->entry))
- {
- GtkEntry *entry = GTK_ENTRY (eprop_unichar->entry);
- gchar utf8st[8];
- gint n;
-
- if ((n = g_unichar_to_utf8 (g_value_get_uint (property->value), utf8st)))
- {
- utf8st[n] = '\0';
- gtk_entry_set_text (entry, utf8st);
- }
- }
+ if ((n = g_unichar_to_utf8 (g_value_get_uint (property->value), utf8st)))
+ {
+ utf8st[n] = '\0';
+ gtk_entry_set_text (entry, utf8st);
+ }
+ }
}
static void
-glade_eprop_unichar_changed (GtkWidget *entry,
- GladeEditorProperty *eprop)
+glade_eprop_unichar_changed (GtkWidget * entry, GladeEditorProperty * eprop)
{
- const gchar *text;
+ const gchar *text;
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- if ((text = gtk_entry_get_text (GTK_ENTRY (entry))) != NULL)
- {
- gunichar unich = g_utf8_get_char (text);
- GValue val = { 0, };
-
- g_value_init (&val, G_TYPE_UINT);
- g_value_set_uint (&val, unich);
+ if ((text = gtk_entry_get_text (GTK_ENTRY (entry))) != NULL)
+ {
+ gunichar unich = g_utf8_get_char (text);
+ GValue val = { 0, };
- glade_editor_property_commit_no_callback (eprop, &val);
+ g_value_init (&val, G_TYPE_UINT);
+ g_value_set_uint (&val, unich);
- g_value_unset (&val);
- }
+ glade_editor_property_commit_no_callback (eprop, &val);
+
+ g_value_unset (&val);
+ }
}
static void
-glade_eprop_unichar_delete (GtkEditable *editable,
- gint start_pos,
- gint end_pos,
- GladeEditorProperty *eprop)
+glade_eprop_unichar_delete (GtkEditable * editable,
+ gint start_pos,
+ gint end_pos, GladeEditorProperty * eprop)
{
- if (eprop->loading) return;
- gtk_editable_select_region (editable, 0, -1);
- g_signal_stop_emission_by_name (G_OBJECT (editable), "delete_text");
+ if (eprop->loading)
+ return;
+ gtk_editable_select_region (editable, 0, -1);
+ g_signal_stop_emission_by_name (G_OBJECT (editable), "delete_text");
}
static void
-glade_eprop_unichar_insert (GtkWidget *entry,
- const gchar *text,
- gint length,
- gint *position,
- GladeEditorProperty *eprop)
+glade_eprop_unichar_insert (GtkWidget * entry,
+ const gchar * text,
+ gint length,
+ gint * position, GladeEditorProperty * eprop)
{
- if (eprop->loading) return;
- g_signal_handlers_block_by_func
- (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_changed), eprop);
- g_signal_handlers_block_by_func
- (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_insert), eprop);
- g_signal_handlers_block_by_func
- (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_delete), eprop);
+ if (eprop->loading)
+ return;
+ g_signal_handlers_block_by_func
+ (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_changed), eprop);
+ g_signal_handlers_block_by_func
+ (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_insert), eprop);
+ g_signal_handlers_block_by_func
+ (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_delete), eprop);
- gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1);
- *position = 0;
- gtk_editable_insert_text (GTK_EDITABLE (entry), text, 1, position);
+ gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1);
+ *position = 0;
+ gtk_editable_insert_text (GTK_EDITABLE (entry), text, 1, position);
- g_signal_handlers_unblock_by_func
- (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_changed), eprop);
- g_signal_handlers_unblock_by_func
- (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_insert), eprop);
- g_signal_handlers_unblock_by_func
- (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_delete), eprop);
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_changed), eprop);
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_insert), eprop);
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (entry), G_CALLBACK (glade_eprop_unichar_delete), eprop);
- g_signal_stop_emission_by_name (G_OBJECT (entry), "insert_text");
+ g_signal_stop_emission_by_name (G_OBJECT (entry), "insert_text");
- glade_eprop_unichar_changed (entry, eprop);
+ glade_eprop_unichar_changed (entry, eprop);
}
static GtkWidget *
-glade_eprop_unichar_create_input (GladeEditorProperty *eprop)
+glade_eprop_unichar_create_input (GladeEditorProperty * eprop)
{
- GladeEPropUnichar *eprop_unichar = GLADE_EPROP_UNICHAR (eprop);
+ GladeEPropUnichar *eprop_unichar = GLADE_EPROP_UNICHAR (eprop);
+
+ eprop_unichar->entry = gtk_entry_new ();
- eprop_unichar->entry = gtk_entry_new ();
+ /* it's 2 to prevent spirious beeps... */
+ gtk_entry_set_max_length (GTK_ENTRY (eprop_unichar->entry), 2);
- /* it's 2 to prevent spirious beeps... */
- gtk_entry_set_max_length (GTK_ENTRY (eprop_unichar->entry), 2);
-
- g_signal_connect (G_OBJECT (eprop_unichar->entry), "changed",
- G_CALLBACK (glade_eprop_unichar_changed), eprop);
- g_signal_connect (G_OBJECT (eprop_unichar->entry), "insert_text",
- G_CALLBACK (glade_eprop_unichar_insert), eprop);
- g_signal_connect (G_OBJECT (eprop_unichar->entry), "delete_text",
- G_CALLBACK (glade_eprop_unichar_delete), eprop);
- return eprop_unichar->entry;
+ g_signal_connect (G_OBJECT (eprop_unichar->entry), "changed",
+ G_CALLBACK (glade_eprop_unichar_changed), eprop);
+ g_signal_connect (G_OBJECT (eprop_unichar->entry), "insert_text",
+ G_CALLBACK (glade_eprop_unichar_insert), eprop);
+ g_signal_connect (G_OBJECT (eprop_unichar->entry), "delete_text",
+ G_CALLBACK (glade_eprop_unichar_delete), eprop);
+ return eprop_unichar->entry;
}
/*******************************************************************************
GladeEditorPropertyObjectClass
*******************************************************************************/
-enum {
- OBJ_COLUMN_WIDGET = 0,
- OBJ_COLUMN_WIDGET_NAME,
- OBJ_COLUMN_WIDGET_CLASS,
- OBJ_COLUMN_SELECTED,
- OBJ_COLUMN_SELECTABLE,
- OBJ_NUM_COLUMNS
+enum
+{
+ OBJ_COLUMN_WIDGET = 0,
+ OBJ_COLUMN_WIDGET_NAME,
+ OBJ_COLUMN_WIDGET_CLASS,
+ OBJ_COLUMN_SELECTED,
+ OBJ_COLUMN_SELECTABLE,
+ OBJ_NUM_COLUMNS
};
#define GLADE_RESPONSE_CLEAR 42
#define GLADE_RESPONSE_CREATE 43
-typedef struct {
- GladeEditorProperty parent_instance;
-
- GtkWidget *entry;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
+
+ GtkWidget *entry;
} GladeEPropObject;
GLADE_MAKE_EPROP (GladeEPropObject, glade_eprop_object)
@@ -2335,41 +2327,37 @@ GLADE_MAKE_EPROP (GladeEPropObject, glade_eprop_object)
#define GLADE_IS_EPROP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_OBJECT))
#define GLADE_IS_EPROP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_OBJECT))
#define GLADE_EPROP_OBJECT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_OBJECT, GladeEPropObjectClass))
-
-static void
-glade_eprop_object_finalize (GObject *object)
+ static void glade_eprop_object_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static gchar *
-glade_eprop_object_name (const gchar *name,
- GtkTreeStore *model,
- GtkTreeIter *parent_iter)
+glade_eprop_object_name (const gchar * name,
+ GtkTreeStore * model, GtkTreeIter * parent_iter)
{
- GtkTreePath *path;
- GString *string;
- gint i;
-
- string = g_string_new (name);
+ GtkTreePath *path;
+ GString *string;
+ gint i;
+
+ string = g_string_new (name);
- if (parent_iter)
- {
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), parent_iter);
- for (i = 0; i < gtk_tree_path_get_depth (path); i++)
- g_string_prepend (string, " ");
- }
+ if (parent_iter)
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), parent_iter);
+ for (i = 0; i < gtk_tree_path_get_depth (path); i++)
+ g_string_prepend (string, " ");
+ }
- return g_string_free (string, FALSE);
+ return g_string_free (string, FALSE);
}
static gboolean
-search_list (GList *list,
- gpointer data)
+search_list (GList * list, gpointer data)
{
- return g_list_find (list, data) != NULL;
+ return g_list_find (list, data) != NULL;
}
@@ -2378,648 +2366,639 @@ search_list (GList *list,
* in the model are the associated GladeWidgets.
*/
static void
-glade_eprop_object_populate_view_real (GtkTreeStore *model,
- GtkTreeIter *parent_iter,
- GList *widgets,
- GList *selected_widgets,
- GList *exception_widgets,
- GType object_type,
- gboolean parentless)
-{
- GList *children, *list;
- GtkTreeIter iter;
- gboolean good_type, has_decendant;
-
- for (list = widgets; list; list = list->next)
- {
- GladeWidget *widget;
-
- if ((widget = glade_widget_get_from_gobject (list->data)) != NULL)
- {
-
- has_decendant = !parentless && glade_widget_has_decendant
- (widget, object_type);
-
- good_type = (widget->adaptor->type == object_type ||
- g_type_is_a (widget->adaptor->type, object_type) ||
- glade_util_class_implements_interface (widget->adaptor->type, object_type));
-
- if (parentless)
- good_type = good_type && !GWA_IS_TOPLEVEL (widget->adaptor);
-
- if (good_type || has_decendant)
- {
- gtk_tree_store_append (model, &iter, parent_iter);
- gtk_tree_store_set
- (model, &iter,
- OBJ_COLUMN_WIDGET, widget,
- OBJ_COLUMN_WIDGET_NAME,
- glade_eprop_object_name (widget->name, model, parent_iter),
- OBJ_COLUMN_WIDGET_CLASS,
- widget->adaptor->title,
- /* Selectable if its a compatible type and
- * its not itself.
- */
- OBJ_COLUMN_SELECTABLE,
- good_type && !search_list (exception_widgets, widget),
- OBJ_COLUMN_SELECTED,
- good_type && search_list (selected_widgets, widget),
- -1);
- }
-
- if (has_decendant &&
- (children = glade_widget_adaptor_get_children
- (widget->adaptor, widget->object)) != NULL)
- {
- GtkTreeIter *copy = NULL;
-
- copy = gtk_tree_iter_copy (&iter);
- glade_eprop_object_populate_view_real (model, copy, children,
- selected_widgets,
- exception_widgets,
- object_type, parentless);
- gtk_tree_iter_free (copy);
-
- g_list_free (children);
- }
- }
- }
+glade_eprop_object_populate_view_real (GtkTreeStore * model,
+ GtkTreeIter * parent_iter,
+ GList * widgets,
+ GList * selected_widgets,
+ GList * exception_widgets,
+ GType object_type, gboolean parentless)
+{
+ GList *children, *list;
+ GtkTreeIter iter;
+ gboolean good_type, has_decendant;
+
+ for (list = widgets; list; list = list->next)
+ {
+ GladeWidget *widget;
+
+ if ((widget = glade_widget_get_from_gobject (list->data)) != NULL)
+ {
+
+ has_decendant = !parentless && glade_widget_has_decendant
+ (widget, object_type);
+
+ good_type = (widget->adaptor->type == object_type ||
+ g_type_is_a (widget->adaptor->type, object_type) ||
+ glade_util_class_implements_interface (widget->adaptor->
+ type,
+ object_type));
+
+ if (parentless)
+ good_type = good_type && !GWA_IS_TOPLEVEL (widget->adaptor);
+
+ if (good_type || has_decendant)
+ {
+ gtk_tree_store_append (model, &iter, parent_iter);
+ gtk_tree_store_set
+ (model, &iter,
+ OBJ_COLUMN_WIDGET, widget,
+ OBJ_COLUMN_WIDGET_NAME,
+ glade_eprop_object_name (widget->name, model, parent_iter),
+ OBJ_COLUMN_WIDGET_CLASS, widget->adaptor->title,
+ /* Selectable if its a compatible type and
+ * its not itself.
+ */
+ OBJ_COLUMN_SELECTABLE,
+ good_type && !search_list (exception_widgets, widget),
+ OBJ_COLUMN_SELECTED,
+ good_type && search_list (selected_widgets, widget), -1);
+ }
+
+ if (has_decendant &&
+ (children = glade_widget_adaptor_get_children
+ (widget->adaptor, widget->object)) != NULL)
+ {
+ GtkTreeIter *copy = NULL;
+
+ copy = gtk_tree_iter_copy (&iter);
+ glade_eprop_object_populate_view_real (model, copy, children,
+ selected_widgets,
+ exception_widgets,
+ object_type, parentless);
+ gtk_tree_iter_free (copy);
+
+ g_list_free (children);
+ }
+ }
+ }
}
static void
-glade_eprop_object_populate_view (GladeProject *project,
- GtkTreeView *view,
- GList *selected,
- GList *exceptions,
- GType object_type,
- gboolean parentless)
-{
- GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (view);
- GList *list, *toplevels = NULL;
-
- /* Make a list of only the toplevel widgets */
- for (list = (GList *) glade_project_get_objects (project); list; list = list->next)
- {
- GObject *object = G_OBJECT (list->data);
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- g_assert (gwidget);
-
- if (gwidget->parent == NULL)
- toplevels = g_list_append (toplevels, object);
- }
-
- /* add the widgets and recurse */
- glade_eprop_object_populate_view_real (model, NULL, toplevels, selected, exceptions,
- object_type,
- parentless);
- g_list_free (toplevels);
+glade_eprop_object_populate_view (GladeProject * project,
+ GtkTreeView * view,
+ GList * selected,
+ GList * exceptions,
+ GType object_type, gboolean parentless)
+{
+ GtkTreeStore *model = (GtkTreeStore *) gtk_tree_view_get_model (view);
+ GList *list, *toplevels = NULL;
+
+ /* Make a list of only the toplevel widgets */
+ for (list = (GList *) glade_project_get_objects (project); list;
+ list = list->next)
+ {
+ GObject *object = G_OBJECT (list->data);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ g_assert (gwidget);
+
+ if (gwidget->parent == NULL)
+ toplevels = g_list_append (toplevels, object);
+ }
+
+ /* add the widgets and recurse */
+ glade_eprop_object_populate_view_real (model, NULL, toplevels, selected,
+ exceptions, object_type, parentless);
+ g_list_free (toplevels);
}
static gboolean
-glade_eprop_object_clear_iter (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
+glade_eprop_object_clear_iter (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, gpointer data)
{
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- OBJ_COLUMN_SELECTED, FALSE, -1);
- return FALSE;
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ OBJ_COLUMN_SELECTED, FALSE, -1);
+ return FALSE;
}
static gboolean
-glade_eprop_object_selected_widget (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- GladeWidget **ret)
-{
- gboolean selected;
- GladeWidget *widget;
-
- gtk_tree_model_get (model, iter,
- OBJ_COLUMN_SELECTED, &selected,
- OBJ_COLUMN_WIDGET, &widget, -1);
-
- if (selected)
- {
- *ret = widget;
- return TRUE;
- }
- return FALSE;
+glade_eprop_object_selected_widget (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, GladeWidget ** ret)
+{
+ gboolean selected;
+ GladeWidget *widget;
+
+ gtk_tree_model_get (model, iter,
+ OBJ_COLUMN_SELECTED, &selected,
+ OBJ_COLUMN_WIDGET, &widget, -1);
+
+ if (selected)
+ {
+ *ret = widget;
+ return TRUE;
+ }
+ return FALSE;
}
static void
-glade_eprop_object_selected (GtkCellRendererToggle *cell,
- gchar *path_str,
- GtkTreeModel *model)
+glade_eprop_object_selected (GtkCellRendererToggle * cell,
+ gchar * path_str, GtkTreeModel * model)
{
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeIter iter;
- gboolean enabled, radio;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeIter iter;
+ gboolean enabled, radio;
- radio = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio-list"));
+ radio = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio-list"));
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter,
- OBJ_COLUMN_SELECTED, &enabled, -1);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, OBJ_COLUMN_SELECTED, &enabled, -1);
- /* Clear the rest of the view first
- */
- if (radio)
- gtk_tree_model_foreach (model, glade_eprop_object_clear_iter, NULL);
+ /* Clear the rest of the view first
+ */
+ if (radio)
+ gtk_tree_model_foreach (model, glade_eprop_object_clear_iter, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- OBJ_COLUMN_SELECTED,
- radio ? TRUE : !enabled, -1);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ OBJ_COLUMN_SELECTED, radio ? TRUE : !enabled, -1);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
}
static GtkWidget *
-glade_eprop_object_view (gboolean radio)
-{
- GtkWidget *view_widget;
- GtkTreeModel *model;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- model = (GtkTreeModel *)gtk_tree_store_new
- (OBJ_NUM_COLUMNS,
- G_TYPE_OBJECT, /* The GladeWidget */
- G_TYPE_STRING, /* The GladeWidget's name */
- G_TYPE_STRING, /* The GladeWidgetClass title */
- G_TYPE_BOOLEAN, /* Whether this row is selected or not */
- G_TYPE_BOOLEAN); /* Whether this GladeWidget is
- * of an acceptable type and
- * therefore can be selected.
- */
-
- g_object_set_data (G_OBJECT (model), "radio-list", GINT_TO_POINTER (radio));
-
- view_widget = gtk_tree_view_new_with_model (model);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view_widget), FALSE);
-
- /* Pass ownership to the view */
- g_object_unref (G_OBJECT (model));
- g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
-
- /********************* fake invisible column *********************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, "visible", FALSE, NULL);
-
- column = gtk_tree_view_column_new_with_attributes (NULL, renderer, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
-
- gtk_tree_view_column_set_visible (column, FALSE);
- gtk_tree_view_set_expander_column (GTK_TREE_VIEW (view_widget), column);
-
- /************************ selected column ************************/
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (G_OBJECT (renderer),
- "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
- "activatable", TRUE,
- "radio", radio,
- NULL);
- g_signal_connect (renderer, "toggled",
- G_CALLBACK (glade_eprop_object_selected), model);
- gtk_tree_view_insert_column_with_attributes
- (GTK_TREE_VIEW (view_widget), 0,
- NULL, renderer,
- "visible", OBJ_COLUMN_SELECTABLE,
- "sensitive", OBJ_COLUMN_SELECTABLE,
- "active", OBJ_COLUMN_SELECTED,
- NULL);
-
- /********************* widget name column *********************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- gtk_tree_view_insert_column_with_attributes
- (GTK_TREE_VIEW (view_widget), 1,
- _("Name"), renderer,
- "text", OBJ_COLUMN_WIDGET_NAME,
- NULL);
-
- /***************** widget class title column ******************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "editable", FALSE,
- "style", PANGO_STYLE_ITALIC,
- "foreground", "Gray", NULL);
- gtk_tree_view_insert_column_with_attributes
- (GTK_TREE_VIEW (view_widget), 2,
- _("Class"), renderer,
- "text", OBJ_COLUMN_WIDGET_CLASS,
- NULL);
-
- return view_widget;
+glade_eprop_object_view (gboolean radio)
+{
+ GtkWidget *view_widget;
+ GtkTreeModel *model;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ model = (GtkTreeModel *) gtk_tree_store_new (OBJ_NUM_COLUMNS, G_TYPE_OBJECT, /* The GladeWidget */
+ G_TYPE_STRING, /* The GladeWidget's name */
+ G_TYPE_STRING, /* The GladeWidgetClass title */
+ G_TYPE_BOOLEAN, /* Whether this row is selected or not */
+ G_TYPE_BOOLEAN); /* Whether this GladeWidget is
+ * of an acceptable type and
+ * therefore can be selected.
+ */
+
+ g_object_set_data (G_OBJECT (model), "radio-list", GINT_TO_POINTER (radio));
+
+ view_widget = gtk_tree_view_new_with_model (model);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view_widget), FALSE);
+
+ /* Pass ownership to the view */
+ g_object_unref (G_OBJECT (model));
+ g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
+
+ /********************* fake invisible column *********************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, "visible", FALSE, NULL);
+
+ column = gtk_tree_view_column_new_with_attributes (NULL, renderer, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
+
+ gtk_tree_view_column_set_visible (column, FALSE);
+ gtk_tree_view_set_expander_column (GTK_TREE_VIEW (view_widget), column);
+
+ /************************ selected column ************************/
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer),
+ "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
+ "activatable", TRUE, "radio", radio, NULL);
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (glade_eprop_object_selected), model);
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (view_widget), 0,
+ NULL, renderer,
+ "visible", OBJ_COLUMN_SELECTABLE,
+ "sensitive", OBJ_COLUMN_SELECTABLE, "active", OBJ_COLUMN_SELECTED, NULL);
+
+ /********************* widget name column *********************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (view_widget), 1,
+ _("Name"), renderer, "text", OBJ_COLUMN_WIDGET_NAME, NULL);
+
+ /***************** widget class title column ******************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer),
+ "editable", FALSE,
+ "style", PANGO_STYLE_ITALIC, "foreground", "Gray", NULL);
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (view_widget), 2,
+ _("Class"), renderer, "text", OBJ_COLUMN_WIDGET_CLASS, NULL);
+
+ return view_widget;
}
static gchar *
-glade_eprop_object_dialog_title (GladeEditorProperty *eprop)
-{
- GladeWidgetAdaptor *adaptor;
- const gchar *format;
-
- if (eprop->klass->parentless_widget)
- format = GLADE_IS_PARAM_SPEC_OBJECTS (eprop->klass->pspec) ?
- _("Choose parentless %s type objects in this project") : _("Choose a parentless %s in this project");
- else
- format = GLADE_IS_PARAM_SPEC_OBJECTS (eprop->klass->pspec) ?
- _("Choose %s type objects in this project") : _("Choose a %s in this project");
-
- if (GLADE_IS_PARAM_SPEC_OBJECTS (eprop->klass->pspec))
- return g_strdup_printf (format, g_type_name
- (glade_param_spec_objects_get_type
- (GLADE_PARAM_SPEC_OBJECTS (eprop->klass->pspec))));
- else if ((adaptor =
- glade_widget_adaptor_get_by_type
- (eprop->klass->pspec->value_type)) != NULL)
- return g_strdup_printf (format, adaptor->title);
-
- /* Fallback on type name (which would look like "GtkButton"
- * instead of "Button" and maybe not translated).
- */
- return g_strdup_printf (format, g_type_name
- (eprop->klass->pspec->value_type));
+glade_eprop_object_dialog_title (GladeEditorProperty * eprop)
+{
+ GladeWidgetAdaptor *adaptor;
+ const gchar *format;
+
+ if (eprop->klass->parentless_widget)
+ format = GLADE_IS_PARAM_SPEC_OBJECTS (eprop->klass->pspec) ?
+ _("Choose parentless %s type objects in this project") :
+ _("Choose a parentless %s in this project");
+ else
+ format = GLADE_IS_PARAM_SPEC_OBJECTS (eprop->klass->pspec) ?
+ _("Choose %s type objects in this project") :
+ _("Choose a %s in this project");
+
+ if (GLADE_IS_PARAM_SPEC_OBJECTS (eprop->klass->pspec))
+ return g_strdup_printf (format, g_type_name
+ (glade_param_spec_objects_get_type
+ (GLADE_PARAM_SPEC_OBJECTS (eprop->klass->pspec))));
+ else if ((adaptor =
+ glade_widget_adaptor_get_by_type
+ (eprop->klass->pspec->value_type)) != NULL)
+ return g_strdup_printf (format, adaptor->title);
+
+ /* Fallback on type name (which would look like "GtkButton"
+ * instead of "Button" and maybe not translated).
+ */
+ return g_strdup_printf (format, g_type_name
+ (eprop->klass->pspec->value_type));
}
gboolean
-glade_editor_property_show_object_dialog (GladeProject *project,
- const gchar *title,
- GtkWidget *parent,
- GType object_type,
- GladeWidget *exception,
- GladeWidget **object)
-{
- GtkWidget *dialog;
- GtkWidget *vbox, *label, *sw;
- GtkWidget *tree_view;
- GtkWidget *content_area;
- GtkWidget *action_area;
- GList *selected_list = NULL, *exception_list = NULL;
- gint res;
-
- g_return_val_if_fail (object != NULL, -1);
-
- if (!parent)
- parent = glade_app_get_window ();
-
- dialog = gtk_dialog_new_with_buttons (title,
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CANCEL,
- GLADE_RESPONSE_CLEAR,
- -1);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- /* HIG settings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-
- gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
-
- /* Checklist */
- label = gtk_label_new_with_mnemonic (_("O_bjects:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
-
- if (*object)
- selected_list = g_list_prepend (selected_list, *object);
-
- if (exception)
- exception_list = g_list_prepend (exception_list, exception);
-
- tree_view = glade_eprop_object_view (TRUE);
- glade_eprop_object_populate_view (project,
- GTK_TREE_VIEW (tree_view),
- selected_list, exception_list,
- object_type, FALSE);
- g_list_free (selected_list);
- g_list_free (exception_list);
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
-
- gtk_widget_show (tree_view);
- gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
-
- /* Run the dialog */
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK)
- {
- GladeWidget *selected = NULL;
-
- gtk_tree_model_foreach
- (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
- (GtkTreeModelForeachFunc)
- glade_eprop_object_selected_widget, &selected);
-
- *object = selected;
- }
- else if (res == GLADE_RESPONSE_CLEAR)
- *object = NULL;
-
- gtk_widget_destroy (dialog);
-
- return (res == GTK_RESPONSE_OK || res == GLADE_RESPONSE_CLEAR);
+glade_editor_property_show_object_dialog (GladeProject * project,
+ const gchar * title,
+ GtkWidget * parent,
+ GType object_type,
+ GladeWidget * exception,
+ GladeWidget ** object)
+{
+ GtkWidget *dialog;
+ GtkWidget *vbox, *label, *sw;
+ GtkWidget *tree_view;
+ GtkWidget *content_area;
+ GtkWidget *action_area;
+ GList *selected_list = NULL, *exception_list = NULL;
+ gint res;
+
+ g_return_val_if_fail (object != NULL, -1);
+
+ if (!parent)
+ parent = glade_app_get_window ();
+
+ dialog = gtk_dialog_new_with_buttons (title,
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ GLADE_RESPONSE_CLEAR, -1);
+
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ /* HIG settings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+
+ /* Checklist */
+ label = gtk_label_new_with_mnemonic (_("O_bjects:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+
+ if (*object)
+ selected_list = g_list_prepend (selected_list, *object);
+
+ if (exception)
+ exception_list = g_list_prepend (exception_list, exception);
+
+ tree_view = glade_eprop_object_view (TRUE);
+ glade_eprop_object_populate_view (project,
+ GTK_TREE_VIEW (tree_view),
+ selected_list, exception_list,
+ object_type, FALSE);
+ g_list_free (selected_list);
+ g_list_free (exception_list);
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ gtk_widget_show (tree_view);
+ gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
+
+ /* Run the dialog */
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+ GladeWidget *selected = NULL;
+
+ gtk_tree_model_foreach
+ (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
+ (GtkTreeModelForeachFunc)
+ glade_eprop_object_selected_widget, &selected);
+
+ *object = selected;
+ }
+ else if (res == GLADE_RESPONSE_CLEAR)
+ *object = NULL;
+
+ gtk_widget_destroy (dialog);
+
+ return (res == GTK_RESPONSE_OK || res == GLADE_RESPONSE_CLEAR);
}
static void
-glade_eprop_object_show_dialog (GtkWidget *dialog_button,
- GladeEditorProperty *eprop)
-{
- GtkWidget *dialog, *parent;
- GtkWidget *vbox, *label, *sw;
- GtkWidget *tree_view;
- GtkWidget *content_area;
- GtkWidget *action_area;
- GladeProject *project;
- gchar *title = glade_eprop_object_dialog_title (eprop);
- gint res;
- GladeWidgetAdaptor *create_adaptor = NULL;
- GList *selected_list = NULL, *exception_list = NULL;
-
- project = glade_widget_get_project (eprop->property->widget);
- parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
-
- if (eprop->property->klass->create_type)
- create_adaptor = glade_widget_adaptor_get_by_name (eprop->property->klass->create_type);
- if (!create_adaptor &&
- G_TYPE_IS_INSTANTIATABLE (eprop->klass->pspec->value_type) &&
- !G_TYPE_IS_ABSTRACT (eprop->klass->pspec->value_type))
- create_adaptor = glade_widget_adaptor_get_by_type (eprop->klass->pspec->value_type);
-
- if (create_adaptor)
- {
- dialog = gtk_dialog_new_with_buttons (title,
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
- _("_New"), GLADE_RESPONSE_CREATE,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- g_free (title);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK,
- GLADE_RESPONSE_CREATE,
- GTK_RESPONSE_CANCEL,
- GLADE_RESPONSE_CLEAR,
- -1);
- }
- else
- {
- dialog = gtk_dialog_new_with_buttons (title,
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- g_free (title);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CANCEL,
- GLADE_RESPONSE_CLEAR,
- -1);
- }
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
- /* HIG settings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-
- gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
-
- /* Checklist */
- label = gtk_label_new_with_mnemonic (_("O_bjects:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
-
- exception_list = g_list_prepend (exception_list, eprop->property->widget);
- if (g_value_get_object (eprop->property->value))
- selected_list = g_list_prepend (selected_list,
- glade_widget_get_from_gobject
- (g_value_get_object (eprop->property->value)));
-
- tree_view = glade_eprop_object_view (TRUE);
- glade_eprop_object_populate_view (project, GTK_TREE_VIEW (tree_view),
- selected_list, exception_list,
- eprop->klass->pspec->value_type,
- eprop->klass->parentless_widget);
- g_list_free (selected_list);
- g_list_free (exception_list);
-
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
-
- gtk_widget_show (tree_view);
- gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
-
-
- /* Run the dialog */
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK)
- {
- GladeWidget *selected = NULL;
-
- gtk_tree_model_foreach
- (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
- (GtkTreeModelForeachFunc)
- glade_eprop_object_selected_widget, &selected);
-
- if (selected)
- {
- GValue *value;
-
- glade_project_selection_set (project, eprop->property->widget->object, TRUE);
-
- value = glade_property_class_make_gvalue_from_string
- (eprop->klass, selected->name, project, eprop->property->widget);
-
- /* Unparent the widget so we can reuse it for this property */
- if (eprop->klass->parentless_widget)
- {
- GObject *new_object, *old_object = NULL;
- GladeWidget *new_widget;
- GladeProperty *old_ref;
-
- if (!G_IS_PARAM_SPEC_OBJECT (eprop->klass->pspec))
- g_warning ("Parentless widget property should be of object type");
- else
- {
- glade_property_get (eprop->property, &old_object);
- new_object = g_value_get_object (value);
- new_widget = glade_widget_get_from_gobject (new_object);
-
- if (new_object && old_object != new_object)
- {
- if ((old_ref = glade_widget_get_parentless_widget_ref (new_widget)))
- {
- glade_command_push_group (_("Setting %s of %s to %s"),
- eprop->property->klass->name,
- eprop->property->widget->name,
- new_widget->name);
- glade_command_set_property (old_ref, NULL);
- glade_editor_property_commit (eprop, value);
- glade_command_pop_group ();
- }
- else
- glade_editor_property_commit (eprop, value);
- }
- }
- }
- else
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
- }
- }
- else if (res == GLADE_RESPONSE_CREATE)
- {
- GValue *value;
- GladeWidget *new_widget;
-
- /* translators: Creating 'a widget' for 'a property' of 'a widget' */
- glade_command_push_group (_("Creating %s for %s of %s"),
- create_adaptor->name,
- eprop->property->klass->name,
- eprop->property->widget->name);
-
- /* Dont bother if the user canceled the widget */
- if ((new_widget = glade_command_create (create_adaptor, NULL, NULL, project)) != NULL)
- {
- glade_project_selection_set (project, eprop->property->widget->object, TRUE);
-
- value = glade_property_class_make_gvalue_from_string
- (eprop->klass, new_widget->name, project, NULL);
-
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
- }
-
- glade_command_pop_group ();
- }
- else if (res == GLADE_RESPONSE_CLEAR)
- {
- GValue *value = glade_property_class_make_gvalue_from_string
- (eprop->klass, NULL, project, eprop->property->widget);
-
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
- }
-
- gtk_widget_destroy (dialog);
+glade_eprop_object_show_dialog (GtkWidget * dialog_button,
+ GladeEditorProperty * eprop)
+{
+ GtkWidget *dialog, *parent;
+ GtkWidget *vbox, *label, *sw;
+ GtkWidget *tree_view;
+ GtkWidget *content_area;
+ GtkWidget *action_area;
+ GladeProject *project;
+ gchar *title = glade_eprop_object_dialog_title (eprop);
+ gint res;
+ GladeWidgetAdaptor *create_adaptor = NULL;
+ GList *selected_list = NULL, *exception_list = NULL;
+
+ project = glade_widget_get_project (eprop->property->widget);
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
+
+ if (eprop->property->klass->create_type)
+ create_adaptor =
+ glade_widget_adaptor_get_by_name (eprop->property->klass->create_type);
+ if (!create_adaptor &&
+ G_TYPE_IS_INSTANTIATABLE (eprop->klass->pspec->value_type) &&
+ !G_TYPE_IS_ABSTRACT (eprop->klass->pspec->value_type))
+ create_adaptor =
+ glade_widget_adaptor_get_by_type (eprop->klass->pspec->value_type);
+
+ if (create_adaptor)
+ {
+ dialog = gtk_dialog_new_with_buttons (title,
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_CLEAR,
+ GLADE_RESPONSE_CLEAR, _("_New"),
+ GLADE_RESPONSE_CREATE, GTK_STOCK_OK,
+ GTK_RESPONSE_OK, NULL);
+ g_free (title);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GLADE_RESPONSE_CREATE,
+ GTK_RESPONSE_CANCEL,
+ GLADE_RESPONSE_CLEAR, -1);
+ }
+ else
+ {
+ dialog = gtk_dialog_new_with_buttons (title,
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_CLEAR,
+ GLADE_RESPONSE_CLEAR, GTK_STOCK_OK,
+ GTK_RESPONSE_OK, NULL);
+ g_free (title);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ GLADE_RESPONSE_CLEAR, -1);
+ }
+
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ /* HIG settings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+
+ /* Checklist */
+ label = gtk_label_new_with_mnemonic (_("O_bjects:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+
+ exception_list = g_list_prepend (exception_list, eprop->property->widget);
+ if (g_value_get_object (eprop->property->value))
+ selected_list = g_list_prepend (selected_list,
+ glade_widget_get_from_gobject
+ (g_value_get_object
+ (eprop->property->value)));
+
+ tree_view = glade_eprop_object_view (TRUE);
+ glade_eprop_object_populate_view (project, GTK_TREE_VIEW (tree_view),
+ selected_list, exception_list,
+ eprop->klass->pspec->value_type,
+ eprop->klass->parentless_widget);
+ g_list_free (selected_list);
+ g_list_free (exception_list);
+
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ gtk_widget_show (tree_view);
+ gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
+
+
+ /* Run the dialog */
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+ GladeWidget *selected = NULL;
+
+ gtk_tree_model_foreach
+ (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
+ (GtkTreeModelForeachFunc)
+ glade_eprop_object_selected_widget, &selected);
+
+ if (selected)
+ {
+ GValue *value;
+
+ glade_project_selection_set (project, eprop->property->widget->object,
+ TRUE);
+
+ value = glade_property_class_make_gvalue_from_string
+ (eprop->klass, selected->name, project, eprop->property->widget);
+
+ /* Unparent the widget so we can reuse it for this property */
+ if (eprop->klass->parentless_widget)
+ {
+ GObject *new_object, *old_object = NULL;
+ GladeWidget *new_widget;
+ GladeProperty *old_ref;
+
+ if (!G_IS_PARAM_SPEC_OBJECT (eprop->klass->pspec))
+ g_warning
+ ("Parentless widget property should be of object type");
+ else
+ {
+ glade_property_get (eprop->property, &old_object);
+ new_object = g_value_get_object (value);
+ new_widget = glade_widget_get_from_gobject (new_object);
+
+ if (new_object && old_object != new_object)
+ {
+ if ((old_ref =
+ glade_widget_get_parentless_widget_ref (new_widget)))
+ {
+ glade_command_push_group (_("Setting %s of %s to %s"),
+ eprop->property->klass->
+ name,
+ eprop->property->widget->
+ name, new_widget->name);
+ glade_command_set_property (old_ref, NULL);
+ glade_editor_property_commit (eprop, value);
+ glade_command_pop_group ();
+ }
+ else
+ glade_editor_property_commit (eprop, value);
+ }
+ }
+ }
+ else
+ glade_editor_property_commit (eprop, value);
+
+ g_value_unset (value);
+ g_free (value);
+ }
+ }
+ else if (res == GLADE_RESPONSE_CREATE)
+ {
+ GValue *value;
+ GladeWidget *new_widget;
+
+ /* translators: Creating 'a widget' for 'a property' of 'a widget' */
+ glade_command_push_group (_("Creating %s for %s of %s"),
+ create_adaptor->name,
+ eprop->property->klass->name,
+ eprop->property->widget->name);
+
+ /* Dont bother if the user canceled the widget */
+ if ((new_widget =
+ glade_command_create (create_adaptor, NULL, NULL, project)) != NULL)
+ {
+ glade_project_selection_set (project, eprop->property->widget->object,
+ TRUE);
+
+ value = glade_property_class_make_gvalue_from_string
+ (eprop->klass, new_widget->name, project, NULL);
+
+ glade_editor_property_commit (eprop, value);
+
+ g_value_unset (value);
+ g_free (value);
+ }
+
+ glade_command_pop_group ();
+ }
+ else if (res == GLADE_RESPONSE_CLEAR)
+ {
+ GValue *value = glade_property_class_make_gvalue_from_string
+ (eprop->klass, NULL, project, eprop->property->widget);
+
+ glade_editor_property_commit (eprop, value);
+
+ g_value_unset (value);
+ g_free (value);
+ }
+
+ gtk_widget_destroy (dialog);
}
static void
-glade_eprop_object_load (GladeEditorProperty *eprop, GladeProperty *property)
+glade_eprop_object_load (GladeEditorProperty * eprop, GladeProperty * property)
{
- GladeEPropObject *eprop_object = GLADE_EPROP_OBJECT (eprop);
- gchar *obj_name;
+ GladeEPropObject *eprop_object = GLADE_EPROP_OBJECT (eprop);
+ gchar *obj_name;
- /* Chain up first */
- editor_property_class->load (eprop, property);
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
- if (property == NULL) return;
+ if (property == NULL)
+ return;
- if ((obj_name = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
- eprop->klass, property->value)) != NULL)
- {
- gtk_entry_set_text (GTK_ENTRY (eprop_object->entry), obj_name);
- g_free (obj_name);
- }
- else
- gtk_entry_set_text (GTK_ENTRY (eprop_object->entry), "");
+ if ((obj_name = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
+ eprop->klass, property->value)) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (eprop_object->entry), obj_name);
+ g_free (obj_name);
+ }
+ else
+ gtk_entry_set_text (GTK_ENTRY (eprop_object->entry), "");
}
static GtkWidget *
-glade_eprop_object_create_input (GladeEditorProperty *eprop)
+glade_eprop_object_create_input (GladeEditorProperty * eprop)
{
- GladeEPropObject *eprop_object = GLADE_EPROP_OBJECT (eprop);
- GtkWidget *hbox;
- GtkWidget *button;
+ GladeEPropObject *eprop_object = GLADE_EPROP_OBJECT (eprop);
+ GtkWidget *hbox;
+ GtkWidget *button;
- hbox = gtk_hbox_new (FALSE, 0);
- eprop_object->entry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (eprop_object->entry), FALSE);
- gtk_widget_show (eprop_object->entry);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_object->entry, TRUE, TRUE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
+ eprop_object->entry = gtk_entry_new ();
+ gtk_editable_set_editable (GTK_EDITABLE (eprop_object->entry), FALSE);
+ gtk_widget_show (eprop_object->entry);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_object->entry, TRUE, TRUE, 0);
- button = gtk_button_new_with_label ("...");
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("...");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_object_show_dialog),
- eprop);
- return hbox;
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_object_show_dialog), eprop);
+ return hbox;
}
@@ -3027,10 +3006,11 @@ glade_eprop_object_create_input (GladeEditorProperty *eprop)
GladeEditorPropertyObjectsClass
*******************************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
-
- GtkWidget *entry;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
+
+ GtkWidget *entry;
} GladeEPropObjects;
GLADE_MAKE_EPROP (GladeEPropObjects, glade_eprop_objects)
@@ -3039,186 +3019,184 @@ GLADE_MAKE_EPROP (GladeEPropObjects, glade_eprop_objects)
#define GLADE_IS_EPROP_OBJECTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_OBJECTS))
#define GLADE_IS_EPROP_OBJECTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_OBJECTS))
#define GLADE_EPROP_OBJECTS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_OBJECTS, GladeEPropObjectsClass))
-
-static void
-glade_eprop_objects_finalize (GObject *object)
+ static void glade_eprop_objects_finalize (GObject * object)
{
- /* Chain up */
- G_OBJECT_CLASS (editor_property_class)->finalize (object);
+ /* Chain up */
+ G_OBJECT_CLASS (editor_property_class)->finalize (object);
}
static void
-glade_eprop_objects_load (GladeEditorProperty *eprop, GladeProperty *property)
+glade_eprop_objects_load (GladeEditorProperty * eprop, GladeProperty * property)
{
- GladeEPropObjects *eprop_objects = GLADE_EPROP_OBJECTS (eprop);
- gchar *obj_name;
+ GladeEPropObjects *eprop_objects = GLADE_EPROP_OBJECTS (eprop);
+ gchar *obj_name;
- /* Chain up first */
- editor_property_class->load (eprop, property);
+ /* Chain up first */
+ editor_property_class->load (eprop, property);
- if (property == NULL) return;
+ if (property == NULL)
+ return;
- if ((obj_name = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
- eprop->klass, property->value)) != NULL)
- {
- gtk_entry_set_text (GTK_ENTRY (eprop_objects->entry), obj_name);
- g_free (obj_name);
- }
- else
- gtk_entry_set_text (GTK_ENTRY (eprop_objects->entry), "");
+ if ((obj_name = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (eprop->klass->handle),
+ eprop->klass, property->value)) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (eprop_objects->entry), obj_name);
+ g_free (obj_name);
+ }
+ else
+ gtk_entry_set_text (GTK_ENTRY (eprop_objects->entry), "");
}
static gboolean
-glade_eprop_objects_selected_widget (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- GList **ret)
+glade_eprop_objects_selected_widget (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, GList ** ret)
{
- gboolean selected;
- GladeWidget *widget;
+ gboolean selected;
+ GladeWidget *widget;
- gtk_tree_model_get (model, iter,
- OBJ_COLUMN_SELECTED, &selected,
- OBJ_COLUMN_WIDGET, &widget, -1);
+ gtk_tree_model_get (model, iter,
+ OBJ_COLUMN_SELECTED, &selected,
+ OBJ_COLUMN_WIDGET, &widget, -1);
- if (selected)
- {
- *ret = g_list_append (*ret, widget->object);
- }
+ if (selected)
+ {
+ *ret = g_list_append (*ret, widget->object);
+ }
- return FALSE;
+ return FALSE;
}
static void
-glade_eprop_objects_show_dialog (GtkWidget *dialog_button,
- GladeEditorProperty *eprop)
-{
- GtkWidget *dialog, *parent;
- GtkWidget *vbox, *label, *sw;
- GtkWidget *tree_view;
- GladeProject *project;
- gchar *title = glade_eprop_object_dialog_title (eprop);
- gint res;
- GList *selected_list = NULL, *exception_list = NULL, *selected_objects = NULL;
-
- project = glade_widget_get_project (eprop->property->widget);
- parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
-
-
- dialog = gtk_dialog_new_with_buttons (title,
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- g_free (title);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0);
-
- /* Checklist */
- label = gtk_label_new (_("Objects:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- tree_view = glade_eprop_object_view (FALSE);
-
-
- exception_list = g_list_prepend (exception_list, eprop->property->widget);
-
- if (g_value_get_object (eprop->property->value))
- {
- GList *l;
- glade_property_get (eprop->property, &selected_objects);
- for (l = selected_objects; l; l = l->next)
- selected_list = g_list_prepend (selected_list,
- glade_widget_get_from_gobject (l->data));
- }
- glade_eprop_object_populate_view (project, GTK_TREE_VIEW (tree_view),
- selected_list, exception_list,
- eprop->klass->pspec->value_type,
- eprop->klass->parentless_widget);
- g_list_free (selected_list);
- g_list_free (exception_list);
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
-
- gtk_widget_show (tree_view);
- gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
- /* Run the dialog */
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK)
- {
- GValue *value;
- GList *selected = NULL;
-
- gtk_tree_model_foreach
- (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
- (GtkTreeModelForeachFunc)
- glade_eprop_objects_selected_widget, &selected);
-
- value = glade_property_class_make_gvalue
- (eprop->klass, selected);
-
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
- }
- else if (res == GLADE_RESPONSE_CLEAR)
- {
- GValue *value = glade_property_class_make_gvalue
- (eprop->klass, NULL);
-
- glade_editor_property_commit (eprop, value);
-
- g_value_unset (value);
- g_free (value);
- }
- gtk_widget_destroy (dialog);
+glade_eprop_objects_show_dialog (GtkWidget * dialog_button,
+ GladeEditorProperty * eprop)
+{
+ GtkWidget *dialog, *parent;
+ GtkWidget *vbox, *label, *sw;
+ GtkWidget *tree_view;
+ GladeProject *project;
+ gchar *title = glade_eprop_object_dialog_title (eprop);
+ gint res;
+ GList *selected_list = NULL, *exception_list = NULL, *selected_objects = NULL;
+
+ project = glade_widget_get_project (eprop->property->widget);
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
+
+
+ dialog = gtk_dialog_new_with_buttons (title,
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ g_free (title);
+
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+
+ gtk_box_pack_start (GTK_BOX
+ (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox,
+ TRUE, TRUE, 0);
+
+ /* Checklist */
+ label = gtk_label_new (_("Objects:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ tree_view = glade_eprop_object_view (FALSE);
+
+
+ exception_list = g_list_prepend (exception_list, eprop->property->widget);
+
+ if (g_value_get_object (eprop->property->value))
+ {
+ GList *l;
+ glade_property_get (eprop->property, &selected_objects);
+ for (l = selected_objects; l; l = l->next)
+ selected_list = g_list_prepend (selected_list,
+ glade_widget_get_from_gobject (l->
+ data));
+ }
+ glade_eprop_object_populate_view (project, GTK_TREE_VIEW (tree_view),
+ selected_list, exception_list,
+ eprop->klass->pspec->value_type,
+ eprop->klass->parentless_widget);
+ g_list_free (selected_list);
+ g_list_free (exception_list);
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ gtk_widget_show (tree_view);
+ gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+ /* Run the dialog */
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+ GValue *value;
+ GList *selected = NULL;
+
+ gtk_tree_model_foreach
+ (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
+ (GtkTreeModelForeachFunc)
+ glade_eprop_objects_selected_widget, &selected);
+
+ value = glade_property_class_make_gvalue (eprop->klass, selected);
+
+ glade_editor_property_commit (eprop, value);
+
+ g_value_unset (value);
+ g_free (value);
+ }
+ else if (res == GLADE_RESPONSE_CLEAR)
+ {
+ GValue *value = glade_property_class_make_gvalue (eprop->klass, NULL);
+
+ glade_editor_property_commit (eprop, value);
+
+ g_value_unset (value);
+ g_free (value);
+ }
+ gtk_widget_destroy (dialog);
}
static GtkWidget *
-glade_eprop_objects_create_input (GladeEditorProperty *eprop)
+glade_eprop_objects_create_input (GladeEditorProperty * eprop)
{
- GladeEPropObjects *eprop_objects = GLADE_EPROP_OBJECTS (eprop);
- GtkWidget *hbox;
- GtkWidget *button;
+ GladeEPropObjects *eprop_objects = GLADE_EPROP_OBJECTS (eprop);
+ GtkWidget *hbox;
+ GtkWidget *button;
- hbox = gtk_hbox_new (FALSE, 0);
- eprop_objects->entry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (eprop_objects->entry), FALSE);
- gtk_widget_show (eprop_objects->entry);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_objects->entry, TRUE, TRUE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
+ eprop_objects->entry = gtk_entry_new ();
+ gtk_editable_set_editable (GTK_EDITABLE (eprop_objects->entry), FALSE);
+ gtk_widget_show (eprop_objects->entry);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_objects->entry, TRUE, TRUE, 0);
- button = gtk_button_new_with_label ("...");
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("...");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_objects_show_dialog),
- eprop);
- return hbox;
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_objects_show_dialog), eprop);
+ return hbox;
}
/*******************************************************************************
@@ -3233,13 +3211,12 @@ glade_eprop_objects_create_input (GladeEditorProperty *eprop)
*
*/
void
-glade_editor_property_commit (GladeEditorProperty *eprop,
- GValue *value)
+glade_editor_property_commit (GladeEditorProperty * eprop, GValue * value)
{
- g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
- g_return_if_fail (G_IS_VALUE (value));
+ g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
+ g_return_if_fail (G_IS_VALUE (value));
- g_signal_emit (G_OBJECT (eprop), glade_eprop_signals[COMMIT], 0, value);
+ g_signal_emit (G_OBJECT (eprop), glade_eprop_signals[COMMIT], 0, value);
}
/**
@@ -3252,18 +3229,18 @@ glade_editor_property_commit (GladeEditorProperty *eprop,
* until its loaded with another property or %NULL)
*/
void
-glade_editor_property_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_editor_property_load (GladeEditorProperty * eprop,
+ GladeProperty * property)
{
- g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
- g_return_if_fail (property == NULL || GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
+ g_return_if_fail (property == NULL || GLADE_IS_PROPERTY (property));
- if (eprop->committing)
- return;
+ if (eprop->committing)
+ return;
- eprop->loading = TRUE;
- GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->load (eprop, property);
- eprop->loading = FALSE;
+ eprop->loading = TRUE;
+ GLADE_EDITOR_PROPERTY_GET_CLASS (eprop)->load (eprop, property);
+ eprop->loading = FALSE;
}
@@ -3276,38 +3253,37 @@ glade_editor_property_load (GladeEditorProperty *eprop,
* @eprop from @widget
*/
void
-glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
- GladeWidget *widget)
-{
- GladeProperty *property = NULL;
-
- g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
- g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
-
- if (widget)
- {
- /* properties are allowed to be missing on some internal widgets */
- if (eprop->klass->packing)
- property = glade_widget_get_pack_property (widget, eprop->klass->id);
- else
- property = glade_widget_get_property (widget, eprop->klass->id);
-
- glade_editor_property_load (eprop, property);
-
- if (property)
- {
- g_assert (eprop->klass == property->klass);
-
- gtk_widget_show (GTK_WIDGET (eprop));
- gtk_widget_show (GTK_WIDGET (eprop->item_label));
- }
- else
- {
- gtk_widget_hide (GTK_WIDGET (eprop));
- gtk_widget_hide (GTK_WIDGET (eprop->item_label));
- }
- }
- else
- glade_editor_property_load (eprop, NULL);
+glade_editor_property_load_by_widget (GladeEditorProperty * eprop,
+ GladeWidget * widget)
+{
+ GladeProperty *property = NULL;
+
+ g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
+ g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
+
+ if (widget)
+ {
+ /* properties are allowed to be missing on some internal widgets */
+ if (eprop->klass->packing)
+ property = glade_widget_get_pack_property (widget, eprop->klass->id);
+ else
+ property = glade_widget_get_property (widget, eprop->klass->id);
+
+ glade_editor_property_load (eprop, property);
+
+ if (property)
+ {
+ g_assert (eprop->klass == property->klass);
+
+ gtk_widget_show (GTK_WIDGET (eprop));
+ gtk_widget_show (GTK_WIDGET (eprop->item_label));
+ }
+ else
+ {
+ gtk_widget_hide (GTK_WIDGET (eprop));
+ gtk_widget_hide (GTK_WIDGET (eprop->item_label));
+ }
+ }
+ else
+ glade_editor_property_load (eprop, NULL);
}
-
diff --git a/gladeui/glade-editor-property.h b/gladeui/glade-editor-property.h
index fd2baf2..8ed99c4 100644
--- a/gladeui/glade-editor-property.h
+++ b/gladeui/glade-editor-property.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_EDITOR_PROPERTY_H__
#define __GLADE_EDITOR_PROPERTY_H__
diff --git a/gladeui/glade-editor-table.c b/gladeui/glade-editor-table.c
index 2a1fd46..de91f5c 100644
--- a/gladeui/glade-editor-table.c
+++ b/gladeui/glade-editor-table.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -26,12 +25,12 @@
#include "glade-editor-table.h"
-static void glade_editor_table_init (GladeEditorTable *self);
-static void glade_editor_table_class_init (GladeEditorTableClass *klass);
-static void glade_editor_table_dispose (GObject *object);
-static void glade_editor_table_editable_init (GladeEditableIface *iface);
-static void glade_editor_table_realize (GtkWidget *widget);
-static void glade_editor_table_grab_focus (GtkWidget *widget);
+static void glade_editor_table_init (GladeEditorTable * self);
+static void glade_editor_table_class_init (GladeEditorTableClass * klass);
+static void glade_editor_table_dispose (GObject * object);
+static void glade_editor_table_editable_init (GladeEditableIface * iface);
+static void glade_editor_table_realize (GtkWidget * widget);
+static void glade_editor_table_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeEditorTable, glade_editor_table, GTK_TYPE_GRID,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
@@ -52,342 +51,340 @@ G_DEFINE_TYPE_WITH_CODE (GladeEditorTable, glade_editor_table, GTK_TYPE_GRID,
static void
-glade_editor_table_class_init (GladeEditorTableClass *klass)
+glade_editor_table_class_init (GladeEditorTableClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->dispose = glade_editor_table_dispose;
- widget_class->realize = glade_editor_table_realize;
- widget_class->grab_focus = glade_editor_table_grab_focus;
+ object_class->dispose = glade_editor_table_dispose;
+ widget_class->realize = glade_editor_table_realize;
+ widget_class->grab_focus = glade_editor_table_grab_focus;
}
static void
-glade_editor_table_init (GladeEditorTable *self)
+glade_editor_table_init (GladeEditorTable * self)
{
- gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (self), 4);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (self),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (self), 4);
}
static void
-glade_editor_table_dispose (GObject *object)
+glade_editor_table_dispose (GObject * object)
{
- GladeEditorTable *table = GLADE_EDITOR_TABLE (object);
+ GladeEditorTable *table = GLADE_EDITOR_TABLE (object);
- table->properties =
- (g_list_free (table->properties), NULL);
+ table->properties = (g_list_free (table->properties), NULL);
- /* the entry is finalized anyway, just avoid setting
- * text in it from _load();
- */
- table->name_entry = NULL;
+ /* the entry is finalized anyway, just avoid setting
+ * text in it from _load();
+ */
+ table->name_entry = NULL;
- glade_editable_load (GLADE_EDITABLE (table), NULL);
+ glade_editable_load (GLADE_EDITABLE (table), NULL);
- G_OBJECT_CLASS (glade_editor_table_parent_class)->dispose (object);
+ G_OBJECT_CLASS (glade_editor_table_parent_class)->dispose (object);
}
static void
-glade_editor_table_realize (GtkWidget *widget)
+glade_editor_table_realize (GtkWidget * widget)
{
- GladeEditorTable *table = GLADE_EDITOR_TABLE (widget);
- GList *list;
- GladeEditorProperty *property;
-
- GTK_WIDGET_CLASS (glade_editor_table_parent_class)->realize (widget);
-
- /* Sync up properties, even if widget is NULL */
- for (list = table->properties; list; list = list->next)
- {
- property = list->data;
- glade_editor_property_load_by_widget (property, table->loaded_widget);
- }
+ GladeEditorTable *table = GLADE_EDITOR_TABLE (widget);
+ GList *list;
+ GladeEditorProperty *property;
+
+ GTK_WIDGET_CLASS (glade_editor_table_parent_class)->realize (widget);
+
+ /* Sync up properties, even if widget is NULL */
+ for (list = table->properties; list; list = list->next)
+ {
+ property = list->data;
+ glade_editor_property_load_by_widget (property, table->loaded_widget);
+ }
}
static void
-glade_editor_table_grab_focus (GtkWidget *widget)
+glade_editor_table_grab_focus (GtkWidget * widget)
{
- GladeEditorTable *editor_table = GLADE_EDITOR_TABLE (widget);
-
- if (editor_table->name_entry && gtk_widget_get_mapped (editor_table->name_entry))
- gtk_widget_grab_focus (editor_table->name_entry);
- else if (editor_table->properties)
- gtk_widget_grab_focus (GTK_WIDGET (editor_table->properties->data));
- else
- GTK_WIDGET_CLASS (glade_editor_table_parent_class)->grab_focus (widget);
+ GladeEditorTable *editor_table = GLADE_EDITOR_TABLE (widget);
+
+ if (editor_table->name_entry &&
+ gtk_widget_get_mapped (editor_table->name_entry))
+ gtk_widget_grab_focus (editor_table->name_entry);
+ else if (editor_table->properties)
+ gtk_widget_grab_focus (GTK_WIDGET (editor_table->properties->data));
+ else
+ GTK_WIDGET_CLASS (glade_editor_table_parent_class)->grab_focus (widget);
}
static void
-widget_name_edited (GtkWidget *editable, GladeEditorTable *table)
+widget_name_edited (GtkWidget * editable, GladeEditorTable * table)
{
- GladeWidget *widget;
- gchar *new_name;
-
- g_return_if_fail (GTK_IS_EDITABLE (editable));
- g_return_if_fail (GLADE_IS_EDITOR_TABLE (table));
-
- if (table->loaded_widget == NULL)
- {
- g_warning ("Name entry edited with no loaded widget in editor %p!\n",
- table);
- return;
- }
-
- widget = table->loaded_widget;
- new_name = gtk_editable_get_chars (GTK_EDITABLE (editable), 0, -1);
-
- if (glade_project_available_widget_name (widget->project, widget, new_name))
- glade_command_set_name (widget, new_name);
- g_free (new_name);
+ GladeWidget *widget;
+ gchar *new_name;
+
+ g_return_if_fail (GTK_IS_EDITABLE (editable));
+ g_return_if_fail (GLADE_IS_EDITOR_TABLE (table));
+
+ if (table->loaded_widget == NULL)
+ {
+ g_warning ("Name entry edited with no loaded widget in editor %p!\n",
+ table);
+ return;
+ }
+
+ widget = table->loaded_widget;
+ new_name = gtk_editable_get_chars (GTK_EDITABLE (editable), 0, -1);
+
+ if (glade_project_available_widget_name (widget->project, widget, new_name))
+ glade_command_set_name (widget, new_name);
+ g_free (new_name);
}
static void
-widget_name_changed (GladeWidget *widget,
- GParamSpec *pspec,
- GladeEditorTable *table)
+widget_name_changed (GladeWidget * widget,
+ GParamSpec * pspec, GladeEditorTable * table)
{
- if (!gtk_widget_get_mapped (GTK_WIDGET (table)))
- return;
+ if (!gtk_widget_get_mapped (GTK_WIDGET (table)))
+ return;
- if (table->name_entry)
- {
- BLOCK_NAME_ENTRY_CB (table);
- gtk_entry_set_text (GTK_ENTRY (table->name_entry), table->loaded_widget->name);
- UNBLOCK_NAME_ENTRY_CB (table);
- }
+ if (table->name_entry)
+ {
+ BLOCK_NAME_ENTRY_CB (table);
+ gtk_entry_set_text (GTK_ENTRY (table->name_entry),
+ table->loaded_widget->name);
+ UNBLOCK_NAME_ENTRY_CB (table);
+ }
-}
+}
static void
-widget_finalized (GladeEditorTable *table,
- GladeWidget *where_widget_was)
+widget_finalized (GladeEditorTable * table, GladeWidget * where_widget_was)
{
- table->loaded_widget = NULL;
+ table->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (table), NULL);
+ glade_editable_load (GLADE_EDITABLE (table), NULL);
}
static void
-glade_editor_table_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_editor_table_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeEditorTable *table = GLADE_EDITOR_TABLE (editable);
- GladeEditorProperty *property;
- GList *list;
-
- /* abort mission */
- if (table->loaded_widget == widget)
- return;
-
- if (table->loaded_widget)
- {
- g_signal_handlers_disconnect_by_func (G_OBJECT (table->loaded_widget),
- G_CALLBACK (widget_name_changed), table);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (table->loaded_widget),
- (GWeakNotify)widget_finalized,
- table);
- }
-
- table->loaded_widget = widget;
-
- BLOCK_NAME_ENTRY_CB (table);
-
- if (table->loaded_widget)
- {
- g_signal_connect (G_OBJECT (table->loaded_widget), "notify::name",
- G_CALLBACK (widget_name_changed), table);
-
- /* The widget could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (table->loaded_widget),
- (GWeakNotify)widget_finalized,
- table);
-
- if (table->name_entry)
- gtk_entry_set_text (GTK_ENTRY (table->name_entry), widget->name);
-
- }
- else if (table->name_entry)
- gtk_entry_set_text (GTK_ENTRY (table->name_entry), "");
-
- UNBLOCK_NAME_ENTRY_CB (table);
-
- /* Sync up properties, even if widget is NULL */
- for (list = table->properties; list; list = list->next)
- {
- property = list->data;
- glade_editor_property_load_by_widget (property, widget);
- }
+ GladeEditorTable *table = GLADE_EDITOR_TABLE (editable);
+ GladeEditorProperty *property;
+ GList *list;
+
+ /* abort mission */
+ if (table->loaded_widget == widget)
+ return;
+
+ if (table->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT (table->loaded_widget),
+ G_CALLBACK (widget_name_changed),
+ table);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (table->loaded_widget),
+ (GWeakNotify) widget_finalized, table);
+ }
+
+ table->loaded_widget = widget;
+
+ BLOCK_NAME_ENTRY_CB (table);
+
+ if (table->loaded_widget)
+ {
+ g_signal_connect (G_OBJECT (table->loaded_widget), "notify::name",
+ G_CALLBACK (widget_name_changed), table);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (table->loaded_widget),
+ (GWeakNotify) widget_finalized, table);
+
+ if (table->name_entry)
+ gtk_entry_set_text (GTK_ENTRY (table->name_entry), widget->name);
+
+ }
+ else if (table->name_entry)
+ gtk_entry_set_text (GTK_ENTRY (table->name_entry), "");
+
+ UNBLOCK_NAME_ENTRY_CB (table);
+
+ /* Sync up properties, even if widget is NULL */
+ for (list = table->properties; list; list = list->next)
+ {
+ property = list->data;
+ glade_editor_property_load_by_widget (property, widget);
+ }
}
static void
-glade_editor_table_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_editor_table_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeEditorTable *table = GLADE_EDITOR_TABLE (editable);
-
- if (table->name_label)
- {
- if (show_name)
- {
- gtk_widget_show (table->name_label);
- gtk_widget_show (table->name_entry);
- }
- else
- {
- gtk_widget_hide (table->name_label);
- gtk_widget_hide (table->name_entry);
- }
- }
+ GladeEditorTable *table = GLADE_EDITOR_TABLE (editable);
+
+ if (table->name_label)
+ {
+ if (show_name)
+ {
+ gtk_widget_show (table->name_label);
+ gtk_widget_show (table->name_entry);
+ }
+ else
+ {
+ gtk_widget_hide (table->name_label);
+ gtk_widget_hide (table->name_entry);
+ }
+ }
}
static void
-glade_editor_table_editable_init (GladeEditableIface *iface)
+glade_editor_table_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_editor_table_load;
- iface->set_show_name = glade_editor_table_set_show_name;
+ iface->load = glade_editor_table_load;
+ iface->set_show_name = glade_editor_table_set_show_name;
}
static void
-glade_editor_table_attach (GladeEditorTable *table,
- GtkWidget *child,
- gint pos, gint row)
+glade_editor_table_attach (GladeEditorTable * table,
+ GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
static gint
property_class_comp (gconstpointer a, gconstpointer b)
{
- const GladePropertyClass *ca = a, *cb = b;
-
- if (ca->pspec->owner_type == cb->pspec->owner_type)
- {
- gdouble result = ca->weight - cb->weight;
- /* Avoid cast to int */
- if (result < 0.0) return -1;
- else if (result > 0.0) return 1;
- else return 0;
- }
- else
- {
- if (g_type_is_a (ca->pspec->owner_type, cb->pspec->owner_type))
- return (ca->common || ca->packing) ? 1 : -1;
- else
- return (ca->common || ca->packing) ? -1 : 1;
- }
+ const GladePropertyClass *ca = a, *cb = b;
+
+ if (ca->pspec->owner_type == cb->pspec->owner_type)
+ {
+ gdouble result = ca->weight - cb->weight;
+ /* Avoid cast to int */
+ if (result < 0.0)
+ return -1;
+ else if (result > 0.0)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ {
+ if (g_type_is_a (ca->pspec->owner_type, cb->pspec->owner_type))
+ return (ca->common || ca->packing) ? 1 : -1;
+ else
+ return (ca->common || ca->packing) ? -1 : 1;
+ }
}
static GList *
-get_sorted_properties (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+get_sorted_properties (GladeWidgetAdaptor * adaptor, GladeEditorPageType type)
{
- GList *l, *list = NULL, *properties;
-
- properties = (type == GLADE_PAGE_PACKING) ? adaptor->packing_props : adaptor->properties;
-
- for (l = properties; l; l = g_list_next (l))
- {
- GladePropertyClass *klass = l->data;
-
- /* Collect properties in our domain, query dialogs are allowed editor
- * invisible properties, allow adaptors to filter out properties from
- * the GladeEditorTable using the "custom-layout" attribute.
- */
- if ((!klass->custom_layout) && GLADE_PROPERTY_CLASS_IS_TYPE (klass, type) &&
- (glade_property_class_is_visible (klass) || type == GLADE_PAGE_QUERY))
- {
- list = g_list_prepend (list, klass);
- }
-
- }
- return g_list_sort (list, property_class_comp);
+ GList *l, *list = NULL, *properties;
+
+ properties =
+ (type ==
+ GLADE_PAGE_PACKING) ? adaptor->packing_props : adaptor->properties;
+
+ for (l = properties; l; l = g_list_next (l))
+ {
+ GladePropertyClass *klass = l->data;
+
+ /* Collect properties in our domain, query dialogs are allowed editor
+ * invisible properties, allow adaptors to filter out properties from
+ * the GladeEditorTable using the "custom-layout" attribute.
+ */
+ if ((!klass->custom_layout) && GLADE_PROPERTY_CLASS_IS_TYPE (klass, type)
+ && (glade_property_class_is_visible (klass) ||
+ type == GLADE_PAGE_QUERY))
+ {
+ list = g_list_prepend (list, klass);
+ }
+
+ }
+ return g_list_sort (list, property_class_comp);
}
static GladeEditorProperty *
-append_item (GladeEditorTable *table,
- GladePropertyClass *klass,
- gboolean from_query_dialog)
+append_item (GladeEditorTable * table,
+ GladePropertyClass * klass, gboolean from_query_dialog)
{
- GladeEditorProperty *property;
+ GladeEditorProperty *property;
- if (!(property = glade_widget_adaptor_create_eprop
- (GLADE_WIDGET_ADAPTOR (klass->handle),
- klass, from_query_dialog == FALSE)))
- {
- g_critical ("Unable to create editor for property '%s' of class '%s'",
- klass->id, GLADE_WIDGET_ADAPTOR (klass->handle)->name);
- return NULL;
- }
+ if (!(property = glade_widget_adaptor_create_eprop
+ (GLADE_WIDGET_ADAPTOR (klass->handle),
+ klass, from_query_dialog == FALSE)))
+ {
+ g_critical ("Unable to create editor for property '%s' of class '%s'",
+ klass->id, GLADE_WIDGET_ADAPTOR (klass->handle)->name);
+ return NULL;
+ }
- gtk_widget_show (GTK_WIDGET (property));
- gtk_widget_show_all (property->item_label);
+ gtk_widget_show (GTK_WIDGET (property));
+ gtk_widget_show_all (property->item_label);
- glade_editor_table_attach (table, property->item_label, 0, table->rows);
- glade_editor_table_attach (table, GTK_WIDGET (property), 1, table->rows);
+ glade_editor_table_attach (table, property->item_label, 0, table->rows);
+ glade_editor_table_attach (table, GTK_WIDGET (property), 1, table->rows);
- table->rows++;
+ table->rows++;
- return property;
+ return property;
}
static void
-append_items (GladeEditorTable *table,
- GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+append_items (GladeEditorTable * table,
+ GladeWidgetAdaptor * adaptor, GladeEditorPageType type)
{
- GladeEditorProperty *property;
- GladePropertyClass *property_class;
- GList *list, *sorted_list;
+ GladeEditorProperty *property;
+ GladePropertyClass *property_class;
+ GList *list, *sorted_list;
- sorted_list = get_sorted_properties (adaptor, type);
- for (list = sorted_list; list != NULL; list = list->next)
- {
- property_class = (GladePropertyClass *) list->data;
+ sorted_list = get_sorted_properties (adaptor, type);
+ for (list = sorted_list; list != NULL; list = list->next)
+ {
+ property_class = (GladePropertyClass *) list->data;
- property = append_item (table, property_class, type == GLADE_PAGE_QUERY);
- table->properties = g_list_prepend (table->properties, property);
- }
- g_list_free (sorted_list);
+ property = append_item (table, property_class, type == GLADE_PAGE_QUERY);
+ table->properties = g_list_prepend (table->properties, property);
+ }
+ g_list_free (sorted_list);
- table->properties = g_list_reverse (table->properties);
+ table->properties = g_list_reverse (table->properties);
}
static void
-append_name_field (GladeEditorTable *table)
+append_name_field (GladeEditorTable * table)
{
- gchar *text = _("The Object's name");
-
- /* Name */
- table->name_label = gtk_label_new (_("Name:"));
- gtk_misc_set_alignment (GTK_MISC (table->name_label), 0.0, 0.5);
- gtk_widget_show (table->name_label);
- gtk_widget_set_no_show_all (table->name_label, TRUE);
-
- table->name_entry = gtk_entry_new ();
- gtk_widget_show (table->name_entry);
- gtk_widget_set_no_show_all (table->name_entry, TRUE);
-
- gtk_widget_set_tooltip_text (table->name_label, text);
- gtk_widget_set_tooltip_text (table->name_entry, text);
-
- g_signal_connect (G_OBJECT (table->name_entry), "activate",
- G_CALLBACK (widget_name_edited), table);
- g_signal_connect (G_OBJECT (table->name_entry), "changed",
- G_CALLBACK (widget_name_edited), table);
-
- glade_editor_table_attach (table, table->name_label, 0, table->rows);
- glade_editor_table_attach (table, table->name_entry, 1, table->rows);
-
- table->rows++;
+ gchar *text = _("The Object's name");
+
+ /* Name */
+ table->name_label = gtk_label_new (_("Name:"));
+ gtk_misc_set_alignment (GTK_MISC (table->name_label), 0.0, 0.5);
+ gtk_widget_show (table->name_label);
+ gtk_widget_set_no_show_all (table->name_label, TRUE);
+
+ table->name_entry = gtk_entry_new ();
+ gtk_widget_show (table->name_entry);
+ gtk_widget_set_no_show_all (table->name_entry, TRUE);
+
+ gtk_widget_set_tooltip_text (table->name_label, text);
+ gtk_widget_set_tooltip_text (table->name_entry, text);
+
+ g_signal_connect (G_OBJECT (table->name_entry), "activate",
+ G_CALLBACK (widget_name_edited), table);
+ g_signal_connect (G_OBJECT (table->name_entry), "changed",
+ G_CALLBACK (widget_name_edited), table);
+
+ glade_editor_table_attach (table, table->name_label, 0, table->rows);
+ glade_editor_table_attach (table, table->name_entry, 1, table->rows);
+
+ table->rows++;
}
/**
@@ -401,23 +398,22 @@ append_name_field (GladeEditorTable *table)
*
*/
GtkWidget *
-glade_editor_table_new (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_editor_table_new (GladeWidgetAdaptor * adaptor, GladeEditorPageType type)
{
- GladeEditorTable *table;
+ GladeEditorTable *table;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ table = g_object_new (GLADE_TYPE_EDITOR_TABLE, NULL);
+ table->adaptor = adaptor;
+ table->type = type;
- table = g_object_new (GLADE_TYPE_EDITOR_TABLE, NULL);
- table->adaptor = adaptor;
- table->type = type;
-
- if (type == GLADE_PAGE_GENERAL)
- append_name_field (table);
+ if (type == GLADE_PAGE_GENERAL)
+ append_name_field (table);
- append_items (table, adaptor, type);
+ append_items (table, adaptor, type);
- gtk_widget_show (GTK_WIDGET (table));
+ gtk_widget_show (GTK_WIDGET (table));
- return GTK_WIDGET (table);
+ return GTK_WIDGET (table);
}
diff --git a/gladeui/glade-editor-table.h b/gladeui/glade-editor-table.h
index 2d91087..b84de54 100644
--- a/gladeui/glade-editor-table.h
+++ b/gladeui/glade-editor-table.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/gladeui/glade-editor.c b/gladeui/glade-editor.c
index 47f5ebd..0068eca 100644
--- a/gladeui/glade-editor.c
+++ b/gladeui/glade-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -56,115 +55,112 @@
enum
{
- PROP_0,
- PROP_SHOW_INFO,
- PROP_WIDGET
+ PROP_0,
+ PROP_SHOW_INFO,
+ PROP_WIDGET
};
-enum {
- GTK_DOC_SEARCH,
- LAST_SIGNAL
+enum
+{
+ GTK_DOC_SEARCH,
+ LAST_SIGNAL
};
static GtkVBoxClass *parent_class = NULL;
-static guint glade_editor_signals[LAST_SIGNAL] = { 0 };
+static guint glade_editor_signals[LAST_SIGNAL] = { 0 };
-static void glade_editor_reset_dialog (GladeEditor *editor);
+static void glade_editor_reset_dialog (GladeEditor * editor);
void
-glade_editor_search_doc_search (GladeEditor *editor,
- const gchar *book,
- const gchar *page,
- const gchar *search)
+glade_editor_search_doc_search (GladeEditor * editor,
+ const gchar * book,
+ const gchar * page, const gchar * search)
{
- g_return_if_fail (GLADE_IS_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_EDITOR (editor));
- g_signal_emit (G_OBJECT (editor),
- glade_editor_signals[GTK_DOC_SEARCH],
- 0, book, page, search);
+ g_signal_emit (G_OBJECT (editor),
+ glade_editor_signals[GTK_DOC_SEARCH], 0, book, page, search);
}
static void
-glade_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_editor_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeEditor *editor = GLADE_EDITOR (object);
-
- switch (prop_id)
- {
- case PROP_SHOW_INFO:
- if (g_value_get_boolean (value))
- glade_editor_show_info (editor);
- else
- glade_editor_hide_info (editor);
- break;
- case PROP_WIDGET:
- glade_editor_load_widget (editor, (GladeWidget *)g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeEditor *editor = GLADE_EDITOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_INFO:
+ if (g_value_get_boolean (value))
+ glade_editor_show_info (editor);
+ else
+ glade_editor_hide_info (editor);
+ break;
+ case PROP_WIDGET:
+ glade_editor_load_widget (editor,
+ (GladeWidget *) g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_editor_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GladeEditor *editor = GLADE_EDITOR (object);
-
- switch (prop_id)
- {
- case PROP_SHOW_INFO:
- g_value_set_boolean (value, editor->show_info);
- break;
- case PROP_WIDGET:
- g_value_set_object (value, editor->loaded_widget);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeEditor *editor = GLADE_EDITOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_INFO:
+ g_value_set_boolean (value, editor->show_info);
+ break;
+ case PROP_WIDGET:
+ g_value_set_object (value, editor->loaded_widget);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_editor_class_init (GladeEditorClass *klass)
+glade_editor_class_init (GladeEditorClass * klass)
{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (klass);
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = glade_editor_set_property;
- object_class->get_property = glade_editor_get_property;
-
- klass->gtk_doc_search = NULL;
-
- /* Properties */
- g_object_class_install_property
- (object_class, PROP_SHOW_INFO,
- g_param_spec_boolean ("show-info",
- _("Show info"),
- _("Whether to show an informational "
- "button for the loaded widget"),
- FALSE, G_PARAM_READABLE));
-
- g_object_class_install_property
- (object_class, PROP_WIDGET,
- g_param_spec_object ("widget",
- _("Widget"),
- _("The currently loaded widget in this editor"),
- GLADE_TYPE_WIDGET, G_PARAM_READWRITE));
-
-
- /**
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (klass);
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = glade_editor_set_property;
+ object_class->get_property = glade_editor_get_property;
+
+ klass->gtk_doc_search = NULL;
+
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_SHOW_INFO,
+ g_param_spec_boolean ("show-info",
+ _("Show info"),
+ _("Whether to show an informational "
+ "button for the loaded widget"),
+ FALSE, G_PARAM_READABLE));
+
+ g_object_class_install_property
+ (object_class, PROP_WIDGET,
+ g_param_spec_object ("widget",
+ _("Widget"),
+ _("The currently loaded widget in this editor"),
+ GLADE_TYPE_WIDGET, G_PARAM_READWRITE));
+
+
+ /**
* GladeEditor::gtk-doc-search:
* @gladeeditor: the #GladeEditor which received the signal.
* @arg1: the (#gchar *) book to search or %NULL
@@ -173,293 +169,293 @@ glade_editor_class_init (GladeEditorClass *klass)
*
* Emitted when the editor requests that a doc-search be performed.
*/
- glade_editor_signals[GTK_DOC_SEARCH] =
- g_signal_new ("gtk-doc-search",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeEditorClass,
- gtk_doc_search),
- NULL, NULL,
- glade_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE, 3,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ glade_editor_signals[GTK_DOC_SEARCH] =
+ g_signal_new ("gtk-doc-search",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeEditorClass,
+ gtk_doc_search),
+ NULL, NULL,
+ glade_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, 3,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
}
static GtkWidget *
-glade_editor_notebook_page (GladeEditor *editor, const gchar *name)
+glade_editor_notebook_page (GladeEditor * editor, const gchar * name)
{
- GtkWidget *alignment;
- GtkWidget *sw;
- GtkWidget *label_widget;
- GtkWidget *image;
- static gchar *path;
- static gint page = 0;
-
- /* alignment is needed to ensure property labels have some padding on the left */
- alignment = gtk_alignment_new (0.5, 0, 1, 0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 0);
-
- /* construct tab label widget */
- if (strcmp (name, _("Accessibility")) == 0)
- {
- path = g_build_filename (glade_app_get_pixmaps_dir (), "atk.png", NULL);
- image = gtk_image_new_from_file (path);
- label_widget = gtk_event_box_new ();
- gtk_container_add (GTK_CONTAINER (label_widget), image);
- gtk_widget_show (label_widget);
- gtk_widget_show (image);
-
- gtk_widget_set_tooltip_text (label_widget, name);
- }
- else
- {
- label_widget = gtk_label_new_with_mnemonic (name);
- }
-
- /* configure page container */
- if (strcmp (name, _("_Signals")) == 0)
- {
- gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.5, 0.5, 1, 1);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 0, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (alignment), 6);
- gtk_notebook_insert_page (GTK_NOTEBOOK (editor->notebook), alignment,
- label_widget, page++);
- }
- else
- {
- /* wrap the alignment in a scrolled window */
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
- GTK_WIDGET (alignment));
- gtk_container_set_border_width (GTK_CONTAINER (sw), 6);
-
- gtk_notebook_insert_page (GTK_NOTEBOOK (editor->notebook), sw,
- label_widget, page++);
-
- }
-
- return alignment;
+ GtkWidget *alignment;
+ GtkWidget *sw;
+ GtkWidget *label_widget;
+ GtkWidget *image;
+ static gchar *path;
+ static gint page = 0;
+
+ /* alignment is needed to ensure property labels have some padding on the left */
+ alignment = gtk_alignment_new (0.5, 0, 1, 0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 6, 0);
+
+ /* construct tab label widget */
+ if (strcmp (name, _("Accessibility")) == 0)
+ {
+ path = g_build_filename (glade_app_get_pixmaps_dir (), "atk.png", NULL);
+ image = gtk_image_new_from_file (path);
+ label_widget = gtk_event_box_new ();
+ gtk_container_add (GTK_CONTAINER (label_widget), image);
+ gtk_widget_show (label_widget);
+ gtk_widget_show (image);
+
+ gtk_widget_set_tooltip_text (label_widget, name);
+ }
+ else
+ {
+ label_widget = gtk_label_new_with_mnemonic (name);
+ }
+
+ /* configure page container */
+ if (strcmp (name, _("_Signals")) == 0)
+ {
+ gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.5, 0.5, 1, 1);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 0, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (alignment), 6);
+ gtk_notebook_insert_page (GTK_NOTEBOOK (editor->notebook), alignment,
+ label_widget, page++);
+ }
+ else
+ {
+ /* wrap the alignment in a scrolled window */
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
+ GTK_WIDGET (alignment));
+ gtk_container_set_border_width (GTK_CONTAINER (sw), 6);
+
+ gtk_notebook_insert_page (GTK_NOTEBOOK (editor->notebook), sw,
+ label_widget, page++);
+
+ }
+
+ return alignment;
}
static void
-glade_editor_on_reset_click (GtkButton *button,
- GladeEditor *editor)
+glade_editor_on_reset_click (GtkButton * button, GladeEditor * editor)
{
- glade_editor_reset_dialog (editor);
+ glade_editor_reset_dialog (editor);
}
static void
-glade_editor_on_docs_click (GtkButton *button,
- GladeEditor *editor)
+glade_editor_on_docs_click (GtkButton * button, GladeEditor * editor)
{
- gchar *book;
-
- if (editor->loaded_widget)
- {
- g_object_get (editor->loaded_widget->adaptor, "book", &book, NULL);
- glade_editor_search_doc_search (editor, book,
- editor->loaded_widget->adaptor->name,
- NULL);
- g_free (book);
- }
+ gchar *book;
+
+ if (editor->loaded_widget)
+ {
+ g_object_get (editor->loaded_widget->adaptor, "book", &book, NULL);
+ glade_editor_search_doc_search (editor, book,
+ editor->loaded_widget->adaptor->name,
+ NULL);
+ g_free (book);
+ }
}
static GtkWidget *
-glade_editor_create_info_button (GladeEditor *editor)
+glade_editor_create_info_button (GladeEditor * editor)
{
- GtkWidget *button;
- GtkWidget *image;
-
- button = gtk_button_new ();
+ GtkWidget *button;
+ GtkWidget *image;
- image = glade_util_get_devhelp_icon (GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (image);
+ button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), image);
+ image = glade_util_get_devhelp_icon (GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image);
- gtk_widget_set_tooltip_text (button, _("View documentation for the selected widget"));
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_editor_on_docs_click), editor);
+ gtk_container_add (GTK_CONTAINER (button), image);
- return button;
+ gtk_widget_set_tooltip_text (button,
+ _("View documentation for the selected widget"));
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_editor_on_docs_click), editor);
+
+ return button;
}
static GtkWidget *
-glade_editor_create_reset_button (GladeEditor *editor)
+glade_editor_create_reset_button (GladeEditor * editor)
{
- GtkWidget *image;
- GtkWidget *button;
+ GtkWidget *image;
+ GtkWidget *button;
- button = gtk_button_new ();
+ button = gtk_button_new ();
- image = gtk_image_new_from_stock ("gtk-clear", GTK_ICON_SIZE_BUTTON);
+ image = gtk_image_new_from_stock ("gtk-clear", GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_set_tooltip_text (button, _("Reset widget properties to their defaults"));
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_editor_on_reset_click), editor);
+ gtk_widget_set_tooltip_text (button,
+ _("Reset widget properties to their defaults"));
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_editor_on_reset_click), editor);
- return button;
+ return button;
}
static void
-glade_editor_update_class_warning_cb (GladeWidget *widget,
- GParamSpec *pspec,
- GladeEditor *editor)
+glade_editor_update_class_warning_cb (GladeWidget * widget,
+ GParamSpec * pspec, GladeEditor * editor)
{
- if (widget->support_warning)
- gtk_widget_show (editor->warning);
- else
- gtk_widget_hide (editor->warning);
+ if (widget->support_warning)
+ gtk_widget_show (editor->warning);
+ else
+ gtk_widget_hide (editor->warning);
- gtk_widget_set_tooltip_text (editor->warning, widget->support_warning);
+ gtk_widget_set_tooltip_text (editor->warning, widget->support_warning);
}
static void
-glade_editor_update_class_field (GladeEditor *editor)
+glade_editor_update_class_field (GladeEditor * editor)
{
- if (editor->loaded_widget)
- {
- GladeWidget *widget = editor->loaded_widget;
- gchar *text;
-
- gtk_image_set_from_icon_name (GTK_IMAGE (editor->class_icon),
- widget->adaptor->icon_name,
- GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (editor->class_icon);
-
- /* translators: referring to the properties of a widget named '%s [%s]' */
- text = g_strdup_printf (_("%s Properties - %s [%s]"),
- widget->adaptor->title,
- widget->adaptor->name,
- widget->name);
- gtk_label_set_text (GTK_LABEL (editor->class_label), text);
- g_free (text);
-
- glade_editor_update_class_warning_cb (editor->loaded_widget, NULL, editor);
- }
- else
- {
- gtk_widget_hide (editor->class_icon);
- gtk_widget_hide (editor->warning);
- gtk_label_set_text (GTK_LABEL (editor->class_label), _("Properties"));
- }
+ if (editor->loaded_widget)
+ {
+ GladeWidget *widget = editor->loaded_widget;
+ gchar *text;
+
+ gtk_image_set_from_icon_name (GTK_IMAGE (editor->class_icon),
+ widget->adaptor->icon_name,
+ GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (editor->class_icon);
+
+ /* translators: referring to the properties of a widget named '%s [%s]' */
+ text = g_strdup_printf (_("%s Properties - %s [%s]"),
+ widget->adaptor->title,
+ widget->adaptor->name, widget->name);
+ gtk_label_set_text (GTK_LABEL (editor->class_label), text);
+ g_free (text);
+
+ glade_editor_update_class_warning_cb (editor->loaded_widget, NULL,
+ editor);
+ }
+ else
+ {
+ gtk_widget_hide (editor->class_icon);
+ gtk_widget_hide (editor->warning);
+ gtk_label_set_text (GTK_LABEL (editor->class_label), _("Properties"));
+ }
}
static void
-glade_editor_update_widget_name_cb (GladeWidget *widget,
- GParamSpec *pspec,
- GladeEditor *editor)
+glade_editor_update_widget_name_cb (GladeWidget * widget,
+ GParamSpec * pspec, GladeEditor * editor)
{
- glade_editor_update_class_field (editor);
+ glade_editor_update_class_field (editor);
}
static GtkWidget *
-glade_editor_setup_class_field (GladeEditor *editor)
+glade_editor_setup_class_field (GladeEditor * editor)
{
- GtkWidget *hbox;
-
- hbox = gtk_hbox_new (FALSE, 4);
+ GtkWidget *hbox;
+
+ hbox = gtk_hbox_new (FALSE, 4);
- editor->class_icon = gtk_image_new ();
- editor->class_label = gtk_label_new (NULL);
- editor->warning = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
- GTK_ICON_SIZE_MENU);
+ editor->class_icon = gtk_image_new ();
+ editor->class_label = gtk_label_new (NULL);
+ editor->warning = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
+ GTK_ICON_SIZE_MENU);
- gtk_widget_set_no_show_all (editor->warning, TRUE);
- gtk_widget_set_no_show_all (editor->class_icon, TRUE);
+ gtk_widget_set_no_show_all (editor->warning, TRUE);
+ gtk_widget_set_no_show_all (editor->class_icon, TRUE);
- gtk_misc_set_alignment (GTK_MISC (editor->class_label), 0.0, 0.5);
- gtk_label_set_ellipsize (GTK_LABEL (editor->class_label),
- PANGO_ELLIPSIZE_END);
+ gtk_misc_set_alignment (GTK_MISC (editor->class_label), 0.0, 0.5);
+ gtk_label_set_ellipsize (GTK_LABEL (editor->class_label),
+ PANGO_ELLIPSIZE_END);
- gtk_box_pack_start (GTK_BOX (hbox), editor->class_icon, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), editor->warning, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), editor->class_label, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), editor->class_icon, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), editor->warning, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), editor->class_label, TRUE, TRUE, 0);
- glade_editor_update_class_field (editor);
- gtk_widget_show_all (hbox);
+ glade_editor_update_class_field (editor);
+ gtk_widget_show_all (hbox);
- return hbox;
+ return hbox;
}
static void
-glade_editor_init (GladeEditor *editor)
+glade_editor_init (GladeEditor * editor)
{
- GtkSizeGroup *size_group;
- GtkWidget *hbox;
+ GtkSizeGroup *size_group;
+ GtkWidget *hbox;
- editor->notebook = gtk_notebook_new ();
- editor->page_widget = glade_editor_notebook_page (editor, _("_General"));
- editor->page_packing = glade_editor_notebook_page (editor, _("_Packing"));
- editor->page_common = glade_editor_notebook_page (editor, _("_Common"));
- editor->page_signals = glade_editor_notebook_page (editor, _("_Signals"));
- editor->page_atk = glade_editor_notebook_page (editor, _("Accessibility"));
- editor->editables = NULL;
- editor->loading = FALSE;
+ editor->notebook = gtk_notebook_new ();
+ editor->page_widget = glade_editor_notebook_page (editor, _("_General"));
+ editor->page_packing = glade_editor_notebook_page (editor, _("_Packing"));
+ editor->page_common = glade_editor_notebook_page (editor, _("_Common"));
+ editor->page_signals = glade_editor_notebook_page (editor, _("_Signals"));
+ editor->page_atk = glade_editor_notebook_page (editor, _("Accessibility"));
+ editor->editables = NULL;
+ editor->loading = FALSE;
- editor->class_field = glade_editor_setup_class_field (editor);
+ editor->class_field = glade_editor_setup_class_field (editor);
- gtk_container_set_border_width (GTK_CONTAINER (editor->notebook), 0);
+ gtk_container_set_border_width (GTK_CONTAINER (editor->notebook), 0);
- gtk_box_pack_start (GTK_BOX (editor), editor->class_field, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (editor), editor->notebook, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (editor), editor->class_field, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (editor), editor->notebook, TRUE, TRUE, 0);
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
- gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
+ gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
- /* Reset button */
- editor->reset_button = glade_editor_create_reset_button (editor);
- gtk_box_pack_end (GTK_BOX (hbox), editor->reset_button, FALSE, FALSE, 0);
- gtk_size_group_add_widget (size_group, editor->reset_button);
+ /* Reset button */
+ editor->reset_button = glade_editor_create_reset_button (editor);
+ gtk_box_pack_end (GTK_BOX (hbox), editor->reset_button, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (size_group, editor->reset_button);
- /* Documentation button */
- editor->info_button = glade_editor_create_info_button (editor);
- gtk_box_pack_end (GTK_BOX (hbox), editor->info_button, FALSE, FALSE, 0);
- gtk_size_group_add_widget (size_group, editor->info_button);
+ /* Documentation button */
+ editor->info_button = glade_editor_create_info_button (editor);
+ gtk_box_pack_end (GTK_BOX (hbox), editor->info_button, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (size_group, editor->info_button);
- g_object_unref(size_group);
+ g_object_unref (size_group);
- gtk_widget_show_all (GTK_WIDGET (editor));
- if (editor->show_info)
- gtk_widget_show (editor->info_button);
- else
- gtk_widget_hide (editor->info_button);
+ gtk_widget_show_all (GTK_WIDGET (editor));
+ if (editor->show_info)
+ gtk_widget_show (editor->info_button);
+ else
+ gtk_widget_hide (editor->info_button);
- gtk_widget_hide (GTK_WIDGET (editor));
+ gtk_widget_hide (GTK_WIDGET (editor));
}
GType
glade_editor_get_type (void)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (GladeEditorClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) glade_editor_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (GladeEditor),
- 0,
- (GInstanceInitFunc) glade_editor_init
- };
-
- type = g_type_register_static (GTK_TYPE_VBOX, "GladeEditor", &info, 0);
- }
-
- return type;
+ static GType type = 0;
+
+ if (!type)
+ {
+ static const GTypeInfo info = {
+ sizeof (GladeEditorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) glade_editor_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GladeEditor),
+ 0,
+ (GInstanceInitFunc) glade_editor_init
+ };
+
+ type = g_type_register_static (GTK_TYPE_VBOX, "GladeEditor", &info, 0);
+ }
+
+ return type;
}
/**
@@ -470,305 +466,311 @@ glade_editor_get_type (void)
GladeEditor *
glade_editor_new (void)
{
- GladeEditor *editor;
+ GladeEditor *editor;
- editor = g_object_new (GLADE_TYPE_EDITOR,
- "spacing", 6,
- NULL);
-
- return editor;
+ editor = g_object_new (GLADE_TYPE_EDITOR, "spacing", 6, NULL);
+
+ return editor;
}
static GtkWidget *
-glade_editor_get_editable_by_adaptor (GladeEditor *editor,
- GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_editor_get_editable_by_adaptor (GladeEditor * editor,
+ GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GtkWidget *editable;
- GList *list;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
-
- for (list = editor->editables; list; list = list->next)
- {
- editable = list->data;
- if (type != GPOINTER_TO_INT (g_object_get_data (G_OBJECT (editable), "glade-editor-page-type")))
- continue;
- if (g_object_get_data (G_OBJECT (editable), "glade-widget-adaptor") == adaptor)
- return editable;
- }
-
- editable = (GtkWidget *)glade_widget_adaptor_create_editable (adaptor, type);
- g_return_val_if_fail (editable != NULL, NULL);
-
- g_object_set_data (G_OBJECT (editable), "glade-editor-page-type", GINT_TO_POINTER (type));
- g_object_set_data (G_OBJECT (editable), "glade-widget-adaptor", adaptor);
-
- if (type != GLADE_PAGE_PACKING)
- {
- editor->editables = g_list_prepend (editor->editables, editable);
- g_object_ref_sink (editable);
- }
-
- return editable;
+ GtkWidget *editable;
+ GList *list;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+
+ for (list = editor->editables; list; list = list->next)
+ {
+ editable = list->data;
+ if (type !=
+ GPOINTER_TO_INT (g_object_get_data
+ (G_OBJECT (editable), "glade-editor-page-type")))
+ continue;
+ if (g_object_get_data (G_OBJECT (editable), "glade-widget-adaptor") ==
+ adaptor)
+ return editable;
+ }
+
+ editable = (GtkWidget *) glade_widget_adaptor_create_editable (adaptor, type);
+ g_return_val_if_fail (editable != NULL, NULL);
+
+ g_object_set_data (G_OBJECT (editable), "glade-editor-page-type",
+ GINT_TO_POINTER (type));
+ g_object_set_data (G_OBJECT (editable), "glade-widget-adaptor", adaptor);
+
+ if (type != GLADE_PAGE_PACKING)
+ {
+ editor->editables = g_list_prepend (editor->editables, editable);
+ g_object_ref_sink (editable);
+ }
+
+ return editable;
}
static GtkWidget *
-glade_editor_load_editable_in_page (GladeEditor *editor,
- GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_editor_load_editable_in_page (GladeEditor * editor,
+ GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GtkContainer *container = NULL;
- GtkWidget *scrolled_window, *editable, *child;
- GtkAdjustment *adj;
-
- /* Remove the old table that was in this container */
- switch (type)
- {
- case GLADE_PAGE_GENERAL:
- container = GTK_CONTAINER (editor->page_widget);
- break;
- case GLADE_PAGE_COMMON:
- container = GTK_CONTAINER (editor->page_common);
- break;
- case GLADE_PAGE_PACKING:
- container = GTK_CONTAINER (editor->page_packing);
- break;
- case GLADE_PAGE_ATK:
- container = GTK_CONTAINER (editor->page_atk);
- break;
- case GLADE_PAGE_QUERY:
- default:
- g_critical ("Unreachable code reached !");
- break;
- }
-
- /* Remove the editable (this will destroy on packing pages) */
- child = gtk_bin_get_child (GTK_BIN (container));
- if (child)
- {
- gtk_widget_hide (child);
- gtk_container_remove (container, child);
- }
-
- if (!adaptor)
- return NULL;
-
- if ((editable = glade_editor_get_editable_by_adaptor (editor, adaptor, type)) == NULL)
- return NULL;
-
- /* Attach the new page */
- gtk_container_add (GTK_CONTAINER (container), editable);
- gtk_widget_show (editable);
-
- /* Enable tabbed keynav in the editor */
- scrolled_window = gtk_widget_get_parent (GTK_WIDGET (container));
- scrolled_window = gtk_widget_get_parent (scrolled_window);
-
- /* FIXME: Save pointer to the scrolled window (or just the
- adjustments) before hand. */
- g_assert (GTK_IS_SCROLLED_WINDOW (scrolled_window));
-
- adj = gtk_scrolled_window_get_vadjustment
- (GTK_SCROLLED_WINDOW (scrolled_window));
- gtk_container_set_focus_vadjustment
- (GTK_CONTAINER (editable), adj);
-
- adj = gtk_scrolled_window_get_hadjustment
- (GTK_SCROLLED_WINDOW (scrolled_window));
- gtk_container_set_focus_hadjustment
- (GTK_CONTAINER (editable), adj);
-
- return editable;
+ GtkContainer *container = NULL;
+ GtkWidget *scrolled_window, *editable, *child;
+ GtkAdjustment *adj;
+
+ /* Remove the old table that was in this container */
+ switch (type)
+ {
+ case GLADE_PAGE_GENERAL:
+ container = GTK_CONTAINER (editor->page_widget);
+ break;
+ case GLADE_PAGE_COMMON:
+ container = GTK_CONTAINER (editor->page_common);
+ break;
+ case GLADE_PAGE_PACKING:
+ container = GTK_CONTAINER (editor->page_packing);
+ break;
+ case GLADE_PAGE_ATK:
+ container = GTK_CONTAINER (editor->page_atk);
+ break;
+ case GLADE_PAGE_QUERY:
+ default:
+ g_critical ("Unreachable code reached !");
+ break;
+ }
+
+ /* Remove the editable (this will destroy on packing pages) */
+ child = gtk_bin_get_child (GTK_BIN (container));
+ if (child)
+ {
+ gtk_widget_hide (child);
+ gtk_container_remove (container, child);
+ }
+
+ if (!adaptor)
+ return NULL;
+
+ if ((editable =
+ glade_editor_get_editable_by_adaptor (editor, adaptor, type)) == NULL)
+ return NULL;
+
+ /* Attach the new page */
+ gtk_container_add (GTK_CONTAINER (container), editable);
+ gtk_widget_show (editable);
+
+ /* Enable tabbed keynav in the editor */
+ scrolled_window = gtk_widget_get_parent (GTK_WIDGET (container));
+ scrolled_window = gtk_widget_get_parent (scrolled_window);
+
+ /* FIXME: Save pointer to the scrolled window (or just the
+ adjustments) before hand. */
+ g_assert (GTK_IS_SCROLLED_WINDOW (scrolled_window));
+
+ adj = gtk_scrolled_window_get_vadjustment
+ (GTK_SCROLLED_WINDOW (scrolled_window));
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (editable), adj);
+
+ adj = gtk_scrolled_window_get_hadjustment
+ (GTK_SCROLLED_WINDOW (scrolled_window));
+ gtk_container_set_focus_hadjustment (GTK_CONTAINER (editable), adj);
+
+ return editable;
}
void
-glade_editor_set_signal_editor (GladeEditor *editor, GladeSignalEditor *signal_editor)
+glade_editor_set_signal_editor (GladeEditor * editor,
+ GladeSignalEditor * signal_editor)
{
- if (editor->signal_editor) {
- gtk_container_remove (GTK_CONTAINER (editor->page_signals),
- GTK_WIDGET(editor->signal_editor));
- }
- editor->signal_editor = signal_editor;
- gtk_container_add (GTK_CONTAINER (editor->page_signals),
- GTK_WIDGET(editor->signal_editor));
+ if (editor->signal_editor)
+ {
+ gtk_container_remove (GTK_CONTAINER (editor->page_signals),
+ GTK_WIDGET (editor->signal_editor));
+ }
+ editor->signal_editor = signal_editor;
+ gtk_container_add (GTK_CONTAINER (editor->page_signals),
+ GTK_WIDGET (editor->signal_editor));
}
static void
-glade_editor_load_signal_page (GladeEditor *editor)
+glade_editor_load_signal_page (GladeEditor * editor)
{
- if (editor->signal_editor == NULL) {
- editor->signal_editor = glade_signal_editor_new ((gpointer) editor);
- gtk_container_add (GTK_CONTAINER (editor->page_signals),
- GTK_WIDGET(editor->signal_editor));
- }
+ if (editor->signal_editor == NULL)
+ {
+ editor->signal_editor = glade_signal_editor_new ((gpointer) editor);
+ gtk_container_add (GTK_CONTAINER (editor->page_signals),
+ GTK_WIDGET (editor->signal_editor));
+ }
}
static void
-glade_editor_load_widget_class (GladeEditor *editor, GladeWidgetAdaptor *adaptor)
+glade_editor_load_widget_class (GladeEditor * editor,
+ GladeWidgetAdaptor * adaptor)
{
- glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_GENERAL);
- glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_COMMON);
- glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_ATK);
+ glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_GENERAL);
+ glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_COMMON);
+ glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_ATK);
+
+ glade_editor_load_signal_page (editor);
- glade_editor_load_signal_page (editor);
-
- editor->loaded_adaptor = adaptor;
+ editor->loaded_adaptor = adaptor;
}
static void
-glade_editor_close_cb (GladeProject *project,
- GladeEditor *editor)
+glade_editor_close_cb (GladeProject * project, GladeEditor * editor)
{
- /* project we are viewing was closed,
- * detatch from editor.
- */
- glade_editor_load_widget (editor, NULL);
+ /* project we are viewing was closed,
+ * detatch from editor.
+ */
+ glade_editor_load_widget (editor, NULL);
}
static void
-glade_editor_removed_cb (GladeProject *project,
- GladeWidget *widget,
- GladeEditor *editor)
+glade_editor_removed_cb (GladeProject * project,
+ GladeWidget * widget, GladeEditor * editor)
{
- /* Widget we were viewing was removed from project,
- * detatch from editor.
- */
- if (widget == editor->loaded_widget)
- glade_editor_load_widget (editor, NULL);
+ /* Widget we were viewing was removed from project,
+ * detatch from editor.
+ */
+ if (widget == editor->loaded_widget)
+ glade_editor_load_widget (editor, NULL);
}
static void
-glade_editor_load_editable (GladeEditor *editor,
- GladeWidget *widget,
- GladeEditorPageType type)
+glade_editor_load_editable (GladeEditor * editor,
+ GladeWidget * widget, GladeEditorPageType type)
{
- GtkWidget *editable;
-
- /* Use the parenting adaptor for packing pages... so deffer creating the widgets
- * until load time.
- */
- if (type == GLADE_PAGE_PACKING && widget->parent)
- {
- GladeWidgetAdaptor *adaptor = widget->parent->adaptor;
- editable = glade_editor_load_editable_in_page (editor, adaptor, GLADE_PAGE_PACKING);
- }
- else
- editable = glade_editor_get_editable_by_adaptor
- (editor, widget->adaptor, type);
-
- g_assert (editable);
-
- if (!widget) gtk_widget_hide (editable);
-
- glade_editable_load (GLADE_EDITABLE (editable), widget);
-
- if (widget) gtk_widget_show (editable);
+ GtkWidget *editable;
+
+ /* Use the parenting adaptor for packing pages... so deffer creating the widgets
+ * until load time.
+ */
+ if (type == GLADE_PAGE_PACKING && widget->parent)
+ {
+ GladeWidgetAdaptor *adaptor = widget->parent->adaptor;
+ editable =
+ glade_editor_load_editable_in_page (editor, adaptor,
+ GLADE_PAGE_PACKING);
+ }
+ else
+ editable = glade_editor_get_editable_by_adaptor
+ (editor, widget->adaptor, type);
+
+ g_assert (editable);
+
+ if (!widget)
+ gtk_widget_hide (editable);
+
+ glade_editable_load (GLADE_EDITABLE (editable), widget);
+
+ if (widget)
+ gtk_widget_show (editable);
}
static void
-clear_editables (GladeEditor *editor)
+clear_editables (GladeEditor * editor)
{
- GladeEditable *editable;
- GList *l;
-
- for (l = editor->editables; l; l = l->next)
- {
- editable = l->data;
- glade_editable_load (editable, NULL);
- }
+ GladeEditable *editable;
+ GList *l;
+
+ for (l = editor->editables; l; l = l->next)
+ {
+ editable = l->data;
+ glade_editable_load (editable, NULL);
+ }
}
static void
-glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget)
+glade_editor_load_widget_real (GladeEditor * editor, GladeWidget * widget)
{
- GladeWidgetAdaptor *adaptor;
- GladeProject *project;
- gchar *book;
-
- /* Disconnect from last widget */
- if (editor->loaded_widget != NULL)
- {
- /* better pay a small price now and avoid unseen editables
- * waking up on project metadata changes.
- */
- clear_editables (editor);
-
- project = glade_widget_get_project (editor->loaded_widget);
- g_signal_handler_disconnect (G_OBJECT (project),
- editor->project_closed_signal_id);
- g_signal_handler_disconnect (G_OBJECT (project),
- editor->project_removed_signal_id);
- g_signal_handler_disconnect (G_OBJECT (editor->loaded_widget),
- editor->widget_warning_id);
- g_signal_handler_disconnect (G_OBJECT (editor->loaded_widget),
- editor->widget_name_id);
- }
-
- /* Load the GladeWidgetClass */
- adaptor = widget ? widget->adaptor : NULL;
- if (editor->loaded_adaptor != adaptor || adaptor == NULL)
- glade_editor_load_widget_class (editor, adaptor);
-
- glade_signal_editor_load_widget (editor->signal_editor, widget);
-
- /* we are just clearing, we are done */
- if (widget == NULL)
- {
- gtk_widget_set_sensitive (editor->reset_button, FALSE);
- gtk_widget_set_sensitive (editor->info_button, FALSE);
-
- editor->loaded_widget = NULL;
-
- /* Clear class header */
- glade_editor_update_class_field (editor);
-
- g_object_notify (G_OBJECT (editor), "widget");
- return;
- }
- gtk_widget_set_sensitive (editor->reset_button, TRUE);
-
- g_object_get (editor->loaded_adaptor, "book", &book, NULL);
- gtk_widget_set_sensitive (editor->info_button, book != NULL);
- g_free (book);
-
- editor->loading = TRUE;
-
- /* Load each GladeEditorProperty from 'widget' */
- glade_editor_load_editable (editor, widget, GLADE_PAGE_GENERAL);
- glade_editor_load_editable (editor, widget, GLADE_PAGE_COMMON);
- glade_editor_load_editable (editor, widget, GLADE_PAGE_ATK);
- glade_editor_load_editable (editor, widget, GLADE_PAGE_PACKING);
-
- editor->loaded_widget = widget;
- editor->loading = FALSE;
-
- /* Update class header */
- glade_editor_update_class_field (editor);
-
- /* Connect to new widget */
- project = glade_widget_get_project (editor->loaded_widget);
- editor->project_closed_signal_id =
- g_signal_connect (G_OBJECT (project), "close",
- G_CALLBACK (glade_editor_close_cb), editor);
- editor->project_removed_signal_id =
- g_signal_connect (G_OBJECT (project), "remove-widget",
- G_CALLBACK (glade_editor_removed_cb), editor);
- editor->widget_warning_id =
- g_signal_connect (G_OBJECT (widget), "notify::support-warning",
- G_CALLBACK (glade_editor_update_class_warning_cb),
- editor);
- editor->widget_name_id =
- g_signal_connect (G_OBJECT (widget), "notify::name",
- G_CALLBACK (glade_editor_update_widget_name_cb),
- editor);
-
- gtk_container_check_resize (GTK_CONTAINER (editor));
-
- g_object_notify (G_OBJECT (editor), "widget");
+ GladeWidgetAdaptor *adaptor;
+ GladeProject *project;
+ gchar *book;
+
+ /* Disconnect from last widget */
+ if (editor->loaded_widget != NULL)
+ {
+ /* better pay a small price now and avoid unseen editables
+ * waking up on project metadata changes.
+ */
+ clear_editables (editor);
+
+ project = glade_widget_get_project (editor->loaded_widget);
+ g_signal_handler_disconnect (G_OBJECT (project),
+ editor->project_closed_signal_id);
+ g_signal_handler_disconnect (G_OBJECT (project),
+ editor->project_removed_signal_id);
+ g_signal_handler_disconnect (G_OBJECT (editor->loaded_widget),
+ editor->widget_warning_id);
+ g_signal_handler_disconnect (G_OBJECT (editor->loaded_widget),
+ editor->widget_name_id);
+ }
+
+ /* Load the GladeWidgetClass */
+ adaptor = widget ? widget->adaptor : NULL;
+ if (editor->loaded_adaptor != adaptor || adaptor == NULL)
+ glade_editor_load_widget_class (editor, adaptor);
+
+ glade_signal_editor_load_widget (editor->signal_editor, widget);
+
+ /* we are just clearing, we are done */
+ if (widget == NULL)
+ {
+ gtk_widget_set_sensitive (editor->reset_button, FALSE);
+ gtk_widget_set_sensitive (editor->info_button, FALSE);
+
+ editor->loaded_widget = NULL;
+
+ /* Clear class header */
+ glade_editor_update_class_field (editor);
+
+ g_object_notify (G_OBJECT (editor), "widget");
+ return;
+ }
+ gtk_widget_set_sensitive (editor->reset_button, TRUE);
+
+ g_object_get (editor->loaded_adaptor, "book", &book, NULL);
+ gtk_widget_set_sensitive (editor->info_button, book != NULL);
+ g_free (book);
+
+ editor->loading = TRUE;
+
+ /* Load each GladeEditorProperty from 'widget' */
+ glade_editor_load_editable (editor, widget, GLADE_PAGE_GENERAL);
+ glade_editor_load_editable (editor, widget, GLADE_PAGE_COMMON);
+ glade_editor_load_editable (editor, widget, GLADE_PAGE_ATK);
+ glade_editor_load_editable (editor, widget, GLADE_PAGE_PACKING);
+
+ editor->loaded_widget = widget;
+ editor->loading = FALSE;
+
+ /* Update class header */
+ glade_editor_update_class_field (editor);
+
+ /* Connect to new widget */
+ project = glade_widget_get_project (editor->loaded_widget);
+ editor->project_closed_signal_id =
+ g_signal_connect (G_OBJECT (project), "close",
+ G_CALLBACK (glade_editor_close_cb), editor);
+ editor->project_removed_signal_id =
+ g_signal_connect (G_OBJECT (project), "remove-widget",
+ G_CALLBACK (glade_editor_removed_cb), editor);
+ editor->widget_warning_id =
+ g_signal_connect (G_OBJECT (widget), "notify::support-warning",
+ G_CALLBACK (glade_editor_update_class_warning_cb),
+ editor);
+ editor->widget_name_id =
+ g_signal_connect (G_OBJECT (widget), "notify::name",
+ G_CALLBACK (glade_editor_update_widget_name_cb),
+ editor);
+
+ gtk_container_check_resize (GTK_CONTAINER (editor));
+
+ g_object_notify (G_OBJECT (editor), "widget");
}
/**
@@ -779,15 +781,15 @@ glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget)
* Load @widget into @editor. If @widget is %NULL, clear the editor.
*/
void
-glade_editor_load_widget (GladeEditor *editor, GladeWidget *widget)
+glade_editor_load_widget (GladeEditor * editor, GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_EDITOR (editor));
- g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
-
- if (editor->loaded_widget == widget)
- return;
+ g_return_if_fail (GLADE_IS_EDITOR (editor));
+ g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
+
+ if (editor->loaded_widget == widget)
+ return;
- glade_editor_load_widget_real (editor, widget);
+ glade_editor_load_widget_real (editor, widget);
}
/**
@@ -797,537 +799,514 @@ glade_editor_load_widget (GladeEditor *editor, GladeWidget *widget)
* Synchronize @editor with the currently loaded widget.
*/
void
-glade_editor_refresh (GladeEditor *editor)
+glade_editor_refresh (GladeEditor * editor)
{
- g_return_if_fail (GLADE_IS_EDITOR (editor));
- glade_editor_load_widget_real (editor, editor->loaded_widget);
+ g_return_if_fail (GLADE_IS_EDITOR (editor));
+ glade_editor_load_widget_real (editor, editor->loaded_widget);
}
static void
-query_dialog_style_set_cb (GtkWidget *dialog,
- GtkStyle *previous_style,
- gpointer user_data)
+query_dialog_style_set_cb (GtkWidget * dialog,
+ GtkStyle * previous_style, gpointer user_data)
{
- GtkWidget *content_area, *action_area;
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (content_area), 12);
- gtk_box_set_spacing (GTK_BOX (content_area), 12);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 0);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
+ GtkWidget *content_area, *action_area;
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (content_area), 12);
+ gtk_box_set_spacing (GTK_BOX (content_area), 12);
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 0);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
}
gboolean
-glade_editor_query_dialog (GladeEditor *editor, GladeWidget *widget)
+glade_editor_query_dialog (GladeEditor * editor, GladeWidget * widget)
{
- GtkWidget *dialog, *editable, *content_area;
- gchar *title;
- gint answer;
- gboolean retval = TRUE;
+ GtkWidget *dialog, *editable, *content_area;
+ gchar *title;
+ gint answer;
+ gboolean retval = TRUE;
- title = g_strdup_printf (_("Create a %s"), widget->adaptor->name);
+ title = g_strdup_printf (_("Create a %s"), widget->adaptor->name);
- dialog = gtk_dialog_new_with_buttons (title, NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
+ dialog = gtk_dialog_new_with_buttons (title, NULL,
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- g_free (title);
+ g_free (title);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CANCEL,
- -1);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL, -1);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
- editable = glade_editor_get_editable_by_adaptor (editor,
- widget->adaptor,
- GLADE_PAGE_QUERY);
+ editable = glade_editor_get_editable_by_adaptor (editor,
+ widget->adaptor,
+ GLADE_PAGE_QUERY);
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_box_pack_start (GTK_BOX (content_area),
- editable, FALSE, FALSE, 6);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_box_pack_start (GTK_BOX (content_area), editable, FALSE, FALSE, 6);
- glade_editable_load (GLADE_EDITABLE (editable), widget);
+ glade_editable_load (GLADE_EDITABLE (editable), widget);
- g_signal_connect (dialog, "style-set",
- G_CALLBACK (query_dialog_style_set_cb),
- NULL);
+ g_signal_connect (dialog, "style-set",
+ G_CALLBACK (query_dialog_style_set_cb), NULL);
- answer = gtk_dialog_run (GTK_DIALOG (dialog));
+ answer = gtk_dialog_run (GTK_DIALOG (dialog));
- /*
- * If user cancel's we cancel the whole "create operation" by
- * return FALSE. glade_widget_new() will see the FALSE, and
- * take care of canceling the "create" operation.
- */
- if (answer == GTK_RESPONSE_CANCEL)
- retval = FALSE;
+ /*
+ * If user cancel's we cancel the whole "create operation" by
+ * return FALSE. glade_widget_new() will see the FALSE, and
+ * take care of canceling the "create" operation.
+ */
+ if (answer == GTK_RESPONSE_CANCEL)
+ retval = FALSE;
+
+ gtk_container_remove (GTK_CONTAINER (content_area), editable);
- gtk_container_remove (GTK_CONTAINER (content_area), editable);
-
- gtk_widget_destroy (dialog);
- return retval;
+ gtk_widget_destroy (dialog);
+ return retval;
}
-enum {
- COLUMN_ENABLED = 0,
- COLUMN_PROP_NAME,
- COLUMN_PROPERTY,
- COLUMN_WEIGHT,
- COLUMN_CHILD,
- COLUMN_DEFAULT,
- COLUMN_NDEFAULT,
- COLUMN_DEFSTRING,
- NUM_COLUMNS
+enum
+{
+ COLUMN_ENABLED = 0,
+ COLUMN_PROP_NAME,
+ COLUMN_PROPERTY,
+ COLUMN_WEIGHT,
+ COLUMN_CHILD,
+ COLUMN_DEFAULT,
+ COLUMN_NDEFAULT,
+ COLUMN_DEFSTRING,
+ NUM_COLUMNS
};
static void
-glade_editor_reset_toggled (GtkCellRendererToggle *cell,
- gchar *path_str,
- GtkTreeModel *model)
+glade_editor_reset_toggled (GtkCellRendererToggle * cell,
+ gchar * path_str, GtkTreeModel * model)
{
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeIter iter;
- gboolean enabled;
-
- /* get toggled iter */
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter,
- COLUMN_ENABLED, &enabled, -1);
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- COLUMN_ENABLED, !enabled, -1);
- gtk_tree_path_free (path);
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeIter iter;
+ gboolean enabled;
+
+ /* get toggled iter */
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, COLUMN_ENABLED, &enabled, -1);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ COLUMN_ENABLED, !enabled, -1);
+ gtk_tree_path_free (path);
}
static GtkWidget *
-glade_editor_reset_view (GladeEditor *editor)
+glade_editor_reset_view (GladeEditor * editor)
{
- GtkWidget *view_widget;
- GtkTreeModel *model;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- model = (GtkTreeModel *)gtk_tree_store_new
- (NUM_COLUMNS,
- G_TYPE_BOOLEAN, /* Enabled value */
- G_TYPE_STRING, /* Property name */
- GLADE_TYPE_PROPERTY, /* The property */
- G_TYPE_INT, /* Parent node ? */
- G_TYPE_BOOLEAN, /* Child node ? */
- G_TYPE_BOOLEAN, /* Has default value */
- G_TYPE_BOOLEAN, /* Doesn't have defaut */
- G_TYPE_STRING); /* Default string */
-
- view_widget = gtk_tree_view_new_with_model (model);
- g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
-
- /********************* fake invisible column *********************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, "visible", FALSE, NULL);
-
- column = gtk_tree_view_column_new_with_attributes (NULL, renderer, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
-
- gtk_tree_view_column_set_visible (column, FALSE);
- gtk_tree_view_set_expander_column (GTK_TREE_VIEW (view_widget), column);
-
- /************************ enabled column ************************/
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (G_OBJECT (renderer),
- "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
- "activatable", TRUE,
- NULL);
- g_signal_connect (renderer, "toggled",
- G_CALLBACK (glade_editor_reset_toggled), model);
- gtk_tree_view_insert_column_with_attributes
- (GTK_TREE_VIEW (view_widget), COLUMN_ENABLED,
- _("Reset"), renderer,
- "sensitive", COLUMN_NDEFAULT,
- "activatable", COLUMN_NDEFAULT,
- "active", COLUMN_ENABLED,
- "visible", COLUMN_CHILD,
- NULL);
-
- /********************* property name column *********************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "editable", FALSE,
- NULL);
-
- gtk_tree_view_insert_column_with_attributes
- (GTK_TREE_VIEW (view_widget), COLUMN_PROP_NAME,
- _("Property"), renderer,
- "text", COLUMN_PROP_NAME,
- "weight", COLUMN_WEIGHT,
- NULL);
-
- /******************* default indicator column *******************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "editable", FALSE,
- "style", PANGO_STYLE_ITALIC,
- "foreground", "Gray", NULL);
-
- gtk_tree_view_insert_column_with_attributes
- (GTK_TREE_VIEW (view_widget), COLUMN_DEFSTRING,
- NULL, renderer,
- "text", COLUMN_DEFSTRING,
- "visible", COLUMN_DEFAULT,
- NULL);
-
- return view_widget;
+ GtkWidget *view_widget;
+ GtkTreeModel *model;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ model = (GtkTreeModel *) gtk_tree_store_new (NUM_COLUMNS, G_TYPE_BOOLEAN, /* Enabled value */
+ G_TYPE_STRING, /* Property name */
+ GLADE_TYPE_PROPERTY, /* The property */
+ G_TYPE_INT, /* Parent node ? */
+ G_TYPE_BOOLEAN, /* Child node ? */
+ G_TYPE_BOOLEAN, /* Has default value */
+ G_TYPE_BOOLEAN, /* Doesn't have defaut */
+ G_TYPE_STRING); /* Default string */
+
+ view_widget = gtk_tree_view_new_with_model (model);
+ g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
+
+ /********************* fake invisible column *********************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, "visible", FALSE, NULL);
+
+ column = gtk_tree_view_column_new_with_attributes (NULL, renderer, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
+
+ gtk_tree_view_column_set_visible (column, FALSE);
+ gtk_tree_view_set_expander_column (GTK_TREE_VIEW (view_widget), column);
+
+ /************************ enabled column ************************/
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer),
+ "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
+ "activatable", TRUE, NULL);
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (glade_editor_reset_toggled), model);
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (view_widget), COLUMN_ENABLED,
+ _("Reset"), renderer,
+ "sensitive", COLUMN_NDEFAULT,
+ "activatable", COLUMN_NDEFAULT,
+ "active", COLUMN_ENABLED, "visible", COLUMN_CHILD, NULL);
+
+ /********************* property name column *********************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (view_widget), COLUMN_PROP_NAME,
+ _("Property"), renderer,
+ "text", COLUMN_PROP_NAME, "weight", COLUMN_WEIGHT, NULL);
+
+ /******************* default indicator column *******************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer),
+ "editable", FALSE,
+ "style", PANGO_STYLE_ITALIC, "foreground", "Gray", NULL);
+
+ gtk_tree_view_insert_column_with_attributes
+ (GTK_TREE_VIEW (view_widget), COLUMN_DEFSTRING,
+ NULL, renderer,
+ "text", COLUMN_DEFSTRING, "visible", COLUMN_DEFAULT, NULL);
+
+ return view_widget;
}
static void
-glade_editor_populate_reset_view (GladeEditor *editor,
- GtkTreeView *tree_view)
+glade_editor_populate_reset_view (GladeEditor * editor, GtkTreeView * tree_view)
{
- GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (tree_view);
- GtkTreeIter property_iter, general_iter, common_iter, atk_iter, *iter;
- GList *list;
- GladeProperty *property;
- gboolean def;
-
- g_return_if_fail (editor->loaded_widget != NULL);
-
- gtk_tree_store_append (model, &general_iter, NULL);
- gtk_tree_store_set (model, &general_iter,
- COLUMN_PROP_NAME, _("General"),
- COLUMN_PROPERTY, NULL,
- COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_CHILD, FALSE,
- COLUMN_DEFAULT, FALSE,
- COLUMN_NDEFAULT, FALSE,
- -1);
-
- gtk_tree_store_append (model, &common_iter, NULL);
- gtk_tree_store_set (model, &common_iter,
- COLUMN_PROP_NAME, _("Common"),
- COLUMN_PROPERTY, NULL,
- COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_CHILD, FALSE,
- COLUMN_DEFAULT, FALSE,
- COLUMN_NDEFAULT, FALSE,
- -1);
-
- gtk_tree_store_append (model, &atk_iter, NULL);
- gtk_tree_store_set (model, &atk_iter,
- COLUMN_PROP_NAME, _("Accessibility"),
- COLUMN_PROPERTY, NULL,
- COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_CHILD, FALSE,
- COLUMN_DEFAULT, FALSE,
- COLUMN_NDEFAULT, FALSE,
- -1);
-
- /* General & Common */
- for (list = editor->loaded_widget->properties; list; list = list->next)
- {
- property = list->data;
-
- if (glade_property_class_is_visible (property->klass) == FALSE)
- continue;
-
- if (property->klass->atk)
- iter = &atk_iter;
- else if (property->klass->common)
- iter = &common_iter;
- else
- iter = &general_iter;
-
- def = glade_property_default (property);
-
- gtk_tree_store_append (model, &property_iter, iter);
- gtk_tree_store_set (model, &property_iter,
- COLUMN_ENABLED, !def,
- COLUMN_PROP_NAME, property->klass->name,
- COLUMN_PROPERTY, property,
- COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
- COLUMN_CHILD, TRUE,
- COLUMN_DEFAULT, def,
- COLUMN_NDEFAULT, !def,
- COLUMN_DEFSTRING, _("(default)"),
- -1);
- }
+ GtkTreeStore *model = (GtkTreeStore *) gtk_tree_view_get_model (tree_view);
+ GtkTreeIter property_iter, general_iter, common_iter, atk_iter, *iter;
+ GList *list;
+ GladeProperty *property;
+ gboolean def;
+
+ g_return_if_fail (editor->loaded_widget != NULL);
+
+ gtk_tree_store_append (model, &general_iter, NULL);
+ gtk_tree_store_set (model, &general_iter,
+ COLUMN_PROP_NAME, _("General"),
+ COLUMN_PROPERTY, NULL,
+ COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_CHILD, FALSE,
+ COLUMN_DEFAULT, FALSE, COLUMN_NDEFAULT, FALSE, -1);
+
+ gtk_tree_store_append (model, &common_iter, NULL);
+ gtk_tree_store_set (model, &common_iter,
+ COLUMN_PROP_NAME, _("Common"),
+ COLUMN_PROPERTY, NULL,
+ COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_CHILD, FALSE,
+ COLUMN_DEFAULT, FALSE, COLUMN_NDEFAULT, FALSE, -1);
+
+ gtk_tree_store_append (model, &atk_iter, NULL);
+ gtk_tree_store_set (model, &atk_iter,
+ COLUMN_PROP_NAME, _("Accessibility"),
+ COLUMN_PROPERTY, NULL,
+ COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_CHILD, FALSE,
+ COLUMN_DEFAULT, FALSE, COLUMN_NDEFAULT, FALSE, -1);
+
+ /* General & Common */
+ for (list = editor->loaded_widget->properties; list; list = list->next)
+ {
+ property = list->data;
+
+ if (glade_property_class_is_visible (property->klass) == FALSE)
+ continue;
+
+ if (property->klass->atk)
+ iter = &atk_iter;
+ else if (property->klass->common)
+ iter = &common_iter;
+ else
+ iter = &general_iter;
+
+ def = glade_property_default (property);
+
+ gtk_tree_store_append (model, &property_iter, iter);
+ gtk_tree_store_set (model, &property_iter,
+ COLUMN_ENABLED, !def,
+ COLUMN_PROP_NAME, property->klass->name,
+ COLUMN_PROPERTY, property,
+ COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
+ COLUMN_CHILD, TRUE,
+ COLUMN_DEFAULT, def,
+ COLUMN_NDEFAULT, !def,
+ COLUMN_DEFSTRING, _("(default)"), -1);
+ }
}
static gboolean
-glade_editor_reset_selection_changed_cb (GtkTreeSelection *selection,
- GtkTextView *desc_view)
+glade_editor_reset_selection_changed_cb (GtkTreeSelection * selection,
+ GtkTextView * desc_view)
{
- GtkTreeIter iter;
- GladeProperty *property = NULL;
- GtkTreeModel *model = NULL;
- GtkTextBuffer *text_buffer;
-
- const gchar *message =
- _("Select the properties that you want to reset to their default values");
-
- /* Find selected data and show property blurb here */
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (desc_view));
- gtk_tree_model_get (model, &iter, COLUMN_PROPERTY, &property, -1);
- gtk_text_buffer_set_text (text_buffer,
- property ? property->klass->tooltip : message,
- -1);
- if (property)
- g_object_unref (G_OBJECT (property));
- }
- return TRUE;
+ GtkTreeIter iter;
+ GladeProperty *property = NULL;
+ GtkTreeModel *model = NULL;
+ GtkTextBuffer *text_buffer;
+
+ const gchar *message =
+ _("Select the properties that you want to reset to their default values");
+
+ /* Find selected data and show property blurb here */
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (desc_view));
+ gtk_tree_model_get (model, &iter, COLUMN_PROPERTY, &property, -1);
+ gtk_text_buffer_set_text (text_buffer,
+ property ? property->klass->tooltip : message,
+ -1);
+ if (property)
+ g_object_unref (G_OBJECT (property));
+ }
+ return TRUE;
}
static gboolean
-glade_editor_reset_foreach_selection (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gboolean select)
+glade_editor_reset_foreach_selection (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, gboolean select)
{
- gboolean def;
-
- gtk_tree_model_get (model, iter, COLUMN_DEFAULT, &def, -1);
- /* Dont modify rows that are already default */
- if (def == FALSE)
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- COLUMN_ENABLED, select, -1);
- return FALSE;
+ gboolean def;
+
+ gtk_tree_model_get (model, iter, COLUMN_DEFAULT, &def, -1);
+ /* Dont modify rows that are already default */
+ if (def == FALSE)
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ COLUMN_ENABLED, select, -1);
+ return FALSE;
}
static void
-glade_editor_reset_select_all_clicked (GtkButton *button,
- GtkTreeView *tree_view)
+glade_editor_reset_select_all_clicked (GtkButton * button,
+ GtkTreeView * tree_view)
{
- GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
- gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
- glade_editor_reset_foreach_selection,
- GINT_TO_POINTER (TRUE));
+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+ gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
+ glade_editor_reset_foreach_selection,
+ GINT_TO_POINTER (TRUE));
}
static void
-glade_editor_reset_unselect_all_clicked (GtkButton *button,
- GtkTreeView *tree_view)
+glade_editor_reset_unselect_all_clicked (GtkButton * button,
+ GtkTreeView * tree_view)
{
- GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
- gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
- glade_editor_reset_foreach_selection,
- GINT_TO_POINTER (FALSE));
+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+ gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
+ glade_editor_reset_foreach_selection,
+ GINT_TO_POINTER (FALSE));
}
static gboolean
-glade_editor_reset_accumulate_selected_props (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- GList **accum)
+glade_editor_reset_accumulate_selected_props (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter,
+ GList ** accum)
{
- GladeProperty *property;
- gboolean enabled, def;
+ GladeProperty *property;
+ gboolean enabled, def;
- gtk_tree_model_get (model, iter,
- COLUMN_PROPERTY, &property,
- COLUMN_ENABLED, &enabled,
- COLUMN_DEFAULT, &def,
- -1);
+ gtk_tree_model_get (model, iter,
+ COLUMN_PROPERTY, &property,
+ COLUMN_ENABLED, &enabled, COLUMN_DEFAULT, &def, -1);
- if (property && enabled && !def)
- *accum = g_list_prepend (*accum, property);
+ if (property && enabled && !def)
+ *accum = g_list_prepend (*accum, property);
- if (property)
- g_object_unref (G_OBJECT (property));
+ if (property)
+ g_object_unref (G_OBJECT (property));
- return FALSE;
+ return FALSE;
}
static GList *
-glade_editor_reset_get_selected_props (GtkTreeModel *model)
+glade_editor_reset_get_selected_props (GtkTreeModel * model)
{
- GList *ret = NULL;
+ GList *ret = NULL;
- gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
- glade_editor_reset_accumulate_selected_props, &ret);
+ gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc)
+ glade_editor_reset_accumulate_selected_props, &ret);
- return ret;
+ return ret;
}
static void
-glade_editor_reset_properties (GList *props)
+glade_editor_reset_properties (GList * props)
{
- GList *list, *sdata_list = NULL;
- GCSetPropData *sdata;
- GladeProperty *prop;
- GladeProject *project = NULL;
+ GList *list, *sdata_list = NULL;
+ GCSetPropData *sdata;
+ GladeProperty *prop;
+ GladeProject *project = NULL;
- for (list = props; list; list = list->next)
- {
- prop = list->data;
+ for (list = props; list; list = list->next)
+ {
+ prop = list->data;
- project = glade_widget_get_project (prop->widget);
+ project = glade_widget_get_project (prop->widget);
- sdata = g_new (GCSetPropData, 1);
- sdata->property = prop;
+ sdata = g_new (GCSetPropData, 1);
+ sdata->property = prop;
- sdata->old_value = g_new0 (GValue, 1);
- sdata->new_value = g_new0 (GValue, 1);
+ sdata->old_value = g_new0 (GValue, 1);
+ sdata->new_value = g_new0 (GValue, 1);
- glade_property_get_value (prop, sdata->old_value);
- glade_property_get_default (prop, sdata->new_value);
+ glade_property_get_value (prop, sdata->old_value);
+ glade_property_get_default (prop, sdata->new_value);
- sdata_list = g_list_prepend (sdata_list, sdata);
- }
+ sdata_list = g_list_prepend (sdata_list, sdata);
+ }
- if (project)
- /* GladeCommand takes ownership of allocated list, ugly but practicle */
- glade_command_set_properties_list (project, sdata_list);
+ if (project)
+ /* GladeCommand takes ownership of allocated list, ugly but practicle */
+ glade_command_set_properties_list (project, sdata_list);
}
static void
-glade_editor_reset_dialog (GladeEditor *editor)
+glade_editor_reset_dialog (GladeEditor * editor)
{
- GtkTreeSelection *selection;
- GtkWidget *dialog, *parent;
- GtkWidget *vbox, *hbox, *label, *sw, *button;
- GtkWidget *tree_view, *description_view;
- gint res;
- GList *list;
-
- parent = gtk_widget_get_toplevel (GTK_WIDGET (editor));
- dialog = gtk_dialog_new_with_buttons (_("Reset Widget Properties"),
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0);
-
- /* Checklist */
- label = gtk_label_new_with_mnemonic (_("_Properties:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
-
- tree_view = glade_editor_reset_view (editor);
- if (editor->loaded_widget)
- glade_editor_populate_reset_view (editor, GTK_TREE_VIEW (tree_view));
- gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
-
- gtk_widget_show (tree_view);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
- gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
- /* Select all / Unselect all */
- hbox = gtk_hbutton_box_new ();
- gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
-
- button = gtk_button_new_with_mnemonic (_("_Select All"));
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (button), 6);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_editor_reset_select_all_clicked), tree_view);
-
- button = gtk_button_new_with_mnemonic (_("_Unselect All"));
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (button), 6);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_editor_reset_unselect_all_clicked), tree_view);
-
-
- /* Description */
- label = gtk_label_new_with_mnemonic (_("Property _Description:"));
- gtk_widget_show (label);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 80);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- description_view = gtk_text_view_new ();
- gtk_text_view_set_editable (GTK_TEXT_VIEW (description_view), FALSE);
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (description_view), GTK_WRAP_WORD);
-
- gtk_widget_show (description_view);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), description_view);
- gtk_container_add (GTK_CONTAINER (sw), description_view);
-
- /* Update description */
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (glade_editor_reset_selection_changed_cb),
- description_view);
-
-
-
- /* Run the dialog */
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK) {
-
- /* get all selected properties and reset properties through glade_command */
- if ((list = glade_editor_reset_get_selected_props
- (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)))) != NULL)
- {
- glade_editor_reset_properties (list);
- g_list_free (list);
- }
- }
- gtk_widget_destroy (dialog);
+ GtkTreeSelection *selection;
+ GtkWidget *dialog, *parent;
+ GtkWidget *vbox, *hbox, *label, *sw, *button;
+ GtkWidget *tree_view, *description_view;
+ gint res;
+ GList *list;
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (editor));
+ dialog = gtk_dialog_new_with_buttons (_("Reset Widget Properties"),
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+
+ gtk_box_pack_start (GTK_BOX
+ (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox,
+ TRUE, TRUE, 0);
+
+ /* Checklist */
+ label = gtk_label_new_with_mnemonic (_("_Properties:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+
+ tree_view = glade_editor_reset_view (editor);
+ if (editor->loaded_widget)
+ glade_editor_populate_reset_view (editor, GTK_TREE_VIEW (tree_view));
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ gtk_widget_show (tree_view);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), tree_view);
+ gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+ /* Select all / Unselect all */
+ hbox = gtk_hbutton_box_new ();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_mnemonic (_("_Select All"));
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (button), 6);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_editor_reset_select_all_clicked),
+ tree_view);
+
+ button = gtk_button_new_with_mnemonic (_("_Unselect All"));
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (button), 6);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_editor_reset_unselect_all_clicked),
+ tree_view);
+
+
+ /* Description */
+ label = gtk_label_new_with_mnemonic (_("Property _Description:"));
+ gtk_widget_show (label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 80);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ description_view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (description_view), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (description_view), GTK_WRAP_WORD);
+
+ gtk_widget_show (description_view);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), description_view);
+ gtk_container_add (GTK_CONTAINER (sw), description_view);
+
+ /* Update description */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (glade_editor_reset_selection_changed_cb),
+ description_view);
+
+
+
+ /* Run the dialog */
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+
+ /* get all selected properties and reset properties through glade_command */
+ if ((list = glade_editor_reset_get_selected_props
+ (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)))) != NULL)
+ {
+ glade_editor_reset_properties (list);
+ g_list_free (list);
+ }
+ }
+ gtk_widget_destroy (dialog);
}
void
-glade_editor_show_info (GladeEditor *editor)
+glade_editor_show_info (GladeEditor * editor)
{
- g_return_if_fail (GLADE_IS_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_EDITOR (editor));
- if (editor->show_info != TRUE)
- {
- editor->show_info = TRUE;
- gtk_widget_show (editor->info_button);
+ if (editor->show_info != TRUE)
+ {
+ editor->show_info = TRUE;
+ gtk_widget_show (editor->info_button);
- g_object_notify (G_OBJECT (editor), "show-info");
- }
+ g_object_notify (G_OBJECT (editor), "show-info");
+ }
}
void
-glade_editor_hide_info (GladeEditor *editor)
+glade_editor_hide_info (GladeEditor * editor)
{
- g_return_if_fail (GLADE_IS_EDITOR (editor));
+ g_return_if_fail (GLADE_IS_EDITOR (editor));
- if (editor->show_info != FALSE)
- {
- editor->show_info = FALSE;
- gtk_widget_hide (editor->info_button);
+ if (editor->show_info != FALSE)
+ {
+ editor->show_info = FALSE;
+ gtk_widget_hide (editor->info_button);
- g_object_notify (G_OBJECT (editor), "show-info");
- }
+ g_object_notify (G_OBJECT (editor), "show-info");
+ }
}
/**
@@ -1338,52 +1317,50 @@ glade_editor_hide_info (GladeEditor *editor)
* specifically.
*
* Returns: the newly created dialog window
- */
+ */
GtkWidget *
-glade_editor_dialog_for_widget (GladeWidget *widget)
+glade_editor_dialog_for_widget (GladeWidget * widget)
{
- GtkWidget *window, *editor;
- gchar *title, *prj_name;
-
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
-
- /* Window */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
-
- prj_name = glade_project_get_name (widget->project);
- /* Translators: first %s is the project name, second is a widget name */
- title = g_strdup_printf (_("%s - %s Properties"), prj_name,
- glade_widget_get_name (widget));
- gtk_window_set_title (GTK_WINDOW (window), title);
- g_free (title);
- g_free (prj_name);
-
-
- if (glade_app_get_accel_group ())
- {
- gtk_window_add_accel_group (GTK_WINDOW (window),
- glade_app_get_accel_group ());
- g_signal_connect (G_OBJECT (window), "key-press-event",
- G_CALLBACK (glade_utils_hijack_key_press), NULL);
- }
-
- editor = g_object_new (GLADE_TYPE_EDITOR,
- "spacing", 6,
- NULL);
- glade_editor_load_widget (GLADE_EDITOR (editor), widget);
-
-
- g_signal_connect_swapped (G_OBJECT (editor), "notify::widget",
- G_CALLBACK (gtk_widget_destroy), window);
-
-
- gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
-
- gtk_window_set_default_size (GTK_WINDOW (window), 400, 480);
-
- gtk_widget_show_all (editor);
- return window;
+ GtkWidget *window, *editor;
+ gchar *title, *prj_name;
+
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+
+ /* Window */
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ prj_name = glade_project_get_name (widget->project);
+ /* Translators: first %s is the project name, second is a widget name */
+ title = g_strdup_printf (_("%s - %s Properties"), prj_name,
+ glade_widget_get_name (widget));
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ g_free (title);
+ g_free (prj_name);
+
+
+ if (glade_app_get_accel_group ())
+ {
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ glade_app_get_accel_group ());
+ g_signal_connect (G_OBJECT (window), "key-press-event",
+ G_CALLBACK (glade_utils_hijack_key_press), NULL);
+ }
+
+ editor = g_object_new (GLADE_TYPE_EDITOR, "spacing", 6, NULL);
+ glade_editor_load_widget (GLADE_EDITOR (editor), widget);
+
+
+ g_signal_connect_swapped (G_OBJECT (editor), "notify::widget",
+ G_CALLBACK (gtk_widget_destroy), window);
+
+
+ gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
+ gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 480);
+
+ gtk_widget_show_all (editor);
+ return window;
}
diff --git a/gladeui/glade-editor.h b/gladeui/glade-editor.h
index a3f6fe3..aff35ea 100644
--- a/gladeui/glade-editor.h
+++ b/gladeui/glade-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_EDITOR_H__
#define __GLADE_EDITOR_H__
diff --git a/gladeui/glade-fixed.c b/gladeui/glade-fixed.c
index bd52492..71cf953 100644
--- a/gladeui/glade-fixed.c
+++ b/gladeui/glade-fixed.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-fixed.c - A GladeWidget derivative object wrapper designed to
* handle free-form child placement for containers such as
@@ -60,27 +59,30 @@
#include "glade-fixed.h"
/* properties */
-enum {
- PROP_0,
- PROP_X_PROP,
- PROP_Y_PROP,
- PROP_WIDTH_PROP,
- PROP_HEIGHT_PROP,
- PROP_CAN_RESIZE
+enum
+{
+ PROP_0,
+ PROP_X_PROP,
+ PROP_Y_PROP,
+ PROP_WIDTH_PROP,
+ PROP_HEIGHT_PROP,
+ PROP_CAN_RESIZE
};
/* signals */
-enum {
- CONFIGURE_CHILD,
- CONFIGURE_BEGIN,
- CONFIGURE_END,
- FIXED_SIGNALS
+enum
+{
+ CONFIGURE_CHILD,
+ CONFIGURE_BEGIN,
+ CONFIGURE_END,
+ FIXED_SIGNALS
};
-typedef struct {
- gulong press_id;
- gulong release_id;
- gulong motion_id;
+typedef struct
+{
+ gulong press_id;
+ gulong release_id;
+ gulong motion_id;
} GFSigData;
#define CHILD_WIDTH_MIN 20
@@ -92,598 +94,597 @@ typedef struct {
#define GRAB_CORNER_WIDTH 7
static GObjectClass *parent_class;
-static guint glade_fixed_signals[FIXED_SIGNALS];
+static guint glade_fixed_signals[FIXED_SIGNALS];
/*******************************************************************************
Static helper routines
*******************************************************************************/
static GladeCursorType
-glade_fixed_get_operation (GtkWidget *widget,
- gint x,
- gint y)
+glade_fixed_get_operation (GtkWidget * widget, gint x, gint y)
{
- GladeCursorType operation = GLADE_CURSOR_DRAG;
- GtkAllocation allocation;
+ GladeCursorType operation = GLADE_CURSOR_DRAG;
+ GtkAllocation allocation;
#if 0
- g_print ("%s called (width %d height %d x %d y %d)\n",
- __FUNCTION__,
- widget->allocation.width,
- widget->allocation.height, x, y);
+ g_print ("%s called (width %d height %d x %d y %d)\n",
+ __FUNCTION__,
+ widget->allocation.width, widget->allocation.height, x, y);
#endif
- gtk_widget_get_allocation (widget, &allocation);
- if (x < GRAB_BORDER_WIDTH) {
- if (y < GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_TOP_LEFT;
- else if (y > allocation.height - GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_BOTTOM_LEFT;
- else
- operation = GLADE_CURSOR_RESIZE_LEFT;
- } else if (x > allocation.width - GRAB_BORDER_WIDTH) {
- if (y < GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_TOP_RIGHT;
- else if (y > allocation.height - GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_BOTTOM_RIGHT;
- else
- operation = GLADE_CURSOR_RESIZE_RIGHT;
- } else if (y < GRAB_BORDER_WIDTH) {
- if (x < GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_TOP_LEFT;
- else if (x > allocation.width - GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_TOP_RIGHT;
- else
- operation = GLADE_CURSOR_RESIZE_TOP;
- } else if (y > allocation.height - GRAB_BORDER_WIDTH) {
- if (x < GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_BOTTOM_LEFT;
- else if (x > allocation.width - GRAB_BORDER_WIDTH)
- operation = GLADE_CURSOR_RESIZE_BOTTOM_RIGHT;
- else
- operation = GLADE_CURSOR_RESIZE_BOTTOM;
- }
- return operation;
+ gtk_widget_get_allocation (widget, &allocation);
+ if (x < GRAB_BORDER_WIDTH)
+ {
+ if (y < GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_TOP_LEFT;
+ else if (y > allocation.height - GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_BOTTOM_LEFT;
+ else
+ operation = GLADE_CURSOR_RESIZE_LEFT;
+ }
+ else if (x > allocation.width - GRAB_BORDER_WIDTH)
+ {
+ if (y < GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_TOP_RIGHT;
+ else if (y > allocation.height - GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_BOTTOM_RIGHT;
+ else
+ operation = GLADE_CURSOR_RESIZE_RIGHT;
+ }
+ else if (y < GRAB_BORDER_WIDTH)
+ {
+ if (x < GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_TOP_LEFT;
+ else if (x > allocation.width - GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_TOP_RIGHT;
+ else
+ operation = GLADE_CURSOR_RESIZE_TOP;
+ }
+ else if (y > allocation.height - GRAB_BORDER_WIDTH)
+ {
+ if (x < GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_BOTTOM_LEFT;
+ else if (x > allocation.width - GRAB_BORDER_WIDTH)
+ operation = GLADE_CURSOR_RESIZE_BOTTOM_RIGHT;
+ else
+ operation = GLADE_CURSOR_RESIZE_BOTTOM;
+ }
+ return operation;
}
static void
-glade_fixed_save_state (GladeFixed *fixed,
- GladeWidget *child)
+glade_fixed_save_state (GladeFixed * fixed, GladeWidget * child)
{
- GtkAllocation allocation;
-
- gtk_widget_get_pointer (GTK_WIDGET (GLADE_WIDGET (fixed)->object),
- &(GLADE_FIXED (fixed)->pointer_x_origin),
- &(GLADE_FIXED (fixed)->pointer_y_origin));
-
- gtk_widget_translate_coordinates (GTK_WIDGET (child->object),
- GTK_WIDGET (GLADE_WIDGET (fixed)->object),
- 0, 0,
- &(fixed->child_x_origin),
- &(fixed->child_y_origin));
-
- gtk_widget_get_allocation (GTK_WIDGET (child->object), &allocation);
- fixed->child_width_origin = allocation.width;
- fixed->child_height_origin = allocation.height;
-
- fixed->pointer_x_child_origin =
- fixed->pointer_x_origin - fixed->child_x_origin;
- fixed->pointer_y_child_origin =
- fixed->pointer_y_origin - fixed->child_y_origin;
+ GtkAllocation allocation;
+
+ gtk_widget_get_pointer (GTK_WIDGET (GLADE_WIDGET (fixed)->object),
+ &(GLADE_FIXED (fixed)->pointer_x_origin),
+ &(GLADE_FIXED (fixed)->pointer_y_origin));
+
+ gtk_widget_translate_coordinates (GTK_WIDGET (child->object),
+ GTK_WIDGET (GLADE_WIDGET (fixed)->object),
+ 0, 0,
+ &(fixed->child_x_origin),
+ &(fixed->child_y_origin));
+
+ gtk_widget_get_allocation (GTK_WIDGET (child->object), &allocation);
+ fixed->child_width_origin = allocation.width;
+ fixed->child_height_origin = allocation.height;
+
+ fixed->pointer_x_child_origin =
+ fixed->pointer_x_origin - fixed->child_x_origin;
+ fixed->pointer_y_child_origin =
+ fixed->pointer_y_origin - fixed->child_y_origin;
}
-static void
-glade_fixed_filter_event (GladeFixed *fixed,
- gint *x,
- gint *y,
- gint left,
- gint right,
- gint top,
- gint bottom)
-{
- GtkAllocation allocation;
- gint cont_width, cont_height;
-
- g_return_if_fail (x && y);
-
- gtk_widget_get_allocation (GTK_WIDGET (GLADE_WIDGET (fixed)->object), &allocation);
- cont_width = allocation.width;
- cont_height = allocation.height;
-
- /* Clip out mouse events that are outside the window.
- */
- if ((left || fixed->operation == GLADE_CURSOR_DRAG) &&
- *x - fixed->pointer_x_child_origin < 0)
- *x = fixed->pointer_x_child_origin;
- if ((top || fixed->operation == GLADE_CURSOR_DRAG) &&
- *y - fixed->pointer_y_child_origin < 0)
- *y = fixed->pointer_y_child_origin;
-
- if ((right || fixed->operation == GLADE_CURSOR_DRAG) &&
- *x + (fixed->child_width_origin -
- fixed->pointer_x_child_origin) > cont_width)
- *x = cont_width - (fixed->child_width_origin -
- fixed->pointer_x_child_origin);
- if ((bottom || fixed->operation == GLADE_CURSOR_DRAG) &&
- *y + (fixed->child_height_origin -
- fixed->pointer_y_child_origin) > cont_height)
- *y = cont_height - (fixed->child_height_origin -
- fixed->pointer_y_child_origin);
-
- /* Clip out mouse events that mean shrinking to less than 0.
- */
- if (left &&
- (*x - fixed->pointer_x_child_origin) >
- (fixed->child_x_origin + (fixed->child_width_origin - CHILD_WIDTH_MIN))) {
- *x = (fixed->child_x_origin + (fixed->child_width_origin - CHILD_WIDTH_MIN)) -
- fixed->pointer_x_child_origin;
- } else if (right &&
- (*x - fixed->pointer_x_child_origin) <
- fixed->child_x_origin - (fixed->child_width_origin + CHILD_WIDTH_MIN)) {
- *x = (fixed->child_x_origin - (fixed->child_width_origin + CHILD_WIDTH_MIN)) +
- fixed->pointer_x_child_origin;
- }
-
-
- if (top &&
- (*y - fixed->pointer_y_child_origin) >
- (fixed->child_y_origin + (fixed->child_height_origin - CHILD_HEIGHT_MIN))) {
- *y = (fixed->child_y_origin + (fixed->child_height_origin - CHILD_HEIGHT_MIN)) -
- fixed->pointer_y_child_origin;
- } else if (bottom &&
- (*y - fixed->pointer_y_child_origin) <
- fixed->child_y_origin - (fixed->child_height_origin + CHILD_HEIGHT_MIN)) {
- *y = (fixed->child_y_origin - (fixed->child_height_origin + CHILD_HEIGHT_MIN)) +
- fixed->pointer_y_child_origin;
- }
-}
-
static void
-glade_fixed_handle_swindow (GladeFixed *fixed,
- GdkRectangle *area)
+glade_fixed_filter_event (GladeFixed * fixed,
+ gint * x,
+ gint * y,
+ gint left, gint right, gint top, gint bottom)
{
- GtkWidget *fixed_widget = GTK_WIDGET (GLADE_WIDGET (fixed)->object);
- GtkWidget *swindow = NULL, *swindow_child = NULL;
- GtkAdjustment *hadj, *vadj;
- GtkAllocation child_allocation;
- gint x, y;
-
- swindow_child = swindow = fixed_widget;
- while (swindow && !GTK_IS_SCROLLED_WINDOW (swindow))
- {
- if (!GTK_IS_VIEWPORT (swindow))
- swindow_child = swindow;
-
- swindow = gtk_widget_get_parent (swindow);
- }
-
- if (swindow)
- {
- /* Set the adjustments to use appropriate pixel units and then
- * square in on the target drop area.
- */
- hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (swindow));
- vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (swindow));
- gtk_widget_get_allocation (swindow_child, &child_allocation);
-
- g_object_set (G_OBJECT (hadj),
- "lower", 0.0F,
- "upper", (gdouble) child_allocation.width + 0.0,
- NULL);
-
- g_object_set (G_OBJECT (vadj),
- "lower", 0.0F,
- "upper", (gdouble) child_allocation.height + 0.0,
- NULL);
-
- gtk_widget_translate_coordinates (fixed_widget,
- swindow_child,
- area->x, area->y, &x, &y);
-
- gtk_adjustment_clamp_page (hadj, x, x + area->width);
- gtk_adjustment_clamp_page (vadj, y, y + area->height);
- }
+ GtkAllocation allocation;
+ gint cont_width, cont_height;
+
+ g_return_if_fail (x && y);
+
+ gtk_widget_get_allocation (GTK_WIDGET (GLADE_WIDGET (fixed)->object),
+ &allocation);
+ cont_width = allocation.width;
+ cont_height = allocation.height;
+
+ /* Clip out mouse events that are outside the window.
+ */
+ if ((left || fixed->operation == GLADE_CURSOR_DRAG) &&
+ *x - fixed->pointer_x_child_origin < 0)
+ *x = fixed->pointer_x_child_origin;
+ if ((top || fixed->operation == GLADE_CURSOR_DRAG) &&
+ *y - fixed->pointer_y_child_origin < 0)
+ *y = fixed->pointer_y_child_origin;
+
+ if ((right || fixed->operation == GLADE_CURSOR_DRAG) &&
+ *x + (fixed->child_width_origin -
+ fixed->pointer_x_child_origin) > cont_width)
+ *x = cont_width - (fixed->child_width_origin -
+ fixed->pointer_x_child_origin);
+ if ((bottom || fixed->operation == GLADE_CURSOR_DRAG) &&
+ *y + (fixed->child_height_origin -
+ fixed->pointer_y_child_origin) > cont_height)
+ *y = cont_height - (fixed->child_height_origin -
+ fixed->pointer_y_child_origin);
+
+ /* Clip out mouse events that mean shrinking to less than 0.
+ */
+ if (left &&
+ (*x - fixed->pointer_x_child_origin) >
+ (fixed->child_x_origin + (fixed->child_width_origin - CHILD_WIDTH_MIN)))
+ {
+ *x = (fixed->child_x_origin +
+ (fixed->child_width_origin - CHILD_WIDTH_MIN)) -
+ fixed->pointer_x_child_origin;
+ }
+ else if (right &&
+ (*x - fixed->pointer_x_child_origin) <
+ fixed->child_x_origin - (fixed->child_width_origin +
+ CHILD_WIDTH_MIN))
+ {
+ *x = (fixed->child_x_origin -
+ (fixed->child_width_origin + CHILD_WIDTH_MIN)) +
+ fixed->pointer_x_child_origin;
+ }
+
+
+ if (top &&
+ (*y - fixed->pointer_y_child_origin) >
+ (fixed->child_y_origin + (fixed->child_height_origin - CHILD_HEIGHT_MIN)))
+ {
+ *y = (fixed->child_y_origin +
+ (fixed->child_height_origin - CHILD_HEIGHT_MIN)) -
+ fixed->pointer_y_child_origin;
+ }
+ else if (bottom &&
+ (*y - fixed->pointer_y_child_origin) <
+ fixed->child_y_origin - (fixed->child_height_origin +
+ CHILD_HEIGHT_MIN))
+ {
+ *y = (fixed->child_y_origin -
+ (fixed->child_height_origin + CHILD_HEIGHT_MIN)) +
+ fixed->pointer_y_child_origin;
+ }
}
static void
-glade_fixed_configure_widget (GladeFixed *fixed,
- GladeWidget *child)
+glade_fixed_handle_swindow (GladeFixed * fixed, GdkRectangle * area)
{
- GladeWidget *gwidget = GLADE_WIDGET (fixed);
- GdkRectangle new_area;
- gboolean handled, right, left, top, bottom;
- gint x, y;
-
- gtk_widget_get_pointer (GTK_WIDGET (gwidget->object), &x, &y);
-
- right = GLADE_FIXED_CURSOR_RIGHT (fixed->operation);
- left = GLADE_FIXED_CURSOR_LEFT (fixed->operation);
- top = GLADE_FIXED_CURSOR_TOP (fixed->operation);
- bottom = GLADE_FIXED_CURSOR_BOTTOM (fixed->operation);
-
- /* Filter out events that make your widget go out of bounds */
- glade_fixed_filter_event (fixed, &x, &y, left, right, top, bottom);
-
- new_area.x = fixed->child_x_origin;
- new_area.y = fixed->child_y_origin;
- new_area.width = fixed->child_width_origin;
- new_area.height = fixed->child_height_origin;
-
- /* Modify current size.
- */
- if (fixed->operation == GLADE_CURSOR_DRAG)
- {
- /* Move widget */
- new_area.x = fixed->child_x_origin +
- x - fixed->pointer_x_origin;
- new_area.y = fixed->child_y_origin +
- y - fixed->pointer_y_origin;
-
- } else {
-
- if (bottom)
- {
- new_area.height =
- fixed->child_height_origin +
- (y - fixed->pointer_y_origin);
- } else if (top)
- {
-
- new_area.height =
- fixed->child_height_origin -
- (y - fixed->pointer_y_origin);
- new_area.y =
- fixed->child_y_origin +
- (y - fixed->pointer_y_origin);
- }
-
- if (right)
- {
- new_area.width =
- fixed->child_width_origin +
- (x - fixed->pointer_x_origin);
- } else if (left)
- {
- new_area.width =
- fixed->child_width_origin -
- (x - fixed->pointer_x_origin);
- new_area.x =
- fixed->child_x_origin +
- (x - fixed->pointer_x_origin);
- }
- }
-
- /* Trim */
- if (new_area.width < CHILD_WIDTH_MIN)
- new_area.width = CHILD_WIDTH_MIN;
- if (new_area.height < CHILD_WIDTH_MIN)
- new_area.height = CHILD_HEIGHT_MIN;
-
- /* before configuring the child widget, make make sure the target child
- * widget area is visible if the GladeFixed is placed inside a scrolled
- * window or a viewport inside a scrolled window.
- */
- glade_fixed_handle_swindow (fixed, &new_area);
-
- /* Apply new rectangle to the object */
- g_signal_emit (G_OBJECT (fixed),
- glade_fixed_signals[CONFIGURE_CHILD],
- 0, child, &new_area, &handled);
-
- /* Correct glitches when some widgets are draged over others */
- gtk_widget_queue_draw (GTK_WIDGET (GLADE_WIDGET (fixed)->object));
+ GtkWidget *fixed_widget = GTK_WIDGET (GLADE_WIDGET (fixed)->object);
+ GtkWidget *swindow = NULL, *swindow_child = NULL;
+ GtkAdjustment *hadj, *vadj;
+ GtkAllocation child_allocation;
+ gint x, y;
+
+ swindow_child = swindow = fixed_widget;
+ while (swindow && !GTK_IS_SCROLLED_WINDOW (swindow))
+ {
+ if (!GTK_IS_VIEWPORT (swindow))
+ swindow_child = swindow;
+
+ swindow = gtk_widget_get_parent (swindow);
+ }
+
+ if (swindow)
+ {
+ /* Set the adjustments to use appropriate pixel units and then
+ * square in on the target drop area.
+ */
+ hadj =
+ gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (swindow));
+ vadj =
+ gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (swindow));
+ gtk_widget_get_allocation (swindow_child, &child_allocation);
+
+ g_object_set (G_OBJECT (hadj),
+ "lower", 0.0F,
+ "upper", (gdouble) child_allocation.width + 0.0, NULL);
+
+ g_object_set (G_OBJECT (vadj),
+ "lower", 0.0F,
+ "upper", (gdouble) child_allocation.height + 0.0, NULL);
+
+ gtk_widget_translate_coordinates (fixed_widget,
+ swindow_child,
+ area->x, area->y, &x, &y);
+
+ gtk_adjustment_clamp_page (hadj, x, x + area->width);
+ gtk_adjustment_clamp_page (vadj, y, y + area->height);
+ }
}
static void
-glade_fixed_disconnect_child (GladeFixed *fixed,
- GladeWidget *child)
+glade_fixed_configure_widget (GladeFixed * fixed, GladeWidget * child)
{
- GFSigData *data;
-
- if (GTK_IS_WIDGET (child->object) == FALSE)
- return;
-
- if ((data = g_object_get_data (G_OBJECT (child), "glade-fixed-signal-data")) != NULL)
- {
- g_signal_handler_disconnect (child, data->press_id);
- g_signal_handler_disconnect (child, data->release_id);
- g_signal_handler_disconnect (child, data->motion_id);
-
- g_object_set_data (G_OBJECT (child), "glade-fixed-signal-data", NULL);
- }
+ GladeWidget *gwidget = GLADE_WIDGET (fixed);
+ GdkRectangle new_area;
+ gboolean handled, right, left, top, bottom;
+ gint x, y;
+
+ gtk_widget_get_pointer (GTK_WIDGET (gwidget->object), &x, &y);
+
+ right = GLADE_FIXED_CURSOR_RIGHT (fixed->operation);
+ left = GLADE_FIXED_CURSOR_LEFT (fixed->operation);
+ top = GLADE_FIXED_CURSOR_TOP (fixed->operation);
+ bottom = GLADE_FIXED_CURSOR_BOTTOM (fixed->operation);
+
+ /* Filter out events that make your widget go out of bounds */
+ glade_fixed_filter_event (fixed, &x, &y, left, right, top, bottom);
+
+ new_area.x = fixed->child_x_origin;
+ new_area.y = fixed->child_y_origin;
+ new_area.width = fixed->child_width_origin;
+ new_area.height = fixed->child_height_origin;
+
+ /* Modify current size.
+ */
+ if (fixed->operation == GLADE_CURSOR_DRAG)
+ {
+ /* Move widget */
+ new_area.x = fixed->child_x_origin + x - fixed->pointer_x_origin;
+ new_area.y = fixed->child_y_origin + y - fixed->pointer_y_origin;
+
+ }
+ else
+ {
+
+ if (bottom)
+ {
+ new_area.height =
+ fixed->child_height_origin + (y - fixed->pointer_y_origin);
+ }
+ else if (top)
+ {
+
+ new_area.height =
+ fixed->child_height_origin - (y - fixed->pointer_y_origin);
+ new_area.y = fixed->child_y_origin + (y - fixed->pointer_y_origin);
+ }
+
+ if (right)
+ {
+ new_area.width =
+ fixed->child_width_origin + (x - fixed->pointer_x_origin);
+ }
+ else if (left)
+ {
+ new_area.width =
+ fixed->child_width_origin - (x - fixed->pointer_x_origin);
+ new_area.x = fixed->child_x_origin + (x - fixed->pointer_x_origin);
+ }
+ }
+
+ /* Trim */
+ if (new_area.width < CHILD_WIDTH_MIN)
+ new_area.width = CHILD_WIDTH_MIN;
+ if (new_area.height < CHILD_WIDTH_MIN)
+ new_area.height = CHILD_HEIGHT_MIN;
+
+ /* before configuring the child widget, make make sure the target child
+ * widget area is visible if the GladeFixed is placed inside a scrolled
+ * window or a viewport inside a scrolled window.
+ */
+ glade_fixed_handle_swindow (fixed, &new_area);
+
+ /* Apply new rectangle to the object */
+ g_signal_emit (G_OBJECT (fixed),
+ glade_fixed_signals[CONFIGURE_CHILD],
+ 0, child, &new_area, &handled);
+
+ /* Correct glitches when some widgets are draged over others */
+ gtk_widget_queue_draw (GTK_WIDGET (GLADE_WIDGET (fixed)->object));
}
static void
-glade_fixed_connect_child (GladeFixed *fixed,
- GladeWidget *child)
+glade_fixed_disconnect_child (GladeFixed * fixed, GladeWidget * child)
{
- GFSigData *data;
+ GFSigData *data;
- if (GTK_IS_WIDGET (child->object) == FALSE)
- return;
+ if (GTK_IS_WIDGET (child->object) == FALSE)
+ return;
- if ((data = g_object_get_data (G_OBJECT (child), "glade-fixed-signal-data")) != NULL)
- glade_fixed_disconnect_child (fixed, child);
-
- data = g_new (GFSigData, 1);
+ if ((data =
+ g_object_get_data (G_OBJECT (child), "glade-fixed-signal-data")) != NULL)
+ {
+ g_signal_handler_disconnect (child, data->press_id);
+ g_signal_handler_disconnect (child, data->release_id);
+ g_signal_handler_disconnect (child, data->motion_id);
- /* Connect-after here... leave a chance for selection
- */
- data->press_id =
- g_signal_connect_after
- (child, "button-press-event", G_CALLBACK
- (GLADE_FIXED_GET_CLASS(fixed)->child_event), fixed);
- data->release_id =
- g_signal_connect
- (child, "button-release-event", G_CALLBACK
- (GLADE_FIXED_GET_CLASS(fixed)->child_event), fixed);
- data->motion_id =
- g_signal_connect
- (child, "motion-notify-event", G_CALLBACK
- (GLADE_FIXED_GET_CLASS(fixed)->child_event), fixed);
-
-
- g_object_set_data_full (G_OBJECT (child), "glade-fixed-signal-data",
- data, g_free);
+ g_object_set_data (G_OBJECT (child), "glade-fixed-signal-data", NULL);
+ }
+}
+
+static void
+glade_fixed_connect_child (GladeFixed * fixed, GladeWidget * child)
+{
+ GFSigData *data;
+
+ if (GTK_IS_WIDGET (child->object) == FALSE)
+ return;
+
+ if ((data =
+ g_object_get_data (G_OBJECT (child), "glade-fixed-signal-data")) != NULL)
+ glade_fixed_disconnect_child (fixed, child);
+
+ data = g_new (GFSigData, 1);
+
+ /* Connect-after here... leave a chance for selection
+ */
+ data->press_id =
+ g_signal_connect_after
+ (child, "button-press-event", G_CALLBACK
+ (GLADE_FIXED_GET_CLASS (fixed)->child_event), fixed);
+ data->release_id =
+ g_signal_connect
+ (child, "button-release-event", G_CALLBACK
+ (GLADE_FIXED_GET_CLASS (fixed)->child_event), fixed);
+ data->motion_id =
+ g_signal_connect
+ (child, "motion-notify-event", G_CALLBACK
+ (GLADE_FIXED_GET_CLASS (fixed)->child_event), fixed);
+
+
+ g_object_set_data_full (G_OBJECT (child), "glade-fixed-signal-data",
+ data, g_free);
}
/*******************************************************************************
GladeFixedClass
*******************************************************************************/
static gboolean
-glade_fixed_configure_child_impl (GladeFixed *fixed,
- GladeWidget *child,
- GdkRectangle *rect)
+glade_fixed_configure_child_impl (GladeFixed * fixed,
+ GladeWidget * child, GdkRectangle * rect)
{
- /* Make sure we can modify these properties */
- glade_widget_pack_property_set_enabled (child, fixed->x_prop, TRUE);
- glade_widget_pack_property_set_enabled (child, fixed->y_prop, TRUE);
- glade_widget_property_set_enabled (child, fixed->width_prop, TRUE);
- glade_widget_property_set_enabled (child, fixed->height_prop, TRUE);
-
- glade_widget_pack_property_set (child, fixed->x_prop, rect->x);
- glade_widget_pack_property_set (child, fixed->y_prop, rect->y);
- glade_widget_property_set (child, fixed->width_prop, rect->width);
- glade_widget_property_set (child, fixed->height_prop, rect->height);
- return TRUE;
+ /* Make sure we can modify these properties */
+ glade_widget_pack_property_set_enabled (child, fixed->x_prop, TRUE);
+ glade_widget_pack_property_set_enabled (child, fixed->y_prop, TRUE);
+ glade_widget_property_set_enabled (child, fixed->width_prop, TRUE);
+ glade_widget_property_set_enabled (child, fixed->height_prop, TRUE);
+
+ glade_widget_pack_property_set (child, fixed->x_prop, rect->x);
+ glade_widget_pack_property_set (child, fixed->y_prop, rect->y);
+ glade_widget_property_set (child, fixed->width_prop, rect->width);
+ glade_widget_property_set (child, fixed->height_prop, rect->height);
+ return TRUE;
}
static gboolean
-glade_fixed_configure_end_impl (GladeFixed *fixed,
- GladeWidget *child)
+glade_fixed_configure_end_impl (GladeFixed * fixed, GladeWidget * child)
{
- GValue x_value = { 0, };
- GValue y_value = { 0, };
- GValue width_value = { 0, };
- GValue height_value = { 0, };
- GValue new_x_value = { 0, };
- GValue new_y_value = { 0, };
- GValue new_width_value = { 0, };
- GValue new_height_value = { 0, };
- GladeProperty *x_prop, *y_prop, *width_prop, *height_prop;
-
- x_prop = glade_widget_get_pack_property (child, fixed->x_prop);
- y_prop = glade_widget_get_pack_property (child, fixed->y_prop);
- width_prop = glade_widget_get_property (child, fixed->width_prop);
- height_prop = glade_widget_get_property (child, fixed->height_prop);
-
- g_return_val_if_fail (GLADE_IS_PROPERTY (x_prop), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (y_prop), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (width_prop), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (height_prop), FALSE);
-
- g_value_init (&x_value, G_TYPE_INT);
- g_value_init (&y_value, G_TYPE_INT);
- g_value_init (&width_value, G_TYPE_INT);
- g_value_init (&height_value, G_TYPE_INT);
-
- glade_property_get_value (x_prop, &new_x_value);
- glade_property_get_value (y_prop, &new_y_value);
- glade_property_get_value (width_prop, &new_width_value);
- glade_property_get_value (height_prop, &new_height_value);
-
- g_value_set_int (&x_value, fixed->child_x_origin);
- g_value_set_int (&y_value, fixed->child_y_origin);
- g_value_set_int (&width_value, fixed->child_width_origin);
- g_value_set_int (&height_value, fixed->child_height_origin);
-
- glade_command_push_group (_("Placing %s inside %s"),
- child->name,
- GLADE_WIDGET (fixed)->name);
-
- /* whew, all that for this call !
- */
- glade_command_set_properties (x_prop, &x_value, &new_x_value,
- y_prop, &y_value, &new_y_value,
- width_prop, &width_value, &new_width_value,
- height_prop, &height_value, &new_height_value,
- NULL);
-
- glade_command_pop_group ();
-
- g_value_unset (&x_value);
- g_value_unset (&y_value);
- g_value_unset (&width_value);
- g_value_unset (&height_value);
- g_value_unset (&new_x_value);
- g_value_unset (&new_y_value);
- g_value_unset (&new_width_value);
- g_value_unset (&new_height_value);
-
- return TRUE;
+ GValue x_value = { 0, };
+ GValue y_value = { 0, };
+ GValue width_value = { 0, };
+ GValue height_value = { 0, };
+ GValue new_x_value = { 0, };
+ GValue new_y_value = { 0, };
+ GValue new_width_value = { 0, };
+ GValue new_height_value = { 0, };
+ GladeProperty *x_prop, *y_prop, *width_prop, *height_prop;
+
+ x_prop = glade_widget_get_pack_property (child, fixed->x_prop);
+ y_prop = glade_widget_get_pack_property (child, fixed->y_prop);
+ width_prop = glade_widget_get_property (child, fixed->width_prop);
+ height_prop = glade_widget_get_property (child, fixed->height_prop);
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY (x_prop), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (y_prop), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (width_prop), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (height_prop), FALSE);
+
+ g_value_init (&x_value, G_TYPE_INT);
+ g_value_init (&y_value, G_TYPE_INT);
+ g_value_init (&width_value, G_TYPE_INT);
+ g_value_init (&height_value, G_TYPE_INT);
+
+ glade_property_get_value (x_prop, &new_x_value);
+ glade_property_get_value (y_prop, &new_y_value);
+ glade_property_get_value (width_prop, &new_width_value);
+ glade_property_get_value (height_prop, &new_height_value);
+
+ g_value_set_int (&x_value, fixed->child_x_origin);
+ g_value_set_int (&y_value, fixed->child_y_origin);
+ g_value_set_int (&width_value, fixed->child_width_origin);
+ g_value_set_int (&height_value, fixed->child_height_origin);
+
+ glade_command_push_group (_("Placing %s inside %s"),
+ child->name, GLADE_WIDGET (fixed)->name);
+
+ /* whew, all that for this call !
+ */
+ glade_command_set_properties (x_prop, &x_value, &new_x_value,
+ y_prop, &y_value, &new_y_value,
+ width_prop, &width_value, &new_width_value,
+ height_prop, &height_value, &new_height_value,
+ NULL);
+
+ glade_command_pop_group ();
+
+ g_value_unset (&x_value);
+ g_value_unset (&y_value);
+ g_value_unset (&width_value);
+ g_value_unset (&height_value);
+ g_value_unset (&new_x_value);
+ g_value_unset (&new_y_value);
+ g_value_unset (&new_width_value);
+ g_value_unset (&new_height_value);
+
+ return TRUE;
}
static void
-glade_fixed_cancel_operation (GladeFixed *fixed,
- GladeCursorType new_operation)
+glade_fixed_cancel_operation (GladeFixed * fixed, GladeCursorType new_operation)
{
- gboolean handled;
-
- g_signal_emit (G_OBJECT (fixed),
- glade_fixed_signals[CONFIGURE_END],
- 0, fixed->configuring, &handled);
-
- /* Leave the machine state intact untill after
- * the user handled signal.
- */
- fixed->operation = new_operation;
- fixed->configuring = NULL;
-}
+ gboolean handled;
-static gboolean
-glade_fixed_handle_child_event (GladeFixed *fixed,
- GladeWidget *child,
- GtkWidget *event_widget,
- GdkEvent *event)
-{
- GladeCursorType operation;
- GdkModifierType event_state = 0;
- GladePointerMode pointer_mode;
- GtkWidget *fixed_widget, *child_widget;
- gint fixed_x, fixed_y, child_x, child_y;
- gboolean handled = FALSE, sig_handled;
-
- fixed_widget = GTK_WIDGET (GLADE_WIDGET (fixed)->object);
- child_widget = GTK_WIDGET (child->object);
+ g_signal_emit (G_OBJECT (fixed),
+ glade_fixed_signals[CONFIGURE_END],
+ 0, fixed->configuring, &handled);
- pointer_mode = glade_app_get_pointer_mode ();
+ /* Leave the machine state intact untill after
+ * the user handled signal.
+ */
+ fixed->operation = new_operation;
+ fixed->configuring = NULL;
+}
- /* when widget->window points to a parent window, these calculations
- * would be wrong if we based them on the GTK_WIDGET (fixed)->window,
- * so we must always consult the event widget's window
- */
- gtk_widget_get_pointer (fixed_widget, &fixed_x, &fixed_y);
-
- /* Container widgets are trustable to have widget->window occupying
- * the entire widget allocation (gtk_widget_get_pointer broken on GtkEntry).
- */
- gtk_widget_translate_coordinates (fixed_widget,
- child_widget,
- fixed_x, fixed_y,
- &child_x, &child_y);
-
- if (fixed->can_resize)
- operation = glade_fixed_get_operation (GTK_WIDGET (child->object),
- child_x, child_y);
- else
- operation = GLADE_CURSOR_DRAG;
-
- gdk_event_get_state (event, &event_state);
-
- switch (event->type)
- {
- case GDK_MOTION_NOTIFY:
- if (fixed->configuring == NULL)
- {
- if ((event_state & GDK_SHIFT_MASK) ||
- pointer_mode == GLADE_POINTER_DRAG_RESIZE)
- glade_cursor_set (((GdkEventAny *)event)->window,
- operation);
- else if (pointer_mode == GLADE_POINTER_SELECT)
- glade_cursor_set (((GdkEventAny *)event)->window,
- GLADE_CURSOR_SELECTOR);
-
- } else if (fixed->configuring && !(event_state & GDK_BUTTON1_MASK))
- {
- /* Cancel drags that no longer have mouse down */
- glade_cursor_set (((GdkEventAny *)event)->window,
- operation);
-
- glade_fixed_cancel_operation (fixed, operation);
- handled = TRUE;
- } else if (fixed->configuring)
- {
- /* Need to update mouse for configures. */
- gtk_widget_get_pointer (fixed_widget,
- &fixed->mouse_x, &fixed->mouse_y);
-
- glade_fixed_configure_widget (fixed, child);
- glade_cursor_set (((GdkEventAny *)event)->window,
- fixed->operation);
- handled = TRUE;
- }
-
- gdk_window_get_pointer (gtk_widget_get_window (GTK_WIDGET (child->object)), NULL, NULL, NULL);
- break;
- case GDK_BUTTON_PRESS:
- /* We cant rely on GDK_BUTTON1_MASK since event->state isnt yet updated
- * by the current event itself
- */
- if (((GdkEventButton *)event)->button == 1 &&
- ((event_state & GDK_SHIFT_MASK) ||
- pointer_mode == GLADE_POINTER_DRAG_RESIZE))
- {
- fixed->configuring = child;
- /* Save widget allocation and pointer pos */
- glade_fixed_save_state (fixed, child);
-
- fixed->operation = operation;
- glade_cursor_set (((GdkEventAny *)event)->window, fixed->operation);
-
- g_signal_emit (G_OBJECT (fixed),
- glade_fixed_signals[CONFIGURE_BEGIN],
- 0, child, &sig_handled);
-
- handled = TRUE;
- }
- break;
- case GDK_BUTTON_RELEASE:
- if (((GdkEventButton *)event)->button == 1 && fixed->configuring)
- {
-
- if ((event_state & GDK_SHIFT_MASK) ||
- pointer_mode == GLADE_POINTER_DRAG_RESIZE)
- glade_cursor_set (((GdkEventAny *)event)->window,
- operation);
- else
- glade_cursor_set (((GdkEventAny *)event)->window,
- GLADE_CURSOR_SELECTOR);
-
- glade_fixed_cancel_operation (fixed, operation);
- handled = TRUE;
- }
- break;
- default:
- break;
- }
- return handled;
+static gboolean
+glade_fixed_handle_child_event (GladeFixed * fixed,
+ GladeWidget * child,
+ GtkWidget * event_widget, GdkEvent * event)
+{
+ GladeCursorType operation;
+ GdkModifierType event_state = 0;
+ GladePointerMode pointer_mode;
+ GtkWidget *fixed_widget, *child_widget;
+ gint fixed_x, fixed_y, child_x, child_y;
+ gboolean handled = FALSE, sig_handled;
+
+ fixed_widget = GTK_WIDGET (GLADE_WIDGET (fixed)->object);
+ child_widget = GTK_WIDGET (child->object);
+
+ pointer_mode = glade_app_get_pointer_mode ();
+
+ /* when widget->window points to a parent window, these calculations
+ * would be wrong if we based them on the GTK_WIDGET (fixed)->window,
+ * so we must always consult the event widget's window
+ */
+ gtk_widget_get_pointer (fixed_widget, &fixed_x, &fixed_y);
+
+ /* Container widgets are trustable to have widget->window occupying
+ * the entire widget allocation (gtk_widget_get_pointer broken on GtkEntry).
+ */
+ gtk_widget_translate_coordinates (fixed_widget,
+ child_widget,
+ fixed_x, fixed_y, &child_x, &child_y);
+
+ if (fixed->can_resize)
+ operation = glade_fixed_get_operation (GTK_WIDGET (child->object),
+ child_x, child_y);
+ else
+ operation = GLADE_CURSOR_DRAG;
+
+ gdk_event_get_state (event, &event_state);
+
+ switch (event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ if (fixed->configuring == NULL)
+ {
+ if ((event_state & GDK_SHIFT_MASK) ||
+ pointer_mode == GLADE_POINTER_DRAG_RESIZE)
+ glade_cursor_set (((GdkEventAny *) event)->window, operation);
+ else if (pointer_mode == GLADE_POINTER_SELECT)
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ GLADE_CURSOR_SELECTOR);
+
+ }
+ else if (fixed->configuring && !(event_state & GDK_BUTTON1_MASK))
+ {
+ /* Cancel drags that no longer have mouse down */
+ glade_cursor_set (((GdkEventAny *) event)->window, operation);
+
+ glade_fixed_cancel_operation (fixed, operation);
+ handled = TRUE;
+ }
+ else if (fixed->configuring)
+ {
+ /* Need to update mouse for configures. */
+ gtk_widget_get_pointer (fixed_widget,
+ &fixed->mouse_x, &fixed->mouse_y);
+
+ glade_fixed_configure_widget (fixed, child);
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ fixed->operation);
+ handled = TRUE;
+ }
+
+ gdk_window_get_pointer (gtk_widget_get_window
+ (GTK_WIDGET (child->object)), NULL, NULL, NULL);
+ break;
+ case GDK_BUTTON_PRESS:
+ /* We cant rely on GDK_BUTTON1_MASK since event->state isnt yet updated
+ * by the current event itself
+ */
+ if (((GdkEventButton *) event)->button == 1 &&
+ ((event_state & GDK_SHIFT_MASK) ||
+ pointer_mode == GLADE_POINTER_DRAG_RESIZE))
+ {
+ fixed->configuring = child;
+ /* Save widget allocation and pointer pos */
+ glade_fixed_save_state (fixed, child);
+
+ fixed->operation = operation;
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ fixed->operation);
+
+ g_signal_emit (G_OBJECT (fixed),
+ glade_fixed_signals[CONFIGURE_BEGIN],
+ 0, child, &sig_handled);
+
+ handled = TRUE;
+ }
+ break;
+ case GDK_BUTTON_RELEASE:
+ if (((GdkEventButton *) event)->button == 1 && fixed->configuring)
+ {
+
+ if ((event_state & GDK_SHIFT_MASK) ||
+ pointer_mode == GLADE_POINTER_DRAG_RESIZE)
+ glade_cursor_set (((GdkEventAny *) event)->window, operation);
+ else
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ GLADE_CURSOR_SELECTOR);
+
+ glade_fixed_cancel_operation (fixed, operation);
+ handled = TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+ return handled;
}
static gint
-glade_fixed_child_event (GladeWidget *gwidget,
- GdkEvent *event,
- GladeFixed *fixed)
+glade_fixed_child_event (GladeWidget * gwidget,
+ GdkEvent * event, GladeFixed * fixed)
{
- GtkWidget *event_widget;
-
- /* Get the basic event info... */
- gdk_window_get_user_data (((GdkEventAny *)event)->window, (gpointer)&event_widget);
-
- /* Skip all this choosyness if we're already in a drag/resize
- */
- if (fixed->configuring)
- {
- return glade_fixed_handle_child_event
- (fixed, fixed->configuring, event_widget, event);
- }
-
- g_return_val_if_fail (GLADE_IS_WIDGET (gwidget), FALSE);
-
- /* Early return for fixed children with selection in
- * the palette.
- */
- if (GLADE_IS_FIXED (gwidget) &&
- glade_app_get_pointer_mode() == GLADE_POINTER_ADD_WIDGET)
- {
- glade_cursor_set (((GdkEventAny *)event)->window,
- GLADE_CURSOR_ADD_WIDGET);
- return FALSE;
- }
-
- return glade_fixed_handle_child_event
- (fixed, gwidget, event_widget, event);
+ GtkWidget *event_widget;
+
+ /* Get the basic event info... */
+ gdk_window_get_user_data (((GdkEventAny *) event)->window,
+ (gpointer) & event_widget);
+
+ /* Skip all this choosyness if we're already in a drag/resize
+ */
+ if (fixed->configuring)
+ {
+ return glade_fixed_handle_child_event
+ (fixed, fixed->configuring, event_widget, event);
+ }
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (gwidget), FALSE);
+
+ /* Early return for fixed children with selection in
+ * the palette.
+ */
+ if (GLADE_IS_FIXED (gwidget) &&
+ glade_app_get_pointer_mode () == GLADE_POINTER_ADD_WIDGET)
+ {
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ GLADE_CURSOR_ADD_WIDGET);
+ return FALSE;
+ }
+
+ return glade_fixed_handle_child_event (fixed, gwidget, event_widget, event);
}
@@ -691,327 +692,327 @@ glade_fixed_child_event (GladeWidget *gwidget,
GladeWidgetClass
*******************************************************************************/
static void
-glade_fixed_add_child_impl (GladeWidget *gwidget_fixed,
- GladeWidget *child,
- gboolean at_mouse)
+glade_fixed_add_child_impl (GladeWidget * gwidget_fixed,
+ GladeWidget * child, gboolean at_mouse)
{
- GladeFixed *fixed = GLADE_FIXED (gwidget_fixed);
- GtkAllocation allocation;
- GdkRectangle rect;
- gboolean handled;
-
- g_return_if_fail (GLADE_IS_FIXED (fixed));
- g_return_if_fail (GLADE_IS_WIDGET (child));
-
- /* Chain up for the basic parenting */
- GLADE_WIDGET_CLASS (parent_class)->add_child
- (GLADE_WIDGET (fixed), child, at_mouse);
-
- /* We only operate on widgets here */
- if (!GTK_IS_WIDGET (child->object))
- return;
-
- gtk_widget_add_events (GTK_WIDGET (child->object),
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK);
-
- glade_fixed_connect_child (fixed, child);
-
- /* Setup rect and send configure
- */
- if (fixed->creating)
- {
- rect.x = fixed->mouse_x;
- rect.y = fixed->mouse_y;
- rect.width = CHILD_WIDTH_DEF;
- rect.height = CHILD_HEIGHT_DEF;
-
- g_signal_emit (G_OBJECT (fixed),
- glade_fixed_signals[CONFIGURE_CHILD],
- 0, child, &rect, &handled);
- }
- else if (at_mouse)
- {
- gtk_widget_get_allocation (GTK_WIDGET (child->object), &allocation);
- rect.x = fixed->mouse_x;
- rect.y = fixed->mouse_y;
- rect.width = allocation.width;
- rect.height = allocation.height;
-
- if (rect.width < CHILD_WIDTH_DEF)
- rect.width = CHILD_WIDTH_DEF;
-
- if (rect.height < CHILD_HEIGHT_DEF)
- rect.height = CHILD_HEIGHT_DEF;
-
- g_signal_emit (G_OBJECT (fixed),
- glade_fixed_signals[CONFIGURE_CHILD],
- 0, child, &rect, &handled);
- }
- return;
+ GladeFixed *fixed = GLADE_FIXED (gwidget_fixed);
+ GtkAllocation allocation;
+ GdkRectangle rect;
+ gboolean handled;
+
+ g_return_if_fail (GLADE_IS_FIXED (fixed));
+ g_return_if_fail (GLADE_IS_WIDGET (child));
+
+ /* Chain up for the basic parenting */
+ GLADE_WIDGET_CLASS (parent_class)->add_child
+ (GLADE_WIDGET (fixed), child, at_mouse);
+
+ /* We only operate on widgets here */
+ if (!GTK_IS_WIDGET (child->object))
+ return;
+
+ gtk_widget_add_events (GTK_WIDGET (child->object),
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK);
+
+ glade_fixed_connect_child (fixed, child);
+
+ /* Setup rect and send configure
+ */
+ if (fixed->creating)
+ {
+ rect.x = fixed->mouse_x;
+ rect.y = fixed->mouse_y;
+ rect.width = CHILD_WIDTH_DEF;
+ rect.height = CHILD_HEIGHT_DEF;
+
+ g_signal_emit (G_OBJECT (fixed),
+ glade_fixed_signals[CONFIGURE_CHILD],
+ 0, child, &rect, &handled);
+ }
+ else if (at_mouse)
+ {
+ gtk_widget_get_allocation (GTK_WIDGET (child->object), &allocation);
+ rect.x = fixed->mouse_x;
+ rect.y = fixed->mouse_y;
+ rect.width = allocation.width;
+ rect.height = allocation.height;
+
+ if (rect.width < CHILD_WIDTH_DEF)
+ rect.width = CHILD_WIDTH_DEF;
+
+ if (rect.height < CHILD_HEIGHT_DEF)
+ rect.height = CHILD_HEIGHT_DEF;
+
+ g_signal_emit (G_OBJECT (fixed),
+ glade_fixed_signals[CONFIGURE_CHILD],
+ 0, child, &rect, &handled);
+ }
+ return;
}
static void
-glade_fixed_remove_child_impl (GladeWidget *fixed,
- GladeWidget *child)
+glade_fixed_remove_child_impl (GladeWidget * fixed, GladeWidget * child)
{
- glade_fixed_disconnect_child (GLADE_FIXED (fixed), child);
+ glade_fixed_disconnect_child (GLADE_FIXED (fixed), child);
- /* Chain up for the basic unparenting */
- GLADE_WIDGET_CLASS (parent_class)->remove_child
- (GLADE_WIDGET (fixed), child);
+ /* Chain up for the basic unparenting */
+ GLADE_WIDGET_CLASS (parent_class)->remove_child (GLADE_WIDGET (fixed), child);
}
static void
-glade_fixed_replace_child_impl (GladeWidget *fixed,
- GObject *old_object,
- GObject *new_object)
+glade_fixed_replace_child_impl (GladeWidget * fixed,
+ GObject * old_object, GObject * new_object)
{
- GladeWidget *gnew_widget = glade_widget_get_from_gobject (new_object);
- GladeWidget *gold_widget = glade_widget_get_from_gobject (old_object);
+ GladeWidget *gnew_widget = glade_widget_get_from_gobject (new_object);
+ GladeWidget *gold_widget = glade_widget_get_from_gobject (old_object);
- if (gold_widget)
- glade_fixed_disconnect_child (GLADE_FIXED (fixed), gold_widget);
+ if (gold_widget)
+ glade_fixed_disconnect_child (GLADE_FIXED (fixed), gold_widget);
- /* Chain up for the basic reparenting */
- GLADE_WIDGET_CLASS (parent_class)->replace_child
- (GLADE_WIDGET (fixed), old_object, new_object);
+ /* Chain up for the basic reparenting */
+ GLADE_WIDGET_CLASS (parent_class)->replace_child
+ (GLADE_WIDGET (fixed), old_object, new_object);
- if (gnew_widget)
- glade_fixed_connect_child (GLADE_FIXED (fixed), gnew_widget);
+ if (gnew_widget)
+ glade_fixed_connect_child (GLADE_FIXED (fixed), gnew_widget);
}
static gint
-glade_fixed_event (GladeWidget *gwidget_fixed,
- GdkEvent *event)
+glade_fixed_event (GladeWidget * gwidget_fixed, GdkEvent * event)
{
- GladeFixed *fixed = GLADE_FIXED (gwidget_fixed);
- GladeWidgetAdaptor *adaptor;
- GtkWidget *event_widget;
- gboolean handled = FALSE;
-
- adaptor = glade_palette_get_current_item (glade_app_get_palette ());
-
- /* Get the event widget and the deep widget */
- gdk_window_get_user_data (((GdkEventAny *)event)->window, (gpointer)&event_widget);
-
- /* If the GladeWidget used this event... let it slide.
- */
- if (GLADE_WIDGET_CLASS (parent_class)->event (gwidget_fixed, event))
- return TRUE;
-
- switch (event->type)
- {
-
- case GDK_BUTTON_PRESS:
- case GDK_MOTION_NOTIFY:
- case GDK_BUTTON_RELEASE:
- gtk_widget_get_pointer (GTK_WIDGET (gwidget_fixed->object),
- &fixed->mouse_x, &fixed->mouse_y);
- if (fixed->configuring)
- {
- return glade_fixed_handle_child_event
- (fixed, fixed->configuring,
- event_widget, event);
- }
- break;
- default:
- break;
- }
-
- switch (event->type)
- {
- case GDK_BUTTON_PRESS: /* add widget */
- if (((GdkEventButton *) event)->button == 1)
- {
-
- if (adaptor != NULL)
- {
- /* A widget type is selected in the palette.
- * Add a new widget of that type.
- */
- fixed->creating = TRUE;
- glade_command_create (adaptor,
- GLADE_WIDGET (fixed), NULL,
- GLADE_WIDGET (fixed)->project);
- fixed->creating = FALSE;
-
- glade_palette_deselect_current_item (glade_app_get_palette(), TRUE);
-
- handled = TRUE;
- }
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (glade_app_get_pointer_mode() == GLADE_POINTER_ADD_WIDGET)
- {
- glade_cursor_set (((GdkEventAny *)event)->window,
- GLADE_CURSOR_ADD_WIDGET);
-
- handled = TRUE;
- }
- else if (GLADE_IS_FIXED (gwidget_fixed->parent) == FALSE &&
- glade_app_get_pointer_mode() == GLADE_POINTER_SELECT)
- glade_cursor_set (((GdkEventAny *)event)->window,
- GLADE_CURSOR_SELECTOR);
- break;
- default:
- break;
- }
- return handled;
+ GladeFixed *fixed = GLADE_FIXED (gwidget_fixed);
+ GladeWidgetAdaptor *adaptor;
+ GtkWidget *event_widget;
+ gboolean handled = FALSE;
+
+ adaptor = glade_palette_get_current_item (glade_app_get_palette ());
+
+ /* Get the event widget and the deep widget */
+ gdk_window_get_user_data (((GdkEventAny *) event)->window,
+ (gpointer) & event_widget);
+
+ /* If the GladeWidget used this event... let it slide.
+ */
+ if (GLADE_WIDGET_CLASS (parent_class)->event (gwidget_fixed, event))
+ return TRUE;
+
+ switch (event->type)
+ {
+
+ case GDK_BUTTON_PRESS:
+ case GDK_MOTION_NOTIFY:
+ case GDK_BUTTON_RELEASE:
+ gtk_widget_get_pointer (GTK_WIDGET (gwidget_fixed->object),
+ &fixed->mouse_x, &fixed->mouse_y);
+ if (fixed->configuring)
+ {
+ return glade_fixed_handle_child_event
+ (fixed, fixed->configuring, event_widget, event);
+ }
+ break;
+ default:
+ break;
+ }
+
+ switch (event->type)
+ {
+ case GDK_BUTTON_PRESS: /* add widget */
+ if (((GdkEventButton *) event)->button == 1)
+ {
+
+ if (adaptor != NULL)
+ {
+ /* A widget type is selected in the palette.
+ * Add a new widget of that type.
+ */
+ fixed->creating = TRUE;
+ glade_command_create (adaptor,
+ GLADE_WIDGET (fixed), NULL,
+ GLADE_WIDGET (fixed)->project);
+ fixed->creating = FALSE;
+
+ glade_palette_deselect_current_item (glade_app_get_palette (),
+ TRUE);
+
+ handled = TRUE;
+ }
+ }
+ break;
+ case GDK_MOTION_NOTIFY:
+ if (glade_app_get_pointer_mode () == GLADE_POINTER_ADD_WIDGET)
+ {
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ GLADE_CURSOR_ADD_WIDGET);
+
+ handled = TRUE;
+ }
+ else if (GLADE_IS_FIXED (gwidget_fixed->parent) == FALSE &&
+ glade_app_get_pointer_mode () == GLADE_POINTER_SELECT)
+ glade_cursor_set (((GdkEventAny *) event)->window,
+ GLADE_CURSOR_SELECTOR);
+ break;
+ default:
+ break;
+ }
+ return handled;
}
/*******************************************************************************
GObjectClass
*******************************************************************************/
static void
-glade_fixed_finalize (GObject *object)
+glade_fixed_finalize (GObject * object)
{
- GladeFixed *fixed = GLADE_FIXED (object);
-
- /* A GladeFixed should be finalized as a result of its
- * GtkContainer being destroyed, so we shouldn't need to bother
- * about disconnecting all the child signals.
- */
- g_free (fixed->x_prop);
- g_free (fixed->y_prop);
- g_free (fixed->width_prop);
- g_free (fixed->height_prop);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ GladeFixed *fixed = GLADE_FIXED (object);
+
+ /* A GladeFixed should be finalized as a result of its
+ * GtkContainer being destroyed, so we shouldn't need to bother
+ * about disconnecting all the child signals.
+ */
+ g_free (fixed->x_prop);
+ g_free (fixed->y_prop);
+ g_free (fixed->width_prop);
+ g_free (fixed->height_prop);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-glade_fixed_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_fixed_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeFixed *fixed = GLADE_FIXED (object);
-
- switch (prop_id)
- {
- case PROP_X_PROP:
- g_free (fixed->x_prop);
- fixed->x_prop = g_value_dup_string (value);
- break;
- case PROP_Y_PROP:
- g_free (fixed->y_prop);
- fixed->y_prop = g_value_dup_string (value);
- break;
- case PROP_WIDTH_PROP:
- g_free (fixed->width_prop);
- fixed->width_prop = g_value_dup_string (value);
- break;
- case PROP_HEIGHT_PROP:
- g_free (fixed->height_prop);
- fixed->height_prop = g_value_dup_string (value);
- break;
- case PROP_CAN_RESIZE:
- fixed->can_resize = g_value_get_boolean (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeFixed *fixed = GLADE_FIXED (object);
+
+ switch (prop_id)
+ {
+ case PROP_X_PROP:
+ g_free (fixed->x_prop);
+ fixed->x_prop = g_value_dup_string (value);
+ break;
+ case PROP_Y_PROP:
+ g_free (fixed->y_prop);
+ fixed->y_prop = g_value_dup_string (value);
+ break;
+ case PROP_WIDTH_PROP:
+ g_free (fixed->width_prop);
+ fixed->width_prop = g_value_dup_string (value);
+ break;
+ case PROP_HEIGHT_PROP:
+ g_free (fixed->height_prop);
+ fixed->height_prop = g_value_dup_string (value);
+ break;
+ case PROP_CAN_RESIZE:
+ fixed->can_resize = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_fixed_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_fixed_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GladeFixed *fixed = GLADE_FIXED (object);
-
- switch (prop_id)
- {
- case PROP_X_PROP: g_value_set_string (value, fixed->x_prop); break;
- case PROP_Y_PROP: g_value_set_string (value, fixed->y_prop); break;
- case PROP_WIDTH_PROP: g_value_set_string (value, fixed->width_prop); break;
- case PROP_HEIGHT_PROP: g_value_set_string (value, fixed->height_prop); break;
- case PROP_CAN_RESIZE: g_value_set_boolean (value, fixed->can_resize); break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeFixed *fixed = GLADE_FIXED (object);
+
+ switch (prop_id)
+ {
+ case PROP_X_PROP:
+ g_value_set_string (value, fixed->x_prop);
+ break;
+ case PROP_Y_PROP:
+ g_value_set_string (value, fixed->y_prop);
+ break;
+ case PROP_WIDTH_PROP:
+ g_value_set_string (value, fixed->width_prop);
+ break;
+ case PROP_HEIGHT_PROP:
+ g_value_set_string (value, fixed->height_prop);
+ break;
+ case PROP_CAN_RESIZE:
+ g_value_set_boolean (value, fixed->can_resize);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_fixed_init (GladeFixed *fixed)
+glade_fixed_init (GladeFixed * fixed)
{
- /* Set defaults */
- fixed->x_prop = g_strdup ("x");
- fixed->y_prop = g_strdup ("y");
- fixed->width_prop = g_strdup ("width");
- fixed->height_prop = g_strdup ("height");
- fixed->can_resize = TRUE;
+ /* Set defaults */
+ fixed->x_prop = g_strdup ("x");
+ fixed->y_prop = g_strdup ("y");
+ fixed->width_prop = g_strdup ("width");
+ fixed->height_prop = g_strdup ("height");
+ fixed->can_resize = TRUE;
}
static void
-glade_fixed_class_init (GladeFixedClass *fixed_class)
+glade_fixed_class_init (GladeFixedClass * fixed_class)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (fixed_class);
- GladeWidgetClass *gwidget_class = GLADE_WIDGET_CLASS (fixed_class);
-
- parent_class =
- G_OBJECT_CLASS
- (g_type_class_peek_parent (gobject_class));
-
- gobject_class->finalize = glade_fixed_finalize;
- gobject_class->set_property = glade_fixed_set_property;
- gobject_class->get_property = glade_fixed_get_property;
-
- gwidget_class->event = glade_fixed_event;
- gwidget_class->add_child = glade_fixed_add_child_impl;
- gwidget_class->remove_child = glade_fixed_remove_child_impl;
- gwidget_class->replace_child = glade_fixed_replace_child_impl;
-
- fixed_class->configure_child = glade_fixed_configure_child_impl;
- fixed_class->configure_begin = NULL;
- fixed_class->configure_end = glade_fixed_configure_end_impl;
- fixed_class->child_event = glade_fixed_child_event;
-
- /* Properties */
- g_object_class_install_property
- (gobject_class, PROP_X_PROP,
- g_param_spec_string
- ("x_prop", _("X position property"),
- _("The property used to set the X position of a child object"),
- "x", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (gobject_class, PROP_Y_PROP,
- g_param_spec_string
- ("y_prop", _("Y position property"),
- _("The property used to set the Y position of a child object"),
- "y", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (gobject_class, PROP_WIDTH_PROP,
- g_param_spec_string
- ("width_prop", _("Width property"),
- _("The property used to set the width of a child object"),
- "width-request", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (gobject_class, PROP_HEIGHT_PROP,
- g_param_spec_string
- ("height_prop", _("Height property"),
- _("The property used to set the height of a child object"),
- "height-request", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (gobject_class, PROP_CAN_RESIZE,
- g_param_spec_boolean
- ("can_resize", _("Can resize"),
- _("Whether this container supports resizes of child widgets"),
- TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /**
+ GObjectClass *gobject_class = G_OBJECT_CLASS (fixed_class);
+ GladeWidgetClass *gwidget_class = GLADE_WIDGET_CLASS (fixed_class);
+
+ parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (gobject_class));
+
+ gobject_class->finalize = glade_fixed_finalize;
+ gobject_class->set_property = glade_fixed_set_property;
+ gobject_class->get_property = glade_fixed_get_property;
+
+ gwidget_class->event = glade_fixed_event;
+ gwidget_class->add_child = glade_fixed_add_child_impl;
+ gwidget_class->remove_child = glade_fixed_remove_child_impl;
+ gwidget_class->replace_child = glade_fixed_replace_child_impl;
+
+ fixed_class->configure_child = glade_fixed_configure_child_impl;
+ fixed_class->configure_begin = NULL;
+ fixed_class->configure_end = glade_fixed_configure_end_impl;
+ fixed_class->child_event = glade_fixed_child_event;
+
+ /* Properties */
+ g_object_class_install_property
+ (gobject_class, PROP_X_PROP,
+ g_param_spec_string
+ ("x_prop", _("X position property"),
+ _("The property used to set the X position of a child object"),
+ "x", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (gobject_class, PROP_Y_PROP,
+ g_param_spec_string
+ ("y_prop", _("Y position property"),
+ _("The property used to set the Y position of a child object"),
+ "y", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (gobject_class, PROP_WIDTH_PROP,
+ g_param_spec_string
+ ("width_prop", _("Width property"),
+ _("The property used to set the width of a child object"),
+ "width-request", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (gobject_class, PROP_HEIGHT_PROP,
+ g_param_spec_string
+ ("height_prop", _("Height property"),
+ _("The property used to set the height of a child object"),
+ "height-request", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (gobject_class, PROP_CAN_RESIZE,
+ g_param_spec_boolean
+ ("can_resize", _("Can resize"),
+ _("Whether this container supports resizes of child widgets"),
+ TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ /**
* GladeFixed::configure-child:
* @gladewidget: the #GladeFixed which received the signal.
* @arg1: the child #GladeWidget
@@ -1022,17 +1023,17 @@ glade_fixed_class_init (GladeFixedClass *fixed_class)
* Returns: %TRUE means you have handled the event and cancels the
* default handler from being triggered.
*/
- glade_fixed_signals[CONFIGURE_CHILD] =
- g_signal_new ("configure-child",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET
- (GladeFixedClass, configure_child),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__OBJECT_POINTER,
- G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_POINTER);
-
- /**
+ glade_fixed_signals[CONFIGURE_CHILD] =
+ g_signal_new ("configure-child",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET
+ (GladeFixedClass, configure_child),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__OBJECT_POINTER,
+ G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_POINTER);
+
+ /**
* GladeFixed::configure-begin:
* @gladewidget: the #GladeFixed which received the signal.
* @arg1: the child #GladeWidget
@@ -1042,17 +1043,17 @@ glade_fixed_class_init (GladeFixedClass *fixed_class)
* Returns: %TRUE means you have handled the event and cancels the
* default handler from being triggered.
*/
- glade_fixed_signals[CONFIGURE_BEGIN] =
- g_signal_new ("configure-begin",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET
- (GladeFixedClass, configure_begin),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
-
- /**
+ glade_fixed_signals[CONFIGURE_BEGIN] =
+ g_signal_new ("configure-begin",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET
+ (GladeFixedClass, configure_begin),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
+
+ /**
* GladeFixed::configure-end:
* @gladewidget: the #GladeFixed which received the signal.
* @arg1: the child #GladeWidget
@@ -1062,15 +1063,15 @@ glade_fixed_class_init (GladeFixedClass *fixed_class)
* Returns: %TRUE means you have handled the event and cancels the
* default handler from being triggered.
*/
- glade_fixed_signals[CONFIGURE_END] =
- g_signal_new ("configure-end",
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET
- (GladeFixedClass, configure_end),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__OBJECT,
- G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
+ glade_fixed_signals[CONFIGURE_END] =
+ g_signal_new ("configure-end",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET
+ (GladeFixedClass, configure_end),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT);
}
@@ -1081,26 +1082,24 @@ glade_fixed_class_init (GladeFixedClass *fixed_class)
GType
glade_fixed_get_type (void)
{
- static GType fixed_type = 0;
-
- if (!fixed_type)
- {
- static const GTypeInfo fixed_info =
- {
- sizeof (GladeFixedClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) glade_fixed_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (GladeFixed),
- 0, /* n_preallocs */
- (GInstanceInitFunc) glade_fixed_init,
- };
- fixed_type =
- g_type_register_static (GLADE_TYPE_WIDGET,
- "GladeFixed",
- &fixed_info, 0);
- }
- return fixed_type;
+ static GType fixed_type = 0;
+
+ if (!fixed_type)
+ {
+ static const GTypeInfo fixed_info = {
+ sizeof (GladeFixedClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) glade_fixed_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (GladeFixed),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) glade_fixed_init,
+ };
+ fixed_type =
+ g_type_register_static (GLADE_TYPE_WIDGET,
+ "GladeFixed", &fixed_info, 0);
+ }
+ return fixed_type;
}
diff --git a/gladeui/glade-fixed.h b/gladeui/glade-fixed.h
index a1b2f2e..1653346 100644
--- a/gladeui/glade-fixed.h
+++ b/gladeui/glade-fixed.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_FIXED_H__
#define __GLADE_FIXED_H__
diff --git a/gladeui/glade-id-allocator.c b/gladeui/glade-id-allocator.c
index b208cd4..b125e89 100644
--- a/gladeui/glade-id-allocator.c
+++ b/gladeui/glade-id-allocator.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2004 Owen Taylor
*
@@ -33,8 +32,8 @@
struct _GladeIDAllocator
{
- guint n_words;
- guint32 *data;
+ guint n_words;
+ guint32 *data;
};
/**
@@ -45,14 +44,14 @@ struct _GladeIDAllocator
GladeIDAllocator *
glade_id_allocator_new (void)
{
- GladeIDAllocator *allocator = g_slice_new (GladeIDAllocator);
-
- allocator->n_words = INITIAL_WORDS;
- allocator->data = g_new (guint32, INITIAL_WORDS);
-
- memset (allocator->data, 0xff, INITIAL_WORDS * sizeof (guint32));
-
- return allocator;
+ GladeIDAllocator *allocator = g_slice_new (GladeIDAllocator);
+
+ allocator->n_words = INITIAL_WORDS;
+ allocator->data = g_new (guint32, INITIAL_WORDS);
+
+ memset (allocator->data, 0xff, INITIAL_WORDS * sizeof (guint32));
+
+ return allocator;
}
/**
@@ -62,45 +61,45 @@ glade_id_allocator_new (void)
* Frees @allocator and its associated memory
*/
void
-glade_id_allocator_destroy (GladeIDAllocator *allocator)
+glade_id_allocator_destroy (GladeIDAllocator * allocator)
{
- g_return_if_fail (allocator != NULL);
+ g_return_if_fail (allocator != NULL);
- g_free (allocator->data);
- g_slice_free (GladeIDAllocator, allocator);
+ g_free (allocator->data);
+ g_slice_free (GladeIDAllocator, allocator);
}
static inline gint
first_set_bit (guint32 word)
{
- static const char table[16] = {
- 4, 0, 1, 0,
- 2, 0, 1, 0,
- 3, 0, 1, 0,
- 2, 0, 1, 0
- };
-
- gint result = 0;
-
- if ((word & 0xffff) == 0)
- {
- word >>= 16;
- result += 16;
- }
-
- if ((word & 0xff) == 0)
- {
- word >>= 8;
- result += 8;
- }
-
- if ((word & 0xf) == 0)
- {
- word >>= 4;
- result += 4;
- }
-
- return result + table[word & 0xf];
+ static const char table[16] = {
+ 4, 0, 1, 0,
+ 2, 0, 1, 0,
+ 3, 0, 1, 0,
+ 2, 0, 1, 0
+ };
+
+ gint result = 0;
+
+ if ((word & 0xffff) == 0)
+ {
+ word >>= 16;
+ result += 16;
+ }
+
+ if ((word & 0xff) == 0)
+ {
+ word >>= 8;
+ result += 8;
+ }
+
+ if ((word & 0xf) == 0)
+ {
+ word >>= 4;
+ result += 4;
+ }
+
+ return result + table[word & 0xf];
}
/**
@@ -111,34 +110,34 @@ first_set_bit (guint32 word)
* Returns:
*/
guint
-glade_id_allocator_allocate (GladeIDAllocator *allocator)
+glade_id_allocator_allocate (GladeIDAllocator * allocator)
{
- guint i;
-
- g_return_val_if_fail (allocator != NULL, 0);
-
- for (i = 0; i < allocator->n_words; i++)
- {
- if (allocator->data[i] != 0)
- {
- gint free_bit = first_set_bit (allocator->data[i]);
- allocator->data[i] &= ~(1 << free_bit);
-
- return 32 * i + free_bit + 1;
- }
- }
-
- {
- guint n_words = allocator->n_words;
-
- allocator->data = g_renew (guint32, allocator->data, n_words * 2);
- memset (&allocator->data[n_words], 0xff, n_words * sizeof (guint32));
- allocator->n_words = n_words * 2;
-
- allocator->data[n_words] = 0xffffffff - 1;
-
- return 32 * n_words + 1;
- }
+ guint i;
+
+ g_return_val_if_fail (allocator != NULL, 0);
+
+ for (i = 0; i < allocator->n_words; i++)
+ {
+ if (allocator->data[i] != 0)
+ {
+ gint free_bit = first_set_bit (allocator->data[i]);
+ allocator->data[i] &= ~(1 << free_bit);
+
+ return 32 * i + free_bit + 1;
+ }
+ }
+
+ {
+ guint n_words = allocator->n_words;
+
+ allocator->data = g_renew (guint32, allocator->data, n_words * 2);
+ memset (&allocator->data[n_words], 0xff, n_words * sizeof (guint32));
+ allocator->n_words = n_words * 2;
+
+ allocator->data[n_words] = 0xffffffff - 1;
+
+ return 32 * n_words + 1;
+ }
}
/**
@@ -149,42 +148,42 @@ glade_id_allocator_allocate (GladeIDAllocator *allocator)
* TODO: write me
*/
void
-glade_id_allocator_release (GladeIDAllocator *allocator,
- guint id)
+glade_id_allocator_release (GladeIDAllocator * allocator, guint id)
{
- g_return_if_fail (allocator != NULL);
+ g_return_if_fail (allocator != NULL);
- id = id > 0 ? id - 1 : 0;
- allocator->data[id >> 5] |= 1 << (id & 31);
+ id = id > 0 ? id - 1 : 0;
+ allocator->data[id >> 5] |= 1 << (id & 31);
}
#ifdef GLADE_ID_ALLOCATOR_TEST
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- GladeIDAllocator *allocator = glade_id_allocator_new ();
- guint i;
- guint iter;
-
- for (i = 0; i < 1000; i++)
- {
- guint id = glade_id_allocator_allocate (allocator);
- g_assert (id == i);
- }
-
- for (i = 0; i < 1000; i++)
- glade_id_allocator_release (allocator, i);
-
- for (iter = 0; iter < 10000; iter++)
- {
- for (i = 0; i < 1000; i++)
- glade_id_allocator_alloc (allocator);
-
- for (i = 0; i < 1000; i++)
- glade_id_allocator_release (allocator, i);
- }
-
- glade_id_allocator_destroy (allocator);
-
- return 0;
+ GladeIDAllocator *allocator = glade_id_allocator_new ();
+ guint i;
+ guint iter;
+
+ for (i = 0; i < 1000; i++)
+ {
+ guint id = glade_id_allocator_allocate (allocator);
+ g_assert (id == i);
+ }
+
+ for (i = 0; i < 1000; i++)
+ glade_id_allocator_release (allocator, i);
+
+ for (iter = 0; iter < 10000; iter++)
+ {
+ for (i = 0; i < 1000; i++)
+ glade_id_allocator_alloc (allocator);
+
+ for (i = 0; i < 1000; i++)
+ glade_id_allocator_release (allocator, i);
+ }
+
+ glade_id_allocator_destroy (allocator);
+
+ return 0;
}
#endif
diff --git a/gladeui/glade-id-allocator.h b/gladeui/glade-id-allocator.h
index f842fdb..3326f5d 100644
--- a/gladeui/glade-id-allocator.h
+++ b/gladeui/glade-id-allocator.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2004 Owen Taylor
*
diff --git a/gladeui/glade-inspector.c b/gladeui/glade-inspector.c
index 1c94d42..70d6ee2 100644
--- a/gladeui/glade-inspector.c
+++ b/gladeui/glade-inspector.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-inspector.h
*
@@ -59,732 +58,714 @@
enum
{
- PROP_0,
- PROP_PROJECT
+ PROP_0,
+ PROP_PROJECT
};
enum
{
- SELECTION_CHANGED,
- ITEM_ACTIVATED,
- LAST_SIGNAL
-};
+ SELECTION_CHANGED,
+ ITEM_ACTIVATED,
+ LAST_SIGNAL
+};
struct _GladeInspectorPrivate
{
- GtkWidget *view;
- GtkTreeModel *filter;
+ GtkWidget *view;
+ GtkTreeModel *filter;
- GladeProject *project;
+ GladeProject *project;
- GtkWidget *entry;
- GCompletion * completion;
- guint idle_complete;
- gboolean search_disabled;
+ GtkWidget *entry;
+ GCompletion *completion;
+ guint idle_complete;
+ gboolean search_disabled;
};
-static guint glade_inspector_signals[LAST_SIGNAL] = {0};
+static guint glade_inspector_signals[LAST_SIGNAL] = { 0 };
-static void glade_inspector_dispose (GObject *object);
-static void glade_inspector_finalize (GObject *object);
-static void add_columns (GtkTreeView *inspector);
-static void item_activated_cb (GtkTreeView *view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GladeInspector *inspector);
-static void selection_changed_cb (GtkTreeSelection *selection,
- GladeInspector *inspector);
-static gint button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- GladeInspector *inspector);
+static void glade_inspector_dispose (GObject * object);
+static void glade_inspector_finalize (GObject * object);
+static void add_columns (GtkTreeView * inspector);
+static void item_activated_cb (GtkTreeView * view,
+ GtkTreePath * path,
+ GtkTreeViewColumn * column,
+ GladeInspector * inspector);
+static void selection_changed_cb (GtkTreeSelection * selection,
+ GladeInspector * inspector);
+static gint button_press_cb (GtkWidget * widget,
+ GdkEventButton * event,
+ GladeInspector * inspector);
G_DEFINE_TYPE (GladeInspector, glade_inspector, GTK_TYPE_VBOX)
-
-
-static void
-glade_inspector_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ static void
+ glade_inspector_set_property (GObject * object,
+ guint property_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeInspector *inspector = GLADE_INSPECTOR (object);
+ GladeInspector *inspector = GLADE_INSPECTOR (object);
- switch (property_id)
- {
- case PROP_PROJECT:
- glade_inspector_set_project (inspector, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ switch (property_id)
+ {
+ case PROP_PROJECT:
+ glade_inspector_set_project (inspector, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-glade_inspector_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+glade_inspector_get_property (GObject * object,
+ guint property_id,
+ GValue * value, GParamSpec * pspec)
{
- GladeInspector *inspector = GLADE_INSPECTOR (object);
+ GladeInspector *inspector = GLADE_INSPECTOR (object);
- switch (property_id)
- {
- case PROP_PROJECT:
- g_value_set_object (value, glade_inspector_get_project (inspector));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
+ switch (property_id)
+ {
+ case PROP_PROJECT:
+ g_value_set_object (value, glade_inspector_get_project (inspector));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
}
static void
-glade_inspector_class_init (GladeInspectorClass *klass)
+glade_inspector_class_init (GladeInspectorClass * klass)
{
- GObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = glade_inspector_dispose;
- object_class->finalize = glade_inspector_finalize;
- object_class->set_property = glade_inspector_set_property;
- object_class->get_property = glade_inspector_get_property;
+ object_class = G_OBJECT_CLASS (klass);
- /**
+ object_class->dispose = glade_inspector_dispose;
+ object_class->finalize = glade_inspector_finalize;
+ object_class->set_property = glade_inspector_set_property;
+ object_class->get_property = glade_inspector_get_property;
+
+ /**
* GladeInspector::selection-changed:
* @inspector: the object which received the signal
*
* Emitted when the selection changes in the GladeInspector.
*/
- glade_inspector_signals[SELECTION_CHANGED] =
- g_signal_new ("selection-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeInspectorClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
+ glade_inspector_signals[SELECTION_CHANGED] =
+ g_signal_new ("selection-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeInspectorClass, selection_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ /**
* GladeInspector::item-activated:
* @inspector: the object which received the signal
*
* Emitted when a item is activated in the GladeInspector.
*/
- glade_inspector_signals[ITEM_ACTIVATED] =
- g_signal_new ("item-activated",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeInspectorClass, item_activated),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_PROJECT,
- g_param_spec_object ("project",
- _("Project"),
- _("The project being inspected"),
- GLADE_TYPE_PROJECT,
- G_PARAM_READABLE | G_PARAM_WRITABLE));
-
- g_type_class_add_private (klass, sizeof (GladeInspectorPrivate));
+ glade_inspector_signals[ITEM_ACTIVATED] =
+ g_signal_new ("item-activated",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeInspectorClass, item_activated),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ g_object_class_install_property (object_class,
+ PROP_PROJECT,
+ g_param_spec_object ("project",
+ _("Project"),
+ _
+ ("The project being inspected"),
+ GLADE_TYPE_PROJECT,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
+ g_type_class_add_private (klass, sizeof (GladeInspectorPrivate));
}
static gboolean
-find_in_string_insensitive (const gchar *_haystack,
- const gchar *_needle)
+find_in_string_insensitive (const gchar * _haystack, const gchar * _needle)
{
- gboolean visible;
- gchar *haystack = g_utf8_casefold (_haystack, -1);
- gchar *needle = g_utf8_casefold (_needle, -1);
+ gboolean visible;
+ gchar *haystack = g_utf8_casefold (_haystack, -1);
+ gchar *needle = g_utf8_casefold (_needle, -1);
- visible = strstr (haystack, needle) != NULL;
+ visible = strstr (haystack, needle) != NULL;
- g_free (haystack);
- g_free (needle);
+ g_free (haystack);
+ g_free (needle);
- return visible;
+ return visible;
}
static gboolean
-glade_inspector_visible_func (GtkTreeModel* model,
- GtkTreeIter* parent,
- gpointer data)
-{
- GladeInspector* inspector = data;
- GladeInspectorPrivate *priv = inspector->priv;
-
- GtkTreeIter iter;
-
- gboolean retval = FALSE;
-
- if (priv->search_disabled)
- return TRUE;
-
- if (gtk_tree_model_iter_children (model, &iter, parent))
- {
- do
- {
- retval = glade_inspector_visible_func (model, &iter, data);
- }
- while (gtk_tree_model_iter_next (model, &iter) && !retval);
- }
- if (!retval)
- {
- const gchar* text = gtk_entry_get_text (GTK_ENTRY(priv->entry));
- gchar* widget_name;
-
- gtk_tree_model_get (model, parent, GLADE_PROJECT_MODEL_COLUMN_NAME,
- &widget_name, -1);
-
- retval = find_in_string_insensitive (widget_name, text);
-
- g_free (widget_name);
- }
-
- return retval;
+glade_inspector_visible_func (GtkTreeModel * model,
+ GtkTreeIter * parent, gpointer data)
+{
+ GladeInspector *inspector = data;
+ GladeInspectorPrivate *priv = inspector->priv;
+
+ GtkTreeIter iter;
+
+ gboolean retval = FALSE;
+
+ if (priv->search_disabled)
+ return TRUE;
+
+ if (gtk_tree_model_iter_children (model, &iter, parent))
+ {
+ do
+ {
+ retval = glade_inspector_visible_func (model, &iter, data);
+ }
+ while (gtk_tree_model_iter_next (model, &iter) && !retval);
+ }
+ if (!retval)
+ {
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ gchar *widget_name;
+
+ gtk_tree_model_get (model, parent, GLADE_PROJECT_MODEL_COLUMN_NAME,
+ &widget_name, -1);
+
+ retval = find_in_string_insensitive (widget_name, text);
+
+ g_free (widget_name);
+ }
+
+ return retval;
}
static void
-glade_inspector_filter (GladeInspector* inspector)
+glade_inspector_filter (GladeInspector * inspector)
{
- GladeInspectorPrivate *priv = inspector->priv;
+ GladeInspectorPrivate *priv = inspector->priv;
+
+ if (!priv->search_disabled)
+ {
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter));
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (priv->view));
+ }
- if (!priv->search_disabled)
- {
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER(priv->filter));
- gtk_tree_view_expand_all (GTK_TREE_VIEW (priv->view));
- }
-
}
static void
-search_entry_changed_cb (GtkEntry *entry,
- GladeInspector *inspector)
+search_entry_changed_cb (GtkEntry * entry, GladeInspector * inspector)
{
- glade_inspector_filter (inspector);
+ glade_inspector_filter (inspector);
}
static gboolean
-search_complete_idle (GladeInspector *inspector)
+search_complete_idle (GladeInspector * inspector)
{
- GladeInspectorPrivate *priv = inspector->priv;
- const gchar *str;
- gchar *completed = NULL;
- GList *list;
- gsize length;
+ GladeInspectorPrivate *priv = inspector->priv;
+ const gchar *str;
+ gchar *completed = NULL;
+ GList *list;
+ gsize length;
- str = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ str = gtk_entry_get_text (GTK_ENTRY (priv->entry));
- list = g_completion_complete (priv->completion, str, &completed);
- if (completed) {
- length = strlen (str);
+ list = g_completion_complete (priv->completion, str, &completed);
+ if (completed)
+ {
+ length = strlen (str);
- gtk_entry_set_text (GTK_ENTRY (priv->entry), completed);
- gtk_editable_set_position (GTK_EDITABLE (priv->entry), length);
- gtk_editable_select_region (GTK_EDITABLE (priv->entry),
- length, -1);
- g_free (completed);
- }
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), completed);
+ gtk_editable_set_position (GTK_EDITABLE (priv->entry), length);
+ gtk_editable_select_region (GTK_EDITABLE (priv->entry), length, -1);
+ g_free (completed);
+ }
- priv->idle_complete = 0;
+ priv->idle_complete = 0;
- return FALSE;
+ return FALSE;
}
static void
-search_entry_text_inserted_cb (GtkEntry *entry,
- const gchar *text,
- gint length,
- gint *position,
- GladeInspector *inspector)
+search_entry_text_inserted_cb (GtkEntry * entry,
+ const gchar * text,
+ gint length,
+ gint * position, GladeInspector * inspector)
{
- GladeInspectorPrivate *priv = inspector->priv;
+ GladeInspectorPrivate *priv = inspector->priv;
- if (!priv->search_disabled && !priv->idle_complete) {
- priv->idle_complete =
- g_idle_add ((GSourceFunc) search_complete_idle,
- inspector);
- }
+ if (!priv->search_disabled && !priv->idle_complete)
+ {
+ priv->idle_complete =
+ g_idle_add ((GSourceFunc) search_complete_idle, inspector);
+ }
}
static gboolean
-search_entry_key_press_event_cb (GtkEntry *entry,
- GdkEventKey *event,
- GladeInspector *inspector)
-{
- GladeInspectorPrivate *priv = inspector->priv;
- const gchar *str;
-
- if (event->keyval == GDK_KEY_Tab)
- {
- if (event->state & GDK_CONTROL_MASK)
- {
- gtk_widget_grab_focus (priv->view);
- }
- else
- {
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
- gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
- }
- return TRUE;
- }
-
- if (event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter)
- {
- GladeWidget *widget;
- GList *list;
-
- str = gtk_entry_get_text (GTK_ENTRY (priv->entry));
-
- if (str && (list = g_completion_complete (priv->completion, str, NULL)) != NULL)
- {
- widget = glade_widget_get_from_gobject (list->data);
-
- gtk_entry_set_text (GTK_ENTRY (entry), widget->name);
-
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
- gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
- }
- return TRUE;
+search_entry_key_press_event_cb (GtkEntry * entry,
+ GdkEventKey * event,
+ GladeInspector * inspector)
+{
+ GladeInspectorPrivate *priv = inspector->priv;
+ const gchar *str;
+
+ if (event->keyval == GDK_KEY_Tab)
+ {
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ gtk_widget_grab_focus (priv->view);
+ }
+ else
+ {
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
+ }
+ return TRUE;
+ }
+
+ if (event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter)
+ {
+ GladeWidget *widget;
+ GList *list;
+
+ str = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+
+ if (str &&
+ (list = g_completion_complete (priv->completion, str, NULL)) != NULL)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
+
+ gtk_entry_set_text (GTK_ENTRY (entry), widget->name);
+
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
}
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
-widget_font_desc_set_style (GtkWidget *widget, PangoStyle style)
+widget_font_desc_set_style (GtkWidget * widget, PangoStyle style)
{
- PangoFontDescription *font_desc = pango_font_description_copy (gtk_widget_get_style (widget)->font_desc);
-
- pango_font_description_set_style (font_desc, style);
- gtk_widget_modify_font (widget, font_desc);
- pango_font_description_free (font_desc);
+ PangoFontDescription *font_desc =
+ pango_font_description_copy (gtk_widget_get_style (widget)->font_desc);
+
+ pango_font_description_set_style (font_desc, style);
+ gtk_widget_modify_font (widget, font_desc);
+ pango_font_description_free (font_desc);
}
static const gchar *
-search_complete_func (GObject *object)
+search_complete_func (GObject * object)
{
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- g_assert (widget);
- return glade_widget_get_name (widget);
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ g_assert (widget);
+ return glade_widget_get_name (widget);
}
static void
-search_entry_update (GladeInspector *inspector)
+search_entry_update (GladeInspector * inspector)
{
- GladeInspectorPrivate *priv = inspector->priv;
- const gchar *str = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ GladeInspectorPrivate *priv = inspector->priv;
+ const gchar *str = gtk_entry_get_text (GTK_ENTRY (priv->entry));
- if (str[0] == '\0')
- {
- priv->search_disabled = TRUE;
- widget_font_desc_set_style (priv->entry, PANGO_STYLE_ITALIC);
- gtk_entry_set_text (GTK_ENTRY (priv->entry), _("< search widgets >"));
- gtk_widget_modify_text (priv->entry, GTK_STATE_NORMAL,
- >k_widget_get_style (priv->entry)->text[GTK_STATE_INSENSITIVE]);
- }
+ if (str[0] == '\0')
+ {
+ priv->search_disabled = TRUE;
+ widget_font_desc_set_style (priv->entry, PANGO_STYLE_ITALIC);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), _("< search widgets >"));
+ gtk_widget_modify_text (priv->entry, GTK_STATE_NORMAL,
+ >k_widget_get_style (priv->entry)->
+ text[GTK_STATE_INSENSITIVE]);
+ }
}
static gboolean
-search_entry_focus_in_cb (GtkWidget *entry,
- GdkEventFocus *event,
- GladeInspector *inspector)
+search_entry_focus_in_cb (GtkWidget * entry,
+ GdkEventFocus * event, GladeInspector * inspector)
{
- GladeInspectorPrivate *priv = inspector->priv;
+ GladeInspectorPrivate *priv = inspector->priv;
- if (priv->search_disabled)
- {
- gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
- gtk_widget_modify_text (priv->entry, GTK_STATE_NORMAL, NULL);
- gtk_widget_modify_font (priv->entry, NULL);
- priv->search_disabled = FALSE;
- }
-
- return FALSE;
+ if (priv->search_disabled)
+ {
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
+ gtk_widget_modify_text (priv->entry, GTK_STATE_NORMAL, NULL);
+ gtk_widget_modify_font (priv->entry, NULL);
+ priv->search_disabled = FALSE;
+ }
+
+ return FALSE;
}
static gboolean
-search_entry_focus_out_cb (GtkWidget *entry,
- GdkEventFocus *event,
- GladeInspector *inspector)
+search_entry_focus_out_cb (GtkWidget * entry,
+ GdkEventFocus * event, GladeInspector * inspector)
{
- search_entry_update (inspector);
-
- return FALSE;
+ search_entry_update (inspector);
+
+ return FALSE;
}
static void
-glade_inspector_init (GladeInspector *inspector)
+glade_inspector_init (GladeInspector * inspector)
{
- GladeInspectorPrivate *priv;
- GtkWidget *sw;
- GtkTreeSelection *selection;
-
- inspector->priv = priv = GLADE_INSPECTOR_GET_PRIVATE (inspector);
+ GladeInspectorPrivate *priv;
+ GtkWidget *sw;
+ GtkTreeSelection *selection;
+
+ inspector->priv = priv = GLADE_INSPECTOR_GET_PRIVATE (inspector);
+
+ gtk_widget_push_composite_child ();
+
+ priv->project = NULL;
- gtk_widget_push_composite_child ();
-
- priv->project = NULL;
+ priv->entry = gtk_entry_new ();
- priv->entry = gtk_entry_new ();
-
- search_entry_update (inspector);
- gtk_widget_show (priv->entry);
- gtk_box_pack_start (GTK_BOX (inspector), priv->entry, FALSE, FALSE, 2);
+ search_entry_update (inspector);
+ gtk_widget_show (priv->entry);
+ gtk_box_pack_start (GTK_BOX (inspector), priv->entry, FALSE, FALSE, 2);
- g_signal_connect (priv->entry, "changed",
- G_CALLBACK (search_entry_changed_cb),
- inspector);
+ g_signal_connect (priv->entry, "changed",
+ G_CALLBACK (search_entry_changed_cb), inspector);
- g_signal_connect (priv->entry, "key-press-event",
- G_CALLBACK (search_entry_key_press_event_cb),
- inspector);
+ g_signal_connect (priv->entry, "key-press-event",
+ G_CALLBACK (search_entry_key_press_event_cb), inspector);
- g_signal_connect_after (priv->entry, "insert-text",
- G_CALLBACK (search_entry_text_inserted_cb),
- inspector);
+ g_signal_connect_after (priv->entry, "insert-text",
+ G_CALLBACK (search_entry_text_inserted_cb),
+ inspector);
- g_signal_connect (priv->entry, "focus-in-event",
- G_CALLBACK (search_entry_focus_in_cb),
- inspector);
+ g_signal_connect (priv->entry, "focus-in-event",
+ G_CALLBACK (search_entry_focus_in_cb), inspector);
- g_signal_connect (priv->entry, "focus-out-event",
- G_CALLBACK (search_entry_focus_out_cb),
- inspector);
+ g_signal_connect (priv->entry, "focus-out-event",
+ G_CALLBACK (search_entry_focus_out_cb), inspector);
- priv->completion = g_completion_new ((GCompletionFunc) search_complete_func);
+ priv->completion = g_completion_new ((GCompletionFunc) search_complete_func);
- priv->view = gtk_tree_view_new ();
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->view), FALSE);
+ priv->view = gtk_tree_view_new ();
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (priv->view), FALSE);
-
- add_columns (GTK_TREE_VIEW (priv->view));
- g_signal_connect (G_OBJECT (priv->view), "row-activated",
- G_CALLBACK (item_activated_cb), inspector);
+ add_columns (GTK_TREE_VIEW (priv->view));
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->view));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- g_signal_connect (G_OBJECT (selection), "changed",
- G_CALLBACK (selection_changed_cb), inspector);
+ g_signal_connect (G_OBJECT (priv->view), "row-activated",
+ G_CALLBACK (item_activated_cb), inspector);
- /* popup menu */
- g_signal_connect (G_OBJECT (priv->view), "button-press-event",
- G_CALLBACK (button_press_cb), inspector);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->view));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (selection_changed_cb), inspector);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (sw), priv->view);
- gtk_box_pack_start (GTK_BOX (inspector), sw, TRUE, TRUE, 0);
-
- gtk_widget_show (priv->view);
- gtk_widget_show (sw);
+ /* popup menu */
+ g_signal_connect (G_OBJECT (priv->view), "button-press-event",
+ G_CALLBACK (button_press_cb), inspector);
-
- gtk_widget_pop_composite_child ();
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER (sw), priv->view);
+ gtk_box_pack_start (GTK_BOX (inspector), sw, TRUE, TRUE, 0);
+
+ gtk_widget_show (priv->view);
+ gtk_widget_show (sw);
+
+
+
+ gtk_widget_pop_composite_child ();
}
static void
-glade_inspector_dispose (GObject *object)
+glade_inspector_dispose (GObject * object)
{
- GladeInspector *inspector = GLADE_INSPECTOR(object);
-
- glade_inspector_set_project (inspector, NULL);
+ GladeInspector *inspector = GLADE_INSPECTOR (object);
- G_OBJECT_CLASS (glade_inspector_parent_class)->dispose (object);
+ glade_inspector_set_project (inspector, NULL);
+
+ G_OBJECT_CLASS (glade_inspector_parent_class)->dispose (object);
}
static void
-glade_inspector_finalize (GObject *object)
-{
- G_OBJECT_CLASS (glade_inspector_parent_class)->finalize (object);
+glade_inspector_finalize (GObject * object)
+{
+ G_OBJECT_CLASS (glade_inspector_parent_class)->finalize (object);
}
static void
-project_selection_changed_cb (GladeProject *project,
- GladeInspector *inspector)
-{
- GladeWidget *widget;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter *iter;
- GtkTreePath *path, *ancestor_path;
- GList *list;
-
- g_return_if_fail (GLADE_IS_INSPECTOR (inspector));
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (inspector->priv->project == project);
-
- g_signal_handlers_block_by_func (gtk_tree_view_get_selection (GTK_TREE_VIEW (inspector->priv->view)),
- G_CALLBACK (selection_changed_cb),
- inspector);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (inspector->priv->view));
- g_return_if_fail (selection != NULL);
-
- model = inspector->priv->filter;
-
- gtk_tree_selection_unselect_all (selection);
-
- for (list = glade_project_selection_get (project);
- list && list->data; list = list->next)
- {
- if ((widget = glade_widget_get_from_gobject (G_OBJECT (list->data))) != NULL)
- {
- if ((iter = glade_util_find_iter_by_widget (model, widget, GLADE_PROJECT_MODEL_COLUMN_OBJECT)) != NULL)
- {
- path = gtk_tree_model_get_path (model, iter);
- ancestor_path = gtk_tree_path_copy (path);
-
- /* expand parent node */
- if (gtk_tree_path_up (ancestor_path))
- gtk_tree_view_expand_to_path
- (GTK_TREE_VIEW (inspector->priv->view), ancestor_path);
-
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (inspector->priv->view),
- path,
- NULL,
- TRUE,
- 0.5,
- 0);
-
- gtk_tree_selection_select_iter (selection, iter);
-
- gtk_tree_iter_free (iter);
- gtk_tree_path_free (path);
- gtk_tree_path_free (ancestor_path);
- }
- }
- }
-
- g_signal_handlers_unblock_by_func (gtk_tree_view_get_selection (GTK_TREE_VIEW (inspector->priv->view)),
- G_CALLBACK (selection_changed_cb),
- inspector);
+project_selection_changed_cb (GladeProject * project,
+ GladeInspector * inspector)
+{
+ GladeWidget *widget;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter *iter;
+ GtkTreePath *path, *ancestor_path;
+ GList *list;
+
+ g_return_if_fail (GLADE_IS_INSPECTOR (inspector));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (inspector->priv->project == project);
+
+ g_signal_handlers_block_by_func (gtk_tree_view_get_selection
+ (GTK_TREE_VIEW (inspector->priv->view)),
+ G_CALLBACK (selection_changed_cb),
+ inspector);
+
+ selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (inspector->priv->view));
+ g_return_if_fail (selection != NULL);
+
+ model = inspector->priv->filter;
+
+ gtk_tree_selection_unselect_all (selection);
+
+ for (list = glade_project_selection_get (project);
+ list && list->data; list = list->next)
+ {
+ if ((widget =
+ glade_widget_get_from_gobject (G_OBJECT (list->data))) != NULL)
+ {
+ if ((iter =
+ glade_util_find_iter_by_widget (model, widget,
+ GLADE_PROJECT_MODEL_COLUMN_OBJECT))
+ != NULL)
+ {
+ path = gtk_tree_model_get_path (model, iter);
+ ancestor_path = gtk_tree_path_copy (path);
+
+ /* expand parent node */
+ if (gtk_tree_path_up (ancestor_path))
+ gtk_tree_view_expand_to_path
+ (GTK_TREE_VIEW (inspector->priv->view), ancestor_path);
+
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW
+ (inspector->priv->view), path, NULL,
+ TRUE, 0.5, 0);
+
+ gtk_tree_selection_select_iter (selection, iter);
+
+ gtk_tree_iter_free (iter);
+ gtk_tree_path_free (path);
+ gtk_tree_path_free (ancestor_path);
+ }
+ }
+ }
+
+ g_signal_handlers_unblock_by_func (gtk_tree_view_get_selection
+ (GTK_TREE_VIEW (inspector->priv->view)),
+ G_CALLBACK (selection_changed_cb),
+ inspector);
}
static void
-selection_foreach_func (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- GList **selection)
+selection_foreach_func (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, GList ** selection)
{
- GObject* object;
-
- gtk_tree_model_get (model, iter, GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
+ GObject *object;
+
+ gtk_tree_model_get (model, iter, GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object,
+ -1);
- if (object)
- {
- *selection = g_list_prepend (*selection, object);
- g_object_unref (object);
- }
+ if (object)
+ {
+ *selection = g_list_prepend (*selection, object);
+ g_object_unref (object);
+ }
}
static void
-selection_changed_cb (GtkTreeSelection *selection,
- GladeInspector *inspector)
+selection_changed_cb (GtkTreeSelection * selection, GladeInspector * inspector)
{
- GList *sel = NULL, *l;
+ GList *sel = NULL, *l;
- gtk_tree_selection_selected_foreach (selection,
- (GtkTreeSelectionForeachFunc)selection_foreach_func,
- &sel);
+ gtk_tree_selection_selected_foreach (selection,
+ (GtkTreeSelectionForeachFunc)
+ selection_foreach_func, &sel);
- /* We dont modify the project selection for a change that
- * leaves us with no selection.
- *
- * This is typically because the user is changing the name
- * of a widget and the filter is active, the new name causes
- * the row to go out of the model and the selection to be
- * cleared, if we clear the selection we remove the editor
- * that the user is trying to type into.
- */
- if (!sel)
- return;
+ /* We dont modify the project selection for a change that
+ * leaves us with no selection.
+ *
+ * This is typically because the user is changing the name
+ * of a widget and the filter is active, the new name causes
+ * the row to go out of the model and the selection to be
+ * cleared, if we clear the selection we remove the editor
+ * that the user is trying to type into.
+ */
+ if (!sel)
+ return;
- g_signal_handlers_block_by_func (inspector->priv->project,
- G_CALLBACK (project_selection_changed_cb),
- inspector);
+ g_signal_handlers_block_by_func (inspector->priv->project,
+ G_CALLBACK (project_selection_changed_cb),
+ inspector);
- glade_app_selection_clear (FALSE);
- for (l = sel; l; l = l->next)
- glade_app_selection_add (G_OBJECT (l->data), FALSE);
- glade_app_selection_changed ();
- g_list_free (sel);
+ glade_app_selection_clear (FALSE);
+ for (l = sel; l; l = l->next)
+ glade_app_selection_add (G_OBJECT (l->data), FALSE);
+ glade_app_selection_changed ();
+ g_list_free (sel);
- g_signal_handlers_unblock_by_func (inspector->priv->project,
- G_CALLBACK (project_selection_changed_cb),
- inspector);
+ g_signal_handlers_unblock_by_func (inspector->priv->project,
+ G_CALLBACK (project_selection_changed_cb),
+ inspector);
- g_signal_emit (inspector, glade_inspector_signals[SELECTION_CHANGED], 0);
+ g_signal_emit (inspector, glade_inspector_signals[SELECTION_CHANGED], 0);
}
static void
-item_activated_cb (GtkTreeView *view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GladeInspector *inspector)
-{
- g_signal_emit (inspector, glade_inspector_signals[ITEM_ACTIVATED], 0);
+item_activated_cb (GtkTreeView * view,
+ GtkTreePath * path,
+ GtkTreeViewColumn * column, GladeInspector * inspector)
+{
+ g_signal_emit (inspector, glade_inspector_signals[ITEM_ACTIVATED], 0);
}
static gint
-button_press_cb (GtkWidget *widget,
- GdkEventButton *event,
- GladeInspector *inspector)
-{
- GtkTreeView *view = GTK_TREE_VIEW (widget);
- GladeInspectorPrivate *priv = inspector->priv;
- GtkTreePath *path = NULL;
- gboolean handled = FALSE;
-
- /* Give some kind of access in case of missing right button */
- if (event->window == gtk_tree_view_get_bin_window (view) &&
- glade_popup_is_popup_event (event))
- {
- if (gtk_tree_view_get_path_at_pos (view, (gint) event->x, (gint) event->y,
- &path, NULL,
- NULL, NULL) && path != NULL)
- {
- GtkTreeIter iter;
- GladeWidget *object = NULL;
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->project),
- &iter, path))
- {
- /* now we can obtain the widget from the iter.
- */
- gtk_tree_model_get (GTK_TREE_MODEL (priv->project), &iter,
- GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
-
- if (widget != NULL)
- glade_popup_widget_pop (glade_widget_get_from_gobject (object),
- event, TRUE);
- else
- glade_popup_simple_pop (event);
-
- handled = TRUE;
-
- gtk_tree_path_free (path);
- }
- }
- else
- {
- glade_popup_simple_pop (event);
- handled = TRUE;
- }
- }
- return handled;
+button_press_cb (GtkWidget * widget,
+ GdkEventButton * event, GladeInspector * inspector)
+{
+ GtkTreeView *view = GTK_TREE_VIEW (widget);
+ GladeInspectorPrivate *priv = inspector->priv;
+ GtkTreePath *path = NULL;
+ gboolean handled = FALSE;
+
+ /* Give some kind of access in case of missing right button */
+ if (event->window == gtk_tree_view_get_bin_window (view) &&
+ glade_popup_is_popup_event (event))
+ {
+ if (gtk_tree_view_get_path_at_pos (view, (gint) event->x, (gint) event->y,
+ &path, NULL,
+ NULL, NULL) && path != NULL)
+ {
+ GtkTreeIter iter;
+ GladeWidget *object = NULL;
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->project),
+ &iter, path))
+ {
+ /* now we can obtain the widget from the iter.
+ */
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->project), &iter,
+ GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object,
+ -1);
+
+ if (widget != NULL)
+ glade_popup_widget_pop (glade_widget_get_from_gobject (object),
+ event, TRUE);
+ else
+ glade_popup_simple_pop (event);
+
+ handled = TRUE;
+
+ gtk_tree_path_free (path);
+ }
+ }
+ else
+ {
+ glade_popup_simple_pop (event);
+ handled = TRUE;
+ }
+ }
+ return handled;
}
static void
-add_columns (GtkTreeView *view)
-{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- column = gtk_tree_view_column_new ();
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "icon_name", GLADE_PROJECT_MODEL_COLUMN_ICON_NAME,
- NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "text", GLADE_PROJECT_MODEL_COLUMN_NAME,
- NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer, "style", PANGO_STYLE_ITALIC, NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "text", GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME,
- NULL);
-
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "style", PANGO_STYLE_ITALIC,
- "foreground", "Gray", NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column,
- renderer,
- "text", GLADE_PROJECT_MODEL_COLUMN_MISC,
- NULL);
-
- gtk_tree_view_append_column (view, column);
- gtk_tree_view_set_headers_visible (view, FALSE);
+add_columns (GtkTreeView * view)
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ column = gtk_tree_view_column_new ();
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "icon_name",
+ GLADE_PROJECT_MODEL_COLUMN_ICON_NAME,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "text", GLADE_PROJECT_MODEL_COLUMN_NAME,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (renderer, "style", PANGO_STYLE_ITALIC, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "text",
+ GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME,
+ NULL);
+
+
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer),
+ "style", PANGO_STYLE_ITALIC, "foreground", "Gray", NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column,
+ renderer,
+ "text", GLADE_PROJECT_MODEL_COLUMN_MISC,
+ NULL);
+
+ gtk_tree_view_append_column (view, column);
+ gtk_tree_view_set_headers_visible (view, FALSE);
}
static void
-update_project_completion (GladeProject *project,
- GladeWidget *widget,
- GladeInspector *inspector)
+update_project_completion (GladeProject * project,
+ GladeWidget * widget, GladeInspector * inspector)
{
- GladeInspectorPrivate *priv = inspector->priv;
- const GList* items;
+ GladeInspectorPrivate *priv = inspector->priv;
+ const GList *items;
- g_completion_clear_items (priv->completion);
+ g_completion_clear_items (priv->completion);
- if (!priv->project)
- return;
+ if (!priv->project)
+ return;
- items = glade_project_get_objects (priv->project);
+ items = glade_project_get_objects (priv->project);
- /* GCompletion API should take 'const GList *' */
- g_completion_add_items (priv->completion, (GList *)items);
+ /* GCompletion API should take 'const GList *' */
+ g_completion_add_items (priv->completion, (GList *) items);
}
static void
-disconnect_project_signals (GladeInspector *inspector,
- GladeProject *project)
-{
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (update_project_completion),
- inspector);
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (update_project_completion),
- inspector);
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (update_project_completion),
- inspector);
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (project_selection_changed_cb),
- inspector);
+disconnect_project_signals (GladeInspector * inspector, GladeProject * project)
+{
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK (update_project_completion),
+ inspector);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK (update_project_completion),
+ inspector);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK (update_project_completion),
+ inspector);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK
+ (project_selection_changed_cb),
+ inspector);
}
static void
-connect_project_signals (GladeInspector *inspector,
- GladeProject *project)
-{
- g_signal_connect (G_OBJECT (project), "add-widget",
- G_CALLBACK (update_project_completion),
- inspector);
- g_signal_connect (G_OBJECT (project), "remove-widget",
- G_CALLBACK (update_project_completion),
- inspector);
- g_signal_connect (G_OBJECT (project), "widget-name-changed",
- G_CALLBACK (update_project_completion),
- inspector);
- g_signal_connect (G_OBJECT (project), "selection-changed",
- G_CALLBACK (project_selection_changed_cb),
- inspector);
+connect_project_signals (GladeInspector * inspector, GladeProject * project)
+{
+ g_signal_connect (G_OBJECT (project), "add-widget",
+ G_CALLBACK (update_project_completion), inspector);
+ g_signal_connect (G_OBJECT (project), "remove-widget",
+ G_CALLBACK (update_project_completion), inspector);
+ g_signal_connect (G_OBJECT (project), "widget-name-changed",
+ G_CALLBACK (update_project_completion), inspector);
+ g_signal_connect (G_OBJECT (project), "selection-changed",
+ G_CALLBACK (project_selection_changed_cb), inspector);
}
/**
@@ -796,46 +777,48 @@ connect_project_signals (GladeInspector *inspector,
* project, pass %NULL for @project.
*/
void
-glade_inspector_set_project (GladeInspector *inspector,
- GladeProject *project)
+glade_inspector_set_project (GladeInspector * inspector, GladeProject * project)
{
- g_return_if_fail (GLADE_IS_INSPECTOR (inspector));
- g_return_if_fail (GLADE_IS_PROJECT (project) || project == NULL);
+ g_return_if_fail (GLADE_IS_INSPECTOR (inspector));
+ g_return_if_fail (GLADE_IS_PROJECT (project) || project == NULL);
+
+ GladeInspectorPrivate *priv = inspector->priv;
+
+ if (inspector->priv->project)
+ {
+ disconnect_project_signals (inspector, inspector->priv->project);
+
+ /* Release our filter which releases the project */
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), NULL);
+ priv->filter = NULL;
+ priv->project = NULL;
+ }
- GladeInspectorPrivate* priv = inspector->priv;
+ if (project)
+ {
+ priv->project = project;
- if (inspector->priv->project)
- {
- disconnect_project_signals (inspector, inspector->priv->project);
+ /* The filter holds our reference to 'project' */
+ priv->filter =
+ gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->project), NULL);
- /* Release our filter which releases the project */
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), NULL);
- priv->filter = NULL;
- priv->project = NULL;
- }
-
- if (project)
- {
- priv->project = project;
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER
+ (priv->filter),
+ (GtkTreeModelFilterVisibleFunc)
+ glade_inspector_visible_func,
+ inspector, NULL);
- /* The filter holds our reference to 'project' */
- priv->filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->project), NULL);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), priv->filter);
+ g_object_unref (priv->filter); /* pass ownership of the filter to the model */
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (priv->filter),
- (GtkTreeModelFilterVisibleFunc)glade_inspector_visible_func,
- inspector, NULL);
+ connect_project_signals (inspector, project);
+ }
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->view), priv->filter);
- g_object_unref (priv->filter); /* pass ownership of the filter to the model */
+ update_project_completion (project, NULL, inspector);
- connect_project_signals (inspector, project);
- }
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (inspector->priv->view));
- update_project_completion (project, NULL, inspector);
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (inspector->priv->view));
-
- g_object_notify (G_OBJECT (inspector), "project");
+ g_object_notify (G_OBJECT (inspector), "project");
}
/**
@@ -847,11 +830,11 @@ glade_inspector_set_project (GladeInspector *inspector,
* Returns: A #GladeProject
*/
GladeProject *
-glade_inspector_get_project (GladeInspector *inspector)
+glade_inspector_get_project (GladeInspector * inspector)
{
- g_return_val_if_fail (GLADE_IS_INSPECTOR (inspector), NULL);
+ g_return_val_if_fail (GLADE_IS_INSPECTOR (inspector), NULL);
- return inspector->priv->project;
+ return inspector->priv->project;
}
/**
@@ -863,36 +846,37 @@ glade_inspector_get_project (GladeInspector *inspector)
* Returns: A #GList
*/
GList *
-glade_inspector_get_selected_items (GladeInspector *inspector)
-{
- GtkTreeSelection* selection;
- GList *items = NULL, *paths;
- GladeInspectorPrivate *priv = inspector->priv;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->view));
-
- for (paths = gtk_tree_selection_get_selected_rows (selection, NULL);
- paths != NULL; paths = g_list_next (paths->next))
- {
- GtkTreeIter filter_iter;
- GtkTreeIter iter;
- GtkTreePath *path = (GtkTreePath *) paths->data;
- GObject *object = NULL;
-
- gtk_tree_model_get_iter (priv->filter, &filter_iter, path);
- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(priv->filter),
- &iter, &filter_iter);
- gtk_tree_model_get (GTK_TREE_MODEL (priv->project), &iter,
- GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
-
- g_object_unref (object);
- items = g_list_prepend (items, glade_widget_get_from_gobject (object));
- }
-
- g_list_foreach (paths, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (paths);
-
- return items;
+glade_inspector_get_selected_items (GladeInspector * inspector)
+{
+ GtkTreeSelection *selection;
+ GList *items = NULL, *paths;
+ GladeInspectorPrivate *priv = inspector->priv;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->view));
+
+ for (paths = gtk_tree_selection_get_selected_rows (selection, NULL);
+ paths != NULL; paths = g_list_next (paths->next))
+ {
+ GtkTreeIter filter_iter;
+ GtkTreeIter iter;
+ GtkTreePath *path = (GtkTreePath *) paths->data;
+ GObject *object = NULL;
+
+ gtk_tree_model_get_iter (priv->filter, &filter_iter, path);
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
+ (priv->filter), &iter,
+ &filter_iter);
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->project), &iter,
+ GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
+
+ g_object_unref (object);
+ items = g_list_prepend (items, glade_widget_get_from_gobject (object));
+ }
+
+ g_list_foreach (paths, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (paths);
+
+ return items;
}
/**
@@ -905,7 +889,7 @@ glade_inspector_get_selected_items (GladeInspector *inspector)
GtkWidget *
glade_inspector_new (void)
{
- return g_object_new (GLADE_TYPE_INSPECTOR, NULL);
+ return g_object_new (GLADE_TYPE_INSPECTOR, NULL);
}
/**
@@ -917,19 +901,15 @@ glade_inspector_new (void)
* Returns: a new #GladeInspector
*/
GtkWidget *
-glade_inspector_new_with_project (GladeProject *project)
+glade_inspector_new_with_project (GladeProject * project)
{
- GladeInspector *inspector;
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ GladeInspector *inspector;
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- inspector = g_object_new (GLADE_TYPE_INSPECTOR,
- "project", project,
- NULL);
-
- /* Make sure we expended to the right path */
- project_selection_changed_cb (project, inspector);
-
- return GTK_WIDGET (inspector);
-}
+ inspector = g_object_new (GLADE_TYPE_INSPECTOR, "project", project, NULL);
+ /* Make sure we expended to the right path */
+ project_selection_changed_cb (project, inspector);
+ return GTK_WIDGET (inspector);
+}
diff --git a/gladeui/glade-inspector.h b/gladeui/glade-inspector.h
index 2004b97..dc13fc2 100644
--- a/gladeui/glade-inspector.h
+++ b/gladeui/glade-inspector.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-inspector.h
*
diff --git a/gladeui/glade-name-context.c b/gladeui/glade-name-context.c
index 42b1cc8..ca8d47b 100644
--- a/gladeui/glade-name-context.c
+++ b/gladeui/glade-name-context.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-name-context.c
*
@@ -32,10 +31,11 @@
#include "glade-id-allocator.h"
#include "glade-name-context.h"
-struct _GladeNameContext {
- GHashTable *name_allocators;
+struct _GladeNameContext
+{
+ GHashTable *name_allocators;
- GHashTable *names;
+ GHashTable *names;
};
@@ -43,199 +43,197 @@ struct _GladeNameContext {
GladeNameContext *
glade_name_context_new (void)
{
- GladeNameContext *context = g_new0 (GladeNameContext, 1);
+ GladeNameContext *context = g_new0 (GladeNameContext, 1);
- context->name_allocators = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify) glade_id_allocator_destroy);
+ context->name_allocators = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify)
+ glade_id_allocator_destroy);
- context->names = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
+ context->names = g_hash_table_new_full (g_str_hash,
+ g_str_equal, g_free, NULL);
- return context;
+ return context;
}
void
-glade_name_context_destroy (GladeNameContext *context)
+glade_name_context_destroy (GladeNameContext * context)
{
- g_return_if_fail (context != NULL);
+ g_return_if_fail (context != NULL);
- g_hash_table_destroy (context->name_allocators);
- g_hash_table_destroy (context->names);
- g_free (context);
+ g_hash_table_destroy (context->name_allocators);
+ g_hash_table_destroy (context->names);
+ g_free (context);
}
gchar *
-glade_name_context_new_name (GladeNameContext *context,
- const gchar *base_name)
+glade_name_context_new_name (GladeNameContext * context,
+ const gchar * base_name)
{
- GladeIDAllocator *id_allocator;
- const gchar *number;
- gchar *name = NULL, *freeme = NULL;
- guint i = 1;
-
- g_return_val_if_fail (context != NULL, NULL);
- g_return_val_if_fail (base_name && base_name[0], NULL);
-
- number = base_name + strlen (base_name);
- while (number > base_name && g_ascii_isdigit (number[-1]))
- --number;
-
- if (*number)
- {
- freeme = g_strndup (base_name, number - base_name);
- base_name = freeme;
- }
-
- id_allocator = g_hash_table_lookup (context->name_allocators, base_name);
-
- if (id_allocator == NULL)
- {
- id_allocator = glade_id_allocator_new ();
- g_hash_table_insert (context->name_allocators,
- g_strdup (base_name), id_allocator);
- }
-
- do
- {
- g_free (name);
- i = glade_id_allocator_allocate (id_allocator);
- name = g_strdup_printf ("%s%u", base_name, i);
- }
- while (glade_name_context_has_name (context, name));
-
- g_free (freeme);
- return name;
+ GladeIDAllocator *id_allocator;
+ const gchar *number;
+ gchar *name = NULL, *freeme = NULL;
+ guint i = 1;
+
+ g_return_val_if_fail (context != NULL, NULL);
+ g_return_val_if_fail (base_name && base_name[0], NULL);
+
+ number = base_name + strlen (base_name);
+ while (number > base_name && g_ascii_isdigit (number[-1]))
+ --number;
+
+ if (*number)
+ {
+ freeme = g_strndup (base_name, number - base_name);
+ base_name = freeme;
+ }
+
+ id_allocator = g_hash_table_lookup (context->name_allocators, base_name);
+
+ if (id_allocator == NULL)
+ {
+ id_allocator = glade_id_allocator_new ();
+ g_hash_table_insert (context->name_allocators,
+ g_strdup (base_name), id_allocator);
+ }
+
+ do
+ {
+ g_free (name);
+ i = glade_id_allocator_allocate (id_allocator);
+ name = g_strdup_printf ("%s%u", base_name, i);
+ }
+ while (glade_name_context_has_name (context, name));
+
+ g_free (freeme);
+ return name;
}
gchar *
-glade_name_context_dual_new_name (GladeNameContext *context,
- GladeNameContext *another_context,
- const gchar *base_name)
+glade_name_context_dual_new_name (GladeNameContext * context,
+ GladeNameContext * another_context,
+ const gchar * base_name)
{
- GladeIDAllocator *id_allocator;
- const gchar *number;
- gchar *name = NULL, *freeme = NULL;
- guint i = 1;
-
- g_return_val_if_fail (context != NULL, NULL);
- g_return_val_if_fail (another_context != NULL, NULL);
- g_return_val_if_fail (base_name && base_name[0], NULL);
-
- number = base_name + strlen (base_name);
- while (number > base_name && g_ascii_isdigit (number[-1]))
- --number;
-
- if (*number)
- {
- freeme = g_strndup (base_name, number - base_name);
- base_name = freeme;
- }
-
- id_allocator = g_hash_table_lookup (context->name_allocators, base_name);
-
- if (id_allocator == NULL)
- {
- id_allocator = glade_id_allocator_new ();
- g_hash_table_insert (context->name_allocators,
- g_strdup (base_name), id_allocator);
- }
-
- do
- {
- g_free (name);
- i = glade_id_allocator_allocate (id_allocator);
- name = g_strdup_printf ("%s%u", base_name, i);
- }
- while (glade_name_context_has_name (context, name) ||
- glade_name_context_has_name (another_context, name));
-
- g_free (freeme);
- return name;
+ GladeIDAllocator *id_allocator;
+ const gchar *number;
+ gchar *name = NULL, *freeme = NULL;
+ guint i = 1;
+
+ g_return_val_if_fail (context != NULL, NULL);
+ g_return_val_if_fail (another_context != NULL, NULL);
+ g_return_val_if_fail (base_name && base_name[0], NULL);
+
+ number = base_name + strlen (base_name);
+ while (number > base_name && g_ascii_isdigit (number[-1]))
+ --number;
+
+ if (*number)
+ {
+ freeme = g_strndup (base_name, number - base_name);
+ base_name = freeme;
+ }
+
+ id_allocator = g_hash_table_lookup (context->name_allocators, base_name);
+
+ if (id_allocator == NULL)
+ {
+ id_allocator = glade_id_allocator_new ();
+ g_hash_table_insert (context->name_allocators,
+ g_strdup (base_name), id_allocator);
+ }
+
+ do
+ {
+ g_free (name);
+ i = glade_id_allocator_allocate (id_allocator);
+ name = g_strdup_printf ("%s%u", base_name, i);
+ }
+ while (glade_name_context_has_name (context, name) ||
+ glade_name_context_has_name (another_context, name));
+
+ g_free (freeme);
+ return name;
}
guint
-glade_name_context_n_names (GladeNameContext *context)
+glade_name_context_n_names (GladeNameContext * context)
{
- g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (context != NULL, FALSE);
- return g_hash_table_size (context->names);
+ return g_hash_table_size (context->names);
}
gboolean
-glade_name_context_has_name (GladeNameContext *context,
- const gchar *name)
+glade_name_context_has_name (GladeNameContext * context, const gchar * name)
{
- g_return_val_if_fail (context != NULL, FALSE);
- g_return_val_if_fail (name && name[0], FALSE);
+ g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (name && name[0], FALSE);
- return (g_hash_table_lookup (context->names, name) != NULL);
+ return (g_hash_table_lookup (context->names, name) != NULL);
}
gboolean
-glade_name_context_add_name (GladeNameContext *context,
- const gchar *name)
+glade_name_context_add_name (GladeNameContext * context, const gchar * name)
{
- gboolean ret = FALSE;
-
- g_return_val_if_fail (context != NULL, FALSE);
- g_return_val_if_fail (name && name[0], FALSE);
-
- if (!glade_name_context_has_name (context, name))
- {
- g_hash_table_insert (context->names, g_strdup (name), GINT_TO_POINTER (TRUE));
- ret = TRUE;
- }
-
- return ret;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (name && name[0], FALSE);
+
+ if (!glade_name_context_has_name (context, name))
+ {
+ g_hash_table_insert (context->names, g_strdup (name),
+ GINT_TO_POINTER (TRUE));
+ ret = TRUE;
+ }
+
+ return ret;
}
void
-glade_name_context_release_name (GladeNameContext *context,
- const gchar *name)
+glade_name_context_release_name (GladeNameContext * context, const gchar * name)
{
- const gchar *first_number = name;
- gchar *end_number, *base_name;
- GladeIDAllocator *id_allocator;
- gunichar ch;
- gint id;
+ const gchar *first_number = name;
+ gchar *end_number, *base_name;
+ GladeIDAllocator *id_allocator;
+ gunichar ch;
+ gint id;
+
+ g_return_if_fail (context != NULL);
+ g_return_if_fail (name && name[0]);
- g_return_if_fail (context != NULL);
- g_return_if_fail (name && name[0]);
+ /* Remove from name hash first... */
+ g_hash_table_remove (context->names, name);
- /* Remove from name hash first... */
- g_hash_table_remove (context->names, name);
+ do
+ {
+ ch = g_utf8_get_char (first_number);
- do
- {
- ch = g_utf8_get_char (first_number);
+ if (ch == 0 || g_unichar_isdigit (ch))
+ break;
- if (ch == 0 || g_unichar_isdigit (ch))
- break;
+ first_number = g_utf8_next_char (first_number);
+ }
+ while (TRUE);
- first_number = g_utf8_next_char (first_number);
- }
- while (TRUE);
+ /* if there is a number - then we have to unallocate it... */
+ if (ch == 0)
+ return;
- /* if there is a number - then we have to unallocate it... */
- if (ch == 0) return;
+ base_name = g_strdup (name);
+ *(base_name + (first_number - name)) = 0;
- base_name = g_strdup (name);
- *(base_name + (first_number - name)) = 0;
-
- if ((id_allocator =
- g_hash_table_lookup (context->name_allocators, base_name)) != NULL)
- {
+ if ((id_allocator =
+ g_hash_table_lookup (context->name_allocators, base_name)) != NULL)
+ {
- id = (int) strtol (first_number, &end_number, 10);
- if (*end_number == 0)
- glade_id_allocator_release (id_allocator, id);
- }
+ id = (int) strtol (first_number, &end_number, 10);
+ if (*end_number == 0)
+ glade_id_allocator_release (id_allocator, id);
+ }
- g_free (base_name);
+ g_free (base_name);
}
diff --git a/gladeui/glade-name-context.h b/gladeui/glade-name-context.h
index 088e502..036bd63 100644
--- a/gladeui/glade-name-context.h
+++ b/gladeui/glade-name-context.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_NAME_CONTEXT_H__
#define __GLADE_NAME_CONTEXT_H__
diff --git a/gladeui/glade-named-icon-chooser-dialog.c b/gladeui/glade-named-icon-chooser-dialog.c
index 8fc33b6..f0e4819 100644
--- a/gladeui/glade-named-icon-chooser-dialog.c
+++ b/gladeui/glade-named-icon-chooser-dialog.c
@@ -39,1497 +39,1517 @@
enum
{
- CONTEXTS_ID_COLUMN,
- CONTEXTS_NAME_COLUMN,
- CONTEXTS_TITLE_COLUMN,
-
- CONTEXTS_N_COLUMS
+ CONTEXTS_ID_COLUMN,
+ CONTEXTS_NAME_COLUMN,
+ CONTEXTS_TITLE_COLUMN,
+
+ CONTEXTS_N_COLUMS
};
enum
{
- ICONS_CONTEXT_COLUMN,
- ICONS_STANDARD_COLUMN,
- ICONS_NAME_COLUMN,
-
- ICONS_N_COLUMNS
+ ICONS_CONTEXT_COLUMN,
+ ICONS_STANDARD_COLUMN,
+ ICONS_NAME_COLUMN,
+
+ ICONS_N_COLUMNS
};
enum
{
- GLADE_NAMED_ICON
+ GLADE_NAMED_ICON
};
-enum {
- ICON_ACTIVATED,
- SELECTION_CHANGED,
-
- LAST_SIGNAL
+enum
+{
+ ICON_ACTIVATED,
+ SELECTION_CHANGED,
+
+ LAST_SIGNAL
};
struct _GladeNamedIconChooserDialogPrivate
{
- GtkWidget *icons_view;
- GtkTreeModel *filter_model; /* filtering model */
- GtkListStore *icons_store; /* data store */
- GtkTreeSelection *selection;
-
- GtkWidget *contexts_view;
- GtkListStore *contexts_store;
-
- GtkWidget *entry;
- GtkEntryCompletion *entry_completion;
-
- GtkWidget *button; /* list-standard-only checkbutton */
-
- gint context_id; /* current icon name context for icon filtering */
-
- gchar *pending_select_name; /* an icon name for a pending treeview selection.
- * can only select name after model is loaded
- * and the widget is mapped */
-
- GtkIconTheme *icon_theme; /* the current icon theme */
- guint load_id; /* id of the idle function for loading data into model */
-
- gboolean settings_list_standard; /* whether to list standard icon names only */
-
- GtkWidget *last_focus_widget;
-
- gboolean icons_loaded; /* whether the icons have been loaded into the model */
+ GtkWidget *icons_view;
+ GtkTreeModel *filter_model; /* filtering model */
+ GtkListStore *icons_store; /* data store */
+ GtkTreeSelection *selection;
+
+ GtkWidget *contexts_view;
+ GtkListStore *contexts_store;
+
+ GtkWidget *entry;
+ GtkEntryCompletion *entry_completion;
+
+ GtkWidget *button; /* list-standard-only checkbutton */
+
+ gint context_id; /* current icon name context for icon filtering */
+
+ gchar *pending_select_name; /* an icon name for a pending treeview selection.
+ * can only select name after model is loaded
+ * and the widget is mapped */
+
+ GtkIconTheme *icon_theme; /* the current icon theme */
+ guint load_id; /* id of the idle function for loading data into model */
+
+ gboolean settings_list_standard; /* whether to list standard icon names only */
+
+ GtkWidget *last_focus_widget;
+
+ gboolean icons_loaded; /* whether the icons have been loaded into the model */
};
static GHashTable *standard_icon_quarks = NULL;
-static guint dialog_signals[LAST_SIGNAL] = { 0, };
+static guint dialog_signals[LAST_SIGNAL] = { 0, };
+
+gchar
+ *glade_named_icon_chooser_dialog_get_icon_name (GladeNamedIconChooserDialog
+ * dialog);
-gchar *glade_named_icon_chooser_dialog_get_icon_name (GladeNamedIconChooserDialog *dialog);
+void glade_named_icon_chooser_dialog_set_icon_name (GladeNamedIconChooserDialog
+ * dialog,
+ const gchar * icon_name);
-void glade_named_icon_chooser_dialog_set_icon_name (GladeNamedIconChooserDialog *dialog,
- const gchar *icon_name);
+gboolean
+glade_named_icon_chooser_dialog_set_context (GladeNamedIconChooserDialog *
+ dialog, const gchar * context);
-gboolean glade_named_icon_chooser_dialog_set_context (GladeNamedIconChooserDialog *dialog,
- const gchar *context);
+gchar *glade_named_icon_chooser_dialog_get_context (GladeNamedIconChooserDialog
+ * dialog);
-gchar *glade_named_icon_chooser_dialog_get_context (GladeNamedIconChooserDialog *dialog);
+static gboolean should_respond (GladeNamedIconChooserDialog * dialog);
-static gboolean should_respond (GladeNamedIconChooserDialog *dialog);
+static void filter_icons_model (GladeNamedIconChooserDialog * dialog);
-static void filter_icons_model (GladeNamedIconChooserDialog *dialog);
+static gboolean scan_for_name_func (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, gpointer data);
-static gboolean scan_for_name_func (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data);
+static gboolean scan_for_context_func (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, gpointer data);
-static gboolean scan_for_context_func (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data);
-
-static void settings_load (GladeNamedIconChooserDialog *dialog);
+static void settings_load (GladeNamedIconChooserDialog * dialog);
-static void settings_save (GladeNamedIconChooserDialog *dialog);
+static void settings_save (GladeNamedIconChooserDialog * dialog);
-G_DEFINE_TYPE (GladeNamedIconChooserDialog, glade_named_icon_chooser_dialog, GTK_TYPE_DIALOG);
+G_DEFINE_TYPE (GladeNamedIconChooserDialog, glade_named_icon_chooser_dialog,
+ GTK_TYPE_DIALOG);
static void
-entry_set_name (GladeNamedIconChooserDialog *dialog, const gchar *name)
-{
- /* Must disable completion before setting text, in order to avoid
- * spurious warnings (possible GTK+ bug).
- */
- gtk_entry_set_completion (GTK_ENTRY (dialog->priv->entry), NULL);
-
- gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry), name);
-
- gtk_entry_set_completion (GTK_ENTRY (dialog->priv->entry), dialog->priv->entry_completion);
+entry_set_name (GladeNamedIconChooserDialog * dialog, const gchar * name)
+{
+ /* Must disable completion before setting text, in order to avoid
+ * spurious warnings (possible GTK+ bug).
+ */
+ gtk_entry_set_completion (GTK_ENTRY (dialog->priv->entry), NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->priv->entry), name);
+
+ gtk_entry_set_completion (GTK_ENTRY (dialog->priv->entry),
+ dialog->priv->entry_completion);
}
static GtkIconTheme *
-get_icon_theme_for_widget (GtkWidget *widget)
+get_icon_theme_for_widget (GtkWidget * widget)
{
- if (gtk_widget_has_screen (widget))
- return gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
+ if (gtk_widget_has_screen (widget))
+ return gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
- return gtk_icon_theme_get_default ();
+ return gtk_icon_theme_get_default ();
}
/* validates name according to the icon naming spec (en_US.US_ASCII [a-z1-9_-.]) */
static gboolean
-is_well_formed (const gchar *name)
-{
- gchar *c = (gchar *) name;
- for (; *c; c++)
- {
- if (g_ascii_isalnum (*c))
- {
- if (g_ascii_isalpha (*c) && !g_ascii_islower (*c))
- return FALSE;
- }
- else if (*c != '_' && *c != '-' && *c != '.')
- {
- return FALSE;
- }
- }
- return TRUE;
+is_well_formed (const gchar * name)
+{
+ gchar *c = (gchar *) name;
+ for (; *c; c++)
+ {
+ if (g_ascii_isalnum (*c))
+ {
+ if (g_ascii_isalpha (*c) && !g_ascii_islower (*c))
+ return FALSE;
+ }
+ else if (*c != '_' && *c != '-' && *c != '.')
+ {
+ return FALSE;
+ }
+ }
+ return TRUE;
}
static void
-check_entry_text (GladeNamedIconChooserDialog *dialog,
- gchar **name_ret,
- gboolean *is_wellformed_ret,
- gboolean *is_empty_ret)
-{
- if (strlen (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry))) == 0)
- {
- *name_ret = NULL;
- *is_wellformed_ret = TRUE;
- *is_empty_ret = TRUE;
-
- return;
- }
-
- *is_empty_ret = FALSE;
-
- *is_wellformed_ret = is_well_formed (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)));
-
- if (*is_wellformed_ret)
- *name_ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)));
- else
- *name_ret = NULL;
+check_entry_text (GladeNamedIconChooserDialog * dialog,
+ gchar ** name_ret,
+ gboolean * is_wellformed_ret, gboolean * is_empty_ret)
+{
+ if (strlen (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry))) == 0)
+ {
+ *name_ret = NULL;
+ *is_wellformed_ret = TRUE;
+ *is_empty_ret = TRUE;
+
+ return;
+ }
+
+ *is_empty_ret = FALSE;
+
+ *is_wellformed_ret =
+ is_well_formed (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)));
+
+ if (*is_wellformed_ret)
+ *name_ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)));
+ else
+ *name_ret = NULL;
}
static void
-changed_text_handler (GtkEditable *editable,
- GladeNamedIconChooserDialog *dialog)
+changed_text_handler (GtkEditable * editable,
+ GladeNamedIconChooserDialog * dialog)
{
- g_signal_emit_by_name (dialog, "selection-changed", NULL);
-}
+ g_signal_emit_by_name (dialog, "selection-changed", NULL);
+}
/* ensure that only valid text can be inserted into entry */
static void
-insert_text_handler (GtkEditable *editable,
- const gchar *text,
- gint length,
- gint *position,
- GladeNamedIconChooserDialog *dialog)
-{
- if (is_well_formed (text))
- {
-
- g_signal_handlers_block_by_func (editable, (gpointer) insert_text_handler, dialog);
-
- gtk_editable_insert_text (editable, text, length, position);
-
- g_signal_handlers_unblock_by_func (editable, (gpointer) insert_text_handler, dialog);
-
- }
- else
- {
- gdk_display_beep (gtk_widget_get_display (GTK_WIDGET (dialog)));
- }
-
- g_signal_stop_emission_by_name (editable, "insert-text");
+insert_text_handler (GtkEditable * editable,
+ const gchar * text,
+ gint length,
+ gint * position, GladeNamedIconChooserDialog * dialog)
+{
+ if (is_well_formed (text))
+ {
+
+ g_signal_handlers_block_by_func (editable, (gpointer) insert_text_handler,
+ dialog);
+
+ gtk_editable_insert_text (editable, text, length, position);
+
+ g_signal_handlers_unblock_by_func (editable,
+ (gpointer) insert_text_handler,
+ dialog);
+
+ }
+ else
+ {
+ gdk_display_beep (gtk_widget_get_display (GTK_WIDGET (dialog)));
+ }
+
+ g_signal_stop_emission_by_name (editable, "insert-text");
}
typedef struct
{
- gchar *name; /* the name of the icon or context */
+ gchar *name; /* the name of the icon or context */
- guint found : 1; /* whether an item matching `name' was found */
- guint do_select : 1; /* select the matched row */
- guint do_cursor : 1; /* put cursor at the matched row */
- guint do_activate : 1; /* activate the matched row */
+ guint found:1; /* whether an item matching `name' was found */
+ guint do_select:1; /* select the matched row */
+ guint do_cursor:1; /* put cursor at the matched row */
+ guint do_activate:1; /* activate the matched row */
- GladeNamedIconChooserDialog *dialog;
+ GladeNamedIconChooserDialog *dialog;
} ForEachFuncData;
void
-glade_named_icon_chooser_dialog_set_icon_name (GladeNamedIconChooserDialog *dialog,
- const gchar *name)
-{
- ForEachFuncData *data;
- gboolean located_in_theme;
-
- g_return_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog));
- g_return_if_fail (gtk_widget_has_screen (GTK_WIDGET (dialog)));
-
- if (name == NULL)
- {
- gtk_tree_selection_unselect_all (dialog->priv->selection);
- entry_set_name (dialog, "");
- return;
- }
-
- located_in_theme = gtk_icon_theme_has_icon (get_icon_theme_for_widget (GTK_WIDGET (dialog)),
- name);
-
- if (located_in_theme)
- {
-
- if (dialog->priv->icons_loaded && dialog->priv->filter_model)
- {
-
- data = g_slice_new0(ForEachFuncData);
- data->name = g_strdup (name);
- data->found = FALSE;
- data->do_activate = FALSE;
- data->do_select = TRUE;
- data->do_cursor = TRUE;
- data->dialog = dialog;
-
- gtk_tree_model_foreach (dialog->priv->filter_model,
- scan_for_name_func,
- data);
-
- g_free (data->name);
- g_slice_free (ForEachFuncData, data);
-
- }
- else
- {
- dialog->priv->pending_select_name = g_strdup (name);
- }
-
- /* selecting a treeview row will set the entry text,
- * but we must have this here in case the row has been filtered out
- */
- entry_set_name (dialog, name);
-
- }
- else if (is_well_formed (name))
- {
-
- gtk_tree_selection_unselect_all (dialog->priv->selection);
-
- entry_set_name (dialog, name);
- }
- else
- {
- g_warning ("invalid icon name: '%s' is not well formed", name);
- }
+glade_named_icon_chooser_dialog_set_icon_name (GladeNamedIconChooserDialog *
+ dialog, const gchar * name)
+{
+ ForEachFuncData *data;
+ gboolean located_in_theme;
+
+ g_return_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog));
+ g_return_if_fail (gtk_widget_has_screen (GTK_WIDGET (dialog)));
+
+ if (name == NULL)
+ {
+ gtk_tree_selection_unselect_all (dialog->priv->selection);
+ entry_set_name (dialog, "");
+ return;
+ }
+
+ located_in_theme =
+ gtk_icon_theme_has_icon (get_icon_theme_for_widget (GTK_WIDGET (dialog)),
+ name);
+
+ if (located_in_theme)
+ {
+
+ if (dialog->priv->icons_loaded && dialog->priv->filter_model)
+ {
+
+ data = g_slice_new0 (ForEachFuncData);
+ data->name = g_strdup (name);
+ data->found = FALSE;
+ data->do_activate = FALSE;
+ data->do_select = TRUE;
+ data->do_cursor = TRUE;
+ data->dialog = dialog;
+
+ gtk_tree_model_foreach (dialog->priv->filter_model,
+ scan_for_name_func, data);
+
+ g_free (data->name);
+ g_slice_free (ForEachFuncData, data);
+
+ }
+ else
+ {
+ dialog->priv->pending_select_name = g_strdup (name);
+ }
+
+ /* selecting a treeview row will set the entry text,
+ * but we must have this here in case the row has been filtered out
+ */
+ entry_set_name (dialog, name);
+
+ }
+ else if (is_well_formed (name))
+ {
+
+ gtk_tree_selection_unselect_all (dialog->priv->selection);
+
+ entry_set_name (dialog, name);
+ }
+ else
+ {
+ g_warning ("invalid icon name: '%s' is not well formed", name);
+ }
}
gboolean
-glade_named_icon_chooser_dialog_set_context (GladeNamedIconChooserDialog *dialog,
- const gchar *name)
-{
- ForEachFuncData *data;
-
- g_return_val_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog), FALSE);
-
- data = g_slice_new0 (ForEachFuncData);
-
- if (name)
- data->name = g_strdup (name);
- else
- data->name = g_strdup ("All Contexts");
-
- data->found = FALSE;
- data->do_select = TRUE;
- data->do_activate = FALSE;
- data->do_cursor = FALSE;
- data->dialog = dialog;
-
- gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->priv->contexts_store),
- (GtkTreeModelForeachFunc) scan_for_context_func,
- data);
-
- g_free (data->name);
- g_slice_free (ForEachFuncData, data);
-
- return TRUE;
+glade_named_icon_chooser_dialog_set_context (GladeNamedIconChooserDialog *
+ dialog, const gchar * name)
+{
+ ForEachFuncData *data;
+
+ g_return_val_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog), FALSE);
+
+ data = g_slice_new0 (ForEachFuncData);
+
+ if (name)
+ data->name = g_strdup (name);
+ else
+ data->name = g_strdup ("All Contexts");
+
+ data->found = FALSE;
+ data->do_select = TRUE;
+ data->do_activate = FALSE;
+ data->do_cursor = FALSE;
+ data->dialog = dialog;
+
+ gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->priv->contexts_store),
+ (GtkTreeModelForeachFunc) scan_for_context_func,
+ data);
+
+ g_free (data->name);
+ g_slice_free (ForEachFuncData, data);
+
+ return TRUE;
}
gchar *
-glade_named_icon_chooser_dialog_get_context (GladeNamedIconChooserDialog *dialog)
-{
- GtkTreeSelection *sel;
- GtkTreeIter iter;
- gchar *context_name;
-
- g_return_val_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog), NULL);
-
- sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->contexts_view));
-
- if (gtk_tree_selection_get_selected (sel, NULL, &iter))
- {
-
- gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->contexts_store), &iter,
- CONTEXTS_NAME_COLUMN, &context_name,
- -1);
-
- /* if context_name is NULL, then it is the 'all categories' special context */
- return context_name;
-
- }
- else
- {
- return NULL;
- }
+glade_named_icon_chooser_dialog_get_context (GladeNamedIconChooserDialog *
+ dialog)
+{
+ GtkTreeSelection *sel;
+ GtkTreeIter iter;
+ gchar *context_name;
+
+ g_return_val_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog), NULL);
+
+ sel =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->contexts_view));
+
+ if (gtk_tree_selection_get_selected (sel, NULL, &iter))
+ {
+
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->contexts_store), &iter,
+ CONTEXTS_NAME_COLUMN, &context_name, -1);
+
+ /* if context_name is NULL, then it is the 'all categories' special context */
+ return context_name;
+
+ }
+ else
+ {
+ return NULL;
+ }
}
static gchar *
-get_icon_name_from_selection (GladeNamedIconChooserDialog *dialog)
+get_icon_name_from_selection (GladeNamedIconChooserDialog * dialog)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
- gchar *name;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gchar *name;
+
+ if (!gtk_tree_selection_get_selected (dialog->priv->selection, &model, &iter))
+ return NULL;
- if (!gtk_tree_selection_get_selected (dialog->priv->selection, &model, &iter))
- return NULL;
-
- gtk_tree_model_get (model, &iter,
- ICONS_NAME_COLUMN, &name,
- -1);
+ gtk_tree_model_get (model, &iter, ICONS_NAME_COLUMN, &name, -1);
- return name;
+ return name;
}
-gchar*
-glade_named_icon_chooser_dialog_get_icon_name (GladeNamedIconChooserDialog *dialog)
-{
- GtkWidget *current_focus;
- gchar *name;
-
- g_return_val_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog), NULL);
-
- current_focus = gtk_window_get_focus (GTK_WINDOW (dialog));
-
- if (current_focus == dialog->priv->icons_view)
- {
-
- view:
- name = get_icon_name_from_selection (dialog);
-
- if (name == NULL)
- goto entry;
-
- }
- else if (current_focus == dialog->priv->entry)
- {
- gboolean is_wellformed, is_empty;
- entry:
- check_entry_text (dialog, &name, &is_wellformed, &is_empty);
-
- if (!is_wellformed || is_empty)
- return NULL;
-
- }
- else if (dialog->priv->last_focus_widget == dialog->priv->icons_view)
- {
- goto view;
- }
- else if (dialog->priv->last_focus_widget == dialog->priv->entry)
- {
- goto entry;
- }
- else
- {
- goto view;
- }
-
- return name;
+gchar *
+glade_named_icon_chooser_dialog_get_icon_name (GladeNamedIconChooserDialog *
+ dialog)
+{
+ GtkWidget *current_focus;
+ gchar *name;
+
+ g_return_val_if_fail (GLADE_IS_NAMED_ICON_CHOOSER_DIALOG (dialog), NULL);
+
+ current_focus = gtk_window_get_focus (GTK_WINDOW (dialog));
+
+ if (current_focus == dialog->priv->icons_view)
+ {
+
+ view:
+ name = get_icon_name_from_selection (dialog);
+
+ if (name == NULL)
+ goto entry;
+
+ }
+ else if (current_focus == dialog->priv->entry)
+ {
+ gboolean is_wellformed, is_empty;
+ entry:
+ check_entry_text (dialog, &name, &is_wellformed, &is_empty);
+
+ if (!is_wellformed || is_empty)
+ return NULL;
+
+ }
+ else if (dialog->priv->last_focus_widget == dialog->priv->icons_view)
+ {
+ goto view;
+ }
+ else if (dialog->priv->last_focus_widget == dialog->priv->entry)
+ {
+ goto entry;
+ }
+ else
+ {
+ goto view;
+ }
+
+ return name;
}
static void
-set_busy_cursor (GladeNamedIconChooserDialog *dialog,
- gboolean busy)
+set_busy_cursor (GladeNamedIconChooserDialog * dialog, gboolean busy)
{
- GdkDisplay *display;
- GdkCursor *cursor;
+ GdkDisplay *display;
+ GdkCursor *cursor;
- if (!gtk_widget_get_realized (GTK_WIDGET (dialog)))
- return;
+ if (!gtk_widget_get_realized (GTK_WIDGET (dialog)))
+ return;
- display = gtk_widget_get_display (GTK_WIDGET (dialog));
+ display = gtk_widget_get_display (GTK_WIDGET (dialog));
- if (busy)
- cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
- else
- cursor = NULL;
+ if (busy)
+ cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
+ else
+ cursor = NULL;
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog)), cursor);
- gdk_display_flush (display);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog)), cursor);
+ gdk_display_flush (display);
- if (cursor)
- gdk_cursor_unref (cursor);
+ if (cursor)
+ gdk_cursor_unref (cursor);
}
-static GtkListStore*
+static GtkListStore *
populate_icon_contexts_model (void)
{
- GtkListStore *store;
- GtkTreeIter iter;
- guint i;
-
- store = gtk_list_store_new (CONTEXTS_N_COLUMS,
- G_TYPE_INT,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- CONTEXTS_ID_COLUMN, -1,
- CONTEXTS_NAME_COLUMN, "All Contexts",
- CONTEXTS_TITLE_COLUMN, _("All Contexts"),
- -1);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- CONTEXTS_ID_COLUMN, -1,
- CONTEXTS_NAME_COLUMN, NULL,
- CONTEXTS_TITLE_COLUMN, NULL,
- -1);
-
- for (i = 0; i < G_N_ELEMENTS (standard_contexts); i++)
- {
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- CONTEXTS_ID_COLUMN, i,
- CONTEXTS_NAME_COLUMN, standard_contexts[i].name,
- CONTEXTS_TITLE_COLUMN, _(standard_contexts[i].title),
- -1);
- }
-
- return store;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ guint i;
+
+ store = gtk_list_store_new (CONTEXTS_N_COLUMS,
+ G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
+
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ CONTEXTS_ID_COLUMN, -1,
+ CONTEXTS_NAME_COLUMN, "All Contexts",
+ CONTEXTS_TITLE_COLUMN, _("All Contexts"), -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ CONTEXTS_ID_COLUMN, -1,
+ CONTEXTS_NAME_COLUMN, NULL,
+ CONTEXTS_TITLE_COLUMN, NULL, -1);
+
+ for (i = 0; i < G_N_ELEMENTS (standard_contexts); i++)
+ {
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ CONTEXTS_ID_COLUMN, i,
+ CONTEXTS_NAME_COLUMN, standard_contexts[i].name,
+ CONTEXTS_TITLE_COLUMN, _(standard_contexts[i].title),
+ -1);
+ }
+
+ return store;
}
static void
-icons_row_activated_cb (GtkTreeView *view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- GladeNamedIconChooserDialog *dialog)
+icons_row_activated_cb (GtkTreeView * view,
+ GtkTreePath * path,
+ GtkTreeViewColumn * column,
+ GladeNamedIconChooserDialog * dialog)
{
- g_signal_emit_by_name (dialog, "icon-activated", NULL);
+ g_signal_emit_by_name (dialog, "icon-activated", NULL);
}
static void
-icons_selection_changed_cb (GtkTreeSelection *selection,
- GladeNamedIconChooserDialog *dialog)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *name;
-
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- gtk_tree_model_get (model, &iter,
- ICONS_NAME_COLUMN, &name,
- -1);
- if (name)
- entry_set_name (dialog, name);
-
- g_free (name);
- }
- else
- {
- /* entry_set_name (dialog, ""); */
- }
-
- /* we emit "selection-changed" for chooser in insert_text_handler()
- * to avoid emitting the signal twice */
+icons_selection_changed_cb (GtkTreeSelection * selection,
+ GladeNamedIconChooserDialog * dialog)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *name;
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ gtk_tree_model_get (model, &iter, ICONS_NAME_COLUMN, &name, -1);
+ if (name)
+ entry_set_name (dialog, name);
+
+ g_free (name);
+ }
+ else
+ {
+ /* entry_set_name (dialog, ""); */
+ }
+
+ /* we emit "selection-changed" for chooser in insert_text_handler()
+ * to avoid emitting the signal twice */
}
static void
-contexts_row_activated_cb (GtkTreeView *view,
- GtkTreePath *cpath,
- GtkTreeViewColumn *column,
- GladeNamedIconChooserDialog *dialog)
-{
- GtkTreeIter iter;
- GtkTreePath *path;
-
- if (gtk_tree_model_get_iter_first (dialog->priv->filter_model, &iter))
- {
-
- gtk_tree_selection_select_iter (dialog->priv->selection, &iter);
-
- path = gtk_tree_model_get_path (dialog->priv->filter_model, &iter);
-
- gtk_tree_selection_select_path (dialog->priv->selection, path);
-
- gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (dialog->priv->icons_view), -1, 0);
-
- gtk_tree_path_free (path);
-
- }
- gtk_widget_grab_focus (dialog->priv->icons_view);
+contexts_row_activated_cb (GtkTreeView * view,
+ GtkTreePath * cpath,
+ GtkTreeViewColumn * column,
+ GladeNamedIconChooserDialog * dialog)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ if (gtk_tree_model_get_iter_first (dialog->priv->filter_model, &iter))
+ {
+
+ gtk_tree_selection_select_iter (dialog->priv->selection, &iter);
+
+ path = gtk_tree_model_get_path (dialog->priv->filter_model, &iter);
+
+ gtk_tree_selection_select_path (dialog->priv->selection, path);
+
+ gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (dialog->priv->icons_view),
+ -1, 0);
+
+ gtk_tree_path_free (path);
+
+ }
+ gtk_widget_grab_focus (dialog->priv->icons_view);
}
static void
-contexts_selection_changed_cb (GtkTreeSelection *selection,
- GladeNamedIconChooserDialog *dialog)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- gboolean retval;
- gint context_id;
-
- retval = gtk_tree_selection_get_selected (selection, &model, &iter);
-
- if (retval)
- {
-
- gtk_tree_model_get (model, &iter,
- CONTEXTS_ID_COLUMN, &context_id,
- -1);
-
- dialog->priv->context_id = context_id;
-
- if (!dialog->priv->filter_model)
- return;
-
- filter_icons_model (dialog);
- }
-
- entry_set_name (dialog, "");
+contexts_selection_changed_cb (GtkTreeSelection * selection,
+ GladeNamedIconChooserDialog * dialog)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gboolean retval;
+ gint context_id;
+
+ retval = gtk_tree_selection_get_selected (selection, &model, &iter);
+
+ if (retval)
+ {
+
+ gtk_tree_model_get (model, &iter, CONTEXTS_ID_COLUMN, &context_id, -1);
+
+ dialog->priv->context_id = context_id;
+
+ if (!dialog->priv->filter_model)
+ return;
+
+ filter_icons_model (dialog);
+ }
+
+ entry_set_name (dialog, "");
}
static gboolean
-row_separator_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer unused)
+row_separator_func (GtkTreeModel * model, GtkTreeIter * iter, gpointer unused)
{
- gboolean retval;
- gchar *name, *title;
+ gboolean retval;
+ gchar *name, *title;
+
+ gtk_tree_model_get (model, iter,
+ CONTEXTS_NAME_COLUMN, &name,
+ CONTEXTS_TITLE_COLUMN, &title, -1);
- gtk_tree_model_get (model, iter,
- CONTEXTS_NAME_COLUMN, &name,
- CONTEXTS_TITLE_COLUMN, &title,
- -1);
+ retval = !name && !title;
- retval = !name && !title;
+ g_free (name);
+ g_free (title);
- g_free (name);
- g_free (title);
-
- return retval;
+ return retval;
}
-static GtkWidget*
-create_contexts_view (GladeNamedIconChooserDialog *dialog)
-{
- GtkTreeView *view;
- GtkTreeViewColumn *column;
- GtkTreePath *path;
-
- dialog->priv->contexts_store = populate_icon_contexts_model ();
-
- view = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->priv->contexts_store)));
-
- column = gtk_tree_view_column_new_with_attributes (NULL,
- gtk_cell_renderer_text_new (),
- "text", CONTEXTS_TITLE_COLUMN,
- NULL);
-
- gtk_tree_view_append_column (view, column);
- gtk_tree_view_set_headers_visible (view, FALSE);
-
- gtk_tree_view_set_row_separator_func (view,
- (GtkTreeViewRowSeparatorFunc) row_separator_func,
- NULL,
- NULL);
-
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view), GTK_SELECTION_BROWSE);
-
- path = gtk_tree_path_new_from_indices (0, -1);
- gtk_tree_selection_select_path (gtk_tree_view_get_selection (view), path);
- gtk_tree_path_free (path);
-
- g_signal_connect (view, "row-activated",
- G_CALLBACK (contexts_row_activated_cb),
- dialog);
-
- g_signal_connect (gtk_tree_view_get_selection (view), "changed",
- G_CALLBACK (contexts_selection_changed_cb),
- dialog);
-
- gtk_widget_show (GTK_WIDGET (view));
-
- return GTK_WIDGET (view);
+static GtkWidget *
+create_contexts_view (GladeNamedIconChooserDialog * dialog)
+{
+ GtkTreeView *view;
+ GtkTreeViewColumn *column;
+ GtkTreePath *path;
+
+ dialog->priv->contexts_store = populate_icon_contexts_model ();
+
+ view =
+ GTK_TREE_VIEW (gtk_tree_view_new_with_model
+ (GTK_TREE_MODEL (dialog->priv->contexts_store)));
+
+ column = gtk_tree_view_column_new_with_attributes (NULL,
+ gtk_cell_renderer_text_new
+ (), "text",
+ CONTEXTS_TITLE_COLUMN,
+ NULL);
+
+ gtk_tree_view_append_column (view, column);
+ gtk_tree_view_set_headers_visible (view, FALSE);
+
+ gtk_tree_view_set_row_separator_func (view,
+ (GtkTreeViewRowSeparatorFunc)
+ row_separator_func, NULL, NULL);
+
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view),
+ GTK_SELECTION_BROWSE);
+
+ path = gtk_tree_path_new_from_indices (0, -1);
+ gtk_tree_selection_select_path (gtk_tree_view_get_selection (view), path);
+ gtk_tree_path_free (path);
+
+ g_signal_connect (view, "row-activated",
+ G_CALLBACK (contexts_row_activated_cb), dialog);
+
+ g_signal_connect (gtk_tree_view_get_selection (view), "changed",
+ G_CALLBACK (contexts_selection_changed_cb), dialog);
+
+ gtk_widget_show (GTK_WIDGET (view));
+
+ return GTK_WIDGET (view);
}
/* filters the icons model based on the current state */
static void
-filter_icons_model (GladeNamedIconChooserDialog *dialog)
+filter_icons_model (GladeNamedIconChooserDialog * dialog)
{
- set_busy_cursor (dialog, TRUE);
-
- g_object_ref (dialog->priv->filter_model);
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view), NULL);
- gtk_entry_completion_set_model (dialog->priv->entry_completion, NULL);
-
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->priv->filter_model));
+ set_busy_cursor (dialog, TRUE);
+
+ g_object_ref (dialog->priv->filter_model);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view), NULL);
+ gtk_entry_completion_set_model (dialog->priv->entry_completion, NULL);
+
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER
+ (dialog->priv->filter_model));
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view), dialog->priv->filter_model);
- gtk_entry_completion_set_model (dialog->priv->entry_completion, GTK_TREE_MODEL (dialog->priv->icons_store));
- gtk_entry_completion_set_text_column (dialog->priv->entry_completion, ICONS_NAME_COLUMN);
- g_object_unref (dialog->priv->filter_model);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view),
+ dialog->priv->filter_model);
+ gtk_entry_completion_set_model (dialog->priv->entry_completion,
+ GTK_TREE_MODEL (dialog->priv->icons_store));
+ gtk_entry_completion_set_text_column (dialog->priv->entry_completion,
+ ICONS_NAME_COLUMN);
+ g_object_unref (dialog->priv->filter_model);
- set_busy_cursor (dialog, FALSE);
+ set_busy_cursor (dialog, FALSE);
}
static gboolean
-filter_visible_func (GtkTreeModel *model,
- GtkTreeIter *iter,
- GladeNamedIconChooserDialog *dialog)
+filter_visible_func (GtkTreeModel * model,
+ GtkTreeIter * iter, GladeNamedIconChooserDialog * dialog)
{
- gboolean standard;
- gint context_id;
+ gboolean standard;
+ gint context_id;
- gtk_tree_model_get (model, iter,
- ICONS_CONTEXT_COLUMN, &context_id,
- ICONS_STANDARD_COLUMN, &standard,
- -1);
+ gtk_tree_model_get (model, iter,
+ ICONS_CONTEXT_COLUMN, &context_id,
+ ICONS_STANDARD_COLUMN, &standard, -1);
- if (dialog->priv->context_id == -1)
- return (dialog->priv->settings_list_standard) ? TRUE && standard : TRUE;
+ if (dialog->priv->context_id == -1)
+ return (dialog->priv->settings_list_standard) ? TRUE && standard : TRUE;
- if (context_id == dialog->priv->context_id)
- return (dialog->priv->settings_list_standard) ? TRUE && standard : TRUE;
- else
- return FALSE;
+ if (context_id == dialog->priv->context_id)
+ return (dialog->priv->settings_list_standard) ? TRUE && standard : TRUE;
+ else
+ return FALSE;
}
static gboolean
-search_equal_func (GtkTreeModel *model,
+search_equal_func (GtkTreeModel * model,
gint column,
- const gchar *key,
- GtkTreeIter *iter,
- GladeNamedIconChooserDialog *dialog)
+ const gchar * key,
+ GtkTreeIter * iter, GladeNamedIconChooserDialog * dialog)
{
- gchar *name;
- gboolean retval;
+ gchar *name;
+ gboolean retval;
- gtk_tree_model_get (model, iter,
- ICONS_NAME_COLUMN, &name,
- -1);
-
- retval = ! g_str_has_prefix (name, key);
+ gtk_tree_model_get (model, iter, ICONS_NAME_COLUMN, &name, -1);
- g_free (name);
-
- return retval;
+ retval = !g_str_has_prefix (name, key);
+
+ g_free (name);
+
+ return retval;
}
static gboolean
-scan_for_context_func (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
-{
- ForEachFuncData *data = (ForEachFuncData *) user_data;
- GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->dialog->priv->contexts_view));
- gchar *name = NULL;
-
- gtk_tree_model_get (model, iter, CONTEXTS_NAME_COLUMN, &name, -1);
- if (!name)
- return FALSE;
-
- if (strcmp (name, data->name) == 0)
- {
-
- data->found = TRUE;
-
- if (data->do_activate)
- gtk_tree_view_row_activated (GTK_TREE_VIEW (data->dialog->priv->contexts_view),
- path,
- gtk_tree_view_get_column
- (GTK_TREE_VIEW (data->dialog->priv->contexts_view), 0));
-
- if (data->do_select)
- gtk_tree_selection_select_path (selection, path);
- else
- gtk_tree_selection_unselect_path (selection, path);
-
- if (data->do_cursor)
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (data->dialog->priv->contexts_view),
- path, NULL, FALSE);
-
- g_free (name);
-
- return TRUE;
- }
-
- g_free (name);
-
- return FALSE;
+scan_for_context_func (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, gpointer user_data)
+{
+ ForEachFuncData *data = (ForEachFuncData *) user_data;
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW
+ (data->dialog->priv->contexts_view));
+ gchar *name = NULL;
+
+ gtk_tree_model_get (model, iter, CONTEXTS_NAME_COLUMN, &name, -1);
+ if (!name)
+ return FALSE;
+
+ if (strcmp (name, data->name) == 0)
+ {
+
+ data->found = TRUE;
+
+ if (data->do_activate)
+ gtk_tree_view_row_activated (GTK_TREE_VIEW
+ (data->dialog->priv->contexts_view), path,
+ gtk_tree_view_get_column (GTK_TREE_VIEW
+ (data->dialog->
+ priv->
+ contexts_view),
+ 0));
+
+ if (data->do_select)
+ gtk_tree_selection_select_path (selection, path);
+ else
+ gtk_tree_selection_unselect_path (selection, path);
+
+ if (data->do_cursor)
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW
+ (data->dialog->priv->contexts_view), path,
+ NULL, FALSE);
+
+ g_free (name);
+
+ return TRUE;
+ }
+
+ g_free (name);
+
+ return FALSE;
}
gboolean
-scan_for_name_func (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data)
-{
- ForEachFuncData *data = (ForEachFuncData *) user_data;
- gchar *name = NULL;
-
- gtk_tree_model_get (model, iter, ICONS_NAME_COLUMN, &name, -1);
- if (!name)
- return FALSE;
-
- if (strcmp (name, data->name) == 0)
- {
-
- data->found = TRUE;
-
- if (data->do_activate)
- gtk_tree_view_row_activated (GTK_TREE_VIEW (data->dialog->priv->icons_view),
- path,
- gtk_tree_view_get_column
- (GTK_TREE_VIEW (data->dialog->priv->icons_view), 0));
-
- if (data->do_select)
- gtk_tree_selection_select_path (data->dialog->priv->selection, path);
- else
- gtk_tree_selection_unselect_path (data->dialog->priv->selection, path);
-
- if (data->do_cursor)
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (data->dialog->priv->icons_view),
- path, NULL, FALSE);
-
- g_free (name);
-
- return TRUE;
- }
-
- g_free (name);
-
- return FALSE;
+scan_for_name_func (GtkTreeModel * model,
+ GtkTreePath * path, GtkTreeIter * iter, gpointer user_data)
+{
+ ForEachFuncData *data = (ForEachFuncData *) user_data;
+ gchar *name = NULL;
+
+ gtk_tree_model_get (model, iter, ICONS_NAME_COLUMN, &name, -1);
+ if (!name)
+ return FALSE;
+
+ if (strcmp (name, data->name) == 0)
+ {
+
+ data->found = TRUE;
+
+ if (data->do_activate)
+ gtk_tree_view_row_activated (GTK_TREE_VIEW
+ (data->dialog->priv->icons_view), path,
+ gtk_tree_view_get_column (GTK_TREE_VIEW
+ (data->dialog->
+ priv->
+ icons_view),
+ 0));
+
+ if (data->do_select)
+ gtk_tree_selection_select_path (data->dialog->priv->selection, path);
+ else
+ gtk_tree_selection_unselect_path (data->dialog->priv->selection, path);
+
+ if (data->do_cursor)
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW
+ (data->dialog->priv->icons_view), path, NULL,
+ FALSE);
+
+ g_free (name);
+
+ return TRUE;
+ }
+
+ g_free (name);
+
+ return FALSE;
}
static void
-centre_selected_row (GladeNamedIconChooserDialog *dialog)
-{
- GList *l;
-
- g_assert (dialog->priv->icons_store != NULL);
- g_assert (dialog->priv->selection != NULL);
-
- l = gtk_tree_selection_get_selected_rows (dialog->priv->selection, NULL);
-
- if (l) {
- g_assert (gtk_widget_get_mapped (GTK_WIDGET (dialog)));
- g_assert (gtk_widget_get_visible (GTK_WIDGET (dialog)));
-
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (dialog->priv->icons_view),
- (GtkTreePath *) l->data,
- NULL,
- TRUE,
- 0.5, 0.0);
-
+centre_selected_row (GladeNamedIconChooserDialog * dialog)
+{
+ GList *l;
+
+ g_assert (dialog->priv->icons_store != NULL);
+ g_assert (dialog->priv->selection != NULL);
+
+ l = gtk_tree_selection_get_selected_rows (dialog->priv->selection, NULL);
+
+ if (l)
+ {
+ g_assert (gtk_widget_get_mapped (GTK_WIDGET (dialog)));
+ g_assert (gtk_widget_get_visible (GTK_WIDGET (dialog)));
+
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (dialog->priv->icons_view),
+ (GtkTreePath *) l->data,
+ NULL, TRUE, 0.5, 0.0);
+
/* gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->priv->icons_view),
(GtkTreePath *) l->data,
0,
FALSE);
gtk_widget_grab_focus (dialog->priv->icons_view);
-*/
- g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (l);
- }
+*/
+ g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (l);
+ }
}
static void
-select_first_row (GladeNamedIconChooserDialog *dialog)
+select_first_row (GladeNamedIconChooserDialog * dialog)
{
- GtkTreePath *path;
+ GtkTreePath *path;
- if (!dialog->priv->filter_model)
- return;
+ if (!dialog->priv->filter_model)
+ return;
- path = gtk_tree_path_new_from_indices (0, -1);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->priv->icons_view), path, NULL, FALSE);
- gtk_tree_path_free (path);
+ path = gtk_tree_path_new_from_indices (0, -1);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->priv->icons_view), path,
+ NULL, FALSE);
+ gtk_tree_path_free (path);
}
static void
-pending_select_name_process (GladeNamedIconChooserDialog *dialog)
-{
- ForEachFuncData *data;
-
- g_assert (dialog->priv->icons_store != NULL);
- g_assert (dialog->priv->selection != NULL);
-
- if (dialog->priv->pending_select_name)
- {
-
- data = g_slice_new0 (ForEachFuncData);
-
- data->name = dialog->priv->pending_select_name;
- data->do_select = TRUE;
- data->do_activate = FALSE;
- data->dialog = dialog;
-
- gtk_tree_model_foreach (dialog->priv->filter_model,
- scan_for_name_func,
- data);
-
- g_free (dialog->priv->pending_select_name);
- dialog->priv->pending_select_name = NULL;
-
- g_slice_free (ForEachFuncData, data);
-
- }
- else
- {
- if (strlen (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry))) == 0)
- {
- select_first_row (dialog);
- }
- }
-
- centre_selected_row (dialog);
+pending_select_name_process (GladeNamedIconChooserDialog * dialog)
+{
+ ForEachFuncData *data;
+
+ g_assert (dialog->priv->icons_store != NULL);
+ g_assert (dialog->priv->selection != NULL);
+
+ if (dialog->priv->pending_select_name)
+ {
+
+ data = g_slice_new0 (ForEachFuncData);
+
+ data->name = dialog->priv->pending_select_name;
+ data->do_select = TRUE;
+ data->do_activate = FALSE;
+ data->dialog = dialog;
+
+ gtk_tree_model_foreach (dialog->priv->filter_model,
+ scan_for_name_func, data);
+
+ g_free (dialog->priv->pending_select_name);
+ dialog->priv->pending_select_name = NULL;
+
+ g_slice_free (ForEachFuncData, data);
+
+ }
+ else
+ {
+ if (strlen (gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry))) == 0)
+ {
+ select_first_row (dialog);
+ }
+ }
+
+ centre_selected_row (dialog);
}
static gboolean
-is_standard_icon_name (const gchar *icon_name)
+is_standard_icon_name (const gchar * icon_name)
{
- GQuark quark;
-
- quark = g_quark_try_string (icon_name);
-
- if (quark == 0)
- return FALSE;
+ GQuark quark;
+
+ quark = g_quark_try_string (icon_name);
- return (g_hash_table_lookup (standard_icon_quarks, GUINT_TO_POINTER (quark)) != NULL);
+ if (quark == 0)
+ return FALSE;
+
+ return (g_hash_table_lookup (standard_icon_quarks, GUINT_TO_POINTER (quark))
+ != NULL);
}
static void
-cleanup_after_load (GladeNamedIconChooserDialog *dialog)
+cleanup_after_load (GladeNamedIconChooserDialog * dialog)
{
- GDK_THREADS_ENTER ();
+ GDK_THREADS_ENTER ();
+
+ dialog->priv->load_id = 0;
- dialog->priv->load_id = 0;
-
- pending_select_name_process (dialog);
+ pending_select_name_process (dialog);
- set_busy_cursor (dialog, FALSE);
-
- GDK_THREADS_LEAVE ();
+ set_busy_cursor (dialog, FALSE);
+
+ GDK_THREADS_LEAVE ();
}
static void
-chooser_set_model (GladeNamedIconChooserDialog *dialog)
-{
-
- /* filter model */
- dialog->priv->filter_model = gtk_tree_model_filter_new (GTK_TREE_MODEL (dialog->priv->icons_store), NULL);
-
- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->priv->filter_model),
- (GtkTreeModelFilterVisibleFunc) filter_visible_func,
- dialog,
- NULL);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view), dialog->priv->filter_model);
- g_object_unref (dialog->priv->filter_model);
-
- gtk_entry_completion_set_model (dialog->priv->entry_completion, GTK_TREE_MODEL (dialog->priv->icons_store));
- gtk_entry_completion_set_text_column (dialog->priv->entry_completion, ICONS_NAME_COLUMN);
-
- gtk_tree_view_set_search_column (GTK_TREE_VIEW (dialog->priv->icons_view), ICONS_NAME_COLUMN);
-
- dialog->priv->icons_loaded = TRUE;
+chooser_set_model (GladeNamedIconChooserDialog * dialog)
+{
+
+ /* filter model */
+ dialog->priv->filter_model =
+ gtk_tree_model_filter_new (GTK_TREE_MODEL (dialog->priv->icons_store),
+ NULL);
+
+ gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER
+ (dialog->priv->filter_model),
+ (GtkTreeModelFilterVisibleFunc)
+ filter_visible_func, dialog, NULL);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view),
+ dialog->priv->filter_model);
+ g_object_unref (dialog->priv->filter_model);
+
+ gtk_entry_completion_set_model (dialog->priv->entry_completion,
+ GTK_TREE_MODEL (dialog->priv->icons_store));
+ gtk_entry_completion_set_text_column (dialog->priv->entry_completion,
+ ICONS_NAME_COLUMN);
+
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (dialog->priv->icons_view),
+ ICONS_NAME_COLUMN);
+
+ dialog->priv->icons_loaded = TRUE;
}
typedef struct
{
- gchar *name;
- gint context;
+ gchar *name;
+ gint context;
} IconData;
static gint
-icon_data_compare (IconData *a, IconData *b)
+icon_data_compare (IconData * a, IconData * b)
{
- return g_ascii_strcasecmp (a->name, b->name);
+ return g_ascii_strcasecmp (a->name, b->name);
}
static gboolean
-reload_icons (GladeNamedIconChooserDialog *dialog)
-{
- GtkListStore *store = dialog->priv->icons_store;
- GtkTreeIter iter;
- guint i;
- GList *l, *icons = NULL;
-
- GDK_THREADS_ENTER ();
-
- /* retrieve icon names from each context */
- for (i = 0; i < G_N_ELEMENTS (standard_contexts); i++) {
-
- GList *icons_in_context = gtk_icon_theme_list_icons (dialog->priv->icon_theme,
- standard_contexts[i].name);
-
- for (l = icons_in_context; l; l = l->next) {
-
- IconData *data = g_slice_new (IconData);
-
- data->name = (gchar *) l->data;
- data->context = i;
-
- icons = g_list_prepend (icons, data);
- }
-
- g_list_free (icons_in_context);
- }
-
- /* sort icon names */
- icons = g_list_sort (icons, (GCompareFunc) icon_data_compare);
-
- /* put into to model */
- for (l = icons; l; l = l->next) {
-
- IconData *data = (IconData *) l->data;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- ICONS_CONTEXT_COLUMN, data->context,
- ICONS_STANDARD_COLUMN, is_standard_icon_name (data->name),
- ICONS_NAME_COLUMN, data->name,
- -1);
-
- g_free (data->name);
- g_slice_free (IconData, data);
- }
-
- g_list_free (icons);
-
- chooser_set_model (dialog);
-
- GDK_THREADS_LEAVE ();
-
- return FALSE;
+reload_icons (GladeNamedIconChooserDialog * dialog)
+{
+ GtkListStore *store = dialog->priv->icons_store;
+ GtkTreeIter iter;
+ guint i;
+ GList *l, *icons = NULL;
+
+ GDK_THREADS_ENTER ();
+
+ /* retrieve icon names from each context */
+ for (i = 0; i < G_N_ELEMENTS (standard_contexts); i++)
+ {
+
+ GList *icons_in_context =
+ gtk_icon_theme_list_icons (dialog->priv->icon_theme,
+ standard_contexts[i].name);
+
+ for (l = icons_in_context; l; l = l->next)
+ {
+
+ IconData *data = g_slice_new (IconData);
+
+ data->name = (gchar *) l->data;
+ data->context = i;
+
+ icons = g_list_prepend (icons, data);
+ }
+
+ g_list_free (icons_in_context);
+ }
+
+ /* sort icon names */
+ icons = g_list_sort (icons, (GCompareFunc) icon_data_compare);
+
+ /* put into to model */
+ for (l = icons; l; l = l->next)
+ {
+
+ IconData *data = (IconData *) l->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ ICONS_CONTEXT_COLUMN, data->context,
+ ICONS_STANDARD_COLUMN,
+ is_standard_icon_name (data->name), ICONS_NAME_COLUMN,
+ data->name, -1);
+
+ g_free (data->name);
+ g_slice_free (IconData, data);
+ }
+
+ g_list_free (icons);
+
+ chooser_set_model (dialog);
+
+ GDK_THREADS_LEAVE ();
+
+ return FALSE;
}
static void
-change_icon_theme (GladeNamedIconChooserDialog *dialog)
+change_icon_theme (GladeNamedIconChooserDialog * dialog)
{
- if (dialog->priv->icon_theme == NULL)
- dialog->priv->icon_theme = get_icon_theme_for_widget (GTK_WIDGET (dialog));
+ if (dialog->priv->icon_theme == NULL)
+ dialog->priv->icon_theme = get_icon_theme_for_widget (GTK_WIDGET (dialog));
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view), NULL);
- gtk_list_store_clear (dialog->priv->icons_store);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->icons_view), NULL);
+ gtk_list_store_clear (dialog->priv->icons_store);
- set_busy_cursor (dialog, TRUE);
+ set_busy_cursor (dialog, TRUE);
- dialog->priv->load_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE + 300,
- (GSourceFunc) reload_icons,
- dialog,
- (GDestroyNotify) cleanup_after_load);
+ dialog->priv->load_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE + 300,
+ (GSourceFunc) reload_icons,
+ dialog,
+ (GDestroyNotify) cleanup_after_load);
}
static void
-glade_named_icon_chooser_dialog_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen)
+glade_named_icon_chooser_dialog_screen_changed (GtkWidget * widget,
+ GdkScreen * previous_screen)
{
- GladeNamedIconChooserDialog *dialog;
-
- dialog = GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
+ GladeNamedIconChooserDialog *dialog;
+
+ dialog = GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
- if (GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->screen_changed)
- GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->screen_changed (widget, previous_screen);
+ if (GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->
+ screen_changed)
+ GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->
+ screen_changed (widget, previous_screen);
- if (gtk_widget_get_mapped (widget))
- change_icon_theme (dialog);
+ if (gtk_widget_get_mapped (widget))
+ change_icon_theme (dialog);
}
-static GtkWidget*
-create_icons_view (GladeNamedIconChooserDialog *dialog)
-{
- GtkTreeView *view;
- GtkTreeViewColumn *column;
- GtkCellRenderer *pixbuf_renderer, *text_renderer;
-
- view = GTK_TREE_VIEW (gtk_tree_view_new ());
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_min_width (column, 56);
- gtk_tree_view_column_set_title (column, NULL);
- pixbuf_renderer = gtk_cell_renderer_pixbuf_new ();
-
- gtk_tree_view_column_pack_start (column,
- pixbuf_renderer,
- TRUE);
-
- gtk_tree_view_column_set_attributes (column,
- pixbuf_renderer,
- "icon-name", ICONS_NAME_COLUMN,
- NULL);
-
- gtk_tree_view_append_column (view, column);
- g_object_set (pixbuf_renderer,
- "xpad", 2,
- "xalign", 1.0,
- "stock-size",GTK_ICON_SIZE_MENU,
- NULL);
-
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, "Name");
- text_renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (text_renderer),
- "ellipsize", PANGO_ELLIPSIZE_END,
- "yalign", 0.0,
- NULL);
-
- gtk_tree_view_column_pack_start (column,
- text_renderer,
- TRUE);
-
- gtk_tree_view_column_set_attributes (column,
- text_renderer,
- "text", ICONS_NAME_COLUMN,
- NULL);
-
-
- gtk_tree_view_append_column (view, column);
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_column_set_resizable (column, FALSE);
-
- gtk_tree_view_set_headers_visible (view, FALSE);
-
- gtk_tree_view_set_enable_search (view, TRUE);
- gtk_tree_view_set_search_equal_func (view,
- (GtkTreeViewSearchEqualFunc) search_equal_func,
- dialog,
- NULL);
-
- g_signal_connect (view, "row-activated",
- G_CALLBACK (icons_row_activated_cb),
- dialog);
-
- g_signal_connect (gtk_tree_view_get_selection (view), "changed",
- G_CALLBACK (icons_selection_changed_cb),
- dialog);
-
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view), GTK_SELECTION_BROWSE);
-
- dialog->priv->selection = gtk_tree_view_get_selection (view);
-
- gtk_tree_view_set_rules_hint (view, TRUE);
-
- gtk_widget_show (GTK_WIDGET (view));
-
- return GTK_WIDGET (view);
+static GtkWidget *
+create_icons_view (GladeNamedIconChooserDialog * dialog)
+{
+ GtkTreeView *view;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *pixbuf_renderer, *text_renderer;
+
+ view = GTK_TREE_VIEW (gtk_tree_view_new ());
+
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_min_width (column, 56);
+ gtk_tree_view_column_set_title (column, NULL);
+ pixbuf_renderer = gtk_cell_renderer_pixbuf_new ();
+
+ gtk_tree_view_column_pack_start (column, pixbuf_renderer, TRUE);
+
+ gtk_tree_view_column_set_attributes (column,
+ pixbuf_renderer,
+ "icon-name", ICONS_NAME_COLUMN, NULL);
+
+ gtk_tree_view_append_column (view, column);
+ g_object_set (pixbuf_renderer,
+ "xpad", 2,
+ "xalign", 1.0, "stock-size", GTK_ICON_SIZE_MENU, NULL);
+
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_title (column, "Name");
+ text_renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (text_renderer),
+ "ellipsize", PANGO_ELLIPSIZE_END, "yalign", 0.0, NULL);
+
+ gtk_tree_view_column_pack_start (column, text_renderer, TRUE);
+
+ gtk_tree_view_column_set_attributes (column,
+ text_renderer,
+ "text", ICONS_NAME_COLUMN, NULL);
+
+
+ gtk_tree_view_append_column (view, column);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_column_set_resizable (column, FALSE);
+
+ gtk_tree_view_set_headers_visible (view, FALSE);
+
+ gtk_tree_view_set_enable_search (view, TRUE);
+ gtk_tree_view_set_search_equal_func (view,
+ (GtkTreeViewSearchEqualFunc)
+ search_equal_func, dialog, NULL);
+
+ g_signal_connect (view, "row-activated",
+ G_CALLBACK (icons_row_activated_cb), dialog);
+
+ g_signal_connect (gtk_tree_view_get_selection (view), "changed",
+ G_CALLBACK (icons_selection_changed_cb), dialog);
+
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view),
+ GTK_SELECTION_BROWSE);
+
+ dialog->priv->selection = gtk_tree_view_get_selection (view);
+
+ gtk_tree_view_set_rules_hint (view, TRUE);
+
+ gtk_widget_show (GTK_WIDGET (view));
+
+ return GTK_WIDGET (view);
}
/* sets the 'list-standard' state and refilters the icons model */
static void
-button_toggled (GtkToggleButton *button, GladeNamedIconChooserDialog *dialog)
+button_toggled (GtkToggleButton * button, GladeNamedIconChooserDialog * dialog)
{
- dialog->priv->settings_list_standard = gtk_toggle_button_get_active (button);
+ dialog->priv->settings_list_standard = gtk_toggle_button_get_active (button);
- if (dialog->priv->filter_model != NULL)
- filter_icons_model (dialog);
+ if (dialog->priv->filter_model != NULL)
+ filter_icons_model (dialog);
}
-static GHashTable*
+static GHashTable *
create_standard_icon_quarks ()
{
- GHashTable *table;
- GQuark quark;
- guint i;
-
- table = g_hash_table_new (NULL, NULL);
-
- for (i = 0; i < G_N_ELEMENTS (standard_icon_names); i++)
- {
-
- quark = g_quark_from_static_string (standard_icon_names[i]);
-
- g_hash_table_insert (table,
- GUINT_TO_POINTER (quark),
- GUINT_TO_POINTER (quark));
- }
-
- return table;
+ GHashTable *table;
+ GQuark quark;
+ guint i;
+
+ table = g_hash_table_new (NULL, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (standard_icon_names); i++)
+ {
+
+ quark = g_quark_from_static_string (standard_icon_names[i]);
+
+ g_hash_table_insert (table,
+ GUINT_TO_POINTER (quark), GUINT_TO_POINTER (quark));
+ }
+
+ return table;
}
static void
-glade_named_icon_chooser_dialog_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+glade_named_icon_chooser_dialog_style_set (GtkWidget * widget,
+ GtkStyle * previous_style)
{
- if (gtk_widget_has_screen (widget) && gtk_widget_get_mapped (widget))
- change_icon_theme (GLADE_NAMED_ICON_CHOOSER_DIALOG (widget));
+ if (gtk_widget_has_screen (widget) && gtk_widget_get_mapped (widget))
+ change_icon_theme (GLADE_NAMED_ICON_CHOOSER_DIALOG (widget));
}
/* override GtkWidget::show_all since we have internal widgets we wish to keep
* hidden unless we decide otherwise, like the list-standard-icons-only checkbox.
*/
static void
-glade_named_icon_chooser_dialog_show_all (GtkWidget *widget)
+glade_named_icon_chooser_dialog_show_all (GtkWidget * widget)
{
- gtk_widget_show (widget);
+ gtk_widget_show (widget);
}
/* Handler for GtkWindow::set-focus; this is where we save the last-focused
* widget on our toplevel. See glade_named_icon_chooser_dialog_hierarchy_changed()
*/
static void
-glade_named_icon_chooser_dialog_set_focus (GtkWindow *window,
- GtkWidget *focus)
+glade_named_icon_chooser_dialog_set_focus (GtkWindow * window,
+ GtkWidget * focus)
{
-
- GTK_WINDOW_CLASS (glade_named_icon_chooser_dialog_parent_class)->set_focus (window, focus);
- GLADE_NAMED_ICON_CHOOSER_DIALOG (window)->priv->last_focus_widget = gtk_window_get_focus (window);
+ GTK_WINDOW_CLASS (glade_named_icon_chooser_dialog_parent_class)->
+ set_focus (window, focus);
+
+ GLADE_NAMED_ICON_CHOOSER_DIALOG (window)->priv->last_focus_widget =
+ gtk_window_get_focus (window);
}
static void
-glade_named_icon_chooser_dialog_finalize (GObject *object)
-{
- GladeNamedIconChooserDialog *dialog = GLADE_NAMED_ICON_CHOOSER_DIALOG (object);
-
- if (dialog->priv->pending_select_name)
- {
- g_free (dialog->priv->pending_select_name);
- dialog->priv->pending_select_name = NULL;
- }
-
- G_OBJECT_CLASS (glade_named_icon_chooser_dialog_parent_class)->finalize (object);
+glade_named_icon_chooser_dialog_finalize (GObject * object)
+{
+ GladeNamedIconChooserDialog *dialog =
+ GLADE_NAMED_ICON_CHOOSER_DIALOG (object);
+
+ if (dialog->priv->pending_select_name)
+ {
+ g_free (dialog->priv->pending_select_name);
+ dialog->priv->pending_select_name = NULL;
+ }
+
+ G_OBJECT_CLASS (glade_named_icon_chooser_dialog_parent_class)->
+ finalize (object);
}
static void
-glade_named_icon_chooser_dialog_map (GtkWidget *widget)
+glade_named_icon_chooser_dialog_map (GtkWidget * widget)
{
- GladeNamedIconChooserDialog *dialog = GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
+ GladeNamedIconChooserDialog *dialog =
+ GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
+
+ GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->map (widget);
+
+ settings_load (dialog);
- GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->map (widget);
-
- settings_load (dialog);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->button),
- dialog->priv->settings_list_standard);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->button),
+ dialog->priv->settings_list_standard);
- gtk_widget_grab_focus (dialog->priv->icons_view);
+ gtk_widget_grab_focus (dialog->priv->icons_view);
}
static void
-glade_named_icon_chooser_dialog_unmap (GtkWidget *widget)
+glade_named_icon_chooser_dialog_unmap (GtkWidget * widget)
{
- GladeNamedIconChooserDialog *dialog = GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
+ GladeNamedIconChooserDialog *dialog =
+ GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
- settings_save (dialog);
+ settings_save (dialog);
- GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->unmap (widget);
+ GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->
+ unmap (widget);
}
/* we load the icons in expose() because we want the widget
* to be fully painted before loading begins
- */
+ */
static gboolean
-glade_named_icon_chooser_dialog_draw (GtkWidget *widget,
- cairo_t *cr)
+glade_named_icon_chooser_dialog_draw (GtkWidget * widget, cairo_t * cr)
{
- GladeNamedIconChooserDialog *dialog = GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
- gboolean retval;
-
- retval = GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->draw (widget,
- cr);
- if (!dialog->priv->icons_loaded)
- {
- change_icon_theme (GLADE_NAMED_ICON_CHOOSER_DIALOG (widget));
- dialog->priv->icons_loaded = TRUE;
- }
-
- return retval;
+ GladeNamedIconChooserDialog *dialog =
+ GLADE_NAMED_ICON_CHOOSER_DIALOG (widget);
+ gboolean retval;
+
+ retval =
+ GTK_WIDGET_CLASS (glade_named_icon_chooser_dialog_parent_class)->
+ draw (widget, cr);
+ if (!dialog->priv->icons_loaded)
+ {
+ change_icon_theme (GLADE_NAMED_ICON_CHOOSER_DIALOG (widget));
+ dialog->priv->icons_loaded = TRUE;
+ }
+
+ return retval;
}
static void
-response_cb (GtkDialog *dialog,
- gint response_id)
-{
- GladeNamedIconChooserDialogPrivate *priv;
-
- priv = GLADE_NAMED_ICON_CHOOSER_DIALOG_GET_PRIVATE (dialog);
-
- /* Act only on response IDs we recognize */
- if (!(response_id == GTK_RESPONSE_ACCEPT
- || response_id == GTK_RESPONSE_OK
- || response_id == GTK_RESPONSE_YES
- || response_id == GTK_RESPONSE_APPLY))
- return;
-
- if (!should_respond (GLADE_NAMED_ICON_CHOOSER_DIALOG (dialog)))
- {
- g_signal_stop_emission_by_name (dialog, "response");
- }
+response_cb (GtkDialog * dialog, gint response_id)
+{
+ GladeNamedIconChooserDialogPrivate *priv;
+
+ priv = GLADE_NAMED_ICON_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+
+ /* Act only on response IDs we recognize */
+ if (!(response_id == GTK_RESPONSE_ACCEPT
+ || response_id == GTK_RESPONSE_OK
+ || response_id == GTK_RESPONSE_YES
+ || response_id == GTK_RESPONSE_APPLY))
+ return;
+
+ if (!should_respond (GLADE_NAMED_ICON_CHOOSER_DIALOG (dialog)))
+ {
+ g_signal_stop_emission_by_name (dialog, "response");
+ }
}
/* we intercept the GladeNamedIconChooser::icon-activated signal and try to
* make the dialog emit a valid response signal
*/
static void
-icon_activated_cb (GladeNamedIconChooserDialog *dialog)
-{
- GList *children, *l;
-
- children = gtk_container_get_children (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))));
-
- for (l = children; l; l = l->next)
- {
- GtkWidget *widget;
- gint response_id;
-
- widget = GTK_WIDGET (l->data);
- response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
-
- if (response_id == GTK_RESPONSE_ACCEPT ||
- response_id == GTK_RESPONSE_OK ||
- response_id == GTK_RESPONSE_YES ||
- response_id == GTK_RESPONSE_APPLY)
- {
- g_list_free (children);
-
- gtk_dialog_response (GTK_DIALOG (dialog), response_id);
-
- return;
- }
- }
- g_list_free (children);
+icon_activated_cb (GladeNamedIconChooserDialog * dialog)
+{
+ GList *children, *l;
+
+ children =
+ gtk_container_get_children (GTK_CONTAINER
+ (gtk_dialog_get_action_area
+ (GTK_DIALOG (dialog))));
+
+ for (l = children; l; l = l->next)
+ {
+ GtkWidget *widget;
+ gint response_id;
+
+ widget = GTK_WIDGET (l->data);
+ response_id =
+ gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
+
+ if (response_id == GTK_RESPONSE_ACCEPT ||
+ response_id == GTK_RESPONSE_OK ||
+ response_id == GTK_RESPONSE_YES || response_id == GTK_RESPONSE_APPLY)
+ {
+ g_list_free (children);
+
+ gtk_dialog_response (GTK_DIALOG (dialog), response_id);
+
+ return;
+ }
+ }
+ g_list_free (children);
}
/* we intercept the GladeNamedIconChooser::selection-changed signal and try to
* make the affirmative response button insensitive when the selection is empty
*/
static void
-selection_changed_cb (GladeNamedIconChooserDialog *dialog)
-{
- GList *children, *l;
- gchar *icon_name;
-
- children = gtk_container_get_children (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))));
-
- for (l = children; l; l = l->next)
- {
- GtkWidget *widget;
- gint response_id;
-
- widget = GTK_WIDGET (l->data);
- response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
-
- if (response_id == GTK_RESPONSE_ACCEPT ||
- response_id == GTK_RESPONSE_OK ||
- response_id == GTK_RESPONSE_YES ||
- response_id == GTK_RESPONSE_APPLY)
- {
- icon_name = glade_named_icon_chooser_dialog_get_icon_name (dialog);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
- response_id,
- icon_name != NULL);
- g_free (icon_name);
- g_list_free (children);
- return;
- }
- }
- g_list_free (children);
+selection_changed_cb (GladeNamedIconChooserDialog * dialog)
+{
+ GList *children, *l;
+ gchar *icon_name;
+
+ children =
+ gtk_container_get_children (GTK_CONTAINER
+ (gtk_dialog_get_action_area
+ (GTK_DIALOG (dialog))));
+
+ for (l = children; l; l = l->next)
+ {
+ GtkWidget *widget;
+ gint response_id;
+
+ widget = GTK_WIDGET (l->data);
+ response_id =
+ gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
+
+ if (response_id == GTK_RESPONSE_ACCEPT ||
+ response_id == GTK_RESPONSE_OK ||
+ response_id == GTK_RESPONSE_YES || response_id == GTK_RESPONSE_APPLY)
+ {
+ icon_name = glade_named_icon_chooser_dialog_get_icon_name (dialog);
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ response_id, icon_name != NULL);
+ g_free (icon_name);
+ g_list_free (children);
+ return;
+ }
+ }
+ g_list_free (children);
}
static void
-glade_named_icon_chooser_dialog_init (GladeNamedIconChooserDialog *dialog)
-{
- GtkWidget *contents;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *sw;
- GtkWidget *label;
- GtkWidget *hpaned;
- GtkWidget *content_area;
- GtkWidget *action_area;
- GtkSizeGroup *group;
-
- dialog->priv = GLADE_NAMED_ICON_CHOOSER_DIALOG_GET_PRIVATE (dialog);
-
- dialog->priv->filter_model = NULL;
- dialog->priv->icons_store = NULL;
- dialog->priv->context_id = -1;
- dialog->priv->pending_select_name = NULL;
- dialog->priv->last_focus_widget = NULL;
- dialog->priv->icons_loaded = FALSE;
-
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Named Icon Chooser"));
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), 610, 480);
+glade_named_icon_chooser_dialog_init (GladeNamedIconChooserDialog * dialog)
+{
+ GtkWidget *contents;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *sw;
+ GtkWidget *label;
+ GtkWidget *hpaned;
+ GtkWidget *content_area;
+ GtkWidget *action_area;
+ GtkSizeGroup *group;
+
+ dialog->priv = GLADE_NAMED_ICON_CHOOSER_DIALOG_GET_PRIVATE (dialog);
+
+ dialog->priv->filter_model = NULL;
+ dialog->priv->icons_store = NULL;
+ dialog->priv->context_id = -1;
+ dialog->priv->pending_select_name = NULL;
+ dialog->priv->last_focus_widget = NULL;
+ dialog->priv->icons_loaded = FALSE;
+
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Named Icon Chooser"));
+
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 610, 480);
#if !GTK_CHECK_VERSION (2, 21, 8)
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
#endif
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (content_area), 12);
- gtk_box_set_spacing (GTK_BOX (content_area), 12);
- action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
- gtk_container_set_border_width (GTK_CONTAINER (action_area), 0);
- gtk_box_set_spacing (GTK_BOX (action_area), 6);
-
- /* We do a signal connection here rather than overriding the method in
- * class_init because GtkDialog::response is a RUN_LAST signal. We want *our*
- * handler to be run *first*, regardless of whether the user installs response
- * handlers of his own.
- */
- g_signal_connect (dialog, "response",
- G_CALLBACK (response_cb),
- NULL);
-
- g_signal_connect (dialog, "icon-activated",
- G_CALLBACK (icon_activated_cb),
- NULL);
-
- g_signal_connect (dialog, "selection-changed",
- G_CALLBACK (selection_changed_cb),
- NULL);
-
-
- if (standard_icon_quarks == NULL)
- standard_icon_quarks = create_standard_icon_quarks ();
-
-
- gtk_widget_push_composite_child ();
-
- contents = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (contents);
-
- label = gtk_label_new_with_mnemonic (_("Icon _Name:"));
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_widget_show (label);
-
- dialog->priv->entry = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (dialog->priv->entry), TRUE);
- gtk_entry_set_width_chars (GTK_ENTRY (dialog->priv->entry), 40);
- g_object_set (G_OBJECT (dialog->priv->entry), "truncate-multiline", TRUE, NULL);
- g_signal_connect (G_OBJECT (dialog->priv->entry), "changed",
- G_CALLBACK (changed_text_handler), dialog);
- g_signal_connect (G_OBJECT (dialog->priv->entry), "insert-text",
- G_CALLBACK (insert_text_handler), dialog);
- gtk_widget_show (dialog->priv->entry);
-
- dialog->priv->entry_completion = gtk_entry_completion_new ();
- gtk_entry_set_completion (GTK_ENTRY (dialog->priv->entry), dialog->priv->entry_completion);
- gtk_entry_completion_set_popup_completion (dialog->priv->entry_completion, FALSE);
- gtk_entry_completion_set_inline_completion (dialog->priv->entry_completion, TRUE);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->priv->entry);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_widget_show (hbox);
-
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), dialog->priv->entry, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (contents), hbox, FALSE, FALSE, 6);
-
- hpaned = gtk_hpaned_new ();
- gtk_paned_set_position (GTK_PANED (hpaned), 150);
- gtk_widget_show (hpaned);
-
- dialog->priv->contexts_view = create_contexts_view (dialog);
- dialog->priv->icons_view = create_icons_view (dialog);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-
- label = gtk_label_new_with_mnemonic (_("C_ontexts:"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->priv->contexts_view);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_size_group_add_widget (group, label);
- gtk_widget_show (label);
-
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
- gtk_widget_show (sw);
-
- gtk_container_add (GTK_CONTAINER (sw), dialog->priv->contexts_view);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_paned_pack1 (GTK_PANED (hpaned), vbox, FALSE, FALSE);
-
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- label = gtk_label_new_with_mnemonic (_("Icon Na_mes:"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->priv->icons_view);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_size_group_add_widget (group, label);
- gtk_widget_show (label);
-
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
- gtk_widget_show (sw);
-
- gtk_container_add (GTK_CONTAINER (sw), dialog->priv->icons_view);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_paned_pack2 (GTK_PANED (hpaned), vbox, TRUE, FALSE);
-
- gtk_box_pack_start (GTK_BOX (contents), hpaned, TRUE, TRUE, 0);
-
-
- g_object_unref (G_OBJECT (group));
-
- dialog->priv->button = gtk_check_button_new_with_mnemonic (_("_List standard icons only"));
- gtk_widget_show (dialog->priv->button);
-
- g_signal_connect (dialog->priv->button, "toggled",
- G_CALLBACK (button_toggled),
- dialog);
-
- gtk_box_pack_start (GTK_BOX (contents), dialog->priv->button, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (content_area), contents, TRUE, TRUE, 0);
-
- gtk_widget_pop_composite_child ();
-
- /* underlying model */
- dialog->priv->icons_store = gtk_list_store_new (ICONS_N_COLUMNS,
- G_TYPE_UINT,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING);
-
-
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (content_area), 12);
+ gtk_box_set_spacing (GTK_BOX (content_area), 12);
+ action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 0);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
+
+ /* We do a signal connection here rather than overriding the method in
+ * class_init because GtkDialog::response is a RUN_LAST signal. We want *our*
+ * handler to be run *first*, regardless of whether the user installs response
+ * handlers of his own.
+ */
+ g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
+
+ g_signal_connect (dialog, "icon-activated",
+ G_CALLBACK (icon_activated_cb), NULL);
+
+ g_signal_connect (dialog, "selection-changed",
+ G_CALLBACK (selection_changed_cb), NULL);
+
+
+ if (standard_icon_quarks == NULL)
+ standard_icon_quarks = create_standard_icon_quarks ();
+
+
+ gtk_widget_push_composite_child ();
+
+ contents = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (contents);
+
+ label = gtk_label_new_with_mnemonic (_("Icon _Name:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_widget_show (label);
+
+ dialog->priv->entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->priv->entry), TRUE);
+ gtk_entry_set_width_chars (GTK_ENTRY (dialog->priv->entry), 40);
+ g_object_set (G_OBJECT (dialog->priv->entry), "truncate-multiline", TRUE,
+ NULL);
+ g_signal_connect (G_OBJECT (dialog->priv->entry), "changed",
+ G_CALLBACK (changed_text_handler), dialog);
+ g_signal_connect (G_OBJECT (dialog->priv->entry), "insert-text",
+ G_CALLBACK (insert_text_handler), dialog);
+ gtk_widget_show (dialog->priv->entry);
+
+ dialog->priv->entry_completion = gtk_entry_completion_new ();
+ gtk_entry_set_completion (GTK_ENTRY (dialog->priv->entry),
+ dialog->priv->entry_completion);
+ gtk_entry_completion_set_popup_completion (dialog->priv->entry_completion,
+ FALSE);
+ gtk_entry_completion_set_inline_completion (dialog->priv->entry_completion,
+ TRUE);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->priv->entry);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox);
+
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->priv->entry, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (contents), hbox, FALSE, FALSE, 6);
+
+ hpaned = gtk_hpaned_new ();
+ gtk_paned_set_position (GTK_PANED (hpaned), 150);
+ gtk_widget_show (hpaned);
+
+ dialog->priv->contexts_view = create_contexts_view (dialog);
+ dialog->priv->icons_view = create_icons_view (dialog);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+
+ label = gtk_label_new_with_mnemonic (_("C_ontexts:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label),
+ dialog->priv->contexts_view);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_size_group_add_widget (group, label);
+ gtk_widget_show (label);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+ gtk_widget_show (sw);
+
+ gtk_container_add (GTK_CONTAINER (sw), dialog->priv->contexts_view);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_paned_pack1 (GTK_PANED (hpaned), vbox, FALSE, FALSE);
+
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ label = gtk_label_new_with_mnemonic (_("Icon Na_mes:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->priv->icons_view);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_size_group_add_widget (group, label);
+ gtk_widget_show (label);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+ gtk_widget_show (sw);
+
+ gtk_container_add (GTK_CONTAINER (sw), dialog->priv->icons_view);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_paned_pack2 (GTK_PANED (hpaned), vbox, TRUE, FALSE);
+
+ gtk_box_pack_start (GTK_BOX (contents), hpaned, TRUE, TRUE, 0);
+
+
+ g_object_unref (G_OBJECT (group));
+
+ dialog->priv->button =
+ gtk_check_button_new_with_mnemonic (_("_List standard icons only"));
+ gtk_widget_show (dialog->priv->button);
+
+ g_signal_connect (dialog->priv->button, "toggled",
+ G_CALLBACK (button_toggled), dialog);
+
+ gtk_box_pack_start (GTK_BOX (contents), dialog->priv->button, FALSE, FALSE,
+ 0);
+ gtk_box_pack_start (GTK_BOX (content_area), contents, TRUE, TRUE, 0);
+
+ gtk_widget_pop_composite_child ();
+
+ /* underlying model */
+ dialog->priv->icons_store = gtk_list_store_new (ICONS_N_COLUMNS,
+ G_TYPE_UINT,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING);
+
+
}
static void
-glade_named_icon_chooser_dialog_class_init (GladeNamedIconChooserDialogClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkWindowClass *window_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- window_class = GTK_WINDOW_CLASS (klass);
-
- object_class->finalize = glade_named_icon_chooser_dialog_finalize;
-
- widget_class->map = glade_named_icon_chooser_dialog_map;
- widget_class->unmap = glade_named_icon_chooser_dialog_unmap;
- widget_class->draw = glade_named_icon_chooser_dialog_draw;
- widget_class->show_all = glade_named_icon_chooser_dialog_show_all;
- widget_class->style_set = glade_named_icon_chooser_dialog_style_set;
- widget_class->screen_changed = glade_named_icon_chooser_dialog_screen_changed;
-
- window_class->set_focus = glade_named_icon_chooser_dialog_set_focus;
-
- /**
+glade_named_icon_chooser_dialog_class_init (GladeNamedIconChooserDialogClass *
+ klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkWindowClass *window_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+ window_class = GTK_WINDOW_CLASS (klass);
+
+ object_class->finalize = glade_named_icon_chooser_dialog_finalize;
+
+ widget_class->map = glade_named_icon_chooser_dialog_map;
+ widget_class->unmap = glade_named_icon_chooser_dialog_unmap;
+ widget_class->draw = glade_named_icon_chooser_dialog_draw;
+ widget_class->show_all = glade_named_icon_chooser_dialog_show_all;
+ widget_class->style_set = glade_named_icon_chooser_dialog_style_set;
+ widget_class->screen_changed = glade_named_icon_chooser_dialog_screen_changed;
+
+ window_class->set_focus = glade_named_icon_chooser_dialog_set_focus;
+
+ /**
* GladeNamedIconChooserDialog::icon-activated
* @chooser: the object which received the signal
*
@@ -1538,16 +1558,15 @@ glade_named_icon_chooser_dialog_class_init (GladeNamedIconChooserDialogClass *kl
* in the recently used resources list, or by pressing
* <keycap>Enter</keycap>.
*/
- dialog_signals[ICON_ACTIVATED] =
- g_signal_new ("icon-activated",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeNamedIconChooserDialogClass, icon_activated),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
+ dialog_signals[ICON_ACTIVATED] =
+ g_signal_new ("icon-activated",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeNamedIconChooserDialogClass,
+ icon_activated), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ /**
* GladeNamedIconChooserDialog::selection-changed
* @chooser: the object which received the signal
*
@@ -1556,195 +1575,185 @@ glade_named_icon_chooser_dialog_class_init (GladeNamedIconChooserDialogClass *kl
* modifies the selection with the mouse or the keyboard, or when
* explicitely calling functions to change the selection.
*/
- dialog_signals[SELECTION_CHANGED] =
- g_signal_new ("selection-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeNamedIconChooserDialogClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
-
- g_type_class_add_private (klass, sizeof (GladeNamedIconChooserDialogPrivate));
+ dialog_signals[SELECTION_CHANGED] =
+ g_signal_new ("selection-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeNamedIconChooserDialogClass,
+ selection_changed), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+
+ g_type_class_add_private (klass, sizeof (GladeNamedIconChooserDialogPrivate));
}
static gboolean
-should_respond (GladeNamedIconChooserDialog *dialog)
-{
- gchar *icon_name;
-
- /* is there an icon selected? */
- icon_name = glade_named_icon_chooser_dialog_get_icon_name (dialog);
- if (!icon_name)
- return FALSE;
-
- g_free (icon_name);
- return TRUE;
+should_respond (GladeNamedIconChooserDialog * dialog)
+{
+ gchar *icon_name;
+
+ /* is there an icon selected? */
+ icon_name = glade_named_icon_chooser_dialog_get_icon_name (dialog);
+ if (!icon_name)
+ return FALSE;
+
+ g_free (icon_name);
+ return TRUE;
}
/* get's the name of the configuration file */
static gchar *
get_config_filename (void)
{
- return g_build_filename (g_get_user_config_dir (), "gladeui", "config", NULL);
+ return g_build_filename (g_get_user_config_dir (), "gladeui", "config", NULL);
}
/* get's the name of the directory that contains the config file */
static char *
get_config_dirname (void)
{
- return g_build_filename (g_get_user_config_dir (), "gladeui", NULL);
+ return g_build_filename (g_get_user_config_dir (), "gladeui", NULL);
}
/* loads the configuration settings */
static void
-settings_load (GladeNamedIconChooserDialog *dialog)
-{
- GKeyFile *keyfile;
- gboolean success, boolean_value;
- gchar *filename;
- GError *error = NULL;
-
- keyfile = g_key_file_new ();
-
- filename = get_config_filename ();
- success = g_key_file_load_from_file (keyfile,
- filename,
- G_KEY_FILE_NONE,
- &error);
- g_free (filename);
-
- if (!success)
- {
-
- dialog->priv->settings_list_standard = DEFAULT_SETTING_LIST_STANDARD_ONLY;
-
- g_clear_error (&error);
- g_key_file_free (keyfile);
- return;
- }
-
-
- boolean_value = g_key_file_get_boolean (keyfile,
- "Named Icon Chooser",
- "ListStandardOnly",
- &error);
- if (error)
- {
- dialog->priv->settings_list_standard = DEFAULT_SETTING_LIST_STANDARD_ONLY;
- g_clear_error (&error);
- }
- else
- {
- dialog->priv->settings_list_standard = boolean_value;
- }
-
- g_key_file_free (keyfile);
+settings_load (GladeNamedIconChooserDialog * dialog)
+{
+ GKeyFile *keyfile;
+ gboolean success, boolean_value;
+ gchar *filename;
+ GError *error = NULL;
+
+ keyfile = g_key_file_new ();
+
+ filename = get_config_filename ();
+ success = g_key_file_load_from_file (keyfile,
+ filename, G_KEY_FILE_NONE, &error);
+ g_free (filename);
+
+ if (!success)
+ {
+
+ dialog->priv->settings_list_standard = DEFAULT_SETTING_LIST_STANDARD_ONLY;
+
+ g_clear_error (&error);
+ g_key_file_free (keyfile);
+ return;
+ }
+
+
+ boolean_value = g_key_file_get_boolean (keyfile,
+ "Named Icon Chooser",
+ "ListStandardOnly", &error);
+ if (error)
+ {
+ dialog->priv->settings_list_standard = DEFAULT_SETTING_LIST_STANDARD_ONLY;
+ g_clear_error (&error);
+ }
+ else
+ {
+ dialog->priv->settings_list_standard = boolean_value;
+ }
+
+ g_key_file_free (keyfile);
}
/* creates a GKeyFile based on the current settings */
static GKeyFile *
-settings_to_keyfile (GladeNamedIconChooserDialog *dialog)
-{
- GKeyFile *keyfile;
- gboolean retval;
- gchar *filename;
-
- keyfile = g_key_file_new ();
-
- filename = get_config_filename ();
- retval = g_key_file_load_from_file (keyfile,
- get_config_filename (),
- G_KEY_FILE_NONE,
- NULL);
- g_free (filename);
-
- g_key_file_set_boolean (keyfile,
- "Named Icon Chooser",
- "ListStandardOnly",
- dialog->priv->settings_list_standard);
-
- return keyfile;
+settings_to_keyfile (GladeNamedIconChooserDialog * dialog)
+{
+ GKeyFile *keyfile;
+ gboolean retval;
+ gchar *filename;
+
+ keyfile = g_key_file_new ();
+
+ filename = get_config_filename ();
+ retval = g_key_file_load_from_file (keyfile,
+ get_config_filename (),
+ G_KEY_FILE_NONE, NULL);
+ g_free (filename);
+
+ g_key_file_set_boolean (keyfile,
+ "Named Icon Chooser",
+ "ListStandardOnly",
+ dialog->priv->settings_list_standard);
+
+ return keyfile;
}
/* serializes the the current configuration to the config file */
static void
-settings_save (GladeNamedIconChooserDialog *dialog)
-{
- GKeyFile *keyfile;
- gchar *contents;
- gsize contents_length;
- gchar *filename = NULL, *dirname = NULL;
- GError *error = NULL;
-
- keyfile = settings_to_keyfile (dialog);
-
- contents = g_key_file_to_data (keyfile,
- &contents_length,
- &error);
-
- if (error)
- goto out;
-
- filename = get_config_filename ();
-
- if (!g_file_set_contents (filename, contents, contents_length, NULL))
- {
- gchar *dirname;
- gint saved_errno;
-
- dirname = get_config_dirname ();
- if (g_mkdir_with_parents (dirname, 0700) != 0) /* 0700 per the XDG basedir spec */
- {
-
- saved_errno = errno;
- g_set_error (&error,
- G_FILE_ERROR,
- g_file_error_from_errno (saved_errno),
- _("Could not create directory: %s"),
- dirname);
- goto out;
- }
-
- if (!g_file_set_contents (filename, contents, contents_length, &error))
- {
- goto out;
- }
- }
-
- out:
-
- g_free (contents);
- g_free (dirname);
- g_free (filename);
- g_clear_error (&error);
- g_key_file_free (keyfile);
+settings_save (GladeNamedIconChooserDialog * dialog)
+{
+ GKeyFile *keyfile;
+ gchar *contents;
+ gsize contents_length;
+ gchar *filename = NULL, *dirname = NULL;
+ GError *error = NULL;
+
+ keyfile = settings_to_keyfile (dialog);
+
+ contents = g_key_file_to_data (keyfile, &contents_length, &error);
+
+ if (error)
+ goto out;
+
+ filename = get_config_filename ();
+
+ if (!g_file_set_contents (filename, contents, contents_length, NULL))
+ {
+ gchar *dirname;
+ gint saved_errno;
+
+ dirname = get_config_dirname ();
+ if (g_mkdir_with_parents (dirname, 0700) != 0) /* 0700 per the XDG basedir spec */
+ {
+
+ saved_errno = errno;
+ g_set_error (&error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (saved_errno),
+ _("Could not create directory: %s"), dirname);
+ goto out;
+ }
+
+ if (!g_file_set_contents (filename, contents, contents_length, &error))
+ {
+ goto out;
+ }
+ }
+
+out:
+
+ g_free (contents);
+ g_free (dirname);
+ g_free (filename);
+ g_clear_error (&error);
+ g_key_file_free (keyfile);
}
static GtkWidget *
-glade_named_icon_chooser_dialog_new_valist (const gchar *title,
- GtkWindow *parent,
- const gchar *first_button_text,
- va_list varargs)
-{
- GtkWidget *result;
- const char *button_text = first_button_text;
- gint response_id;
-
- result = g_object_new (GLADE_TYPE_NAMED_ICON_CHOOSER_DIALOG,
- "title", title,
- "transient-for", parent,
- NULL);
-
- while (button_text)
- {
- response_id = va_arg (varargs, gint);
- gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
- button_text = va_arg (varargs, const gchar *);
- }
-
- return result;
+glade_named_icon_chooser_dialog_new_valist (const gchar * title,
+ GtkWindow * parent,
+ const gchar * first_button_text,
+ va_list varargs)
+{
+ GtkWidget *result;
+ const char *button_text = first_button_text;
+ gint response_id;
+
+ result = g_object_new (GLADE_TYPE_NAMED_ICON_CHOOSER_DIALOG,
+ "title", title, "transient-for", parent, NULL);
+
+ while (button_text)
+ {
+ response_id = va_arg (varargs, gint);
+ gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
+ button_text = va_arg (varargs, const gchar *);
+ }
+
+ return result;
}
/**
@@ -1761,20 +1770,19 @@ glade_named_icon_chooser_dialog_new_valist (const gchar *title,
* Return value: a new #GladeNamedIconChooserDialog
*/
GtkWidget *
-glade_named_icon_chooser_dialog_new (const gchar *title,
- GtkWindow *parent,
- const gchar *first_button_text,
- ...)
-{
- GtkWidget *result;
- va_list varargs;
-
- va_start (varargs, first_button_text);
- result = glade_named_icon_chooser_dialog_new_valist (title,
- parent,
- first_button_text,
- varargs);
- va_end (varargs);
-
- return result;
+glade_named_icon_chooser_dialog_new (const gchar * title,
+ GtkWindow * parent,
+ const gchar * first_button_text, ...)
+{
+ GtkWidget *result;
+ va_list varargs;
+
+ va_start (varargs, first_button_text);
+ result = glade_named_icon_chooser_dialog_new_valist (title,
+ parent,
+ first_button_text,
+ varargs);
+ va_end (varargs);
+
+ return result;
}
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index 629ccc5..b4ff927 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-palette.c
*
@@ -56,83 +55,83 @@
struct _GladePalettePrivate
{
- const GList *catalogs; /* List of widget catalogs */
+ const GList *catalogs; /* List of widget catalogs */
- GtkWidget *selector_hbox;
- GtkWidget *selector_button;
- GtkWidget *create_root_button;
+ GtkWidget *selector_hbox;
+ GtkWidget *selector_button;
+ GtkWidget *create_root_button;
- GtkWidget *toolpalette;
- GtkWidget *current_item;
+ GtkWidget *toolpalette;
+ GtkWidget *current_item;
- GladeItemAppearance item_appearance;
- gboolean use_small_item_icons;
- gboolean sticky_selection_mode; /* whether sticky_selection mode has been enabled */
+ GladeItemAppearance item_appearance;
+ gboolean use_small_item_icons;
+ gboolean sticky_selection_mode; /* whether sticky_selection mode has been enabled */
};
enum
{
- TOGGLED,
- REFRESH,
- LAST_SIGNAL
+ TOGGLED,
+ REFRESH,
+ LAST_SIGNAL
};
enum
{
- PROP_0,
- PROP_CURRENT_ITEM,
- PROP_ITEM_APPEARANCE,
- PROP_USE_SMALL_ITEM_ICONS,
- PROP_SHOW_SELECTOR_BUTTON,
- PROP_CATALOGS
+ PROP_0,
+ PROP_CURRENT_ITEM,
+ PROP_ITEM_APPEARANCE,
+ PROP_USE_SMALL_ITEM_ICONS,
+ PROP_SHOW_SELECTOR_BUTTON,
+ PROP_CATALOGS
};
-static guint glade_palette_signals[LAST_SIGNAL] = {0};
+static guint glade_palette_signals[LAST_SIGNAL] = { 0 };
-static void glade_palette_append_item_group (GladePalette *palette, GladeWidgetGroup *group);
+static void glade_palette_append_item_group (GladePalette * palette,
+ GladeWidgetGroup * group);
-static void glade_palette_update_appearance (GladePalette *palette);
+static void glade_palette_update_appearance (GladePalette * palette);
G_DEFINE_TYPE (GladePalette, glade_palette, GTK_TYPE_VBOX)
-
-
-static void
-selector_button_toggled_cb (GtkToggleButton *button, GladePalette *palette)
-{
- if (gtk_toggle_button_get_active (button))
- {
- glade_palette_deselect_current_item (palette, FALSE);
- }
- else if (glade_palette_get_current_item (palette) == NULL)
- {
- gtk_toggle_button_set_active (button, TRUE);
- }
+ static void
+ selector_button_toggled_cb (GtkToggleButton * button,
+ GladePalette * palette)
+{
+ if (gtk_toggle_button_get_active (button))
+ {
+ glade_palette_deselect_current_item (palette, FALSE);
+ }
+ else if (glade_palette_get_current_item (palette) == NULL)
+ {
+ gtk_toggle_button_set_active (button, TRUE);
+ }
}
static void
-glade_palette_set_catalogs (GladePalette *palette, GList *catalogs)
+glade_palette_set_catalogs (GladePalette * palette, GList * catalogs)
{
- GladePalettePrivate *priv;
- GList *l;
+ GladePalettePrivate *priv;
+ GList *l;
+
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
+ priv = palette->priv;
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = palette->priv;
+ priv->catalogs = catalogs;
- priv->catalogs = catalogs;
+ for (l = (GList *) priv->catalogs; l; l = l->next)
+ {
+ GList *groups = glade_catalog_get_widget_groups (GLADE_CATALOG (l->data));
- for (l = (GList *) priv->catalogs; l; l = l->next)
- {
- GList *groups = glade_catalog_get_widget_groups (GLADE_CATALOG (l->data));
+ for (; groups; groups = groups->next)
+ {
+ GladeWidgetGroup *group = GLADE_WIDGET_GROUP (groups->data);
- for (; groups; groups = groups->next)
- {
- GladeWidgetGroup *group = GLADE_WIDGET_GROUP (groups->data);
+ if (glade_widget_group_get_adaptors (group))
+ glade_palette_append_item_group (palette, group);
+ }
+ }
- if (glade_widget_group_get_adaptors (group))
- glade_palette_append_item_group (palette, group);
- }
- }
-
}
/**
@@ -143,20 +142,21 @@ glade_palette_set_catalogs (GladePalette *palette, GList *catalogs)
* Sets the appearance of the palette items.
*/
void
-glade_palette_set_item_appearance (GladePalette *palette, GladeItemAppearance item_appearance)
+glade_palette_set_item_appearance (GladePalette * palette,
+ GladeItemAppearance item_appearance)
{
- GladePalettePrivate *priv;
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = palette->priv;
+ GladePalettePrivate *priv;
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
+ priv = palette->priv;
- if (priv->item_appearance != item_appearance)
- {
- priv->item_appearance = item_appearance;
+ if (priv->item_appearance != item_appearance)
+ {
+ priv->item_appearance = item_appearance;
- glade_palette_update_appearance (palette);
+ glade_palette_update_appearance (palette);
- g_object_notify (G_OBJECT (palette), "item-appearance");
- }
+ g_object_notify (G_OBJECT (palette), "item-appearance");
+ }
}
/**
@@ -167,21 +167,22 @@ glade_palette_set_item_appearance (GladePalette *palette, GladeItemAppearance it
* Sets whether to use small item icons.
*/
void
-glade_palette_set_use_small_item_icons (GladePalette *palette, gboolean use_small_item_icons)
+glade_palette_set_use_small_item_icons (GladePalette * palette,
+ gboolean use_small_item_icons)
{
- GladePalettePrivate *priv;
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = palette->priv;
+ GladePalettePrivate *priv;
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
+ priv = palette->priv;
- if (priv->use_small_item_icons != use_small_item_icons)
- {
- priv->use_small_item_icons = use_small_item_icons;
+ if (priv->use_small_item_icons != use_small_item_icons)
+ {
+ priv->use_small_item_icons = use_small_item_icons;
- glade_palette_update_appearance (palette);
+ glade_palette_update_appearance (palette);
- g_object_notify (G_OBJECT (palette), "use-small-item-icons");
-
- }
+ g_object_notify (G_OBJECT (palette), "use-small-item-icons");
+
+ }
}
@@ -193,22 +194,23 @@ glade_palette_set_use_small_item_icons (GladePalette *palette, gboolean use_smal
* Sets whether to show the internal widget selector button
*/
void
-glade_palette_set_show_selector_button (GladePalette *palette, gboolean show_selector_button)
-{
- GladePalettePrivate *priv;
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = palette->priv;
-
- if (gtk_widget_get_visible (priv->selector_hbox) != show_selector_button)
- {
- if (show_selector_button)
- gtk_widget_show (priv->selector_hbox);
- else
- gtk_widget_hide (priv->selector_hbox);
-
- g_object_notify (G_OBJECT (palette), "show-selector-button");
-
- }
+glade_palette_set_show_selector_button (GladePalette * palette,
+ gboolean show_selector_button)
+{
+ GladePalettePrivate *priv;
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
+ priv = palette->priv;
+
+ if (gtk_widget_get_visible (priv->selector_hbox) != show_selector_button)
+ {
+ if (show_selector_button)
+ gtk_widget_show (priv->selector_hbox);
+ else
+ gtk_widget_hide (priv->selector_hbox);
+
+ g_object_notify (G_OBJECT (palette), "show-selector-button");
+
+ }
}
@@ -216,551 +218,570 @@ glade_palette_set_show_selector_button (GladePalette *palette, gboolean show_sel
* hidden unless we decide otherwise, like the hidden selector button.
*/
static void
-glade_palette_show_all (GtkWidget *widget)
+glade_palette_show_all (GtkWidget * widget)
{
- gtk_widget_show (widget);
+ gtk_widget_show (widget);
}
-static void
-glade_palette_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GladePalette *palette = GLADE_PALETTE (object);
-
- switch (prop_id)
- {
- case PROP_USE_SMALL_ITEM_ICONS:
- glade_palette_set_use_small_item_icons (palette, g_value_get_boolean (value));
- break;
- case PROP_ITEM_APPEARANCE:
- glade_palette_set_item_appearance (palette, g_value_get_enum (value));
- break;
- case PROP_SHOW_SELECTOR_BUTTON:
- glade_palette_set_show_selector_button (palette, g_value_get_boolean (value));
- break;
- case PROP_CATALOGS:
- glade_palette_set_catalogs (palette, g_value_get_pointer (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+static void
+glade_palette_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GladePalette *palette = GLADE_PALETTE (object);
+
+ switch (prop_id)
+ {
+ case PROP_USE_SMALL_ITEM_ICONS:
+ glade_palette_set_use_small_item_icons (palette,
+ g_value_get_boolean (value));
+ break;
+ case PROP_ITEM_APPEARANCE:
+ glade_palette_set_item_appearance (palette, g_value_get_enum (value));
+ break;
+ case PROP_SHOW_SELECTOR_BUTTON:
+ glade_palette_set_show_selector_button (palette,
+ g_value_get_boolean (value));
+ break;
+ case PROP_CATALOGS:
+ glade_palette_set_catalogs (palette, g_value_get_pointer (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-glade_palette_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GladePalette *palette = GLADE_PALETTE (object);
- GladePalettePrivate *priv = palette->priv;
-
- switch (prop_id)
- {
- case PROP_CURRENT_ITEM:
- if (priv->current_item)
- g_value_set_pointer (value, g_object_get_data
- (G_OBJECT (priv->current_item), "glade-widget-adaptor"));
- else
- g_value_set_pointer (value, NULL);
-
- break;
- case PROP_USE_SMALL_ITEM_ICONS:
- g_value_set_boolean (value, priv->use_small_item_icons);
- break;
- case PROP_SHOW_SELECTOR_BUTTON:
- g_value_set_boolean (value, gtk_widget_get_visible (priv->selector_button));
- break;
- case PROP_ITEM_APPEARANCE:
- g_value_set_enum (value, priv->item_appearance);
- break;
- case PROP_CATALOGS:
- g_value_set_pointer (value, (gpointer) priv->catalogs);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_palette_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GladePalette *palette = GLADE_PALETTE (object);
+ GladePalettePrivate *priv = palette->priv;
+
+ switch (prop_id)
+ {
+ case PROP_CURRENT_ITEM:
+ if (priv->current_item)
+ g_value_set_pointer (value, g_object_get_data
+ (G_OBJECT (priv->current_item),
+ "glade-widget-adaptor"));
+ else
+ g_value_set_pointer (value, NULL);
+
+ break;
+ case PROP_USE_SMALL_ITEM_ICONS:
+ g_value_set_boolean (value, priv->use_small_item_icons);
+ break;
+ case PROP_SHOW_SELECTOR_BUTTON:
+ g_value_set_boolean (value,
+ gtk_widget_get_visible (priv->selector_button));
+ break;
+ case PROP_ITEM_APPEARANCE:
+ g_value_set_enum (value, priv->item_appearance);
+ break;
+ case PROP_CATALOGS:
+ g_value_set_pointer (value, (gpointer) priv->catalogs);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_palette_dispose (GObject *object)
+glade_palette_dispose (GObject * object)
{
- GladePalettePrivate *priv;
-
- priv = GLADE_PALETTE (object)->priv;
+ GladePalettePrivate *priv;
+
+ priv = GLADE_PALETTE (object)->priv;
+
+ priv->catalogs = NULL;
- priv->catalogs = NULL;
-
- G_OBJECT_CLASS (glade_palette_parent_class)->dispose (object);
+ G_OBJECT_CLASS (glade_palette_parent_class)->dispose (object);
}
static void
-glade_palette_finalize (GObject *object)
+glade_palette_finalize (GObject * object)
{
- GladePalettePrivate *priv;
-
- priv = GLADE_PALETTE (object)->priv;
+ GladePalettePrivate *priv;
- G_OBJECT_CLASS (glade_palette_parent_class)->finalize (object);
+ priv = GLADE_PALETTE (object)->priv;
+
+ G_OBJECT_CLASS (glade_palette_parent_class)->finalize (object);
}
static void
-glade_palette_toggled (GladePalette *palette)
-{
- GladeWidgetAdaptor *adaptor;
- GladeWidget *widget;
-
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- adaptor = glade_palette_get_current_item (palette);
-
- /* class may be NULL if the selector was pressed */
- if (adaptor && GWA_IS_TOPLEVEL (adaptor))
- {
- /* Inappropriate toplevel classes for libglade are
- * disabled so no chance of creating a non-window toplevel here
- */
- widget = glade_palette_create_root_widget (palette, adaptor);
- }
+glade_palette_toggled (GladePalette * palette)
+{
+ GladeWidgetAdaptor *adaptor;
+ GladeWidget *widget;
+
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
+ adaptor = glade_palette_get_current_item (palette);
+
+ /* class may be NULL if the selector was pressed */
+ if (adaptor && GWA_IS_TOPLEVEL (adaptor))
+ {
+ /* Inappropriate toplevel classes for libglade are
+ * disabled so no chance of creating a non-window toplevel here
+ */
+ widget = glade_palette_create_root_widget (palette, adaptor);
+ }
}
static void
-glade_palette_class_init (GladePaletteClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- klass->toggled = glade_palette_toggled;
-
- object_class->get_property = glade_palette_get_property;
- object_class->set_property = glade_palette_set_property;
- object_class->dispose = glade_palette_dispose;
- object_class->finalize = glade_palette_finalize;
-
- widget_class->show_all = glade_palette_show_all;
-
- glade_palette_signals[TOGGLED] =
- g_signal_new ("toggled",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladePaletteClass, toggled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- glade_palette_signals[REFRESH] =
- g_signal_new ("refresh",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladePaletteClass, refresh),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_ITEM_APPEARANCE,
- g_param_spec_enum ("item-appearance",
- "Item Appearance",
- "The appearance of the palette items",
- GLADE_TYPE_ITEM_APPEARANCE,
- GLADE_ITEM_ICON_ONLY,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_ITEM_APPEARANCE,
- g_param_spec_boolean ("use-small-item-icons",
- "Use Small Item Icons",
- "Whether to use small icons to represent items",
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_ITEM_APPEARANCE,
- g_param_spec_boolean ("show-selector-button",
- "Show Selector Button",
- "Whether to show the internal selector button",
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_CURRENT_ITEM,
- g_param_spec_pointer ("current-item",
- "Current Item Class",
- "The GladeWidgetAdaptor of the currently selected item",
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
- PROP_CATALOGS,
- g_param_spec_pointer ("catalogs",
- "Widget catalogs",
- "The widget catalogs for the palette",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-
- g_type_class_add_private (object_class, sizeof (GladePalettePrivate));
+glade_palette_class_init (GladePaletteClass * klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+
+ klass->toggled = glade_palette_toggled;
+
+ object_class->get_property = glade_palette_get_property;
+ object_class->set_property = glade_palette_set_property;
+ object_class->dispose = glade_palette_dispose;
+ object_class->finalize = glade_palette_finalize;
+
+ widget_class->show_all = glade_palette_show_all;
+
+ glade_palette_signals[TOGGLED] =
+ g_signal_new ("toggled",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladePaletteClass, toggled),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ glade_palette_signals[REFRESH] =
+ g_signal_new ("refresh",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladePaletteClass, refresh),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ g_object_class_install_property (object_class,
+ PROP_ITEM_APPEARANCE,
+ g_param_spec_enum ("item-appearance",
+ "Item Appearance",
+ "The appearance of the palette items",
+ GLADE_TYPE_ITEM_APPEARANCE,
+ GLADE_ITEM_ICON_ONLY,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_ITEM_APPEARANCE,
+ g_param_spec_boolean ("use-small-item-icons",
+ "Use Small Item Icons",
+ "Whether to use small icons to represent items",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_ITEM_APPEARANCE,
+ g_param_spec_boolean ("show-selector-button",
+ "Show Selector Button",
+ "Whether to show the internal selector button",
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_CURRENT_ITEM,
+ g_param_spec_pointer ("current-item",
+ "Current Item Class",
+ "The GladeWidgetAdaptor of the currently selected item",
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_CATALOGS,
+ g_param_spec_pointer ("catalogs",
+ "Widget catalogs",
+ "The widget catalogs for the palette",
+ G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class, sizeof (GladePalettePrivate));
}
GladeWidget *
-glade_palette_create_root_widget (GladePalette *palette, GladeWidgetAdaptor *adaptor)
-{
- GladeWidget *widget;
-
- /* Dont deselect palette if create is canceled by user in query dialog */
- if ((widget = glade_command_create (adaptor, NULL, NULL, glade_app_get_project ())) != NULL)
- glade_palette_deselect_current_item (palette, FALSE);
-
- return widget;
+glade_palette_create_root_widget (GladePalette * palette,
+ GladeWidgetAdaptor * adaptor)
+{
+ GladeWidget *widget;
+
+ /* Dont deselect palette if create is canceled by user in query dialog */
+ if ((widget =
+ glade_command_create (adaptor, NULL, NULL,
+ glade_app_get_project ())) != NULL)
+ glade_palette_deselect_current_item (palette, FALSE);
+
+ return widget;
}
static void
-glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
-{
- GladePalettePrivate *priv;
- GdkModifierType mask;
- GladeWidgetAdaptor *adaptor;
- gboolean is_root_active;
-
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button) ||
- GTK_IS_TOGGLE_BUTTON (button));
- priv = palette->priv;
-
- is_root_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->create_root_button));
-
- if (button == priv->create_root_button && priv->current_item && is_root_active)
- {
- adaptor = glade_palette_get_current_item (palette);
- glade_palette_create_root_widget (palette, adaptor);
- return;
- }
-
- g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button));
-
- adaptor = g_object_get_data (G_OBJECT (button), "glade-widget-adaptor");
- if (!adaptor) return;
-
- /* if we are toggling currently active item into non-active state */
- if (priv->current_item == button)
- {
- priv->current_item = NULL;
- g_object_notify (G_OBJECT (palette), "current-item");
-
- glade_app_set_pointer_mode (GLADE_POINTER_SELECT);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->selector_button), TRUE);
-
- priv->sticky_selection_mode = FALSE;
-
- g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
-
- return;
- }
-
- /* now we are interested only in buttons which toggle from inactive to active */
- if (!gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (button)))
- return;
-
- if (priv->current_item && (button != priv->current_item))
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->current_item), FALSE);
-
- priv->current_item = button;
-
- if (is_root_active)
- {
- glade_palette_create_root_widget (palette, adaptor);
- return;
- }
-
- g_object_notify (G_OBJECT (palette), "current-item");
-
- glade_app_set_pointer_mode (GLADE_POINTER_ADD_WIDGET);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->selector_button), FALSE);
-
- /* check whether to enable sticky selection */
- gdk_window_get_pointer (gtk_widget_get_window (button), NULL, NULL, &mask);
- priv->sticky_selection_mode = (!GWA_IS_TOPLEVEL (adaptor)) && (mask & GDK_CONTROL_MASK);
-
- g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
+glade_palette_on_button_toggled (GtkWidget * button, GladePalette * palette)
+{
+ GladePalettePrivate *priv;
+ GdkModifierType mask;
+ GladeWidgetAdaptor *adaptor;
+ gboolean is_root_active;
+
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
+ g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button) ||
+ GTK_IS_TOGGLE_BUTTON (button));
+ priv = palette->priv;
+
+ is_root_active =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (priv->create_root_button));
+
+ if (button == priv->create_root_button && priv->current_item &&
+ is_root_active)
+ {
+ adaptor = glade_palette_get_current_item (palette);
+ glade_palette_create_root_widget (palette, adaptor);
+ return;
+ }
+
+ g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button));
+
+ adaptor = g_object_get_data (G_OBJECT (button), "glade-widget-adaptor");
+ if (!adaptor)
+ return;
+
+ /* if we are toggling currently active item into non-active state */
+ if (priv->current_item == button)
+ {
+ priv->current_item = NULL;
+ g_object_notify (G_OBJECT (palette), "current-item");
+
+ glade_app_set_pointer_mode (GLADE_POINTER_SELECT);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->selector_button),
+ TRUE);
+
+ priv->sticky_selection_mode = FALSE;
+
+ g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
+
+ return;
+ }
+
+ /* now we are interested only in buttons which toggle from inactive to active */
+ if (!gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (button)))
+ return;
+
+ if (priv->current_item && (button != priv->current_item))
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON
+ (priv->current_item), FALSE);
+
+ priv->current_item = button;
+
+ if (is_root_active)
+ {
+ glade_palette_create_root_widget (palette, adaptor);
+ return;
+ }
+
+ g_object_notify (G_OBJECT (palette), "current-item");
+
+ glade_app_set_pointer_mode (GLADE_POINTER_ADD_WIDGET);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->selector_button),
+ FALSE);
+
+ /* check whether to enable sticky selection */
+ gdk_window_get_pointer (gtk_widget_get_window (button), NULL, NULL, &mask);
+ priv->sticky_selection_mode = (!GWA_IS_TOPLEVEL (adaptor)) &&
+ (mask & GDK_CONTROL_MASK);
+
+ g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
}
static void
-glade_palette_item_refresh (GtkWidget *item)
-{
- GladeProject *project;
- GladeSupportMask support;
- GladeWidgetAdaptor *adaptor;
- gchar *warning, *text;
-
- adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
- g_assert (adaptor);
-
- if ((project = glade_app_check_get_project ()) &&
- (warning =
- glade_project_verify_widget_adaptor (project, adaptor, &support)) != NULL)
- {
- /* set sensitivity */
- gtk_widget_set_sensitive (GTK_WIDGET (item), !(support & GLADE_SUPPORT_MISMATCH));
-
- if (support & GLADE_SUPPORT_DEPRECATED)
- /* XXX Todo, draw a cross overlaying the widget icon */
- gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), GTK_STOCK_DIALOG_WARNING);
- else
- gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), adaptor->icon_name);
-
- /* prepend widget title */
- text = g_strdup_printf ("%s: %s", adaptor->title, warning);
- gtk_widget_set_tooltip_text (item, text);
- g_free (text);
- g_free (warning);
- }
- else
- {
- gtk_widget_set_tooltip_text (GTK_WIDGET (item), adaptor->title);
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), adaptor->icon_name);
- }
+glade_palette_item_refresh (GtkWidget * item)
+{
+ GladeProject *project;
+ GladeSupportMask support;
+ GladeWidgetAdaptor *adaptor;
+ gchar *warning, *text;
+
+ adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
+ g_assert (adaptor);
+
+ if ((project = glade_app_check_get_project ()) &&
+ (warning =
+ glade_project_verify_widget_adaptor (project, adaptor,
+ &support)) != NULL)
+ {
+ /* set sensitivity */
+ gtk_widget_set_sensitive (GTK_WIDGET (item),
+ !(support & GLADE_SUPPORT_MISMATCH));
+
+ if (support & GLADE_SUPPORT_DEPRECATED)
+ /* XXX Todo, draw a cross overlaying the widget icon */
+ gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item),
+ GTK_STOCK_DIALOG_WARNING);
+ else
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item),
+ adaptor->icon_name);
+
+ /* prepend widget title */
+ text = g_strdup_printf ("%s: %s", adaptor->title, warning);
+ gtk_widget_set_tooltip_text (item, text);
+ g_free (text);
+ g_free (warning);
+ }
+ else
+ {
+ gtk_widget_set_tooltip_text (GTK_WIDGET (item), adaptor->title);
+ gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item),
+ adaptor->icon_name);
+ }
}
static gint
-glade_palette_item_button_press (GtkWidget *button,
- GdkEventButton *event,
- GladePalette *item)
+glade_palette_item_button_press (GtkWidget * button,
+ GdkEventButton * event, GladePalette * item)
{
- if (glade_popup_is_popup_event (event))
- {
- GladeWidgetAdaptor *adaptor;
+ if (glade_popup_is_popup_event (event))
+ {
+ GladeWidgetAdaptor *adaptor;
- adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
-
- glade_popup_palette_pop (adaptor, event);
- return TRUE;
- }
+ adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
+
+ glade_popup_palette_pop (adaptor, event);
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-static GtkWidget*
-glade_palette_new_item (GladePalette *palette, GladeWidgetAdaptor *adaptor)
+static GtkWidget *
+glade_palette_new_item (GladePalette * palette, GladeWidgetAdaptor * adaptor)
{
- GtkWidget *item, *button, *label, *box;
+ GtkWidget *item, *button, *label, *box;
- item = (GtkWidget *)gtk_toggle_tool_button_new ();
- g_object_set_data (G_OBJECT (item), "glade-widget-adaptor", adaptor);
+ item = (GtkWidget *) gtk_toggle_tool_button_new ();
+ g_object_set_data (G_OBJECT (item), "glade-widget-adaptor", adaptor);
- button = gtk_bin_get_child (GTK_BIN (item));
- g_assert (GTK_IS_BUTTON (button));
-
- /* Add a box to avoid the ellipsize on the items */
- box = gtk_hbox_new (FALSE, 0);
- label = gtk_label_new (adaptor->title);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_widget_show (box);
- gtk_container_add (GTK_CONTAINER (box), label);
- gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (item), box);
- glade_palette_item_refresh (item);
+ button = gtk_bin_get_child (GTK_BIN (item));
+ g_assert (GTK_IS_BUTTON (button));
- /* Update selection when the item is pushed */
- g_signal_connect (G_OBJECT (item), "toggled",
- G_CALLBACK (glade_palette_on_button_toggled), palette);
+ /* Add a box to avoid the ellipsize on the items */
+ box = gtk_hbox_new (FALSE, 0);
+ label = gtk_label_new (adaptor->title);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_widget_show (box);
+ gtk_container_add (GTK_CONTAINER (box), label);
+ gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (item), box);
+ glade_palette_item_refresh (item);
- /* Update palette item when active project state changes */
- g_signal_connect_swapped (G_OBJECT (palette), "refresh",
- G_CALLBACK (glade_palette_item_refresh), item);
+ /* Update selection when the item is pushed */
+ g_signal_connect (G_OBJECT (item), "toggled",
+ G_CALLBACK (glade_palette_on_button_toggled), palette);
- /* Fire Glade palette popup menus */
- g_signal_connect (G_OBJECT (button), "button-press-event",
- G_CALLBACK (glade_palette_item_button_press), item);
+ /* Update palette item when active project state changes */
+ g_signal_connect_swapped (G_OBJECT (palette), "refresh",
+ G_CALLBACK (glade_palette_item_refresh), item);
- gtk_widget_show (item);
+ /* Fire Glade palette popup menus */
+ g_signal_connect (G_OBJECT (button), "button-press-event",
+ G_CALLBACK (glade_palette_item_button_press), item);
- return item;
+ gtk_widget_show (item);
+
+ return item;
}
-static GtkWidget*
-glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group)
+static GtkWidget *
+glade_palette_new_item_group (GladePalette * palette, GladeWidgetGroup * group)
{
- GladePalettePrivate *priv;
- GtkWidget *item_group, *item, *label;
- GList *l;
+ GladePalettePrivate *priv;
+ GtkWidget *item_group, *item, *label;
+ GList *l;
- priv = palette->priv;
+ priv = palette->priv;
- /* Give the item group a left aligned label */
- label = gtk_label_new (glade_widget_group_get_title (group));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
+ /* Give the item group a left aligned label */
+ label = gtk_label_new (glade_widget_group_get_title (group));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
- item_group = gtk_tool_item_group_new ("");
- gtk_tool_item_group_set_label_widget (GTK_TOOL_ITEM_GROUP (item_group),
- label);
+ item_group = gtk_tool_item_group_new ("");
+ gtk_tool_item_group_set_label_widget (GTK_TOOL_ITEM_GROUP (item_group),
+ label);
- /* Tell the item group to ellipsize our custom label for us */
- gtk_tool_item_group_set_ellipsize (GTK_TOOL_ITEM_GROUP (item_group),
- PANGO_ELLIPSIZE_END);
+ /* Tell the item group to ellipsize our custom label for us */
+ gtk_tool_item_group_set_ellipsize (GTK_TOOL_ITEM_GROUP (item_group),
+ PANGO_ELLIPSIZE_END);
- gtk_widget_set_tooltip_text (item_group, glade_widget_group_get_title (group));
+ gtk_widget_set_tooltip_text (item_group,
+ glade_widget_group_get_title (group));
- /* Go through all the widget classes in this catalog. */
- for (l = (GList *) glade_widget_group_get_adaptors (group); l; l = l->next)
- {
- GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (l->data);
+ /* Go through all the widget classes in this catalog. */
+ for (l = (GList *) glade_widget_group_get_adaptors (group); l; l = l->next)
+ {
+ GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (l->data);
- /* Create/append new item */
- item = glade_palette_new_item (palette, adaptor);
- gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (item_group),
- GTK_TOOL_ITEM (item), -1);
- }
+ /* Create/append new item */
+ item = glade_palette_new_item (palette, adaptor);
+ gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (item_group),
+ GTK_TOOL_ITEM (item), -1);
+ }
- /* set default expanded state */
- gtk_tool_item_group_set_collapsed (GTK_TOOL_ITEM_GROUP (item_group),
- glade_widget_group_get_expanded (group) == FALSE);
+ /* set default expanded state */
+ gtk_tool_item_group_set_collapsed (GTK_TOOL_ITEM_GROUP (item_group),
+ glade_widget_group_get_expanded (group) ==
+ FALSE);
- gtk_widget_show (item_group);
+ gtk_widget_show (item_group);
- return item_group;
+ return item_group;
}
static void
-glade_palette_append_item_group (GladePalette *palette,
- GladeWidgetGroup *group)
+glade_palette_append_item_group (GladePalette * palette,
+ GladeWidgetGroup * group)
{
- GladePalettePrivate *priv = palette->priv;
- GtkWidget *item_group;
+ GladePalettePrivate *priv = palette->priv;
+ GtkWidget *item_group;
- if ((item_group = glade_palette_new_item_group (palette, group)) != NULL)
- gtk_container_add (GTK_CONTAINER (priv->toolpalette), item_group);
+ if ((item_group = glade_palette_new_item_group (palette, group)) != NULL)
+ gtk_container_add (GTK_CONTAINER (priv->toolpalette), item_group);
}
static void
-glade_palette_update_appearance (GladePalette *palette)
+glade_palette_update_appearance (GladePalette * palette)
{
- GladePalettePrivate *priv;
- GtkToolbarStyle style;
- GtkIconSize size;
-
- priv = palette->priv;
-
- size = priv->use_small_item_icons ? GTK_ICON_SIZE_MENU : GTK_ICON_SIZE_BUTTON;
-
- switch (priv->item_appearance)
- {
- case GLADE_ITEM_ICON_AND_LABEL: style = GTK_TOOLBAR_BOTH_HORIZ; break;
- case GLADE_ITEM_ICON_ONLY: style = GTK_TOOLBAR_ICONS; break;
- case GLADE_ITEM_LABEL_ONLY: style = GTK_TOOLBAR_TEXT; break;
- default:
- g_assert_not_reached ();
- break;
- }
+ GladePalettePrivate *priv;
+ GtkToolbarStyle style;
+ GtkIconSize size;
+
+ priv = palette->priv;
+
+ size = priv->use_small_item_icons ? GTK_ICON_SIZE_MENU : GTK_ICON_SIZE_BUTTON;
+
+ switch (priv->item_appearance)
+ {
+ case GLADE_ITEM_ICON_AND_LABEL:
+ style = GTK_TOOLBAR_BOTH_HORIZ;
+ break;
+ case GLADE_ITEM_ICON_ONLY:
+ style = GTK_TOOLBAR_ICONS;
+ break;
+ case GLADE_ITEM_LABEL_ONLY:
+ style = GTK_TOOLBAR_TEXT;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
- gtk_tool_palette_set_icon_size (GTK_TOOL_PALETTE (priv->toolpalette), size);
- gtk_tool_palette_set_style (GTK_TOOL_PALETTE (priv->toolpalette), style);
+ gtk_tool_palette_set_icon_size (GTK_TOOL_PALETTE (priv->toolpalette), size);
+ gtk_tool_palette_set_style (GTK_TOOL_PALETTE (priv->toolpalette), style);
}
-static GtkWidget*
-glade_palette_create_selector_button (GladePalette *palette)
+static GtkWidget *
+glade_palette_create_selector_button (GladePalette * palette)
{
- GtkWidget *selector;
- GtkWidget *image;
- gchar *path;
+ GtkWidget *selector;
+ GtkWidget *image;
+ gchar *path;
+
+ /* create selector button */
+ selector = gtk_toggle_button_new ();
- /* create selector button */
- selector = gtk_toggle_button_new ();
-
- gtk_container_set_border_width (GTK_CONTAINER (selector), 0);
+ gtk_container_set_border_width (GTK_CONTAINER (selector), 0);
- path = g_build_filename (glade_app_get_pixmaps_dir (), "selector.png", NULL);
- image = gtk_image_new_from_file (path);
- gtk_widget_show (image);
-
- gtk_container_add (GTK_CONTAINER (selector), image);
- gtk_button_set_relief (GTK_BUTTON (selector), GTK_RELIEF_NONE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (selector), TRUE);
+ path = g_build_filename (glade_app_get_pixmaps_dir (), "selector.png", NULL);
+ image = gtk_image_new_from_file (path);
+ gtk_widget_show (image);
- g_signal_connect (G_OBJECT (selector), "toggled",
- G_CALLBACK (selector_button_toggled_cb),
- palette);
+ gtk_container_add (GTK_CONTAINER (selector), image);
+ gtk_button_set_relief (GTK_BUTTON (selector), GTK_RELIEF_NONE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (selector), TRUE);
- g_free (path);
+ g_signal_connect (G_OBJECT (selector), "toggled",
+ G_CALLBACK (selector_button_toggled_cb), palette);
- return selector;
+ g_free (path);
+
+ return selector;
}
-static GtkWidget*
-glade_palette_create_create_root_button (GladePalette *palette)
-{
- GtkWidget *create_root_button;
-
- create_root_button = gtk_toggle_button_new ();
-
- gtk_container_set_border_width (GTK_CONTAINER (create_root_button), 0);
- gtk_button_set_use_stock (GTK_BUTTON (create_root_button), TRUE);
- gtk_button_set_label (GTK_BUTTON (create_root_button), "gtk-add");
-
- g_signal_connect (G_OBJECT (create_root_button), "toggled",
- G_CALLBACK (glade_palette_on_button_toggled),
- palette);
-
- return create_root_button;
+static GtkWidget *
+glade_palette_create_create_root_button (GladePalette * palette)
+{
+ GtkWidget *create_root_button;
+
+ create_root_button = gtk_toggle_button_new ();
+
+ gtk_container_set_border_width (GTK_CONTAINER (create_root_button), 0);
+ gtk_button_set_use_stock (GTK_BUTTON (create_root_button), TRUE);
+ gtk_button_set_label (GTK_BUTTON (create_root_button), "gtk-add");
+
+ g_signal_connect (G_OBJECT (create_root_button), "toggled",
+ G_CALLBACK (glade_palette_on_button_toggled), palette);
+
+ return create_root_button;
}
static void
-glade_palette_init (GladePalette *palette)
-{
- GladePalettePrivate *priv;
- GtkWidget *sw;
-
- priv = palette->priv = GLADE_PALETTE_GET_PRIVATE (palette);
-
- priv->catalogs = NULL;
- priv->current_item = NULL;
- priv->item_appearance = GLADE_ITEM_ICON_ONLY;
- priv->use_small_item_icons = FALSE;
- priv->sticky_selection_mode = FALSE;
-
- /* create selector button */
- priv->selector_button = glade_palette_create_selector_button (palette);
- priv->selector_hbox = gtk_hbox_new (FALSE, 0);
- priv->create_root_button = glade_palette_create_create_root_button (palette);
- gtk_box_pack_start (GTK_BOX (priv->selector_hbox), priv->selector_button, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (priv->selector_hbox), priv->create_root_button, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (palette), priv->selector_hbox, FALSE, FALSE, 0);
- gtk_widget_show (priv->selector_button);
- gtk_widget_show (priv->create_root_button);
- gtk_widget_show (priv->selector_hbox);
-
- gtk_widget_set_tooltip_text (priv->selector_button, _("Widget selector"));
- gtk_widget_set_tooltip_text (priv->create_root_button, _("Create root widget"));
-
- /* The GtkToolPalette */
- priv->toolpalette = gtk_tool_palette_new ();
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
- GTK_SHADOW_NONE);
-
- gtk_container_add (GTK_CONTAINER (sw), priv->toolpalette);
- gtk_box_pack_start (GTK_BOX (palette), sw, TRUE, TRUE, 0);
-
- gtk_widget_show (sw);
- gtk_widget_show (priv->toolpalette);
-
- glade_palette_update_appearance (palette);
-
- gtk_widget_set_no_show_all (GTK_WIDGET (palette), TRUE);
+glade_palette_init (GladePalette * palette)
+{
+ GladePalettePrivate *priv;
+ GtkWidget *sw;
+
+ priv = palette->priv = GLADE_PALETTE_GET_PRIVATE (palette);
+
+ priv->catalogs = NULL;
+ priv->current_item = NULL;
+ priv->item_appearance = GLADE_ITEM_ICON_ONLY;
+ priv->use_small_item_icons = FALSE;
+ priv->sticky_selection_mode = FALSE;
+
+ /* create selector button */
+ priv->selector_button = glade_palette_create_selector_button (palette);
+ priv->selector_hbox = gtk_hbox_new (FALSE, 0);
+ priv->create_root_button = glade_palette_create_create_root_button (palette);
+ gtk_box_pack_start (GTK_BOX (priv->selector_hbox), priv->selector_button,
+ FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->selector_hbox), priv->create_root_button,
+ FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (palette), priv->selector_hbox, FALSE, FALSE, 0);
+ gtk_widget_show (priv->selector_button);
+ gtk_widget_show (priv->create_root_button);
+ gtk_widget_show (priv->selector_hbox);
+
+ gtk_widget_set_tooltip_text (priv->selector_button, _("Widget selector"));
+ gtk_widget_set_tooltip_text (priv->create_root_button,
+ _("Create root widget"));
+
+ /* The GtkToolPalette */
+ priv->toolpalette = gtk_tool_palette_new ();
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
+ GTK_SHADOW_NONE);
+
+ gtk_container_add (GTK_CONTAINER (sw), priv->toolpalette);
+ gtk_box_pack_start (GTK_BOX (palette), sw, TRUE, TRUE, 0);
+
+ gtk_widget_show (sw);
+ gtk_widget_show (priv->toolpalette);
+
+ glade_palette_update_appearance (palette);
+
+ gtk_widget_set_no_show_all (GTK_WIDGET (palette), TRUE);
}
/**
@@ -773,14 +794,15 @@ glade_palette_init (GladePalette *palette)
* if no item is selected.
*/
GladeWidgetAdaptor *
-glade_palette_get_current_item (GladePalette *palette)
+glade_palette_get_current_item (GladePalette * palette)
{
- g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
+ g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
- if (palette->priv->current_item)
- return g_object_get_data (G_OBJECT (palette->priv->current_item), "glade-widget-adaptor");
+ if (palette->priv->current_item)
+ return g_object_get_data (G_OBJECT (palette->priv->current_item),
+ "glade-widget-adaptor");
- return NULL;
+ return NULL;
}
/**
@@ -791,20 +813,19 @@ glade_palette_get_current_item (GladePalette *palette)
*
* Returns: a new #GladePalette
*/
-GtkWidget*
-glade_palette_new (const GList *catalogs)
+GtkWidget *
+glade_palette_new (const GList * catalogs)
{
- GladePalette *palette;
+ GladePalette *palette;
- g_return_val_if_fail (catalogs != NULL, NULL);
+ g_return_val_if_fail (catalogs != NULL, NULL);
- palette = g_object_new (GLADE_TYPE_PALETTE,
- "spacing", 2,
- "item-appearance", GLADE_ITEM_ICON_ONLY,
- "catalogs", catalogs,
- NULL);
+ palette = g_object_new (GLADE_TYPE_PALETTE,
+ "spacing", 2,
+ "item-appearance", GLADE_ITEM_ICON_ONLY,
+ "catalogs", catalogs, NULL);
- return GTK_WIDGET (palette);
+ return GTK_WIDGET (palette);
}
/**
@@ -815,28 +836,32 @@ glade_palette_new (const GList *catalogs)
* Deselects the currently selected item
*/
void
-glade_palette_deselect_current_item (GladePalette *palette, gboolean sticky_aware)
+glade_palette_deselect_current_item (GladePalette * palette,
+ gboolean sticky_aware)
{
- g_return_if_fail (GLADE_IS_PALETTE (palette));
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
- if (sticky_aware && palette->priv->sticky_selection_mode)
- return;
+ if (sticky_aware && palette->priv->sticky_selection_mode)
+ return;
- if (palette->priv->current_item)
- {
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (palette->priv->current_item), FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (palette->priv->selector_button), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (palette->priv->create_root_button), FALSE);
-
- palette->priv->current_item = NULL;
- g_object_notify (G_OBJECT (palette), "current-item");
+ if (palette->priv->current_item)
+ {
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON
+ (palette->priv->current_item), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (palette->priv->selector_button), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (palette->priv->create_root_button), FALSE);
- glade_app_set_pointer_mode (GLADE_POINTER_SELECT);
+ palette->priv->current_item = NULL;
+ g_object_notify (G_OBJECT (palette), "current-item");
- g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
+ glade_app_set_pointer_mode (GLADE_POINTER_SELECT);
+
+ g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
+
+ }
- }
-
}
/**
@@ -846,11 +871,11 @@ glade_palette_deselect_current_item (GladePalette *palette, gboolean sticky_awar
* Returns: The appearance of the palette items
*/
GladeItemAppearance
-glade_palette_get_item_appearance (GladePalette *palette)
+glade_palette_get_item_appearance (GladePalette * palette)
{;
- g_return_val_if_fail (GLADE_IS_PALETTE (palette), GLADE_ITEM_ICON_ONLY);
+ g_return_val_if_fail (GLADE_IS_PALETTE (palette), GLADE_ITEM_ICON_ONLY);
- return palette->priv->item_appearance;
+ return palette->priv->item_appearance;
}
/**
@@ -860,11 +885,11 @@ glade_palette_get_item_appearance (GladePalette *palette)
* Returns: Whether small item icons are used
*/
gboolean
-glade_palette_get_use_small_item_icons (GladePalette *palette)
+glade_palette_get_use_small_item_icons (GladePalette * palette)
{
- g_return_val_if_fail (GLADE_IS_PALETTE (palette), FALSE);
+ g_return_val_if_fail (GLADE_IS_PALETTE (palette), FALSE);
- return palette->priv->use_small_item_icons;
+ return palette->priv->use_small_item_icons;
}
/**
@@ -874,11 +899,11 @@ glade_palette_get_use_small_item_icons (GladePalette *palette)
* Returns: Whether the selector button is visible
*/
gboolean
-glade_palette_get_show_selector_button (GladePalette *palette)
+glade_palette_get_show_selector_button (GladePalette * palette)
{
- g_return_val_if_fail (GLADE_IS_PALETTE (palette), FALSE);
+ g_return_val_if_fail (GLADE_IS_PALETTE (palette), FALSE);
- return gtk_widget_get_visible (palette->priv->selector_hbox);
+ return gtk_widget_get_visible (palette->priv->selector_hbox);
}
/**
@@ -888,10 +913,9 @@ glade_palette_get_show_selector_button (GladePalette *palette)
* Refreshes project dependant states of palette buttons
*/
void
-glade_palette_refresh (GladePalette *palette)
+glade_palette_refresh (GladePalette * palette)
{
- g_return_if_fail (GLADE_IS_PALETTE (palette));
+ g_return_if_fail (GLADE_IS_PALETTE (palette));
- g_signal_emit (G_OBJECT (palette), glade_palette_signals[REFRESH], 0);
+ g_signal_emit (G_OBJECT (palette), glade_palette_signals[REFRESH], 0);
}
-
diff --git a/gladeui/glade-palette.h b/gladeui/glade-palette.h
index d6358c9..373fbb9 100644
--- a/gladeui/glade-palette.h
+++ b/gladeui/glade-palette.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-palette.h
*
diff --git a/gladeui/glade-parameter.c b/gladeui/glade-parameter.c
index 05c9390..689fb0d 100644
--- a/gladeui/glade-parameter.c
+++ b/gladeui/glade-parameter.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -31,7 +30,7 @@
* your plugin will treat certain widget classes.
*/
-#include <stdlib.h> /* for atoi and atof */
+#include <stdlib.h> /* for atoi and atof */
#include <string.h>
#include "glade.h"
@@ -49,19 +48,22 @@
* found, it stores a #gint representation of its value into @value.
*/
void
-glade_parameter_get_integer (GList *parameters, const gchar *key, gint *value)
+glade_parameter_get_integer (GList * parameters, const gchar * key,
+ gint * value)
{
- GladeParameter *parameter;
- GList *list;
-
- list = parameters;
- for (; list != NULL; list = list->next) {
- parameter = list->data;
- if (strcmp (key, parameter->key) == 0) {
- *value = g_ascii_strtoll (parameter->value, NULL, 10);
- return;
- }
- }
+ GladeParameter *parameter;
+ GList *list;
+
+ list = parameters;
+ for (; list != NULL; list = list->next)
+ {
+ parameter = list->data;
+ if (strcmp (key, parameter->key) == 0)
+ {
+ *value = g_ascii_strtoll (parameter->value, NULL, 10);
+ return;
+ }
+ }
}
/**
@@ -74,19 +76,22 @@ glade_parameter_get_integer (GList *parameters, const gchar *key, gint *value)
* found, it stores a #gfloat representation of its value into @value.
*/
void
-glade_parameter_get_float (GList *parameters, const gchar *key, gfloat *value)
+glade_parameter_get_float (GList * parameters, const gchar * key,
+ gfloat * value)
{
- GladeParameter *parameter;
- GList *list;
-
- list = parameters;
- for (; list != NULL; list = list->next) {
- parameter = list->data;
- if (strcmp (key, parameter->key) == 0) {
- *value = (float) g_ascii_strtod (parameter->value, NULL);
- return;
- }
- }
+ GladeParameter *parameter;
+ GList *list;
+
+ list = parameters;
+ for (; list != NULL; list = list->next)
+ {
+ parameter = list->data;
+ if (strcmp (key, parameter->key) == 0)
+ {
+ *value = (float) g_ascii_strtod (parameter->value, NULL);
+ return;
+ }
+ }
}
/**
@@ -99,25 +104,28 @@ glade_parameter_get_float (GList *parameters, const gchar *key, gfloat *value)
* found, it stores a #gboolean representation of its value into @value.
*/
void
-glade_parameter_get_boolean (GList *parameters, const gchar *key, gboolean *value)
+glade_parameter_get_boolean (GList * parameters, const gchar * key,
+ gboolean * value)
{
- GladeParameter *parameter;
- GList *list;
-
- list = parameters;
- for (; list != NULL; list = list->next) {
- parameter = list->data;
- if (strcmp (key, parameter->key) == 0) {
- if (strcmp (parameter->value, GLADE_TAG_TRUE) == 0)
- *value = TRUE;
- else if (strcmp (parameter->value, GLADE_TAG_FALSE) == 0)
- *value = FALSE;
- else
- g_warning ("Invalid boolean parameter *%s* (%s/%s)",
- parameter->value, GLADE_TAG_TRUE, GLADE_TAG_FALSE);
- return;
- }
- }
+ GladeParameter *parameter;
+ GList *list;
+
+ list = parameters;
+ for (; list != NULL; list = list->next)
+ {
+ parameter = list->data;
+ if (strcmp (key, parameter->key) == 0)
+ {
+ if (strcmp (parameter->value, GLADE_TAG_TRUE) == 0)
+ *value = TRUE;
+ else if (strcmp (parameter->value, GLADE_TAG_FALSE) == 0)
+ *value = FALSE;
+ else
+ g_warning ("Invalid boolean parameter *%s* (%s/%s)",
+ parameter->value, GLADE_TAG_TRUE, GLADE_TAG_FALSE);
+ return;
+ }
+ }
}
/**
@@ -131,21 +139,24 @@ glade_parameter_get_boolean (GList *parameters, const gchar *key, gboolean *valu
* @value.
*/
void
-glade_parameter_get_string (GList *parameters, const gchar *key, gchar **value)
+glade_parameter_get_string (GList * parameters, const gchar * key,
+ gchar ** value)
{
- GladeParameter *parameter;
- GList *list;
-
- list = parameters;
- for (; list != NULL; list = list->next) {
- parameter = list->data;
- if (strcmp (key, parameter->key) == 0) {
- if (*value != NULL)
- g_free (*value);
- *value = g_strdup (parameter->value);
- return;
- }
- }
+ GladeParameter *parameter;
+ GList *list;
+
+ list = parameters;
+ for (; list != NULL; list = list->next)
+ {
+ parameter = list->data;
+ if (strcmp (key, parameter->key) == 0)
+ {
+ if (*value != NULL)
+ g_free (*value);
+ *value = g_strdup (parameter->value);
+ return;
+ }
+ }
}
/**
@@ -155,14 +166,14 @@ glade_parameter_get_string (GList *parameters, const gchar *key, gchar **value)
* Frees @parameter and its associated memory.
*/
void
-glade_parameter_free (GladeParameter *parameter)
+glade_parameter_free (GladeParameter * parameter)
{
- if (!parameter)
- return;
+ if (!parameter)
+ return;
- g_free (parameter->key);
- g_free (parameter->value);
- g_free (parameter);
+ g_free (parameter->key);
+ g_free (parameter->value);
+ g_free (parameter);
}
/**
@@ -173,11 +184,11 @@ glade_parameter_free (GladeParameter *parameter)
GladeParameter *
glade_parameter_new (void)
{
- GladeParameter *parameter;
+ GladeParameter *parameter;
- parameter = g_new0 (GladeParameter, 1);
+ parameter = g_new0 (GladeParameter, 1);
- return parameter;
+ return parameter;
}
/**
@@ -187,36 +198,38 @@ glade_parameter_new (void)
* Returns: a new #GladeParameter cloned from @parameter
*/
GladeParameter *
-glade_parameter_clone (GladeParameter *parameter)
+glade_parameter_clone (GladeParameter * parameter)
{
- GladeParameter *clone;
+ GladeParameter *clone;
- if (parameter == NULL)
- return NULL;
+ if (parameter == NULL)
+ return NULL;
- clone = glade_parameter_new ();
- clone->key = g_strdup (parameter->key);
- clone->value = g_strdup (parameter->value);
+ clone = glade_parameter_new ();
+ clone->key = g_strdup (parameter->key);
+ clone->value = g_strdup (parameter->value);
- return clone;
+ return clone;
}
static GladeParameter *
-glade_parameter_new_from_node (GladeXmlNode *node)
+glade_parameter_new_from_node (GladeXmlNode * node)
{
- GladeParameter *parameter;
+ GladeParameter *parameter;
- if (!glade_xml_node_verify (node, GLADE_TAG_PARAMETER))
- return NULL;
-
- parameter = glade_parameter_new ();
- parameter->key = glade_xml_get_property_string_required (node, GLADE_TAG_KEY, NULL);
- parameter->value = glade_xml_get_property_string_required (node, GLADE_TAG_VALUE, NULL);
+ if (!glade_xml_node_verify (node, GLADE_TAG_PARAMETER))
+ return NULL;
- if (!parameter->key || !parameter->value)
- return NULL;
+ parameter = glade_parameter_new ();
+ parameter->key =
+ glade_xml_get_property_string_required (node, GLADE_TAG_KEY, NULL);
+ parameter->value =
+ glade_xml_get_property_string_required (node, GLADE_TAG_VALUE, NULL);
- return parameter;
+ if (!parameter->key || !parameter->value)
+ return NULL;
+
+ return parameter;
}
/**
@@ -231,20 +244,21 @@ glade_parameter_new_from_node (GladeXmlNode *node)
* or %NULL if none is found
*/
static GList *
-glade_parameter_list_find_by_key (GList *list, const gchar *key)
+glade_parameter_list_find_by_key (GList * list, const gchar * key)
{
- GladeParameter *parameter;
-
- for (; list != NULL; list = list->next) {
- parameter = list->data;
- g_return_val_if_fail (parameter->key != NULL, NULL);
- if (strcmp (parameter->key, key) == 0)
- return list;
- }
-
- return NULL;
+ GladeParameter *parameter;
+
+ for (; list != NULL; list = list->next)
+ {
+ parameter = list->data;
+ g_return_val_if_fail (parameter->key != NULL, NULL);
+ if (strcmp (parameter->key, key) == 0)
+ return list;
+ }
+
+ return NULL;
}
-
+
/**
* glade_parameter_list_new_from_node:
* @list: a #GList node
@@ -255,42 +269,43 @@ glade_parameter_list_find_by_key (GList *list, const gchar *key)
* Returns:
*/
GList *
-glade_parameter_list_new_from_node (GList *list, GladeXmlNode *node)
+glade_parameter_list_new_from_node (GList * list, GladeXmlNode * node)
{
- GladeParameter *parameter;
- GladeXmlNode *child;
- GList *findme;
-
- if (!glade_xml_node_verify (node, GLADE_TAG_PARAMETERS))
- return NULL;
- child = glade_xml_search_child (node, GLADE_TAG_PARAMETER);
- if (child == NULL)
- return NULL;
-
- child = glade_xml_node_get_children (node);
-
- for (; child != NULL; child = glade_xml_node_next (child)) {
- if (!glade_xml_node_verify (child, GLADE_TAG_PARAMETER))
- return NULL;
-
- parameter = glade_parameter_new_from_node (child);
- if (parameter == NULL)
- return NULL;
- /* Is this parameter already there ? just replace
- * the pointer and free the old one
- */
- findme = glade_parameter_list_find_by_key (list,
- parameter->key);
- if (findme) {
- glade_parameter_free (findme->data);
- findme->data = parameter;
- continue;
- }
-
- list = g_list_prepend (list, parameter);
- }
-
- list = g_list_reverse (list);
-
- return list;
+ GladeParameter *parameter;
+ GladeXmlNode *child;
+ GList *findme;
+
+ if (!glade_xml_node_verify (node, GLADE_TAG_PARAMETERS))
+ return NULL;
+ child = glade_xml_search_child (node, GLADE_TAG_PARAMETER);
+ if (child == NULL)
+ return NULL;
+
+ child = glade_xml_node_get_children (node);
+
+ for (; child != NULL; child = glade_xml_node_next (child))
+ {
+ if (!glade_xml_node_verify (child, GLADE_TAG_PARAMETER))
+ return NULL;
+
+ parameter = glade_parameter_new_from_node (child);
+ if (parameter == NULL)
+ return NULL;
+ /* Is this parameter already there ? just replace
+ * the pointer and free the old one
+ */
+ findme = glade_parameter_list_find_by_key (list, parameter->key);
+ if (findme)
+ {
+ glade_parameter_free (findme->data);
+ findme->data = parameter;
+ continue;
+ }
+
+ list = g_list_prepend (list, parameter);
+ }
+
+ list = g_list_reverse (list);
+
+ return list;
}
diff --git a/gladeui/glade-parameter.h b/gladeui/glade-parameter.h
index 7b4d6e1..9a0cd94 100644
--- a/gladeui/glade-parameter.h
+++ b/gladeui/glade-parameter.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_PARAMETER_H__
#define __GLADE_PARAMETER_H__
diff --git a/gladeui/glade-placeholder.c b/gladeui/glade-placeholder.c
index 57ebc48..1daa30e 100644
--- a/gladeui/glade-placeholder.c
+++ b/gladeui/glade-placeholder.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003, 2004 Joaquin Cuenca Abela
*
@@ -51,109 +50,109 @@
#define WIDTH_REQUISITION 20
#define HEIGHT_REQUISITION 20
-static void glade_placeholder_finalize (GObject *object);
-static void glade_placeholder_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void glade_placeholder_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void glade_placeholder_realize (GtkWidget *widget);
-static void glade_placeholder_unrealize (GtkWidget *widget);
-static void glade_placeholder_map (GtkWidget *widget);
-static void glade_placeholder_unmap (GtkWidget *widget);
-
-static void glade_placeholder_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-static gboolean glade_placeholder_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static gboolean glade_placeholder_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event);
-
-static gboolean glade_placeholder_button_press (GtkWidget *widget,
- GdkEventButton *event);
-
-static gboolean glade_placeholder_popup_menu (GtkWidget *widget);
-
-enum {
- PROP_0,
- PROP_HADJUSTMENT,
- PROP_VADJUSTMENT,
- PROP_HSCROLL_POLICY,
- PROP_VSCROLL_POLICY
+static void glade_placeholder_finalize (GObject * object);
+static void glade_placeholder_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void glade_placeholder_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void glade_placeholder_realize (GtkWidget * widget);
+static void glade_placeholder_unrealize (GtkWidget * widget);
+static void glade_placeholder_map (GtkWidget * widget);
+static void glade_placeholder_unmap (GtkWidget * widget);
+
+static void glade_placeholder_size_allocate (GtkWidget * widget,
+ GtkAllocation * allocation);
+
+static gboolean glade_placeholder_draw (GtkWidget * widget, cairo_t * cr);
+
+static gboolean glade_placeholder_motion_notify_event (GtkWidget * widget,
+ GdkEventMotion * event);
+
+static gboolean glade_placeholder_button_press (GtkWidget * widget,
+ GdkEventButton * event);
+
+static gboolean glade_placeholder_popup_menu (GtkWidget * widget);
+
+enum
+{
+ PROP_0,
+ PROP_HADJUSTMENT,
+ PROP_VADJUSTMENT,
+ PROP_HSCROLL_POLICY,
+ PROP_VSCROLL_POLICY
};
G_DEFINE_TYPE_WITH_CODE (GladePlaceholder, glade_placeholder, GTK_TYPE_WIDGET,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
-
-static void
-glade_placeholder_class_init (GladePlaceholderClass *klass)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
+ static void glade_placeholder_class_init (GladePlaceholderClass * klass)
{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = glade_placeholder_finalize;
- object_class->set_property = glade_placeholder_set_property;
- object_class->get_property = glade_placeholder_get_property;
-
- widget_class->realize = glade_placeholder_realize;
- widget_class->unrealize = glade_placeholder_unrealize;
- widget_class->map = glade_placeholder_map;
- widget_class->unmap = glade_placeholder_unmap;
- widget_class->size_allocate = glade_placeholder_size_allocate;
- widget_class->draw = glade_placeholder_draw;
- widget_class->motion_notify_event = glade_placeholder_motion_notify_event;
- widget_class->button_press_event = glade_placeholder_button_press;
- widget_class->popup_menu = glade_placeholder_popup_menu;
-
-
- /* GtkScrollable implementation */
- g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
- g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
- g_object_class_override_property (object_class, PROP_HSCROLL_POLICY, "hscroll-policy");
- g_object_class_override_property (object_class, PROP_VSCROLL_POLICY, "vscroll-policy");
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = glade_placeholder_finalize;
+ object_class->set_property = glade_placeholder_set_property;
+ object_class->get_property = glade_placeholder_get_property;
+
+ widget_class->realize = glade_placeholder_realize;
+ widget_class->unrealize = glade_placeholder_unrealize;
+ widget_class->map = glade_placeholder_map;
+ widget_class->unmap = glade_placeholder_unmap;
+ widget_class->size_allocate = glade_placeholder_size_allocate;
+ widget_class->draw = glade_placeholder_draw;
+ widget_class->motion_notify_event = glade_placeholder_motion_notify_event;
+ widget_class->button_press_event = glade_placeholder_button_press;
+ widget_class->popup_menu = glade_placeholder_popup_menu;
+
+
+ /* GtkScrollable implementation */
+ g_object_class_override_property (object_class, PROP_HADJUSTMENT,
+ "hadjustment");
+ g_object_class_override_property (object_class, PROP_VADJUSTMENT,
+ "vadjustment");
+ g_object_class_override_property (object_class, PROP_HSCROLL_POLICY,
+ "hscroll-policy");
+ g_object_class_override_property (object_class, PROP_VSCROLL_POLICY,
+ "vscroll-policy");
}
static void
-glade_placeholder_notify_parent (GObject *gobject,
- GParamSpec *arg1,
- gpointer user_data)
+glade_placeholder_notify_parent (GObject * gobject,
+ GParamSpec * arg1, gpointer user_data)
{
- GladePlaceholder *placeholder = GLADE_PLACEHOLDER (gobject);
- GladeWidget *parent = glade_placeholder_get_parent (placeholder);
-
- if (placeholder->packing_actions)
- {
- g_list_foreach (placeholder->packing_actions, (GFunc)g_object_unref, NULL);
- g_list_free (placeholder->packing_actions);
- placeholder->packing_actions = NULL;
- }
-
- if (parent && parent->adaptor->packing_actions)
- placeholder->packing_actions = glade_widget_adaptor_pack_actions_new (parent->adaptor);
+ GladePlaceholder *placeholder = GLADE_PLACEHOLDER (gobject);
+ GladeWidget *parent = glade_placeholder_get_parent (placeholder);
+
+ if (placeholder->packing_actions)
+ {
+ g_list_foreach (placeholder->packing_actions, (GFunc) g_object_unref,
+ NULL);
+ g_list_free (placeholder->packing_actions);
+ placeholder->packing_actions = NULL;
+ }
+
+ if (parent && parent->adaptor->packing_actions)
+ placeholder->packing_actions =
+ glade_widget_adaptor_pack_actions_new (parent->adaptor);
}
static void
-glade_placeholder_init (GladePlaceholder *placeholder)
+glade_placeholder_init (GladePlaceholder * placeholder)
{
- placeholder->packing_actions = NULL;
+ placeholder->packing_actions = NULL;
+
+ gtk_widget_set_can_focus (GTK_WIDGET (placeholder), TRUE);
+ gtk_widget_set_has_window (GTK_WIDGET (placeholder), FALSE);
- gtk_widget_set_can_focus (GTK_WIDGET (placeholder), TRUE);
- gtk_widget_set_has_window (GTK_WIDGET (placeholder), FALSE);
+ gtk_widget_set_size_request (GTK_WIDGET (placeholder),
+ WIDTH_REQUISITION, HEIGHT_REQUISITION);
- gtk_widget_set_size_request (GTK_WIDGET (placeholder),
- WIDTH_REQUISITION,
- HEIGHT_REQUISITION);
+ g_signal_connect (placeholder, "notify::parent",
+ G_CALLBACK (glade_placeholder_notify_parent), NULL);
- g_signal_connect (placeholder, "notify::parent",
- G_CALLBACK (glade_placeholder_notify_parent),
- NULL);
-
- gtk_widget_show (GTK_WIDGET (placeholder));
+ gtk_widget_show (GTK_WIDGET (placeholder));
}
/**
@@ -164,343 +163,342 @@ glade_placeholder_init (GladePlaceholder *placeholder)
GtkWidget *
glade_placeholder_new (void)
{
- return g_object_new (GLADE_TYPE_PLACEHOLDER, NULL);
+ return g_object_new (GLADE_TYPE_PLACEHOLDER, NULL);
}
static void
-glade_placeholder_finalize (GObject *object)
+glade_placeholder_finalize (GObject * object)
{
- GladePlaceholder *placeholder;
-
- g_return_if_fail (GLADE_IS_PLACEHOLDER (object));
- placeholder = GLADE_PLACEHOLDER (object);
-
- if (placeholder->packing_actions)
- {
- g_list_foreach (placeholder->packing_actions, (GFunc)g_object_unref, NULL);
- g_list_free (placeholder->packing_actions);
- }
-
- G_OBJECT_CLASS (glade_placeholder_parent_class)->finalize (object);
+ GladePlaceholder *placeholder;
+
+ g_return_if_fail (GLADE_IS_PLACEHOLDER (object));
+ placeholder = GLADE_PLACEHOLDER (object);
+
+ if (placeholder->packing_actions)
+ {
+ g_list_foreach (placeholder->packing_actions, (GFunc) g_object_unref,
+ NULL);
+ g_list_free (placeholder->packing_actions);
+ }
+
+ G_OBJECT_CLASS (glade_placeholder_parent_class)->finalize (object);
}
static void
-glade_placeholder_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_placeholder_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
switch (prop_id)
{
- case PROP_HADJUSTMENT:
- case PROP_VADJUSTMENT:
- case PROP_HSCROLL_POLICY:
- case PROP_VSCROLL_POLICY:
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_HADJUSTMENT:
+ case PROP_VADJUSTMENT:
+ case PROP_HSCROLL_POLICY:
+ case PROP_VSCROLL_POLICY:
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-glade_placeholder_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_placeholder_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
switch (prop_id)
{
- case PROP_HADJUSTMENT:
- case PROP_VADJUSTMENT:
- g_value_set_object (value, NULL);
- break;
- case PROP_HSCROLL_POLICY:
- case PROP_VSCROLL_POLICY:
- g_value_set_enum (value, GTK_SCROLL_MINIMUM);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_HADJUSTMENT:
+ case PROP_VADJUSTMENT:
+ g_value_set_object (value, NULL);
+ break;
+ case PROP_HSCROLL_POLICY:
+ case PROP_VSCROLL_POLICY:
+ g_value_set_enum (value, GTK_SCROLL_MINIMUM);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-glade_placeholder_realize (GtkWidget *widget)
+glade_placeholder_realize (GtkWidget * widget)
{
- GladePlaceholder *placeholder;
- GtkAllocation allocation;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- placeholder = GLADE_PLACEHOLDER (widget);
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.event_mask =
- gtk_widget_get_events (widget) |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK;
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gtk_widget_get_parent_window (widget);
- gtk_widget_set_window (widget, g_object_ref (window));
-
- placeholder->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (placeholder->event_window, widget);
-
- gtk_widget_style_attach (widget);
+ GladePlaceholder *placeholder;
+ GtkAllocation allocation;
+ GdkWindow *window;
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ placeholder = GLADE_PLACEHOLDER (widget);
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.wclass = GDK_INPUT_ONLY;
+ attributes.event_mask =
+ gtk_widget_get_events (widget) |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, g_object_ref (window));
+
+ placeholder->event_window =
+ gdk_window_new (gtk_widget_get_parent_window (widget), &attributes,
+ attributes_mask);
+ gdk_window_set_user_data (placeholder->event_window, widget);
+
+ gtk_widget_style_attach (widget);
}
static void
-glade_placeholder_unrealize (GtkWidget *widget)
+glade_placeholder_unrealize (GtkWidget * widget)
{
- GladePlaceholder *placeholder;
-
- placeholder = GLADE_PLACEHOLDER (widget);
-
- if (placeholder->event_window)
- {
- gdk_window_set_user_data (placeholder->event_window, NULL);
- gdk_window_destroy (placeholder->event_window);
- placeholder->event_window = NULL;
- }
-
- GTK_WIDGET_CLASS (glade_placeholder_parent_class)->unrealize (widget);
+ GladePlaceholder *placeholder;
+
+ placeholder = GLADE_PLACEHOLDER (widget);
+
+ if (placeholder->event_window)
+ {
+ gdk_window_set_user_data (placeholder->event_window, NULL);
+ gdk_window_destroy (placeholder->event_window);
+ placeholder->event_window = NULL;
+ }
+
+ GTK_WIDGET_CLASS (glade_placeholder_parent_class)->unrealize (widget);
}
static void
-glade_placeholder_map (GtkWidget *widget)
+glade_placeholder_map (GtkWidget * widget)
{
- GladePlaceholder *placeholder;
+ GladePlaceholder *placeholder;
- placeholder = GLADE_PLACEHOLDER (widget);
+ placeholder = GLADE_PLACEHOLDER (widget);
- if (placeholder->event_window)
- {
- gdk_window_show (placeholder->event_window);
- }
+ if (placeholder->event_window)
+ {
+ gdk_window_show (placeholder->event_window);
+ }
- GTK_WIDGET_CLASS (glade_placeholder_parent_class)->map (widget);
+ GTK_WIDGET_CLASS (glade_placeholder_parent_class)->map (widget);
}
static void
-glade_placeholder_unmap (GtkWidget *widget)
+glade_placeholder_unmap (GtkWidget * widget)
{
- GladePlaceholder *placeholder;
+ GladePlaceholder *placeholder;
- placeholder = GLADE_PLACEHOLDER (widget);
+ placeholder = GLADE_PLACEHOLDER (widget);
- if (placeholder->event_window)
- {
- gdk_window_hide (placeholder->event_window);
- }
+ if (placeholder->event_window)
+ {
+ gdk_window_hide (placeholder->event_window);
+ }
- GTK_WIDGET_CLASS (glade_placeholder_parent_class)->unmap (widget);
+ GTK_WIDGET_CLASS (glade_placeholder_parent_class)->unmap (widget);
}
static void
-glade_placeholder_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+glade_placeholder_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
{
- GladePlaceholder *placeholder;
+ GladePlaceholder *placeholder;
- placeholder = GLADE_PLACEHOLDER (widget);
+ placeholder = GLADE_PLACEHOLDER (widget);
- gtk_widget_set_allocation (widget, allocation);
+ gtk_widget_set_allocation (widget, allocation);
- if (gtk_widget_get_realized (widget))
- {
- gdk_window_move_resize (placeholder->event_window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
- }
+ if (gtk_widget_get_realized (widget))
+ {
+ gdk_window_move_resize (placeholder->event_window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+ }
}
-GladeProject*
-glade_placeholder_get_project (GladePlaceholder *placeholder)
+GladeProject *
+glade_placeholder_get_project (GladePlaceholder * placeholder)
{
- GladeWidget *parent;
- parent = glade_placeholder_get_parent (placeholder);
- return parent ? GLADE_PROJECT (parent->project) : NULL;
+ GladeWidget *parent;
+ parent = glade_placeholder_get_parent (placeholder);
+ return parent ? GLADE_PROJECT (parent->project) : NULL;
}
static void
-glade_placeholder_draw_background (GtkWidget* widget, cairo_t *cr)
+glade_placeholder_draw_background (GtkWidget * widget, cairo_t * cr)
{
- cairo_surface_t *surface;
- cairo_t *cr2;
- const gint width = 10;
- const gint height = 10;
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
- cr2 = cairo_create (surface);
- cairo_surface_destroy (surface);
-
- cairo_set_source_rgb (cr2, 0.75, 0.75, 0.75); /* light gray */
- cairo_paint (cr2);
-
- cairo_set_source_rgb (cr2, 0.5, 0.5, 0.5); /* dark gray */
- cairo_rectangle (cr2, width / 2, 0, width / 2, height / 2);
- cairo_rectangle (cr2, 0, height / 2, width / 2, height / 2);
- cairo_fill (cr2);
-
- surface = cairo_surface_reference (cairo_get_target (cr2));
- cairo_destroy (cr2);
-
- cairo_save (cr);
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_surface_destroy (surface);
- cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
- cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
- cairo_paint (cr);
- cairo_restore (cr);
+ cairo_surface_t *surface;
+ cairo_t *cr2;
+ const gint width = 10;
+ const gint height = 10;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
+ cr2 = cairo_create (surface);
+ cairo_surface_destroy (surface);
+
+ cairo_set_source_rgb (cr2, 0.75, 0.75, 0.75); /* light gray */
+ cairo_paint (cr2);
+
+ cairo_set_source_rgb (cr2, 0.5, 0.5, 0.5); /* dark gray */
+ cairo_rectangle (cr2, width / 2, 0, width / 2, height / 2);
+ cairo_rectangle (cr2, 0, height / 2, width / 2, height / 2);
+ cairo_fill (cr2);
+
+ surface = cairo_surface_reference (cairo_get_target (cr2));
+ cairo_destroy (cr2);
+
+ cairo_save (cr);
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_surface_destroy (surface);
+ cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ cairo_paint (cr);
+ cairo_restore (cr);
}
static gboolean
-glade_placeholder_draw (GtkWidget *widget, cairo_t *cr)
+glade_placeholder_draw (GtkWidget * widget, cairo_t * cr)
{
- GtkStyle *style;
- GdkColor *light;
- GdkColor *dark;
- gint w, h;
+ GtkStyle *style;
+ GdkColor *light;
+ GdkColor *dark;
+ gint w, h;
- style = gtk_widget_get_style (widget);
- light = &style->light[GTK_STATE_NORMAL];
- dark = &style->dark[GTK_STATE_NORMAL];
+ style = gtk_widget_get_style (widget);
+ light = &style->light[GTK_STATE_NORMAL];
+ dark = &style->dark[GTK_STATE_NORMAL];
- h = gtk_widget_get_allocated_height (widget);
- w = gtk_widget_get_allocated_width (widget);
+ h = gtk_widget_get_allocated_height (widget);
+ w = gtk_widget_get_allocated_width (widget);
- glade_placeholder_draw_background (widget, cr);
-
- cairo_set_line_width (cr, 1.0);
+ glade_placeholder_draw_background (widget, cr);
- glade_utils_cairo_draw_line (cr, light, 0, 0, w - 1, 0);
- glade_utils_cairo_draw_line (cr, light, 0, 0, 0, h - 1);
- glade_utils_cairo_draw_line (cr, dark, 0, h - 1, w - 1, h - 1);
- glade_utils_cairo_draw_line (cr, dark, w - 1, 0, w - 1, h - 1);
+ cairo_set_line_width (cr, 1.0);
- glade_util_draw_selection_nodes (widget, cr);
+ glade_utils_cairo_draw_line (cr, light, 0, 0, w - 1, 0);
+ glade_utils_cairo_draw_line (cr, light, 0, 0, 0, h - 1);
+ glade_utils_cairo_draw_line (cr, dark, 0, h - 1, w - 1, h - 1);
+ glade_utils_cairo_draw_line (cr, dark, w - 1, 0, w - 1, h - 1);
- return FALSE;
+ glade_util_draw_selection_nodes (widget, cr);
+
+ return FALSE;
}
-static gboolean
-glade_placeholder_motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
+static gboolean
+glade_placeholder_motion_notify_event (GtkWidget * widget,
+ GdkEventMotion * event)
{
- GladePointerMode pointer_mode;
- GladeWidget *gparent;
-
- g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
-
- gparent = glade_placeholder_get_parent (GLADE_PLACEHOLDER (widget));
- pointer_mode = glade_app_get_pointer_mode ();
-
- if (pointer_mode == GLADE_POINTER_SELECT &&
- /* If we are the child of a widget that is in a GladeFixed, then
- * we are the means of drag/resize and we dont want to fight for
- * the cursor (ideally; GladeCursor should somehow deal with such
- * concurrencies I suppose).
- */
- (gparent->parent &&
- GLADE_IS_FIXED (gparent->parent)) == FALSE)
- glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR);
- else if (pointer_mode == GLADE_POINTER_ADD_WIDGET)
- glade_cursor_set (event->window, GLADE_CURSOR_ADD_WIDGET);
-
- return FALSE;
+ GladePointerMode pointer_mode;
+ GladeWidget *gparent;
+
+ g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
+
+ gparent = glade_placeholder_get_parent (GLADE_PLACEHOLDER (widget));
+ pointer_mode = glade_app_get_pointer_mode ();
+
+ if (pointer_mode == GLADE_POINTER_SELECT &&
+ /* If we are the child of a widget that is in a GladeFixed, then
+ * we are the means of drag/resize and we dont want to fight for
+ * the cursor (ideally; GladeCursor should somehow deal with such
+ * concurrencies I suppose).
+ */
+ (gparent->parent && GLADE_IS_FIXED (gparent->parent)) == FALSE)
+ glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR);
+ else if (pointer_mode == GLADE_POINTER_ADD_WIDGET)
+ glade_cursor_set (event->window, GLADE_CURSOR_ADD_WIDGET);
+
+ return FALSE;
}
static gboolean
-glade_placeholder_button_press (GtkWidget *widget, GdkEventButton *event)
+glade_placeholder_button_press (GtkWidget * widget, GdkEventButton * event)
{
- GladePlaceholder *placeholder;
- GladeProject *project;
- GladeWidgetAdaptor *adaptor;
- GladePalette *palette;
- gboolean handled = FALSE;
-
- g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
-
- adaptor = glade_palette_get_current_item (glade_app_get_palette ());
-
- palette = glade_app_get_palette ();
- placeholder = GLADE_PLACEHOLDER (widget);
- project = glade_placeholder_get_project (placeholder);
-
- if (!gtk_widget_has_focus (widget))
- gtk_widget_grab_focus (widget);
-
- if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
- {
- if (adaptor != NULL)
- {
- GladeWidget *parent = glade_placeholder_get_parent (placeholder);
-
- if (!glade_util_check_and_warn_scrollable (parent, adaptor, glade_app_get_window()))
- {
- /* A widget type is selected in the palette.
- * Add a new widget of that type.
- */
- glade_command_create (adaptor, parent, placeholder, project);
-
- glade_palette_deselect_current_item (glade_app_get_palette(), TRUE);
-
- /* reset the cursor */
- glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR);
- }
- handled = TRUE;
- }
- }
-
- if (!handled && glade_popup_is_popup_event (event))
- {
- glade_popup_placeholder_pop (placeholder, event);
- handled = TRUE;
- }
-
- return handled;
+ GladePlaceholder *placeholder;
+ GladeProject *project;
+ GladeWidgetAdaptor *adaptor;
+ GladePalette *palette;
+ gboolean handled = FALSE;
+
+ g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
+
+ adaptor = glade_palette_get_current_item (glade_app_get_palette ());
+
+ palette = glade_app_get_palette ();
+ placeholder = GLADE_PLACEHOLDER (widget);
+ project = glade_placeholder_get_project (placeholder);
+
+ if (!gtk_widget_has_focus (widget))
+ gtk_widget_grab_focus (widget);
+
+ if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
+ {
+ if (adaptor != NULL)
+ {
+ GladeWidget *parent = glade_placeholder_get_parent (placeholder);
+
+ if (!glade_util_check_and_warn_scrollable
+ (parent, adaptor, glade_app_get_window ()))
+ {
+ /* A widget type is selected in the palette.
+ * Add a new widget of that type.
+ */
+ glade_command_create (adaptor, parent, placeholder, project);
+
+ glade_palette_deselect_current_item (glade_app_get_palette (),
+ TRUE);
+
+ /* reset the cursor */
+ glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR);
+ }
+ handled = TRUE;
+ }
+ }
+
+ if (!handled && glade_popup_is_popup_event (event))
+ {
+ glade_popup_placeholder_pop (placeholder, event);
+ handled = TRUE;
+ }
+
+ return handled;
}
static gboolean
-glade_placeholder_popup_menu (GtkWidget *widget)
+glade_placeholder_popup_menu (GtkWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
+ g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
- glade_popup_placeholder_pop (GLADE_PLACEHOLDER (widget), NULL);
+ glade_popup_placeholder_pop (GLADE_PLACEHOLDER (widget), NULL);
- return TRUE;
+ return TRUE;
}
GladeWidget *
-glade_placeholder_get_parent (GladePlaceholder *placeholder)
+glade_placeholder_get_parent (GladePlaceholder * placeholder)
{
- GtkWidget *widget;
- GladeWidget *parent = NULL;
-
- g_return_val_if_fail (GLADE_IS_PLACEHOLDER (placeholder), NULL);
-
- for (widget = gtk_widget_get_parent (GTK_WIDGET (placeholder));
- widget != NULL;
- widget = gtk_widget_get_parent (widget))
- {
- if ((parent = glade_widget_get_from_gobject (widget)) != NULL)
- break;
- }
- return parent;
+ GtkWidget *widget;
+ GladeWidget *parent = NULL;
+
+ g_return_val_if_fail (GLADE_IS_PLACEHOLDER (placeholder), NULL);
+
+ for (widget = gtk_widget_get_parent (GTK_WIDGET (placeholder));
+ widget != NULL; widget = gtk_widget_get_parent (widget))
+ {
+ if ((parent = glade_widget_get_from_gobject (widget)) != NULL)
+ break;
+ }
+ return parent;
}
diff --git a/gladeui/glade-placeholder.h b/gladeui/glade-placeholder.h
index f520e7b..bddc579 100644
--- a/gladeui/glade-placeholder.h
+++ b/gladeui/glade-placeholder.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2003, 2004 Joaquin Cuenca Abela
*
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 002dc6a..fc0f866 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -41,163 +40,160 @@
WIDGET POPUP
*******************************************************/
static void
-glade_popup_select_cb (GtkMenuItem *item, GladeWidget *widget)
+glade_popup_select_cb (GtkMenuItem * item, GladeWidget * widget)
{
- glade_util_clear_selection ();
- glade_app_selection_set
- (glade_widget_get_object (widget), TRUE);
+ glade_util_clear_selection ();
+ glade_app_selection_set (glade_widget_get_object (widget), TRUE);
}
static GladePlaceholder *
-find_placeholder (GObject *object)
+find_placeholder (GObject * object)
{
- GtkContainer *container;
- GladePlaceholder *retval = NULL;
- GtkWidget *child;
- GList *c, *l;
-
- if (!GTK_IS_CONTAINER (object))
- return NULL;
-
- container = GTK_CONTAINER (object);
-
- for (c = l = glade_util_container_get_all_children (container);
- l;
- l = g_list_next (l))
- {
- child = l->data;
-
- if (GLADE_IS_PLACEHOLDER (child))
- {
- retval = GLADE_PLACEHOLDER (child);
- break;
- }
- }
-
- g_list_free (c);
-
- return retval;
+ GtkContainer *container;
+ GladePlaceholder *retval = NULL;
+ GtkWidget *child;
+ GList *c, *l;
+
+ if (!GTK_IS_CONTAINER (object))
+ return NULL;
+
+ container = GTK_CONTAINER (object);
+
+ for (c = l = glade_util_container_get_all_children (container);
+ l; l = g_list_next (l))
+ {
+ child = l->data;
+
+ if (GLADE_IS_PLACEHOLDER (child))
+ {
+ retval = GLADE_PLACEHOLDER (child);
+ break;
+ }
+ }
+
+ g_list_free (c);
+
+ return retval;
}
static void
-glade_popup_placeholder_add_cb (GtkMenuItem *item, GladePlaceholder *placeholder)
+glade_popup_placeholder_add_cb (GtkMenuItem * item,
+ GladePlaceholder * placeholder)
{
- GladeWidgetAdaptor *adaptor;
- GladeWidget *parent;
+ GladeWidgetAdaptor *adaptor;
+ GladeWidget *parent;
+
+ adaptor = glade_palette_get_current_item (glade_app_get_palette ());
+ g_return_if_fail (adaptor != NULL);
- adaptor = glade_palette_get_current_item (glade_app_get_palette ());
- g_return_if_fail (adaptor != NULL);
+ parent = glade_placeholder_get_parent (placeholder);
- parent = glade_placeholder_get_parent (placeholder);
+ if (!glade_util_check_and_warn_scrollable
+ (parent, adaptor, glade_app_get_window ()))
+ {
+ glade_command_create (adaptor, parent,
+ placeholder,
+ glade_placeholder_get_project (placeholder));
- if (!glade_util_check_and_warn_scrollable (parent, adaptor, glade_app_get_window()))
- {
- glade_command_create (adaptor, parent,
- placeholder, glade_placeholder_get_project (placeholder));
-
- glade_palette_deselect_current_item (glade_app_get_palette(), TRUE);
- }
+ glade_palette_deselect_current_item (glade_app_get_palette (), TRUE);
+ }
}
static void
-glade_popup_action_add_cb (GtkMenuItem *item, GladeWidget *group)
+glade_popup_action_add_cb (GtkMenuItem * item, GladeWidget * group)
{
- GladeWidgetAdaptor *adaptor;
+ GladeWidgetAdaptor *adaptor;
- adaptor = glade_palette_get_current_item (glade_app_get_palette ());
- g_return_if_fail (adaptor != NULL);
+ adaptor = glade_palette_get_current_item (glade_app_get_palette ());
+ g_return_if_fail (adaptor != NULL);
- glade_command_create (adaptor, group,
- NULL, glade_widget_get_project (group));
-
- glade_palette_deselect_current_item (glade_app_get_palette(), TRUE);
+ glade_command_create (adaptor, group, NULL, glade_widget_get_project (group));
+
+ glade_palette_deselect_current_item (glade_app_get_palette (), TRUE);
}
static void
-glade_popup_root_add_cb (GtkMenuItem *item, gpointer *user_data)
+glade_popup_root_add_cb (GtkMenuItem * item, gpointer * user_data)
{
- GladeWidgetAdaptor *adaptor = (GladeWidgetAdaptor *)user_data;
- GladePalette *palette = glade_app_get_palette ();
-
- if (!adaptor)
- adaptor = glade_palette_get_current_item (palette);
- g_return_if_fail (adaptor != NULL);
-
- glade_palette_create_root_widget (palette, adaptor);
+ GladeWidgetAdaptor *adaptor = (GladeWidgetAdaptor *) user_data;
+ GladePalette *palette = glade_app_get_palette ();
+
+ if (!adaptor)
+ adaptor = glade_palette_get_current_item (palette);
+ g_return_if_fail (adaptor != NULL);
+
+ glade_palette_create_root_widget (palette, adaptor);
}
static void
-glade_popup_cut_cb (GtkMenuItem *item, GladeWidget *widget)
+glade_popup_cut_cb (GtkMenuItem * item, GladeWidget * widget)
{
- GladeProject *project = glade_app_get_project ();
-
- glade_util_clear_selection ();
-
- /* Assign selection first */
- if (glade_project_is_selected
- (project, glade_widget_get_object (widget)) == FALSE)
- {
- glade_app_selection_set
- (glade_widget_get_object (widget), FALSE);
- }
- glade_app_command_cut ();
+ GladeProject *project = glade_app_get_project ();
+
+ glade_util_clear_selection ();
+
+ /* Assign selection first */
+ if (glade_project_is_selected
+ (project, glade_widget_get_object (widget)) == FALSE)
+ {
+ glade_app_selection_set (glade_widget_get_object (widget), FALSE);
+ }
+ glade_app_command_cut ();
}
static void
-glade_popup_copy_cb (GtkMenuItem *item, GladeWidget *widget)
+glade_popup_copy_cb (GtkMenuItem * item, GladeWidget * widget)
{
- GladeProject *project = glade_app_get_project ();
+ GladeProject *project = glade_app_get_project ();
- glade_util_clear_selection ();
+ glade_util_clear_selection ();
- /* Assign selection first */
- if (glade_project_is_selected
- (project, glade_widget_get_object (widget)) == FALSE)
- glade_app_selection_set
- (glade_widget_get_object (widget), FALSE);
+ /* Assign selection first */
+ if (glade_project_is_selected
+ (project, glade_widget_get_object (widget)) == FALSE)
+ glade_app_selection_set (glade_widget_get_object (widget), FALSE);
- glade_app_command_copy ();
+ glade_app_command_copy ();
}
static void
-glade_popup_paste_cb (GtkMenuItem *item, GladeWidget *widget)
+glade_popup_paste_cb (GtkMenuItem * item, GladeWidget * widget)
{
- glade_util_clear_selection ();
+ glade_util_clear_selection ();
- /* The selected widget is the paste destination */
- if (widget)
- glade_app_selection_set (glade_widget_get_object (widget), FALSE);
- else
- glade_app_selection_clear (FALSE);
+ /* The selected widget is the paste destination */
+ if (widget)
+ glade_app_selection_set (glade_widget_get_object (widget), FALSE);
+ else
+ glade_app_selection_clear (FALSE);
- glade_app_command_paste (NULL);
+ glade_app_command_paste (NULL);
}
static void
-glade_popup_delete_cb (GtkMenuItem *item, GladeWidget *widget)
+glade_popup_delete_cb (GtkMenuItem * item, GladeWidget * widget)
{
- GladeProject *project = glade_app_get_project ();
+ GladeProject *project = glade_app_get_project ();
- /* Assign selection first */
- if (glade_project_is_selected
- (project, glade_widget_get_object (widget)) == FALSE)
- glade_app_selection_set
- (glade_widget_get_object (widget), FALSE);
+ /* Assign selection first */
+ if (glade_project_is_selected
+ (project, glade_widget_get_object (widget)) == FALSE)
+ glade_app_selection_set (glade_widget_get_object (widget), FALSE);
- glade_app_command_delete ();
+ glade_app_command_delete ();
}
/********************************************************
PLACEHOLDER POPUP
*******************************************************/
static void
-glade_popup_placeholder_paste_cb (GtkMenuItem *item,
- GladePlaceholder *placeholder)
+glade_popup_placeholder_paste_cb (GtkMenuItem * item,
+ GladePlaceholder * placeholder)
{
- glade_util_clear_selection ();
- glade_app_selection_clear (FALSE);
-
- glade_app_command_paste (placeholder);
+ glade_util_clear_selection ();
+ glade_app_selection_clear (FALSE);
+
+ glade_app_command_paste (placeholder);
}
@@ -205,32 +201,31 @@ glade_popup_placeholder_paste_cb (GtkMenuItem *item,
CLIPBOARD POPUP
*******************************************************/
static void
-glade_popup_clipboard_paste_cb (GtkMenuItem *item,
- GladeWidget *widget)
+glade_popup_clipboard_paste_cb (GtkMenuItem * item, GladeWidget * widget)
{
- glade_util_clear_selection ();
- glade_app_selection_clear (FALSE);
+ glade_util_clear_selection ();
+ glade_app_selection_clear (FALSE);
- glade_app_command_paste (NULL);
+ glade_app_command_paste (NULL);
}
static void
-glade_popup_clipboard_delete_cb (GtkMenuItem *item, GladeWidget *widget)
+glade_popup_clipboard_delete_cb (GtkMenuItem * item, GladeWidget * widget)
{
- glade_app_command_delete_clipboard ();
+ glade_app_command_delete_clipboard ();
}
static void
-glade_popup_docs_cb (GtkMenuItem *item,
- GladeWidgetAdaptor *adaptor)
+glade_popup_docs_cb (GtkMenuItem * item, GladeWidgetAdaptor * adaptor)
{
- gchar *book;
+ gchar *book;
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_object_get (adaptor, "book", &book, NULL);
- glade_editor_search_doc_search (glade_app_get_editor (), book, adaptor->name, NULL);
- g_free (book);
+ g_object_get (adaptor, "book", &book, NULL);
+ glade_editor_search_doc_search (glade_app_get_editor (), book, adaptor->name,
+ NULL);
+ g_free (book);
}
@@ -238,131 +233,127 @@ glade_popup_docs_cb (GtkMenuItem *item,
POPUP BUILDING
*******************************************************/
static GtkWidget *
-glade_popup_append_item (GtkWidget *popup_menu,
- const gchar *stock_id,
- const gchar *label,
- GtkWidget *image,
- gboolean sensitive,
- gpointer callback,
- gpointer data)
+glade_popup_append_item (GtkWidget * popup_menu,
+ const gchar * stock_id,
+ const gchar * label,
+ GtkWidget * image,
+ gboolean sensitive, gpointer callback, gpointer data)
{
- GtkWidget *menu_item;
-
- if (stock_id && label)
- {
- menu_item = gtk_image_menu_item_new_with_mnemonic (label);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
- gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU));
- }
- else if (image && label)
- {
- menu_item = gtk_image_menu_item_new_with_mnemonic (label);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
- }
- else if (stock_id)
- menu_item = gtk_image_menu_item_new_from_stock (stock_id, NULL);
- else
- menu_item = gtk_menu_item_new_with_mnemonic (label);
-
- if (callback)
- g_signal_connect (G_OBJECT (menu_item), "activate",
- G_CALLBACK (callback), data);
-
- gtk_widget_set_sensitive (menu_item, sensitive);
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item);
-
- return menu_item;
+ GtkWidget *menu_item;
+
+ if (stock_id && label)
+ {
+ menu_item = gtk_image_menu_item_new_with_mnemonic (label);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
+ gtk_image_new_from_stock (stock_id,
+ GTK_ICON_SIZE_MENU));
+ }
+ else if (image && label)
+ {
+ menu_item = gtk_image_menu_item_new_with_mnemonic (label);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
+ }
+ else if (stock_id)
+ menu_item = gtk_image_menu_item_new_from_stock (stock_id, NULL);
+ else
+ menu_item = gtk_menu_item_new_with_mnemonic (label);
+
+ if (callback)
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (callback), data);
+
+ gtk_widget_set_sensitive (menu_item, sensitive);
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), menu_item);
+
+ return menu_item;
}
static void
-glade_popup_menuitem_activated (GtkMenuItem *item, const gchar *action_path)
+glade_popup_menuitem_activated (GtkMenuItem * item, const gchar * action_path)
{
- GladeWidget *widget;
-
- if ((widget = g_object_get_data (G_OBJECT (item), "gwa-data")))
- glade_widget_adaptor_action_activate (widget->adaptor,
- widget->object,
- action_path);
+ GladeWidget *widget;
+
+ if ((widget = g_object_get_data (G_OBJECT (item), "gwa-data")))
+ glade_widget_adaptor_action_activate (widget->adaptor,
+ widget->object, action_path);
}
static void
-glade_popup_menuitem_packing_activated (GtkMenuItem *item, const gchar *action_path)
+glade_popup_menuitem_packing_activated (GtkMenuItem * item,
+ const gchar * action_path)
{
- GladeWidget *widget;
-
- if ((widget = g_object_get_data (G_OBJECT (item), "gwa-data")))
- glade_widget_adaptor_child_action_activate (widget->parent->adaptor,
- widget->parent->object,
- widget->object,
- action_path);
+ GladeWidget *widget;
+
+ if ((widget = g_object_get_data (G_OBJECT (item), "gwa-data")))
+ glade_widget_adaptor_child_action_activate (widget->parent->adaptor,
+ widget->parent->object,
+ widget->object, action_path);
}
static void
-glade_popup_menuitem_ph_packing_activated (GtkMenuItem *item, const gchar *action_path)
+glade_popup_menuitem_ph_packing_activated (GtkMenuItem * item,
+ const gchar * action_path)
{
- GladePlaceholder *ph;
- GladeWidget *parent;
-
- if ((ph = g_object_get_data (G_OBJECT (item), "gwa-data")))
- {
- parent = glade_placeholder_get_parent (ph);
- glade_widget_adaptor_child_action_activate (parent->adaptor,
- parent->object,
- G_OBJECT (ph),
- action_path);
- }
+ GladePlaceholder *ph;
+ GladeWidget *parent;
+
+ if ((ph = g_object_get_data (G_OBJECT (item), "gwa-data")))
+ {
+ parent = glade_placeholder_get_parent (ph);
+ glade_widget_adaptor_child_action_activate (parent->adaptor,
+ parent->object,
+ G_OBJECT (ph), action_path);
+ }
}
static gint
-glade_popup_action_populate_menu_real (GtkWidget *menu,
- GladeWidget *gwidget,
- GList *actions,
- GCallback callback,
- gpointer data)
+glade_popup_action_populate_menu_real (GtkWidget * menu,
+ GladeWidget * gwidget,
+ GList * actions,
+ GCallback callback, gpointer data)
{
- GtkWidget *item;
- GList *list;
- gint n = 0;
-
- for (list = actions; list; list = g_list_next (list))
- {
- GladeWidgetAction *a = list->data;
- GtkWidget *submenu = NULL;
-
- if (a->actions)
- {
- submenu = gtk_menu_new ();
- n += glade_popup_action_populate_menu_real (submenu,
- gwidget,
- a->actions,
- callback,
- data);
- }
- else
- submenu = glade_widget_adaptor_action_submenu (gwidget->adaptor,
- gwidget->object,
- a->klass->path);
-
-
- item = glade_popup_append_item (menu,
- a->klass->stock,
- a->klass->label, NULL, TRUE,
- (a->actions) ? NULL : callback,
- (a->actions) ? NULL : a->klass->path);
-
- g_object_set_data (G_OBJECT (item), "gwa-data", data);
-
- gtk_widget_set_sensitive (item, a->sensitive);
-
- if (submenu)
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
-
- n++;
- }
-
- return n;
+ GtkWidget *item;
+ GList *list;
+ gint n = 0;
+
+ for (list = actions; list; list = g_list_next (list))
+ {
+ GladeWidgetAction *a = list->data;
+ GtkWidget *submenu = NULL;
+
+ if (a->actions)
+ {
+ submenu = gtk_menu_new ();
+ n += glade_popup_action_populate_menu_real (submenu,
+ gwidget,
+ a->actions,
+ callback, data);
+ }
+ else
+ submenu = glade_widget_adaptor_action_submenu (gwidget->adaptor,
+ gwidget->object,
+ a->klass->path);
+
+
+ item = glade_popup_append_item (menu,
+ a->klass->stock,
+ a->klass->label, NULL, TRUE,
+ (a->actions) ? NULL : callback,
+ (a->actions) ? NULL : a->klass->path);
+
+ g_object_set_data (G_OBJECT (item), "gwa-data", data);
+
+ gtk_widget_set_sensitive (item, a->sensitive);
+
+ if (submenu)
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
+
+ n++;
+ }
+
+ return n;
}
/*
@@ -377,451 +368,458 @@ glade_popup_action_populate_menu_real (GtkWidget *menu,
* Returns the number of action appended to the menu.
*/
gint
-glade_popup_action_populate_menu (GtkWidget *menu,
- GladeWidget *widget,
- GladeWidgetAction *action,
- gboolean packing)
+glade_popup_action_populate_menu (GtkWidget * menu,
+ GladeWidget * widget,
+ GladeWidgetAction * action, gboolean packing)
{
- gint n;
-
- g_return_val_if_fail (GTK_IS_MENU (menu), 0);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), 0);
-
- if (action)
- {
- g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (action), 0);
- if (glade_widget_get_action (widget, action->klass->path))
- return glade_popup_action_populate_menu_real (menu,
- widget,
- action->actions,
- G_CALLBACK (glade_popup_menuitem_activated),
- widget);
-
- if (glade_widget_get_pack_action (widget, action->klass->path))
- return glade_popup_action_populate_menu_real (menu,
- glade_widget_get_parent (widget),
- action->actions,
- G_CALLBACK (glade_popup_menuitem_packing_activated),
- widget);
-
- return 0;
- }
-
- n = glade_popup_action_populate_menu_real (menu,
- widget,
- widget->actions,
- G_CALLBACK (glade_popup_menuitem_activated),
- widget);
-
- if (packing && widget->packing_actions)
- {
- if (n)
- {
- GtkWidget *separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
- gtk_widget_show (separator);
- }
- n += glade_popup_action_populate_menu_real (menu,
- glade_widget_get_parent (widget),
- widget->packing_actions,
- G_CALLBACK (glade_popup_menuitem_packing_activated),
- widget);
- }
-
- return n;
+ gint n;
+
+ g_return_val_if_fail (GTK_IS_MENU (menu), 0);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), 0);
+
+ if (action)
+ {
+ g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (action), 0);
+ if (glade_widget_get_action (widget, action->klass->path))
+ return glade_popup_action_populate_menu_real (menu,
+ widget,
+ action->actions,
+ G_CALLBACK
+ (glade_popup_menuitem_activated),
+ widget);
+
+ if (glade_widget_get_pack_action (widget, action->klass->path))
+ return glade_popup_action_populate_menu_real (menu,
+ glade_widget_get_parent
+ (widget), action->actions,
+ G_CALLBACK
+ (glade_popup_menuitem_packing_activated),
+ widget);
+
+ return 0;
+ }
+
+ n = glade_popup_action_populate_menu_real (menu,
+ widget,
+ widget->actions,
+ G_CALLBACK
+ (glade_popup_menuitem_activated),
+ widget);
+
+ if (packing && widget->packing_actions)
+ {
+ if (n)
+ {
+ GtkWidget *separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
+ gtk_widget_show (separator);
+ }
+ n += glade_popup_action_populate_menu_real (menu,
+ glade_widget_get_parent
+ (widget),
+ widget->packing_actions,
+ G_CALLBACK
+ (glade_popup_menuitem_packing_activated),
+ widget);
+ }
+
+ return n;
}
static GtkWidget *
-glade_popup_create_menu (GladeWidget *widget,
- GladePlaceholder *placeholder,
- gboolean packing)
+glade_popup_create_menu (GladeWidget * widget,
+ GladePlaceholder * placeholder, gboolean packing)
{
- GladeWidgetAdaptor *current_item;
- GtkWidget *popup_menu;
- GtkWidget *separator;
- gboolean sensitive;
- GladePlaceholder *tmp_placeholder;
- gchar *book;
-
- sensitive = (current_item = glade_palette_get_current_item (glade_app_get_palette ())) != NULL;
-
- popup_menu = gtk_menu_new ();
-
- if (current_item)
- {
-
- /* Special case for GtkAction accelerators */
- if (widget && GTK_IS_ACTION_GROUP (widget->object) &&
- (current_item->type == GTK_TYPE_ACTION ||
- g_type_is_a (current_item->type, GTK_TYPE_ACTION)))
- {
- glade_popup_append_item (popup_menu, NULL, _("_Add widget here"), NULL, TRUE,
- glade_popup_action_add_cb, widget);
- }
- else
- {
- tmp_placeholder = placeholder;
- if (!tmp_placeholder && widget)
- tmp_placeholder = find_placeholder (glade_widget_get_object (widget));
-
- glade_popup_append_item (popup_menu, NULL, _("_Add widget here"), NULL, tmp_placeholder != NULL,
- glade_popup_placeholder_add_cb, tmp_placeholder);
- }
-
- glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL,
- TRUE, glade_popup_root_add_cb, NULL);
-
- separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
- gtk_widget_show (separator);
- }
-
- sensitive = (widget != NULL);
-
- glade_popup_append_item (popup_menu, NULL, _("_Select"), NULL, sensitive,
- glade_popup_select_cb, widget);
- glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, NULL, sensitive,
- glade_popup_cut_cb, widget);
- glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, NULL, sensitive,
- glade_popup_copy_cb, widget);
-
- /* paste is placholder specific when the popup is on a placeholder */
- sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());
-
- if (placeholder)
- glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
- glade_popup_placeholder_paste_cb, placeholder);
- else if (widget)
- glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
- glade_popup_paste_cb, widget);
- else
- glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
- glade_popup_paste_cb, NULL);
-
-
- glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, (widget != NULL),
- glade_popup_delete_cb, widget);
-
-
- /* packing actions are a little different on placholders */
- if (placeholder)
- {
- if (widget && widget->actions)
- {
- GtkWidget *separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
- gtk_widget_show (separator);
-
- glade_popup_action_populate_menu_real
- (popup_menu,
- widget,
- widget->actions,
- G_CALLBACK (glade_popup_menuitem_activated),
- widget);
- }
-
- if (placeholder->packing_actions)
- {
- GtkWidget *separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
- gtk_widget_show (separator);
-
- glade_popup_action_populate_menu_real
- (popup_menu,
- widget,
- placeholder->packing_actions,
- G_CALLBACK (glade_popup_menuitem_ph_packing_activated),
- placeholder);
- }
- }
- else if (widget && (widget->actions || (packing && widget->packing_actions)))
- {
- GtkWidget *separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
- gtk_widget_show (separator);
-
- glade_popup_action_populate_menu (popup_menu, widget, NULL, packing);
- }
-
- if (widget)
- {
- g_object_get (widget->adaptor, "book", &book, NULL);
- if (book)
- {
- GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
- GtkWidget *separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
- gtk_widget_show (separator);
-
- glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
- glade_popup_docs_cb, widget->adaptor);
- }
- g_free (book);
- }
-
- return popup_menu;
+ GladeWidgetAdaptor *current_item;
+ GtkWidget *popup_menu;
+ GtkWidget *separator;
+ gboolean sensitive;
+ GladePlaceholder *tmp_placeholder;
+ gchar *book;
+
+ sensitive = (current_item =
+ glade_palette_get_current_item (glade_app_get_palette ())) !=
+ NULL;
+
+ popup_menu = gtk_menu_new ();
+
+ if (current_item)
+ {
+
+ /* Special case for GtkAction accelerators */
+ if (widget && GTK_IS_ACTION_GROUP (widget->object) &&
+ (current_item->type == GTK_TYPE_ACTION ||
+ g_type_is_a (current_item->type, GTK_TYPE_ACTION)))
+ {
+ glade_popup_append_item (popup_menu, NULL, _("_Add widget here"),
+ NULL, TRUE, glade_popup_action_add_cb,
+ widget);
+ }
+ else
+ {
+ tmp_placeholder = placeholder;
+ if (!tmp_placeholder && widget)
+ tmp_placeholder =
+ find_placeholder (glade_widget_get_object (widget));
+
+ glade_popup_append_item (popup_menu, NULL, _("_Add widget here"),
+ NULL, tmp_placeholder != NULL,
+ glade_popup_placeholder_add_cb,
+ tmp_placeholder);
+ }
+
+ glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"),
+ NULL, TRUE, glade_popup_root_add_cb, NULL);
+
+ separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
+ gtk_widget_show (separator);
+ }
+
+ sensitive = (widget != NULL);
+
+ glade_popup_append_item (popup_menu, NULL, _("_Select"), NULL, sensitive,
+ glade_popup_select_cb, widget);
+ glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, NULL, sensitive,
+ glade_popup_cut_cb, widget);
+ glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, NULL, sensitive,
+ glade_popup_copy_cb, widget);
+
+ /* paste is placholder specific when the popup is on a placeholder */
+ sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());
+
+ if (placeholder)
+ glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
+ glade_popup_placeholder_paste_cb, placeholder);
+ else if (widget)
+ glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
+ glade_popup_paste_cb, widget);
+ else
+ glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
+ glade_popup_paste_cb, NULL);
+
+
+ glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL,
+ (widget != NULL), glade_popup_delete_cb, widget);
+
+
+ /* packing actions are a little different on placholders */
+ if (placeholder)
+ {
+ if (widget && widget->actions)
+ {
+ GtkWidget *separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
+ gtk_widget_show (separator);
+
+ glade_popup_action_populate_menu_real
+ (popup_menu,
+ widget,
+ widget->actions,
+ G_CALLBACK (glade_popup_menuitem_activated), widget);
+ }
+
+ if (placeholder->packing_actions)
+ {
+ GtkWidget *separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
+ gtk_widget_show (separator);
+
+ glade_popup_action_populate_menu_real
+ (popup_menu,
+ widget,
+ placeholder->packing_actions,
+ G_CALLBACK (glade_popup_menuitem_ph_packing_activated),
+ placeholder);
+ }
+ }
+ else if (widget && (widget->actions || (packing && widget->packing_actions)))
+ {
+ GtkWidget *separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
+ gtk_widget_show (separator);
+
+ glade_popup_action_populate_menu (popup_menu, widget, NULL, packing);
+ }
+
+ if (widget)
+ {
+ g_object_get (widget->adaptor, "book", &book, NULL);
+ if (book)
+ {
+ GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
+ GtkWidget *separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
+ gtk_widget_show (separator);
+
+ glade_popup_append_item (popup_menu, NULL, _("Read _documentation"),
+ icon, TRUE, glade_popup_docs_cb,
+ widget->adaptor);
+ }
+ g_free (book);
+ }
+
+ return popup_menu;
}
static GtkWidget *
-glade_popup_create_clipboard_menu (GladeWidget *widget)
+glade_popup_create_clipboard_menu (GladeWidget * widget)
{
- GtkWidget *popup_menu;
-
- popup_menu = gtk_menu_new ();
+ GtkWidget *popup_menu;
- if (gtk_widget_is_toplevel (GTK_WIDGET (glade_widget_get_object (widget))))
- {
- glade_popup_append_item (popup_menu, GTK_STOCK_PASTE,
- NULL, NULL, TRUE,
- glade_popup_clipboard_paste_cb, NULL);
- }
+ popup_menu = gtk_menu_new ();
- glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, TRUE,
- glade_popup_clipboard_delete_cb, widget);
+ if (gtk_widget_is_toplevel (GTK_WIDGET (glade_widget_get_object (widget))))
+ {
+ glade_popup_append_item (popup_menu, GTK_STOCK_PASTE,
+ NULL, NULL, TRUE,
+ glade_popup_clipboard_paste_cb, NULL);
+ }
- return popup_menu;
+ glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, TRUE,
+ glade_popup_clipboard_delete_cb, widget);
+
+ return popup_menu;
}
void
-glade_popup_widget_pop (GladeWidget *widget,
- GdkEventButton *event,
- gboolean packing)
+glade_popup_widget_pop (GladeWidget * widget,
+ GdkEventButton * event, gboolean packing)
{
- GtkWidget *popup_menu;
- gint button;
- gint event_time;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget) || widget == NULL);
-
- popup_menu = glade_popup_create_menu (widget, NULL, packing);
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL, button, event_time);
+ GtkWidget *popup_menu;
+ gint button;
+ gint event_time;
+
+ g_return_if_fail (GLADE_IS_WIDGET (widget) || widget == NULL);
+
+ popup_menu = glade_popup_create_menu (widget, NULL, packing);
+
+ if (event)
+ {
+ button = event->button;
+ event_time = event->time;
+ }
+ else
+ {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL, button, event_time);
}
void
-glade_popup_placeholder_pop (GladePlaceholder *placeholder,
- GdkEventButton *event)
+glade_popup_placeholder_pop (GladePlaceholder * placeholder,
+ GdkEventButton * event)
{
- GladeWidget *widget;
- GtkWidget *popup_menu;
- gint button;
- gint event_time;
-
- g_return_if_fail (GLADE_IS_PLACEHOLDER (placeholder));
-
- widget = glade_placeholder_get_parent (placeholder);
-
- popup_menu = glade_popup_create_menu (widget, placeholder, TRUE);
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL, button, event_time);
+ GladeWidget *widget;
+ GtkWidget *popup_menu;
+ gint button;
+ gint event_time;
+
+ g_return_if_fail (GLADE_IS_PLACEHOLDER (placeholder));
+
+ widget = glade_placeholder_get_parent (placeholder);
+
+ popup_menu = glade_popup_create_menu (widget, placeholder, TRUE);
+
+ if (event)
+ {
+ button = event->button;
+ event_time = event->time;
+ }
+ else
+ {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL, button, event_time);
}
void
-glade_popup_clipboard_pop (GladeWidget *widget,
- GdkEventButton *event)
+glade_popup_clipboard_pop (GladeWidget * widget, GdkEventButton * event)
{
- GtkWidget *popup_menu;
- gint button;
- gint event_time;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget));
-
- popup_menu = glade_popup_create_clipboard_menu (widget);
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL, button, event_time);
+ GtkWidget *popup_menu;
+ gint button;
+ gint event_time;
+
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+
+ popup_menu = glade_popup_create_clipboard_menu (widget);
+
+ if (event)
+ {
+ button = event->button;
+ event_time = event->time;
+ }
+ else
+ {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL, button, event_time);
}
void
-glade_popup_palette_pop (GladeWidgetAdaptor *adaptor,
- GdkEventButton *event)
+glade_popup_palette_pop (GladeWidgetAdaptor * adaptor, GdkEventButton * event)
{
- GladeProject *project;
- GtkWidget *popup_menu;
- gchar *book = NULL;
- gint button;
- gint event_time;
-
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
-
- popup_menu = gtk_menu_new ();
-
- project = glade_app_get_project ();
-
- glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL,
- TRUE, glade_popup_root_add_cb, adaptor);
-
- g_object_get (adaptor, "book", &book, NULL);
- if (book && glade_util_have_devhelp ())
- {
- GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
- glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
- glade_popup_docs_cb, adaptor);
- }
- g_free (book);
-
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL, button, event_time);
+ GladeProject *project;
+ GtkWidget *popup_menu;
+ gchar *book = NULL;
+ gint button;
+ gint event_time;
+
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+
+ popup_menu = gtk_menu_new ();
+
+ project = glade_app_get_project ();
+
+ glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL,
+ TRUE, glade_popup_root_add_cb, adaptor);
+
+ g_object_get (adaptor, "book", &book, NULL);
+ if (book && glade_util_have_devhelp ())
+ {
+ GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
+ glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon,
+ TRUE, glade_popup_docs_cb, adaptor);
+ }
+ g_free (book);
+
+
+ if (event)
+ {
+ button = event->button;
+ event_time = event->time;
+ }
+ else
+ {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL, button, event_time);
}
static void
-glade_popup_clear_property_cb (GtkMenuItem *item,
- GladeProperty *property)
+glade_popup_clear_property_cb (GtkMenuItem * item, GladeProperty * property)
{
- GValue value = { 0, };
+ GValue value = { 0, };
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
}
static void
-glade_popup_property_docs_cb (GtkMenuItem *item,
- GladeProperty *property)
+glade_popup_property_docs_cb (GtkMenuItem * item, GladeProperty * property)
{
- GladeWidgetAdaptor *adaptor, *prop_adaptor;
- gchar *search, *book;
+ GladeWidgetAdaptor *adaptor, *prop_adaptor;
+ gchar *search, *book;
- prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
- adaptor = glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
- search = g_strdup_printf ("The %s property", property->klass->id);
+ prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
+ adaptor =
+ glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
+ search = g_strdup_printf ("The %s property", property->klass->id);
- g_object_get (adaptor, "book", &book, NULL);
+ g_object_get (adaptor, "book", &book, NULL);
- glade_editor_search_doc_search (glade_app_get_editor (),
- book, g_type_name (property->klass->pspec->owner_type), search);
+ glade_editor_search_doc_search (glade_app_get_editor (),
+ book,
+ g_type_name (property->klass->pspec->
+ owner_type), search);
- g_free (book);
- g_free (search);
+ g_free (book);
+ g_free (search);
}
void
-glade_popup_property_pop (GladeProperty *property,
- GdkEventButton *event)
+glade_popup_property_pop (GladeProperty * property, GdkEventButton * event)
{
- GladeWidgetAdaptor *adaptor, *prop_adaptor;
- GtkWidget *popup_menu;
- gchar *book = NULL;
- gint button;
- gint event_time;
-
- prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
- adaptor = glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
-
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
-
- popup_menu = gtk_menu_new ();
-
- glade_popup_append_item (popup_menu, GTK_STOCK_CLEAR, _("Set default value"), NULL,
- TRUE, glade_popup_clear_property_cb, property);
-
- g_object_get (adaptor, "book", &book, NULL);
- if (book && glade_util_have_devhelp ())
- {
- GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
- glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
- glade_popup_property_docs_cb, property);
- }
- g_free (book);
-
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
-
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL, button, event_time);
+ GladeWidgetAdaptor *adaptor, *prop_adaptor;
+ GtkWidget *popup_menu;
+ gchar *book = NULL;
+ gint button;
+ gint event_time;
+
+ prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
+ adaptor =
+ glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
+
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+
+ popup_menu = gtk_menu_new ();
+
+ glade_popup_append_item (popup_menu, GTK_STOCK_CLEAR, _("Set default value"),
+ NULL, TRUE, glade_popup_clear_property_cb, property);
+
+ g_object_get (adaptor, "book", &book, NULL);
+ if (book && glade_util_have_devhelp ())
+ {
+ GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
+ glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon,
+ TRUE, glade_popup_property_docs_cb, property);
+ }
+ g_free (book);
+
+
+ if (event)
+ {
+ button = event->button;
+ event_time = event->time;
+ }
+ else
+ {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL, button, event_time);
}
void
-glade_popup_simple_pop (GdkEventButton *event)
+glade_popup_simple_pop (GdkEventButton * event)
{
- GtkWidget *popup_menu;
- gint button;
- gint event_time;
-
- popup_menu = glade_popup_create_menu (NULL, NULL, FALSE);
- if (!popup_menu)
- return;
-
- if (event)
- {
- button = event->button;
- event_time = event->time;
- }
- else
- {
- button = 0;
- event_time = gtk_get_current_event_time ();
- }
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL, button, event_time);
+ GtkWidget *popup_menu;
+ gint button;
+ gint event_time;
+
+ popup_menu = glade_popup_create_menu (NULL, NULL, FALSE);
+ if (!popup_menu)
+ return;
+
+ if (event)
+ {
+ button = event->button;
+ event_time = event->time;
+ }
+ else
+ {
+ button = 0;
+ event_time = gtk_get_current_event_time ();
+ }
+ gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL, button, event_time);
}
gboolean
-glade_popup_is_popup_event (GdkEventButton *event)
+glade_popup_is_popup_event (GdkEventButton * event)
{
- g_return_val_if_fail (event, FALSE);
+ g_return_val_if_fail (event, FALSE);
#ifdef MAC_INTEGRATION
- return (event->type == GDK_BUTTON_PRESS && event->button == 1 && ((event->state & GDK_MOD1_MASK) != 0));
+ return (event->type == GDK_BUTTON_PRESS && event->button == 1 &&
+ ((event->state & GDK_MOD1_MASK) != 0));
#else
- return (event->type == GDK_BUTTON_PRESS && event->button == 3);
+ return (event->type == GDK_BUTTON_PRESS && event->button == 3);
#endif
}
-
diff --git a/gladeui/glade-popup.h b/gladeui/glade-popup.h
index 77fdb03..0547d62 100644
--- a/gladeui/glade-popup.h
+++ b/gladeui/glade-popup.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_POPUP_H__
#define __GLADE_POPUP_H__
diff --git a/gladeui/glade-previewer.c b/gladeui/glade-previewer.c
index 7c903f3..295950b 100644
--- a/gladeui/glade-previewer.c
+++ b/gladeui/glade-previewer.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2010 Marco Diego Aurélio Mesquita
*
@@ -34,309 +33,326 @@
#include <glib/gi18n-lib.h>
static void
-display_help_and_quit (const GOptionEntry *entries)
+display_help_and_quit (const GOptionEntry * entries)
{
- GOptionContext *context;
- context = g_option_context_new (_("- previews a glade UI definition"));
- g_option_context_add_main_entries (context, entries, NULL);
- g_option_context_add_group (context, gtk_get_option_group (TRUE));
+ GOptionContext *context;
+ context = g_option_context_new (_("- previews a glade UI definition"));
+ g_option_context_add_main_entries (context, entries, NULL);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
- g_print ("%s\n", g_option_context_get_help (context, TRUE, NULL));
+ g_print ("%s\n", g_option_context_get_help (context, TRUE, NULL));
- g_option_context_free (context);
- exit (1);
+ g_option_context_free (context);
+ exit (1);
}
static void
-parse_arguments (int argc, char **argv, gchar **toplevel_name, gchar **file_name)
+parse_arguments (int argc, char **argv, gchar ** toplevel_name,
+ gchar ** file_name)
{
- *toplevel_name = NULL;
- *file_name = NULL;
- gboolean listen = FALSE;
- gboolean version = FALSE;
- GError *error = NULL;
-
- GOptionEntry entries[] =
- {
- { "filename", 'f', G_OPTION_FLAG_FILENAME|G_OPTION_FLAG_OPTIONAL_ARG,
- G_OPTION_ARG_FILENAME, file_name, _("Name of the file to preview"), "FILENAME" },
- { "toplevel", 't', G_OPTION_FLAG_OPTIONAL_ARG,
- G_OPTION_ARG_STRING, toplevel_name, _("Name of the toplevel to preview"), "TOPLEVELNAME" },
- { "listen", 'l', 0, G_OPTION_ARG_NONE, &listen, _("Listen standard input"), NULL },
- { "version", 'v', 0, G_OPTION_ARG_NONE, &version, _("Display previewer version"), NULL },
-
- { NULL }
- };
-
- if (!gtk_init_with_args (&argc, &argv, _("- previews a glade UI definition"),
- entries, NULL, &error))
- {
- g_printerr (_("%s\nRun '%s --help' to see a full list of available command line"
- "options.\n"), error->message, argv[0]);
- g_error_free (error);
- exit(1);
- }
-
- if (version)
- {
- g_print ("glade-previewer " VERSION "\n");
- exit (0);
- }
-
- if (listen && *file_name != NULL)
- {
- g_printerr (_("--listen and --filename must not be simultaneously specified.\n"));
- display_help_and_quit (entries);
- }
-
- if (!listen && *file_name == NULL)
- {
- g_printerr (_("Either --listen or --filename must be specified.\n"));
- display_help_and_quit (entries);
- }
+ *toplevel_name = NULL;
+ *file_name = NULL;
+ gboolean listen = FALSE;
+ gboolean version = FALSE;
+ GError *error = NULL;
+
+ GOptionEntry entries[] = {
+ {"filename", 'f', G_OPTION_FLAG_FILENAME | G_OPTION_FLAG_OPTIONAL_ARG,
+ G_OPTION_ARG_FILENAME, file_name, _("Name of the file to preview"),
+ "FILENAME"},
+ {"toplevel", 't', G_OPTION_FLAG_OPTIONAL_ARG,
+ G_OPTION_ARG_STRING, toplevel_name, _("Name of the toplevel to preview"),
+ "TOPLEVELNAME"},
+ {"listen", 'l', 0, G_OPTION_ARG_NONE, &listen, _("Listen standard input"),
+ NULL},
+ {"version", 'v', 0, G_OPTION_ARG_NONE, &version,
+ _("Display previewer version"), NULL},
+
+ {NULL}
+ };
+
+ if (!gtk_init_with_args (&argc, &argv, _("- previews a glade UI definition"),
+ entries, NULL, &error))
+ {
+ g_printerr (_
+ ("%s\nRun '%s --help' to see a full list of available command line"
+ "options.\n"), error->message, argv[0]);
+ g_error_free (error);
+ exit (1);
+ }
+
+ if (version)
+ {
+ g_print ("glade-previewer " VERSION "\n");
+ exit (0);
+ }
+
+ if (listen && *file_name != NULL)
+ {
+ g_printerr (_
+ ("--listen and --filename must not be simultaneously specified.\n"));
+ display_help_and_quit (entries);
+ }
+
+ if (!listen && *file_name == NULL)
+ {
+ g_printerr (_("Either --listen or --filename must be specified.\n"));
+ display_help_and_quit (entries);
+ }
}
static GtkWidget *
-get_toplevel (gchar *name, gchar *string, gsize length)
+get_toplevel (gchar * name, gchar * string, gsize length)
{
- GError *error = NULL;
- GtkWidget *toplevel = NULL;
- GtkWidget *window = NULL;
- GtkBuilder *builder;
- GObject *object;
- GSList *objects;
-
- builder = gtk_builder_new ();
- if (!gtk_builder_add_from_string (builder, string, length, &error))
- {
- g_printerr (_("Couldn't load builder definition: %s"), error->message);
- g_error_free (error);
- exit (1);
- }
-
- if (name == NULL)
- {
- objects = gtk_builder_get_objects (builder);
-
- /* Iterate trough objects and search for a window or widget */
- while (objects != NULL)
- {
- if (GTK_IS_WIDGET (objects->data) && toplevel == NULL)
- {
- toplevel = GTK_WIDGET(objects->data);
- }
- if (GTK_IS_WINDOW (objects->data))
- {
- window = GTK_WIDGET(objects->data);
- break;
- }
- objects = objects->next;
- }
-
- if (window != NULL)
- {
- toplevel = window;
- }
- else if (toplevel == NULL)
- {
- g_printerr (_("UI definition has no previewable widgets.\n"));
- exit (1);
- }
- } else {
- object = gtk_builder_get_object (builder, name);
-
- if (object == NULL)
- {
- g_printerr (_("Object %s not found in UI definition.\n"), name);
- exit (1);
- }
-
- if (!GTK_IS_WIDGET(object))
- {
- g_printerr (_("Object is not previewable.\n"));
- exit (1);
- }
-
- toplevel = GTK_WIDGET(object);
- }
-
- g_object_unref (builder);
- return toplevel;
+ GError *error = NULL;
+ GtkWidget *toplevel = NULL;
+ GtkWidget *window = NULL;
+ GtkBuilder *builder;
+ GObject *object;
+ GSList *objects;
+
+ builder = gtk_builder_new ();
+ if (!gtk_builder_add_from_string (builder, string, length, &error))
+ {
+ g_printerr (_("Couldn't load builder definition: %s"), error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ if (name == NULL)
+ {
+ objects = gtk_builder_get_objects (builder);
+
+ /* Iterate trough objects and search for a window or widget */
+ while (objects != NULL)
+ {
+ if (GTK_IS_WIDGET (objects->data) && toplevel == NULL)
+ {
+ toplevel = GTK_WIDGET (objects->data);
+ }
+ if (GTK_IS_WINDOW (objects->data))
+ {
+ window = GTK_WIDGET (objects->data);
+ break;
+ }
+ objects = objects->next;
+ }
+
+ if (window != NULL)
+ {
+ toplevel = window;
+ }
+ else if (toplevel == NULL)
+ {
+ g_printerr (_("UI definition has no previewable widgets.\n"));
+ exit (1);
+ }
+ }
+ else
+ {
+ object = gtk_builder_get_object (builder, name);
+
+ if (object == NULL)
+ {
+ g_printerr (_("Object %s not found in UI definition.\n"), name);
+ exit (1);
+ }
+
+ if (!GTK_IS_WIDGET (object))
+ {
+ g_printerr (_("Object is not previewable.\n"));
+ exit (1);
+ }
+
+ toplevel = GTK_WIDGET (object);
+ }
+
+ g_object_unref (builder);
+ return toplevel;
}
static void
-preview_widget (gchar *name, gchar *buffer, gsize length)
+preview_widget (gchar * name, gchar * buffer, gsize length)
{
- GtkWidget *widget;
- GtkWidget *widget_parent;
- GtkWidget *window;
-
- widget = get_toplevel (name, buffer, length);
-
- if (GTK_IS_WINDOW (widget))
- {
- window = widget;
- } else {
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), _("Preview"));
-
- /* Reparenting snippet */
- g_object_ref(widget);
- widget_parent = gtk_widget_get_parent (widget);
- if (widget_parent != NULL) gtk_container_remove(GTK_CONTAINER(widget_parent), widget);
- gtk_container_add(GTK_CONTAINER(window), widget);
- g_object_unref(widget);
- }
-
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- gtk_widget_show_all (window);
+ GtkWidget *widget;
+ GtkWidget *widget_parent;
+ GtkWidget *window;
+
+ widget = get_toplevel (name, buffer, length);
+
+ if (GTK_IS_WINDOW (widget))
+ {
+ window = widget;
+ }
+ else
+ {
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), _("Preview"));
+
+ /* Reparenting snippet */
+ g_object_ref (widget);
+ widget_parent = gtk_widget_get_parent (widget);
+ if (widget_parent != NULL)
+ gtk_container_remove (GTK_CONTAINER (widget_parent), widget);
+ gtk_container_add (GTK_CONTAINER (window), widget);
+ g_object_unref (widget);
+ }
+
+ g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ gtk_widget_show_all (window);
}
static GIOChannel *
channel_from_stream (gint stream)
{
- GIOChannel *channel;
+ GIOChannel *channel;
- #ifdef WINDOWS
- channel = g_io_channel_win32_new_fd (stream);
- #else
- channel = g_io_channel_unix_new (stream);
- #endif
+#ifdef WINDOWS
+ channel = g_io_channel_win32_new_fd (stream);
+#else
+ channel = g_io_channel_unix_new (stream);
+#endif
- return channel;
+ return channel;
}
static void
-preview_file (gchar *toplevel_name, gchar *file_name)
+preview_file (gchar * toplevel_name, gchar * file_name)
{
- gchar *buffer;
- gsize length;
- GError *error = NULL;
- GIOChannel *input;
- gint stream;
-
- stream = fileno (fopen (file_name, "r"));
- input = channel_from_stream (stream);
-
- if (g_io_channel_read_to_end (input, &buffer, &length, &error) != G_IO_STATUS_NORMAL)
- {
- g_printerr (_("Error: %s.\n"), error->message);
- g_error_free (error);
- exit (1);
- }
-
- preview_widget (toplevel_name, buffer, length);
-
- g_free (buffer);
- g_io_channel_unref (input);
+ gchar *buffer;
+ gsize length;
+ GError *error = NULL;
+ GIOChannel *input;
+ gint stream;
+
+ stream = fileno (fopen (file_name, "r"));
+ input = channel_from_stream (stream);
+
+ if (g_io_channel_read_to_end (input, &buffer, &length, &error) !=
+ G_IO_STATUS_NORMAL)
+ {
+ g_printerr (_("Error: %s.\n"), error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ preview_widget (toplevel_name, buffer, length);
+
+ g_free (buffer);
+ g_io_channel_unref (input);
}
static gchar *
-read_buffer (GIOChannel *source)
+read_buffer (GIOChannel * source)
{
- gchar *buffer;
- gchar *token;
- gchar *tmp;
- GError *error = NULL;
-
- if (g_io_channel_read_line (source, &token, NULL, NULL, &error) != G_IO_STATUS_NORMAL)
- {
- g_printerr (_("Error: %s.\n"), error->message);
- g_error_free (error);
- exit (1);
- }
-
- /* Check for quit token */
- if (g_strcmp0 ("<quit>", token) == 0)
- {
- g_free (token);
- return NULL;
- }
-
- /* Loop to load the UI */
- buffer = g_strdup(token);
- do
- {
- g_free (token);
- if (g_io_channel_read_line (source, &token, NULL, NULL, &error) != G_IO_STATUS_NORMAL)
- {
- g_printerr (_("Error: %s.\n"), error->message);
- g_error_free (error);
- exit (1);
- }
- tmp = buffer;
- buffer = g_strconcat (buffer, token, NULL);
- g_free (tmp);
- } while (g_strcmp0 ("</interface>\n", token) != 0);
- g_free (token);
-
- return buffer;
+ gchar *buffer;
+ gchar *token;
+ gchar *tmp;
+ GError *error = NULL;
+
+ if (g_io_channel_read_line (source, &token, NULL, NULL, &error) !=
+ G_IO_STATUS_NORMAL)
+ {
+ g_printerr (_("Error: %s.\n"), error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ /* Check for quit token */
+ if (g_strcmp0 ("<quit>", token) == 0)
+ {
+ g_free (token);
+ return NULL;
+ }
+
+ /* Loop to load the UI */
+ buffer = g_strdup (token);
+ do
+ {
+ g_free (token);
+ if (g_io_channel_read_line (source, &token, NULL, NULL, &error) !=
+ G_IO_STATUS_NORMAL)
+ {
+ g_printerr (_("Error: %s.\n"), error->message);
+ g_error_free (error);
+ exit (1);
+ }
+ tmp = buffer;
+ buffer = g_strconcat (buffer, token, NULL);
+ g_free (tmp);
+ }
+ while (g_strcmp0 ("</interface>\n", token) != 0);
+ g_free (token);
+
+ return buffer;
}
static gboolean
-on_data_incoming (GIOChannel *source, GIOCondition condition, gpointer data)
+on_data_incoming (GIOChannel * source, GIOCondition condition, gpointer data)
{
- gchar *buffer;
- gsize length;
+ gchar *buffer;
+ gsize length;
- gchar *toplevel_name = (gchar*)data;
+ gchar *toplevel_name = (gchar *) data;
- buffer = read_buffer (source);
- if (buffer == NULL)
- {
- gtk_main_quit ();
- return FALSE;
- }
+ buffer = read_buffer (source);
+ if (buffer == NULL)
+ {
+ gtk_main_quit ();
+ return FALSE;
+ }
- if (condition & G_IO_HUP)
- {
- g_printerr (_("Broken pipe!\n"));
- exit (1);
- }
+ if (condition & G_IO_HUP)
+ {
+ g_printerr (_("Broken pipe!\n"));
+ exit (1);
+ }
- length = strlen (buffer);
+ length = strlen (buffer);
- preview_widget (toplevel_name, buffer, length);
- g_free (buffer);
+ preview_widget (toplevel_name, buffer, length);
+ g_free (buffer);
- return TRUE;
+ return TRUE;
}
static void
-start_listener (gchar *toplevel_name)
+start_listener (gchar * toplevel_name)
{
- GIOChannel *input;
- gint stream;
+ GIOChannel *input;
+ gint stream;
- stream = fileno (stdin);
- input = channel_from_stream (stream);
+ stream = fileno (stdin);
+ input = channel_from_stream (stream);
- g_io_add_watch (input, G_IO_IN|G_IO_HUP, on_data_incoming, toplevel_name);
+ g_io_add_watch (input, G_IO_IN | G_IO_HUP, on_data_incoming, toplevel_name);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- gchar *file_name;
- gchar *toplevel_name;
+ gchar *file_name;
+ gchar *toplevel_name;
#ifdef ENABLE_NLS
- setlocale (LC_ALL, "");
- bindtextdomain (GETTEXT_PACKAGE, glade_app_get_locale_dir ());
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, glade_app_get_locale_dir ());
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
#endif
- parse_arguments (argc, argv, &toplevel_name, &file_name);
+ parse_arguments (argc, argv, &toplevel_name, &file_name);
- if (file_name != NULL)
- {
- preview_file (toplevel_name, file_name);
- } else {
- start_listener (toplevel_name);
- }
+ if (file_name != NULL)
+ {
+ preview_file (toplevel_name, file_name);
+ }
+ else
+ {
+ start_listener (toplevel_name);
+ }
- gtk_main ();
+ gtk_main ();
- return 0;
+ return 0;
}
-
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 404b7e4..d26dd9f 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2008 Tristan Van Berkom
@@ -55,329 +54,324 @@
enum
{
- ADD_WIDGET,
- REMOVE_WIDGET,
- WIDGET_NAME_CHANGED,
- SELECTION_CHANGED,
- CLOSE,
- CHANGED,
- PARSE_BEGAN,
- PARSE_FINISHED,
- TARGETS_CHANGED,
- LOAD_PROGRESS,
- LAST_SIGNAL
+ ADD_WIDGET,
+ REMOVE_WIDGET,
+ WIDGET_NAME_CHANGED,
+ SELECTION_CHANGED,
+ CLOSE,
+ CHANGED,
+ PARSE_BEGAN,
+ PARSE_FINISHED,
+ TARGETS_CHANGED,
+ LOAD_PROGRESS,
+ LAST_SIGNAL
};
enum
{
- PROP_0,
- PROP_MODIFIED,
- PROP_HAS_SELECTION,
- PROP_PATH,
- PROP_READ_ONLY,
- PROP_PREVIEWABLE
+ PROP_0,
+ PROP_MODIFIED,
+ PROP_HAS_SELECTION,
+ PROP_PATH,
+ PROP_READ_ONLY,
+ PROP_PREVIEWABLE
};
struct _GladeProjectPrivate
{
- gchar *path; /* The full canonical path of the glade file for this project */
-
- gint unsaved_number; /* A unique number for this project if it is untitled */
-
- gboolean readonly; /* A flag that is set if the project is readonly */
-
- gboolean loading; /* A flags that is set when the project is loading */
-
- gboolean modified; /* A flag that is set when a project has unsaved modifications
- * if this flag is not set we don't have to query
- * for confirmation after a close or exit is
- * requested
- */
-
- gboolean previewable;
-
- gint stamp; /* A a random int per instance of project used to stamp/check the
- * GtkTreeIter->stamps */
- GList *tree; /* List of toplevel Objects in this projects */
- GList *objects; /* List of all objects in this project */
-
- GList *selection; /* We need to keep the selection in the project
- * because we have multiple projects and when the
- * user switchs between them, he will probably
- * not want to loose the selection. This is a list
- * of #GtkWidget items.
- */
-
- GladeNameContext *toplevel_names; /* Context for uniqueness of names at the toplevel */
- GList *toplevels; /* List of toplevels with thier own naming contexts */
-
-
- gboolean has_selection; /* Whether the project has a selection */
-
- GList *undo_stack; /* A stack with the last executed commands */
- GList *prev_redo_item; /* Points to the item previous to the redo items */
-
- gboolean first_modification_is_na; /* the flag indicates that the first_modification item has been lost */
-
- GList *first_modification; /* we record the first modification, so that we
- * can set "modification" to FALSE when we
- * undo this modification
- */
-
- GtkAccelGroup *accel_group;
-
- gchar *comment; /* XML comment, Glade will preserve whatever comment was
- * in file, so users can delete or change it.
- */
-
- time_t mtime; /* last UTC modification time of file, or 0 if it could not be read */
-
- GHashTable *target_versions_major; /* target versions by catalog */
- GHashTable *target_versions_minor; /* target versions by catalog */
-
- GladeNamingPolicy naming_policy; /* What rules apply to widget names */
-
- gchar *resource_path; /* Indicates where to load resources from for this project
- * (full or relative path, null means project directory).
- */
-
- /* Control on the preferences dialog to update buttons etc when properties change */
- GtkWidget *prefs_dialog;
- GtkWidget *project_wide_radio;
- GtkWidget *toplevel_contextual_radio;
- GHashTable *target_radios;
-
- GtkWidget *resource_default_radio;
- GtkWidget *resource_relative_radio;
- GtkWidget *resource_fullpath_radio;
- GtkWidget *relative_path_entry;
- GtkWidget *full_path_button;
-
- /* For the loading progress bars ("load-progress" signal) */
- gint progress_step;
- gint progress_full;
- gboolean load_cancel;
-
- /* Store preview processes, so we can kill them on close */
- GHashTable *preview_channels;
+ gchar *path; /* The full canonical path of the glade file for this project */
+
+ gint unsaved_number; /* A unique number for this project if it is untitled */
+
+ gboolean readonly; /* A flag that is set if the project is readonly */
+
+ gboolean loading; /* A flags that is set when the project is loading */
+
+ gboolean modified; /* A flag that is set when a project has unsaved modifications
+ * if this flag is not set we don't have to query
+ * for confirmation after a close or exit is
+ * requested
+ */
+
+ gboolean previewable;
+
+ gint stamp; /* A a random int per instance of project used to stamp/check the
+ * GtkTreeIter->stamps */
+ GList *tree; /* List of toplevel Objects in this projects */
+ GList *objects; /* List of all objects in this project */
+
+ GList *selection; /* We need to keep the selection in the project
+ * because we have multiple projects and when the
+ * user switchs between them, he will probably
+ * not want to loose the selection. This is a list
+ * of #GtkWidget items.
+ */
+
+ GladeNameContext *toplevel_names; /* Context for uniqueness of names at the toplevel */
+ GList *toplevels; /* List of toplevels with thier own naming contexts */
+
+
+ gboolean has_selection; /* Whether the project has a selection */
+
+ GList *undo_stack; /* A stack with the last executed commands */
+ GList *prev_redo_item; /* Points to the item previous to the redo items */
+
+ gboolean first_modification_is_na; /* the flag indicates that the first_modification item has been lost */
+
+ GList *first_modification; /* we record the first modification, so that we
+ * can set "modification" to FALSE when we
+ * undo this modification
+ */
+
+ GtkAccelGroup *accel_group;
+
+ gchar *comment; /* XML comment, Glade will preserve whatever comment was
+ * in file, so users can delete or change it.
+ */
+
+ time_t mtime; /* last UTC modification time of file, or 0 if it could not be read */
+
+ GHashTable *target_versions_major; /* target versions by catalog */
+ GHashTable *target_versions_minor; /* target versions by catalog */
+
+ GladeNamingPolicy naming_policy; /* What rules apply to widget names */
+
+ gchar *resource_path; /* Indicates where to load resources from for this project
+ * (full or relative path, null means project directory).
+ */
+
+ /* Control on the preferences dialog to update buttons etc when properties change */
+ GtkWidget *prefs_dialog;
+ GtkWidget *project_wide_radio;
+ GtkWidget *toplevel_contextual_radio;
+ GHashTable *target_radios;
+
+ GtkWidget *resource_default_radio;
+ GtkWidget *resource_relative_radio;
+ GtkWidget *resource_fullpath_radio;
+ GtkWidget *relative_path_entry;
+ GtkWidget *full_path_button;
+
+ /* For the loading progress bars ("load-progress" signal) */
+ gint progress_step;
+ gint progress_full;
+ gboolean load_cancel;
+
+ /* Store preview processes, so we can kill them on close */
+ GHashTable *preview_channels;
};
-typedef struct {
- GladeWidget *toplevel;
- GladeNameContext *names;
+typedef struct
+{
+ GladeWidget *toplevel;
+ GladeNameContext *names;
} TopLevelInfo;
-typedef struct {
- gchar *stock;
- gchar *filename;
+typedef struct
+{
+ gchar *stock;
+ gchar *filename;
} StockFilePair;
-typedef struct {
- GIOChannel *channel;
- guint watch;
+typedef struct
+{
+ GIOChannel *channel;
+ guint watch;
} ChannelWatchPair;
-static void glade_project_set_target_version (GladeProject *project,
- const gchar *catalog,
- guint16 major,
- guint16 minor);
+static void glade_project_set_target_version (GladeProject * project,
+ const gchar * catalog,
+ guint16 major, guint16 minor);
-static void glade_project_target_version_for_adaptor (GladeProject *project,
- GladeWidgetAdaptor *adaptor,
- gint *major,
- gint *minor);
+static void glade_project_target_version_for_adaptor (GladeProject * project,
+ GladeWidgetAdaptor *
+ adaptor, gint * major,
+ gint * minor);
-static void glade_project_set_readonly (GladeProject *project,
- gboolean readonly);
+static void glade_project_set_readonly (GladeProject * project,
+ gboolean readonly);
-static gboolean glade_project_verify (GladeProject *project,
- gboolean saving);
+static gboolean glade_project_verify (GladeProject * project, gboolean saving);
-static void glade_project_verify_adaptor (GladeProject *project,
- GladeWidgetAdaptor *adaptor,
- const gchar *path_name,
- GString *string,
- gboolean saving,
- gboolean forwidget,
- GladeSupportMask *mask);
+static void glade_project_verify_adaptor (GladeProject * project,
+ GladeWidgetAdaptor * adaptor,
+ const gchar * path_name,
+ GString * string,
+ gboolean saving,
+ gboolean forwidget,
+ GladeSupportMask * mask);
-static GladeWidget *search_ancestry_by_name (GladeWidget *toplevel,
- const gchar *name);
+static GladeWidget *search_ancestry_by_name (GladeWidget * toplevel,
+ const gchar * name);
-static GtkWidget *glade_project_build_prefs_dialog (GladeProject *project);
+static GtkWidget *glade_project_build_prefs_dialog (GladeProject * project);
-static void policy_project_wide_button_clicked (GtkWidget *widget,
- GladeProject *project);
-static void policy_toplevel_contextual_button_clicked (GtkWidget *widget,
- GladeProject *project);
-static void target_button_clicked (GtkWidget *widget,
- GladeProject *project);
-static void update_prefs_for_resource_path (GladeProject *project);
+static void policy_project_wide_button_clicked (GtkWidget * widget,
+ GladeProject * project);
+static void policy_toplevel_contextual_button_clicked (GtkWidget * widget,
+ GladeProject * project);
+static void target_button_clicked (GtkWidget * widget, GladeProject * project);
+static void update_prefs_for_resource_path (GladeProject * project);
-static guint glade_project_signals[LAST_SIGNAL] = {0};
+static guint glade_project_signals[LAST_SIGNAL] = { 0 };
-static GladeIDAllocator *unsaved_number_allocator = NULL;
+static GladeIDAllocator *unsaved_number_allocator = NULL;
-static void gtk_tree_model_iface_init (GtkTreeModelIface* iface);
+static void gtk_tree_model_iface_init (GtkTreeModelIface * iface);
-static void glade_project_model_get_iter_for_object (GladeProject* project,
- GObject* object,
- GtkTreeIter* iter);
+static void glade_project_model_get_iter_for_object (GladeProject * project,
+ GObject * object,
+ GtkTreeIter * iter);
#define GLADE_PROJECT_LARGE_PROJECT 40
G_DEFINE_TYPE_WITH_CODE (GladeProject, glade_project, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
- gtk_tree_model_iface_init))
-
+ gtk_tree_model_iface_init))
/*******************************************************************
GObjectClass
*******************************************************************/
-
-static GladeIDAllocator *
-get_unsaved_number_allocator (void)
+ static GladeIDAllocator *get_unsaved_number_allocator (void)
{
- if (unsaved_number_allocator == NULL)
- unsaved_number_allocator = glade_id_allocator_new ();
-
- return unsaved_number_allocator;
+ if (unsaved_number_allocator == NULL)
+ unsaved_number_allocator = glade_id_allocator_new ();
+
+ return unsaved_number_allocator;
}
static void
-glade_project_list_unref (GList *original_list)
+glade_project_list_unref (GList * original_list)
{
- GList *l;
- for (l = original_list; l; l = l->next)
- g_object_unref (G_OBJECT (l->data));
+ GList *l;
+ for (l = original_list; l; l = l->next)
+ g_object_unref (G_OBJECT (l->data));
- if (original_list != NULL)
- g_list_free (original_list);
+ if (original_list != NULL)
+ g_list_free (original_list);
}
static void
-unparent_objects_recurse (GladeWidget *widget)
+unparent_objects_recurse (GladeWidget * widget)
{
- GladeWidget *child;
- GList *children, *list;
+ GladeWidget *child;
+ GList *children, *list;
- /* Unparent all children */
- if ((children =
- glade_widget_get_children (widget)) != NULL)
- {
- for (list = children; list; list = list->next)
- {
- child = glade_widget_get_from_gobject (list->data);
+ /* Unparent all children */
+ if ((children = glade_widget_get_children (widget)) != NULL)
+ {
+ for (list = children; list; list = list->next)
+ {
+ child = glade_widget_get_from_gobject (list->data);
- unparent_objects_recurse (child);
+ unparent_objects_recurse (child);
- if (child->internal == NULL)
- glade_widget_remove_child (widget, child);
- }
- g_list_free (children);
- }
+ if (child->internal == NULL)
+ glade_widget_remove_child (widget, child);
+ }
+ g_list_free (children);
+ }
}
static void
-glade_project_dispose (GObject *object)
+glade_project_dispose (GObject * object)
{
- GladeProject *project = GLADE_PROJECT (object);
- GList *list, *tree;
-
- /* Emit close signal */
- g_signal_emit (object, glade_project_signals [CLOSE], 0);
-
- glade_project_selection_clear (project, TRUE);
+ GladeProject *project = GLADE_PROJECT (object);
+ GList *list, *tree;
+
+ /* Emit close signal */
+ g_signal_emit (object, glade_project_signals[CLOSE], 0);
+
+ glade_project_selection_clear (project, TRUE);
- glade_project_list_unref (project->priv->undo_stack);
- project->priv->undo_stack = NULL;
+ glade_project_list_unref (project->priv->undo_stack);
+ project->priv->undo_stack = NULL;
- /* Remove objects from the project */
- tree = g_list_copy (project->priv->tree);
- for (list = tree; list; list = list->next)
- {
- GladeWidget *gwidget = glade_widget_get_from_gobject (list->data);
+ /* Remove objects from the project */
+ tree = g_list_copy (project->priv->tree);
+ for (list = tree; list; list = list->next)
+ {
+ GladeWidget *gwidget = glade_widget_get_from_gobject (list->data);
- g_object_ref (gwidget);
+ g_object_ref (gwidget);
- glade_project_remove_object (project, list->data);
+ glade_project_remove_object (project, list->data);
- unparent_objects_recurse (gwidget);
+ unparent_objects_recurse (gwidget);
- g_object_unref (gwidget);
- }
- g_list_free (tree);
+ g_object_unref (gwidget);
+ }
+ g_list_free (tree);
- g_assert (project->priv->tree == NULL);
- g_assert (project->priv->objects == NULL);
+ g_assert (project->priv->tree == NULL);
+ g_assert (project->priv->objects == NULL);
- G_OBJECT_CLASS (glade_project_parent_class)->dispose (object);
+ G_OBJECT_CLASS (glade_project_parent_class)->dispose (object);
}
static void
-glade_project_finalize (GObject *object)
+glade_project_finalize (GObject * object)
{
- GladeProject *project = GLADE_PROJECT (object);
- GList *list;
- TopLevelInfo *tinfo;
+ GladeProject *project = GLADE_PROJECT (object);
+ GList *list;
+ TopLevelInfo *tinfo;
- /* XXX FIXME: Destroy dialog related sizegroups here... */
- gtk_widget_destroy (project->priv->prefs_dialog);
+ /* XXX FIXME: Destroy dialog related sizegroups here... */
+ gtk_widget_destroy (project->priv->prefs_dialog);
- g_free (project->priv->path);
- g_free (project->priv->comment);
+ g_free (project->priv->path);
+ g_free (project->priv->comment);
- if (project->priv->unsaved_number > 0)
- glade_id_allocator_release (get_unsaved_number_allocator (), project->priv->unsaved_number);
+ if (project->priv->unsaved_number > 0)
+ glade_id_allocator_release (get_unsaved_number_allocator (),
+ project->priv->unsaved_number);
- g_hash_table_destroy (project->priv->target_versions_major);
- g_hash_table_destroy (project->priv->target_versions_minor);
- g_hash_table_destroy (project->priv->target_radios);
+ g_hash_table_destroy (project->priv->target_versions_major);
+ g_hash_table_destroy (project->priv->target_versions_minor);
+ g_hash_table_destroy (project->priv->target_radios);
- glade_name_context_destroy (project->priv->toplevel_names);
+ glade_name_context_destroy (project->priv->toplevel_names);
- for (list = project->priv->toplevels; list; list = list->next)
- {
- tinfo = list->data;
- glade_name_context_destroy (tinfo->names);
- g_free (tinfo);
- }
- g_list_free (project->priv->toplevels);
+ for (list = project->priv->toplevels; list; list = list->next)
+ {
+ tinfo = list->data;
+ glade_name_context_destroy (tinfo->names);
+ g_free (tinfo);
+ }
+ g_list_free (project->priv->toplevels);
- G_OBJECT_CLASS (glade_project_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_project_parent_class)->finalize (object);
}
static void
-glade_project_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GladeProject *project = GLADE_PROJECT (object);
-
- switch (prop_id)
- {
- case PROP_MODIFIED:
- g_value_set_boolean (value, project->priv->modified);
- break;
- case PROP_HAS_SELECTION:
- g_value_set_boolean (value, project->priv->has_selection);
- break;
- case PROP_PATH:
- g_value_set_string (value, project->priv->path);
- break;
- case PROP_READ_ONLY:
- g_value_set_boolean (value, project->priv->readonly);
- break;
- case PROP_PREVIEWABLE:
- g_value_set_boolean (value, project->priv->previewable);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_project_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GladeProject *project = GLADE_PROJECT (object);
+
+ switch (prop_id)
+ {
+ case PROP_MODIFIED:
+ g_value_set_boolean (value, project->priv->modified);
+ break;
+ case PROP_HAS_SELECTION:
+ g_value_set_boolean (value, project->priv->has_selection);
+ break;
+ case PROP_PATH:
+ g_value_set_string (value, project->priv->path);
+ break;
+ case PROP_READ_ONLY:
+ g_value_set_boolean (value, project->priv->readonly);
+ break;
+ case PROP_PREVIEWABLE:
+ g_value_set_boolean (value, project->priv->previewable);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/**
@@ -397,270 +391,265 @@ glade_project_get_property (GObject *object,
*
*/
static void
-glade_project_set_modified (GladeProject *project,
- gboolean modified)
+glade_project_set_modified (GladeProject * project, gboolean modified)
{
- GladeProjectPrivate *priv = project->priv;
+ GladeProjectPrivate *priv = project->priv;
+
+ if (priv->modified != modified)
+ {
+ priv->modified = !priv->modified;
+
+ if (!priv->modified)
+ {
+ priv->first_modification = project->priv->prev_redo_item;
+ priv->first_modification_is_na = FALSE;
+ }
- if (priv->modified != modified)
- {
- priv->modified = !priv->modified;
-
- if (!priv->modified)
- {
- priv->first_modification = project->priv->prev_redo_item;
- priv->first_modification_is_na = FALSE;
- }
-
- g_object_notify (G_OBJECT (project), "modified");
- }
+ g_object_notify (G_OBJECT (project), "modified");
+ }
}
/*******************************************************************
GladeProjectClass
*******************************************************************/
static void
-glade_project_walk_back (GladeProject *project)
+glade_project_walk_back (GladeProject * project)
{
- if (project->priv->prev_redo_item)
- project->priv->prev_redo_item = project->priv->prev_redo_item->prev;
+ if (project->priv->prev_redo_item)
+ project->priv->prev_redo_item = project->priv->prev_redo_item->prev;
}
static void
-glade_project_walk_forward (GladeProject *project)
+glade_project_walk_forward (GladeProject * project)
{
- if (project->priv->prev_redo_item)
- project->priv->prev_redo_item = project->priv->prev_redo_item->next;
- else
- project->priv->prev_redo_item = project->priv->undo_stack;
+ if (project->priv->prev_redo_item)
+ project->priv->prev_redo_item = project->priv->prev_redo_item->next;
+ else
+ project->priv->prev_redo_item = project->priv->undo_stack;
}
static void
-glade_project_undo_impl (GladeProject *project)
+glade_project_undo_impl (GladeProject * project)
{
- GladeCommand *cmd, *next_cmd;
+ GladeCommand *cmd, *next_cmd;
- while ((cmd = glade_project_next_undo_item (project)) != NULL)
- {
- glade_command_undo (cmd);
+ while ((cmd = glade_project_next_undo_item (project)) != NULL)
+ {
+ glade_command_undo (cmd);
- glade_project_walk_back (project);
+ glade_project_walk_back (project);
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [CHANGED],
- 0, cmd, FALSE);
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[CHANGED], 0, cmd, FALSE);
- if ((next_cmd = glade_project_next_undo_item (project)) != NULL &&
- (next_cmd->group_id == 0 || next_cmd->group_id != cmd->group_id))
- break;
- }
+ if ((next_cmd = glade_project_next_undo_item (project)) != NULL &&
+ (next_cmd->group_id == 0 || next_cmd->group_id != cmd->group_id))
+ break;
+ }
- glade_editor_refresh (glade_app_get_editor ());
+ glade_editor_refresh (glade_app_get_editor ());
}
static void
-glade_project_redo_impl (GladeProject *project)
+glade_project_redo_impl (GladeProject * project)
{
- GladeCommand *cmd, *next_cmd;
-
- while ((cmd = glade_project_next_redo_item (project)) != NULL)
- {
- glade_command_execute (cmd);
+ GladeCommand *cmd, *next_cmd;
+
+ while ((cmd = glade_project_next_redo_item (project)) != NULL)
+ {
+ glade_command_execute (cmd);
- glade_project_walk_forward (project);
+ glade_project_walk_forward (project);
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [CHANGED],
- 0, cmd, TRUE);
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[CHANGED], 0, cmd, TRUE);
- if ((next_cmd = glade_project_next_redo_item (project)) != NULL &&
- (next_cmd->group_id == 0 || next_cmd->group_id != cmd->group_id))
- break;
- }
+ if ((next_cmd = glade_project_next_redo_item (project)) != NULL &&
+ (next_cmd->group_id == 0 || next_cmd->group_id != cmd->group_id))
+ break;
+ }
- glade_editor_refresh (glade_app_get_editor ());
+ glade_editor_refresh (glade_app_get_editor ());
}
static GladeCommand *
-glade_project_next_undo_item_impl (GladeProject *project)
+glade_project_next_undo_item_impl (GladeProject * project)
{
- GList *l;
+ GList *l;
- if ((l = project->priv->prev_redo_item) == NULL)
- return NULL;
+ if ((l = project->priv->prev_redo_item) == NULL)
+ return NULL;
- return GLADE_COMMAND (l->data);
+ return GLADE_COMMAND (l->data);
}
static GladeCommand *
-glade_project_next_redo_item_impl (GladeProject *project)
+glade_project_next_redo_item_impl (GladeProject * project)
{
- GList *l;
+ GList *l;
- if ((l = project->priv->prev_redo_item) == NULL)
- return project->priv->undo_stack ?
- GLADE_COMMAND (project->priv->undo_stack->data) : NULL;
- else
- return l->next ? GLADE_COMMAND (l->next->data) : NULL;
+ if ((l = project->priv->prev_redo_item) == NULL)
+ return project->priv->undo_stack ?
+ GLADE_COMMAND (project->priv->undo_stack->data) : NULL;
+ else
+ return l->next ? GLADE_COMMAND (l->next->data) : NULL;
}
static GList *
-glade_project_free_undo_item (GladeProject *project, GList *item)
+glade_project_free_undo_item (GladeProject * project, GList * item)
{
- g_assert (item->data);
+ g_assert (item->data);
- if (item == project->priv->first_modification)
- project->priv->first_modification_is_na = TRUE;
+ if (item == project->priv->first_modification)
+ project->priv->first_modification_is_na = TRUE;
- g_object_unref (G_OBJECT (item->data));
+ g_object_unref (G_OBJECT (item->data));
- return g_list_next (item);
+ return g_list_next (item);
}
static void
-glade_project_push_undo_impl (GladeProject *project, GladeCommand *cmd)
-{
- GladeProjectPrivate *priv = project->priv;
- GList *tmp_redo_item;
-
- /* We should now free all the "redo" items */
- tmp_redo_item = g_list_next (priv->prev_redo_item);
- while (tmp_redo_item)
- tmp_redo_item = glade_project_free_undo_item (project, tmp_redo_item);
-
- if (priv->prev_redo_item)
- {
- g_list_free (g_list_next (priv->prev_redo_item));
- priv->prev_redo_item->next = NULL;
- }
- else
- {
- g_list_free (priv->undo_stack);
- priv->undo_stack = NULL;
- }
-
- /* Try to unify only if group depth is 0 and the project has not been recently saved*/
- if (glade_command_get_group_depth() == 0 &&
- priv->prev_redo_item != NULL &&
- project->priv->prev_redo_item != project->priv->first_modification)
- {
- GladeCommand *cmd1 = priv->prev_redo_item->data;
-
-
- if (glade_command_unifies (cmd1, cmd))
- {
- glade_command_collapse (cmd1, cmd);
- g_object_unref (cmd);
-
- if (glade_command_unifies (cmd1, NULL))
- {
- tmp_redo_item = priv->prev_redo_item;
- glade_project_walk_back (project);
- glade_project_free_undo_item (project, tmp_redo_item);
- priv->undo_stack = g_list_delete_link (priv->undo_stack, tmp_redo_item);
- }
-
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [CHANGED],
- 0, NULL, TRUE);
- return;
- }
- }
-
- /* and then push the new undo item */
- priv->undo_stack = g_list_append (priv->undo_stack, cmd);
-
- if (project->priv->prev_redo_item == NULL)
- priv->prev_redo_item = priv->undo_stack;
- else
- priv->prev_redo_item = g_list_next (priv->prev_redo_item);
-
-
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [CHANGED],
- 0, cmd, TRUE);
+glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
+{
+ GladeProjectPrivate *priv = project->priv;
+ GList *tmp_redo_item;
+
+ /* We should now free all the "redo" items */
+ tmp_redo_item = g_list_next (priv->prev_redo_item);
+ while (tmp_redo_item)
+ tmp_redo_item = glade_project_free_undo_item (project, tmp_redo_item);
+
+ if (priv->prev_redo_item)
+ {
+ g_list_free (g_list_next (priv->prev_redo_item));
+ priv->prev_redo_item->next = NULL;
+ }
+ else
+ {
+ g_list_free (priv->undo_stack);
+ priv->undo_stack = NULL;
+ }
+
+ /* Try to unify only if group depth is 0 and the project has not been recently saved */
+ if (glade_command_get_group_depth () == 0 &&
+ priv->prev_redo_item != NULL &&
+ project->priv->prev_redo_item != project->priv->first_modification)
+ {
+ GladeCommand *cmd1 = priv->prev_redo_item->data;
+
+
+ if (glade_command_unifies (cmd1, cmd))
+ {
+ glade_command_collapse (cmd1, cmd);
+ g_object_unref (cmd);
+
+ if (glade_command_unifies (cmd1, NULL))
+ {
+ tmp_redo_item = priv->prev_redo_item;
+ glade_project_walk_back (project);
+ glade_project_free_undo_item (project, tmp_redo_item);
+ priv->undo_stack =
+ g_list_delete_link (priv->undo_stack, tmp_redo_item);
+ }
+
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[CHANGED], 0, NULL, TRUE);
+ return;
+ }
+ }
+
+ /* and then push the new undo item */
+ priv->undo_stack = g_list_append (priv->undo_stack, cmd);
+
+ if (project->priv->prev_redo_item == NULL)
+ priv->prev_redo_item = priv->undo_stack;
+ else
+ priv->prev_redo_item = g_list_next (priv->prev_redo_item);
+
+
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[CHANGED], 0, cmd, TRUE);
}
static void
glade_project_preview_exits (GPid pid, gint status, gpointer data)
{
- GladeProject *project = (GladeProject *)data;
- ChannelWatchPair *channel_watch;
- GIOChannel *channel;
- gchar *pidstr = g_strdup_printf ("%d", pid);
+ GladeProject *project = (GladeProject *) data;
+ ChannelWatchPair *channel_watch;
+ GIOChannel *channel;
+ gchar *pidstr = g_strdup_printf ("%d", pid);
- channel_watch = g_hash_table_lookup (project->priv->preview_channels, pidstr);
- channel = channel_watch->channel;
- g_io_channel_unref (channel);
- g_hash_table_remove (project->priv->preview_channels, pidstr);
+ channel_watch = g_hash_table_lookup (project->priv->preview_channels, pidstr);
+ channel = channel_watch->channel;
+ g_io_channel_unref (channel);
+ g_hash_table_remove (project->priv->preview_channels, pidstr);
- g_free (pidstr);
- g_free (channel_watch);
+ g_free (pidstr);
+ g_free (channel_watch);
}
static void
-glade_project_kill_previews (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- const gchar *quit = "<quit>";
- GIOChannel *channel;
- ChannelWatchPair *channel_watch = (ChannelWatchPair *) value;
- GError *error = NULL;
- gsize size;
-
- channel = channel_watch->channel;
- /* Removing watch, since the child will commit suicide */
- g_source_remove (channel_watch->watch);
- g_io_channel_write_chars (channel, quit, strlen (quit), &size, &error);
-
- if (size != strlen (quit) && error != NULL)
- {
- g_printerr ("Error passing quit signal trough pipe: %s", error->message);
- g_error_free (error);
- }
-
- g_io_channel_flush (channel, &error);
- if (error != NULL)
- {
- g_printerr ("Error flushing channel: %s", error->message);
- g_error_free (error);
- }
-
- g_io_channel_shutdown (channel, TRUE, &error);
- if (error != NULL)
- {
- g_printerr ("Error shutting down channel: %s", error->message);
- g_error_free (error);
- }
-
- g_io_channel_unref (channel);
- g_free (channel_watch);
+glade_project_kill_previews (gpointer key, gpointer value, gpointer user_data)
+{
+ const gchar *quit = "<quit>";
+ GIOChannel *channel;
+ ChannelWatchPair *channel_watch = (ChannelWatchPair *) value;
+ GError *error = NULL;
+ gsize size;
+
+ channel = channel_watch->channel;
+ /* Removing watch, since the child will commit suicide */
+ g_source_remove (channel_watch->watch);
+ g_io_channel_write_chars (channel, quit, strlen (quit), &size, &error);
+
+ if (size != strlen (quit) && error != NULL)
+ {
+ g_printerr ("Error passing quit signal trough pipe: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_io_channel_flush (channel, &error);
+ if (error != NULL)
+ {
+ g_printerr ("Error flushing channel: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_io_channel_shutdown (channel, TRUE, &error);
+ if (error != NULL)
+ {
+ g_printerr ("Error shutting down channel: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_io_channel_unref (channel);
+ g_free (channel_watch);
}
static void
-glade_project_close_impl (GladeProject *project)
+glade_project_close_impl (GladeProject * project)
{
- g_hash_table_foreach (project->priv->preview_channels, glade_project_kill_previews, project);
- g_hash_table_unref (project->priv->preview_channels);
+ g_hash_table_foreach (project->priv->preview_channels,
+ glade_project_kill_previews, project);
+ g_hash_table_unref (project->priv->preview_channels);
}
static void
-glade_project_changed_impl (GladeProject *project,
- GladeCommand *command,
- gboolean forward)
+glade_project_changed_impl (GladeProject * project,
+ GladeCommand * command, gboolean forward)
{
- if (!project->priv->loading)
- {
- /* if this command is the first modification to cause the project
- * to have unsaved changes, then we can now flag the project as unmodified
- */
- if (!project->priv->first_modification_is_na && project->priv->prev_redo_item == project->priv->first_modification)
- glade_project_set_modified (project, FALSE);
- else
- glade_project_set_modified (project, TRUE);
- }
- glade_app_update_ui ();
+ if (!project->priv->loading)
+ {
+ /* if this command is the first modification to cause the project
+ * to have unsaved changes, then we can now flag the project as unmodified
+ */
+ if (!project->priv->first_modification_is_na &&
+ project->priv->prev_redo_item == project->priv->first_modification)
+ glade_project_set_modified (project, FALSE);
+ else
+ glade_project_set_modified (project, TRUE);
+ }
+ glade_app_update_ui ();
}
@@ -668,179 +657,172 @@ glade_project_changed_impl (GladeProject *project,
Class Initializers
*******************************************************************/
static void
-glade_project_init (GladeProject *project)
-{
- GladeProjectPrivate *priv;
- GList *list;
-
- project->priv = priv =
- G_TYPE_INSTANCE_GET_PRIVATE ((project), GLADE_TYPE_PROJECT, GladeProjectPrivate);
-
- priv->path = NULL;
- priv->readonly = FALSE;
- priv->tree = NULL;
- priv->toplevels = NULL;
- priv->selection = NULL;
- priv->has_selection = FALSE;
- priv->undo_stack = NULL;
- priv->prev_redo_item = NULL;
- priv->first_modification = NULL;
- priv->first_modification_is_na = FALSE;
-
- priv->preview_channels = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- priv->previewable = FALSE;
- priv->toplevel_names = glade_name_context_new ();
- priv->naming_policy = GLADE_POLICY_PROJECT_WIDE;
-
- priv->accel_group = NULL;
-
- priv->unsaved_number = glade_id_allocator_allocate (get_unsaved_number_allocator ());
+glade_project_init (GladeProject * project)
+{
+ GladeProjectPrivate *priv;
+ GList *list;
+
+ project->priv = priv =
+ G_TYPE_INSTANCE_GET_PRIVATE ((project), GLADE_TYPE_PROJECT,
+ GladeProjectPrivate);
+
+ priv->path = NULL;
+ priv->readonly = FALSE;
+ priv->tree = NULL;
+ priv->toplevels = NULL;
+ priv->selection = NULL;
+ priv->has_selection = FALSE;
+ priv->undo_stack = NULL;
+ priv->prev_redo_item = NULL;
+ priv->first_modification = NULL;
+ priv->first_modification_is_na = FALSE;
+
+ priv->preview_channels =
+ g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ priv->previewable = FALSE;
+ priv->toplevel_names = glade_name_context_new ();
+ priv->naming_policy = GLADE_POLICY_PROJECT_WIDE;
+
+ priv->accel_group = NULL;
+
+ priv->unsaved_number =
+ glade_id_allocator_allocate (get_unsaved_number_allocator ());
+
+ do
+ { /* Get a random non-zero TreeIter stamper */
+ priv->stamp = g_random_int ();
+ }
+ while (priv->stamp == 0);
+
+ priv->target_versions_major = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
+ priv->target_versions_minor = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
+
+ for (list = glade_app_get_catalogs (); list; list = list->next)
+ {
+ GladeCatalog *catalog = list->data;
+
+ /* Set default target to catalog version */
+ glade_project_set_target_version (project,
+ glade_catalog_get_name (catalog),
+ glade_catalog_get_major_version
+ (catalog),
+ glade_catalog_get_minor_version
+ (catalog));
+ }
+
+ priv->target_radios = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+ priv->prefs_dialog = glade_project_build_prefs_dialog (project);
- do { /* Get a random non-zero TreeIter stamper */
- priv->stamp = g_random_int ();
- } while (priv->stamp == 0);
+}
- priv->target_versions_major = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
- priv->target_versions_minor = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
+static void
+glade_project_class_init (GladeProjectClass * klass)
+{
+ GObjectClass *object_class;
- for (list = glade_app_get_catalogs(); list; list = list->next)
- {
- GladeCatalog *catalog = list->data;
+ object_class = G_OBJECT_CLASS (klass);
- /* Set default target to catalog version */
- glade_project_set_target_version (project,
- glade_catalog_get_name (catalog),
- glade_catalog_get_major_version (catalog),
- glade_catalog_get_minor_version (catalog));
- }
+ object_class->get_property = glade_project_get_property;
+ object_class->finalize = glade_project_finalize;
+ object_class->dispose = glade_project_dispose;
- priv->target_radios = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- priv->prefs_dialog = glade_project_build_prefs_dialog (project);
+ klass->add_object = NULL;
+ klass->remove_object = NULL;
+ klass->undo = glade_project_undo_impl;
+ klass->redo = glade_project_redo_impl;
+ klass->next_undo_item = glade_project_next_undo_item_impl;
+ klass->next_redo_item = glade_project_next_redo_item_impl;
+ klass->push_undo = glade_project_push_undo_impl;
-}
+ klass->widget_name_changed = NULL;
+ klass->selection_changed = NULL;
+ klass->close = glade_project_close_impl;
+ klass->changed = glade_project_changed_impl;
-static void
-glade_project_class_init (GladeProjectClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->get_property = glade_project_get_property;
- object_class->finalize = glade_project_finalize;
- object_class->dispose = glade_project_dispose;
-
- klass->add_object = NULL;
- klass->remove_object = NULL;
- klass->undo = glade_project_undo_impl;
- klass->redo = glade_project_redo_impl;
- klass->next_undo_item = glade_project_next_undo_item_impl;
- klass->next_redo_item = glade_project_next_redo_item_impl;
- klass->push_undo = glade_project_push_undo_impl;
-
- klass->widget_name_changed = NULL;
- klass->selection_changed = NULL;
- klass->close = glade_project_close_impl;
- klass->changed = glade_project_changed_impl;
-
- /**
+ /**
* GladeProject::add-widget:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget that was added to @gladeproject.
*
* Emitted when a widget is added to a project.
*/
- glade_project_signals[ADD_WIDGET] =
- g_signal_new ("add_widget",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, add_object),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GLADE_TYPE_WIDGET);
-
- /**
+ glade_project_signals[ADD_WIDGET] =
+ g_signal_new ("add_widget",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeProjectClass, add_object),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
+
+ /**
* GladeProject::remove-widget:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget that was removed from @gladeproject.
*
* Emitted when a widget is removed from a project.
*/
- glade_project_signals[REMOVE_WIDGET] =
- g_signal_new ("remove_widget",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, remove_object),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GLADE_TYPE_WIDGET);
-
-
- /**
+ glade_project_signals[REMOVE_WIDGET] =
+ g_signal_new ("remove_widget",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeProjectClass, remove_object),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
+
+
+ /**
* GladeProject::widget-name-changed:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget who's name changed.
*
* Emitted when @gwidget's name changes.
*/
- glade_project_signals[WIDGET_NAME_CHANGED] =
- g_signal_new ("widget_name_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, widget_name_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GLADE_TYPE_WIDGET);
-
-
- /**
+ glade_project_signals[WIDGET_NAME_CHANGED] =
+ g_signal_new ("widget_name_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeProjectClass, widget_name_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
+
+
+ /**
* GladeProject::selection-changed:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject selection list changes.
*/
- glade_project_signals[SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
-
- /**
+ glade_project_signals[SELECTION_CHANGED] =
+ g_signal_new ("selection_changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeProjectClass, selection_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+
+ /**
* GladeProject::close:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when a project is closing (a good time to clean up
* any associated resources).
*/
- glade_project_signals[CLOSE] =
- g_signal_new ("close",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeProjectClass, close),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
+ glade_project_signals[CLOSE] =
+ g_signal_new ("close",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeProjectClass, close),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ /**
* GladeProject::changed:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeCommand that was executed
@@ -848,47 +830,40 @@ glade_project_class_init (GladeProjectClass *klass)
*
* Emitted when a @gladeproject's state changes via a #GladeCommand.
*/
- glade_project_signals[CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GladeProjectClass, changed),
- NULL, NULL,
- glade_marshal_VOID__OBJECT_BOOLEAN,
- G_TYPE_NONE,
- 2,
- GLADE_TYPE_COMMAND, G_TYPE_BOOLEAN);
-
- /**
+ glade_project_signals[CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GladeProjectClass, changed),
+ NULL, NULL,
+ glade_marshal_VOID__OBJECT_BOOLEAN,
+ G_TYPE_NONE, 2, GLADE_TYPE_COMMAND, G_TYPE_BOOLEAN);
+
+ /**
* GladeProject::parse-began:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject parsing starts.
*/
- glade_project_signals[PARSE_BEGAN] =
- g_signal_new ("parse-began",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
+ glade_project_signals[PARSE_BEGAN] =
+ g_signal_new ("parse-began",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ /**
* GladeProject::parse-finished:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject parsing has finished.
*/
- glade_project_signals[PARSE_FINISHED] =
- g_signal_new ("parse-finished",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GladeProjectClass, parse_finished),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ glade_project_signals[PARSE_FINISHED] =
+ g_signal_new ("parse-finished",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GladeProjectClass, parse_finished),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeProject::targets-changed:
@@ -896,16 +871,14 @@ glade_project_class_init (GladeProjectClass *klass)
*
* Emitted when @gladeproject target versions change.
*/
- glade_project_signals[TARGETS_CHANGED] =
- g_signal_new ("targets-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
+ glade_project_signals[TARGETS_CHANGED] =
+ g_signal_new ("targets-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ /**
* GladeProject::load-progress:
* @gladeproject: the #GladeProject which received the signal.
* @objects_total: the total amount of objects to load
@@ -913,57 +886,62 @@ glade_project_class_init (GladeProjectClass *klass)
*
* Emitted while @project is loading.
*/
- glade_project_signals[LOAD_PROGRESS] =
- g_signal_new ("load-progress",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- glade_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
- g_object_class_install_property (object_class,
- PROP_MODIFIED,
- g_param_spec_boolean ("modified",
- "Modified",
- _("Whether project has been modified since it was last saved"),
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
- PROP_HAS_SELECTION,
- g_param_spec_boolean ("has-selection",
- _("Has Selection"),
- _("Whether project has a selection"),
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
- PROP_PATH,
- g_param_spec_string ("path",
- _("Path"),
- _("The filesystem path of the project"),
- NULL,
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
- PROP_READ_ONLY,
- g_param_spec_boolean ("read-only",
- _("Read Only"),
- _("Whether project is read-only"),
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
- PROP_PREVIEWABLE,
- g_param_spec_boolean ("previewable",
- _("Previewable"),
- _("Wether the project can be previewed"),
- FALSE,
- G_PARAM_READABLE));
-
-
-
- g_type_class_add_private (klass, sizeof (GladeProjectPrivate));
+ glade_project_signals[LOAD_PROGRESS] =
+ g_signal_new ("load-progress",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ glade_marshal_VOID__INT_INT,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
+
+ g_object_class_install_property (object_class,
+ PROP_MODIFIED,
+ g_param_spec_boolean ("modified",
+ "Modified",
+ _
+ ("Whether project has been modified since it was last saved"),
+ FALSE,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_HAS_SELECTION,
+ g_param_spec_boolean ("has-selection",
+ _("Has Selection"),
+ _
+ ("Whether project has a selection"),
+ FALSE,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_PATH,
+ g_param_spec_string ("path",
+ _("Path"),
+ _
+ ("The filesystem path of the project"),
+ NULL,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_READ_ONLY,
+ g_param_spec_boolean ("read-only",
+ _("Read Only"),
+ _
+ ("Whether project is read-only"),
+ FALSE,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_PREVIEWABLE,
+ g_param_spec_boolean ("previewable",
+ _("Previewable"),
+ _
+ ("Wether the project can be previewed"),
+ FALSE,
+ G_PARAM_READABLE));
+
+
+
+ g_type_class_add_private (klass, sizeof (GladeProjectPrivate));
}
/*******************************************************************
@@ -980,608 +958,620 @@ glade_project_class_init (GladeProjectClass *klass)
GladeProject *
glade_project_new (void)
{
- GladeProject *project = g_object_new (GLADE_TYPE_PROJECT, NULL);
- return project;
+ GladeProject *project = g_object_new (GLADE_TYPE_PROJECT, NULL);
+ return project;
}
/* Called when finishing loading a glade file to resolve object type properties
*/
-static void
-glade_project_fix_object_props (GladeProject *project)
-{
- GList *l, *ll, *objects;
- GValue *value;
- GladeWidget *gwidget;
- GladeProperty *property;
- gchar *txt;
-
- objects = g_list_copy (project->priv->objects);
- for (l = objects; l; l = l->next)
- {
- gwidget = glade_widget_get_from_gobject (l->data);
-
- for (ll = gwidget->properties; ll; ll = ll->next)
- {
- property = GLADE_PROPERTY (ll->data);
-
- if (glade_property_class_is_object (property->klass) &&
- (txt = g_object_get_data (G_OBJECT (property),
- "glade-loaded-object")) != NULL)
- {
- /* Parse the object list and set the property to it
- * (this magicly works for both objects & object lists)
- */
- value = glade_property_class_make_gvalue_from_string
- (property->klass, txt, gwidget->project, gwidget);
-
- glade_property_set_value (property, value);
-
- g_value_unset (value);
- g_free (value);
-
- g_object_set_data (G_OBJECT (property),
- "glade-loaded-object", NULL);
- }
- }
- }
- g_list_free (objects);
+static void
+glade_project_fix_object_props (GladeProject * project)
+{
+ GList *l, *ll, *objects;
+ GValue *value;
+ GladeWidget *gwidget;
+ GladeProperty *property;
+ gchar *txt;
+
+ objects = g_list_copy (project->priv->objects);
+ for (l = objects; l; l = l->next)
+ {
+ gwidget = glade_widget_get_from_gobject (l->data);
+
+ for (ll = gwidget->properties; ll; ll = ll->next)
+ {
+ property = GLADE_PROPERTY (ll->data);
+
+ if (glade_property_class_is_object (property->klass) &&
+ (txt = g_object_get_data (G_OBJECT (property),
+ "glade-loaded-object")) != NULL)
+ {
+ /* Parse the object list and set the property to it
+ * (this magicly works for both objects & object lists)
+ */
+ value = glade_property_class_make_gvalue_from_string
+ (property->klass, txt, gwidget->project, gwidget);
+
+ glade_property_set_value (property, value);
+
+ g_value_unset (value);
+ g_free (value);
+
+ g_object_set_data (G_OBJECT (property),
+ "glade-loaded-object", NULL);
+ }
+ }
+ }
+ g_list_free (objects);
}
static gchar *
-glade_project_read_requires_from_comment (GladeXmlNode *comment,
- guint16 *major,
- guint16 *minor)
+glade_project_read_requires_from_comment (GladeXmlNode * comment,
+ guint16 * major, guint16 * minor)
{
- gint maj, min;
- gchar *value, buffer[256];
- gchar *required_lib = NULL;
+ gint maj, min;
+ gchar *value, buffer[256];
+ gchar *required_lib = NULL;
- if (!glade_xml_node_is_comment (comment))
- return NULL;
+ if (!glade_xml_node_is_comment (comment))
+ return NULL;
- value = glade_xml_get_content (comment);
+ value = glade_xml_get_content (comment);
- if (value && !strncmp (" interface-requires", value, strlen (" interface-requires")))
- {
- if (sscanf (value, " interface-requires %s %d.%d", buffer, &maj, &min) == 3)
- {
- if (major) *major = maj;
- if (minor) *minor = min;
- required_lib = g_strdup (buffer);
- }
- }
- g_free (value);
+ if (value &&
+ !strncmp (" interface-requires", value, strlen (" interface-requires")))
+ {
+ if (sscanf (value, " interface-requires %s %d.%d", buffer, &maj, &min) ==
+ 3)
+ {
+ if (major)
+ *major = maj;
+ if (minor)
+ *minor = min;
+ required_lib = g_strdup (buffer);
+ }
+ }
+ g_free (value);
- return required_lib;
+ return required_lib;
}
-
+
static gboolean
-glade_project_read_requires (GladeProject *project,
- GladeXmlNode *root_node,
- const gchar *path,
- gboolean *has_gtk_dep)
-{
-
- GString *string = g_string_new (NULL);
- GladeXmlNode *node;
- gchar *required_lib = NULL;
- gboolean loadable = TRUE;
- guint16 major, minor;
-
- for (node = glade_xml_node_get_children_with_comments (root_node);
- node; node = glade_xml_node_next_with_comments (node))
- {
- /* Skip non "requires" tags */
- if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_REQUIRES) ||
- (required_lib =
- glade_project_read_requires_from_comment (node, &major, &minor))))
- continue;
-
- if (!required_lib)
- {
- required_lib =
- glade_xml_get_property_string_required (node, GLADE_XML_TAG_LIB,
- NULL);
- glade_xml_get_property_version (node, GLADE_XML_TAG_VERSION,
- &major, &minor);
- }
-
- if (!required_lib) continue;
-
- /* Dont mention gtk+ as a required lib in
- * the generated glade file
- */
- if (!glade_catalog_is_loaded (required_lib))
- {
- if (!loadable)
- g_string_append (string, ", ");
-
- g_string_append (string, required_lib);
- loadable = FALSE;
- }
- else
- {
- if (has_gtk_dep && strcmp (required_lib, "gtk+") == 0)
- *has_gtk_dep = TRUE;
-
- glade_project_set_target_version
- (project, required_lib, major, minor);
- }
-
- g_free (required_lib);
- }
-
- if (!loadable)
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Failed to load %s.\n"
- "The following required catalogs are unavailable: %s"),
- path, string->str);
- g_string_free (string, TRUE);
- return loadable;
+glade_project_read_requires (GladeProject * project,
+ GladeXmlNode * root_node,
+ const gchar * path, gboolean * has_gtk_dep)
+{
+
+ GString *string = g_string_new (NULL);
+ GladeXmlNode *node;
+ gchar *required_lib = NULL;
+ gboolean loadable = TRUE;
+ guint16 major, minor;
+
+ for (node = glade_xml_node_get_children_with_comments (root_node);
+ node; node = glade_xml_node_next_with_comments (node))
+ {
+ /* Skip non "requires" tags */
+ if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_REQUIRES) ||
+ (required_lib =
+ glade_project_read_requires_from_comment (node, &major, &minor))))
+ continue;
+
+ if (!required_lib)
+ {
+ required_lib =
+ glade_xml_get_property_string_required (node, GLADE_XML_TAG_LIB,
+ NULL);
+ glade_xml_get_property_version (node, GLADE_XML_TAG_VERSION,
+ &major, &minor);
+ }
+
+ if (!required_lib)
+ continue;
+
+ /* Dont mention gtk+ as a required lib in
+ * the generated glade file
+ */
+ if (!glade_catalog_is_loaded (required_lib))
+ {
+ if (!loadable)
+ g_string_append (string, ", ");
+
+ g_string_append (string, required_lib);
+ loadable = FALSE;
+ }
+ else
+ {
+ if (has_gtk_dep && strcmp (required_lib, "gtk+") == 0)
+ *has_gtk_dep = TRUE;
+
+ glade_project_set_target_version
+ (project, required_lib, major, minor);
+ }
+
+ g_free (required_lib);
+ }
+
+ if (!loadable)
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Failed to load %s.\n"
+ "The following required catalogs are unavailable: %s"),
+ path, string->str);
+ g_string_free (string, TRUE);
+ return loadable;
}
static gboolean
-glade_project_read_policy_from_comment (GladeXmlNode *comment,
- GladeNamingPolicy *policy)
+glade_project_read_policy_from_comment (GladeXmlNode * comment,
+ GladeNamingPolicy * policy)
{
- gchar *value, buffer[256];
- gboolean loaded = FALSE;
+ gchar *value, buffer[256];
+ gboolean loaded = FALSE;
- if (!glade_xml_node_is_comment (comment))
- return FALSE;
+ if (!glade_xml_node_is_comment (comment))
+ return FALSE;
- value = glade_xml_get_content (comment);
- if (value && !strncmp (" interface-naming-policy", value, strlen (" interface-naming-policy")))
- {
- if (sscanf (value, " interface-naming-policy %s", buffer) == 1)
- {
- if (strcmp (buffer, "project-wide") == 0)
- *policy = GLADE_POLICY_PROJECT_WIDE;
- else
- *policy = GLADE_POLICY_TOPLEVEL_CONTEXTUAL;
-
- loaded = TRUE;
- }
- }
- g_free (value);
+ value = glade_xml_get_content (comment);
+ if (value &&
+ !strncmp (" interface-naming-policy", value,
+ strlen (" interface-naming-policy")))
+ {
+ if (sscanf (value, " interface-naming-policy %s", buffer) == 1)
+ {
+ if (strcmp (buffer, "project-wide") == 0)
+ *policy = GLADE_POLICY_PROJECT_WIDE;
+ else
+ *policy = GLADE_POLICY_TOPLEVEL_CONTEXTUAL;
+
+ loaded = TRUE;
+ }
+ }
+ g_free (value);
- return loaded;
+ return loaded;
}
static void
-glade_project_read_naming_policy (GladeProject *project,
- GladeXmlNode *root_node)
+glade_project_read_naming_policy (GladeProject * project,
+ GladeXmlNode * root_node)
{
- /* A project file with no mention of a policy needs more lax rules
- * (a new project has a project wide policy by default)
- */
- GladeNamingPolicy policy = GLADE_POLICY_TOPLEVEL_CONTEXTUAL;
- GladeXmlNode *node;
-
- for (node = glade_xml_node_get_children_with_comments (root_node);
- node; node = glade_xml_node_next_with_comments (node))
- {
- if (glade_project_read_policy_from_comment (node, &policy))
- break;
- }
+ /* A project file with no mention of a policy needs more lax rules
+ * (a new project has a project wide policy by default)
+ */
+ GladeNamingPolicy policy = GLADE_POLICY_TOPLEVEL_CONTEXTUAL;
+ GladeXmlNode *node;
+
+ for (node = glade_xml_node_get_children_with_comments (root_node);
+ node; node = glade_xml_node_next_with_comments (node))
+ {
+ if (glade_project_read_policy_from_comment (node, &policy))
+ break;
+ }
- glade_project_set_naming_policy (project, policy);
+ glade_project_set_naming_policy (project, policy);
}
static gchar *
-glade_project_read_resource_path_from_comment (GladeXmlNode *comment)
+glade_project_read_resource_path_from_comment (GladeXmlNode * comment)
{
- gchar *value, buffer[FILENAME_MAX], *path = NULL;
+ gchar *value, buffer[FILENAME_MAX], *path = NULL;
- if (!glade_xml_node_is_comment (comment))
- return FALSE;
+ if (!glade_xml_node_is_comment (comment))
+ return FALSE;
- value = glade_xml_get_content (comment);
- if (value && !strncmp (" interface-local-resource-path", value, strlen (" interface-local-resource-path")))
- {
- if (sscanf (value, " interface-local-resource-path %s", buffer) == 1)
- path = g_strdup (buffer);
- }
- g_free (value);
+ value = glade_xml_get_content (comment);
+ if (value &&
+ !strncmp (" interface-local-resource-path", value,
+ strlen (" interface-local-resource-path")))
+ {
+ if (sscanf (value, " interface-local-resource-path %s", buffer) == 1)
+ path = g_strdup (buffer);
+ }
+ g_free (value);
- return path;
+ return path;
}
static void
-update_project_for_resource_path (GladeProject *project)
+update_project_for_resource_path (GladeProject * project)
{
- GladeWidget *widget;
- GladeProperty *property;
- GList *l, *list;
+ GladeWidget *widget;
+ GladeProperty *property;
+ GList *l, *list;
- for (l = project->priv->objects; l; l = l->next)
- {
-
- widget = glade_widget_get_from_gobject (l->data);
+ for (l = project->priv->objects; l; l = l->next)
+ {
- for (list = widget->properties; list; list = list->next)
- {
- property = list->data;
+ widget = glade_widget_get_from_gobject (l->data);
- /* XXX We should have a "resource" flag on properties that need
- * to be loaded from the resource path, but that would require
- * that they can serialize both ways (custom properties are only
- * required to generate unique strings for value comparisons).
- */
- if (property->klass->pspec->value_type == GDK_TYPE_PIXBUF)
- {
- GValue *value;
- gchar *string;
-
- string = glade_property_class_make_string_from_gvalue
- (property->klass, property->value);
-
- value = glade_property_class_make_gvalue_from_string
- (property->klass, string, project, widget);
-
- glade_property_set_value (property, value);
-
- g_value_unset (value);
- g_free (value);
- g_free (string);
- }
- }
- }
+ for (list = widget->properties; list; list = list->next)
+ {
+ property = list->data;
+
+ /* XXX We should have a "resource" flag on properties that need
+ * to be loaded from the resource path, but that would require
+ * that they can serialize both ways (custom properties are only
+ * required to generate unique strings for value comparisons).
+ */
+ if (property->klass->pspec->value_type == GDK_TYPE_PIXBUF)
+ {
+ GValue *value;
+ gchar *string;
+
+ string = glade_property_class_make_string_from_gvalue
+ (property->klass, property->value);
+
+ value = glade_property_class_make_gvalue_from_string
+ (property->klass, string, project, widget);
+
+ glade_property_set_value (property, value);
+
+ g_value_unset (value);
+ g_free (value);
+ g_free (string);
+ }
+ }
+ }
}
/* This function assumes ownership of 'path'. */
static void
-glade_project_set_resource_path (GladeProject *project,
- gchar *path)
+glade_project_set_resource_path (GladeProject * project, gchar * path)
{
- g_free (project->priv->resource_path);
- project->priv->resource_path = path;
+ g_free (project->priv->resource_path);
+ project->priv->resource_path = path;
- update_project_for_resource_path (project);
- update_prefs_for_resource_path (project);
+ update_project_for_resource_path (project);
+ update_prefs_for_resource_path (project);
}
static void
-glade_project_read_resource_path (GladeProject *project,
- GladeXmlNode *root_node)
+glade_project_read_resource_path (GladeProject * project,
+ GladeXmlNode * root_node)
{
- GladeXmlNode *node;
- gchar *path = NULL;
-
- for (node = glade_xml_node_get_children_with_comments (root_node);
- node; node = glade_xml_node_next_with_comments (node))
- {
- /* Skip non "requires" tags */
- if ((path = glade_project_read_resource_path_from_comment (node)) != NULL)
- break;
- }
+ GladeXmlNode *node;
+ gchar *path = NULL;
+
+ for (node = glade_xml_node_get_children_with_comments (root_node);
+ node; node = glade_xml_node_next_with_comments (node))
+ {
+ /* Skip non "requires" tags */
+ if ((path = glade_project_read_resource_path_from_comment (node)) != NULL)
+ break;
+ }
- glade_project_set_resource_path (project, path);
+ glade_project_set_resource_path (project, path);
}
static void
-glade_project_read_comment (GladeProject *project, GladeXmlDoc *doc)
+glade_project_read_comment (GladeProject * project, GladeXmlDoc * doc)
{
- /* TODO Write me !! Find out how to extract root level comments
- * with libxml2 !!!
- */
+ /* TODO Write me !! Find out how to extract root level comments
+ * with libxml2 !!!
+ */
}
-typedef struct {
- GladeWidget *widget;
- gint major;
- gint minor;
+typedef struct
+{
+ GladeWidget *widget;
+ gint major;
+ gint minor;
} VersionData;
static void
-glade_project_introspect_signal_versions (const gchar *signal_name,
- GPtrArray *signals,
- VersionData *data)
-{
- gint i;
-
- for (i = 0; i < signals->len; i++)
- {
- GladeSignalClass *signal_class;
- GladeSignal *signal = g_ptr_array_index (signals, i);
- gchar *catalog = NULL;
- gboolean is_gtk_adaptor = FALSE;
-
- signal_class = glade_widget_adaptor_get_signal_class (data->widget->adaptor, signal->name);
- /* unknown signal... can it happen ? */
- if (!signal_class)
- continue;
- g_assert (signal_class->adaptor);
-
- /* Check if the signal comes from a GTK+ widget class */
- g_object_get (signal_class->adaptor, "catalog", &catalog, NULL);
- if (strcmp (catalog, "gtk+") == 0)
- is_gtk_adaptor = TRUE;
- g_free (catalog);
-
- /* Check GTK+ version that signal was introduced */
- if (is_gtk_adaptor &&
- (data->major < signal_class->version_since_major ||
- (data->major == signal_class->version_since_major &&
- data->minor < signal_class->version_since_minor)))
- {
- data->major = signal_class->version_since_major;
- data->minor = signal_class->version_since_minor;
- }
- }
+glade_project_introspect_signal_versions (const gchar * signal_name,
+ GPtrArray * signals,
+ VersionData * data)
+{
+ gint i;
+
+ for (i = 0; i < signals->len; i++)
+ {
+ GladeSignalClass *signal_class;
+ GladeSignal *signal = g_ptr_array_index (signals, i);
+ gchar *catalog = NULL;
+ gboolean is_gtk_adaptor = FALSE;
+
+ signal_class =
+ glade_widget_adaptor_get_signal_class (data->widget->adaptor,
+ signal->name);
+ /* unknown signal... can it happen ? */
+ if (!signal_class)
+ continue;
+ g_assert (signal_class->adaptor);
+
+ /* Check if the signal comes from a GTK+ widget class */
+ g_object_get (signal_class->adaptor, "catalog", &catalog, NULL);
+ if (strcmp (catalog, "gtk+") == 0)
+ is_gtk_adaptor = TRUE;
+ g_free (catalog);
+
+ /* Check GTK+ version that signal was introduced */
+ if (is_gtk_adaptor &&
+ (data->major < signal_class->version_since_major ||
+ (data->major == signal_class->version_since_major &&
+ data->minor < signal_class->version_since_minor)))
+ {
+ data->major = signal_class->version_since_major;
+ data->minor = signal_class->version_since_minor;
+ }
+ }
}
static void
-glade_project_introspect_gtk_version (GladeProject *project)
-{
- GladeWidget *widget;
- GList *list, *l;
- gint target_major = 2, target_minor = 12;
-
- for (list = project->priv->objects; list; list = list->next)
- {
- gboolean is_gtk_adaptor = FALSE;
- gchar *catalog = NULL;
- VersionData data = { 0, };
-
- widget = glade_widget_get_from_gobject (list->data);
-
- /* Check if its a GTK+ widget class */
- g_object_get (widget->adaptor, "catalog", &catalog, NULL);
- if (strcmp (catalog, "gtk+") == 0)
- is_gtk_adaptor = TRUE;
- g_free (catalog);
-
- /* Check widget class version */
- if (is_gtk_adaptor && !GWA_VERSION_CHECK (widget->adaptor, target_major, target_minor))
- {
- target_major = GWA_VERSION_SINCE_MAJOR (widget->adaptor);
- target_minor = GWA_VERSION_SINCE_MINOR (widget->adaptor);
- }
-
- /* Check all properties */
- for (l = widget->properties; l; l = l->next)
- {
- GladeProperty *property = l->data;
- GladeWidgetAdaptor *prop_adaptor, *adaptor;
-
- /* Unset properties ofcourse dont count... */
- if (glade_property_original_default (property))
- continue;
-
- /* Check if this property originates from a GTK+ widget class */
- prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
- adaptor = glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
-
- catalog = NULL;
- is_gtk_adaptor = FALSE;
- g_object_get (adaptor, "catalog", &catalog, NULL);
- if (strcmp (catalog, "gtk+") == 0)
- is_gtk_adaptor = TRUE;
- g_free (catalog);
-
- /* Check GTK+ property class versions */
- if (is_gtk_adaptor &&
- !GPC_VERSION_CHECK (property->klass, target_major, target_minor))
- {
- target_major = property->klass->version_since_major;
- target_minor = property->klass->version_since_minor;
- }
- }
-
- /* Check all signal versions here */
- data.widget = widget;
- data.major = target_major;
- data.minor = target_minor;
-
- g_hash_table_foreach (widget->signals,
- (GHFunc)glade_project_introspect_signal_versions,
- &data);
-
- if (target_major < data.major)
- target_major = data.major;
-
- if (target_minor < data.minor)
- target_minor = data.minor;
- }
-
- glade_project_set_target_version (project, "gtk+", target_major, target_minor);
-}
-
-
-static gint
-glade_project_count_xml_objects (GladeProject *project, GladeXmlNode *root, gint count)
-{
- GladeXmlNode *node;
-
- for (node = glade_xml_node_get_children (root);
- node; node = glade_xml_node_next (node))
- {
- if (glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET))
- count = glade_project_count_xml_objects (project, node, ++count);
- else if (glade_xml_node_verify_silent (node, GLADE_XML_TAG_CHILD))
- count = glade_project_count_xml_objects (project, node, count);
- }
- return count;
+glade_project_introspect_gtk_version (GladeProject * project)
+{
+ GladeWidget *widget;
+ GList *list, *l;
+ gint target_major = 2, target_minor = 12;
+
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ gboolean is_gtk_adaptor = FALSE;
+ gchar *catalog = NULL;
+ VersionData data = { 0, };
+
+ widget = glade_widget_get_from_gobject (list->data);
+
+ /* Check if its a GTK+ widget class */
+ g_object_get (widget->adaptor, "catalog", &catalog, NULL);
+ if (strcmp (catalog, "gtk+") == 0)
+ is_gtk_adaptor = TRUE;
+ g_free (catalog);
+
+ /* Check widget class version */
+ if (is_gtk_adaptor &&
+ !GWA_VERSION_CHECK (widget->adaptor, target_major, target_minor))
+ {
+ target_major = GWA_VERSION_SINCE_MAJOR (widget->adaptor);
+ target_minor = GWA_VERSION_SINCE_MINOR (widget->adaptor);
+ }
+
+ /* Check all properties */
+ for (l = widget->properties; l; l = l->next)
+ {
+ GladeProperty *property = l->data;
+ GladeWidgetAdaptor *prop_adaptor, *adaptor;
+
+ /* Unset properties ofcourse dont count... */
+ if (glade_property_original_default (property))
+ continue;
+
+ /* Check if this property originates from a GTK+ widget class */
+ prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
+ adaptor =
+ glade_widget_adaptor_from_pspec (prop_adaptor,
+ property->klass->pspec);
+
+ catalog = NULL;
+ is_gtk_adaptor = FALSE;
+ g_object_get (adaptor, "catalog", &catalog, NULL);
+ if (strcmp (catalog, "gtk+") == 0)
+ is_gtk_adaptor = TRUE;
+ g_free (catalog);
+
+ /* Check GTK+ property class versions */
+ if (is_gtk_adaptor &&
+ !GPC_VERSION_CHECK (property->klass, target_major, target_minor))
+ {
+ target_major = property->klass->version_since_major;
+ target_minor = property->klass->version_since_minor;
+ }
+ }
+
+ /* Check all signal versions here */
+ data.widget = widget;
+ data.major = target_major;
+ data.minor = target_minor;
+
+ g_hash_table_foreach (widget->signals,
+ (GHFunc) glade_project_introspect_signal_versions,
+ &data);
+
+ if (target_major < data.major)
+ target_major = data.major;
+
+ if (target_minor < data.minor)
+ target_minor = data.minor;
+ }
+
+ glade_project_set_target_version (project, "gtk+", target_major,
+ target_minor);
+}
+
+
+static gint
+glade_project_count_xml_objects (GladeProject * project, GladeXmlNode * root,
+ gint count)
+{
+ GladeXmlNode *node;
+
+ for (node = glade_xml_node_get_children (root);
+ node; node = glade_xml_node_next (node))
+ {
+ if (glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET))
+ count = glade_project_count_xml_objects (project, node, ++count);
+ else if (glade_xml_node_verify_silent (node, GLADE_XML_TAG_CHILD))
+ count = glade_project_count_xml_objects (project, node, count);
+ }
+ return count;
}
void
-glade_project_cancel_load (GladeProject *project)
+glade_project_cancel_load (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- project->priv->load_cancel = TRUE;
+ project->priv->load_cancel = TRUE;
}
gboolean
-glade_project_load_cancelled (GladeProject *project)
+glade_project_load_cancelled (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- return project->priv->load_cancel;
+ return project->priv->load_cancel;
}
void
-glade_project_push_progress (GladeProject *project)
+glade_project_push_progress (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- project->priv->progress_step++;
+ project->priv->progress_step++;
- g_signal_emit (project, glade_project_signals [LOAD_PROGRESS], 0,
- project->priv->progress_full,
- project->priv->progress_step);
+ g_signal_emit (project, glade_project_signals[LOAD_PROGRESS], 0,
+ project->priv->progress_full, project->priv->progress_step);
}
static gboolean
-glade_project_load_internal (GladeProject *project)
-{
- GladeXmlContext *context;
- GladeXmlDoc *doc;
- GladeXmlNode *root;
- GladeXmlNode *node;
- GladeWidget *widget;
- gboolean has_gtk_dep = FALSE;
- gint count;
-
- project->priv->selection = NULL;
- project->priv->toplevels = NULL;
- project->priv->objects = NULL;
- project->priv->loading = TRUE;
-
- /* get the context & root node of the catalog file */
- if (!(context =
- glade_xml_context_new_from_path (project->priv->path,
- NULL,
- NULL)))
- {
- g_warning ("Couldn't open glade file [%s].", project->priv->path);
- project->priv->loading = FALSE;
- return FALSE;
- }
-
- project->priv->mtime = glade_util_get_file_mtime (project->priv->path, NULL);
-
- doc = glade_xml_context_get_doc (context);
- root = glade_xml_doc_get_root (doc);
-
- if (!glade_xml_node_verify_silent (root, GLADE_XML_TAG_PROJECT))
- {
- g_warning ("Couldnt recognize GtkBuilder xml, skipping %s", project->priv->path);
- glade_xml_context_free (context);
- project->priv->loading = FALSE;
- return FALSE;
- }
-
- /* Emit "parse-began" signal */
- g_signal_emit (project, glade_project_signals [PARSE_BEGAN], 0);
-
- /* XXX Need to load project->priv->comment ! */
- glade_project_read_comment (project, doc);
-
- if (glade_project_read_requires (project, root, project->priv->path, &has_gtk_dep) == FALSE)
- {
- project->priv->loading = FALSE;
- glade_xml_context_free (context);
- return FALSE;
- }
-
- glade_project_read_naming_policy (project, root);
-
- glade_project_read_resource_path (project, root);
-
- /* Launch a dialog if it's going to take enough time to be
- * worth showing at all */
- count = glade_project_count_xml_objects (project, root, 0);
- project->priv->progress_full = count;
- project->priv->progress_step = 0;
-
- for (node = glade_xml_node_get_children (root);
- node; node = glade_xml_node_next (node))
- {
- /* Skip "requires" tags */
- if (!glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET))
- continue;
-
- if ((widget = glade_widget_read (project, NULL, node, NULL)) != NULL)
- glade_project_add_object (project, NULL, widget->object);
-
- if (project->priv->load_cancel)
- break;
- }
-
- /* Finished with the xml context */
- glade_xml_context_free (context);
-
- if (project->priv->load_cancel)
- {
- project->priv->loading = FALSE;
- return FALSE;
- }
-
- if (!has_gtk_dep)
- glade_project_introspect_gtk_version (project);
-
- if (glade_util_file_is_writeable (project->priv->path) == FALSE)
- glade_project_set_readonly (project, TRUE);
-
- /* Reset project status here too so that you get a clean
- * slate after calling glade_project_open().
- */
- project->priv->modified = FALSE;
- project->priv->loading = FALSE;
-
- /* Now we have to loop over all the object properties
- * and fix'em all ('cause they probably weren't found)
- */
- glade_project_fix_object_props (project);
+glade_project_load_internal (GladeProject * project)
+{
+ GladeXmlContext *context;
+ GladeXmlDoc *doc;
+ GladeXmlNode *root;
+ GladeXmlNode *node;
+ GladeWidget *widget;
+ gboolean has_gtk_dep = FALSE;
+ gint count;
+
+ project->priv->selection = NULL;
+ project->priv->toplevels = NULL;
+ project->priv->objects = NULL;
+ project->priv->loading = TRUE;
+
+ /* get the context & root node of the catalog file */
+ if (!(context =
+ glade_xml_context_new_from_path (project->priv->path, NULL, NULL)))
+ {
+ g_warning ("Couldn't open glade file [%s].", project->priv->path);
+ project->priv->loading = FALSE;
+ return FALSE;
+ }
+
+ project->priv->mtime = glade_util_get_file_mtime (project->priv->path, NULL);
+
+ doc = glade_xml_context_get_doc (context);
+ root = glade_xml_doc_get_root (doc);
+
+ if (!glade_xml_node_verify_silent (root, GLADE_XML_TAG_PROJECT))
+ {
+ g_warning ("Couldnt recognize GtkBuilder xml, skipping %s",
+ project->priv->path);
+ glade_xml_context_free (context);
+ project->priv->loading = FALSE;
+ return FALSE;
+ }
+
+ /* Emit "parse-began" signal */
+ g_signal_emit (project, glade_project_signals[PARSE_BEGAN], 0);
+
+ /* XXX Need to load project->priv->comment ! */
+ glade_project_read_comment (project, doc);
+
+ if (glade_project_read_requires
+ (project, root, project->priv->path, &has_gtk_dep) == FALSE)
+ {
+ project->priv->loading = FALSE;
+ glade_xml_context_free (context);
+ return FALSE;
+ }
+
+ glade_project_read_naming_policy (project, root);
+
+ glade_project_read_resource_path (project, root);
+
+ /* Launch a dialog if it's going to take enough time to be
+ * worth showing at all */
+ count = glade_project_count_xml_objects (project, root, 0);
+ project->priv->progress_full = count;
+ project->priv->progress_step = 0;
+
+ for (node = glade_xml_node_get_children (root);
+ node; node = glade_xml_node_next (node))
+ {
+ /* Skip "requires" tags */
+ if (!glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET))
+ continue;
+
+ if ((widget = glade_widget_read (project, NULL, node, NULL)) != NULL)
+ glade_project_add_object (project, NULL, widget->object);
+
+ if (project->priv->load_cancel)
+ break;
+ }
+
+ /* Finished with the xml context */
+ glade_xml_context_free (context);
+
+ if (project->priv->load_cancel)
+ {
+ project->priv->loading = FALSE;
+ return FALSE;
+ }
+
+ if (!has_gtk_dep)
+ glade_project_introspect_gtk_version (project);
+
+ if (glade_util_file_is_writeable (project->priv->path) == FALSE)
+ glade_project_set_readonly (project, TRUE);
+
+ /* Reset project status here too so that you get a clean
+ * slate after calling glade_project_open().
+ */
+ project->priv->modified = FALSE;
+ project->priv->loading = FALSE;
+
+ /* Now we have to loop over all the object properties
+ * and fix'em all ('cause they probably weren't found)
+ */
+ glade_project_fix_object_props (project);
- /* Emit "parse-finished" signal */
- g_signal_emit (project, glade_project_signals [PARSE_FINISHED], 0);
+ /* Emit "parse-finished" signal */
+ g_signal_emit (project, glade_project_signals[PARSE_FINISHED], 0);
+
+ /* Update ui with versioning info
+ */
+ glade_project_verify_project_for_ui (project);
- /* Update ui with versioning info
- */
- glade_project_verify_project_for_ui (project);
-
- /* Update various things in the UI */
- glade_app_update_ui ();
+ /* Update various things in the UI */
+ glade_app_update_ui ();
- return TRUE;
+ return TRUE;
}
gboolean
-glade_project_load_from_file (GladeProject *project,
- const gchar *path)
-{
- gboolean retval;
-
- g_return_val_if_fail (path != NULL, FALSE);
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
-
- project->priv->path = glade_util_canonical_path (path);
-
- retval = glade_project_load_internal (project);
-
- if (retval)
- {
- gchar *name, *title;
-
- /* Update prefs dialogs here... */
- name = glade_project_get_name (project);
- title = g_strdup_printf (_("%s preferences"), name);
- gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
- g_free (title);
- g_free (name);
- }
- return retval;
+glade_project_load_from_file (GladeProject * project, const gchar * path)
+{
+ gboolean retval;
+
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+
+ project->priv->path = glade_util_canonical_path (path);
+
+ retval = glade_project_load_internal (project);
+
+ if (retval)
+ {
+ gchar *name, *title;
+
+ /* Update prefs dialogs here... */
+ name = glade_project_get_name (project);
+ title = g_strdup_printf (_("%s preferences"), name);
+ gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
+ g_free (title);
+ g_free (name);
+ }
+ return retval;
}
/**
@@ -1594,37 +1584,37 @@ glade_project_load_from_file (GladeProject *project,
* failure
*/
GladeProject *
-glade_project_load (const gchar *path)
-{
- GladeProject *project;
- gboolean retval;
-
- g_return_val_if_fail (path != NULL, NULL);
-
- project = g_object_new (GLADE_TYPE_PROJECT, NULL);
-
- project->priv->path = glade_util_canonical_path (path);
-
- retval = glade_project_load_internal (project);
-
- if (retval)
- {
- gchar *name, *title;
-
- /* Update prefs dialogs here... */
- name = glade_project_get_name (project);
- title = g_strdup_printf (_("%s preferences"), name);
- gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
- g_free (title);
- g_free (name);
-
- return project;
- }
- else
- {
- g_object_unref (project);
- return NULL;
- }
+glade_project_load (const gchar * path)
+{
+ GladeProject *project;
+ gboolean retval;
+
+ g_return_val_if_fail (path != NULL, NULL);
+
+ project = g_object_new (GLADE_TYPE_PROJECT, NULL);
+
+ project->priv->path = glade_util_canonical_path (path);
+
+ retval = glade_project_load_internal (project);
+
+ if (retval)
+ {
+ gchar *name, *title;
+
+ /* Update prefs dialogs here... */
+ name = glade_project_get_name (project);
+ title = g_strdup_printf (_("%s preferences"), name);
+ gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
+ g_free (title);
+ g_free (name);
+
+ return project;
+ }
+ else
+ {
+ g_object_unref (project);
+ return NULL;
+ }
}
/*******************************************************************
@@ -1636,190 +1626,191 @@ glade_project_load (const gchar *path)
static gchar *
glade_project_make_comment ()
{
- time_t now = time (NULL);
- gchar *comment;
- comment = g_strdup_printf (GLADE_XML_COMMENT" "PACKAGE_VERSION" on %s",
- ctime (&now));
- glade_util_replace (comment, '\n', ' ');
-
- return comment;
+ time_t now = time (NULL);
+ gchar *comment;
+ comment = g_strdup_printf (GLADE_XML_COMMENT " " PACKAGE_VERSION " on %s",
+ ctime (&now));
+ glade_util_replace (comment, '\n', ' ');
+
+ return comment;
}
static void
-glade_project_update_comment (GladeProject *project)
-{
- gchar **lines, **l, *comment = NULL;
-
- /* If project has no comment -> add the new one */
- if (project->priv->comment == NULL)
- {
- project->priv->comment = glade_project_make_comment ();
- return;
- }
-
- for (lines = l = g_strsplit (project->priv->comment, "\n", 0); *l; l++)
- {
- gchar *start;
-
- /* Ignore leading spaces */
- for (start = *l; *start && g_ascii_isspace (*start); start++);
-
- if (g_str_has_prefix (start, GLADE_XML_COMMENT))
- {
- /* This line was generated by glade -> updating... */
- g_free (*l);
- *l = comment = glade_project_make_comment ();
- }
- }
-
- if (comment)
- {
- g_free (project->priv->comment);
- project->priv->comment = g_strjoinv ("\n", lines);
- }
-
- g_strfreev (lines);
+glade_project_update_comment (GladeProject * project)
+{
+ gchar **lines, **l, *comment = NULL;
+
+ /* If project has no comment -> add the new one */
+ if (project->priv->comment == NULL)
+ {
+ project->priv->comment = glade_project_make_comment ();
+ return;
+ }
+
+ for (lines = l = g_strsplit (project->priv->comment, "\n", 0); *l; l++)
+ {
+ gchar *start;
+
+ /* Ignore leading spaces */
+ for (start = *l; *start && g_ascii_isspace (*start); start++);
+
+ if (g_str_has_prefix (start, GLADE_XML_COMMENT))
+ {
+ /* This line was generated by glade -> updating... */
+ g_free (*l);
+ *l = comment = glade_project_make_comment ();
+ }
+ }
+
+ if (comment)
+ {
+ g_free (project->priv->comment);
+ project->priv->comment = g_strjoinv ("\n", lines);
+ }
+
+ g_strfreev (lines);
}
static void
-glade_project_write_required_libs (GladeProject *project,
- GladeXmlContext *context,
- GladeXmlNode *root)
-{
- GladeXmlNode *req_node;
- GList *required, *list;
- gint major, minor;
- gchar *version;
-
- if ((required = glade_project_required_libs (project)) != NULL)
- {
- for (list = required; list; list = list->next)
- {
- glade_project_get_target_version (project, (gchar *)list->data,
- &major, &minor);
-
- version = g_strdup_printf ("%d.%d", major, minor);
-
- /* Write the standard requires tag */
- if (GLADE_GTKBUILDER_HAS_VERSIONING (major, minor))
- {
- req_node = glade_xml_node_new (context, GLADE_XML_TAG_REQUIRES);
- glade_xml_node_append_child (root, req_node);
- glade_xml_node_set_property_string (req_node,
- GLADE_XML_TAG_LIB,
- (gchar *)list->data);
- }
- else
- {
- gchar *comment =
- g_strdup_printf (" interface-requires %s %s ",
- (gchar *)list->data, version);
- req_node = glade_xml_node_new_comment (context, comment);
- glade_xml_node_append_child (root, req_node);
- g_free (comment);
- }
-
- glade_xml_node_set_property_string (req_node, GLADE_XML_TAG_VERSION, version);
- g_free (version);
-
- }
- g_list_foreach (required, (GFunc)g_free, NULL);
- g_list_free (required);
- }
+glade_project_write_required_libs (GladeProject * project,
+ GladeXmlContext * context,
+ GladeXmlNode * root)
+{
+ GladeXmlNode *req_node;
+ GList *required, *list;
+ gint major, minor;
+ gchar *version;
+
+ if ((required = glade_project_required_libs (project)) != NULL)
+ {
+ for (list = required; list; list = list->next)
+ {
+ glade_project_get_target_version (project, (gchar *) list->data,
+ &major, &minor);
+
+ version = g_strdup_printf ("%d.%d", major, minor);
+
+ /* Write the standard requires tag */
+ if (GLADE_GTKBUILDER_HAS_VERSIONING (major, minor))
+ {
+ req_node = glade_xml_node_new (context, GLADE_XML_TAG_REQUIRES);
+ glade_xml_node_append_child (root, req_node);
+ glade_xml_node_set_property_string (req_node,
+ GLADE_XML_TAG_LIB,
+ (gchar *) list->data);
+ }
+ else
+ {
+ gchar *comment = g_strdup_printf (" interface-requires %s %s ",
+ (gchar *) list->data, version);
+ req_node = glade_xml_node_new_comment (context, comment);
+ glade_xml_node_append_child (root, req_node);
+ g_free (comment);
+ }
+
+ glade_xml_node_set_property_string (req_node, GLADE_XML_TAG_VERSION,
+ version);
+ g_free (version);
+
+ }
+ g_list_foreach (required, (GFunc) g_free, NULL);
+ g_list_free (required);
+ }
}
static void
-glade_project_write_naming_policy (GladeProject *project,
- GladeXmlContext *context,
- GladeXmlNode *root)
+glade_project_write_naming_policy (GladeProject * project,
+ GladeXmlContext * context,
+ GladeXmlNode * root)
{
- GladeXmlNode *policy_node;
- gchar *comment = g_strdup_printf (" interface-naming-policy %s ",
- project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE ?
- "project-wide" : "toplevel-contextual");
+ GladeXmlNode *policy_node;
+ gchar *comment = g_strdup_printf (" interface-naming-policy %s ",
+ project->priv->naming_policy ==
+ GLADE_POLICY_PROJECT_WIDE ? "project-wide" :
+ "toplevel-contextual");
- policy_node = glade_xml_node_new_comment (context, comment);
- glade_xml_node_append_child (root, policy_node);
- g_free (comment);
+ policy_node = glade_xml_node_new_comment (context, comment);
+ glade_xml_node_append_child (root, policy_node);
+ g_free (comment);
}
static void
-glade_project_write_resource_path (GladeProject *project,
- GladeXmlContext *context,
- GladeXmlNode *root)
+glade_project_write_resource_path (GladeProject * project,
+ GladeXmlContext * context,
+ GladeXmlNode * root)
{
- GladeXmlNode *path_node;
- if (project->priv->resource_path)
- {
- gchar *comment = g_strdup_printf (" interface-local-resource-path %s ",
- project->priv->resource_path);
- path_node = glade_xml_node_new_comment (context, comment);
- glade_xml_node_append_child (root, path_node);
- g_free (comment);
- }
+ GladeXmlNode *path_node;
+ if (project->priv->resource_path)
+ {
+ gchar *comment = g_strdup_printf (" interface-local-resource-path %s ",
+ project->priv->resource_path);
+ path_node = glade_xml_node_new_comment (context, comment);
+ glade_xml_node_append_child (root, path_node);
+ g_free (comment);
+ }
}
static gint
-sort_project_dependancies (GObject *a, GObject *b)
+sort_project_dependancies (GObject * a, GObject * b)
{
- GladeWidget *ga, *gb;
+ GladeWidget *ga, *gb;
- ga = glade_widget_get_from_gobject (a);
- gb = glade_widget_get_from_gobject (b);
+ ga = glade_widget_get_from_gobject (a);
+ gb = glade_widget_get_from_gobject (b);
- if (glade_widget_adaptor_depends (ga->adaptor, ga, gb))
- return 1;
- else if (glade_widget_adaptor_depends (gb->adaptor, gb, ga))
- return -1;
- else
- return strcmp (ga->name, gb->name);
+ if (glade_widget_adaptor_depends (ga->adaptor, ga, gb))
+ return 1;
+ else if (glade_widget_adaptor_depends (gb->adaptor, gb, ga))
+ return -1;
+ else
+ return strcmp (ga->name, gb->name);
}
static GladeXmlContext *
-glade_project_write (GladeProject *project)
+glade_project_write (GladeProject * project)
{
- GladeXmlContext *context;
- GladeXmlDoc *doc;
- GladeXmlNode *root; /* *comment_node; */
- GList *list;
+ GladeXmlContext *context;
+ GladeXmlDoc *doc;
+ GladeXmlNode *root; /* *comment_node; */
+ GList *list;
- doc = glade_xml_doc_new ();
- context = glade_xml_context_new (doc, NULL);
- root = glade_xml_node_new (context, GLADE_XML_TAG_PROJECT);
- glade_xml_doc_set_root (doc, root);
+ doc = glade_xml_doc_new ();
+ context = glade_xml_context_new (doc, NULL);
+ root = glade_xml_node_new (context, GLADE_XML_TAG_PROJECT);
+ glade_xml_doc_set_root (doc, root);
- glade_project_update_comment (project);
- /* comment_node = glade_xml_node_new_comment (context, project->priv->comment); */
+ glade_project_update_comment (project);
+ /* comment_node = glade_xml_node_new_comment (context, project->priv->comment); */
- /* XXX Need to append this to the doc ! not the ROOT !
- glade_xml_node_append_child (root, comment_node); */
+ /* XXX Need to append this to the doc ! not the ROOT !
+ glade_xml_node_append_child (root, comment_node); */
- glade_project_write_required_libs (project, context, root);
+ glade_project_write_required_libs (project, context, root);
- glade_project_write_naming_policy (project, context, root);
+ glade_project_write_naming_policy (project, context, root);
- glade_project_write_resource_path (project, context, root);
+ glade_project_write_resource_path (project, context, root);
- /* Sort the whole thing */
- project->priv->objects =
- g_list_sort (project->priv->objects,
- (GCompareFunc)sort_project_dependancies);
+ /* Sort the whole thing */
+ project->priv->objects =
+ g_list_sort (project->priv->objects,
+ (GCompareFunc) sort_project_dependancies);
- for (list = project->priv->objects; list; list = list->next)
- {
- GladeWidget *widget;
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ GladeWidget *widget;
- widget = glade_widget_get_from_gobject (list->data);
+ widget = glade_widget_get_from_gobject (list->data);
- /*
- * Append toplevel widgets. Each widget then takes
- * care of appending its children.
- */
- if (widget->parent == NULL)
- glade_widget_write (widget, context, root);
- }
-
- return context;
+ /*
+ * Append toplevel widgets. Each widget then takes
+ * care of appending its children.
+ */
+ if (widget->parent == NULL)
+ glade_widget_write (widget, context, root);
+ }
+
+ return context;
}
/**
@@ -1833,144 +1824,152 @@ glade_project_write (GladeProject *project)
* Returns: %TRUE on success, %FALSE on failure
*/
gboolean
-glade_project_save (GladeProject *project, const gchar *path, GError **error)
+glade_project_save (GladeProject * project, const gchar * path, GError ** error)
{
- GladeXmlContext *context;
- GladeXmlDoc *doc;
- gchar *canonical_path;
- gint ret;
+ GladeXmlContext *context;
+ GladeXmlDoc *doc;
+ gchar *canonical_path;
+ gint ret;
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- if (glade_project_is_loading (project))
- return FALSE;
+ if (glade_project_is_loading (project))
+ return FALSE;
- if (!glade_project_verify (project, TRUE))
- return FALSE;
+ if (!glade_project_verify (project, TRUE))
+ return FALSE;
- context = glade_project_write (project);
- doc = glade_xml_context_get_doc (context);
- ret = glade_xml_doc_save (doc, path);
- glade_xml_context_destroy (context);
+ context = glade_project_write (project);
+ doc = glade_xml_context_get_doc (context);
+ ret = glade_xml_doc_save (doc, path);
+ glade_xml_context_destroy (context);
- canonical_path = glade_util_canonical_path (path);
- g_assert (canonical_path);
+ canonical_path = glade_util_canonical_path (path);
+ g_assert (canonical_path);
- if (project->priv->path == NULL ||
- strcmp (canonical_path, project->priv->path))
- {
- gchar *name, *title;
-
- project->priv->path = (g_free (project->priv->path),
- g_strdup (canonical_path));
-
- /* Update prefs dialogs here... */
- name = glade_project_get_name (project);
- title = g_strdup_printf (_("%s preferences"), name);
- gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
- g_free (title);
- g_free (name);
- }
-
- glade_project_set_readonly (project,
- !glade_util_file_is_writeable (project->priv->path));
-
- project->priv->mtime = glade_util_get_file_mtime (project->priv->path, NULL);
-
- glade_project_set_modified (project, FALSE);
-
- if (project->priv->unsaved_number > 0)
- {
- glade_id_allocator_release (get_unsaved_number_allocator (), project->priv->unsaved_number);
- project->priv->unsaved_number = 0;
- }
+ if (project->priv->path == NULL ||
+ strcmp (canonical_path, project->priv->path))
+ {
+ gchar *name, *title;
+
+ project->priv->path = (g_free (project->priv->path),
+ g_strdup (canonical_path));
+
+ /* Update prefs dialogs here... */
+ name = glade_project_get_name (project);
+ title = g_strdup_printf (_("%s preferences"), name);
+ gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
+ g_free (title);
+ g_free (name);
+ }
- g_free (canonical_path);
+ glade_project_set_readonly (project,
+ !glade_util_file_is_writeable (project->priv->
+ path));
- return ret > 0;
+ project->priv->mtime = glade_util_get_file_mtime (project->priv->path, NULL);
+
+ glade_project_set_modified (project, FALSE);
+
+ if (project->priv->unsaved_number > 0)
+ {
+ glade_id_allocator_release (get_unsaved_number_allocator (),
+ project->priv->unsaved_number);
+ project->priv->unsaved_number = 0;
+ }
+
+ g_free (canonical_path);
+
+ return ret > 0;
}
static GPid
-glade_project_launch_preview (GladeProject *project, gchar *buffer, GtkWidget *widget)
-{
- GPid pid;
- GError *error = NULL;
- gchar *argv[4];
- gint child_stdin;
- GIOChannel *output;
- guint watch;
- ChannelWatchPair *channel_watch;
- GladeWidget *glade_widget;
-
-
- #ifdef WINDOWS
- argv[0] = g_build_filename (glade_app_get_bin_dir(), "glade-previewer.exe", NULL);
- #else
- argv[0] = g_build_filename (glade_app_get_bin_dir(), "glade-previewer", NULL);
- #endif
-
-
- argv[1] = "--listen";
-
- if (widget != NULL)
- {
- glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
- argv[2] = g_strdup_printf ("--toplevel=%s", glade_widget->name);
- argv[3] = NULL;
- }
-
- if (g_spawn_async_with_pipes (NULL,
- argv,
- NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
- &pid, &child_stdin, NULL, NULL, &error) == FALSE)
- {
- g_printerr (_("Error launching previewer: %s\n"), error->message);
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Failed to launch preview: %s.\n"),
- error->message);
- g_error_free (error);
- pid = 0;
- goto end;
- }
-
- /* Store watch so we can remove it later */
- watch = g_child_watch_add (pid, glade_project_preview_exits, project);
-
- #ifdef WINDOWS
- output = g_io_channel_win32_new_fd (child_stdin);
- #else
- output = g_io_channel_unix_new (child_stdin);
- #endif
-
- gsize bytes_written;
- g_io_channel_write_chars (output, buffer, strlen (buffer), &bytes_written, &error);
-
- if (bytes_written != strlen (buffer) && error != NULL)
- {
- g_printerr ("Error passing UI trough pipe: %s", error->message);
- g_error_free (error);
- }
-
- g_io_channel_flush (output, &error);
- if (error != NULL)
- {
- g_printerr ("Error flushing UI trough pipe: %s", error->message);
- g_error_free (error);
- }
-
- if (widget != NULL) g_free (argv[2]);
-
- /* Adding channel to list of channels */
- channel_watch = g_new (ChannelWatchPair, 1);
- channel_watch->channel = output;
- channel_watch->watch = watch;
- g_hash_table_insert (project->priv->preview_channels, g_strdup_printf("%d", pid),
- channel_watch);
-
- end:
- g_free (argv[0]);
- return pid;
+glade_project_launch_preview (GladeProject * project, gchar * buffer,
+ GtkWidget * widget)
+{
+ GPid pid;
+ GError *error = NULL;
+ gchar *argv[4];
+ gint child_stdin;
+ GIOChannel *output;
+ guint watch;
+ ChannelWatchPair *channel_watch;
+ GladeWidget *glade_widget;
+
+
+#ifdef WINDOWS
+ argv[0] =
+ g_build_filename (glade_app_get_bin_dir (), "glade-previewer.exe", NULL);
+#else
+ argv[0] =
+ g_build_filename (glade_app_get_bin_dir (), "glade-previewer", NULL);
+#endif
+
+
+ argv[1] = "--listen";
+
+ if (widget != NULL)
+ {
+ glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
+ argv[2] = g_strdup_printf ("--toplevel=%s", glade_widget->name);
+ argv[3] = NULL;
+ }
+
+ if (g_spawn_async_with_pipes (NULL,
+ argv,
+ NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
+ &pid, &child_stdin, NULL, NULL,
+ &error) == FALSE)
+ {
+ g_printerr (_("Error launching previewer: %s\n"), error->message);
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Failed to launch preview: %s.\n"),
+ error->message);
+ g_error_free (error);
+ pid = 0;
+ goto end;
+ }
+
+ /* Store watch so we can remove it later */
+ watch = g_child_watch_add (pid, glade_project_preview_exits, project);
+
+#ifdef WINDOWS
+ output = g_io_channel_win32_new_fd (child_stdin);
+#else
+ output = g_io_channel_unix_new (child_stdin);
+#endif
+
+ gsize bytes_written;
+ g_io_channel_write_chars (output, buffer, strlen (buffer), &bytes_written,
+ &error);
+
+ if (bytes_written != strlen (buffer) && error != NULL)
+ {
+ g_printerr ("Error passing UI trough pipe: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_io_channel_flush (output, &error);
+ if (error != NULL)
+ {
+ g_printerr ("Error flushing UI trough pipe: %s", error->message);
+ g_error_free (error);
+ }
+
+ if (widget != NULL)
+ g_free (argv[2]);
+
+ /* Adding channel to list of channels */
+ channel_watch = g_new (ChannelWatchPair, 1);
+ channel_watch->channel = output;
+ channel_watch->watch = watch;
+ g_hash_table_insert (project->priv->preview_channels,
+ g_strdup_printf ("%d", pid), channel_watch);
+
+end:
+ g_free (argv[0]);
+ return pid;
}
/**
@@ -1984,25 +1983,26 @@ glade_project_launch_preview (GladeProject *project, gchar *buffer, GtkWidget *w
* snapshots can be taken.
*/
void
-glade_project_preview (GladeProject *project, GladeWidget *gwidget)
+glade_project_preview (GladeProject * project, GladeWidget * gwidget)
{
- GladeXmlContext *context;
- gchar *text;
- GtkWidget *widget;
+ GladeXmlContext *context;
+ gchar *text;
+ GtkWidget *widget;
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- context = glade_project_write (project);
+ context = glade_project_write (project);
- text = glade_xml_dump_from_context (context);
+ text = glade_xml_dump_from_context (context);
- gwidget = glade_widget_get_toplevel (gwidget);
- if (!GTK_IS_WIDGET (gwidget->object)) return;
- widget = GTK_WIDGET (gwidget->object);
+ gwidget = glade_widget_get_toplevel (gwidget);
+ if (!GTK_IS_WIDGET (gwidget->object))
+ return;
+ widget = GTK_WIDGET (gwidget->object);
- glade_project_launch_preview (project, text, widget);
+ glade_project_launch_preview (project, text, widget);
- g_free (text);
+ g_free (text);
}
/*******************************************************************
@@ -2045,164 +2045,160 @@ glade_project_preview (GladeProject *project, GladeWidget *gwidget)
#define SIGNAL_VERSION_CONFLICT_MSGFMT _("This signal was introduced in %s %d.%d while project targets %s %d.%d")
static void
-glade_project_verify_property (GladeProject *project,
- GladeProperty *property,
- const gchar *path_name,
- GString *string,
- gboolean forwidget)
-{
- GladeWidgetAdaptor *adaptor, *prop_adaptor;
- gint target_major, target_minor;
- gchar *catalog, *tooltip;
-
- if (glade_property_original_default (property) && !forwidget)
- return;
-
- prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
- adaptor = glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
-
- g_object_get (adaptor, "catalog", &catalog, NULL);
- glade_project_target_version_for_adaptor (property->widget->project, adaptor,
- &target_major,
- &target_minor);
-
- if (!GPC_VERSION_CHECK (property->klass, target_major, target_minor))
- {
- if (forwidget)
- {
- tooltip = g_strdup_printf (PROP_VERSION_CONFLICT_MSGFMT,
- catalog,
- property->klass->version_since_major,
- property->klass->version_since_minor,
- catalog,
- target_major, target_minor);
-
- glade_property_set_support_warning (property, FALSE, tooltip);
- g_free (tooltip);
- }
- else
- g_string_append_printf (string,
- property->klass->packing ?
- PACK_PROP_VERSION_CONFLICT_FMT :
- PROP_VERSION_CONFLICT_FMT,
- path_name,
- property->klass->name,
- adaptor->title, catalog,
- property->klass->version_since_major,
- property->klass->version_since_minor);
- }
- else if (forwidget)
- glade_property_set_support_warning (property, FALSE, NULL);
-
- g_free (catalog);
+glade_project_verify_property (GladeProject * project,
+ GladeProperty * property,
+ const gchar * path_name,
+ GString * string, gboolean forwidget)
+{
+ GladeWidgetAdaptor *adaptor, *prop_adaptor;
+ gint target_major, target_minor;
+ gchar *catalog, *tooltip;
+
+ if (glade_property_original_default (property) && !forwidget)
+ return;
+
+ prop_adaptor = glade_widget_adaptor_from_pclass (property->klass);
+ adaptor =
+ glade_widget_adaptor_from_pspec (prop_adaptor, property->klass->pspec);
+
+ g_object_get (adaptor, "catalog", &catalog, NULL);
+ glade_project_target_version_for_adaptor (property->widget->project, adaptor,
+ &target_major, &target_minor);
+
+ if (!GPC_VERSION_CHECK (property->klass, target_major, target_minor))
+ {
+ if (forwidget)
+ {
+ tooltip = g_strdup_printf (PROP_VERSION_CONFLICT_MSGFMT,
+ catalog,
+ property->klass->version_since_major,
+ property->klass->version_since_minor,
+ catalog, target_major, target_minor);
+
+ glade_property_set_support_warning (property, FALSE, tooltip);
+ g_free (tooltip);
+ }
+ else
+ g_string_append_printf (string,
+ property->klass->packing ?
+ PACK_PROP_VERSION_CONFLICT_FMT :
+ PROP_VERSION_CONFLICT_FMT,
+ path_name,
+ property->klass->name,
+ adaptor->title, catalog,
+ property->klass->version_since_major,
+ property->klass->version_since_minor);
+ }
+ else if (forwidget)
+ glade_property_set_support_warning (property, FALSE, NULL);
+
+ g_free (catalog);
}
static void
-glade_project_verify_properties_internal (GladeWidget *widget,
- const gchar *path_name,
- GString *string,
- gboolean forwidget)
-{
- GList *list;
- GladeProperty *property;
-
- for (list = widget->properties; list; list = list->next)
- {
- property = list->data;
- glade_project_verify_property (widget->project, property, path_name, string, forwidget);
- }
-
- /* Sometimes widgets on the clipboard have packing props with no parent */
- if (widget->parent)
- {
- for (list = widget->packing_properties; list; list = list->next)
- {
- property = list->data;
- glade_project_verify_property (widget->project, property, path_name, string, forwidget);
- }
- }
+glade_project_verify_properties_internal (GladeWidget * widget,
+ const gchar * path_name,
+ GString * string, gboolean forwidget)
+{
+ GList *list;
+ GladeProperty *property;
+
+ for (list = widget->properties; list; list = list->next)
+ {
+ property = list->data;
+ glade_project_verify_property (widget->project, property, path_name,
+ string, forwidget);
+ }
+
+ /* Sometimes widgets on the clipboard have packing props with no parent */
+ if (widget->parent)
+ {
+ for (list = widget->packing_properties; list; list = list->next)
+ {
+ property = list->data;
+ glade_project_verify_property (widget->project, property, path_name,
+ string, forwidget);
+ }
+ }
}
static void
-glade_project_verify_signal (GladeWidget *widget,
- GladeSignal *signal,
- const gchar *path_name,
- GString *string,
- gboolean forwidget)
-{
- GladeSignalClass *signal_class;
- gint target_major, target_minor;
- gchar *catalog;
-
- signal_class =
- glade_widget_adaptor_get_signal_class (widget->adaptor,
- signal->name);
- //* Cannot verify unknown signal */
- if (!signal_class)
- return;
- g_assert (signal_class->adaptor);
-
- g_object_get (signal_class->adaptor, "catalog", &catalog, NULL);
- glade_project_target_version_for_adaptor (widget->project,
- signal_class->adaptor,
- &target_major,
- &target_minor);
-
- if (!GSC_VERSION_CHECK (signal_class, target_major, target_minor))
- {
- if (forwidget)
- {
- gchar *warning;
-
- warning = g_strdup_printf (SIGNAL_VERSION_CONFLICT_MSGFMT,
- catalog,
- signal_class->version_since_major,
- signal_class->version_since_minor,
- catalog, target_major, target_minor);
- glade_signal_set_support_warning (signal, warning);
- g_free (warning);
- }
- else
- g_string_append_printf (string,
- SIGNAL_VERSION_CONFLICT_FMT,
- path_name,
- signal->name,
- signal_class->adaptor->title,
- catalog,
- signal_class->version_since_major,
- signal_class->version_since_minor);
- }
- else if (forwidget)
- glade_signal_set_support_warning (signal, NULL);
-
- g_free (catalog);
+glade_project_verify_signal (GladeWidget * widget,
+ GladeSignal * signal,
+ const gchar * path_name,
+ GString * string, gboolean forwidget)
+{
+ GladeSignalClass *signal_class;
+ gint target_major, target_minor;
+ gchar *catalog;
+
+ signal_class =
+ glade_widget_adaptor_get_signal_class (widget->adaptor, signal->name);
+ //* Cannot verify unknown signal */
+ if (!signal_class)
+ return;
+ g_assert (signal_class->adaptor);
+
+ g_object_get (signal_class->adaptor, "catalog", &catalog, NULL);
+ glade_project_target_version_for_adaptor (widget->project,
+ signal_class->adaptor,
+ &target_major, &target_minor);
+
+ if (!GSC_VERSION_CHECK (signal_class, target_major, target_minor))
+ {
+ if (forwidget)
+ {
+ gchar *warning;
+
+ warning = g_strdup_printf (SIGNAL_VERSION_CONFLICT_MSGFMT,
+ catalog,
+ signal_class->version_since_major,
+ signal_class->version_since_minor,
+ catalog, target_major, target_minor);
+ glade_signal_set_support_warning (signal, warning);
+ g_free (warning);
+ }
+ else
+ g_string_append_printf (string,
+ SIGNAL_VERSION_CONFLICT_FMT,
+ path_name,
+ signal->name,
+ signal_class->adaptor->title,
+ catalog,
+ signal_class->version_since_major,
+ signal_class->version_since_minor);
+ }
+ else if (forwidget)
+ glade_signal_set_support_warning (signal, NULL);
+
+ g_free (catalog);
}
void
-glade_project_update_signal_support_warning (GladeWidget *widget,
- GladeSignal *signal)
+glade_project_update_signal_support_warning (GladeWidget * widget,
+ GladeSignal * signal)
{
- glade_project_verify_signal (widget, signal, NULL, NULL, TRUE);
+ glade_project_verify_signal (widget, signal, NULL, NULL, TRUE);
}
static void
-glade_project_verify_signals (GladeWidget *widget,
- const gchar *path_name,
- GString *string,
- gboolean forwidget)
-{
- GladeSignal *signal;
- GList *signals, *list;
-
- if ((signals = glade_widget_get_signal_list (widget)) != NULL)
- {
- for (list = signals; list; list = list->next)
- {
- signal = list->data;
- glade_project_verify_signal (widget, signal, path_name, string, forwidget);
- }
- g_list_free (signals);
- }
+glade_project_verify_signals (GladeWidget * widget,
+ const gchar * path_name,
+ GString * string, gboolean forwidget)
+{
+ GladeSignal *signal;
+ GList *signals, *list;
+
+ if ((signals = glade_widget_get_signal_list (widget)) != NULL)
+ {
+ for (list = signals; list; list = list->next)
+ {
+ signal = list->data;
+ glade_project_verify_signal (widget, signal, path_name, string,
+ forwidget);
+ }
+ g_list_free (signals);
+ }
}
@@ -2215,169 +2211,165 @@ glade_project_verify_signals (GladeWidget *widget,
* it should update.
*/
void
-glade_project_verify_properties (GladeWidget *widget)
+glade_project_verify_properties (GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- glade_project_verify_properties_internal (widget, NULL, NULL, TRUE);
- glade_project_verify_signals (widget, NULL, NULL, TRUE);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ glade_project_verify_properties_internal (widget, NULL, NULL, TRUE);
+ glade_project_verify_signals (widget, NULL, NULL, TRUE);
- glade_widget_support_changed (widget);
+ glade_widget_support_changed (widget);
}
static gboolean
-glade_project_verify_dialog (GladeProject *project,
- GString *string,
- gboolean saving)
+glade_project_verify_dialog (GladeProject * project,
+ GString * string, gboolean saving)
{
- GtkWidget *swindow;
- GtkWidget *textview;
- GtkWidget *expander;
- GtkTextBuffer *buffer;
- gchar *name;
- gboolean ret;
+ GtkWidget *swindow;
+ GtkWidget *textview;
+ GtkWidget *expander;
+ GtkTextBuffer *buffer;
+ gchar *name;
+ gboolean ret;
+
+ swindow = gtk_scrolled_window_new (NULL, NULL);
+ textview = gtk_text_view_new ();
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
+ expander = gtk_expander_new (_("Details"));
- swindow = gtk_scrolled_window_new (NULL, NULL);
- textview = gtk_text_view_new ();
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
- expander = gtk_expander_new (_("Details"));
+ gtk_text_buffer_set_text (buffer, string->str, -1);
- gtk_text_buffer_set_text (buffer, string->str, -1);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow),
+ textview);
+ gtk_container_add (GTK_CONTAINER (expander), swindow);
+ gtk_widget_show_all (expander);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow),
- textview);
- gtk_container_add (GTK_CONTAINER (expander), swindow);
- gtk_widget_show_all (expander);
+ gtk_widget_set_size_request (swindow, 800, -1);
- gtk_widget_set_size_request (swindow, 800, -1);
-
- name = glade_project_get_name (project);
- ret = glade_util_ui_message (glade_app_get_window (),
- saving ? GLADE_UI_YES_OR_NO : GLADE_UI_INFO,
- expander,
- saving ?
- _("Project \"%s\" has errors. Save anyway?") :
- _("Project \"%s\" has deprecated widgets "
- "and/or version mismatches."), name);
- g_free (name);
+ name = glade_project_get_name (project);
+ ret = glade_util_ui_message (glade_app_get_window (),
+ saving ? GLADE_UI_YES_OR_NO : GLADE_UI_INFO,
+ expander,
+ saving ?
+ _("Project \"%s\" has errors. Save anyway?") :
+ _("Project \"%s\" has deprecated widgets "
+ "and/or version mismatches."), name);
+ g_free (name);
- return ret;
+ return ret;
}
static gboolean
-glade_project_verify (GladeProject *project,
- gboolean saving)
+glade_project_verify (GladeProject * project, gboolean saving)
{
- GString *string = g_string_new (NULL);
- GladeWidget *widget;
- GList *list;
- gboolean ret = TRUE;
- gchar *path_name;
+ GString *string = g_string_new (NULL);
+ GladeWidget *widget;
+ GList *list;
+ gboolean ret = TRUE;
+ gchar *path_name;
- for (list = project->priv->objects; list; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
- path_name = glade_widget_generate_path_name (widget);
+ path_name = glade_widget_generate_path_name (widget);
- glade_project_verify_adaptor (project, widget->adaptor,
- path_name, string, saving, FALSE, NULL);
- glade_project_verify_properties_internal (widget, path_name, string, FALSE);
- glade_project_verify_signals (widget, path_name, string, FALSE);
+ glade_project_verify_adaptor (project, widget->adaptor,
+ path_name, string, saving, FALSE, NULL);
+ glade_project_verify_properties_internal (widget, path_name, string,
+ FALSE);
+ glade_project_verify_signals (widget, path_name, string, FALSE);
- g_free (path_name);
- }
+ g_free (path_name);
+ }
- if (string->len > 0)
- {
- ret = glade_project_verify_dialog (project, string, saving);
+ if (string->len > 0)
+ {
+ ret = glade_project_verify_dialog (project, string, saving);
- if (!saving)
- ret = FALSE;
- }
+ if (!saving)
+ ret = FALSE;
+ }
- g_string_free (string, TRUE);
+ g_string_free (string, TRUE);
- return ret;
+ return ret;
}
static void
-glade_project_target_version_for_adaptor (GladeProject *project,
- GladeWidgetAdaptor *adaptor,
- gint *major,
- gint *minor)
+glade_project_target_version_for_adaptor (GladeProject * project,
+ GladeWidgetAdaptor * adaptor,
+ gint * major, gint * minor)
{
- gchar *catalog = NULL;
+ gchar *catalog = NULL;
- g_object_get (adaptor, "catalog", &catalog, NULL);
- glade_project_get_target_version (project, catalog, major, minor);
- g_free (catalog);
+ g_object_get (adaptor, "catalog", &catalog, NULL);
+ glade_project_get_target_version (project, catalog, major, minor);
+ g_free (catalog);
}
static void
-glade_project_verify_adaptor (GladeProject *project,
- GladeWidgetAdaptor *adaptor,
- const gchar *path_name,
- GString *string,
- gboolean saving,
- gboolean forwidget,
- GladeSupportMask *mask)
-{
- GladeSupportMask support_mask = GLADE_SUPPORT_OK;
- GladeWidgetAdaptor *adaptor_iter;
- gint target_major, target_minor;
- gchar *catalog = NULL;
-
- for (adaptor_iter = adaptor; adaptor_iter && support_mask == GLADE_SUPPORT_OK;
- adaptor_iter = glade_widget_adaptor_get_parent_adaptor (adaptor_iter))
- {
-
- g_object_get (adaptor_iter, "catalog", &catalog, NULL);
- glade_project_target_version_for_adaptor (project, adaptor_iter,
- &target_major,
- &target_minor);
-
- /* Only one versioning message (builder or otherwise)...
- */
- if (!GWA_VERSION_CHECK (adaptor_iter, target_major, target_minor))
- {
- if (forwidget)
- g_string_append_printf (string,
- WIDGET_VERSION_CONFLICT_MSGFMT,
- catalog,
- GWA_VERSION_SINCE_MAJOR (adaptor_iter),
- GWA_VERSION_SINCE_MINOR (adaptor_iter),
- catalog, target_major, target_minor);
- else
- g_string_append_printf (string,
- WIDGET_VERSION_CONFLICT_FMT,
- path_name, adaptor_iter->title, catalog,
- GWA_VERSION_SINCE_MAJOR (adaptor_iter),
- GWA_VERSION_SINCE_MINOR (adaptor_iter));
-
- support_mask |= GLADE_SUPPORT_MISMATCH;
- }
-
- if (!saving && GWA_DEPRECATED (adaptor_iter))
- {
- if (forwidget)
- {
- if (string->len)
- g_string_append (string, "\n");
-
- g_string_append_printf (string, WIDGET_DEPRECATED_MSG);
- }
- else
- g_string_append_printf (string, WIDGET_DEPRECATED_FMT,
- path_name, adaptor_iter->title, catalog,
- target_major, target_minor);
-
- support_mask |= GLADE_SUPPORT_DEPRECATED;
- }
- g_free (catalog);
- }
- if (mask)
- *mask = support_mask;
+glade_project_verify_adaptor (GladeProject * project,
+ GladeWidgetAdaptor * adaptor,
+ const gchar * path_name,
+ GString * string,
+ gboolean saving,
+ gboolean forwidget, GladeSupportMask * mask)
+{
+ GladeSupportMask support_mask = GLADE_SUPPORT_OK;
+ GladeWidgetAdaptor *adaptor_iter;
+ gint target_major, target_minor;
+ gchar *catalog = NULL;
+
+ for (adaptor_iter = adaptor; adaptor_iter && support_mask == GLADE_SUPPORT_OK;
+ adaptor_iter = glade_widget_adaptor_get_parent_adaptor (adaptor_iter))
+ {
+
+ g_object_get (adaptor_iter, "catalog", &catalog, NULL);
+ glade_project_target_version_for_adaptor (project, adaptor_iter,
+ &target_major, &target_minor);
+
+ /* Only one versioning message (builder or otherwise)...
+ */
+ if (!GWA_VERSION_CHECK (adaptor_iter, target_major, target_minor))
+ {
+ if (forwidget)
+ g_string_append_printf (string,
+ WIDGET_VERSION_CONFLICT_MSGFMT,
+ catalog,
+ GWA_VERSION_SINCE_MAJOR (adaptor_iter),
+ GWA_VERSION_SINCE_MINOR (adaptor_iter),
+ catalog, target_major, target_minor);
+ else
+ g_string_append_printf (string,
+ WIDGET_VERSION_CONFLICT_FMT,
+ path_name, adaptor_iter->title, catalog,
+ GWA_VERSION_SINCE_MAJOR (adaptor_iter),
+ GWA_VERSION_SINCE_MINOR (adaptor_iter));
+
+ support_mask |= GLADE_SUPPORT_MISMATCH;
+ }
+
+ if (!saving && GWA_DEPRECATED (adaptor_iter))
+ {
+ if (forwidget)
+ {
+ if (string->len)
+ g_string_append (string, "\n");
+
+ g_string_append_printf (string, WIDGET_DEPRECATED_MSG);
+ }
+ else
+ g_string_append_printf (string, WIDGET_DEPRECATED_FMT,
+ path_name, adaptor_iter->title, catalog,
+ target_major, target_minor);
+
+ support_mask |= GLADE_SUPPORT_DEPRECATED;
+ }
+ g_free (catalog);
+ }
+ if (mask)
+ *mask = support_mask;
}
@@ -2393,27 +2385,27 @@ glade_project_verify_adaptor (GladeProject *project,
* Returns: A newly allocated string
*/
gchar *
-glade_project_verify_widget_adaptor (GladeProject *project,
- GladeWidgetAdaptor *adaptor,
- GladeSupportMask *mask)
+glade_project_verify_widget_adaptor (GladeProject * project,
+ GladeWidgetAdaptor * adaptor,
+ GladeSupportMask * mask)
{
- GString *string = g_string_new (NULL);
- gchar *ret = NULL;
+ GString *string = g_string_new (NULL);
+ gchar *ret = NULL;
- glade_project_verify_adaptor (project, adaptor, NULL,
- string, FALSE, TRUE, mask);
+ glade_project_verify_adaptor (project, adaptor, NULL,
+ string, FALSE, TRUE, mask);
- /* there was a '\0' byte... */
- if (string->len > 0)
- {
- ret = string->str;
- g_string_free (string, FALSE);
- }
- else
- g_string_free (string, TRUE);
+ /* there was a '\0' byte... */
+ if (string->len > 0)
+ {
+ ret = string->str;
+ g_string_free (string, FALSE);
+ }
+ else
+ g_string_free (string, TRUE);
- return ret;
+ return ret;
}
@@ -2424,81 +2416,82 @@ glade_project_verify_widget_adaptor (GladeProject *project,
* Checks the project and updates warning strings in the UI
*/
void
-glade_project_verify_project_for_ui (GladeProject *project)
+glade_project_verify_project_for_ui (GladeProject * project)
{
- GList *list;
- GladeWidget *widget;
- gchar *warning;
+ GList *list;
+ GladeWidget *widget;
+ gchar *warning;
- /* Sync displayable info here */
- for (list = project->priv->objects; list; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
+ /* Sync displayable info here */
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
- warning = glade_project_verify_widget_adaptor (project, widget->adaptor, NULL);
- glade_widget_set_support_warning (widget, warning);
+ warning =
+ glade_project_verify_widget_adaptor (project, widget->adaptor, NULL);
+ glade_widget_set_support_warning (widget, warning);
- if (warning)
- g_free (warning);
+ if (warning)
+ g_free (warning);
- glade_project_verify_properties (widget);
- }
+ glade_project_verify_properties (widget);
+ }
- /* refresh palette if this is the active project */
- if (project == glade_app_get_project ())
- glade_palette_refresh (glade_app_get_palette ());
+ /* refresh palette if this is the active project */
+ if (project == glade_app_get_project ())
+ glade_palette_refresh (glade_app_get_palette ());
}
/*******************************************************************
Project object tracking code, name exclusivity etc...
*******************************************************************/
static GladeNameContext *
-name_context_by_widget (GladeProject *project,
- GladeWidget *gwidget)
+name_context_by_widget (GladeProject * project, GladeWidget * gwidget)
{
- TopLevelInfo *tinfo;
- GladeWidget *iter;
- GList *list;
+ TopLevelInfo *tinfo;
+ GladeWidget *iter;
+ GList *list;
- if (!gwidget->parent)
- return NULL;
+ if (!gwidget->parent)
+ return NULL;
- iter = gwidget;
- while (iter->parent) iter = iter->parent;
+ iter = gwidget;
+ while (iter->parent)
+ iter = iter->parent;
- for (list = project->priv->toplevels; list; list = list->next)
- {
- tinfo = list->data;
- if (tinfo->toplevel == iter)
- return tinfo->names;
- }
- return NULL;
+ for (list = project->priv->toplevels; list; list = list->next)
+ {
+ tinfo = list->data;
+ if (tinfo->toplevel == iter)
+ return tinfo->names;
+ }
+ return NULL;
}
static GladeWidget *
-search_ancestry_by_name (GladeWidget *toplevel, const gchar *name)
-{
- GladeWidget *widget = NULL, *iter;
- GList *list, *children;
-
- if ((children = glade_widget_get_children (toplevel)) != NULL)
- {
- for (list = children; list; list = list->next)
- {
- iter = glade_widget_get_from_gobject (list->data);
-
- if (iter->name && strcmp (iter->name, name) == 0)
- {
- widget = iter;
- break;
- }
- else if ((widget = search_ancestry_by_name (iter, name)) != NULL)
- break;
- }
-
- g_list_free (children);
- }
- return widget;
+search_ancestry_by_name (GladeWidget * toplevel, const gchar * name)
+{
+ GladeWidget *widget = NULL, *iter;
+ GList *list, *children;
+
+ if ((children = glade_widget_get_children (toplevel)) != NULL)
+ {
+ for (list = children; list; list = list->next)
+ {
+ iter = glade_widget_get_from_gobject (list->data);
+
+ if (iter->name && strcmp (iter->name, name) == 0)
+ {
+ widget = iter;
+ break;
+ }
+ else if ((widget = search_ancestry_by_name (iter, name)) != NULL)
+ break;
+ }
+
+ g_list_free (children);
+ }
+ return widget;
}
/**
@@ -2512,84 +2505,93 @@ search_ancestry_by_name (GladeWidget *toplevel, const gchar *name)
* Returns: a pointer to the widget, %NULL if the widget does not exist
*/
GladeWidget *
-glade_project_get_widget_by_name (GladeProject *project, GladeWidget *ancestor, const gchar *name)
+glade_project_get_widget_by_name (GladeProject * project,
+ GladeWidget * ancestor, const gchar * name)
{
- GladeWidget *toplevel, *widget = NULL;
- GList *list;
+ GladeWidget *toplevel, *widget = NULL;
+ GList *list;
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- if (ancestor)
- {
- toplevel = glade_widget_get_toplevel (ancestor);
- if ((widget = search_ancestry_by_name (toplevel, name)) != NULL)
- return widget;
- }
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- /* Now try searching in only toplevel objects... */
- for (list = project->priv->tree; list; list = list->next) {
- GladeWidget *widget;
+ if (ancestor)
+ {
+ toplevel = glade_widget_get_toplevel (ancestor);
+ if ((widget = search_ancestry_by_name (toplevel, name)) != NULL)
+ return widget;
+ }
- widget = glade_widget_get_from_gobject (list->data);
- g_assert (widget->name);
- if (strcmp (widget->name, name) == 0)
- return widget;
- }
+ /* Now try searching in only toplevel objects... */
+ for (list = project->priv->tree; list; list = list->next)
+ {
+ GladeWidget *widget;
- /* Finally resort to a project wide search. */
- for (list = project->priv->objects; list; list = list->next) {
- GladeWidget *widget;
+ widget = glade_widget_get_from_gobject (list->data);
+ g_assert (widget->name);
+ if (strcmp (widget->name, name) == 0)
+ return widget;
+ }
- widget = glade_widget_get_from_gobject (list->data);
- g_return_val_if_fail (widget->name != NULL, NULL);
- if (strcmp (widget->name, name) == 0)
- return widget;
- }
+ /* Finally resort to a project wide search. */
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ GladeWidget *widget;
- return NULL;
+ widget = glade_widget_get_from_gobject (list->data);
+ g_return_val_if_fail (widget->name != NULL, NULL);
+ if (strcmp (widget->name, name) == 0)
+ return widget;
+ }
+
+ return NULL;
}
static void
-glade_project_release_widget_name (GladeProject *project, GladeWidget *gwidget, const char *widget_name)
-{
- GladeNameContext *context = NULL;
- TopLevelInfo *tinfo = NULL;
- GladeWidget *iter;
- GList *list;
-
- /* Search by hand here since we need the tinfo to free... */
- iter = gwidget;
- while (iter->parent) iter = iter->parent;
-
- for (list = project->priv->toplevels; list; list = list->next)
- {
- tinfo = list->data;
- if (tinfo->toplevel == iter)
- {
- context = tinfo->names;
- break;
- }
- }
-
- if (context)
- {
- glade_name_context_release_name (context, widget_name);
- //g_print ("Released widget name %s from sub context\n", widget_name);
- }
-
- if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE || !gwidget->parent)
- {
- glade_name_context_release_name (project->priv->toplevel_names, widget_name);
- //g_print ("Released widget name %s from toplevel context\n", widget_name);
- }
-
- if (context && glade_name_context_n_names (context) == 0)
- {
- glade_name_context_destroy (context);
- g_free (tinfo);
- project->priv->toplevels = g_list_remove (project->priv->toplevels, tinfo);
- }
+glade_project_release_widget_name (GladeProject * project,
+ GladeWidget * gwidget,
+ const char *widget_name)
+{
+ GladeNameContext *context = NULL;
+ TopLevelInfo *tinfo = NULL;
+ GladeWidget *iter;
+ GList *list;
+
+ /* Search by hand here since we need the tinfo to free... */
+ iter = gwidget;
+ while (iter->parent)
+ iter = iter->parent;
+
+ for (list = project->priv->toplevels; list; list = list->next)
+ {
+ tinfo = list->data;
+ if (tinfo->toplevel == iter)
+ {
+ context = tinfo->names;
+ break;
+ }
+ }
+
+ if (context)
+ {
+ glade_name_context_release_name (context, widget_name);
+ //g_print ("Released widget name %s from sub context\n", widget_name);
+ }
+
+ if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE ||
+ !gwidget->parent)
+ {
+ glade_name_context_release_name (project->priv->toplevel_names,
+ widget_name);
+ //g_print ("Released widget name %s from toplevel context\n", widget_name);
+ }
+
+ if (context && glade_name_context_n_names (context) == 0)
+ {
+ glade_name_context_destroy (context);
+ g_free (tinfo);
+ project->priv->toplevels =
+ g_list_remove (project->priv->toplevels, tinfo);
+ }
}
@@ -2604,64 +2606,69 @@ glade_project_release_widget_name (GladeProject *project, GladeWidget *gwidget,
* Returns: whether the name is available or not.
*/
gboolean
-glade_project_available_widget_name (GladeProject *project,
- GladeWidget *widget,
- const gchar *name)
+glade_project_available_widget_name (GladeProject * project,
+ GladeWidget * widget, const gchar * name)
{
- GladeNameContext *context;
- gboolean sub_has_name = FALSE;
- gboolean available = FALSE;
-
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (widget->project == project, FALSE);
+ GladeNameContext *context;
+ gboolean sub_has_name = FALSE;
+ gboolean available = FALSE;
+
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (widget->project == project, FALSE);
- if (!name || !name[0])
- return FALSE;
+ if (!name || !name[0])
+ return FALSE;
- if ((context = name_context_by_widget (project, widget)) != NULL)
- sub_has_name = glade_name_context_has_name (context, name);
+ if ((context = name_context_by_widget (project, widget)) != NULL)
+ sub_has_name = glade_name_context_has_name (context, name);
- if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
- {
- available = (!sub_has_name &&
- !glade_name_context_has_name (project->priv->toplevel_names, name));
+ if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
+ {
+ available = (!sub_has_name &&
+ !glade_name_context_has_name (project->priv->toplevel_names,
+ name));
- }
- else if (context)
- available = !sub_has_name;
- else
- available = !glade_name_context_has_name (project->priv->toplevel_names, name);
+ }
+ else if (context)
+ available = !sub_has_name;
+ else
+ available =
+ !glade_name_context_has_name (project->priv->toplevel_names, name);
- //g_print ("widget name %s is available: %d (policy %d)\n", name, available, project->priv->naming_policy);
+ //g_print ("widget name %s is available: %d (policy %d)\n", name, available, project->priv->naming_policy);
- return available;
+ return available;
}
static void
-glade_project_reserve_widget_name (GladeProject *project, GladeWidget *gwidget, const char *widget_name)
+glade_project_reserve_widget_name (GladeProject * project,
+ GladeWidget * gwidget,
+ const char *widget_name)
{
- GladeNameContext *context;
+ GladeNameContext *context;
- if (!glade_project_available_widget_name (project, gwidget, widget_name))
- {
- g_warning ("BUG: widget '%s' attempting to reserve an unavailable widget name '%s' !",
- gwidget->name, widget_name);
- return;
- }
+ if (!glade_project_available_widget_name (project, gwidget, widget_name))
+ {
+ g_warning
+ ("BUG: widget '%s' attempting to reserve an unavailable widget name '%s' !",
+ gwidget->name, widget_name);
+ return;
+ }
- /* Add to name context(s) */
- if ((context = name_context_by_widget (project, gwidget)) != NULL)
- {
- //g_print ("Reserving widget name %s from sub context\n", widget_name);
- glade_name_context_add_name (context, widget_name);
- }
+ /* Add to name context(s) */
+ if ((context = name_context_by_widget (project, gwidget)) != NULL)
+ {
+ //g_print ("Reserving widget name %s from sub context\n", widget_name);
+ glade_name_context_add_name (context, widget_name);
+ }
- if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE || !gwidget->parent)
- {
- glade_name_context_add_name (project->priv->toplevel_names, widget_name);
- //g_print ("Reserving widget name %s from main context\n", widget_name);
- }
+ if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE ||
+ !gwidget->parent)
+ {
+ glade_name_context_add_name (project->priv->toplevel_names, widget_name);
+ //g_print ("Reserving widget name %s from main context\n", widget_name);
+ }
}
@@ -2678,35 +2685,40 @@ glade_project_reserve_widget_name (GladeProject *project, GladeWidget *gwidget,
* memory for this string
*/
gchar *
-glade_project_new_widget_name (GladeProject *project,
- GladeWidget *widget,
- const gchar *base_name)
-{
- GladeNameContext *context;
- gchar *name;
-
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (widget->project == project, NULL);
- g_return_val_if_fail (base_name && base_name[0], NULL);
-
- context = name_context_by_widget (project, widget);
-
- if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
- {
- if (context)
- name = glade_name_context_dual_new_name (context, project->priv->toplevel_names, base_name);
- else
- name = glade_name_context_new_name (project->priv->toplevel_names, base_name);
- }
- else if (context)
- name = glade_name_context_new_name (context, base_name);
- else
- name = glade_name_context_new_name (project->priv->toplevel_names, base_name);
-
- //g_print ("Allocating widget name %s, widget parent %p\n", name, widget->parent);
-
- return name;
+glade_project_new_widget_name (GladeProject * project,
+ GladeWidget * widget, const gchar * base_name)
+{
+ GladeNameContext *context;
+ gchar *name;
+
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (widget->project == project, NULL);
+ g_return_val_if_fail (base_name && base_name[0], NULL);
+
+ context = name_context_by_widget (project, widget);
+
+ if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
+ {
+ if (context)
+ name =
+ glade_name_context_dual_new_name (context,
+ project->priv->toplevel_names,
+ base_name);
+ else
+ name =
+ glade_name_context_new_name (project->priv->toplevel_names,
+ base_name);
+ }
+ else if (context)
+ name = glade_name_context_new_name (context, base_name);
+ else
+ name =
+ glade_name_context_new_name (project->priv->toplevel_names, base_name);
+
+ //g_print ("Allocating widget name %s, widget parent %p\n", name, widget->parent);
+
+ return name;
}
/**
@@ -2719,114 +2731,111 @@ glade_project_new_widget_name (GladeProject *project,
* available then a new name will be used.
*/
void
-glade_project_set_widget_name (GladeProject *project,
- GladeWidget *widget,
- const gchar *name)
+glade_project_set_widget_name (GladeProject * project,
+ GladeWidget * widget, const gchar * name)
{
- gchar *new_name;
- GtkTreeIter iter;
- GtkTreePath *path;
+ gchar *new_name;
+ GtkTreeIter iter;
+ GtkTreePath *path;
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (widget->project == project);
- g_return_if_fail (name && name[0]);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (widget->project == project);
+ g_return_if_fail (name && name[0]);
- if (strcmp (name, widget->name) == 0)
- return;
+ if (strcmp (name, widget->name) == 0)
+ return;
- /* Police the widget name */
- if (!glade_project_available_widget_name (project, widget, name))
- new_name = glade_project_new_widget_name (project, widget, name);
- else
- new_name = g_strdup (name);
+ /* Police the widget name */
+ if (!glade_project_available_widget_name (project, widget, name))
+ new_name = glade_project_new_widget_name (project, widget, name);
+ else
+ new_name = g_strdup (name);
- glade_project_reserve_widget_name (project, widget, new_name);
+ glade_project_reserve_widget_name (project, widget, new_name);
- /* Release old name and set new widget name */
- glade_project_release_widget_name (project, widget, widget->name);
- glade_widget_set_name (widget, new_name);
-
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [WIDGET_NAME_CHANGED],
- 0, widget);
+ /* Release old name and set new widget name */
+ glade_project_release_widget_name (project, widget, widget->name);
+ glade_widget_set_name (widget, new_name);
- g_free (new_name);
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[WIDGET_NAME_CHANGED], 0, widget);
- /* Notify views about the iter change */
- glade_project_model_get_iter_for_object (project, widget->object, &iter);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
- gtk_tree_model_row_changed (GTK_TREE_MODEL (project), path, &iter);
- gtk_tree_path_free (path);
+ g_free (new_name);
+
+ /* Notify views about the iter change */
+ glade_project_model_get_iter_for_object (project, widget->object, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (project), path, &iter);
+ gtk_tree_path_free (path);
}
static gboolean
-glade_project_has_widget (GladeProject *project)
+glade_project_has_widget (GladeProject * project)
{
- GtkWidget *widget = NULL;
- const GList *objects;
+ GtkWidget *widget = NULL;
+ const GList *objects;
- objects = glade_project_get_objects (project);
+ objects = glade_project_get_objects (project);
- while (objects != NULL)
- {
- if (GTK_IS_WIDGET (objects->data))
- {
- widget = GTK_WIDGET(objects->data);
- break;
- }
- objects = objects->next;
- }
+ while (objects != NULL)
+ {
+ if (GTK_IS_WIDGET (objects->data))
+ {
+ widget = GTK_WIDGET (objects->data);
+ break;
+ }
+ objects = objects->next;
+ }
- return widget != NULL;
+ return widget != NULL;
}
static void
-glade_project_update_previewable (GladeProject *project)
+glade_project_update_previewable (GladeProject * project)
{
- project->priv->previewable = glade_project_has_widget (project);
- g_object_notify (G_OBJECT (project), "previewable");
+ project->priv->previewable = glade_project_has_widget (project);
+ g_object_notify (G_OBJECT (project), "previewable");
}
-static void
-glade_project_notify_row_inserted (GladeProject *project,
- GladeWidget *gwidget)
+static void
+glade_project_notify_row_inserted (GladeProject * project,
+ GladeWidget * gwidget)
{
- GtkTreeIter iter;
- GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkTreePath *path;
- /* The state of old iters go invalid and then the new iter is valid
- * until the next change */
- project->priv->stamp++;
+ /* The state of old iters go invalid and then the new iter is valid
+ * until the next change */
+ project->priv->stamp++;
- glade_project_model_get_iter_for_object (project, gwidget->object, &iter);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (project), path, &iter);
- gtk_tree_path_free (path);
+ glade_project_model_get_iter_for_object (project, gwidget->object, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (project), path, &iter);
+ gtk_tree_path_free (path);
- /* XXX Need to check and call this
- * gtk_tree_model_row_has_child_toggled
- */
+ /* XXX Need to check and call this
+ * gtk_tree_model_row_has_child_toggled
+ */
}
-static void
-glade_project_notify_row_deleted (GladeProject *project,
- GladeWidget *gwidget)
+static void
+glade_project_notify_row_deleted (GladeProject * project, GladeWidget * gwidget)
{
- GtkTreeIter iter;
- GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkTreePath *path;
- glade_project_model_get_iter_for_object (project, gwidget->object, &iter);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (project), path);
- gtk_tree_path_free (path);
+ glade_project_model_get_iter_for_object (project, gwidget->object, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (project), path);
+ gtk_tree_path_free (path);
- /* XXX Need to check and call this
- * gtk_tree_model_row_has_child_toggled
- */
+ /* XXX Need to check and call this
+ * gtk_tree_model_row_has_child_toggled
+ */
- project->priv->stamp++;
+ project->priv->stamp++;
}
/**
@@ -2839,89 +2848,87 @@ glade_project_notify_row_deleted (GladeProject *project,
* Adds an object to the project.
*/
void
-glade_project_add_object (GladeProject *project,
- GladeProject *old_project,
- GObject *object)
-{
- GladeWidget *gwidget;
- GList *list, *children;
- gchar *name;
-
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (G_IS_OBJECT (object));
-
- /* We don't list placeholders */
- if (GLADE_IS_PLACEHOLDER (object))
- return;
-
- /* Only widgets accounted for in the catalog or widgets declared
- * in the plugin with glade_widget_new_for_internal_child () are
- * usefull in the project.
- */
- if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
- return;
-
- if (glade_project_has_object (project, object))
- {
- /* FIXME: It's possible we need to notify the model iface if this
- * happens to make sure the hierarchy is the same, I dont know, this
- * happens when message dialogs with children are rebuilt but the
- * hierarchy still looks good afterwards. */
- return;
- }
-
- /* Create a name context for newly added toplevels... */
- if (!gwidget->parent)
- {
- TopLevelInfo *tinfo = g_new0 (TopLevelInfo, 1);
- tinfo->toplevel = gwidget;
- tinfo->names = glade_name_context_new ();
- project->priv->toplevels = g_list_prepend (project->priv->toplevels, tinfo);
- }
-
- /* Make sure we have an exclusive name first... */
- if (!glade_project_available_widget_name (project, gwidget, gwidget->name))
- {
- name = glade_project_new_widget_name (project, gwidget, gwidget->name);
-
- glade_widget_set_name (gwidget, name);
-
- g_free (name);
- }
-
- glade_project_reserve_widget_name (project, gwidget, gwidget->name);
-
- glade_widget_set_project (gwidget, (gpointer)project);
- g_object_ref_sink (gwidget);
-
- /* Be sure to update the lists before emitting signals */
- if (glade_widget_get_parent (gwidget) == NULL)
- project->priv->tree = g_list_append (project->priv->tree, object);
-
- project->priv->objects = g_list_prepend (project->priv->objects, object);
-
- glade_project_notify_row_inserted (project, gwidget);
-
- /* NOTE: Sensitive ordering here, we need to recurse after updating
- * the tree model listeners (and update those listeners after our
- * internal lists have been resolved), otherwise children are added
- * before the parents (and the views dont like that).
- */
- if ((children = glade_widget_get_children (gwidget)) != NULL)
- {
- for (list = children; list && list->data; list = list->next)
- glade_project_add_object
- (project, old_project, G_OBJECT (list->data));
- g_list_free (children);
- }
-
- /* Update user visible compatibility info */
- glade_project_verify_properties (gwidget);
- glade_project_update_previewable (project);
-
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [ADD_WIDGET],
- 0, gwidget);
+glade_project_add_object (GladeProject * project,
+ GladeProject * old_project, GObject * object)
+{
+ GladeWidget *gwidget;
+ GList *list, *children;
+ gchar *name;
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (G_IS_OBJECT (object));
+
+ /* We don't list placeholders */
+ if (GLADE_IS_PLACEHOLDER (object))
+ return;
+
+ /* Only widgets accounted for in the catalog or widgets declared
+ * in the plugin with glade_widget_new_for_internal_child () are
+ * usefull in the project.
+ */
+ if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
+ return;
+
+ if (glade_project_has_object (project, object))
+ {
+ /* FIXME: It's possible we need to notify the model iface if this
+ * happens to make sure the hierarchy is the same, I dont know, this
+ * happens when message dialogs with children are rebuilt but the
+ * hierarchy still looks good afterwards. */
+ return;
+ }
+
+ /* Create a name context for newly added toplevels... */
+ if (!gwidget->parent)
+ {
+ TopLevelInfo *tinfo = g_new0 (TopLevelInfo, 1);
+ tinfo->toplevel = gwidget;
+ tinfo->names = glade_name_context_new ();
+ project->priv->toplevels =
+ g_list_prepend (project->priv->toplevels, tinfo);
+ }
+
+ /* Make sure we have an exclusive name first... */
+ if (!glade_project_available_widget_name (project, gwidget, gwidget->name))
+ {
+ name = glade_project_new_widget_name (project, gwidget, gwidget->name);
+
+ glade_widget_set_name (gwidget, name);
+
+ g_free (name);
+ }
+
+ glade_project_reserve_widget_name (project, gwidget, gwidget->name);
+
+ glade_widget_set_project (gwidget, (gpointer) project);
+ g_object_ref_sink (gwidget);
+
+ /* Be sure to update the lists before emitting signals */
+ if (glade_widget_get_parent (gwidget) == NULL)
+ project->priv->tree = g_list_append (project->priv->tree, object);
+
+ project->priv->objects = g_list_prepend (project->priv->objects, object);
+
+ glade_project_notify_row_inserted (project, gwidget);
+
+ /* NOTE: Sensitive ordering here, we need to recurse after updating
+ * the tree model listeners (and update those listeners after our
+ * internal lists have been resolved), otherwise children are added
+ * before the parents (and the views dont like that).
+ */
+ if ((children = glade_widget_get_children (gwidget)) != NULL)
+ {
+ for (list = children; list && list->data; list = list->next)
+ glade_project_add_object (project, old_project, G_OBJECT (list->data));
+ g_list_free (children);
+ }
+
+ /* Update user visible compatibility info */
+ glade_project_verify_properties (gwidget);
+ glade_project_update_previewable (project);
+
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[ADD_WIDGET], 0, gwidget);
}
/**
@@ -2932,11 +2939,11 @@ glade_project_add_object (GladeProject *project,
* Returns: whether this object is in this project.
*/
gboolean
-glade_project_has_object (GladeProject *project, GObject *object)
+glade_project_has_object (GladeProject * project, GObject * object)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
- return (g_list_find (project->priv->objects, object)) != NULL;
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
+ return (g_list_find (project->priv->objects, object)) != NULL;
}
/**
@@ -2951,149 +2958,142 @@ glade_project_has_object (GladeProject *project, GObject *object)
* way UNDO can work.
*/
void
-glade_project_remove_object (GladeProject *project, GObject *object)
+glade_project_remove_object (GladeProject * project, GObject * object)
{
- GladeWidget *gwidget;
- GList *list, *children;
-
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (G_IS_OBJECT (object));
+ GladeWidget *gwidget;
+ GList *list, *children;
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (G_IS_OBJECT (object));
- if (GLADE_IS_PLACEHOLDER (object))
- return;
+ if (GLADE_IS_PLACEHOLDER (object))
+ return;
- if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
- return;
+ if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
+ return;
- /* Recurse and remove deepest children first */
- if ((children =
- glade_widget_get_children (gwidget)) != NULL)
- {
- for (list = children; list && list->data; list = list->next)
- glade_project_remove_object (project, G_OBJECT (list->data));
- g_list_free (children);
- }
+ /* Recurse and remove deepest children first */
+ if ((children = glade_widget_get_children (gwidget)) != NULL)
+ {
+ for (list = children; list && list->data; list = list->next)
+ glade_project_remove_object (project, G_OBJECT (list->data));
+ g_list_free (children);
+ }
- /* Notify views that the row is being deleted *before* deleting it */
- glade_project_notify_row_deleted (project, gwidget);
+ /* Notify views that the row is being deleted *before* deleting it */
+ glade_project_notify_row_deleted (project, gwidget);
- /* Remove selection and release name from the name context */
- glade_project_selection_remove (project, object, TRUE);
- glade_project_release_widget_name (project, gwidget,
- glade_widget_get_name (gwidget));
+ /* Remove selection and release name from the name context */
+ glade_project_selection_remove (project, object, TRUE);
+ glade_project_release_widget_name (project, gwidget,
+ glade_widget_get_name (gwidget));
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [REMOVE_WIDGET],
- 0,
- gwidget);
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[REMOVE_WIDGET], 0, gwidget);
- /* Update internal data structure (remove from lists) */
- project->priv->tree = g_list_remove (project->priv->tree, object);
- project->priv->objects = g_list_remove (project->priv->objects, object);
- g_object_unref (gwidget);
+ /* Update internal data structure (remove from lists) */
+ project->priv->tree = g_list_remove (project->priv->tree, object);
+ project->priv->objects = g_list_remove (project->priv->objects, object);
+ g_object_unref (gwidget);
- glade_project_update_previewable (project);
+ glade_project_update_previewable (project);
}
static void
-adjust_naming_policy (GladeProject *project,
- GladeNamingPolicy policy)
+adjust_naming_policy (GladeProject * project, GladeNamingPolicy policy)
{
- GList *list, *objects;
- GladeWidget *widget;
+ GList *list, *objects;
+ GladeWidget *widget;
- /* Ref *all* objects */
- for (list = project->priv->objects; list; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
- g_object_ref (widget);
- }
+ /* Ref *all* objects */
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
+ g_object_ref (widget);
+ }
- /* Remove all toplevels (recursive operation) */
- objects = g_list_copy (project->priv->tree);
- for (list = objects; list; list = list->next)
- glade_project_remove_object (project, G_OBJECT (list->data));
+ /* Remove all toplevels (recursive operation) */
+ objects = g_list_copy (project->priv->tree);
+ for (list = objects; list; list = list->next)
+ glade_project_remove_object (project, G_OBJECT (list->data));
- project->priv->naming_policy = policy;
+ project->priv->naming_policy = policy;
- /* Put the toplevels back with the new policy (recursive operation) */
- for (list = objects; list; list = list->next)
- glade_project_add_object (project, project, G_OBJECT (list->data));
- g_list_free (objects);
+ /* Put the toplevels back with the new policy (recursive operation) */
+ for (list = objects; list; list = list->next)
+ glade_project_add_object (project, project, G_OBJECT (list->data));
+ g_list_free (objects);
- /* Unref them now */
- for (list = project->priv->objects; list; list = list->next)
- {
- widget = glade_widget_get_from_gobject (list->data);
- g_object_ref (widget);
- }
+ /* Unref them now */
+ for (list = project->priv->objects; list; list = list->next)
+ {
+ widget = glade_widget_get_from_gobject (list->data);
+ g_object_ref (widget);
+ }
}
/*******************************************************************
Remaining stubs and api
*******************************************************************/
static void
-glade_project_set_target_version (GladeProject *project,
- const gchar *catalog,
- guint16 major,
- guint16 minor)
-{
- GladeTargetableVersion *version;
- GSList *radios, *list;
- GtkWidget *radio;
-
- g_hash_table_insert (project->priv->target_versions_major,
- g_strdup (catalog),
- GINT_TO_POINTER ( ( int ) major));
- g_hash_table_insert (project->priv->target_versions_minor,
- g_strdup (catalog),
- GINT_TO_POINTER ( ( int ) minor));
-
-
- /* Update prefs dialog from here... */
- if (project->priv->target_radios &&
- (radios = g_hash_table_lookup (project->priv->target_radios, catalog)) != NULL)
- {
- for (list = radios; list; list = list->next)
- g_signal_handlers_block_by_func (G_OBJECT (list->data),
- G_CALLBACK (target_button_clicked),
- project);
-
- for (list = radios; list; list = list->next)
- {
- radio = list->data;
-
- version = g_object_get_data (G_OBJECT (radio), "version");
- if (version->major == major &&
- version->minor == minor)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
- break;
- }
- }
-
- for (list = radios; list; list = list->next)
- g_signal_handlers_unblock_by_func (G_OBJECT (list->data),
- G_CALLBACK (target_button_clicked),
- project);
- }
-
- glade_project_verify_project_for_ui (project);
-
- g_signal_emit (project, glade_project_signals [TARGETS_CHANGED], 0);
+glade_project_set_target_version (GladeProject * project,
+ const gchar * catalog,
+ guint16 major, guint16 minor)
+{
+ GladeTargetableVersion *version;
+ GSList *radios, *list;
+ GtkWidget *radio;
+
+ g_hash_table_insert (project->priv->target_versions_major,
+ g_strdup (catalog), GINT_TO_POINTER ((int) major));
+ g_hash_table_insert (project->priv->target_versions_minor,
+ g_strdup (catalog), GINT_TO_POINTER ((int) minor));
+
+
+ /* Update prefs dialog from here... */
+ if (project->priv->target_radios &&
+ (radios =
+ g_hash_table_lookup (project->priv->target_radios, catalog)) != NULL)
+ {
+ for (list = radios; list; list = list->next)
+ g_signal_handlers_block_by_func (G_OBJECT (list->data),
+ G_CALLBACK (target_button_clicked),
+ project);
+
+ for (list = radios; list; list = list->next)
+ {
+ radio = list->data;
+
+ version = g_object_get_data (G_OBJECT (radio), "version");
+ if (version->major == major && version->minor == minor)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+ break;
+ }
+ }
+
+ for (list = radios; list; list = list->next)
+ g_signal_handlers_unblock_by_func (G_OBJECT (list->data),
+ G_CALLBACK (target_button_clicked),
+ project);
+ }
+
+ glade_project_verify_project_for_ui (project);
+
+ g_signal_emit (project, glade_project_signals[TARGETS_CHANGED], 0);
}
static void
-glade_project_set_readonly (GladeProject *project, gboolean readonly)
+glade_project_set_readonly (GladeProject * project, gboolean readonly)
{
- g_assert (GLADE_IS_PROJECT (project));
-
- if (project->priv->readonly != readonly)
- {
- project->priv->readonly = readonly;
- g_object_notify (G_OBJECT (project), "read-only");
- }
-}
+ g_assert (GLADE_IS_PROJECT (project));
+
+ if (project->priv->readonly != readonly)
+ {
+ project->priv->readonly = readonly;
+ g_object_notify (G_OBJECT (project), "read-only");
+ }
+}
/**
@@ -3107,21 +3107,18 @@ glade_project_set_readonly (GladeProject *project, gboolean readonly)
*
*/
void
-glade_project_get_target_version (GladeProject *project,
- const gchar *catalog,
- gint *major,
- gint *minor)
+glade_project_get_target_version (GladeProject * project,
+ const gchar * catalog,
+ gint * major, gint * minor)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (catalog && catalog[0]);
- g_return_if_fail (major && minor);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (catalog && catalog[0]);
+ g_return_if_fail (major && minor);
- *major = GPOINTER_TO_INT
- (g_hash_table_lookup (project->priv->target_versions_major,
- catalog));
- *minor = GPOINTER_TO_INT
- (g_hash_table_lookup (project->priv->target_versions_minor,
- catalog));
+ *major = GPOINTER_TO_INT
+ (g_hash_table_lookup (project->priv->target_versions_major, catalog));
+ *minor = GPOINTER_TO_INT
+ (g_hash_table_lookup (project->priv->target_versions_minor, catalog));
}
/**
@@ -3133,11 +3130,11 @@ glade_project_get_target_version (GladeProject *project,
* Returns: TRUE if project is read only
*/
gboolean
-glade_project_get_readonly (GladeProject *project)
+glade_project_get_readonly (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- return project->priv->readonly;
+ return project->priv->readonly;
}
@@ -3148,24 +3145,23 @@ glade_project_get_readonly (GladeProject *project)
* Causes @project to emit a "selection_changed" signal.
*/
void
-glade_project_selection_changed (GladeProject *project)
+glade_project_selection_changed (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_signal_emit (G_OBJECT (project),
- glade_project_signals [SELECTION_CHANGED],
- 0);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_signal_emit (G_OBJECT (project),
+ glade_project_signals[SELECTION_CHANGED], 0);
}
static void
-glade_project_set_has_selection (GladeProject *project, gboolean has_selection)
+glade_project_set_has_selection (GladeProject * project, gboolean has_selection)
{
- g_assert (GLADE_IS_PROJECT (project));
+ g_assert (GLADE_IS_PROJECT (project));
- if (project->priv->has_selection != has_selection)
- {
- project->priv->has_selection = has_selection;
- g_object_notify (G_OBJECT (project), "has-selection");
- }
+ if (project->priv->has_selection != has_selection)
+ {
+ project->priv->has_selection = has_selection;
+ g_object_notify (G_OBJECT (project), "has-selection");
+ }
}
/**
@@ -3175,11 +3171,11 @@ glade_project_set_has_selection (GladeProject *project, gboolean has_selection)
* Returns: whether @project currently has a selection
*/
gboolean
-glade_project_get_has_selection (GladeProject *project)
+glade_project_get_has_selection (GladeProject * project)
{
- g_assert (GLADE_IS_PROJECT (project));
+ g_assert (GLADE_IS_PROJECT (project));
- return project->priv->has_selection;
+ return project->priv->has_selection;
}
/**
@@ -3190,11 +3186,10 @@ glade_project_get_has_selection (GladeProject *project)
* Returns: whether @object is in @project selection
*/
gboolean
-glade_project_is_selected (GladeProject *project,
- GObject *object)
+glade_project_is_selected (GladeProject * project, GObject * object)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- return (g_list_find (project->priv->selection, object)) != NULL;
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ return (g_list_find (project->priv->selection, object)) != NULL;
}
/**
@@ -3207,20 +3202,20 @@ glade_project_is_selected (GladeProject *project,
* If @emit_signal is %TRUE, calls glade_project_selection_changed().
*/
void
-glade_project_selection_clear (GladeProject *project, gboolean emit_signal)
+glade_project_selection_clear (GladeProject * project, gboolean emit_signal)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- if (project->priv->selection == NULL)
- return;
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ if (project->priv->selection == NULL)
+ return;
- glade_util_clear_selection ();
+ glade_util_clear_selection ();
- g_list_free (project->priv->selection);
- project->priv->selection = NULL;
- glade_project_set_has_selection (project, FALSE);
+ g_list_free (project->priv->selection);
+ project->priv->selection = NULL;
+ glade_project_set_has_selection (project, FALSE);
- if (emit_signal)
- glade_project_selection_changed (project);
+ if (emit_signal)
+ glade_project_selection_changed (project);
}
/**
@@ -3235,23 +3230,23 @@ glade_project_selection_clear (GladeProject *project, gboolean emit_signal)
* If @emit_signal is %TRUE, calls glade_project_selection_changed().
*/
void
-glade_project_selection_remove (GladeProject *project,
- GObject *object,
- gboolean emit_signal)
+glade_project_selection_remove (GladeProject * project,
+ GObject * object, gboolean emit_signal)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (G_IS_OBJECT (object));
- if (glade_project_is_selected (project, object))
- {
- if (GTK_IS_WIDGET (object))
- glade_util_remove_selection (GTK_WIDGET (object));
- project->priv->selection = g_list_remove (project->priv->selection, object);
- if (project->priv->selection == NULL)
- glade_project_set_has_selection (project, FALSE);
- if (emit_signal)
- glade_project_selection_changed (project);
- }
+ if (glade_project_is_selected (project, object))
+ {
+ if (GTK_IS_WIDGET (object))
+ glade_util_remove_selection (GTK_WIDGET (object));
+ project->priv->selection =
+ g_list_remove (project->priv->selection, object);
+ if (project->priv->selection == NULL)
+ glade_project_set_has_selection (project, FALSE);
+ if (emit_signal)
+ glade_project_selection_changed (project);
+ }
}
/**
@@ -3266,24 +3261,24 @@ glade_project_selection_remove (GladeProject *project,
* If @emit_signal is %TRUE, calls glade_project_selection_changed().
*/
void
-glade_project_selection_add (GladeProject *project,
- GObject *object,
- gboolean emit_signal)
-{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (g_list_find (project->priv->objects, object) != NULL);
-
- if (glade_project_is_selected (project, object) == FALSE)
- {
- if (GTK_IS_WIDGET (object))
- glade_util_add_selection (GTK_WIDGET (object));
- if (project->priv->selection == NULL)
- glade_project_set_has_selection (project, TRUE);
- project->priv->selection = g_list_prepend (project->priv->selection, object);
- if (emit_signal)
- glade_project_selection_changed (project);
- }
+glade_project_selection_add (GladeProject * project,
+ GObject * object, gboolean emit_signal)
+{
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (g_list_find (project->priv->objects, object) != NULL);
+
+ if (glade_project_is_selected (project, object) == FALSE)
+ {
+ if (GTK_IS_WIDGET (object))
+ glade_util_add_selection (GTK_WIDGET (object));
+ if (project->priv->selection == NULL)
+ glade_project_set_has_selection (project, TRUE);
+ project->priv->selection =
+ g_list_prepend (project->priv->selection, object);
+ if (emit_signal)
+ glade_project_selection_changed (project);
+ }
}
/**
@@ -3298,26 +3293,25 @@ glade_project_selection_add (GladeProject *project,
* If @emit_signal is %TRUE, calls glade_project_selection_changed().
*/
void
-glade_project_selection_set (GladeProject *project,
- GObject *object,
- gboolean emit_signal)
+glade_project_selection_set (GladeProject * project,
+ GObject * object, gboolean emit_signal)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (G_IS_OBJECT (object));
- if (g_list_find (project->priv->objects, object) == NULL)
- return;
+ if (g_list_find (project->priv->objects, object) == NULL)
+ return;
- if (project->priv->selection == NULL)
- glade_project_set_has_selection (project, TRUE);
+ if (project->priv->selection == NULL)
+ glade_project_set_has_selection (project, TRUE);
- if (glade_project_is_selected (project, object) == FALSE ||
- g_list_length (project->priv->selection) != 1)
- {
- glade_project_selection_clear (project, FALSE);
- glade_project_selection_add (project, object, emit_signal);
- }
-}
+ if (glade_project_is_selected (project, object) == FALSE ||
+ g_list_length (project->priv->selection) != 1)
+ {
+ glade_project_selection_clear (project, FALSE);
+ glade_project_selection_add (project, object, emit_signal);
+ }
+}
/**
* glade_project_selection_get:
@@ -3327,11 +3321,11 @@ glade_project_selection_set (GladeProject *project,
* @project
*/
GList *
-glade_project_selection_get (GladeProject *project)
+glade_project_selection_get (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- return project->priv->selection;
+ return project->priv->selection;
}
/**
@@ -3342,41 +3336,41 @@ glade_project_selection_get (GladeProject *project)
* of the required catalogs for this project
*/
GList *
-glade_project_required_libs (GladeProject *project)
+glade_project_required_libs (GladeProject * project)
{
- GList *required = NULL, *l, *ll;
- GladeWidget *gwidget;
- gboolean listed;
+ GList *required = NULL, *l, *ll;
+ GladeWidget *gwidget;
+ gboolean listed;
- for (l = project->priv->objects; l; l = l->next)
- {
- gchar *catalog = NULL;
+ for (l = project->priv->objects; l; l = l->next)
+ {
+ gchar *catalog = NULL;
- gwidget = glade_widget_get_from_gobject (l->data);
- g_assert (gwidget);
+ gwidget = glade_widget_get_from_gobject (l->data);
+ g_assert (gwidget);
- g_object_get (gwidget->adaptor, "catalog", &catalog, NULL);
+ g_object_get (gwidget->adaptor, "catalog", &catalog, NULL);
- if (catalog)
- {
- listed = FALSE;
- for (ll = required; ll; ll = ll->next)
- if (!strcmp ((gchar *)ll->data, catalog))
- {
- listed = TRUE;
- break;
- }
-
- if (!listed)
- required = g_list_prepend (required, catalog);
- }
- }
+ if (catalog)
+ {
+ listed = FALSE;
+ for (ll = required; ll; ll = ll->next)
+ if (!strcmp ((gchar *) ll->data, catalog))
+ {
+ listed = TRUE;
+ break;
+ }
+
+ if (!listed)
+ required = g_list_prepend (required, catalog);
+ }
+ }
- /* Assume GTK+ here */
- if (!required)
- required = g_list_prepend (required, g_strdup ("gtk+"));
+ /* Assume GTK+ here */
+ if (!required)
+ required = g_list_prepend (required, g_strdup ("gtk+"));
- return g_list_reverse (required);
+ return g_list_reverse (required);
}
/**
@@ -3386,10 +3380,10 @@ glade_project_required_libs (GladeProject *project)
* Undoes a #GladeCommand in this project.
*/
void
-glade_project_undo (GladeProject *project)
+glade_project_undo (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- GLADE_PROJECT_GET_CLASS (project)->undo (project);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ GLADE_PROJECT_GET_CLASS (project)->undo (project);
}
/**
@@ -3399,10 +3393,10 @@ glade_project_undo (GladeProject *project)
* Redoes a #GladeCommand in this project.
*/
void
-glade_project_redo (GladeProject *project)
+glade_project_redo (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- GLADE_PROJECT_GET_CLASS (project)->redo (project);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ GLADE_PROJECT_GET_CLASS (project)->redo (project);
}
/**
@@ -3414,10 +3408,10 @@ glade_project_redo (GladeProject *project)
* Returns: the #GladeCommand
*/
GladeCommand *
-glade_project_next_undo_item (GladeProject *project)
+glade_project_next_undo_item (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- return GLADE_PROJECT_GET_CLASS (project)->next_undo_item (project);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ return GLADE_PROJECT_GET_CLASS (project)->next_undo_item (project);
}
@@ -3430,10 +3424,10 @@ glade_project_next_undo_item (GladeProject *project)
* Returns: the #GladeCommand
*/
GladeCommand *
-glade_project_next_redo_item (GladeProject *project)
+glade_project_next_redo_item (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- return GLADE_PROJECT_GET_CLASS (project)->next_redo_item (project);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ return GLADE_PROJECT_GET_CLASS (project)->next_redo_item (project);
}
@@ -3446,82 +3440,81 @@ glade_project_next_redo_item (GladeProject *project)
* Pushes a newly created #GladeCommand onto @projects stack.
*/
void
-glade_project_push_undo (GladeProject *project, GladeCommand *cmd)
+glade_project_push_undo (GladeProject * project, GladeCommand * cmd)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GLADE_IS_COMMAND (cmd));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_COMMAND (cmd));
- GLADE_PROJECT_GET_CLASS (project)->push_undo (project, cmd);
+ GLADE_PROJECT_GET_CLASS (project)->push_undo (project, cmd);
}
static GList *
-walk_command (GList *list, gboolean forward)
+walk_command (GList * list, gboolean forward)
{
- GladeCommand *cmd = list->data;
- GladeCommand *next_cmd;
+ GladeCommand *cmd = list->data;
+ GladeCommand *next_cmd;
+
+ if (forward)
+ list = list->next;
+ else
+ list = list->prev;
+
+ next_cmd = list ? list->data : NULL;
- if (forward)
- list = list->next;
- else
- list = list->prev;
-
- next_cmd = list ? list->data : NULL;
-
- while (list && next_cmd->group_id != 0 &&
- next_cmd->group_id == cmd->group_id)
- {
- if (forward)
- list = list->next;
- else
- list = list->prev;
+ while (list && next_cmd->group_id != 0 && next_cmd->group_id == cmd->group_id)
+ {
+ if (forward)
+ list = list->next;
+ else
+ list = list->prev;
- if (list)
- next_cmd = list->data;
- }
+ if (list)
+ next_cmd = list->data;
+ }
- return list;
+ return list;
}
static void
-undo_item_activated (GtkMenuItem *item,
- GladeProject *project)
+undo_item_activated (GtkMenuItem * item, GladeProject * project)
{
- gint index, next_index;
-
- GladeCommand *cmd = g_object_get_data (G_OBJECT (item), "command-data");
- GladeCommand *next_cmd;
+ gint index, next_index;
- index = g_list_index (project->priv->undo_stack, cmd);
+ GladeCommand *cmd = g_object_get_data (G_OBJECT (item), "command-data");
+ GladeCommand *next_cmd;
- do
- {
- next_cmd = glade_project_next_undo_item (project);
- next_index = g_list_index (project->priv->undo_stack, next_cmd);
+ index = g_list_index (project->priv->undo_stack, cmd);
- glade_project_undo (project);
-
- } while (next_index > index);
+ do
+ {
+ next_cmd = glade_project_next_undo_item (project);
+ next_index = g_list_index (project->priv->undo_stack, next_cmd);
+
+ glade_project_undo (project);
+
+ }
+ while (next_index > index);
}
static void
-redo_item_activated (GtkMenuItem *item,
- GladeProject *project)
+redo_item_activated (GtkMenuItem * item, GladeProject * project)
{
- gint index, next_index;
-
- GladeCommand *cmd = g_object_get_data (G_OBJECT (item), "command-data");
- GladeCommand *next_cmd;
+ gint index, next_index;
+
+ GladeCommand *cmd = g_object_get_data (G_OBJECT (item), "command-data");
+ GladeCommand *next_cmd;
- index = g_list_index (project->priv->undo_stack, cmd);
+ index = g_list_index (project->priv->undo_stack, cmd);
- do
- {
- next_cmd = glade_project_next_redo_item (project);
- next_index = g_list_index (project->priv->undo_stack, next_cmd);
+ do
+ {
+ next_cmd = glade_project_next_redo_item (project);
+ next_index = g_list_index (project->priv->undo_stack, next_cmd);
- glade_project_redo (project);
-
- } while (next_index < index);
+ glade_project_redo (project);
+
+ }
+ while (next_index < index);
}
@@ -3534,32 +3527,33 @@ redo_item_activated (GtkMenuItem *item,
* Returns: A newly created menu
*/
GtkWidget *
-glade_project_undo_items (GladeProject *project)
+glade_project_undo_items (GladeProject * project)
{
- GtkWidget *menu = NULL;
- GtkWidget *item;
- GladeCommand *cmd;
- GList *l;
+ GtkWidget *menu = NULL;
+ GtkWidget *item;
+ GladeCommand *cmd;
+ GList *l;
+
+ g_return_val_if_fail (project != NULL, NULL);
- g_return_val_if_fail (project != NULL, NULL);
+ for (l = project->priv->prev_redo_item; l; l = walk_command (l, FALSE))
+ {
+ cmd = l->data;
- for (l = project->priv->prev_redo_item; l; l = walk_command (l, FALSE))
- {
- cmd = l->data;
+ if (!menu)
+ menu = gtk_menu_new ();
- if (!menu) menu = gtk_menu_new ();
-
- item = gtk_menu_item_new_with_label (cmd->description);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
- g_object_set_data (G_OBJECT (item), "command-data", cmd);
+ item = gtk_menu_item_new_with_label (cmd->description);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
+ g_object_set_data (G_OBJECT (item), "command-data", cmd);
- g_signal_connect (G_OBJECT (item), "activate",
- G_CALLBACK (undo_item_activated), project);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (undo_item_activated), project);
- }
-
- return menu;
+ }
+
+ return menu;
}
/**
@@ -3571,43 +3565,43 @@ glade_project_undo_items (GladeProject *project)
* Returns: A newly created menu
*/
GtkWidget *
-glade_project_redo_items (GladeProject *project)
+glade_project_redo_items (GladeProject * project)
{
- GtkWidget *menu = NULL;
- GtkWidget *item;
- GladeCommand *cmd;
- GList *l;
+ GtkWidget *menu = NULL;
+ GtkWidget *item;
+ GladeCommand *cmd;
+ GList *l;
+
+ g_return_val_if_fail (project != NULL, NULL);
+
+ for (l = project->priv->prev_redo_item ?
+ project->priv->prev_redo_item->next :
+ project->priv->undo_stack; l; l = walk_command (l, TRUE))
+ {
+ cmd = l->data;
- g_return_val_if_fail (project != NULL, NULL);
+ if (!menu)
+ menu = gtk_menu_new ();
- for (l = project->priv->prev_redo_item ?
- project->priv->prev_redo_item->next :
- project->priv->undo_stack;
- l; l = walk_command (l, TRUE))
- {
- cmd = l->data;
+ item = gtk_menu_item_new_with_label (cmd->description);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
+ g_object_set_data (G_OBJECT (item), "command-data", cmd);
- if (!menu) menu = gtk_menu_new ();
-
- item = gtk_menu_item_new_with_label (cmd->description);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
- g_object_set_data (G_OBJECT (item), "command-data", cmd);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (redo_item_activated), project);
- g_signal_connect (G_OBJECT (item), "activate",
- G_CALLBACK (redo_item_activated), project);
+ }
- }
-
- return menu;
+ return menu;
}
void
-glade_project_reset_path (GladeProject *project)
+glade_project_reset_path (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
- project->priv->path = (g_free (project->priv->path), NULL);
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ project->priv->path = (g_free (project->priv->path), NULL);
}
/**
@@ -3623,53 +3617,55 @@ glade_project_reset_path (GladeProject *project)
* local path the the project resource.
*/
gchar *
-glade_project_resource_fullpath (GladeProject *project,
- const gchar *resource)
+glade_project_resource_fullpath (GladeProject * project, const gchar * resource)
{
- gchar *fullpath, *project_dir = NULL, *basename;
+ gchar *fullpath, *project_dir = NULL, *basename;
+
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+
+ basename = g_path_get_basename (resource);
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ if (project->priv->path == NULL)
+ project_dir = g_get_current_dir ();
+ else
+ project_dir = g_path_get_dirname (project->priv->path);
- basename = g_path_get_basename (resource);
+ if (project->priv->resource_path)
+ {
+ if (g_path_is_absolute (project->priv->resource_path))
+ fullpath =
+ g_build_filename (project->priv->resource_path, basename, NULL);
+ else
+ fullpath =
+ g_build_filename (project_dir, project->priv->resource_path,
+ basename, NULL);
+ }
+ else
+ fullpath = g_build_filename (project_dir, basename, NULL);
- if (project->priv->path == NULL)
- project_dir = g_get_current_dir ();
- else
- project_dir = g_path_get_dirname (project->priv->path);
+ g_free (project_dir);
+ g_free (basename);
- if (project->priv->resource_path)
- {
- if (g_path_is_absolute (project->priv->resource_path))
- fullpath = g_build_filename (project->priv->resource_path, basename, NULL);
- else
- fullpath = g_build_filename (project_dir, project->priv->resource_path, basename, NULL);
- }
- else
- fullpath = g_build_filename (project_dir, basename, NULL);
-
- g_free (project_dir);
- g_free (basename);
-
- return fullpath;
+ return fullpath;
}
const gchar *
-glade_project_get_path (GladeProject *project)
+glade_project_get_path (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- return project->priv->path;
+ return project->priv->path;
}
gchar *
-glade_project_get_name (GladeProject *project)
+glade_project_get_name (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- if (project->priv->path)
- return g_filename_display_basename (project->priv->path);
- else
- return g_strdup_printf (_("Unsaved %i"), project->priv->unsaved_number);
+ if (project->priv->path)
+ return g_filename_display_basename (project->priv->path);
+ else
+ return g_strdup_printf (_("Unsaved %i"), project->priv->unsaved_number);
}
/**
@@ -3680,19 +3676,19 @@ glade_project_get_name (GladeProject *project)
*
*/
gboolean
-glade_project_is_loading (GladeProject *project)
+glade_project_is_loading (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
-
- return project->priv->loading;
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+
+ return project->priv->loading;
}
time_t
-glade_project_get_file_mtime (GladeProject *project)
+glade_project_get_file_mtime (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), 0);
-
- return project->priv->mtime;
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), 0);
+
+ return project->priv->mtime;
}
/**
@@ -3702,11 +3698,11 @@ glade_project_get_file_mtime (GladeProject *project)
* Returns: List of all objects in this project
*/
const GList *
-glade_project_get_objects (GladeProject *project)
+glade_project_get_objects (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- return project->priv->objects;
+ return project->priv->objects;
}
/**
@@ -3716,530 +3712,576 @@ glade_project_get_objects (GladeProject *project)
* Get's whether the project has been modified since it was last saved.
*
* Returns: #TRUE if the project has been modified since it was last saved
- */
+ */
gboolean
-glade_project_get_modified (GladeProject *project)
+glade_project_get_modified (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
- return project->priv->modified;
+ return project->priv->modified;
}
void
-glade_project_set_naming_policy (GladeProject *project,
- GladeNamingPolicy policy)
+glade_project_set_naming_policy (GladeProject * project,
+ GladeNamingPolicy policy)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- if (project->priv->naming_policy != policy)
- {
- adjust_naming_policy (project, policy);
+ if (project->priv->naming_policy != policy)
+ {
+ adjust_naming_policy (project, policy);
- /* Update the toggle button in the prefs dialog here: */
- g_signal_handlers_block_by_func (project->priv->project_wide_radio,
- G_CALLBACK (policy_project_wide_button_clicked), project);
- g_signal_handlers_block_by_func (project->priv->toplevel_contextual_radio,
- G_CALLBACK (policy_toplevel_contextual_button_clicked), project);
+ /* Update the toggle button in the prefs dialog here: */
+ g_signal_handlers_block_by_func (project->priv->project_wide_radio,
+ G_CALLBACK
+ (policy_project_wide_button_clicked),
+ project);
+ g_signal_handlers_block_by_func (project->priv->toplevel_contextual_radio,
+ G_CALLBACK
+ (policy_toplevel_contextual_button_clicked),
+ project);
- if (policy == GLADE_POLICY_PROJECT_WIDE)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->project_wide_radio), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->toplevel_contextual_radio), TRUE);
+ if (policy == GLADE_POLICY_PROJECT_WIDE)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->project_wide_radio),
+ TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->
+ toplevel_contextual_radio), TRUE);
- g_signal_handlers_unblock_by_func (project->priv->project_wide_radio,
- G_CALLBACK (policy_project_wide_button_clicked), project);
- g_signal_handlers_unblock_by_func (project->priv->toplevel_contextual_radio,
- G_CALLBACK (policy_toplevel_contextual_button_clicked), project);
+ g_signal_handlers_unblock_by_func (project->priv->project_wide_radio,
+ G_CALLBACK
+ (policy_project_wide_button_clicked),
+ project);
+ g_signal_handlers_unblock_by_func (project->priv->
+ toplevel_contextual_radio,
+ G_CALLBACK
+ (policy_toplevel_contextual_button_clicked),
+ project);
- }
+ }
}
gboolean
-glade_project_get_previewable (GladeProject *project)
+glade_project_get_previewable (GladeProject * project)
{
- return project->priv->previewable;
+ return project->priv->previewable;
}
GladeNamingPolicy
-glade_project_get_naming_policy (GladeProject *project)
+glade_project_get_naming_policy (GladeProject * project)
{
- g_return_val_if_fail (GLADE_IS_PROJECT (project), -1);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), -1);
- return project->priv->naming_policy;
+ return project->priv->naming_policy;
}
static gint
-count_objects_with_name (GladeProject *project,
- const gchar *name)
+count_objects_with_name (GladeProject * project, const gchar * name)
{
- GList *l;
- GladeWidget *widget;
- gint count = 0;
+ GList *l;
+ GladeWidget *widget;
+ gint count = 0;
- for (l = project->priv->objects; l; l = l->next)
- {
- widget = glade_widget_get_from_gobject (l->data);
- if (!strcmp (widget->name, name))
- count++;
- }
- return count;
+ for (l = project->priv->objects; l; l = l->next)
+ {
+ widget = glade_widget_get_from_gobject (l->data);
+ if (!strcmp (widget->name, name))
+ count++;
+ }
+ return count;
}
static void
-policy_project_wide_button_clicked (GtkWidget *widget,
- GladeProject *project)
+policy_project_wide_button_clicked (GtkWidget * widget, GladeProject * project)
{
- GList *l, *objects;
- GladeWidget *gwidget;
-
- /* The formatting here is only to avoid a string change in a stable series... */
- gchar *prj_name = glade_project_get_name (project);
- glade_command_push_group (_("Setting %s to use a %s naming policy"),
- prj_name, "project wide");
- g_free (prj_name);
-
- /* Uniquify names here before switching policy (so names undo) */
- objects = g_list_copy (project->priv->objects);
- for (l = g_list_last (objects); l; l = l->prev)
- {
- gwidget = glade_widget_get_from_gobject (l->data);
+ GList *l, *objects;
+ GladeWidget *gwidget;
- if (count_objects_with_name (project, gwidget->name) > 1)
- {
- GladeNameContext *context =
- name_context_by_widget (project, gwidget);
- gchar *new_name;
+ /* The formatting here is only to avoid a string change in a stable series... */
+ gchar *prj_name = glade_project_get_name (project);
+ glade_command_push_group (_("Setting %s to use a %s naming policy"),
+ prj_name, "project wide");
+ g_free (prj_name);
- if (context)
- new_name = glade_name_context_dual_new_name
- (context, project->priv->toplevel_names, gwidget->name);
- else
- new_name = glade_name_context_new_name (project->priv->toplevel_names, gwidget->name);
+ /* Uniquify names here before switching policy (so names undo) */
+ objects = g_list_copy (project->priv->objects);
+ for (l = g_list_last (objects); l; l = l->prev)
+ {
+ gwidget = glade_widget_get_from_gobject (l->data);
- glade_command_set_name (gwidget, new_name);
- }
- }
- g_list_free (objects);
+ if (count_objects_with_name (project, gwidget->name) > 1)
+ {
+ GladeNameContext *context = name_context_by_widget (project, gwidget);
+ gchar *new_name;
+
+ if (context)
+ new_name = glade_name_context_dual_new_name
+ (context, project->priv->toplevel_names, gwidget->name);
+ else
+ new_name =
+ glade_name_context_new_name (project->priv->toplevel_names,
+ gwidget->name);
+
+ glade_command_set_name (gwidget, new_name);
+ }
+ }
+ g_list_free (objects);
- glade_command_set_project_naming_policy (project, GLADE_POLICY_PROJECT_WIDE);
+ glade_command_set_project_naming_policy (project, GLADE_POLICY_PROJECT_WIDE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
}
static void
-policy_toplevel_contextual_button_clicked (GtkWidget *widget,
- GladeProject *project)
+policy_toplevel_contextual_button_clicked (GtkWidget * widget,
+ GladeProject * project)
{
- glade_command_set_project_naming_policy (project, GLADE_POLICY_TOPLEVEL_CONTEXTUAL);
+ glade_command_set_project_naming_policy (project,
+ GLADE_POLICY_TOPLEVEL_CONTEXTUAL);
}
static void
-target_button_clicked (GtkWidget *widget,
- GladeProject *project)
+target_button_clicked (GtkWidget * widget, GladeProject * project)
{
- GladeTargetableVersion *version =
- g_object_get_data (G_OBJECT (widget), "version");
- gchar *catalog =
- g_object_get_data (G_OBJECT (widget), "catalog");
+ GladeTargetableVersion *version =
+ g_object_get_data (G_OBJECT (widget), "version");
+ gchar *catalog = g_object_get_data (G_OBJECT (widget), "catalog");
- glade_project_set_target_version (project,
- catalog,
- version->major,
- version->minor);
+ glade_project_set_target_version (project,
+ catalog, version->major, version->minor);
}
static void
-verify_clicked (GtkWidget *button,
- GladeProject *project)
+verify_clicked (GtkWidget * button, GladeProject * project)
{
- if (glade_project_verify (project, FALSE))
- {
- gchar *name = glade_project_get_name (project);
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("Project %s has no deprecated widgets "
- "or version mismatches."),
- name);
- g_free (name);
- }
+ if (glade_project_verify (project, FALSE))
+ {
+ gchar *name = glade_project_get_name (project);
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Project %s has no deprecated widgets "
+ "or version mismatches."), name);
+ g_free (name);
+ }
}
static void
-resource_default_toggled (GtkWidget *widget,
- GladeProject *project)
+resource_default_toggled (GtkWidget * widget, GladeProject * project)
{
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- return;
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ return;
- glade_project_set_resource_path (project, NULL);
- gtk_widget_set_sensitive (project->priv->relative_path_entry, FALSE);
- gtk_widget_set_sensitive (project->priv->full_path_button, FALSE);
+ glade_project_set_resource_path (project, NULL);
+ gtk_widget_set_sensitive (project->priv->relative_path_entry, FALSE);
+ gtk_widget_set_sensitive (project->priv->full_path_button, FALSE);
}
static void
-resource_relative_toggled (GtkWidget *widget,
- GladeProject *project)
+resource_relative_toggled (GtkWidget * widget, GladeProject * project)
{
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- return;
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ return;
- gtk_widget_set_sensitive (project->priv->relative_path_entry, TRUE);
- gtk_widget_set_sensitive (project->priv->full_path_button, FALSE);
+ gtk_widget_set_sensitive (project->priv->relative_path_entry, TRUE);
+ gtk_widget_set_sensitive (project->priv->full_path_button, FALSE);
}
static void
-resource_fullpath_toggled (GtkWidget *widget,
- GladeProject *project)
+resource_fullpath_toggled (GtkWidget * widget, GladeProject * project)
{
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- return;
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ return;
- gtk_widget_set_sensitive (project->priv->relative_path_entry, FALSE);
- gtk_widget_set_sensitive (project->priv->full_path_button, TRUE);
+ gtk_widget_set_sensitive (project->priv->relative_path_entry, FALSE);
+ gtk_widget_set_sensitive (project->priv->full_path_button, TRUE);
}
static void
-resource_path_activated (GtkEntry *entry,
- GladeProject *project)
+resource_path_activated (GtkEntry * entry, GladeProject * project)
{
- const gchar *text = gtk_entry_get_text (entry);
+ const gchar *text = gtk_entry_get_text (entry);
- glade_project_set_resource_path (project, text ? g_strdup (text) : NULL);
+ glade_project_set_resource_path (project, text ? g_strdup (text) : NULL);
}
static void
-resource_full_path_set (GtkFileChooserButton *button,
- GladeProject *project)
+resource_full_path_set (GtkFileChooserButton * button, GladeProject * project)
{
- gchar *text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (button));
+ gchar *text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (button));
- glade_project_set_resource_path (project, text);
+ glade_project_set_resource_path (project, text);
}
static void
-update_prefs_for_resource_path (GladeProject *project)
-{
- gtk_widget_set_sensitive (project->priv->full_path_button, FALSE);
- gtk_widget_set_sensitive (project->priv->relative_path_entry, FALSE);
-
-
- g_signal_handlers_block_by_func (project->priv->resource_default_radio,
- G_CALLBACK (resource_default_toggled), project);
- g_signal_handlers_block_by_func (project->priv->resource_relative_radio,
- G_CALLBACK (resource_relative_toggled), project);
- g_signal_handlers_block_by_func (project->priv->resource_fullpath_radio,
- G_CALLBACK (resource_fullpath_toggled), project);
- g_signal_handlers_block_by_func (project->priv->relative_path_entry,
- G_CALLBACK (resource_path_activated), project);
-
- if (project->priv->resource_path == NULL)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->resource_default_radio), TRUE);
- else if (g_path_is_absolute (project->priv->resource_path))
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->resource_fullpath_radio), TRUE);
- gtk_widget_set_sensitive (project->priv->full_path_button, TRUE);
- }
- else
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->resource_relative_radio), TRUE);
- gtk_widget_set_sensitive (project->priv->relative_path_entry, TRUE);
- }
-
- gtk_entry_set_text (GTK_ENTRY (project->priv->relative_path_entry),
- project->priv->resource_path ? project->priv->resource_path : "");
-
- g_signal_handlers_unblock_by_func (project->priv->resource_default_radio,
- G_CALLBACK (resource_default_toggled), project);
- g_signal_handlers_unblock_by_func (project->priv->resource_relative_radio,
- G_CALLBACK (resource_relative_toggled), project);
- g_signal_handlers_unblock_by_func (project->priv->resource_fullpath_radio,
- G_CALLBACK (resource_fullpath_toggled), project);
- g_signal_handlers_unblock_by_func (project->priv->relative_path_entry,
- G_CALLBACK (resource_path_activated), project);
+update_prefs_for_resource_path (GladeProject * project)
+{
+ gtk_widget_set_sensitive (project->priv->full_path_button, FALSE);
+ gtk_widget_set_sensitive (project->priv->relative_path_entry, FALSE);
+
+
+ g_signal_handlers_block_by_func (project->priv->resource_default_radio,
+ G_CALLBACK (resource_default_toggled),
+ project);
+ g_signal_handlers_block_by_func (project->priv->resource_relative_radio,
+ G_CALLBACK (resource_relative_toggled),
+ project);
+ g_signal_handlers_block_by_func (project->priv->resource_fullpath_radio,
+ G_CALLBACK (resource_fullpath_toggled),
+ project);
+ g_signal_handlers_block_by_func (project->priv->relative_path_entry,
+ G_CALLBACK (resource_path_activated),
+ project);
+
+ if (project->priv->resource_path == NULL)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->resource_default_radio),
+ TRUE);
+ else if (g_path_is_absolute (project->priv->resource_path))
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->resource_fullpath_radio),
+ TRUE);
+ gtk_widget_set_sensitive (project->priv->full_path_button, TRUE);
+ }
+ else
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->resource_relative_radio),
+ TRUE);
+ gtk_widget_set_sensitive (project->priv->relative_path_entry, TRUE);
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (project->priv->relative_path_entry),
+ project->priv->resource_path ? project->priv->
+ resource_path : "");
+
+ g_signal_handlers_unblock_by_func (project->priv->resource_default_radio,
+ G_CALLBACK (resource_default_toggled),
+ project);
+ g_signal_handlers_unblock_by_func (project->priv->resource_relative_radio,
+ G_CALLBACK (resource_relative_toggled),
+ project);
+ g_signal_handlers_unblock_by_func (project->priv->resource_fullpath_radio,
+ G_CALLBACK (resource_fullpath_toggled),
+ project);
+ g_signal_handlers_unblock_by_func (project->priv->relative_path_entry,
+ G_CALLBACK (resource_path_activated),
+ project);
}
static GtkWidget *
-glade_project_build_prefs_box (GladeProject *project)
-{
- GtkWidget *main_box, *button;
- GtkWidget *vbox, *hbox, *frame;
- GtkWidget *target_radio, *active_radio;
- GtkWidget *label, *alignment;
- GList *list, *targets;
- gchar *string;
- GtkWidget *main_frame, *main_alignment;
- GtkSizeGroup *sizegroup1 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL),
- *sizegroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL),
- *sizegroup3 = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-
- main_frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (main_frame), GTK_SHADOW_NONE);
- main_alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
- main_box = gtk_vbox_new (FALSE, 0);
-
- gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 0, 0, 4, 0);
-
- gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
- gtk_container_add (GTK_CONTAINER (main_frame), main_alignment);
-
- /* Naming policy format */
- string = g_strdup_printf ("<b>%s</b>", _("Object names are unique:"));
- frame = gtk_frame_new (NULL);
- hbox = gtk_hbox_new (FALSE, 0);
- alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
-
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
-
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
-
- project->priv->project_wide_radio = gtk_radio_button_new_with_label (NULL, _("within the project"));
- project->priv->toplevel_contextual_radio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (project->priv->project_wide_radio), _("inside toplevels"));
-
- gtk_size_group_add_widget (sizegroup1, project->priv->project_wide_radio);
- gtk_size_group_add_widget (sizegroup2, project->priv->toplevel_contextual_radio);
-
- gtk_box_pack_start (GTK_BOX (hbox), project->priv->project_wide_radio, TRUE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), project->priv->toplevel_contextual_radio, TRUE, TRUE, 2);
-
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_container_add (GTK_CONTAINER (alignment), hbox);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 6);
-
- if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->project_wide_radio), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (project->priv->toplevel_contextual_radio), TRUE);
-
- g_signal_connect (G_OBJECT (project->priv->project_wide_radio), "clicked",
- G_CALLBACK (policy_project_wide_button_clicked), project);
-
- g_signal_connect (G_OBJECT (project->priv->toplevel_contextual_radio), "clicked",
- G_CALLBACK (policy_toplevel_contextual_button_clicked), project);
-
-
- /* Resource path */
- string = g_strdup_printf ("<b>%s</b>", _("Image resources are loaded locally:"));
- frame = gtk_frame_new (NULL);
- vbox = gtk_vbox_new (FALSE, 0);
- alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
-
- gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 2);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
- gtk_container_add (GTK_CONTAINER (alignment), vbox);
-
- /* Project directory... */
- project->priv->resource_default_radio = gtk_radio_button_new_with_label (NULL, _("From the project directory"));
- gtk_box_pack_start (GTK_BOX (vbox), project->priv->resource_default_radio, FALSE, FALSE, 0);
- gtk_size_group_add_widget (sizegroup3, project->priv->resource_default_radio);
-
- /* Project relative directory... */
- hbox = gtk_hbox_new (FALSE, 0);
- project->priv->resource_relative_radio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (project->priv->resource_default_radio), _("From a project relative directory"));
-
- gtk_box_pack_start (GTK_BOX (hbox), project->priv->resource_relative_radio, TRUE, TRUE, 0);
- project->priv->relative_path_entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), project->priv->relative_path_entry, FALSE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_size_group_add_widget (sizegroup3, hbox);
-
-
- /* fullpath directory... */
- hbox = gtk_hbox_new (FALSE, 0);
- project->priv->resource_fullpath_radio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (project->priv->resource_default_radio), _("From this directory"));
- gtk_box_pack_start (GTK_BOX (hbox), project->priv->resource_fullpath_radio, TRUE, TRUE, 0);
-
- project->priv->full_path_button = gtk_file_chooser_button_new (_("Choose a path to load image resources"),
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
- gtk_box_pack_start (GTK_BOX (hbox), project->priv->full_path_button, FALSE, TRUE, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_size_group_add_widget (sizegroup3, hbox);
-
- update_prefs_for_resource_path (project);
-
- g_signal_connect (G_OBJECT (project->priv->resource_default_radio), "toggled",
- G_CALLBACK (resource_default_toggled), project);
- g_signal_connect (G_OBJECT (project->priv->resource_relative_radio), "toggled",
- G_CALLBACK (resource_relative_toggled), project);
- g_signal_connect (G_OBJECT (project->priv->resource_fullpath_radio), "toggled",
- G_CALLBACK (resource_fullpath_toggled), project);
-
- g_signal_connect (G_OBJECT (project->priv->relative_path_entry), "activate",
- G_CALLBACK (resource_path_activated), project);
- g_signal_connect (G_OBJECT (project->priv->full_path_button), "file-set",
- G_CALLBACK (resource_full_path_set), project);
-
- /* Target versions */
- string = g_strdup_printf ("<b>%s</b>", _("Toolkit versions required:"));
- frame = gtk_frame_new (NULL);
- vbox = gtk_vbox_new (FALSE, 0);
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
-
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
-
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
-
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_container_add (GTK_CONTAINER (alignment), vbox);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 6);
-
- /* Add stuff to vbox */
- for (list = glade_app_get_catalogs (); list; list = list->next)
- {
- GladeCatalog *catalog = list->data;
- gint minor, major;
-
- /* Skip if theres only one option */
- if (g_list_length (glade_catalog_get_targets (catalog)) <= 1)
- continue;
-
- glade_project_get_target_version (project,
- glade_catalog_get_name (catalog),
- &major,
- &minor);
-
- /* Special case to mark GTK+ in upper case */
- if (strcmp (glade_catalog_get_name (catalog), "gtk+") == 0)
- label = gtk_label_new ("GTK+");
- else
- label = gtk_label_new (glade_catalog_get_name (catalog));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0F, 0.5F);
-
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 2);
- hbox = gtk_hbox_new (FALSE, 0);
-
- active_radio = NULL;
- target_radio = NULL;
-
- for (targets = glade_catalog_get_targets (catalog);
- targets; targets = targets->next)
- {
- GladeTargetableVersion *version = targets->data;
- gchar *name = g_strdup_printf ("%d.%d",
- version->major,
- version->minor);
-
- if (!target_radio)
- target_radio = gtk_radio_button_new_with_label (NULL, name);
- else
- target_radio =
- gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (target_radio), name);
- g_free (name);
-
- g_signal_connect (G_OBJECT (target_radio), "clicked",
- G_CALLBACK (target_button_clicked), project);
-
- g_object_set_data (G_OBJECT (target_radio), "version", version);
- g_object_set_data (G_OBJECT (target_radio), "catalog",
- (gchar *)glade_catalog_get_name (catalog));
-
- gtk_box_pack_end (GTK_BOX (hbox), target_radio, TRUE, TRUE, 2);
-
- if (major == version->major &&
- minor == version->minor)
- active_radio = target_radio;
-
- }
-
- if (active_radio)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_radio), TRUE);
- g_hash_table_insert (project->priv->target_radios,
- g_strdup (glade_catalog_get_name (catalog)),
- gtk_radio_button_get_group (GTK_RADIO_BUTTON (active_radio)));
- }
- else
- g_warning ("Corrupt catalog versions");
-
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
- }
-
- /* Run verify */
- hbox = gtk_hbox_new (FALSE, 2);
- button = gtk_button_new_from_stock (GTK_STOCK_EXECUTE);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (verify_clicked), project);
-
- label = gtk_label_new (_("Verify versions and deprecations:"));
-
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 4);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 4);
-
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
-
- gtk_widget_show_all (main_frame);
-
- return main_frame;
+glade_project_build_prefs_box (GladeProject * project)
+{
+ GtkWidget *main_box, *button;
+ GtkWidget *vbox, *hbox, *frame;
+ GtkWidget *target_radio, *active_radio;
+ GtkWidget *label, *alignment;
+ GList *list, *targets;
+ gchar *string;
+ GtkWidget *main_frame, *main_alignment;
+ GtkSizeGroup *sizegroup1 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL),
+ *sizegroup2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL),
+ *sizegroup3 = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+
+ main_frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (main_frame), GTK_SHADOW_NONE);
+ main_alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
+ main_box = gtk_vbox_new (FALSE, 0);
+
+ gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 0, 0, 4, 0);
+
+ gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
+ gtk_container_add (GTK_CONTAINER (main_frame), main_alignment);
+
+ /* Naming policy format */
+ string = g_strdup_printf ("<b>%s</b>", _("Object names are unique:"));
+ frame = gtk_frame_new (NULL);
+ hbox = gtk_hbox_new (FALSE, 0);
+ alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
+
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
+
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+
+ label = gtk_label_new (string);
+ g_free (string);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+ project->priv->project_wide_radio =
+ gtk_radio_button_new_with_label (NULL, _("within the project"));
+ project->priv->toplevel_contextual_radio =
+ gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
+ (project->priv->
+ project_wide_radio),
+ _("inside toplevels"));
+
+ gtk_size_group_add_widget (sizegroup1, project->priv->project_wide_radio);
+ gtk_size_group_add_widget (sizegroup2,
+ project->priv->toplevel_contextual_radio);
+
+ gtk_box_pack_start (GTK_BOX (hbox), project->priv->project_wide_radio, TRUE,
+ TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), project->priv->toplevel_contextual_radio,
+ TRUE, TRUE, 2);
+
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_container_add (GTK_CONTAINER (alignment), hbox);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 6);
+
+ if (project->priv->naming_policy == GLADE_POLICY_PROJECT_WIDE)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->project_wide_radio), TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (project->priv->toplevel_contextual_radio),
+ TRUE);
+
+ g_signal_connect (G_OBJECT (project->priv->project_wide_radio), "clicked",
+ G_CALLBACK (policy_project_wide_button_clicked), project);
+
+ g_signal_connect (G_OBJECT (project->priv->toplevel_contextual_radio),
+ "clicked",
+ G_CALLBACK (policy_toplevel_contextual_button_clicked),
+ project);
+
+
+ /* Resource path */
+ string =
+ g_strdup_printf ("<b>%s</b>", _("Image resources are loaded locally:"));
+ frame = gtk_frame_new (NULL);
+ vbox = gtk_vbox_new (FALSE, 0);
+ alignment = gtk_alignment_new (0.5F, 0.5F, 0.8F, 0.8F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ label = gtk_label_new (string);
+ g_free (string);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+ gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 2);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+ /* Project directory... */
+ project->priv->resource_default_radio =
+ gtk_radio_button_new_with_label (NULL, _("From the project directory"));
+ gtk_box_pack_start (GTK_BOX (vbox), project->priv->resource_default_radio,
+ FALSE, FALSE, 0);
+ gtk_size_group_add_widget (sizegroup3, project->priv->resource_default_radio);
+
+ /* Project relative directory... */
+ hbox = gtk_hbox_new (FALSE, 0);
+ project->priv->resource_relative_radio =
+ gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
+ (project->priv->
+ resource_default_radio),
+ _
+ ("From a project relative directory"));
+
+ gtk_box_pack_start (GTK_BOX (hbox), project->priv->resource_relative_radio,
+ TRUE, TRUE, 0);
+ project->priv->relative_path_entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), project->priv->relative_path_entry, FALSE,
+ TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (sizegroup3, hbox);
+
+
+ /* fullpath directory... */
+ hbox = gtk_hbox_new (FALSE, 0);
+ project->priv->resource_fullpath_radio =
+ gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
+ (project->priv->
+ resource_default_radio),
+ _("From this directory"));
+ gtk_box_pack_start (GTK_BOX (hbox), project->priv->resource_fullpath_radio,
+ TRUE, TRUE, 0);
+
+ project->priv->full_path_button =
+ gtk_file_chooser_button_new (_("Choose a path to load image resources"),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ gtk_box_pack_start (GTK_BOX (hbox), project->priv->full_path_button, FALSE,
+ TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_size_group_add_widget (sizegroup3, hbox);
+
+ update_prefs_for_resource_path (project);
+
+ g_signal_connect (G_OBJECT (project->priv->resource_default_radio), "toggled",
+ G_CALLBACK (resource_default_toggled), project);
+ g_signal_connect (G_OBJECT (project->priv->resource_relative_radio),
+ "toggled", G_CALLBACK (resource_relative_toggled), project);
+ g_signal_connect (G_OBJECT (project->priv->resource_fullpath_radio),
+ "toggled", G_CALLBACK (resource_fullpath_toggled), project);
+
+ g_signal_connect (G_OBJECT (project->priv->relative_path_entry), "activate",
+ G_CALLBACK (resource_path_activated), project);
+ g_signal_connect (G_OBJECT (project->priv->full_path_button), "file-set",
+ G_CALLBACK (resource_full_path_set), project);
+
+ /* Target versions */
+ string = g_strdup_printf ("<b>%s</b>", _("Toolkit versions required:"));
+ frame = gtk_frame_new (NULL);
+ vbox = gtk_vbox_new (FALSE, 0);
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 8, 0, 12, 0);
+
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+
+ label = gtk_label_new (string);
+ g_free (string);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ gtk_box_pack_start (GTK_BOX (main_box), frame, TRUE, TRUE, 6);
+
+ /* Add stuff to vbox */
+ for (list = glade_app_get_catalogs (); list; list = list->next)
+ {
+ GladeCatalog *catalog = list->data;
+ gint minor, major;
+
+ /* Skip if theres only one option */
+ if (g_list_length (glade_catalog_get_targets (catalog)) <= 1)
+ continue;
+
+ glade_project_get_target_version (project,
+ glade_catalog_get_name (catalog),
+ &major, &minor);
+
+ /* Special case to mark GTK+ in upper case */
+ if (strcmp (glade_catalog_get_name (catalog), "gtk+") == 0)
+ label = gtk_label_new ("GTK+");
+ else
+ label = gtk_label_new (glade_catalog_get_name (catalog));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0F, 0.5F);
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 2);
+ hbox = gtk_hbox_new (FALSE, 0);
+
+ active_radio = NULL;
+ target_radio = NULL;
+
+ for (targets = glade_catalog_get_targets (catalog);
+ targets; targets = targets->next)
+ {
+ GladeTargetableVersion *version = targets->data;
+ gchar *name = g_strdup_printf ("%d.%d",
+ version->major,
+ version->minor);
+
+ if (!target_radio)
+ target_radio = gtk_radio_button_new_with_label (NULL, name);
+ else
+ target_radio =
+ gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON (target_radio), name);
+ g_free (name);
+
+ g_signal_connect (G_OBJECT (target_radio), "clicked",
+ G_CALLBACK (target_button_clicked), project);
+
+ g_object_set_data (G_OBJECT (target_radio), "version", version);
+ g_object_set_data (G_OBJECT (target_radio), "catalog",
+ (gchar *) glade_catalog_get_name (catalog));
+
+ gtk_box_pack_end (GTK_BOX (hbox), target_radio, TRUE, TRUE, 2);
+
+ if (major == version->major && minor == version->minor)
+ active_radio = target_radio;
+
+ }
+
+ if (active_radio)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_radio), TRUE);
+ g_hash_table_insert (project->priv->target_radios,
+ g_strdup (glade_catalog_get_name (catalog)),
+ gtk_radio_button_get_group (GTK_RADIO_BUTTON
+ (active_radio)));
+ }
+ else
+ g_warning ("Corrupt catalog versions");
+
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
+ }
+
+ /* Run verify */
+ hbox = gtk_hbox_new (FALSE, 2);
+ button = gtk_button_new_from_stock (GTK_STOCK_EXECUTE);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (verify_clicked), project);
+
+ label = gtk_label_new (_("Verify versions and deprecations:"));
+
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 4);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 4);
+
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
+
+ gtk_widget_show_all (main_frame);
+
+ return main_frame;
}
static GtkWidget *
-glade_project_build_prefs_dialog (GladeProject *project)
+glade_project_build_prefs_dialog (GladeProject * project)
{
- GtkWidget *widget, *dialog;
- gchar *title, *name;
+ GtkWidget *widget, *dialog;
+ gchar *title, *name;
- name = glade_project_get_name (project);
- title = g_strdup_printf (_("%s preferences"), name);
+ name = glade_project_get_name (project);
+ title = g_strdup_printf (_("%s preferences"), name);
- dialog = gtk_dialog_new_with_buttons (title,
- GTK_WINDOW (glade_app_get_window ()),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_ACCEPT,
- NULL);
- g_free (title);
- g_free (name);
+ dialog = gtk_dialog_new_with_buttons (title,
+ GTK_WINDOW (glade_app_get_window ()),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_ACCEPT, NULL);
+ g_free (title);
+ g_free (name);
- widget = glade_project_build_prefs_box (project);
- gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- widget, TRUE, TRUE, 2);
+ widget = glade_project_build_prefs_box (project);
+ gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ widget, TRUE, TRUE, 2);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX
+ (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
- /* HIG spacings */
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 6);
+ /* HIG spacings */
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); /* 2 * 5 + 2 = 12 */
+ gtk_container_set_border_width (GTK_CONTAINER
+ (gtk_dialog_get_action_area
+ (GTK_DIALOG (dialog))), 5);
+ gtk_box_set_spacing (GTK_BOX
+ (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 6);
- /* Were explicitly destroying it anyway */
- g_signal_connect (G_OBJECT (dialog), "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+ /* Were explicitly destroying it anyway */
+ g_signal_connect (G_OBJECT (dialog), "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
- /* Only one action, used to "close" the dialog */
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (gtk_widget_hide), NULL);
+ /* Only one action, used to "close" the dialog */
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (gtk_widget_hide), NULL);
- return dialog;
+ return dialog;
}
/**
@@ -4249,486 +4291,463 @@ glade_project_build_prefs_dialog (GladeProject *project)
* Runs a preferences dialog for @project.
*/
void
-glade_project_preferences (GladeProject *project)
+glade_project_preferences (GladeProject * project)
{
- g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- gtk_window_present (GTK_WINDOW (project->priv->prefs_dialog));
+ gtk_window_present (GTK_WINDOW (project->priv->prefs_dialog));
}
gchar *
-glade_project_display_dependencies (GladeProject *project)
+glade_project_display_dependencies (GladeProject * project)
{
- GList *catalogs, *l;
- GString *string;
+ GList *catalogs, *l;
+ GString *string;
- g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
- string = g_string_new ("");
+ string = g_string_new ("");
- catalogs = glade_project_required_libs (project);
- for (l = catalogs; l; l = l->next)
- {
- gchar *catalog = l->data;
- gint major = 0, minor = 0;
+ catalogs = glade_project_required_libs (project);
+ for (l = catalogs; l; l = l->next)
+ {
+ gchar *catalog = l->data;
+ gint major = 0, minor = 0;
- glade_project_get_target_version (project, catalog, &major, &minor);
+ glade_project_get_target_version (project, catalog, &major, &minor);
- if (l != catalogs)
- g_string_append (string, ", ");
+ if (l != catalogs)
+ g_string_append (string, ", ");
- /* Capitalize GTK+ */
- if (strcmp (catalog, "gtk+") == 0)
- g_string_append_printf (string, "GTK+ >= %d.%d", major, minor);
- else if (major && minor)
- g_string_append_printf (string, "%s >= %d.%d", catalog, major, minor);
- else
- g_string_append_printf (string, "%s", catalog);
+ /* Capitalize GTK+ */
+ if (strcmp (catalog, "gtk+") == 0)
+ g_string_append_printf (string, "GTK+ >= %d.%d", major, minor);
+ else if (major && minor)
+ g_string_append_printf (string, "%s >= %d.%d", catalog, major, minor);
+ else
+ g_string_append_printf (string, "%s", catalog);
- g_free (catalog);
- }
- g_list_free (catalogs);
+ g_free (catalog);
+ }
+ g_list_free (catalogs);
- return g_string_free (string, FALSE);
+ return g_string_free (string, FALSE);
}
/* GtkTreeModel implementation */
static void
-glade_project_model_get_iter_for_object (GladeProject* project,
- GObject* object,
- GtkTreeIter* iter)
+glade_project_model_get_iter_for_object (GladeProject * project,
+ GObject * object, GtkTreeIter * iter)
{
- g_assert (object);
+ g_assert (object);
- iter->stamp = project->priv->stamp;
- iter->user_data = object;
+ iter->stamp = project->priv->stamp;
+ iter->user_data = object;
}
static GtkTreeModelFlags
-glade_project_model_get_flags (GtkTreeModel* model)
+glade_project_model_get_flags (GtkTreeModel * model)
{
- return 0;
+ return 0;
}
static gint
-glade_project_model_get_n_columns (GtkTreeModel* model)
+glade_project_model_get_n_columns (GtkTreeModel * model)
{
- return GLADE_PROJECT_MODEL_N_COLUMNS;
+ return GLADE_PROJECT_MODEL_N_COLUMNS;
}
static GType
-glade_project_model_get_column_type (GtkTreeModel* model,
- gint column)
-{
- switch (column)
- {
- case GLADE_PROJECT_MODEL_COLUMN_ICON_NAME:
- return G_TYPE_STRING;
- case GLADE_PROJECT_MODEL_COLUMN_NAME:
- return G_TYPE_STRING;
- case GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME:
- return G_TYPE_STRING;
- case GLADE_PROJECT_MODEL_COLUMN_OBJECT:
- return G_TYPE_OBJECT;
- case GLADE_PROJECT_MODEL_COLUMN_MISC:
- return G_TYPE_STRING;
- default:
- g_assert_not_reached();
- return G_TYPE_NONE;
- }
+glade_project_model_get_column_type (GtkTreeModel * model, gint column)
+{
+ switch (column)
+ {
+ case GLADE_PROJECT_MODEL_COLUMN_ICON_NAME:
+ return G_TYPE_STRING;
+ case GLADE_PROJECT_MODEL_COLUMN_NAME:
+ return G_TYPE_STRING;
+ case GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME:
+ return G_TYPE_STRING;
+ case GLADE_PROJECT_MODEL_COLUMN_OBJECT:
+ return G_TYPE_OBJECT;
+ case GLADE_PROJECT_MODEL_COLUMN_MISC:
+ return G_TYPE_STRING;
+ default:
+ g_assert_not_reached ();
+ return G_TYPE_NONE;
+ }
}
static gboolean
-glade_project_model_get_iter (GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkTreePath* path)
-{
- GladeProject* project = GLADE_PROJECT (model);
- gint* indices = gtk_tree_path_get_indices (path);
- gint depth = gtk_tree_path_get_depth (path);
- GladeWidget* widget;
- GObject* object;
-
- gint i;
- GList* parent;
-
- if ((parent = g_list_nth (project->priv->tree, indices[0])) != NULL)
- {
- object = parent->data;
- widget = glade_widget_get_from_gobject (object);
- }
- else
- {
- iter->stamp = 0;
- iter->user_data = NULL;
- return FALSE;
- }
-
- for (i = 1; i < depth; i++)
- {
- GList* children = glade_widget_get_children (widget);
- GList* node;
- if (!children)
- {
- iter->stamp = 0;
- iter->user_data = NULL;
- return FALSE;
- }
-
- node = g_list_nth (children, indices[i]);
-
- if (node)
- {
- object = G_OBJECT (node->data);
- }
- g_list_free (children);
-
- if (!node)
- {
- iter->stamp = 0;
- iter->user_data = NULL;
- return FALSE;
- }
-
- widget =
- glade_widget_get_from_gobject (object);
- }
-
- if (object)
- {
- glade_project_model_get_iter_for_object (project,
- object,
- iter);
- return TRUE;
- }
- else
- {
- iter->stamp = 0;
- iter->user_data = NULL;
- return FALSE;
- }
-}
-
-static GtkTreePath*
-glade_project_model_get_path (GtkTreeModel* model,
- GtkTreeIter* iter)
-{
- GladeProject* project = GLADE_PROJECT (model);
- GtkTreePath* path;
- GObject* object;
- GladeWidget* widget;
- GladeWidget* toplevel;
- GladeWidget* parent;
- GList* top;
-
- g_return_val_if_fail (VALID_ITER (project, iter), NULL);
-
- object = iter->user_data;
- widget = glade_widget_get_from_gobject (object);
- toplevel = glade_widget_get_toplevel (widget);
- parent = widget;
-
- path = gtk_tree_path_new ();
-
- while ((parent = glade_widget_get_parent (widget)) != NULL)
- {
- GList* children = glade_widget_get_children (parent);
- GList* child = g_list_find (children, glade_widget_get_object (widget));
-
- if (!child)
- gtk_tree_path_prepend_index (path,
- 0);
- else
- gtk_tree_path_prepend_index (path,
- g_list_position (children, child));
-
- g_list_free (children);
- widget = parent;
- }
-
- /* Get the index for the top-level list */
- top = g_list_find (project->priv->tree,
- glade_widget_get_object (toplevel));
- g_assert (top != NULL);
- gtk_tree_path_prepend_index (path, g_list_position (project->priv->tree,
- top));
-
- return path;
+glade_project_model_get_iter (GtkTreeModel * model,
+ GtkTreeIter * iter, GtkTreePath * path)
+{
+ GladeProject *project = GLADE_PROJECT (model);
+ gint *indices = gtk_tree_path_get_indices (path);
+ gint depth = gtk_tree_path_get_depth (path);
+ GladeWidget *widget;
+ GObject *object;
+
+ gint i;
+ GList *parent;
+
+ if ((parent = g_list_nth (project->priv->tree, indices[0])) != NULL)
+ {
+ object = parent->data;
+ widget = glade_widget_get_from_gobject (object);
+ }
+ else
+ {
+ iter->stamp = 0;
+ iter->user_data = NULL;
+ return FALSE;
+ }
+
+ for (i = 1; i < depth; i++)
+ {
+ GList *children = glade_widget_get_children (widget);
+ GList *node;
+ if (!children)
+ {
+ iter->stamp = 0;
+ iter->user_data = NULL;
+ return FALSE;
+ }
+
+ node = g_list_nth (children, indices[i]);
+
+ if (node)
+ {
+ object = G_OBJECT (node->data);
+ }
+ g_list_free (children);
+
+ if (!node)
+ {
+ iter->stamp = 0;
+ iter->user_data = NULL;
+ return FALSE;
+ }
+
+ widget = glade_widget_get_from_gobject (object);
+ }
+
+ if (object)
+ {
+ glade_project_model_get_iter_for_object (project, object, iter);
+ return TRUE;
+ }
+ else
+ {
+ iter->stamp = 0;
+ iter->user_data = NULL;
+ return FALSE;
+ }
+}
+
+static GtkTreePath *
+glade_project_model_get_path (GtkTreeModel * model, GtkTreeIter * iter)
+{
+ GladeProject *project = GLADE_PROJECT (model);
+ GtkTreePath *path;
+ GObject *object;
+ GladeWidget *widget;
+ GladeWidget *toplevel;
+ GladeWidget *parent;
+ GList *top;
+
+ g_return_val_if_fail (VALID_ITER (project, iter), NULL);
+
+ object = iter->user_data;
+ widget = glade_widget_get_from_gobject (object);
+ toplevel = glade_widget_get_toplevel (widget);
+ parent = widget;
+
+ path = gtk_tree_path_new ();
+
+ while ((parent = glade_widget_get_parent (widget)) != NULL)
+ {
+ GList *children = glade_widget_get_children (parent);
+ GList *child = g_list_find (children, glade_widget_get_object (widget));
+
+ if (!child)
+ gtk_tree_path_prepend_index (path, 0);
+ else
+ gtk_tree_path_prepend_index (path, g_list_position (children, child));
+
+ g_list_free (children);
+ widget = parent;
+ }
+
+ /* Get the index for the top-level list */
+ top = g_list_find (project->priv->tree, glade_widget_get_object (toplevel));
+ g_assert (top != NULL);
+ gtk_tree_path_prepend_index (path, g_list_position (project->priv->tree,
+ top));
+
+ return path;
}
static void
-glade_project_model_get_value (GtkTreeModel* model,
- GtkTreeIter* iter,
- gint column,
- GValue* value)
-{
- GObject* object;
- GladeWidget* widget;
- gchar *str = NULL, *child_type;
-
- g_return_if_fail (VALID_ITER (model, iter));
-
- object = iter->user_data;
- widget = glade_widget_get_from_gobject (object);
-
- value = g_value_init (value,
- glade_project_model_get_column_type (model, column));
-
- switch (column)
- {
- case GLADE_PROJECT_MODEL_COLUMN_ICON_NAME:
- g_object_get (widget->adaptor, "icon-name", &str, NULL);
- g_value_take_string (value, str);
- break;
- case GLADE_PROJECT_MODEL_COLUMN_NAME:
- g_value_set_string (value,
- glade_widget_get_name (widget));
- break;
- case GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME:
- g_value_set_static_string (value,
- G_OBJECT_TYPE_NAME(object));
- break;
- case GLADE_PROJECT_MODEL_COLUMN_OBJECT:
- g_value_set_object (value, object);
- break;
- case GLADE_PROJECT_MODEL_COLUMN_MISC:
- /* special child type / internal child */
- if (glade_widget_get_internal (widget) != NULL)
- str = g_strdup_printf (_("(internal %s)"),
- glade_widget_get_internal (widget));
- else if ((child_type = g_object_get_data (glade_widget_get_object (widget),
- "special-child-type")) != NULL)
- str = g_strdup_printf (_("(%s child)"), child_type);
-
- g_value_take_string (value, str);
- break;
- default:
- g_assert_not_reached();
- }
+glade_project_model_get_value (GtkTreeModel * model,
+ GtkTreeIter * iter, gint column, GValue * value)
+{
+ GObject *object;
+ GladeWidget *widget;
+ gchar *str = NULL, *child_type;
+
+ g_return_if_fail (VALID_ITER (model, iter));
+
+ object = iter->user_data;
+ widget = glade_widget_get_from_gobject (object);
+
+ value = g_value_init (value,
+ glade_project_model_get_column_type (model, column));
+
+ switch (column)
+ {
+ case GLADE_PROJECT_MODEL_COLUMN_ICON_NAME:
+ g_object_get (widget->adaptor, "icon-name", &str, NULL);
+ g_value_take_string (value, str);
+ break;
+ case GLADE_PROJECT_MODEL_COLUMN_NAME:
+ g_value_set_string (value, glade_widget_get_name (widget));
+ break;
+ case GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME:
+ g_value_set_static_string (value, G_OBJECT_TYPE_NAME (object));
+ break;
+ case GLADE_PROJECT_MODEL_COLUMN_OBJECT:
+ g_value_set_object (value, object);
+ break;
+ case GLADE_PROJECT_MODEL_COLUMN_MISC:
+ /* special child type / internal child */
+ if (glade_widget_get_internal (widget) != NULL)
+ str = g_strdup_printf (_("(internal %s)"),
+ glade_widget_get_internal (widget));
+ else if ((child_type =
+ g_object_get_data (glade_widget_get_object (widget),
+ "special-child-type")) != NULL)
+ str = g_strdup_printf (_("(%s child)"), child_type);
+
+ g_value_take_string (value, str);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
}
static gboolean
-glade_project_model_iter_next (GtkTreeModel* model,
- GtkTreeIter* iter)
-{
- GladeProject* project = GLADE_PROJECT (model);
- GObject* object = iter->user_data;
- GladeWidget* widget;
- GladeWidget* parent;
- GList* children;
- GList* child;
- GList* next;
- gboolean retval = FALSE;
-
- g_return_val_if_fail (VALID_ITER (project, iter), FALSE);
-
- widget = glade_widget_get_from_gobject (object);
- parent = glade_widget_get_parent (widget);
-
- if (parent)
- {
- children = glade_widget_get_children(parent);
- }
- else
- {
- children = project->priv->tree;
- }
-
- child = g_list_find (children, object);
- if (child)
- {
- next = g_list_next (child);
- if (next)
- {
- glade_project_model_get_iter_for_object (project,
- next->data,
- iter);
- retval = TRUE;
- }
- }
- if (children != project->priv->tree)
- g_list_free (children);
-
- return retval;
+glade_project_model_iter_next (GtkTreeModel * model, GtkTreeIter * iter)
+{
+ GladeProject *project = GLADE_PROJECT (model);
+ GObject *object = iter->user_data;
+ GladeWidget *widget;
+ GladeWidget *parent;
+ GList *children;
+ GList *child;
+ GList *next;
+ gboolean retval = FALSE;
+
+ g_return_val_if_fail (VALID_ITER (project, iter), FALSE);
+
+ widget = glade_widget_get_from_gobject (object);
+ parent = glade_widget_get_parent (widget);
+
+ if (parent)
+ {
+ children = glade_widget_get_children (parent);
+ }
+ else
+ {
+ children = project->priv->tree;
+ }
+
+ child = g_list_find (children, object);
+ if (child)
+ {
+ next = g_list_next (child);
+ if (next)
+ {
+ glade_project_model_get_iter_for_object (project, next->data, iter);
+ retval = TRUE;
+ }
+ }
+ if (children != project->priv->tree)
+ g_list_free (children);
+
+ return retval;
}
static gboolean
-glade_project_model_iter_has_child (GtkTreeModel* model,
- GtkTreeIter* iter)
+glade_project_model_iter_has_child (GtkTreeModel * model, GtkTreeIter * iter)
{
- GladeWidget* widget;
- GList* children;
+ GladeWidget *widget;
+ GList *children;
- g_return_val_if_fail (VALID_ITER (model, iter), FALSE);
+ g_return_val_if_fail (VALID_ITER (model, iter), FALSE);
- widget = glade_widget_get_from_gobject (iter->user_data);
- children = glade_widget_get_children(widget);
+ widget = glade_widget_get_from_gobject (iter->user_data);
+ children = glade_widget_get_children (widget);
- if (children != NULL)
- {
- g_list_free (children);
- return TRUE;
- }
- return FALSE;
+ if (children != NULL)
+ {
+ g_list_free (children);
+ return TRUE;
+ }
+ return FALSE;
}
static gint
-glade_project_model_iter_n_children (GtkTreeModel* model,
- GtkTreeIter* iter)
+glade_project_model_iter_n_children (GtkTreeModel * model, GtkTreeIter * iter)
{
- GladeProject* project = GLADE_PROJECT (model);
+ GladeProject *project = GLADE_PROJECT (model);
- g_return_val_if_fail (iter == NULL || VALID_ITER (project, iter), 0);
+ g_return_val_if_fail (iter == NULL || VALID_ITER (project, iter), 0);
- if (iter)
- {
- GladeWidget* widget = glade_widget_get_from_gobject (iter->user_data);
- GList* children = glade_widget_get_children(widget);
- if (children)
- {
- gint n = g_list_length (children);
- g_list_free (children);
- return n;
- }
- }
- else
- return g_list_length (project->priv->tree);
- return 0;
+ if (iter)
+ {
+ GladeWidget *widget = glade_widget_get_from_gobject (iter->user_data);
+ GList *children = glade_widget_get_children (widget);
+ if (children)
+ {
+ gint n = g_list_length (children);
+ g_list_free (children);
+ return n;
+ }
+ }
+ else
+ return g_list_length (project->priv->tree);
+ return 0;
}
static gboolean
-glade_project_model_iter_nth_child (GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkTreeIter* parent,
- gint n)
-{
- GladeProject* project = GLADE_PROJECT (model);
- GList* children;
-
- g_return_val_if_fail (parent == NULL || VALID_ITER (project, parent), FALSE);
-
- if (parent != NULL)
- {
- GObject* object = parent->user_data;
- GladeWidget* widget = glade_widget_get_from_gobject (object);
- children = glade_widget_get_children(widget);
- }
- else
- {
- children = project->priv->tree;
- }
-
- if (children)
- {
- gboolean retval = FALSE;
- GList* child = g_list_nth (children, n);
- if (child)
- {
- glade_project_model_get_iter_for_object (project,
- child->data,
- iter);
- retval = TRUE;
- }
- else
- {
- iter->stamp = 0;
- iter->user_data = NULL;
- }
-
- if (children != project->priv->tree)
- g_list_free (children);
-
- return retval;
- }
-
- iter->stamp = 0;
- iter->user_data = NULL;
-
- return FALSE;
+glade_project_model_iter_nth_child (GtkTreeModel * model,
+ GtkTreeIter * iter,
+ GtkTreeIter * parent, gint n)
+{
+ GladeProject *project = GLADE_PROJECT (model);
+ GList *children;
+
+ g_return_val_if_fail (parent == NULL || VALID_ITER (project, parent), FALSE);
+
+ if (parent != NULL)
+ {
+ GObject *object = parent->user_data;
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ children = glade_widget_get_children (widget);
+ }
+ else
+ {
+ children = project->priv->tree;
+ }
+
+ if (children)
+ {
+ gboolean retval = FALSE;
+ GList *child = g_list_nth (children, n);
+ if (child)
+ {
+ glade_project_model_get_iter_for_object (project, child->data, iter);
+ retval = TRUE;
+ }
+ else
+ {
+ iter->stamp = 0;
+ iter->user_data = NULL;
+ }
+
+ if (children != project->priv->tree)
+ g_list_free (children);
+
+ return retval;
+ }
+
+ iter->stamp = 0;
+ iter->user_data = NULL;
+
+ return FALSE;
}
static gboolean
-glade_project_model_iter_children (GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkTreeIter* parent)
-{
- GladeProject* project = GLADE_PROJECT (model);
-
- g_return_val_if_fail (parent == NULL || VALID_ITER (project, parent), FALSE);
-
- if (parent)
- {
- GladeWidget* widget = glade_widget_get_from_gobject (parent->user_data);
- GList* children = glade_widget_get_children (widget);
-
- if (children)
- {
- glade_project_model_get_iter_for_object (project,
- G_OBJECT(children->data),
- iter);
- g_list_free (children);
- return TRUE;
- }
- }
- else
- {
- if (project->priv->tree)
- {
- glade_project_model_get_iter_for_object (project,
- G_OBJECT(project->priv->tree->data),
- iter);
- return TRUE;
- }
- }
-
- iter->stamp = 0;
- iter->user_data = NULL;
- return FALSE;
+glade_project_model_iter_children (GtkTreeModel * model,
+ GtkTreeIter * iter, GtkTreeIter * parent)
+{
+ GladeProject *project = GLADE_PROJECT (model);
+
+ g_return_val_if_fail (parent == NULL || VALID_ITER (project, parent), FALSE);
+
+ if (parent)
+ {
+ GladeWidget *widget = glade_widget_get_from_gobject (parent->user_data);
+ GList *children = glade_widget_get_children (widget);
+
+ if (children)
+ {
+ glade_project_model_get_iter_for_object (project,
+ G_OBJECT (children->data),
+ iter);
+ g_list_free (children);
+ return TRUE;
+ }
+ }
+ else
+ {
+ if (project->priv->tree)
+ {
+ glade_project_model_get_iter_for_object (project,
+ G_OBJECT (project->priv->
+ tree->data), iter);
+ return TRUE;
+ }
+ }
+
+ iter->stamp = 0;
+ iter->user_data = NULL;
+ return FALSE;
}
static gboolean
-glade_project_model_iter_parent (GtkTreeModel* model,
- GtkTreeIter* iter,
- GtkTreeIter* child)
+glade_project_model_iter_parent (GtkTreeModel * model,
+ GtkTreeIter * iter, GtkTreeIter * child)
{
- GladeProject* project = GLADE_PROJECT (model);
- GladeWidget* widget;
- GladeWidget* parent;
+ GladeProject *project = GLADE_PROJECT (model);
+ GladeWidget *widget;
+ GladeWidget *parent;
- g_return_val_if_fail (VALID_ITER (project, child), FALSE);
+ g_return_val_if_fail (VALID_ITER (project, child), FALSE);
- widget = glade_widget_get_from_gobject (child->user_data);
- parent = glade_widget_get_parent (widget);
+ widget = glade_widget_get_from_gobject (child->user_data);
+ parent = glade_widget_get_parent (widget);
- if (parent)
- {
- glade_project_model_get_iter_for_object (project,
- glade_widget_get_object (parent),
- iter);
- return TRUE;
- }
+ if (parent)
+ {
+ glade_project_model_get_iter_for_object (project,
+ glade_widget_get_object (parent),
+ iter);
+ return TRUE;
+ }
- iter->stamp = 0;
- iter->user_data = NULL;
+ iter->stamp = 0;
+ iter->user_data = NULL;
- return FALSE;
+ return FALSE;
}
static void
-gtk_tree_model_iface_init (GtkTreeModelIface* iface)
-{
- iface->get_flags = glade_project_model_get_flags;
- iface->get_column_type = glade_project_model_get_column_type;
- iface->get_n_columns = glade_project_model_get_n_columns;
- iface->get_iter = glade_project_model_get_iter;
- iface->get_path = glade_project_model_get_path;
- iface->get_value = glade_project_model_get_value;
- iface->iter_next = glade_project_model_iter_next;
- iface->iter_children = glade_project_model_iter_children;
- iface->iter_has_child = glade_project_model_iter_has_child;
- iface->iter_n_children = glade_project_model_iter_n_children;
- iface->iter_nth_child = glade_project_model_iter_nth_child;
- iface->iter_parent = glade_project_model_iter_parent;
+gtk_tree_model_iface_init (GtkTreeModelIface * iface)
+{
+ iface->get_flags = glade_project_model_get_flags;
+ iface->get_column_type = glade_project_model_get_column_type;
+ iface->get_n_columns = glade_project_model_get_n_columns;
+ iface->get_iter = glade_project_model_get_iter;
+ iface->get_path = glade_project_model_get_path;
+ iface->get_value = glade_project_model_get_value;
+ iface->iter_next = glade_project_model_iter_next;
+ iface->iter_children = glade_project_model_iter_children;
+ iface->iter_has_child = glade_project_model_iter_has_child;
+ iface->iter_n_children = glade_project_model_iter_n_children;
+ iface->iter_nth_child = glade_project_model_iter_nth_child;
+ iface->iter_parent = glade_project_model_iter_parent;
}
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index 41b03e0..59e5f09 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_PROJECT_H__
#define __GLADE_PROJECT_H__
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index 44863f6..fd4f44f 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -67,44 +66,44 @@
GladePropertyClass *
glade_property_class_new (gpointer handle)
{
- GladePropertyClass *property_class;
-
- property_class = g_new0 (GladePropertyClass, 1);
- property_class->handle = handle;
- property_class->pspec = NULL;
- property_class->id = NULL;
- property_class->name = NULL;
- property_class->tooltip = NULL;
- property_class->def = NULL;
- property_class->orig_def = NULL;
- property_class->parameters = NULL;
- property_class->query = FALSE;
- property_class->optional = FALSE;
- property_class->optional_default = FALSE;
- property_class->is_modified = FALSE;
- property_class->common = FALSE;
- property_class->packing = FALSE;
- property_class->atk = FALSE;
- property_class->visible = TRUE;
- property_class->custom_layout = FALSE;
- property_class->save = TRUE;
- property_class->save_always = FALSE;
- property_class->ignore = FALSE;
- property_class->needs_sync = FALSE;
- property_class->themed_icon = FALSE;
- property_class->stock = FALSE;
- property_class->stock_icon = FALSE;
- property_class->translatable = FALSE;
- property_class->virt = TRUE;
- property_class->transfer_on_paste = FALSE;
- property_class->weight = -1.0;
- property_class->parentless_widget = FALSE;
-
- /* Initialize them to the base version */
- property_class->version_since_major = GWA_VERSION_SINCE_MAJOR (handle);
- property_class->version_since_minor = GWA_VERSION_SINCE_MINOR (handle);
-
- return property_class;
+ GladePropertyClass *property_class;
+
+ property_class = g_new0 (GladePropertyClass, 1);
+ property_class->handle = handle;
+ property_class->pspec = NULL;
+ property_class->id = NULL;
+ property_class->name = NULL;
+ property_class->tooltip = NULL;
+ property_class->def = NULL;
+ property_class->orig_def = NULL;
+ property_class->parameters = NULL;
+ property_class->query = FALSE;
+ property_class->optional = FALSE;
+ property_class->optional_default = FALSE;
+ property_class->is_modified = FALSE;
+ property_class->common = FALSE;
+ property_class->packing = FALSE;
+ property_class->atk = FALSE;
+ property_class->visible = TRUE;
+ property_class->custom_layout = FALSE;
+ property_class->save = TRUE;
+ property_class->save_always = FALSE;
+ property_class->ignore = FALSE;
+ property_class->needs_sync = FALSE;
+ property_class->themed_icon = FALSE;
+ property_class->stock = FALSE;
+ property_class->stock_icon = FALSE;
+ property_class->translatable = FALSE;
+ property_class->virt = TRUE;
+ property_class->transfer_on_paste = FALSE;
+ property_class->weight = -1.0;
+ property_class->parentless_widget = FALSE;
+
+ /* Initialize them to the base version */
+ property_class->version_since_major = GWA_VERSION_SINCE_MAJOR (handle);
+ property_class->version_since_minor = GWA_VERSION_SINCE_MINOR (handle);
+
+ return property_class;
}
/**
@@ -114,50 +113,49 @@ glade_property_class_new (gpointer handle)
* Returns: a new #GladePropertyClass cloned from @property_class
*/
GladePropertyClass *
-glade_property_class_clone (GladePropertyClass *property_class)
+glade_property_class_clone (GladePropertyClass * property_class)
{
- GladePropertyClass *clone;
-
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property_class), NULL);
-
- clone = g_new0 (GladePropertyClass, 1);
-
- /* copy ints over */
- memcpy (clone, property_class, sizeof(GladePropertyClass));
-
- /* Make sure we own our strings */
- clone->pspec = property_class->pspec;
- clone->id = g_strdup (clone->id);
- clone->name = g_strdup (clone->name);
- clone->tooltip = g_strdup (clone->tooltip);
-
- if (G_IS_VALUE (property_class->def))
- {
- clone->def = g_new0 (GValue, 1);
- g_value_init (clone->def, property_class->pspec->value_type);
- g_value_copy (property_class->def, clone->def);
- }
-
- if (G_IS_VALUE (property_class->orig_def))
- {
- clone->orig_def = g_new0 (GValue, 1);
- g_value_init (clone->orig_def, property_class->pspec->value_type);
- g_value_copy (property_class->orig_def, clone->orig_def);
- }
-
- if (clone->parameters)
- {
- GList *parameter;
-
- clone->parameters = g_list_copy (clone->parameters);
-
- for (parameter = clone->parameters;
- parameter != NULL;
- parameter = parameter->next)
- parameter->data =
- glade_parameter_clone ((GladeParameter*) parameter->data);
- }
- return clone;
+ GladePropertyClass *clone;
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (property_class), NULL);
+
+ clone = g_new0 (GladePropertyClass, 1);
+
+ /* copy ints over */
+ memcpy (clone, property_class, sizeof (GladePropertyClass));
+
+ /* Make sure we own our strings */
+ clone->pspec = property_class->pspec;
+ clone->id = g_strdup (clone->id);
+ clone->name = g_strdup (clone->name);
+ clone->tooltip = g_strdup (clone->tooltip);
+
+ if (G_IS_VALUE (property_class->def))
+ {
+ clone->def = g_new0 (GValue, 1);
+ g_value_init (clone->def, property_class->pspec->value_type);
+ g_value_copy (property_class->def, clone->def);
+ }
+
+ if (G_IS_VALUE (property_class->orig_def))
+ {
+ clone->orig_def = g_new0 (GValue, 1);
+ g_value_init (clone->orig_def, property_class->pspec->value_type);
+ g_value_copy (property_class->orig_def, clone->orig_def);
+ }
+
+ if (clone->parameters)
+ {
+ GList *parameter;
+
+ clone->parameters = g_list_copy (clone->parameters);
+
+ for (parameter = clone->parameters;
+ parameter != NULL; parameter = parameter->next)
+ parameter->data =
+ glade_parameter_clone ((GladeParameter *) parameter->data);
+ }
+ return clone;
}
/**
@@ -167,151 +165,159 @@ glade_property_class_clone (GladePropertyClass *property_class)
* Frees @klass and its associated memory.
*/
void
-glade_property_class_free (GladePropertyClass *property_class)
+glade_property_class_free (GladePropertyClass * property_class)
{
- if (property_class == NULL)
- return;
-
- g_return_if_fail (GLADE_IS_PROPERTY_CLASS (property_class));
-
- g_free (property_class->id);
- g_free (property_class->tooltip);
- g_free (property_class->name);
- if (property_class->orig_def)
- {
- if (G_VALUE_TYPE (property_class->orig_def) != 0)
- g_value_unset (property_class->orig_def);
- g_free (property_class->orig_def);
- }
- if (property_class->def)
- {
- if (G_VALUE_TYPE (property_class->def) != 0)
- g_value_unset (property_class->def);
- g_free (property_class->def);
- }
- g_list_foreach (property_class->parameters, (GFunc) glade_parameter_free, NULL);
- g_list_free (property_class->parameters);
- g_free (property_class);
+ if (property_class == NULL)
+ return;
+
+ g_return_if_fail (GLADE_IS_PROPERTY_CLASS (property_class));
+
+ g_free (property_class->id);
+ g_free (property_class->tooltip);
+ g_free (property_class->name);
+ if (property_class->orig_def)
+ {
+ if (G_VALUE_TYPE (property_class->orig_def) != 0)
+ g_value_unset (property_class->orig_def);
+ g_free (property_class->orig_def);
+ }
+ if (property_class->def)
+ {
+ if (G_VALUE_TYPE (property_class->def) != 0)
+ g_value_unset (property_class->def);
+ g_free (property_class->def);
+ }
+ g_list_foreach (property_class->parameters, (GFunc) glade_parameter_free,
+ NULL);
+ g_list_free (property_class->parameters);
+ g_free (property_class);
}
GValue *
-glade_property_class_get_default_from_spec (GParamSpec *spec)
+glade_property_class_get_default_from_spec (GParamSpec * spec)
{
- GValue *value;
- value = g_new0 (GValue, 1);
- g_value_init (value, spec->value_type);
- g_param_value_set_default (spec, value);
- return value;
+ GValue *value;
+ value = g_new0 (GValue, 1);
+ g_value_init (value, spec->value_type);
+ g_param_value_set_default (spec, value);
+ return value;
}
static gchar *
glade_property_class_make_string_from_enum (GType etype, gint eval)
{
- GEnumClass *eclass;
- gchar *string = NULL;
- guint i;
-
- g_return_val_if_fail ((eclass = g_type_class_ref (etype)) != NULL, NULL);
- for (i = 0; i < eclass->n_values; i++)
- {
- if (eval == eclass->values[i].value)
- {
- string = g_strdup (eclass->values[i].value_nick);
- break;
- }
- }
- g_type_class_unref (eclass);
- return string;
+ GEnumClass *eclass;
+ gchar *string = NULL;
+ guint i;
+
+ g_return_val_if_fail ((eclass = g_type_class_ref (etype)) != NULL, NULL);
+ for (i = 0; i < eclass->n_values; i++)
+ {
+ if (eval == eclass->values[i].value)
+ {
+ string = g_strdup (eclass->values[i].value_nick);
+ break;
+ }
+ }
+ g_type_class_unref (eclass);
+ return string;
}
static gchar *
-glade_property_class_make_string_from_flags (GladePropertyClass *klass, guint fvals, gboolean displayables)
+glade_property_class_make_string_from_flags (GladePropertyClass * klass,
+ guint fvals, gboolean displayables)
{
- GFlagsClass *fclass;
- GFlagsValue *fvalue;
- GString *string;
- gchar *retval;
-
- g_return_val_if_fail ((fclass = g_type_class_ref (klass->pspec->value_type)) != NULL, NULL);
-
- string = g_string_new("");
-
- while ((fvalue = g_flags_get_first_value(fclass, fvals)) != NULL)
- {
- const gchar *val_str = NULL;
-
- fvals &= ~fvalue->value;
-
- if (displayables)
- val_str = glade_get_displayable_value (klass->pspec->value_type,
- fvalue->value_name);
-
- if (string->str[0])
- g_string_append(string, " | ");
-
- g_string_append (string, (val_str) ? val_str : fvalue->value_name);
-
- /* If one of the flags value is 0 this loop become infinite :) */
- if (fvalue->value == 0) break;
- }
-
- retval = string->str;
-
- g_type_class_unref (fclass);
- g_string_free(string, FALSE);
-
- return retval;
+ GFlagsClass *fclass;
+ GFlagsValue *fvalue;
+ GString *string;
+ gchar *retval;
+
+ g_return_val_if_fail ((fclass =
+ g_type_class_ref (klass->pspec->value_type)) != NULL,
+ NULL);
+
+ string = g_string_new ("");
+
+ while ((fvalue = g_flags_get_first_value (fclass, fvals)) != NULL)
+ {
+ const gchar *val_str = NULL;
+
+ fvals &= ~fvalue->value;
+
+ if (displayables)
+ val_str = glade_get_displayable_value (klass->pspec->value_type,
+ fvalue->value_name);
+
+ if (string->str[0])
+ g_string_append (string, " | ");
+
+ g_string_append (string, (val_str) ? val_str : fvalue->value_name);
+
+ /* If one of the flags value is 0 this loop become infinite :) */
+ if (fvalue->value == 0)
+ break;
+ }
+
+ retval = string->str;
+
+ g_type_class_unref (fclass);
+ g_string_free (string, FALSE);
+
+ return retval;
}
static gchar *
-glade_property_class_make_string_from_object (GladePropertyClass *property_class,
- GObject *object)
+glade_property_class_make_string_from_object (GladePropertyClass *
+ property_class, GObject * object)
{
- GladeWidget *gwidget;
- gchar *string = NULL, *filename;
-
- if (!object) return NULL;
-
- if (property_class->pspec->value_type == GDK_TYPE_PIXBUF)
- {
- if ((filename = g_object_get_data (object, "GladeFileName")) != NULL)
- string = g_strdup (filename);
- }
- else if ((gwidget = glade_widget_get_from_gobject (object)) != NULL)
- string = g_strdup (gwidget->name);
- else
- g_critical ("Object type property refers to an object "
- "outside the project");
-
- return string;
+ GladeWidget *gwidget;
+ gchar *string = NULL, *filename;
+
+ if (!object)
+ return NULL;
+
+ if (property_class->pspec->value_type == GDK_TYPE_PIXBUF)
+ {
+ if ((filename = g_object_get_data (object, "GladeFileName")) != NULL)
+ string = g_strdup (filename);
+ }
+ else if ((gwidget = glade_widget_get_from_gobject (object)) != NULL)
+ string = g_strdup (gwidget->name);
+ else
+ g_critical ("Object type property refers to an object "
+ "outside the project");
+
+ return string;
}
static gchar *
-glade_property_class_make_string_from_objects (GladePropertyClass *property_class,
- GList *objects)
+glade_property_class_make_string_from_objects (GladePropertyClass *
+ property_class, GList * objects)
{
- GObject *object;
- GList *list;
- gchar *string = NULL, *obj_str, *tmp;
-
- for (list = objects; list; list = list->next)
- {
- object = list->data;
-
- obj_str = glade_property_class_make_string_from_object (property_class, object);
-
- if (string == NULL)
- string = obj_str;
- else if (obj_str != NULL)
- {
- tmp = g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER, obj_str);
- string = (g_free (string), tmp);
- g_free (obj_str);
- }
- }
- return string;
+ GObject *object;
+ GList *list;
+ gchar *string = NULL, *obj_str, *tmp;
+
+ for (list = objects; list; list = list->next)
+ {
+ object = list->data;
+
+ obj_str =
+ glade_property_class_make_string_from_object (property_class, object);
+
+ if (string == NULL)
+ string = obj_str;
+ else if (obj_str != NULL)
+ {
+ tmp =
+ g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER, obj_str);
+ string = (g_free (string), tmp);
+ g_free (obj_str);
+ }
+ }
+ return string;
}
/**
@@ -322,117 +328,121 @@ glade_property_class_make_string_from_objects (GladePropertyClass *property_clas
* Returns: A newly allocated string representation of @value
*/
gchar *
-glade_property_class_make_string_from_gvalue (GladePropertyClass *property_class,
- const GValue *value)
+glade_property_class_make_string_from_gvalue (GladePropertyClass *
+ property_class,
+ const GValue * value)
{
- gchar *string = NULL, **strv, str[G_ASCII_DTOSTR_BUF_SIZE];
- GObject *object;
- GdkColor *color;
- GList *objects;
-
- if (G_IS_PARAM_SPEC_ENUM (property_class->pspec))
- {
- gint eval = g_value_get_enum (value);
- string = glade_property_class_make_string_from_enum
- (property_class->pspec->value_type, eval);
- }
- else if (G_IS_PARAM_SPEC_FLAGS (property_class->pspec))
- {
- guint flags = g_value_get_flags (value);
- string = glade_property_class_make_string_from_flags
- (property_class, flags, FALSE);
- }
- else if (G_IS_PARAM_SPEC_VALUE_ARRAY (property_class->pspec))
- {
- GValueArray *value_array = g_value_get_boxed (value);
-
- if (value_array && value_array->n_values &&
- G_VALUE_HOLDS (&value_array->values [0], G_TYPE_STRING))
- {
- gint i, n_values = value_array->n_values;
- GString *gstring = g_string_new (NULL);
-
- for (i = 0; i < n_values; i++)
- {
- g_string_append (gstring, g_value_get_string (&value_array->values [i]));
- g_string_append_c (gstring, '\n');
- }
- string = gstring->str;
- g_string_free (gstring, FALSE);
- }
- }
- else if (G_IS_PARAM_SPEC_BOXED (property_class->pspec))
- {
- if (property_class->pspec->value_type == GDK_TYPE_COLOR)
- {
- color = g_value_get_boxed (value);
- if (color)
- string = g_strdup_printf ("#%04x%04x%04x",
- color->red,
- color->green,
- color->blue);
- }
- else if (property_class->pspec->value_type == G_TYPE_STRV)
- {
- strv = g_value_get_boxed (value);
- if (strv) string = g_strjoinv ("\n", strv);
- }
- }
- else if (G_IS_PARAM_SPEC_INT(property_class->pspec))
- string = g_strdup_printf ("%d", g_value_get_int (value));
- else if (G_IS_PARAM_SPEC_UINT(property_class->pspec))
- string = g_strdup_printf ("%u", g_value_get_uint (value));
- else if (G_IS_PARAM_SPEC_LONG(property_class->pspec))
- string = g_strdup_printf ("%ld", g_value_get_long (value));
- else if (G_IS_PARAM_SPEC_ULONG(property_class->pspec))
- string = g_strdup_printf ("%lu", g_value_get_ulong (value));
- else if (G_IS_PARAM_SPEC_INT64(property_class->pspec))
- string = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (value));
- else if (G_IS_PARAM_SPEC_UINT64(property_class->pspec))
- string = g_strdup_printf ("%" G_GUINT64_FORMAT, g_value_get_uint64 (value));
- else if (G_IS_PARAM_SPEC_FLOAT(property_class->pspec))
- {
- g_ascii_dtostr (str, sizeof (str), g_value_get_float (value));
- string = g_strdup (str);
- }
- else if (G_IS_PARAM_SPEC_DOUBLE(property_class->pspec))
- {
- g_ascii_dtostr (str, sizeof (str), g_value_get_double (value));
- string = g_strdup (str);
- }
- else if (G_IS_PARAM_SPEC_STRING(property_class->pspec))
- {
- string = g_value_dup_string (value);
- }
- else if (G_IS_PARAM_SPEC_CHAR(property_class->pspec))
- string = g_strdup_printf ("%c", g_value_get_char (value));
- else if (G_IS_PARAM_SPEC_UCHAR(property_class->pspec))
- string = g_strdup_printf ("%c", g_value_get_uchar (value));
- else if (G_IS_PARAM_SPEC_UNICHAR(property_class->pspec))
- {
- int len;
- string = g_malloc (7);
- len = g_unichar_to_utf8 (g_value_get_uint (value), string);
- string[len] = '\0';
- }
- else if (G_IS_PARAM_SPEC_BOOLEAN(property_class->pspec))
- string = g_strdup_printf ("%s", g_value_get_boolean (value) ?
- GLADE_TAG_TRUE : GLADE_TAG_FALSE);
- else if (G_IS_PARAM_SPEC_OBJECT(property_class->pspec))
- {
- object = g_value_get_object (value);
- string = glade_property_class_make_string_from_object (property_class, object);
- }
- else if (GLADE_IS_PARAM_SPEC_OBJECTS (property_class->pspec))
- {
- objects = g_value_get_boxed (value);
- string = glade_property_class_make_string_from_objects (property_class, objects);
- }
- else
- g_critical ("Unsupported pspec type %s (value -> string)",
- g_type_name (G_PARAM_SPEC_TYPE (property_class->pspec)));
-
- return string;
+ gchar *string = NULL, **strv, str[G_ASCII_DTOSTR_BUF_SIZE];
+ GObject *object;
+ GdkColor *color;
+ GList *objects;
+
+ if (G_IS_PARAM_SPEC_ENUM (property_class->pspec))
+ {
+ gint eval = g_value_get_enum (value);
+ string = glade_property_class_make_string_from_enum
+ (property_class->pspec->value_type, eval);
+ }
+ else if (G_IS_PARAM_SPEC_FLAGS (property_class->pspec))
+ {
+ guint flags = g_value_get_flags (value);
+ string = glade_property_class_make_string_from_flags
+ (property_class, flags, FALSE);
+ }
+ else if (G_IS_PARAM_SPEC_VALUE_ARRAY (property_class->pspec))
+ {
+ GValueArray *value_array = g_value_get_boxed (value);
+
+ if (value_array && value_array->n_values &&
+ G_VALUE_HOLDS (&value_array->values[0], G_TYPE_STRING))
+ {
+ gint i, n_values = value_array->n_values;
+ GString *gstring = g_string_new (NULL);
+
+ for (i = 0; i < n_values; i++)
+ {
+ g_string_append (gstring,
+ g_value_get_string (&value_array->values[i]));
+ g_string_append_c (gstring, '\n');
+ }
+ string = gstring->str;
+ g_string_free (gstring, FALSE);
+ }
+ }
+ else if (G_IS_PARAM_SPEC_BOXED (property_class->pspec))
+ {
+ if (property_class->pspec->value_type == GDK_TYPE_COLOR)
+ {
+ color = g_value_get_boxed (value);
+ if (color)
+ string = g_strdup_printf ("#%04x%04x%04x",
+ color->red, color->green, color->blue);
+ }
+ else if (property_class->pspec->value_type == G_TYPE_STRV)
+ {
+ strv = g_value_get_boxed (value);
+ if (strv)
+ string = g_strjoinv ("\n", strv);
+ }
+ }
+ else if (G_IS_PARAM_SPEC_INT (property_class->pspec))
+ string = g_strdup_printf ("%d", g_value_get_int (value));
+ else if (G_IS_PARAM_SPEC_UINT (property_class->pspec))
+ string = g_strdup_printf ("%u", g_value_get_uint (value));
+ else if (G_IS_PARAM_SPEC_LONG (property_class->pspec))
+ string = g_strdup_printf ("%ld", g_value_get_long (value));
+ else if (G_IS_PARAM_SPEC_ULONG (property_class->pspec))
+ string = g_strdup_printf ("%lu", g_value_get_ulong (value));
+ else if (G_IS_PARAM_SPEC_INT64 (property_class->pspec))
+ string = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (value));
+ else if (G_IS_PARAM_SPEC_UINT64 (property_class->pspec))
+ string = g_strdup_printf ("%" G_GUINT64_FORMAT, g_value_get_uint64 (value));
+ else if (G_IS_PARAM_SPEC_FLOAT (property_class->pspec))
+ {
+ g_ascii_dtostr (str, sizeof (str), g_value_get_float (value));
+ string = g_strdup (str);
+ }
+ else if (G_IS_PARAM_SPEC_DOUBLE (property_class->pspec))
+ {
+ g_ascii_dtostr (str, sizeof (str), g_value_get_double (value));
+ string = g_strdup (str);
+ }
+ else if (G_IS_PARAM_SPEC_STRING (property_class->pspec))
+ {
+ string = g_value_dup_string (value);
+ }
+ else if (G_IS_PARAM_SPEC_CHAR (property_class->pspec))
+ string = g_strdup_printf ("%c", g_value_get_char (value));
+ else if (G_IS_PARAM_SPEC_UCHAR (property_class->pspec))
+ string = g_strdup_printf ("%c", g_value_get_uchar (value));
+ else if (G_IS_PARAM_SPEC_UNICHAR (property_class->pspec))
+ {
+ int len;
+ string = g_malloc (7);
+ len = g_unichar_to_utf8 (g_value_get_uint (value), string);
+ string[len] = '\0';
+ }
+ else if (G_IS_PARAM_SPEC_BOOLEAN (property_class->pspec))
+ string = g_strdup_printf ("%s", g_value_get_boolean (value) ?
+ GLADE_TAG_TRUE : GLADE_TAG_FALSE);
+ else if (G_IS_PARAM_SPEC_OBJECT (property_class->pspec))
+ {
+ object = g_value_get_object (value);
+ string =
+ glade_property_class_make_string_from_object (property_class, object);
+ }
+ else if (GLADE_IS_PARAM_SPEC_OBJECTS (property_class->pspec))
+ {
+ objects = g_value_get_boxed (value);
+ string =
+ glade_property_class_make_string_from_objects (property_class,
+ objects);
+ }
+ else
+ g_critical ("Unsupported pspec type %s (value -> string)",
+ g_type_name (G_PARAM_SPEC_TYPE (property_class->pspec)));
+
+ return string;
}
/* This is copied exactly from libglade. I've just renamed the function.
@@ -440,79 +450,82 @@ glade_property_class_make_string_from_gvalue (GladePropertyClass *property_class
static guint
glade_property_class_make_flags_from_string (GType type, const char *string)
{
- GFlagsClass *fclass;
- gchar *endptr, *prevptr;
- guint i, j, ret = 0;
- char *flagstr;
-
- ret = strtoul(string, &endptr, 0);
- if (endptr != string) /* parsed a number */
- return ret;
-
- fclass = g_type_class_ref(type);
-
-
- flagstr = g_strdup (string);
- for (ret = i = j = 0; ; i++) {
- gboolean eos;
-
- eos = flagstr [i] == '\0';
-
- if (eos || flagstr [i] == '|') {
- GFlagsValue *fv;
- const char *flag;
- gunichar ch;
-
- flag = &flagstr [j];
- endptr = &flagstr [i];
-
- if (!eos) {
- flagstr [i++] = '\0';
- j = i;
- }
-
- /* trim spaces */
- for (;;)
- {
- ch = g_utf8_get_char (flag);
- if (!g_unichar_isspace (ch))
- break;
- flag = g_utf8_next_char (flag);
- }
-
- while (endptr > flag)
- {
- prevptr = g_utf8_prev_char (endptr);
- ch = g_utf8_get_char (prevptr);
- if (!g_unichar_isspace (ch))
- break;
- endptr = prevptr;
- }
-
- if (endptr > flag)
- {
- *endptr = '\0';
- fv = g_flags_get_value_by_name (fclass, flag);
-
- if (!fv)
- fv = g_flags_get_value_by_nick (fclass, flag);
-
- if (fv)
- ret |= fv->value;
- else
- g_warning ("Unknown flag: '%s'", flag);
- }
-
- if (eos)
- break;
- }
+ GFlagsClass *fclass;
+ gchar *endptr, *prevptr;
+ guint i, j, ret = 0;
+ char *flagstr;
+
+ ret = strtoul (string, &endptr, 0);
+ if (endptr != string) /* parsed a number */
+ return ret;
+
+ fclass = g_type_class_ref (type);
+
+
+ flagstr = g_strdup (string);
+ for (ret = i = j = 0;; i++)
+ {
+ gboolean eos;
+
+ eos = flagstr[i] == '\0';
+
+ if (eos || flagstr[i] == '|')
+ {
+ GFlagsValue *fv;
+ const char *flag;
+ gunichar ch;
+
+ flag = &flagstr[j];
+ endptr = &flagstr[i];
+
+ if (!eos)
+ {
+ flagstr[i++] = '\0';
+ j = i;
+ }
+
+ /* trim spaces */
+ for (;;)
+ {
+ ch = g_utf8_get_char (flag);
+ if (!g_unichar_isspace (ch))
+ break;
+ flag = g_utf8_next_char (flag);
+ }
+
+ while (endptr > flag)
+ {
+ prevptr = g_utf8_prev_char (endptr);
+ ch = g_utf8_get_char (prevptr);
+ if (!g_unichar_isspace (ch))
+ break;
+ endptr = prevptr;
+ }
+
+ if (endptr > flag)
+ {
+ *endptr = '\0';
+ fv = g_flags_get_value_by_name (fclass, flag);
+
+ if (!fv)
+ fv = g_flags_get_value_by_nick (fclass, flag);
+
+ if (fv)
+ ret |= fv->value;
+ else
+ g_warning ("Unknown flag: '%s'", flag);
+ }
+
+ if (eos)
+ break;
+ }
}
-
- g_free (flagstr);
- g_type_class_unref(fclass);
+ g_free (flagstr);
- return ret;
+ g_type_class_unref (fclass);
+
+ return ret;
}
/* This is copied exactly from libglade. I've just renamed the function.
@@ -520,102 +533,108 @@ glade_property_class_make_flags_from_string (GType type, const char *string)
static gint
glade_property_class_make_enum_from_string (GType type, const char *string)
{
- GEnumClass *eclass;
- GEnumValue *ev;
- gchar *endptr;
- gint ret = 0;
+ GEnumClass *eclass;
+ GEnumValue *ev;
+ gchar *endptr;
+ gint ret = 0;
- ret = strtoul(string, &endptr, 0);
- if (endptr != string) /* parsed a number */
- return ret;
+ ret = strtoul (string, &endptr, 0);
+ if (endptr != string) /* parsed a number */
+ return ret;
- eclass = g_type_class_ref(type);
- ev = g_enum_get_value_by_name(eclass, string);
- if (!ev) ev = g_enum_get_value_by_nick(eclass, string);
- if (ev) ret = ev->value;
+ eclass = g_type_class_ref (type);
+ ev = g_enum_get_value_by_name (eclass, string);
+ if (!ev)
+ ev = g_enum_get_value_by_nick (eclass, string);
+ if (ev)
+ ret = ev->value;
- g_type_class_unref(eclass);
+ g_type_class_unref (eclass);
- return ret;
+ return ret;
}
static GObject *
-glade_property_class_make_object_from_string (GladePropertyClass *property_class,
- const gchar *string,
- GladeProject *project,
- GladeWidget *widget)
+glade_property_class_make_object_from_string (GladePropertyClass *
+ property_class,
+ const gchar * string,
+ GladeProject * project,
+ GladeWidget * widget)
{
- GObject *object = NULL;
- gchar *fullpath;
-
- if (string == NULL) return NULL;
-
- if (property_class->pspec->value_type == GDK_TYPE_PIXBUF && project)
- {
- GdkPixbuf *pixbuf;
-
- if (*string == '\0') return NULL;
-
- fullpath = glade_project_resource_fullpath (project, string);
-
- if ((pixbuf = gdk_pixbuf_new_from_file (fullpath, NULL)) == NULL)
- {
- static GdkPixbuf *icon = NULL;
-
- if (icon == NULL)
- {
- GtkWidget *widget = gtk_label_new ("");
- icon = gtk_widget_render_icon (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU, NULL);
- gtk_widget_destroy (widget);
- }
-
- pixbuf = gdk_pixbuf_copy (icon);
- }
-
- if (pixbuf)
- {
- object = G_OBJECT (pixbuf);
- g_object_set_data_full (object, "GladeFileName",
- g_strdup (string), g_free);
- }
-
- g_free (fullpath);
- }
- else if (project)
- {
- GladeWidget *gwidget;
- if ((gwidget = glade_project_get_widget_by_name
- (project, widget, string)) != NULL)
- object = gwidget->object;
- }
-
- return object;
+ GObject *object = NULL;
+ gchar *fullpath;
+
+ if (string == NULL)
+ return NULL;
+
+ if (property_class->pspec->value_type == GDK_TYPE_PIXBUF && project)
+ {
+ GdkPixbuf *pixbuf;
+
+ if (*string == '\0')
+ return NULL;
+
+ fullpath = glade_project_resource_fullpath (project, string);
+
+ if ((pixbuf = gdk_pixbuf_new_from_file (fullpath, NULL)) == NULL)
+ {
+ static GdkPixbuf *icon = NULL;
+
+ if (icon == NULL)
+ {
+ GtkWidget *widget = gtk_label_new ("");
+ icon = gtk_widget_render_icon (widget,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU, NULL);
+ gtk_widget_destroy (widget);
+ }
+
+ pixbuf = gdk_pixbuf_copy (icon);
+ }
+
+ if (pixbuf)
+ {
+ object = G_OBJECT (pixbuf);
+ g_object_set_data_full (object, "GladeFileName",
+ g_strdup (string), g_free);
+ }
+
+ g_free (fullpath);
+ }
+ else if (project)
+ {
+ GladeWidget *gwidget;
+ if ((gwidget = glade_project_get_widget_by_name
+ (project, widget, string)) != NULL)
+ object = gwidget->object;
+ }
+
+ return object;
}
static GList *
-glade_property_class_make_objects_from_string (GladePropertyClass *property_class,
- const gchar *string,
- GladeProject *project,
- GladeWidget *widget)
+glade_property_class_make_objects_from_string (GladePropertyClass *
+ property_class,
+ const gchar * string,
+ GladeProject * project,
+ GladeWidget * widget)
{
- GList *objects = NULL;
- GObject *object;
- gchar **split;
- guint i;
-
- if ((split = g_strsplit (string, GPC_OBJECT_DELIMITER, 0)) != NULL)
- {
- for (i = 0; split[i]; i++)
- {
- if ((object = glade_property_class_make_object_from_string
- (property_class, split[i], project, widget)) != NULL)
- objects = g_list_prepend (objects, object);
- }
- g_strfreev (split);
- }
- return g_list_reverse (objects);
+ GList *objects = NULL;
+ GObject *object;
+ gchar **split;
+ guint i;
+
+ if ((split = g_strsplit (string, GPC_OBJECT_DELIMITER, 0)) != NULL)
+ {
+ for (i = 0; split[i]; i++)
+ {
+ if ((object = glade_property_class_make_object_from_string
+ (property_class, split[i], project, widget)) != NULL)
+ objects = g_list_prepend (objects, object);
+ }
+ g_strfreev (split);
+ }
+ return g_list_reverse (objects);
}
/**
@@ -628,109 +647,110 @@ glade_property_class_make_objects_from_string (GladePropertyClass *property_clas
* and @string criteria.
*/
GValue *
-glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class,
- const gchar *string,
- GladeProject *project,
- GladeWidget *widget)
+glade_property_class_make_gvalue_from_string (GladePropertyClass *
+ property_class,
+ const gchar * string,
+ GladeProject * project,
+ GladeWidget * widget)
{
- GValue *value = g_new0 (GValue, 1);
- gchar **strv;
- GdkColor color = { 0, };
-
- g_value_init (value, property_class->pspec->value_type);
-
- if (G_IS_PARAM_SPEC_ENUM(property_class->pspec))
- {
- gint eval = glade_property_class_make_enum_from_string
- (property_class->pspec->value_type, string);
- g_value_set_enum (value, eval);
- }
- else if (G_IS_PARAM_SPEC_FLAGS(property_class->pspec))
- {
- guint flags = glade_property_class_make_flags_from_string
- (property_class->pspec->value_type, string);
- g_value_set_flags (value, flags);
- }
- else if (G_IS_PARAM_SPEC_VALUE_ARRAY (property_class->pspec))
- {
- GValueArray *value_array = g_value_array_new (0);
- GValue str_value = {0, };
- gint i;
-
- g_value_init (&str_value, G_TYPE_STRING);
- strv = g_strsplit (string, "\n", 0);
-
- for (i = 0; strv[i]; i++)
- {
- g_value_set_static_string (&str_value, strv[i]);
- value_array = g_value_array_append (value_array, &str_value);
- }
- g_value_set_boxed (value, value_array);
- g_strfreev (strv);
- }
- else if (G_IS_PARAM_SPEC_BOXED(property_class->pspec))
- {
- if (property_class->pspec->value_type == GDK_TYPE_COLOR)
- {
- if (gdk_color_parse(string, &color))
- g_value_set_boxed(value, &color);
- else
- g_warning ("could not parse colour name `%s'", string);
- }
- else if (property_class->pspec->value_type == G_TYPE_STRV)
- {
- strv = g_strsplit (string, "\n", 0);
- g_value_take_boxed (value, strv);
- }
- }
- else if (G_IS_PARAM_SPEC_INT(property_class->pspec))
- g_value_set_int (value, g_ascii_strtoll (string, NULL, 10));
- else if (G_IS_PARAM_SPEC_UINT(property_class->pspec))
- g_value_set_uint (value, g_ascii_strtoull (string, NULL, 10));
- else if (G_IS_PARAM_SPEC_LONG(property_class->pspec))
- g_value_set_long (value, g_ascii_strtoll (string, NULL, 10));
- else if (G_IS_PARAM_SPEC_ULONG(property_class->pspec))
- g_value_set_ulong (value, g_ascii_strtoull (string, NULL, 10));
- else if (G_IS_PARAM_SPEC_INT64(property_class->pspec))
- g_value_set_int64 (value, g_ascii_strtoll (string, NULL, 10));
- else if (G_IS_PARAM_SPEC_UINT64(property_class->pspec))
- g_value_set_uint64 (value, g_ascii_strtoull (string, NULL, 10));
- else if (G_IS_PARAM_SPEC_FLOAT(property_class->pspec))
- g_value_set_float (value, (float) g_ascii_strtod (string, NULL));
- else if (G_IS_PARAM_SPEC_DOUBLE(property_class->pspec))
- g_value_set_double (value, g_ascii_strtod (string, NULL));
- else if (G_IS_PARAM_SPEC_STRING(property_class->pspec))
- g_value_set_string (value, string);
- else if (G_IS_PARAM_SPEC_CHAR(property_class->pspec))
- g_value_set_char (value, string[0]);
- else if (G_IS_PARAM_SPEC_UCHAR(property_class->pspec))
- g_value_set_uchar (value, string[0]);
- else if (G_IS_PARAM_SPEC_UNICHAR(property_class->pspec))
- g_value_set_uint (value, g_utf8_get_char (string));
- else if (G_IS_PARAM_SPEC_BOOLEAN(property_class->pspec))
- {
- if (strcmp (string, GLADE_TAG_TRUE) == 0)
- g_value_set_boolean (value, TRUE);
- else
- g_value_set_boolean (value, FALSE);
- }
- else if (G_IS_PARAM_SPEC_OBJECT(property_class->pspec))
- {
- GObject *object = glade_property_class_make_object_from_string
- (property_class, string, project, widget);
- g_value_set_object (value, object);
- }
- else if (GLADE_IS_PARAM_SPEC_OBJECTS (property_class->pspec))
- {
- GList *objects = glade_property_class_make_objects_from_string
- (property_class, string, project, widget);
- g_value_set_boxed (value, objects);
- }
- else
- g_critical ("Unsupported pspec type %s (string -> value)",
- g_type_name(G_PARAM_SPEC_TYPE (property_class->pspec)));
-
- return value;
+ GValue *value = g_new0 (GValue, 1);
+ gchar **strv;
+ GdkColor color = { 0, };
+
+ g_value_init (value, property_class->pspec->value_type);
+
+ if (G_IS_PARAM_SPEC_ENUM (property_class->pspec))
+ {
+ gint eval = glade_property_class_make_enum_from_string
+ (property_class->pspec->value_type, string);
+ g_value_set_enum (value, eval);
+ }
+ else if (G_IS_PARAM_SPEC_FLAGS (property_class->pspec))
+ {
+ guint flags = glade_property_class_make_flags_from_string
+ (property_class->pspec->value_type, string);
+ g_value_set_flags (value, flags);
+ }
+ else if (G_IS_PARAM_SPEC_VALUE_ARRAY (property_class->pspec))
+ {
+ GValueArray *value_array = g_value_array_new (0);
+ GValue str_value = { 0, };
+ gint i;
+
+ g_value_init (&str_value, G_TYPE_STRING);
+ strv = g_strsplit (string, "\n", 0);
+
+ for (i = 0; strv[i]; i++)
+ {
+ g_value_set_static_string (&str_value, strv[i]);
+ value_array = g_value_array_append (value_array, &str_value);
+ }
+ g_value_set_boxed (value, value_array);
+ g_strfreev (strv);
+ }
+ else if (G_IS_PARAM_SPEC_BOXED (property_class->pspec))
+ {
+ if (property_class->pspec->value_type == GDK_TYPE_COLOR)
+ {
+ if (gdk_color_parse (string, &color))
+ g_value_set_boxed (value, &color);
+ else
+ g_warning ("could not parse colour name `%s'", string);
+ }
+ else if (property_class->pspec->value_type == G_TYPE_STRV)
+ {
+ strv = g_strsplit (string, "\n", 0);
+ g_value_take_boxed (value, strv);
+ }
+ }
+ else if (G_IS_PARAM_SPEC_INT (property_class->pspec))
+ g_value_set_int (value, g_ascii_strtoll (string, NULL, 10));
+ else if (G_IS_PARAM_SPEC_UINT (property_class->pspec))
+ g_value_set_uint (value, g_ascii_strtoull (string, NULL, 10));
+ else if (G_IS_PARAM_SPEC_LONG (property_class->pspec))
+ g_value_set_long (value, g_ascii_strtoll (string, NULL, 10));
+ else if (G_IS_PARAM_SPEC_ULONG (property_class->pspec))
+ g_value_set_ulong (value, g_ascii_strtoull (string, NULL, 10));
+ else if (G_IS_PARAM_SPEC_INT64 (property_class->pspec))
+ g_value_set_int64 (value, g_ascii_strtoll (string, NULL, 10));
+ else if (G_IS_PARAM_SPEC_UINT64 (property_class->pspec))
+ g_value_set_uint64 (value, g_ascii_strtoull (string, NULL, 10));
+ else if (G_IS_PARAM_SPEC_FLOAT (property_class->pspec))
+ g_value_set_float (value, (float) g_ascii_strtod (string, NULL));
+ else if (G_IS_PARAM_SPEC_DOUBLE (property_class->pspec))
+ g_value_set_double (value, g_ascii_strtod (string, NULL));
+ else if (G_IS_PARAM_SPEC_STRING (property_class->pspec))
+ g_value_set_string (value, string);
+ else if (G_IS_PARAM_SPEC_CHAR (property_class->pspec))
+ g_value_set_char (value, string[0]);
+ else if (G_IS_PARAM_SPEC_UCHAR (property_class->pspec))
+ g_value_set_uchar (value, string[0]);
+ else if (G_IS_PARAM_SPEC_UNICHAR (property_class->pspec))
+ g_value_set_uint (value, g_utf8_get_char (string));
+ else if (G_IS_PARAM_SPEC_BOOLEAN (property_class->pspec))
+ {
+ if (strcmp (string, GLADE_TAG_TRUE) == 0)
+ g_value_set_boolean (value, TRUE);
+ else
+ g_value_set_boolean (value, FALSE);
+ }
+ else if (G_IS_PARAM_SPEC_OBJECT (property_class->pspec))
+ {
+ GObject *object = glade_property_class_make_object_from_string
+ (property_class, string, project, widget);
+ g_value_set_object (value, object);
+ }
+ else if (GLADE_IS_PARAM_SPEC_OBJECTS (property_class->pspec))
+ {
+ GList *objects = glade_property_class_make_objects_from_string
+ (property_class, string, project, widget);
+ g_value_set_boxed (value, objects);
+ }
+ else
+ g_critical ("Unsupported pspec type %s (string -> value)",
+ g_type_name (G_PARAM_SPEC_TYPE (property_class->pspec)));
+
+ return value;
}
/**
@@ -743,55 +763,55 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class
* and a @vl arg of the correct type.
*/
GValue *
-glade_property_class_make_gvalue_from_vl (GladePropertyClass *klass,
- va_list vl)
+glade_property_class_make_gvalue_from_vl (GladePropertyClass * klass,
+ va_list vl)
{
- GValue *value;
-
- g_return_val_if_fail (klass != NULL, NULL);
-
- value = g_new0 (GValue, 1);
- g_value_init (value, klass->pspec->value_type);
-
- if (G_IS_PARAM_SPEC_ENUM(klass->pspec))
- g_value_set_enum (value, va_arg (vl, gint));
- else if (G_IS_PARAM_SPEC_FLAGS(klass->pspec))
- g_value_set_flags (value, va_arg (vl, gint));
- else if (G_IS_PARAM_SPEC_INT(klass->pspec))
- g_value_set_int (value, va_arg (vl, gint));
- else if (G_IS_PARAM_SPEC_UINT(klass->pspec))
- g_value_set_uint (value, va_arg (vl, guint));
- else if (G_IS_PARAM_SPEC_LONG(klass->pspec))
- g_value_set_long (value, va_arg (vl, glong));
- else if (G_IS_PARAM_SPEC_ULONG(klass->pspec))
- g_value_set_ulong (value, va_arg (vl, gulong));
- else if (G_IS_PARAM_SPEC_INT64(klass->pspec))
- g_value_set_int64 (value, va_arg (vl, gint64));
- else if (G_IS_PARAM_SPEC_UINT64(klass->pspec))
- g_value_set_uint64 (value, va_arg (vl, guint64));
- else if (G_IS_PARAM_SPEC_FLOAT(klass->pspec))
- g_value_set_float (value, (gfloat)va_arg (vl, gdouble));
- else if (G_IS_PARAM_SPEC_DOUBLE(klass->pspec))
- g_value_set_double (value, va_arg (vl, gdouble));
- else if (G_IS_PARAM_SPEC_STRING(klass->pspec))
- g_value_set_string (value, va_arg (vl, gchar *));
- else if (G_IS_PARAM_SPEC_CHAR(klass->pspec))
- g_value_set_char (value, (gchar)va_arg (vl, gint));
- else if (G_IS_PARAM_SPEC_UCHAR(klass->pspec))
- g_value_set_uchar (value, (guchar)va_arg (vl, guint));
- else if (G_IS_PARAM_SPEC_UNICHAR(klass->pspec))
- g_value_set_uint (value, va_arg (vl, gunichar));
- else if (G_IS_PARAM_SPEC_BOOLEAN(klass->pspec))
- g_value_set_boolean (value, va_arg (vl, gboolean));
- else if (G_IS_PARAM_SPEC_OBJECT(klass->pspec))
- g_value_set_object (value, va_arg (vl, gpointer));
- else if (G_VALUE_HOLDS_BOXED (value))
- g_value_set_boxed (value, va_arg (vl, gpointer));
- else
- g_critical ("Unsupported pspec type %s (vl -> string)",
- g_type_name(G_PARAM_SPEC_TYPE (klass->pspec)));
-
- return value;
+ GValue *value;
+
+ g_return_val_if_fail (klass != NULL, NULL);
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, klass->pspec->value_type);
+
+ if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
+ g_value_set_enum (value, va_arg (vl, gint));
+ else if (G_IS_PARAM_SPEC_FLAGS (klass->pspec))
+ g_value_set_flags (value, va_arg (vl, gint));
+ else if (G_IS_PARAM_SPEC_INT (klass->pspec))
+ g_value_set_int (value, va_arg (vl, gint));
+ else if (G_IS_PARAM_SPEC_UINT (klass->pspec))
+ g_value_set_uint (value, va_arg (vl, guint));
+ else if (G_IS_PARAM_SPEC_LONG (klass->pspec))
+ g_value_set_long (value, va_arg (vl, glong));
+ else if (G_IS_PARAM_SPEC_ULONG (klass->pspec))
+ g_value_set_ulong (value, va_arg (vl, gulong));
+ else if (G_IS_PARAM_SPEC_INT64 (klass->pspec))
+ g_value_set_int64 (value, va_arg (vl, gint64));
+ else if (G_IS_PARAM_SPEC_UINT64 (klass->pspec))
+ g_value_set_uint64 (value, va_arg (vl, guint64));
+ else if (G_IS_PARAM_SPEC_FLOAT (klass->pspec))
+ g_value_set_float (value, (gfloat) va_arg (vl, gdouble));
+ else if (G_IS_PARAM_SPEC_DOUBLE (klass->pspec))
+ g_value_set_double (value, va_arg (vl, gdouble));
+ else if (G_IS_PARAM_SPEC_STRING (klass->pspec))
+ g_value_set_string (value, va_arg (vl, gchar *));
+ else if (G_IS_PARAM_SPEC_CHAR (klass->pspec))
+ g_value_set_char (value, (gchar) va_arg (vl, gint));
+ else if (G_IS_PARAM_SPEC_UCHAR (klass->pspec))
+ g_value_set_uchar (value, (guchar) va_arg (vl, guint));
+ else if (G_IS_PARAM_SPEC_UNICHAR (klass->pspec))
+ g_value_set_uint (value, va_arg (vl, gunichar));
+ else if (G_IS_PARAM_SPEC_BOOLEAN (klass->pspec))
+ g_value_set_boolean (value, va_arg (vl, gboolean));
+ else if (G_IS_PARAM_SPEC_OBJECT (klass->pspec))
+ g_value_set_object (value, va_arg (vl, gpointer));
+ else if (G_VALUE_HOLDS_BOXED (value))
+ g_value_set_boxed (value, va_arg (vl, gpointer));
+ else
+ g_critical ("Unsupported pspec type %s (vl -> string)",
+ g_type_name (G_PARAM_SPEC_TYPE (klass->pspec)));
+
+ return value;
}
/**
@@ -803,19 +823,18 @@ glade_property_class_make_gvalue_from_vl (GladePropertyClass *klass,
* and the provided argument.
*/
GValue *
-glade_property_class_make_gvalue (GladePropertyClass *klass,
- ...)
+glade_property_class_make_gvalue (GladePropertyClass * klass, ...)
{
- GValue *value;
- va_list vl;
+ GValue *value;
+ va_list vl;
- g_return_val_if_fail (klass != NULL, NULL);
+ g_return_val_if_fail (klass != NULL, NULL);
- va_start (vl, klass);
- value = glade_property_class_make_gvalue_from_vl (klass, vl);
- va_end (vl);
+ va_start (vl, klass);
+ value = glade_property_class_make_gvalue_from_vl (klass, vl);
+ va_end (vl);
- return value;
+ return value;
}
@@ -830,53 +849,52 @@ glade_property_class_make_gvalue (GladePropertyClass *klass,
* Sets @vl from @value based on @klass criteria.
*/
void
-glade_property_class_set_vl_from_gvalue (GladePropertyClass *klass,
- GValue *value,
- va_list vl)
+glade_property_class_set_vl_from_gvalue (GladePropertyClass * klass,
+ GValue * value, va_list vl)
{
- g_return_if_fail (klass != NULL);
- g_return_if_fail (value != NULL);
-
- /* The argument is a pointer of the specified type, cast the pointer and assign
- * the value using the proper g_value_get_ variation.
- */
- if (G_IS_PARAM_SPEC_ENUM(klass->pspec))
- *(gint *)(va_arg (vl, gint *)) = g_value_get_enum (value);
- else if (G_IS_PARAM_SPEC_FLAGS(klass->pspec))
- *(gint *)(va_arg (vl, gint *)) = g_value_get_flags (value);
- else if (G_IS_PARAM_SPEC_INT(klass->pspec))
- *(gint *)(va_arg (vl, gint *)) = g_value_get_int (value);
- else if (G_IS_PARAM_SPEC_UINT(klass->pspec))
- *(guint *)(va_arg (vl, guint *)) = g_value_get_uint (value);
- else if (G_IS_PARAM_SPEC_LONG(klass->pspec))
- *(glong *)(va_arg (vl, glong *)) = g_value_get_long (value);
- else if (G_IS_PARAM_SPEC_ULONG(klass->pspec))
- *(gulong *)(va_arg (vl, gulong *)) = g_value_get_ulong (value);
- else if (G_IS_PARAM_SPEC_INT64(klass->pspec))
- *(gint64 *)(va_arg (vl, gint64 *)) = g_value_get_int64 (value);
- else if (G_IS_PARAM_SPEC_UINT64(klass->pspec))
- *(guint64 *)(va_arg (vl, guint64 *)) = g_value_get_uint64 (value);
- else if (G_IS_PARAM_SPEC_FLOAT(klass->pspec))
- *(gfloat *)(va_arg (vl, gdouble *)) = g_value_get_float (value);
- else if (G_IS_PARAM_SPEC_DOUBLE(klass->pspec))
- *(gdouble *)(va_arg (vl, gdouble *)) = g_value_get_double (value);
- else if (G_IS_PARAM_SPEC_STRING(klass->pspec))
- *(gchar **)(va_arg (vl, gchar *)) = (gchar *)g_value_get_string (value);
- else if (G_IS_PARAM_SPEC_CHAR(klass->pspec))
- *(gchar *)(va_arg (vl, gint *)) = g_value_get_char (value);
- else if (G_IS_PARAM_SPEC_UCHAR(klass->pspec))
- *(guchar *)(va_arg (vl, guint *)) = g_value_get_uchar (value);
- else if (G_IS_PARAM_SPEC_UNICHAR(klass->pspec))
- *(guint *)(va_arg (vl, gunichar *)) = g_value_get_uint (value);
- else if (G_IS_PARAM_SPEC_BOOLEAN(klass->pspec))
- *(gboolean *)(va_arg (vl, gboolean *)) = g_value_get_boolean (value);
- else if (G_IS_PARAM_SPEC_OBJECT(klass->pspec))
- *(gpointer *)(va_arg (vl, gpointer *)) = g_value_get_object (value);
- else if (G_VALUE_HOLDS_BOXED (value))
- *(gpointer *)(va_arg (vl, gpointer *)) = g_value_get_boxed (value);
- else
- g_critical ("Unsupported pspec type %s (string -> vl)",
- g_type_name(G_PARAM_SPEC_TYPE (klass->pspec)));
+ g_return_if_fail (klass != NULL);
+ g_return_if_fail (value != NULL);
+
+ /* The argument is a pointer of the specified type, cast the pointer and assign
+ * the value using the proper g_value_get_ variation.
+ */
+ if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
+ *(gint *) (va_arg (vl, gint *)) = g_value_get_enum (value);
+ else if (G_IS_PARAM_SPEC_FLAGS (klass->pspec))
+ *(gint *) (va_arg (vl, gint *)) = g_value_get_flags (value);
+ else if (G_IS_PARAM_SPEC_INT (klass->pspec))
+ *(gint *) (va_arg (vl, gint *)) = g_value_get_int (value);
+ else if (G_IS_PARAM_SPEC_UINT (klass->pspec))
+ *(guint *) (va_arg (vl, guint *)) = g_value_get_uint (value);
+ else if (G_IS_PARAM_SPEC_LONG (klass->pspec))
+ *(glong *) (va_arg (vl, glong *)) = g_value_get_long (value);
+ else if (G_IS_PARAM_SPEC_ULONG (klass->pspec))
+ *(gulong *) (va_arg (vl, gulong *)) = g_value_get_ulong (value);
+ else if (G_IS_PARAM_SPEC_INT64 (klass->pspec))
+ *(gint64 *) (va_arg (vl, gint64 *)) = g_value_get_int64 (value);
+ else if (G_IS_PARAM_SPEC_UINT64 (klass->pspec))
+ *(guint64 *) (va_arg (vl, guint64 *)) = g_value_get_uint64 (value);
+ else if (G_IS_PARAM_SPEC_FLOAT (klass->pspec))
+ *(gfloat *) (va_arg (vl, gdouble *)) = g_value_get_float (value);
+ else if (G_IS_PARAM_SPEC_DOUBLE (klass->pspec))
+ *(gdouble *) (va_arg (vl, gdouble *)) = g_value_get_double (value);
+ else if (G_IS_PARAM_SPEC_STRING (klass->pspec))
+ *(gchar **) (va_arg (vl, gchar *)) = (gchar *) g_value_get_string (value);
+ else if (G_IS_PARAM_SPEC_CHAR (klass->pspec))
+ *(gchar *) (va_arg (vl, gint *)) = g_value_get_char (value);
+ else if (G_IS_PARAM_SPEC_UCHAR (klass->pspec))
+ *(guchar *) (va_arg (vl, guint *)) = g_value_get_uchar (value);
+ else if (G_IS_PARAM_SPEC_UNICHAR (klass->pspec))
+ *(guint *) (va_arg (vl, gunichar *)) = g_value_get_uint (value);
+ else if (G_IS_PARAM_SPEC_BOOLEAN (klass->pspec))
+ *(gboolean *) (va_arg (vl, gboolean *)) = g_value_get_boolean (value);
+ else if (G_IS_PARAM_SPEC_OBJECT (klass->pspec))
+ *(gpointer *) (va_arg (vl, gpointer *)) = g_value_get_object (value);
+ else if (G_VALUE_HOLDS_BOXED (value))
+ *(gpointer *) (va_arg (vl, gpointer *)) = g_value_get_boxed (value);
+ else
+ g_critical ("Unsupported pspec type %s (string -> vl)",
+ g_type_name (G_PARAM_SPEC_TYPE (klass->pspec)));
}
/**
@@ -889,17 +907,16 @@ glade_property_class_set_vl_from_gvalue (GladePropertyClass *klass,
* Assignes the provided return location to @value
*/
void
-glade_property_class_get_from_gvalue (GladePropertyClass *klass,
- GValue *value,
- ...)
+glade_property_class_get_from_gvalue (GladePropertyClass * klass,
+ GValue * value, ...)
{
- va_list vl;
+ va_list vl;
- g_return_if_fail (klass != NULL);
+ g_return_if_fail (klass != NULL);
- va_start (vl, value);
- glade_property_class_set_vl_from_gvalue (klass, value, vl);
- va_end (vl);
+ va_start (vl, value);
+ glade_property_class_set_vl_from_gvalue (klass, value, vl);
+ va_end (vl);
}
@@ -907,70 +924,70 @@ glade_property_class_get_from_gvalue (GladePropertyClass *klass,
* adaptors and editors.
*/
GladePropertyClass *
-glade_property_class_new_from_spec_full (gpointer handle,
- GParamSpec *spec,
- gboolean need_handle)
+glade_property_class_new_from_spec_full (gpointer handle,
+ GParamSpec * spec,
+ gboolean need_handle)
{
- GObjectClass *gtk_widget_class;
- GladePropertyClass *property_class;
- GladeEditorProperty *eprop = NULL;
-
- g_return_val_if_fail (spec != NULL, NULL);
- gtk_widget_class = g_type_class_ref (GTK_TYPE_WIDGET);
-
- /* Only properties that are _new_from_spec() are
- * not virtual properties
- */
- property_class = glade_property_class_new (handle);
- property_class->virt = FALSE;
- property_class->pspec = spec;
-
- /* We only use the writable properties */
- if ((spec->flags & G_PARAM_WRITABLE) == 0)
- goto failed;
-
- property_class->id = g_strdup (spec->name);
- property_class->name = g_strdup (g_param_spec_get_nick (spec));
-
- /* Register only editable properties.
- */
- if (need_handle && !(eprop = glade_widget_adaptor_create_eprop
- (GLADE_WIDGET_ADAPTOR (handle), property_class, FALSE)))
- goto failed;
-
- /* Just created it to see if it was supported.... destroy now... */
- if (eprop)
- gtk_widget_destroy (GTK_WIDGET (eprop));
-
- /* If its on the GtkWidgetClass, it goes in "common"
- * (unless stipulated otherwise in the xml file)
- */
- if (g_object_class_find_property (gtk_widget_class,
- g_param_spec_get_name (spec)) != NULL)
- property_class->common = TRUE;
-
- /* Flag the construct only properties */
- if (spec->flags & G_PARAM_CONSTRUCT_ONLY)
- property_class->construct_only = TRUE;
-
- if (!property_class->id || !property_class->name)
- {
- g_critical ("No name or id for "
- "glade_property_class_new_from_spec, failed.");
- goto failed;
- }
-
- property_class->tooltip = g_strdup (g_param_spec_get_blurb (spec));
- property_class->orig_def = glade_property_class_get_default_from_spec (spec);
- property_class->def = glade_property_class_get_default_from_spec (spec);
-
- g_type_class_unref (gtk_widget_class);
- return property_class;
-
- failed:
- glade_property_class_free (property_class);
- g_type_class_unref (gtk_widget_class);
- return NULL;
+ GObjectClass *gtk_widget_class;
+ GladePropertyClass *property_class;
+ GladeEditorProperty *eprop = NULL;
+
+ g_return_val_if_fail (spec != NULL, NULL);
+ gtk_widget_class = g_type_class_ref (GTK_TYPE_WIDGET);
+
+ /* Only properties that are _new_from_spec() are
+ * not virtual properties
+ */
+ property_class = glade_property_class_new (handle);
+ property_class->virt = FALSE;
+ property_class->pspec = spec;
+
+ /* We only use the writable properties */
+ if ((spec->flags & G_PARAM_WRITABLE) == 0)
+ goto failed;
+
+ property_class->id = g_strdup (spec->name);
+ property_class->name = g_strdup (g_param_spec_get_nick (spec));
+
+ /* Register only editable properties.
+ */
+ if (need_handle && !(eprop = glade_widget_adaptor_create_eprop
+ (GLADE_WIDGET_ADAPTOR (handle), property_class, FALSE)))
+ goto failed;
+
+ /* Just created it to see if it was supported.... destroy now... */
+ if (eprop)
+ gtk_widget_destroy (GTK_WIDGET (eprop));
+
+ /* If its on the GtkWidgetClass, it goes in "common"
+ * (unless stipulated otherwise in the xml file)
+ */
+ if (g_object_class_find_property (gtk_widget_class,
+ g_param_spec_get_name (spec)) != NULL)
+ property_class->common = TRUE;
+
+ /* Flag the construct only properties */
+ if (spec->flags & G_PARAM_CONSTRUCT_ONLY)
+ property_class->construct_only = TRUE;
+
+ if (!property_class->id || !property_class->name)
+ {
+ g_critical ("No name or id for "
+ "glade_property_class_new_from_spec, failed.");
+ goto failed;
+ }
+
+ property_class->tooltip = g_strdup (g_param_spec_get_blurb (spec));
+ property_class->orig_def = glade_property_class_get_default_from_spec (spec);
+ property_class->def = glade_property_class_get_default_from_spec (spec);
+
+ g_type_class_unref (gtk_widget_class);
+ return property_class;
+
+failed:
+ glade_property_class_free (property_class);
+ g_type_class_unref (gtk_widget_class);
+ return NULL;
}
/**
@@ -982,10 +999,9 @@ glade_property_class_new_from_spec_full (gpointer handle,
* or %NULL if its unsupported.
*/
GladePropertyClass *
-glade_property_class_new_from_spec (gpointer handle,
- GParamSpec *spec)
+glade_property_class_new_from_spec (gpointer handle, GParamSpec * spec)
{
- return glade_property_class_new_from_spec_full (handle, spec, TRUE);
+ return glade_property_class_new_from_spec_full (handle, spec, TRUE);
}
/**
@@ -996,10 +1012,10 @@ glade_property_class_new_from_spec (gpointer handle,
* Returns: whether or not to show this property in the editor
*/
gboolean
-glade_property_class_is_visible (GladePropertyClass *klass)
+glade_property_class_is_visible (GladePropertyClass * klass)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
- return klass->visible;
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
+ return klass->visible;
}
/**
@@ -1010,13 +1026,13 @@ glade_property_class_is_visible (GladePropertyClass *klass)
* that refers to another object in this project.
*/
gboolean
-glade_property_class_is_object (GladePropertyClass *klass)
+glade_property_class_is_object (GladePropertyClass * klass)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
- return (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec) ||
- (G_IS_PARAM_SPEC_OBJECT(klass->pspec) &&
- klass->pspec->value_type != GDK_TYPE_PIXBUF));
+ return (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec) ||
+ (G_IS_PARAM_SPEC_OBJECT (klass->pspec) &&
+ klass->pspec->value_type != GDK_TYPE_PIXBUF));
}
/**
@@ -1028,89 +1044,91 @@ glade_property_class_is_object (GladePropertyClass *klass)
* Reads and caches displayable values from the catalog
*/
static void
-gpc_read_displayable_values_from_node (GladeXmlNode *node,
- GladePropertyClass *klass,
- const gchar *domain)
+gpc_read_displayable_values_from_node (GladeXmlNode * node,
+ GladePropertyClass * klass,
+ const gchar * domain)
{
- gpointer the_class = g_type_class_ref (klass->pspec->value_type);
- GladeXmlNode *child;
- GEnumValue *enum_values = NULL;
- GFlagsValue *flags_values = NULL;
- gint n_values, registered_values = 0;
-
- if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
- {
- GEnumClass *eclass = the_class;
- enum_values = eclass->values;
- n_values = eclass->n_values;
- }
- else
- {
- GFlagsClass *fclass = the_class;
- flags_values = fclass->values;
- n_values = fclass->n_values;
- }
-
- if ((child = glade_xml_search_child (node, GLADE_TAG_VALUE)) == NULL)
- return;
-
- child = glade_xml_node_get_children (node);
- while (child != NULL)
- {
- gint i;
- gchar *id, *name;
- GEnumValue *enum_val;
- GFlagsValue *flags_val;
-
-
- id = glade_xml_get_property_string_required (child, GLADE_TAG_ID, NULL);
- name = glade_xml_get_property_string_required (child, GLADE_TAG_NAME, NULL);
-
- if (!id || !name)
- continue;
-
- for (i = 0; i < n_values; i++)
- {
- /* is it a match ?? */
- if ((G_IS_PARAM_SPEC_ENUM (klass->pspec) &&
- (strcmp (id, enum_values[i].value_name) == 0 ||
- strcmp (id, enum_values[i].value_nick) == 0)) ||
- (G_IS_PARAM_SPEC_FLAGS (klass->pspec) &&
- (strcmp (id, flags_values[i].value_name) == 0 ||
- strcmp (id, flags_values[i].value_nick) == 0)))
- {
- registered_values++;
-
- if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
- {
- enum_val = &enum_values[i];
- glade_register_displayable_value (klass->pspec->value_type,
- enum_val->value_nick,
- domain, name);
- }
- else
- {
- flags_val = &flags_values[i];
- glade_register_displayable_value (klass->pspec->value_type,
- flags_val->value_nick,
- domain, name);
-
- }
- break;
- }
- }
-
- g_free(id);
-
- child = glade_xml_node_next (child);
- }
-
- if (n_values != registered_values)
- g_message ("%d missing displayable value for %s::%s", n_values - registered_values,
- ((GladeWidgetAdaptor*)klass->handle)->name, klass->id);
-
- g_type_class_unref (the_class);
-
+ gpointer the_class = g_type_class_ref (klass->pspec->value_type);
+ GladeXmlNode *child;
+ GEnumValue *enum_values = NULL;
+ GFlagsValue *flags_values = NULL;
+ gint n_values, registered_values = 0;
+
+ if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
+ {
+ GEnumClass *eclass = the_class;
+ enum_values = eclass->values;
+ n_values = eclass->n_values;
+ }
+ else
+ {
+ GFlagsClass *fclass = the_class;
+ flags_values = fclass->values;
+ n_values = fclass->n_values;
+ }
+
+ if ((child = glade_xml_search_child (node, GLADE_TAG_VALUE)) == NULL)
+ return;
+
+ child = glade_xml_node_get_children (node);
+ while (child != NULL)
+ {
+ gint i;
+ gchar *id, *name;
+ GEnumValue *enum_val;
+ GFlagsValue *flags_val;
+
+
+ id = glade_xml_get_property_string_required (child, GLADE_TAG_ID, NULL);
+ name =
+ glade_xml_get_property_string_required (child, GLADE_TAG_NAME, NULL);
+
+ if (!id || !name)
+ continue;
+
+ for (i = 0; i < n_values; i++)
+ {
+ /* is it a match ?? */
+ if ((G_IS_PARAM_SPEC_ENUM (klass->pspec) &&
+ (strcmp (id, enum_values[i].value_name) == 0 ||
+ strcmp (id, enum_values[i].value_nick) == 0)) ||
+ (G_IS_PARAM_SPEC_FLAGS (klass->pspec) &&
+ (strcmp (id, flags_values[i].value_name) == 0 ||
+ strcmp (id, flags_values[i].value_nick) == 0)))
+ {
+ registered_values++;
+
+ if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
+ {
+ enum_val = &enum_values[i];
+ glade_register_displayable_value (klass->pspec->value_type,
+ enum_val->value_nick,
+ domain, name);
+ }
+ else
+ {
+ flags_val = &flags_values[i];
+ glade_register_displayable_value (klass->pspec->value_type,
+ flags_val->value_nick,
+ domain, name);
+
+ }
+ break;
+ }
+ }
+
+ g_free (id);
+
+ child = glade_xml_node_next (child);
+ }
+
+ if (n_values != registered_values)
+ g_message ("%d missing displayable value for %s::%s",
+ n_values - registered_values,
+ ((GladeWidgetAdaptor *) klass->handle)->name, klass->id);
+
+ g_type_class_unref (the_class);
+
}
/**
@@ -1122,233 +1140,257 @@ gpc_read_displayable_values_from_node (GladeXmlNode *node,
* Returns: An appropriate #GtkAdjustment for use in the Property editor
*/
GtkAdjustment *
-glade_property_class_make_adjustment (GladePropertyClass *property_class)
+glade_property_class_make_adjustment (GladePropertyClass * property_class)
{
- GtkAdjustment *adjustment;
- gdouble min = 0, max = 0, def = 0;
- gboolean float_range = FALSE;
-
- g_return_val_if_fail (property_class != NULL, NULL);
- g_return_val_if_fail (property_class->pspec != NULL, NULL);
-
- if (G_IS_PARAM_SPEC_INT(property_class->pspec))
- {
- min = (gdouble)((GParamSpecInt *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecInt *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecInt *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_UINT(property_class->pspec))
- {
- min = (gdouble)((GParamSpecUInt *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecUInt *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecUInt *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_LONG(property_class->pspec))
- {
- min = (gdouble)((GParamSpecLong *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecLong *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecLong *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_ULONG(property_class->pspec))
- {
- min = (gdouble)((GParamSpecULong *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecULong *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecULong *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_INT64(property_class->pspec))
- {
- min = (gdouble)((GParamSpecInt64 *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecInt64 *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecInt64 *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_UINT64(property_class->pspec))
- {
- min = (gdouble)((GParamSpecUInt64 *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecUInt64 *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecUInt64 *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_FLOAT(property_class->pspec))
- {
- float_range = TRUE;
- min = ((GParamSpecFloat *) property_class->pspec)->minimum;
- max = ((GParamSpecFloat *) property_class->pspec)->maximum;
- def = ((GParamSpecFloat *) property_class->pspec)->default_value;
- } else if (G_IS_PARAM_SPEC_DOUBLE(property_class->pspec))
- {
- float_range = TRUE;
- min = (gdouble)((GParamSpecDouble *) property_class->pspec)->minimum;
- max = (gdouble)((GParamSpecDouble *) property_class->pspec)->maximum;
- def = (gdouble)((GParamSpecDouble *) property_class->pspec)->default_value;
- } else
- {
- g_critical ("Can't make adjustment for pspec type %s",
- g_type_name(G_PARAM_SPEC_TYPE (property_class->pspec)));
- }
-
- adjustment = (GtkAdjustment *)gtk_adjustment_new (def, min, max,
- float_range ?
- FLOATING_STEP_INCREMENT :
- NUMERICAL_STEP_INCREMENT,
- float_range ? FLOATING_PAGE_INCREMENT :
- NUMERICAL_PAGE_INCREMENT,
- float_range ? FLOATING_PAGE_SIZE :
- NUMERICAL_PAGE_SIZE);
- return adjustment;
+ GtkAdjustment *adjustment;
+ gdouble min = 0, max = 0, def = 0;
+ gboolean float_range = FALSE;
+
+ g_return_val_if_fail (property_class != NULL, NULL);
+ g_return_val_if_fail (property_class->pspec != NULL, NULL);
+
+ if (G_IS_PARAM_SPEC_INT (property_class->pspec))
+ {
+ min = (gdouble) ((GParamSpecInt *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecInt *) property_class->pspec)->maximum;
+ def = (gdouble) ((GParamSpecInt *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_UINT (property_class->pspec))
+ {
+ min = (gdouble) ((GParamSpecUInt *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecUInt *) property_class->pspec)->maximum;
+ def = (gdouble) ((GParamSpecUInt *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_LONG (property_class->pspec))
+ {
+ min = (gdouble) ((GParamSpecLong *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecLong *) property_class->pspec)->maximum;
+ def = (gdouble) ((GParamSpecLong *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_ULONG (property_class->pspec))
+ {
+ min = (gdouble) ((GParamSpecULong *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecULong *) property_class->pspec)->maximum;
+ def =
+ (gdouble) ((GParamSpecULong *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_INT64 (property_class->pspec))
+ {
+ min = (gdouble) ((GParamSpecInt64 *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecInt64 *) property_class->pspec)->maximum;
+ def =
+ (gdouble) ((GParamSpecInt64 *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_UINT64 (property_class->pspec))
+ {
+ min = (gdouble) ((GParamSpecUInt64 *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecUInt64 *) property_class->pspec)->maximum;
+ def =
+ (gdouble) ((GParamSpecUInt64 *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_FLOAT (property_class->pspec))
+ {
+ float_range = TRUE;
+ min = ((GParamSpecFloat *) property_class->pspec)->minimum;
+ max = ((GParamSpecFloat *) property_class->pspec)->maximum;
+ def = ((GParamSpecFloat *) property_class->pspec)->default_value;
+ }
+ else if (G_IS_PARAM_SPEC_DOUBLE (property_class->pspec))
+ {
+ float_range = TRUE;
+ min = (gdouble) ((GParamSpecDouble *) property_class->pspec)->minimum;
+ max = (gdouble) ((GParamSpecDouble *) property_class->pspec)->maximum;
+ def =
+ (gdouble) ((GParamSpecDouble *) property_class->pspec)->default_value;
+ }
+ else
+ {
+ g_critical ("Can't make adjustment for pspec type %s",
+ g_type_name (G_PARAM_SPEC_TYPE (property_class->pspec)));
+ }
+
+ adjustment = (GtkAdjustment *) gtk_adjustment_new (def, min, max,
+ float_range ?
+ FLOATING_STEP_INCREMENT :
+ NUMERICAL_STEP_INCREMENT,
+ float_range ?
+ FLOATING_PAGE_INCREMENT :
+ NUMERICAL_PAGE_INCREMENT,
+ float_range ?
+ FLOATING_PAGE_SIZE :
+ NUMERICAL_PAGE_SIZE);
+ return adjustment;
}
static GParamSpec *
-glade_property_class_parse_specifications (GladePropertyClass *klass,
- GladeXmlNode *spec_node)
+glade_property_class_parse_specifications (GladePropertyClass * klass,
+ GladeXmlNode * spec_node)
{
- gchar *string;
- GType spec_type = 0, value_type = 0;
- GParamSpec *pspec = NULL;
-
- if ((string = glade_xml_get_value_string_required
- (spec_node, GLADE_TAG_TYPE, "Need a type of GParamSpec to define")) != NULL)
- spec_type = glade_util_get_type_from_name (string, FALSE);
-
- g_free (string);
-
- g_return_val_if_fail (spec_type != 0, NULL);
-
- if (spec_type == G_TYPE_PARAM_ENUM ||
- spec_type == G_TYPE_PARAM_FLAGS ||
- spec_type == G_TYPE_PARAM_BOXED ||
- spec_type == G_TYPE_PARAM_OBJECT ||
- spec_type == GLADE_TYPE_PARAM_OBJECTS)
- {
- if ((string = glade_xml_get_value_string_required
- (spec_node, GLADE_TAG_VALUE_TYPE,
- "Need a value type to define enums flags boxed and object specs")) != NULL)
- value_type = glade_util_get_type_from_name (string, FALSE);
-
- g_free (string);
-
- g_return_val_if_fail (value_type != 0, NULL);
-
- if (spec_type == G_TYPE_PARAM_ENUM)
- {
- GEnumClass *eclass = g_type_class_ref (value_type);
- pspec = g_param_spec_enum ("dummy", "dummy", "dummy",
- value_type, eclass->minimum, G_PARAM_READABLE|G_PARAM_WRITABLE);
- g_type_class_unref (eclass);
- }
- else if (spec_type == G_TYPE_PARAM_FLAGS)
- pspec = g_param_spec_flags ("dummy", "dummy", "dummy",
- value_type, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (spec_type == G_TYPE_PARAM_OBJECT)
- pspec = g_param_spec_object ("dummy", "dummy", "dummy",
- value_type, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (spec_type == GLADE_TYPE_PARAM_OBJECTS)
- pspec = glade_param_spec_objects ("dummy", "dummy", "dummy",
- value_type, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else/* if (spec_type == G_TYPE_PARAM_BOXED) */
- pspec = g_param_spec_boxed ("dummy", "dummy", "dummy",
- value_type, G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_STRING)
- pspec = g_param_spec_string ("dummy", "dummy", "dummy",
- NULL, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (spec_type == G_TYPE_PARAM_BOOLEAN)
- pspec = g_param_spec_boolean ("dummy", "dummy", "dummy",
- FALSE, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else
- {
- gchar *minstr, *maxstr;
-
- minstr = glade_xml_get_value_string (spec_node, GLADE_TAG_MIN_VALUE);
- maxstr = glade_xml_get_value_string (spec_node, GLADE_TAG_MAX_VALUE);
-
- if (spec_type == G_TYPE_PARAM_CHAR)
- {
- gint8 min = minstr ? minstr[0]: G_MININT8;
- gint8 max = maxstr ? maxstr[0]: G_MAXINT8;
-
- pspec = g_param_spec_char ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_UCHAR)
- {
- guint8 min = minstr ? minstr[0]: 0;
- guint8 max = maxstr ? maxstr[0]: G_MAXUINT8;
-
- pspec = g_param_spec_uchar ("dummy", "dummy", "dummy",
- min, max, 0,
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_INT)
- {
- gint min = minstr ? g_ascii_strtoll (minstr, NULL, 10): G_MININT;
- gint max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10): G_MAXINT;
-
- pspec = g_param_spec_int ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_UINT)
- {
- guint min = minstr ? g_ascii_strtoll (minstr, NULL, 10): 0;
- guint max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10): G_MAXUINT;
-
- pspec = g_param_spec_uint ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_LONG)
- {
- glong min = minstr ? g_ascii_strtoll (minstr, NULL, 10): G_MINLONG;
- glong max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10): G_MAXLONG;
-
- pspec = g_param_spec_long ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_ULONG)
- {
- gulong min = minstr ? g_ascii_strtoll (minstr, NULL, 10): 0;
- gulong max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10): G_MAXULONG;
-
- pspec = g_param_spec_ulong ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_INT64)
- {
- gint64 min = minstr ? g_ascii_strtoll (minstr, NULL, 10): G_MININT64;
- gint64 max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10): G_MAXINT64;
-
- pspec = g_param_spec_int64 ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_UINT64)
- {
- guint64 min = minstr ? g_ascii_strtoll (minstr, NULL, 10): 0;
- guint64 max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10): G_MAXUINT64;
-
- pspec = g_param_spec_uint64 ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_FLOAT)
- {
- gfloat min = minstr ? (float) g_ascii_strtod (minstr, NULL) : G_MINFLOAT;
- gfloat max = maxstr ? (float) g_ascii_strtod (maxstr, NULL) : G_MAXFLOAT;
-
- pspec = g_param_spec_float ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else if (spec_type == G_TYPE_PARAM_DOUBLE)
- {
- gdouble min = minstr ? g_ascii_strtod (minstr, NULL) : G_MINFLOAT;
- gdouble max = maxstr ? g_ascii_strtod (maxstr, NULL) : G_MAXFLOAT;
-
- pspec = g_param_spec_float ("dummy", "dummy", "dummy",
- min, max, CLAMP (0, min, max),
- G_PARAM_READABLE|G_PARAM_WRITABLE);
- }
- else
- g_critical ("Unsupported pspec type %s (value -> string)", g_type_name (spec_type));
- }
- return pspec;
+ gchar *string;
+ GType spec_type = 0, value_type = 0;
+ GParamSpec *pspec = NULL;
+
+ if ((string = glade_xml_get_value_string_required
+ (spec_node, GLADE_TAG_TYPE,
+ "Need a type of GParamSpec to define")) != NULL)
+ spec_type = glade_util_get_type_from_name (string, FALSE);
+
+ g_free (string);
+
+ g_return_val_if_fail (spec_type != 0, NULL);
+
+ if (spec_type == G_TYPE_PARAM_ENUM ||
+ spec_type == G_TYPE_PARAM_FLAGS ||
+ spec_type == G_TYPE_PARAM_BOXED ||
+ spec_type == G_TYPE_PARAM_OBJECT || spec_type == GLADE_TYPE_PARAM_OBJECTS)
+ {
+ if ((string = glade_xml_get_value_string_required
+ (spec_node, GLADE_TAG_VALUE_TYPE,
+ "Need a value type to define enums flags boxed and object specs"))
+ != NULL)
+ value_type = glade_util_get_type_from_name (string, FALSE);
+
+ g_free (string);
+
+ g_return_val_if_fail (value_type != 0, NULL);
+
+ if (spec_type == G_TYPE_PARAM_ENUM)
+ {
+ GEnumClass *eclass = g_type_class_ref (value_type);
+ pspec = g_param_spec_enum ("dummy", "dummy", "dummy",
+ value_type, eclass->minimum,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ g_type_class_unref (eclass);
+ }
+ else if (spec_type == G_TYPE_PARAM_FLAGS)
+ pspec = g_param_spec_flags ("dummy", "dummy", "dummy",
+ value_type, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (spec_type == G_TYPE_PARAM_OBJECT)
+ pspec = g_param_spec_object ("dummy", "dummy", "dummy",
+ value_type,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (spec_type == GLADE_TYPE_PARAM_OBJECTS)
+ pspec = glade_param_spec_objects ("dummy", "dummy", "dummy",
+ value_type,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else /* if (spec_type == G_TYPE_PARAM_BOXED) */
+ pspec = g_param_spec_boxed ("dummy", "dummy", "dummy",
+ value_type,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_STRING)
+ pspec = g_param_spec_string ("dummy", "dummy", "dummy",
+ NULL, G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (spec_type == G_TYPE_PARAM_BOOLEAN)
+ pspec = g_param_spec_boolean ("dummy", "dummy", "dummy",
+ FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else
+ {
+ gchar *minstr, *maxstr;
+
+ minstr = glade_xml_get_value_string (spec_node, GLADE_TAG_MIN_VALUE);
+ maxstr = glade_xml_get_value_string (spec_node, GLADE_TAG_MAX_VALUE);
+
+ if (spec_type == G_TYPE_PARAM_CHAR)
+ {
+ gint8 min = minstr ? minstr[0] : G_MININT8;
+ gint8 max = maxstr ? maxstr[0] : G_MAXINT8;
+
+ pspec = g_param_spec_char ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_UCHAR)
+ {
+ guint8 min = minstr ? minstr[0] : 0;
+ guint8 max = maxstr ? maxstr[0] : G_MAXUINT8;
+
+ pspec = g_param_spec_uchar ("dummy", "dummy", "dummy",
+ min, max, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_INT)
+ {
+ gint min = minstr ? g_ascii_strtoll (minstr, NULL, 10) : G_MININT;
+ gint max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10) : G_MAXINT;
+
+ pspec = g_param_spec_int ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_UINT)
+ {
+ guint min = minstr ? g_ascii_strtoll (minstr, NULL, 10) : 0;
+ guint max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10) : G_MAXUINT;
+
+ pspec = g_param_spec_uint ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_LONG)
+ {
+ glong min = minstr ? g_ascii_strtoll (minstr, NULL, 10) : G_MINLONG;
+ glong max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10) : G_MAXLONG;
+
+ pspec = g_param_spec_long ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_ULONG)
+ {
+ gulong min = minstr ? g_ascii_strtoll (minstr, NULL, 10) : 0;
+ gulong max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10) : G_MAXULONG;
+
+ pspec = g_param_spec_ulong ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_INT64)
+ {
+ gint64 min = minstr ? g_ascii_strtoll (minstr, NULL, 10) : G_MININT64;
+ gint64 max = maxstr ? g_ascii_strtoll (maxstr, NULL, 10) : G_MAXINT64;
+
+ pspec = g_param_spec_int64 ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_UINT64)
+ {
+ guint64 min = minstr ? g_ascii_strtoll (minstr, NULL, 10) : 0;
+ guint64 max =
+ maxstr ? g_ascii_strtoll (maxstr, NULL, 10) : G_MAXUINT64;
+
+ pspec = g_param_spec_uint64 ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_FLOAT)
+ {
+ gfloat min =
+ minstr ? (float) g_ascii_strtod (minstr, NULL) : G_MINFLOAT;
+ gfloat max =
+ maxstr ? (float) g_ascii_strtod (maxstr, NULL) : G_MAXFLOAT;
+
+ pspec = g_param_spec_float ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else if (spec_type == G_TYPE_PARAM_DOUBLE)
+ {
+ gdouble min = minstr ? g_ascii_strtod (minstr, NULL) : G_MINFLOAT;
+ gdouble max = maxstr ? g_ascii_strtod (maxstr, NULL) : G_MAXFLOAT;
+
+ pspec = g_param_spec_float ("dummy", "dummy", "dummy",
+ min, max, CLAMP (0, min, max),
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ }
+ else
+ g_critical ("Unsupported pspec type %s (value -> string)",
+ g_type_name (spec_type));
+ }
+ return pspec;
}
@@ -1367,207 +1409,249 @@ glade_property_class_parse_specifications (GladePropertyClass *klass,
* has Disabled="TRUE".
*/
gboolean
-glade_property_class_update_from_node (GladeXmlNode *node,
- GModule *module,
- GType object_type,
- GladePropertyClass **property_class,
- const gchar *domain)
+glade_property_class_update_from_node (GladeXmlNode * node,
+ GModule * module,
+ GType object_type,
+ GladePropertyClass ** property_class,
+ const gchar * domain)
{
- GladePropertyClass *klass;
- GParamSpec *pspec = NULL;
- gchar *buf, *translated;
- GladeXmlNode *child, *spec_node;
-
- g_return_val_if_fail (property_class != NULL, FALSE);
-
- /* for code cleanliness... */
- klass = *property_class;
-
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
- g_return_val_if_fail (glade_xml_node_verify (node, GLADE_TAG_PROPERTY), FALSE);
-
- /* check the id */
- buf = glade_xml_get_property_string_required (node, GLADE_TAG_ID, NULL);
- if (!buf)
- return FALSE;
- g_free (buf);
-
- if (glade_xml_get_property_boolean (node, GLADE_TAG_DISABLED, FALSE))
- {
- /* Its easier for us to keep disabled properties around and
- * only virtually disable them */
- klass->ignore = TRUE;
- klass->save = FALSE;
- klass->visible = FALSE;
- }
-
- if ((spec_node = glade_xml_search_child (node, GLADE_TAG_SPECIFICATIONS)) != NULL)
- pspec = glade_property_class_parse_specifications (klass, spec_node);
- else if ((buf = glade_xml_get_value_string (node, GLADE_TAG_SPEC)) != NULL)
- {
- pspec = glade_utils_get_pspec_from_funcname (buf);
- g_free (buf);
- }
-
- /* ... get the tooltip from the pspec ... */
- if (pspec != NULL)
- {
- klass->pspec = pspec;
-
- /* Make sure we can tell properties apart by there
- * owning class.
- */
- klass->pspec->owner_type = object_type;
-
- /* We overrode the pspec, now it *is* a virtual property. */
- klass->virt = TRUE;
-
- if (strcmp (g_param_spec_get_blurb (klass->pspec), "dummy") != 0)
- {
- g_free (klass->tooltip);
- klass->tooltip = g_strdup (g_param_spec_get_blurb (klass->pspec));
- }
-
- if (klass->name == NULL || strcmp (g_param_spec_get_nick (klass->pspec), "dummy") != 0)
- {
- g_free (klass->name);
- klass->name = g_strdup (g_param_spec_get_nick (klass->pspec));
- }
-
- if (klass->pspec->flags & G_PARAM_CONSTRUCT_ONLY)
- klass->construct_only = TRUE;
-
- if (klass->orig_def) {
- g_value_unset (klass->orig_def);
- g_free (klass->orig_def);
- }
- klass->orig_def = glade_property_class_get_default_from_spec (klass->pspec);
-
- if (klass->def) {
- g_value_unset (klass->def);
- g_free (klass->def);
- }
- klass->def = glade_property_class_get_default_from_spec (klass->pspec);
-
- }
- else if (!klass->pspec)
- {
- /* If catalog file didn't specify a pspec function
- * and this property isn't found by introspection
- * we simply delete it from the list always.
- */
- glade_property_class_free (klass);
- *property_class = NULL;
- return TRUE;
- }
-
- /* Get the default */
- if ((buf = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT)) != NULL)
- {
- if (klass->def) {
- g_value_unset (klass->def);
- g_free (klass->def);
- }
- klass->def = glade_property_class_make_gvalue_from_string (klass, buf, NULL, NULL);
-
- if (klass->virt) {
- g_value_unset (klass->orig_def);
- g_free (klass->orig_def);
- klass->orig_def = glade_property_class_make_gvalue_from_string (klass, buf, NULL, NULL);
- }
-
- g_free (buf);
- }
-
- /* If needed, update the name... */
- if ((buf = glade_xml_get_property_string (node, GLADE_TAG_NAME)) != NULL)
- {
- g_free (klass->name);
-
- translated = dgettext (domain, buf);
- if (buf != translated)
- {
- /* translated is owned by gettext */
- klass->name = g_strdup (translated);
- g_free (buf);
- }
- else
- {
- klass->name = buf;
- }
- }
-
- /* ...and the tooltip */
- if ((buf = glade_xml_get_value_string (node, GLADE_TAG_TOOLTIP)) != NULL)
- {
- g_free (klass->tooltip);
-
- translated = dgettext (domain, buf);
- if (buf != translated)
- {
- /* translated is owned by gettext */
- klass->tooltip = g_strdup (translated);
- g_free (buf);
- }
- else
- {
- klass->tooltip = buf;
- }
- }
-
- /* Visible lines */
- glade_xml_get_value_int (node, GLADE_TAG_VISIBLE_LINES, &klass->visible_lines);
-
- /* Get the Parameters */
- if ((child = glade_xml_search_child (node, GLADE_TAG_PARAMETERS)) != NULL)
- klass->parameters = glade_parameter_list_new_from_node (klass->parameters, child);
-
- klass->construct_only = glade_xml_get_property_boolean (node, GLADE_TAG_CONSTRUCT_ONLY, klass->construct_only);
- klass->translatable = glade_xml_get_property_boolean (node, GLADE_TAG_TRANSLATABLE, klass->translatable);
- klass->common = glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, klass->common);
- klass->optional = glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL, klass->optional);
- klass->query = glade_xml_get_property_boolean (node, GLADE_TAG_QUERY, klass->query);
- klass->save = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, klass->save);
- klass->visible = glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, klass->visible);
- klass->custom_layout = glade_xml_get_property_boolean (node, GLADE_TAG_CUSTOM_LAYOUT, klass->custom_layout);
- klass->ignore = glade_xml_get_property_boolean (node, GLADE_TAG_IGNORE, klass->ignore);
- klass->needs_sync = glade_xml_get_property_boolean (node, GLADE_TAG_NEEDS_SYNC, klass->needs_sync);
- klass->themed_icon = glade_xml_get_property_boolean (node, GLADE_TAG_THEMED_ICON, klass->themed_icon);
- klass->stock = glade_xml_get_property_boolean (node, GLADE_TAG_STOCK, klass->stock);
- klass->stock_icon = glade_xml_get_property_boolean (node, GLADE_TAG_STOCK_ICON, klass->stock_icon);
- klass->weight = glade_xml_get_property_double (node, GLADE_TAG_WEIGHT, klass->weight);
- klass->transfer_on_paste = glade_xml_get_property_boolean (node, GLADE_TAG_TRANSFER_ON_PASTE, klass->transfer_on_paste);
- klass->save_always = glade_xml_get_property_boolean (node, GLADE_TAG_SAVE_ALWAYS, klass->save_always);
- klass->parentless_widget = glade_xml_get_property_boolean (node, GLADE_TAG_PARENTLESS_WIDGET, klass->parentless_widget);
-
-
- if ((buf = glade_xml_get_property_string
- (node, GLADE_TAG_CREATE_TYPE)) != NULL)
- {
- if (klass->create_type)
- g_free (klass->create_type);
- klass->create_type = buf;
- }
-
- /* If this property's value is an enumeration or flag then we try to get the displayable values */
- if ((G_IS_PARAM_SPEC_ENUM(klass->pspec) || G_IS_PARAM_SPEC_FLAGS(klass->pspec)) &&
- (child = glade_xml_search_child (node, GLADE_TAG_DISPLAYABLE_VALUES)))
- gpc_read_displayable_values_from_node (child, klass, domain);
-
- /* Right now allowing the backend to specify that some properties
- * go in the atk tab, ideally this shouldnt be needed.
- */
- klass->atk = glade_xml_get_property_boolean (node, GLADE_TAG_ATK_PROPERTY, klass->atk);
-
- if (klass->optional)
- klass->optional_default =
- glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL_DEFAULT,
- klass->optional_default);
-
- /* notify that we changed the property class */
- klass->is_modified = TRUE;
-
- return TRUE;
+ GladePropertyClass *klass;
+ GParamSpec *pspec = NULL;
+ gchar *buf, *translated;
+ GladeXmlNode *child, *spec_node;
+
+ g_return_val_if_fail (property_class != NULL, FALSE);
+
+ /* for code cleanliness... */
+ klass = *property_class;
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
+ g_return_val_if_fail (glade_xml_node_verify (node, GLADE_TAG_PROPERTY),
+ FALSE);
+
+ /* check the id */
+ buf = glade_xml_get_property_string_required (node, GLADE_TAG_ID, NULL);
+ if (!buf)
+ return FALSE;
+ g_free (buf);
+
+ if (glade_xml_get_property_boolean (node, GLADE_TAG_DISABLED, FALSE))
+ {
+ /* Its easier for us to keep disabled properties around and
+ * only virtually disable them */
+ klass->ignore = TRUE;
+ klass->save = FALSE;
+ klass->visible = FALSE;
+ }
+
+ if ((spec_node =
+ glade_xml_search_child (node, GLADE_TAG_SPECIFICATIONS)) != NULL)
+ pspec = glade_property_class_parse_specifications (klass, spec_node);
+ else if ((buf = glade_xml_get_value_string (node, GLADE_TAG_SPEC)) != NULL)
+ {
+ pspec = glade_utils_get_pspec_from_funcname (buf);
+ g_free (buf);
+ }
+
+ /* ... get the tooltip from the pspec ... */
+ if (pspec != NULL)
+ {
+ klass->pspec = pspec;
+
+ /* Make sure we can tell properties apart by there
+ * owning class.
+ */
+ klass->pspec->owner_type = object_type;
+
+ /* We overrode the pspec, now it *is* a virtual property. */
+ klass->virt = TRUE;
+
+ if (strcmp (g_param_spec_get_blurb (klass->pspec), "dummy") != 0)
+ {
+ g_free (klass->tooltip);
+ klass->tooltip = g_strdup (g_param_spec_get_blurb (klass->pspec));
+ }
+
+ if (klass->name == NULL ||
+ strcmp (g_param_spec_get_nick (klass->pspec), "dummy") != 0)
+ {
+ g_free (klass->name);
+ klass->name = g_strdup (g_param_spec_get_nick (klass->pspec));
+ }
+
+ if (klass->pspec->flags & G_PARAM_CONSTRUCT_ONLY)
+ klass->construct_only = TRUE;
+
+ if (klass->orig_def)
+ {
+ g_value_unset (klass->orig_def);
+ g_free (klass->orig_def);
+ }
+ klass->orig_def =
+ glade_property_class_get_default_from_spec (klass->pspec);
+
+ if (klass->def)
+ {
+ g_value_unset (klass->def);
+ g_free (klass->def);
+ }
+ klass->def = glade_property_class_get_default_from_spec (klass->pspec);
+
+ }
+ else if (!klass->pspec)
+ {
+ /* If catalog file didn't specify a pspec function
+ * and this property isn't found by introspection
+ * we simply delete it from the list always.
+ */
+ glade_property_class_free (klass);
+ *property_class = NULL;
+ return TRUE;
+ }
+
+ /* Get the default */
+ if ((buf = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT)) != NULL)
+ {
+ if (klass->def)
+ {
+ g_value_unset (klass->def);
+ g_free (klass->def);
+ }
+ klass->def =
+ glade_property_class_make_gvalue_from_string (klass, buf, NULL, NULL);
+
+ if (klass->virt)
+ {
+ g_value_unset (klass->orig_def);
+ g_free (klass->orig_def);
+ klass->orig_def =
+ glade_property_class_make_gvalue_from_string (klass, buf, NULL,
+ NULL);
+ }
+
+ g_free (buf);
+ }
+
+ /* If needed, update the name... */
+ if ((buf = glade_xml_get_property_string (node, GLADE_TAG_NAME)) != NULL)
+ {
+ g_free (klass->name);
+
+ translated = dgettext (domain, buf);
+ if (buf != translated)
+ {
+ /* translated is owned by gettext */
+ klass->name = g_strdup (translated);
+ g_free (buf);
+ }
+ else
+ {
+ klass->name = buf;
+ }
+ }
+
+ /* ...and the tooltip */
+ if ((buf = glade_xml_get_value_string (node, GLADE_TAG_TOOLTIP)) != NULL)
+ {
+ g_free (klass->tooltip);
+
+ translated = dgettext (domain, buf);
+ if (buf != translated)
+ {
+ /* translated is owned by gettext */
+ klass->tooltip = g_strdup (translated);
+ g_free (buf);
+ }
+ else
+ {
+ klass->tooltip = buf;
+ }
+ }
+
+ /* Visible lines */
+ glade_xml_get_value_int (node, GLADE_TAG_VISIBLE_LINES,
+ &klass->visible_lines);
+
+ /* Get the Parameters */
+ if ((child = glade_xml_search_child (node, GLADE_TAG_PARAMETERS)) != NULL)
+ klass->parameters =
+ glade_parameter_list_new_from_node (klass->parameters, child);
+
+ klass->construct_only =
+ glade_xml_get_property_boolean (node, GLADE_TAG_CONSTRUCT_ONLY,
+ klass->construct_only);
+ klass->translatable =
+ glade_xml_get_property_boolean (node, GLADE_TAG_TRANSLATABLE,
+ klass->translatable);
+ klass->common =
+ glade_xml_get_property_boolean (node, GLADE_TAG_COMMON, klass->common);
+ klass->optional =
+ glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL,
+ klass->optional);
+ klass->query =
+ glade_xml_get_property_boolean (node, GLADE_TAG_QUERY, klass->query);
+ klass->save =
+ glade_xml_get_property_boolean (node, GLADE_TAG_SAVE, klass->save);
+ klass->visible =
+ glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, klass->visible);
+ klass->custom_layout =
+ glade_xml_get_property_boolean (node, GLADE_TAG_CUSTOM_LAYOUT,
+ klass->custom_layout);
+ klass->ignore =
+ glade_xml_get_property_boolean (node, GLADE_TAG_IGNORE, klass->ignore);
+ klass->needs_sync =
+ glade_xml_get_property_boolean (node, GLADE_TAG_NEEDS_SYNC,
+ klass->needs_sync);
+ klass->themed_icon =
+ glade_xml_get_property_boolean (node, GLADE_TAG_THEMED_ICON,
+ klass->themed_icon);
+ klass->stock =
+ glade_xml_get_property_boolean (node, GLADE_TAG_STOCK, klass->stock);
+ klass->stock_icon =
+ glade_xml_get_property_boolean (node, GLADE_TAG_STOCK_ICON,
+ klass->stock_icon);
+ klass->weight =
+ glade_xml_get_property_double (node, GLADE_TAG_WEIGHT, klass->weight);
+ klass->transfer_on_paste =
+ glade_xml_get_property_boolean (node, GLADE_TAG_TRANSFER_ON_PASTE,
+ klass->transfer_on_paste);
+ klass->save_always =
+ glade_xml_get_property_boolean (node, GLADE_TAG_SAVE_ALWAYS,
+ klass->save_always);
+ klass->parentless_widget =
+ glade_xml_get_property_boolean (node, GLADE_TAG_PARENTLESS_WIDGET,
+ klass->parentless_widget);
+
+
+ if ((buf = glade_xml_get_property_string
+ (node, GLADE_TAG_CREATE_TYPE)) != NULL)
+ {
+ if (klass->create_type)
+ g_free (klass->create_type);
+ klass->create_type = buf;
+ }
+
+ /* If this property's value is an enumeration or flag then we try to get the displayable values */
+ if ((G_IS_PARAM_SPEC_ENUM (klass->pspec) ||
+ G_IS_PARAM_SPEC_FLAGS (klass->pspec)) &&
+ (child = glade_xml_search_child (node, GLADE_TAG_DISPLAYABLE_VALUES)))
+ gpc_read_displayable_values_from_node (child, klass, domain);
+
+ /* Right now allowing the backend to specify that some properties
+ * go in the atk tab, ideally this shouldnt be needed.
+ */
+ klass->atk =
+ glade_xml_get_property_boolean (node, GLADE_TAG_ATK_PROPERTY, klass->atk);
+
+ if (klass->optional)
+ klass->optional_default =
+ glade_xml_get_property_boolean (node, GLADE_TAG_OPTIONAL_DEFAULT,
+ klass->optional_default);
+
+ /* notify that we changed the property class */
+ klass->is_modified = TRUE;
+
+ return TRUE;
}
@@ -1582,15 +1666,15 @@ glade_property_class_update_from_node (GladeXmlNode *node,
* have the same name are not matches).
*/
gboolean
-glade_property_class_match (GladePropertyClass *klass,
- GladePropertyClass *comp)
+glade_property_class_match (GladePropertyClass * klass,
+ GladePropertyClass * comp)
{
- g_return_val_if_fail (klass != NULL, FALSE);
- g_return_val_if_fail (comp != NULL, FALSE);
+ g_return_val_if_fail (klass != NULL, FALSE);
+ g_return_val_if_fail (comp != NULL, FALSE);
- return (strcmp (klass->id, comp->id) == 0 &&
- klass->packing == comp->packing &&
- klass->pspec->owner_type == comp->pspec->owner_type);
+ return (strcmp (klass->id, comp->id) == 0 &&
+ klass->packing == comp->packing &&
+ klass->pspec->owner_type == comp->pspec->owner_type);
}
@@ -1602,19 +1686,18 @@ glade_property_class_match (GladePropertyClass *klass,
* can be a %NULL value for boxed or object type param specs.
*/
gboolean
-glade_property_class_void_value (GladePropertyClass *klass,
- GValue *value)
+glade_property_class_void_value (GladePropertyClass * klass, GValue * value)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
-
- if (G_IS_PARAM_SPEC_OBJECT (klass->pspec) &&
- g_value_get_object (value) == NULL)
- return TRUE;
- else if (G_IS_PARAM_SPEC_BOXED (klass->pspec) &&
- g_value_get_boxed (value) == NULL)
- return TRUE;
-
- return FALSE;
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), FALSE);
+
+ if (G_IS_PARAM_SPEC_OBJECT (klass->pspec) &&
+ g_value_get_object (value) == NULL)
+ return TRUE;
+ else if (G_IS_PARAM_SPEC_BOXED (klass->pspec) &&
+ g_value_get_boxed (value) == NULL)
+ return TRUE;
+
+ return FALSE;
}
/**
@@ -1629,54 +1712,55 @@ glade_property_class_void_value (GladePropertyClass *klass,
* equal to or greater than value2, respectively.
*/
gint
-glade_property_class_compare (GladePropertyClass *klass,
- const GValue *value1,
- const GValue *value2)
+glade_property_class_compare (GladePropertyClass * klass,
+ const GValue * value1, const GValue * value2)
{
- gint retval;
-
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), -1);
-
- /* GLib does not know how to compare a boxed real value */
- if (G_VALUE_HOLDS_BOXED (value1) || G_VALUE_HOLDS_BOXED (value2))
- {
- gchar *val1, *val2;
-
- /* So boxed types are compared by string and the backend is required to generate
- * unique strings for values for this purpose.
- *
- * NOTE: We could add a pclass option to use the string compare vs. boxed compare...
- */
- val1 = glade_widget_adaptor_string_from_value (klass->handle, klass, value1);
- val2 = glade_widget_adaptor_string_from_value (klass->handle, klass, value2);
-
- if (val1 && val2)
- retval = strcmp (val1, val2);
- else
- retval = val1 - val2;
-
- g_free (val1);
- g_free (val2);
- }
- else
- {
- if (G_IS_PARAM_SPEC_STRING (klass->pspec))
- {
- const gchar *value_str1, *value_str2;
-
- /* in string specs; NULL and '\0' are
- * treated as equivalent.
- */
- value_str1 = g_value_get_string (value1);
- value_str2 = g_value_get_string (value2);
-
- if (value_str1 == NULL && value_str2 && value_str2[0] == '\0')
- return 0;
- else if (value_str2 == NULL && value_str1 && value_str1[0] == '\0')
- return 0;
- }
- retval = g_param_values_cmp (klass->pspec, value1, value2);
- }
-
- return retval;
+ gint retval;
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), -1);
+
+ /* GLib does not know how to compare a boxed real value */
+ if (G_VALUE_HOLDS_BOXED (value1) || G_VALUE_HOLDS_BOXED (value2))
+ {
+ gchar *val1, *val2;
+
+ /* So boxed types are compared by string and the backend is required to generate
+ * unique strings for values for this purpose.
+ *
+ * NOTE: We could add a pclass option to use the string compare vs. boxed compare...
+ */
+ val1 =
+ glade_widget_adaptor_string_from_value (klass->handle, klass, value1);
+ val2 =
+ glade_widget_adaptor_string_from_value (klass->handle, klass, value2);
+
+ if (val1 && val2)
+ retval = strcmp (val1, val2);
+ else
+ retval = val1 - val2;
+
+ g_free (val1);
+ g_free (val2);
+ }
+ else
+ {
+ if (G_IS_PARAM_SPEC_STRING (klass->pspec))
+ {
+ const gchar *value_str1, *value_str2;
+
+ /* in string specs; NULL and '\0' are
+ * treated as equivalent.
+ */
+ value_str1 = g_value_get_string (value1);
+ value_str2 = g_value_get_string (value2);
+
+ if (value_str1 == NULL && value_str2 && value_str2[0] == '\0')
+ return 0;
+ else if (value_str2 == NULL && value_str1 && value_str1[0] == '\0')
+ return 0;
+ }
+ retval = g_param_values_cmp (klass->pspec, value1, value2);
+ }
+
+ return retval;
}
diff --git a/gladeui/glade-property-class.h b/gladeui/glade-property-class.h
index 7b0e509..01faf16 100644
--- a/gladeui/glade-property-class.h
+++ b/gladeui/glade-property-class.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_PROPERTY_CLASS_H__
#define __GLADE_PROPERTY_CLASS_H__
diff --git a/gladeui/glade-property.c b/gladeui/glade-property.c
index c4ca681..2013ded 100644
--- a/gladeui/glade-property.c
+++ b/gladeui/glade-property.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2006 The GNOME Foundation.
@@ -40,7 +39,7 @@
*/
#include <stdio.h>
-#include <stdlib.h> /* for atoi and atof */
+#include <stdlib.h> /* for atoi and atof */
#include <string.h>
#include <glib/gi18n-lib.h>
@@ -59,546 +58,545 @@
enum
{
- VALUE_CHANGED,
- TOOLTIP_CHANGED,
- LAST_SIGNAL
+ VALUE_CHANGED,
+ TOOLTIP_CHANGED,
+ LAST_SIGNAL
};
enum
{
- PROP_0,
- PROP_CLASS,
- PROP_ENABLED,
- PROP_SENSITIVE,
- PROP_I18N_TRANSLATABLE,
- PROP_I18N_CONTEXT,
- PROP_I18N_COMMENT,
- PROP_STATE
+ PROP_0,
+ PROP_CLASS,
+ PROP_ENABLED,
+ PROP_SENSITIVE,
+ PROP_I18N_TRANSLATABLE,
+ PROP_I18N_CONTEXT,
+ PROP_I18N_COMMENT,
+ PROP_STATE
};
-static guint glade_property_signals[LAST_SIGNAL] = { 0 };
-static GObjectClass* parent_class = NULL;
+static guint glade_property_signals[LAST_SIGNAL] = { 0 };
+
+static GObjectClass *parent_class = NULL;
/*******************************************************************************
GladeProperty class methods
*******************************************************************************/
static GladeProperty *
-glade_property_dup_impl (GladeProperty *template_prop, GladeWidget *widget)
+glade_property_dup_impl (GladeProperty * template_prop, GladeWidget * widget)
{
- GladeProperty *property;
-
- property = g_object_new (GLADE_TYPE_PROPERTY,
- "class", template_prop->klass,
- "i18n-translatable", template_prop->i18n_translatable,
- "i18n-context", template_prop->i18n_context,
- "i18n-comment", template_prop->i18n_comment,
- NULL);
- property->widget = widget;
- property->value = g_new0 (GValue, 1);
-
- g_value_init (property->value, template_prop->value->g_type);
-
- /* Cannot duplicate parentless_widget property */
- if (template_prop->klass->parentless_widget)
- {
- if (!G_IS_PARAM_SPEC_OBJECT (template_prop->klass->pspec))
- g_warning ("Parentless widget property should be of object type");
-
- g_value_set_object (property->value, NULL);
- }
- else
- g_value_copy (template_prop->value, property->value);
-
- /* Need value in place here ... */
- glade_property_set_enabled (property, template_prop->enabled);
- glade_property_set_sensitive (property, template_prop->sensitive,
- template_prop->insensitive_tooltip);
-
- return property;
+ GladeProperty *property;
+
+ property = g_object_new (GLADE_TYPE_PROPERTY,
+ "class", template_prop->klass,
+ "i18n-translatable",
+ template_prop->i18n_translatable, "i18n-context",
+ template_prop->i18n_context, "i18n-comment",
+ template_prop->i18n_comment, NULL);
+ property->widget = widget;
+ property->value = g_new0 (GValue, 1);
+
+ g_value_init (property->value, template_prop->value->g_type);
+
+ /* Cannot duplicate parentless_widget property */
+ if (template_prop->klass->parentless_widget)
+ {
+ if (!G_IS_PARAM_SPEC_OBJECT (template_prop->klass->pspec))
+ g_warning ("Parentless widget property should be of object type");
+
+ g_value_set_object (property->value, NULL);
+ }
+ else
+ g_value_copy (template_prop->value, property->value);
+
+ /* Need value in place here ... */
+ glade_property_set_enabled (property, template_prop->enabled);
+ glade_property_set_sensitive (property, template_prop->sensitive,
+ template_prop->insensitive_tooltip);
+
+ return property;
}
static gboolean
-glade_property_equals_value_impl (GladeProperty *property,
- const GValue *value)
+glade_property_equals_value_impl (GladeProperty * property,
+ const GValue * value)
{
- return !glade_property_class_compare (property->klass, property->value, value);
+ return !glade_property_class_compare (property->klass, property->value,
+ value);
}
static void
-glade_property_update_prop_refs (GladeProperty *property,
- const GValue *old_value,
- const GValue *new_value)
+glade_property_update_prop_refs (GladeProperty * property,
+ const GValue * old_value,
+ const GValue * new_value)
{
- GladeWidget *gold, *gnew;
- GObject *old_object, *new_object;
- GList *old_list, *new_list, *list, *removed, *added;
-
- if (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec))
- {
- /* Make our own copies incase we're walking an
- * unstable list
- */
- old_list = g_value_dup_boxed (old_value);
- new_list = g_value_dup_boxed (new_value);
-
- /* Diff up the GList */
- removed = glade_util_removed_from_list (old_list, new_list);
- added = glade_util_added_in_list (old_list, new_list);
-
- /* Adjust the appropriate prop refs */
- for (list = removed; list; list = list->next)
- {
- old_object = list->data;
- gold = glade_widget_get_from_gobject (old_object);
- if (gold != NULL)
- glade_widget_remove_prop_ref (gold, property);
- }
- for (list = added; list; list = list->next)
- {
- new_object = list->data;
- gnew = glade_widget_get_from_gobject (new_object);
- if (gnew != NULL)
- glade_widget_add_prop_ref (gnew, property);
- }
-
- g_list_free (removed);
- g_list_free (added);
- g_list_free (old_list);
- g_list_free (new_list);
- }
- else
- {
- if ((old_object = g_value_get_object (old_value)) != NULL)
- {
- gold = glade_widget_get_from_gobject (old_object);
- g_return_if_fail (gold != NULL);
- glade_widget_remove_prop_ref (gold, property);
- }
-
- if ((new_object = g_value_get_object (new_value)) != NULL)
- {
- gnew = glade_widget_get_from_gobject (new_object);
- g_return_if_fail (gnew != NULL);
- glade_widget_add_prop_ref (gnew, property);
- }
- }
+ GladeWidget *gold, *gnew;
+ GObject *old_object, *new_object;
+ GList *old_list, *new_list, *list, *removed, *added;
+
+ if (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec))
+ {
+ /* Make our own copies incase we're walking an
+ * unstable list
+ */
+ old_list = g_value_dup_boxed (old_value);
+ new_list = g_value_dup_boxed (new_value);
+
+ /* Diff up the GList */
+ removed = glade_util_removed_from_list (old_list, new_list);
+ added = glade_util_added_in_list (old_list, new_list);
+
+ /* Adjust the appropriate prop refs */
+ for (list = removed; list; list = list->next)
+ {
+ old_object = list->data;
+ gold = glade_widget_get_from_gobject (old_object);
+ if (gold != NULL)
+ glade_widget_remove_prop_ref (gold, property);
+ }
+ for (list = added; list; list = list->next)
+ {
+ new_object = list->data;
+ gnew = glade_widget_get_from_gobject (new_object);
+ if (gnew != NULL)
+ glade_widget_add_prop_ref (gnew, property);
+ }
+
+ g_list_free (removed);
+ g_list_free (added);
+ g_list_free (old_list);
+ g_list_free (new_list);
+ }
+ else
+ {
+ if ((old_object = g_value_get_object (old_value)) != NULL)
+ {
+ gold = glade_widget_get_from_gobject (old_object);
+ g_return_if_fail (gold != NULL);
+ glade_widget_remove_prop_ref (gold, property);
+ }
+
+ if ((new_object = g_value_get_object (new_value)) != NULL)
+ {
+ gnew = glade_widget_get_from_gobject (new_object);
+ g_return_if_fail (gnew != NULL);
+ glade_widget_add_prop_ref (gnew, property);
+ }
+ }
}
static gboolean
-glade_property_verify (GladeProperty *property, const GValue *value)
+glade_property_verify (GladeProperty * property, const GValue * value)
{
- gboolean ret = FALSE;
-
- if (property->klass->packing && property->widget->parent)
- ret = glade_widget_adaptor_child_verify_property (property->widget->parent->adaptor,
- property->widget->parent->object,
- property->widget->object,
- property->klass->id,
- value);
- else if (!property->klass->packing)
- ret = glade_widget_adaptor_verify_property (property->widget->adaptor,
- property->widget->object,
- property->klass->id,
- value);
-
- return ret;
+ gboolean ret = FALSE;
+
+ if (property->klass->packing && property->widget->parent)
+ ret =
+ glade_widget_adaptor_child_verify_property (property->widget->parent->
+ adaptor,
+ property->widget->parent->
+ object,
+ property->widget->object,
+ property->klass->id, value);
+ else if (!property->klass->packing)
+ ret = glade_widget_adaptor_verify_property (property->widget->adaptor,
+ property->widget->object,
+ property->klass->id, value);
+
+ return ret;
}
static void
-glade_property_fix_state (GladeProperty *property)
+glade_property_fix_state (GladeProperty * property)
{
- property->state = GLADE_STATE_NORMAL;
+ property->state = GLADE_STATE_NORMAL;
+
+ if (!glade_property_original_default (property))
+ property->state = GLADE_STATE_CHANGED;
- if (!glade_property_original_default (property))
- property->state = GLADE_STATE_CHANGED;
+ if (property->support_warning)
+ property->state |= GLADE_STATE_UNSUPPORTED;
- if (property->support_warning)
- property->state |= GLADE_STATE_UNSUPPORTED;
+ if (property->support_disabled)
+ property->state |= GLADE_STATE_SUPPORT_DISABLED;
- if (property->support_disabled)
- property->state |= GLADE_STATE_SUPPORT_DISABLED;
-
- g_object_notify (G_OBJECT (property), "state");
+ g_object_notify (G_OBJECT (property), "state");
}
static gboolean
-glade_property_set_value_impl (GladeProperty *property, const GValue *value)
+glade_property_set_value_impl (GladeProperty * property, const GValue * value)
{
- GladeProject *project = property->widget ?
- glade_widget_get_project (property->widget) : NULL;
- gboolean changed = FALSE;
- GValue old_value = {0,};
+ GladeProject *project = property->widget ?
+ glade_widget_get_project (property->widget) : NULL;
+ gboolean changed = FALSE;
+ GValue old_value = { 0, };
#if 0
- {
- g_print ("***************************************************\n");
- g_print ("Setting %s property %s on %s ..\n",
- property->klass->packing ? "packing" : "normal",
- property->klass->id,
- property->widget ? property->widget->name : "unknown");
-
- gchar *str1 = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, property->value);
- gchar *str2 = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, value);
- g_print ("from %s to %s\n", str1, str2);
- g_free (str1);
- g_free (str2);
- }
+ {
+ g_print ("***************************************************\n");
+ g_print ("Setting %s property %s on %s ..\n",
+ property->klass->packing ? "packing" : "normal",
+ property->klass->id,
+ property->widget ? property->widget->name : "unknown");
+
+ gchar *str1 = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle),
+ property->klass, property->value);
+ gchar *str2 = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle),
+ property->klass, value);
+ g_print ("from %s to %s\n", str1, str2);
+ g_free (str1);
+ g_free (str2);
+ }
#endif
- if (!g_value_type_compatible (G_VALUE_TYPE (property->value), G_VALUE_TYPE (value)))
- {
- g_warning ("Trying to assign an incompatible value to property %s\n",
- property->klass->id);
- return FALSE;
- }
-
- /* Check if the backend doesnt give us permission to
- * set this value.
- */
- if (glade_property_superuser () == FALSE && property->widget &&
- project && glade_project_is_loading (project) == FALSE &&
- glade_property_verify (property, value) == FALSE)
- {
- return FALSE;
- }
-
- /* save "changed" state.
- */
- changed = !glade_property_equals_value (property, value);
-
-
- /* Add/Remove references from widget ref stacks here
- * (before assigning the value)
- */
- if (property->widget && changed && glade_property_class_is_object (property->klass))
- glade_property_update_prop_refs (property, property->value, value);
-
-
- /* Make a copy of the old value */
- g_value_init (&old_value, G_VALUE_TYPE (property->value));
- g_value_copy (property->value, &old_value);
-
- /* Assign property first so that; if the object need be
- * rebuilt, it will reflect the new value
- */
- g_value_reset (property->value);
- g_value_copy (value, property->value);
-
- GLADE_PROPERTY_GET_KLASS (property)->sync (property);
-
- glade_property_fix_state (property);
-
- if (changed && property->widget)
- {
- g_signal_emit (G_OBJECT (property),
- glade_property_signals[VALUE_CHANGED],
- 0, &old_value, property->value);
-
- glade_project_verify_properties (property->widget);
- }
-
- g_value_unset (&old_value);
- return TRUE;
+ if (!g_value_type_compatible
+ (G_VALUE_TYPE (property->value), G_VALUE_TYPE (value)))
+ {
+ g_warning ("Trying to assign an incompatible value to property %s\n",
+ property->klass->id);
+ return FALSE;
+ }
+
+ /* Check if the backend doesnt give us permission to
+ * set this value.
+ */
+ if (glade_property_superuser () == FALSE && property->widget &&
+ project && glade_project_is_loading (project) == FALSE &&
+ glade_property_verify (property, value) == FALSE)
+ {
+ return FALSE;
+ }
+
+ /* save "changed" state.
+ */
+ changed = !glade_property_equals_value (property, value);
+
+
+ /* Add/Remove references from widget ref stacks here
+ * (before assigning the value)
+ */
+ if (property->widget && changed &&
+ glade_property_class_is_object (property->klass))
+ glade_property_update_prop_refs (property, property->value, value);
+
+
+ /* Make a copy of the old value */
+ g_value_init (&old_value, G_VALUE_TYPE (property->value));
+ g_value_copy (property->value, &old_value);
+
+ /* Assign property first so that; if the object need be
+ * rebuilt, it will reflect the new value
+ */
+ g_value_reset (property->value);
+ g_value_copy (value, property->value);
+
+ GLADE_PROPERTY_GET_KLASS (property)->sync (property);
+
+ glade_property_fix_state (property);
+
+ if (changed && property->widget)
+ {
+ g_signal_emit (G_OBJECT (property),
+ glade_property_signals[VALUE_CHANGED],
+ 0, &old_value, property->value);
+
+ glade_project_verify_properties (property->widget);
+ }
+
+ g_value_unset (&old_value);
+ return TRUE;
}
static void
-glade_property_get_value_impl (GladeProperty *property, GValue *value)
+glade_property_get_value_impl (GladeProperty * property, GValue * value)
{
- g_value_init (value, property->klass->pspec->value_type);
- g_value_copy (property->value, value);
+ g_value_init (value, property->klass->pspec->value_type);
+ g_value_copy (property->value, value);
}
static void
-glade_property_sync_impl (GladeProperty *property)
+glade_property_sync_impl (GladeProperty * property)
{
- /* Heh, here are the many reasons not to
- * sync a property ;-)
- */
- if (/* the class can be NULL during object,
- * construction this is just a temporary state */
- property->klass == NULL ||
- /* optional properties that are disabled */
- property->enabled == FALSE ||
- /* explicit "never sync" flag */
- property->klass->ignore ||
- /* recursion guards */
- property->syncing >= property->sync_tolerance ||
- /* No widget owns this property yet */
- property->widget == NULL)
- return;
-
- /* Only the properties from widget->properties should affect the runtime widget.
- * (other properties may be used for convenience in the plugin).
- */
- if ((property->klass->packing &&
- !glade_widget_get_pack_property (property->widget, property->klass->id)) ||
- !glade_widget_get_property (property->widget, property->klass->id))
- return;
-
- property->syncing++;
-
- /* In the case of construct_only, the widget instance must be rebuilt
- * to apply the property
- */
- if (property->klass->construct_only && property->syncing == 1)
- {
- /* Virtual properties can be construct only, in which
- * case they are allowed to trigger a rebuild, and in
- * the process are allowed to get "synced" after the
- * instance is rebuilt.
- */
- if (property->klass->virt)
- property->sync_tolerance++;
-
- glade_widget_rebuild (property->widget);
-
- if (property->klass->virt)
- property->sync_tolerance--;
- }
- else if (property->klass->packing)
- glade_widget_child_set_property (glade_widget_get_parent (property->widget),
- property->widget,
- property->klass->id,
- property->value);
- else
- glade_widget_object_set_property (property->widget,
- property->klass->id,
- property->value);
-
- property->syncing--;
+ /* Heh, here are the many reasons not to
+ * sync a property ;-)
+ */
+ if ( /* the class can be NULL during object,
+ * construction this is just a temporary state */
+ property->klass == NULL ||
+ /* optional properties that are disabled */
+ property->enabled == FALSE ||
+ /* explicit "never sync" flag */
+ property->klass->ignore ||
+ /* recursion guards */
+ property->syncing >= property->sync_tolerance ||
+ /* No widget owns this property yet */
+ property->widget == NULL)
+ return;
+
+ /* Only the properties from widget->properties should affect the runtime widget.
+ * (other properties may be used for convenience in the plugin).
+ */
+ if ((property->klass->packing &&
+ !glade_widget_get_pack_property (property->widget, property->klass->id))
+ || !glade_widget_get_property (property->widget, property->klass->id))
+ return;
+
+ property->syncing++;
+
+ /* In the case of construct_only, the widget instance must be rebuilt
+ * to apply the property
+ */
+ if (property->klass->construct_only && property->syncing == 1)
+ {
+ /* Virtual properties can be construct only, in which
+ * case they are allowed to trigger a rebuild, and in
+ * the process are allowed to get "synced" after the
+ * instance is rebuilt.
+ */
+ if (property->klass->virt)
+ property->sync_tolerance++;
+
+ glade_widget_rebuild (property->widget);
+
+ if (property->klass->virt)
+ property->sync_tolerance--;
+ }
+ else if (property->klass->packing)
+ glade_widget_child_set_property (glade_widget_get_parent (property->widget),
+ property->widget,
+ property->klass->id, property->value);
+ else
+ glade_widget_object_set_property (property->widget,
+ property->klass->id, property->value);
+
+ property->syncing--;
}
static void
-glade_property_load_impl (GladeProperty *property)
+glade_property_load_impl (GladeProperty * property)
{
- GObject *object;
- GObjectClass *oclass;
-
- if (property->widget == NULL ||
- property->klass->virt ||
- property->klass->packing ||
- property->klass->ignore ||
- !(property->klass->pspec->flags & G_PARAM_READABLE) ||
- G_IS_PARAM_SPEC_OBJECT(property->klass->pspec))
- return;
-
- object = glade_widget_get_object (property->widget);
- oclass = G_OBJECT_GET_CLASS (object);
-
- if (g_object_class_find_property (oclass, property->klass->id))
- glade_widget_object_get_property (property->widget, property->klass->id, property->value);
+ GObject *object;
+ GObjectClass *oclass;
+
+ if (property->widget == NULL ||
+ property->klass->virt ||
+ property->klass->packing ||
+ property->klass->ignore ||
+ !(property->klass->pspec->flags & G_PARAM_READABLE) ||
+ G_IS_PARAM_SPEC_OBJECT (property->klass->pspec))
+ return;
+
+ object = glade_widget_get_object (property->widget);
+ oclass = G_OBJECT_GET_CLASS (object);
+
+ if (g_object_class_find_property (oclass, property->klass->id))
+ glade_widget_object_get_property (property->widget, property->klass->id,
+ property->value);
}
/*******************************************************************************
GObjectClass & Object Construction
*******************************************************************************/
static void
-glade_property_set_real_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_property_set_real_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeProperty *property = GLADE_PROPERTY (object);
-
- switch (prop_id)
- {
- case PROP_CLASS:
- property->klass = g_value_get_pointer (value);
- break;
- case PROP_ENABLED:
- glade_property_set_enabled (property, g_value_get_boolean (value));
- break;
- case PROP_SENSITIVE:
- property->sensitive = g_value_get_boolean (value);
- break;
- case PROP_I18N_TRANSLATABLE:
- glade_property_i18n_set_translatable (property, g_value_get_boolean (value));
- break;
- case PROP_I18N_CONTEXT:
- glade_property_i18n_set_context (property, g_value_get_string (value));
- break;
- case PROP_I18N_COMMENT:
- glade_property_i18n_set_comment (property, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeProperty *property = GLADE_PROPERTY (object);
+
+ switch (prop_id)
+ {
+ case PROP_CLASS:
+ property->klass = g_value_get_pointer (value);
+ break;
+ case PROP_ENABLED:
+ glade_property_set_enabled (property, g_value_get_boolean (value));
+ break;
+ case PROP_SENSITIVE:
+ property->sensitive = g_value_get_boolean (value);
+ break;
+ case PROP_I18N_TRANSLATABLE:
+ glade_property_i18n_set_translatable (property,
+ g_value_get_boolean (value));
+ break;
+ case PROP_I18N_CONTEXT:
+ glade_property_i18n_set_context (property, g_value_get_string (value));
+ break;
+ case PROP_I18N_COMMENT:
+ glade_property_i18n_set_comment (property, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_property_get_real_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_property_get_real_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GladeProperty *property = GLADE_PROPERTY (object);
-
- switch (prop_id)
- {
- case PROP_CLASS:
- g_value_set_pointer (value, property->klass);
- break;
- case PROP_ENABLED:
- g_value_set_boolean (value, glade_property_get_enabled (property));
- break;
- case PROP_SENSITIVE:
- g_value_set_boolean (value, glade_property_get_sensitive (property));
- break;
- case PROP_I18N_TRANSLATABLE:
- g_value_set_boolean (value, glade_property_i18n_get_translatable (property));
- break;
- case PROP_I18N_CONTEXT:
- g_value_set_string (value, glade_property_i18n_get_context (property));
- break;
- case PROP_I18N_COMMENT:
- g_value_set_string (value, glade_property_i18n_get_comment (property));
- break;
- case PROP_STATE:
- g_value_set_int (value, property->state);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeProperty *property = GLADE_PROPERTY (object);
+
+ switch (prop_id)
+ {
+ case PROP_CLASS:
+ g_value_set_pointer (value, property->klass);
+ break;
+ case PROP_ENABLED:
+ g_value_set_boolean (value, glade_property_get_enabled (property));
+ break;
+ case PROP_SENSITIVE:
+ g_value_set_boolean (value, glade_property_get_sensitive (property));
+ break;
+ case PROP_I18N_TRANSLATABLE:
+ g_value_set_boolean (value,
+ glade_property_i18n_get_translatable (property));
+ break;
+ case PROP_I18N_CONTEXT:
+ g_value_set_string (value, glade_property_i18n_get_context (property));
+ break;
+ case PROP_I18N_COMMENT:
+ g_value_set_string (value, glade_property_i18n_get_comment (property));
+ break;
+ case PROP_STATE:
+ g_value_set_int (value, property->state);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_property_finalize (GObject *object)
+glade_property_finalize (GObject * object)
{
- GladeProperty *property = GLADE_PROPERTY (object);
-
- if (property->value)
- {
- g_value_unset (property->value);
- g_free (property->value);
- }
- if (property->i18n_comment)
- g_free (property->i18n_comment);
- if (property->i18n_context)
- g_free (property->i18n_context);
- if (property->support_warning)
- g_free (property->support_warning);
- if (property->insensitive_tooltip)
- g_free (property->insensitive_tooltip);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ GladeProperty *property = GLADE_PROPERTY (object);
+
+ if (property->value)
+ {
+ g_value_unset (property->value);
+ g_free (property->value);
+ }
+ if (property->i18n_comment)
+ g_free (property->i18n_comment);
+ if (property->i18n_context)
+ g_free (property->i18n_context);
+ if (property->support_warning)
+ g_free (property->support_warning);
+ if (property->insensitive_tooltip)
+ g_free (property->insensitive_tooltip);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-glade_property_init (GladeProperty *property)
+glade_property_init (GladeProperty * property)
{
- property->enabled = TRUE;
- property->sensitive = TRUE;
- property->i18n_translatable = TRUE;
- property->i18n_comment = NULL;
- property->sync_tolerance = 1;
+ property->enabled = TRUE;
+ property->sensitive = TRUE;
+ property->i18n_translatable = TRUE;
+ property->i18n_comment = NULL;
+ property->sync_tolerance = 1;
}
static void
-glade_property_klass_init (GladePropertyKlass *prop_class)
+glade_property_klass_init (GladePropertyKlass * prop_class)
{
- GObjectClass *object_class;
- g_return_if_fail (prop_class != NULL);
-
- parent_class = g_type_class_peek_parent (prop_class);
- object_class = G_OBJECT_CLASS (prop_class);
-
- /* GObjectClass */
- object_class->set_property = glade_property_set_real_property;
- object_class->get_property = glade_property_get_real_property;
- object_class->finalize = glade_property_finalize;
-
- /* Class methods */
- prop_class->dup = glade_property_dup_impl;
- prop_class->equals_value = glade_property_equals_value_impl;
- prop_class->set_value = glade_property_set_value_impl;
- prop_class->get_value = glade_property_get_value_impl;
- prop_class->sync = glade_property_sync_impl;
- prop_class->load = glade_property_load_impl;
- prop_class->value_changed = NULL;
- prop_class->tooltip_changed = NULL;
-
- /* Properties */
- g_object_class_install_property
- (object_class, PROP_CLASS,
- g_param_spec_pointer
- ("class", _("Class"),
- _("The GladePropertyClass for this property"),
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_ENABLED,
- g_param_spec_boolean
- ("enabled", _("Enabled"),
- _("If the property is optional, this is its enabled state"),
- TRUE, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_SENSITIVE,
- g_param_spec_boolean
- ("sensitive", _("Sensitive"),
- _("This gives backends control to set property sensitivity"),
- TRUE, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_I18N_CONTEXT,
- g_param_spec_string
- ("i18n-context", _("Context"),
- _("Context for translation"),
- NULL, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_I18N_COMMENT,
- g_param_spec_string
- ("i18n-comment", _("Comment"),
- _("Comment for translators"),
- NULL, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_I18N_TRANSLATABLE,
- g_param_spec_boolean
- ("i18n-translatable", _("Translatable"),
- _("Whether this property is translatable"),
- TRUE, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_STATE,
- g_param_spec_int
- ("state", _("Visual State"),
- _("Priority information for the property editor to act on"),
- GLADE_STATE_NORMAL,
- G_MAXINT,
- GLADE_STATE_NORMAL,
- G_PARAM_READABLE));
-
- /* Signal */
- glade_property_signals[VALUE_CHANGED] =
- g_signal_new ("value-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladePropertyKlass,
- value_changed),
- NULL, NULL,
- glade_marshal_VOID__POINTER_POINTER,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
-
- glade_property_signals[TOOLTIP_CHANGED] =
- g_signal_new ("tooltip-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladePropertyKlass,
- tooltip_changed),
- NULL, NULL,
- glade_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ GObjectClass *object_class;
+ g_return_if_fail (prop_class != NULL);
+
+ parent_class = g_type_class_peek_parent (prop_class);
+ object_class = G_OBJECT_CLASS (prop_class);
+
+ /* GObjectClass */
+ object_class->set_property = glade_property_set_real_property;
+ object_class->get_property = glade_property_get_real_property;
+ object_class->finalize = glade_property_finalize;
+
+ /* Class methods */
+ prop_class->dup = glade_property_dup_impl;
+ prop_class->equals_value = glade_property_equals_value_impl;
+ prop_class->set_value = glade_property_set_value_impl;
+ prop_class->get_value = glade_property_get_value_impl;
+ prop_class->sync = glade_property_sync_impl;
+ prop_class->load = glade_property_load_impl;
+ prop_class->value_changed = NULL;
+ prop_class->tooltip_changed = NULL;
+
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_CLASS,
+ g_param_spec_pointer
+ ("class", _("Class"),
+ _("The GladePropertyClass for this property"),
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_ENABLED,
+ g_param_spec_boolean
+ ("enabled", _("Enabled"),
+ _("If the property is optional, this is its enabled state"),
+ TRUE, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_SENSITIVE,
+ g_param_spec_boolean
+ ("sensitive", _("Sensitive"),
+ _("This gives backends control to set property sensitivity"),
+ TRUE, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_I18N_CONTEXT,
+ g_param_spec_string
+ ("i18n-context", _("Context"),
+ _("Context for translation"), NULL, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_I18N_COMMENT,
+ g_param_spec_string
+ ("i18n-comment", _("Comment"),
+ _("Comment for translators"), NULL, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_I18N_TRANSLATABLE,
+ g_param_spec_boolean
+ ("i18n-translatable", _("Translatable"),
+ _("Whether this property is translatable"), TRUE, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_STATE,
+ g_param_spec_int
+ ("state", _("Visual State"),
+ _("Priority information for the property editor to act on"),
+ GLADE_STATE_NORMAL, G_MAXINT, GLADE_STATE_NORMAL, G_PARAM_READABLE));
+
+ /* Signal */
+ glade_property_signals[VALUE_CHANGED] =
+ g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladePropertyKlass,
+ value_changed),
+ NULL, NULL,
+ glade_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+
+ glade_property_signals[TOOLTIP_CHANGED] =
+ g_signal_new ("tooltip-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladePropertyKlass,
+ tooltip_changed),
+ NULL, NULL,
+ glade_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING);
}
@@ -606,28 +604,26 @@ glade_property_klass_init (GladePropertyKlass *prop_class)
GType
glade_property_get_type (void)
{
- static GType property_type = 0;
-
- if (!property_type)
- {
- static const GTypeInfo property_info =
- {
- sizeof (GladePropertyKlass), /* Klass is our class */
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) glade_property_klass_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (GladeProperty),
- 0, /* n_preallocs */
- (GInstanceInitFunc) glade_property_init,
- };
- property_type =
- g_type_register_static (G_TYPE_OBJECT,
- "GladeProperty",
- &property_info, 0);
- }
- return property_type;
+ static GType property_type = 0;
+
+ if (!property_type)
+ {
+ static const GTypeInfo property_info = {
+ sizeof (GladePropertyKlass), /* Klass is our class */
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) glade_property_klass_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (GladeProperty),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) glade_property_init,
+ };
+ property_type =
+ g_type_register_static (G_TYPE_OBJECT,
+ "GladeProperty", &property_info, 0);
+ }
+ return property_type;
}
/*******************************************************************************
@@ -647,32 +643,30 @@ glade_property_get_type (void)
* Returns: The newly created #GladeProperty
*/
GladeProperty *
-glade_property_new (GladePropertyClass *klass,
- GladeWidget *widget,
- GValue *value)
+glade_property_new (GladePropertyClass * klass,
+ GladeWidget * widget, GValue * value)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
-
- property =
- (GladeProperty *)g_object_new (GLADE_TYPE_PROPERTY, NULL);
- property->klass = klass;
- property->widget = widget;
- property->value = value;
-
- if (klass->optional)
- property->enabled = klass->optional_default;
-
- if (property->value == NULL)
- {
- g_assert (klass->orig_def);
-
- property->value = g_new0 (GValue, 1);
- g_value_init (property->value, klass->orig_def->g_type);
- g_value_copy (klass->orig_def, property->value);
- }
- return property;
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
+
+ property = (GladeProperty *) g_object_new (GLADE_TYPE_PROPERTY, NULL);
+ property->klass = klass;
+ property->widget = widget;
+ property->value = value;
+
+ if (klass->optional)
+ property->enabled = klass->optional_default;
+
+ if (property->value == NULL)
+ {
+ g_assert (klass->orig_def);
+
+ property->value = g_new0 (GValue, 1);
+ g_value_init (property->value, klass->orig_def->g_type);
+ g_value_copy (klass->orig_def, property->value);
+ }
+ return property;
}
/**
@@ -683,19 +677,19 @@ glade_property_new (GladePropertyClass *klass,
* Returns: A newly duplicated property based on the new widget
*/
GladeProperty *
-glade_property_dup (GladeProperty *template_prop, GladeWidget *widget)
+glade_property_dup (GladeProperty * template_prop, GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (template_prop), NULL);
- return GLADE_PROPERTY_GET_KLASS (template_prop)->dup (template_prop, widget);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (template_prop), NULL);
+ return GLADE_PROPERTY_GET_KLASS (template_prop)->dup (template_prop, widget);
}
static void
-glade_property_reset_common (GladeProperty *property, gboolean original)
+glade_property_reset_common (GladeProperty * property, gboolean original)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- GLADE_PROPERTY_GET_KLASS (property)->set_value
- (property, (original) ? property->klass->orig_def : property->klass->def);
+ GLADE_PROPERTY_GET_KLASS (property)->set_value
+ (property, (original) ? property->klass->orig_def : property->klass->def);
}
/**
@@ -705,9 +699,9 @@ glade_property_reset_common (GladeProperty *property, gboolean original)
* Resets this property to its default value
*/
void
-glade_property_reset (GladeProperty *property)
+glade_property_reset (GladeProperty * property)
{
- glade_property_reset_common (property, FALSE);
+ glade_property_reset_common (property, FALSE);
}
/**
@@ -717,17 +711,17 @@ glade_property_reset (GladeProperty *property)
* Resets this property to its original default value
*/
void
-glade_property_original_reset (GladeProperty *property)
+glade_property_original_reset (GladeProperty * property)
{
- glade_property_reset_common (property, TRUE);
+ glade_property_reset_common (property, TRUE);
}
static gboolean
-glade_property_default_common (GladeProperty *property, gboolean orig)
+glade_property_default_common (GladeProperty * property, gboolean orig)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- return GLADE_PROPERTY_GET_KLASS (property)->equals_value
- (property, (orig) ? property->klass->orig_def : property->klass->def);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ return GLADE_PROPERTY_GET_KLASS (property)->equals_value
+ (property, (orig) ? property->klass->orig_def : property->klass->def);
}
/**
@@ -737,9 +731,9 @@ glade_property_default_common (GladeProperty *property, gboolean orig)
* Returns: Whether this property is at its default value
*/
gboolean
-glade_property_default (GladeProperty *property)
+glade_property_default (GladeProperty * property)
{
- return glade_property_default_common (property, FALSE);
+ return glade_property_default_common (property, FALSE);
}
/**
@@ -749,9 +743,9 @@ glade_property_default (GladeProperty *property)
* Returns: Whether this property is at its original default value
*/
gboolean
-glade_property_original_default (GladeProperty *property)
+glade_property_original_default (GladeProperty * property)
{
- return glade_property_default_common (property, TRUE);
+ return glade_property_default_common (property, TRUE);
}
/**
@@ -762,11 +756,10 @@ glade_property_original_default (GladeProperty *property)
* Returns: Whether this property is equal to the value provided
*/
gboolean
-glade_property_equals_value (GladeProperty *property,
- const GValue *value)
+glade_property_equals_value (GladeProperty * property, const GValue * value)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- return GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ return GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value);
}
/**
@@ -777,20 +770,20 @@ glade_property_equals_value (GladeProperty *property,
* Returns: Whether this property is equal to the value provided
*/
static gboolean
-glade_property_equals_va_list (GladeProperty *property, va_list vl)
+glade_property_equals_va_list (GladeProperty * property, va_list vl)
{
- GValue *value;
- gboolean ret;
+ GValue *value;
+ gboolean ret;
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ value = glade_property_class_make_gvalue_from_vl (property->klass, vl);
- value = glade_property_class_make_gvalue_from_vl (property->klass, vl);
+ ret = GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value);
- ret = GLADE_PROPERTY_GET_KLASS (property)->equals_value (property, value);
-
- g_value_unset (value);
- g_free (value);
- return ret;
+ g_value_unset (value);
+ g_free (value);
+ return ret;
}
/**
@@ -801,18 +794,18 @@ glade_property_equals_va_list (GladeProperty *property, va_list vl)
* Returns: Whether this property is equal to the value provided
*/
gboolean
-glade_property_equals (GladeProperty *property, ...)
+glade_property_equals (GladeProperty * property, ...)
{
- va_list vl;
- gboolean ret;
+ va_list vl;
+ gboolean ret;
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- va_start (vl, property);
- ret = glade_property_equals_va_list (property, vl);
- va_end (vl);
+ va_start (vl, property);
+ ret = glade_property_equals_va_list (property, vl);
+ va_end (vl);
- return ret;
+ return ret;
}
/**
@@ -825,11 +818,11 @@ glade_property_equals (GladeProperty *property, ...)
* Returns: Whether the property was successfully set.
*/
gboolean
-glade_property_set_value (GladeProperty *property, const GValue *value)
+glade_property_set_value (GladeProperty * property, const GValue * value)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
- return GLADE_PROPERTY_GET_KLASS (property)->set_value (property, value);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+ return GLADE_PROPERTY_GET_KLASS (property)->set_value (property, value);
}
/**
@@ -840,21 +833,21 @@ glade_property_set_value (GladeProperty *property, const GValue *value)
* Sets the property's value
*/
gboolean
-glade_property_set_va_list (GladeProperty *property, va_list vl)
+glade_property_set_va_list (GladeProperty * property, va_list vl)
{
- GValue *value;
- gboolean success;
+ GValue *value;
+ gboolean success;
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- value = glade_property_class_make_gvalue_from_vl (property->klass, vl);
+ value = glade_property_class_make_gvalue_from_vl (property->klass, vl);
- success = GLADE_PROPERTY_GET_KLASS (property)->set_value (property, value);
+ success = GLADE_PROPERTY_GET_KLASS (property)->set_value (property, value);
- g_value_unset (value);
- g_free (value);
+ g_value_unset (value);
+ g_free (value);
- return success;
+ return success;
}
/**
@@ -865,18 +858,18 @@ glade_property_set_va_list (GladeProperty *property, va_list vl)
* Sets the property's value (in a convenient way)
*/
gboolean
-glade_property_set (GladeProperty *property, ...)
+glade_property_set (GladeProperty * property, ...)
{
- va_list vl;
- gboolean success;
+ va_list vl;
+ gboolean success;
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- va_start (vl, property);
- success = glade_property_set_va_list (property, vl);
- va_end (vl);
+ va_start (vl, property);
+ success = glade_property_set_va_list (property, vl);
+ va_end (vl);
- return success;
+ return success;
}
/**
@@ -887,11 +880,11 @@ glade_property_set (GladeProperty *property, ...)
* Retrieve the property value
*/
void
-glade_property_get_value (GladeProperty *property, GValue *value)
+glade_property_get_value (GladeProperty * property, GValue * value)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- g_return_if_fail (value != NULL);
- GLADE_PROPERTY_GET_KLASS (property)->get_value (property, value);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (value != NULL);
+ GLADE_PROPERTY_GET_KLASS (property)->get_value (property, value);
}
/**
@@ -902,13 +895,13 @@ glade_property_get_value (GladeProperty *property, GValue *value)
* Retrieve the default property value
*/
void
-glade_property_get_default (GladeProperty *property, GValue *value)
+glade_property_get_default (GladeProperty * property, GValue * value)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- g_return_if_fail (value != NULL);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (value != NULL);
- g_value_init (value, property->klass->pspec->value_type);
- g_value_copy (property->klass->def, value);
+ g_value_init (value, property->klass->pspec->value_type);
+ g_value_copy (property->klass->def, value);
}
/**
@@ -919,10 +912,11 @@ glade_property_get_default (GladeProperty *property, GValue *value)
* Retrieve the property value
*/
void
-glade_property_get_va_list (GladeProperty *property, va_list vl)
+glade_property_get_va_list (GladeProperty * property, va_list vl)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- glade_property_class_set_vl_from_gvalue (property->klass, property->value, vl);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ glade_property_class_set_vl_from_gvalue (property->klass, property->value,
+ vl);
}
/**
@@ -933,15 +927,15 @@ glade_property_get_va_list (GladeProperty *property, va_list vl)
* Retrieve the property value
*/
void
-glade_property_get (GladeProperty *property, ...)
+glade_property_get (GladeProperty * property, ...)
{
- va_list vl;
+ va_list vl;
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- va_start (vl, property);
- glade_property_get_va_list (property, vl);
- va_end (vl);
+ va_start (vl, property);
+ glade_property_get_va_list (property, vl);
+ va_end (vl);
}
/**
@@ -951,10 +945,10 @@ glade_property_get (GladeProperty *property, ...)
* Synchronize the object with this property
*/
void
-glade_property_sync (GladeProperty *property)
+glade_property_sync (GladeProperty * property)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- GLADE_PROPERTY_GET_KLASS (property)->sync (property);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ GLADE_PROPERTY_GET_KLASS (property)->sync (property);
}
/**
@@ -964,10 +958,10 @@ glade_property_sync (GladeProperty *property)
* Loads the value of @property from the coresponding object instance
*/
void
-glade_property_load (GladeProperty *property)
+glade_property_load (GladeProperty * property)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- GLADE_PROPERTY_GET_KLASS (property)->load (property);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ GLADE_PROPERTY_GET_KLASS (property)->load (property);
}
/**
@@ -984,63 +978,61 @@ glade_property_load (GladeProperty *property)
* completely loaded
*/
void
-glade_property_read (GladeProperty *property,
- GladeProject *project,
- GladeXmlNode *prop)
+glade_property_read (GladeProperty * property,
+ GladeProject * project, GladeXmlNode * prop)
{
- GValue *gvalue = NULL;
- gchar /* *id, *name, */ *value;
- gint translatable = FALSE;
- gchar *comment = NULL, *context = NULL;
-
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (prop != NULL);
-
- if (!glade_xml_node_verify (prop, GLADE_XML_TAG_PROPERTY))
- return;
-
- if (!(value = glade_xml_get_content (prop)))
- return;
-
- if (glade_property_class_is_object (property->klass))
- {
- /* we must synchronize this directly after loading this project
- * (i.e. lookup the actual objects after they've been parsed and
- * are present).
- */
- g_object_set_data_full (G_OBJECT (property),
- "glade-loaded-object",
- g_strdup (value), g_free);
- }
- else
- {
- gvalue = glade_property_class_make_gvalue_from_string
- (property->klass, value, project, property->widget);
-
- GLADE_PROPERTY_GET_KLASS
- (property)->set_value (property, gvalue);
-
- g_value_unset (gvalue);
- g_free (gvalue);
-
- /* If an optional property is specified in the
- * glade file, its enabled
- */
- property->enabled = TRUE;
- }
-
- translatable = glade_xml_get_property_boolean (prop, GLADE_TAG_TRANSLATABLE, FALSE);
- comment = glade_xml_get_property_string (prop, GLADE_TAG_COMMENT);
- context = glade_xml_get_property_string (prop, GLADE_TAG_CONTEXT);
-
- glade_property_i18n_set_translatable (property, translatable);
- glade_property_i18n_set_comment (property, comment);
- glade_property_i18n_set_context (property, context);
-
- g_free (comment);
- g_free (context);
- g_free (value);
+ GValue *gvalue = NULL;
+ gchar /* *id, *name, */ * value;
+ gint translatable = FALSE;
+ gchar *comment = NULL, *context = NULL;
+
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_PROJECT (project));
+ g_return_if_fail (prop != NULL);
+
+ if (!glade_xml_node_verify (prop, GLADE_XML_TAG_PROPERTY))
+ return;
+
+ if (!(value = glade_xml_get_content (prop)))
+ return;
+
+ if (glade_property_class_is_object (property->klass))
+ {
+ /* we must synchronize this directly after loading this project
+ * (i.e. lookup the actual objects after they've been parsed and
+ * are present).
+ */
+ g_object_set_data_full (G_OBJECT (property),
+ "glade-loaded-object", g_strdup (value), g_free);
+ }
+ else
+ {
+ gvalue = glade_property_class_make_gvalue_from_string
+ (property->klass, value, project, property->widget);
+
+ GLADE_PROPERTY_GET_KLASS (property)->set_value (property, gvalue);
+
+ g_value_unset (gvalue);
+ g_free (gvalue);
+
+ /* If an optional property is specified in the
+ * glade file, its enabled
+ */
+ property->enabled = TRUE;
+ }
+
+ translatable =
+ glade_xml_get_property_boolean (prop, GLADE_TAG_TRANSLATABLE, FALSE);
+ comment = glade_xml_get_property_string (prop, GLADE_TAG_COMMENT);
+ context = glade_xml_get_property_string (prop, GLADE_TAG_CONTEXT);
+
+ glade_property_i18n_set_translatable (property, translatable);
+ glade_property_i18n_set_comment (property, comment);
+ glade_property_i18n_set_context (property, context);
+
+ g_free (comment);
+ g_free (context);
+ g_free (value);
}
@@ -1053,81 +1045,81 @@ glade_property_read (GladeProperty *property,
* Write @property to @node
*/
void
-glade_property_write (GladeProperty *property,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_property_write (GladeProperty * property,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- GladeXmlNode *prop_node;
- GladeProject *project;
- gchar *name, *value, *tmp;
-
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- g_return_if_fail (node != NULL);
-
- project = property->widget->project;
-
- /* This code should work the same for <packing> and <widget> */
- if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_PACKING) ||
- glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET)))
- return;
-
- g_assert (property->klass->orig_def);
- g_assert (property->klass->def);
-
- /* Skip properties that are default by original pspec default
- * (excepting those that specified otherwise).
- */
- if (!(property->klass->save_always || property->save_always) &&
- glade_property_original_default (property))
- return;
-
- /* Escape our string and save with underscores */
- name = g_strdup (property->klass->id);
- glade_util_replace (name, '-', '_');
-
- /* convert the value of this property to a string */
- if (!(value = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle), property->klass, property->value)))
- /* make sure we keep the empty string, also... upcomming
- * funcs that may not like NULL.
- */
- value = g_strdup ("");
- else
- {
- /* Escape the string so that it will be parsed as it should. */
- tmp = value;
- value = g_markup_escape_text (value, -1);
- g_free (tmp);
- }
-
- /* Now dump the node values... */
- prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
- glade_xml_node_append_child (node, prop_node);
-
- /* Name and value */
- glade_xml_node_set_property_string (prop_node, GLADE_XML_TAG_NAME, name);
- glade_xml_set_content (prop_node, value);
-
- /* i18n stuff */
- if (property->klass->translatable)
- {
- if (property->i18n_translatable)
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_TRANSLATABLE,
- GLADE_XML_TAG_I18N_TRUE);
-
- if (property->i18n_context)
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_CONTEXT,
- property->i18n_context);
-
- if (property->i18n_comment)
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_COMMENT,
- property->i18n_comment);
- }
- g_free (name);
- g_free (value);
+ GladeXmlNode *prop_node;
+ GladeProject *project;
+ gchar *name, *value, *tmp;
+
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (node != NULL);
+
+ project = property->widget->project;
+
+ /* This code should work the same for <packing> and <widget> */
+ if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_PACKING) ||
+ glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET)))
+ return;
+
+ g_assert (property->klass->orig_def);
+ g_assert (property->klass->def);
+
+ /* Skip properties that are default by original pspec default
+ * (excepting those that specified otherwise).
+ */
+ if (!(property->klass->save_always || property->save_always) &&
+ glade_property_original_default (property))
+ return;
+
+ /* Escape our string and save with underscores */
+ name = g_strdup (property->klass->id);
+ glade_util_replace (name, '-', '_');
+
+ /* convert the value of this property to a string */
+ if (!(value = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle), property->klass,
+ property->value)))
+ /* make sure we keep the empty string, also... upcomming
+ * funcs that may not like NULL.
+ */
+ value = g_strdup ("");
+ else
+ {
+ /* Escape the string so that it will be parsed as it should. */
+ tmp = value;
+ value = g_markup_escape_text (value, -1);
+ g_free (tmp);
+ }
+
+ /* Now dump the node values... */
+ prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
+ glade_xml_node_append_child (node, prop_node);
+
+ /* Name and value */
+ glade_xml_node_set_property_string (prop_node, GLADE_XML_TAG_NAME, name);
+ glade_xml_set_content (prop_node, value);
+
+ /* i18n stuff */
+ if (property->klass->translatable)
+ {
+ if (property->i18n_translatable)
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_TRANSLATABLE,
+ GLADE_XML_TAG_I18N_TRUE);
+
+ if (property->i18n_context)
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_CONTEXT,
+ property->i18n_context);
+
+ if (property->i18n_comment)
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_COMMENT,
+ property->i18n_comment);
+ }
+ g_free (name);
+ g_free (value);
}
/**
@@ -1141,33 +1133,32 @@ glade_property_write (GladeProperty *property,
* or #GParamSpecObject type property.
*/
void
-glade_property_add_object (GladeProperty *property,
- GObject *object)
+glade_property_add_object (GladeProperty * property, GObject * object)
{
- GList *list = NULL, *new_list = NULL;
-
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec) ||
- G_IS_PARAM_SPEC_OBJECT (property->klass->pspec));
-
- if (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec))
- {
- glade_property_get (property, &list);
- new_list = g_list_copy (list);
-
- new_list = g_list_append (new_list, object);
- glade_property_set (property, new_list);
-
- /* ownership of the list is not passed
- * through glade_property_set()
- */
- g_list_free (new_list);
- }
- else
- {
- glade_property_set (property, object);
- }
+ GList *list = NULL, *new_list = NULL;
+
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec) ||
+ G_IS_PARAM_SPEC_OBJECT (property->klass->pspec));
+
+ if (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec))
+ {
+ glade_property_get (property, &list);
+ new_list = g_list_copy (list);
+
+ new_list = g_list_append (new_list, object);
+ glade_property_set (property, new_list);
+
+ /* ownership of the list is not passed
+ * through glade_property_set()
+ */
+ g_list_free (new_list);
+ }
+ else
+ {
+ glade_property_set (property, object);
+ }
}
/**
@@ -1181,157 +1172,149 @@ glade_property_add_object (GladeProperty *property,
* or #GParamSpecObject type property.
*/
void
-glade_property_remove_object (GladeProperty *property,
- GObject *object)
+glade_property_remove_object (GladeProperty * property, GObject * object)
{
- GList *list = NULL, *new_list = NULL;
-
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec) ||
- G_IS_PARAM_SPEC_OBJECT (property->klass->pspec));
-
- if (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec))
- {
- /* If object isnt in list; list should stay in tact.
- * not bothering to check for now.
- */
- glade_property_get (property, &list);
- new_list = g_list_copy (list);
-
- new_list = g_list_remove (new_list, object);
- glade_property_set (property, new_list);
-
- /* ownership of the list is not passed
- * through glade_property_set()
- */
- g_list_free (new_list);
- }
- else
- {
- glade_property_set (property, NULL);
- }
+ GList *list = NULL, *new_list = NULL;
+
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec) ||
+ G_IS_PARAM_SPEC_OBJECT (property->klass->pspec));
+
+ if (GLADE_IS_PARAM_SPEC_OBJECTS (property->klass->pspec))
+ {
+ /* If object isnt in list; list should stay in tact.
+ * not bothering to check for now.
+ */
+ glade_property_get (property, &list);
+ new_list = g_list_copy (list);
+
+ new_list = g_list_remove (new_list, object);
+ glade_property_set (property, new_list);
+
+ /* ownership of the list is not passed
+ * through glade_property_set()
+ */
+ g_list_free (new_list);
+ }
+ else
+ {
+ glade_property_set (property, NULL);
+ }
}
/* Parameters for translatable properties. */
void
-glade_property_i18n_set_comment (GladeProperty *property,
- const gchar *str)
+glade_property_i18n_set_comment (GladeProperty * property, const gchar * str)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- if (property->i18n_comment)
- g_free (property->i18n_comment);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ if (property->i18n_comment)
+ g_free (property->i18n_comment);
- property->i18n_comment = g_strdup (str);
- g_object_notify (G_OBJECT (property), "i18n-comment");
+ property->i18n_comment = g_strdup (str);
+ g_object_notify (G_OBJECT (property), "i18n-comment");
}
G_CONST_RETURN gchar *
-glade_property_i18n_get_comment (GladeProperty *property)
+glade_property_i18n_get_comment (GladeProperty * property)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL);
- return property->i18n_comment;
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL);
+ return property->i18n_comment;
}
void
-glade_property_i18n_set_context (GladeProperty *property,
- const gchar *str)
+glade_property_i18n_set_context (GladeProperty * property, const gchar * str)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- if (property->i18n_context)
- g_free (property->i18n_context);
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ if (property->i18n_context)
+ g_free (property->i18n_context);
- property->i18n_context = g_strdup (str);
- g_object_notify (G_OBJECT (property), "i18n-context");
+ property->i18n_context = g_strdup (str);
+ g_object_notify (G_OBJECT (property), "i18n-context");
}
G_CONST_RETURN gchar *
-glade_property_i18n_get_context (GladeProperty *property)
+glade_property_i18n_get_context (GladeProperty * property)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL);
- return property->i18n_context;
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), NULL);
+ return property->i18n_context;
}
void
-glade_property_i18n_set_translatable (GladeProperty *property,
- gboolean translatable)
+glade_property_i18n_set_translatable (GladeProperty * property,
+ gboolean translatable)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
- property->i18n_translatable = translatable;
- g_object_notify (G_OBJECT (property), "i18n-translatable");
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+ property->i18n_translatable = translatable;
+ g_object_notify (G_OBJECT (property), "i18n-translatable");
}
gboolean
-glade_property_i18n_get_translatable (GladeProperty *property)
+glade_property_i18n_get_translatable (GladeProperty * property)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- return property->i18n_translatable;
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ return property->i18n_translatable;
}
void
-glade_property_set_sensitive (GladeProperty *property,
- gboolean sensitive,
- const gchar *reason)
+glade_property_set_sensitive (GladeProperty * property,
+ gboolean sensitive, const gchar * reason)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
-
- /* reason is only why we're disableing it */
- if (sensitive == FALSE)
- {
- if (property->insensitive_tooltip)
- g_free (property->insensitive_tooltip);
- property->insensitive_tooltip =
- g_strdup (reason);
- }
-
- if (property->sensitive != sensitive)
- {
- property->sensitive = sensitive;
-
- /* Clear it */
- if (sensitive)
- property->insensitive_tooltip =
- (g_free (property->insensitive_tooltip), NULL);
-
- g_signal_emit (G_OBJECT (property),
- glade_property_signals[TOOLTIP_CHANGED],
- 0,
- property->klass->tooltip,
- property->insensitive_tooltip,
- property->support_warning);
-
- }
- g_object_notify (G_OBJECT (property), "sensitive");
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
+
+ /* reason is only why we're disableing it */
+ if (sensitive == FALSE)
+ {
+ if (property->insensitive_tooltip)
+ g_free (property->insensitive_tooltip);
+ property->insensitive_tooltip = g_strdup (reason);
+ }
+
+ if (property->sensitive != sensitive)
+ {
+ property->sensitive = sensitive;
+
+ /* Clear it */
+ if (sensitive)
+ property->insensitive_tooltip =
+ (g_free (property->insensitive_tooltip), NULL);
+
+ g_signal_emit (G_OBJECT (property),
+ glade_property_signals[TOOLTIP_CHANGED],
+ 0,
+ property->klass->tooltip,
+ property->insensitive_tooltip, property->support_warning);
+
+ }
+ g_object_notify (G_OBJECT (property), "sensitive");
}
gboolean
-glade_property_get_sensitive (GladeProperty *property)
+glade_property_get_sensitive (GladeProperty * property)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- return property->sensitive;
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ return property->sensitive;
}
void
-glade_property_set_support_warning (GladeProperty *property,
- gboolean disable,
- const gchar *reason)
+glade_property_set_support_warning (GladeProperty * property,
+ gboolean disable, const gchar * reason)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- if (property->support_warning)
- g_free (property->support_warning);
- property->support_warning = g_strdup (reason);
+ if (property->support_warning)
+ g_free (property->support_warning);
+ property->support_warning = g_strdup (reason);
- property->support_disabled = disable;
+ property->support_disabled = disable;
- g_signal_emit (G_OBJECT (property),
- glade_property_signals[TOOLTIP_CHANGED],
- 0,
- property->klass->tooltip,
- property->insensitive_tooltip,
- property->support_warning);
+ g_signal_emit (G_OBJECT (property),
+ glade_property_signals[TOOLTIP_CHANGED],
+ 0,
+ property->klass->tooltip,
+ property->insensitive_tooltip, property->support_warning);
- glade_property_fix_state (property);
+ glade_property_fix_state (property);
}
@@ -1347,12 +1330,11 @@ glade_property_set_support_warning (GladeProperty *property,
* or derived widget code).
*/
void
-glade_property_set_save_always (GladeProperty *property,
- gboolean setting)
+glade_property_set_save_always (GladeProperty * property, gboolean setting)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- property->save_always = setting;
+ property->save_always = setting;
}
/**
@@ -1363,33 +1345,32 @@ glade_property_set_save_always (GladeProperty *property,
* to always be saved regardless of its default value.
*/
gboolean
-glade_property_get_save_always (GladeProperty *property)
+glade_property_get_save_always (GladeProperty * property)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- return property->save_always;
+ return property->save_always;
}
void
-glade_property_set_enabled (GladeProperty *property,
- gboolean enabled)
+glade_property_set_enabled (GladeProperty * property, gboolean enabled)
{
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- property->enabled = enabled;
- if (enabled)
- glade_property_sync (property);
+ property->enabled = enabled;
+ if (enabled)
+ glade_property_sync (property);
- glade_property_fix_state (property);
+ glade_property_fix_state (property);
- g_object_notify (G_OBJECT (property), "enabled");
+ g_object_notify (G_OBJECT (property), "enabled");
}
gboolean
-glade_property_get_enabled (GladeProperty *property)
+glade_property_get_enabled (GladeProperty * property)
{
- g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
- return property->enabled;
+ g_return_val_if_fail (GLADE_IS_PROPERTY (property), FALSE);
+ return property->enabled;
}
@@ -1398,20 +1379,20 @@ static gint glade_property_su_stack = 0;
void
glade_property_push_superuser (void)
{
- glade_property_su_stack++;
+ glade_property_su_stack++;
}
void
glade_property_pop_superuser (void)
{
- if (--glade_property_su_stack < 0)
- {
- g_critical ("Bug: property super user stack is corrupt.\n");
- }
+ if (--glade_property_su_stack < 0)
+ {
+ g_critical ("Bug: property super user stack is corrupt.\n");
+ }
}
gboolean
glade_property_superuser (void)
{
- return glade_property_su_stack > 0;
+ return glade_property_su_stack > 0;
}
diff --git a/gladeui/glade-property.h b/gladeui/glade-property.h
index 9364963..1c1ef84 100644
--- a/gladeui/glade-property.h
+++ b/gladeui/glade-property.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_PROPERTY_H__
#define __GLADE_PROPERTY_H__
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 83c07c9..fca6c68 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -45,1092 +44,1083 @@
#include "glade-marshallers.h"
#include "glade-accumulators.h"
-typedef gboolean (*IsVoidFunc) (const gchar *signal_handler);
+typedef gboolean (*IsVoidFunc) (const gchar * signal_handler);
enum
{
- GSE_COLUMN_SIGNAL,
- GSE_COLUMN_HANDLER,
- GSE_COLUMN_AFTER,
- GSE_COLUMN_USERDATA,
- GSE_COLUMN_SWAPPED,
-
- GSE_COLUMN_USERDATA_SLOT,
- GSE_COLUMN_SWAPPED_VISIBLE,
- GSE_COLUMN_AFTER_VISIBLE,
- GSE_COLUMN_HANDLER_EDITABLE,
- GSE_COLUMN_USERDATA_EDITABLE,
- GSE_COLUMN_SLOT, /* if this row contains a "<Type...>" label */
- GSE_COLUMN_BOLD,
- GSE_COLUMN_CONTENT,
-
- GSE_COLUMN_WARN,
- GSE_COLUMN_TOOLTIP,
- GSE_NUM_COLUMNS
+ GSE_COLUMN_SIGNAL,
+ GSE_COLUMN_HANDLER,
+ GSE_COLUMN_AFTER,
+ GSE_COLUMN_USERDATA,
+ GSE_COLUMN_SWAPPED,
+
+ GSE_COLUMN_USERDATA_SLOT,
+ GSE_COLUMN_SWAPPED_VISIBLE,
+ GSE_COLUMN_AFTER_VISIBLE,
+ GSE_COLUMN_HANDLER_EDITABLE,
+ GSE_COLUMN_USERDATA_EDITABLE,
+ GSE_COLUMN_SLOT, /* if this row contains a "<Type...>" label */
+ GSE_COLUMN_BOLD,
+ GSE_COLUMN_CONTENT,
+
+ GSE_COLUMN_WARN,
+ GSE_COLUMN_TOOLTIP,
+ GSE_NUM_COLUMNS
};
enum
{
- HANDLER_EDITING_STARTED,
- USERDATA_EDITING_STARTED,
- LAST_SIGNAL
+ HANDLER_EDITING_STARTED,
+ USERDATA_EDITING_STARTED,
+ LAST_SIGNAL
};
enum
{
- PROP_0,
- PROP_HANDLER_COLUMN,
- PROP_USERDATA_COLUMN,
- PROP_HANDLER_COMPLETION,
- PROP_USERDATA_COMPLETION,
- PROP_HANDLER_RENDERER,
- PROP_USERDATA_RENDERER
+ PROP_0,
+ PROP_HANDLER_COLUMN,
+ PROP_USERDATA_COLUMN,
+ PROP_HANDLER_COMPLETION,
+ PROP_USERDATA_COMPLETION,
+ PROP_HANDLER_RENDERER,
+ PROP_USERDATA_RENDERER
};
G_DEFINE_TYPE (GladeSignalEditor, glade_signal_editor, GTK_TYPE_VBOX)
+ struct _GladeSignalEditorPrivate
+ {
+ GladeWidget *widget;
+ GladeWidgetAdaptor *adaptor;
-struct _GladeSignalEditorPrivate
-{
- GladeWidget *widget;
- GladeWidgetAdaptor *adaptor;
-
- gpointer *editor;
-
- GtkWidget *signals_list;
- GtkTreeStore *model;
- GtkTreeView *tree_view;
-
- GtkTreeModel *handler_store;
- GtkTreeModel *userdata_store;
- GtkCellRenderer *handler_renderer;
- GtkCellRenderer *userdata_renderer;
-
- GtkTreeViewColumn *handler_column;
- GtkTreeViewColumn *userdata_column;
- IsVoidFunc is_void_handler;
- IsVoidFunc is_void_userdata;
-
- gulong refresh_id;
-};
+ gpointer *editor;
+
+ GtkWidget *signals_list;
+ GtkTreeStore *model;
+ GtkTreeView *tree_view;
+
+ GtkTreeModel *handler_store;
+ GtkTreeModel *userdata_store;
+ GtkCellRenderer *handler_renderer;
+ GtkCellRenderer *userdata_renderer;
+
+ GtkTreeViewColumn *handler_column;
+ GtkTreeViewColumn *userdata_column;
+ IsVoidFunc is_void_handler;
+ IsVoidFunc is_void_userdata;
+
+ gulong refresh_id;
+ };
#define HANDLER_DEFAULT _("<Type here>")
#define USERDATA_DEFAULT _("<Object>")
-static gboolean
-glade_signal_editor_handler_editing_started_default (GladeSignalEditor *editor,
- gchar *signal_name,
- GtkTreeIter *iter,
- GtkCellEditable *editable);
-static gboolean
-glade_signal_editor_userdata_editing_started_default (GladeSignalEditor *editor,
- gchar *signal_name,
- GtkTreeIter *iter,
- GtkCellEditable *editable);
-
-static gboolean
-is_void_handler (const gchar *signal_handler)
+ static gboolean
+ glade_signal_editor_handler_editing_started_default (GladeSignalEditor
+ * editor,
+ gchar *
+ signal_name,
+ GtkTreeIter *
+ iter,
+ GtkCellEditable *
+ editable);
+ static gboolean
+ glade_signal_editor_userdata_editing_started_default (GladeSignalEditor
+ * editor,
+ gchar *
+ signal_name,
+ GtkTreeIter *
+ iter,
+ GtkCellEditable *
+ editable);
+
+ static gboolean is_void_handler (const gchar * signal_handler)
{
- return ( signal_handler == NULL ||
- *signal_handler == 0 ||
- g_utf8_collate (signal_handler, HANDLER_DEFAULT) == 0);
+ return (signal_handler == NULL ||
+ *signal_handler == 0 ||
+ g_utf8_collate (signal_handler, HANDLER_DEFAULT) == 0);
}
static gboolean
-is_void_userdata (const gchar *user_data)
+is_void_userdata (const gchar * user_data)
{
- return ( user_data == NULL ||
- *user_data == 0 ||
- g_utf8_collate (user_data, USERDATA_DEFAULT) == 0);
+ return (user_data == NULL ||
+ *user_data == 0 || g_utf8_collate (user_data, USERDATA_DEFAULT) == 0);
}
static void
-glade_signal_editor_after_swapped_toggled (GtkCellRendererToggle *cell,
- gchar *path_str,
- gpointer data)
+glade_signal_editor_after_swapped_toggled (GtkCellRendererToggle * cell,
+ gchar * path_str, gpointer data)
{
- GladeSignalEditor *editor = (GladeSignalEditor*) data;
- GladeSignalEditorPrivate* priv = editor->priv;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GtkTreeIter iter;
- GtkTreeIter iter_parent;
- GladeSignal *old_signal;
- GladeSignal *new_signal;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- gchar *signal_name;
- gchar *handler;
- gchar *userdata;
- gboolean swapped, new_swapped;
- gboolean after, new_after;
-
- /* get toggled iter */
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter,
- GSE_COLUMN_SIGNAL, &signal_name,
- GSE_COLUMN_HANDLER, &handler,
- GSE_COLUMN_USERDATA,&userdata,
- GSE_COLUMN_SWAPPED, &swapped,
- GSE_COLUMN_AFTER, &after, -1);
-
- if (signal_name == NULL)
- {
- if (!gtk_tree_model_iter_parent (model, &iter_parent, &iter))
- g_assert (FALSE);
-
- gtk_tree_model_get (model, &iter_parent, GSE_COLUMN_SIGNAL, &signal_name, -1);
- g_assert (signal_name != NULL);
- }
-
- if (is_void_userdata (userdata))
- {
- g_free (userdata);
- userdata = NULL;
- }
-
- new_after = after;
- new_swapped = swapped;
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "signal-after-cell")))
- new_after = !after;
- else
- new_swapped = !swapped;
-
- old_signal = glade_signal_new (signal_name, handler, userdata, after, swapped);
- new_signal = glade_signal_new (signal_name, handler, userdata, new_after, new_swapped);
-
- glade_command_change_signal (priv->widget, old_signal, new_signal);
-
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- GSE_COLUMN_AFTER, new_after,
- GSE_COLUMN_SWAPPED, new_swapped,
- -1);
-
- glade_signal_free (old_signal);
- glade_signal_free (new_signal);
- gtk_tree_path_free (path);
- g_free (signal_name);
- g_free (handler);
- g_free (userdata);
+ GladeSignalEditor *editor = (GladeSignalEditor *) data;
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GtkTreeIter iter;
+ GtkTreeIter iter_parent;
+ GladeSignal *old_signal;
+ GladeSignal *new_signal;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ gchar *signal_name;
+ gchar *handler;
+ gchar *userdata;
+ gboolean swapped, new_swapped;
+ gboolean after, new_after;
+
+ /* get toggled iter */
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter,
+ GSE_COLUMN_SIGNAL, &signal_name,
+ GSE_COLUMN_HANDLER, &handler,
+ GSE_COLUMN_USERDATA, &userdata,
+ GSE_COLUMN_SWAPPED, &swapped,
+ GSE_COLUMN_AFTER, &after, -1);
+
+ if (signal_name == NULL)
+ {
+ if (!gtk_tree_model_iter_parent (model, &iter_parent, &iter))
+ g_assert (FALSE);
+
+ gtk_tree_model_get (model, &iter_parent, GSE_COLUMN_SIGNAL, &signal_name,
+ -1);
+ g_assert (signal_name != NULL);
+ }
+
+ if (is_void_userdata (userdata))
+ {
+ g_free (userdata);
+ userdata = NULL;
+ }
+
+ new_after = after;
+ new_swapped = swapped;
+ if (GPOINTER_TO_INT
+ (g_object_get_data (G_OBJECT (cell), "signal-after-cell")))
+ new_after = !after;
+ else
+ new_swapped = !swapped;
+
+ old_signal =
+ glade_signal_new (signal_name, handler, userdata, after, swapped);
+ new_signal =
+ glade_signal_new (signal_name, handler, userdata, new_after, new_swapped);
+
+ glade_command_change_signal (priv->widget, old_signal, new_signal);
+
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ GSE_COLUMN_AFTER, new_after,
+ GSE_COLUMN_SWAPPED, new_swapped, -1);
+
+ glade_signal_free (old_signal);
+ glade_signal_free (new_signal);
+ gtk_tree_path_free (path);
+ g_free (signal_name);
+ g_free (handler);
+ g_free (userdata);
}
static void
-append_slot (GladeSignalEditor *self, GtkTreeIter *iter_signal, const gchar *signal_name)
+append_slot (GladeSignalEditor * self, GtkTreeIter * iter_signal,
+ const gchar * signal_name)
{
- GtkTreeIter iter_new_slot;
- GtkTreeIter iter_class;
- GladeSignalEditorPrivate* priv = self->priv;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GladeSignal *sig = glade_signal_new (signal_name, NULL, NULL, FALSE, FALSE);
-
- /* Check versioning warning here with a virtual signal */
- glade_project_update_signal_support_warning (priv->widget, sig);
-
- gtk_tree_store_append (GTK_TREE_STORE (model), &iter_new_slot, iter_signal);
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter_new_slot,
- GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
- GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, FALSE,
- GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
- GSE_COLUMN_HANDLER_EDITABLE, TRUE,
- GSE_COLUMN_USERDATA_EDITABLE,FALSE,
- GSE_COLUMN_AFTER, FALSE,
- GSE_COLUMN_AFTER_VISIBLE, FALSE,
- GSE_COLUMN_SLOT, TRUE,
- GSE_COLUMN_USERDATA_SLOT, TRUE,
- GSE_COLUMN_CONTENT, TRUE,
- GSE_COLUMN_WARN, FALSE,
- GSE_COLUMN_TOOLTIP, sig->support_warning,
- -1);
- gtk_tree_model_iter_parent (model, &iter_class, iter_signal);
-
- /* mark the signal & class name as bold */
- gtk_tree_store_set (GTK_TREE_STORE (model), iter_signal, GSE_COLUMN_BOLD, TRUE, -1);
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter_class, GSE_COLUMN_BOLD, TRUE, -1);
-
- glade_signal_free (sig);
+ GtkTreeIter iter_new_slot;
+ GtkTreeIter iter_class;
+ GladeSignalEditorPrivate *priv = self->priv;
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GladeSignal *sig = glade_signal_new (signal_name, NULL, NULL, FALSE, FALSE);
+
+ /* Check versioning warning here with a virtual signal */
+ glade_project_update_signal_support_warning (priv->widget, sig);
+
+ gtk_tree_store_append (GTK_TREE_STORE (model), &iter_new_slot, iter_signal);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter_new_slot,
+ GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
+ GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, FALSE,
+ GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
+ GSE_COLUMN_HANDLER_EDITABLE, TRUE,
+ GSE_COLUMN_USERDATA_EDITABLE, FALSE,
+ GSE_COLUMN_AFTER, FALSE,
+ GSE_COLUMN_AFTER_VISIBLE, FALSE,
+ GSE_COLUMN_SLOT, TRUE,
+ GSE_COLUMN_USERDATA_SLOT, TRUE,
+ GSE_COLUMN_CONTENT, TRUE,
+ GSE_COLUMN_WARN, FALSE,
+ GSE_COLUMN_TOOLTIP, sig->support_warning, -1);
+ gtk_tree_model_iter_parent (model, &iter_class, iter_signal);
+
+ /* mark the signal & class name as bold */
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter_signal, GSE_COLUMN_BOLD,
+ TRUE, -1);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter_class, GSE_COLUMN_BOLD,
+ TRUE, -1);
+
+ glade_signal_free (sig);
}
static void
-move_row (GtkTreeModel *model, GtkTreeIter *from, GtkTreeIter *to)
+move_row (GtkTreeModel * model, GtkTreeIter * from, GtkTreeIter * to)
{
- gchar *handler;
- gchar *userdata, *support_warning;
- gboolean after;
- gboolean slot;
- gboolean visible;
- gboolean userdata_slot;
- gboolean handler_editable;
- gboolean userdata_editable;
- gboolean swapped;
- gboolean swapped_visible;
- gboolean bold, content, warn;
-
- gtk_tree_model_get (model, from,
- GSE_COLUMN_HANDLER, &handler,
- GSE_COLUMN_USERDATA, &userdata,
- GSE_COLUMN_AFTER, &after,
- GSE_COLUMN_SLOT, &slot,
- GSE_COLUMN_AFTER_VISIBLE, &visible,
- GSE_COLUMN_HANDLER_EDITABLE, &handler_editable,
- GSE_COLUMN_USERDATA_EDITABLE, &userdata_editable,
- GSE_COLUMN_USERDATA_SLOT, &userdata_slot,
- GSE_COLUMN_SWAPPED, &swapped,
- GSE_COLUMN_SWAPPED_VISIBLE, &swapped_visible,
- GSE_COLUMN_BOLD, &bold,
- GSE_COLUMN_CONTENT, &content,
- GSE_COLUMN_WARN, &warn,
- GSE_COLUMN_TOOLTIP, &support_warning,
- -1);
-
- gtk_tree_store_set (GTK_TREE_STORE (model), to,
- GSE_COLUMN_HANDLER, handler,
- GSE_COLUMN_USERDATA, userdata,
- GSE_COLUMN_AFTER, after,
- GSE_COLUMN_SLOT, slot,
- GSE_COLUMN_AFTER_VISIBLE, visible,
- GSE_COLUMN_HANDLER_EDITABLE, handler_editable,
- GSE_COLUMN_USERDATA_EDITABLE, userdata_editable,
- GSE_COLUMN_USERDATA_SLOT, userdata_slot,
- GSE_COLUMN_SWAPPED, swapped,
- GSE_COLUMN_SWAPPED_VISIBLE, swapped_visible,
- GSE_COLUMN_BOLD, bold,
- GSE_COLUMN_CONTENT, content,
- GSE_COLUMN_WARN, warn,
- GSE_COLUMN_TOOLTIP, support_warning,
- -1);
-
- g_free (support_warning);
- g_free (handler);
- g_free (userdata);
+ gchar *handler;
+ gchar *userdata, *support_warning;
+ gboolean after;
+ gboolean slot;
+ gboolean visible;
+ gboolean userdata_slot;
+ gboolean handler_editable;
+ gboolean userdata_editable;
+ gboolean swapped;
+ gboolean swapped_visible;
+ gboolean bold, content, warn;
+
+ gtk_tree_model_get (model, from,
+ GSE_COLUMN_HANDLER, &handler,
+ GSE_COLUMN_USERDATA, &userdata,
+ GSE_COLUMN_AFTER, &after,
+ GSE_COLUMN_SLOT, &slot,
+ GSE_COLUMN_AFTER_VISIBLE, &visible,
+ GSE_COLUMN_HANDLER_EDITABLE, &handler_editable,
+ GSE_COLUMN_USERDATA_EDITABLE, &userdata_editable,
+ GSE_COLUMN_USERDATA_SLOT, &userdata_slot,
+ GSE_COLUMN_SWAPPED, &swapped,
+ GSE_COLUMN_SWAPPED_VISIBLE, &swapped_visible,
+ GSE_COLUMN_BOLD, &bold,
+ GSE_COLUMN_CONTENT, &content,
+ GSE_COLUMN_WARN, &warn,
+ GSE_COLUMN_TOOLTIP, &support_warning, -1);
+
+ gtk_tree_store_set (GTK_TREE_STORE (model), to,
+ GSE_COLUMN_HANDLER, handler,
+ GSE_COLUMN_USERDATA, userdata,
+ GSE_COLUMN_AFTER, after,
+ GSE_COLUMN_SLOT, slot,
+ GSE_COLUMN_AFTER_VISIBLE, visible,
+ GSE_COLUMN_HANDLER_EDITABLE, handler_editable,
+ GSE_COLUMN_USERDATA_EDITABLE, userdata_editable,
+ GSE_COLUMN_USERDATA_SLOT, userdata_slot,
+ GSE_COLUMN_SWAPPED, swapped,
+ GSE_COLUMN_SWAPPED_VISIBLE, swapped_visible,
+ GSE_COLUMN_BOLD, bold,
+ GSE_COLUMN_CONTENT, content,
+ GSE_COLUMN_WARN, warn,
+ GSE_COLUMN_TOOLTIP, support_warning, -1);
+
+ g_free (support_warning);
+ g_free (handler);
+ g_free (userdata);
}
static void
-remove_slot (GtkTreeModel *model, GtkTreeIter *iter, GtkTreeIter *iter_signal)
+remove_slot (GtkTreeModel * model, GtkTreeIter * iter,
+ GtkTreeIter * iter_signal)
{
- GtkTreeIter iter_class;
-
- gtk_tree_model_iter_parent (model, &iter_class, iter_signal);
-
- /* special case for removing the handler of the first row */
- if (iter == NULL)
- {
- GtkTreeIter first_iter;
-
- gtk_tree_model_iter_nth_child (model, &first_iter, iter_signal, 0);
- move_row (model, &first_iter, iter_signal);
- gtk_tree_store_remove (GTK_TREE_STORE (model), &first_iter);
- }
- else
- gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
-
- if (!gtk_tree_model_iter_has_child (model, iter_signal))
- {
- /* mark the signal & class name as normal */
- gtk_tree_store_set (GTK_TREE_STORE (model), iter_signal,
- GSE_COLUMN_BOLD, FALSE, -1);
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter_class,
- GSE_COLUMN_BOLD, FALSE, -1);
- }
+ GtkTreeIter iter_class;
+
+ gtk_tree_model_iter_parent (model, &iter_class, iter_signal);
+
+ /* special case for removing the handler of the first row */
+ if (iter == NULL)
+ {
+ GtkTreeIter first_iter;
+
+ gtk_tree_model_iter_nth_child (model, &first_iter, iter_signal, 0);
+ move_row (model, &first_iter, iter_signal);
+ gtk_tree_store_remove (GTK_TREE_STORE (model), &first_iter);
+ }
+ else
+ gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
+
+ if (!gtk_tree_model_iter_has_child (model, iter_signal))
+ {
+ /* mark the signal & class name as normal */
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter_signal,
+ GSE_COLUMN_BOLD, FALSE, -1);
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter_class,
+ GSE_COLUMN_BOLD, FALSE, -1);
+ }
}
static gboolean
-glade_signal_editor_handler_editing_done (GladeSignalEditor *self,
- const gchar *signal_name,
- const gchar *old_handler,
- const gchar *new_handler,
- GtkTreeIter *iter)
+glade_signal_editor_handler_editing_done (GladeSignalEditor * self,
+ const gchar * signal_name,
+ const gchar * old_handler,
+ const gchar * new_handler,
+ GtkTreeIter * iter)
{
- GladeSignalEditorPrivate *priv = self->priv;
- GladeWidget *glade_widget = priv->widget;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- gchar *tmp_signal_name;
- gchar *userdata;
- GtkTreeIter iter_signal;
- gboolean after, swapped;
- gboolean is_top_handler;
-
- gtk_tree_model_get (model, iter,
- GSE_COLUMN_SIGNAL, &tmp_signal_name,
- GSE_COLUMN_USERDATA, &userdata,
- GSE_COLUMN_AFTER, &after,
- GSE_COLUMN_SWAPPED, &swapped,
- -1);
-
- if (priv->is_void_userdata (userdata))
- {
- g_free (userdata);
- userdata = NULL;
- }
-
- if (tmp_signal_name == NULL)
- {
- is_top_handler = FALSE;
- gtk_tree_model_iter_parent (model, &iter_signal, iter);
- }
- else
- {
- is_top_handler = TRUE;
- iter_signal = *iter;
- g_free (tmp_signal_name);
- }
-
- /* we're adding a new handler */
- if (old_handler == NULL && new_handler)
- {
- GladeSignal *new_signal = glade_signal_new (signal_name, new_handler,
- NULL, FALSE, FALSE);
- glade_command_add_signal (glade_widget, new_signal);
- glade_signal_free (new_signal);
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- GSE_COLUMN_HANDLER, new_handler,
- GSE_COLUMN_AFTER_VISIBLE, TRUE,
- GSE_COLUMN_SLOT, FALSE,
- GSE_COLUMN_USERDATA_EDITABLE,TRUE, -1);
-
- /* append a <Type...> slot */
- append_slot (self, &iter_signal, signal_name);
- }
-
- /* we're removing a signal handler */
- else if (old_handler && new_handler == NULL)
- {
- GladeSignal *old_signal =
- glade_signal_new (signal_name,
- old_handler,
- userdata,
- after,
- swapped);
- glade_command_remove_signal (glade_widget, old_signal);
- glade_signal_free (old_signal);
-
- gtk_tree_store_set
- (GTK_TREE_STORE (model), iter,
- GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
- GSE_COLUMN_AFTER, FALSE,
- GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, FALSE,
- GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
- GSE_COLUMN_HANDLER_EDITABLE, TRUE,
- GSE_COLUMN_USERDATA_EDITABLE,FALSE,
- GSE_COLUMN_AFTER_VISIBLE, FALSE,
- GSE_COLUMN_SLOT, TRUE,
- GSE_COLUMN_USERDATA_SLOT, TRUE,
- GSE_COLUMN_CONTENT, TRUE,
- -1);
-
- remove_slot (model, is_top_handler ? NULL : iter, &iter_signal);
- }
-
- /* we're changing a signal handler */
- else if (old_handler && new_handler)
- {
- GladeSignal *old_signal =
- glade_signal_new
- (signal_name,
- old_handler,
- userdata,
- after,
- swapped);
- GladeSignal *new_signal =
- glade_signal_new
- (signal_name,
- new_handler,
- userdata,
- after,
- swapped);
-
- if (glade_signal_equal (old_signal, new_signal) == FALSE)
- glade_command_change_signal (glade_widget, old_signal, new_signal);
-
- glade_signal_free (old_signal);
- glade_signal_free (new_signal);
-
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- GSE_COLUMN_HANDLER, new_handler,
- GSE_COLUMN_AFTER_VISIBLE, TRUE,
- GSE_COLUMN_SLOT, FALSE,
- GSE_COLUMN_USERDATA_EDITABLE,TRUE, -1);
- }
-
- g_free (userdata);
-
- return FALSE;
+ GladeSignalEditorPrivate *priv = self->priv;
+ GladeWidget *glade_widget = priv->widget;
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ gchar *tmp_signal_name;
+ gchar *userdata;
+ GtkTreeIter iter_signal;
+ gboolean after, swapped;
+ gboolean is_top_handler;
+
+ gtk_tree_model_get (model, iter,
+ GSE_COLUMN_SIGNAL, &tmp_signal_name,
+ GSE_COLUMN_USERDATA, &userdata,
+ GSE_COLUMN_AFTER, &after,
+ GSE_COLUMN_SWAPPED, &swapped, -1);
+
+ if (priv->is_void_userdata (userdata))
+ {
+ g_free (userdata);
+ userdata = NULL;
+ }
+
+ if (tmp_signal_name == NULL)
+ {
+ is_top_handler = FALSE;
+ gtk_tree_model_iter_parent (model, &iter_signal, iter);
+ }
+ else
+ {
+ is_top_handler = TRUE;
+ iter_signal = *iter;
+ g_free (tmp_signal_name);
+ }
+
+ /* we're adding a new handler */
+ if (old_handler == NULL && new_handler)
+ {
+ GladeSignal *new_signal = glade_signal_new (signal_name, new_handler,
+ NULL, FALSE, FALSE);
+ glade_command_add_signal (glade_widget, new_signal);
+ glade_signal_free (new_signal);
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ GSE_COLUMN_HANDLER, new_handler,
+ GSE_COLUMN_AFTER_VISIBLE, TRUE,
+ GSE_COLUMN_SLOT, FALSE,
+ GSE_COLUMN_USERDATA_EDITABLE, TRUE, -1);
+
+ /* append a <Type...> slot */
+ append_slot (self, &iter_signal, signal_name);
+ }
+
+ /* we're removing a signal handler */
+ else if (old_handler && new_handler == NULL)
+ {
+ GladeSignal *old_signal = glade_signal_new (signal_name,
+ old_handler,
+ userdata,
+ after,
+ swapped);
+ glade_command_remove_signal (glade_widget, old_signal);
+ glade_signal_free (old_signal);
+
+ gtk_tree_store_set
+ (GTK_TREE_STORE (model), iter,
+ GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
+ GSE_COLUMN_AFTER, FALSE,
+ GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, FALSE,
+ GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
+ GSE_COLUMN_HANDLER_EDITABLE, TRUE,
+ GSE_COLUMN_USERDATA_EDITABLE, FALSE,
+ GSE_COLUMN_AFTER_VISIBLE, FALSE,
+ GSE_COLUMN_SLOT, TRUE,
+ GSE_COLUMN_USERDATA_SLOT, TRUE, GSE_COLUMN_CONTENT, TRUE, -1);
+
+ remove_slot (model, is_top_handler ? NULL : iter, &iter_signal);
+ }
+
+ /* we're changing a signal handler */
+ else if (old_handler && new_handler)
+ {
+ GladeSignal *old_signal = glade_signal_new (signal_name,
+ old_handler,
+ userdata,
+ after,
+ swapped);
+ GladeSignal *new_signal = glade_signal_new (signal_name,
+ new_handler,
+ userdata,
+ after,
+ swapped);
+
+ if (glade_signal_equal (old_signal, new_signal) == FALSE)
+ glade_command_change_signal (glade_widget, old_signal, new_signal);
+
+ glade_signal_free (old_signal);
+ glade_signal_free (new_signal);
+
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ GSE_COLUMN_HANDLER, new_handler,
+ GSE_COLUMN_AFTER_VISIBLE, TRUE,
+ GSE_COLUMN_SLOT, FALSE,
+ GSE_COLUMN_USERDATA_EDITABLE, TRUE, -1);
+ }
+
+ g_free (userdata);
+
+ return FALSE;
}
static gboolean
-glade_signal_editor_userdata_editing_done (GladeSignalEditor *self,
- const gchar *signal_name,
- const gchar *old_userdata,
- const gchar *new_userdata,
- GtkTreeIter *iter)
+glade_signal_editor_userdata_editing_done (GladeSignalEditor * self,
+ const gchar * signal_name,
+ const gchar * old_userdata,
+ const gchar * new_userdata,
+ GtkTreeIter * iter)
{
- GladeSignalEditorPrivate *priv = self->priv;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GladeWidget *glade_widget = priv->widget;
- gchar *handler;
- gboolean after, swapped;
- GladeSignal *old_signal, *new_signal;
-
- gtk_tree_model_get (model, iter,
- GSE_COLUMN_HANDLER, &handler,
- GSE_COLUMN_AFTER, &after,
- GSE_COLUMN_SWAPPED, &swapped,
- -1);
-
- /* We are removing userdata */
- if (new_userdata == NULL)
- {
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- GSE_COLUMN_USERDATA_SLOT, TRUE,
- GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, FALSE,
- GSE_COLUMN_SWAPPED_VISIBLE, FALSE, -1);
- }
- else
- {
- gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- GSE_COLUMN_USERDATA_SLOT, FALSE,
- GSE_COLUMN_USERDATA, new_userdata,
- GSE_COLUMN_SWAPPED_VISIBLE, TRUE,
- -1);
- }
-
- old_signal = glade_signal_new (signal_name, handler, old_userdata, after, swapped);
-
- new_signal = glade_signal_new (signal_name, handler, new_userdata, after, swapped);
-
- if (glade_signal_equal (old_signal, new_signal) == FALSE)
- glade_command_change_signal (glade_widget, old_signal, new_signal);
-
- glade_signal_free (old_signal);
- glade_signal_free (new_signal);
-
- g_free (handler);
- return FALSE;
+ GladeSignalEditorPrivate *priv = self->priv;
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GladeWidget *glade_widget = priv->widget;
+ gchar *handler;
+ gboolean after, swapped;
+ GladeSignal *old_signal, *new_signal;
+
+ gtk_tree_model_get (model, iter,
+ GSE_COLUMN_HANDLER, &handler,
+ GSE_COLUMN_AFTER, &after,
+ GSE_COLUMN_SWAPPED, &swapped, -1);
+
+ /* We are removing userdata */
+ if (new_userdata == NULL)
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ GSE_COLUMN_USERDATA_SLOT, TRUE,
+ GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, FALSE,
+ GSE_COLUMN_SWAPPED_VISIBLE, FALSE, -1);
+ }
+ else
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ GSE_COLUMN_USERDATA_SLOT, FALSE,
+ GSE_COLUMN_USERDATA, new_userdata,
+ GSE_COLUMN_SWAPPED_VISIBLE, TRUE, -1);
+ }
+
+ old_signal =
+ glade_signal_new (signal_name, handler, old_userdata, after, swapped);
+
+ new_signal =
+ glade_signal_new (signal_name, handler, new_userdata, after, swapped);
+
+ if (glade_signal_equal (old_signal, new_signal) == FALSE)
+ glade_command_change_signal (glade_widget, old_signal, new_signal);
+
+ glade_signal_free (old_signal);
+ glade_signal_free (new_signal);
+
+ g_free (handler);
+ return FALSE;
}
static gchar *
-glade_signal_editor_get_signal_name (GtkTreeModel *model, GtkTreeIter *iter)
+glade_signal_editor_get_signal_name (GtkTreeModel * model, GtkTreeIter * iter)
{
- gchar *signal_name;
- gtk_tree_model_get (model, iter,
- GSE_COLUMN_SIGNAL, &signal_name,
- -1);
- if (signal_name == NULL)
- {
- GtkTreeIter iter_signal;
-
- if (!gtk_tree_model_iter_parent (model, &iter_signal, iter))
- g_assert (FALSE);
-
- gtk_tree_model_get (model, &iter_signal, GSE_COLUMN_SIGNAL, &signal_name, -1);
- g_assert (signal_name != NULL);
- }
-
- return signal_name;
+ gchar *signal_name;
+ gtk_tree_model_get (model, iter, GSE_COLUMN_SIGNAL, &signal_name, -1);
+ if (signal_name == NULL)
+ {
+ GtkTreeIter iter_signal;
+
+ if (!gtk_tree_model_iter_parent (model, &iter_signal, iter))
+ g_assert (FALSE);
+
+ gtk_tree_model_get (model, &iter_signal, GSE_COLUMN_SIGNAL, &signal_name,
+ -1);
+ g_assert (signal_name != NULL);
+ }
+
+ return signal_name;
}
static void
-glade_signal_editor_column_cell_edited (const gchar *path_str,
- const gchar *new_value,
- gpointer data,
- gint column,
- IsVoidFunc is_void_callback)
+glade_signal_editor_column_cell_edited (const gchar * path_str,
+ const gchar * new_value,
+ gpointer data,
+ gint column,
+ IsVoidFunc is_void_callback)
{
- GladeSignalEditor* self = GLADE_SIGNAL_EDITOR (data);
- GladeSignalEditorPrivate *priv = self->priv;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeIter iter;
- gchar *signal_name;
- gchar *old_value;
-
- g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
- gtk_tree_path_free (path);
- gtk_tree_model_get (model, &iter,
- column, &old_value,
- -1);
-
- signal_name = glade_signal_editor_get_signal_name (model, &iter);
-
- if (is_void_callback (new_value))
- new_value = NULL;
-
- if (is_void_callback (old_value))
- {
- g_free (old_value);
- old_value = NULL;
- }
-
- /* if not a false alarm */
- if (old_value || new_value);
- {
- switch (column)
- {
- case GSE_COLUMN_HANDLER:
- glade_signal_editor_handler_editing_done (self,
- signal_name,
- old_value,
- new_value,
- &iter);
- break;
- case GSE_COLUMN_USERDATA:
- glade_signal_editor_userdata_editing_done (self,
- signal_name,
- old_value,
- new_value,
- &iter);
- break;
-
- }
- }
-
- g_free (signal_name);
- g_free (old_value);
+ GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (data);
+ GladeSignalEditorPrivate *priv = self->priv;
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeIter iter;
+ gchar *signal_name;
+ gchar *old_value;
+
+ g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
+ gtk_tree_path_free (path);
+ gtk_tree_model_get (model, &iter, column, &old_value, -1);
+
+ signal_name = glade_signal_editor_get_signal_name (model, &iter);
+
+ if (is_void_callback (new_value))
+ new_value = NULL;
+
+ if (is_void_callback (old_value))
+ {
+ g_free (old_value);
+ old_value = NULL;
+ }
+
+ /* if not a false alarm */
+ if (old_value || new_value);
+ {
+ switch (column)
+ {
+ case GSE_COLUMN_HANDLER:
+ glade_signal_editor_handler_editing_done (self,
+ signal_name,
+ old_value,
+ new_value, &iter);
+ break;
+ case GSE_COLUMN_USERDATA:
+ glade_signal_editor_userdata_editing_done (self,
+ signal_name,
+ old_value,
+ new_value, &iter);
+ break;
+
+ }
+ }
+
+ g_free (signal_name);
+ g_free (old_value);
}
static void
-glade_signal_editor_handler_cell_edited (GtkCellRendererText *cell,
- const gchar *path_str,
- const gchar *new_handler,
- gpointer data)
+glade_signal_editor_handler_cell_edited (GtkCellRendererText * cell,
+ const gchar * path_str,
+ const gchar * new_handler,
+ gpointer data)
{
- GladeSignalEditor *editor = GLADE_SIGNAL_EDITOR (data);
+ GladeSignalEditor *editor = GLADE_SIGNAL_EDITOR (data);
- glade_signal_editor_column_cell_edited (path_str, new_handler, data,
- GSE_COLUMN_HANDLER,
- editor->priv->is_void_handler);
+ glade_signal_editor_column_cell_edited (path_str, new_handler, data,
+ GSE_COLUMN_HANDLER,
+ editor->priv->is_void_handler);
}
static void
-glade_signal_editor_userdata_cell_edited (GtkCellRendererText *cell,
- const gchar *path_str,
- const gchar *new_userdata,
- gpointer data)
+glade_signal_editor_userdata_cell_edited (GtkCellRendererText * cell,
+ const gchar * path_str,
+ const gchar * new_userdata,
+ gpointer data)
{
- GladeSignalEditor *editor = GLADE_SIGNAL_EDITOR (data);
+ GladeSignalEditor *editor = GLADE_SIGNAL_EDITOR (data);
- glade_signal_editor_column_cell_edited (path_str, new_userdata, data,
- GSE_COLUMN_USERDATA,
- editor->priv->is_void_userdata);
+ glade_signal_editor_column_cell_edited (path_str, new_userdata, data,
+ GSE_COLUMN_USERDATA,
+ editor->priv->is_void_userdata);
}
static void
-glade_signal_editor_column_editing_started (GtkCellEditable *editable,
- const gchar *path_str,
- GladeSignalEditor *editor,
- guint signal)
+glade_signal_editor_column_editing_started (GtkCellEditable * editable,
+ const gchar * path_str,
+ GladeSignalEditor * editor,
+ guint signal)
{
- GladeSignalEditorPrivate *priv = editor->priv;
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GtkTreePath *path;
- GtkTreeIter iter;
- gchar *signal_name;
-
- path = gtk_tree_path_new_from_string (path_str);
- g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
- gtk_tree_path_free (path);
- signal_name = glade_signal_editor_get_signal_name (model, &iter);
- switch (signal)
- {
- case HANDLER_EDITING_STARTED:
- glade_signal_editor_handler_editing_started_default (editor,
- signal_name,
- &iter,
- editable);
- break;
- case USERDATA_EDITING_STARTED:
- glade_signal_editor_userdata_editing_started_default (editor,
- signal_name,
- &iter,
- editable);
- break;
- }
- g_free (signal_name);
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gchar *signal_name;
+
+ path = gtk_tree_path_new_from_string (path_str);
+ g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
+ gtk_tree_path_free (path);
+ signal_name = glade_signal_editor_get_signal_name (model, &iter);
+ switch (signal)
+ {
+ case HANDLER_EDITING_STARTED:
+ glade_signal_editor_handler_editing_started_default (editor,
+ signal_name,
+ &iter, editable);
+ break;
+ case USERDATA_EDITING_STARTED:
+ glade_signal_editor_userdata_editing_started_default (editor,
+ signal_name,
+ &iter, editable);
+ break;
+ }
+ g_free (signal_name);
}
static void
-glade_signal_editor_handler_editing_started (GtkCellRenderer *cell,
- GtkCellEditable *editable,
- const gchar *path,
- GladeSignalEditor *editor)
+glade_signal_editor_handler_editing_started (GtkCellRenderer * cell,
+ GtkCellEditable * editable,
+ const gchar * path,
+ GladeSignalEditor * editor)
{
- glade_signal_editor_column_editing_started (editable, path,
- editor, HANDLER_EDITING_STARTED);
+ glade_signal_editor_column_editing_started (editable, path,
+ editor, HANDLER_EDITING_STARTED);
}
static void
-glade_signal_editor_userdata_editing_started (GtkCellRenderer *cell,
- GtkCellEditable *editable,
- const gchar *path,
- GladeSignalEditor *editor)
+glade_signal_editor_userdata_editing_started (GtkCellRenderer * cell,
+ GtkCellEditable * editable,
+ const gchar * path,
+ GladeSignalEditor * editor)
{
- glade_signal_editor_column_editing_started (editable, path,
- editor, USERDATA_EDITING_STARTED);
+ glade_signal_editor_column_editing_started (editable, path,
+ editor, USERDATA_EDITING_STARTED);
}
static void
-glade_signal_editor_signal_cell_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+glade_signal_editor_signal_cell_data_func (GtkTreeViewColumn * tree_column,
+ GtkCellRenderer * cell,
+ GtkTreeModel * tree_model,
+ GtkTreeIter * iter, gpointer data)
{
- gboolean bold;
+ gboolean bold;
- gtk_tree_model_get (tree_model, iter, GSE_COLUMN_BOLD, &bold, -1);
- if (bold)
- g_object_set (G_OBJECT (cell), "weight", PANGO_WEIGHT_BOLD, NULL);
- else
- g_object_set (G_OBJECT (cell), "weight", PANGO_WEIGHT_NORMAL, NULL);
+ gtk_tree_model_get (tree_model, iter, GSE_COLUMN_BOLD, &bold, -1);
+ if (bold)
+ g_object_set (G_OBJECT (cell), "weight", PANGO_WEIGHT_BOLD, NULL);
+ else
+ g_object_set (G_OBJECT (cell), "weight", PANGO_WEIGHT_NORMAL, NULL);
}
static void
-glade_signal_editor_handler_cell_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+glade_signal_editor_handler_cell_data_func (GtkTreeViewColumn * tree_column,
+ GtkCellRenderer * cell,
+ GtkTreeModel * tree_model,
+ GtkTreeIter * iter, gpointer data)
{
- gboolean slot;
-
- gtk_tree_model_get (tree_model, iter, GSE_COLUMN_SLOT, &slot, -1);
- if (slot)
- g_object_set (G_OBJECT (cell),
- "style", PANGO_STYLE_ITALIC,
- "foreground", "Gray", NULL);
- else
- g_object_set (G_OBJECT (cell),
- "style", PANGO_STYLE_NORMAL,
- "foreground", NULL, NULL);
+ gboolean slot;
+
+ gtk_tree_model_get (tree_model, iter, GSE_COLUMN_SLOT, &slot, -1);
+ if (slot)
+ g_object_set (G_OBJECT (cell),
+ "style", PANGO_STYLE_ITALIC, "foreground", "Gray", NULL);
+ else
+ g_object_set (G_OBJECT (cell),
+ "style", PANGO_STYLE_NORMAL, "foreground", NULL, NULL);
}
static void
-glade_signal_editor_userdata_cell_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+glade_signal_editor_userdata_cell_data_func (GtkTreeViewColumn * tree_column,
+ GtkCellRenderer * cell,
+ GtkTreeModel * tree_model,
+ GtkTreeIter * iter, gpointer data)
{
- gboolean userdata_slot;
-
- gtk_tree_model_get (tree_model, iter, GSE_COLUMN_USERDATA_SLOT, &userdata_slot, -1);
- if (userdata_slot)
- g_object_set (G_OBJECT (cell),
- "style", PANGO_STYLE_ITALIC,
- "foreground", "Gray", NULL);
- else
- g_object_set (G_OBJECT (cell),
- "style", PANGO_STYLE_NORMAL,
- "foreground", NULL, NULL);
+ gboolean userdata_slot;
+
+ gtk_tree_model_get (tree_model, iter, GSE_COLUMN_USERDATA_SLOT,
+ &userdata_slot, -1);
+ if (userdata_slot)
+ g_object_set (G_OBJECT (cell),
+ "style", PANGO_STYLE_ITALIC, "foreground", "Gray", NULL);
+ else
+ g_object_set (G_OBJECT (cell),
+ "style", PANGO_STYLE_NORMAL, "foreground", NULL, NULL);
}
-static void
-glade_signal_editor_devhelp_cb (GtkCellRenderer *cell,
- const gchar *path_str,
- GladeSignalEditor *editor)
+static void
+glade_signal_editor_devhelp_cb (GtkCellRenderer * cell,
+ const gchar * path_str,
+ GladeSignalEditor * editor)
{
- GladeSignalEditorPrivate *priv = editor->priv;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GtkTreeIter iter;
- GladeSignalClass *signal_class;
- gchar *signal, *search, *book = NULL;
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GtkTreeIter iter;
+ GladeSignalClass *signal_class;
+ gchar *signal, *search, *book = NULL;
- g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
- gtk_tree_path_free (path);
+ g_return_if_fail (gtk_tree_model_get_iter (model, &iter, path));
+ gtk_tree_path_free (path);
- signal = glade_signal_editor_get_signal_name (model, &iter);
- search = g_strdup_printf ("The %s signal", signal);
+ signal = glade_signal_editor_get_signal_name (model, &iter);
+ search = g_strdup_printf ("The %s signal", signal);
- signal_class = glade_widget_adaptor_get_signal_class (priv->widget->adaptor,
- signal);
- g_assert (signal_class);
+ signal_class = glade_widget_adaptor_get_signal_class (priv->widget->adaptor,
+ signal);
+ g_assert (signal_class);
- g_object_get (signal_class->adaptor, "book", &book, NULL);
+ g_object_get (signal_class->adaptor, "book", &book, NULL);
- glade_editor_search_doc_search (glade_app_get_editor (),
- book, signal_class->adaptor->name, search);
+ glade_editor_search_doc_search (glade_app_get_editor (),
+ book, signal_class->adaptor->name, search);
- g_free (search);
- g_free (book);
- g_free (signal);
+ g_free (search);
+ g_free (book);
+ g_free (signal);
}
static void
-set_column_header_tooltip_on_realize (GtkWidget *label,
- const gchar *tooltip_txt)
+set_column_header_tooltip_on_realize (GtkWidget * label,
+ const gchar * tooltip_txt)
{
- GtkWidget *header =
- gtk_widget_get_ancestor (label, GTK_TYPE_BUTTON);
+ GtkWidget *header = gtk_widget_get_ancestor (label, GTK_TYPE_BUTTON);
- if (header)
- gtk_widget_set_tooltip_text (header, tooltip_txt);
+ if (header)
+ gtk_widget_set_tooltip_text (header, tooltip_txt);
}
/* convenience function: tooltip_txt must be static memory */
static void
-column_header_widget (GtkTreeViewColumn *column,
- const gchar *txt,
- const gchar *tooltip_txt)
+column_header_widget (GtkTreeViewColumn * column,
+ const gchar * txt, const gchar * tooltip_txt)
{
- GtkWidget *event_box, *label;
+ GtkWidget *event_box, *label;
+
+ event_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
+
+ gtk_widget_set_tooltip_text (event_box, tooltip_txt);
- event_box = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
+ label = gtk_label_new (txt);
- gtk_widget_set_tooltip_text (event_box, tooltip_txt);
+ gtk_widget_show (event_box);
+ gtk_widget_show (label);
- label = gtk_label_new (txt);
+ g_signal_connect_after (G_OBJECT (label), "realize",
+ G_CALLBACK (set_column_header_tooltip_on_realize),
+ (gpointer) tooltip_txt);
- gtk_widget_show (event_box);
- gtk_widget_show (label);
-
- g_signal_connect_after (G_OBJECT (label), "realize",
- G_CALLBACK (set_column_header_tooltip_on_realize), (gpointer)tooltip_txt);
+ gtk_container_add (GTK_CONTAINER (event_box), label);
- gtk_container_add (GTK_CONTAINER (event_box), label);
-
- gtk_tree_view_column_set_widget (column, event_box);
-}
+ gtk_tree_view_column_set_widget (column, event_box);
+}
static void
-glade_signal_editor_user_data_activate (GtkCellRenderer *icon_renderer,
- const gchar *path_str,
- GladeSignalEditor *editor)
+glade_signal_editor_user_data_activate (GtkCellRenderer * icon_renderer,
+ const gchar * path_str,
+ GladeSignalEditor * editor)
{
- GladeSignalEditorPrivate *priv = editor->priv;
- GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
- GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
- GtkTreeIter iter;
- gchar *object_name = NULL, *signal_name = NULL, *handler = NULL;
- gboolean after, swapped;
- GladeWidget *project_object = NULL;
- GladeProject *project;
- GList *selected = NULL, *exception = NULL;
-
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter,
- GSE_COLUMN_HANDLER, &handler,
- GSE_COLUMN_USERDATA,&object_name,
- GSE_COLUMN_SWAPPED, &swapped,
- GSE_COLUMN_AFTER, &after, -1);
-
- signal_name = glade_signal_editor_get_signal_name (model, &iter);
- project = glade_widget_get_project (priv->widget);
-
- if (object_name)
- {
- project_object = glade_project_get_widget_by_name (project, NULL, object_name);
- selected = g_list_prepend (selected, project_object);
- }
-
- exception = g_list_prepend (exception, priv->widget);
-
- if (glade_editor_property_show_object_dialog (project,
- _("Select an object to pass to the handler"),
- gtk_widget_get_toplevel (GTK_WIDGET(editor)),
- G_TYPE_OBJECT,
- priv->widget, &project_object))
- {
- GladeSignal *old_signal = glade_signal_new (signal_name, handler, object_name, after, swapped);
- GladeSignal *new_signal = glade_signal_new (signal_name, handler,
- project_object ? project_object->name : NULL,
- after, swapped);
-
- glade_command_change_signal (priv->widget, old_signal, new_signal);
- glade_signal_free (old_signal);
- glade_signal_free (new_signal);
-
- /* We are removing userdata */
- if (project_object == NULL)
- {
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- GSE_COLUMN_USERDATA_SLOT, TRUE,
- GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, FALSE,
- GSE_COLUMN_SWAPPED_VISIBLE, FALSE, -1);
- }
- else
- {
- gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
- GSE_COLUMN_USERDATA_SLOT, FALSE,
- GSE_COLUMN_USERDATA, project_object->name,
- GSE_COLUMN_SWAPPED_VISIBLE, TRUE,
- -1);
- }
- }
-
- gtk_tree_path_free (path);
- g_free (signal_name);
- g_free (object_name);
- g_free (handler);
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->model);
+ GtkTreeIter iter;
+ gchar *object_name = NULL, *signal_name = NULL, *handler = NULL;
+ gboolean after, swapped;
+ GladeWidget *project_object = NULL;
+ GladeProject *project;
+ GList *selected = NULL, *exception = NULL;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter,
+ GSE_COLUMN_HANDLER, &handler,
+ GSE_COLUMN_USERDATA, &object_name,
+ GSE_COLUMN_SWAPPED, &swapped,
+ GSE_COLUMN_AFTER, &after, -1);
+
+ signal_name = glade_signal_editor_get_signal_name (model, &iter);
+ project = glade_widget_get_project (priv->widget);
+
+ if (object_name)
+ {
+ project_object =
+ glade_project_get_widget_by_name (project, NULL, object_name);
+ selected = g_list_prepend (selected, project_object);
+ }
+
+ exception = g_list_prepend (exception, priv->widget);
+
+ if (glade_editor_property_show_object_dialog (project,
+ _
+ ("Select an object to pass to the handler"),
+ gtk_widget_get_toplevel
+ (GTK_WIDGET (editor)),
+ G_TYPE_OBJECT, priv->widget,
+ &project_object))
+ {
+ GladeSignal *old_signal =
+ glade_signal_new (signal_name, handler, object_name, after, swapped);
+ GladeSignal *new_signal = glade_signal_new (signal_name, handler,
+ project_object ?
+ project_object->name : NULL,
+ after, swapped);
+
+ glade_command_change_signal (priv->widget, old_signal, new_signal);
+ glade_signal_free (old_signal);
+ glade_signal_free (new_signal);
+
+ /* We are removing userdata */
+ if (project_object == NULL)
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ GSE_COLUMN_USERDATA_SLOT, TRUE,
+ GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, FALSE,
+ GSE_COLUMN_SWAPPED_VISIBLE, FALSE, -1);
+ }
+ else
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
+ GSE_COLUMN_USERDATA_SLOT, FALSE,
+ GSE_COLUMN_USERDATA, project_object->name,
+ GSE_COLUMN_SWAPPED_VISIBLE, TRUE, -1);
+ }
+ }
+
+ gtk_tree_path_free (path);
+ g_free (signal_name);
+ g_free (object_name);
+ g_free (handler);
}
void
-glade_signal_editor_construct_signals_list (GladeSignalEditor *editor)
+glade_signal_editor_construct_signals_list (GladeSignalEditor * editor)
{
- GtkTreeView *view;
- GtkWidget *view_widget;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeModel *model;
-
- GladeSignalEditorPrivate *priv = editor->priv;
-
- priv->model = gtk_tree_store_new
- (GSE_NUM_COLUMNS,
- G_TYPE_STRING, /* Signal value */
- G_TYPE_STRING, /* Handler value */
- G_TYPE_BOOLEAN, /* After value */
- G_TYPE_STRING, /* User data value */
- G_TYPE_BOOLEAN, /* Swapped value */
- G_TYPE_BOOLEAN, /* Whether userdata is a slot */
- G_TYPE_BOOLEAN, /* Swapped visibility */
- G_TYPE_BOOLEAN, /* After visibility */
- G_TYPE_BOOLEAN, /* Handler editable */
- G_TYPE_BOOLEAN, /* Userdata editable */
- G_TYPE_BOOLEAN, /* New slot */
- G_TYPE_BOOLEAN, /* Mark with bold */
- G_TYPE_BOOLEAN, /* Not a class title slot */
- G_TYPE_BOOLEAN, /* Show a warning icon for the signal */
- G_TYPE_STRING); /* A tooltip for the signal row */
-
- model = GTK_TREE_MODEL (priv->model);
-
- view_widget = gtk_tree_view_new_with_model (model);
- g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
-
- view = GTK_TREE_VIEW (view_widget);
-
- gtk_tree_view_set_tooltip_column (view, GSE_COLUMN_TOOLTIP);
-
- /* the view now holds a reference, we can get rid of our own */
- g_object_unref (G_OBJECT (priv->model));
-
- /************************ signal column ************************/
- column = gtk_tree_view_column_new ();
- column_header_widget (column, _("Signal"), _("The name of the signal to connect to"));
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_DIALOG_WARNING, NULL);
-
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "visible", GSE_COLUMN_WARN,
- NULL);
-
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width-chars", 20,
- NULL);
- gtk_tree_view_column_pack_end (column, renderer, TRUE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", GSE_COLUMN_SIGNAL,
- NULL);
-
- gtk_tree_view_column_set_cell_data_func (column, renderer,
- glade_signal_editor_signal_cell_data_func,
- NULL, NULL);
-
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_append_column (view, column);
-
- /************************ handler column ************************/
- if (!priv->handler_store)
- priv->handler_store = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
-
- if (!priv->handler_renderer)
- {
- priv->handler_renderer = gtk_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (priv->handler_renderer),
- "model", priv->handler_store,
- "text-column", 0,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width-chars", 14,
- NULL);
- }
-
- g_signal_connect (priv->handler_renderer, "edited",
- G_CALLBACK (glade_signal_editor_handler_cell_edited), editor);
-
- g_signal_connect (priv->handler_renderer, "editing-started",
- G_CALLBACK (glade_signal_editor_handler_editing_started),
- editor);
-
- if (!priv->handler_column)
- {
- priv->handler_column = gtk_tree_view_column_new_with_attributes
- (NULL, priv->handler_renderer,
- "editable", GSE_COLUMN_HANDLER_EDITABLE,
- "text", GSE_COLUMN_HANDLER, NULL);
-
- column_header_widget (priv->handler_column, _("Handler"),
- _("Enter the handler to run for this signal"));
-
- gtk_tree_view_column_set_cell_data_func (priv->handler_column, priv->handler_renderer,
- glade_signal_editor_handler_cell_data_func,
- NULL, NULL);
- }
-
- gtk_tree_view_column_set_resizable (priv->handler_column, TRUE);
- gtk_tree_view_column_set_expand (priv->handler_column, TRUE);
- gtk_tree_view_append_column (view, priv->handler_column);
-
- /************************ userdata column ************************/
- if (!priv->userdata_renderer)
- {
- priv->userdata_renderer = gtk_cell_renderer_text_new ();
- }
-
- if (!priv->userdata_store)
- priv->userdata_store = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
-
- g_signal_connect (priv->userdata_renderer, "edited",
- G_CALLBACK (glade_signal_editor_userdata_cell_edited), editor);
-
- g_signal_connect (priv->userdata_renderer, "editing-started",
- G_CALLBACK (glade_signal_editor_userdata_editing_started),
- editor);
-
- if (!priv->userdata_column)
- {
- priv->userdata_column =
- gtk_tree_view_column_new_with_attributes
- (NULL, priv->userdata_renderer,
- "text", GSE_COLUMN_USERDATA, NULL);
-
- column_header_widget (priv->userdata_column, _("Object"),
- _("An object to pass to the handler"));
-
- gtk_tree_view_column_set_cell_data_func (priv->userdata_column, priv->userdata_renderer,
- glade_signal_editor_userdata_cell_data_func,
- NULL, NULL);
-
- g_object_set (G_OBJECT (priv->userdata_renderer),
- "editable", FALSE,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width-chars", 10,
- NULL);
-
- renderer = glade_cell_renderer_icon_new ();
- g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_EDIT, NULL);
-
- g_signal_connect (G_OBJECT (renderer), "activate",
- G_CALLBACK (glade_signal_editor_user_data_activate), editor);
- gtk_tree_view_column_pack_end (priv->userdata_column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (priv->userdata_column, renderer,
- "activatable", GSE_COLUMN_USERDATA_EDITABLE,
- "visible", GSE_COLUMN_USERDATA_EDITABLE,
- NULL);
- }
-
- gtk_tree_view_column_set_resizable (priv->userdata_column, TRUE);
- gtk_tree_view_column_set_expand (priv->userdata_column, TRUE);
- gtk_tree_view_append_column (view, priv->userdata_column);
-
- /************************ swapped column ************************/
- renderer = gtk_cell_renderer_toggle_new ();
- g_signal_connect (renderer, "toggled",
- G_CALLBACK (glade_signal_editor_after_swapped_toggled), editor);
- column = gtk_tree_view_column_new_with_attributes
- (NULL, renderer,
- "active", GSE_COLUMN_SWAPPED,
- "sensitive", GSE_COLUMN_SWAPPED_VISIBLE,
- "activatable", GSE_COLUMN_SWAPPED_VISIBLE,
- "visible", GSE_COLUMN_CONTENT,
- NULL);
-
- column_header_widget (column,_("Swap"),
- _("Whether the instance and object should be swapped when calling the handler"));
-
- gtk_tree_view_append_column (view, column);
-
- /************************ after column ************************/
- renderer = gtk_cell_renderer_toggle_new ();
-
- g_object_set (G_OBJECT (renderer),
- "xpad", 15,
- NULL);
- g_object_set_data (G_OBJECT (renderer), "signal-after-cell",
- GINT_TO_POINTER (TRUE));
-
- g_signal_connect (renderer, "toggled",
- G_CALLBACK (glade_signal_editor_after_swapped_toggled), editor);
- column = gtk_tree_view_column_new_with_attributes
- (NULL, renderer,
- "active", GSE_COLUMN_AFTER,
- "sensitive", GSE_COLUMN_AFTER_VISIBLE,
- "activatable", GSE_COLUMN_AFTER_VISIBLE,
- "visible", GSE_COLUMN_CONTENT,
- NULL);
-
- column_header_widget (column, _("After"),
- _("Whether the handler should be called before "
- "or after the default handler of the signal"));
-
- /* Append the devhelp icon if we have it */
- if (glade_util_have_devhelp ())
- {
- renderer = glade_cell_renderer_icon_new ();
-
- g_object_set (G_OBJECT (renderer),
- "activatable", TRUE,
- NULL);
-
- if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), GLADE_DEVHELP_ICON_NAME))
- g_object_set (G_OBJECT (renderer), "icon-name", GLADE_DEVHELP_ICON_NAME, NULL);
- else
- g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_INFO, NULL);
-
- g_signal_connect (G_OBJECT (renderer), "activate",
- G_CALLBACK (glade_signal_editor_devhelp_cb), editor);
-
- gtk_tree_view_column_pack_end (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "visible", GSE_COLUMN_CONTENT, NULL);
-
- }
-
- gtk_tree_view_append_column (view, column);
-
-
- priv->signals_list = view_widget;
+ GtkTreeView *view;
+ GtkWidget *view_widget;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeModel *model;
+
+ GladeSignalEditorPrivate *priv = editor->priv;
+
+ priv->model = gtk_tree_store_new (GSE_NUM_COLUMNS, G_TYPE_STRING, /* Signal value */
+ G_TYPE_STRING, /* Handler value */
+ G_TYPE_BOOLEAN, /* After value */
+ G_TYPE_STRING, /* User data value */
+ G_TYPE_BOOLEAN, /* Swapped value */
+ G_TYPE_BOOLEAN, /* Whether userdata is a slot */
+ G_TYPE_BOOLEAN, /* Swapped visibility */
+ G_TYPE_BOOLEAN, /* After visibility */
+ G_TYPE_BOOLEAN, /* Handler editable */
+ G_TYPE_BOOLEAN, /* Userdata editable */
+ G_TYPE_BOOLEAN, /* New slot */
+ G_TYPE_BOOLEAN, /* Mark with bold */
+ G_TYPE_BOOLEAN, /* Not a class title slot */
+ G_TYPE_BOOLEAN, /* Show a warning icon for the signal */
+ G_TYPE_STRING); /* A tooltip for the signal row */
+
+ model = GTK_TREE_MODEL (priv->model);
+
+ view_widget = gtk_tree_view_new_with_model (model);
+ g_object_set (G_OBJECT (view_widget), "enable-search", FALSE, NULL);
+
+ view = GTK_TREE_VIEW (view_widget);
+
+ gtk_tree_view_set_tooltip_column (view, GSE_COLUMN_TOOLTIP);
+
+ /* the view now holds a reference, we can get rid of our own */
+ g_object_unref (G_OBJECT (priv->model));
+
+ /************************ signal column ************************/
+ column = gtk_tree_view_column_new ();
+ column_header_widget (column, _("Signal"),
+ _("The name of the signal to connect to"));
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_DIALOG_WARNING,
+ NULL);
+
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "visible", GSE_COLUMN_WARN, NULL);
+
+
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer),
+ "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 20, NULL);
+ gtk_tree_view_column_pack_end (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", GSE_COLUMN_SIGNAL, NULL);
+
+ gtk_tree_view_column_set_cell_data_func (column, renderer,
+ glade_signal_editor_signal_cell_data_func,
+ NULL, NULL);
+
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_append_column (view, column);
+
+ /************************ handler column ************************/
+ if (!priv->handler_store)
+ priv->handler_store =
+ GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
+
+ if (!priv->handler_renderer)
+ {
+ priv->handler_renderer = gtk_cell_renderer_combo_new ();
+ g_object_set (G_OBJECT (priv->handler_renderer),
+ "model", priv->handler_store,
+ "text-column", 0,
+ "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 14, NULL);
+ }
+
+ g_signal_connect (priv->handler_renderer, "edited",
+ G_CALLBACK (glade_signal_editor_handler_cell_edited),
+ editor);
+
+ g_signal_connect (priv->handler_renderer, "editing-started",
+ G_CALLBACK (glade_signal_editor_handler_editing_started),
+ editor);
+
+ if (!priv->handler_column)
+ {
+ priv->handler_column = gtk_tree_view_column_new_with_attributes
+ (NULL, priv->handler_renderer,
+ "editable", GSE_COLUMN_HANDLER_EDITABLE,
+ "text", GSE_COLUMN_HANDLER, NULL);
+
+ column_header_widget (priv->handler_column, _("Handler"),
+ _("Enter the handler to run for this signal"));
+
+ gtk_tree_view_column_set_cell_data_func (priv->handler_column,
+ priv->handler_renderer,
+ glade_signal_editor_handler_cell_data_func,
+ NULL, NULL);
+ }
+
+ gtk_tree_view_column_set_resizable (priv->handler_column, TRUE);
+ gtk_tree_view_column_set_expand (priv->handler_column, TRUE);
+ gtk_tree_view_append_column (view, priv->handler_column);
+
+ /************************ userdata column ************************/
+ if (!priv->userdata_renderer)
+ {
+ priv->userdata_renderer = gtk_cell_renderer_text_new ();
+ }
+
+ if (!priv->userdata_store)
+ priv->userdata_store =
+ GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
+
+ g_signal_connect (priv->userdata_renderer, "edited",
+ G_CALLBACK (glade_signal_editor_userdata_cell_edited),
+ editor);
+
+ g_signal_connect (priv->userdata_renderer, "editing-started",
+ G_CALLBACK (glade_signal_editor_userdata_editing_started),
+ editor);
+
+ if (!priv->userdata_column)
+ {
+ priv->userdata_column =
+ gtk_tree_view_column_new_with_attributes
+ (NULL, priv->userdata_renderer, "text", GSE_COLUMN_USERDATA, NULL);
+
+ column_header_widget (priv->userdata_column, _("Object"),
+ _("An object to pass to the handler"));
+
+ gtk_tree_view_column_set_cell_data_func (priv->userdata_column,
+ priv->userdata_renderer,
+ glade_signal_editor_userdata_cell_data_func,
+ NULL, NULL);
+
+ g_object_set (G_OBJECT (priv->userdata_renderer),
+ "editable", FALSE,
+ "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 10, NULL);
+
+ renderer = glade_cell_renderer_icon_new ();
+ g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_EDIT, NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "activate",
+ G_CALLBACK (glade_signal_editor_user_data_activate),
+ editor);
+ gtk_tree_view_column_pack_end (priv->userdata_column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (priv->userdata_column, renderer,
+ "activatable",
+ GSE_COLUMN_USERDATA_EDITABLE,
+ "visible",
+ GSE_COLUMN_USERDATA_EDITABLE, NULL);
+ }
+
+ gtk_tree_view_column_set_resizable (priv->userdata_column, TRUE);
+ gtk_tree_view_column_set_expand (priv->userdata_column, TRUE);
+ gtk_tree_view_append_column (view, priv->userdata_column);
+
+ /************************ swapped column ************************/
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (glade_signal_editor_after_swapped_toggled),
+ editor);
+ column =
+ gtk_tree_view_column_new_with_attributes (NULL, renderer, "active",
+ GSE_COLUMN_SWAPPED, "sensitive",
+ GSE_COLUMN_SWAPPED_VISIBLE,
+ "activatable",
+ GSE_COLUMN_SWAPPED_VISIBLE,
+ "visible", GSE_COLUMN_CONTENT,
+ NULL);
+
+ column_header_widget (column, _("Swap"),
+ _
+ ("Whether the instance and object should be swapped when calling the handler"));
+
+ gtk_tree_view_append_column (view, column);
+
+ /************************ after column ************************/
+ renderer = gtk_cell_renderer_toggle_new ();
+
+ g_object_set (G_OBJECT (renderer), "xpad", 15, NULL);
+ g_object_set_data (G_OBJECT (renderer), "signal-after-cell",
+ GINT_TO_POINTER (TRUE));
+
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (glade_signal_editor_after_swapped_toggled),
+ editor);
+ column =
+ gtk_tree_view_column_new_with_attributes (NULL, renderer, "active",
+ GSE_COLUMN_AFTER, "sensitive",
+ GSE_COLUMN_AFTER_VISIBLE,
+ "activatable",
+ GSE_COLUMN_AFTER_VISIBLE,
+ "visible", GSE_COLUMN_CONTENT,
+ NULL);
+
+ column_header_widget (column, _("After"),
+ _("Whether the handler should be called before "
+ "or after the default handler of the signal"));
+
+ /* Append the devhelp icon if we have it */
+ if (glade_util_have_devhelp ())
+ {
+ renderer = glade_cell_renderer_icon_new ();
+
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+
+ if (gtk_icon_theme_has_icon
+ (gtk_icon_theme_get_default (), GLADE_DEVHELP_ICON_NAME))
+ g_object_set (G_OBJECT (renderer), "icon-name", GLADE_DEVHELP_ICON_NAME,
+ NULL);
+ else
+ g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_INFO, NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "activate",
+ G_CALLBACK (glade_signal_editor_devhelp_cb), editor);
+
+ gtk_tree_view_column_pack_end (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "visible", GSE_COLUMN_CONTENT, NULL);
+
+ }
+
+ gtk_tree_view_append_column (view, column);
+
+
+ priv->signals_list = view_widget;
}
-static GObject*
-glade_signal_editor_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+static GObject *
+glade_signal_editor_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
{
- GtkWidget *scroll;
- GladeSignalEditor *editor;
- GladeSignalEditorPrivate *priv;
- GObject *retval;
+ GtkWidget *scroll;
+ GladeSignalEditor *editor;
+ GladeSignalEditorPrivate *priv;
+ GObject *retval;
- retval = G_OBJECT_CLASS (glade_signal_editor_parent_class)->constructor
- (type, n_construct_properties, construct_properties);
- editor = GLADE_SIGNAL_EDITOR (retval);
- priv = editor->priv;
+ retval = G_OBJECT_CLASS (glade_signal_editor_parent_class)->constructor
+ (type, n_construct_properties, construct_properties);
+ editor = GLADE_SIGNAL_EDITOR (retval);
+ priv = editor->priv;
- scroll = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
- GTK_SHADOW_IN);
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
+ GTK_SHADOW_IN);
- g_signal_emit_by_name (glade_app_get(), "signal-editor-created", retval);
+ g_signal_emit_by_name (glade_app_get (), "signal-editor-created", retval);
- gtk_container_add (GTK_CONTAINER (scroll), priv->signals_list);
+ gtk_container_add (GTK_CONTAINER (scroll), priv->signals_list);
- gtk_box_pack_start (GTK_BOX (editor), scroll, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (editor), scroll, TRUE, TRUE, 0);
- gtk_widget_show_all (GTK_WIDGET(editor));
+ gtk_widget_show_all (GTK_WIDGET (editor));
- return retval;
+ return retval;
}
/**
@@ -1140,25 +1130,25 @@ glade_signal_editor_constructor (GType type,
* Returns: a new #GladeSignalEditor associated with @editor
*/
GladeSignalEditor *
-glade_signal_editor_new (gpointer *editor)
+glade_signal_editor_new (gpointer * editor)
{
- GladeSignalEditor *signal_editor;
+ GladeSignalEditor *signal_editor;
- signal_editor = GLADE_SIGNAL_EDITOR (g_object_new (GLADE_TYPE_SIGNAL_EDITOR,
- NULL, NULL));
- signal_editor->priv->editor = editor;
+ signal_editor = GLADE_SIGNAL_EDITOR (g_object_new (GLADE_TYPE_SIGNAL_EDITOR,
+ NULL, NULL));
+ signal_editor->priv->editor = editor;
- return signal_editor;
+ return signal_editor;
}
static void
-glade_signal_editor_refresh_support (GladeWidget *widget,
- GladeSignalEditor *editor)
+glade_signal_editor_refresh_support (GladeWidget * widget,
+ GladeSignalEditor * editor)
{
- GladeSignalEditorPrivate *priv = editor->priv;
-
- g_assert (priv->widget == widget);
- glade_signal_editor_load_widget (editor, priv->widget);
+ GladeSignalEditorPrivate *priv = editor->priv;
+
+ g_assert (priv->widget == widget);
+ glade_signal_editor_load_widget (editor, priv->widget);
}
/**
@@ -1169,497 +1159,499 @@ glade_signal_editor_refresh_support (GladeWidget *widget,
* TODO: write me
*/
void
-glade_signal_editor_load_widget (GladeSignalEditor *editor,
- GladeWidget *widget)
+glade_signal_editor_load_widget (GladeSignalEditor * editor,
+ GladeWidget * widget)
{
- GList *list;
- const gchar *last_type = "";
- GtkTreeIter iter;
- GtkTreeIter parent_class;
- GtkTreeIter parent_signal;
- GtkTreePath *path_first;
- GPtrArray *signals;
-
- GladeSignalEditorPrivate *priv = editor->priv;
-
-
- g_return_if_fail (GLADE_IS_SIGNAL_EDITOR (editor));
- g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
-
- if (priv->widget != widget)
- {
- if (priv->widget)
- {
- g_signal_handler_disconnect (priv->widget, priv->refresh_id);
- priv->refresh_id = 0;
- g_object_unref (priv->widget);
- }
-
- priv->widget = widget;
- priv->adaptor = widget ? widget->adaptor : NULL;
-
- if (priv->widget)
- {
- g_object_ref (priv->widget);
- priv->refresh_id =
- g_signal_connect (G_OBJECT (priv->widget), "support-changed",
- G_CALLBACK (glade_signal_editor_refresh_support), editor);
- }
- }
-
- if (!widget)
- return;
-
- gtk_tree_store_clear (priv->model);
-
- /* Loop over every signal type
- */
- for (list = priv->adaptor->signals; list; list = list->next)
- {
- GladeSignalClass *signal = (GladeSignalClass *) list->data;
- GladeSignal *sig = glade_signal_new (signal->name, NULL, NULL, FALSE, FALSE);
-
- /* Check versioning here with a virtual signal */
- glade_project_update_signal_support_warning (priv->widget, sig);
-
- /* Add class name that this signal belongs to.
- */
- if (strcmp(last_type, signal->type))
- {
- gtk_tree_store_append (priv->model, &parent_class, NULL);
- gtk_tree_store_set (priv->model, &parent_class,
- GSE_COLUMN_SIGNAL, signal->type,
- GSE_COLUMN_AFTER_VISIBLE, FALSE,
- GSE_COLUMN_HANDLER_EDITABLE, FALSE,
- GSE_COLUMN_USERDATA_EDITABLE,FALSE,
- GSE_COLUMN_SLOT, FALSE,
- GSE_COLUMN_BOLD, FALSE,
- GSE_COLUMN_CONTENT, FALSE,
- -1);
- last_type = signal->type;
- }
-
- gtk_tree_store_append (priv->model, &parent_signal, &parent_class);
- signals = glade_widget_list_signal_handlers (widget, signal->name);
-
- if (!signals || signals->len == 0)
- {
-
- gtk_tree_store_set
- (priv->model, &parent_signal,
- GSE_COLUMN_SIGNAL, signal->name,
- GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
- GSE_COLUMN_AFTER, FALSE,
- GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, FALSE,
- GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
- GSE_COLUMN_HANDLER_EDITABLE, TRUE,
- GSE_COLUMN_USERDATA_EDITABLE,FALSE,
- GSE_COLUMN_AFTER_VISIBLE, FALSE,
- GSE_COLUMN_SLOT, TRUE,
- GSE_COLUMN_USERDATA_SLOT, TRUE,
- GSE_COLUMN_CONTENT, TRUE,
- GSE_COLUMN_WARN, sig->support_warning != NULL,
- GSE_COLUMN_TOOLTIP, sig->support_warning,
- -1);
- }
- else
- {
- guint i;
- GtkTreePath *path_parent_class;
- GladeSignal *widget_signal =
- (GladeSignal*) g_ptr_array_index (signals, 0);
-
- /* mark the class of this signal as bold and expand it,
- * as there is at least one signal with handler */
- gtk_tree_store_set (priv->model, &parent_class, GSE_COLUMN_BOLD, TRUE, -1);
- path_parent_class =
- gtk_tree_model_get_path (GTK_TREE_MODEL (priv->model),
- &parent_class);
- gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->signals_list),
- path_parent_class, FALSE);
- gtk_tree_path_free (path_parent_class);
-
- gtk_tree_store_set
- (priv->model, &parent_signal,
- GSE_COLUMN_SIGNAL, signal->name,
- GSE_COLUMN_HANDLER, widget_signal->handler,
- GSE_COLUMN_AFTER, widget_signal->after,
- GSE_COLUMN_USERDATA,
- widget_signal->userdata ?
- widget_signal->userdata : USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, widget_signal->swapped,
- GSE_COLUMN_SWAPPED_VISIBLE,
- widget_signal->userdata ? TRUE : FALSE,
- GSE_COLUMN_AFTER_VISIBLE, TRUE,
- GSE_COLUMN_HANDLER_EDITABLE, TRUE,
- GSE_COLUMN_USERDATA_EDITABLE, TRUE,
- GSE_COLUMN_SLOT, FALSE,
- GSE_COLUMN_USERDATA_SLOT,
- widget_signal->userdata ? FALSE : TRUE,
- GSE_COLUMN_BOLD, TRUE,
- GSE_COLUMN_CONTENT, TRUE,
- GSE_COLUMN_WARN, widget_signal->support_warning != NULL,
- GSE_COLUMN_TOOLTIP, widget_signal->support_warning,
- -1);
-
- for (i = 1; i < signals->len; i++)
- {
- widget_signal = (GladeSignal*) g_ptr_array_index (signals, i);
- gtk_tree_store_append (priv->model, &iter, &parent_signal);
-
- gtk_tree_store_set
- (priv->model, &iter,
- GSE_COLUMN_HANDLER, widget_signal->handler,
- GSE_COLUMN_AFTER, widget_signal->after,
- GSE_COLUMN_USERDATA,
- widget_signal->userdata ?
- widget_signal->userdata : USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, widget_signal->swapped,
- GSE_COLUMN_SWAPPED_VISIBLE,
- widget_signal->userdata ? TRUE : FALSE,
- GSE_COLUMN_AFTER_VISIBLE, TRUE,
- GSE_COLUMN_HANDLER_EDITABLE, TRUE,
- GSE_COLUMN_USERDATA_EDITABLE, TRUE,
- GSE_COLUMN_SLOT, FALSE,
- GSE_COLUMN_USERDATA_SLOT,
- widget_signal->userdata ? FALSE : TRUE,
- GSE_COLUMN_CONTENT, TRUE,
- GSE_COLUMN_WARN, FALSE,
- GSE_COLUMN_TOOLTIP, widget_signal->support_warning,
- -1);
- }
-
- /* add the <Type...> slot */
- gtk_tree_store_append (priv->model, &iter, &parent_signal);
- gtk_tree_store_set
- (priv->model, &iter,
- GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
- GSE_COLUMN_AFTER, FALSE,
- GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
- GSE_COLUMN_SWAPPED, FALSE,
- GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
- GSE_COLUMN_HANDLER_EDITABLE, TRUE,
- GSE_COLUMN_USERDATA_EDITABLE,FALSE,
- GSE_COLUMN_AFTER_VISIBLE, FALSE,
- GSE_COLUMN_SLOT, TRUE,
- GSE_COLUMN_USERDATA_SLOT, TRUE,
- GSE_COLUMN_CONTENT, TRUE,
- GSE_COLUMN_WARN, FALSE,
- GSE_COLUMN_TOOLTIP, sig->support_warning,
- -1);
- }
-
- glade_signal_free (sig);
-
- }
-
- path_first = gtk_tree_path_new_first ();
- gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->signals_list), path_first, FALSE);
- gtk_tree_path_free (path_first);
+ GList *list;
+ const gchar *last_type = "";
+ GtkTreeIter iter;
+ GtkTreeIter parent_class;
+ GtkTreeIter parent_signal;
+ GtkTreePath *path_first;
+ GPtrArray *signals;
+
+ GladeSignalEditorPrivate *priv = editor->priv;
+
+
+ g_return_if_fail (GLADE_IS_SIGNAL_EDITOR (editor));
+ g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
+
+ if (priv->widget != widget)
+ {
+ if (priv->widget)
+ {
+ g_signal_handler_disconnect (priv->widget, priv->refresh_id);
+ priv->refresh_id = 0;
+ g_object_unref (priv->widget);
+ }
+
+ priv->widget = widget;
+ priv->adaptor = widget ? widget->adaptor : NULL;
+
+ if (priv->widget)
+ {
+ g_object_ref (priv->widget);
+ priv->refresh_id =
+ g_signal_connect (G_OBJECT (priv->widget), "support-changed",
+ G_CALLBACK
+ (glade_signal_editor_refresh_support), editor);
+ }
+ }
+
+ if (!widget)
+ return;
+
+ gtk_tree_store_clear (priv->model);
+
+ /* Loop over every signal type
+ */
+ for (list = priv->adaptor->signals; list; list = list->next)
+ {
+ GladeSignalClass *signal = (GladeSignalClass *) list->data;
+ GladeSignal *sig =
+ glade_signal_new (signal->name, NULL, NULL, FALSE, FALSE);
+
+ /* Check versioning here with a virtual signal */
+ glade_project_update_signal_support_warning (priv->widget, sig);
+
+ /* Add class name that this signal belongs to.
+ */
+ if (strcmp (last_type, signal->type))
+ {
+ gtk_tree_store_append (priv->model, &parent_class, NULL);
+ gtk_tree_store_set (priv->model, &parent_class,
+ GSE_COLUMN_SIGNAL, signal->type,
+ GSE_COLUMN_AFTER_VISIBLE, FALSE,
+ GSE_COLUMN_HANDLER_EDITABLE, FALSE,
+ GSE_COLUMN_USERDATA_EDITABLE, FALSE,
+ GSE_COLUMN_SLOT, FALSE,
+ GSE_COLUMN_BOLD, FALSE,
+ GSE_COLUMN_CONTENT, FALSE, -1);
+ last_type = signal->type;
+ }
+
+ gtk_tree_store_append (priv->model, &parent_signal, &parent_class);
+ signals = glade_widget_list_signal_handlers (widget, signal->name);
+
+ if (!signals || signals->len == 0)
+ {
+
+ gtk_tree_store_set
+ (priv->model, &parent_signal,
+ GSE_COLUMN_SIGNAL, signal->name,
+ GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
+ GSE_COLUMN_AFTER, FALSE,
+ GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, FALSE,
+ GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
+ GSE_COLUMN_HANDLER_EDITABLE, TRUE,
+ GSE_COLUMN_USERDATA_EDITABLE, FALSE,
+ GSE_COLUMN_AFTER_VISIBLE, FALSE,
+ GSE_COLUMN_SLOT, TRUE,
+ GSE_COLUMN_USERDATA_SLOT, TRUE,
+ GSE_COLUMN_CONTENT, TRUE,
+ GSE_COLUMN_WARN, sig->support_warning != NULL,
+ GSE_COLUMN_TOOLTIP, sig->support_warning, -1);
+ }
+ else
+ {
+ guint i;
+ GtkTreePath *path_parent_class;
+ GladeSignal *widget_signal =
+ (GladeSignal *) g_ptr_array_index (signals, 0);
+
+ /* mark the class of this signal as bold and expand it,
+ * as there is at least one signal with handler */
+ gtk_tree_store_set (priv->model, &parent_class, GSE_COLUMN_BOLD, TRUE,
+ -1);
+ path_parent_class =
+ gtk_tree_model_get_path (GTK_TREE_MODEL (priv->model),
+ &parent_class);
+ gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->signals_list),
+ path_parent_class, FALSE);
+ gtk_tree_path_free (path_parent_class);
+
+ gtk_tree_store_set
+ (priv->model, &parent_signal,
+ GSE_COLUMN_SIGNAL, signal->name,
+ GSE_COLUMN_HANDLER, widget_signal->handler,
+ GSE_COLUMN_AFTER, widget_signal->after,
+ GSE_COLUMN_USERDATA,
+ widget_signal->userdata ?
+ widget_signal->userdata : USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, widget_signal->swapped,
+ GSE_COLUMN_SWAPPED_VISIBLE,
+ widget_signal->userdata ? TRUE : FALSE,
+ GSE_COLUMN_AFTER_VISIBLE, TRUE,
+ GSE_COLUMN_HANDLER_EDITABLE, TRUE,
+ GSE_COLUMN_USERDATA_EDITABLE, TRUE,
+ GSE_COLUMN_SLOT, FALSE,
+ GSE_COLUMN_USERDATA_SLOT,
+ widget_signal->userdata ? FALSE : TRUE,
+ GSE_COLUMN_BOLD, TRUE,
+ GSE_COLUMN_CONTENT, TRUE,
+ GSE_COLUMN_WARN, widget_signal->support_warning != NULL,
+ GSE_COLUMN_TOOLTIP, widget_signal->support_warning, -1);
+
+ for (i = 1; i < signals->len; i++)
+ {
+ widget_signal = (GladeSignal *) g_ptr_array_index (signals, i);
+ gtk_tree_store_append (priv->model, &iter, &parent_signal);
+
+ gtk_tree_store_set
+ (priv->model, &iter,
+ GSE_COLUMN_HANDLER, widget_signal->handler,
+ GSE_COLUMN_AFTER, widget_signal->after,
+ GSE_COLUMN_USERDATA,
+ widget_signal->userdata ?
+ widget_signal->userdata : USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, widget_signal->swapped,
+ GSE_COLUMN_SWAPPED_VISIBLE,
+ widget_signal->userdata ? TRUE : FALSE,
+ GSE_COLUMN_AFTER_VISIBLE, TRUE,
+ GSE_COLUMN_HANDLER_EDITABLE, TRUE,
+ GSE_COLUMN_USERDATA_EDITABLE, TRUE,
+ GSE_COLUMN_SLOT, FALSE,
+ GSE_COLUMN_USERDATA_SLOT,
+ widget_signal->userdata ? FALSE : TRUE,
+ GSE_COLUMN_CONTENT, TRUE,
+ GSE_COLUMN_WARN, FALSE,
+ GSE_COLUMN_TOOLTIP, widget_signal->support_warning, -1);
+ }
+
+ /* add the <Type...> slot */
+ gtk_tree_store_append (priv->model, &iter, &parent_signal);
+ gtk_tree_store_set
+ (priv->model, &iter,
+ GSE_COLUMN_HANDLER, HANDLER_DEFAULT,
+ GSE_COLUMN_AFTER, FALSE,
+ GSE_COLUMN_USERDATA, USERDATA_DEFAULT,
+ GSE_COLUMN_SWAPPED, FALSE,
+ GSE_COLUMN_SWAPPED_VISIBLE, FALSE,
+ GSE_COLUMN_HANDLER_EDITABLE, TRUE,
+ GSE_COLUMN_USERDATA_EDITABLE, FALSE,
+ GSE_COLUMN_AFTER_VISIBLE, FALSE,
+ GSE_COLUMN_SLOT, TRUE,
+ GSE_COLUMN_USERDATA_SLOT, TRUE,
+ GSE_COLUMN_CONTENT, TRUE,
+ GSE_COLUMN_WARN, FALSE,
+ GSE_COLUMN_TOOLTIP, sig->support_warning, -1);
+ }
+
+ glade_signal_free (sig);
+
+ }
+
+ path_first = gtk_tree_path_new_first ();
+ gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->signals_list), path_first,
+ FALSE);
+ gtk_tree_path_free (path_first);
}
static void
-glade_signal_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+glade_signal_editor_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (object);
- GladeSignalEditorPrivate *priv = self->priv;
-
- switch (prop_id)
- {
- case PROP_HANDLER_COLUMN:
- g_value_set_object (value, priv->handler_column);
- break;
- case PROP_USERDATA_COLUMN:
- g_value_set_object (value, priv->userdata_column);
- break;
- case PROP_HANDLER_COMPLETION:
- g_value_set_object (value, priv->handler_store);
- break;
- case PROP_USERDATA_COMPLETION:
- g_value_set_object (value, priv->userdata_store);
- break;
- case PROP_HANDLER_RENDERER:
- g_value_set_object (value, priv->handler_renderer);
- break;
- case PROP_USERDATA_RENDERER:
- g_value_set_object (value, priv->userdata_renderer);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (object);
+ GladeSignalEditorPrivate *priv = self->priv;
+
+ switch (prop_id)
+ {
+ case PROP_HANDLER_COLUMN:
+ g_value_set_object (value, priv->handler_column);
+ break;
+ case PROP_USERDATA_COLUMN:
+ g_value_set_object (value, priv->userdata_column);
+ break;
+ case PROP_HANDLER_COMPLETION:
+ g_value_set_object (value, priv->handler_store);
+ break;
+ case PROP_USERDATA_COMPLETION:
+ g_value_set_object (value, priv->userdata_store);
+ break;
+ case PROP_HANDLER_RENDERER:
+ g_value_set_object (value, priv->handler_renderer);
+ break;
+ case PROP_USERDATA_RENDERER:
+ g_value_set_object (value, priv->userdata_renderer);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_signal_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+glade_signal_editor_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (object);
- GladeSignalEditorPrivate *priv = self->priv;
-
- switch (prop_id)
- {
- case PROP_HANDLER_COLUMN:
- priv->handler_column = g_value_get_object (value);
- break;
- case PROP_USERDATA_COLUMN:
- priv->userdata_column = g_value_get_object (value);
- break;
- case PROP_HANDLER_COMPLETION:
- priv->handler_store = g_value_get_object (value);
- break;
- case PROP_USERDATA_COMPLETION:
- priv->userdata_store = g_value_get_object (value);
- break;
- case PROP_HANDLER_RENDERER:
- priv->handler_renderer = g_value_get_object (value);
- break;
- case PROP_USERDATA_RENDERER:
- priv->userdata_renderer = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (object);
+ GladeSignalEditorPrivate *priv = self->priv;
+
+ switch (prop_id)
+ {
+ case PROP_HANDLER_COLUMN:
+ priv->handler_column = g_value_get_object (value);
+ break;
+ case PROP_USERDATA_COLUMN:
+ priv->userdata_column = g_value_get_object (value);
+ break;
+ case PROP_HANDLER_COMPLETION:
+ priv->handler_store = g_value_get_object (value);
+ break;
+ case PROP_USERDATA_COMPLETION:
+ priv->userdata_store = g_value_get_object (value);
+ break;
+ case PROP_HANDLER_RENDERER:
+ priv->handler_renderer = g_value_get_object (value);
+ break;
+ case PROP_USERDATA_RENDERER:
+ priv->userdata_renderer = g_value_get_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_signal_editor_dispose (GObject *object)
+glade_signal_editor_dispose (GObject * object)
{
- GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (object);
-
- glade_signal_editor_load_widget (self, NULL);
+ GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (object);
+
+ glade_signal_editor_load_widget (self, NULL);
- G_OBJECT_CLASS (glade_signal_editor_parent_class)->dispose (object);
+ G_OBJECT_CLASS (glade_signal_editor_parent_class)->dispose (object);
}
static void
-glade_signal_editor_init (GladeSignalEditor *self)
+glade_signal_editor_init (GladeSignalEditor * self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GLADE_TYPE_SIGNAL_EDITOR, GladeSignalEditorPrivate);
-
- self->priv->is_void_handler = is_void_handler;
- self->priv->is_void_userdata = is_void_userdata;
+ self->priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (self, GLADE_TYPE_SIGNAL_EDITOR,
+ GladeSignalEditorPrivate);
+
+ self->priv->is_void_handler = is_void_handler;
+ self->priv->is_void_userdata = is_void_userdata;
}
static void
-glade_signal_editor_class_init (GladeSignalEditorClass *klass)
+glade_signal_editor_class_init (GladeSignalEditorClass * klass)
{
- GObjectClass *object_class;
-
- glade_signal_editor_parent_class = g_type_class_peek_parent (klass);
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = glade_signal_editor_constructor;
- object_class->get_property = glade_signal_editor_get_property;
- object_class->set_property = glade_signal_editor_set_property;
- object_class->dispose = glade_signal_editor_dispose;
-
- g_object_class_install_property (object_class,
- PROP_HANDLER_COLUMN,
- g_param_spec_object ("handler-column",
- NULL,
- NULL,
- GTK_TYPE_TREE_VIEW_COLUMN,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_USERDATA_COLUMN,
- g_param_spec_object ("userdata-column",
- NULL,
- NULL,
- GTK_TYPE_TREE_VIEW_COLUMN,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_HANDLER_COMPLETION,
- g_param_spec_object ("handler-completion",
- NULL,
- NULL,
- GTK_TYPE_TREE_MODEL,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_USERDATA_COMPLETION,
- g_param_spec_object ("userdata-completion",
- NULL,
- NULL,
- GTK_TYPE_TREE_MODEL,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_HANDLER_RENDERER,
- g_param_spec_object ("handler-renderer",
- NULL,
- NULL,
- GTK_TYPE_CELL_RENDERER,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_USERDATA_RENDERER,
- g_param_spec_object ("userdata-renderer",
- NULL,
- NULL,
- GTK_TYPE_CELL_RENDERER,
- G_PARAM_READABLE |
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT));
- g_type_class_add_private (klass, sizeof (GladeSignalEditorPrivate));
+ GObjectClass *object_class;
+
+ glade_signal_editor_parent_class = g_type_class_peek_parent (klass);
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = glade_signal_editor_constructor;
+ object_class->get_property = glade_signal_editor_get_property;
+ object_class->set_property = glade_signal_editor_set_property;
+ object_class->dispose = glade_signal_editor_dispose;
+
+ g_object_class_install_property (object_class,
+ PROP_HANDLER_COLUMN,
+ g_param_spec_object ("handler-column",
+ NULL,
+ NULL,
+ GTK_TYPE_TREE_VIEW_COLUMN,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_USERDATA_COLUMN,
+ g_param_spec_object ("userdata-column",
+ NULL,
+ NULL,
+ GTK_TYPE_TREE_VIEW_COLUMN,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_HANDLER_COMPLETION,
+ g_param_spec_object ("handler-completion",
+ NULL,
+ NULL,
+ GTK_TYPE_TREE_MODEL,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_USERDATA_COMPLETION,
+ g_param_spec_object ("userdata-completion",
+ NULL,
+ NULL,
+ GTK_TYPE_TREE_MODEL,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_HANDLER_RENDERER,
+ g_param_spec_object ("handler-renderer",
+ NULL,
+ NULL,
+ GTK_TYPE_CELL_RENDERER,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_USERDATA_RENDERER,
+ g_param_spec_object ("userdata-renderer",
+ NULL,
+ NULL,
+ GTK_TYPE_CELL_RENDERER,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT));
+ g_type_class_add_private (klass, sizeof (GladeSignalEditorPrivate));
}
static void
-glade_signal_editor_editing_started (GtkEntry *entry, IsVoidFunc callback)
+glade_signal_editor_editing_started (GtkEntry * entry, IsVoidFunc callback)
{
- if (callback (gtk_entry_get_text (entry)))
- gtk_entry_set_text (entry, "");
+ if (callback (gtk_entry_get_text (entry)))
+ gtk_entry_set_text (entry, "");
}
static void
-glade_signal_editor_handler_store_update (GladeSignalEditor *editor,
- const gchar *signal_name,
- GtkListStore *store)
+glade_signal_editor_handler_store_update (GladeSignalEditor * editor,
+ const gchar * signal_name,
+ GtkListStore * store)
{
- GladeSignalEditorPrivate *priv = editor->priv;
-
- const gchar *handlers[] = {"gtk_widget_show",
- "gtk_widget_hide",
- "gtk_widget_grab_focus",
- "gtk_widget_destroy",
- "gtk_true",
- "gtk_false",
- "gtk_main_quit",
- NULL};
-
- GtkTreeIter tmp_iter;
- gint i;
- gchar *handler, *signal, *name;
-
- name = (gchar *) glade_widget_get_name (priv->widget);
-
- signal = g_strdup (signal_name);
- glade_util_replace (signal, '-', '_');
-
- gtk_list_store_clear (store);
-
- gtk_list_store_append (store, &tmp_iter);
- handler = g_strdup_printf ("on_%s_%s", name, signal);
- gtk_list_store_set (store, &tmp_iter, 0, handler, -1);
- g_free (handler);
-
- gtk_list_store_append (store, &tmp_iter);
- handler = g_strdup_printf ("%s_%s_cb", name, signal);
- gtk_list_store_set (store, &tmp_iter, 0, handler, -1);
- g_free (handler);
-
- g_free (signal);
- for (i = 0; handlers[i]; i++)
- {
- gtk_list_store_append (store, &tmp_iter);
- gtk_list_store_set (store, &tmp_iter, 0, handlers[i], -1);
- }
+ GladeSignalEditorPrivate *priv = editor->priv;
+
+ const gchar *handlers[] = { "gtk_widget_show",
+ "gtk_widget_hide",
+ "gtk_widget_grab_focus",
+ "gtk_widget_destroy",
+ "gtk_true",
+ "gtk_false",
+ "gtk_main_quit",
+ NULL
+ };
+
+ GtkTreeIter tmp_iter;
+ gint i;
+ gchar *handler, *signal, *name;
+
+ name = (gchar *) glade_widget_get_name (priv->widget);
+
+ signal = g_strdup (signal_name);
+ glade_util_replace (signal, '-', '_');
+
+ gtk_list_store_clear (store);
+
+ gtk_list_store_append (store, &tmp_iter);
+ handler = g_strdup_printf ("on_%s_%s", name, signal);
+ gtk_list_store_set (store, &tmp_iter, 0, handler, -1);
+ g_free (handler);
+
+ gtk_list_store_append (store, &tmp_iter);
+ handler = g_strdup_printf ("%s_%s_cb", name, signal);
+ gtk_list_store_set (store, &tmp_iter, 0, handler, -1);
+ g_free (handler);
+
+ g_free (signal);
+ for (i = 0; handlers[i]; i++)
+ {
+ gtk_list_store_append (store, &tmp_iter);
+ gtk_list_store_set (store, &tmp_iter, 0, handlers[i], -1);
+ }
}
static gboolean
-glade_signal_editor_handler_editing_started_default (GladeSignalEditor *editor,
- gchar *signal_name,
- GtkTreeIter *iter,
- GtkCellEditable *editable)
+glade_signal_editor_handler_editing_started_default (GladeSignalEditor * editor,
+ gchar * signal_name,
+ GtkTreeIter * iter,
+ GtkCellEditable * editable)
{
- GladeSignalEditorPrivate *priv = editor->priv;
- GtkEntry *entry;
- GtkEntryCompletion *completion;
- GtkTreeModel *completion_store = priv->handler_store;
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkEntry *entry;
+ GtkEntryCompletion *completion;
+ GtkTreeModel *completion_store = priv->handler_store;
- g_return_val_if_fail (GTK_IS_BIN (editable), FALSE);
- g_return_val_if_fail (GTK_IS_LIST_STORE (completion_store), FALSE);
+ g_return_val_if_fail (GTK_IS_BIN (editable), FALSE);
+ g_return_val_if_fail (GTK_IS_LIST_STORE (completion_store), FALSE);
- entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable)));
+ entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable)));
- glade_signal_editor_editing_started (entry, priv->is_void_handler);
+ glade_signal_editor_editing_started (entry, priv->is_void_handler);
- glade_signal_editor_handler_store_update (editor, signal_name,
- GTK_LIST_STORE (completion_store));
+ glade_signal_editor_handler_store_update (editor, signal_name,
+ GTK_LIST_STORE (completion_store));
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_text_column (completion, 0);
- gtk_entry_completion_set_inline_completion (completion, TRUE);
- gtk_entry_completion_set_popup_completion (completion, FALSE);
- gtk_entry_completion_set_model (completion, completion_store);
- gtk_entry_set_completion (entry, completion);
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_text_column (completion, 0);
+ gtk_entry_completion_set_inline_completion (completion, TRUE);
+ gtk_entry_completion_set_popup_completion (completion, FALSE);
+ gtk_entry_completion_set_model (completion, completion_store);
+ gtk_entry_set_completion (entry, completion);
- return FALSE;
+ return FALSE;
}
static void
-glade_signal_editor_userdata_store_update (GladeSignalEditor *self,
- GtkListStore *store)
+glade_signal_editor_userdata_store_update (GladeSignalEditor * self,
+ GtkListStore * store)
{
- GtkTreeIter tmp_iter;
- GList *list;
+ GtkTreeIter tmp_iter;
+ GList *list;
- GladeSignalEditorPrivate *priv = self->priv;
+ GladeSignalEditorPrivate *priv = self->priv;
- gtk_list_store_clear (store);
+ gtk_list_store_clear (store);
- for (list = (GList *) glade_project_get_objects (priv->widget->project);
- list && list->data;
- list = g_list_next (list))
- {
- GladeWidget *widget = glade_widget_get_from_gobject (list->data);
+ for (list = (GList *) glade_project_get_objects (priv->widget->project);
+ list && list->data; list = g_list_next (list))
+ {
+ GladeWidget *widget = glade_widget_get_from_gobject (list->data);
- if (widget)
- {
- gtk_list_store_append (store, &tmp_iter);
- gtk_list_store_set (store, &tmp_iter, 0, widget->name, -1);
- }
- }
+ if (widget)
+ {
+ gtk_list_store_append (store, &tmp_iter);
+ gtk_list_store_set (store, &tmp_iter, 0, widget->name, -1);
+ }
+ }
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 0,
- GTK_SORT_DESCENDING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 0,
+ GTK_SORT_DESCENDING);
}
static gboolean
-glade_signal_editor_userdata_editing_started_default (GladeSignalEditor *editor,
- gchar *signal_name,
- GtkTreeIter *iter,
- GtkCellEditable *editable)
+glade_signal_editor_userdata_editing_started_default (GladeSignalEditor *
+ editor,
+ gchar * signal_name,
+ GtkTreeIter * iter,
+ GtkCellEditable *
+ editable)
{
- GtkEntry *entry;
- GtkEntryCompletion *completion;
- GladeSignalEditorPrivate *priv = editor->priv;
- GtkTreeModel *completion_store = priv->userdata_store;
-
- g_return_val_if_fail (priv->widget != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_LIST_STORE (completion_store), FALSE);
- g_return_val_if_fail (GTK_IS_ENTRY (editable), FALSE);
+ GtkEntry *entry;
+ GtkEntryCompletion *completion;
+ GladeSignalEditorPrivate *priv = editor->priv;
+ GtkTreeModel *completion_store = priv->userdata_store;
+
+ g_return_val_if_fail (priv->widget != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_LIST_STORE (completion_store), FALSE);
+ g_return_val_if_fail (GTK_IS_ENTRY (editable), FALSE);
- entry = GTK_ENTRY (editable);
+ entry = GTK_ENTRY (editable);
- glade_signal_editor_editing_started (entry, priv->is_void_handler);
+ glade_signal_editor_editing_started (entry, priv->is_void_handler);
- glade_signal_editor_userdata_store_update (editor, GTK_LIST_STORE (completion_store));
+ glade_signal_editor_userdata_store_update (editor,
+ GTK_LIST_STORE (completion_store));
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_text_column (completion, 0);
- gtk_entry_completion_set_model (completion, completion_store);
- gtk_entry_set_completion (entry, completion);
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_text_column (completion, 0);
+ gtk_entry_completion_set_model (completion, completion_store);
+ gtk_entry_set_completion (entry, completion);
- return FALSE;
+ return FALSE;
}
diff --git a/gladeui/glade-signal-editor.h b/gladeui/glade-signal-editor.h
index 8a8ef2d..6f0ce08 100644
--- a/gladeui/glade-signal-editor.h
+++ b/gladeui/glade-signal-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_SIGNAL_EDITOR_H__
#define __GLADE_SIGNAL_EDITOR_H__
diff --git a/gladeui/glade-signal.c b/gladeui/glade-signal.c
index a6fb008..ea0009f 100644
--- a/gladeui/glade-signal.c
+++ b/gladeui/glade-signal.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -42,21 +41,20 @@
*
* Returns: the new #GladeSignal
*/
-GladeSignal *glade_signal_new (const gchar *name,
- const gchar *handler,
- const gchar *userdata,
- gboolean after,
- gboolean swapped)
+GladeSignal *
+glade_signal_new (const gchar * name,
+ const gchar * handler,
+ const gchar * userdata, gboolean after, gboolean swapped)
{
- GladeSignal *signal = g_slice_new0 (GladeSignal);
+ GladeSignal *signal = g_slice_new0 (GladeSignal);
- signal->name = g_strdup (name);
- signal->handler = g_strdup (handler);
- signal->userdata = userdata ? g_strdup (userdata) : NULL;
- signal->after = after;
- signal->swapped = swapped;
+ signal->name = g_strdup (name);
+ signal->handler = g_strdup (handler);
+ signal->userdata = userdata ? g_strdup (userdata) : NULL;
+ signal->after = after;
+ signal->swapped = swapped;
- return signal;
+ return signal;
}
/**
@@ -66,15 +64,15 @@ GladeSignal *glade_signal_new (const gchar *name,
* Frees @signal and its associated memory.
*/
void
-glade_signal_free (GladeSignal *signal)
+glade_signal_free (GladeSignal * signal)
{
- g_return_if_fail (GLADE_IS_SIGNAL (signal));
+ g_return_if_fail (GLADE_IS_SIGNAL (signal));
- g_free (signal->name);
- g_free (signal->handler);
- g_free (signal->userdata);
- g_free (signal->support_warning);
- g_slice_free (GladeSignal, signal);
+ g_free (signal->name);
+ g_free (signal->handler);
+ g_free (signal->userdata);
+ g_free (signal->support_warning);
+ g_slice_free (GladeSignal, signal);
}
/**
@@ -85,25 +83,24 @@ glade_signal_free (GladeSignal *signal)
* Returns: %TRUE if @sig1 and @sig2 have identical attributes, %FALSE otherwise
*/
gboolean
-glade_signal_equal (GladeSignal *sig1, GladeSignal *sig2)
+glade_signal_equal (GladeSignal * sig1, GladeSignal * sig2)
{
- gboolean ret = FALSE;
- g_return_val_if_fail (GLADE_IS_SIGNAL (sig1), FALSE);
- g_return_val_if_fail (GLADE_IS_SIGNAL (sig2), FALSE);
-
- /* Intentionally ignore support_warning */
- if (!strcmp (sig1->name, sig2->name) &&
- !strcmp (sig1->handler, sig2->handler) &&
- sig1->after == sig2->after &&
- sig1->swapped == sig2->swapped)
- {
- if ((sig1->userdata == NULL && sig2->userdata == NULL) ||
- (sig1->userdata != NULL && sig2->userdata != NULL &&
- !strcmp (sig1->userdata, sig2->userdata)))
- ret = TRUE;
- }
-
- return ret;
+ gboolean ret = FALSE;
+ g_return_val_if_fail (GLADE_IS_SIGNAL (sig1), FALSE);
+ g_return_val_if_fail (GLADE_IS_SIGNAL (sig2), FALSE);
+
+ /* Intentionally ignore support_warning */
+ if (!strcmp (sig1->name, sig2->name) &&
+ !strcmp (sig1->handler, sig2->handler) &&
+ sig1->after == sig2->after && sig1->swapped == sig2->swapped)
+ {
+ if ((sig1->userdata == NULL && sig2->userdata == NULL) ||
+ (sig1->userdata != NULL && sig2->userdata != NULL &&
+ !strcmp (sig1->userdata, sig2->userdata)))
+ ret = TRUE;
+ }
+
+ return ret;
}
/**
@@ -113,21 +110,19 @@ glade_signal_equal (GladeSignal *sig1, GladeSignal *sig2)
* Returns: a new #GladeSignal with the same attributes as @signal
*/
GladeSignal *
-glade_signal_clone (const GladeSignal *signal)
+glade_signal_clone (const GladeSignal * signal)
{
- GladeSignal *dup;
+ GladeSignal *dup;
+
+ g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
- g_return_val_if_fail (GLADE_IS_SIGNAL (signal), NULL);
+ dup = glade_signal_new (signal->name,
+ signal->handler,
+ signal->userdata, signal->after, signal->swapped);
- dup = glade_signal_new (signal->name,
- signal->handler,
- signal->userdata,
- signal->after,
- signal->swapped);
+ glade_signal_set_support_warning (dup, signal->support_warning);
- glade_signal_set_support_warning (dup, signal->support_warning);
-
- return dup;
+ return dup;
}
/**
@@ -139,45 +134,45 @@ glade_signal_clone (const GladeSignal *signal)
* Writes @signal to @node
*/
void
-glade_signal_write (GladeSignal *signal,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_signal_write (GladeSignal * signal,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- GladeXmlNode *signal_node;
- gchar *name;
-
- /* Should assert GLADE_XML_TAG_WIDGET tag here, but no
- * access to project, so not really seriosly needed
- */
-
- name = g_strdup (signal->name);
-
- /* Now dump the node values... */
- signal_node = glade_xml_node_new (context, GLADE_XML_TAG_SIGNAL);
- glade_xml_node_append_child (node, signal_node);
-
- glade_xml_node_set_property_string (signal_node, GLADE_XML_TAG_NAME, name);
- glade_xml_node_set_property_string (signal_node, GLADE_XML_TAG_HANDLER, signal->handler);
-
- if (signal->userdata)
- glade_xml_node_set_property_string (signal_node,
- GLADE_XML_TAG_OBJECT,
- signal->userdata);
-
- if (signal->after)
- glade_xml_node_set_property_string (signal_node,
- GLADE_XML_TAG_AFTER,
- GLADE_XML_TAG_SIGNAL_TRUE);
-
- /* Always serialize swapped regardless of format (libglade should not complain about this
- * and we prefer to not lose data in conversions).
- */
- glade_xml_node_set_property_string (signal_node,
- GLADE_XML_TAG_SWAPPED,
- signal->swapped ?
- GLADE_XML_TAG_SIGNAL_TRUE : GLADE_XML_TAG_SIGNAL_FALSE);
-
- g_free (name);
+ GladeXmlNode *signal_node;
+ gchar *name;
+
+ /* Should assert GLADE_XML_TAG_WIDGET tag here, but no
+ * access to project, so not really seriosly needed
+ */
+
+ name = g_strdup (signal->name);
+
+ /* Now dump the node values... */
+ signal_node = glade_xml_node_new (context, GLADE_XML_TAG_SIGNAL);
+ glade_xml_node_append_child (node, signal_node);
+
+ glade_xml_node_set_property_string (signal_node, GLADE_XML_TAG_NAME, name);
+ glade_xml_node_set_property_string (signal_node, GLADE_XML_TAG_HANDLER,
+ signal->handler);
+
+ if (signal->userdata)
+ glade_xml_node_set_property_string (signal_node,
+ GLADE_XML_TAG_OBJECT, signal->userdata);
+
+ if (signal->after)
+ glade_xml_node_set_property_string (signal_node,
+ GLADE_XML_TAG_AFTER,
+ GLADE_XML_TAG_SIGNAL_TRUE);
+
+ /* Always serialize swapped regardless of format (libglade should not complain about this
+ * and we prefer to not lose data in conversions).
+ */
+ glade_xml_node_set_property_string (signal_node,
+ GLADE_XML_TAG_SWAPPED,
+ signal->swapped ?
+ GLADE_XML_TAG_SIGNAL_TRUE :
+ GLADE_XML_TAG_SIGNAL_FALSE);
+
+ g_free (name);
}
@@ -190,49 +185,52 @@ glade_signal_write (GladeSignal *signal,
* Returns: A newly created #GladeSignal
*/
GladeSignal *
-glade_signal_read (GladeXmlNode *node)
+glade_signal_read (GladeXmlNode * node)
{
- GladeSignal *signal;
- gchar *name, *handler;
-
- g_return_val_if_fail (glade_xml_node_verify_silent
- (node, GLADE_XML_TAG_SIGNAL), NULL);
-
- if (!(name =
- glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME, NULL)))
- return NULL;
- glade_util_replace (name, '_', '-');
-
- if (!(handler =
- glade_xml_get_property_string_required (node, GLADE_XML_TAG_HANDLER, NULL)))
- {
- g_free (name);
- return NULL;
- }
-
- signal = g_new0 (GladeSignal, 1);
- signal->name = name;
- signal->handler = handler;
- signal->after = glade_xml_get_property_boolean (node, GLADE_XML_TAG_AFTER, FALSE);
- signal->userdata = glade_xml_get_property_string (node, GLADE_XML_TAG_OBJECT);
- signal->swapped = glade_xml_get_property_boolean (node, GLADE_XML_TAG_SWAPPED,
- /* If a signal specifies an object, its swapped
- * by default behaviour in GtkBuilder */
- signal->userdata != NULL);
-
- return signal;
+ GladeSignal *signal;
+ gchar *name, *handler;
+
+ g_return_val_if_fail (glade_xml_node_verify_silent
+ (node, GLADE_XML_TAG_SIGNAL), NULL);
+
+ if (!(name =
+ glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME,
+ NULL)))
+ return NULL;
+ glade_util_replace (name, '_', '-');
+
+ if (!(handler =
+ glade_xml_get_property_string_required (node, GLADE_XML_TAG_HANDLER,
+ NULL)))
+ {
+ g_free (name);
+ return NULL;
+ }
+
+ signal = g_new0 (GladeSignal, 1);
+ signal->name = name;
+ signal->handler = handler;
+ signal->after =
+ glade_xml_get_property_boolean (node, GLADE_XML_TAG_AFTER, FALSE);
+ signal->userdata = glade_xml_get_property_string (node, GLADE_XML_TAG_OBJECT);
+ signal->swapped = glade_xml_get_property_boolean (node, GLADE_XML_TAG_SWAPPED,
+ /* If a signal specifies an object, its swapped
+ * by default behaviour in GtkBuilder */
+ signal->userdata != NULL);
+
+ return signal;
}
void
-glade_signal_set_support_warning (GladeSignal *signal,
- const gchar *support_warning)
+glade_signal_set_support_warning (GladeSignal * signal,
+ const gchar * support_warning)
{
- g_return_if_fail (GLADE_IS_SIGNAL (signal));
-
- if (g_strcmp0 (signal->support_warning, support_warning))
- {
- g_free (signal->support_warning);
- signal->support_warning =
- support_warning ? g_strdup (support_warning) : NULL;
- }
+ g_return_if_fail (GLADE_IS_SIGNAL (signal));
+
+ if (g_strcmp0 (signal->support_warning, support_warning))
+ {
+ g_free (signal->support_warning);
+ signal->support_warning =
+ support_warning ? g_strdup (support_warning) : NULL;
+ }
}
diff --git a/gladeui/glade-signal.h b/gladeui/glade-signal.h
index 0fed81a..485c5af 100644
--- a/gladeui/glade-signal.h
+++ b/gladeui/glade-signal.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_SIGNAL_H__
#define __GLADE_SIGNAL_H__
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index 1396a9d..6bbfa9c 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -19,7 +18,7 @@
* Authors:
* Chema Celorio <chema celorio com>
*/
-
+
#include <config.h>
/**
@@ -72,37 +71,37 @@ static GList *glade_util_selection = NULL;
* Returns:
*/
static gchar *
-glade_util_compose_get_type_func (const gchar *name)
+glade_util_compose_get_type_func (const gchar * name)
{
- gchar *retval;
- GString *tmp;
- gint i = 1, j;
+ gchar *retval;
+ GString *tmp;
+ gint i = 1, j;
- tmp = g_string_new (name);
+ tmp = g_string_new (name);
- while (tmp->str[i])
- {
- if (g_ascii_isupper (tmp->str[i]))
- {
- tmp = g_string_insert_c (tmp, i++, '_');
+ while (tmp->str[i])
+ {
+ if (g_ascii_isupper (tmp->str[i]))
+ {
+ tmp = g_string_insert_c (tmp, i++, '_');
- j = 0;
- while (g_ascii_isupper (tmp->str[i++]))
- j++;
+ j = 0;
+ while (g_ascii_isupper (tmp->str[i++]))
+ j++;
- if (j > 2)
- g_string_insert_c (tmp, i-2, '_');
+ if (j > 2)
+ g_string_insert_c (tmp, i - 2, '_');
- continue;
- }
- i++;
- }
+ continue;
+ }
+ i++;
+ }
- tmp = g_string_append (tmp, "_get_type");
- retval = g_ascii_strdown (tmp->str, tmp->len);
- g_string_free (tmp, TRUE);
+ tmp = g_string_append (tmp, "_get_type");
+ retval = g_ascii_strdown (tmp->str, tmp->len);
+ g_string_free (tmp, TRUE);
- return retval;
+ return retval;
}
/**
@@ -117,38 +116,37 @@ glade_util_compose_get_type_func (const gchar *name)
* Returns: the new #GType
*/
GType
-glade_util_get_type_from_name (const gchar *name, gboolean have_func)
-{
- static GModule *allsymbols = NULL;
- GType (*get_type) ();
- GType type = 0;
- gchar *func_name = (gchar*)name;
-
- if ((type = g_type_from_name (name)) == 0 &&
- (have_func || (func_name = glade_util_compose_get_type_func (name)) != NULL))
- {
-
- if (!allsymbols)
- allsymbols = g_module_open (NULL, 0);
-
- if (g_module_symbol (allsymbols, func_name,
- (gpointer) &get_type))
- {
- g_assert (get_type);
- type = get_type ();
- }
- else
- {
- g_warning (_("We could not find the symbol \"%s\""),
- func_name);
- }
- g_free (func_name);
- }
-
- if (type == 0)
- g_warning(_("Could not get the type from \"%s\""), name);
-
- return type;
+glade_util_get_type_from_name (const gchar * name, gboolean have_func)
+{
+ static GModule *allsymbols = NULL;
+ GType (*get_type) ();
+ GType type = 0;
+ gchar *func_name = (gchar *) name;
+
+ if ((type = g_type_from_name (name)) == 0 &&
+ (have_func ||
+ (func_name = glade_util_compose_get_type_func (name)) != NULL))
+ {
+
+ if (!allsymbols)
+ allsymbols = g_module_open (NULL, 0);
+
+ if (g_module_symbol (allsymbols, func_name, (gpointer) & get_type))
+ {
+ g_assert (get_type);
+ type = get_type ();
+ }
+ else
+ {
+ g_warning (_("We could not find the symbol \"%s\""), func_name);
+ }
+ g_free (func_name);
+ }
+
+ if (type == 0)
+ g_warning (_("Could not get the type from \"%s\""), name);
+
+ return type;
}
/**
@@ -159,26 +157,25 @@ glade_util_get_type_from_name (const gchar *name, gboolean have_func)
* specified by @funcname
*/
GParamSpec *
-glade_utils_get_pspec_from_funcname (const gchar *funcname)
+glade_utils_get_pspec_from_funcname (const gchar * funcname)
{
- static GModule *allsymbols = NULL;
- GParamSpec *pspec = NULL;
- GParamSpec *(*get_pspec)() = NULL;
-
- if (!allsymbols)
- allsymbols = g_module_open (NULL, 0);
+ static GModule *allsymbols = NULL;
+ GParamSpec *pspec = NULL;
+ GParamSpec *(*get_pspec) () = NULL;
+
+ if (!allsymbols)
+ allsymbols = g_module_open (NULL, 0);
- if (!g_module_symbol (allsymbols, funcname,
- (gpointer) &get_pspec)) {
- g_warning (_("We could not find the symbol \"%s\""),
- funcname);
- return NULL;
- }
+ if (!g_module_symbol (allsymbols, funcname, (gpointer) & get_pspec))
+ {
+ g_warning (_("We could not find the symbol \"%s\""), funcname);
+ return NULL;
+ }
- g_assert (get_pspec);
- pspec = get_pspec ();
+ g_assert (get_pspec);
+ pspec = get_pspec ();
- return pspec;
+ return pspec;
}
/**
@@ -198,117 +195,123 @@ glade_utils_get_pspec_from_funcname (const gchar *funcname)
* the user selected "YES"; False otherwise.
*/
gint
-glade_util_ui_message (GtkWidget *parent,
- GladeUIMessageType type,
- GtkWidget *widget,
- const gchar *format,
- ...)
-{
- GtkWidget *dialog;
- GtkMessageType message_type = GTK_MESSAGE_INFO;
- GtkButtonsType buttons_type = GTK_BUTTONS_OK;
- va_list args;
- gchar *string;
- gint response;
-
- va_start (args, format);
- string = g_strdup_vprintf (format, args);
- va_end (args);
-
- /* Get message_type */
- switch (type)
- {
- case GLADE_UI_INFO: message_type = GTK_MESSAGE_INFO; break;
- case GLADE_UI_WARN:
- case GLADE_UI_ARE_YOU_SURE:
- message_type = GTK_MESSAGE_WARNING;
- break;
- case GLADE_UI_ERROR: message_type = GTK_MESSAGE_ERROR; break;
- case GLADE_UI_YES_OR_NO: message_type = GTK_MESSAGE_QUESTION; break;
- break;
- default:
- g_critical ("Bad arg for glade_util_ui_message");
- break;
- }
-
-
- /* Get buttons_type */
- switch (type)
- {
- case GLADE_UI_INFO:
- case GLADE_UI_WARN:
- case GLADE_UI_ERROR:
- buttons_type = GTK_BUTTONS_OK;
- break;
- case GLADE_UI_ARE_YOU_SURE: buttons_type = GTK_BUTTONS_OK_CANCEL; break;
- case GLADE_UI_YES_OR_NO: buttons_type = GTK_BUTTONS_YES_NO; break;
- break;
- default:
- g_critical ("Bad arg for glade_util_ui_message");
- break;
- }
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- message_type,
- buttons_type,
- "%s",
- string);
-
- gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
-
- if (widget)
- gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- widget, TRUE, TRUE, 2);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
- g_free (string);
-
- return (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_YES);
+glade_util_ui_message (GtkWidget * parent,
+ GladeUIMessageType type,
+ GtkWidget * widget, const gchar * format, ...)
+{
+ GtkWidget *dialog;
+ GtkMessageType message_type = GTK_MESSAGE_INFO;
+ GtkButtonsType buttons_type = GTK_BUTTONS_OK;
+ va_list args;
+ gchar *string;
+ gint response;
+
+ va_start (args, format);
+ string = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ /* Get message_type */
+ switch (type)
+ {
+ case GLADE_UI_INFO:
+ message_type = GTK_MESSAGE_INFO;
+ break;
+ case GLADE_UI_WARN:
+ case GLADE_UI_ARE_YOU_SURE:
+ message_type = GTK_MESSAGE_WARNING;
+ break;
+ case GLADE_UI_ERROR:
+ message_type = GTK_MESSAGE_ERROR;
+ break;
+ case GLADE_UI_YES_OR_NO:
+ message_type = GTK_MESSAGE_QUESTION;
+ break;
+ break;
+ default:
+ g_critical ("Bad arg for glade_util_ui_message");
+ break;
+ }
+
+
+ /* Get buttons_type */
+ switch (type)
+ {
+ case GLADE_UI_INFO:
+ case GLADE_UI_WARN:
+ case GLADE_UI_ERROR:
+ buttons_type = GTK_BUTTONS_OK;
+ break;
+ case GLADE_UI_ARE_YOU_SURE:
+ buttons_type = GTK_BUTTONS_OK_CANCEL;
+ break;
+ case GLADE_UI_YES_OR_NO:
+ buttons_type = GTK_BUTTONS_YES_NO;
+ break;
+ break;
+ default:
+ g_critical ("Bad arg for glade_util_ui_message");
+ break;
+ }
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ message_type, buttons_type, "%s", string);
+
+ gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+
+ if (widget)
+ gtk_box_pack_end (GTK_BOX
+ (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ widget, TRUE, TRUE, 2);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+ g_free (string);
+
+ return (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_YES);
}
gboolean
-glade_util_check_and_warn_scrollable (GladeWidget *parent,
- GladeWidgetAdaptor *child_adaptor,
- GtkWidget *parent_widget)
-{
- if (GTK_IS_SCROLLED_WINDOW (parent->object) &&
- GWA_SCROLLABLE_WIDGET (child_adaptor) == FALSE)
- {
- GladeWidgetAdaptor *vadaptor =
- glade_widget_adaptor_get_by_type (GTK_TYPE_VIEWPORT);
-
- glade_util_ui_message (parent_widget,
- GLADE_UI_INFO, NULL,
- _("Cannot add non scrollable %s widget to a %s directly.\n"
- "Add a %s first."),
- child_adaptor->title,
- parent->adaptor->title,
- vadaptor->title);
- return TRUE;
- }
- return FALSE;
-}
-
-typedef struct {
- GtkStatusbar *statusbar;
- guint context_id;
- guint message_id;
+glade_util_check_and_warn_scrollable (GladeWidget * parent,
+ GladeWidgetAdaptor * child_adaptor,
+ GtkWidget * parent_widget)
+{
+ if (GTK_IS_SCROLLED_WINDOW (parent->object) &&
+ GWA_SCROLLABLE_WIDGET (child_adaptor) == FALSE)
+ {
+ GladeWidgetAdaptor *vadaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_VIEWPORT);
+
+ glade_util_ui_message (parent_widget,
+ GLADE_UI_INFO, NULL,
+ _
+ ("Cannot add non scrollable %s widget to a %s directly.\n"
+ "Add a %s first."), child_adaptor->title,
+ parent->adaptor->title, vadaptor->title);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+typedef struct
+{
+ GtkStatusbar *statusbar;
+ guint context_id;
+ guint message_id;
} FlashInfo;
static const guint flash_length = 3;
static gboolean
-remove_message_timeout (FlashInfo * fi)
+remove_message_timeout (FlashInfo * fi)
{
- gtk_statusbar_remove (fi->statusbar, fi->context_id, fi->message_id);
- g_free (fi);
+ gtk_statusbar_remove (fi->statusbar, fi->context_id, fi->message_id);
+ g_free (fi);
- /* remove the timeout */
- return FALSE;
+ /* remove the timeout */
+ return FALSE;
}
/**
@@ -320,63 +323,68 @@ remove_message_timeout (FlashInfo * fi)
* Flash a temporary message on the statusbar.
*/
void
-glade_util_flash_message (GtkWidget *statusbar, guint context_id, gchar *format, ...)
+glade_util_flash_message (GtkWidget * statusbar, guint context_id,
+ gchar * format, ...)
{
- va_list args;
- FlashInfo *fi;
- gchar *message;
+ va_list args;
+ FlashInfo *fi;
+ gchar *message;
- g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
- g_return_if_fail (format != NULL);
+ g_return_if_fail (GTK_IS_STATUSBAR (statusbar));
+ g_return_if_fail (format != NULL);
- va_start (args, format);
- message = g_strdup_vprintf (format, args);
- va_end (args);
+ va_start (args, format);
+ message = g_strdup_vprintf (format, args);
+ va_end (args);
- fi = g_new (FlashInfo, 1);
- fi->statusbar = GTK_STATUSBAR (statusbar);
- fi->context_id = context_id;
- fi->message_id = gtk_statusbar_push (fi->statusbar, fi->context_id, message);
+ fi = g_new (FlashInfo, 1);
+ fi->statusbar = GTK_STATUSBAR (statusbar);
+ fi->context_id = context_id;
+ fi->message_id = gtk_statusbar_push (fi->statusbar, fi->context_id, message);
- g_timeout_add_seconds (flash_length, (GSourceFunc) remove_message_timeout, fi);
+ g_timeout_add_seconds (flash_length, (GSourceFunc) remove_message_timeout,
+ fi);
- g_free (message);
+ g_free (message);
}
static gint
-glade_util_compare_uline_labels (const gchar *labela, const gchar *labelb)
+glade_util_compare_uline_labels (const gchar * labela, const gchar * labelb)
{
- for (;;) {
- gunichar c1, c2;
-
- if (*labela == '\0')
- return (*labelb == '\0') ? 0 : -1;
- if (*labelb == '\0')
- return 1;
-
- c1 = g_utf8_get_char (labela);
- if (c1 == '_') {
- labela = g_utf8_next_char (labela);
- c1 = g_utf8_get_char (labela);
- }
-
- c2 = g_utf8_get_char (labelb);
- if (c2 == '_') {
- labelb = g_utf8_next_char (labelb);
- c2 = g_utf8_get_char (labelb);
- }
-
- if (c1 < c2)
- return -1;
- if (c1 > c2)
- return 1;
-
- labela = g_utf8_next_char (labela);
- labelb = g_utf8_next_char (labelb);
- }
+ for (;;)
+ {
+ gunichar c1, c2;
+
+ if (*labela == '\0')
+ return (*labelb == '\0') ? 0 : -1;
+ if (*labelb == '\0')
+ return 1;
+
+ c1 = g_utf8_get_char (labela);
+ if (c1 == '_')
+ {
+ labela = g_utf8_next_char (labela);
+ c1 = g_utf8_get_char (labela);
+ }
+
+ c2 = g_utf8_get_char (labelb);
+ if (c2 == '_')
+ {
+ labelb = g_utf8_next_char (labelb);
+ c2 = g_utf8_get_char (labelb);
+ }
+
+ if (c1 < c2)
+ return -1;
+ if (c1 > c2)
+ return 1;
+
+ labela = g_utf8_next_char (labela);
+ labelb = g_utf8_next_char (labelb);
+ }
- /* Shouldn't be reached. */
- return 0;
+ /* Shouldn't be reached. */
+ return 0;
}
/**
@@ -393,31 +401,31 @@ glade_util_compare_uline_labels (const gchar *labela, const gchar *labelb)
gint
glade_util_compare_stock_labels (gconstpointer a, gconstpointer b)
{
- const gchar *stock_ida = a, *stock_idb = b;
- GtkStockItem itema, itemb;
- gboolean founda, foundb;
- gint retval;
-
- founda = gtk_stock_lookup (stock_ida, &itema);
- foundb = gtk_stock_lookup (stock_idb, &itemb);
-
- if (founda)
- {
- if (!foundb)
- retval = -1;
- else
- /* FIXME: Not ideal for UTF-8. */
- retval = glade_util_compare_uline_labels (itema.label, itemb.label);
- }
- else
- {
- if (!foundb)
- retval = 0;
- else
- retval = 1;
- }
-
- return retval;
+ const gchar *stock_ida = a, *stock_idb = b;
+ GtkStockItem itema, itemb;
+ gboolean founda, foundb;
+ gint retval;
+
+ founda = gtk_stock_lookup (stock_ida, &itema);
+ foundb = gtk_stock_lookup (stock_idb, &itemb);
+
+ if (founda)
+ {
+ if (!foundb)
+ retval = -1;
+ else
+ /* FIXME: Not ideal for UTF-8. */
+ retval = glade_util_compare_uline_labels (itema.label, itemb.label);
+ }
+ else
+ {
+ if (!foundb)
+ retval = 0;
+ else
+ retval = 1;
+ }
+
+ return retval;
}
/**
@@ -429,18 +437,18 @@ glade_util_compare_stock_labels (gconstpointer a, gconstpointer b)
* beeing hidden.
*/
void
-glade_util_hide_window (GtkWindow *window)
+glade_util_hide_window (GtkWindow * window)
{
- gint x, y;
+ gint x, y;
- g_return_if_fail (GTK_IS_WINDOW (window));
+ g_return_if_fail (GTK_IS_WINDOW (window));
- /* remember position of window for when it is used again */
- gtk_window_get_position (window, &x, &y);
+ /* remember position of window for when it is used again */
+ gtk_window_get_position (window, &x, &y);
- gtk_widget_hide (GTK_WIDGET (window));
+ gtk_widget_hide (GTK_WIDGET (window));
- gtk_window_move(window, x, y);
+ gtk_window_move (window, x, y);
}
/**
@@ -454,55 +462,55 @@ glade_util_hide_window (GtkWindow *window)
* for showing the dialog
*/
GtkWidget *
-glade_util_file_dialog_new (const gchar *title,
- GladeProject *project,
- GtkWindow *parent,
- GladeUtilFileDialogType action)
-{
- GtkWidget *file_dialog;
- GtkFileFilter *file_filter;
-
- g_return_val_if_fail ((action == GLADE_FILE_DIALOG_ACTION_OPEN ||
- action == GLADE_FILE_DIALOG_ACTION_SAVE), NULL);
-
- g_return_val_if_fail ((action != GLADE_FILE_DIALOG_ACTION_SAVE ||
- GLADE_IS_PROJECT (project)), NULL);
-
- file_dialog = gtk_file_chooser_dialog_new (title, parent, action,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- action == GLADE_FILE_DIALOG_ACTION_OPEN ?
- GTK_STOCK_OPEN : GTK_STOCK_SAVE,
- GTK_RESPONSE_OK,
- NULL);
-
- file_filter = gtk_file_filter_new ();
- gtk_file_filter_add_pattern (file_filter, "*");
- gtk_file_filter_set_name (file_filter, _("All Files"));
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
-
- file_filter = gtk_file_filter_new ();
- gtk_file_filter_add_pattern (file_filter, "*.glade");
- gtk_file_filter_set_name (file_filter, _("Libglade Files"));
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
-
- file_filter = gtk_file_filter_new ();
- gtk_file_filter_add_pattern (file_filter, "*.ui");
- gtk_file_filter_set_name (file_filter, _("GtkBuilder Files"));
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
-
- file_filter = gtk_file_filter_new ();
- gtk_file_filter_add_pattern (file_filter, "*.ui");
- gtk_file_filter_add_pattern (file_filter, "*.glade");
- gtk_file_filter_set_name (file_filter, _("All Glade Files"));
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
-
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
-
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (file_dialog), TRUE);
- gtk_dialog_set_default_response (GTK_DIALOG (file_dialog), GTK_RESPONSE_OK);
-
- return file_dialog;
+glade_util_file_dialog_new (const gchar * title,
+ GladeProject * project,
+ GtkWindow * parent, GladeUtilFileDialogType action)
+{
+ GtkWidget *file_dialog;
+ GtkFileFilter *file_filter;
+
+ g_return_val_if_fail ((action == GLADE_FILE_DIALOG_ACTION_OPEN ||
+ action == GLADE_FILE_DIALOG_ACTION_SAVE), NULL);
+
+ g_return_val_if_fail ((action != GLADE_FILE_DIALOG_ACTION_SAVE ||
+ GLADE_IS_PROJECT (project)), NULL);
+
+ file_dialog = gtk_file_chooser_dialog_new (title, parent, action,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ action ==
+ GLADE_FILE_DIALOG_ACTION_OPEN ?
+ GTK_STOCK_OPEN : GTK_STOCK_SAVE,
+ GTK_RESPONSE_OK, NULL);
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (file_filter, "*");
+ gtk_file_filter_set_name (file_filter, _("All Files"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (file_filter, "*.glade");
+ gtk_file_filter_set_name (file_filter, _("Libglade Files"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (file_filter, "*.ui");
+ gtk_file_filter_set_name (file_filter, _("GtkBuilder Files"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (file_filter, "*.ui");
+ gtk_file_filter_add_pattern (file_filter, "*.glade");
+ gtk_file_filter_set_name (file_filter, _("All Glade Files"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_dialog), file_filter);
+
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER
+ (file_dialog), TRUE);
+ gtk_dialog_set_default_response (GTK_DIALOG (file_dialog), GTK_RESPONSE_OK);
+
+ return file_dialog;
}
/**
@@ -514,17 +522,17 @@ glade_util_file_dialog_new (const gchar *title,
* Replaces each occurance of the character @a in @str to @b.
*/
void
-glade_util_replace (gchar *str, gchar a, gchar b)
+glade_util_replace (gchar * str, gchar a, gchar b)
{
- g_return_if_fail (str != NULL);
+ g_return_if_fail (str != NULL);
- while (*str != 0)
- {
- if (*str == a)
- *str = b;
+ while (*str != 0)
+ {
+ if (*str == a)
+ *str = b;
- str = g_utf8_next_char (str);
- }
+ str = g_utf8_next_char (str);
+ }
}
/**
@@ -535,17 +543,17 @@ glade_util_replace (gchar *str, gchar a, gchar b)
* in a freshly parserd #GladeInterface
*/
gchar *
-glade_util_read_prop_name (const gchar *str)
+glade_util_read_prop_name (const gchar * str)
{
- gchar *id;
+ gchar *id;
- g_return_val_if_fail (str != NULL, NULL);
+ g_return_val_if_fail (str != NULL, NULL);
- id = g_strdup (str);
+ id = g_strdup (str);
- glade_util_replace (id, '_', '-');
+ glade_util_replace (id, '_', '-');
- return id;
+ return id;
}
@@ -559,55 +567,62 @@ glade_util_read_prop_name (const gchar *str)
* Returns: a newly allocated string
*/
gchar *
-glade_util_duplicate_underscores (const gchar *name)
+glade_util_duplicate_underscores (const gchar * name)
{
- const gchar *tmp;
- const gchar *last_tmp = name;
- gchar *underscored_name = g_malloc (strlen (name) * 2 + 1);
- gchar *tmp_underscored = underscored_name;
+ const gchar *tmp;
+ const gchar *last_tmp = name;
+ gchar *underscored_name = g_malloc (strlen (name) * 2 + 1);
+ gchar *tmp_underscored = underscored_name;
- for (tmp = last_tmp; *tmp; tmp = g_utf8_next_char (tmp))
- {
- if (*tmp == '_')
- {
- memcpy (tmp_underscored, last_tmp, tmp - last_tmp + 1);
- tmp_underscored += tmp - last_tmp + 1;
- last_tmp = tmp + 1;
- *tmp_underscored++ = '_';
- }
- }
+ for (tmp = last_tmp; *tmp; tmp = g_utf8_next_char (tmp))
+ {
+ if (*tmp == '_')
+ {
+ memcpy (tmp_underscored, last_tmp, tmp - last_tmp + 1);
+ tmp_underscored += tmp - last_tmp + 1;
+ last_tmp = tmp + 1;
+ *tmp_underscored++ = '_';
+ }
+ }
- memcpy (tmp_underscored, last_tmp, tmp - last_tmp + 1);
+ memcpy (tmp_underscored, last_tmp, tmp - last_tmp + 1);
- return underscored_name;
+ return underscored_name;
}
static void
-glade_util_draw_nodes (cairo_t *cr, GdkColor *color,
- gint x, gint y,
- gint width, gint height)
-{
- if (width > GLADE_UTIL_SELECTION_NODE_SIZE && height > GLADE_UTIL_SELECTION_NODE_SIZE) {
- glade_utils_cairo_draw_rectangle (cr, color, TRUE,
- x, y,
- GLADE_UTIL_SELECTION_NODE_SIZE,
- GLADE_UTIL_SELECTION_NODE_SIZE);
- glade_utils_cairo_draw_rectangle (cr, color, TRUE,
- x, y + height - GLADE_UTIL_SELECTION_NODE_SIZE,
- GLADE_UTIL_SELECTION_NODE_SIZE,
- GLADE_UTIL_SELECTION_NODE_SIZE);
- glade_utils_cairo_draw_rectangle (cr, color, TRUE,
- x + width - GLADE_UTIL_SELECTION_NODE_SIZE, y,
- GLADE_UTIL_SELECTION_NODE_SIZE,
- GLADE_UTIL_SELECTION_NODE_SIZE);
- glade_utils_cairo_draw_rectangle (cr, color, TRUE,
- x + width - GLADE_UTIL_SELECTION_NODE_SIZE,
- y + height - GLADE_UTIL_SELECTION_NODE_SIZE,
- GLADE_UTIL_SELECTION_NODE_SIZE,
- GLADE_UTIL_SELECTION_NODE_SIZE);
- }
-
- glade_utils_cairo_draw_rectangle (cr, color, FALSE, x, y, width - 1, height - 1);
+glade_util_draw_nodes (cairo_t * cr, GdkColor * color,
+ gint x, gint y, gint width, gint height)
+{
+ if (width > GLADE_UTIL_SELECTION_NODE_SIZE &&
+ height > GLADE_UTIL_SELECTION_NODE_SIZE)
+ {
+ glade_utils_cairo_draw_rectangle (cr, color, TRUE,
+ x, y,
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ GLADE_UTIL_SELECTION_NODE_SIZE);
+ glade_utils_cairo_draw_rectangle (cr, color, TRUE,
+ x,
+ y + height -
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ GLADE_UTIL_SELECTION_NODE_SIZE);
+ glade_utils_cairo_draw_rectangle (cr, color, TRUE,
+ x + width -
+ GLADE_UTIL_SELECTION_NODE_SIZE, y,
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ GLADE_UTIL_SELECTION_NODE_SIZE);
+ glade_utils_cairo_draw_rectangle (cr, color, TRUE,
+ x + width -
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ y + height -
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ GLADE_UTIL_SELECTION_NODE_SIZE,
+ GLADE_UTIL_SELECTION_NODE_SIZE);
+ }
+
+ glade_utils_cairo_draw_rectangle (cr, color, FALSE, x, y, width - 1,
+ height - 1);
}
/**
@@ -618,26 +633,26 @@ glade_util_draw_nodes (cairo_t *cr, GdkColor *color,
* Draws selection on @widget if @widget is selected.
*/
void
-glade_util_draw_selection_nodes (GtkWidget *widget, cairo_t *cr)
+glade_util_draw_selection_nodes (GtkWidget * widget, cairo_t * cr)
{
- GdkColor *color;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ GdkColor *color;
- cairo_save (cr);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- color = &(gtk_widget_get_style (widget)->black);
+ cairo_save (cr);
- if (g_list_find (glade_util_selection, widget))
- {
- GtkAllocation allocation;
+ color = &(gtk_widget_get_style (widget)->black);
- gtk_widget_get_allocation (widget, &allocation);
- glade_util_draw_nodes (cr, color,
- 0, 0, allocation.width, allocation.height);
- }
+ if (g_list_find (glade_util_selection, widget))
+ {
+ GtkAllocation allocation;
- cairo_restore (cr);
+ gtk_widget_get_allocation (widget, &allocation);
+ glade_util_draw_nodes (cr, color,
+ 0, 0, allocation.width, allocation.height);
+ }
+
+ cairo_restore (cr);
}
/**
@@ -647,15 +662,14 @@ glade_util_draw_selection_nodes (GtkWidget *widget, cairo_t *cr)
* Add visual selection to this GtkWidget
*/
void
-glade_util_add_selection (GtkWidget *widget)
+glade_util_add_selection (GtkWidget * widget)
{
- g_return_if_fail (GTK_IS_WIDGET (widget));
- if (glade_util_has_selection (widget))
- return;
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (glade_util_has_selection (widget))
+ return;
- glade_util_selection =
- g_list_prepend (glade_util_selection, widget);
- gtk_widget_queue_draw (widget);
+ glade_util_selection = g_list_prepend (glade_util_selection, widget);
+ gtk_widget_queue_draw (widget);
}
/**
@@ -665,23 +679,22 @@ glade_util_add_selection (GtkWidget *widget)
* Remove visual selection from this GtkWidget
*/
void
-glade_util_remove_selection (GtkWidget *widget)
+glade_util_remove_selection (GtkWidget * widget)
{
- GtkWidget *parent;
+ GtkWidget *parent;
- g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!glade_util_has_selection (widget))
- return;
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (!glade_util_has_selection (widget))
+ return;
- glade_util_selection =
- g_list_remove (glade_util_selection, widget);
+ glade_util_selection = g_list_remove (glade_util_selection, widget);
- /* We redraw the parent, since the selection rectangle may not be
- cleared if we just redraw the widget itself. */
- parent = gtk_widget_get_parent (widget);
- if (parent)
- gtk_widget_queue_draw (parent);
- gtk_widget_queue_draw (widget);
+ /* We redraw the parent, since the selection rectangle may not be
+ cleared if we just redraw the widget itself. */
+ parent = gtk_widget_get_parent (widget);
+ if (parent)
+ gtk_widget_queue_draw (parent);
+ gtk_widget_queue_draw (widget);
}
/**
@@ -692,23 +705,20 @@ glade_util_remove_selection (GtkWidget *widget)
void
glade_util_clear_selection (void)
{
- GtkWidget *widget;
- GtkWidget *parent;
- GList *list;
+ GtkWidget *widget;
+ GtkWidget *parent;
+ GList *list;
- for (list = glade_util_selection;
- list && list->data;
- list = list->next)
- {
- widget = list->data;
- parent = gtk_widget_get_parent (widget);
+ for (list = glade_util_selection; list && list->data; list = list->next)
+ {
+ widget = list->data;
+ parent = gtk_widget_get_parent (widget);
- if (parent)
- gtk_widget_queue_draw (parent);
- gtk_widget_queue_draw (widget);
- }
- glade_util_selection =
- (g_list_free (glade_util_selection), NULL);
+ if (parent)
+ gtk_widget_queue_draw (parent);
+ gtk_widget_queue_draw (widget);
+ }
+ glade_util_selection = (g_list_free (glade_util_selection), NULL);
}
/**
@@ -718,10 +728,10 @@ glade_util_clear_selection (void)
* Returns: %TRUE if @widget has visual selection, %FALSE otherwise
*/
gboolean
-glade_util_has_selection (GtkWidget *widget)
+glade_util_has_selection (GtkWidget * widget)
{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return g_list_find (glade_util_selection, widget) != NULL;
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+ return g_list_find (glade_util_selection, widget) != NULL;
}
/**
@@ -732,7 +742,7 @@ glade_util_has_selection (GtkWidget *widget)
GList *
glade_util_get_selection ()
{
- return glade_util_selection;
+ return glade_util_selection;
}
/*
@@ -740,13 +750,12 @@ glade_util_get_selection ()
* expose gtk_container_get_all_children
*/
static void
-gtk_container_children_callback (GtkWidget *widget,
- gpointer client_data)
+gtk_container_children_callback (GtkWidget * widget, gpointer client_data)
{
- GList **children;
+ GList **children;
- children = (GList**) client_data;
- *children = g_list_prepend (*children, widget);
+ children = (GList **) client_data;
+ *children = g_list_prepend (*children, widget);
}
/**
@@ -763,18 +772,16 @@ gtk_container_children_callback (GtkWidget *widget,
* Returns: a #GList giving the contents of @container
*/
GList *
-glade_util_container_get_all_children (GtkContainer *container)
+glade_util_container_get_all_children (GtkContainer * container)
{
- GList *children = NULL;
+ GList *children = NULL;
- g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
+ g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
- gtk_container_forall (container,
- gtk_container_children_callback,
- &children);
+ gtk_container_forall (container, gtk_container_children_callback, &children);
- /* Preserve the natural order by reversing the list */
- return g_list_reverse (children);
+ /* Preserve the natural order by reversing the list */
+ return g_list_reverse (children);
}
/**
@@ -784,82 +791,80 @@ glade_util_container_get_all_children (GtkContainer *container)
* Returns: the amount of #GladePlaceholders parented by @parent
*/
gint
-glade_util_count_placeholders (GladeWidget *parent)
+glade_util_count_placeholders (GladeWidget * parent)
{
- gint placeholders = 0;
- GList *list, *children;
+ gint placeholders = 0;
+ GList *list, *children;
- /* count placeholders */
- if ((children = glade_widget_adaptor_get_children
- (parent->adaptor, parent->object)) != NULL)
- {
- for (list = children; list && list->data; list = list->next)
- {
- if (GLADE_IS_PLACEHOLDER (list->data))
- placeholders++;
- }
- g_list_free (children);
- }
+ /* count placeholders */
+ if ((children = glade_widget_adaptor_get_children
+ (parent->adaptor, parent->object)) != NULL)
+ {
+ for (list = children; list && list->data; list = list->next)
+ {
+ if (GLADE_IS_PLACEHOLDER (list->data))
+ placeholders++;
+ }
+ g_list_free (children);
+ }
- return placeholders;
+ return placeholders;
}
static GtkTreeIter *
-glade_util_find_iter (GtkTreeModel *model,
- GtkTreeIter *iter,
- GladeWidget *findme,
- gint column)
-{
- GtkTreeIter *retval = NULL;
- GObject* object = NULL;
- GtkTreeIter *next;
-
- g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
- g_return_val_if_fail (iter != NULL, NULL);
-
- next = gtk_tree_iter_copy (iter);
- g_return_val_if_fail (next != NULL, NULL);
-
- while (retval == NULL)
- {
- GladeWidget *widget;
-
- gtk_tree_model_get (model, next, column, &object, -1);
- if (object &&
- gtk_tree_model_get_column_type (model, column) == G_TYPE_OBJECT)
- g_object_unref (object);
-
- widget = glade_widget_get_from_gobject (object);
-
- if (widget == findme)
- {
- retval = gtk_tree_iter_copy (next);
- break;
- }
- else if (glade_widget_is_ancestor (findme, widget))
- {
- if (gtk_tree_model_iter_has_child (model, next))
- {
- GtkTreeIter child;
- gtk_tree_model_iter_children (model, &child, next);
- if ((retval = glade_util_find_iter
- (model, &child, findme, column)) != NULL)
- break;
- }
-
- /* Only search the branches where the searched widget
- * is actually a child of the this row, optimize the
- * searching this way
- */
- break;
- }
-
- if (!gtk_tree_model_iter_next (model, next))
- break;
- }
- gtk_tree_iter_free (next);
-
- return retval;
+glade_util_find_iter (GtkTreeModel * model,
+ GtkTreeIter * iter, GladeWidget * findme, gint column)
+{
+ GtkTreeIter *retval = NULL;
+ GObject *object = NULL;
+ GtkTreeIter *next;
+
+ g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
+ g_return_val_if_fail (iter != NULL, NULL);
+
+ next = gtk_tree_iter_copy (iter);
+ g_return_val_if_fail (next != NULL, NULL);
+
+ while (retval == NULL)
+ {
+ GladeWidget *widget;
+
+ gtk_tree_model_get (model, next, column, &object, -1);
+ if (object &&
+ gtk_tree_model_get_column_type (model, column) == G_TYPE_OBJECT)
+ g_object_unref (object);
+
+ widget = glade_widget_get_from_gobject (object);
+
+ if (widget == findme)
+ {
+ retval = gtk_tree_iter_copy (next);
+ break;
+ }
+ else if (glade_widget_is_ancestor (findme, widget))
+ {
+ if (gtk_tree_model_iter_has_child (model, next))
+ {
+ GtkTreeIter child;
+ gtk_tree_model_iter_children (model, &child, next);
+ if ((retval = glade_util_find_iter
+ (model, &child, findme, column)) != NULL)
+ break;
+ }
+
+ /* Only search the branches where the searched widget
+ * is actually a child of the this row, optimize the
+ * searching this way
+ */
+ break;
+ }
+
+ if (!gtk_tree_model_iter_next (model, next))
+ break;
+ }
+ gtk_tree_iter_free (next);
+
+ return retval;
}
/**
@@ -876,37 +881,35 @@ glade_util_find_iter (GtkTreeModel *model,
*
*/
GtkTreeIter *
-glade_util_find_iter_by_widget (GtkTreeModel *model,
- GladeWidget *findme,
- gint column)
+glade_util_find_iter_by_widget (GtkTreeModel * model,
+ GladeWidget * findme, gint column)
{
- GtkTreeIter iter;
- if (gtk_tree_model_get_iter_first (model, &iter))
- {
- return glade_util_find_iter (model, &iter, findme, column);
- }
- return NULL;
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ {
+ return glade_util_find_iter (model, &iter, findme, column);
+ }
+ return NULL;
}
gboolean
-glade_util_basenames_match (const gchar *path1,
- const gchar *path2)
-{
- gboolean match = FALSE;
- gchar *bname1;
- gchar *bname2;
-
- if (path1 && path2)
- {
- bname1 = g_path_get_basename (path1);
- bname2 = g_path_get_basename (path2);
-
- match = !strcmp (bname1, bname2);
-
- g_free (bname1);
- g_free (bname2);
- }
- return match;
+glade_util_basenames_match (const gchar * path1, const gchar * path2)
+{
+ gboolean match = FALSE;
+ gchar *bname1;
+ gchar *bname2;
+
+ if (path1 && path2)
+ {
+ bname1 = g_path_get_basename (path1);
+ bname2 = g_path_get_basename (path2);
+
+ match = !strcmp (bname1, bname2);
+
+ g_free (bname1);
+ g_free (bname2);
+ }
+ return match;
}
/**
@@ -917,17 +920,17 @@ glade_util_basenames_match (const gchar *path1,
* duplicate data entries
*/
GList *
-glade_util_purify_list (GList *list)
+glade_util_purify_list (GList * list)
{
- GList *l, *newlist = NULL;
+ GList *l, *newlist = NULL;
- for (l = list; l; l = l->next)
- if (!g_list_find (newlist, l->data))
- newlist = g_list_prepend (newlist, l->data);
+ for (l = list; l; l = l->next)
+ if (!g_list_find (newlist, l->data))
+ newlist = g_list_prepend (newlist, l->data);
- g_list_free (list);
+ g_list_free (list);
- return g_list_reverse (newlist);
+ return g_list_reverse (newlist);
}
/**
@@ -940,18 +943,17 @@ glade_util_purify_list (GList *list)
*
*/
GList *
-glade_util_added_in_list (GList *old_list,
- GList *new_list)
+glade_util_added_in_list (GList * old_list, GList * new_list)
{
- GList *added = NULL, *list;
+ GList *added = NULL, *list;
- for (list = new_list; list; list = list->next)
- {
- if (!g_list_find (old_list, list->data))
- added = g_list_prepend (added, list->data);
- }
+ for (list = new_list; list; list = list->next)
+ {
+ if (!g_list_find (old_list, list->data))
+ added = g_list_prepend (added, list->data);
+ }
- return g_list_reverse (added);
+ return g_list_reverse (added);
}
/**
@@ -964,18 +966,17 @@ glade_util_added_in_list (GList *old_list,
*
*/
GList *
-glade_util_removed_from_list (GList *old_list,
- GList *new_list)
+glade_util_removed_from_list (GList * old_list, GList * new_list)
{
- GList *added = NULL, *list;
+ GList *added = NULL, *list;
- for (list = old_list; list; list = list->next)
- {
- if (!g_list_find (new_list, list->data))
- added = g_list_prepend (added, list->data);
- }
+ for (list = old_list; list; list = list->next)
+ {
+ if (!g_list_find (new_list, list->data))
+ added = g_list_prepend (added, list->data);
+ }
- return g_list_reverse (added);
+ return g_list_reverse (added);
}
@@ -993,58 +994,61 @@ glade_util_removed_from_list (GList *old_list,
* since libc's realpath() does exactly the same.
*/
gchar *
-glade_util_canonical_path (const gchar *path)
+glade_util_canonical_path (const gchar * path)
{
- gchar *orig_dir, *dirname, *basename, *direct_dir, *direct_name = NULL;
+ gchar *orig_dir, *dirname, *basename, *direct_dir, *direct_name = NULL;
- g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (path != NULL, NULL);
- basename = g_path_get_basename (path);
+ basename = g_path_get_basename (path);
- if ((orig_dir = g_get_current_dir ()) != NULL)
- {
- if ((dirname = g_path_get_dirname (path)) != NULL)
- {
- if (g_chdir (dirname) == 0)
- {
- if ((direct_dir = g_get_current_dir ()) != NULL)
- direct_name =
- g_build_filename (direct_dir, basename, NULL);
- else
- g_warning ("g_path");
-
- if (g_chdir (orig_dir) != 0)
- g_warning ("Unable to chdir back to %s directory (%s)",
- orig_dir, g_strerror (errno));
-
- } else g_warning ("Unable to chdir to %s directory (%s)",
- dirname, g_strerror (errno));
-
- g_free (dirname);
- } else g_warning ("Unable to get directory component of %s\n", path);
- g_free (orig_dir);
- }
+ if ((orig_dir = g_get_current_dir ()) != NULL)
+ {
+ if ((dirname = g_path_get_dirname (path)) != NULL)
+ {
+ if (g_chdir (dirname) == 0)
+ {
+ if ((direct_dir = g_get_current_dir ()) != NULL)
+ direct_name = g_build_filename (direct_dir, basename, NULL);
+ else
+ g_warning ("g_path");
+
+ if (g_chdir (orig_dir) != 0)
+ g_warning ("Unable to chdir back to %s directory (%s)",
+ orig_dir, g_strerror (errno));
+
+ }
+ else
+ g_warning ("Unable to chdir to %s directory (%s)",
+ dirname, g_strerror (errno));
+
+ g_free (dirname);
+ }
+ else
+ g_warning ("Unable to get directory component of %s\n", path);
+ g_free (orig_dir);
+ }
- if (basename) g_free (basename);
+ if (basename)
+ g_free (basename);
- return direct_name;
+ return direct_name;
}
static gboolean
-glade_util_canonical_match (const gchar *src_path,
- const gchar *dest_path)
+glade_util_canonical_match (const gchar * src_path, const gchar * dest_path)
{
- gchar *canonical_src, *canonical_dest;
- gboolean match;
- canonical_src = glade_util_canonical_path (src_path);
- canonical_dest = glade_util_canonical_path (dest_path);
+ gchar *canonical_src, *canonical_dest;
+ gboolean match;
+ canonical_src = glade_util_canonical_path (src_path);
+ canonical_dest = glade_util_canonical_path (dest_path);
+
+ match = (strcmp (canonical_src, canonical_dest) == 0);
- match = (strcmp (canonical_src, canonical_dest) == 0);
+ g_free (canonical_src);
+ g_free (canonical_dest);
- g_free (canonical_src);
- g_free (canonical_dest);
-
- return match;
+ return match;
}
/**
@@ -1059,118 +1063,118 @@ glade_util_canonical_match (const gchar *src_path,
* Returns: True if the copy was successfull.
*/
gboolean
-glade_util_copy_file (const gchar *src_path,
- const gchar *dest_path)
-{
- GIOChannel *src, *dest;
- GError *error = NULL;
- GIOStatus read_status, write_status = G_IO_STATUS_ERROR;
- gchar buffer[GLADE_UTIL_COPY_BUFFSIZE];
- gsize bytes_read, bytes_written, written;
- gboolean success = FALSE;
-
- /* FIXME: This may break if src_path & dest_path are actually
- * the same file, right now the canonical comparison is the
- * best check I have.
- */
- if (glade_util_canonical_match (src_path, dest_path))
- return FALSE;
-
- if (g_file_test (dest_path, G_FILE_TEST_IS_REGULAR) != FALSE)
- if (glade_util_ui_message
- (glade_app_get_window(), GLADE_UI_YES_OR_NO, NULL,
- _("%s exists.\nDo you want to replace it?"), dest_path) == FALSE)
- return FALSE;
-
-
- if ((src = g_io_channel_new_file (src_path, "r", &error)) != NULL)
- {
- g_io_channel_set_encoding (src, NULL, NULL);
-
- if ((dest = g_io_channel_new_file (dest_path, "w", &error)) != NULL)
- {
- g_io_channel_set_encoding (dest, NULL, NULL);
-
- while ((read_status = g_io_channel_read_chars
- (src, buffer, GLADE_UTIL_COPY_BUFFSIZE,
- &bytes_read, &error)) != G_IO_STATUS_ERROR)
- {
- bytes_written = 0;
- while ((write_status = g_io_channel_write_chars
- (dest, buffer + bytes_written,
- bytes_read - bytes_written,
- &written, &error)) != G_IO_STATUS_ERROR &&
- (bytes_written + written) < bytes_read)
- bytes_written += written;
-
- if (write_status == G_IO_STATUS_ERROR)
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error writing to %s: %s"),
- dest_path, error->message);
- error = (g_error_free (error), NULL);
- break;
- }
-
- /* Break on EOF & ERROR but not AGAIN and not NORMAL */
- if (read_status == G_IO_STATUS_EOF) break;
- }
-
- if (read_status == G_IO_STATUS_ERROR)
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error reading %s: %s"),
- src_path, error->message);
- error = (g_error_free (error), NULL);
- }
-
-
- /* From here on, unless we have problems shutting down, succuss ! */
- success = (read_status == G_IO_STATUS_EOF &&
- write_status == G_IO_STATUS_NORMAL);
-
- if (g_io_channel_shutdown (dest, TRUE, &error) != G_IO_STATUS_NORMAL)
- {
- glade_util_ui_message
- (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error shutting down I/O channel %s: %s"),
- dest_path, error->message);
- error = (g_error_free (error), NULL);
- success = FALSE;
- }
- }
- else
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Failed to open %s for writing: %s"),
- dest_path, error->message);
- error = (g_error_free (error), NULL);
-
- }
-
-
- if (g_io_channel_shutdown (src, TRUE, &error) != G_IO_STATUS_NORMAL)
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Error shutting down I/O channel %s: %s"),
- src_path, error->message);
- success = FALSE;
- }
- }
- else
- {
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_ERROR, NULL,
- _("Failed to open %s for reading: %s"),
- src_path, error->message);
- error = (g_error_free (error), NULL);
- }
- return success;
+glade_util_copy_file (const gchar * src_path, const gchar * dest_path)
+{
+ GIOChannel *src, *dest;
+ GError *error = NULL;
+ GIOStatus read_status, write_status = G_IO_STATUS_ERROR;
+ gchar buffer[GLADE_UTIL_COPY_BUFFSIZE];
+ gsize bytes_read, bytes_written, written;
+ gboolean success = FALSE;
+
+ /* FIXME: This may break if src_path & dest_path are actually
+ * the same file, right now the canonical comparison is the
+ * best check I have.
+ */
+ if (glade_util_canonical_match (src_path, dest_path))
+ return FALSE;
+
+ if (g_file_test (dest_path, G_FILE_TEST_IS_REGULAR) != FALSE)
+ if (glade_util_ui_message
+ (glade_app_get_window (), GLADE_UI_YES_OR_NO, NULL,
+ _("%s exists.\nDo you want to replace it?"), dest_path) == FALSE)
+ return FALSE;
+
+
+ if ((src = g_io_channel_new_file (src_path, "r", &error)) != NULL)
+ {
+ g_io_channel_set_encoding (src, NULL, NULL);
+
+ if ((dest = g_io_channel_new_file (dest_path, "w", &error)) != NULL)
+ {
+ g_io_channel_set_encoding (dest, NULL, NULL);
+
+ while ((read_status = g_io_channel_read_chars
+ (src, buffer, GLADE_UTIL_COPY_BUFFSIZE,
+ &bytes_read, &error)) != G_IO_STATUS_ERROR)
+ {
+ bytes_written = 0;
+ while ((write_status = g_io_channel_write_chars
+ (dest, buffer + bytes_written,
+ bytes_read - bytes_written,
+ &written, &error)) != G_IO_STATUS_ERROR &&
+ (bytes_written + written) < bytes_read)
+ bytes_written += written;
+
+ if (write_status == G_IO_STATUS_ERROR)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error writing to %s: %s"),
+ dest_path, error->message);
+ error = (g_error_free (error), NULL);
+ break;
+ }
+
+ /* Break on EOF & ERROR but not AGAIN and not NORMAL */
+ if (read_status == G_IO_STATUS_EOF)
+ break;
+ }
+
+ if (read_status == G_IO_STATUS_ERROR)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error reading %s: %s"),
+ src_path, error->message);
+ error = (g_error_free (error), NULL);
+ }
+
+
+ /* From here on, unless we have problems shutting down, succuss ! */
+ success = (read_status == G_IO_STATUS_EOF &&
+ write_status == G_IO_STATUS_NORMAL);
+
+ if (g_io_channel_shutdown (dest, TRUE, &error) != G_IO_STATUS_NORMAL)
+ {
+ glade_util_ui_message
+ (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error shutting down I/O channel %s: %s"),
+ dest_path, error->message);
+ error = (g_error_free (error), NULL);
+ success = FALSE;
+ }
+ }
+ else
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Failed to open %s for writing: %s"),
+ dest_path, error->message);
+ error = (g_error_free (error), NULL);
+
+ }
+
+
+ if (g_io_channel_shutdown (src, TRUE, &error) != G_IO_STATUS_NORMAL)
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Error shutting down I/O channel %s: %s"),
+ src_path, error->message);
+ success = FALSE;
+ }
+ }
+ else
+ {
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_ERROR, NULL,
+ _("Failed to open %s for reading: %s"),
+ src_path, error->message);
+ error = (g_error_free (error), NULL);
+ }
+ return success;
}
/**
@@ -1181,42 +1185,40 @@ glade_util_copy_file (const gchar *src_path,
* Returns: whether @class_type implements the @iface_type interface
*/
gboolean
-glade_util_class_implements_interface (GType class_type,
- GType iface_type)
-{
- GType *ifaces;
- guint n_ifaces, i;
- gboolean implemented = FALSE;
-
- if ((ifaces = g_type_interfaces (class_type, &n_ifaces)) != NULL)
- {
- for (i = 0; i < n_ifaces; i++)
- if (ifaces[i] == iface_type)
- {
- implemented = TRUE;
- break;
- }
- g_free (ifaces);
- }
- return implemented;
+glade_util_class_implements_interface (GType class_type, GType iface_type)
+{
+ GType *ifaces;
+ guint n_ifaces, i;
+ gboolean implemented = FALSE;
+
+ if ((ifaces = g_type_interfaces (class_type, &n_ifaces)) != NULL)
+ {
+ for (i = 0; i < n_ifaces; i++)
+ if (ifaces[i] == iface_type)
+ {
+ implemented = TRUE;
+ break;
+ }
+ g_free (ifaces);
+ }
+ return implemented;
}
static GModule *
-try_load_library (const gchar *library_path,
- const gchar *library_name)
+try_load_library (const gchar * library_path, const gchar * library_name)
{
- GModule *module = NULL;
- gchar *path;
+ GModule *module = NULL;
+ gchar *path;
- path = g_module_build_path (library_path, library_name);
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- {
- if (!(module = g_module_open (path, G_MODULE_BIND_LAZY)))
- g_warning ("Failed to load %s: %s", path, g_module_error ());
- }
- g_free (path);
+ path = g_module_build_path (library_path, library_name);
+ if (g_file_test (path, G_FILE_TEST_EXISTS))
+ {
+ if (!(module = g_module_open (path, G_MODULE_BIND_LAZY)))
+ g_warning ("Failed to load %s: %s", path, g_module_error ());
+ }
+ g_free (path);
- return module;
+ return module;
}
/**
@@ -1232,50 +1234,54 @@ try_load_library (const gchar *library_path,
* Returns: a #GModule on success, or %NULL on failure.
*/
GModule *
-glade_util_load_library (const gchar *library_name)
+glade_util_load_library (const gchar * library_name)
{
- gchar *default_paths[] = { (gchar *)glade_app_get_modules_dir (),
- NULL, /* <-- dynamically allocated */
- "/lib",
- "/usr/lib",
- "/usr/local/lib",
- NULL };
+ gchar *default_paths[] = { (gchar *) glade_app_get_modules_dir (),
+ NULL, /* <-- dynamically allocated */
+ "/lib",
+ "/usr/lib",
+ "/usr/local/lib",
+ NULL
+ };
- GModule *module = NULL;
- const gchar *search_path;
- gchar **split;
- gint i;
+ GModule *module = NULL;
+ const gchar *search_path;
+ gchar **split;
+ gint i;
-
- if ((search_path = g_getenv (GLADE_ENV_MODULE_PATH)) != NULL)
- {
- if ((split = g_strsplit (search_path, ":", 0)) != NULL)
- {
- for (i = 0; split[i] != NULL; i++)
- if ((module = try_load_library (split[i], library_name)) != NULL)
- break;
- g_strfreev (split);
- }
- }
+ if ((search_path = g_getenv (GLADE_ENV_MODULE_PATH)) != NULL)
+ {
+ if ((split = g_strsplit (search_path, ":", 0)) != NULL)
+ {
+ for (i = 0; split[i] != NULL; i++)
+ if ((module = try_load_library (split[i], library_name)) != NULL)
+ break;
+
+ g_strfreev (split);
+ }
+ }
- if (!module)
- {
- /* Search ${prefix}/lib after searching ${prefix}/lib/glade3/modules... */
- default_paths[1] = g_build_filename (glade_app_get_modules_dir (), "..", "..", NULL);
+ if (!module)
+ {
+ /* Search ${prefix}/lib after searching ${prefix}/lib/glade3/modules... */
+ default_paths[1] =
+ g_build_filename (glade_app_get_modules_dir (), "..", "..", NULL);
- for (i = 0; default_paths[i] != NULL; i++)
- if ((module = try_load_library (default_paths[i], library_name)) != NULL)
- break;
+ for (i = 0; default_paths[i] != NULL; i++)
+ if ((module =
+ try_load_library (default_paths[i], library_name)) != NULL)
+ break;
- g_free (default_paths[1]);
- }
+ g_free (default_paths[1]);
+ }
- if (!module)
- g_critical ("Unable to load module '%s' from any search paths", library_name);
-
- return module;
+ if (!module)
+ g_critical ("Unable to load module '%s' from any search paths",
+ library_name);
+
+ return module;
}
/**
@@ -1287,18 +1293,18 @@ glade_util_load_library (const gchar *library_name)
* Returns: TRUE if file is writeable
*/
gboolean
-glade_util_file_is_writeable (const gchar *path)
+glade_util_file_is_writeable (const gchar * path)
{
- GIOChannel *channel;
- g_return_val_if_fail (path != NULL, FALSE);
+ GIOChannel *channel;
+ g_return_val_if_fail (path != NULL, FALSE);
- /* The only way to really know if the file is writable */
- if ((channel = g_io_channel_new_file (path, "a+", NULL)) != NULL)
- {
- g_io_channel_unref (channel);
- return TRUE;
- }
- return FALSE;
+ /* The only way to really know if the file is writable */
+ if ((channel = g_io_channel_new_file (path, "a+", NULL)) != NULL)
+ {
+ g_io_channel_unref (channel);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -1309,10 +1315,10 @@ glade_util_file_is_writeable (const gchar *path)
gboolean
glade_util_have_devhelp (void)
{
- static gint have_devhelp = -1;
- gchar *ptr;
- gint cnt, ret, major, minor;
- GError *error = NULL;
+ static gint have_devhelp = -1;
+ gchar *ptr;
+ gint cnt, ret, major, minor;
+ GError *error = NULL;
#define DEVHELP_OLD_MESSAGE \
"The DevHelp installed on your system is too old, " \
@@ -1322,54 +1328,56 @@ glade_util_have_devhelp (void)
"No DevHelp installed on your system, " \
"devhelp feature will be disabled."
- if (have_devhelp >= 0) return have_devhelp;
-
- have_devhelp = 0;
-
- if ((ptr = g_find_program_in_path ("devhelp")) != NULL)
- {
- g_free (ptr);
-
- if (g_spawn_command_line_sync ("devhelp --version",
- &ptr, NULL, &ret, &error))
- {
- /* If we have a successfull return code.. parse the output.
- */
- if (ret == 0)
- {
- gchar name[16];
- if ((cnt = sscanf (ptr, "%15s %d.%d\n",
- name, &major, &minor)) == 3)
- {
- /* Devhelp 0.12 required.
- */
- if (major >= 0 && minor >= 12)
- have_devhelp = 1;
- else
- g_message (DEVHELP_OLD_MESSAGE);
- }
- else
-
- {
- if (ptr != NULL || strlen (ptr) > 0)
- g_warning ("devhelp had unparsable output: "
- "'%s' (parsed %d elements)", ptr, cnt);
- else
- g_message (DEVHELP_OLD_MESSAGE);
- }
- }
- else g_warning ("devhelp had bad return code: '%d'", ret);
- }
- else
- {
- g_warning ("Error trying to launch devhelp: %s",
- error->message);
- g_error_free (error);
- }
- }
- else g_message (DEVHELP_MISSING_MESSAGE);
-
- return have_devhelp;
+ if (have_devhelp >= 0)
+ return have_devhelp;
+
+ have_devhelp = 0;
+
+ if ((ptr = g_find_program_in_path ("devhelp")) != NULL)
+ {
+ g_free (ptr);
+
+ if (g_spawn_command_line_sync ("devhelp --version",
+ &ptr, NULL, &ret, &error))
+ {
+ /* If we have a successfull return code.. parse the output.
+ */
+ if (ret == 0)
+ {
+ gchar name[16];
+ if ((cnt = sscanf (ptr, "%15s %d.%d\n",
+ name, &major, &minor)) == 3)
+ {
+ /* Devhelp 0.12 required.
+ */
+ if (major >= 0 && minor >= 12)
+ have_devhelp = 1;
+ else
+ g_message (DEVHELP_OLD_MESSAGE);
+ }
+ else
+
+ {
+ if (ptr != NULL || strlen (ptr) > 0)
+ g_warning ("devhelp had unparsable output: "
+ "'%s' (parsed %d elements)", ptr, cnt);
+ else
+ g_message (DEVHELP_OLD_MESSAGE);
+ }
+ }
+ else
+ g_warning ("devhelp had bad return code: '%d'", ret);
+ }
+ else
+ {
+ g_warning ("Error trying to launch devhelp: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ else
+ g_message (DEVHELP_MISSING_MESSAGE);
+
+ return have_devhelp;
}
/**
@@ -1380,32 +1388,35 @@ glade_util_have_devhelp (void)
*
* Returns: a #GtkImage
*/
-GtkWidget*
+GtkWidget *
glade_util_get_devhelp_icon (GtkIconSize size)
{
- GtkIconTheme *icon_theme;
- GdkScreen *screen;
- GtkWidget *image;
- gchar *path;
+ GtkIconTheme *icon_theme;
+ GdkScreen *screen;
+ GtkWidget *image;
+ gchar *path;
- image = gtk_image_new ();
- screen = gtk_widget_get_screen (GTK_WIDGET (image));
- icon_theme = gtk_icon_theme_get_for_screen (screen);
+ image = gtk_image_new ();
+ screen = gtk_widget_get_screen (GTK_WIDGET (image));
+ icon_theme = gtk_icon_theme_get_for_screen (screen);
- if (gtk_icon_theme_has_icon (icon_theme, GLADE_DEVHELP_ICON_NAME))
- {
- gtk_image_set_from_icon_name (GTK_IMAGE (image), GLADE_DEVHELP_ICON_NAME, size);
- }
- else
- {
- path = g_build_filename (glade_app_get_pixmaps_dir (), GLADE_DEVHELP_FALLBACK_ICON_FILE, NULL);
+ if (gtk_icon_theme_has_icon (icon_theme, GLADE_DEVHELP_ICON_NAME))
+ {
+ gtk_image_set_from_icon_name (GTK_IMAGE (image), GLADE_DEVHELP_ICON_NAME,
+ size);
+ }
+ else
+ {
+ path =
+ g_build_filename (glade_app_get_pixmaps_dir (),
+ GLADE_DEVHELP_FALLBACK_ICON_FILE, NULL);
- gtk_image_set_from_file (GTK_IMAGE (image), path);
+ gtk_image_set_from_file (GTK_IMAGE (image), path);
- g_free (path);
- }
+ g_free (path);
+ }
- return image;
+ return image;
}
/**
@@ -1419,78 +1430,79 @@ glade_util_get_devhelp_icon (GtkIconSize size)
*
*/
void
-glade_util_search_devhelp (const gchar *book,
- const gchar *page,
- const gchar *search)
+glade_util_search_devhelp (const gchar * book,
+ const gchar * page, const gchar * search)
{
- GError *error = NULL;
- gchar *book_comm = NULL, *page_comm = NULL, *search_comm = NULL;
- gchar *string;
+ GError *error = NULL;
+ gchar *book_comm = NULL, *page_comm = NULL, *search_comm = NULL;
+ gchar *string;
- g_return_if_fail (glade_util_have_devhelp ());
+ g_return_if_fail (glade_util_have_devhelp ());
- if (book) book_comm = g_strdup_printf ("book:%s", book);
- if (page) page_comm = g_strdup_printf (" page:%s", page);
- if (search) search_comm = g_strdup_printf (" %s", search);
+ if (book)
+ book_comm = g_strdup_printf ("book:%s", book);
+ if (page)
+ page_comm = g_strdup_printf (" page:%s", page);
+ if (search)
+ search_comm = g_strdup_printf (" %s", search);
- string = g_strdup_printf ("devhelp -s \"%s%s%s\"",
- book_comm ? book_comm : "",
- page_comm ? page_comm : "",
- search_comm ? search_comm : "");
+ string = g_strdup_printf ("devhelp -s \"%s%s%s\"",
+ book_comm ? book_comm : "",
+ page_comm ? page_comm : "",
+ search_comm ? search_comm : "");
- if (g_spawn_command_line_async (string, &error) == FALSE)
- {
- g_warning ("Error envoking devhelp: %s", error->message);
- g_error_free (error);
- }
+ if (g_spawn_command_line_async (string, &error) == FALSE)
+ {
+ g_warning ("Error envoking devhelp: %s", error->message);
+ g_error_free (error);
+ }
- g_free (string);
- if (book_comm) g_free (book_comm);
- if (page_comm) g_free (page_comm);
- if (search_comm) g_free (search_comm);
+ g_free (string);
+ if (book_comm)
+ g_free (book_comm);
+ if (page_comm)
+ g_free (page_comm);
+ if (search_comm)
+ g_free (search_comm);
}
GtkWidget *
-glade_util_get_placeholder_from_pointer (GtkContainer *container)
-{
- GtkWidget *toplevel;
- GtkWidget *retval = NULL, *child;
- GtkAllocation allocation;
- GList *c, *l;
- gint x, y, x2, y2;
-
- g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
-
- gtk_widget_get_pointer (toplevel, &x, &y);
-
- for (c = l = glade_util_container_get_all_children (container);
- l;
- l = g_list_next (l))
- {
- child = l->data;
-
- if (GLADE_IS_PLACEHOLDER (child) &&
- gtk_widget_get_mapped (child))
- {
- gtk_widget_translate_coordinates (toplevel, child,
- x, y, &x2, &y2);
-
- gtk_widget_get_allocation (child, &allocation);
- if (x2 >= 0 && y2 >= 0 &&
- x2 <= allocation.width &&
- y2 <= allocation.height)
- {
- retval = child;
- break;
- }
- }
- }
-
- g_list_free (c);
-
- return retval;
+glade_util_get_placeholder_from_pointer (GtkContainer * container)
+{
+ GtkWidget *toplevel;
+ GtkWidget *retval = NULL, *child;
+ GtkAllocation allocation;
+ GList *c, *l;
+ gint x, y, x2, y2;
+
+ g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
+
+ gtk_widget_get_pointer (toplevel, &x, &y);
+
+ for (c = l = glade_util_container_get_all_children (container);
+ l; l = g_list_next (l))
+ {
+ child = l->data;
+
+ if (GLADE_IS_PLACEHOLDER (child) && gtk_widget_get_mapped (child))
+ {
+ gtk_widget_translate_coordinates (toplevel, child, x, y, &x2, &y2);
+
+ gtk_widget_get_allocation (child, &allocation);
+ if (x2 >= 0 && y2 >= 0 &&
+ x2 <= allocation.width && y2 <= allocation.height)
+ {
+ retval = child;
+ break;
+ }
+ }
+ }
+
+ g_list_free (c);
+
+ return retval;
}
/**
@@ -1501,19 +1513,19 @@ glade_util_get_placeholder_from_pointer (GtkContainer *container)
*
*/
gboolean
-glade_util_object_is_loading (GObject *object)
+glade_util_object_is_loading (GObject * object)
{
- GladeProject *project;
- GladeWidget *widget;
+ GladeProject *project;
+ GladeWidget *widget;
+
+ g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
+
+ widget = glade_widget_get_from_gobject (object);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
-
- widget = glade_widget_get_from_gobject (object);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
-
- project = glade_widget_get_project (widget);
-
- return glade_project_is_loading (project);
+ project = glade_widget_get_project (widget);
+
+ return glade_project_is_loading (project);
}
/**
@@ -1526,40 +1538,39 @@ glade_util_object_is_loading (GObject *object)
*
*/
gboolean
-glade_util_url_show (const gchar *url)
+glade_util_url_show (const gchar * url)
{
- GtkWidget *widget;
- GError *error = NULL;
- gboolean ret;
-
- g_return_val_if_fail (url != NULL, FALSE);
-
- widget = glade_app_get_window ();
+ GtkWidget *widget;
+ GError *error = NULL;
+ gboolean ret;
- ret = gtk_show_uri (gtk_widget_get_screen (widget),
- url,
- gtk_get_current_event_time (),
- &error);
- if (error != NULL)
- {
- GtkWidget *dialog_widget;
+ g_return_val_if_fail (url != NULL, FALSE);
- dialog_widget = gtk_message_dialog_new (GTK_WINDOW (widget),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", _("Could not show link:"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog_widget),
- "%s", error->message);
- g_error_free (error);
+ widget = glade_app_get_window ();
- g_signal_connect (dialog_widget, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
-
- gtk_window_present (GTK_WINDOW (dialog_widget));
- }
+ ret = gtk_show_uri (gtk_widget_get_screen (widget),
+ url, gtk_get_current_event_time (), &error);
+ if (error != NULL)
+ {
+ GtkWidget *dialog_widget;
+
+ dialog_widget = gtk_message_dialog_new (GTK_WINDOW (widget),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", _("Could not show link:"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG
+ (dialog_widget), "%s",
+ error->message);
+ g_error_free (error);
+
+ g_signal_connect (dialog_widget, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+
+ gtk_window_present (GTK_WINDOW (dialog_widget));
+ }
- return ret;
+ return ret;
}
/**
@@ -1573,163 +1584,177 @@ glade_util_url_show (const gchar *url)
* could not be read.
*/
time_t
-glade_util_get_file_mtime (const gchar *filename, GError **error)
-{
- struct stat info;
- gint retval;
-
- retval = g_stat (filename, &info);
-
- if (retval != 0) {
- g_set_error (error,
- G_FILE_ERROR,
- g_file_error_from_errno (errno),
- "could not stat file '%s': %s", filename, g_strerror (errno));
- return (time_t) 0;
- } else {
- return info.st_mtime;
- }
+glade_util_get_file_mtime (const gchar * filename, GError ** error)
+{
+ struct stat info;
+ gint retval;
+
+ retval = g_stat (filename, &info);
+
+ if (retval != 0)
+ {
+ g_set_error (error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "could not stat file '%s': %s", filename,
+ g_strerror (errno));
+ return (time_t) 0;
+ }
+ else
+ {
+ return info.st_mtime;
+ }
}
gchar *
-glade_util_filename_to_icon_name (const gchar *value)
+glade_util_filename_to_icon_name (const gchar * value)
{
- gchar *icon_name, *p;
- g_return_val_if_fail (value && value[0], NULL);
+ gchar *icon_name, *p;
+ g_return_val_if_fail (value && value[0], NULL);
+
+ icon_name = g_strdup_printf ("glade-generated-%s", value);
- icon_name = g_strdup_printf ("glade-generated-%s", value);
+ if ((p = strrchr (icon_name, '.')) != NULL)
+ *p = '-';
- if ((p = strrchr (icon_name, '.')) != NULL)
- *p = '-';
-
- return icon_name;
+ return icon_name;
}
gchar *
-glade_util_icon_name_to_filename (const gchar *value)
+glade_util_icon_name_to_filename (const gchar * value)
{
- /* sscanf makes us allocate a buffer */
- gchar filename[FILENAME_MAX], *p;
- g_return_val_if_fail (value && value[0], NULL);
+ /* sscanf makes us allocate a buffer */
+ gchar filename[FILENAME_MAX], *p;
+ g_return_val_if_fail (value && value[0], NULL);
- sscanf (value, "glade-generated-%s", filename);
+ sscanf (value, "glade-generated-%s", filename);
- /* XXX: Filenames without an extention will evidently
- * break here
- */
- if ((p = strrchr (filename, '-')) != NULL)
- *p = '.';
-
- return g_strdup (filename);
+ /* XXX: Filenames without an extention will evidently
+ * break here
+ */
+ if ((p = strrchr (filename, '-')) != NULL)
+ *p = '.';
+
+ return g_strdup (filename);
}
gint
-glade_utils_enum_value_from_string (GType enum_type, const gchar *strval)
+glade_utils_enum_value_from_string (GType enum_type, const gchar * strval)
{
- gint value = 0;
- const gchar *displayable;
- GValue *gvalue;
+ gint value = 0;
+ const gchar *displayable;
+ GValue *gvalue;
- g_return_val_if_fail (strval && strval[0], 0);
+ g_return_val_if_fail (strval && strval[0], 0);
- if (((displayable = glade_get_value_from_displayable (enum_type, strval)) != NULL &&
- (gvalue = glade_utils_value_from_string (enum_type, displayable, NULL, NULL)) != NULL) ||
- (gvalue = glade_utils_value_from_string (enum_type, strval, NULL, NULL)) != NULL)
- {
- value = g_value_get_enum (gvalue);
- g_value_unset (gvalue);
- g_free (gvalue);
- }
- return value;
+ if (((displayable =
+ glade_get_value_from_displayable (enum_type, strval)) != NULL &&
+ (gvalue =
+ glade_utils_value_from_string (enum_type, displayable, NULL,
+ NULL)) != NULL) ||
+ (gvalue =
+ glade_utils_value_from_string (enum_type, strval, NULL, NULL)) != NULL)
+ {
+ value = g_value_get_enum (gvalue);
+ g_value_unset (gvalue);
+ g_free (gvalue);
+ }
+ return value;
}
static gchar *
-glade_utils_enum_string_from_value_real (GType enum_type, gint value, gboolean displayable)
+glade_utils_enum_string_from_value_real (GType enum_type, gint value,
+ gboolean displayable)
{
- GValue gvalue = { 0, };
- gchar *string;
+ GValue gvalue = { 0, };
+ gchar *string;
- g_value_init (&gvalue, enum_type);
- g_value_set_enum (&gvalue, value);
+ g_value_init (&gvalue, enum_type);
+ g_value_set_enum (&gvalue, value);
- string = glade_utils_string_from_value (&gvalue);
- g_value_unset (&gvalue);
+ string = glade_utils_string_from_value (&gvalue);
+ g_value_unset (&gvalue);
- if (displayable && string)
- {
- const gchar *dstring = glade_get_displayable_value (enum_type, string);
- if (dstring)
- {
- g_free (string);
- return g_strdup (dstring);
- }
- }
+ if (displayable && string)
+ {
+ const gchar *dstring = glade_get_displayable_value (enum_type, string);
+ if (dstring)
+ {
+ g_free (string);
+ return g_strdup (dstring);
+ }
+ }
- return string;
+ return string;
}
gchar *
glade_utils_enum_string_from_value (GType enum_type, gint value)
{
- return glade_utils_enum_string_from_value_real (enum_type, value, FALSE);
+ return glade_utils_enum_string_from_value_real (enum_type, value, FALSE);
}
gchar *
glade_utils_enum_string_from_value_displayable (GType enum_type, gint value)
{
- return glade_utils_enum_string_from_value_real (enum_type, value, TRUE);
+ return glade_utils_enum_string_from_value_real (enum_type, value, TRUE);
}
gint
-glade_utils_flags_value_from_string (GType flags_type, const gchar *strval)
+glade_utils_flags_value_from_string (GType flags_type, const gchar * strval)
{
- gint value = 0;
- const gchar *displayable;
- GValue *gvalue;
+ gint value = 0;
+ const gchar *displayable;
+ GValue *gvalue;
- g_return_val_if_fail (strval && strval[0], 0);
+ g_return_val_if_fail (strval && strval[0], 0);
- if (((displayable = glade_get_value_from_displayable (flags_type, strval)) != NULL &&
- (gvalue = glade_utils_value_from_string (flags_type, displayable, NULL, NULL)) != NULL) ||
- (gvalue = glade_utils_value_from_string (flags_type, strval, NULL, NULL)) != NULL)
- {
- value = g_value_get_flags (gvalue);
- g_value_unset (gvalue);
- g_free (gvalue);
- }
- return value;
+ if (((displayable =
+ glade_get_value_from_displayable (flags_type, strval)) != NULL &&
+ (gvalue =
+ glade_utils_value_from_string (flags_type, displayable, NULL,
+ NULL)) != NULL) ||
+ (gvalue =
+ glade_utils_value_from_string (flags_type, strval, NULL, NULL)) != NULL)
+ {
+ value = g_value_get_flags (gvalue);
+ g_value_unset (gvalue);
+ g_free (gvalue);
+ }
+ return value;
}
static gchar *
-glade_utils_flags_string_from_value_real (GType flags_type, gint value, gboolean displayable)
+glade_utils_flags_string_from_value_real (GType flags_type, gint value,
+ gboolean displayable)
{
- GValue gvalue = { 0, };
- gchar *string;
+ GValue gvalue = { 0, };
+ gchar *string;
- g_value_init (&gvalue, flags_type);
- g_value_set_flags (&gvalue, value);
+ g_value_init (&gvalue, flags_type);
+ g_value_set_flags (&gvalue, value);
- string = glade_utils_string_from_value (&gvalue);
- g_value_unset (&gvalue);
+ string = glade_utils_string_from_value (&gvalue);
+ g_value_unset (&gvalue);
- if (displayable && string)
- {
- const gchar *dstring = glade_get_displayable_value (flags_type, string);
- if (dstring)
- {
- g_free (string);
- return g_strdup (dstring);
- }
- }
+ if (displayable && string)
+ {
+ const gchar *dstring = glade_get_displayable_value (flags_type, string);
+ if (dstring)
+ {
+ g_free (string);
+ return g_strdup (dstring);
+ }
+ }
- return string;
+ return string;
}
gchar *
glade_utils_flags_string_from_value (GType flags_type, gint value)
{
- return glade_utils_flags_string_from_value_real (flags_type, value, FALSE);
+ return glade_utils_flags_string_from_value_real (flags_type, value, FALSE);
}
@@ -1737,7 +1762,7 @@ glade_utils_flags_string_from_value (GType flags_type, gint value)
gchar *
glade_utils_flags_string_from_value_displayable (GType flags_type, gint value)
{
- return glade_utils_flags_string_from_value_real (flags_type, value, TRUE);
+ return glade_utils_flags_string_from_value_real (flags_type, value, TRUE);
}
@@ -1749,102 +1774,119 @@ static GHashTable *generic_property_classes = NULL;
static gboolean
-utils_gtype_equal (gconstpointer v1,
- gconstpointer v2)
+utils_gtype_equal (gconstpointer v1, gconstpointer v2)
{
- return *((const GType*) v1) == *((const GType*) v2);
+ return *((const GType *) v1) == *((const GType *) v2);
}
static guint
utils_gtype_hash (gconstpointer v)
{
- return *(const GType*) v;
+ return *(const GType *) v;
}
static GladePropertyClass *
pclass_from_gtype (GType type)
{
- GladePropertyClass *property_class = NULL;
- GParamSpec *pspec = NULL;
-
- if (!generic_property_classes)
- generic_property_classes = g_hash_table_new_full (utils_gtype_hash, utils_gtype_equal,
- g_free, (GDestroyNotify)glade_property_class_free);
-
- property_class = g_hash_table_lookup (generic_property_classes, &type);
-
- if (!property_class)
- {
- /* Support enum and flag types, and a hardcoded list of fundamental types */
- if (type == G_TYPE_CHAR)
- pspec = g_param_spec_char ("dummy", "dummy", "dummy",
- G_MININT8, G_MAXINT8, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_UCHAR)
- pspec = g_param_spec_char ("dummy", "dummy", "dummy",
- 0, G_MAXUINT8, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_BOOLEAN)
- pspec = g_param_spec_boolean ("dummy", "dummy", "dummy",
- FALSE, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_INT)
- pspec = g_param_spec_int ("dummy", "dummy", "dummy",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_UINT)
- pspec = g_param_spec_uint ("dummy", "dummy", "dummy",
- 0, G_MAXUINT, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_LONG)
- pspec = g_param_spec_long ("dummy", "dummy", "dummy",
- G_MINLONG, G_MAXLONG, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_ULONG)
- pspec = g_param_spec_ulong ("dummy", "dummy", "dummy",
- 0, G_MAXULONG, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_INT64)
- pspec = g_param_spec_int64 ("dummy", "dummy", "dummy",
- G_MININT64, G_MAXINT64, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_UINT64)
- pspec = g_param_spec_uint64 ("dummy", "dummy", "dummy",
- 0, G_MAXUINT64, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_FLOAT)
- pspec = g_param_spec_float ("dummy", "dummy", "dummy",
- G_MINFLOAT, G_MAXFLOAT, 1.0F, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_DOUBLE)
- pspec = g_param_spec_double ("dummy", "dummy", "dummy",
- G_MINDOUBLE, G_MAXDOUBLE, 1.0F, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_STRING)
- pspec = g_param_spec_string ("dummy", "dummy", "dummy",
- NULL, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (type == G_TYPE_OBJECT || g_type_is_a (type, G_TYPE_OBJECT))
- pspec = g_param_spec_object ("dummy", "dummy", "dummy",
- type, G_PARAM_READABLE|G_PARAM_WRITABLE);
- else if (G_TYPE_IS_ENUM (type))
- {
- GEnumClass *eclass = g_type_class_ref (type);
- pspec = g_param_spec_enum ("dummy", "dummy", "dummy",
- type, eclass->minimum, G_PARAM_READABLE|G_PARAM_WRITABLE);
- g_type_class_unref (eclass);
- }
- else if (G_TYPE_IS_FLAGS (type))
- pspec = g_param_spec_flags ("dummy", "dummy", "dummy",
- type, 0, G_PARAM_READABLE|G_PARAM_WRITABLE);
-
- if (pspec)
- {
- if ((property_class =
- glade_property_class_new_from_spec_full (NULL, pspec, FALSE)) != NULL)
- {
- /* XXX If we ever free the hash table, property classes wont touch
- * the allocated pspecs, so they would theoretically be leaked.
- */
- g_hash_table_insert (generic_property_classes,
- g_memdup (&type, sizeof (GType)), property_class);
- }
- else
- g_warning ("Unable to create property class for type %s", g_type_name (type));
- }
- else
- g_warning ("No generic conversion support for type %s", g_type_name (type));
- }
- return property_class;
+ GladePropertyClass *property_class = NULL;
+ GParamSpec *pspec = NULL;
+
+ if (!generic_property_classes)
+ generic_property_classes =
+ g_hash_table_new_full (utils_gtype_hash, utils_gtype_equal, g_free,
+ (GDestroyNotify) glade_property_class_free);
+
+ property_class = g_hash_table_lookup (generic_property_classes, &type);
+
+ if (!property_class)
+ {
+ /* Support enum and flag types, and a hardcoded list of fundamental types */
+ if (type == G_TYPE_CHAR)
+ pspec = g_param_spec_char ("dummy", "dummy", "dummy",
+ G_MININT8, G_MAXINT8, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_UCHAR)
+ pspec = g_param_spec_char ("dummy", "dummy", "dummy",
+ 0, G_MAXUINT8, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_BOOLEAN)
+ pspec = g_param_spec_boolean ("dummy", "dummy", "dummy",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_INT)
+ pspec = g_param_spec_int ("dummy", "dummy", "dummy",
+ G_MININT, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_UINT)
+ pspec = g_param_spec_uint ("dummy", "dummy", "dummy",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_LONG)
+ pspec = g_param_spec_long ("dummy", "dummy", "dummy",
+ G_MINLONG, G_MAXLONG, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_ULONG)
+ pspec = g_param_spec_ulong ("dummy", "dummy", "dummy",
+ 0, G_MAXULONG, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_INT64)
+ pspec = g_param_spec_int64 ("dummy", "dummy", "dummy",
+ G_MININT64, G_MAXINT64, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_UINT64)
+ pspec = g_param_spec_uint64 ("dummy", "dummy", "dummy",
+ 0, G_MAXUINT64, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_FLOAT)
+ pspec = g_param_spec_float ("dummy", "dummy", "dummy",
+ G_MINFLOAT, G_MAXFLOAT, 1.0F,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_DOUBLE)
+ pspec = g_param_spec_double ("dummy", "dummy", "dummy",
+ G_MINDOUBLE, G_MAXDOUBLE, 1.0F,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_STRING)
+ pspec = g_param_spec_string ("dummy", "dummy", "dummy",
+ NULL, G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (type == G_TYPE_OBJECT || g_type_is_a (type, G_TYPE_OBJECT))
+ pspec = g_param_spec_object ("dummy", "dummy", "dummy",
+ type, G_PARAM_READABLE | G_PARAM_WRITABLE);
+ else if (G_TYPE_IS_ENUM (type))
+ {
+ GEnumClass *eclass = g_type_class_ref (type);
+ pspec = g_param_spec_enum ("dummy", "dummy", "dummy",
+ type, eclass->minimum,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+ g_type_class_unref (eclass);
+ }
+ else if (G_TYPE_IS_FLAGS (type))
+ pspec = g_param_spec_flags ("dummy", "dummy", "dummy",
+ type, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE);
+
+ if (pspec)
+ {
+ if ((property_class =
+ glade_property_class_new_from_spec_full (NULL, pspec,
+ FALSE)) != NULL)
+ {
+ /* XXX If we ever free the hash table, property classes wont touch
+ * the allocated pspecs, so they would theoretically be leaked.
+ */
+ g_hash_table_insert (generic_property_classes,
+ g_memdup (&type, sizeof (GType)),
+ property_class);
+ }
+ else
+ g_warning ("Unable to create property class for type %s",
+ g_type_name (type));
+ }
+ else
+ g_warning ("No generic conversion support for type %s",
+ g_type_name (type));
+ }
+ return property_class;
}
/**
@@ -1861,20 +1903,20 @@ pclass_from_gtype (GType type)
* Returns: A newly allocated and set #GValue
*/
GValue *
-glade_utils_value_from_string (GType type,
- const gchar *string,
- GladeProject *project,
- GladeWidget *widget)
+glade_utils_value_from_string (GType type,
+ const gchar * string,
+ GladeProject * project, GladeWidget * widget)
{
- GladePropertyClass *pclass;
+ GladePropertyClass *pclass;
- g_return_val_if_fail (type != G_TYPE_INVALID, NULL);
- g_return_val_if_fail (string != NULL, NULL);
+ g_return_val_if_fail (type != G_TYPE_INVALID, NULL);
+ g_return_val_if_fail (string != NULL, NULL);
- if ((pclass = pclass_from_gtype (type)) != NULL)
- return glade_property_class_make_gvalue_from_string (pclass, string, project, widget);
+ if ((pclass = pclass_from_gtype (type)) != NULL)
+ return glade_property_class_make_gvalue_from_string (pclass, string,
+ project, widget);
- return NULL;
+ return NULL;
}
@@ -1888,16 +1930,16 @@ glade_utils_value_from_string (GType type,
* Returns: A newly allocated string
*/
gchar *
-glade_utils_string_from_value (const GValue *value)
+glade_utils_string_from_value (const GValue * value)
{
- GladePropertyClass *pclass;
+ GladePropertyClass *pclass;
- g_return_val_if_fail (value != NULL, NULL);
+ g_return_val_if_fail (value != NULL, NULL);
- if ((pclass = pclass_from_gtype (G_VALUE_TYPE (value))) != NULL)
- return glade_property_class_make_string_from_gvalue (pclass, value);
+ if ((pclass = pclass_from_gtype (G_VALUE_TYPE (value))) != NULL)
+ return glade_property_class_make_string_from_gvalue (pclass, value);
- return NULL;
+ return NULL;
}
@@ -1912,39 +1954,38 @@ glade_utils_string_from_value (const GValue *value)
* Returns: A new #GtkListStore
*/
GtkListStore *
-glade_utils_liststore_from_enum_type (GType enum_type,
- gboolean include_empty)
+glade_utils_liststore_from_enum_type (GType enum_type, gboolean include_empty)
{
- GtkListStore *store;
- GtkTreeIter iter;
- GEnumClass *eclass;
- guint i;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GEnumClass *eclass;
+ guint i;
- eclass = g_type_class_ref (enum_type);
+ eclass = g_type_class_ref (enum_type);
- store = gtk_list_store_new (1, G_TYPE_STRING);
+ store = gtk_list_store_new (1, G_TYPE_STRING);
- if (include_empty)
- {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- 0, _("None"),
- -1);
- }
-
- for (i = 0; i < eclass->n_values; i++)
- {
- const gchar *displayable = glade_get_displayable_value (enum_type, eclass->values[i].value_nick);
+ if (include_empty)
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("None"), -1);
+ }
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- 0, displayable ? displayable : eclass->values[i].value_nick,
- -1);
- }
+ for (i = 0; i < eclass->n_values; i++)
+ {
+ const gchar *displayable =
+ glade_get_displayable_value (enum_type, eclass->values[i].value_nick);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ 0,
+ displayable ? displayable : eclass->values[i].
+ value_nick, -1);
+ }
- g_type_class_unref (eclass);
+ g_type_class_unref (eclass);
- return store;
+ return store;
}
@@ -1965,36 +2006,30 @@ glade_utils_liststore_from_enum_type (GType enum_type,
* Returns: whether the event was handled
*/
gint
-glade_utils_hijack_key_press (GtkWindow *win,
- GdkEventKey *event,
- gpointer user_data)
-{
- GtkWidget *focus_widget;
-
- focus_widget = gtk_window_get_focus (win);
- if (focus_widget &&
- (event->keyval == GDK_KEY_Delete || /* Filter Delete from accelerator keys */
- ((event->state & GDK_CONTROL_MASK) && /* CNTL keys... */
- ((event->keyval == GDK_KEY_c || event->keyval == GDK_KEY_C) || /* CNTL-C (copy) */
- (event->keyval == GDK_KEY_x || event->keyval == GDK_KEY_X) || /* CNTL-X (cut) */
- (event->keyval == GDK_KEY_v || event->keyval == GDK_KEY_V) || /* CNTL-V (paste) */
- (event->keyval == GDK_KEY_n || event->keyval == GDK_KEY_N))))) /* CNTL-N (new project) */
- {
- return gtk_widget_event (focus_widget,
- (GdkEvent *)event);
- }
- return FALSE;
+glade_utils_hijack_key_press (GtkWindow * win,
+ GdkEventKey * event, gpointer user_data)
+{
+ GtkWidget *focus_widget;
+
+ focus_widget = gtk_window_get_focus (win);
+ if (focus_widget && (event->keyval == GDK_KEY_Delete || /* Filter Delete from accelerator keys */
+ ((event->state & GDK_CONTROL_MASK) && /* CNTL keys... */
+ ((event->keyval == GDK_KEY_c || event->keyval == GDK_KEY_C) || /* CNTL-C (copy) */
+ (event->keyval == GDK_KEY_x || event->keyval == GDK_KEY_X) || /* CNTL-X (cut) */
+ (event->keyval == GDK_KEY_v || event->keyval == GDK_KEY_V) || /* CNTL-V (paste) */
+ (event->keyval == GDK_KEY_n || event->keyval == GDK_KEY_N))))) /* CNTL-N (new project) */
+ {
+ return gtk_widget_event (focus_widget, (GdkEvent *) event);
+ }
+ return FALSE;
}
void
-glade_utils_cairo_draw_line (cairo_t *cr,
- GdkColor *color,
- gint x1,
- gint y1,
- gint x2,
- gint y2)
+glade_utils_cairo_draw_line (cairo_t * cr,
+ GdkColor * color,
+ gint x1, gint y1, gint x2, gint y2)
{
cairo_save (cr);
@@ -2010,13 +2045,10 @@ glade_utils_cairo_draw_line (cairo_t *cr,
void
-glade_utils_cairo_draw_rectangle (cairo_t *cr,
- GdkColor *color,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height)
+glade_utils_cairo_draw_rectangle (cairo_t * cr,
+ GdkColor * color,
+ gboolean filled,
+ gint x, gint y, gint width, gint height)
{
gdk_cairo_set_source_color (cr, color);
@@ -2035,50 +2067,50 @@ glade_utils_cairo_draw_rectangle (cairo_t *cr,
/* copied from gedit */
gchar *
-glade_utils_replace_home_dir_with_tilde (const gchar *path)
+glade_utils_replace_home_dir_with_tilde (const gchar * path)
{
#ifdef G_OS_UNIX
- gchar *tmp;
- gchar *home;
+ gchar *tmp;
+ gchar *home;
- g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (path != NULL, NULL);
- /* Note that g_get_home_dir returns a const string */
- tmp = (gchar *) g_get_home_dir ();
+ /* Note that g_get_home_dir returns a const string */
+ tmp = (gchar *) g_get_home_dir ();
- if (tmp == NULL)
- return g_strdup (path);
+ if (tmp == NULL)
+ return g_strdup (path);
- home = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
- if (home == NULL)
- return g_strdup (path);
+ home = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
+ if (home == NULL)
+ return g_strdup (path);
- if (strcmp (path, home) == 0)
- {
- g_free (home);
-
- return g_strdup ("~");
- }
+ if (strcmp (path, home) == 0)
+ {
+ g_free (home);
- tmp = home;
- home = g_strdup_printf ("%s/", tmp);
- g_free (tmp);
+ return g_strdup ("~");
+ }
+
+ tmp = home;
+ home = g_strdup_printf ("%s/", tmp);
+ g_free (tmp);
- if (g_str_has_prefix (path, home))
- {
- gchar *res;
+ if (g_str_has_prefix (path, home))
+ {
+ gchar *res;
- res = g_strdup_printf ("~/%s", path + strlen (home));
+ res = g_strdup_printf ("~/%s", path + strlen (home));
- g_free (home);
-
- return res;
- }
+ g_free (home);
+
+ return res;
+ }
- g_free (home);
+ g_free (home);
- return g_strdup (path);
+ return g_strdup (path);
#else
- return g_strdup (path);
+ return g_strdup (path);
#endif
}
diff --git a/gladeui/glade-utils.h b/gladeui/glade-utils.h
index 70f48d4..17a0c13 100644
--- a/gladeui/glade-utils.h
+++ b/gladeui/glade-utils.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_UTILS_H__
#define __GLADE_UTILS_H__
diff --git a/gladeui/glade-widget-action.c b/gladeui/glade-widget-action.c
index 108dbfe..be5195d 100644
--- a/gladeui/glade-widget-action.c
+++ b/gladeui/glade-widget-action.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2007 Juan Pablo Ugarte.
*
@@ -36,139 +35,144 @@
enum
{
- PROP_0,
+ PROP_0,
- PROP_CLASS,
- PROP_SENSITIVE
+ PROP_CLASS,
+ PROP_SENSITIVE
};
G_DEFINE_TYPE (GladeWidgetAction, glade_widget_action, G_TYPE_OBJECT);
static void
-glade_widget_action_init (GladeWidgetAction *object)
+glade_widget_action_init (GladeWidgetAction * object)
{
- object->sensitive = TRUE;
- object->actions = NULL;
+ object->sensitive = TRUE;
+ object->actions = NULL;
}
static void
-glade_widget_action_finalize (GObject *object)
+glade_widget_action_finalize (GObject * object)
{
- GladeWidgetAction *action = GLADE_WIDGET_ACTION (object);
-
- if (action->actions)
- {
- g_list_foreach (action->actions, (GFunc)g_object_unref, NULL);
- g_list_free (action->actions);
- }
-
- G_OBJECT_CLASS (glade_widget_action_parent_class)->finalize (object);
+ GladeWidgetAction *action = GLADE_WIDGET_ACTION (object);
+
+ if (action->actions)
+ {
+ g_list_foreach (action->actions, (GFunc) g_object_unref, NULL);
+ g_list_free (action->actions);
+ }
+
+ G_OBJECT_CLASS (glade_widget_action_parent_class)->finalize (object);
}
static GObject *
-glade_widget_action_constructor(GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+glade_widget_action_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
{
- GladeWidgetAction *action;
- GObject *object;
- GList *l;
-
- object = G_OBJECT_CLASS (glade_widget_action_parent_class)->constructor
- (type, n_construct_properties, construct_properties);
-
- action = GLADE_WIDGET_ACTION (object);
-
- if (action->klass == NULL)
- {
- g_warning ("GladeWidgetAction constructed without class property");
- return object;
- }
-
- for (l = action->klass->actions; l; l = g_list_next (l))
- {
- GWActionClass *action_class = l->data;
- GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
- "class", action_class,
- NULL);
-
- action->actions = g_list_prepend (action->actions,
- GLADE_WIDGET_ACTION (obj));
- }
-
- action->actions = g_list_reverse (action->actions);
-
- return object;
+ GladeWidgetAction *action;
+ GObject *object;
+ GList *l;
+
+ object = G_OBJECT_CLASS (glade_widget_action_parent_class)->constructor
+ (type, n_construct_properties, construct_properties);
+
+ action = GLADE_WIDGET_ACTION (object);
+
+ if (action->klass == NULL)
+ {
+ g_warning ("GladeWidgetAction constructed without class property");
+ return object;
+ }
+
+ for (l = action->klass->actions; l; l = g_list_next (l))
+ {
+ GWActionClass *action_class = l->data;
+ GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
+ "class", action_class,
+ NULL);
+
+ action->actions = g_list_prepend (action->actions,
+ GLADE_WIDGET_ACTION (obj));
+ }
+
+ action->actions = g_list_reverse (action->actions);
+
+ return object;
}
static void
-glade_widget_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+glade_widget_action_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
- GladeWidgetAction *action = GLADE_WIDGET_ACTION (object);
-
- g_return_if_fail (GLADE_IS_WIDGET_ACTION (object));
-
- switch (prop_id)
- {
- case PROP_CLASS:
- action->klass = g_value_get_pointer (value);
- break;
- case PROP_SENSITIVE:
- glade_widget_action_set_sensitive (action,
- g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeWidgetAction *action = GLADE_WIDGET_ACTION (object);
+
+ g_return_if_fail (GLADE_IS_WIDGET_ACTION (object));
+
+ switch (prop_id)
+ {
+ case PROP_CLASS:
+ action->klass = g_value_get_pointer (value);
+ break;
+ case PROP_SENSITIVE:
+ glade_widget_action_set_sensitive (action, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_widget_action_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+glade_widget_action_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
- GladeWidgetAction *action = GLADE_WIDGET_ACTION (object);
-
- g_return_if_fail (GLADE_IS_WIDGET_ACTION (object));
-
- switch (prop_id)
- {
- case PROP_CLASS:
- g_value_set_pointer (value, action->klass);
- break;
- case PROP_SENSITIVE:
- g_value_set_boolean (value, action->sensitive);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GladeWidgetAction *action = GLADE_WIDGET_ACTION (object);
+
+ g_return_if_fail (GLADE_IS_WIDGET_ACTION (object));
+
+ switch (prop_id)
+ {
+ case PROP_CLASS:
+ g_value_set_pointer (value, action->klass);
+ break;
+ case PROP_SENSITIVE:
+ g_value_set_boolean (value, action->sensitive);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_widget_action_class_init (GladeWidgetActionClass *klass)
+glade_widget_action_class_init (GladeWidgetActionClass * klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- glade_widget_action_parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
-
- object_class->constructor = glade_widget_action_constructor;
- object_class->finalize = glade_widget_action_finalize;
- object_class->set_property = glade_widget_action_set_property;
- object_class->get_property = glade_widget_action_get_property;
-
- g_object_class_install_property (object_class,
- PROP_CLASS,
- g_param_spec_pointer ("class",
- _("class"),
- _("GladeWidgetActionClass structure pointer"),
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
-
- g_object_class_install_property (object_class,
- PROP_SENSITIVE,
- g_param_spec_boolean ("sensitive",
- _("Sensitive"),
- _("Whether this action is sensitive"),
- TRUE,
- G_PARAM_READWRITE));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ glade_widget_action_parent_class =
+ G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+
+ object_class->constructor = glade_widget_action_constructor;
+ object_class->finalize = glade_widget_action_finalize;
+ object_class->set_property = glade_widget_action_set_property;
+ object_class->get_property = glade_widget_action_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_CLASS,
+ g_param_spec_pointer ("class",
+ _("class"),
+ _
+ ("GladeWidgetActionClass structure pointer"),
+ G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_SENSITIVE,
+ g_param_spec_boolean ("sensitive",
+ _("Sensitive"),
+ _
+ ("Whether this action is sensitive"),
+ TRUE,
+ G_PARAM_READWRITE));
}
@@ -179,16 +183,17 @@ glade_widget_action_class_init (GladeWidgetActionClass *klass)
* Frees a GWActionClass.
*/
void
-glade_widget_action_class_free (GWActionClass *action)
+glade_widget_action_class_free (GWActionClass * action)
{
- if (action->actions)
- g_list_foreach (action->actions, (GFunc)glade_widget_action_class_free, NULL);
-
- /*Dont free id since it points to path*/
- g_free (action->path);
- g_free (action->label);
- g_free (action->stock);
- g_free (action);
+ if (action->actions)
+ g_list_foreach (action->actions, (GFunc) glade_widget_action_class_free,
+ NULL);
+
+ /*Dont free id since it points to path */
+ g_free (action->path);
+ g_free (action->label);
+ g_free (action->stock);
+ g_free (action);
}
/**
@@ -198,31 +203,31 @@ glade_widget_action_class_free (GWActionClass *action)
* Returns: a newlly allocated copy of @action.
*/
GWActionClass *
-glade_widget_action_class_clone (GWActionClass *action)
+glade_widget_action_class_clone (GWActionClass * action)
{
- GWActionClass *copy;
- GList *l;
-
- g_return_val_if_fail (action != NULL, NULL);
-
- copy = g_new0 (GWActionClass, 1);
- copy->path = g_strdup (action->path);
- copy->label = g_strdup (action->label);
- copy->stock = g_strdup (action->stock);
- copy->important = action->important;
-
- /* id points to path! */
- copy->id = copy->path + (action->id - action->path);
-
- for (l = action->actions; l; l = g_list_next (l))
- {
- GWActionClass *child = glade_widget_action_class_clone (l->data);
- copy->actions = g_list_prepend (copy->actions, child);
- }
-
- copy->actions = g_list_reverse (copy->actions);
-
- return copy;
+ GWActionClass *copy;
+ GList *l;
+
+ g_return_val_if_fail (action != NULL, NULL);
+
+ copy = g_new0 (GWActionClass, 1);
+ copy->path = g_strdup (action->path);
+ copy->label = g_strdup (action->label);
+ copy->stock = g_strdup (action->stock);
+ copy->important = action->important;
+
+ /* id points to path! */
+ copy->id = copy->path + (action->id - action->path);
+
+ for (l = action->actions; l; l = g_list_next (l))
+ {
+ GWActionClass *child = glade_widget_action_class_clone (l->data);
+ copy->actions = g_list_prepend (copy->actions, child);
+ }
+
+ copy->actions = g_list_reverse (copy->actions);
+
+ return copy;
}
/**
@@ -235,23 +240,23 @@ glade_widget_action_class_clone (GWActionClass *action)
* Returns: whether or not @child was removed from @action.
*/
gboolean
-glade_widget_action_remove (GladeWidgetAction *action,
- GladeWidgetAction *child)
+glade_widget_action_remove (GladeWidgetAction * action,
+ GladeWidgetAction * child)
{
- GList *l;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (action), FALSE);
- g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (child), FALSE);
-
- for (l = action->actions; l; l = g_list_next (l))
- {
- if (child == l->data)
- {
- action->actions = g_list_remove (action->actions, child);
- return TRUE;
- }
- }
- return FALSE;
+ GList *l;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (action), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (child), FALSE);
+
+ for (l = action->actions; l; l = g_list_next (l))
+ {
+ if (child == l->data)
+ {
+ action->actions = g_list_remove (action->actions, child);
+ return TRUE;
+ }
+ }
+ return FALSE;
}
/**
@@ -263,9 +268,10 @@ glade_widget_action_remove (GladeWidgetAction *action,
*
*/
void
-glade_widget_action_set_sensitive (GladeWidgetAction *action, gboolean sensitive)
+glade_widget_action_set_sensitive (GladeWidgetAction * action,
+ gboolean sensitive)
{
- g_return_if_fail (GLADE_IS_WIDGET_ACTION (action));
- action->sensitive = sensitive;
- g_object_notify (G_OBJECT (action), "sensitive");
+ g_return_if_fail (GLADE_IS_WIDGET_ACTION (action));
+ action->sensitive = sensitive;
+ g_object_notify (G_OBJECT (action), "sensitive");
}
diff --git a/gladeui/glade-widget-action.h b/gladeui/glade-widget-action.h
index 7cb6660..14c38d6 100644
--- a/gladeui/glade-widget-action.h
+++ b/gladeui/glade-widget-action.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2007 Juan Pablo Ugarte.
*
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index dcac025..cfd6c7b 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -57,53 +56,57 @@
#define GLADE_WIDGET_ADAPTOR_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GLADE_TYPE_WIDGET_ADAPTOR, GladeWidgetAdaptorPrivate))
-struct _GladeWidgetAdaptorPrivate {
+struct _GladeWidgetAdaptorPrivate
+{
- gchar *catalog; /* The name of the widget catalog this class
- * was declared by.
- */
+ gchar *catalog; /* The name of the widget catalog this class
+ * was declared by.
+ */
- gchar *book; /* DevHelp search namespace for this widget class
- */
+ gchar *book; /* DevHelp search namespace for this widget class
+ */
- GdkCursor *cursor; /* a cursor for inserting widgets */
+ GdkCursor *cursor; /* a cursor for inserting widgets */
- gchar *special_child_type; /* Special case code for children that
- * are special children (like notebook tab
- * widgets for example).
- */
+ gchar *special_child_type; /* Special case code for children that
+ * are special children (like notebook tab
+ * widgets for example).
+ */
};
-struct _GladeChildPacking {
- gchar *parent_name;
- GList *packing_defaults;
+struct _GladeChildPacking
+{
+ gchar *parent_name;
+ GList *packing_defaults;
};
-struct _GladePackingDefault {
- gchar *id;
- gchar *value;
+struct _GladePackingDefault
+{
+ gchar *id;
+ gchar *value;
};
-enum {
- PROP_0,
- PROP_NAME,
- PROP_TYPE,
- PROP_TITLE,
- PROP_GENERIC_NAME,
- PROP_ICON_NAME,
- PROP_CATALOG,
- PROP_BOOK,
- PROP_SPECIAL_TYPE,
- PROP_CURSOR
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_TYPE,
+ PROP_TITLE,
+ PROP_GENERIC_NAME,
+ PROP_ICON_NAME,
+ PROP_CATALOG,
+ PROP_BOOK,
+ PROP_SPECIAL_TYPE,
+ PROP_CURSOR
};
-typedef struct _GladeChildPacking GladeChildPacking;
-typedef struct _GladePackingDefault GladePackingDefault;
+typedef struct _GladeChildPacking GladeChildPacking;
+typedef struct _GladePackingDefault GladePackingDefault;
static GObjectClass *parent_class = NULL;
-static GHashTable *adaptor_hash = NULL;
+static GHashTable *adaptor_hash = NULL;
/*******************************************************************************
Helper functions
@@ -115,141 +118,143 @@ static GHashTable *adaptor_hash = NULL;
This function will not override weight if it is already set (weight >= 0.0)
*/
static void
-gwa_properties_set_weight (GList **properties, GType parent)
-{
- gint normal = 0, common = 0, packing = 0;
- GList *l;
-
- for (l = *properties; l && l->data; l = g_list_next (l))
- {
- GladePropertyClass *klass = l->data;
-
- if (klass->visible &&
- (parent) ? parent == klass->pspec->owner_type : TRUE &&
- !klass->atk)
- {
- /* Use a different counter for each tab (common, packing and normal) */
- if (klass->common) common++;
- else if (klass->packing) packing++;
- else normal++;
-
- /* Skip if it is already set */
- if (klass->weight >= 0.0) continue;
-
- /* Special-casing weight of properties for seperate tabs */
- if (klass->common) klass->weight = common;
- else if (klass->packing) klass->weight = packing;
- else klass->weight = normal;
- }
- }
+gwa_properties_set_weight (GList ** properties, GType parent)
+{
+ gint normal = 0, common = 0, packing = 0;
+ GList *l;
+
+ for (l = *properties; l && l->data; l = g_list_next (l))
+ {
+ GladePropertyClass *klass = l->data;
+
+ if (klass->visible &&
+ (parent) ? parent == klass->pspec->owner_type : TRUE && !klass->atk)
+ {
+ /* Use a different counter for each tab (common, packing and normal) */
+ if (klass->common)
+ common++;
+ else if (klass->packing)
+ packing++;
+ else
+ normal++;
+
+ /* Skip if it is already set */
+ if (klass->weight >= 0.0)
+ continue;
+
+ /* Special-casing weight of properties for seperate tabs */
+ if (klass->common)
+ klass->weight = common;
+ else if (klass->packing)
+ klass->weight = packing;
+ else
+ klass->weight = normal;
+ }
+ }
}
static void
-gwa_create_cursor (GladeWidgetAdaptor *adaptor)
+gwa_create_cursor (GladeWidgetAdaptor * adaptor)
{
- GdkPixbuf *tmp_pixbuf, *widget_pixbuf;
- const GdkPixbuf *add_pixbuf;
- GdkDisplay *display;
- GError *error = NULL;
+ GdkPixbuf *tmp_pixbuf, *widget_pixbuf;
+ const GdkPixbuf *add_pixbuf;
+ GdkDisplay *display;
+ GError *error = NULL;
+
+ /* only certain widget classes need to have cursors */
+ if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) == FALSE ||
+ G_TYPE_IS_ABSTRACT (adaptor->type) != FALSE ||
+ adaptor->generic_name == NULL)
+ return;
- /* only certain widget classes need to have cursors */
- if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) == FALSE ||
- G_TYPE_IS_ABSTRACT (adaptor->type) != FALSE ||
- adaptor->generic_name == NULL)
- return;
+ /* cannot continue if 'add widget' cursor pixbuf has not been loaded for any reason */
+ if ((add_pixbuf = glade_cursor_get_add_widget_pixbuf ()) == NULL)
+ return;
- /* cannot continue if 'add widget' cursor pixbuf has not been loaded for any reason */
- if ((add_pixbuf = glade_cursor_get_add_widget_pixbuf ()) == NULL)
- return;
+ display = gdk_display_get_default ();
- display = gdk_display_get_default ();
+ /* create a temporary pixbuf clear to transparent black */
+ tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 32, 32);
+ gdk_pixbuf_fill (tmp_pixbuf, 0x00000000);
- /* create a temporary pixbuf clear to transparent black*/
- tmp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 32, 32);
- gdk_pixbuf_fill (tmp_pixbuf, 0x00000000);
+ if (gtk_icon_theme_has_icon
+ (gtk_icon_theme_get_default (), adaptor->icon_name))
+ {
+ widget_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ adaptor->icon_name,
+ 22, 0, &error);
+
+ if (error)
+ {
+ g_warning ("Could not load image data for named icon '%s': %s",
+ adaptor->icon_name, error->message);
+ g_error_free (error);
+ return;
+ }
- if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), adaptor->icon_name))
- {
- widget_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- adaptor->icon_name,
- 22,
- 0,
- &error);
-
- if (error) {
- g_warning ("Could not load image data for named icon '%s': %s",
- adaptor->icon_name,
- error->message);
- g_error_free (error);
- return;
- }
-
- } else {
- return;
- }
+ }
+ else
+ {
+ return;
+ }
- /* composite pixbufs */
- gdk_pixbuf_composite (widget_pixbuf, tmp_pixbuf,
- 8, 8, 22, 22,
- 8, 8, 1, 1,
- GDK_INTERP_NEAREST, 255);
+ /* composite pixbufs */
+ gdk_pixbuf_composite (widget_pixbuf, tmp_pixbuf,
+ 8, 8, 22, 22, 8, 8, 1, 1, GDK_INTERP_NEAREST, 255);
- gdk_pixbuf_composite (add_pixbuf, tmp_pixbuf,
- 0, 0, 12, 12,
- 0, 0, 1, 1,
- GDK_INTERP_NEAREST, 255);
+ gdk_pixbuf_composite (add_pixbuf, tmp_pixbuf,
+ 0, 0, 12, 12, 0, 0, 1, 1, GDK_INTERP_NEAREST, 255);
- adaptor->priv->cursor = gdk_cursor_new_from_pixbuf (display, tmp_pixbuf, 6, 6);
+ adaptor->priv->cursor =
+ gdk_cursor_new_from_pixbuf (display, tmp_pixbuf, 6, 6);
- g_object_unref (tmp_pixbuf);
- g_object_unref (widget_pixbuf);
+ g_object_unref (tmp_pixbuf);
+ g_object_unref (widget_pixbuf);
}
static gboolean
-gwa_gtype_equal (gconstpointer v1,
- gconstpointer v2)
+gwa_gtype_equal (gconstpointer v1, gconstpointer v2)
{
- return *((const GType*) v1) == *((const GType*) v2);
+ return *((const GType *) v1) == *((const GType *) v2);
}
static guint
gwa_gtype_hash (gconstpointer v)
{
- return *(const GType*) v;
+ return *(const GType *) v;
}
static gboolean
-glade_widget_adaptor_hash_find (gpointer key, gpointer value, gpointer user_data)
+glade_widget_adaptor_hash_find (gpointer key, gpointer value,
+ gpointer user_data)
{
- GladeWidgetAdaptor *adaptor = value;
- GType *type = user_data;
-
- if (g_type_is_a (adaptor->type, *type))
- {
- *type = adaptor->type;
- return TRUE;
- }
-
- return FALSE;
+ GladeWidgetAdaptor *adaptor = value;
+ GType *type = user_data;
+
+ if (g_type_is_a (adaptor->type, *type))
+ {
+ *type = adaptor->type;
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
glade_abort_if_derived_adaptors_exist (GType type)
{
- if (adaptor_hash)
- {
- GType retval = type;
-
- g_hash_table_find (adaptor_hash,
- glade_widget_adaptor_hash_find,
- &retval);
- if (retval != type)
- g_error (_("A derived adaptor (%s) of %s already exist!"),
- g_type_name (retval), g_type_name (type));
- }
+ if (adaptor_hash)
+ {
+ GType retval = type;
+
+ g_hash_table_find (adaptor_hash, glade_widget_adaptor_hash_find, &retval);
+ if (retval != type)
+ g_error (_("A derived adaptor (%s) of %s already exist!"),
+ g_type_name (retval), g_type_name (type));
+ }
}
/*******************************************************************************
@@ -260,909 +265,926 @@ glade_abort_if_derived_adaptors_exist (GType type)
static GladeWidgetAdaptor *
glade_widget_adaptor_get_parent_adaptor_by_type (GType adaptor_type)
{
- GladeWidgetAdaptor *parent_adaptor = NULL;
- GType iter_type;
+ GladeWidgetAdaptor *parent_adaptor = NULL;
+ GType iter_type;
- for (iter_type = g_type_parent (adaptor_type);
- iter_type > 0;
- iter_type = g_type_parent (iter_type))
- {
- if ((parent_adaptor =
- glade_widget_adaptor_get_by_type (iter_type)) != NULL)
- return parent_adaptor;
- }
+ for (iter_type = g_type_parent (adaptor_type);
+ iter_type > 0; iter_type = g_type_parent (iter_type))
+ {
+ if ((parent_adaptor =
+ glade_widget_adaptor_get_by_type (iter_type)) != NULL)
+ return parent_adaptor;
+ }
- return NULL;
+ return NULL;
}
/* XXX DOCME
*/
GladeWidgetAdaptor *
-glade_widget_adaptor_get_parent_adaptor (GladeWidgetAdaptor *adaptor)
+glade_widget_adaptor_get_parent_adaptor (GladeWidgetAdaptor * adaptor)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- return glade_widget_adaptor_get_parent_adaptor_by_type (adaptor->type);
+ return glade_widget_adaptor_get_parent_adaptor_by_type (adaptor->type);
}
static gint
gwa_signal_comp (gconstpointer a, gconstpointer b)
{
- const GladeSignalClass *signal_a = a, *signal_b = b;
- return strcmp (signal_b->query.signal_name, signal_a->query.signal_name);
+ const GladeSignalClass *signal_a = a, *signal_b = b;
+ return strcmp (signal_b->query.signal_name, signal_a->query.signal_name);
}
static gint
gwa_signal_find_comp (gconstpointer a, gconstpointer b)
{
- const GladeSignalClass *signal = a;
- const gchar *name = b;
- return strcmp (name, signal->query.signal_name);
+ const GladeSignalClass *signal = a;
+ const gchar *name = b;
+ return strcmp (name, signal->query.signal_name);
}
static void
-gwa_add_signals (GladeWidgetAdaptor *adaptor, GList **signals, GType type)
-{
- guint count, *sig_ids, num_signals;
- GladeWidgetAdaptor *type_adaptor;
- GladeSignalClass *cur;
- GList *list = NULL;
-
- type_adaptor = glade_widget_adaptor_get_by_type (type);
-
- if (G_TYPE_IS_INSTANTIATABLE (type) || G_TYPE_IS_INTERFACE (type))
- {
- sig_ids = g_signal_list_ids (type, &num_signals);
-
- for (count = 0; count < num_signals; count++)
- {
- cur = g_new0 (GladeSignalClass, 1);
-
- g_signal_query (sig_ids[count], &(cur->query));
-
- /* Since glib gave us this signal id... it should
- * exist no matter what.
- */
- g_assert (cur->query.signal_id != 0);
-
- /* When creating this type, this type is not registered yet,
- * but we still get the right value here.
- */
- cur->adaptor = type_adaptor ? type_adaptor : adaptor;
- cur->name = (cur->query.signal_name);
- cur->type = (gchar *) g_type_name (type);
-
- /* Initialize signal versions to adaptor version */
- cur->version_since_major = GWA_VERSION_SINCE_MAJOR (cur->adaptor);
- cur->version_since_minor = GWA_VERSION_SINCE_MINOR (cur->adaptor);
-
- list = g_list_prepend (list, cur);
- }
- g_free (sig_ids);
-
- list = g_list_sort (list, gwa_signal_comp);
- *signals = g_list_concat (list, *signals);
- }
-}
-
-static GList *
-gwa_list_signals (GladeWidgetAdaptor *adaptor, GType real_type)
-{
- GList *signals = NULL;
- GType type, parent, *i, *p;
-
- g_return_val_if_fail (real_type != 0, NULL);
-
- for (type = real_type; g_type_is_a (type, G_TYPE_OBJECT); type = parent)
- {
- parent = g_type_parent (type);
-
- /* Add class signals */
- gwa_add_signals (adaptor, &signals, type);
-
- /* Add class interfaces signals */
- for (i = p = g_type_interfaces (type, NULL); *i; i++)
- if (!glade_util_class_implements_interface (parent, *i))
- gwa_add_signals (adaptor, &signals, *i);
-
- g_free (p);
- }
-
- return g_list_reverse (signals);
-}
-
-static GList *
-gwa_clone_parent_properties (GladeWidgetAdaptor *adaptor, gboolean is_packing)
-{
- GladeWidgetAdaptor *parent_adaptor;
- GList *properties = NULL, *list, *proplist;
-
- if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL)
- {
- proplist = is_packing ?
- parent_adaptor->packing_props :
- parent_adaptor->properties;
-
- for (list = proplist; list; list = list->next)
- {
- GladePropertyClass *pclass =
- glade_property_class_clone (list->data);
- pclass->handle = adaptor;
-
- /* Reset versioning in derived catalogs just once */
- if (strcmp (adaptor->priv->catalog,
- parent_adaptor->priv->catalog))
- {
- pclass->version_since_major = 0;
- pclass->version_since_minor = 0;
- }
- properties = g_list_prepend (properties, pclass);
- }
- }
-
- return g_list_reverse (properties);
+gwa_add_signals (GladeWidgetAdaptor * adaptor, GList ** signals, GType type)
+{
+ guint count, *sig_ids, num_signals;
+ GladeWidgetAdaptor *type_adaptor;
+ GladeSignalClass *cur;
+ GList *list = NULL;
+
+ type_adaptor = glade_widget_adaptor_get_by_type (type);
+
+ if (G_TYPE_IS_INSTANTIATABLE (type) || G_TYPE_IS_INTERFACE (type))
+ {
+ sig_ids = g_signal_list_ids (type, &num_signals);
+
+ for (count = 0; count < num_signals; count++)
+ {
+ cur = g_new0 (GladeSignalClass, 1);
+
+ g_signal_query (sig_ids[count], &(cur->query));
+
+ /* Since glib gave us this signal id... it should
+ * exist no matter what.
+ */
+ g_assert (cur->query.signal_id != 0);
+
+ /* When creating this type, this type is not registered yet,
+ * but we still get the right value here.
+ */
+ cur->adaptor = type_adaptor ? type_adaptor : adaptor;
+ cur->name = (cur->query.signal_name);
+ cur->type = (gchar *) g_type_name (type);
+
+ /* Initialize signal versions to adaptor version */
+ cur->version_since_major = GWA_VERSION_SINCE_MAJOR (cur->adaptor);
+ cur->version_since_minor = GWA_VERSION_SINCE_MINOR (cur->adaptor);
+
+ list = g_list_prepend (list, cur);
+ }
+ g_free (sig_ids);
+
+ list = g_list_sort (list, gwa_signal_comp);
+ *signals = g_list_concat (list, *signals);
+ }
+}
+
+static GList *
+gwa_list_signals (GladeWidgetAdaptor * adaptor, GType real_type)
+{
+ GList *signals = NULL;
+ GType type, parent, *i, *p;
+
+ g_return_val_if_fail (real_type != 0, NULL);
+
+ for (type = real_type; g_type_is_a (type, G_TYPE_OBJECT); type = parent)
+ {
+ parent = g_type_parent (type);
+
+ /* Add class signals */
+ gwa_add_signals (adaptor, &signals, type);
+
+ /* Add class interfaces signals */
+ for (i = p = g_type_interfaces (type, NULL); *i; i++)
+ if (!glade_util_class_implements_interface (parent, *i))
+ gwa_add_signals (adaptor, &signals, *i);
+
+ g_free (p);
+ }
+
+ return g_list_reverse (signals);
+}
+
+static GList *
+gwa_clone_parent_properties (GladeWidgetAdaptor * adaptor, gboolean is_packing)
+{
+ GladeWidgetAdaptor *parent_adaptor;
+ GList *properties = NULL, *list, *proplist;
+
+ if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL)
+ {
+ proplist = is_packing ?
+ parent_adaptor->packing_props : parent_adaptor->properties;
+
+ for (list = proplist; list; list = list->next)
+ {
+ GladePropertyClass *pclass = glade_property_class_clone (list->data);
+ pclass->handle = adaptor;
+
+ /* Reset versioning in derived catalogs just once */
+ if (strcmp (adaptor->priv->catalog, parent_adaptor->priv->catalog))
+ {
+ pclass->version_since_major = 0;
+ pclass->version_since_minor = 0;
+ }
+ properties = g_list_prepend (properties, pclass);
+ }
+ }
+
+ return g_list_reverse (properties);
}
static void
-gwa_setup_introspected_props_from_pspecs (GladeWidgetAdaptor *adaptor,
- GParamSpec **specs,
- gint n_specs,
- gboolean is_packing)
-{
- GladeWidgetAdaptor *parent_adaptor = gwa_get_parent_adaptor (adaptor);
- GladePropertyClass *property_class;
- gint i;
- GList *list = NULL;
-
- for (i = 0; i < n_specs; i++)
- {
- if (parent_adaptor == NULL ||
- /* Dont create it if it already exists */
- (!is_packing && !glade_widget_adaptor_get_property_class (parent_adaptor,
- specs[i]->name)) ||
- (is_packing && !glade_widget_adaptor_get_pack_property_class (parent_adaptor,
- specs[i]->name)))
- {
- if ((property_class =
- glade_property_class_new_from_spec (adaptor, specs[i])) != NULL)
- list = g_list_prepend (list, property_class);
- }
- }
-
- if (is_packing)
- adaptor->packing_props =
- g_list_concat (adaptor->packing_props,
- g_list_reverse (list));
- else
- adaptor->properties =
- g_list_concat (adaptor->properties,
- g_list_reverse (list));
+gwa_setup_introspected_props_from_pspecs (GladeWidgetAdaptor * adaptor,
+ GParamSpec ** specs,
+ gint n_specs, gboolean is_packing)
+{
+ GladeWidgetAdaptor *parent_adaptor = gwa_get_parent_adaptor (adaptor);
+ GladePropertyClass *property_class;
+ gint i;
+ GList *list = NULL;
+
+ for (i = 0; i < n_specs; i++)
+ {
+ if (parent_adaptor == NULL ||
+ /* Dont create it if it already exists */
+ (!is_packing &&
+ !glade_widget_adaptor_get_property_class (parent_adaptor,
+ specs[i]->name)) ||
+ (is_packing &&
+ !glade_widget_adaptor_get_pack_property_class (parent_adaptor,
+ specs[i]->name)))
+ {
+ if ((property_class =
+ glade_property_class_new_from_spec (adaptor, specs[i])) != NULL)
+ list = g_list_prepend (list, property_class);
+ }
+ }
+
+ if (is_packing)
+ adaptor->packing_props =
+ g_list_concat (adaptor->packing_props, g_list_reverse (list));
+ else
+ adaptor->properties =
+ g_list_concat (adaptor->properties, g_list_reverse (list));
}
static void
-gwa_setup_properties (GladeWidgetAdaptor *adaptor,
- GObjectClass *object_class,
- gboolean is_packing)
-{
- GParamSpec **specs = NULL;
- guint n_specs = 0;
- GList *l;
-
- /* only GtkContainer child propeties can be introspected */
- if (is_packing && !g_type_is_a (adaptor->type, GTK_TYPE_CONTAINER))
- return;
-
- /* First clone the parents properties */
- if (is_packing)
- adaptor->packing_props = gwa_clone_parent_properties (adaptor, is_packing);
- else
- adaptor->properties = gwa_clone_parent_properties (adaptor, is_packing);
-
- /* Now automaticly introspect new properties added in this class,
- * allow the class writer to decide what to override in the resulting
- * list of properties.
- */
- if (is_packing)
- specs = gtk_container_class_list_child_properties (object_class, &n_specs);
- else
- specs = g_object_class_list_properties (object_class, &n_specs);
- gwa_setup_introspected_props_from_pspecs (adaptor, specs, n_specs, is_packing);
- g_free (specs);
-
- if (is_packing)
- {
- /* We have to mark packing properties from GladeWidgetAdaptor
- * because GladePropertyClass doesnt have a valid parent GType
- * to introspect it.
- *
- * (which could be used to call gtk_container_class_find_child_property()
- * and properly introspect whether or not its a packing property).
- */
- for (l = adaptor->packing_props; l; l = l->next)
- {
- GladePropertyClass *property_class = l->data;
- property_class->packing = TRUE;
- }
- }
+gwa_setup_properties (GladeWidgetAdaptor * adaptor,
+ GObjectClass * object_class, gboolean is_packing)
+{
+ GParamSpec **specs = NULL;
+ guint n_specs = 0;
+ GList *l;
+
+ /* only GtkContainer child propeties can be introspected */
+ if (is_packing && !g_type_is_a (adaptor->type, GTK_TYPE_CONTAINER))
+ return;
+
+ /* First clone the parents properties */
+ if (is_packing)
+ adaptor->packing_props = gwa_clone_parent_properties (adaptor, is_packing);
+ else
+ adaptor->properties = gwa_clone_parent_properties (adaptor, is_packing);
+
+ /* Now automaticly introspect new properties added in this class,
+ * allow the class writer to decide what to override in the resulting
+ * list of properties.
+ */
+ if (is_packing)
+ specs = gtk_container_class_list_child_properties (object_class, &n_specs);
+ else
+ specs = g_object_class_list_properties (object_class, &n_specs);
+ gwa_setup_introspected_props_from_pspecs (adaptor, specs, n_specs,
+ is_packing);
+ g_free (specs);
+
+ if (is_packing)
+ {
+ /* We have to mark packing properties from GladeWidgetAdaptor
+ * because GladePropertyClass doesnt have a valid parent GType
+ * to introspect it.
+ *
+ * (which could be used to call gtk_container_class_find_child_property()
+ * and properly introspect whether or not its a packing property).
+ */
+ for (l = adaptor->packing_props; l; l = l->next)
+ {
+ GladePropertyClass *property_class = l->data;
+ property_class->packing = TRUE;
+ }
+ }
}
static GList *
-gwa_inherit_child_packing (GladeWidgetAdaptor *adaptor)
+gwa_inherit_child_packing (GladeWidgetAdaptor * adaptor)
{
- GladeWidgetAdaptor *parent_adaptor;
- GList *child_packings = NULL, *packing_list, *default_list;
+ GladeWidgetAdaptor *parent_adaptor;
+ GList *child_packings = NULL, *packing_list, *default_list;
- if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL)
- {
- for (packing_list = parent_adaptor->child_packings;
- packing_list; packing_list = packing_list->next)
- {
- GladeChildPacking *packing = packing_list->data;
- GladeChildPacking *packing_dup = g_new0 (GladeChildPacking, 1);
+ if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL)
+ {
+ for (packing_list = parent_adaptor->child_packings;
+ packing_list; packing_list = packing_list->next)
+ {
+ GladeChildPacking *packing = packing_list->data;
+ GladeChildPacking *packing_dup = g_new0 (GladeChildPacking, 1);
- packing_dup->parent_name = g_strdup (packing->parent_name);
+ packing_dup->parent_name = g_strdup (packing->parent_name);
- for (default_list = packing->packing_defaults;
- default_list; default_list = default_list->next)
- {
- GladePackingDefault *def = default_list->data;
- GladePackingDefault *def_dup = g_new0 (GladePackingDefault, 1);
+ for (default_list = packing->packing_defaults;
+ default_list; default_list = default_list->next)
+ {
+ GladePackingDefault *def = default_list->data;
+ GladePackingDefault *def_dup = g_new0 (GladePackingDefault, 1);
- def_dup->id = g_strdup (def->id);
- def_dup->value = g_strdup (def->value);
+ def_dup->id = g_strdup (def->id);
+ def_dup->value = g_strdup (def->value);
- packing_dup->packing_defaults =
- g_list_prepend (packing_dup->packing_defaults, def_dup);
- }
+ packing_dup->packing_defaults =
+ g_list_prepend (packing_dup->packing_defaults, def_dup);
+ }
- child_packings = g_list_prepend (child_packings, packing_dup);
- }
- }
- return child_packings;
+ child_packings = g_list_prepend (child_packings, packing_dup);
+ }
+ }
+ return child_packings;
}
static void
-gwa_inherit_signals (GladeWidgetAdaptor *adaptor)
-{
- GladeWidgetAdaptor *parent_adaptor;
- GList *list, *node;
- GladeSignalClass *signal, *parent_signal;
-
- if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL)
- {
- for (list = adaptor->signals; list; list = list->next)
- {
- signal = list->data;
-
- if ((node = g_list_find_custom
- (parent_adaptor->signals, signal->name,
- (GCompareFunc)gwa_signal_find_comp)) != NULL)
- {
- parent_signal = node->data;
-
- /* Reset versioning in derived catalogs just once */
- if (strcmp (adaptor->priv->catalog,
- parent_adaptor->priv->catalog))
- signal->version_since_major = 0;
- else
- {
- signal->version_since_major =
- parent_signal->version_since_major;
- signal->version_since_minor =
- parent_signal->version_since_minor;
- }
- }
- }
- }
+gwa_inherit_signals (GladeWidgetAdaptor * adaptor)
+{
+ GladeWidgetAdaptor *parent_adaptor;
+ GList *list, *node;
+ GladeSignalClass *signal, *parent_signal;
+
+ if ((parent_adaptor = gwa_get_parent_adaptor (adaptor)) != NULL)
+ {
+ for (list = adaptor->signals; list; list = list->next)
+ {
+ signal = list->data;
+
+ if ((node = g_list_find_custom
+ (parent_adaptor->signals, signal->name,
+ (GCompareFunc) gwa_signal_find_comp)) != NULL)
+ {
+ parent_signal = node->data;
+
+ /* Reset versioning in derived catalogs just once */
+ if (strcmp (adaptor->priv->catalog,
+ parent_adaptor->priv->catalog))
+ signal->version_since_major = 0;
+ else
+ {
+ signal->version_since_major =
+ parent_signal->version_since_major;
+ signal->version_since_minor =
+ parent_signal->version_since_minor;
+ }
+ }
+ }
+ }
}
static GObject *
-glade_widget_adaptor_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- GladeWidgetAdaptor *adaptor, *parent_adaptor;
- GObject *ret_obj;
- GObjectClass *object_class;
-
- glade_abort_if_derived_adaptors_exist (type);
-
- ret_obj = G_OBJECT_CLASS (parent_class)->constructor
- (type, n_construct_properties, construct_properties);
-
- adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
- parent_adaptor = gwa_get_parent_adaptor (adaptor);
-
- if (adaptor->type == G_TYPE_NONE)
- g_warning ("Adaptor created without a type");
- if (adaptor->name == NULL)
- g_warning ("Adaptor created without a name");
-
- /* Build decorations */
- if (!adaptor->icon_name) {
- adaptor->icon_name = g_strdup ("gtk-missing-image");
- }
- gwa_create_cursor (adaptor);
-
- /* Let it leek */
- if ((object_class = g_type_class_ref (adaptor->type)))
- {
- /* Build signals & properties */
- adaptor->signals = gwa_list_signals (adaptor, adaptor->type);
-
- gwa_inherit_signals (adaptor);
- gwa_setup_properties (adaptor, object_class, FALSE);
- gwa_setup_properties (adaptor, object_class, TRUE);
- }
-
- /* Inherit packing defaults here */
- adaptor->child_packings = gwa_inherit_child_packing (adaptor);
-
- /* Inherit special-child-type */
- if (parent_adaptor)
- adaptor->priv->special_child_type =
- parent_adaptor->priv->special_child_type ?
- g_strdup (parent_adaptor->priv->special_child_type) : NULL;
-
-
- /* Reset version numbering if we're in a new catalog just once */
- if (parent_adaptor &&
- strcmp (adaptor->priv->catalog, parent_adaptor->priv->catalog))
- {
- GLADE_WIDGET_ADAPTOR_GET_CLASS(adaptor)->version_since_major =
- GLADE_WIDGET_ADAPTOR_GET_CLASS(adaptor)->version_since_minor = 0;
- }
-
- /* Copy parent actions */
- if (parent_adaptor)
- {
- GList *l;
-
- if (parent_adaptor->actions)
- {
- for (l = parent_adaptor->actions; l; l = g_list_next (l))
- {
- GWActionClass *child = glade_widget_action_class_clone (l->data);
- adaptor->actions = g_list_prepend (adaptor->actions, child);
- }
- adaptor->actions = g_list_reverse (adaptor->actions);
- }
-
- if (parent_adaptor->packing_actions)
- {
- for (l = parent_adaptor->packing_actions; l; l = g_list_next (l))
- {
- GWActionClass *child = glade_widget_action_class_clone (l->data);
- adaptor->packing_actions = g_list_prepend (adaptor->packing_actions, child);
- }
- adaptor->packing_actions = g_list_reverse (adaptor->packing_actions);
- }
- }
-
- return ret_obj;
+glade_widget_adaptor_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
+{
+ GladeWidgetAdaptor *adaptor, *parent_adaptor;
+ GObject *ret_obj;
+ GObjectClass *object_class;
+
+ glade_abort_if_derived_adaptors_exist (type);
+
+ ret_obj = G_OBJECT_CLASS (parent_class)->constructor
+ (type, n_construct_properties, construct_properties);
+
+ adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
+ parent_adaptor = gwa_get_parent_adaptor (adaptor);
+
+ if (adaptor->type == G_TYPE_NONE)
+ g_warning ("Adaptor created without a type");
+ if (adaptor->name == NULL)
+ g_warning ("Adaptor created without a name");
+
+ /* Build decorations */
+ if (!adaptor->icon_name)
+ {
+ adaptor->icon_name = g_strdup ("gtk-missing-image");
+ }
+ gwa_create_cursor (adaptor);
+
+ /* Let it leek */
+ if ((object_class = g_type_class_ref (adaptor->type)))
+ {
+ /* Build signals & properties */
+ adaptor->signals = gwa_list_signals (adaptor, adaptor->type);
+
+ gwa_inherit_signals (adaptor);
+ gwa_setup_properties (adaptor, object_class, FALSE);
+ gwa_setup_properties (adaptor, object_class, TRUE);
+ }
+
+ /* Inherit packing defaults here */
+ adaptor->child_packings = gwa_inherit_child_packing (adaptor);
+
+ /* Inherit special-child-type */
+ if (parent_adaptor)
+ adaptor->priv->special_child_type =
+ parent_adaptor->priv->special_child_type ?
+ g_strdup (parent_adaptor->priv->special_child_type) : NULL;
+
+
+ /* Reset version numbering if we're in a new catalog just once */
+ if (parent_adaptor &&
+ strcmp (adaptor->priv->catalog, parent_adaptor->priv->catalog))
+ {
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->version_since_major =
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->version_since_minor = 0;
+ }
+
+ /* Copy parent actions */
+ if (parent_adaptor)
+ {
+ GList *l;
+
+ if (parent_adaptor->actions)
+ {
+ for (l = parent_adaptor->actions; l; l = g_list_next (l))
+ {
+ GWActionClass *child = glade_widget_action_class_clone (l->data);
+ adaptor->actions = g_list_prepend (adaptor->actions, child);
+ }
+ adaptor->actions = g_list_reverse (adaptor->actions);
+ }
+
+ if (parent_adaptor->packing_actions)
+ {
+ for (l = parent_adaptor->packing_actions; l; l = g_list_next (l))
+ {
+ GWActionClass *child = glade_widget_action_class_clone (l->data);
+ adaptor->packing_actions =
+ g_list_prepend (adaptor->packing_actions, child);
+ }
+ adaptor->packing_actions = g_list_reverse (adaptor->packing_actions);
+ }
+ }
+
+ return ret_obj;
}
static void
-gwa_packing_default_free (GladePackingDefault *def)
+gwa_packing_default_free (GladePackingDefault * def)
{
- g_free (def->id);
- g_free (def->value);
+ g_free (def->id);
+ g_free (def->value);
}
static void
-gwa_child_packing_free (GladeChildPacking *packing)
+gwa_child_packing_free (GladeChildPacking * packing)
{
- g_free (packing->parent_name);
+ g_free (packing->parent_name);
- g_list_foreach (packing->packing_defaults,
- (GFunc) gwa_packing_default_free, NULL);
- g_list_free (packing->packing_defaults);
+ g_list_foreach (packing->packing_defaults,
+ (GFunc) gwa_packing_default_free, NULL);
+ g_list_free (packing->packing_defaults);
}
static void
-glade_widget_adaptor_finalize (GObject *object)
-{
- GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (object);
-
- /* Free properties and signals */
- g_list_foreach (adaptor->properties, (GFunc) glade_property_class_free, NULL);
- g_list_free (adaptor->properties);
-
- g_list_foreach (adaptor->packing_props, (GFunc) glade_property_class_free, NULL);
- g_list_free (adaptor->packing_props);
-
- /* Be careful, this list holds GladeSignalClass* not GladeSignal,
- * thus g_free is enough as all members are const */
- g_list_foreach (adaptor->signals, (GFunc) g_free, NULL);
- g_list_free (adaptor->signals);
-
-
- /* Free child packings */
- g_list_foreach (adaptor->child_packings,
- (GFunc) gwa_child_packing_free,
- NULL);
- g_list_free (adaptor->child_packings);
-
- if (adaptor->priv->book) g_free (adaptor->priv->book);
- if (adaptor->priv->catalog) g_free (adaptor->priv->catalog);
- if (adaptor->priv->special_child_type)
- g_free (adaptor->priv->special_child_type);
-
- if (adaptor->priv->cursor != NULL)
- gdk_cursor_unref (adaptor->priv->cursor);
-
- if (adaptor->name) g_free (adaptor->name);
- if (adaptor->generic_name) g_free (adaptor->generic_name);
- if (adaptor->title) g_free (adaptor->title);
- if (adaptor->icon_name) g_free (adaptor->icon_name);
- if (adaptor->missing_icon) g_free (adaptor->missing_icon);
-
- if (adaptor->actions)
- {
- g_list_foreach (adaptor->actions,
- (GFunc) glade_widget_action_class_free,
- NULL);
- g_list_free (adaptor->actions);
- }
-
- if (adaptor->packing_actions)
- {
- g_list_foreach (adaptor->packing_actions,
- (GFunc) glade_widget_action_class_free,
- NULL);
- g_list_free (adaptor->packing_actions);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+glade_widget_adaptor_finalize (GObject * object)
+{
+ GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (object);
+
+ /* Free properties and signals */
+ g_list_foreach (adaptor->properties, (GFunc) glade_property_class_free, NULL);
+ g_list_free (adaptor->properties);
+
+ g_list_foreach (adaptor->packing_props, (GFunc) glade_property_class_free,
+ NULL);
+ g_list_free (adaptor->packing_props);
+
+ /* Be careful, this list holds GladeSignalClass* not GladeSignal,
+ * thus g_free is enough as all members are const */
+ g_list_foreach (adaptor->signals, (GFunc) g_free, NULL);
+ g_list_free (adaptor->signals);
+
+
+ /* Free child packings */
+ g_list_foreach (adaptor->child_packings,
+ (GFunc) gwa_child_packing_free, NULL);
+ g_list_free (adaptor->child_packings);
+
+ if (adaptor->priv->book)
+ g_free (adaptor->priv->book);
+ if (adaptor->priv->catalog)
+ g_free (adaptor->priv->catalog);
+ if (adaptor->priv->special_child_type)
+ g_free (adaptor->priv->special_child_type);
+
+ if (adaptor->priv->cursor != NULL)
+ gdk_cursor_unref (adaptor->priv->cursor);
+
+ if (adaptor->name)
+ g_free (adaptor->name);
+ if (adaptor->generic_name)
+ g_free (adaptor->generic_name);
+ if (adaptor->title)
+ g_free (adaptor->title);
+ if (adaptor->icon_name)
+ g_free (adaptor->icon_name);
+ if (adaptor->missing_icon)
+ g_free (adaptor->missing_icon);
+
+ if (adaptor->actions)
+ {
+ g_list_foreach (adaptor->actions,
+ (GFunc) glade_widget_action_class_free, NULL);
+ g_list_free (adaptor->actions);
+ }
+
+ if (adaptor->packing_actions)
+ {
+ g_list_foreach (adaptor->packing_actions,
+ (GFunc) glade_widget_action_class_free, NULL);
+ g_list_free (adaptor->packing_actions);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-glade_widget_adaptor_real_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GladeWidgetAdaptor *adaptor;
-
- adaptor = GLADE_WIDGET_ADAPTOR (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- /* assume once (construct-only) */
- adaptor->name = g_value_dup_string (value);
- adaptor->real_type = g_type_from_name (adaptor->name);
- break;
- case PROP_ICON_NAME:
- /* assume once (construct-only) */
- adaptor->icon_name = g_value_dup_string (value);
- break;
- case PROP_TYPE:
- adaptor->type = g_value_get_gtype (value);
- break;
- case PROP_TITLE:
- if (adaptor->title) g_free (adaptor->title);
- adaptor->title = g_value_dup_string (value);
- break;
- case PROP_GENERIC_NAME:
- if (adaptor->generic_name) g_free (adaptor->generic_name);
- adaptor->generic_name = g_value_dup_string (value);
- break;
- case PROP_CATALOG:
- /* assume once (construct-only) */
- adaptor->priv->catalog = g_value_dup_string (value);
- break;
- case PROP_BOOK:
- /* assume once (construct-only) */
- adaptor->priv->book = g_value_dup_string (value);
- break;
- case PROP_SPECIAL_TYPE:
- /* assume once (construct-only) */
- adaptor->priv->special_child_type = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_widget_adaptor_real_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
+ GladeWidgetAdaptor *adaptor;
+
+ adaptor = GLADE_WIDGET_ADAPTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ /* assume once (construct-only) */
+ adaptor->name = g_value_dup_string (value);
+ adaptor->real_type = g_type_from_name (adaptor->name);
+ break;
+ case PROP_ICON_NAME:
+ /* assume once (construct-only) */
+ adaptor->icon_name = g_value_dup_string (value);
+ break;
+ case PROP_TYPE:
+ adaptor->type = g_value_get_gtype (value);
+ break;
+ case PROP_TITLE:
+ if (adaptor->title)
+ g_free (adaptor->title);
+ adaptor->title = g_value_dup_string (value);
+ break;
+ case PROP_GENERIC_NAME:
+ if (adaptor->generic_name)
+ g_free (adaptor->generic_name);
+ adaptor->generic_name = g_value_dup_string (value);
+ break;
+ case PROP_CATALOG:
+ /* assume once (construct-only) */
+ adaptor->priv->catalog = g_value_dup_string (value);
+ break;
+ case PROP_BOOK:
+ /* assume once (construct-only) */
+ adaptor->priv->book = g_value_dup_string (value);
+ break;
+ case PROP_SPECIAL_TYPE:
+ /* assume once (construct-only) */
+ adaptor->priv->special_child_type = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_widget_adaptor_real_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
-
- GladeWidgetAdaptor *adaptor;
-
- adaptor = GLADE_WIDGET_ADAPTOR (object);
-
- switch (prop_id)
- {
- case PROP_NAME: g_value_set_string (value, adaptor->name); break;
- case PROP_TYPE: g_value_set_gtype (value, adaptor->type); break;
- case PROP_TITLE: g_value_set_string (value, adaptor->title); break;
- case PROP_GENERIC_NAME: g_value_set_string (value, adaptor->generic_name); break;
- case PROP_ICON_NAME: g_value_set_string (value, adaptor->icon_name); break;
- case PROP_CATALOG: g_value_set_string (value, adaptor->priv->catalog); break;
- case PROP_BOOK: g_value_set_string (value, adaptor->priv->book); break;
- case PROP_SPECIAL_TYPE:
- g_value_set_string (value, adaptor->priv->special_child_type);
- break;
- case PROP_CURSOR: g_value_set_pointer (value, adaptor->priv->cursor); break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_widget_adaptor_real_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+
+ GladeWidgetAdaptor *adaptor;
+
+ adaptor = GLADE_WIDGET_ADAPTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, adaptor->name);
+ break;
+ case PROP_TYPE:
+ g_value_set_gtype (value, adaptor->type);
+ break;
+ case PROP_TITLE:
+ g_value_set_string (value, adaptor->title);
+ break;
+ case PROP_GENERIC_NAME:
+ g_value_set_string (value, adaptor->generic_name);
+ break;
+ case PROP_ICON_NAME:
+ g_value_set_string (value, adaptor->icon_name);
+ break;
+ case PROP_CATALOG:
+ g_value_set_string (value, adaptor->priv->catalog);
+ break;
+ case PROP_BOOK:
+ g_value_set_string (value, adaptor->priv->book);
+ break;
+ case PROP_SPECIAL_TYPE:
+ g_value_set_string (value, adaptor->priv->special_child_type);
+ break;
+ case PROP_CURSOR:
+ g_value_set_pointer (value, adaptor->priv->cursor);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
/*******************************************************************************
GladeWidgetAdaptor base class implementations
*******************************************************************************/
static GladeWidget *
-glade_widget_adaptor_object_create_widget (GladeWidgetAdaptor *adaptor,
- const gchar *first_property_name,
- va_list var_args)
+glade_widget_adaptor_object_create_widget (GladeWidgetAdaptor * adaptor,
+ const gchar * first_property_name,
+ va_list var_args)
{
- return (GladeWidget *)g_object_new_valist (GLADE_TYPE_WIDGET, first_property_name, var_args);
+ return (GladeWidget *) g_object_new_valist (GLADE_TYPE_WIDGET,
+ first_property_name, var_args);
}
static GObject *
-glade_widget_adaptor_object_construct_object (GladeWidgetAdaptor *adaptor,
- guint n_parameters,
- GParameter *parameters)
+glade_widget_adaptor_object_construct_object (GladeWidgetAdaptor * adaptor,
+ guint n_parameters,
+ GParameter * parameters)
{
- return g_object_newv (adaptor->type, n_parameters, parameters);
+ return g_object_newv (adaptor->type, n_parameters, parameters);
}
static void
-glade_widget_adaptor_object_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_widget_adaptor_object_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- g_object_set_property (object, property_name, value);
+ g_object_set_property (object, property_name, value);
}
static void
-glade_widget_adaptor_object_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- GValue *value)
+glade_widget_adaptor_object_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ GValue * value)
{
- g_object_get_property (object, property_name, value);
+ g_object_get_property (object, property_name, value);
}
static void
-glade_widget_adaptor_object_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_id)
+glade_widget_adaptor_object_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_id)
{
- g_message ("No action_activate() support in adaptor %s for action '%s'",
- adaptor->name, action_id);
+ g_message ("No action_activate() support in adaptor %s for action '%s'",
+ adaptor->name, action_id);
}
static void
-glade_widget_adaptor_object_child_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *action_id)
+glade_widget_adaptor_object_child_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * action_id)
{
- g_message ("No child_action_activate() support in adaptor %s for action '%s'",
- adaptor->name, action_id);
+ g_message ("No child_action_activate() support in adaptor %s for action '%s'",
+ adaptor->name, action_id);
}
static gboolean
-glade_widget_adaptor_object_depends (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeWidget *another)
+glade_widget_adaptor_object_depends (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeWidget * another)
{
- return FALSE;
+ return FALSE;
}
static void
-glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *iter_node;
- GladeSignal *signal;
- GladeProperty *property;
- gchar *name, *prop_name;
- GList *read_properties = NULL, *l;
-
- /* Read in the properties */
- for (iter_node = glade_xml_node_get_children (node);
- iter_node; iter_node = glade_xml_node_next (iter_node))
- {
- if (!glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_PROPERTY))
- continue;
-
- /* Get prop name from node and lookup property ...*/
- if (!(name = glade_xml_get_property_string_required
- (iter_node, GLADE_XML_TAG_NAME, NULL)))
- continue;
-
- prop_name = glade_util_read_prop_name (name);
-
- /* Some properties may be special child type of custom, just leave them for the adaptor */
- if ((property = glade_widget_get_property (widget, prop_name)) != NULL)
- {
- glade_property_read (property, widget->project, iter_node);
- read_properties = g_list_prepend (read_properties, property);
- }
-
- g_free (prop_name);
- g_free (name);
- }
-
- /* Sync the remaining values not read in from the Glade file.. */
- for (l = widget->properties; l; l = l->next)
- {
- property = l->data;
-
- if (!g_list_find (read_properties, property))
- glade_property_sync (property);
- }
- g_list_free (read_properties);
-
- /* Read in the signals */
- for (iter_node = glade_xml_node_get_children (node);
- iter_node; iter_node = glade_xml_node_next (iter_node))
- {
- if (!glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_SIGNAL))
- continue;
-
- if (!(signal = glade_signal_read (iter_node)))
- continue;
-
- glade_widget_add_signal_handler (widget, signal);
- }
-
- /* Read in children */
- for (iter_node = glade_xml_node_get_children (node);
- iter_node; iter_node = glade_xml_node_next (iter_node))
- {
- if (glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_CHILD))
- glade_widget_read_child (widget, iter_node);
-
- if (glade_project_load_cancelled (widget->project))
- return;
- }
+glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *iter_node;
+ GladeSignal *signal;
+ GladeProperty *property;
+ gchar *name, *prop_name;
+ GList *read_properties = NULL, *l;
+
+ /* Read in the properties */
+ for (iter_node = glade_xml_node_get_children (node);
+ iter_node; iter_node = glade_xml_node_next (iter_node))
+ {
+ if (!glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_PROPERTY))
+ continue;
+
+ /* Get prop name from node and lookup property ... */
+ if (!(name = glade_xml_get_property_string_required
+ (iter_node, GLADE_XML_TAG_NAME, NULL)))
+ continue;
+
+ prop_name = glade_util_read_prop_name (name);
+
+ /* Some properties may be special child type of custom, just leave them for the adaptor */
+ if ((property = glade_widget_get_property (widget, prop_name)) != NULL)
+ {
+ glade_property_read (property, widget->project, iter_node);
+ read_properties = g_list_prepend (read_properties, property);
+ }
+
+ g_free (prop_name);
+ g_free (name);
+ }
+
+ /* Sync the remaining values not read in from the Glade file.. */
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
+
+ if (!g_list_find (read_properties, property))
+ glade_property_sync (property);
+ }
+ g_list_free (read_properties);
+
+ /* Read in the signals */
+ for (iter_node = glade_xml_node_get_children (node);
+ iter_node; iter_node = glade_xml_node_next (iter_node))
+ {
+ if (!glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_SIGNAL))
+ continue;
+
+ if (!(signal = glade_signal_read (iter_node)))
+ continue;
+
+ glade_widget_add_signal_handler (widget, signal);
+ }
+
+ /* Read in children */
+ for (iter_node = glade_xml_node_get_children (node);
+ iter_node; iter_node = glade_xml_node_next (iter_node))
+ {
+ if (glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_CHILD))
+ glade_widget_read_child (widget, iter_node);
+
+ if (glade_project_load_cancelled (widget->project))
+ return;
+ }
}
static void
-glade_widget_adaptor_object_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_widget_adaptor_object_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GList *props;
+ GList *props;
- /* Write the properties */
- for (props = widget->properties;
- props; props = props->next)
- {
- if (GLADE_PROPERTY (props->data)->klass->save &&
- GLADE_PROPERTY (props->data)->enabled)
- glade_property_write (GLADE_PROPERTY (props->data), context, node);
- }
+ /* Write the properties */
+ for (props = widget->properties; props; props = props->next)
+ {
+ if (GLADE_PROPERTY (props->data)->klass->save &&
+ GLADE_PROPERTY (props->data)->enabled)
+ glade_property_write (GLADE_PROPERTY (props->data), context, node);
+ }
}
static void
-glade_widget_adaptor_object_read_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *widget_node, *packing_node, *iter_node;
- GladeWidget *child_widget;
- gchar *internal_name;
- gchar *name, *prop_name;
- GladeProperty *property;
-
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
- return;
-
- internal_name =
- glade_xml_get_property_string
- (node, GLADE_XML_TAG_INTERNAL_CHILD);
-
- if ((widget_node =
- glade_xml_search_child (node, GLADE_XML_TAG_WIDGET)) != NULL)
- {
- child_widget =
- glade_widget_read (widget->project,
- widget,
- widget_node,
- internal_name);
-
- if (child_widget)
- {
- if (!internal_name) {
- glade_widget_set_child_type_from_node
- (widget, child_widget->object, node);
- glade_widget_add_child (widget, child_widget, FALSE);
- }
-
- if ((packing_node =
- glade_xml_search_child
- (node, GLADE_XML_TAG_PACKING)) != NULL)
- {
-
- /* Read in the properties */
- for (iter_node = glade_xml_node_get_children (packing_node);
- iter_node; iter_node = glade_xml_node_next (iter_node))
- {
- if (!glade_xml_node_verify_silent (iter_node, GLADE_XML_TAG_PROPERTY))
- continue;
-
- /* Get prop name from node and lookup property ...*/
- if (!(name = glade_xml_get_property_string_required
- (iter_node, GLADE_XML_TAG_NAME, NULL)))
- continue;
-
- prop_name = glade_util_read_prop_name (name);
-
- /* Some properties may be special child type of custom,
- * just leave them for the adaptor */
- if ((property = glade_widget_get_pack_property (child_widget, prop_name)) != NULL)
- glade_property_read (property, child_widget->project, iter_node);
-
- g_free (prop_name);
- g_free (name);
- }
- }
- }
-
- } else {
- GObject *palaceholder =
- G_OBJECT (glade_placeholder_new ());
- glade_widget_set_child_type_from_node (widget, palaceholder, node);
- glade_widget_adaptor_add (adaptor, widget->object, palaceholder);
-
- }
- g_free (internal_name);
+glade_widget_adaptor_object_read_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *widget_node, *packing_node, *iter_node;
+ GladeWidget *child_widget;
+ gchar *internal_name;
+ gchar *name, *prop_name;
+ GladeProperty *property;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
+ return;
+
+ internal_name =
+ glade_xml_get_property_string (node, GLADE_XML_TAG_INTERNAL_CHILD);
+
+ if ((widget_node =
+ glade_xml_search_child (node, GLADE_XML_TAG_WIDGET)) != NULL)
+ {
+ child_widget =
+ glade_widget_read (widget->project,
+ widget, widget_node, internal_name);
+
+ if (child_widget)
+ {
+ if (!internal_name)
+ {
+ glade_widget_set_child_type_from_node
+ (widget, child_widget->object, node);
+ glade_widget_add_child (widget, child_widget, FALSE);
+ }
+
+ if ((packing_node =
+ glade_xml_search_child (node, GLADE_XML_TAG_PACKING)) != NULL)
+ {
+
+ /* Read in the properties */
+ for (iter_node = glade_xml_node_get_children (packing_node);
+ iter_node; iter_node = glade_xml_node_next (iter_node))
+ {
+ if (!glade_xml_node_verify_silent
+ (iter_node, GLADE_XML_TAG_PROPERTY))
+ continue;
+
+ /* Get prop name from node and lookup property ... */
+ if (!(name = glade_xml_get_property_string_required
+ (iter_node, GLADE_XML_TAG_NAME, NULL)))
+ continue;
+
+ prop_name = glade_util_read_prop_name (name);
+
+ /* Some properties may be special child type of custom,
+ * just leave them for the adaptor */
+ if ((property =
+ glade_widget_get_pack_property (child_widget,
+ prop_name)) != NULL)
+ glade_property_read (property, child_widget->project,
+ iter_node);
+
+ g_free (prop_name);
+ g_free (name);
+ }
+ }
+ }
+
+ }
+ else
+ {
+ GObject *palaceholder = G_OBJECT (glade_placeholder_new ());
+ glade_widget_set_child_type_from_node (widget, palaceholder, node);
+ glade_widget_adaptor_add (adaptor, widget->object, palaceholder);
+
+ }
+ g_free (internal_name);
}
static void
-glade_widget_adaptor_object_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeXmlNode *child_node, *packing_node;
- GList *props;
-
- child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
- glade_xml_node_append_child (node, child_node);
-
- /* Set internal child */
- if (widget->internal)
- glade_xml_node_set_property_string (child_node,
- GLADE_XML_TAG_INTERNAL_CHILD,
- widget->internal);
-
- /* Write out the widget */
- glade_widget_write (widget, context, child_node);
-
- /* Write out packing properties and special-child-type */
- packing_node = glade_xml_node_new (context, GLADE_XML_TAG_PACKING);
- glade_xml_node_append_child (child_node, packing_node);
-
- for (props = widget->packing_properties;
- props; props = props->next)
- {
- if (GLADE_PROPERTY (props->data)->klass->save &&
- GLADE_PROPERTY (props->data)->enabled)
- glade_property_write (GLADE_PROPERTY (props->data),
- context, packing_node);
- }
-
- glade_widget_write_special_child_prop (widget->parent,
- widget->object,
- context, child_node);
-
- /* Default packing properties and such are not saved,
- * so lets check afterwords if there was anything saved
- * and then just remove the node.
- */
- if (!glade_xml_node_get_children (packing_node))
- {
- glade_xml_node_remove (packing_node);
- glade_xml_node_delete (packing_node);
- }
-}
-
-static GType
-glade_widget_adaptor_get_eprop_type (GParamSpec *pspec)
-{
- GType type = 0;
-
- if (G_IS_PARAM_SPEC_ENUM(pspec))
- type = GLADE_TYPE_EPROP_ENUM;
- else if (G_IS_PARAM_SPEC_FLAGS(pspec))
- type = GLADE_TYPE_EPROP_FLAGS;
- else if (G_IS_PARAM_SPEC_VALUE_ARRAY (pspec))
- {
- if (pspec->value_type == G_TYPE_VALUE_ARRAY)
- type = GLADE_TYPE_EPROP_TEXT;
- }
- else if (G_IS_PARAM_SPEC_BOXED(pspec))
- {
- if (pspec->value_type == GDK_TYPE_COLOR)
- type = GLADE_TYPE_EPROP_COLOR;
- else if (pspec->value_type == G_TYPE_STRV)
- type = GLADE_TYPE_EPROP_TEXT;
- }
- else if (G_IS_PARAM_SPEC_STRING(pspec))
- type = GLADE_TYPE_EPROP_TEXT;
- else if (G_IS_PARAM_SPEC_BOOLEAN(pspec))
- type = GLADE_TYPE_EPROP_BOOL;
- else if (G_IS_PARAM_SPEC_FLOAT(pspec) ||
- G_IS_PARAM_SPEC_DOUBLE(pspec) ||
- G_IS_PARAM_SPEC_INT(pspec) ||
- G_IS_PARAM_SPEC_UINT(pspec) ||
- G_IS_PARAM_SPEC_LONG(pspec) ||
- G_IS_PARAM_SPEC_ULONG(pspec) ||
- G_IS_PARAM_SPEC_INT64(pspec) ||
- G_IS_PARAM_SPEC_UINT64(pspec))
- type = GLADE_TYPE_EPROP_NUMERIC;
- else if (G_IS_PARAM_SPEC_UNICHAR(pspec))
- type = GLADE_TYPE_EPROP_UNICHAR;
- else if (G_IS_PARAM_SPEC_OBJECT(pspec))
- {
- if (pspec->value_type == GDK_TYPE_PIXBUF)
- type = GLADE_TYPE_EPROP_TEXT;
- else
- type = GLADE_TYPE_EPROP_OBJECT;
- }
- else if (GLADE_IS_PARAM_SPEC_OBJECTS(pspec))
- type = GLADE_TYPE_EPROP_OBJECTS;
-
- return type;
+glade_widget_adaptor_object_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *child_node, *packing_node;
+ GList *props;
+
+ child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
+ glade_xml_node_append_child (node, child_node);
+
+ /* Set internal child */
+ if (widget->internal)
+ glade_xml_node_set_property_string (child_node,
+ GLADE_XML_TAG_INTERNAL_CHILD,
+ widget->internal);
+
+ /* Write out the widget */
+ glade_widget_write (widget, context, child_node);
+
+ /* Write out packing properties and special-child-type */
+ packing_node = glade_xml_node_new (context, GLADE_XML_TAG_PACKING);
+ glade_xml_node_append_child (child_node, packing_node);
+
+ for (props = widget->packing_properties; props; props = props->next)
+ {
+ if (GLADE_PROPERTY (props->data)->klass->save &&
+ GLADE_PROPERTY (props->data)->enabled)
+ glade_property_write (GLADE_PROPERTY (props->data),
+ context, packing_node);
+ }
+
+ glade_widget_write_special_child_prop (widget->parent,
+ widget->object, context, child_node);
+
+ /* Default packing properties and such are not saved,
+ * so lets check afterwords if there was anything saved
+ * and then just remove the node.
+ */
+ if (!glade_xml_node_get_children (packing_node))
+ {
+ glade_xml_node_remove (packing_node);
+ glade_xml_node_delete (packing_node);
+ }
+}
+
+static GType
+glade_widget_adaptor_get_eprop_type (GParamSpec * pspec)
+{
+ GType type = 0;
+
+ if (G_IS_PARAM_SPEC_ENUM (pspec))
+ type = GLADE_TYPE_EPROP_ENUM;
+ else if (G_IS_PARAM_SPEC_FLAGS (pspec))
+ type = GLADE_TYPE_EPROP_FLAGS;
+ else if (G_IS_PARAM_SPEC_VALUE_ARRAY (pspec))
+ {
+ if (pspec->value_type == G_TYPE_VALUE_ARRAY)
+ type = GLADE_TYPE_EPROP_TEXT;
+ }
+ else if (G_IS_PARAM_SPEC_BOXED (pspec))
+ {
+ if (pspec->value_type == GDK_TYPE_COLOR)
+ type = GLADE_TYPE_EPROP_COLOR;
+ else if (pspec->value_type == G_TYPE_STRV)
+ type = GLADE_TYPE_EPROP_TEXT;
+ }
+ else if (G_IS_PARAM_SPEC_STRING (pspec))
+ type = GLADE_TYPE_EPROP_TEXT;
+ else if (G_IS_PARAM_SPEC_BOOLEAN (pspec))
+ type = GLADE_TYPE_EPROP_BOOL;
+ else if (G_IS_PARAM_SPEC_FLOAT (pspec) ||
+ G_IS_PARAM_SPEC_DOUBLE (pspec) ||
+ G_IS_PARAM_SPEC_INT (pspec) ||
+ G_IS_PARAM_SPEC_UINT (pspec) ||
+ G_IS_PARAM_SPEC_LONG (pspec) ||
+ G_IS_PARAM_SPEC_ULONG (pspec) ||
+ G_IS_PARAM_SPEC_INT64 (pspec) || G_IS_PARAM_SPEC_UINT64 (pspec))
+ type = GLADE_TYPE_EPROP_NUMERIC;
+ else if (G_IS_PARAM_SPEC_UNICHAR (pspec))
+ type = GLADE_TYPE_EPROP_UNICHAR;
+ else if (G_IS_PARAM_SPEC_OBJECT (pspec))
+ {
+ if (pspec->value_type == GDK_TYPE_PIXBUF)
+ type = GLADE_TYPE_EPROP_TEXT;
+ else
+ type = GLADE_TYPE_EPROP_OBJECT;
+ }
+ else if (GLADE_IS_PARAM_SPEC_OBJECTS (pspec))
+ type = GLADE_TYPE_EPROP_OBJECTS;
+
+ return type;
}
static GladeEditorProperty *
-glade_widget_adaptor_object_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
+glade_widget_adaptor_object_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ gboolean use_command)
{
- GladeEditorProperty *eprop;
- GType type = 0;
+ GladeEditorProperty *eprop;
+ GType type = 0;
+
+ /* Find the right type of GladeEditorProperty for this
+ * GladePropertyClass.
+ */
+ if ((type = glade_widget_adaptor_get_eprop_type (klass->pspec)) == 0)
+ return NULL;
- /* Find the right type of GladeEditorProperty for this
- * GladePropertyClass.
- */
- if ((type = glade_widget_adaptor_get_eprop_type (klass->pspec)) == 0)
- return NULL;
-
- /* special case for string specs that denote themed application icons. */
- if (klass->themed_icon)
- type = GLADE_TYPE_EPROP_NAMED_ICON;
+ /* special case for string specs that denote themed application icons. */
+ if (klass->themed_icon)
+ type = GLADE_TYPE_EPROP_NAMED_ICON;
- /* Create and return the correct type of GladeEditorProperty */
- eprop = g_object_new (type,
- "property-class", klass,
- "use-command", use_command,
- NULL);
+ /* Create and return the correct type of GladeEditorProperty */
+ eprop = g_object_new (type,
+ "property-class", klass,
+ "use-command", use_command, NULL);
- return eprop;
+ return eprop;
}
static gchar *
-glade_widget_adaptor_object_string_from_value (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- const GValue *value)
+glade_widget_adaptor_object_string_from_value (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ const GValue * value)
{
- return glade_property_class_make_string_from_gvalue (klass, value);
+ return glade_property_class_make_string_from_gvalue (klass, value);
}
static GladeEditable *
-glade_widget_adaptor_object_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_widget_adaptor_object_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- return (GladeEditable *)glade_editor_table_new (adaptor, type);
+ return (GladeEditable *) glade_editor_table_new (adaptor, type);
}
@@ -1170,183 +1192,175 @@ glade_widget_adaptor_object_create_editable (GladeWidgetAdaptor *adaptor,
GladeWidgetAdaptor type registration and class initializer
*******************************************************************************/
static void
-glade_widget_adaptor_init (GladeWidgetAdaptor *adaptor)
+glade_widget_adaptor_init (GladeWidgetAdaptor * adaptor)
{
- adaptor->priv = GLADE_WIDGET_ADAPTOR_GET_PRIVATE (adaptor);
+ adaptor->priv = GLADE_WIDGET_ADAPTOR_GET_PRIVATE (adaptor);
}
static void
-glade_widget_adaptor_class_init (GladeWidgetAdaptorClass *adaptor_class)
-{
- GObjectClass *object_class;
- g_return_if_fail (adaptor_class != NULL);
-
- parent_class = g_type_class_peek_parent (adaptor_class);
- object_class = G_OBJECT_CLASS (adaptor_class);
-
- /* GObjectClass */
- object_class->constructor = glade_widget_adaptor_constructor;
- object_class->finalize = glade_widget_adaptor_finalize;
- object_class->set_property = glade_widget_adaptor_real_set_property;
- object_class->get_property = glade_widget_adaptor_real_get_property;
-
- /* Class methods */
- adaptor_class->create_widget = glade_widget_adaptor_object_create_widget;
- adaptor_class->construct_object = glade_widget_adaptor_object_construct_object;
- adaptor_class->deep_post_create = NULL;
- adaptor_class->post_create = NULL;
- adaptor_class->get_internal_child = NULL;
- adaptor_class->verify_property = NULL;
- adaptor_class->set_property = glade_widget_adaptor_object_set_property;
- adaptor_class->get_property = glade_widget_adaptor_object_get_property;
- adaptor_class->add = NULL;
- adaptor_class->remove = NULL;
- adaptor_class->replace_child = NULL;
- adaptor_class->get_children = NULL;
- adaptor_class->child_set_property = NULL;
- adaptor_class->child_get_property = NULL;
- adaptor_class->action_activate = glade_widget_adaptor_object_action_activate;
- adaptor_class->child_action_activate= glade_widget_adaptor_object_child_action_activate;
- adaptor_class->action_submenu = NULL;
- adaptor_class->depends = glade_widget_adaptor_object_depends;
- adaptor_class->read_widget = glade_widget_adaptor_object_read_widget;
- adaptor_class->write_widget = glade_widget_adaptor_object_write_widget;
- adaptor_class->read_child = glade_widget_adaptor_object_read_child;
- adaptor_class->write_child = glade_widget_adaptor_object_write_child;
- adaptor_class->create_eprop = glade_widget_adaptor_object_create_eprop;
- adaptor_class->string_from_value = glade_widget_adaptor_object_string_from_value;
- adaptor_class->create_editable = glade_widget_adaptor_object_create_editable;
-
- /* Base defaults here */
- adaptor_class->toplevel = FALSE;
- adaptor_class->use_placeholders = FALSE;
- adaptor_class->default_width = -1;
- adaptor_class->default_height = -1;
-
- /* Properties */
- g_object_class_install_property
- (object_class, PROP_NAME,
- g_param_spec_string
- ("name", _("Name"),
- _("Name of the class"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_TYPE,
- g_param_spec_gtype
- ("type", _("Type"),
- _("GType of the class"),
- G_TYPE_NONE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_TITLE,
- g_param_spec_string
- ("title", _("Title"),
- _("Translated title for the class used in the glade UI"),
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_GENERIC_NAME,
- g_param_spec_string
- ("generic-name", _("Generic Name"),
- _("Used to generate names of new widgets"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_ICON_NAME,
- g_param_spec_string
- ("icon-name", _("Icon Name"),
- _("The icon name"),
- DEFAULT_ICON_NAME,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_CATALOG,
- g_param_spec_string
- ("catalog", _("Catalog"),
- _("The name of the widget catalog this class was declared by"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_BOOK,
- g_param_spec_string
- ("book", _("Book"),
- _("DevHelp search namespace for this widget class"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_SPECIAL_TYPE,
- g_param_spec_string
- ("special-child-type", _("Special Child Type"),
- _("Holds the name of the packing property to depict "
- "special children for this container class"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_CURSOR,
- g_param_spec_pointer
- ("cursor", _("Cursor"),
- _("A cursor for inserting widgets in the UI"),
- G_PARAM_READABLE));
-
- g_type_class_add_private (adaptor_class, sizeof (GladeWidgetAdaptorPrivate));
+glade_widget_adaptor_class_init (GladeWidgetAdaptorClass * adaptor_class)
+{
+ GObjectClass *object_class;
+ g_return_if_fail (adaptor_class != NULL);
+
+ parent_class = g_type_class_peek_parent (adaptor_class);
+ object_class = G_OBJECT_CLASS (adaptor_class);
+
+ /* GObjectClass */
+ object_class->constructor = glade_widget_adaptor_constructor;
+ object_class->finalize = glade_widget_adaptor_finalize;
+ object_class->set_property = glade_widget_adaptor_real_set_property;
+ object_class->get_property = glade_widget_adaptor_real_get_property;
+
+ /* Class methods */
+ adaptor_class->create_widget = glade_widget_adaptor_object_create_widget;
+ adaptor_class->construct_object =
+ glade_widget_adaptor_object_construct_object;
+ adaptor_class->deep_post_create = NULL;
+ adaptor_class->post_create = NULL;
+ adaptor_class->get_internal_child = NULL;
+ adaptor_class->verify_property = NULL;
+ adaptor_class->set_property = glade_widget_adaptor_object_set_property;
+ adaptor_class->get_property = glade_widget_adaptor_object_get_property;
+ adaptor_class->add = NULL;
+ adaptor_class->remove = NULL;
+ adaptor_class->replace_child = NULL;
+ adaptor_class->get_children = NULL;
+ adaptor_class->child_set_property = NULL;
+ adaptor_class->child_get_property = NULL;
+ adaptor_class->action_activate = glade_widget_adaptor_object_action_activate;
+ adaptor_class->child_action_activate =
+ glade_widget_adaptor_object_child_action_activate;
+ adaptor_class->action_submenu = NULL;
+ adaptor_class->depends = glade_widget_adaptor_object_depends;
+ adaptor_class->read_widget = glade_widget_adaptor_object_read_widget;
+ adaptor_class->write_widget = glade_widget_adaptor_object_write_widget;
+ adaptor_class->read_child = glade_widget_adaptor_object_read_child;
+ adaptor_class->write_child = glade_widget_adaptor_object_write_child;
+ adaptor_class->create_eprop = glade_widget_adaptor_object_create_eprop;
+ adaptor_class->string_from_value =
+ glade_widget_adaptor_object_string_from_value;
+ adaptor_class->create_editable = glade_widget_adaptor_object_create_editable;
+
+ /* Base defaults here */
+ adaptor_class->toplevel = FALSE;
+ adaptor_class->use_placeholders = FALSE;
+ adaptor_class->default_width = -1;
+ adaptor_class->default_height = -1;
+
+ /* Properties */
+ g_object_class_install_property
+ (object_class, PROP_NAME,
+ g_param_spec_string
+ ("name", _("Name"),
+ _("Name of the class"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_TYPE,
+ g_param_spec_gtype
+ ("type", _("Type"),
+ _("GType of the class"),
+ G_TYPE_NONE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_TITLE,
+ g_param_spec_string
+ ("title", _("Title"),
+ _("Translated title for the class used in the glade UI"),
+ NULL, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_GENERIC_NAME,
+ g_param_spec_string
+ ("generic-name", _("Generic Name"),
+ _("Used to generate names of new widgets"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_ICON_NAME,
+ g_param_spec_string
+ ("icon-name", _("Icon Name"),
+ _("The icon name"),
+ DEFAULT_ICON_NAME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_CATALOG,
+ g_param_spec_string
+ ("catalog", _("Catalog"),
+ _("The name of the widget catalog this class was declared by"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_BOOK,
+ g_param_spec_string
+ ("book", _("Book"),
+ _("DevHelp search namespace for this widget class"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_SPECIAL_TYPE,
+ g_param_spec_string
+ ("special-child-type", _("Special Child Type"),
+ _("Holds the name of the packing property to depict "
+ "special children for this container class"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_CURSOR,
+ g_param_spec_pointer
+ ("cursor", _("Cursor"),
+ _("A cursor for inserting widgets in the UI"), G_PARAM_READABLE));
+
+ g_type_class_add_private (adaptor_class, sizeof (GladeWidgetAdaptorPrivate));
}
GType
glade_widget_adaptor_get_type (void)
{
- static GType adaptor_type = 0;
-
- if (!adaptor_type)
- {
- static const GTypeInfo adaptor_info =
- {
- sizeof (GladeWidgetAdaptorClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) glade_widget_adaptor_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (GladeWidgetAdaptor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) glade_widget_adaptor_init,
- };
- adaptor_type =
- g_type_register_static (G_TYPE_OBJECT,
- "GladeGObjectAdaptor",
- &adaptor_info, 0);
- }
- return adaptor_type;
+ static GType adaptor_type = 0;
+
+ if (!adaptor_type)
+ {
+ static const GTypeInfo adaptor_info = {
+ sizeof (GladeWidgetAdaptorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) glade_widget_adaptor_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (GladeWidgetAdaptor),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) glade_widget_adaptor_init,
+ };
+ adaptor_type =
+ g_type_register_static (G_TYPE_OBJECT,
+ "GladeGObjectAdaptor", &adaptor_info, 0);
+ }
+ return adaptor_type;
}
GType
glade_create_reason_get_type (void)
{
- static GType etype = 0;
+ static GType etype = 0;
- if (etype == 0)
- {
- static const GEnumValue values[] = {
- { GLADE_CREATE_USER, "GLADE_CREATE_USER", "create-user" },
- { GLADE_CREATE_COPY, "GLADE_CREATE_COPY", "create-copy" },
- { GLADE_CREATE_LOAD, "GLADE_CREATE_LOAD", "create-load" },
- { GLADE_CREATE_REBUILD, "GLADE_CREATE_REBUILD", "create-rebuild" },
- { 0, NULL, NULL }
- };
+ if (etype == 0)
+ {
+ static const GEnumValue values[] = {
+ {GLADE_CREATE_USER, "GLADE_CREATE_USER", "create-user"},
+ {GLADE_CREATE_COPY, "GLADE_CREATE_COPY", "create-copy"},
+ {GLADE_CREATE_LOAD, "GLADE_CREATE_LOAD", "create-load"},
+ {GLADE_CREATE_REBUILD, "GLADE_CREATE_REBUILD", "create-rebuild"},
+ {0, NULL, NULL}
+ };
- etype = g_enum_register_static ("GladeCreateReason", values);
+ etype = g_enum_register_static ("GladeCreateReason", values);
- }
+ }
- return etype;
+ return etype;
}
/*******************************************************************************
@@ -1354,242 +1368,219 @@ glade_create_reason_get_type (void)
*******************************************************************************/
typedef struct
{
- GladeXmlNode *node;
- GModule *module;
+ GladeXmlNode *node;
+ GModule *module;
} GWADerivedClassData;
static void
-gwa_derived_init (GladeWidgetAdaptor *adaptor, gpointer g_class)
+gwa_derived_init (GladeWidgetAdaptor * adaptor, gpointer g_class)
{
}
static void
-gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass *klass,
- GladeXmlNode *node,
- GModule *module)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- gpointer symbol;
-
- /*
- * We use a temporary variable to avoid a bogus gcc warning.
- * the thing it that g_module_symbol() should use a function pointer
- * instead of a gpointer!
- */
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CONSTRUCTOR_FUNCTION,
- &symbol))
- object_class->constructor = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CREATE_WIDGET_FUNCTION,
- &symbol))
- klass->create_widget = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION,
- &symbol))
- klass->construct_object = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_DEEP_POST_CREATE_FUNCTION,
- &symbol))
- klass->deep_post_create = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_POST_CREATE_FUNCTION,
- &symbol))
- klass->post_create = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_SET_FUNCTION,
- &symbol))
- klass->set_property = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_GET_FUNCTION,
- &symbol))
- klass->get_property = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_VERIFY_FUNCTION,
- &symbol))
- klass->verify_property = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_ADD_CHILD_FUNCTION,
- &symbol))
- klass->add = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_REMOVE_CHILD_FUNCTION,
- &symbol))
- klass->remove = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_REPLACE_CHILD_FUNCTION,
- &symbol))
- klass->replace_child = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_GET_CHILDREN_FUNCTION,
- &symbol))
- klass->get_children = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CHILD_SET_PROP_FUNCTION,
- &symbol))
- klass->child_set_property = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CHILD_GET_PROP_FUNCTION,
- &symbol))
- klass->child_get_property = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CHILD_VERIFY_FUNCTION,
- &symbol))
- klass->child_verify_property = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION,
- &symbol))
- klass->get_internal_child = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_ACTION_ACTIVATE_FUNCTION,
- &symbol))
- klass->action_activate = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION,
- &symbol))
- klass->child_action_activate = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_ACTION_SUBMENU_FUNCTION,
- &symbol))
- klass->action_submenu = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_DEPENDS_FUNCTION,
- &symbol))
- klass->depends = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_READ_WIDGET_FUNCTION,
- &symbol))
- klass->read_widget = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_WRITE_WIDGET_FUNCTION,
- &symbol))
- klass->write_widget = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_READ_CHILD_FUNCTION,
- &symbol))
- klass->read_child = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_WRITE_CHILD_FUNCTION,
- &symbol))
- klass->write_child = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CREATE_EPROP_FUNCTION,
- &symbol))
- klass->create_eprop = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_STRING_FROM_VALUE_FUNCTION,
- &symbol))
- klass->string_from_value = symbol;
-
- if (glade_xml_load_sym_from_node (node, module,
- GLADE_TAG_CREATE_EDITABLE_FUNCTION,
- &symbol))
- klass->create_editable = symbol;
+gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass * klass,
+ GladeXmlNode * node, GModule * module)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ gpointer symbol;
+
+ /*
+ * We use a temporary variable to avoid a bogus gcc warning.
+ * the thing it that g_module_symbol() should use a function pointer
+ * instead of a gpointer!
+ */
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CONSTRUCTOR_FUNCTION, &symbol))
+ object_class->constructor = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CREATE_WIDGET_FUNCTION, &symbol))
+ klass->create_widget = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CONSTRUCT_OBJECT_FUNCTION,
+ &symbol))
+ klass->construct_object = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_DEEP_POST_CREATE_FUNCTION,
+ &symbol))
+ klass->deep_post_create = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_POST_CREATE_FUNCTION, &symbol))
+ klass->post_create = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_SET_FUNCTION, &symbol))
+ klass->set_property = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_GET_FUNCTION, &symbol))
+ klass->get_property = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_VERIFY_FUNCTION, &symbol))
+ klass->verify_property = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_ADD_CHILD_FUNCTION, &symbol))
+ klass->add = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_REMOVE_CHILD_FUNCTION, &symbol))
+ klass->remove = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_REPLACE_CHILD_FUNCTION, &symbol))
+ klass->replace_child = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_GET_CHILDREN_FUNCTION, &symbol))
+ klass->get_children = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CHILD_SET_PROP_FUNCTION, &symbol))
+ klass->child_set_property = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CHILD_GET_PROP_FUNCTION, &symbol))
+ klass->child_get_property = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CHILD_VERIFY_FUNCTION, &symbol))
+ klass->child_verify_property = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_GET_INTERNAL_CHILD_FUNCTION,
+ &symbol))
+ klass->get_internal_child = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_ACTION_ACTIVATE_FUNCTION,
+ &symbol))
+ klass->action_activate = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION,
+ &symbol))
+ klass->child_action_activate = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_ACTION_SUBMENU_FUNCTION, &symbol))
+ klass->action_submenu = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_DEPENDS_FUNCTION, &symbol))
+ klass->depends = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_READ_WIDGET_FUNCTION, &symbol))
+ klass->read_widget = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_WRITE_WIDGET_FUNCTION, &symbol))
+ klass->write_widget = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_READ_CHILD_FUNCTION, &symbol))
+ klass->read_child = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_WRITE_CHILD_FUNCTION, &symbol))
+ klass->write_child = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CREATE_EPROP_FUNCTION, &symbol))
+ klass->create_eprop = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_STRING_FROM_VALUE_FUNCTION,
+ &symbol))
+ klass->string_from_value = symbol;
+
+ if (glade_xml_load_sym_from_node (node, module,
+ GLADE_TAG_CREATE_EDITABLE_FUNCTION,
+ &symbol))
+ klass->create_editable = symbol;
}
static void
-gwa_derived_class_init (GladeWidgetAdaptorClass *adaptor_class,
- GWADerivedClassData *data)
+gwa_derived_class_init (GladeWidgetAdaptorClass * adaptor_class,
+ GWADerivedClassData * data)
{
- GladeXmlNode *node = data->node;
- GModule *module = data->module;
-
- /* Load catalog symbols from module */
- if (module) gwa_extend_with_node_load_sym (adaptor_class, node, module);
+ GladeXmlNode *node = data->node;
+ GModule *module = data->module;
+
+ /* Load catalog symbols from module */
+ if (module)
+ gwa_extend_with_node_load_sym (adaptor_class, node, module);
- glade_xml_get_property_version
- (node, GLADE_TAG_VERSION_SINCE,
- &adaptor_class->version_since_major,
- &adaptor_class->version_since_minor);
+ glade_xml_get_property_version
+ (node, GLADE_TAG_VERSION_SINCE,
+ &adaptor_class->version_since_major,
+ &adaptor_class->version_since_minor);
- adaptor_class->deprecated =
- glade_xml_get_property_boolean
- (node, GLADE_TAG_DEPRECATED, adaptor_class->deprecated);
+ adaptor_class->deprecated =
+ glade_xml_get_property_boolean
+ (node, GLADE_TAG_DEPRECATED, adaptor_class->deprecated);
- adaptor_class->toplevel =
- glade_xml_get_property_boolean
- (node, GLADE_TAG_TOPLEVEL, adaptor_class->toplevel);
+ adaptor_class->toplevel =
+ glade_xml_get_property_boolean
+ (node, GLADE_TAG_TOPLEVEL, adaptor_class->toplevel);
- adaptor_class->use_placeholders =
- glade_xml_get_property_boolean
- (node, GLADE_TAG_USE_PLACEHOLDERS, adaptor_class->use_placeholders);
+ adaptor_class->use_placeholders =
+ glade_xml_get_property_boolean
+ (node, GLADE_TAG_USE_PLACEHOLDERS, adaptor_class->use_placeholders);
- adaptor_class->default_width =
- glade_xml_get_property_int
- (node, GLADE_TAG_DEFAULT_WIDTH, adaptor_class->default_width);
+ adaptor_class->default_width =
+ glade_xml_get_property_int
+ (node, GLADE_TAG_DEFAULT_WIDTH, adaptor_class->default_width);
- adaptor_class->default_height =
- glade_xml_get_property_int
- (node, GLADE_TAG_DEFAULT_HEIGHT, adaptor_class->default_height);
+ adaptor_class->default_height =
+ glade_xml_get_property_int
+ (node, GLADE_TAG_DEFAULT_HEIGHT, adaptor_class->default_height);
}
static GType
-gwa_derive_adaptor_for_type (GType object_type, GWADerivedClassData *data)
-{
- GladeWidgetAdaptor *adaptor;
- GType iter_type, derived_type;
- GType parent_type = GLADE_TYPE_WIDGET_ADAPTOR;
- gchar *type_name;
- GTypeInfo adaptor_info =
- {
- sizeof (GladeWidgetAdaptorClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gwa_derived_class_init,
- (GClassFinalizeFunc) NULL,
- data, /* class_data */
- sizeof (GladeWidgetAdaptor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gwa_derived_init,
- };
-
- for (iter_type = g_type_parent (object_type);
- iter_type > 0;
- iter_type = g_type_parent (iter_type))
- {
- if ((adaptor =
- glade_widget_adaptor_get_by_type (iter_type)) != NULL)
- {
- parent_type = G_TYPE_FROM_INSTANCE (adaptor);
- break;
- }
- }
-
- /* Note that we must pass ownership of the type_name string
- * to the type system
- */
- type_name = g_strdup_printf ("Glade%sAdaptor", g_type_name (object_type));
- derived_type = g_type_register_static (parent_type, type_name,
- &adaptor_info, 0);
-
- return derived_type;
+gwa_derive_adaptor_for_type (GType object_type, GWADerivedClassData * data)
+{
+ GladeWidgetAdaptor *adaptor;
+ GType iter_type, derived_type;
+ GType parent_type = GLADE_TYPE_WIDGET_ADAPTOR;
+ gchar *type_name;
+ GTypeInfo adaptor_info = {
+ sizeof (GladeWidgetAdaptorClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gwa_derived_class_init,
+ (GClassFinalizeFunc) NULL,
+ data, /* class_data */
+ sizeof (GladeWidgetAdaptor),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gwa_derived_init,
+ };
+
+ for (iter_type = g_type_parent (object_type);
+ iter_type > 0; iter_type = g_type_parent (iter_type))
+ {
+ if ((adaptor = glade_widget_adaptor_get_by_type (iter_type)) != NULL)
+ {
+ parent_type = G_TYPE_FROM_INSTANCE (adaptor);
+ break;
+ }
+ }
+
+ /* Note that we must pass ownership of the type_name string
+ * to the type system
+ */
+ type_name = g_strdup_printf ("Glade%sAdaptor", g_type_name (object_type));
+ derived_type = g_type_register_static (parent_type, type_name,
+ &adaptor_info, 0);
+
+ return derived_type;
}
@@ -1597,11 +1588,9 @@ gwa_derive_adaptor_for_type (GType object_type, GWADerivedClassData *data)
API
*******************************************************************************/
static void
-accum_adaptor (GType *type,
- GladeWidgetAdaptor *adaptor,
- GList **list)
+accum_adaptor (GType * type, GladeWidgetAdaptor * adaptor, GList ** list)
{
- *list = g_list_prepend (*list, adaptor);
+ *list = g_list_prepend (*list, adaptor);
}
/**
@@ -1614,11 +1603,11 @@ accum_adaptor (GType *type,
GList *
glade_widget_adaptor_list_adaptors (void)
{
- GList *adaptors = NULL;
+ GList *adaptors = NULL;
- g_hash_table_foreach (adaptor_hash, (GHFunc)accum_adaptor, &adaptors);
-
- return adaptors;
+ g_hash_table_foreach (adaptor_hash, (GHFunc) accum_adaptor, &adaptors);
+
+ return adaptors;
}
/**
@@ -1629,527 +1618,539 @@ glade_widget_adaptor_list_adaptors (void)
* object type must have a registered adaptor).
*/
void
-glade_widget_adaptor_register (GladeWidgetAdaptor *adaptor)
+glade_widget_adaptor_register (GladeWidgetAdaptor * adaptor)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- if (glade_widget_adaptor_get_by_name (adaptor->name))
- {
- g_warning ("Adaptor class for '%s' already registered",
- adaptor->name);
- return;
- }
+ if (glade_widget_adaptor_get_by_name (adaptor->name))
+ {
+ g_warning ("Adaptor class for '%s' already registered", adaptor->name);
+ return;
+ }
- if (!adaptor_hash)
- adaptor_hash = g_hash_table_new_full (gwa_gtype_hash, gwa_gtype_equal,
- g_free, g_object_unref);
+ if (!adaptor_hash)
+ adaptor_hash = g_hash_table_new_full (gwa_gtype_hash, gwa_gtype_equal,
+ g_free, g_object_unref);
- g_hash_table_insert (adaptor_hash,
- g_memdup (&adaptor->type,
- sizeof (GType)), adaptor);
+ g_hash_table_insert (adaptor_hash,
+ g_memdup (&adaptor->type, sizeof (GType)), adaptor);
}
static GladePackingDefault *
-gwa_default_from_child_packing (GladeChildPacking *packing, const gchar *id)
+gwa_default_from_child_packing (GladeChildPacking * packing, const gchar * id)
{
- GList *list;
+ GList *list;
- for (list = packing->packing_defaults; list; list = list->next)
- {
- GladePackingDefault *def = list->data;
+ for (list = packing->packing_defaults; list; list = list->next)
+ {
+ GladePackingDefault *def = list->data;
- if (id && !strcmp (id, def->id))
- return def;
- }
+ if (id && !strcmp (id, def->id))
+ return def;
+ }
- return NULL;
+ return NULL;
}
static GladeChildPacking *
-glade_widget_adaptor_get_child_packing (GladeWidgetAdaptor *child_adaptor,
- const gchar *parent_name)
+glade_widget_adaptor_get_child_packing (GladeWidgetAdaptor * child_adaptor,
+ const gchar * parent_name)
{
- GList *l;
+ GList *l;
- for (l = child_adaptor->child_packings; l; l = l->next)
- {
- GladeChildPacking *packing;
+ for (l = child_adaptor->child_packings; l; l = l->next)
+ {
+ GladeChildPacking *packing;
- packing = (GladeChildPacking *) l->data;
+ packing = (GladeChildPacking *) l->data;
- if (!strcmp (packing->parent_name, parent_name))
- return packing;
- }
+ if (!strcmp (packing->parent_name, parent_name))
+ return packing;
+ }
- return NULL;
+ return NULL;
}
static void
-gwa_set_packing_defaults_from_node (GladeWidgetAdaptor *adaptor,
- GladeXmlNode *node)
-{
- GladeXmlNode *child;
-
- for (child = glade_xml_node_get_children (node);
- child; child = glade_xml_node_next (child))
+gwa_set_packing_defaults_from_node (GladeWidgetAdaptor * adaptor,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *child;
+
+ for (child = glade_xml_node_get_children (node);
+ child; child = glade_xml_node_next (child))
+ {
+ gchar *name;
+ GladeXmlNode *prop_node;
+ GladeChildPacking *packing;
+
+ if (!glade_xml_node_verify (child, GLADE_TAG_PARENT_CLASS))
+ continue;
+
+ if ((name = glade_xml_get_property_string_required
+ (child, GLADE_TAG_NAME, adaptor->name)) == NULL)
+ continue;
+
+ /* If a GladeChildPacking exists for this parent, use it -
+ * otherwise prepend a new one
+ */
+ if ((packing =
+ glade_widget_adaptor_get_child_packing (adaptor, name)) == NULL)
{
- gchar *name;
- GladeXmlNode *prop_node;
- GladeChildPacking *packing;
- if (!glade_xml_node_verify (child, GLADE_TAG_PARENT_CLASS))
- continue;
+ packing = g_new0 (GladeChildPacking, 1);
+ packing->parent_name = name;
- if ((name = glade_xml_get_property_string_required
- (child, GLADE_TAG_NAME, adaptor->name)) == NULL)
- continue;
+ adaptor->child_packings =
+ g_list_prepend (adaptor->child_packings, packing);
- /* If a GladeChildPacking exists for this parent, use it -
- * otherwise prepend a new one
- */
- if ((packing =
- glade_widget_adaptor_get_child_packing (adaptor, name)) == NULL)
- {
+ }
- packing = g_new0 (GladeChildPacking, 1);
- packing->parent_name = name;
+ for (prop_node = glade_xml_node_get_children (child);
+ prop_node; prop_node = glade_xml_node_next (prop_node))
+ {
+ GladePackingDefault *def;
+ gchar *id;
+ gchar *value;
+
+ if ((id =
+ glade_xml_get_property_string_required
+ (prop_node, GLADE_TAG_ID, adaptor->name)) == NULL)
+ continue;
+
+ if ((value =
+ glade_xml_get_property_string_required
+ (prop_node, GLADE_TAG_DEFAULT, adaptor->name)) == NULL)
+ {
+ g_free (id);
+ continue;
+ }
+
+ if ((def = gwa_default_from_child_packing (packing, id)) == NULL)
+ {
+ def = g_new0 (GladePackingDefault, 1);
+ def->id = id;
+ def->value = value;
+
+ packing->packing_defaults =
+ g_list_prepend (packing->packing_defaults, def);
+ }
+ else
+ {
+ g_free (id);
+ g_free (def->value);
+ def->value = value;
+ }
+
+ adaptor->child_packings =
+ g_list_prepend (adaptor->child_packings, packing);
+
+ }
+ }
+}
- adaptor->child_packings =
- g_list_prepend (adaptor->child_packings, packing);
+static void
+gwa_update_properties_from_node (GladeWidgetAdaptor * adaptor,
+ GladeXmlNode * node,
+ GModule * module,
+ GList ** properties,
+ const gchar * domain, gboolean is_packing)
+{
+ GladeXmlNode *child;
+
+ for (child = glade_xml_node_get_children (node);
+ child; child = glade_xml_node_next (child))
+ {
+ gchar *id;
+ GList *list;
+ GladePropertyClass *property_class;
+ gboolean updated;
+
+ if (!glade_xml_node_verify (child, GLADE_TAG_PROPERTY))
+ continue;
+
+ id = glade_xml_get_property_string_required
+ (child, GLADE_TAG_ID, adaptor->name);
+ if (!id)
+ continue;
+
+ /* property names from catalogs also need to have the '-' form */
+ glade_util_replace (id, '_', '-');
+
+ /* find the property in our list, if not found append a new property */
+ for (list = *properties; list && list->data; list = list->next)
+ {
+ property_class = GLADE_PROPERTY_CLASS (list->data);
+ if (property_class->id != NULL &&
+ g_ascii_strcasecmp (id, property_class->id) == 0)
+ break;
+ }
- }
+ if (list)
+ {
+ property_class = GLADE_PROPERTY_CLASS (list->data);
+ }
+ else
+ {
+ property_class = glade_property_class_new (adaptor);
+ property_class->id = g_strdup (id);
- for (prop_node = glade_xml_node_get_children (child);
- prop_node; prop_node = glade_xml_node_next (prop_node))
- {
- GladePackingDefault *def;
- gchar *id;
- gchar *value;
-
- if ((id =
- glade_xml_get_property_string_required
- (prop_node, GLADE_TAG_ID, adaptor->name)) == NULL)
- continue;
-
- if ((value =
- glade_xml_get_property_string_required
- (prop_node, GLADE_TAG_DEFAULT, adaptor->name)) == NULL)
- {
- g_free (id);
- continue;
- }
-
- if ((def = gwa_default_from_child_packing (packing, id)) == NULL)
- {
- def = g_new0 (GladePackingDefault, 1);
- def->id = id;
- def->value = value;
-
- packing->packing_defaults =
- g_list_prepend (packing->packing_defaults, def);
- }
- else
- {
- g_free (id);
- g_free (def->value);
- def->value = value;
- }
-
- adaptor->child_packings =
- g_list_prepend (adaptor->child_packings, packing);
+ /* When creating new virtual packing properties,
+ * make sure we mark them as such here.
+ */
+ if (is_packing)
+ property_class->packing = TRUE;
- }
- }
-}
+ *properties = g_list_append (*properties, property_class);
+ list = g_list_last (*properties);
+ }
-static void
-gwa_update_properties_from_node (GladeWidgetAdaptor *adaptor,
- GladeXmlNode *node,
- GModule *module,
- GList **properties,
- const gchar *domain,
- gboolean is_packing)
-{
- GladeXmlNode *child;
-
- for (child = glade_xml_node_get_children (node);
- child; child = glade_xml_node_next (child))
- {
- gchar *id;
- GList *list;
- GladePropertyClass *property_class;
- gboolean updated;
-
- if (!glade_xml_node_verify (child, GLADE_TAG_PROPERTY))
- continue;
-
- id = glade_xml_get_property_string_required
- (child, GLADE_TAG_ID, adaptor->name);
- if (!id)
- continue;
-
- /* property names from catalogs also need to have the '-' form */
- glade_util_replace (id, '_', '-');
-
- /* find the property in our list, if not found append a new property */
- for (list = *properties; list && list->data; list = list->next)
- {
- property_class = GLADE_PROPERTY_CLASS (list->data);
- if (property_class->id != NULL &&
- g_ascii_strcasecmp (id, property_class->id) == 0)
- break;
- }
-
- if (list)
- {
- property_class = GLADE_PROPERTY_CLASS (list->data);
- }
- else
- {
- property_class = glade_property_class_new (adaptor);
- property_class->id = g_strdup (id);
-
- /* When creating new virtual packing properties,
- * make sure we mark them as such here.
- */
- if (is_packing)
- property_class->packing = TRUE;
-
- *properties = g_list_append (*properties, property_class);
- list = g_list_last (*properties);
- }
-
- if ((updated = glade_property_class_update_from_node
- (child, module, adaptor->type,
- &property_class, domain)) == FALSE)
- {
- g_warning ("failed to update %s property of %s from xml",
- id, adaptor->name);
- g_free (id);
- continue;
- }
-
- /* if this pointer was set to null, its a property we dont handle. */
- if (!property_class)
- *properties = g_list_delete_link (*properties, list);
-
- g_free (id);
- }
+ if ((updated = glade_property_class_update_from_node
+ (child, module, adaptor->type, &property_class, domain)) == FALSE)
+ {
+ g_warning ("failed to update %s property of %s from xml",
+ id, adaptor->name);
+ g_free (id);
+ continue;
+ }
+
+ /* if this pointer was set to null, its a property we dont handle. */
+ if (!property_class)
+ *properties = g_list_delete_link (*properties, list);
+
+ g_free (id);
+ }
}
static GParamSpec *
-pspec_dup (GParamSpec *spec)
-{
- const gchar *name, *nick, *blurb;
- GType spec_type, value_type;
- GParamSpec *pspec = NULL;
-
- spec_type = G_PARAM_SPEC_TYPE (spec);
- value_type = spec->value_type;
-
- name = g_param_spec_get_name (spec);
- nick = g_param_spec_get_nick (spec);
- blurb = g_param_spec_get_blurb (spec);
-
- if (spec_type == G_TYPE_PARAM_ENUM ||
- spec_type == G_TYPE_PARAM_FLAGS ||
- spec_type == G_TYPE_PARAM_BOXED ||
- spec_type == G_TYPE_PARAM_OBJECT ||
- spec_type == GLADE_TYPE_PARAM_OBJECTS)
- {
-
- if (spec_type == G_TYPE_PARAM_ENUM)
- {
- GParamSpecEnum *p = (GParamSpecEnum *)spec;
- pspec = g_param_spec_enum (name, nick, blurb, value_type, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_FLAGS)
- {
- GParamSpecFlags *p = (GParamSpecFlags *)spec;
- pspec = g_param_spec_flags (name, nick, blurb, value_type, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_OBJECT)
- pspec = g_param_spec_object (name, nick, blurb, value_type, 0);
- else if (spec_type == GLADE_TYPE_PARAM_OBJECTS)
- pspec = glade_param_spec_objects (name, nick, blurb, value_type, 0);
- else
- pspec = g_param_spec_boxed (name, nick, blurb, value_type, 0);
- }
- else if (spec_type == G_TYPE_PARAM_STRING)
- {
- GParamSpecString *p = (GParamSpecString *)spec;
- pspec = g_param_spec_string (name, nick, blurb, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_BOOLEAN)
- {
- GParamSpecBoolean *p = (GParamSpecBoolean *)spec;
- pspec = g_param_spec_boolean (name, nick, blurb, p->default_value, 0);
- }
- else
- {
- if (spec_type == G_TYPE_PARAM_CHAR)
- {
- GParamSpecChar *p = (GParamSpecChar *)spec;
- pspec = g_param_spec_char (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_UCHAR)
- {
- GParamSpecUChar *p = (GParamSpecUChar *)spec;
- pspec = g_param_spec_uchar (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_INT)
- {
- GParamSpecInt *p = (GParamSpecInt *)spec;
- pspec = g_param_spec_int (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_UINT)
- {
- GParamSpecUInt *p = (GParamSpecUInt *)spec;
- pspec = g_param_spec_uint (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_LONG)
- {
- GParamSpecLong *p = (GParamSpecLong *)spec;
- pspec = g_param_spec_long (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_ULONG)
- {
- GParamSpecULong *p = (GParamSpecULong *)spec;
- pspec = g_param_spec_ulong (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_INT64)
- {
- GParamSpecInt64 *p = (GParamSpecInt64 *)spec;
- pspec = g_param_spec_int64 (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_UINT64)
- {
- GParamSpecUInt64 *p = (GParamSpecUInt64 *)spec;
- pspec = g_param_spec_uint64 (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_FLOAT)
- {
- GParamSpecFloat *p = (GParamSpecFloat *)spec;
- pspec = g_param_spec_float (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- else if (spec_type == G_TYPE_PARAM_DOUBLE)
- {
- GParamSpecDouble *p = (GParamSpecDouble *)spec;
- pspec = g_param_spec_float (name, nick, blurb,
- p->minimum, p->maximum, p->default_value, 0);
- }
- }
- return pspec;
+pspec_dup (GParamSpec * spec)
+{
+ const gchar *name, *nick, *blurb;
+ GType spec_type, value_type;
+ GParamSpec *pspec = NULL;
+
+ spec_type = G_PARAM_SPEC_TYPE (spec);
+ value_type = spec->value_type;
+
+ name = g_param_spec_get_name (spec);
+ nick = g_param_spec_get_nick (spec);
+ blurb = g_param_spec_get_blurb (spec);
+
+ if (spec_type == G_TYPE_PARAM_ENUM ||
+ spec_type == G_TYPE_PARAM_FLAGS ||
+ spec_type == G_TYPE_PARAM_BOXED ||
+ spec_type == G_TYPE_PARAM_OBJECT || spec_type == GLADE_TYPE_PARAM_OBJECTS)
+ {
+
+ if (spec_type == G_TYPE_PARAM_ENUM)
+ {
+ GParamSpecEnum *p = (GParamSpecEnum *) spec;
+ pspec =
+ g_param_spec_enum (name, nick, blurb, value_type,
+ p->default_value, 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_FLAGS)
+ {
+ GParamSpecFlags *p = (GParamSpecFlags *) spec;
+ pspec =
+ g_param_spec_flags (name, nick, blurb, value_type,
+ p->default_value, 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_OBJECT)
+ pspec = g_param_spec_object (name, nick, blurb, value_type, 0);
+ else if (spec_type == GLADE_TYPE_PARAM_OBJECTS)
+ pspec = glade_param_spec_objects (name, nick, blurb, value_type, 0);
+ else
+ pspec = g_param_spec_boxed (name, nick, blurb, value_type, 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_STRING)
+ {
+ GParamSpecString *p = (GParamSpecString *) spec;
+ pspec = g_param_spec_string (name, nick, blurb, p->default_value, 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_BOOLEAN)
+ {
+ GParamSpecBoolean *p = (GParamSpecBoolean *) spec;
+ pspec = g_param_spec_boolean (name, nick, blurb, p->default_value, 0);
+ }
+ else
+ {
+ if (spec_type == G_TYPE_PARAM_CHAR)
+ {
+ GParamSpecChar *p = (GParamSpecChar *) spec;
+ pspec = g_param_spec_char (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_UCHAR)
+ {
+ GParamSpecUChar *p = (GParamSpecUChar *) spec;
+ pspec = g_param_spec_uchar (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_INT)
+ {
+ GParamSpecInt *p = (GParamSpecInt *) spec;
+ pspec = g_param_spec_int (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_UINT)
+ {
+ GParamSpecUInt *p = (GParamSpecUInt *) spec;
+ pspec = g_param_spec_uint (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_LONG)
+ {
+ GParamSpecLong *p = (GParamSpecLong *) spec;
+ pspec = g_param_spec_long (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_ULONG)
+ {
+ GParamSpecULong *p = (GParamSpecULong *) spec;
+ pspec = g_param_spec_ulong (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_INT64)
+ {
+ GParamSpecInt64 *p = (GParamSpecInt64 *) spec;
+ pspec = g_param_spec_int64 (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_UINT64)
+ {
+ GParamSpecUInt64 *p = (GParamSpecUInt64 *) spec;
+ pspec = g_param_spec_uint64 (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_FLOAT)
+ {
+ GParamSpecFloat *p = (GParamSpecFloat *) spec;
+ pspec = g_param_spec_float (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ else if (spec_type == G_TYPE_PARAM_DOUBLE)
+ {
+ GParamSpecDouble *p = (GParamSpecDouble *) spec;
+ pspec = g_param_spec_float (name, nick, blurb,
+ p->minimum, p->maximum, p->default_value,
+ 0);
+ }
+ }
+ return pspec;
}
static void
-gwa_update_properties_from_type (GladeWidgetAdaptor *adaptor,
- GType type,
- GList **properties,
- gboolean is_packing)
-{
- gpointer object_class = g_type_class_ref (type);
- GParamSpec **specs = NULL, *spec;
- guint i, n_specs = 0;
-
- /* only GtkContainer child propeties can be introspected */
- if (is_packing && !g_type_is_a (adaptor->type, GTK_TYPE_CONTAINER))
- return;
-
- if (is_packing)
- specs = gtk_container_class_list_child_properties (object_class, &n_specs);
- else
- specs = g_object_class_list_properties (object_class, &n_specs);
-
- for (i = 0; i < n_specs; i++)
- {
- GladePropertyClass *property_class;
- GList *list;
-
- /* find the property in our list, if not found append a new property */
- for (list = *properties; list && list->data; list = list->next)
- {
- property_class = GLADE_PROPERTY_CLASS (list->data);
- if (property_class->id != NULL &&
- g_ascii_strcasecmp (specs[i]->name, property_class->id) == 0)
- break;
- }
-
- if (list == NULL && (spec = pspec_dup (specs[i])))
- {
- property_class = glade_property_class_new (adaptor);
- property_class->id = g_strdup (spec->name);
-
- property_class->pspec = spec;
-
- /* Make sure we can tell properties apart by there
- * owning class.
- */
- property_class->pspec->owner_type = adaptor->type;
-
- /* Disable properties by default since the does not really implement them */
- property_class->virt = TRUE;
- property_class->ignore = TRUE;
-
- property_class->tooltip = g_strdup (g_param_spec_get_blurb (spec));
- property_class->name = g_strdup (g_param_spec_get_nick (spec));
-
- if (property_class->pspec->flags & G_PARAM_CONSTRUCT_ONLY)
- property_class->construct_only = TRUE;
-
- property_class->orig_def = glade_property_class_get_default_from_spec (spec);
-
- property_class->def = glade_property_class_get_default_from_spec (spec);
-
- property_class->packing = is_packing;
-
- *properties = g_list_append (*properties, property_class);
- }
- }
-
- g_free (specs);
-}
+gwa_update_properties_from_type (GladeWidgetAdaptor * adaptor,
+ GType type,
+ GList ** properties, gboolean is_packing)
+{
+ gpointer object_class = g_type_class_ref (type);
+ GParamSpec **specs = NULL, *spec;
+ guint i, n_specs = 0;
+
+ /* only GtkContainer child propeties can be introspected */
+ if (is_packing && !g_type_is_a (adaptor->type, GTK_TYPE_CONTAINER))
+ return;
+
+ if (is_packing)
+ specs = gtk_container_class_list_child_properties (object_class, &n_specs);
+ else
+ specs = g_object_class_list_properties (object_class, &n_specs);
+
+ for (i = 0; i < n_specs; i++)
+ {
+ GladePropertyClass *property_class;
+ GList *list;
+
+ /* find the property in our list, if not found append a new property */
+ for (list = *properties; list && list->data; list = list->next)
+ {
+ property_class = GLADE_PROPERTY_CLASS (list->data);
+ if (property_class->id != NULL &&
+ g_ascii_strcasecmp (specs[i]->name, property_class->id) == 0)
+ break;
+ }
+
+ if (list == NULL && (spec = pspec_dup (specs[i])))
+ {
+ property_class = glade_property_class_new (adaptor);
+ property_class->id = g_strdup (spec->name);
+
+ property_class->pspec = spec;
+
+ /* Make sure we can tell properties apart by there
+ * owning class.
+ */
+ property_class->pspec->owner_type = adaptor->type;
+
+ /* Disable properties by default since the does not really implement them */
+ property_class->virt = TRUE;
+ property_class->ignore = TRUE;
+
+ property_class->tooltip = g_strdup (g_param_spec_get_blurb (spec));
+ property_class->name = g_strdup (g_param_spec_get_nick (spec));
+
+ if (property_class->pspec->flags & G_PARAM_CONSTRUCT_ONLY)
+ property_class->construct_only = TRUE;
+
+ property_class->orig_def =
+ glade_property_class_get_default_from_spec (spec);
+
+ property_class->def =
+ glade_property_class_get_default_from_spec (spec);
+
+ property_class->packing = is_packing;
+
+ *properties = g_list_append (*properties, property_class);
+ }
+ }
+
+ g_free (specs);
+}
static void
-gwa_action_update_from_node (GladeWidgetAdaptor *adaptor,
- gboolean is_packing,
- GladeXmlNode *node,
- const gchar *domain,
- gchar *group_path)
-{
- GladeXmlNode *child;
- gchar *id, *label, *stock, *action_path;
- gboolean group, important;
-
- for (child = glade_xml_node_get_children (node);
- child; child = glade_xml_node_next (child))
- {
- if ((group = glade_xml_node_verify_silent (child, GLADE_TAG_ACTION)) == FALSE)
- continue;
-
- id = glade_xml_get_property_string_required
- (child, GLADE_TAG_ID, adaptor->name);
- if (id == NULL)
- continue;
-
- if (group_path)
- action_path = g_strdup_printf ("%s/%s", group_path, id);
- else
- action_path = id;
-
- label = glade_xml_get_property_string (child, GLADE_TAG_NAME);
- stock = glade_xml_get_property_string (child, GLADE_TAG_STOCK);
- important = glade_xml_get_property_boolean (child, GLADE_TAG_IMPORTANT, FALSE);
-
- if (label)
- {
- gchar *translated = dgettext (domain, label);
- if (label != translated)
- {
- g_free (label);
- label = g_strdup (translated);
- }
- }
-
- if (is_packing)
- glade_widget_adaptor_pack_action_add (adaptor, action_path, label, stock, important);
- else
- glade_widget_adaptor_action_add (adaptor, action_path, label, stock, important);
-
- if (group) gwa_action_update_from_node (adaptor, is_packing, child, domain, action_path);
-
- g_free (id);
- g_free (label);
- g_free (stock);
- if (group_path) g_free (action_path);
- }
+gwa_action_update_from_node (GladeWidgetAdaptor * adaptor,
+ gboolean is_packing,
+ GladeXmlNode * node,
+ const gchar * domain, gchar * group_path)
+{
+ GladeXmlNode *child;
+ gchar *id, *label, *stock, *action_path;
+ gboolean group, important;
+
+ for (child = glade_xml_node_get_children (node);
+ child; child = glade_xml_node_next (child))
+ {
+ if ((group =
+ glade_xml_node_verify_silent (child, GLADE_TAG_ACTION)) == FALSE)
+ continue;
+
+ id = glade_xml_get_property_string_required
+ (child, GLADE_TAG_ID, adaptor->name);
+ if (id == NULL)
+ continue;
+
+ if (group_path)
+ action_path = g_strdup_printf ("%s/%s", group_path, id);
+ else
+ action_path = id;
+
+ label = glade_xml_get_property_string (child, GLADE_TAG_NAME);
+ stock = glade_xml_get_property_string (child, GLADE_TAG_STOCK);
+ important =
+ glade_xml_get_property_boolean (child, GLADE_TAG_IMPORTANT, FALSE);
+
+ if (label)
+ {
+ gchar *translated = dgettext (domain, label);
+ if (label != translated)
+ {
+ g_free (label);
+ label = g_strdup (translated);
+ }
+ }
+
+ if (is_packing)
+ glade_widget_adaptor_pack_action_add (adaptor, action_path, label,
+ stock, important);
+ else
+ glade_widget_adaptor_action_add (adaptor, action_path, label, stock,
+ important);
+
+ if (group)
+ gwa_action_update_from_node (adaptor, is_packing, child, domain,
+ action_path);
+
+ g_free (id);
+ g_free (label);
+ g_free (stock);
+ if (group_path)
+ g_free (action_path);
+ }
}
static void
-gwa_set_signals_from_node (GladeWidgetAdaptor *adaptor,
- GladeXmlNode *node)
-{
- GladeXmlNode *child;
- GladeSignalClass *signal;
- GList *list;
- gchar *id;
-
- for (child = glade_xml_node_get_children (node);
- child; child = glade_xml_node_next (child))
- {
- if (!glade_xml_node_verify (child, GLADE_TAG_SIGNAL))
- continue;
-
- if (!(id = glade_xml_get_property_string_required (child, GLADE_TAG_ID, NULL)))
- continue;
-
- if ((list =
- g_list_find_custom (adaptor->signals, id,
- (GCompareFunc)gwa_signal_find_comp)) != NULL)
- {
- signal = list->data;
- glade_xml_get_property_version
- (child, GLADE_TAG_VERSION_SINCE,
- &signal->version_since_major,
- &signal->version_since_minor);
- }
- g_free (id);
- }
+gwa_set_signals_from_node (GladeWidgetAdaptor * adaptor, GladeXmlNode * node)
+{
+ GladeXmlNode *child;
+ GladeSignalClass *signal;
+ GList *list;
+ gchar *id;
+
+ for (child = glade_xml_node_get_children (node);
+ child; child = glade_xml_node_next (child))
+ {
+ if (!glade_xml_node_verify (child, GLADE_TAG_SIGNAL))
+ continue;
+
+ if (!
+ (id =
+ glade_xml_get_property_string_required (child, GLADE_TAG_ID, NULL)))
+ continue;
+
+ if ((list =
+ g_list_find_custom (adaptor->signals, id,
+ (GCompareFunc) gwa_signal_find_comp)) != NULL)
+ {
+ signal = list->data;
+ glade_xml_get_property_version
+ (child, GLADE_TAG_VERSION_SINCE,
+ &signal->version_since_major, &signal->version_since_minor);
+ }
+ g_free (id);
+ }
}
static gboolean
-gwa_extend_with_node (GladeWidgetAdaptor *adaptor,
- GladeXmlNode *node,
- GModule *module,
- const gchar *domain)
-{
- GladeXmlNode *child;
- gchar *child_type;
-
- /* Override the special-child-type here */
- if ((child_type =
- glade_xml_get_value_string (node, GLADE_TAG_SPECIAL_CHILD_TYPE)) != NULL)
- adaptor->priv->special_child_type =
- (g_free (adaptor->priv->special_child_type), child_type);
-
- if ((child =
- glade_xml_search_child (node, GLADE_TAG_PROPERTIES)) != NULL)
- gwa_update_properties_from_node
- (adaptor, child, module, &adaptor->properties, domain, FALSE);
-
- if ((child =
- glade_xml_search_child (node, GLADE_TAG_PACKING_PROPERTIES)) != NULL)
- gwa_update_properties_from_node
- (adaptor, child, module, &adaptor->packing_props, domain, TRUE);
-
- if ((child =
- glade_xml_search_child (node, GLADE_TAG_PACKING_DEFAULTS)) != NULL)
- gwa_set_packing_defaults_from_node (adaptor, child);
-
- if ((child =
- glade_xml_search_child (node, GLADE_TAG_SIGNALS)) != NULL)
- gwa_set_signals_from_node (adaptor, child);
-
- if ((child =
- glade_xml_search_child (node, GLADE_TAG_ACTIONS)) != NULL)
- gwa_action_update_from_node (adaptor, FALSE, child, domain, NULL);
-
- if ((child =
- glade_xml_search_child (node, GLADE_TAG_PACKING_ACTIONS)) != NULL)
- gwa_action_update_from_node (adaptor, TRUE, child, domain, NULL);
-
- return TRUE;
+gwa_extend_with_node (GladeWidgetAdaptor * adaptor,
+ GladeXmlNode * node,
+ GModule * module, const gchar * domain)
+{
+ GladeXmlNode *child;
+ gchar *child_type;
+
+ /* Override the special-child-type here */
+ if ((child_type =
+ glade_xml_get_value_string (node, GLADE_TAG_SPECIAL_CHILD_TYPE)) != NULL)
+ adaptor->priv->special_child_type =
+ (g_free (adaptor->priv->special_child_type), child_type);
+
+ if ((child = glade_xml_search_child (node, GLADE_TAG_PROPERTIES)) != NULL)
+ gwa_update_properties_from_node
+ (adaptor, child, module, &adaptor->properties, domain, FALSE);
+
+ if ((child =
+ glade_xml_search_child (node, GLADE_TAG_PACKING_PROPERTIES)) != NULL)
+ gwa_update_properties_from_node
+ (adaptor, child, module, &adaptor->packing_props, domain, TRUE);
+
+ if ((child =
+ glade_xml_search_child (node, GLADE_TAG_PACKING_DEFAULTS)) != NULL)
+ gwa_set_packing_defaults_from_node (adaptor, child);
+
+ if ((child = glade_xml_search_child (node, GLADE_TAG_SIGNALS)) != NULL)
+ gwa_set_signals_from_node (adaptor, child);
+
+ if ((child = glade_xml_search_child (node, GLADE_TAG_ACTIONS)) != NULL)
+ gwa_action_update_from_node (adaptor, FALSE, child, domain, NULL);
+
+ if ((child =
+ glade_xml_search_child (node, GLADE_TAG_PACKING_ACTIONS)) != NULL)
+ gwa_action_update_from_node (adaptor, TRUE, child, domain, NULL);
+
+ return TRUE;
}
/**
@@ -2165,94 +2166,91 @@ gwa_extend_with_node (GladeWidgetAdaptor *adaptor,
* Returns: An icon name, or NULL if the object class does not require one.
*/
static gchar *
-create_icon_name_for_object_class (const gchar *class_name,
- GType class_type,
- const gchar *icon_name,
- const gchar *icon_prefix,
- const gchar *generic_name)
-{
- gchar *name;
-
- /* only certain object classes need to have icons */
- if (G_TYPE_IS_INSTANTIATABLE (class_type) == FALSE ||
- G_TYPE_IS_ABSTRACT (class_type) != FALSE ||
- generic_name == NULL)
- {
- return NULL;
- }
-
- /* if no icon name has been specified, we then fallback to a default icon name */
- if (!icon_name)
- name = g_strdup_printf ("widget-%s-%s", icon_prefix, generic_name);
- else
- name = g_strdup (icon_name);
-
- return name;
+create_icon_name_for_object_class (const gchar * class_name,
+ GType class_type,
+ const gchar * icon_name,
+ const gchar * icon_prefix,
+ const gchar * generic_name)
+{
+ gchar *name;
+
+ /* only certain object classes need to have icons */
+ if (G_TYPE_IS_INSTANTIATABLE (class_type) == FALSE ||
+ G_TYPE_IS_ABSTRACT (class_type) != FALSE || generic_name == NULL)
+ {
+ return NULL;
+ }
+
+ /* if no icon name has been specified, we then fallback to a default icon name */
+ if (!icon_name)
+ name = g_strdup_printf ("widget-%s-%s", icon_prefix, generic_name);
+ else
+ name = g_strdup (icon_name);
+
+ return name;
}
static void
-gwa_displayable_values_check (GladeWidgetAdaptor *adaptor, gboolean packing)
-{
- GList *l, *p = (packing) ? adaptor->packing_props : adaptor->properties;
-
- for (l = p; l; l = g_list_next (l))
- {
- GladePropertyClass *klass = l->data;
-
- if (adaptor->type == klass->pspec->owner_type && klass->visible &&
- (G_IS_PARAM_SPEC_ENUM (klass->pspec) || G_IS_PARAM_SPEC_FLAGS (klass->pspec)) &&
- !glade_type_has_displayable_values (klass->pspec->value_type) &&
- klass->pspec->value_type != GLADE_TYPE_STOCK &&
- klass->pspec->value_type != GLADE_TYPE_STOCK_IMAGE)
- {
- /* We do not need displayable values if the property is not visible */
- g_message ("No displayable values for %sproperty %s::%s",
- (packing) ? "child " : "",
- adaptor->name, klass->id);
- }
- }
+gwa_displayable_values_check (GladeWidgetAdaptor * adaptor, gboolean packing)
+{
+ GList *l, *p = (packing) ? adaptor->packing_props : adaptor->properties;
+
+ for (l = p; l; l = g_list_next (l))
+ {
+ GladePropertyClass *klass = l->data;
+
+ if (adaptor->type == klass->pspec->owner_type && klass->visible &&
+ (G_IS_PARAM_SPEC_ENUM (klass->pspec) ||
+ G_IS_PARAM_SPEC_FLAGS (klass->pspec)) &&
+ !glade_type_has_displayable_values (klass->pspec->value_type) &&
+ klass->pspec->value_type != GLADE_TYPE_STOCK &&
+ klass->pspec->value_type != GLADE_TYPE_STOCK_IMAGE)
+ {
+ /* We do not need displayable values if the property is not visible */
+ g_message ("No displayable values for %sproperty %s::%s",
+ (packing) ? "child " : "", adaptor->name, klass->id);
+ }
+ }
}
static GType
-generate_type (const char *name,
- const char *parent_name)
-{
- GType parent_type, retval;
- GTypeQuery query;
- GTypeInfo *type_info;
- char *new_name;
-
- g_return_val_if_fail (name != NULL, 0);
- g_return_val_if_fail (parent_name != NULL, 0);
-
- parent_type = glade_util_get_type_from_name (parent_name, FALSE);
- g_return_val_if_fail (parent_type != 0, 0);
-
- g_type_query (parent_type, &query);
- g_return_val_if_fail (query.type != 0, 0);
-
- /*
- * If the type already exist it means we want to use the parent type
- * instead of the real one at runtime.
- * This is currently used to instantiate GtkWindow as a GtkEventBox
- * at runtime.
- */
- if (g_type_from_name (name))
- new_name = g_strdup_printf ("GladeFake%s", name);
- else
- new_name = NULL;
-
- type_info = g_new0 (GTypeInfo, 1);
- type_info->class_size = query.class_size;
- type_info->instance_size = query.instance_size;
-
- retval = g_type_register_static (parent_type,
- (new_name) ? new_name : name,
- type_info, 0);
-
- g_free (new_name);
-
- return retval;
+generate_type (const char *name, const char *parent_name)
+{
+ GType parent_type, retval;
+ GTypeQuery query;
+ GTypeInfo *type_info;
+ char *new_name;
+
+ g_return_val_if_fail (name != NULL, 0);
+ g_return_val_if_fail (parent_name != NULL, 0);
+
+ parent_type = glade_util_get_type_from_name (parent_name, FALSE);
+ g_return_val_if_fail (parent_type != 0, 0);
+
+ g_type_query (parent_type, &query);
+ g_return_val_if_fail (query.type != 0, 0);
+
+ /*
+ * If the type already exist it means we want to use the parent type
+ * instead of the real one at runtime.
+ * This is currently used to instantiate GtkWindow as a GtkEventBox
+ * at runtime.
+ */
+ if (g_type_from_name (name))
+ new_name = g_strdup_printf ("GladeFake%s", name);
+ else
+ new_name = NULL;
+
+ type_info = g_new0 (GTypeInfo, 1);
+ type_info->class_size = query.class_size;
+ type_info->instance_size = query.instance_size;
+
+ retval = g_type_register_static (parent_type,
+ (new_name) ? new_name : name, type_info, 0);
+
+ g_free (new_name);
+
+ return retval;
}
@@ -2267,227 +2265,234 @@ generate_type (const char *name,
* prior to child classes, otherwise inheritance wont work) and parses in
* the relevent catalog info.
*/
-GladeWidgetAdaptor *
-glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
- GladeXmlNode *class_node,
- GModule *module)
-{
- GladeWidgetAdaptor *adaptor = NULL;
- gchar *name, *generic_name, *icon_name, *adaptor_icon_name, *adaptor_name, *func_name;
- gchar *title, *translated_title, *parent_name;
- GType object_type, adaptor_type, parent_type;
- gchar *missing_icon = NULL;
- GWADerivedClassData data;
-
-
- if (!glade_xml_node_verify (class_node, GLADE_TAG_GLADE_WIDGET_CLASS))
- {
- g_warning ("Widget class node is not '%s'",
- GLADE_TAG_GLADE_WIDGET_CLASS);
- return NULL;
- }
-
- if ((name = glade_xml_get_property_string_required
- (class_node, GLADE_TAG_NAME, NULL)) == NULL)
- return NULL;
-
- /* Either get the instance type by:
- *
- * - Autosubclassing a specified parent type (a fake widget class)
- * - parsing the _get_type() function directly from the catalog
- * - deriving foo_bar_get_type() from the name FooBar and loading that.
- */
- if ((parent_name = glade_xml_get_property_string (class_node, GLADE_TAG_PARENT)) != NULL)
- {
- if (!glade_widget_adaptor_get_by_name (parent_name))
- {
- g_warning ("Trying to define class '%s' for parent class '%s', but parent class '%s' "
- "is not registered", name, parent_name, parent_name);
- g_free (name);
- g_free (parent_name);
- return NULL;
- }
- object_type = generate_type (name, parent_name);
- g_free (parent_name);
- }
- else if ((func_name = glade_xml_get_property_string (class_node, GLADE_TAG_GET_TYPE_FUNCTION)) != NULL)
- object_type = glade_util_get_type_from_name (func_name, TRUE);
- else
- {
- GType type_iter;
-
- object_type = glade_util_get_type_from_name (name, FALSE);
-
- for (type_iter = g_type_parent (object_type);
- type_iter;
- type_iter = g_type_parent (type_iter))
- {
- GladeWidgetAdaptor *a = glade_widget_adaptor_get_by_name (g_type_name (type_iter));
-
- if (a && a->real_type != a->type)
- {
- object_type = generate_type (name, g_type_name (a->type));
- break;
- }
- }
- }
-
- if (object_type == 0)
- {
- g_warning ("Failed to load the GType for '%s'", name);
- g_free (name);
- return NULL;
- }
-
- if (glade_widget_adaptor_get_by_type (object_type))
- {
- g_warning ("Adaptor class for '%s' already defined",
- g_type_name (object_type));
- g_free (name);
- return NULL;
- }
-
- if ((adaptor_name = glade_xml_get_property_string (class_node, GLADE_TAG_ADAPTOR)))
- adaptor_type = g_type_from_name (adaptor_name);
- else
- {
- /*
- * We use this struct pointer to pass data to
- * gwa_derived_class_init() because we must override constructor()
- * from the catalog before calling g_object_new() :P
- */
- data.node = class_node;
- data.module = module;
- adaptor_type = gwa_derive_adaptor_for_type (object_type, &data);
- }
-
- if (adaptor_type == 0)
- {
- g_warning ("Failed to get %s's adaptor %s", name,
- (adaptor_name) ? adaptor_name : "");
- g_free (adaptor_name);
- g_free (name);
- return NULL;
- }
-
- generic_name = glade_xml_get_property_string (class_node, GLADE_TAG_GENERIC_NAME);
- icon_name = glade_xml_get_property_string (class_node, GLADE_TAG_ICON_NAME);
-
- /* get a suitable icon name for adaptor */
- adaptor_icon_name =
- create_icon_name_for_object_class (name,
- object_type,
- icon_name,
- glade_catalog_get_icon_prefix (catalog),
- generic_name);
-
-
- /* check if icon is available (a null icon-name is an abstract class) */
- if (adaptor_icon_name &&
- !gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), adaptor_icon_name))
- {
- GladeWidgetAdaptor *parent =
- glade_widget_adaptor_get_parent_adaptor_by_type (object_type);
-
- /* Save the desired name */
- missing_icon = adaptor_icon_name;
-
- adaptor_icon_name = g_strdup ((parent && parent->icon_name) ?
- parent->icon_name : DEFAULT_ICON_NAME);
-
- }
-
- adaptor = g_object_new (adaptor_type,
- "type", object_type,
- "name", name,
- "catalog", glade_catalog_get_name (catalog),
- "generic-name", generic_name,
- "icon-name", adaptor_icon_name,
- NULL);
-
- adaptor->missing_icon = missing_icon;
-
- g_free (generic_name);
- g_free (icon_name);
- g_free (adaptor_icon_name);
-
-
- title = glade_xml_get_property_string_required (class_node,
- GLADE_TAG_TITLE,
- "This value is needed to "
- "display object class names "
- "in the UI");
- if (title == NULL)
- {
- g_warning ("Class '%s' declared without a '%s' attribute", name, GLADE_TAG_TITLE);
- adaptor->title = g_strdup (name);
- }
- else
- {
- /* translate */
- translated_title = dgettext (glade_catalog_get_domain (catalog), title);
- if (translated_title != title)
- {
- /* gettext owns translated_title */
- adaptor->title = g_strdup (translated_title);
- g_free (title);
- }
- else
- {
- adaptor->title = title;
- }
- }
-
- if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) &&
- G_TYPE_IS_ABSTRACT (adaptor->type) == FALSE &&
- adaptor->generic_name == NULL)
- {
- g_warning ("Instantiatable class '%s' built without a '%s'",
- name, GLADE_TAG_GENERIC_NAME);
- }
-
- /* if adaptor->type (the runtime used by glade) differs from adaptor->name
- * (the name specified in the catalog) means we are using the type specified in the
- * the parent tag as the runtime and the class already exist.
- * So we need to add the properties and signals from the real class
- * even though they wont be aplied at runtime.
- */
- if (adaptor->type != adaptor->real_type)
- {
- adaptor->signals = gwa_list_signals (adaptor, adaptor->real_type);
-
- gwa_update_properties_from_type (adaptor, adaptor->real_type,
- &adaptor->properties, FALSE);
- gwa_update_properties_from_type (adaptor, adaptor->real_type,
- &adaptor->packing_props, TRUE);
- }
-
- /* Perform a stoopid fallback just incase */
- if (adaptor->generic_name == NULL)
- adaptor->generic_name = g_strdup ("widget");
-
- adaptor->priv->catalog = g_strdup (glade_catalog_get_name (catalog));
-
- if (glade_catalog_get_book (catalog))
- adaptor->priv->book = g_strdup (glade_catalog_get_book (catalog));
-
- gwa_extend_with_node (adaptor, class_node, module, glade_catalog_get_domain (catalog));
-
- /* Set default weight on properties */
- for (parent_type = adaptor->type;
- parent_type != 0;
- parent_type = g_type_parent (parent_type))
- {
- gwa_properties_set_weight (&adaptor->properties, parent_type);
- gwa_properties_set_weight (&adaptor->packing_props, parent_type);
- }
-
- gwa_displayable_values_check (adaptor, FALSE);
- gwa_displayable_values_check (adaptor, TRUE);
-
- glade_widget_adaptor_register (adaptor);
-
- return adaptor;
+GladeWidgetAdaptor *
+glade_widget_adaptor_from_catalog (GladeCatalog * catalog,
+ GladeXmlNode * class_node, GModule * module)
+{
+ GladeWidgetAdaptor *adaptor = NULL;
+ gchar *name, *generic_name, *icon_name, *adaptor_icon_name, *adaptor_name,
+ *func_name;
+ gchar *title, *translated_title, *parent_name;
+ GType object_type, adaptor_type, parent_type;
+ gchar *missing_icon = NULL;
+ GWADerivedClassData data;
+
+
+ if (!glade_xml_node_verify (class_node, GLADE_TAG_GLADE_WIDGET_CLASS))
+ {
+ g_warning ("Widget class node is not '%s'", GLADE_TAG_GLADE_WIDGET_CLASS);
+ return NULL;
+ }
+
+ if ((name = glade_xml_get_property_string_required
+ (class_node, GLADE_TAG_NAME, NULL)) == NULL)
+ return NULL;
+
+ /* Either get the instance type by:
+ *
+ * - Autosubclassing a specified parent type (a fake widget class)
+ * - parsing the _get_type() function directly from the catalog
+ * - deriving foo_bar_get_type() from the name FooBar and loading that.
+ */
+ if ((parent_name =
+ glade_xml_get_property_string (class_node, GLADE_TAG_PARENT)) != NULL)
+ {
+ if (!glade_widget_adaptor_get_by_name (parent_name))
+ {
+ g_warning
+ ("Trying to define class '%s' for parent class '%s', but parent class '%s' "
+ "is not registered", name, parent_name, parent_name);
+ g_free (name);
+ g_free (parent_name);
+ return NULL;
+ }
+ object_type = generate_type (name, parent_name);
+ g_free (parent_name);
+ }
+ else if ((func_name =
+ glade_xml_get_property_string (class_node,
+ GLADE_TAG_GET_TYPE_FUNCTION)) !=
+ NULL)
+ object_type = glade_util_get_type_from_name (func_name, TRUE);
+ else
+ {
+ GType type_iter;
+
+ object_type = glade_util_get_type_from_name (name, FALSE);
+
+ for (type_iter = g_type_parent (object_type);
+ type_iter; type_iter = g_type_parent (type_iter))
+ {
+ GladeWidgetAdaptor *a =
+ glade_widget_adaptor_get_by_name (g_type_name (type_iter));
+
+ if (a && a->real_type != a->type)
+ {
+ object_type = generate_type (name, g_type_name (a->type));
+ break;
+ }
+ }
+ }
+
+ if (object_type == 0)
+ {
+ g_warning ("Failed to load the GType for '%s'", name);
+ g_free (name);
+ return NULL;
+ }
+
+ if (glade_widget_adaptor_get_by_type (object_type))
+ {
+ g_warning ("Adaptor class for '%s' already defined",
+ g_type_name (object_type));
+ g_free (name);
+ return NULL;
+ }
+
+ if ((adaptor_name =
+ glade_xml_get_property_string (class_node, GLADE_TAG_ADAPTOR)))
+ adaptor_type = g_type_from_name (adaptor_name);
+ else
+ {
+ /*
+ * We use this struct pointer to pass data to
+ * gwa_derived_class_init() because we must override constructor()
+ * from the catalog before calling g_object_new() :P
+ */
+ data.node = class_node;
+ data.module = module;
+ adaptor_type = gwa_derive_adaptor_for_type (object_type, &data);
+ }
+
+ if (adaptor_type == 0)
+ {
+ g_warning ("Failed to get %s's adaptor %s", name,
+ (adaptor_name) ? adaptor_name : "");
+ g_free (adaptor_name);
+ g_free (name);
+ return NULL;
+ }
+
+ generic_name =
+ glade_xml_get_property_string (class_node, GLADE_TAG_GENERIC_NAME);
+ icon_name = glade_xml_get_property_string (class_node, GLADE_TAG_ICON_NAME);
+
+ /* get a suitable icon name for adaptor */
+ adaptor_icon_name =
+ create_icon_name_for_object_class (name,
+ object_type,
+ icon_name,
+ glade_catalog_get_icon_prefix
+ (catalog), generic_name);
+
+
+ /* check if icon is available (a null icon-name is an abstract class) */
+ if (adaptor_icon_name &&
+ !gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
+ adaptor_icon_name))
+ {
+ GladeWidgetAdaptor *parent =
+ glade_widget_adaptor_get_parent_adaptor_by_type (object_type);
+
+ /* Save the desired name */
+ missing_icon = adaptor_icon_name;
+
+ adaptor_icon_name = g_strdup ((parent && parent->icon_name) ?
+ parent->icon_name : DEFAULT_ICON_NAME);
+
+ }
+
+ adaptor = g_object_new (adaptor_type,
+ "type", object_type,
+ "name", name,
+ "catalog", glade_catalog_get_name (catalog),
+ "generic-name", generic_name,
+ "icon-name", adaptor_icon_name, NULL);
+
+ adaptor->missing_icon = missing_icon;
+
+ g_free (generic_name);
+ g_free (icon_name);
+ g_free (adaptor_icon_name);
+
+
+ title = glade_xml_get_property_string_required (class_node,
+ GLADE_TAG_TITLE,
+ "This value is needed to "
+ "display object class names "
+ "in the UI");
+ if (title == NULL)
+ {
+ g_warning ("Class '%s' declared without a '%s' attribute", name,
+ GLADE_TAG_TITLE);
+ adaptor->title = g_strdup (name);
+ }
+ else
+ {
+ /* translate */
+ translated_title = dgettext (glade_catalog_get_domain (catalog), title);
+ if (translated_title != title)
+ {
+ /* gettext owns translated_title */
+ adaptor->title = g_strdup (translated_title);
+ g_free (title);
+ }
+ else
+ {
+ adaptor->title = title;
+ }
+ }
+
+ if (G_TYPE_IS_INSTANTIATABLE (adaptor->type) &&
+ G_TYPE_IS_ABSTRACT (adaptor->type) == FALSE &&
+ adaptor->generic_name == NULL)
+ {
+ g_warning ("Instantiatable class '%s' built without a '%s'",
+ name, GLADE_TAG_GENERIC_NAME);
+ }
+
+ /* if adaptor->type (the runtime used by glade) differs from adaptor->name
+ * (the name specified in the catalog) means we are using the type specified in the
+ * the parent tag as the runtime and the class already exist.
+ * So we need to add the properties and signals from the real class
+ * even though they wont be aplied at runtime.
+ */
+ if (adaptor->type != adaptor->real_type)
+ {
+ adaptor->signals = gwa_list_signals (adaptor, adaptor->real_type);
+
+ gwa_update_properties_from_type (adaptor, adaptor->real_type,
+ &adaptor->properties, FALSE);
+ gwa_update_properties_from_type (adaptor, adaptor->real_type,
+ &adaptor->packing_props, TRUE);
+ }
+
+ /* Perform a stoopid fallback just incase */
+ if (adaptor->generic_name == NULL)
+ adaptor->generic_name = g_strdup ("widget");
+
+ adaptor->priv->catalog = g_strdup (glade_catalog_get_name (catalog));
+
+ if (glade_catalog_get_book (catalog))
+ adaptor->priv->book = g_strdup (glade_catalog_get_book (catalog));
+
+ gwa_extend_with_node (adaptor, class_node, module,
+ glade_catalog_get_domain (catalog));
+
+ /* Set default weight on properties */
+ for (parent_type = adaptor->type;
+ parent_type != 0; parent_type = g_type_parent (parent_type))
+ {
+ gwa_properties_set_weight (&adaptor->properties, parent_type);
+ gwa_properties_set_weight (&adaptor->packing_props, parent_type);
+ }
+
+ gwa_displayable_values_check (adaptor, FALSE);
+ gwa_displayable_values_check (adaptor, TRUE);
+
+ glade_widget_adaptor_register (adaptor);
+
+ return adaptor;
}
/**
@@ -2511,36 +2516,35 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
* @internal_object of name @internal_name
*/
GladeWidget *
-glade_widget_adaptor_create_internal (GladeWidget *parent,
- GObject *internal_object,
- const gchar *internal_name,
- const gchar *parent_name,
- gboolean anarchist,
- GladeCreateReason reason)
-{
- GladeWidgetAdaptor *adaptor;
- GladeProject *project;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL);
- project = glade_widget_get_project (parent);
-
- if ((adaptor = glade_widget_adaptor_get_by_name
- (G_OBJECT_TYPE_NAME (internal_object))) == NULL)
- {
- g_critical ("Unable to find widget class for type %s",
- G_OBJECT_TYPE_NAME (internal_object));
- return NULL;
- }
-
- return glade_widget_adaptor_create_widget (adaptor, FALSE,
- "anarchist", anarchist,
- "parent", parent,
- "project", project,
- "internal", internal_name,
- "internal-name", parent_name,
- "reason", reason,
- "object", internal_object,
- NULL);
+glade_widget_adaptor_create_internal (GladeWidget * parent,
+ GObject * internal_object,
+ const gchar * internal_name,
+ const gchar * parent_name,
+ gboolean anarchist,
+ GladeCreateReason reason)
+{
+ GladeWidgetAdaptor *adaptor;
+ GladeProject *project;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL);
+ project = glade_widget_get_project (parent);
+
+ if ((adaptor = glade_widget_adaptor_get_by_name
+ (G_OBJECT_TYPE_NAME (internal_object))) == NULL)
+ {
+ g_critical ("Unable to find widget class for type %s",
+ G_OBJECT_TYPE_NAME (internal_object));
+ return NULL;
+ }
+
+ return glade_widget_adaptor_create_widget (adaptor, FALSE,
+ "anarchist", anarchist,
+ "parent", parent,
+ "project", project,
+ "internal", internal_name,
+ "internal-name", parent_name,
+ "reason", reason,
+ "object", internal_object, NULL);
}
/**
@@ -2565,63 +2569,66 @@ glade_widget_adaptor_create_internal (GladeWidget *parent,
* this macro returns the newly created #GladeWidget
*/
GladeWidget *
-glade_widget_adaptor_create_widget_real (gboolean query,
- const gchar *first_property,
- ...)
+glade_widget_adaptor_create_widget_real (gboolean query,
+ const gchar * first_property, ...)
{
- GladeWidgetAdaptor *adaptor;
- GladeWidget *gwidget;
- va_list vl, vl_copy;
+ GladeWidgetAdaptor *adaptor;
+ GladeWidget *gwidget;
+ va_list vl, vl_copy;
- g_return_val_if_fail (strcmp (first_property, "adaptor") == 0, NULL);
+ g_return_val_if_fail (strcmp (first_property, "adaptor") == 0, NULL);
- va_start (vl, first_property);
- va_copy (vl_copy, vl);
+ va_start (vl, first_property);
+ va_copy (vl_copy, vl);
- adaptor = va_arg (vl, GladeWidgetAdaptor *);
+ adaptor = va_arg (vl, GladeWidgetAdaptor *);
- va_end (vl);
+ va_end (vl);
- if (GLADE_IS_WIDGET_ADAPTOR (adaptor) == FALSE)
- {
- g_critical ("No adaptor found in glade_widget_adaptor_create_widget_real args");
- va_end (vl_copy);
- return NULL;
- }
+ if (GLADE_IS_WIDGET_ADAPTOR (adaptor) == FALSE)
+ {
+ g_critical
+ ("No adaptor found in glade_widget_adaptor_create_widget_real args");
+ va_end (vl_copy);
+ return NULL;
+ }
- gwidget = GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->create_widget (adaptor, first_property, vl_copy);
+ gwidget =
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->create_widget (adaptor,
+ first_property,
+ vl_copy);
- va_end (vl_copy);
-
- if (query && glade_widget_adaptor_query (adaptor))
- {
- GladeEditor *editor = glade_app_get_editor ();
-
- /* If user pressed cancel on query popup. */
- if (!glade_editor_query_dialog (editor, gwidget))
- {
- g_object_unref (G_OBJECT (gwidget));
- return NULL;
- }
- }
+ va_end (vl_copy);
- return gwidget;
+ if (query && glade_widget_adaptor_query (adaptor))
+ {
+ GladeEditor *editor = glade_app_get_editor ();
+
+ /* If user pressed cancel on query popup. */
+ if (!glade_editor_query_dialog (editor, gwidget))
+ {
+ g_object_unref (G_OBJECT (gwidget));
+ return NULL;
+ }
+ }
+
+ return gwidget;
}
typedef struct
{
- const gchar *name;
- GladeWidgetAdaptor *adaptor;
+ const gchar *name;
+ GladeWidgetAdaptor *adaptor;
} GladeAdaptorSearchPair;
static void
-search_adaptor_by_name (GType *type,
- GladeWidgetAdaptor *adaptor,
- GladeAdaptorSearchPair *pair)
+search_adaptor_by_name (GType * type,
+ GladeWidgetAdaptor * adaptor,
+ GladeAdaptorSearchPair * pair)
{
- if (!strcmp (adaptor->name, pair->name))
- pair->adaptor = adaptor;
+ if (!strcmp (adaptor->name, pair->name))
+ pair->adaptor = adaptor;
}
/**
@@ -2631,19 +2638,19 @@ search_adaptor_by_name (GType *type,
* Returns: an existing #GladeWidgetAdaptor with the name equaling @name,
* or %NULL if such a class doesn't exist
**/
-GladeWidgetAdaptor *
-glade_widget_adaptor_get_by_name (const gchar *name)
+GladeWidgetAdaptor *
+glade_widget_adaptor_get_by_name (const gchar * name)
{
- GladeAdaptorSearchPair pair = { name, NULL };
-
- if (adaptor_hash != NULL)
- {
- g_hash_table_foreach (adaptor_hash,
- (GHFunc)search_adaptor_by_name, &pair);
- }
- return pair.adaptor;
+ GladeAdaptorSearchPair pair = { name, NULL };
+
+ if (adaptor_hash != NULL)
+ {
+ g_hash_table_foreach (adaptor_hash,
+ (GHFunc) search_adaptor_by_name, &pair);
+ }
+ return pair.adaptor;
}
@@ -2654,13 +2661,13 @@ glade_widget_adaptor_get_by_name (const gchar *name)
* Returns: an existing #GladeWidgetAdaptor with the type equaling @type,
* or %NULL if such a class doesn't exist
**/
-GladeWidgetAdaptor *
-glade_widget_adaptor_get_by_type (GType type)
+GladeWidgetAdaptor *
+glade_widget_adaptor_get_by_type (GType type)
{
- if (adaptor_hash != NULL)
- return g_hash_table_lookup (adaptor_hash, &type);
- else
- return NULL;
+ if (adaptor_hash != NULL)
+ return g_hash_table_lookup (adaptor_hash, &type);
+ else
+ return NULL;
}
/**
@@ -2675,30 +2682,30 @@ glade_widget_adaptor_get_by_type (GType type)
* Returns: the closest #GladeWidgetAdaptor in the ancestry to @adaptor
* which is responsable for introducing @pspec.
**/
-GladeWidgetAdaptor *
-glade_widget_adaptor_from_pspec (GladeWidgetAdaptor *adaptor,
- GParamSpec *spec)
+GladeWidgetAdaptor *
+glade_widget_adaptor_from_pspec (GladeWidgetAdaptor * adaptor,
+ GParamSpec * spec)
{
- GladeWidgetAdaptor *spec_adaptor;
- GType spec_type = spec->owner_type;
+ GladeWidgetAdaptor *spec_adaptor;
+ GType spec_type = spec->owner_type;
- if (!spec_type)
- return adaptor;
+ if (!spec_type)
+ return adaptor;
- spec_adaptor = glade_widget_adaptor_get_by_type (spec->owner_type);
+ spec_adaptor = glade_widget_adaptor_get_by_type (spec->owner_type);
- g_return_val_if_fail (g_type_is_a (adaptor->type, spec->owner_type), NULL);
+ g_return_val_if_fail (g_type_is_a (adaptor->type, spec->owner_type), NULL);
- while (spec_type && !spec_adaptor && spec_type != adaptor->type)
- {
- spec_type = g_type_parent (spec_type);
- spec_adaptor = glade_widget_adaptor_get_by_type (spec_type);
- }
-
- if (spec_adaptor)
- return spec_adaptor;
+ while (spec_type && !spec_adaptor && spec_type != adaptor->type)
+ {
+ spec_type = g_type_parent (spec_type);
+ spec_adaptor = glade_widget_adaptor_get_by_type (spec_type);
+ }
- return adaptor;
+ if (spec_adaptor)
+ return spec_adaptor;
+
+ return adaptor;
}
/**
@@ -2710,20 +2717,20 @@ glade_widget_adaptor_from_pspec (GladeWidgetAdaptor *adaptor,
*
* Returns: A #GladePropertyClass object
*/
-GladePropertyClass *
-glade_widget_adaptor_get_property_class (GladeWidgetAdaptor *adaptor,
- const gchar *name)
+GladePropertyClass *
+glade_widget_adaptor_get_property_class (GladeWidgetAdaptor * adaptor,
+ const gchar * name)
{
- GList *list;
- GladePropertyClass *pclass;
+ GList *list;
+ GladePropertyClass *pclass;
- for (list = adaptor->properties; list && list->data; list = list->next)
- {
- pclass = list->data;
- if (strcmp (pclass->id, name) == 0)
- return pclass;
- }
- return NULL;
+ for (list = adaptor->properties; list && list->data; list = list->next)
+ {
+ pclass = list->data;
+ if (strcmp (pclass->id, name) == 0)
+ return pclass;
+ }
+ return NULL;
}
/**
@@ -2736,20 +2743,20 @@ glade_widget_adaptor_get_property_class (GladeWidgetAdaptor *adaptor,
*
* Returns: A #GladePropertyClass object
*/
-GladePropertyClass *
-glade_widget_adaptor_get_pack_property_class (GladeWidgetAdaptor *adaptor,
- const gchar *name)
+GladePropertyClass *
+glade_widget_adaptor_get_pack_property_class (GladeWidgetAdaptor * adaptor,
+ const gchar * name)
{
- GList *list;
- GladePropertyClass *pclass;
+ GList *list;
+ GladePropertyClass *pclass;
- for (list = adaptor->packing_props; list && list->data; list = list->next)
- {
- pclass = list->data;
- if (strcmp (pclass->id, name) == 0)
- return pclass;
- }
- return NULL;
+ for (list = adaptor->packing_props; list && list->data; list = list->next)
+ {
+ pclass = list->data;
+ if (strcmp (pclass->id, name) == 0)
+ return pclass;
+ }
+ return NULL;
}
/**
@@ -2761,73 +2768,69 @@ glade_widget_adaptor_get_pack_property_class (GladeWidgetAdaptor *adaptor,
* Returns: A list of params for use in g_object_newv ()
*/
GParameter *
-glade_widget_adaptor_default_params (GladeWidgetAdaptor *adaptor,
- gboolean construct,
- guint *n_params)
-{
- GArray *params;
- GObjectClass *oclass;
- GParamSpec **pspec;
- GladePropertyClass *pclass;
- guint n_props, i;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (n_params != NULL, NULL);
-
- /* As a slight optimization, we never unref the class
- */
- oclass = g_type_class_ref (adaptor->type);
- pspec = g_object_class_list_properties (oclass, &n_props);
- params = g_array_new (FALSE, FALSE, sizeof (GParameter));
-
- for (i = 0; i < n_props; i++)
- {
- GParameter parameter = { 0, };
-
- pclass = glade_widget_adaptor_get_property_class
- (adaptor, pspec[i]->name);
-
- /* Ignore properties based on some criteria
- */
- if (pclass == NULL || /* Unaccounted for in the builder */
- pclass->virt || /* should not be set before
- GladeWidget wrapper exists */
- pclass->ignore) /* Catalog explicitly ignores the object */
- continue;
-
- if (construct &&
- (pspec[i]->flags &
- (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0)
- continue;
- else if (!construct &&
- (pspec[i]->flags &
- (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0)
- continue;
-
-
- if (g_value_type_compatible (G_VALUE_TYPE (pclass->def),
- pspec[i]->value_type) == FALSE)
- {
- g_critical ("Type mismatch on %s property of %s",
- parameter.name, adaptor->name);
- continue;
- }
-
- if (g_param_values_cmp (pspec[i],
- pclass->def,
- pclass->orig_def) == 0)
- continue;
-
- parameter.name = pspec[i]->name; /* These are not copied/freed */
- g_value_init (¶meter.value, pspec[i]->value_type);
- g_value_copy (pclass->def, ¶meter.value);
-
- g_array_append_val (params, parameter);
- }
- g_free (pspec);
-
- *n_params = params->len;
- return (GParameter *)g_array_free (params, FALSE);
+glade_widget_adaptor_default_params (GladeWidgetAdaptor * adaptor,
+ gboolean construct, guint * n_params)
+{
+ GArray *params;
+ GObjectClass *oclass;
+ GParamSpec **pspec;
+ GladePropertyClass *pclass;
+ guint n_props, i;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (n_params != NULL, NULL);
+
+ /* As a slight optimization, we never unref the class
+ */
+ oclass = g_type_class_ref (adaptor->type);
+ pspec = g_object_class_list_properties (oclass, &n_props);
+ params = g_array_new (FALSE, FALSE, sizeof (GParameter));
+
+ for (i = 0; i < n_props; i++)
+ {
+ GParameter parameter = { 0, };
+
+ pclass = glade_widget_adaptor_get_property_class
+ (adaptor, pspec[i]->name);
+
+ /* Ignore properties based on some criteria
+ */
+ if (pclass == NULL || /* Unaccounted for in the builder */
+ pclass->virt || /* should not be set before
+ GladeWidget wrapper exists */
+ pclass->ignore) /* Catalog explicitly ignores the object */
+ continue;
+
+ if (construct &&
+ (pspec[i]->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0)
+ continue;
+ else if (!construct &&
+ (pspec[i]->flags &
+ (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) != 0)
+ continue;
+
+
+ if (g_value_type_compatible (G_VALUE_TYPE (pclass->def),
+ pspec[i]->value_type) == FALSE)
+ {
+ g_critical ("Type mismatch on %s property of %s",
+ parameter.name, adaptor->name);
+ continue;
+ }
+
+ if (g_param_values_cmp (pspec[i], pclass->def, pclass->orig_def) == 0)
+ continue;
+
+ parameter.name = pspec[i]->name; /* These are not copied/freed */
+ g_value_init (¶meter.value, pspec[i]->value_type);
+ g_value_copy (pclass->def, ¶meter.value);
+
+ g_array_append_val (params, parameter);
+ }
+ g_free (pspec);
+
+ *n_params = params->len;
+ return (GParameter *) g_array_free (params, FALSE);
}
/**
@@ -2844,13 +2847,15 @@ glade_widget_adaptor_default_params (GladeWidgetAdaptor *adaptor,
* Returns: A newly created #GObject
*/
GObject *
-glade_widget_adaptor_construct_object (GladeWidgetAdaptor *adaptor,
- guint n_parameters,
- GParameter *parameters)
+glade_widget_adaptor_construct_object (GladeWidgetAdaptor * adaptor,
+ guint n_parameters,
+ GParameter * parameters)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->construct_object (adaptor, n_parameters, parameters);
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->construct_object (adaptor,
+ n_parameters,
+ parameters);
}
/**
@@ -2862,24 +2867,25 @@ glade_widget_adaptor_construct_object (GladeWidgetAdaptor *adaptor,
* An adaptor function to be called after the object is created
*/
void
-glade_widget_adaptor_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
-
- /* Run post_create in 2 stages, one that chains up and all class adaptors
- * in the hierarchy get a peek, another that is used to setup placeholders
- * and things that differ from the child/parent implementations
- */
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->deep_post_create)
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->deep_post_create (adaptor, object, reason);
-
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->post_create)
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->post_create (adaptor, object, reason);
- /* XXX Dont complain here if no implementation is found */
+glade_widget_adaptor_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
+{
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
+
+ /* Run post_create in 2 stages, one that chains up and all class adaptors
+ * in the hierarchy get a peek, another that is used to setup placeholders
+ * and things that differ from the child/parent implementations
+ */
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->deep_post_create)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->deep_post_create (adaptor, object,
+ reason);
+
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->post_create)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->post_create (adaptor, object,
+ reason);
+ /* XXX Dont complain here if no implementation is found */
}
/**
@@ -2893,22 +2899,23 @@ glade_widget_adaptor_post_create (GladeWidgetAdaptor *adaptor,
* Returns: The internal #GObject
*/
GObject *
-glade_widget_adaptor_get_internal_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *internal_name)
+glade_widget_adaptor_get_internal_child (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * internal_name)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
- g_return_val_if_fail (internal_name != NULL, NULL);
- g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+ g_return_val_if_fail (internal_name != NULL, NULL);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type),
+ NULL);
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_internal_child)
- return GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->get_internal_child (adaptor, object, internal_name);
- else
- g_critical ("No get_internal_child() support in adaptor %s", adaptor->name);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_internal_child)
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->get_internal_child (adaptor, object, internal_name);
+ else
+ g_critical ("No get_internal_child() support in adaptor %s", adaptor->name);
- return NULL;
+ return NULL;
}
/**
@@ -2923,19 +2930,19 @@ glade_widget_adaptor_get_internal_child (GladeWidgetAdaptor *adaptor,
*
*/
void
-glade_widget_adaptor_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_widget_adaptor_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (property_name != NULL && value != NULL);
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
- /* The base class provides an implementation */
- GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->set_property (adaptor, object, property_name, value);
+ /* The base class provides an implementation */
+ GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->set_property (adaptor, object, property_name, value);
}
@@ -2950,19 +2957,18 @@ glade_widget_adaptor_set_property (GladeWidgetAdaptor *adaptor,
*
*/
void
-glade_widget_adaptor_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- GValue *value)
+glade_widget_adaptor_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name, GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (property_name != NULL && value != NULL);
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
- /* The base class provides an implementation */
- GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->get_property (adaptor, object, property_name, value);
+ /* The base class provides an implementation */
+ GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->get_property (adaptor, object, property_name, value);
}
@@ -2983,21 +2989,22 @@ glade_widget_adaptor_get_property (GladeWidgetAdaptor *adaptor,
* will silently return TRUE if the class did not provide a verify function.
*/
gboolean
-glade_widget_adaptor_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_widget_adaptor_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
- g_return_val_if_fail (property_name != NULL && value != NULL, FALSE);
- g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
+ g_return_val_if_fail (property_name != NULL && value != NULL, FALSE);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type),
+ FALSE);
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->verify_property)
- return GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->verify_property (adaptor, object, property_name, value);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->verify_property)
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->verify_property (adaptor, object, property_name, value);
- return TRUE;
+ return TRUE;
}
/**
@@ -3009,19 +3016,18 @@ glade_widget_adaptor_verify_property (GladeWidgetAdaptor *adaptor,
* Adds @child to @container.
*/
void
-glade_widget_adaptor_add (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_widget_adaptor_add (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (container));
- g_return_if_fail (G_IS_OBJECT (child));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (container));
+ g_return_if_fail (G_IS_OBJECT (child));
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add)
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add (adaptor, container, child);
- else
- g_critical ("No add() support in adaptor %s", adaptor->name);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add (adaptor, container, child);
+ else
+ g_critical ("No add() support in adaptor %s", adaptor->name);
}
@@ -3034,19 +3040,19 @@ glade_widget_adaptor_add (GladeWidgetAdaptor *adaptor,
* Removes @child from @container.
*/
void
-glade_widget_adaptor_remove (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_widget_adaptor_remove (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (container));
- g_return_if_fail (G_IS_OBJECT (child));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (container));
+ g_return_if_fail (G_IS_OBJECT (child));
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove)
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove (adaptor, container, child);
- else
- g_critical ("No remove() support in adaptor %s", adaptor->name);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove (adaptor, container,
+ child);
+ else
+ g_critical ("No remove() support in adaptor %s", adaptor->name);
}
/**
@@ -3059,20 +3065,21 @@ glade_widget_adaptor_remove (GladeWidgetAdaptor *adaptor,
* Returns: A #GList of children
*/
GList *
-glade_widget_adaptor_get_children (GladeWidgetAdaptor *adaptor,
- GObject *container)
+glade_widget_adaptor_get_children (GladeWidgetAdaptor * adaptor,
+ GObject * container)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (G_IS_OBJECT (container), NULL);
- g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (G_IS_OBJECT (container), NULL);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type),
+ NULL);
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_children)
- return GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->get_children (adaptor, container);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_children)
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->get_children (adaptor, container);
- /* Dont complain here if no implementation is found */
+ /* Dont complain here if no implementation is found */
- return NULL;
+ return NULL;
}
/**
@@ -3084,26 +3091,25 @@ glade_widget_adaptor_get_children (GladeWidgetAdaptor *adaptor,
* Returns: whether @child is infact inside @container.
*/
gboolean
-glade_widget_adaptor_has_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_widget_adaptor_has_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- GList *list, *children = NULL;
- gboolean found = FALSE;
+ GList *list, *children = NULL;
+ gboolean found = FALSE;
- children = glade_widget_adaptor_get_children (adaptor, container);
+ children = glade_widget_adaptor_get_children (adaptor, container);
- for (list = children; list && list->data; list = list->next)
- {
- if (list->data == child)
- {
- found = TRUE;
- break;
- }
- }
+ for (list = children; list && list->data; list = list->next)
+ {
+ if (list->data == child)
+ {
+ found = TRUE;
+ break;
+ }
+ }
- g_list_free (children);
- return found;
+ g_list_free (children);
+ return found;
}
/**
@@ -3117,24 +3123,24 @@ glade_widget_adaptor_has_child (GladeWidgetAdaptor *adaptor,
* Sets @child's packing property identified by @property_name to @value.
*/
void
-glade_widget_adaptor_child_set_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
+glade_widget_adaptor_child_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (container));
- g_return_if_fail (G_IS_OBJECT (child));
- g_return_if_fail (property_name != NULL && value != NULL);
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (container));
+ g_return_if_fail (G_IS_OBJECT (child));
+ g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_set_property)
- GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->child_set_property (adaptor, container, child,
- property_name, value);
- else
- g_critical ("No child_set_property() support in adaptor %s", adaptor->name);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_set_property)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->child_set_property (adaptor, container, child,
+ property_name, value);
+ else
+ g_critical ("No child_set_property() support in adaptor %s", adaptor->name);
}
@@ -3149,24 +3155,24 @@ glade_widget_adaptor_child_set_property (GladeWidgetAdaptor *adaptor,
* Gets @child's packing property identified by @property_name.
*/
void
-glade_widget_adaptor_child_get_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (container));
- g_return_if_fail (G_IS_OBJECT (child));
- g_return_if_fail (property_name != NULL && value != NULL);
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
-
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_get_property)
- GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->child_get_property (adaptor, container, child,
- property_name, value);
- else
- g_critical ("No child_set_property() support in adaptor %s", adaptor->name);
+glade_widget_adaptor_child_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (container));
+ g_return_if_fail (G_IS_OBJECT (child));
+ g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
+
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_get_property)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->child_get_property (adaptor, container, child,
+ property_name, value);
+ else
+ g_critical ("No child_set_property() support in adaptor %s", adaptor->name);
}
/**
@@ -3187,25 +3193,26 @@ glade_widget_adaptor_child_get_property (GladeWidgetAdaptor *adaptor,
* will silently return TRUE if the class did not provide a verify function.
*/
gboolean
-glade_widget_adaptor_child_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
+glade_widget_adaptor_child_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (G_IS_OBJECT (container), FALSE);
- g_return_val_if_fail (G_IS_OBJECT (child), FALSE);
- g_return_val_if_fail (property_name != NULL && value != NULL, FALSE);
- g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (container), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (child), FALSE);
+ g_return_val_if_fail (property_name != NULL && value != NULL, FALSE);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type),
+ FALSE);
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_verify_property)
- return GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->child_verify_property (adaptor,
- container, child,
- property_name, value);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_verify_property)
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->child_verify_property (adaptor,
+ container, child,
+ property_name, value);
- return TRUE;
+ return TRUE;
}
@@ -3221,22 +3228,21 @@ glade_widget_adaptor_child_verify_property (GladeWidgetAdaptor *adaptor,
* property values.
*/
void
-glade_widget_adaptor_replace_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *old_obj,
- GObject *new_obj)
+glade_widget_adaptor_replace_child (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * old_obj, GObject * new_obj)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (container));
- g_return_if_fail (G_IS_OBJECT (old_obj));
- g_return_if_fail (G_IS_OBJECT (new_obj));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (container));
+ g_return_if_fail (G_IS_OBJECT (old_obj));
+ g_return_if_fail (G_IS_OBJECT (new_obj));
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->replace_child)
- GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->replace_child (adaptor, container, old_obj, new_obj);
- else
- g_critical ("No replace_child() support in adaptor %s", adaptor->name);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->replace_child)
+ GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->replace_child (adaptor, container, old_obj, new_obj);
+ else
+ g_critical ("No replace_child() support in adaptor %s", adaptor->name);
}
/**
@@ -3247,22 +3253,22 @@ glade_widget_adaptor_replace_child (GladeWidgetAdaptor *adaptor,
* certain properties upon creation of this class.
*/
gboolean
-glade_widget_adaptor_query (GladeWidgetAdaptor *adaptor)
+glade_widget_adaptor_query (GladeWidgetAdaptor * adaptor)
{
- GladePropertyClass *pclass;
- GList *l;
+ GladePropertyClass *pclass;
+ GList *l;
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- for (l = adaptor->properties; l; l = l->next)
- {
- pclass = l->data;
+ for (l = adaptor->properties; l; l = l->next)
+ {
+ pclass = l->data;
- if (pclass->query)
- return TRUE;
- }
+ if (pclass->query)
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
/**
@@ -3277,29 +3283,30 @@ glade_widget_adaptor_query (GladeWidgetAdaptor *adaptor)
* Returns: a string representing the default value for @property_id
*/
G_CONST_RETURN gchar *
-glade_widget_adaptor_get_packing_default (GladeWidgetAdaptor *child_adaptor,
- GladeWidgetAdaptor *container_adaptor,
- const gchar *id)
-{
- GladeChildPacking *packing = NULL;
- GList *l;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (child_adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (container_adaptor), NULL);
-
- if ((packing =
- glade_widget_adaptor_get_child_packing (child_adaptor,
- container_adaptor->name)) != NULL)
- {
- for (l = packing->packing_defaults; l; l = l->next)
- {
- GladePackingDefault *def = l->data;
-
- if (strcmp (def->id, id) == 0)
- return def->value;
- }
- }
- return NULL;
+glade_widget_adaptor_get_packing_default (GladeWidgetAdaptor * child_adaptor,
+ GladeWidgetAdaptor *
+ container_adaptor, const gchar * id)
+{
+ GladeChildPacking *packing = NULL;
+ GList *l;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (child_adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (container_adaptor), NULL);
+
+ if ((packing =
+ glade_widget_adaptor_get_child_packing (child_adaptor,
+ container_adaptor->name)) !=
+ NULL)
+ {
+ for (l = packing->packing_defaults; l; l = l->next)
+ {
+ GladePackingDefault *def = l->data;
+
+ if (strcmp (def->id, id) == 0)
+ return def->value;
+ }
+ }
+ return NULL;
}
/**
@@ -3312,115 +3319,118 @@ glade_widget_adaptor_get_packing_default (GladeWidgetAdaptor *child_adaptor,
* Returns: whether or not @adaptor is a container
*/
gboolean
-glade_widget_adaptor_is_container (GladeWidgetAdaptor *adaptor)
+glade_widget_adaptor_is_container (GladeWidgetAdaptor * adaptor)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- /* A GWA container must at least implement add/remove/get_children
- */
- return (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add &&
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove &&
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_children);
+ /* A GWA container must at least implement add/remove/get_children
+ */
+ return (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->add &&
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->remove &&
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->get_children);
}
static const gchar *
-gwa_action_path_get_id (const gchar *action_path)
+gwa_action_path_get_id (const gchar * action_path)
{
- const gchar *id;
-
- if ((id = g_strrstr (action_path, "/")) && id[1] != '\0')
- return &id[1];
- else
- return action_path;
+ const gchar *id;
+
+ if ((id = g_strrstr (action_path, "/")) && id[1] != '\0')
+ return &id[1];
+ else
+ return action_path;
}
static GWActionClass *
-gwa_action_lookup (GList *actions, const gchar *action_id)
+gwa_action_lookup (GList * actions, const gchar * action_id)
{
- GList *l;
-
- for (l = actions; l; l = g_list_next (l))
- {
- GWActionClass *action = l->data;
- if (strcmp (action->id, action_id) == 0)
- return action;
- }
-
- return NULL;
+ GList *l;
+
+ for (l = actions; l; l = g_list_next (l))
+ {
+ GWActionClass *action = l->data;
+ if (strcmp (action->id, action_id) == 0)
+ return action;
+ }
+
+ return NULL;
}
static GWActionClass *
-gwa_action_get_last_group (GList *actions, const gchar *action_path)
-{
- gchar **tokens = g_strsplit (action_path, "/", 0);
- GWActionClass *group = NULL;
- gint i;
-
- for (i = 0; tokens[i] && tokens[i+1]; i++)
- {
- if ((group = gwa_action_lookup (actions, tokens[i])) == NULL)
- {
- g_strfreev (tokens);
- return NULL;
- }
- actions = group->actions;
- }
-
- g_strfreev (tokens);
- return group;
+gwa_action_get_last_group (GList * actions, const gchar * action_path)
+{
+ gchar **tokens = g_strsplit (action_path, "/", 0);
+ GWActionClass *group = NULL;
+ gint i;
+
+ for (i = 0; tokens[i] && tokens[i + 1]; i++)
+ {
+ if ((group = gwa_action_lookup (actions, tokens[i])) == NULL)
+ {
+ g_strfreev (tokens);
+ return NULL;
+ }
+ actions = group->actions;
+ }
+
+ g_strfreev (tokens);
+ return group;
}
static gboolean
-glade_widget_adaptor_action_add_real (GList **list,
- const gchar *action_path,
- const gchar *label,
- const gchar *stock,
- gboolean important)
-{
- GWActionClass *action, *group;
- const gchar *id;
-
- id = gwa_action_path_get_id (action_path);
-
- if ((group = gwa_action_get_last_group (*list, action_path)))
- list = &group->actions;
-
- if ((action = gwa_action_lookup (*list, id)))
- {
- /* Update parent's label/stock */
- if (label && action->label)
- {
- g_free (action->label);
- if (strcmp (label, "") == 0) label = NULL;
- action->label = (label) ? g_strdup (label) : NULL;
- }
- if (stock && action->stock)
- {
- g_free (action->stock);
- if (strcmp (stock, "") == 0) stock = NULL;
- action->stock = (stock) ? g_strdup (stock) : NULL;
- }
- }
- else
- {
- /* New Action */
- action = g_new0 (GWActionClass, 1);
- action->path = g_strdup (action_path);
- action->id = (gchar*) gwa_action_path_get_id (action->path);
-
- if (label && strcmp (label, "") == 0) label = NULL;
- if (stock && strcmp (stock, "") == 0) stock = NULL;
-
- action->label = (label) ? g_strdup (label) : NULL;
- action->stock = (stock) ? g_strdup (stock) : NULL;
- }
-
- action->important = important;
-
- *list = g_list_append (*list, action);
-
- return TRUE;
+glade_widget_adaptor_action_add_real (GList ** list,
+ const gchar * action_path,
+ const gchar * label,
+ const gchar * stock, gboolean important)
+{
+ GWActionClass *action, *group;
+ const gchar *id;
+
+ id = gwa_action_path_get_id (action_path);
+
+ if ((group = gwa_action_get_last_group (*list, action_path)))
+ list = &group->actions;
+
+ if ((action = gwa_action_lookup (*list, id)))
+ {
+ /* Update parent's label/stock */
+ if (label && action->label)
+ {
+ g_free (action->label);
+ if (strcmp (label, "") == 0)
+ label = NULL;
+ action->label = (label) ? g_strdup (label) : NULL;
+ }
+ if (stock && action->stock)
+ {
+ g_free (action->stock);
+ if (strcmp (stock, "") == 0)
+ stock = NULL;
+ action->stock = (stock) ? g_strdup (stock) : NULL;
+ }
+ }
+ else
+ {
+ /* New Action */
+ action = g_new0 (GWActionClass, 1);
+ action->path = g_strdup (action_path);
+ action->id = (gchar *) gwa_action_path_get_id (action->path);
+
+ if (label && strcmp (label, "") == 0)
+ label = NULL;
+ if (stock && strcmp (stock, "") == 0)
+ stock = NULL;
+
+ action->label = (label) ? g_strdup (label) : NULL;
+ action->stock = (stock) ? g_strdup (stock) : NULL;
+ }
+
+ action->important = important;
+
+ *list = g_list_append (*list, action);
+
+ return TRUE;
}
/**
@@ -3437,20 +3447,17 @@ glade_widget_adaptor_action_add_real (GList **list,
* Returns: whether or not the action was added/updated.
*/
gboolean
-glade_widget_adaptor_action_add (GladeWidgetAdaptor *adaptor,
- const gchar *action_path,
- const gchar *label,
- const gchar *stock,
- gboolean important)
-{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (action_path != NULL, FALSE);
-
- return glade_widget_adaptor_action_add_real (&adaptor->actions,
- action_path,
- label,
- stock,
- important);
+glade_widget_adaptor_action_add (GladeWidgetAdaptor * adaptor,
+ const gchar * action_path,
+ const gchar * label,
+ const gchar * stock, gboolean important)
+{
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (action_path != NULL, FALSE);
+
+ return glade_widget_adaptor_action_add_real (&adaptor->actions,
+ action_path,
+ label, stock, important);
}
/**
@@ -3467,40 +3474,39 @@ glade_widget_adaptor_action_add (GladeWidgetAdaptor *adaptor,
* Returns: whether or not the action was added/updated.
*/
gboolean
-glade_widget_adaptor_pack_action_add (GladeWidgetAdaptor *adaptor,
- const gchar *action_path,
- const gchar *label,
- const gchar *stock,
- gboolean important)
-{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (action_path != NULL, FALSE);
-
- return glade_widget_adaptor_action_add_real (&adaptor->packing_actions,
- action_path,
- label,
- stock,
- important);
+glade_widget_adaptor_pack_action_add (GladeWidgetAdaptor * adaptor,
+ const gchar * action_path,
+ const gchar * label,
+ const gchar * stock, gboolean important)
+{
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (action_path != NULL, FALSE);
+
+ return glade_widget_adaptor_action_add_real (&adaptor->packing_actions,
+ action_path,
+ label, stock, important);
}
static gboolean
-glade_widget_adaptor_action_remove_real (GList **list, const gchar *action_path)
+glade_widget_adaptor_action_remove_real (GList ** list,
+ const gchar * action_path)
{
- GWActionClass *action, *group;
- const gchar *id;
-
- id = gwa_action_path_get_id (action_path);
-
- if ((group = gwa_action_get_last_group (*list, action_path)))
- list = &group->actions;
+ GWActionClass *action, *group;
+ const gchar *id;
+
+ id = gwa_action_path_get_id (action_path);
+
+ if ((group = gwa_action_get_last_group (*list, action_path)))
+ list = &group->actions;
+
+ if ((action = gwa_action_lookup (*list, id)) == NULL)
+ return FALSE;
- if ((action = gwa_action_lookup (*list, id)) == NULL) return FALSE;
-
- *list = g_list_remove (*list, action);
-
- glade_widget_action_class_free (action);
-
- return TRUE;
+ *list = g_list_remove (*list, action);
+
+ glade_widget_action_class_free (action);
+
+ return TRUE;
}
/**
@@ -3513,14 +3519,14 @@ glade_widget_adaptor_action_remove_real (GList **list, const gchar *action_path)
* Returns: whether or not the action was removed.
*/
gboolean
-glade_widget_adaptor_action_remove (GladeWidgetAdaptor *adaptor,
- const gchar *action_path)
+glade_widget_adaptor_action_remove (GladeWidgetAdaptor * adaptor,
+ const gchar * action_path)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (action_path != NULL, FALSE);
-
- return glade_widget_adaptor_action_remove_real (&adaptor->actions,
- action_path);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (action_path != NULL, FALSE);
+
+ return glade_widget_adaptor_action_remove_real (&adaptor->actions,
+ action_path);
}
/**
@@ -3533,14 +3539,14 @@ glade_widget_adaptor_action_remove (GladeWidgetAdaptor *adaptor,
* Returns: whether or not the action was removed.
*/
gboolean
-glade_widget_adaptor_pack_action_remove (GladeWidgetAdaptor *adaptor,
- const gchar *action_path)
+glade_widget_adaptor_pack_action_remove (GladeWidgetAdaptor * adaptor,
+ const gchar * action_path)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (action_path != NULL, FALSE);
-
- return glade_widget_adaptor_action_remove_real (&adaptor->packing_actions,
- action_path);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (action_path != NULL, FALSE);
+
+ return glade_widget_adaptor_action_remove_real (&adaptor->packing_actions,
+ action_path);
}
@@ -3553,21 +3559,21 @@ glade_widget_adaptor_pack_action_remove (GladeWidgetAdaptor *adaptor,
* Returns: a new list of GladeWidgetAction.
*/
GList *
-glade_widget_adaptor_pack_actions_new (GladeWidgetAdaptor *adaptor)
-{
- GList *l, *list = NULL;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
-
- for (l = adaptor->packing_actions; l; l = g_list_next (l))
- {
- GWActionClass *action = l->data;
- GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
- "class", action, NULL);
-
- list = g_list_prepend (list, GLADE_WIDGET_ACTION (obj));
- }
- return g_list_reverse (list);
+glade_widget_adaptor_pack_actions_new (GladeWidgetAdaptor * adaptor)
+{
+ GList *l, *list = NULL;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+
+ for (l = adaptor->packing_actions; l; l = g_list_next (l))
+ {
+ GWActionClass *action = l->data;
+ GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
+ "class", action, NULL);
+
+ list = g_list_prepend (list, GLADE_WIDGET_ACTION (obj));
+ }
+ return g_list_reverse (list);
}
/**
@@ -3579,15 +3585,16 @@ glade_widget_adaptor_pack_actions_new (GladeWidgetAdaptor *adaptor)
* An adaptor function to be called on widget actions.
*/
void
-glade_widget_adaptor_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
+glade_widget_adaptor_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_activate (adaptor, object, action_path);
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_activate (adaptor, object,
+ action_path);
}
/**
@@ -3599,17 +3606,20 @@ glade_widget_adaptor_action_activate (GladeWidgetAdaptor *adaptor,
* An adaptor function to be called on widget actions.
*/
void
-glade_widget_adaptor_child_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *action_path)
+glade_widget_adaptor_child_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * action_path)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (G_IS_OBJECT (container));
- g_return_if_fail (G_IS_OBJECT (object));
- g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (G_IS_OBJECT (container));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_action_activate (adaptor, container, object, action_path);
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_action_activate (adaptor,
+ container,
+ object,
+ action_path);
}
/**
@@ -3624,18 +3634,21 @@ glade_widget_adaptor_child_action_activate (GladeWidgetAdaptor *adaptor,
* Returns: A newly created #GtkMenu or %NULL
*/
GtkWidget *
-glade_widget_adaptor_action_submenu (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
+glade_widget_adaptor_action_submenu (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
- g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type),
+ NULL);
- if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_submenu)
- return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_submenu (adaptor, object, action_path);
+ if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_submenu)
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_submenu (adaptor,
+ object,
+ action_path);
- return NULL;
+ return NULL;
}
/**
@@ -3651,15 +3664,15 @@ glade_widget_adaptor_action_submenu (GladeWidgetAdaptor *adaptor,
* the resulting glade file.
*/
gboolean
-glade_widget_adaptor_depends (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeWidget *another)
+glade_widget_adaptor_depends (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeWidget * another)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (GLADE_IS_WIDGET (another), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (another), FALSE);
- return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->depends (adaptor, widget, another);
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->depends (adaptor, widget,
+ another);
}
/**
@@ -3672,15 +3685,14 @@ glade_widget_adaptor_depends (GladeWidgetAdaptor *adaptor,
* when loading xml files.
*/
void
-glade_widget_adaptor_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_widget_adaptor_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (node != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (node != NULL);
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->read_widget (adaptor, widget, node);
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->read_widget (adaptor, widget, node);
}
@@ -3695,17 +3707,17 @@ glade_widget_adaptor_read_widget (GladeWidgetAdaptor *adaptor,
* when writing xml files.
*/
void
-glade_widget_adaptor_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_widget_adaptor_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (node != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (node != NULL);
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->write_widget (adaptor, widget,
- context, node);
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->write_widget (adaptor, widget,
+ context, node);
}
@@ -3720,15 +3732,14 @@ glade_widget_adaptor_write_widget (GladeWidgetAdaptor *adaptor,
* glade_widget_read())
*/
void
-glade_widget_adaptor_read_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_widget_adaptor_read_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (node != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (node != NULL);
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->read_child (adaptor, widget, node);
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->read_child (adaptor, widget, node);
}
@@ -3744,17 +3755,17 @@ glade_widget_adaptor_read_child (GladeWidgetAdaptor *adaptor,
* into glade_widget_write())
*/
void
-glade_widget_adaptor_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_widget_adaptor_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (node != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (node != NULL);
- GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->write_child (adaptor, widget,
- context, node);
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->write_child (adaptor, widget,
+ context, node);
}
@@ -3770,22 +3781,22 @@ glade_widget_adaptor_write_child (GladeWidgetAdaptor *adaptor,
* Returns: A newly created #GladeEditorProperty
*/
GladeEditorProperty *
-glade_widget_adaptor_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
+glade_widget_adaptor_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ gboolean use_command)
{
- GladeEditorProperty *eprop;
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
+ GladeEditorProperty *eprop;
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
- eprop = GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->create_eprop (adaptor, klass, use_command);
+ eprop = GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->create_eprop (adaptor, klass, use_command);
- /* XXX we really need to print a g_error() here, exept we are
- * now using this func to test for unsupported properties
- * at init time from glade-property-class */
+ /* XXX we really need to print a g_error() here, exept we are
+ * now using this func to test for unsupported properties
+ * at init time from glade-property-class */
- return eprop;
+ return eprop;
}
@@ -3803,24 +3814,24 @@ glade_widget_adaptor_create_eprop (GladeWidgetAdaptor *adaptor,
* Returns: A newly created #GladeEditorProperty
*/
GladeEditorProperty *
-glade_widget_adaptor_create_eprop_by_name (GladeWidgetAdaptor *adaptor,
- const gchar *property_id,
- gboolean packing,
- gboolean use_command)
+glade_widget_adaptor_create_eprop_by_name (GladeWidgetAdaptor * adaptor,
+ const gchar * property_id,
+ gboolean packing,
+ gboolean use_command)
{
- GladePropertyClass *klass;
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (property_id && property_id[0], NULL);
+ GladePropertyClass *klass;
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (property_id && property_id[0], NULL);
- if (packing)
- klass = glade_widget_adaptor_get_pack_property_class (adaptor, property_id);
- else
- klass = glade_widget_adaptor_get_property_class (adaptor, property_id);
+ if (packing)
+ klass = glade_widget_adaptor_get_pack_property_class (adaptor, property_id);
+ else
+ klass = glade_widget_adaptor_get_property_class (adaptor, property_id);
- g_return_val_if_fail (klass != NULL, NULL);
+ g_return_val_if_fail (klass != NULL, NULL);
- return GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->create_eprop (adaptor, klass, use_command);
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->create_eprop (adaptor, klass, use_command);
}
@@ -3837,15 +3848,17 @@ glade_widget_adaptor_create_eprop_by_name (GladeWidgetAdaptor *adaptor,
* Returns: A newly allocated string representation of @value
*/
gchar *
-glade_widget_adaptor_string_from_value (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- const GValue *value)
+glade_widget_adaptor_string_from_value (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ const GValue * value)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
- g_return_val_if_fail (value != NULL, NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_PROPERTY_CLASS (klass), NULL);
+ g_return_val_if_fail (value != NULL, NULL);
- return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->string_from_value (adaptor, klass, value);
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->string_from_value (adaptor,
+ klass,
+ value);
}
@@ -3859,23 +3872,23 @@ glade_widget_adaptor_string_from_value (GladeWidgetAdaptor *adaptor,
* Returns: a #GladeSignalClass or %NULL
*/
GladeSignalClass *
-glade_widget_adaptor_get_signal_class (GladeWidgetAdaptor *adaptor,
- const gchar *name)
+glade_widget_adaptor_get_signal_class (GladeWidgetAdaptor * adaptor,
+ const gchar * name)
{
- GList *list;
- GladeSignalClass *signal;
+ GList *list;
+ GladeSignalClass *signal;
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- for (list = adaptor->signals; list; list = list->next)
- {
- signal = list->data;
- if (!strcmp (signal->name, name))
- return signal;
- }
+ for (list = adaptor->signals; list; list = list->next)
+ {
+ signal = list->data;
+ if (!strcmp (signal->name, name))
+ return signal;
+ }
- return NULL;
+ return NULL;
}
@@ -3891,12 +3904,11 @@ glade_widget_adaptor_get_signal_class (GladeWidgetAdaptor *adaptor,
* Returns: A new #GladeEditable widget
*/
GladeEditable *
-glade_widget_adaptor_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_widget_adaptor_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- return GLADE_WIDGET_ADAPTOR_GET_CLASS
- (adaptor)->create_editable (adaptor, type);
+ return GLADE_WIDGET_ADAPTOR_GET_CLASS
+ (adaptor)->create_editable (adaptor, type);
}
-
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index 0ff4643..46b4cbb 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_WIDGET_ADAPTOR_H__
#define __GLADE_WIDGET_ADAPTOR_H__
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 5699399..92df27c 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom
* Copyright (C) 2004 Joaquin Cuenca Abela
@@ -59,48 +58,48 @@
-static void glade_widget_set_adaptor (GladeWidget *widget,
- GladeWidgetAdaptor *adaptor);
-static void glade_widget_set_properties (GladeWidget *widget,
- GList *properties);
-static void glade_widget_set_object (GladeWidget *gwidget,
- GObject *new_object,
- gboolean destroy);
+static void glade_widget_set_adaptor (GladeWidget * widget,
+ GladeWidgetAdaptor * adaptor);
+static void glade_widget_set_properties (GladeWidget * widget,
+ GList * properties);
+static void glade_widget_set_object (GladeWidget * gwidget,
+ GObject * new_object, gboolean destroy);
enum
{
- ADD_SIGNAL_HANDLER,
- REMOVE_SIGNAL_HANDLER,
- CHANGE_SIGNAL_HANDLER,
- BUTTON_PRESS_EVENT,
- BUTTON_RELEASE_EVENT,
- MOTION_NOTIFY_EVENT,
- SUPPORT_CHANGED,
- LAST_SIGNAL
+ ADD_SIGNAL_HANDLER,
+ REMOVE_SIGNAL_HANDLER,
+ CHANGE_SIGNAL_HANDLER,
+ BUTTON_PRESS_EVENT,
+ BUTTON_RELEASE_EVENT,
+ MOTION_NOTIFY_EVENT,
+ SUPPORT_CHANGED,
+ LAST_SIGNAL
};
enum
{
- PROP_0,
- PROP_NAME,
- PROP_INTERNAL,
- PROP_ANARCHIST,
- PROP_OBJECT,
- PROP_ADAPTOR,
- PROP_PROJECT,
- PROP_PROPERTIES,
- PROP_PARENT,
- PROP_INTERNAL_NAME,
- PROP_TEMPLATE,
- PROP_TEMPLATE_EXACT,
- PROP_REASON,
- PROP_TOPLEVEL_WIDTH,
- PROP_TOPLEVEL_HEIGHT,
- PROP_SUPPORT_WARNING
+ PROP_0,
+ PROP_NAME,
+ PROP_INTERNAL,
+ PROP_ANARCHIST,
+ PROP_OBJECT,
+ PROP_ADAPTOR,
+ PROP_PROJECT,
+ PROP_PROPERTIES,
+ PROP_PARENT,
+ PROP_INTERNAL_NAME,
+ PROP_TEMPLATE,
+ PROP_TEMPLATE_EXACT,
+ PROP_REASON,
+ PROP_TOPLEVEL_WIDTH,
+ PROP_TOPLEVEL_HEIGHT,
+ PROP_SUPPORT_WARNING
};
-static guint glade_widget_signals[LAST_SIGNAL] = {0};
-static GQuark glade_widget_name_quark = 0;
+static guint glade_widget_signals[LAST_SIGNAL] = { 0 };
+
+static GQuark glade_widget_name_quark = 0;
#define IS_GLADE_WIDGET_EVENT(event) \
@@ -109,294 +108,288 @@ static GQuark glade_widget_name_quark = 0;
(event) == GDK_MOTION_NOTIFY)
G_DEFINE_TYPE (GladeWidget, glade_widget, G_TYPE_INITIALLY_UNOWNED)
-
/*******************************************************************************
GladeWidget class methods
*******************************************************************************/
-static void
-glade_widget_set_packing_actions (GladeWidget *widget, GladeWidget *parent)
+ static void
+ glade_widget_set_packing_actions (GladeWidget * widget,
+ GladeWidget * parent)
{
- if (widget->packing_actions)
- {
- g_list_foreach (widget->packing_actions, (GFunc)g_object_unref, NULL);
- g_list_free (widget->packing_actions);
- widget->packing_actions = NULL;
- }
-
- if (parent->adaptor->packing_actions)
- widget->packing_actions = glade_widget_adaptor_pack_actions_new (parent->adaptor);
+ if (widget->packing_actions)
+ {
+ g_list_foreach (widget->packing_actions, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->packing_actions);
+ widget->packing_actions = NULL;
+ }
+
+ if (parent->adaptor->packing_actions)
+ widget->packing_actions =
+ glade_widget_adaptor_pack_actions_new (parent->adaptor);
}
static void
-glade_widget_add_child_impl (GladeWidget *widget,
- GladeWidget *child,
- gboolean at_mouse)
+glade_widget_add_child_impl (GladeWidget * widget,
+ GladeWidget * child, gboolean at_mouse)
{
- g_object_ref (child);
+ g_object_ref (child);
- /* Safe to set the parent first... setting it afterwards
- * creates packing properties, and that is not always
- * desirable.
- */
- glade_widget_set_parent (child, widget);
+ /* Safe to set the parent first... setting it afterwards
+ * creates packing properties, and that is not always
+ * desirable.
+ */
+ glade_widget_set_parent (child, widget);
- /* Set packing actions first so we have access from the plugin
- */
- glade_widget_set_packing_actions (child, widget);
-
- glade_widget_adaptor_add
- (widget->adaptor, widget->object, child->object);
-
- /* XXX FIXME:
- * We have a fundamental flaw here, we set packing props
- * after parenting the widget so that we can introspect the
- * values setup by the runtime widget, in which case the plugin
- * cannot access its packing properties and set them sensitive
- * or connect to thier signals etc. maybe its not so important
- * but its a flaw worthy of note, some kind of double pass api
- * would be needed to accomadate this.
- */
+ /* Set packing actions first so we have access from the plugin
+ */
+ glade_widget_set_packing_actions (child, widget);
-
- /* Setup packing properties here so we can introspect the new
- * values from the backend.
- */
- glade_widget_set_packing_properties (child, widget);
+ glade_widget_adaptor_add (widget->adaptor, widget->object, child->object);
+
+ /* XXX FIXME:
+ * We have a fundamental flaw here, we set packing props
+ * after parenting the widget so that we can introspect the
+ * values setup by the runtime widget, in which case the plugin
+ * cannot access its packing properties and set them sensitive
+ * or connect to thier signals etc. maybe its not so important
+ * but its a flaw worthy of note, some kind of double pass api
+ * would be needed to accomadate this.
+ */
+
+
+ /* Setup packing properties here so we can introspect the new
+ * values from the backend.
+ */
+ glade_widget_set_packing_properties (child, widget);
}
static void
-glade_widget_remove_child_impl (GladeWidget *widget,
- GladeWidget *child)
+glade_widget_remove_child_impl (GladeWidget * widget, GladeWidget * child)
{
- glade_widget_adaptor_remove
- (widget->adaptor, widget->object, child->object);
+ glade_widget_adaptor_remove (widget->adaptor, widget->object, child->object);
- child->parent = NULL;
+ child->parent = NULL;
- g_object_unref (child);
+ g_object_unref (child);
}
static void
-glade_widget_replace_child_impl (GladeWidget *widget,
- GObject *old_object,
- GObject *new_object)
+glade_widget_replace_child_impl (GladeWidget * widget,
+ GObject * old_object, GObject * new_object)
{
- GladeWidget *gnew_widget = glade_widget_get_from_gobject (new_object);
- GladeWidget *gold_widget = glade_widget_get_from_gobject (old_object);
+ GladeWidget *gnew_widget = glade_widget_get_from_gobject (new_object);
+ GladeWidget *gold_widget = glade_widget_get_from_gobject (old_object);
- if (gnew_widget)
- {
- g_object_ref (gnew_widget);
+ if (gnew_widget)
+ {
+ g_object_ref (gnew_widget);
- gnew_widget->parent = widget;
+ gnew_widget->parent = widget;
- /* Set packing actions first so we have access from the plugin
- */
- glade_widget_set_packing_actions (gnew_widget, widget);
- }
+ /* Set packing actions first so we have access from the plugin
+ */
+ glade_widget_set_packing_actions (gnew_widget, widget);
+ }
- if (gold_widget)
- {
- g_object_unref (gold_widget);
+ if (gold_widget)
+ {
+ g_object_unref (gold_widget);
- if (gold_widget != gnew_widget)
- gold_widget->parent = NULL;
- }
+ if (gold_widget != gnew_widget)
+ gold_widget->parent = NULL;
+ }
- glade_widget_adaptor_replace_child
- (widget->adaptor, widget->object,
- old_object, new_object);
+ glade_widget_adaptor_replace_child
+ (widget->adaptor, widget->object, old_object, new_object);
- /* Setup packing properties here so we can introspect the new
- * values from the backend.
- */
- if (gnew_widget)
- glade_widget_set_packing_properties (gnew_widget, widget);
+ /* Setup packing properties here so we can introspect the new
+ * values from the backend.
+ */
+ if (gnew_widget)
+ glade_widget_set_packing_properties (gnew_widget, widget);
}
static void
-glade_widget_add_signal_handler_impl (GladeWidget *widget, GladeSignal *signal_handler)
+glade_widget_add_signal_handler_impl (GladeWidget * widget,
+ GladeSignal * signal_handler)
{
- GPtrArray *signals;
- GladeSignal *new_signal_handler;
+ GPtrArray *signals;
+ GladeSignal *new_signal_handler;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_SIGNAL (signal_handler));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_SIGNAL (signal_handler));
- signals = glade_widget_list_signal_handlers (widget, signal_handler->name);
- if (!signals)
- {
- signals = g_ptr_array_new ();
- g_hash_table_insert (widget->signals, g_strdup (signal_handler->name), signals);
- }
+ signals = glade_widget_list_signal_handlers (widget, signal_handler->name);
+ if (!signals)
+ {
+ signals = g_ptr_array_new ();
+ g_hash_table_insert (widget->signals, g_strdup (signal_handler->name),
+ signals);
+ }
- new_signal_handler = glade_signal_clone (signal_handler);
- g_ptr_array_add (signals, new_signal_handler);
+ new_signal_handler = glade_signal_clone (signal_handler);
+ g_ptr_array_add (signals, new_signal_handler);
- glade_project_update_signal_support_warning (widget, new_signal_handler);
+ glade_project_update_signal_support_warning (widget, new_signal_handler);
}
static void
-glade_widget_remove_signal_handler_impl (GladeWidget *widget, GladeSignal *signal_handler)
+glade_widget_remove_signal_handler_impl (GladeWidget * widget,
+ GladeSignal * signal_handler)
{
- GPtrArray *signals;
- GladeSignal *tmp_signal_handler;
- guint i;
+ GPtrArray *signals;
+ GladeSignal *tmp_signal_handler;
+ guint i;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_SIGNAL (signal_handler));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_SIGNAL (signal_handler));
- signals = glade_widget_list_signal_handlers (widget, signal_handler->name);
+ signals = glade_widget_list_signal_handlers (widget, signal_handler->name);
- /* trying to remove an inexistent signal? */
- g_assert (signals);
+ /* trying to remove an inexistent signal? */
+ g_assert (signals);
- for (i = 0; i < signals->len; i++)
- {
- tmp_signal_handler = g_ptr_array_index (signals, i);
- if (glade_signal_equal (tmp_signal_handler, signal_handler))
- {
- glade_signal_free (tmp_signal_handler);
- g_ptr_array_remove_index (signals, i);
- break;
- }
- }
+ for (i = 0; i < signals->len; i++)
+ {
+ tmp_signal_handler = g_ptr_array_index (signals, i);
+ if (glade_signal_equal (tmp_signal_handler, signal_handler))
+ {
+ glade_signal_free (tmp_signal_handler);
+ g_ptr_array_remove_index (signals, i);
+ break;
+ }
+ }
}
static void
-glade_widget_change_signal_handler_impl (GladeWidget *widget,
- GladeSignal *old_signal_handler,
- GladeSignal *new_signal_handler)
-{
- GPtrArray *signals;
- GladeSignal *signal_handler_iter;
- guint i;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_SIGNAL (old_signal_handler));
- g_return_if_fail (GLADE_IS_SIGNAL (new_signal_handler));
- g_return_if_fail (strcmp (old_signal_handler->name, new_signal_handler->name) == 0);
-
- signals = glade_widget_list_signal_handlers (widget, old_signal_handler->name);
-
- /* trying to remove an inexistent signal? */
- g_assert (signals);
-
- for (i = 0; i < signals->len; i++)
- {
- signal_handler_iter = g_ptr_array_index (signals, i);
- if (glade_signal_equal (signal_handler_iter, old_signal_handler))
- {
- if (strcmp (old_signal_handler->handler,
- new_signal_handler->handler) != 0)
- {
- g_free (signal_handler_iter->handler);
- signal_handler_iter->handler =
- g_strdup (new_signal_handler->handler);
- }
-
- /* Handler */
- if (signal_handler_iter->handler)
- g_free (signal_handler_iter->handler);
- signal_handler_iter->handler =
- g_strdup (new_signal_handler->handler);
-
- /* Object */
- if (signal_handler_iter->userdata)
- g_free (signal_handler_iter->userdata);
- signal_handler_iter->userdata =
- g_strdup (new_signal_handler->userdata);
-
- signal_handler_iter->after = new_signal_handler->after;
- signal_handler_iter->swapped = new_signal_handler->swapped;
- break;
- }
- }
+glade_widget_change_signal_handler_impl (GladeWidget * widget,
+ GladeSignal * old_signal_handler,
+ GladeSignal * new_signal_handler)
+{
+ GPtrArray *signals;
+ GladeSignal *signal_handler_iter;
+ guint i;
+
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_SIGNAL (old_signal_handler));
+ g_return_if_fail (GLADE_IS_SIGNAL (new_signal_handler));
+ g_return_if_fail (strcmp (old_signal_handler->name, new_signal_handler->name)
+ == 0);
+
+ signals =
+ glade_widget_list_signal_handlers (widget, old_signal_handler->name);
+
+ /* trying to remove an inexistent signal? */
+ g_assert (signals);
+
+ for (i = 0; i < signals->len; i++)
+ {
+ signal_handler_iter = g_ptr_array_index (signals, i);
+ if (glade_signal_equal (signal_handler_iter, old_signal_handler))
+ {
+ if (strcmp (old_signal_handler->handler,
+ new_signal_handler->handler) != 0)
+ {
+ g_free (signal_handler_iter->handler);
+ signal_handler_iter->handler =
+ g_strdup (new_signal_handler->handler);
+ }
+
+ /* Handler */
+ if (signal_handler_iter->handler)
+ g_free (signal_handler_iter->handler);
+ signal_handler_iter->handler = g_strdup (new_signal_handler->handler);
+
+ /* Object */
+ if (signal_handler_iter->userdata)
+ g_free (signal_handler_iter->userdata);
+ signal_handler_iter->userdata =
+ g_strdup (new_signal_handler->userdata);
+
+ signal_handler_iter->after = new_signal_handler->after;
+ signal_handler_iter->swapped = new_signal_handler->swapped;
+ break;
+ }
+ }
}
static gboolean
-glade_widget_button_press_event_impl (GladeWidget *gwidget,
- GdkEvent *base_event)
-{
- GtkWidget *widget;
- GdkEventButton *event = (GdkEventButton *)base_event;
- gboolean handled = FALSE;
-
- /* make sure to grab focus, since we may stop default handlers */
- widget = GTK_WIDGET (glade_widget_get_object (gwidget));
- if (gtk_widget_get_can_focus (widget) && !gtk_widget_has_focus (widget))
- gtk_widget_grab_focus (widget);
-
- /* if it's already selected don't stop default handlers, e.g. toggle button */
- if (event->button == 1)
- {
- if (event->state & GDK_CONTROL_MASK)
- {
- if (glade_project_is_selected (gwidget->project,
- gwidget->object))
- glade_app_selection_remove
- (gwidget->object, TRUE);
- else
- glade_app_selection_add
- (gwidget->object, TRUE);
- handled = TRUE;
- }
- else if (glade_project_is_selected (gwidget->project,
- gwidget->object) == FALSE)
- {
- glade_util_clear_selection ();
- glade_app_selection_set
- (gwidget->object, TRUE);
-
- /* Add selection without interrupting event flow
- * when shift is down, this allows better behaviour
- * for GladeFixed children
- */
- handled = !(event->state & GDK_SHIFT_MASK);
- }
- }
-
- /* Give some kind of access in case of missing right button */
- if (!handled && glade_popup_is_popup_event (event))
- {
- glade_popup_widget_pop (gwidget, event, TRUE);
- handled = TRUE;
- }
-
- return handled;
+glade_widget_button_press_event_impl (GladeWidget * gwidget,
+ GdkEvent * base_event)
+{
+ GtkWidget *widget;
+ GdkEventButton *event = (GdkEventButton *) base_event;
+ gboolean handled = FALSE;
+
+ /* make sure to grab focus, since we may stop default handlers */
+ widget = GTK_WIDGET (glade_widget_get_object (gwidget));
+ if (gtk_widget_get_can_focus (widget) && !gtk_widget_has_focus (widget))
+ gtk_widget_grab_focus (widget);
+
+ /* if it's already selected don't stop default handlers, e.g. toggle button */
+ if (event->button == 1)
+ {
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ if (glade_project_is_selected (gwidget->project, gwidget->object))
+ glade_app_selection_remove (gwidget->object, TRUE);
+ else
+ glade_app_selection_add (gwidget->object, TRUE);
+ handled = TRUE;
+ }
+ else if (glade_project_is_selected (gwidget->project,
+ gwidget->object) == FALSE)
+ {
+ glade_util_clear_selection ();
+ glade_app_selection_set (gwidget->object, TRUE);
+
+ /* Add selection without interrupting event flow
+ * when shift is down, this allows better behaviour
+ * for GladeFixed children
+ */
+ handled = !(event->state & GDK_SHIFT_MASK);
+ }
+ }
+
+ /* Give some kind of access in case of missing right button */
+ if (!handled && glade_popup_is_popup_event (event))
+ {
+ glade_popup_widget_pop (gwidget, event, TRUE);
+ handled = TRUE;
+ }
+
+ return handled;
}
static gboolean
-glade_widget_event_impl (GladeWidget *gwidget,
- GdkEvent *event)
-{
- gboolean handled = FALSE;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (gwidget), FALSE);
-
- switch (event->type)
- {
- case GDK_BUTTON_PRESS:
- g_signal_emit (gwidget,
- glade_widget_signals[BUTTON_PRESS_EVENT], 0,
- event, &handled);
- break;
- case GDK_BUTTON_RELEASE:
- g_signal_emit (gwidget,
- glade_widget_signals[BUTTON_RELEASE_EVENT], 0,
- event, &handled);
- break;
- case GDK_MOTION_NOTIFY:
- g_signal_emit (gwidget,
- glade_widget_signals[MOTION_NOTIFY_EVENT], 0,
- event, &handled);
- break;
- default:
- break;
- }
-
- return handled;
+glade_widget_event_impl (GladeWidget * gwidget, GdkEvent * event)
+{
+ gboolean handled = FALSE;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (gwidget), FALSE);
+
+ switch (event->type)
+ {
+ case GDK_BUTTON_PRESS:
+ g_signal_emit (gwidget,
+ glade_widget_signals[BUTTON_PRESS_EVENT], 0,
+ event, &handled);
+ break;
+ case GDK_BUTTON_RELEASE:
+ g_signal_emit (gwidget,
+ glade_widget_signals[BUTTON_RELEASE_EVENT], 0,
+ event, &handled);
+ break;
+ case GDK_MOTION_NOTIFY:
+ g_signal_emit (gwidget,
+ glade_widget_signals[MOTION_NOTIFY_EVENT], 0,
+ event, &handled);
+ break;
+ default:
+ break;
+ }
+
+ return handled;
}
@@ -410,23 +403,23 @@ glade_widget_event_impl (GladeWidget *gwidget,
* Returns: whether the event was handled or not.
*/
gboolean
-glade_widget_event (GladeWidget *gwidget,
- GdkEvent *event)
+glade_widget_event (GladeWidget * gwidget, GdkEvent * event)
{
- gboolean handled = FALSE;
+ gboolean handled = FALSE;
- /* Lets just avoid some synthetic events (like focus-change) */
- if (((GdkEventAny *)event)->window == NULL) return FALSE;
+ /* Lets just avoid some synthetic events (like focus-change) */
+ if (((GdkEventAny *) event)->window == NULL)
+ return FALSE;
- handled = GLADE_WIDGET_GET_CLASS (gwidget)->event (gwidget, event);
+ handled = GLADE_WIDGET_GET_CLASS (gwidget)->event (gwidget, event);
#if 0
- if (event->type != GDK_EXPOSE)
- g_print ("event widget '%s' handled '%d' event '%d'\n",
- gwidget->name, handled, event->type);
+ if (event->type != GDK_EXPOSE)
+ g_print ("event widget '%s' handled '%d' event '%d'\n",
+ gwidget->name, handled, event->type);
#endif
- return handled;
+ return handled;
}
/*******************************************************************************
@@ -441,134 +434,133 @@ glade_widget_event (GladeWidget *gwidget,
* values currently in use.
*/
static GParameter *
-glade_widget_template_params (GladeWidget *widget,
- gboolean construct,
- guint *n_params)
-{
- GladeWidgetAdaptor *klass;
- GArray *params;
- GObjectClass *oclass;
- GParamSpec **pspec;
- GladeProperty *glade_property;
- GladePropertyClass *pclass;
- guint n_props, i;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (n_params != NULL, NULL);
-
- klass = widget->adaptor;
-
- /* As a slight optimization, we never unref the class
- */
- oclass = g_type_class_ref (klass->type);
- pspec = g_object_class_list_properties (oclass, &n_props);
- params = g_array_new (FALSE, FALSE, sizeof (GParameter));
-
- for (i = 0; i < n_props; i++)
- {
- GParameter parameter = { 0, };
-
- if ((glade_property =
- glade_widget_get_property (widget, pspec[i]->name)) == NULL)
- continue;
-
- pclass = glade_property->klass;
-
- /* Ignore properties based on some criteria
- */
- if (!glade_property_get_enabled (glade_property) ||
- pclass == NULL || /* Unaccounted for in the builder */
- pclass->virt || /* should not be set before
- GladeWidget wrapper exists */
- pclass->ignore) /* Catalog explicitly ignores the object */
- continue;
-
- if (construct &&
- (pspec[i]->flags &
- (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0)
- continue;
- else if (!construct &&
- (pspec[i]->flags &
- (G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0)
- continue;
-
- if (g_value_type_compatible (G_VALUE_TYPE (pclass->def),
- pspec[i]->value_type) == FALSE)
- {
- g_critical ("Type mismatch on %s property of %s",
- parameter.name, klass->name);
- continue;
- }
-
- if (g_param_values_cmp (pspec[i],
- glade_property->value,
- pclass->orig_def) == 0)
- continue;
-
-
- parameter.name = pspec[i]->name; /* These are not copied/freed */
- g_value_init (¶meter.value, pspec[i]->value_type);
- g_value_copy (glade_property->value, ¶meter.value);
-
- g_array_append_val (params, parameter);
- }
- g_free (pspec);
-
- *n_params = params->len;
- return (GParameter *)g_array_free (params, FALSE);
+glade_widget_template_params (GladeWidget * widget,
+ gboolean construct, guint * n_params)
+{
+ GladeWidgetAdaptor *klass;
+ GArray *params;
+ GObjectClass *oclass;
+ GParamSpec **pspec;
+ GladeProperty *glade_property;
+ GladePropertyClass *pclass;
+ guint n_props, i;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (n_params != NULL, NULL);
+
+ klass = widget->adaptor;
+
+ /* As a slight optimization, we never unref the class
+ */
+ oclass = g_type_class_ref (klass->type);
+ pspec = g_object_class_list_properties (oclass, &n_props);
+ params = g_array_new (FALSE, FALSE, sizeof (GParameter));
+
+ for (i = 0; i < n_props; i++)
+ {
+ GParameter parameter = { 0, };
+
+ if ((glade_property =
+ glade_widget_get_property (widget, pspec[i]->name)) == NULL)
+ continue;
+
+ pclass = glade_property->klass;
+
+ /* Ignore properties based on some criteria
+ */
+ if (!glade_property_get_enabled (glade_property) || pclass == NULL || /* Unaccounted for in the builder */
+ pclass->virt || /* should not be set before
+ GladeWidget wrapper exists */
+ pclass->ignore) /* Catalog explicitly ignores the object */
+ continue;
+
+ if (construct &&
+ (pspec[i]->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0)
+ continue;
+ else if (!construct &&
+ (pspec[i]->flags &
+ (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) != 0)
+ continue;
+
+ if (g_value_type_compatible (G_VALUE_TYPE (pclass->def),
+ pspec[i]->value_type) == FALSE)
+ {
+ g_critical ("Type mismatch on %s property of %s",
+ parameter.name, klass->name);
+ continue;
+ }
+
+ if (g_param_values_cmp (pspec[i],
+ glade_property->value, pclass->orig_def) == 0)
+ continue;
+
+
+ parameter.name = pspec[i]->name; /* These are not copied/freed */
+ g_value_init (¶meter.value, pspec[i]->value_type);
+ g_value_copy (glade_property->value, ¶meter.value);
+
+ g_array_append_val (params, parameter);
+ }
+ g_free (pspec);
+
+ *n_params = params->len;
+ return (GParameter *) g_array_free (params, FALSE);
}
static void
-free_params (GParameter *params, guint n_params)
+free_params (GParameter * params, guint n_params)
{
- gint i;
- for (i = 0; i < n_params; i++)
- g_value_unset (&(params[i].value));
- g_free (params);
+ gint i;
+ for (i = 0; i < n_params; i++)
+ g_value_unset (&(params[i].value));
+ g_free (params);
}
static GObject *
-glade_widget_build_object (GladeWidget *widget,
- GladeWidget *template,
- GladeCreateReason reason)
-{
- GParameter *params;
- GObject *object;
- guint n_params, i;
-
- if (reason == GLADE_CREATE_LOAD)
- {
- object = glade_widget_adaptor_construct_object (widget->adaptor, 0, NULL);
- glade_widget_set_object (widget, object, TRUE);
- return object;
- }
-
- if (template)
- params = glade_widget_template_params (widget, TRUE, &n_params);
- else
- params = glade_widget_adaptor_default_params (widget->adaptor, TRUE, &n_params);
-
- /* Create the new object with the correct parameters.
- */
- object = glade_widget_adaptor_construct_object (widget->adaptor, n_params, params);
+glade_widget_build_object (GladeWidget * widget,
+ GladeWidget * template, GladeCreateReason reason)
+{
+ GParameter *params;
+ GObject *object;
+ guint n_params, i;
- free_params (params, n_params);
+ if (reason == GLADE_CREATE_LOAD)
+ {
+ object = glade_widget_adaptor_construct_object (widget->adaptor, 0, NULL);
+ glade_widget_set_object (widget, object, TRUE);
+ return object;
+ }
+
+ if (template)
+ params = glade_widget_template_params (widget, TRUE, &n_params);
+ else
+ params =
+ glade_widget_adaptor_default_params (widget->adaptor, TRUE, &n_params);
+
+ /* Create the new object with the correct parameters.
+ */
+ object =
+ glade_widget_adaptor_construct_object (widget->adaptor, n_params, params);
- /* Dont destroy toplevels when rebuilding, handle that separately */
- glade_widget_set_object (widget, object, reason != GLADE_CREATE_REBUILD);
+ free_params (params, n_params);
- if (template)
- params = glade_widget_template_params (widget, FALSE, &n_params);
- else
- params = glade_widget_adaptor_default_params (widget->adaptor, FALSE, &n_params);
+ /* Dont destroy toplevels when rebuilding, handle that separately */
+ glade_widget_set_object (widget, object, reason != GLADE_CREATE_REBUILD);
- for (i = 0; i < n_params; i++)
- glade_widget_adaptor_set_property (widget->adaptor, object, params[i].name, &(params[i].value));
+ if (template)
+ params = glade_widget_template_params (widget, FALSE, &n_params);
+ else
+ params =
+ glade_widget_adaptor_default_params (widget->adaptor, FALSE, &n_params);
- free_params (params, n_params);
+ for (i = 0; i < n_params; i++)
+ glade_widget_adaptor_set_property (widget->adaptor, object, params[i].name,
+ &(params[i].value));
- return object;
+ free_params (params, n_params);
+
+ return object;
}
/**
@@ -585,46 +577,47 @@ glade_widget_build_object (GladeWidget *widget,
* Returns: A newly allocated #GList of new #GladeProperty objects.
*/
GList *
-glade_widget_dup_properties (GladeWidget *dest_widget, GList *template_props, gboolean as_load,
- gboolean copy_parentless, gboolean exact)
+glade_widget_dup_properties (GladeWidget * dest_widget, GList * template_props,
+ gboolean as_load, gboolean copy_parentless,
+ gboolean exact)
{
- GList *list, *properties = NULL;
+ GList *list, *properties = NULL;
+
+ for (list = template_props; list && list->data; list = list->next)
+ {
+ GladeProperty *prop = list->data;
- for (list = template_props; list && list->data; list = list->next)
- {
- GladeProperty *prop = list->data;
-
- if (prop->klass->save == FALSE && as_load)
- continue;
+ if (prop->klass->save == FALSE && as_load)
+ continue;
- if (prop->klass->parentless_widget && copy_parentless)
- {
- GObject *object = NULL;
- GladeWidget *parentless;
+ if (prop->klass->parentless_widget && copy_parentless)
+ {
+ GObject *object = NULL;
+ GladeWidget *parentless;
- glade_property_get (prop, &object);
+ glade_property_get (prop, &object);
- prop = glade_property_dup (prop, NULL);
+ prop = glade_property_dup (prop, NULL);
- if (object)
- {
- parentless = glade_widget_get_from_gobject (object);
+ if (object)
+ {
+ parentless = glade_widget_get_from_gobject (object);
- parentless = glade_widget_dup (parentless, exact);
+ parentless = glade_widget_dup (parentless, exact);
- glade_widget_set_project (parentless, dest_widget->project);
+ glade_widget_set_project (parentless, dest_widget->project);
- glade_property_set (prop, parentless->object);
- }
- }
- else
- prop = glade_property_dup (prop, NULL);
+ glade_property_set (prop, parentless->object);
+ }
+ }
+ else
+ prop = glade_property_dup (prop, NULL);
- properties = g_list_prepend (properties, prop);
- }
- return g_list_reverse (properties);
+ properties = g_list_prepend (properties, prop);
+ }
+ return g_list_reverse (properties);
}
/**
@@ -640,681 +633,658 @@ glade_widget_dup_properties (GladeWidget *dest_widget, GList *template_props, gb
* style properties).
*/
void
-glade_widget_remove_property (GladeWidget *widget,
- const gchar *id_property)
+glade_widget_remove_property (GladeWidget * widget, const gchar * id_property)
{
- GladeProperty *prop;
+ GladeProperty *prop;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (id_property);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (id_property);
- /* XXX FIXME: currently we arent calling this on packing properties,
- * but doing so could cause crashes because the hash table is not
- * managed properly
- */
- if ((prop = glade_widget_get_property (widget, id_property)) != NULL)
- {
- widget->properties = g_list_remove (widget->properties, prop);
- g_hash_table_remove (widget->props_hash, prop->klass->id);
- g_object_unref (prop);
- }
- else
- g_critical ("Couldnt find property %s on widget %s\n",
- id_property, widget->name);
+ /* XXX FIXME: currently we arent calling this on packing properties,
+ * but doing so could cause crashes because the hash table is not
+ * managed properly
+ */
+ if ((prop = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ widget->properties = g_list_remove (widget->properties, prop);
+ g_hash_table_remove (widget->props_hash, prop->klass->id);
+ g_object_unref (prop);
+ }
+ else
+ g_critical ("Couldnt find property %s on widget %s\n",
+ id_property, widget->name);
}
static void
-glade_widget_set_catalog_defaults (GList *list)
+glade_widget_set_catalog_defaults (GList * list)
{
- GList *l;
- for (l = list; l && l->data; l = l->next)
- {
- GladeProperty *prop = l->data;
- GladePropertyClass *klass = prop->klass;
-
- if (glade_property_equals_value (prop, klass->orig_def) &&
- g_param_values_cmp (klass->pspec, klass->orig_def, klass->def))
- glade_property_reset (prop);
- }
+ GList *l;
+ for (l = list; l && l->data; l = l->next)
+ {
+ GladeProperty *prop = l->data;
+ GladePropertyClass *klass = prop->klass;
+
+ if (glade_property_equals_value (prop, klass->orig_def) &&
+ g_param_values_cmp (klass->pspec, klass->orig_def, klass->def))
+ glade_property_reset (prop);
+ }
}
static void
-glade_widget_sync_custom_props (GladeWidget *widget)
+glade_widget_sync_custom_props (GladeWidget * widget)
{
- GList *l;
- for (l = widget->properties; l && l->data; l = l->next)
- {
- GladeProperty *prop = GLADE_PROPERTY(l->data);
+ GList *l;
+ for (l = widget->properties; l && l->data; l = l->next)
+ {
+ GladeProperty *prop = GLADE_PROPERTY (l->data);
- if (prop->klass->virt || prop->klass->needs_sync)
- glade_property_sync (prop);
+ if (prop->klass->virt || prop->klass->needs_sync)
+ glade_property_sync (prop);
- }
+ }
}
static void
-glade_widget_sync_packing_props (GladeWidget *widget)
+glade_widget_sync_packing_props (GladeWidget * widget)
{
- GList *l;
- for (l = widget->packing_properties; l && l->data; l = l->next) {
- GladeProperty *prop = GLADE_PROPERTY(l->data);
- glade_property_sync (prop);
- }
+ GList *l;
+ for (l = widget->packing_properties; l && l->data; l = l->next)
+ {
+ GladeProperty *prop = GLADE_PROPERTY (l->data);
+ glade_property_sync (prop);
+ }
}
static GObject *
-glade_widget_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
-{
- GladeWidget *gwidget;
- GObject *ret_obj, *object;
- GList *properties = NULL, *list;
-
- ret_obj = G_OBJECT_CLASS (glade_widget_parent_class)->constructor
- (type, n_construct_properties, construct_properties);
-
- gwidget = GLADE_WIDGET (ret_obj);
-
- if (gwidget->name == NULL)
- {
- if (gwidget->internal)
- {
- gchar *name_base = g_strdup_printf ("%s-%s",
- gwidget->construct_internal,
- gwidget->internal);
-
- if (gwidget->project)
- {
- gwidget->name =
- glade_project_new_widget_name (gwidget->project,
- gwidget,
- name_base);
- g_free (name_base);
- }
- else
- gwidget->name = name_base;
-
- }
- else if (gwidget->project)
- gwidget->name = glade_project_new_widget_name
- (gwidget->project, gwidget,
- gwidget->adaptor->generic_name);
- else
- gwidget->name =
- g_strdup (gwidget->adaptor->generic_name);
- }
-
- if (gwidget->construct_template)
- {
- properties = glade_widget_dup_properties
- (gwidget, gwidget->construct_template->properties, FALSE, TRUE, gwidget->construct_exact);
-
- glade_widget_set_properties (gwidget, properties);
- }
-
- if (gwidget->object == NULL)
- {
- object = glade_widget_build_object (gwidget,
- gwidget->construct_template,
- gwidget->construct_reason);
- }
-
- /* Copy sync parentless widget props here after a dup
- */
- if (gwidget->construct_reason == GLADE_CREATE_COPY)
- {
- for (list = gwidget->properties; list; list = list->next)
- {
- GladeProperty *property = list->data;
- if (property->klass->parentless_widget)
- glade_property_sync (property);
- }
- }
-
- /* Setup width/height */
- gwidget->width = GWA_DEFAULT_WIDTH (gwidget->adaptor);
- gwidget->height = GWA_DEFAULT_HEIGHT (gwidget->adaptor);
-
- /* Introspect object properties before passing it to post_create,
- * but only when its freshly created (depend on glade file at
- * load time and copying properties at dup time).
- */
- if (gwidget->construct_reason == GLADE_CREATE_USER)
- for (list = gwidget->properties; list; list = list->next)
- glade_property_load (GLADE_PROPERTY (list->data));
-
- /* We only use catalog defaults when the widget was created by the user! */
- if (gwidget->construct_reason == GLADE_CREATE_USER)
- glade_widget_set_catalog_defaults (gwidget->properties);
-
- /* Only call this once the GladeWidget is completely built
- * (but before calling custom handlers...)
- */
- glade_widget_adaptor_post_create (gwidget->adaptor,
- gwidget->object,
- gwidget->construct_reason);
+glade_widget_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
+{
+ GladeWidget *gwidget;
+ GObject *ret_obj, *object;
+ GList *properties = NULL, *list;
- /* Virtual properties need to be explicitly synchronized.
- */
- if (gwidget->construct_reason == GLADE_CREATE_USER)
- glade_widget_sync_custom_props (gwidget);
-
- if (gwidget->parent && gwidget->packing_properties == NULL)
- glade_widget_set_packing_properties (gwidget, gwidget->parent);
-
- if (GTK_IS_WIDGET (gwidget->object) && !gtk_widget_is_toplevel (GTK_WIDGET (gwidget->object)))
- {
- gwidget->visible = TRUE;
- gtk_widget_show_all (GTK_WIDGET (gwidget->object));
- }
- else if (GTK_IS_WIDGET (gwidget->object) == FALSE)
- gwidget->visible = TRUE;
-
- return ret_obj;
+ ret_obj = G_OBJECT_CLASS (glade_widget_parent_class)->constructor
+ (type, n_construct_properties, construct_properties);
+
+ gwidget = GLADE_WIDGET (ret_obj);
+
+ if (gwidget->name == NULL)
+ {
+ if (gwidget->internal)
+ {
+ gchar *name_base = g_strdup_printf ("%s-%s",
+ gwidget->construct_internal,
+ gwidget->internal);
+
+ if (gwidget->project)
+ {
+ gwidget->name =
+ glade_project_new_widget_name (gwidget->project,
+ gwidget, name_base);
+ g_free (name_base);
+ }
+ else
+ gwidget->name = name_base;
+
+ }
+ else if (gwidget->project)
+ gwidget->name = glade_project_new_widget_name
+ (gwidget->project, gwidget, gwidget->adaptor->generic_name);
+ else
+ gwidget->name = g_strdup (gwidget->adaptor->generic_name);
+ }
+
+ if (gwidget->construct_template)
+ {
+ properties = glade_widget_dup_properties
+ (gwidget, gwidget->construct_template->properties, FALSE, TRUE,
+ gwidget->construct_exact);
+
+ glade_widget_set_properties (gwidget, properties);
+ }
+
+ if (gwidget->object == NULL)
+ {
+ object = glade_widget_build_object (gwidget,
+ gwidget->construct_template,
+ gwidget->construct_reason);
+ }
+
+ /* Copy sync parentless widget props here after a dup
+ */
+ if (gwidget->construct_reason == GLADE_CREATE_COPY)
+ {
+ for (list = gwidget->properties; list; list = list->next)
+ {
+ GladeProperty *property = list->data;
+ if (property->klass->parentless_widget)
+ glade_property_sync (property);
+ }
+ }
+
+ /* Setup width/height */
+ gwidget->width = GWA_DEFAULT_WIDTH (gwidget->adaptor);
+ gwidget->height = GWA_DEFAULT_HEIGHT (gwidget->adaptor);
+
+ /* Introspect object properties before passing it to post_create,
+ * but only when its freshly created (depend on glade file at
+ * load time and copying properties at dup time).
+ */
+ if (gwidget->construct_reason == GLADE_CREATE_USER)
+ for (list = gwidget->properties; list; list = list->next)
+ glade_property_load (GLADE_PROPERTY (list->data));
+
+ /* We only use catalog defaults when the widget was created by the user! */
+ if (gwidget->construct_reason == GLADE_CREATE_USER)
+ glade_widget_set_catalog_defaults (gwidget->properties);
+
+ /* Only call this once the GladeWidget is completely built
+ * (but before calling custom handlers...)
+ */
+ glade_widget_adaptor_post_create (gwidget->adaptor,
+ gwidget->object, gwidget->construct_reason);
+
+ /* Virtual properties need to be explicitly synchronized.
+ */
+ if (gwidget->construct_reason == GLADE_CREATE_USER)
+ glade_widget_sync_custom_props (gwidget);
+
+ if (gwidget->parent && gwidget->packing_properties == NULL)
+ glade_widget_set_packing_properties (gwidget, gwidget->parent);
+
+ if (GTK_IS_WIDGET (gwidget->object) &&
+ !gtk_widget_is_toplevel (GTK_WIDGET (gwidget->object)))
+ {
+ gwidget->visible = TRUE;
+ gtk_widget_show_all (GTK_WIDGET (gwidget->object));
+ }
+ else if (GTK_IS_WIDGET (gwidget->object) == FALSE)
+ gwidget->visible = TRUE;
+
+ return ret_obj;
}
static void
-glade_widget_finalize (GObject *object)
+glade_widget_finalize (GObject * object)
{
- GladeWidget *widget = GLADE_WIDGET (object);
+ GladeWidget *widget = GLADE_WIDGET (object);
- g_return_if_fail (GLADE_IS_WIDGET (object));
+ g_return_if_fail (GLADE_IS_WIDGET (object));
#if 0
- /* A good way to check if refcounts are balancing at project close time */
- g_print ("Finalizing widget %s\n", widget->name);
+ /* A good way to check if refcounts are balancing at project close time */
+ g_print ("Finalizing widget %s\n", widget->name);
#endif
- g_free (widget->name);
- g_free (widget->internal);
- g_free (widget->support_warning);
- g_hash_table_destroy (widget->signals);
+ g_free (widget->name);
+ g_free (widget->internal);
+ g_free (widget->support_warning);
+ g_hash_table_destroy (widget->signals);
- if (widget->props_hash)
- g_hash_table_destroy (widget->props_hash);
- if (widget->pack_props_hash)
- g_hash_table_destroy (widget->pack_props_hash);
+ if (widget->props_hash)
+ g_hash_table_destroy (widget->props_hash);
+ if (widget->pack_props_hash)
+ g_hash_table_destroy (widget->pack_props_hash);
- G_OBJECT_CLASS (glade_widget_parent_class)->finalize(object);
+ G_OBJECT_CLASS (glade_widget_parent_class)->finalize (object);
}
static void
-reset_object_property (GladeProperty *property,
- GladeProject *project)
+reset_object_property (GladeProperty * property, GladeProject * project)
{
- if (glade_property_class_is_object (property->klass))
- glade_property_reset (property);
+ if (glade_property_class_is_object (property->klass))
+ glade_property_reset (property);
}
static void
-glade_widget_dispose (GObject *object)
-{
- GladeWidget *widget = GLADE_WIDGET (object);
-
- glade_widget_push_superuser ();
-
- /* Release references by way of object properties... */
- while (widget->prop_refs)
- {
- GladeProperty *property = GLADE_PROPERTY (widget->prop_refs->data);
- glade_property_set (property, NULL);
- }
-
- if (widget->properties)
- g_list_foreach (widget->properties, (GFunc)reset_object_property, widget->project);
-
- /* We have to make sure properties release thier references on other widgets first
- * hence the reset (for object properties) */
- if (widget->properties)
- {
- g_list_foreach (widget->properties, (GFunc)g_object_unref, NULL);
- g_list_free (widget->properties);
- widget->properties = NULL;
- }
-
- glade_widget_set_object (widget, NULL, TRUE);
-
- if (widget->packing_properties)
- {
- g_list_foreach (widget->packing_properties, (GFunc)g_object_unref, NULL);
- g_list_free (widget->packing_properties);
- widget->packing_properties = NULL;
- }
-
- if (widget->actions)
- {
- g_list_foreach (widget->actions, (GFunc)g_object_unref, NULL);
- g_list_free (widget->actions);
- widget->actions = NULL;
- }
-
- if (widget->packing_actions)
- {
- g_list_foreach (widget->packing_actions, (GFunc)g_object_unref, NULL);
- g_list_free (widget->packing_actions);
- widget->packing_actions = NULL;
- }
-
- glade_widget_pop_superuser ();
-
- G_OBJECT_CLASS (glade_widget_parent_class)->dispose (object);
+glade_widget_dispose (GObject * object)
+{
+ GladeWidget *widget = GLADE_WIDGET (object);
+
+ glade_widget_push_superuser ();
+
+ /* Release references by way of object properties... */
+ while (widget->prop_refs)
+ {
+ GladeProperty *property = GLADE_PROPERTY (widget->prop_refs->data);
+ glade_property_set (property, NULL);
+ }
+
+ if (widget->properties)
+ g_list_foreach (widget->properties, (GFunc) reset_object_property,
+ widget->project);
+
+ /* We have to make sure properties release thier references on other widgets first
+ * hence the reset (for object properties) */
+ if (widget->properties)
+ {
+ g_list_foreach (widget->properties, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->properties);
+ widget->properties = NULL;
+ }
+
+ glade_widget_set_object (widget, NULL, TRUE);
+
+ if (widget->packing_properties)
+ {
+ g_list_foreach (widget->packing_properties, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->packing_properties);
+ widget->packing_properties = NULL;
+ }
+
+ if (widget->actions)
+ {
+ g_list_foreach (widget->actions, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->actions);
+ widget->actions = NULL;
+ }
+
+ if (widget->packing_actions)
+ {
+ g_list_foreach (widget->packing_actions, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->packing_actions);
+ widget->packing_actions = NULL;
+ }
+
+ glade_widget_pop_superuser ();
+
+ G_OBJECT_CLASS (glade_widget_parent_class)->dispose (object);
}
static void
-glade_widget_set_real_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GladeWidget *widget;
-
- widget = GLADE_WIDGET (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- glade_widget_set_name (widget, g_value_get_string (value));
- break;
- case PROP_INTERNAL:
- glade_widget_set_internal (widget, g_value_get_string (value));
- break;
- case PROP_ANARCHIST:
- widget->anarchist = g_value_get_boolean (value);
- break;
- case PROP_OBJECT:
- if (g_value_get_object (value))
- glade_widget_set_object (widget, g_value_get_object (value), TRUE);
- break;
- case PROP_PROJECT:
- glade_widget_set_project (widget, GLADE_PROJECT (g_value_get_object (value)));
- break;
- case PROP_ADAPTOR:
- glade_widget_set_adaptor (widget, GLADE_WIDGET_ADAPTOR
- (g_value_get_object (value)));
- break;
- case PROP_PROPERTIES:
- glade_widget_set_properties (widget, (GList *)g_value_get_pointer (value));
- break;
- case PROP_PARENT:
- glade_widget_set_parent (widget, GLADE_WIDGET (g_value_get_object (value)));
- break;
- case PROP_INTERNAL_NAME:
- if (g_value_get_string (value))
- widget->construct_internal = g_value_dup_string (value);
- break;
- case PROP_TEMPLATE:
- widget->construct_template = g_value_get_object (value);
- break;
- case PROP_TEMPLATE_EXACT:
- widget->construct_exact = g_value_get_boolean (value);
- break;
- case PROP_REASON:
- widget->construct_reason = g_value_get_int (value);
- break;
- case PROP_TOPLEVEL_WIDTH:
- widget->width = g_value_get_int (value);
- break;
- case PROP_TOPLEVEL_HEIGHT:
- widget->height = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_widget_set_real_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GladeWidget *widget;
+
+ widget = GLADE_WIDGET (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ glade_widget_set_name (widget, g_value_get_string (value));
+ break;
+ case PROP_INTERNAL:
+ glade_widget_set_internal (widget, g_value_get_string (value));
+ break;
+ case PROP_ANARCHIST:
+ widget->anarchist = g_value_get_boolean (value);
+ break;
+ case PROP_OBJECT:
+ if (g_value_get_object (value))
+ glade_widget_set_object (widget, g_value_get_object (value), TRUE);
+ break;
+ case PROP_PROJECT:
+ glade_widget_set_project (widget,
+ GLADE_PROJECT (g_value_get_object (value)));
+ break;
+ case PROP_ADAPTOR:
+ glade_widget_set_adaptor (widget, GLADE_WIDGET_ADAPTOR
+ (g_value_get_object (value)));
+ break;
+ case PROP_PROPERTIES:
+ glade_widget_set_properties (widget,
+ (GList *) g_value_get_pointer (value));
+ break;
+ case PROP_PARENT:
+ glade_widget_set_parent (widget,
+ GLADE_WIDGET (g_value_get_object (value)));
+ break;
+ case PROP_INTERNAL_NAME:
+ if (g_value_get_string (value))
+ widget->construct_internal = g_value_dup_string (value);
+ break;
+ case PROP_TEMPLATE:
+ widget->construct_template = g_value_get_object (value);
+ break;
+ case PROP_TEMPLATE_EXACT:
+ widget->construct_exact = g_value_get_boolean (value);
+ break;
+ case PROP_REASON:
+ widget->construct_reason = g_value_get_int (value);
+ break;
+ case PROP_TOPLEVEL_WIDTH:
+ widget->width = g_value_get_int (value);
+ break;
+ case PROP_TOPLEVEL_HEIGHT:
+ widget->height = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-glade_widget_get_real_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GladeWidget *widget;
-
- widget = GLADE_WIDGET (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, widget->name);
- break;
- case PROP_INTERNAL:
- g_value_set_string (value, widget->internal);
- break;
- case PROP_ANARCHIST:
- g_value_set_boolean (value, widget->anarchist);
- break;
- case PROP_ADAPTOR:
- g_value_set_object (value, widget->adaptor);
- break;
- case PROP_PROJECT:
- g_value_set_object (value, G_OBJECT (widget->project));
- break;
- case PROP_OBJECT:
- g_value_set_object (value, widget->object);
- break;
- case PROP_PROPERTIES:
- g_value_set_pointer (value, widget->properties);
- break;
- case PROP_PARENT:
- g_value_set_object (value, widget->parent);
- break;
- case PROP_TOPLEVEL_WIDTH:
- g_value_set_int (value, widget->width);
- break;
- case PROP_TOPLEVEL_HEIGHT:
- g_value_set_int (value, widget->height);
- break;
- case PROP_SUPPORT_WARNING:
- g_value_set_string (value, widget->support_warning);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+glade_widget_get_real_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GladeWidget *widget;
+
+ widget = GLADE_WIDGET (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, widget->name);
+ break;
+ case PROP_INTERNAL:
+ g_value_set_string (value, widget->internal);
+ break;
+ case PROP_ANARCHIST:
+ g_value_set_boolean (value, widget->anarchist);
+ break;
+ case PROP_ADAPTOR:
+ g_value_set_object (value, widget->adaptor);
+ break;
+ case PROP_PROJECT:
+ g_value_set_object (value, G_OBJECT (widget->project));
+ break;
+ case PROP_OBJECT:
+ g_value_set_object (value, widget->object);
+ break;
+ case PROP_PROPERTIES:
+ g_value_set_pointer (value, widget->properties);
+ break;
+ case PROP_PARENT:
+ g_value_set_object (value, widget->parent);
+ break;
+ case PROP_TOPLEVEL_WIDTH:
+ g_value_set_int (value, widget->width);
+ break;
+ case PROP_TOPLEVEL_HEIGHT:
+ g_value_set_int (value, widget->height);
+ break;
+ case PROP_SUPPORT_WARNING:
+ g_value_set_string (value, widget->support_warning);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
free_signals (gpointer value)
{
- GPtrArray *signals = (GPtrArray*) value;
- guint i;
- guint nb_signals;
+ GPtrArray *signals = (GPtrArray *) value;
+ guint i;
+ guint nb_signals;
- if (signals == NULL)
- return;
+ if (signals == NULL)
+ return;
- /* g_ptr_array_foreach (signals, (GFunc) glade_signal_free, NULL);
- * only available in modern versions of Gtk+ */
- nb_signals = signals->len;
- for (i = 0; i < nb_signals; i++)
- glade_signal_free (g_ptr_array_index (signals, i));
+ /* g_ptr_array_foreach (signals, (GFunc) glade_signal_free, NULL);
+ * only available in modern versions of Gtk+ */
+ nb_signals = signals->len;
+ for (i = 0; i < nb_signals; i++)
+ glade_signal_free (g_ptr_array_index (signals, i));
- g_ptr_array_free (signals, TRUE);
+ g_ptr_array_free (signals, TRUE);
}
static void
-glade_widget_init (GladeWidget *widget)
-{
- widget->adaptor = NULL;
- widget->project = NULL;
- widget->name = NULL;
- widget->internal = NULL;
- widget->object = NULL;
- widget->properties = NULL;
- widget->packing_properties = NULL;
- widget->prop_refs = NULL;
- widget->signals = g_hash_table_new_full
- (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) free_signals);
-
- /* Initial invalid values */
- widget->width = -1;
- widget->height = -1;
+glade_widget_init (GladeWidget * widget)
+{
+ widget->adaptor = NULL;
+ widget->project = NULL;
+ widget->name = NULL;
+ widget->internal = NULL;
+ widget->object = NULL;
+ widget->properties = NULL;
+ widget->packing_properties = NULL;
+ widget->prop_refs = NULL;
+ widget->signals = g_hash_table_new_full
+ (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free, (GDestroyNotify) free_signals);
+
+ /* Initial invalid values */
+ widget->width = -1;
+ widget->height = -1;
}
static void
-glade_widget_class_init (GladeWidgetClass *klass)
-{
- GObjectClass *object_class;
-
- if (glade_widget_name_quark == 0)
- glade_widget_name_quark =
- g_quark_from_static_string ("GladeWidgetDataTag");
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = glade_widget_constructor;
- object_class->finalize = glade_widget_finalize;
- object_class->dispose = glade_widget_dispose;
- object_class->set_property = glade_widget_set_real_property;
- object_class->get_property = glade_widget_get_real_property;
-
- klass->add_child = glade_widget_add_child_impl;
- klass->remove_child = glade_widget_remove_child_impl;
- klass->replace_child = glade_widget_replace_child_impl;
- klass->event = glade_widget_event_impl;
-
- klass->add_signal_handler = glade_widget_add_signal_handler_impl;
- klass->remove_signal_handler = glade_widget_remove_signal_handler_impl;
- klass->change_signal_handler = glade_widget_change_signal_handler_impl;
-
- klass->button_press_event = glade_widget_button_press_event_impl;
- klass->button_release_event = NULL;
- klass->motion_notify_event = NULL;
-
- g_object_class_install_property
- (object_class, PROP_NAME,
- g_param_spec_string ("name", _("Name"),
- _("The name of the widget"),
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (object_class, PROP_INTERNAL,
- g_param_spec_string ("internal", _("Internal name"),
- _("The internal name of the widget"),
- NULL, G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (object_class, PROP_ANARCHIST,
- g_param_spec_boolean ("anarchist", _("Anarchist"),
- _("Whether this composite child is "
- "an ancestral child or an anarchist child"),
- FALSE, G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_OBJECT,
- g_param_spec_object ("object", _("Object"),
- _("The object associated"),
- G_TYPE_OBJECT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (object_class, PROP_ADAPTOR,
- g_param_spec_object ("adaptor", _("Adaptor"),
- _("The class adaptor for the associated widget"),
- GLADE_TYPE_WIDGET_ADAPTOR,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_PROJECT,
- g_param_spec_object ("project", _("Project"),
- _("The glade project that "
- "this widget belongs to"),
- GLADE_TYPE_PROJECT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (object_class, PROP_PROPERTIES,
- g_param_spec_pointer ("properties", _("Properties"),
- _("A list of GladeProperties"),
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_PARENT,
- g_param_spec_object ("parent", _("Parent"),
- _("A pointer to the parenting GladeWidget"),
- GLADE_TYPE_WIDGET,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property
- (object_class, PROP_INTERNAL_NAME,
- g_param_spec_string ("internal-name", _("Internal Name"),
- _("A generic name prefix for internal widgets"),
- NULL, G_PARAM_CONSTRUCT_ONLY|G_PARAM_WRITABLE));
-
- g_object_class_install_property
- (object_class, PROP_TEMPLATE,
- g_param_spec_object ("template", _("Template"),
- _("A GladeWidget template to base a new widget on"),
- GLADE_TYPE_WIDGET,
- G_PARAM_CONSTRUCT_ONLY|G_PARAM_WRITABLE));
-
- g_object_class_install_property
- (object_class, PROP_TEMPLATE_EXACT,
- g_param_spec_boolean ("template-exact", _("Exact Template"),
- _("Whether we are creating an exact duplicate when using a template"),
- FALSE, G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property
- (object_class, PROP_REASON,
- g_param_spec_int ("reason", _("Reason"),
- _("A GladeCreateReason for this creation"),
- GLADE_CREATE_USER,
- GLADE_CREATE_REASONS - 1,
- GLADE_CREATE_USER,
- G_PARAM_CONSTRUCT_ONLY|G_PARAM_WRITABLE));
-
- g_object_class_install_property
- (object_class, PROP_TOPLEVEL_WIDTH,
- g_param_spec_int ("toplevel-width", _("Toplevel Width"),
- _("The width of the widget when toplevel in "
- "the GladeDesignLayout"),
- -1,
- G_MAXINT,
- -1,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_TOPLEVEL_HEIGHT,
- g_param_spec_int ("toplevel-height", _("Toplevel Height"),
- _("The height of the widget when toplevel in "
- "the GladeDesignLayout"),
- -1,
- G_MAXINT,
- -1,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (object_class, PROP_SUPPORT_WARNING,
- g_param_spec_string ("support warning", _("Support Warning"),
- _("A warning string about version mismatches"),
- NULL, G_PARAM_READABLE));
-
- /**
+glade_widget_class_init (GladeWidgetClass * klass)
+{
+ GObjectClass *object_class;
+
+ if (glade_widget_name_quark == 0)
+ glade_widget_name_quark = g_quark_from_static_string ("GladeWidgetDataTag");
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructor = glade_widget_constructor;
+ object_class->finalize = glade_widget_finalize;
+ object_class->dispose = glade_widget_dispose;
+ object_class->set_property = glade_widget_set_real_property;
+ object_class->get_property = glade_widget_get_real_property;
+
+ klass->add_child = glade_widget_add_child_impl;
+ klass->remove_child = glade_widget_remove_child_impl;
+ klass->replace_child = glade_widget_replace_child_impl;
+ klass->event = glade_widget_event_impl;
+
+ klass->add_signal_handler = glade_widget_add_signal_handler_impl;
+ klass->remove_signal_handler = glade_widget_remove_signal_handler_impl;
+ klass->change_signal_handler = glade_widget_change_signal_handler_impl;
+
+ klass->button_press_event = glade_widget_button_press_event_impl;
+ klass->button_release_event = NULL;
+ klass->motion_notify_event = NULL;
+
+ g_object_class_install_property
+ (object_class, PROP_NAME,
+ g_param_spec_string ("name", _("Name"),
+ _("The name of the widget"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (object_class, PROP_INTERNAL,
+ g_param_spec_string ("internal", _("Internal name"),
+ _("The internal name of the widget"),
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (object_class, PROP_ANARCHIST,
+ g_param_spec_boolean ("anarchist", _("Anarchist"),
+ _("Whether this composite child is "
+ "an ancestral child or an anarchist child"),
+ FALSE, G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_OBJECT,
+ g_param_spec_object ("object", _("Object"),
+ _("The object associated"),
+ G_TYPE_OBJECT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (object_class, PROP_ADAPTOR,
+ g_param_spec_object ("adaptor", _("Adaptor"),
+ _("The class adaptor for the associated widget"),
+ GLADE_TYPE_WIDGET_ADAPTOR,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_PROJECT,
+ g_param_spec_object ("project", _("Project"),
+ _("The glade project that "
+ "this widget belongs to"),
+ GLADE_TYPE_PROJECT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (object_class, PROP_PROPERTIES,
+ g_param_spec_pointer ("properties", _("Properties"),
+ _("A list of GladeProperties"),
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_PARENT,
+ g_param_spec_object ("parent", _("Parent"),
+ _("A pointer to the parenting GladeWidget"),
+ GLADE_TYPE_WIDGET,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property
+ (object_class, PROP_INTERNAL_NAME,
+ g_param_spec_string ("internal-name", _("Internal Name"),
+ _("A generic name prefix for internal widgets"),
+ NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+ g_object_class_install_property
+ (object_class, PROP_TEMPLATE,
+ g_param_spec_object ("template", _("Template"),
+ _("A GladeWidget template to base a new widget on"),
+ GLADE_TYPE_WIDGET,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+ g_object_class_install_property
+ (object_class, PROP_TEMPLATE_EXACT,
+ g_param_spec_boolean ("template-exact", _("Exact Template"),
+ _
+ ("Whether we are creating an exact duplicate when using a template"),
+ FALSE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class, PROP_REASON,
+ g_param_spec_int ("reason", _("Reason"),
+ _("A GladeCreateReason for this creation"),
+ GLADE_CREATE_USER,
+ GLADE_CREATE_REASONS - 1,
+ GLADE_CREATE_USER,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+ g_object_class_install_property
+ (object_class, PROP_TOPLEVEL_WIDTH,
+ g_param_spec_int ("toplevel-width", _("Toplevel Width"),
+ _("The width of the widget when toplevel in "
+ "the GladeDesignLayout"),
+ -1, G_MAXINT, -1, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_TOPLEVEL_HEIGHT,
+ g_param_spec_int ("toplevel-height", _("Toplevel Height"),
+ _("The height of the widget when toplevel in "
+ "the GladeDesignLayout"),
+ -1, G_MAXINT, -1, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (object_class, PROP_SUPPORT_WARNING,
+ g_param_spec_string ("support warning", _("Support Warning"),
+ _("A warning string about version mismatches"),
+ NULL, G_PARAM_READABLE));
+
+ /**
* GladeWidget::add-signal-handler:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the #GladeSignal that was added to @gladewidget.
*/
- glade_widget_signals[ADD_SIGNAL_HANDLER] =
- g_signal_new ("add-signal-handler",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeWidgetClass, add_signal_handler),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
-
- /**
+ glade_widget_signals[ADD_SIGNAL_HANDLER] =
+ g_signal_new ("add-signal-handler",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeWidgetClass, add_signal_handler),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ /**
* GladeWidget::remove-signal-handler:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the #GladeSignal that was removed from @gladewidget.
*/
- glade_widget_signals[REMOVE_SIGNAL_HANDLER] =
- g_signal_new ("remove-signal-handler",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeWidgetClass, remove_signal_handler),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
-
-
- /**
+ glade_widget_signals[REMOVE_SIGNAL_HANDLER] =
+ g_signal_new ("remove-signal-handler",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeWidgetClass, remove_signal_handler),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+
+ /**
* GladeWidget::change-signal-handler:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the old #GladeSignal
* @arg2: the new #GladeSignal
*/
- glade_widget_signals[CHANGE_SIGNAL_HANDLER] =
- g_signal_new ("change-signal-handler",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeWidgetClass, change_signal_handler),
- NULL, NULL,
- glade_marshal_VOID__POINTER_POINTER,
- G_TYPE_NONE,
- 2,
- G_TYPE_POINTER, G_TYPE_POINTER);
-
-
- /**
+ glade_widget_signals[CHANGE_SIGNAL_HANDLER] =
+ g_signal_new ("change-signal-handler",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeWidgetClass, change_signal_handler),
+ NULL, NULL,
+ glade_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+
+
+ /**
* GladeWidget::button-press-event:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the #GdkEvent
*/
- glade_widget_signals[BUTTON_PRESS_EVENT] =
- g_signal_new ("button-press-event",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeWidgetClass, button_press_event),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__BOXED,
- G_TYPE_BOOLEAN, 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- /**
+ glade_widget_signals[BUTTON_PRESS_EVENT] =
+ g_signal_new ("button-press-event",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeWidgetClass, button_press_event),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__BOXED,
+ G_TYPE_BOOLEAN, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ /**
* GladeWidget::button-relese-event:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the #GdkEvent
*/
- glade_widget_signals[BUTTON_RELEASE_EVENT] =
- g_signal_new ("button-release-event",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeWidgetClass, button_release_event),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__BOXED,
- G_TYPE_BOOLEAN, 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
-
- /**
+ glade_widget_signals[BUTTON_RELEASE_EVENT] =
+ g_signal_new ("button-release-event",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeWidgetClass, button_release_event),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__BOXED,
+ G_TYPE_BOOLEAN, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+
+ /**
* GladeWidget::motion-notify-event:
* @gladewidget: the #GladeWidget which received the signal.
* @arg1: the #GdkEvent
*/
- glade_widget_signals[MOTION_NOTIFY_EVENT] =
- g_signal_new ("motion-notify-event",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GladeWidgetClass, motion_notify_event),
- glade_boolean_handled_accumulator, NULL,
- glade_marshal_BOOLEAN__BOXED,
- G_TYPE_BOOLEAN, 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
-
- /**
+ glade_widget_signals[MOTION_NOTIFY_EVENT] =
+ g_signal_new ("motion-notify-event",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeWidgetClass, motion_notify_event),
+ glade_boolean_handled_accumulator, NULL,
+ glade_marshal_BOOLEAN__BOXED,
+ G_TYPE_BOOLEAN, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+
+ /**
* GladeWidget::support-changed:
* @gladewidget: the #GladeWidget which received the signal.
*
* Emitted when property and signal support metadatas and messages
* have been updated.
*/
- glade_widget_signals[SUPPORT_CHANGED] =
- g_signal_new ("support-changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ glade_widget_signals[SUPPORT_CHANGED] =
+ g_signal_new ("support-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
@@ -1323,511 +1293,511 @@ glade_widget_class_init (GladeWidgetClass *klass)
Static stuff....
*******************************************************************************/
static void
-glade_widget_copy_packing_props (GladeWidget *parent,
- GladeWidget *child,
- GladeWidget *template_widget)
+glade_widget_copy_packing_props (GladeWidget * parent,
+ GladeWidget * child,
+ GladeWidget * template_widget)
{
- GladeProperty *dup_prop, *orig_prop;
- GList *l;
+ GladeProperty *dup_prop, *orig_prop;
+ GList *l;
- g_return_if_fail (child->parent == parent);
+ g_return_if_fail (child->parent == parent);
- glade_widget_set_packing_properties (child, parent);
+ glade_widget_set_packing_properties (child, parent);
- for (l = child->packing_properties; l && l->data; l = l->next)
- {
- dup_prop = GLADE_PROPERTY(l->data);
- orig_prop = glade_widget_get_pack_property (template_widget, dup_prop->klass->id);
- glade_property_set_value (dup_prop, orig_prop->value);
- }
+ for (l = child->packing_properties; l && l->data; l = l->next)
+ {
+ dup_prop = GLADE_PROPERTY (l->data);
+ orig_prop =
+ glade_widget_get_pack_property (template_widget, dup_prop->klass->id);
+ glade_property_set_value (dup_prop, orig_prop->value);
+ }
}
static void
-glade_widget_set_default_packing_properties (GladeWidget *container,
- GladeWidget *child)
-{
- GladePropertyClass *property_class;
- GList *l;
-
- for (l = container->adaptor->packing_props; l; l = l->next)
- {
- const gchar *def;
- GValue *value;
-
- property_class = l->data;
-
- if ((def =
- glade_widget_adaptor_get_packing_default
- (child->adaptor, container->adaptor, property_class->id)) == NULL)
- continue;
-
- value = glade_property_class_make_gvalue_from_string (property_class,
- def,
- child->project,
- child);
-
- glade_widget_child_set_property (container, child,
- property_class->id, value);
- g_value_unset (value);
- g_free (value);
- }
+glade_widget_set_default_packing_properties (GladeWidget * container,
+ GladeWidget * child)
+{
+ GladePropertyClass *property_class;
+ GList *l;
+
+ for (l = container->adaptor->packing_props; l; l = l->next)
+ {
+ const gchar *def;
+ GValue *value;
+
+ property_class = l->data;
+
+ if ((def =
+ glade_widget_adaptor_get_packing_default
+ (child->adaptor, container->adaptor, property_class->id)) == NULL)
+ continue;
+
+ value = glade_property_class_make_gvalue_from_string (property_class,
+ def,
+ child->project,
+ child);
+
+ glade_widget_child_set_property (container, child,
+ property_class->id, value);
+ g_value_unset (value);
+ g_free (value);
+ }
}
/**
* When looking for an internal child we have to walk up the hierarchy...
*/
static GObject *
-glade_widget_get_internal_child (GladeWidget *parent,
- const gchar *internal)
+glade_widget_get_internal_child (GladeWidget * parent, const gchar * internal)
{
- while (parent)
- {
- GladeWidgetAdaptorClass *adaptor_class =
- GLADE_WIDGET_ADAPTOR_GET_CLASS (parent->adaptor);
+ while (parent)
+ {
+ GladeWidgetAdaptorClass *adaptor_class =
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (parent->adaptor);
- if (adaptor_class->get_internal_child)
- return glade_widget_adaptor_get_internal_child
- (parent->adaptor, parent->object, internal);
+ if (adaptor_class->get_internal_child)
+ return glade_widget_adaptor_get_internal_child
+ (parent->adaptor, parent->object, internal);
- parent = glade_widget_get_parent (parent);
- }
- return NULL;
+ parent = glade_widget_get_parent (parent);
+ }
+ return NULL;
}
static GladeGetInternalFunc
-glade_widget_get_internal_func (GladeWidget *main_target,
- GladeWidget *parent,
- GladeWidget **parent_ret)
+glade_widget_get_internal_func (GladeWidget * main_target,
+ GladeWidget * parent, GladeWidget ** parent_ret)
{
- GladeWidget *gwidget;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL);
-
- for (gwidget = parent; gwidget; gwidget = gwidget->parent)
- {
- GladeWidgetAdaptorClass *adaptor_class =
- GLADE_WIDGET_ADAPTOR_GET_CLASS (gwidget->adaptor);
+ GladeWidget *gwidget;
- if (adaptor_class->get_internal_child)
- {
- if (parent_ret) *parent_ret = gwidget;
- return adaptor_class->get_internal_child;
- }
+ g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL);
- /* Limit the itterations into where the copy routine stared */
- if (gwidget == main_target)
- break;
- }
+ for (gwidget = parent; gwidget; gwidget = gwidget->parent)
+ {
+ GladeWidgetAdaptorClass *adaptor_class =
+ GLADE_WIDGET_ADAPTOR_GET_CLASS (gwidget->adaptor);
+
+ if (adaptor_class->get_internal_child)
+ {
+ if (parent_ret)
+ *parent_ret = gwidget;
+ return adaptor_class->get_internal_child;
+ }
+
+ /* Limit the itterations into where the copy routine stared */
+ if (gwidget == main_target)
+ break;
+ }
- return NULL;
+ return NULL;
}
static GladeWidget *
-glade_widget_dup_internal (GladeWidget *main_target,
- GladeWidget *parent,
- GladeWidget *template_widget,
- gboolean exact)
-{
- GladeGetInternalFunc get_internal;
- GladeWidget *gwidget = NULL, *internal_parent;
- GList *children;
- GtkWidget *placeholder;
- gchar *child_type;
- GList *l;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (template_widget), NULL);
- g_return_val_if_fail (parent == NULL || GLADE_IS_WIDGET (parent), NULL);
-
- /* Dont actually duplicate internal widgets, but recurse through them anyway. */
- if (parent && template_widget->internal)
- {
- GObject *internal_object = NULL;
-
- if ((get_internal =
- glade_widget_get_internal_func (main_target, parent, &internal_parent)) != NULL)
- {
- /* We cant use "parent" here, we have to recurse up the hierarchy to find
- * the "parent" that has `get_internal_child' support (i.e. internal children
- * may have depth).
- */
- if ((internal_object = get_internal (internal_parent->adaptor,
- internal_parent->object,
- template_widget->internal)) != NULL)
- {
- gwidget = glade_widget_get_from_gobject (internal_object);
- g_assert (gwidget);
- }
- }
- }
-
- /* If either it was not internal, or we failed to lookup the internal child
- * in the copied hierarchy (this can happen when copying an internal vbox from
- * a composite dialog for instance). */
- if (gwidget == NULL)
- {
- gchar *name = g_strdup (template_widget->name);
- gwidget = glade_widget_adaptor_create_widget
- (template_widget->adaptor, FALSE,
- "name", name,
- "parent", parent,
- "project", template_widget->project,
- "template", template_widget,
- "template-exact", exact,
- "reason", GLADE_CREATE_COPY, NULL);
- g_free (name);
- }
-
- /* Copy signals over here regardless of internal or not... */
- if (exact)
- glade_widget_copy_signals (gwidget, template_widget);
-
- if ((children =
- glade_widget_adaptor_get_children (template_widget->adaptor,
- template_widget->object)) != NULL)
- {
- GList *list;
-
- for (list = children; list && list->data; list = list->next)
- {
- GObject *child = G_OBJECT (list->data);
- GladeWidget *child_gwidget, *child_dup;
-
- child_type = g_object_get_data (child, "special-child-type");
-
- if ((child_gwidget = glade_widget_get_from_gobject (child)) == NULL)
- {
- /* Bring the placeholders along ...
- * but not unmarked internal children */
- if (GLADE_IS_PLACEHOLDER (child))
- {
- placeholder = glade_placeholder_new ();
-
- g_object_set_data_full (G_OBJECT (placeholder),
- "special-child-type",
- g_strdup (child_type),
- g_free);
-
- glade_widget_adaptor_add (gwidget->adaptor,
- gwidget->object,
- G_OBJECT (placeholder));
- }
- }
- else
- {
- /* Recurse through every GladeWidget (internal or not) */
- child_dup = glade_widget_dup_internal (main_target, gwidget, child_gwidget, exact);
-
- if (child_dup->internal == NULL)
- {
- g_object_set_data_full (child_dup->object,
- "special-child-type",
- g_strdup (child_type),
- g_free);
-
- glade_widget_add_child (gwidget, child_dup, FALSE);
- }
-
- /* Internal children that are not heirarchic children
- * need to avoid copying these packing props (like popup windows
- * created on behalf of composite widgets).
- */
- if (glade_widget_adaptor_has_child (gwidget->adaptor,
- gwidget->object,
- child_dup->object))
- glade_widget_copy_packing_props (gwidget,
- child_dup,
- child_gwidget);
-
- }
- }
- g_list_free (children);
- }
-
- if (gwidget->internal)
- glade_widget_copy_properties (gwidget, template_widget, TRUE, exact);
-
- if (gwidget->packing_properties == NULL)
- gwidget->packing_properties =
- glade_widget_dup_properties (gwidget, template_widget->packing_properties, FALSE, FALSE, FALSE);
-
- /* If custom properties are still at thier
- * default value, they need to be synced.
- */
- glade_widget_sync_custom_props (gwidget);
-
- /* Some properties may not be synced so we reload them */
- for (l = gwidget->properties; l; l = l->next)
- glade_property_load (GLADE_PROPERTY (l->data));
-
- if (GWA_IS_TOPLEVEL (gwidget->adaptor) && GTK_IS_WIDGET (gwidget->object))
- g_object_set (gwidget,
- "toplevel-width", template_widget->width,
- "toplevel-height", template_widget->height,
- NULL);
- return gwidget;
-}
-
-
-typedef struct {
- GladeWidget *widget;
- GtkWidget *placeholder;
- GList *properties;
-
- gchar *internal_name;
- GList *internal_list;
+glade_widget_dup_internal (GladeWidget * main_target,
+ GladeWidget * parent,
+ GladeWidget * template_widget, gboolean exact)
+{
+ GladeGetInternalFunc get_internal;
+ GladeWidget *gwidget = NULL, *internal_parent;
+ GList *children;
+ GtkWidget *placeholder;
+ gchar *child_type;
+ GList *l;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (template_widget), NULL);
+ g_return_val_if_fail (parent == NULL || GLADE_IS_WIDGET (parent), NULL);
+
+ /* Dont actually duplicate internal widgets, but recurse through them anyway. */
+ if (parent && template_widget->internal)
+ {
+ GObject *internal_object = NULL;
+
+ if ((get_internal =
+ glade_widget_get_internal_func (main_target, parent,
+ &internal_parent)) != NULL)
+ {
+ /* We cant use "parent" here, we have to recurse up the hierarchy to find
+ * the "parent" that has `get_internal_child' support (i.e. internal children
+ * may have depth).
+ */
+ if ((internal_object = get_internal (internal_parent->adaptor,
+ internal_parent->object,
+ template_widget->internal)) !=
+ NULL)
+ {
+ gwidget = glade_widget_get_from_gobject (internal_object);
+ g_assert (gwidget);
+ }
+ }
+ }
+
+ /* If either it was not internal, or we failed to lookup the internal child
+ * in the copied hierarchy (this can happen when copying an internal vbox from
+ * a composite dialog for instance). */
+ if (gwidget == NULL)
+ {
+ gchar *name = g_strdup (template_widget->name);
+ gwidget = glade_widget_adaptor_create_widget
+ (template_widget->adaptor, FALSE,
+ "name", name,
+ "parent", parent,
+ "project", template_widget->project,
+ "template", template_widget,
+ "template-exact", exact, "reason", GLADE_CREATE_COPY, NULL);
+ g_free (name);
+ }
+
+ /* Copy signals over here regardless of internal or not... */
+ if (exact)
+ glade_widget_copy_signals (gwidget, template_widget);
+
+ if ((children =
+ glade_widget_adaptor_get_children (template_widget->adaptor,
+ template_widget->object)) != NULL)
+ {
+ GList *list;
+
+ for (list = children; list && list->data; list = list->next)
+ {
+ GObject *child = G_OBJECT (list->data);
+ GladeWidget *child_gwidget, *child_dup;
+
+ child_type = g_object_get_data (child, "special-child-type");
+
+ if ((child_gwidget = glade_widget_get_from_gobject (child)) == NULL)
+ {
+ /* Bring the placeholders along ...
+ * but not unmarked internal children */
+ if (GLADE_IS_PLACEHOLDER (child))
+ {
+ placeholder = glade_placeholder_new ();
+
+ g_object_set_data_full (G_OBJECT (placeholder),
+ "special-child-type",
+ g_strdup (child_type), g_free);
+
+ glade_widget_adaptor_add (gwidget->adaptor,
+ gwidget->object,
+ G_OBJECT (placeholder));
+ }
+ }
+ else
+ {
+ /* Recurse through every GladeWidget (internal or not) */
+ child_dup =
+ glade_widget_dup_internal (main_target, gwidget,
+ child_gwidget, exact);
+
+ if (child_dup->internal == NULL)
+ {
+ g_object_set_data_full (child_dup->object,
+ "special-child-type",
+ g_strdup (child_type), g_free);
+
+ glade_widget_add_child (gwidget, child_dup, FALSE);
+ }
+
+ /* Internal children that are not heirarchic children
+ * need to avoid copying these packing props (like popup windows
+ * created on behalf of composite widgets).
+ */
+ if (glade_widget_adaptor_has_child (gwidget->adaptor,
+ gwidget->object,
+ child_dup->object))
+ glade_widget_copy_packing_props (gwidget,
+ child_dup, child_gwidget);
+
+ }
+ }
+ g_list_free (children);
+ }
+
+ if (gwidget->internal)
+ glade_widget_copy_properties (gwidget, template_widget, TRUE, exact);
+
+ if (gwidget->packing_properties == NULL)
+ gwidget->packing_properties =
+ glade_widget_dup_properties (gwidget,
+ template_widget->packing_properties, FALSE,
+ FALSE, FALSE);
+
+ /* If custom properties are still at thier
+ * default value, they need to be synced.
+ */
+ glade_widget_sync_custom_props (gwidget);
+
+ /* Some properties may not be synced so we reload them */
+ for (l = gwidget->properties; l; l = l->next)
+ glade_property_load (GLADE_PROPERTY (l->data));
+
+ if (GWA_IS_TOPLEVEL (gwidget->adaptor) && GTK_IS_WIDGET (gwidget->object))
+ g_object_set (gwidget,
+ "toplevel-width", template_widget->width,
+ "toplevel-height", template_widget->height, NULL);
+ return gwidget;
+}
+
+
+typedef struct
+{
+ GladeWidget *widget;
+ GtkWidget *placeholder;
+ GList *properties;
+
+ gchar *internal_name;
+ GList *internal_list;
} GladeChildExtract;
static GList *
-glade_widget_extract_children (GladeWidget *gwidget)
-{
- GladeChildExtract *extract;
- GList *extract_list = NULL;
- GList *children, *list;
-
- children = glade_widget_adaptor_get_children
- (gwidget->adaptor, gwidget->object);
-
- for (list = children; list && list->data; list = list->next)
- {
- GObject *child = G_OBJECT(list->data);
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
+glade_widget_extract_children (GladeWidget * gwidget)
+{
+ GladeChildExtract *extract;
+ GList *extract_list = NULL;
+ GList *children, *list;
+
+ children = glade_widget_adaptor_get_children
+ (gwidget->adaptor, gwidget->object);
+
+ for (list = children; list && list->data; list = list->next)
+ {
+ GObject *child = G_OBJECT (list->data);
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
#if 0
- g_print ("Extracting %s from %s\n",
- gchild ? gchild->name :
- GLADE_IS_PLACEHOLDER (child) ? "placeholder" : "unknown widget",
- gwidget->name);
+ g_print ("Extracting %s from %s\n",
+ gchild ? gchild->name :
+ GLADE_IS_PLACEHOLDER (child) ? "placeholder" : "unknown widget",
+ gwidget->name);
#endif
- if (gchild && gchild->internal)
- {
- /* Recurse and collect any deep child hierarchies
- * inside composite widgets.
- */
- extract = g_new0 (GladeChildExtract, 1);
- extract->internal_name = g_strdup (gchild->internal);
- extract->internal_list = glade_widget_extract_children (gchild);
- extract->properties =
- glade_widget_dup_properties (gchild, gchild->properties, TRUE, FALSE, FALSE);
-
- extract_list = g_list_prepend (extract_list, extract);
-
- }
- else if (gchild || GLADE_IS_PLACEHOLDER (child))
- {
- extract = g_new0 (GladeChildExtract, 1);
-
- if (gchild)
- {
- extract->widget = g_object_ref (gchild);
-
- /* Make copies of the packing properties
- */
- extract->properties =
- glade_widget_dup_properties
- (gchild, gchild->packing_properties, TRUE, FALSE, FALSE);
-
- glade_widget_remove_child (gwidget, gchild);
- }
- else
- {
- /* need to handle placeholders by hand here */
- extract->placeholder = g_object_ref (child);
- glade_widget_adaptor_remove (gwidget->adaptor,
- gwidget->object, child);
- }
- extract_list =
- g_list_prepend (extract_list, extract);
- }
- }
-
- if (children)
- g_list_free (children);
-
- return g_list_reverse (extract_list);
-}
+ if (gchild && gchild->internal)
+ {
+ /* Recurse and collect any deep child hierarchies
+ * inside composite widgets.
+ */
+ extract = g_new0 (GladeChildExtract, 1);
+ extract->internal_name = g_strdup (gchild->internal);
+ extract->internal_list = glade_widget_extract_children (gchild);
+ extract->properties =
+ glade_widget_dup_properties (gchild, gchild->properties, TRUE,
+ FALSE, FALSE);
+
+ extract_list = g_list_prepend (extract_list, extract);
+
+ }
+ else if (gchild || GLADE_IS_PLACEHOLDER (child))
+ {
+ extract = g_new0 (GladeChildExtract, 1);
+
+ if (gchild)
+ {
+ extract->widget = g_object_ref (gchild);
+
+ /* Make copies of the packing properties
+ */
+ extract->properties =
+ glade_widget_dup_properties
+ (gchild, gchild->packing_properties, TRUE, FALSE, FALSE);
+
+ glade_widget_remove_child (gwidget, gchild);
+ }
+ else
+ {
+ /* need to handle placeholders by hand here */
+ extract->placeholder = g_object_ref (child);
+ glade_widget_adaptor_remove (gwidget->adaptor,
+ gwidget->object, child);
+ }
+ extract_list = g_list_prepend (extract_list, extract);
+ }
+ }
-static void
-glade_widget_insert_children (GladeWidget *gwidget, GList *children)
-{
- GladeChildExtract *extract;
- GladeWidget *gchild;
- GObject *internal_object;
- GList *list, *l;
-
- for (list = children; list; list = list->next)
- {
- extract = list->data;
-
- if (extract->internal_name)
- {
- GladeGetInternalFunc get_internal;
- GladeWidget *internal_parent;
-
-
- /* Recurse and add deep widget hierarchies to internal
- * widgets.
- */
- get_internal = glade_widget_get_internal_func
- (NULL, gwidget, &internal_parent);
-
- internal_object = get_internal (internal_parent->adaptor,
- internal_parent->object,
- extract->internal_name);
-
- gchild = glade_widget_get_from_gobject (internal_object);
-
- /* This will free the list... */
- glade_widget_insert_children (gchild, extract->internal_list);
-
- /* Set the properties after inserting the children */
- for (l = extract->properties; l; l = l->next)
- {
- GValue value = { 0, };
- GladeProperty *saved_prop = l->data;
- GladeProperty *widget_prop =
- glade_widget_get_property (gchild,
- saved_prop->klass->id);
-
- glade_property_get_value (saved_prop, &value);
- glade_property_set_value (widget_prop, &value);
- g_value_unset (&value);
-
- /* Free them as we go ... */
- g_object_unref (saved_prop);
- }
-
- if (extract->properties)
- g_list_free (extract->properties);
-
- g_free (extract->internal_name);
- }
- else if (extract->widget)
- {
- glade_widget_add_child (gwidget, extract->widget, FALSE);
- g_object_unref (extract->widget);
-
- for (l = extract->properties; l; l = l->next)
- {
- GValue value = { 0, };
- GladeProperty *saved_prop = l->data;
- GladeProperty *widget_prop =
- glade_widget_get_pack_property (extract->widget,
- saved_prop->klass->id);
-
- glade_property_get_value (saved_prop, &value);
- glade_property_set_value (widget_prop, &value);
- g_value_unset (&value);
-
- /* Free them as we go ... */
- g_object_unref (saved_prop);
- }
- if (extract->properties)
- g_list_free (extract->properties);
- }
- else
- {
- glade_widget_adaptor_add (gwidget->adaptor,
- gwidget->object,
- G_OBJECT (extract->placeholder));
- g_object_unref (extract->placeholder);
- }
- g_free (extract);
- }
-
- if (children)
- g_list_free (children);
+ if (children)
+ g_list_free (children);
+
+ return g_list_reverse (extract_list);
}
static void
-glade_widget_set_properties (GladeWidget *widget, GList *properties)
+glade_widget_insert_children (GladeWidget * gwidget, GList * children)
{
- GladeProperty *property;
- GList *list;
+ GladeChildExtract *extract;
+ GladeWidget *gchild;
+ GObject *internal_object;
+ GList *list, *l;
- if (properties)
- {
- if (widget->properties)
- {
- g_list_foreach (widget->properties, (GFunc)g_object_unref, NULL);
- g_list_free (widget->properties);
- }
- if (widget->props_hash)
- g_hash_table_destroy (widget->props_hash);
+ for (list = children; list; list = list->next)
+ {
+ extract = list->data;
+
+ if (extract->internal_name)
+ {
+ GladeGetInternalFunc get_internal;
+ GladeWidget *internal_parent;
+
+
+ /* Recurse and add deep widget hierarchies to internal
+ * widgets.
+ */
+ get_internal = glade_widget_get_internal_func
+ (NULL, gwidget, &internal_parent);
+
+ internal_object = get_internal (internal_parent->adaptor,
+ internal_parent->object,
+ extract->internal_name);
+
+ gchild = glade_widget_get_from_gobject (internal_object);
+
+ /* This will free the list... */
+ glade_widget_insert_children (gchild, extract->internal_list);
+
+ /* Set the properties after inserting the children */
+ for (l = extract->properties; l; l = l->next)
+ {
+ GValue value = { 0, };
+ GladeProperty *saved_prop = l->data;
+ GladeProperty *widget_prop = glade_widget_get_property (gchild,
+ saved_prop->
+ klass->
+ id);
+
+ glade_property_get_value (saved_prop, &value);
+ glade_property_set_value (widget_prop, &value);
+ g_value_unset (&value);
+
+ /* Free them as we go ... */
+ g_object_unref (saved_prop);
+ }
+
+ if (extract->properties)
+ g_list_free (extract->properties);
+
+ g_free (extract->internal_name);
+ }
+ else if (extract->widget)
+ {
+ glade_widget_add_child (gwidget, extract->widget, FALSE);
+ g_object_unref (extract->widget);
+
+ for (l = extract->properties; l; l = l->next)
+ {
+ GValue value = { 0, };
+ GladeProperty *saved_prop = l->data;
+ GladeProperty *widget_prop =
+ glade_widget_get_pack_property (extract->widget,
+ saved_prop->klass->id);
+
+ glade_property_get_value (saved_prop, &value);
+ glade_property_set_value (widget_prop, &value);
+ g_value_unset (&value);
+
+ /* Free them as we go ... */
+ g_object_unref (saved_prop);
+ }
+ if (extract->properties)
+ g_list_free (extract->properties);
+ }
+ else
+ {
+ glade_widget_adaptor_add (gwidget->adaptor,
+ gwidget->object,
+ G_OBJECT (extract->placeholder));
+ g_object_unref (extract->placeholder);
+ }
+ g_free (extract);
+ }
- widget->properties = properties;
- widget->props_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ if (children)
+ g_list_free (children);
+}
- for (list = properties; list; list = list->next)
- {
- property = list->data;
- property->widget = widget;
+static void
+glade_widget_set_properties (GladeWidget * widget, GList * properties)
+{
+ GladeProperty *property;
+ GList *list;
- g_hash_table_insert (widget->props_hash, property->klass->id, property);
- }
- }
+ if (properties)
+ {
+ if (widget->properties)
+ {
+ g_list_foreach (widget->properties, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->properties);
+ }
+ if (widget->props_hash)
+ g_hash_table_destroy (widget->props_hash);
+
+ widget->properties = properties;
+ widget->props_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ for (list = properties; list; list = list->next)
+ {
+ property = list->data;
+ property->widget = widget;
+
+ g_hash_table_insert (widget->props_hash, property->klass->id,
+ property);
+ }
+ }
}
static void
-glade_widget_set_actions (GladeWidget *widget, GladeWidgetAdaptor *adaptor)
-{
- GList *l;
-
- for (l = adaptor->actions; l; l = g_list_next (l))
- {
- GWActionClass *action = l->data;
- GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
- "class", action, NULL);
-
- widget->actions = g_list_prepend (widget->actions,
- GLADE_WIDGET_ACTION (obj));
- }
- widget->actions = g_list_reverse (widget->actions);
+glade_widget_set_actions (GladeWidget * widget, GladeWidgetAdaptor * adaptor)
+{
+ GList *l;
+
+ for (l = adaptor->actions; l; l = g_list_next (l))
+ {
+ GWActionClass *action = l->data;
+ GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
+ "class", action, NULL);
+
+ widget->actions = g_list_prepend (widget->actions,
+ GLADE_WIDGET_ACTION (obj));
+ }
+ widget->actions = g_list_reverse (widget->actions);
}
static void
-glade_widget_set_adaptor (GladeWidget *widget, GladeWidgetAdaptor *adaptor)
+glade_widget_set_adaptor (GladeWidget * widget, GladeWidgetAdaptor * adaptor)
{
- GladePropertyClass *property_class;
- GladeProperty *property;
- GList *list, *properties = NULL;
+ GladePropertyClass *property_class;
+ GladeProperty *property;
+ GList *list, *properties = NULL;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
- /* calling set_class out of the constructor? */
- g_return_if_fail (widget->adaptor == NULL);
-
- widget->adaptor = adaptor;
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+ /* calling set_class out of the constructor? */
+ g_return_if_fail (widget->adaptor == NULL);
- /* If we have no properties; we are not in the process of loading
- */
- if (!widget->properties)
- {
- for (list = adaptor->properties; list; list = list->next)
- {
- property_class = GLADE_PROPERTY_CLASS(list->data);
- if ((property = glade_property_new (property_class,
- widget, NULL)) == NULL)
- {
- g_warning ("Failed to create [%s] property",
- property_class->id);
- continue;
- }
- properties = g_list_prepend (properties, property);
- }
- glade_widget_set_properties (widget, g_list_reverse (properties));
- }
-
- /* Create actions from adaptor */
- glade_widget_set_actions (widget, adaptor);
+ widget->adaptor = adaptor;
+
+ /* If we have no properties; we are not in the process of loading
+ */
+ if (!widget->properties)
+ {
+ for (list = adaptor->properties; list; list = list->next)
+ {
+ property_class = GLADE_PROPERTY_CLASS (list->data);
+ if ((property = glade_property_new (property_class,
+ widget, NULL)) == NULL)
+ {
+ g_warning ("Failed to create [%s] property", property_class->id);
+ continue;
+ }
+ properties = g_list_prepend (properties, property);
+ }
+ glade_widget_set_properties (widget, g_list_reverse (properties));
+ }
+
+ /* Create actions from adaptor */
+ glade_widget_set_actions (widget, adaptor);
}
static gboolean
-draw_selection (GtkWidget *widget_gtk,
- cairo_t *cr,
- GladeWidget *gwidget)
+draw_selection (GtkWidget * widget_gtk, cairo_t * cr, GladeWidget * gwidget)
{
- glade_util_draw_selection_nodes (widget_gtk, cr);
- return FALSE;
+ glade_util_draw_selection_nodes (widget_gtk, cr);
+ return FALSE;
}
@@ -1835,51 +1805,48 @@ draw_selection (GtkWidget *widget_gtk,
all its children recursively. We need this to draw the selection
rectangles and to get button press/release events reliably. */
static void
-glade_widget_connect_signal_handlers (GtkWidget *widget_gtk,
- GCallback callback,
- GladeWidget *gwidget)
-{
- GList *children, *list;
-
- /* Check if we've already connected an event handler. */
- if (!g_object_get_data (G_OBJECT (widget_gtk),
- GLADE_TAG_EVENT_HANDLER_CONNECTED))
- {
- /* Make sure we can recieve the kind of events we're
- * connecting for
- */
- gtk_widget_add_events (widget_gtk,
- GDK_POINTER_MOTION_MASK | /* Handle pointer events */
- GDK_POINTER_MOTION_HINT_MASK | /* for drag/resize and */
- GDK_BUTTON_PRESS_MASK | /* managing selection. */
- GDK_BUTTON_RELEASE_MASK);
-
- g_signal_connect (G_OBJECT (widget_gtk), "event",
- callback, gwidget);
-
- g_signal_connect_after (G_OBJECT (widget_gtk), "draw",
- G_CALLBACK (draw_selection), gwidget);
-
-
- g_object_set_data (G_OBJECT (widget_gtk),
- GLADE_TAG_EVENT_HANDLER_CONNECTED,
- GINT_TO_POINTER (1));
- }
-
- /* We also need to get expose events for any children.
- */
- if (GTK_IS_CONTAINER (widget_gtk))
- {
- if ((children =
- glade_util_container_get_all_children (GTK_CONTAINER
- (widget_gtk))) != NULL)
- {
- for (list = children; list; list = list->next)
- glade_widget_connect_signal_handlers
- (GTK_WIDGET (list->data), callback, gwidget);
- g_list_free (children);
- }
- }
+glade_widget_connect_signal_handlers (GtkWidget * widget_gtk,
+ GCallback callback, GladeWidget * gwidget)
+{
+ GList *children, *list;
+
+ /* Check if we've already connected an event handler. */
+ if (!g_object_get_data (G_OBJECT (widget_gtk),
+ GLADE_TAG_EVENT_HANDLER_CONNECTED))
+ {
+ /* Make sure we can recieve the kind of events we're
+ * connecting for
+ */
+ gtk_widget_add_events (widget_gtk, GDK_POINTER_MOTION_MASK | /* Handle pointer events */
+ GDK_POINTER_MOTION_HINT_MASK | /* for drag/resize and */
+ GDK_BUTTON_PRESS_MASK | /* managing selection. */
+ GDK_BUTTON_RELEASE_MASK);
+
+ g_signal_connect (G_OBJECT (widget_gtk), "event", callback, gwidget);
+
+ g_signal_connect_after (G_OBJECT (widget_gtk), "draw",
+ G_CALLBACK (draw_selection), gwidget);
+
+
+ g_object_set_data (G_OBJECT (widget_gtk),
+ GLADE_TAG_EVENT_HANDLER_CONNECTED,
+ GINT_TO_POINTER (1));
+ }
+
+ /* We also need to get expose events for any children.
+ */
+ if (GTK_IS_CONTAINER (widget_gtk))
+ {
+ if ((children =
+ glade_util_container_get_all_children (GTK_CONTAINER
+ (widget_gtk))) != NULL)
+ {
+ for (list = children; list; list = list->next)
+ glade_widget_connect_signal_handlers
+ (GTK_WIDGET (list->data), callback, gwidget);
+ g_list_free (children);
+ }
+ }
}
/*
@@ -1887,24 +1854,25 @@ glade_widget_connect_signal_handlers (GtkWidget *widget_gtk,
* child type for this widget of this container.
*/
static GList *
-glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *widget)
-{
- GladePropertyClass *property_class;
- GladeProperty *property;
- GList *list, *packing_props = NULL;
-
- /* XXX TODO: by checking with some GladePropertyClass metadata, decide
- * which packing properties go on which type of children.
- */
- for (list = container->adaptor->packing_props;
- list && list->data; list = list->next)
- {
- property_class = list->data;
- property = glade_property_new (property_class, widget, NULL);
- packing_props = g_list_prepend (packing_props, property);
+glade_widget_create_packing_properties (GladeWidget * container,
+ GladeWidget * widget)
+{
+ GladePropertyClass *property_class;
+ GladeProperty *property;
+ GList *list, *packing_props = NULL;
+
+ /* XXX TODO: by checking with some GladePropertyClass metadata, decide
+ * which packing properties go on which type of children.
+ */
+ for (list = container->adaptor->packing_props;
+ list && list->data; list = list->next)
+ {
+ property_class = list->data;
+ property = glade_property_new (property_class, widget, NULL);
+ packing_props = g_list_prepend (packing_props, property);
- }
- return g_list_reverse (packing_props);
+ }
+ return g_list_reverse (packing_props);
}
/*******************************************************************************
@@ -1913,22 +1881,23 @@ glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *wid
GladeWidget *
glade_widget_get_from_gobject (gpointer object)
{
- g_return_val_if_fail (G_IS_OBJECT (object), NULL);
-
- return g_object_get_qdata (G_OBJECT (object), glade_widget_name_quark);
+ g_return_val_if_fail (G_IS_OBJECT (object), NULL);
+
+ return g_object_get_qdata (G_OBJECT (object), glade_widget_name_quark);
}
static void
-glade_widget_add_to_layout (GladeWidget *widget, GtkWidget *layout)
+glade_widget_add_to_layout (GladeWidget * widget, GtkWidget * layout)
{
- if (gtk_bin_get_child (GTK_BIN (layout)) != GTK_WIDGET (widget->object))
- {
- if (gtk_bin_get_child (GTK_BIN (layout)) != NULL)
- gtk_container_remove (GTK_CONTAINER (layout), gtk_bin_get_child (GTK_BIN (layout)));
+ if (gtk_bin_get_child (GTK_BIN (layout)) != GTK_WIDGET (widget->object))
+ {
+ if (gtk_bin_get_child (GTK_BIN (layout)) != NULL)
+ gtk_container_remove (GTK_CONTAINER (layout),
+ gtk_bin_get_child (GTK_BIN (layout)));
- gtk_container_add (GTK_CONTAINER (layout), GTK_WIDGET (widget->object));
- gtk_widget_show_all (GTK_WIDGET (widget->object));
- }
+ gtk_container_add (GTK_CONTAINER (layout), GTK_WIDGET (widget->object));
+ gtk_widget_show_all (GTK_WIDGET (widget->object));
+ }
}
/**
@@ -1938,51 +1907,54 @@ glade_widget_add_to_layout (GladeWidget *widget, GtkWidget *layout)
* Display @widget in it's project's GladeDesignView
*/
void
-glade_widget_show (GladeWidget *widget)
-{
- GladeDesignView *view;
- GtkWidget *layout;
- GladeProperty *property;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget));
-
- /* Position window at saved coordinates or in the center */
- if (GTK_IS_WIDGET (widget->object) && !widget->parent)
- {
- /* Maybe a property references this widget internally, show that widget instead */
- if ((property = glade_widget_get_parentless_widget_ref (widget)) != NULL)
- {
- /* will never happen, paranoid check to avoid endless recursion. */
- if (property->widget != widget)
- glade_widget_show (property->widget);
- return;
- }
-
- view = glade_design_view_get_from_project (glade_widget_get_project (widget));
-
- if (!view)
- return;
-
- layout = GTK_WIDGET (glade_design_view_get_layout (view));
-
- if (!layout)
- return;
-
- if (gtk_widget_get_realized (layout))
- glade_widget_add_to_layout (widget, layout);
- else
- g_signal_connect_data (G_OBJECT (layout), "map",
- G_CALLBACK (glade_widget_add_to_layout),
- widget, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
-
- }
- else if (GTK_IS_WIDGET (widget->object))
- {
- GladeWidget *toplevel = glade_widget_get_toplevel (widget);
- if (toplevel != widget)
- glade_widget_show (toplevel);
- }
- widget->visible = TRUE;
+glade_widget_show (GladeWidget * widget)
+{
+ GladeDesignView *view;
+ GtkWidget *layout;
+ GladeProperty *property;
+
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+
+ /* Position window at saved coordinates or in the center */
+ if (GTK_IS_WIDGET (widget->object) && !widget->parent)
+ {
+ /* Maybe a property references this widget internally, show that widget instead */
+ if ((property = glade_widget_get_parentless_widget_ref (widget)) != NULL)
+ {
+ /* will never happen, paranoid check to avoid endless recursion. */
+ if (property->widget != widget)
+ glade_widget_show (property->widget);
+ return;
+ }
+
+ view =
+ glade_design_view_get_from_project (glade_widget_get_project
+ (widget));
+
+ if (!view)
+ return;
+
+ layout = GTK_WIDGET (glade_design_view_get_layout (view));
+
+ if (!layout)
+ return;
+
+ if (gtk_widget_get_realized (layout))
+ glade_widget_add_to_layout (widget, layout);
+ else
+ g_signal_connect_data (G_OBJECT (layout), "map",
+ G_CALLBACK (glade_widget_add_to_layout),
+ widget, NULL,
+ G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+
+ }
+ else if (GTK_IS_WIDGET (widget->object))
+ {
+ GladeWidget *toplevel = glade_widget_get_toplevel (widget);
+ if (toplevel != widget)
+ glade_widget_show (toplevel);
+ }
+ widget->visible = TRUE;
}
/**
@@ -1992,28 +1964,30 @@ glade_widget_show (GladeWidget *widget)
* Hide @widget
*/
void
-glade_widget_hide (GladeWidget *widget)
+glade_widget_hide (GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- if (GTK_IS_WIDGET (widget->object))
- {
- GladeDesignView *view;
- GtkWidget *layout;
-
- if ((view = glade_design_view_get_from_project (glade_widget_get_project (widget))) != NULL)
- {
- GtkWidget *child;
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ if (GTK_IS_WIDGET (widget->object))
+ {
+ GladeDesignView *view;
+ GtkWidget *layout;
+
+ if ((view =
+ glade_design_view_get_from_project (glade_widget_get_project
+ (widget))) != NULL)
+ {
+ GtkWidget *child;
- layout = GTK_WIDGET (glade_design_view_get_layout (view));
- child = gtk_bin_get_child (GTK_BIN (layout));
+ layout = GTK_WIDGET (glade_design_view_get_layout (view));
+ child = gtk_bin_get_child (GTK_BIN (layout));
- if (child == GTK_WIDGET (widget->object))
- gtk_container_remove (GTK_CONTAINER (layout), child);
- }
+ if (child == GTK_WIDGET (widget->object))
+ gtk_container_remove (GTK_CONTAINER (layout), child);
+ }
- gtk_widget_hide (GTK_WIDGET (widget->object));
- }
- widget->visible = FALSE;
+ gtk_widget_hide (GTK_WIDGET (widget->object));
+ }
+ widget->visible = FALSE;
}
/**
@@ -2027,19 +2001,19 @@ glade_widget_hide (GladeWidget *widget)
* reffer to this object.
*/
void
-glade_widget_add_prop_ref (GladeWidget *widget, GladeProperty *property)
+glade_widget_add_prop_ref (GladeWidget * widget, GladeProperty * property)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- if (!g_list_find (widget->prop_refs, property))
- widget->prop_refs = g_list_prepend (widget->prop_refs, property);
+ if (!g_list_find (widget->prop_refs, property))
+ widget->prop_refs = g_list_prepend (widget->prop_refs, property);
- /* parentless widget reffed widgets are added to thier reffering widgets.
- * they cant be in the design view.
- */
- if (property->klass->parentless_widget)
- glade_widget_hide (widget);
+ /* parentless widget reffed widgets are added to thier reffering widgets.
+ * they cant be in the design view.
+ */
+ if (property->klass->parentless_widget)
+ glade_widget_hide (widget);
}
/**
@@ -2053,71 +2027,72 @@ glade_widget_add_prop_ref (GladeWidget *widget, GladeProperty *property)
* reffer to this object.
*/
void
-glade_widget_remove_prop_ref (GladeWidget *widget, GladeProperty *property)
+glade_widget_remove_prop_ref (GladeWidget * widget, GladeProperty * property)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_PROPERTY (property));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_PROPERTY (property));
- widget->prop_refs = g_list_remove (widget->prop_refs, property);
+ widget->prop_refs = g_list_remove (widget->prop_refs, property);
}
GladeProperty *
-glade_widget_get_parentless_widget_ref (GladeWidget *widget)
+glade_widget_get_parentless_widget_ref (GladeWidget * widget)
{
- GList *l;
- GladeProperty *property;
+ GList *l;
+ GladeProperty *property;
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- for (l = widget->prop_refs; l && l->data; l = l->next)
- {
- property = GLADE_PROPERTY (l->data);
+ for (l = widget->prop_refs; l && l->data; l = l->next)
+ {
+ property = GLADE_PROPERTY (l->data);
- if (property->klass->parentless_widget)
- /* only one external property can point to this widget */
- return property;
- }
- return NULL;
+ if (property->klass->parentless_widget)
+ /* only one external property can point to this widget */
+ return property;
+ }
+ return NULL;
}
GList *
-glade_widget_get_parentless_reffed_widgets (GladeWidget *widget)
+glade_widget_get_parentless_reffed_widgets (GladeWidget * widget)
{
- GObject *reffed = NULL;
- GladeProperty *property = NULL;
- GList *l, *widgets = NULL;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ GObject *reffed = NULL;
+ GladeProperty *property = NULL;
+ GList *l, *widgets = NULL;
- for (l = widget->properties; l && l->data; l = l->next)
- {
- property = GLADE_PROPERTY (l->data);
- reffed = NULL;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- if (property->klass->parentless_widget)
- {
- glade_property_get (property, &reffed);
- if (reffed)
- widgets = g_list_prepend (widgets, glade_widget_get_from_gobject (reffed));
- }
- }
- return g_list_reverse (widgets);
+ for (l = widget->properties; l && l->data; l = l->next)
+ {
+ property = GLADE_PROPERTY (l->data);
+ reffed = NULL;
+
+ if (property->klass->parentless_widget)
+ {
+ glade_property_get (property, &reffed);
+ if (reffed)
+ widgets =
+ g_list_prepend (widgets,
+ glade_widget_get_from_gobject (reffed));
+ }
+ }
+ return g_list_reverse (widgets);
}
static void
-glade_widget_accum_signal_foreach (const gchar *key,
- GPtrArray *signals,
- GList **list)
+glade_widget_accum_signal_foreach (const gchar * key,
+ GPtrArray * signals, GList ** list)
{
- GladeSignal *signal;
- gint i;
+ GladeSignal *signal;
+ gint i;
- for (i = 0; i < signals->len; i++)
- {
- signal = (GladeSignal *)signals->pdata[i];
- *list = g_list_append (*list, signal);
- }
+ for (i = 0; i < signals->len; i++)
+ {
+ signal = (GladeSignal *) signals->pdata[i];
+ *list = g_list_append (*list, signal);
+ }
}
/**
@@ -2130,32 +2105,30 @@ glade_widget_accum_signal_foreach (const gchar *key,
* must call g_list_free() to free the list.
*/
GList *
-glade_widget_get_signal_list (GladeWidget *widget)
+glade_widget_get_signal_list (GladeWidget * widget)
{
- GList *signals = NULL;
+ GList *signals = NULL;
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_hash_table_foreach (widget->signals,
- (GHFunc)glade_widget_accum_signal_foreach,
- &signals);
+ g_hash_table_foreach (widget->signals,
+ (GHFunc) glade_widget_accum_signal_foreach, &signals);
- return signals;
+ return signals;
}
static void
-glade_widget_copy_signal_foreach (const gchar *key,
- GPtrArray *signals,
- GladeWidget *dest)
+glade_widget_copy_signal_foreach (const gchar * key,
+ GPtrArray * signals, GladeWidget * dest)
{
- GladeSignal *signal;
- gint i;
+ GladeSignal *signal;
+ gint i;
- for (i = 0; i < signals->len; i++)
- {
- signal = (GladeSignal *)signals->pdata[i];
- glade_widget_add_signal_handler (dest, signal);
- }
+ for (i = 0; i < signals->len; i++)
+ {
+ signal = (GladeSignal *) signals->pdata[i];
+ glade_widget_add_signal_handler (dest, signal);
+ }
}
/**
@@ -2167,15 +2140,13 @@ glade_widget_copy_signal_foreach (const gchar *key,
* matching signals in @template_widget
*/
void
-glade_widget_copy_signals (GladeWidget *widget,
- GladeWidget *template_widget)
+glade_widget_copy_signals (GladeWidget * widget, GladeWidget * template_widget)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (template_widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (template_widget));
- g_hash_table_foreach (template_widget->signals,
- (GHFunc)glade_widget_copy_signal_foreach,
- widget);
+ g_hash_table_foreach (template_widget->signals,
+ (GHFunc) glade_widget_copy_signal_foreach, widget);
}
/**
@@ -2189,53 +2160,52 @@ glade_widget_copy_signals (GladeWidget *widget,
* matching properties in @template_widget
*/
void
-glade_widget_copy_properties (GladeWidget *widget,
- GladeWidget *template_widget,
- gboolean copy_parentless,
- gboolean exact)
-{
- GList *l;
-
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (template_widget));
-
- for (l = widget->properties; l && l->data; l = l->next)
- {
- GladeProperty *widget_prop = GLADE_PROPERTY(l->data);
- GladeProperty *template_prop;
-
- /* Check if they share the same class definition, different
- * properties may have the same name (support for
- * copying properties across "not-quite" compatible widget
- * classes, like GtkImageMenuItem --> GtkCheckMenuItem).
- */
- if ((template_prop =
- glade_widget_get_property (template_widget,
- widget_prop->klass->id)) != NULL &&
- glade_property_class_match (template_prop->klass, widget_prop->klass))
- {
- if (template_prop->klass->parentless_widget && copy_parentless)
- {
- GObject *object = NULL;
- GladeWidget *parentless;
-
- glade_property_get (template_prop, &object);
- if (object)
- {
- parentless = glade_widget_get_from_gobject (object);
- parentless = glade_widget_dup (parentless, exact);
-
- glade_widget_set_project (parentless, widget->project);
-
- glade_property_set (widget_prop, parentless->object);
- }
- else
- glade_property_set (widget_prop, NULL);
- }
- else
- glade_property_set_value (widget_prop, template_prop->value);
- }
- }
+glade_widget_copy_properties (GladeWidget * widget,
+ GladeWidget * template_widget,
+ gboolean copy_parentless, gboolean exact)
+{
+ GList *l;
+
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (template_widget));
+
+ for (l = widget->properties; l && l->data; l = l->next)
+ {
+ GladeProperty *widget_prop = GLADE_PROPERTY (l->data);
+ GladeProperty *template_prop;
+
+ /* Check if they share the same class definition, different
+ * properties may have the same name (support for
+ * copying properties across "not-quite" compatible widget
+ * classes, like GtkImageMenuItem --> GtkCheckMenuItem).
+ */
+ if ((template_prop =
+ glade_widget_get_property (template_widget,
+ widget_prop->klass->id)) != NULL &&
+ glade_property_class_match (template_prop->klass, widget_prop->klass))
+ {
+ if (template_prop->klass->parentless_widget && copy_parentless)
+ {
+ GObject *object = NULL;
+ GladeWidget *parentless;
+
+ glade_property_get (template_prop, &object);
+ if (object)
+ {
+ parentless = glade_widget_get_from_gobject (object);
+ parentless = glade_widget_dup (parentless, exact);
+
+ glade_widget_set_project (parentless, widget->project);
+
+ glade_property_set (widget_prop, parentless->object);
+ }
+ else
+ glade_property_set (widget_prop, NULL);
+ }
+ else
+ glade_property_set_value (widget_prop, template_prop->value);
+ }
+ }
}
/**
@@ -2248,14 +2218,13 @@ glade_widget_copy_properties (GladeWidget *widget,
* Adds @child to @parent in a generic way for this #GladeWidget parent.
*/
void
-glade_widget_add_child (GladeWidget *parent,
- GladeWidget *child,
- gboolean at_mouse)
+glade_widget_add_child (GladeWidget * parent,
+ GladeWidget * child, gboolean at_mouse)
{
- g_return_if_fail (GLADE_IS_WIDGET (parent));
- g_return_if_fail (GLADE_IS_WIDGET (child));
+ g_return_if_fail (GLADE_IS_WIDGET (parent));
+ g_return_if_fail (GLADE_IS_WIDGET (child));
- GLADE_WIDGET_GET_CLASS (parent)->add_child (parent, child, at_mouse);
+ GLADE_WIDGET_GET_CLASS (parent)->add_child (parent, child, at_mouse);
}
/**
@@ -2266,13 +2235,12 @@ glade_widget_add_child (GladeWidget *parent,
* Removes @child from @parent in a generic way for this #GladeWidget parent.
*/
void
-glade_widget_remove_child (GladeWidget *parent,
- GladeWidget *child)
+glade_widget_remove_child (GladeWidget * parent, GladeWidget * child)
{
- g_return_if_fail (GLADE_IS_WIDGET (parent));
- g_return_if_fail (GLADE_IS_WIDGET (child));
+ g_return_if_fail (GLADE_IS_WIDGET (parent));
+ g_return_if_fail (GLADE_IS_WIDGET (child));
- GLADE_WIDGET_GET_CLASS (parent)->remove_child (parent, child);
+ GLADE_WIDGET_GET_CLASS (parent)->remove_child (parent, child);
}
/**
@@ -2288,24 +2256,24 @@ glade_widget_remove_child (GladeWidget *parent,
* Returns: The newly created #GladeWidget
*/
GladeWidget *
-glade_widget_dup (GladeWidget *template_widget,
- gboolean exact)
+glade_widget_dup (GladeWidget * template_widget, gboolean exact)
{
- GladeWidget *widget;
+ GladeWidget *widget;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (template_widget), NULL);
- g_return_val_if_fail (GLADE_IS_WIDGET (template_widget), NULL);
-
- glade_widget_push_superuser ();
- widget = glade_widget_dup_internal (template_widget, NULL, template_widget, exact);
- glade_widget_pop_superuser ();
+ glade_widget_push_superuser ();
+ widget =
+ glade_widget_dup_internal (template_widget, NULL, template_widget, exact);
+ glade_widget_pop_superuser ();
- return widget;
+ return widget;
}
typedef struct
{
- GladeProperty *property;
- GValue value;
+ GladeProperty *property;
+ GValue value;
} PropertyData;
/**
@@ -2318,156 +2286,152 @@ typedef struct
*
*/
void
-glade_widget_rebuild (GladeWidget *gwidget)
+glade_widget_rebuild (GladeWidget * gwidget)
{
- GObject *new_object, *old_object;
- GladeWidgetAdaptor *adaptor;
- GList *children;
- gboolean reselect = FALSE, inproject, inparent;
- GList *restore_properties = NULL;
- GList *save_properties, *l;
-
- g_return_if_fail (GLADE_IS_WIDGET (gwidget));
+ GObject *new_object, *old_object;
+ GladeWidgetAdaptor *adaptor;
+ GList *children;
+ gboolean reselect = FALSE, inproject, inparent;
+ GList *restore_properties = NULL;
+ GList *save_properties, *l;
- adaptor = gwidget->adaptor;
+ g_return_if_fail (GLADE_IS_WIDGET (gwidget));
- g_object_ref (gwidget);
+ adaptor = gwidget->adaptor;
- /* Extract and keep the child hierarchies aside... */
- children = glade_widget_extract_children (gwidget);
+ g_object_ref (gwidget);
- /* Here we take care removing the widget from the project and
- * the selection before rebuilding the instance.
- */
- inproject = gwidget->project ?
- (glade_project_has_object
- (gwidget->project, gwidget->object) ? TRUE : FALSE) : FALSE;
-
- if (inproject)
- {
- if (glade_project_is_selected (gwidget->project,
- gwidget->object))
- {
- reselect = TRUE;
- glade_project_selection_remove
- (gwidget->project, gwidget->object, FALSE);
- }
- glade_project_remove_object (gwidget->project, gwidget->object);
- }
-
- /* parentless_widget and object properties that reffer to this widget
- * should be unset before transfering */
- l = g_list_copy (gwidget->properties);
- save_properties = g_list_copy (gwidget->prop_refs);
- save_properties = g_list_concat (l, save_properties);
-
- for (l = save_properties; l; l = l->next)
- {
- GladeProperty *property = GLADE_PROPERTY (l->data);
- if (property->widget != gwidget || property->klass->parentless_widget)
- {
- PropertyData *prop_data;
-
- if (!G_IS_PARAM_SPEC_OBJECT (property->klass->pspec))
- g_warning ("Parentless widget property should be of object type");
-
- prop_data = g_new0 (PropertyData, 1);
- prop_data->property = property;
-
- if (property->widget == gwidget)
- {
- g_value_init (&prop_data->value, property->value->g_type);
- g_value_copy (property->value, &prop_data->value);
- }
- restore_properties = g_list_prepend (restore_properties,
- prop_data);
- glade_property_set (property, NULL);
- }
- }
- g_list_free (save_properties);
-
- /* Hold a reference to the old widget while we transport properties
- * and children from it
- */
- old_object = g_object_ref (glade_widget_get_object (gwidget));
- new_object = glade_widget_build_object (gwidget, gwidget, GLADE_CREATE_REBUILD);
+ /* Extract and keep the child hierarchies aside... */
+ children = glade_widget_extract_children (gwidget);
- /* Only call this once the object has a proper GladeWidget */
- glade_widget_adaptor_post_create (adaptor, new_object, GLADE_CREATE_REBUILD);
+ /* Here we take care removing the widget from the project and
+ * the selection before rebuilding the instance.
+ */
+ inproject = gwidget->project ?
+ (glade_project_has_object
+ (gwidget->project, gwidget->object) ? TRUE : FALSE) : FALSE;
- /* Replace old object with new object in parent
- * (this can happen during construction before the object is actually
- * added to the parent but the parent pointer is set).
- */
+ if (inproject)
+ {
+ if (glade_project_is_selected (gwidget->project, gwidget->object))
+ {
+ reselect = TRUE;
+ glade_project_selection_remove
+ (gwidget->project, gwidget->object, FALSE);
+ }
+ glade_project_remove_object (gwidget->project, gwidget->object);
+ }
- inparent = (gwidget->parent &&
- glade_widget_adaptor_has_child (gwidget->parent->adaptor,
- gwidget->parent->object,
- old_object));
- if (inparent)
- glade_widget_replace (gwidget->parent,
- old_object, new_object);
-
- /* Must call dispose for cases like dialogs and toplevels */
- if (GTK_IS_WINDOW (old_object))
- gtk_widget_destroy (GTK_WIDGET (old_object));
- else
- g_object_unref (old_object);
-
- /* Reparent any children of the old object to the new object
- * (this function will consume and free the child list).
- */
- glade_widget_push_superuser ();
- glade_widget_insert_children (gwidget, children);
- glade_widget_pop_superuser ();
-
- /* Custom properties aren't transfered in build_object, since build_object
- * is only concerned with object creation.
- */
- glade_widget_sync_custom_props (gwidget);
-
- /* Setting parentless_widget and prop_ref properties back */
- for (l = restore_properties; l; l = l->next)
- {
- PropertyData *prop_data = l->data;
- GladeProperty *property = prop_data->property;
-
- if (property->widget == gwidget)
- {
- glade_property_set_value (property, &prop_data->value);
- g_value_unset (&prop_data->value);
- }
- else
- {
- /* restore property references on rebuilt objects */
- glade_property_set (property, gwidget->object);
- }
- g_free (prop_data);
- }
- g_list_free (restore_properties);
-
- /* Sync packing.
- */
- if (inparent)
- glade_widget_sync_packing_props (gwidget);
+ /* parentless_widget and object properties that reffer to this widget
+ * should be unset before transfering */
+ l = g_list_copy (gwidget->properties);
+ save_properties = g_list_copy (gwidget->prop_refs);
+ save_properties = g_list_concat (l, save_properties);
- /* If the widget was in a project (and maybe the selection), then
- * restore that stuff.
- */
- if (inproject)
- {
- glade_project_add_object (gwidget->project, NULL,
- gwidget->object);
- if (reselect)
- glade_project_selection_add
- (gwidget->project, gwidget->object, TRUE);
- }
+ for (l = save_properties; l; l = l->next)
+ {
+ GladeProperty *property = GLADE_PROPERTY (l->data);
+ if (property->widget != gwidget || property->klass->parentless_widget)
+ {
+ PropertyData *prop_data;
+
+ if (!G_IS_PARAM_SPEC_OBJECT (property->klass->pspec))
+ g_warning ("Parentless widget property should be of object type");
+
+ prop_data = g_new0 (PropertyData, 1);
+ prop_data->property = property;
+
+ if (property->widget == gwidget)
+ {
+ g_value_init (&prop_data->value, property->value->g_type);
+ g_value_copy (property->value, &prop_data->value);
+ }
+ restore_properties = g_list_prepend (restore_properties, prop_data);
+ glade_property_set (property, NULL);
+ }
+ }
+ g_list_free (save_properties);
+
+ /* Hold a reference to the old widget while we transport properties
+ * and children from it
+ */
+ old_object = g_object_ref (glade_widget_get_object (gwidget));
+ new_object =
+ glade_widget_build_object (gwidget, gwidget, GLADE_CREATE_REBUILD);
+
+ /* Only call this once the object has a proper GladeWidget */
+ glade_widget_adaptor_post_create (adaptor, new_object, GLADE_CREATE_REBUILD);
+
+ /* Replace old object with new object in parent
+ * (this can happen during construction before the object is actually
+ * added to the parent but the parent pointer is set).
+ */
+
+ inparent = (gwidget->parent &&
+ glade_widget_adaptor_has_child (gwidget->parent->adaptor,
+ gwidget->parent->object,
+ old_object));
+ if (inparent)
+ glade_widget_replace (gwidget->parent, old_object, new_object);
+
+ /* Must call dispose for cases like dialogs and toplevels */
+ if (GTK_IS_WINDOW (old_object))
+ gtk_widget_destroy (GTK_WIDGET (old_object));
+ else
+ g_object_unref (old_object);
+
+ /* Reparent any children of the old object to the new object
+ * (this function will consume and free the child list).
+ */
+ glade_widget_push_superuser ();
+ glade_widget_insert_children (gwidget, children);
+ glade_widget_pop_superuser ();
+
+ /* Custom properties aren't transfered in build_object, since build_object
+ * is only concerned with object creation.
+ */
+ glade_widget_sync_custom_props (gwidget);
+
+ /* Setting parentless_widget and prop_ref properties back */
+ for (l = restore_properties; l; l = l->next)
+ {
+ PropertyData *prop_data = l->data;
+ GladeProperty *property = prop_data->property;
+
+ if (property->widget == gwidget)
+ {
+ glade_property_set_value (property, &prop_data->value);
+ g_value_unset (&prop_data->value);
+ }
+ else
+ {
+ /* restore property references on rebuilt objects */
+ glade_property_set (property, gwidget->object);
+ }
+ g_free (prop_data);
+ }
+ g_list_free (restore_properties);
+
+ /* Sync packing.
+ */
+ if (inparent)
+ glade_widget_sync_packing_props (gwidget);
- /* We shouldnt show if its not already visible */
- if (gwidget->visible)
- glade_widget_show (gwidget);
+ /* If the widget was in a project (and maybe the selection), then
+ * restore that stuff.
+ */
+ if (inproject)
+ {
+ glade_project_add_object (gwidget->project, NULL, gwidget->object);
+ if (reselect)
+ glade_project_selection_add (gwidget->project, gwidget->object, TRUE);
+ }
- g_object_unref (gwidget);
+ /* We shouldnt show if its not already visible */
+ if (gwidget->visible)
+ glade_widget_show (gwidget);
+
+ g_object_unref (gwidget);
}
/**
@@ -2478,11 +2442,13 @@ glade_widget_rebuild (GladeWidget *gwidget)
* Adds a signal handler for @widget
*/
void
-glade_widget_add_signal_handler (GladeWidget *widget, GladeSignal *signal_handler)
+glade_widget_add_signal_handler (GladeWidget * widget,
+ GladeSignal * signal_handler)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_signal_emit (widget, glade_widget_signals[ADD_SIGNAL_HANDLER], 0, signal_handler);
+ g_signal_emit (widget, glade_widget_signals[ADD_SIGNAL_HANDLER], 0,
+ signal_handler);
}
@@ -2494,11 +2460,13 @@ glade_widget_add_signal_handler (GladeWidget *widget, GladeSignal *signal_handle
* Removes a signal handler from @widget
*/
void
-glade_widget_remove_signal_handler (GladeWidget *widget, GladeSignal *signal_handler)
+glade_widget_remove_signal_handler (GladeWidget * widget,
+ GladeSignal * signal_handler)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_signal_emit (widget, glade_widget_signals[REMOVE_SIGNAL_HANDLER], 0, signal_handler);
+ g_signal_emit (widget, glade_widget_signals[REMOVE_SIGNAL_HANDLER], 0,
+ signal_handler);
}
/**
@@ -2510,14 +2478,14 @@ glade_widget_remove_signal_handler (GladeWidget *widget, GladeSignal *signal_han
* Changes a #GladeSignal on @widget
*/
void
-glade_widget_change_signal_handler (GladeWidget *widget,
- GladeSignal *old_signal_handler,
- GladeSignal *new_signal_handler)
+glade_widget_change_signal_handler (GladeWidget * widget,
+ GladeSignal * old_signal_handler,
+ GladeSignal * new_signal_handler)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_signal_emit (widget, glade_widget_signals[CHANGE_SIGNAL_HANDLER], 0,
- old_signal_handler, new_signal_handler);
+ g_signal_emit (widget, glade_widget_signals[CHANGE_SIGNAL_HANDLER], 0,
+ old_signal_handler, new_signal_handler);
}
/**
@@ -2528,11 +2496,10 @@ glade_widget_change_signal_handler (GladeWidget *widget,
* Returns: A #GPtrArray of #GladeSignal for @signal_name
*/
GPtrArray *
-glade_widget_list_signal_handlers (GladeWidget *widget,
- const gchar *signal_name) /* array of GladeSignal* */
+glade_widget_list_signal_handlers (GladeWidget * widget, const gchar * signal_name) /* array of GladeSignal* */
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return g_hash_table_lookup (widget->signals, signal_name);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return g_hash_table_lookup (widget->signals, signal_name);
}
/**
@@ -2543,17 +2510,17 @@ glade_widget_list_signal_handlers (GladeWidget *widget,
* Sets @widget's name to @name.
*/
void
-glade_widget_set_name (GladeWidget *widget, const gchar *name)
+glade_widget_set_name (GladeWidget * widget, const gchar * name)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- if (widget->name != name)
- {
- if (widget->name)
- g_free (widget->name);
-
- widget->name = g_strdup (name);
- g_object_notify (G_OBJECT (widget), "name");
- }
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ if (widget->name != name)
+ {
+ if (widget->name)
+ g_free (widget->name);
+
+ widget->name = g_strdup (name);
+ g_object_notify (G_OBJECT (widget), "name");
+ }
}
/**
@@ -2563,10 +2530,10 @@ glade_widget_set_name (GladeWidget *widget, const gchar *name)
* Returns: a pointer to @widget's name
*/
const gchar *
-glade_widget_get_name (GladeWidget *widget)
+glade_widget_get_name (GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return widget->name;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return widget->name;
}
/**
@@ -2577,14 +2544,15 @@ glade_widget_get_name (GladeWidget *widget)
* Sets the internal name of @widget to @internal
*/
void
-glade_widget_set_internal (GladeWidget *widget, const gchar *internal)
+glade_widget_set_internal (GladeWidget * widget, const gchar * internal)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- if (widget->internal != internal) {
- g_free (widget->internal);
- widget->internal = g_strdup (internal);
- g_object_notify (G_OBJECT (widget), "internal");
- }
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ if (widget->internal != internal)
+ {
+ g_free (widget->internal);
+ widget->internal = g_strdup (internal);
+ g_object_notify (G_OBJECT (widget), "internal");
+ }
}
/**
@@ -2594,10 +2562,10 @@ glade_widget_set_internal (GladeWidget *widget, const gchar *internal)
* Returns: the internal name of @widget
*/
G_CONST_RETURN gchar *
-glade_widget_get_internal (GladeWidget *widget)
+glade_widget_get_internal (GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return widget->internal;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return widget->internal;
}
/**
@@ -2607,10 +2575,10 @@ glade_widget_get_internal (GladeWidget *widget)
* Returns: the #GladeWidgetAdaptor of @widget
*/
GladeWidgetAdaptor *
-glade_widget_get_adaptor (GladeWidget *widget)
+glade_widget_get_adaptor (GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return widget->adaptor;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return widget->adaptor;
}
/**
@@ -2621,13 +2589,13 @@ glade_widget_get_adaptor (GladeWidget *widget)
* Makes @widget belong to @project.
*/
void
-glade_widget_set_project (GladeWidget *widget, GladeProject *project)
+glade_widget_set_project (GladeWidget * widget, GladeProject * project)
{
- if (widget->project != project)
- {
- widget->project = project;
- g_object_notify (G_OBJECT (widget), "project");
- }
+ if (widget->project != project)
+ {
+ widget->project = project;
+ g_object_notify (G_OBJECT (widget), "project");
+ }
}
/**
@@ -2637,10 +2605,10 @@ glade_widget_set_project (GladeWidget *widget, GladeProject *project)
* Returns: the #GladeProject that @widget belongs to
*/
GladeProject *
-glade_widget_get_project (GladeWidget *widget)
+glade_widget_get_project (GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return widget->project;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return widget->project;
}
/**
@@ -2651,18 +2619,18 @@ glade_widget_get_project (GladeWidget *widget)
* Returns: the #GladeProperty in @widget named @id_property
*/
GladeProperty *
-glade_widget_get_property (GladeWidget *widget, const gchar *id_property)
+glade_widget_get_property (GladeWidget * widget, const gchar * id_property)
{
- GladeProperty *property;
+ GladeProperty *property;
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (id_property != NULL, NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (id_property != NULL, NULL);
- if (widget->props_hash &&
- (property = g_hash_table_lookup (widget->props_hash, id_property)))
- return property;
+ if (widget->props_hash &&
+ (property = g_hash_table_lookup (widget->props_hash, id_property)))
+ return property;
- return glade_widget_get_pack_property (widget, id_property);
+ return glade_widget_get_pack_property (widget, id_property);
}
/**
@@ -2673,18 +2641,18 @@ glade_widget_get_property (GladeWidget *widget, const gchar *id_property)
* Returns: the #GladeProperty in @widget named @id_property
*/
GladeProperty *
-glade_widget_get_pack_property (GladeWidget *widget, const gchar *id_property)
+glade_widget_get_pack_property (GladeWidget * widget, const gchar * id_property)
{
- GladeProperty *property;
+ GladeProperty *property;
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (id_property != NULL, NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (id_property != NULL, NULL);
- if (widget->pack_props_hash &&
- (property = g_hash_table_lookup (widget->pack_props_hash, id_property)))
- return property;
+ if (widget->pack_props_hash &&
+ (property = g_hash_table_lookup (widget->pack_props_hash, id_property)))
+ return property;
- return NULL;
+ return NULL;
}
@@ -2700,24 +2668,22 @@ glade_widget_get_pack_property (GladeWidget *widget, const gchar *id_property)
*
*/
gboolean
-glade_widget_property_get (GladeWidget *widget,
- const gchar *id_property,
- ...)
-{
- GladeProperty *property;
- va_list vl;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
-
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- {
- va_start (vl, id_property);
- glade_property_get_va_list (property, vl);
- va_end (vl);
- return TRUE;
- }
- return FALSE;
+glade_widget_property_get (GladeWidget * widget, const gchar * id_property, ...)
+{
+ GladeProperty *property;
+ va_list vl;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ va_start (vl, id_property);
+ glade_property_get_va_list (property, vl);
+ va_end (vl);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2731,24 +2697,22 @@ glade_widget_property_get (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_property_set (GladeWidget *widget,
- const gchar *id_property,
- ...)
-{
- GladeProperty *property;
- va_list vl;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
-
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- {
- va_start (vl, id_property);
- glade_property_set_va_list (property, vl);
- va_end (vl);
- return TRUE;
- }
- return FALSE;
+glade_widget_property_set (GladeWidget * widget, const gchar * id_property, ...)
+{
+ GladeProperty *property;
+ va_list vl;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ va_start (vl, id_property);
+ glade_property_set_va_list (property, vl);
+ va_end (vl);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2762,24 +2726,23 @@ glade_widget_property_set (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_pack_property_get (GladeWidget *widget,
- const gchar *id_property,
- ...)
-{
- GladeProperty *property;
- va_list vl;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
-
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- {
- va_start (vl, id_property);
- glade_property_get_va_list (property, vl);
- va_end (vl);
- return TRUE;
- }
- return FALSE;
+glade_widget_pack_property_get (GladeWidget * widget,
+ const gchar * id_property, ...)
+{
+ GladeProperty *property;
+ va_list vl;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ {
+ va_start (vl, id_property);
+ glade_property_get_va_list (property, vl);
+ va_end (vl);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2793,24 +2756,23 @@ glade_widget_pack_property_get (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_pack_property_set (GladeWidget *widget,
- const gchar *id_property,
- ...)
-{
- GladeProperty *property;
- va_list vl;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
-
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- {
- va_start (vl, id_property);
- glade_property_set_va_list (property, vl);
- va_end (vl);
- return TRUE;
- }
- return FALSE;
+glade_widget_pack_property_set (GladeWidget * widget,
+ const gchar * id_property, ...)
+{
+ GladeProperty *property;
+ va_list vl;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ {
+ va_start (vl, id_property);
+ glade_property_set_va_list (property, vl);
+ va_end (vl);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2826,22 +2788,21 @@ glade_widget_pack_property_set (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_property_set_sensitive (GladeWidget *widget,
- const gchar *id_property,
- gboolean sensitive,
- const gchar *reason)
+glade_widget_property_set_sensitive (GladeWidget * widget,
+ const gchar * id_property,
+ gboolean sensitive, const gchar * reason)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
+ GladeProperty *property;
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- {
- glade_property_set_sensitive (property, sensitive, reason);
- return TRUE;
- }
- return FALSE;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ glade_property_set_sensitive (property, sensitive, reason);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2857,22 +2818,22 @@ glade_widget_property_set_sensitive (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_pack_property_set_sensitive (GladeWidget *widget,
- const gchar *id_property,
- gboolean sensitive,
- const gchar *reason)
+glade_widget_pack_property_set_sensitive (GladeWidget * widget,
+ const gchar * id_property,
+ gboolean sensitive,
+ const gchar * reason)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- {
- glade_property_set_sensitive (property, sensitive, reason);
- return TRUE;
- }
- return FALSE;
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ {
+ glade_property_set_sensitive (property, sensitive, reason);
+ return TRUE;
+ }
+ return FALSE;
}
@@ -2888,21 +2849,20 @@ glade_widget_pack_property_set_sensitive (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_property_set_enabled (GladeWidget *widget,
- const gchar *id_property,
- gboolean enabled)
+glade_widget_property_set_enabled (GladeWidget * widget,
+ const gchar * id_property, gboolean enabled)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
+ GladeProperty *property;
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- {
- glade_property_set_enabled (property, enabled);
- return TRUE;
- }
- return FALSE;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ glade_property_set_enabled (property, enabled);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2917,21 +2877,21 @@ glade_widget_property_set_enabled (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_pack_property_set_enabled (GladeWidget *widget,
- const gchar *id_property,
- gboolean enabled)
+glade_widget_pack_property_set_enabled (GladeWidget * widget,
+ const gchar * id_property,
+ gboolean enabled)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- {
- glade_property_set_enabled (property, enabled);
- return TRUE;
- }
- return FALSE;
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ {
+ glade_property_set_enabled (property, enabled);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2949,21 +2909,21 @@ glade_widget_pack_property_set_enabled (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_property_set_save_always (GladeWidget *widget,
- const gchar *id_property,
- gboolean setting)
+glade_widget_property_set_save_always (GladeWidget * widget,
+ const gchar * id_property,
+ gboolean setting)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
+ GladeProperty *property;
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- {
- glade_property_set_save_always (property, setting);
- return TRUE;
- }
- return FALSE;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
+
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ glade_property_set_save_always (property, setting);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -2981,21 +2941,21 @@ glade_widget_property_set_save_always (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_pack_property_set_save_always (GladeWidget *widget,
- const gchar *id_property,
- gboolean setting)
+glade_widget_pack_property_set_save_always (GladeWidget * widget,
+ const gchar * id_property,
+ gboolean setting)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- g_return_val_if_fail (id_property != NULL, FALSE);
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (id_property != NULL, FALSE);
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- {
- glade_property_set_save_always (property, setting);
- return TRUE;
- }
- return FALSE;
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ {
+ glade_property_set_save_always (property, setting);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -3013,22 +2973,21 @@ glade_widget_pack_property_set_save_always (GladeWidget *widget,
* Returns: A newly allocated string representing @id_property
*/
gchar *
-glade_widget_property_string (GladeWidget *widget,
- const gchar *id_property,
- const GValue *value)
+glade_widget_property_string (GladeWidget * widget,
+ const gchar * id_property, const GValue * value)
{
- GladeProperty *property;
- gchar *ret_string = NULL;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (id_property != NULL, NULL);
+ GladeProperty *property;
+ gchar *ret_string = NULL;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (id_property != NULL, NULL);
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- ret_string = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, value ? value : property->value);
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ ret_string = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle),
+ property->klass, value ? value : property->value);
- return ret_string;
+ return ret_string;
}
/**
@@ -3043,22 +3002,22 @@ glade_widget_property_string (GladeWidget *widget,
* Returns: A newly allocated string representing @id_property
*/
gchar *
-glade_widget_pack_property_string (GladeWidget *widget,
- const gchar *id_property,
- const GValue *value)
+glade_widget_pack_property_string (GladeWidget * widget,
+ const gchar * id_property,
+ const GValue * value)
{
- GladeProperty *property;
- gchar *ret_string = NULL;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (id_property != NULL, NULL);
+ GladeProperty *property;
+ gchar *ret_string = NULL;
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- ret_string = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, value ? value : property->value);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (id_property != NULL, NULL);
- return ret_string;
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ ret_string = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle),
+ property->klass, value ? value : property->value);
+
+ return ret_string;
}
@@ -3072,19 +3031,18 @@ glade_widget_pack_property_string (GladeWidget *widget,
* Returns: whether @id_property was found or not.
*/
gboolean
-glade_widget_property_reset (GladeWidget *widget,
- const gchar *id_property)
+glade_widget_property_reset (GladeWidget * widget, const gchar * id_property)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- {
- glade_property_reset (property);
- return TRUE;
- }
- return FALSE;
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ {
+ glade_property_reset (property);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -3096,35 +3054,36 @@ glade_widget_property_reset (GladeWidget *widget,
*
* Returns: whether @id_property was found or not.
*/
-gboolean
-glade_widget_pack_property_reset (GladeWidget *widget,
- const gchar *id_property)
+gboolean
+glade_widget_pack_property_reset (GladeWidget * widget,
+ const gchar * id_property)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- {
- glade_property_reset (property);
- return TRUE;
- }
- return FALSE;
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ {
+ glade_property_reset (property);
+ return TRUE;
+ }
+ return FALSE;
}
static gboolean
-glade_widget_property_default_common (GladeWidget *widget,
- const gchar *id_property, gboolean original)
+glade_widget_property_default_common (GladeWidget * widget,
+ const gchar * id_property,
+ gboolean original)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ GladeProperty *property;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- if ((property = glade_widget_get_property (widget, id_property)) != NULL)
- return (original) ? glade_property_original_default (property) :
- glade_property_default (property);
+ if ((property = glade_widget_get_property (widget, id_property)) != NULL)
+ return (original) ? glade_property_original_default (property) :
+ glade_property_default (property);
- return FALSE;
+ return FALSE;
}
/**
@@ -3136,10 +3095,9 @@ glade_widget_property_default_common (GladeWidget *widget,
* currently set to it's default value.
*/
gboolean
-glade_widget_property_default (GladeWidget *widget,
- const gchar *id_property)
+glade_widget_property_default (GladeWidget * widget, const gchar * id_property)
{
- return glade_widget_property_default_common (widget, id_property, FALSE);
+ return glade_widget_property_default_common (widget, id_property, FALSE);
}
/**
@@ -3151,10 +3109,10 @@ glade_widget_property_default (GladeWidget *widget,
* currently set to it's original default value.
*/
gboolean
-glade_widget_property_original_default (GladeWidget *widget,
- const gchar *id_property)
+glade_widget_property_original_default (GladeWidget * widget,
+ const gchar * id_property)
{
- return glade_widget_property_default_common (widget, id_property, TRUE);
+ return glade_widget_property_default_common (widget, id_property, TRUE);
}
/**
@@ -3165,18 +3123,18 @@ glade_widget_property_original_default (GladeWidget *widget,
* Returns: whether whether @id_property was found and is
* currently set to it's default value.
*/
-gboolean
-glade_widget_pack_property_default (GladeWidget *widget,
- const gchar *id_property)
+gboolean
+glade_widget_pack_property_default (GladeWidget * widget,
+ const gchar * id_property)
{
- GladeProperty *property;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ GladeProperty *property;
- if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
- return glade_property_default (property);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- return FALSE;
+ if ((property = glade_widget_get_pack_property (widget, id_property)) != NULL)
+ return glade_property_default (property);
+
+ return FALSE;
}
@@ -3190,16 +3148,15 @@ glade_widget_pack_property_default (GladeWidget *widget,
* the runtime object of @widget.
*/
void
-glade_widget_object_set_property (GladeWidget *widget,
- const gchar *property_name,
- const GValue *value)
+glade_widget_object_set_property (GladeWidget * widget,
+ const gchar * property_name,
+ const GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (property_name != NULL && value != NULL);
- glade_widget_adaptor_set_property (widget->adaptor,
- widget->object,
- property_name, value);
+ glade_widget_adaptor_set_property (widget->adaptor,
+ widget->object, property_name, value);
}
@@ -3213,16 +3170,14 @@ glade_widget_object_set_property (GladeWidget *widget,
* the runtime object of @widget and sets it in @value.
*/
void
-glade_widget_object_get_property (GladeWidget *widget,
- const gchar *property_name,
- GValue *value)
+glade_widget_object_get_property (GladeWidget * widget,
+ const gchar * property_name, GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (property_name != NULL && value != NULL);
- glade_widget_adaptor_get_property (widget->adaptor,
- widget->object,
- property_name, value);
+ glade_widget_adaptor_get_property (widget->adaptor,
+ widget->object, property_name, value);
}
/**
@@ -3235,19 +3190,18 @@ glade_widget_object_get_property (GladeWidget *widget,
* Sets @child's packing property identified by @property_name to @value.
*/
void
-glade_widget_child_set_property (GladeWidget *widget,
- GladeWidget *child,
- const gchar *property_name,
- const GValue *value)
+glade_widget_child_set_property (GladeWidget * widget,
+ GladeWidget * child,
+ const gchar * property_name,
+ const GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (child));
- g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (child));
+ g_return_if_fail (property_name != NULL && value != NULL);
- glade_widget_adaptor_child_set_property (widget->adaptor,
- widget->object,
- child->object,
- property_name, value);
+ glade_widget_adaptor_child_set_property (widget->adaptor,
+ widget->object,
+ child->object, property_name, value);
}
/**
@@ -3260,124 +3214,123 @@ glade_widget_child_set_property (GladeWidget *widget,
* Gets @child's packing property identified by @property_name.
*/
void
-glade_widget_child_get_property (GladeWidget *widget,
- GladeWidget *child,
- const gchar *property_name,
- GValue *value)
+glade_widget_child_get_property (GladeWidget * widget,
+ GladeWidget * child,
+ const gchar * property_name, GValue * value)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (child));
- g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (child));
+ g_return_if_fail (property_name != NULL && value != NULL);
- glade_widget_adaptor_child_get_property (widget->adaptor,
- widget->object,
- child->object,
- property_name, value);
+ glade_widget_adaptor_child_get_property (widget->adaptor,
+ widget->object,
+ child->object, property_name, value);
}
-static gboolean
-glade_widget_event_private (GtkWidget *widget,
- GdkEvent *event,
- GladeWidget *gwidget)
+static gboolean
+glade_widget_event_private (GtkWidget * widget,
+ GdkEvent * event, GladeWidget * gwidget)
{
- GtkWidget *layout = widget;
+ GtkWidget *layout = widget;
- /* Dont run heavy machienery for events we're not interested in
- * marshalling */
- if (!IS_GLADE_WIDGET_EVENT (event->type))
- return FALSE;
+ /* Dont run heavy machienery for events we're not interested in
+ * marshalling */
+ if (!IS_GLADE_WIDGET_EVENT (event->type))
+ return FALSE;
- /* Find the parenting layout container */
- while (layout && !GLADE_IS_DESIGN_LAYOUT (layout))
- layout = gtk_widget_get_parent (layout);
+ /* Find the parenting layout container */
+ while (layout && !GLADE_IS_DESIGN_LAYOUT (layout))
+ layout = gtk_widget_get_parent (layout);
- /* Event outside the logical heirarchy, could be a menuitem
- * or other such popup window, we'll presume to send it directly
- * to the GladeWidget that connected here.
- */
- if (!layout)
- return glade_widget_event (gwidget, event);
+ /* Event outside the logical heirarchy, could be a menuitem
+ * or other such popup window, we'll presume to send it directly
+ * to the GladeWidget that connected here.
+ */
+ if (!layout)
+ return glade_widget_event (gwidget, event);
- /* Let the parenting GladeDesignLayout decide which GladeWidget to
- * marshall this event to.
- */
- if (GLADE_IS_DESIGN_LAYOUT (layout))
- return glade_design_layout_widget_event (GLADE_DESIGN_LAYOUT (layout),
- gwidget, event);
- else
- return FALSE;
+ /* Let the parenting GladeDesignLayout decide which GladeWidget to
+ * marshall this event to.
+ */
+ if (GLADE_IS_DESIGN_LAYOUT (layout))
+ return glade_design_layout_widget_event (GLADE_DESIGN_LAYOUT (layout),
+ gwidget, event);
+ else
+ return FALSE;
}
static void
-glade_widget_set_object (GladeWidget *gwidget, GObject *new_object, gboolean destroy)
-{
- GladeWidgetAdaptor *adaptor;
- GObject *old_object;
-
- g_return_if_fail (GLADE_IS_WIDGET (gwidget));
- g_return_if_fail (new_object == NULL ||
- g_type_is_a (G_OBJECT_TYPE (new_object),
- gwidget->adaptor->type));
-
- if (gwidget->object == new_object)
- return;
-
- adaptor = gwidget->adaptor;
- old_object = gwidget->object;
- gwidget->object = new_object;
-
- if (new_object)
- {
- /* Add internal reference to new widget if its not internal */
- if (gwidget->internal == NULL)
- {
- /* Assume ownership of floating objects */
- if (g_object_is_floating (new_object))
- g_object_ref_sink (new_object);
- }
-
- g_object_set_qdata (G_OBJECT (new_object), glade_widget_name_quark, gwidget);
-
- if (g_type_is_a (gwidget->adaptor->type, GTK_TYPE_WIDGET))
- {
- /* Disable any built-in DnD
- */
- gtk_drag_dest_unset (GTK_WIDGET (new_object));
- gtk_drag_source_unset (GTK_WIDGET (new_object));
-
- /* Take care of drawing selection directly on widgets
- * for the time being
- */
- glade_widget_connect_signal_handlers
- (GTK_WIDGET(new_object),
- G_CALLBACK (glade_widget_event_private),
- gwidget);
- }
- }
-
- /* Remove internal reference to old widget */
- if (old_object)
- {
- /* From this point on, the GladeWidget is no longer retrievable with
- * glade_widget_get_from_gobject() */
- g_object_set_qdata (G_OBJECT (old_object), glade_widget_name_quark, NULL);
-
- if (gwidget->internal == NULL)
- {
+glade_widget_set_object (GladeWidget * gwidget, GObject * new_object,
+ gboolean destroy)
+{
+ GladeWidgetAdaptor *adaptor;
+ GObject *old_object;
+
+ g_return_if_fail (GLADE_IS_WIDGET (gwidget));
+ g_return_if_fail (new_object == NULL ||
+ g_type_is_a (G_OBJECT_TYPE (new_object),
+ gwidget->adaptor->type));
+
+ if (gwidget->object == new_object)
+ return;
+
+ adaptor = gwidget->adaptor;
+ old_object = gwidget->object;
+ gwidget->object = new_object;
+
+ if (new_object)
+ {
+ /* Add internal reference to new widget if its not internal */
+ if (gwidget->internal == NULL)
+ {
+ /* Assume ownership of floating objects */
+ if (g_object_is_floating (new_object))
+ g_object_ref_sink (new_object);
+ }
+
+ g_object_set_qdata (G_OBJECT (new_object), glade_widget_name_quark,
+ gwidget);
+
+ if (g_type_is_a (gwidget->adaptor->type, GTK_TYPE_WIDGET))
+ {
+ /* Disable any built-in DnD
+ */
+ gtk_drag_dest_unset (GTK_WIDGET (new_object));
+ gtk_drag_source_unset (GTK_WIDGET (new_object));
+
+ /* Take care of drawing selection directly on widgets
+ * for the time being
+ */
+ glade_widget_connect_signal_handlers
+ (GTK_WIDGET (new_object),
+ G_CALLBACK (glade_widget_event_private), gwidget);
+ }
+ }
+
+ /* Remove internal reference to old widget */
+ if (old_object)
+ {
+ /* From this point on, the GladeWidget is no longer retrievable with
+ * glade_widget_get_from_gobject() */
+ g_object_set_qdata (G_OBJECT (old_object), glade_widget_name_quark, NULL);
+
+ if (gwidget->internal == NULL)
+ {
#if _YOU_WANT_TO_LOOK_AT_PROJECT_REFCOUNT_BALANCING_
- g_print ("Killing '%s::%s' widget's object with reference count %d\n",
- gwidget->adaptor->name, gwidget->name ? gwidget->name : "(unknown)",
- old_object->ref_count);
+ g_print ("Killing '%s::%s' widget's object with reference count %d\n",
+ gwidget->adaptor->name,
+ gwidget->name ? gwidget->name : "(unknown)",
+ old_object->ref_count);
#endif
- if (GTK_IS_WINDOW (old_object) && destroy)
- gtk_widget_destroy (GTK_WIDGET (old_object));
- else
- g_object_unref (old_object);
-
- }
- }
- g_object_notify (G_OBJECT (gwidget), "object");
+ if (GTK_IS_WINDOW (old_object) && destroy)
+ gtk_widget_destroy (GTK_WIDGET (old_object));
+ else
+ g_object_unref (old_object);
+
+ }
+ }
+ g_object_notify (G_OBJECT (gwidget), "object");
}
/**
@@ -3387,10 +3340,10 @@ glade_widget_set_object (GladeWidget *gwidget, GObject *new_object, gboolean des
* Returns: the #GObject associated with @widget
*/
GObject *
-glade_widget_get_object (GladeWidget *widget)
+glade_widget_get_object (GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return widget->object;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return widget->object;
}
/**
@@ -3400,10 +3353,10 @@ glade_widget_get_object (GladeWidget *widget)
* Returns: The parenting #GladeWidget
*/
GladeWidget *
-glade_widget_get_parent (GladeWidget *widget)
+glade_widget_get_parent (GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- return widget->parent;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ return widget->parent;
}
/**
@@ -3414,33 +3367,33 @@ glade_widget_get_parent (GladeWidget *widget)
* sets the parenting #GladeWidget
*/
void
-glade_widget_set_parent (GladeWidget *widget,
- GladeWidget *parent)
+glade_widget_set_parent (GladeWidget * widget, GladeWidget * parent)
{
- GladeWidget *old_parent;
+ GladeWidget *old_parent;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
- old_parent = widget->parent;
- widget->parent = parent;
+ old_parent = widget->parent;
+ widget->parent = parent;
- /* Set packing props only if the object is actually parented by 'parent'
- * (a subsequent call should come from glade_command after parenting).
- */
- if (widget->object && parent != NULL &&
- glade_widget_adaptor_has_child
- (parent->adaptor, parent->object, widget->object))
- {
- if (old_parent == NULL || widget->packing_properties == NULL ||
- old_parent->adaptor->type != parent->adaptor->type)
- glade_widget_set_packing_properties (widget, parent);
- else
- glade_widget_sync_packing_props (widget);
- }
-
- if (parent) glade_widget_set_packing_actions (widget, parent);
-
- g_object_notify (G_OBJECT (widget), "parent");
+ /* Set packing props only if the object is actually parented by 'parent'
+ * (a subsequent call should come from glade_command after parenting).
+ */
+ if (widget->object && parent != NULL &&
+ glade_widget_adaptor_has_child
+ (parent->adaptor, parent->object, widget->object))
+ {
+ if (old_parent == NULL || widget->packing_properties == NULL ||
+ old_parent->adaptor->type != parent->adaptor->type)
+ glade_widget_set_packing_properties (widget, parent);
+ else
+ glade_widget_sync_packing_props (widget);
+ }
+
+ if (parent)
+ glade_widget_set_packing_actions (widget, parent);
+
+ g_object_notify (G_OBJECT (widget), "parent");
}
/**
@@ -3457,29 +3410,30 @@ glade_widget_set_parent (GladeWidget *widget,
* exposed for Glade configuration</para></note>
*/
GList *
-glade_widget_get_children (GladeWidget *widget)
-{
- GList *adapter_children;
- GList *real_children = NULL;
- GList *node;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
-
- adapter_children = glade_widget_adaptor_get_children (glade_widget_get_adaptor (widget),
- widget->object);
-
- for (node = adapter_children; node != NULL; node = g_list_next (node))
- {
- if (glade_widget_get_from_gobject (node->data))
- {
- real_children = g_list_prepend (real_children, node->data);
- }
- }
- g_list_free (adapter_children);
-
- return g_list_reverse (real_children);
-}
-
+glade_widget_get_children (GladeWidget * widget)
+{
+ GList *adapter_children;
+ GList *real_children = NULL;
+ GList *node;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+
+ adapter_children =
+ glade_widget_adaptor_get_children (glade_widget_get_adaptor (widget),
+ widget->object);
+
+ for (node = adapter_children; node != NULL; node = g_list_next (node))
+ {
+ if (glade_widget_get_from_gobject (node->data))
+ {
+ real_children = g_list_prepend (real_children, node->data);
+ }
+ }
+ g_list_free (adapter_children);
+
+ return g_list_reverse (real_children);
+}
+
/**
* glade_widget_get_toplevel:
@@ -3488,15 +3442,15 @@ glade_widget_get_children (GladeWidget *widget)
* Returns: The toplevel #GladeWidget in the hierarchy (or @widget)
*/
GladeWidget *
-glade_widget_get_toplevel (GladeWidget *widget)
+glade_widget_get_toplevel (GladeWidget * widget)
{
- GladeWidget *toplevel = widget;
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ GladeWidget *toplevel = widget;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- while (toplevel->parent)
- toplevel = toplevel->parent;
+ while (toplevel->parent)
+ toplevel = toplevel->parent;
- return toplevel;
+ return toplevel;
}
/**
@@ -3510,60 +3464,58 @@ glade_widget_get_toplevel (GladeWidget *widget)
* has changed, the current list is freed and replaced.
*/
void
-glade_widget_set_packing_properties (GladeWidget *widget,
- GladeWidget *container)
+glade_widget_set_packing_properties (GladeWidget * widget,
+ GladeWidget * container)
{
- GList *list;
+ GList *list;
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (container));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (container));
- g_list_foreach (widget->packing_properties, (GFunc)g_object_unref, NULL);
- g_list_free (widget->packing_properties);
- widget->packing_properties = NULL;
+ g_list_foreach (widget->packing_properties, (GFunc) g_object_unref, NULL);
+ g_list_free (widget->packing_properties);
+ widget->packing_properties = NULL;
- if (widget->pack_props_hash)
- g_hash_table_destroy (widget->pack_props_hash);
- widget->pack_props_hash = NULL;
+ if (widget->pack_props_hash)
+ g_hash_table_destroy (widget->pack_props_hash);
+ widget->pack_props_hash = NULL;
- /* We have to detect whether this is an anarchist child of a composite
- * widget or not, in otherwords; whether its really a direct child or
- * a child of a popup window created on the composite widget's behalf.
- */
- if (widget->anarchist) return;
+ /* We have to detect whether this is an anarchist child of a composite
+ * widget or not, in otherwords; whether its really a direct child or
+ * a child of a popup window created on the composite widget's behalf.
+ */
+ if (widget->anarchist)
+ return;
- widget->packing_properties = glade_widget_create_packing_properties (container, widget);
- widget->pack_props_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ widget->packing_properties =
+ glade_widget_create_packing_properties (container, widget);
+ widget->pack_props_hash = g_hash_table_new (g_str_hash, g_str_equal);
- /* update the quick reference hash table */
- for (list = widget->packing_properties;
- list && list->data;
- list = list->next)
- {
- GladeProperty *property = list->data;
- g_hash_table_insert (widget->pack_props_hash, property->klass->id, property);
- }
+ /* update the quick reference hash table */
+ for (list = widget->packing_properties; list && list->data; list = list->next)
+ {
+ GladeProperty *property = list->data;
+ g_hash_table_insert (widget->pack_props_hash, property->klass->id,
+ property);
+ }
- /* Dont introspect on properties that are not parented yet.
- */
- if (glade_widget_adaptor_has_child (container->adaptor,
- container->object,
- widget->object))
- {
- glade_widget_set_default_packing_properties (container, widget);
-
- /* update the values of the properties to the ones we get from gtk */
- for (list = widget->packing_properties;
- list && list->data;
- list = list->next)
- {
- GladeProperty *property = list->data;
- g_value_reset (property->value);
- glade_widget_child_get_property
- (container,
- widget, property->klass->id, property->value);
- }
- }
+ /* Dont introspect on properties that are not parented yet.
+ */
+ if (glade_widget_adaptor_has_child (container->adaptor,
+ container->object, widget->object))
+ {
+ glade_widget_set_default_packing_properties (container, widget);
+
+ /* update the values of the properties to the ones we get from gtk */
+ for (list = widget->packing_properties;
+ list && list->data; list = list->next)
+ {
+ GladeProperty *property = list->data;
+ g_value_reset (property->value);
+ glade_widget_child_get_property
+ (container, widget, property->klass->id, property->value);
+ }
+ }
}
/**
@@ -3575,30 +3527,29 @@ glade_widget_set_packing_properties (GladeWidget *widget,
* or any decendants that implement the @type interface
*/
gboolean
-glade_widget_has_decendant (GladeWidget *widget, GType type)
-{
- GladeWidget *child;
- GList *children, *l;
- gboolean found = FALSE;
-
- if (G_TYPE_IS_INTERFACE (type) &&
- glade_util_class_implements_interface
- (widget->adaptor->type, type))
- return TRUE;
- else if (G_TYPE_IS_INTERFACE (type) == FALSE &&
- g_type_is_a (widget->adaptor->type, type))
- return TRUE;
-
- if ((children = glade_widget_adaptor_get_children
- (widget->adaptor, widget->object)) != NULL)
- {
- for (l = children; l; l = l->next)
- if ((child = glade_widget_get_from_gobject (l->data)) != NULL &&
- (found = glade_widget_has_decendant (child, type)))
- break;
- g_list_free (children);
- }
- return found;
+glade_widget_has_decendant (GladeWidget * widget, GType type)
+{
+ GladeWidget *child;
+ GList *children, *l;
+ gboolean found = FALSE;
+
+ if (G_TYPE_IS_INTERFACE (type) &&
+ glade_util_class_implements_interface (widget->adaptor->type, type))
+ return TRUE;
+ else if (G_TYPE_IS_INTERFACE (type) == FALSE &&
+ g_type_is_a (widget->adaptor->type, type))
+ return TRUE;
+
+ if ((children = glade_widget_adaptor_get_children
+ (widget->adaptor, widget->object)) != NULL)
+ {
+ for (l = children; l; l = l->next)
+ if ((child = glade_widget_get_from_gobject (l->data)) != NULL &&
+ (found = glade_widget_has_decendant (child, type)))
+ break;
+ g_list_free (children);
+ }
+ return found;
}
/**
@@ -3612,12 +3563,14 @@ glade_widget_has_decendant (GladeWidget *widget, GType type)
* Note that both GObjects must be owned by a GladeWidget.
*/
void
-glade_widget_replace (GladeWidget *parent, GObject *old_object, GObject *new_object)
+glade_widget_replace (GladeWidget * parent, GObject * old_object,
+ GObject * new_object)
{
- g_return_if_fail (G_IS_OBJECT (old_object));
- g_return_if_fail (G_IS_OBJECT (new_object));
+ g_return_if_fail (G_IS_OBJECT (old_object));
+ g_return_if_fail (G_IS_OBJECT (new_object));
- GLADE_WIDGET_GET_CLASS (parent)->replace_child (parent, old_object, new_object);
+ GLADE_WIDGET_GET_CLASS (parent)->replace_child (parent, old_object,
+ new_object);
}
/*******************************************************************************
@@ -3625,53 +3578,48 @@ glade_widget_replace (GladeWidget *parent, GObject *old_object, GObject *new_obj
*******************************************************************************/
/* XXX Doc me !*/
void
-glade_widget_write_special_child_prop (GladeWidget *parent,
- GObject *object,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_widget_write_special_child_prop (GladeWidget * parent,
+ GObject * object,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *packing_node;
- gchar *buff, *special_child_type;
+ GladeXmlNode *packing_node;
+ gchar *buff, *special_child_type;
- buff = g_object_get_data (object, "special-child-type");
- g_object_get (parent->adaptor, "special-child-type", &special_child_type, NULL);
+ buff = g_object_get_data (object, "special-child-type");
+ g_object_get (parent->adaptor, "special-child-type", &special_child_type,
+ NULL);
- packing_node = glade_xml_search_child (node, GLADE_XML_TAG_PACKING);
+ packing_node = glade_xml_search_child (node, GLADE_XML_TAG_PACKING);
- if (special_child_type && buff)
- {
- glade_xml_node_set_property_string (node,
- GLADE_XML_TAG_TYPE,
- buff);
- }
- g_free (special_child_type);
+ if (special_child_type && buff)
+ {
+ glade_xml_node_set_property_string (node, GLADE_XML_TAG_TYPE, buff);
+ }
+ g_free (special_child_type);
}
/* XXX Doc me ! */
void
-glade_widget_set_child_type_from_node (GladeWidget *parent,
- GObject *child,
- GladeXmlNode *node)
+glade_widget_set_child_type_from_node (GladeWidget * parent,
+ GObject * child, GladeXmlNode * node)
{
- gchar *special_child_type, *value;
+ gchar *special_child_type, *value;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
+ return;
- g_object_get (parent->adaptor, "special-child-type", &special_child_type, NULL);
- if (!special_child_type)
- return;
-
- /* all child types here are depicted by the "type" property */
- if ((value =
- glade_xml_get_property_string (node, GLADE_XML_TAG_TYPE)))
- {
- g_object_set_data_full (child,
- "special-child-type",
- value,
- g_free);
- }
- g_free (special_child_type);
+ g_object_get (parent->adaptor, "special-child-type", &special_child_type,
+ NULL);
+ if (!special_child_type)
+ return;
+
+ /* all child types here are depicted by the "type" property */
+ if ((value = glade_xml_get_property_string (node, GLADE_XML_TAG_TYPE)))
+ {
+ g_object_set_data_full (child, "special-child-type", value, g_free);
+ }
+ g_free (special_child_type);
}
@@ -3683,13 +3631,12 @@ glade_widget_set_child_type_from_node (GladeWidget *parent,
* Reads in a child widget from the xml (handles 'child' tag)
*/
void
-glade_widget_read_child (GladeWidget *widget,
- GladeXmlNode *node)
+glade_widget_read_child (GladeWidget * widget, GladeXmlNode * node)
{
- if (glade_project_load_cancelled (widget->project))
- return;
+ if (glade_project_load_cancelled (widget->project))
+ return;
- glade_widget_adaptor_read_child (widget->adaptor, widget, node);
+ glade_widget_adaptor_read_child (widget->adaptor, widget, node);
}
/**
@@ -3701,86 +3648,79 @@ glade_widget_read_child (GladeWidget *widget,
* Returns: a new #GladeWidget for @project, based on @node
*/
GladeWidget *
-glade_widget_read (GladeProject *project,
- GladeWidget *parent,
- GladeXmlNode *node,
- const gchar *internal)
-{
- GladeWidgetAdaptor *adaptor;
- GladeWidget *widget = NULL;
- gchar *klass, *id;
-
- if (glade_project_load_cancelled (project))
- return NULL;
-
- glade_widget_push_superuser ();
-
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return NULL;
-
- if ((klass =
- glade_xml_get_property_string_required
- (node, GLADE_XML_TAG_CLASS, NULL)) != NULL)
- {
- if ((id =
- glade_xml_get_property_string_required
- (node, GLADE_XML_TAG_ID, NULL)) != NULL)
- {
- /*
- * Create GladeWidget instance based on type.
- */
- if ((adaptor =
- glade_widget_adaptor_get_by_name (klass)) != NULL)
- {
-
- // Internal children !!!
- if (internal)
- {
- GObject *child_object =
- glade_widget_get_internal_child
- (parent, internal);
-
- if (!child_object)
- {
- g_warning ("Failed to locate "
- "internal child %s of %s",
- internal,
- glade_widget_get_name (parent));
- return FALSE;
- }
-
- if (!(widget =
- glade_widget_get_from_gobject (child_object)))
- g_error ("Unable to get GladeWidget "
- "for internal child %s\n",
- internal);
-
- /* Apply internal widget name from here */
- glade_widget_set_name (widget, id);
- } else {
- widget = glade_widget_adaptor_create_widget
- (adaptor, FALSE,
- "name", id,
- "parent", parent,
- "project", project,
- "reason", GLADE_CREATE_LOAD, NULL);
- }
-
- glade_widget_adaptor_read_widget (adaptor,
- widget,
- node);
-
- }
- g_free (id);
- }
- g_free (klass);
- }
-
- glade_widget_pop_superuser ();
-
- glade_project_push_progress (project);
-
- return widget;
+glade_widget_read (GladeProject * project,
+ GladeWidget * parent,
+ GladeXmlNode * node, const gchar * internal)
+{
+ GladeWidgetAdaptor *adaptor;
+ GladeWidget *widget = NULL;
+ gchar *klass, *id;
+
+ if (glade_project_load_cancelled (project))
+ return NULL;
+
+ glade_widget_push_superuser ();
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return NULL;
+
+ if ((klass =
+ glade_xml_get_property_string_required
+ (node, GLADE_XML_TAG_CLASS, NULL)) != NULL)
+ {
+ if ((id =
+ glade_xml_get_property_string_required
+ (node, GLADE_XML_TAG_ID, NULL)) != NULL)
+ {
+ /*
+ * Create GladeWidget instance based on type.
+ */
+ if ((adaptor = glade_widget_adaptor_get_by_name (klass)) != NULL)
+ {
+
+ // Internal children !!!
+ if (internal)
+ {
+ GObject *child_object =
+ glade_widget_get_internal_child (parent, internal);
+
+ if (!child_object)
+ {
+ g_warning ("Failed to locate "
+ "internal child %s of %s",
+ internal, glade_widget_get_name (parent));
+ return FALSE;
+ }
+
+ if (!(widget = glade_widget_get_from_gobject (child_object)))
+ g_error ("Unable to get GladeWidget "
+ "for internal child %s\n", internal);
+
+ /* Apply internal widget name from here */
+ glade_widget_set_name (widget, id);
+ }
+ else
+ {
+ widget = glade_widget_adaptor_create_widget
+ (adaptor, FALSE,
+ "name", id,
+ "parent", parent,
+ "project", project, "reason", GLADE_CREATE_LOAD, NULL);
+ }
+
+ glade_widget_adaptor_read_widget (adaptor, widget, node);
+
+ }
+ g_free (id);
+ }
+ g_free (klass);
+ }
+
+ glade_widget_pop_superuser ();
+
+ glade_project_push_progress (project);
+
+ return widget;
}
@@ -3795,17 +3735,15 @@ glade_widget_read (GladeProject *project,
* of packing properties and special child types.
*/
void
-glade_widget_write_child (GladeWidget *widget,
- GladeWidget *child,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_widget_write_child (GladeWidget * widget,
+ GladeWidget * child,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (child));
- g_return_if_fail (child->parent == widget);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (child));
+ g_return_if_fail (child->parent == widget);
- glade_widget_adaptor_write_child (widget->adaptor,
- child, context, node);
+ glade_widget_adaptor_write_child (widget->adaptor, child, context, node);
}
@@ -3819,71 +3757,65 @@ glade_widget_write_child (GladeWidget *widget,
* Writes out a placeholder to the xml
*/
void
-glade_widget_write_placeholder (GladeWidget *parent,
- GObject *object,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_widget_write_placeholder (GladeWidget * parent,
+ GObject * object,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- GladeXmlNode *child_node, *packing_node, *placeholder_node;
+ GladeXmlNode *child_node, *packing_node, *placeholder_node;
- child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
- glade_xml_node_append_child (node, child_node);
+ child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
+ glade_xml_node_append_child (node, child_node);
- placeholder_node = glade_xml_node_new (context, GLADE_XML_TAG_PLACEHOLDER);
- glade_xml_node_append_child (child_node, placeholder_node);
+ placeholder_node = glade_xml_node_new (context, GLADE_XML_TAG_PLACEHOLDER);
+ glade_xml_node_append_child (child_node, placeholder_node);
- /* maybe write out special-child-type here */
- packing_node = glade_xml_node_new (context, GLADE_XML_TAG_PACKING);
- glade_xml_node_append_child (child_node, packing_node);
+ /* maybe write out special-child-type here */
+ packing_node = glade_xml_node_new (context, GLADE_XML_TAG_PACKING);
+ glade_xml_node_append_child (child_node, packing_node);
- glade_widget_write_special_child_prop (parent, object,
- context, child_node);
+ glade_widget_write_special_child_prop (parent, object, context, child_node);
- if (!glade_xml_node_get_children (packing_node))
- {
- glade_xml_node_remove (packing_node);
- glade_xml_node_delete (packing_node);
- }
+ if (!glade_xml_node_get_children (packing_node))
+ {
+ glade_xml_node_remove (packing_node);
+ glade_xml_node_delete (packing_node);
+ }
}
-typedef struct {
- GladeXmlContext *context;
- GladeXmlNode *node;
+typedef struct
+{
+ GladeXmlContext *context;
+ GladeXmlNode *node;
} WriteSignalsInfo;
static void
-glade_widget_adaptor_write_signals (gpointer key,
- gpointer value,
- gpointer user_data)
+glade_widget_adaptor_write_signals (gpointer key,
+ gpointer value, gpointer user_data)
{
- WriteSignalsInfo *info;
- GPtrArray *signals;
- guint i;
+ WriteSignalsInfo *info;
+ GPtrArray *signals;
+ guint i;
- info = (WriteSignalsInfo *) user_data;
- signals = (GPtrArray *) value;
- for (i = 0; i < signals->len; i++)
- {
- GladeSignal *signal = g_ptr_array_index (signals, i);
- glade_signal_write (signal,
- info->context,
- info->node);
- }
+ info = (WriteSignalsInfo *) user_data;
+ signals = (GPtrArray *) value;
+ for (i = 0; i < signals->len; i++)
+ {
+ GladeSignal *signal = g_ptr_array_index (signals, i);
+ glade_signal_write (signal, info->context, info->node);
+ }
}
-void
-glade_widget_write_signals (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+void
+glade_widget_write_signals (GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- WriteSignalsInfo info;
+ WriteSignalsInfo info;
- info.context = context;
- info.node = node;
+ info.context = context;
+ info.node = node;
- g_hash_table_foreach (widget->signals,
- glade_widget_adaptor_write_signals,
- &info);
+ g_hash_table_foreach (widget->signals,
+ glade_widget_adaptor_write_signals, &info);
}
@@ -3897,48 +3829,48 @@ glade_widget_write_signals (GladeWidget *widget,
* and appends the created #GladeXmlNode to @node.
*/
void
-glade_widget_write (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeXmlNode *widget_node;
- GList *l, *list;
-
- widget_node = glade_xml_node_new (context, GLADE_XML_TAG_WIDGET);
- glade_xml_node_append_child (node, widget_node);
-
- /* Set class and id */
- glade_xml_node_set_property_string (widget_node,
- GLADE_XML_TAG_CLASS,
- widget->adaptor->name);
- glade_xml_node_set_property_string (widget_node,
- GLADE_XML_TAG_ID,
- widget->name);
-
- /* Write out widget content (properties and signals) */
- glade_widget_adaptor_write_widget (widget->adaptor, widget, context, widget_node);
-
- /* Write the signals strictly after all properties and before children
- */
- glade_widget_write_signals (widget, context, widget_node);
-
- /* Write the children */
- if ((list =
- glade_widget_adaptor_get_children (widget->adaptor, widget->object)) != NULL)
- {
- for (l = list; l; l = l->next)
- {
- GladeWidget *child = glade_widget_get_from_gobject (l->data);
-
- if (child)
- glade_widget_write_child (widget, child, context, widget_node);
- else if (GLADE_IS_PLACEHOLDER (l->data))
- glade_widget_write_placeholder (widget,
- G_OBJECT (l->data),
- context, widget_node);
- }
- g_list_free (list);
- }
+glade_widget_write (GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+ GladeXmlNode *widget_node;
+ GList *l, *list;
+
+ widget_node = glade_xml_node_new (context, GLADE_XML_TAG_WIDGET);
+ glade_xml_node_append_child (node, widget_node);
+
+ /* Set class and id */
+ glade_xml_node_set_property_string (widget_node,
+ GLADE_XML_TAG_CLASS,
+ widget->adaptor->name);
+ glade_xml_node_set_property_string (widget_node,
+ GLADE_XML_TAG_ID, widget->name);
+
+ /* Write out widget content (properties and signals) */
+ glade_widget_adaptor_write_widget (widget->adaptor, widget, context,
+ widget_node);
+
+ /* Write the signals strictly after all properties and before children
+ */
+ glade_widget_write_signals (widget, context, widget_node);
+
+ /* Write the children */
+ if ((list =
+ glade_widget_adaptor_get_children (widget->adaptor,
+ widget->object)) != NULL)
+ {
+ for (l = list; l; l = l->next)
+ {
+ GladeWidget *child = glade_widget_get_from_gobject (l->data);
+
+ if (child)
+ glade_widget_write_child (widget, child, context, widget_node);
+ else if (GLADE_IS_PLACEHOLDER (l->data))
+ glade_widget_write_placeholder (widget,
+ G_OBJECT (l->data),
+ context, widget_node);
+ }
+ g_list_free (list);
+ }
}
@@ -3954,8 +3886,7 @@ glade_widget_write (GladeWidget *widget,
* grandchild, great grandchild, etc.
**/
gboolean
-glade_widget_is_ancestor (GladeWidget *widget,
- GladeWidget *ancestor)
+glade_widget_is_ancestor (GladeWidget * widget, GladeWidget * ancestor)
{
g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GLADE_IS_WIDGET (ancestor), FALSE);
@@ -3963,7 +3894,7 @@ glade_widget_is_ancestor (GladeWidget *widget,
while (widget)
{
if (widget->parent == ancestor)
- return TRUE;
+ return TRUE;
widget = widget->parent;
}
@@ -3991,7 +3922,7 @@ static gint glade_widget_su_stack = 0;
gboolean
glade_widget_superuser (void)
{
- return glade_widget_su_stack > 0;
+ return glade_widget_su_stack > 0;
}
/**
@@ -4002,8 +3933,8 @@ glade_widget_superuser (void)
void
glade_widget_push_superuser (void)
{
- glade_property_push_superuser ();
- glade_widget_su_stack++;
+ glade_property_push_superuser ();
+ glade_widget_su_stack++;
}
@@ -4015,11 +3946,11 @@ glade_widget_push_superuser (void)
void
glade_widget_pop_superuser (void)
{
- if (--glade_widget_su_stack < 0)
- {
- g_critical ("Bug: widget super user stack is corrupt.\n");
- }
- glade_property_pop_superuser ();
+ if (--glade_widget_su_stack < 0)
+ {
+ g_critical ("Bug: widget super user stack is corrupt.\n");
+ }
+ glade_property_pop_superuser ();
}
@@ -4038,44 +3969,45 @@ glade_widget_pop_superuser (void)
* Returns: whether to use placeholders for this relationship.
*/
gboolean
-glade_widget_placeholder_relation (GladeWidget *parent,
- GladeWidget *widget)
+glade_widget_placeholder_relation (GladeWidget * parent, GladeWidget * widget)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (parent), FALSE);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (parent), FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- return (GTK_IS_CONTAINER (parent->object) &&
- GTK_IS_WIDGET (widget->object) &&
- GWA_USE_PLACEHOLDERS (parent->adaptor));
+ return (GTK_IS_CONTAINER (parent->object) &&
+ GTK_IS_WIDGET (widget->object) &&
+ GWA_USE_PLACEHOLDERS (parent->adaptor));
}
static GladeWidgetAction *
-glade_widget_action_lookup (GList **actions, const gchar *path, gboolean remove)
-{
- GList *l;
-
- for (l = *actions; l; l = g_list_next (l))
- {
- GladeWidgetAction *action = l->data;
-
- if (strcmp (action->klass->path, path) == 0)
- {
- if (remove)
- {
- *actions = g_list_remove (*actions, action);
- g_object_unref (action);
- return NULL;
- }
- return action;
- }
-
- if (action->actions &&
- g_str_has_prefix (path, action->klass->path) &&
- (action = glade_widget_action_lookup (&action->actions, path, remove)))
- return action;
- }
-
- return NULL;
+glade_widget_action_lookup (GList ** actions, const gchar * path,
+ gboolean remove)
+{
+ GList *l;
+
+ for (l = *actions; l; l = g_list_next (l))
+ {
+ GladeWidgetAction *action = l->data;
+
+ if (strcmp (action->klass->path, path) == 0)
+ {
+ if (remove)
+ {
+ *actions = g_list_remove (*actions, action);
+ g_object_unref (action);
+ return NULL;
+ }
+ return action;
+ }
+
+ if (action->actions &&
+ g_str_has_prefix (path, action->klass->path) &&
+ (action =
+ glade_widget_action_lookup (&action->actions, path, remove)))
+ return action;
+ }
+
+ return NULL;
}
/**
@@ -4088,12 +4020,12 @@ glade_widget_action_lookup (GList **actions, const gchar *path, gboolean remove)
* Returns: the action or NULL if not found.
*/
GladeWidgetAction *
-glade_widget_get_action (GladeWidget *widget, const gchar *action_path)
+glade_widget_get_action (GladeWidget * widget, const gchar * action_path)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (action_path != NULL, NULL);
-
- return glade_widget_action_lookup (&widget->actions, action_path, FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (action_path != NULL, NULL);
+
+ return glade_widget_action_lookup (&widget->actions, action_path, FALSE);
}
/**
@@ -4106,12 +4038,13 @@ glade_widget_get_action (GladeWidget *widget, const gchar *action_path)
* Returns: the action or NULL if not found.
*/
GladeWidgetAction *
-glade_widget_get_pack_action (GladeWidget *widget, const gchar *action_path)
+glade_widget_get_pack_action (GladeWidget * widget, const gchar * action_path)
{
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (action_path != NULL, NULL);
-
- return glade_widget_action_lookup (&widget->packing_actions, action_path, FALSE);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (action_path != NULL, NULL);
+
+ return glade_widget_action_lookup (&widget->packing_actions, action_path,
+ FALSE);
}
@@ -4127,20 +4060,20 @@ glade_widget_get_pack_action (GladeWidget *widget, const gchar *action_path)
* Returns: whether @action_path was found or not.
*/
gboolean
-glade_widget_set_action_sensitive (GladeWidget *widget,
- const gchar *action_path,
- gboolean sensitive)
+glade_widget_set_action_sensitive (GladeWidget * widget,
+ const gchar * action_path,
+ gboolean sensitive)
{
- GladeWidgetAction *action;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ GladeWidgetAction *action;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
- if ((action = glade_widget_get_action (widget, action_path)) != NULL)
- {
- glade_widget_action_set_sensitive (action, sensitive);
- return TRUE;
- }
- return FALSE;
+ if ((action = glade_widget_get_action (widget, action_path)) != NULL)
+ {
+ glade_widget_action_set_sensitive (action, sensitive);
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -4154,20 +4087,20 @@ glade_widget_set_action_sensitive (GladeWidget *widget,
* Returns: whether @action_path was found or not.
*/
gboolean
-glade_widget_set_pack_action_sensitive (GladeWidget *widget,
- const gchar *action_path,
- gboolean sensitive)
+glade_widget_set_pack_action_sensitive (GladeWidget * widget,
+ const gchar * action_path,
+ gboolean sensitive)
{
- GladeWidgetAction *action;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+ GladeWidgetAction *action;
- if ((action = glade_widget_get_pack_action (widget, action_path)) != NULL)
- {
- glade_widget_action_set_sensitive (action, sensitive);
- return TRUE;
- }
- return FALSE;
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
+
+ if ((action = glade_widget_get_pack_action (widget, action_path)) != NULL)
+ {
+ glade_widget_action_set_sensitive (action, sensitive);
+ return TRUE;
+ }
+ return FALSE;
}
@@ -4179,12 +4112,12 @@ glade_widget_set_pack_action_sensitive (GladeWidget *widget,
* Remove an action.
*/
void
-glade_widget_remove_action (GladeWidget *widget, const gchar *action_path)
+glade_widget_remove_action (GladeWidget * widget, const gchar * action_path)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (action_path != NULL);
-
- glade_widget_action_lookup (&widget->actions, action_path, TRUE);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (action_path != NULL);
+
+ glade_widget_action_lookup (&widget->actions, action_path, TRUE);
}
/**
@@ -4195,12 +4128,13 @@ glade_widget_remove_action (GladeWidget *widget, const gchar *action_path)
* Remove a packing action.
*/
void
-glade_widget_remove_pack_action (GladeWidget *widget, const gchar *action_path)
+glade_widget_remove_pack_action (GladeWidget * widget,
+ const gchar * action_path)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (action_path != NULL);
-
- glade_widget_action_lookup (&widget->packing_actions, action_path, TRUE);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (action_path != NULL);
+
+ glade_widget_action_lookup (&widget->packing_actions, action_path, TRUE);
}
/**
@@ -4216,27 +4150,25 @@ glade_widget_remove_pack_action (GladeWidget *widget, const gchar *action_path)
* Returns: A newly created and connected GladeEditorProperty
*/
GladeEditorProperty *
-glade_widget_create_editor_property (GladeWidget *widget,
- const gchar *property,
- gboolean packing,
- gboolean use_command)
+glade_widget_create_editor_property (GladeWidget * widget,
+ const gchar * property,
+ gboolean packing, gboolean use_command)
{
- GladeEditorProperty *eprop;
- GladeProperty *p;
-
- if (packing)
- p = glade_widget_get_pack_property (widget, property);
- else
- p = glade_widget_get_property (widget, property);
+ GladeEditorProperty *eprop;
+ GladeProperty *p;
+
+ if (packing)
+ p = glade_widget_get_pack_property (widget, property);
+ else
+ p = glade_widget_get_property (widget, property);
- g_return_val_if_fail (GLADE_IS_PROPERTY (p), NULL);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (p), NULL);
- eprop = glade_widget_adaptor_create_eprop (widget->adaptor,
- p->klass,
- use_command);
- glade_editor_property_load (eprop, p);
-
- return eprop;
+ eprop = glade_widget_adaptor_create_eprop (widget->adaptor,
+ p->klass, use_command);
+ glade_editor_property_load (eprop, p);
+
+ return eprop;
}
/**
@@ -4248,36 +4180,35 @@ glade_widget_create_editor_property (GladeWidget *widget,
* Returns: A newly allocated string
*/
gchar *
-glade_widget_generate_path_name (GladeWidget *widget)
+glade_widget_generate_path_name (GladeWidget * widget)
{
- GString *string;
- GladeWidget *iter;
+ GString *string;
+ GladeWidget *iter;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
+ string = g_string_new (widget->name);
- string = g_string_new (widget->name);
-
- for (iter = widget->parent; iter; iter = iter->parent)
- {
- gchar *str = g_strdup_printf ("%s:", iter->name);
- g_string_prepend (string, str);
- g_free (str);
- }
+ for (iter = widget->parent; iter; iter = iter->parent)
+ {
+ gchar *str = g_strdup_printf ("%s:", iter->name);
+ g_string_prepend (string, str);
+ g_free (str);
+ }
- return g_string_free (string, FALSE);
+ return g_string_free (string, FALSE);
}
void
-glade_widget_set_support_warning (GladeWidget *widget,
- const gchar *warning)
+glade_widget_set_support_warning (GladeWidget * widget, const gchar * warning)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
-
- if (widget->support_warning)
- g_free (widget->support_warning);
- widget->support_warning = g_strdup (warning);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+
+ if (widget->support_warning)
+ g_free (widget->support_warning);
+ widget->support_warning = g_strdup (warning);
- g_object_notify (G_OBJECT (widget), "support-warning");
+ g_object_notify (G_OBJECT (widget), "support-warning");
}
/**
@@ -4291,16 +4222,14 @@ glade_widget_set_support_warning (GladeWidget *widget,
*
*/
void
-glade_widget_lock (GladeWidget *widget,
- GladeWidget *locked)
+glade_widget_lock (GladeWidget * widget, GladeWidget * locked)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (locked));
- g_return_if_fail (locked->lock == NULL);
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (locked));
+ g_return_if_fail (locked->lock == NULL);
- locked->lock = widget;
- widget->locked_widgets =
- g_list_prepend (widget->locked_widgets, locked);
+ locked->lock = widget;
+ widget->locked_widgets = g_list_prepend (widget->locked_widgets, locked);
}
/**
@@ -4312,14 +4241,14 @@ glade_widget_lock (GladeWidget *widget,
*
*/
void
-glade_widget_unlock (GladeWidget *widget)
+glade_widget_unlock (GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_return_if_fail (GLADE_IS_WIDGET (widget->lock));
-
- widget->lock->locked_widgets =
- g_list_remove (widget->lock->locked_widgets, widget);
- widget->lock = NULL;
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget->lock));
+
+ widget->lock->locked_widgets =
+ g_list_remove (widget->lock->locked_widgets, widget);
+ widget->lock = NULL;
}
@@ -4331,9 +4260,9 @@ glade_widget_unlock (GladeWidget *widget)
*
*/
void
-glade_widget_support_changed (GladeWidget *widget)
+glade_widget_support_changed (GladeWidget * widget)
{
- g_return_if_fail (GLADE_IS_WIDGET (widget));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
- g_signal_emit (widget, glade_widget_signals[SUPPORT_CHANGED], 0);
+ g_signal_emit (widget, glade_widget_signals[SUPPORT_CHANGED], 0);
}
diff --git a/gladeui/glade-widget.h b/gladeui/glade-widget.h
index 541e2f1..3a83023 100644
--- a/gladeui/glade-widget.h
+++ b/gladeui/glade-widget.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_WIDGET_H__
#define __GLADE_WIDGET_H__
diff --git a/gladeui/glade-xml-utils.c b/gladeui/glade-xml-utils.c
index c280c8f..1756f7b 100644
--- a/gladeui/glade-xml-utils.c
+++ b/gladeui/glade-xml-utils.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* This functions are based on gnome-print/libgpa/gpa-xml.c which were in turn
* based on gnumeric/xml-io.c
*/
@@ -35,18 +34,19 @@
struct _GladeXmlNode
{
- xmlNodePtr node;
+ xmlNodePtr node;
};
struct _GladeXmlDoc
{
- xmlDoc doc;
+ xmlDoc doc;
};
-struct _GladeXmlContext {
- GladeXmlDoc *doc;
- gboolean freedoc;
- xmlNsPtr ns;
+struct _GladeXmlContext
+{
+ GladeXmlDoc *doc;
+ gboolean freedoc;
+ xmlNsPtr ns;
};
@@ -63,12 +63,12 @@ struct _GladeXmlContext {
static gchar *
-claim_string (xmlChar *string)
+claim_string (xmlChar * string)
{
- gchar *ret;
- ret = g_strdup (CAST_BAD(string));
- xmlFree (string);
- return ret;
+ gchar *ret;
+ ret = g_strdup (CAST_BAD (string));
+ xmlFree (string);
+ return ret;
}
/**
@@ -80,18 +80,19 @@ claim_string (xmlChar *string)
* Sets the property @name in @node_in to @val
*/
void
-glade_xml_set_value (GladeXmlNode *node_in, const gchar *name, const gchar *val)
+glade_xml_set_value (GladeXmlNode * node_in, const gchar * name,
+ const gchar * val)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- xmlChar *ret;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlChar *ret;
- ret = xmlGetProp (node, BAD_CAST(name));
- if (ret)
- {
- xmlFree (ret);
- xmlSetProp (node, BAD_CAST(name), BAD_CAST(val));
- return;
- }
+ ret = xmlGetProp (node, BAD_CAST (name));
+ if (ret)
+ {
+ xmlFree (ret);
+ xmlSetProp (node, BAD_CAST (name), BAD_CAST (val));
+ return;
+ }
}
/**
@@ -103,12 +104,12 @@ glade_xml_set_value (GladeXmlNode *node_in, const gchar *name, const gchar *val)
* Returns: A newly allocated string
*/
gchar *
-glade_xml_get_content (GladeXmlNode *node_in)
+glade_xml_get_content (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- xmlChar *val = xmlNodeGetContent(node);
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlChar *val = xmlNodeGetContent (node);
- return claim_string (val);
+ return claim_string (val);
}
/**
@@ -119,11 +120,11 @@ glade_xml_get_content (GladeXmlNode *node_in)
* Sets the content of @node to @content.
*/
void
-glade_xml_set_content (GladeXmlNode *node_in, const gchar *content)
+glade_xml_set_content (GladeXmlNode * node_in, const gchar * content)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- xmlNodeSetContent(node, BAD_CAST(content));
+ xmlNodeSetContent (node, BAD_CAST (content));
}
/*
@@ -135,16 +136,16 @@ glade_xml_set_content (GladeXmlNode *node_in, const gchar *content)
*
*/
static gchar *
-glade_xml_get_value (xmlNodePtr node, const gchar *name)
+glade_xml_get_value (xmlNodePtr node, const gchar * name)
{
- xmlNodePtr child;
- gchar *ret = NULL;
-
- for (child = node->children; child; child = child->next)
- if (!xmlStrcmp (child->name, BAD_CAST(name)))
- ret = claim_string (xmlNodeGetContent(child));
+ xmlNodePtr child;
+ gchar *ret = NULL;
+
+ for (child = node->children; child; child = child->next)
+ if (!xmlStrcmp (child->name, BAD_CAST (name)))
+ ret = claim_string (xmlNodeGetContent (child));
- return ret;
+ return ret;
}
/**
@@ -155,15 +156,15 @@ glade_xml_get_value (xmlNodePtr node, const gchar *name)
* Returns: %TRUE if @node_in's name is equal to @name, %FALSE otherwise
*/
gboolean
-glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name)
+glade_xml_node_verify_silent (GladeXmlNode * node_in, const gchar * name)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+
+ g_return_val_if_fail (node != NULL, FALSE);
- g_return_val_if_fail (node != NULL, FALSE);
-
- if (xmlStrcmp (node->name, BAD_CAST(name)) != 0)
- return FALSE;
- return TRUE;
+ if (xmlStrcmp (node->name, BAD_CAST (name)) != 0)
+ return FALSE;
+ return TRUE;
}
/**
@@ -177,18 +178,18 @@ glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name)
* Returns: %TRUE if @node_in's name is equal to @name, %FALSE otherwise
*/
gboolean
-glade_xml_node_verify (GladeXmlNode *node_in, const gchar *name)
+glade_xml_node_verify (GladeXmlNode * node_in, const gchar * name)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- if (!glade_xml_node_verify_silent (node_in, name))
- {
- g_warning ("Expected node was \"%s\", encountered \"%s\"",
- name, node->name);
- return FALSE;
- }
+ if (!glade_xml_node_verify_silent (node_in, name))
+ {
+ g_warning ("Expected node was \"%s\", encountered \"%s\"",
+ name, node->name);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/**
@@ -203,26 +204,27 @@ glade_xml_node_verify (GladeXmlNode *node_in, const gchar *name)
* Returns: %TRUE if the node is found, %FALSE otherwise
*/
gboolean
-glade_xml_get_value_int (GladeXmlNode *node_in, const gchar *name, gint *val)
+glade_xml_get_value_int (GladeXmlNode * node_in, const gchar * name, gint * val)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar *value, *endptr = NULL;
- gint64 i;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value, *endptr = NULL;
+ gint64 i;
- value = glade_xml_get_value (node, name);
- if (value == NULL)
- return FALSE;
+ value = glade_xml_get_value (node, name);
+ if (value == NULL)
+ return FALSE;
- errno = 0;
- i = g_ascii_strtoll (value, &endptr, 10);
- if (errno != 0 || (i == 0 && endptr == value)) {
- g_free (value);
- return FALSE;
- }
+ errno = 0;
+ i = g_ascii_strtoll (value, &endptr, 10);
+ if (errno != 0 || (i == 0 && endptr == value))
+ {
+ g_free (value);
+ return FALSE;
+ }
- g_free (value);
- *val = (gint) i;
- return TRUE;
+ g_free (value);
+ *val = (gint) i;
+ return TRUE;
}
/**
@@ -237,17 +239,18 @@ glade_xml_get_value_int (GladeXmlNode *node_in, const gchar *name, gint *val)
* Returns:
**/
gboolean
-glade_xml_get_value_int_required (GladeXmlNode *node, const gchar *name, gint *val)
+glade_xml_get_value_int_required (GladeXmlNode * node, const gchar * name,
+ gint * val)
{
- gboolean ret;
-
- ret = glade_xml_get_value_int (node, name, val);
+ gboolean ret;
+
+ ret = glade_xml_get_value_int (node, name, val);
- if (ret == FALSE)
- g_warning ("The file did not contain the required value \"%s\"\n"
- "Under the \"%s\" tag.", name, glade_xml_node_get_name (node));
-
- return ret;
+ if (ret == FALSE)
+ g_warning ("The file did not contain the required value \"%s\"\n"
+ "Under the \"%s\" tag.", name, glade_xml_node_get_name (node));
+
+ return ret;
}
/*
@@ -255,30 +258,31 @@ glade_xml_get_value_int_required (GladeXmlNode *node, const gchar *name, gint *
* the content of a child.
*/
gchar *
-glade_xml_get_value_string (GladeXmlNode *node_in, const gchar *name)
+glade_xml_get_value_string (GladeXmlNode * node_in, const gchar * name)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- return glade_xml_get_value (node, name);
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ return glade_xml_get_value (node, name);
}
static gchar *
-glade_xml_get_property (xmlNodePtr node, const gchar *name)
+glade_xml_get_property (xmlNodePtr node, const gchar * name)
{
- xmlChar *val;
+ xmlChar *val;
- val = xmlGetProp (node, BAD_CAST(name));
+ val = xmlGetProp (node, BAD_CAST (name));
- if (val)
- return claim_string (val);
+ if (val)
+ return claim_string (val);
- return NULL;
+ return NULL;
}
static void
-glade_xml_set_property (xmlNodePtr node, const gchar *name, const gchar *value)
+glade_xml_set_property (xmlNodePtr node, const gchar * name,
+ const gchar * value)
{
- if (value)
- xmlSetProp (node, BAD_CAST(name), BAD_CAST(value));
+ if (value)
+ xmlSetProp (node, BAD_CAST (name), BAD_CAST (value));
}
#define GLADE_TAG_TRUE "True"
@@ -292,34 +296,35 @@ glade_xml_set_property (xmlNodePtr node, const gchar *name, const gchar *value)
* the content of a child.
*/
gboolean
-glade_xml_get_boolean (GladeXmlNode *node_in, const gchar *name, gboolean _default)
-{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar * value;
- gboolean ret = FALSE;
-
- value = glade_xml_get_value (node, name);
- if (value == NULL)
- return _default;
-
- if (strcmp (value, GLADE_TAG_FALSE) == 0)
- ret = FALSE;
- else if (strcmp (value, GLADE_TAG_FALSE2) == 0)
- ret = FALSE;
- else if (strcmp (value, GLADE_TAG_FALSE3) == 0)
- ret = FALSE;
- else if (strcmp (value, GLADE_TAG_TRUE) == 0)
- ret = TRUE;
- else if (strcmp (value, GLADE_TAG_TRUE2) == 0)
- ret = TRUE;
- else if (strcmp (value, GLADE_TAG_TRUE3) == 0)
- ret = TRUE;
- else
- g_warning ("Boolean tag unrecognized *%s*\n", value);
-
- g_free (value);
-
- return ret;
+glade_xml_get_boolean (GladeXmlNode * node_in, const gchar * name,
+ gboolean _default)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value;
+ gboolean ret = FALSE;
+
+ value = glade_xml_get_value (node, name);
+ if (value == NULL)
+ return _default;
+
+ if (strcmp (value, GLADE_TAG_FALSE) == 0)
+ ret = FALSE;
+ else if (strcmp (value, GLADE_TAG_FALSE2) == 0)
+ ret = FALSE;
+ else if (strcmp (value, GLADE_TAG_FALSE3) == 0)
+ ret = FALSE;
+ else if (strcmp (value, GLADE_TAG_TRUE) == 0)
+ ret = TRUE;
+ else if (strcmp (value, GLADE_TAG_TRUE2) == 0)
+ ret = TRUE;
+ else if (strcmp (value, GLADE_TAG_TRUE3) == 0)
+ ret = TRUE;
+ else
+ g_warning ("Boolean tag unrecognized *%s*\n", value);
+
+ g_free (value);
+
+ return ret;
}
/*
@@ -327,96 +332,92 @@ glade_xml_get_boolean (GladeXmlNode *node_in, const gchar *name, gboolean _defau
* the content of a child.
*/
gboolean
-glade_xml_get_property_boolean (GladeXmlNode *node_in,
- const gchar *name,
- gboolean _default)
-{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar * value;
- gboolean ret = FALSE;
-
- value = glade_xml_get_property (node, name);
- if (value == NULL)
- return _default;
-
- if (strcmp (value, GLADE_TAG_FALSE) == 0)
- ret = FALSE;
- else if (strcmp (value, GLADE_TAG_FALSE2) == 0)
- ret = FALSE;
- else if (strcmp (value, GLADE_TAG_FALSE3) == 0)
- ret = FALSE;
- else if (strcmp (value, GLADE_TAG_TRUE) == 0)
- ret = TRUE;
- else if (strcmp (value, GLADE_TAG_TRUE2) == 0)
- ret = TRUE;
- else if (strcmp (value, GLADE_TAG_TRUE3) == 0)
- ret = TRUE;
- else
- g_warning ("Boolean tag unrecognized *%s*\n", value);
-
- g_free (value);
-
- return ret;
+glade_xml_get_property_boolean (GladeXmlNode * node_in,
+ const gchar * name, gboolean _default)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value;
+ gboolean ret = FALSE;
+
+ value = glade_xml_get_property (node, name);
+ if (value == NULL)
+ return _default;
+
+ if (strcmp (value, GLADE_TAG_FALSE) == 0)
+ ret = FALSE;
+ else if (strcmp (value, GLADE_TAG_FALSE2) == 0)
+ ret = FALSE;
+ else if (strcmp (value, GLADE_TAG_FALSE3) == 0)
+ ret = FALSE;
+ else if (strcmp (value, GLADE_TAG_TRUE) == 0)
+ ret = TRUE;
+ else if (strcmp (value, GLADE_TAG_TRUE2) == 0)
+ ret = TRUE;
+ else if (strcmp (value, GLADE_TAG_TRUE3) == 0)
+ ret = TRUE;
+ else
+ g_warning ("Boolean tag unrecognized *%s*\n", value);
+
+ g_free (value);
+
+ return ret;
}
gdouble
-glade_xml_get_property_double (GladeXmlNode *node_in,
- const gchar *name,
- gdouble _default)
-{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gdouble retval;
- gchar *value;
-
- if ((value = glade_xml_get_property (node, name)) == NULL)
- return _default;
-
- errno = 0;
-
- retval = g_ascii_strtod (value, NULL);
-
- if (errno)
- {
- g_free (value);
- return _default;
- }
- else
- {
- g_free (value);
- return retval;
- }
+glade_xml_get_property_double (GladeXmlNode * node_in,
+ const gchar * name, gdouble _default)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gdouble retval;
+ gchar *value;
+
+ if ((value = glade_xml_get_property (node, name)) == NULL)
+ return _default;
+
+ errno = 0;
+
+ retval = g_ascii_strtod (value, NULL);
+
+ if (errno)
+ {
+ g_free (value);
+ return _default;
+ }
+ else
+ {
+ g_free (value);
+ return retval;
+ }
}
gint
-glade_xml_get_property_int (GladeXmlNode *node_in,
- const gchar *name,
- gint _default)
+glade_xml_get_property_int (GladeXmlNode * node_in,
+ const gchar * name, gint _default)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gint retval;
- gchar *value;
-
- if ((value = glade_xml_get_property (node, name)) == NULL)
- return _default;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gint retval;
+ gchar *value;
+
+ if ((value = glade_xml_get_property (node, name)) == NULL)
+ return _default;
+
+ retval = g_ascii_strtoll (value, NULL, 10);
- retval = g_ascii_strtoll (value, NULL, 10);
-
- g_free (value);
+ g_free (value);
- return retval;
+ return retval;
}
void
-glade_xml_node_set_property_boolean (GladeXmlNode *node_in,
- const gchar *name,
- gboolean value)
+glade_xml_node_set_property_boolean (GladeXmlNode * node_in,
+ const gchar * name, gboolean value)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- if (value)
- glade_xml_set_property (node, name, GLADE_TAG_TRUE);
- else
- glade_xml_set_property (node, name, GLADE_TAG_FALSE);
+ if (value)
+ glade_xml_set_property (node, name, GLADE_TAG_TRUE);
+ else
+ glade_xml_set_property (node, name, GLADE_TAG_FALSE);
}
#undef GLADE_TAG_TRUE
@@ -427,133 +428,129 @@ glade_xml_node_set_property_boolean (GladeXmlNode *node_in,
#undef GLADE_TAG_FALSE3
gchar *
-glade_xml_get_value_string_required (GladeXmlNode *node_in,
- const gchar *name,
- const gchar *xtra)
+glade_xml_get_value_string_required (GladeXmlNode * node_in,
+ const gchar * name, const gchar * xtra)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar *value = glade_xml_get_value (node, name);
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value = glade_xml_get_value (node, name);
- if (value == NULL)
- {
- if (xtra == NULL)
- g_warning ("The file did not contain the required value \"%s\"\n"
- "Under the \"%s\" tag.", name, node->name);
- else
- g_warning ("The file did not contain the required value \"%s\"\n"
- "Under the \"%s\" tag (%s).", name, node->name, xtra);
- }
+ if (value == NULL)
+ {
+ if (xtra == NULL)
+ g_warning ("The file did not contain the required value \"%s\"\n"
+ "Under the \"%s\" tag.", name, node->name);
+ else
+ g_warning ("The file did not contain the required value \"%s\"\n"
+ "Under the \"%s\" tag (%s).", name, node->name, xtra);
+ }
- return value;
+ return value;
}
gchar *
-glade_xml_get_property_string (GladeXmlNode *node_in, const gchar *name)
+glade_xml_get_property_string (GladeXmlNode * node_in, const gchar * name)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- return glade_xml_get_property (node, name);
+ return glade_xml_get_property (node, name);
}
void
-glade_xml_node_set_property_string (GladeXmlNode *node_in,
- const gchar *name,
- const gchar *string)
+glade_xml_node_set_property_string (GladeXmlNode * node_in,
+ const gchar * name, const gchar * string)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- glade_xml_set_property (node, name, string);
+ glade_xml_set_property (node, name, string);
}
gchar *
-glade_xml_get_property_string_required (GladeXmlNode *node_in,
- const gchar *name,
- const gchar *xtra)
+glade_xml_get_property_string_required (GladeXmlNode * node_in,
+ const gchar * name, const gchar * xtra)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar *value = glade_xml_get_property_string (node_in, name);
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value = glade_xml_get_property_string (node_in, name);
- if (value == NULL)
- {
- if (xtra == NULL)
- g_warning ("The file did not contain the required property \"%s\"\n"
- "Under the \"%s\" tag.", name, node->name);
- else
- g_warning ("The file did not contain the required property \"%s\"\n"
- "Under the \"%s\" tag (%s).", name, node->name, xtra);
- }
- return value;
+ if (value == NULL)
+ {
+ if (xtra == NULL)
+ g_warning ("The file did not contain the required property \"%s\"\n"
+ "Under the \"%s\" tag.", name, node->name);
+ else
+ g_warning ("The file did not contain the required property \"%s\"\n"
+ "Under the \"%s\" tag (%s).", name, node->name, xtra);
+ }
+ return value;
}
gboolean
-glade_xml_get_property_version (GladeXmlNode *node_in,
- const gchar *name,
- guint16 *major,
- guint16 *minor)
-{
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar *value = glade_xml_get_property_string (node_in, name);
- gchar **split;
-
- if (!value)
- return FALSE;
-
- if ((split = g_strsplit (value, ".", 2)))
- {
- if (!split[0] || !split[1])
- {
- g_warning ("Malformed version property \"%s\"\n"
- "Under the \"%s\" tag (%s)", name, node->name, value);
- return FALSE;
- }
-
- *major = g_ascii_strtoll (split[0], NULL, 10);
- *minor = g_ascii_strtoll (split[1], NULL, 10);
-
- g_strfreev (split);
- }
- return TRUE;
+glade_xml_get_property_version (GladeXmlNode * node_in,
+ const gchar * name,
+ guint16 * major, guint16 * minor)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value = glade_xml_get_property_string (node_in, name);
+ gchar **split;
+
+ if (!value)
+ return FALSE;
+
+ if ((split = g_strsplit (value, ".", 2)))
+ {
+ if (!split[0] || !split[1])
+ {
+ g_warning ("Malformed version property \"%s\"\n"
+ "Under the \"%s\" tag (%s)", name, node->name, value);
+ return FALSE;
+ }
+
+ *major = g_ascii_strtoll (split[0], NULL, 10);
+ *minor = g_ascii_strtoll (split[1], NULL, 10);
+
+ g_strfreev (split);
+ }
+ return TRUE;
}
GList *
-glade_xml_get_property_targetable_versions (GladeXmlNode *node_in,
- const gchar *name)
-{
- GladeTargetableVersion *version;
- GList *targetable = NULL;
- xmlNodePtr node = (xmlNodePtr) node_in;
- gchar *value;
- gchar **split, **maj_min;
- gint i;
-
- if (!(value = glade_xml_get_property_string (node_in, name)))
- return NULL;
-
- if ((split = g_strsplit (value, ",", 0)) != NULL)
- {
- for (i = 0; split[i]; i++)
- {
- maj_min = g_strsplit (split[i], ".", 2);
-
- if (!maj_min[0] || !maj_min[1])
- {
- g_warning ("Malformed version property \"%s\"\n"
- "Under the \"%s\" tag (%s)", name, node->name, value);
- }
- else
- {
- version = g_new (GladeTargetableVersion, 1);
- version->major = g_ascii_strtoll (maj_min[0], NULL, 10);
- version->minor = g_ascii_strtoll (maj_min[1], NULL, 10);
-
- targetable = g_list_append (targetable, version);
- }
- g_strfreev (maj_min);
- }
-
- g_strfreev (split);
- }
- return targetable;
+glade_xml_get_property_targetable_versions (GladeXmlNode * node_in,
+ const gchar * name)
+{
+ GladeTargetableVersion *version;
+ GList *targetable = NULL;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ gchar *value;
+ gchar **split, **maj_min;
+ gint i;
+
+ if (!(value = glade_xml_get_property_string (node_in, name)))
+ return NULL;
+
+ if ((split = g_strsplit (value, ",", 0)) != NULL)
+ {
+ for (i = 0; split[i]; i++)
+ {
+ maj_min = g_strsplit (split[i], ".", 2);
+
+ if (!maj_min[0] || !maj_min[1])
+ {
+ g_warning ("Malformed version property \"%s\"\n"
+ "Under the \"%s\" tag (%s)", name, node->name, value);
+ }
+ else
+ {
+ version = g_new (GladeTargetableVersion, 1);
+ version->major = g_ascii_strtoll (maj_min[0], NULL, 10);
+ version->minor = g_ascii_strtoll (maj_min[1], NULL, 10);
+
+ targetable = g_list_append (targetable, version);
+ }
+ g_strfreev (maj_min);
+ }
+
+ g_strfreev (split);
+ }
+ return targetable;
}
@@ -562,23 +559,23 @@ glade_xml_get_property_targetable_versions (GladeXmlNode *node_in,
* Search a child by name,
*/
GladeXmlNode *
-glade_xml_search_child (GladeXmlNode *node_in, const gchar *name)
+glade_xml_search_child (GladeXmlNode * node_in, const gchar * name)
{
- xmlNodePtr node;
- xmlNodePtr child;
+ xmlNodePtr node;
+ xmlNodePtr child;
- g_return_val_if_fail (node_in != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (node_in != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- node = (xmlNodePtr) node_in;
+ node = (xmlNodePtr) node_in;
- for (child = node->children; child; child = child->next)
- {
- if (!xmlStrcmp (child->name, BAD_CAST(name)))
- return (GladeXmlNode *)child;
- }
+ for (child = node->children; child; child = child->next)
+ {
+ if (!xmlStrcmp (child->name, BAD_CAST (name)))
+ return (GladeXmlNode *) child;
+ }
- return NULL;
+ return NULL;
}
/**
@@ -592,99 +589,99 @@ glade_xml_search_child (GladeXmlNode *node_in, const gchar *name)
* Return Value:
**/
GladeXmlNode *
-glade_xml_search_child_required (GladeXmlNode *node, const gchar* name)
+glade_xml_search_child_required (GladeXmlNode * node, const gchar * name)
{
- GladeXmlNode *child;
-
- child = glade_xml_search_child (node, name);
+ GladeXmlNode *child;
- if (child == NULL)
- g_warning ("The file did not contain the required tag \"%s\"\n"
- "Under the \"%s\" node.", name, glade_xml_node_get_name (node));
+ child = glade_xml_search_child (node, name);
- return child;
+ if (child == NULL)
+ g_warning ("The file did not contain the required tag \"%s\"\n"
+ "Under the \"%s\" node.", name, glade_xml_node_get_name (node));
+
+ return child;
}
/* --------------------------- Parse Context ----------------------------*/
static GladeXmlContext *
-glade_xml_context_new_real (GladeXmlDoc *doc, gboolean freedoc, xmlNsPtr ns)
+glade_xml_context_new_real (GladeXmlDoc * doc, gboolean freedoc, xmlNsPtr ns)
{
- GladeXmlContext *context = g_new0 (GladeXmlContext, 1);
+ GladeXmlContext *context = g_new0 (GladeXmlContext, 1);
+
+ context->doc = doc;
+ context->freedoc = freedoc;
+ context->ns = ns;
- context->doc = doc;
- context->freedoc = freedoc;
- context->ns = ns;
-
- return context;
+ return context;
}
GladeXmlContext *
-glade_xml_context_new (GladeXmlDoc *doc, const gchar *name_space)
+glade_xml_context_new (GladeXmlDoc * doc, const gchar * name_space)
{
- /* We are not using the namespace now */
- return glade_xml_context_new_real (doc, TRUE, NULL);
+ /* We are not using the namespace now */
+ return glade_xml_context_new_real (doc, TRUE, NULL);
}
void
-glade_xml_context_destroy (GladeXmlContext *context)
+glade_xml_context_destroy (GladeXmlContext * context)
{
- g_return_if_fail (context != NULL);
- if (context->freedoc)
- xmlFreeDoc ((xmlDoc*)context->doc);
- g_free (context);
+ g_return_if_fail (context != NULL);
+ if (context->freedoc)
+ xmlFreeDoc ((xmlDoc *) context->doc);
+ g_free (context);
}
GladeXmlContext *
-glade_xml_context_new_from_path (const gchar *full_path,
- const gchar *nspace,
- const gchar *root_name)
-{
- GladeXmlContext *context;
- xmlDocPtr doc;
- xmlNsPtr name_space;
- xmlNodePtr root;
-
- g_return_val_if_fail (full_path != NULL, NULL);
-
- doc = xmlParseFile (full_path);
-
- /* That's not an error condition. The file is not readable, and we can't know it
- * before we try to read it (testing for readability is a call to race conditions).
- * So we should not print a warning */
- if (doc == NULL)
- return NULL;
-
- if (doc->children == NULL) {
- g_warning ("Invalid xml File, tree empty [%s]&", full_path);
- xmlFreeDoc (doc);
- return NULL;
- }
-
- name_space = xmlSearchNsByHref (doc, doc->children, BAD_CAST(nspace));
- if (name_space == NULL && nspace != NULL)
- {
- g_warning ("The file did not contain the expected name space\n"
- "Expected \"%s\" [%s]",
- nspace, full_path);
- xmlFreeDoc (doc);
- return NULL;
- }
-
- root = xmlDocGetRootElement(doc);
- if (root_name != NULL &&
- ((root->name == NULL) || (xmlStrcmp (root->name, BAD_CAST(root_name)) != 0)))
- {
- g_warning ("The file did not contain the expected root name\n"
- "Expected \"%s\", actual : \"%s\" [%s]",
- root_name, root->name, full_path);
- xmlFreeDoc (doc);
- return NULL;
- }
-
- context = glade_xml_context_new_real ((GladeXmlDoc *)doc, TRUE, name_space);
-
- return context;
+glade_xml_context_new_from_path (const gchar * full_path,
+ const gchar * nspace, const gchar * root_name)
+{
+ GladeXmlContext *context;
+ xmlDocPtr doc;
+ xmlNsPtr name_space;
+ xmlNodePtr root;
+
+ g_return_val_if_fail (full_path != NULL, NULL);
+
+ doc = xmlParseFile (full_path);
+
+ /* That's not an error condition. The file is not readable, and we can't know it
+ * before we try to read it (testing for readability is a call to race conditions).
+ * So we should not print a warning */
+ if (doc == NULL)
+ return NULL;
+
+ if (doc->children == NULL)
+ {
+ g_warning ("Invalid xml File, tree empty [%s]&", full_path);
+ xmlFreeDoc (doc);
+ return NULL;
+ }
+
+ name_space = xmlSearchNsByHref (doc, doc->children, BAD_CAST (nspace));
+ if (name_space == NULL && nspace != NULL)
+ {
+ g_warning ("The file did not contain the expected name space\n"
+ "Expected \"%s\" [%s]", nspace, full_path);
+ xmlFreeDoc (doc);
+ return NULL;
+ }
+
+ root = xmlDocGetRootElement (doc);
+ if (root_name != NULL &&
+ ((root->name == NULL) ||
+ (xmlStrcmp (root->name, BAD_CAST (root_name)) != 0)))
+ {
+ g_warning ("The file did not contain the expected root name\n"
+ "Expected \"%s\", actual : \"%s\" [%s]",
+ root_name, root->name, full_path);
+ xmlFreeDoc (doc);
+ return NULL;
+ }
+
+ context = glade_xml_context_new_real ((GladeXmlDoc *) doc, TRUE, name_space);
+
+ return context;
}
/**
@@ -694,189 +691,191 @@ glade_xml_context_new_from_path (const gchar *full_path,
* Similar to glade_xml_context_destroy but it also frees the document set in the context
**/
void
-glade_xml_context_free (GladeXmlContext *context)
+glade_xml_context_free (GladeXmlContext * context)
{
- g_return_if_fail (context != NULL);
- if (context->doc)
- xmlFreeDoc ((xmlDocPtr) context->doc);
- context->doc = NULL;
-
- g_free (context);
+ g_return_if_fail (context != NULL);
+ if (context->doc)
+ xmlFreeDoc ((xmlDocPtr) context->doc);
+ context->doc = NULL;
+
+ g_free (context);
}
void
-glade_xml_node_append_child (GladeXmlNode *node_in, GladeXmlNode *child_in)
+glade_xml_node_append_child (GladeXmlNode * node_in, GladeXmlNode * child_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- xmlNodePtr child = (xmlNodePtr) child_in;
-
- g_return_if_fail (node != NULL);
- g_return_if_fail (child != NULL);
-
- xmlAddChild (node, child);
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr child = (xmlNodePtr) child_in;
+
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (child != NULL);
+
+ xmlAddChild (node, child);
}
void
-glade_xml_node_remove (GladeXmlNode *node_in)
+glade_xml_node_remove (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
-
- g_return_if_fail (node != NULL);
-
- xmlReplaceNode (node, NULL);
+ xmlNodePtr node = (xmlNodePtr) node_in;
+
+ g_return_if_fail (node != NULL);
+
+ xmlReplaceNode (node, NULL);
}
GladeXmlNode *
-glade_xml_node_new (GladeXmlContext *context, const gchar *name)
+glade_xml_node_new (GladeXmlContext * context, const gchar * name)
{
- g_return_val_if_fail (context != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (context != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- return (GladeXmlNode *) xmlNewDocNode ((xmlDocPtr) context->doc, context->ns, BAD_CAST(name), NULL);
+ return (GladeXmlNode *) xmlNewDocNode ((xmlDocPtr) context->doc, context->ns,
+ BAD_CAST (name), NULL);
}
-GladeXmlNode *
-glade_xml_node_new_comment (GladeXmlContext *context, const gchar *comment)
+GladeXmlNode *
+glade_xml_node_new_comment (GladeXmlContext * context, const gchar * comment)
{
- g_return_val_if_fail (context != NULL, NULL);
- g_return_val_if_fail (comment != NULL, NULL);
+ g_return_val_if_fail (context != NULL, NULL);
+ g_return_val_if_fail (comment != NULL, NULL);
- return (GladeXmlNode *) xmlNewDocComment ((xmlDocPtr) context->doc, BAD_CAST(comment));
+ return (GladeXmlNode *) xmlNewDocComment ((xmlDocPtr) context->doc,
+ BAD_CAST (comment));
}
-
+
void
-glade_xml_node_delete (GladeXmlNode *node)
+glade_xml_node_delete (GladeXmlNode * node)
{
- xmlFreeNode ((xmlNodePtr) node);
+ xmlFreeNode ((xmlNodePtr) node);
}
GladeXmlDoc *
-glade_xml_context_get_doc (GladeXmlContext *context)
+glade_xml_context_get_doc (GladeXmlContext * context)
{
- return context->doc;
+ return context->doc;
}
gchar *
-glade_xml_dump_from_context (GladeXmlContext *context)
+glade_xml_dump_from_context (GladeXmlContext * context)
{
- GladeXmlDoc *doc;
- xmlChar *string = NULL;
- gchar *text;
- int size;
+ GladeXmlDoc *doc;
+ xmlChar *string = NULL;
+ gchar *text;
+ int size;
- doc = glade_xml_context_get_doc (context);
- xmlDocDumpFormatMemory(&(doc->doc), &string, &size, 1);
+ doc = glade_xml_context_get_doc (context);
+ xmlDocDumpFormatMemory (&(doc->doc), &string, &size, 1);
- text = claim_string (string);
+ text = claim_string (string);
- return text;
+ return text;
}
gboolean
-glade_xml_node_is_comment (GladeXmlNode *node_in)
+glade_xml_node_is_comment (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- if (node == NULL)
- return FALSE;
- if ((xmlStrcmp ( node->name, BAD_CAST("text")) == 0) ||
- (xmlStrcmp ( node->name, BAD_CAST("comment")) == 0))
- return TRUE;
- return FALSE;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ if (node == NULL)
+ return FALSE;
+ if ((xmlStrcmp (node->name, BAD_CAST ("text")) == 0) ||
+ (xmlStrcmp (node->name, BAD_CAST ("comment")) == 0))
+ return TRUE;
+ return FALSE;
}
GladeXmlNode *
-glade_xml_node_get_children (GladeXmlNode *node_in)
+glade_xml_node_get_children (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- xmlNodePtr children;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr children;
- children = node->children;
- while (glade_xml_node_is_comment ((GladeXmlNode *)children))
- children = children->next;
+ children = node->children;
+ while (glade_xml_node_is_comment ((GladeXmlNode *) children))
+ children = children->next;
- return (GladeXmlNode *)children;
+ return (GladeXmlNode *) children;
}
GladeXmlNode *
-glade_xml_node_get_parent (GladeXmlNode *node_in)
+glade_xml_node_get_parent (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- return (GladeXmlNode *)node->parent;
+ return (GladeXmlNode *) node->parent;
}
GladeXmlNode *
-glade_xml_node_get_children_with_comments (GladeXmlNode *node_in)
+glade_xml_node_get_children_with_comments (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- return (GladeXmlNode *)node->children;
+ return (GladeXmlNode *) node->children;
}
GladeXmlNode *
-glade_xml_node_next (GladeXmlNode *node_in)
+glade_xml_node_next (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- node = node->next;
- while (glade_xml_node_is_comment ((GladeXmlNode *)node))
- node = node->next;
+ node = node->next;
+ while (glade_xml_node_is_comment ((GladeXmlNode *) node))
+ node = node->next;
- return (GladeXmlNode *)node;
+ return (GladeXmlNode *) node;
}
GladeXmlNode *
-glade_xml_node_next_with_comments (GladeXmlNode *node_in)
+glade_xml_node_next_with_comments (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- return (GladeXmlNode *)node->next;
+ return (GladeXmlNode *) node->next;
}
const gchar *
-glade_xml_node_get_name (GladeXmlNode *node_in)
+glade_xml_node_get_name (GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
- return CAST_BAD(node->name);
+ return CAST_BAD (node->name);
}
GladeXmlDoc *
glade_xml_doc_new (void)
{
- xmlDocPtr xml_doc = xmlNewDoc (BAD_CAST("1.0"));
+ xmlDocPtr xml_doc = xmlNewDoc (BAD_CAST ("1.0"));
- return (GladeXmlDoc *)xml_doc;
+ return (GladeXmlDoc *) xml_doc;
}
void
-glade_xml_doc_set_root (GladeXmlDoc *doc_in, GladeXmlNode *node_in)
+glade_xml_doc_set_root (GladeXmlDoc * doc_in, GladeXmlNode * node_in)
{
- xmlNodePtr node = (xmlNodePtr) node_in;
- xmlDocPtr doc = (xmlDocPtr) doc_in;
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ xmlDocPtr doc = (xmlDocPtr) doc_in;
- xmlDocSetRootElement (doc, node);
+ xmlDocSetRootElement (doc, node);
}
gint
-glade_xml_doc_save (GladeXmlDoc *doc_in, const gchar *full_path)
+glade_xml_doc_save (GladeXmlDoc * doc_in, const gchar * full_path)
{
- xmlDocPtr doc = (xmlDocPtr) doc_in;
+ xmlDocPtr doc = (xmlDocPtr) doc_in;
- xmlKeepBlanksDefault (0);
- return xmlSaveFormatFileEnc (full_path, doc, "UTF-8", 1);
+ xmlKeepBlanksDefault (0);
+ return xmlSaveFormatFileEnc (full_path, doc, "UTF-8", 1);
}
void
-glade_xml_doc_free (GladeXmlDoc *doc_in)
+glade_xml_doc_free (GladeXmlDoc * doc_in)
{
- xmlDocPtr doc = (xmlDocPtr) doc_in;
-
- xmlFreeDoc (doc);
+ xmlDocPtr doc = (xmlDocPtr) doc_in;
+
+ xmlFreeDoc (doc);
}
/**
@@ -886,59 +885,57 @@ glade_xml_doc_free (GladeXmlDoc *doc_in)
* Returns: the #GladeXmlNode that is the document root of @doc
*/
GladeXmlNode *
-glade_xml_doc_get_root (GladeXmlDoc *doc)
+glade_xml_doc_get_root (GladeXmlDoc * doc)
{
- xmlNodePtr node;
+ xmlNodePtr node;
- node = xmlDocGetRootElement((xmlDocPtr)(doc));
+ node = xmlDocGetRootElement ((xmlDocPtr) (doc));
- return (GladeXmlNode *)node;
+ return (GladeXmlNode *) node;
}
gboolean
-glade_xml_load_sym_from_node (GladeXmlNode *node_in,
- GModule *module,
- gchar *tagname,
- gpointer *sym_location)
-{
- static GModule *self = NULL;
- gboolean retval = FALSE;
- gchar *buff;
-
- if (!self)
- self = g_module_open (NULL, 0);
-
- if ((buff = glade_xml_get_value_string (node_in, tagname)) != NULL)
- {
- if (!module)
- {
- g_warning ("Catalog specified symbol '%s' for tag '%s', "
- "no module available to load it from !",
- buff, tagname);
- g_free (buff);
- return FALSE;
- }
-
- /* I use here a g_warning to signal these errors instead of a dialog
- * box, as if there is one of this kind of errors, there will probably
- * a lot of them, and we don't want to inflict the user the pain of
- * plenty of dialog boxes. Ideally, we should collect these errors,
- * and show all of them at the end of the load process.
- *
- * I dont know who wrote the above in glade-property-class.c, but
- * its a good point... makeing a bugzilla entry.
- * -Tristan
- *
- * XXX http://bugzilla.gnome.org/show_bug.cgi?id=331797
- */
- if (g_module_symbol (module, buff, sym_location) ||
- g_module_symbol (self, buff, sym_location))
- retval = TRUE;
- else
- g_warning ("Could not find %s in %s or in global namespace\n",
- buff, g_module_name (module));
-
- g_free (buff);
- }
- return retval;
+glade_xml_load_sym_from_node (GladeXmlNode * node_in,
+ GModule * module,
+ gchar * tagname, gpointer * sym_location)
+{
+ static GModule *self = NULL;
+ gboolean retval = FALSE;
+ gchar *buff;
+
+ if (!self)
+ self = g_module_open (NULL, 0);
+
+ if ((buff = glade_xml_get_value_string (node_in, tagname)) != NULL)
+ {
+ if (!module)
+ {
+ g_warning ("Catalog specified symbol '%s' for tag '%s', "
+ "no module available to load it from !", buff, tagname);
+ g_free (buff);
+ return FALSE;
+ }
+
+ /* I use here a g_warning to signal these errors instead of a dialog
+ * box, as if there is one of this kind of errors, there will probably
+ * a lot of them, and we don't want to inflict the user the pain of
+ * plenty of dialog boxes. Ideally, we should collect these errors,
+ * and show all of them at the end of the load process.
+ *
+ * I dont know who wrote the above in glade-property-class.c, but
+ * its a good point... makeing a bugzilla entry.
+ * -Tristan
+ *
+ * XXX http://bugzilla.gnome.org/show_bug.cgi?id=331797
+ */
+ if (g_module_symbol (module, buff, sym_location) ||
+ g_module_symbol (self, buff, sym_location))
+ retval = TRUE;
+ else
+ g_warning ("Could not find %s in %s or in global namespace\n",
+ buff, g_module_name (module));
+
+ g_free (buff);
+ }
+ return retval;
}
diff --git a/gladeui/glade-xml-utils.h b/gladeui/glade-xml-utils.h
index 1b170e1..6823dfd 100644
--- a/gladeui/glade-xml-utils.h
+++ b/gladeui/glade-xml-utils.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* TODO : s/glade_xml_get_/glade_xml_node_get/g */
#ifndef __GLADE_XML_UTILS_H__
#define __GLADE_XML_UTILS_H__
diff --git a/gladeui/glade.h b/gladeui/glade.h
index 32ae7c7..867fe73 100644
--- a/gladeui/glade.h
+++ b/gladeui/glade.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade.h
*
diff --git a/gladeui/icon-naming-spec.c b/gladeui/icon-naming-spec.c
index af0513e..f823ec7 100644
--- a/gladeui/icon-naming-spec.c
+++ b/gladeui/icon-naming-spec.c
@@ -28,25 +28,35 @@
#include <glib/gi18n-lib.h>
/* Standard Contexts */
-static const struct {
- const char *name;
- const char *title;
-} standard_contexts[] = {
- { "Actions", N_("Actions") },
- { "Applications", N_("Applications") },
- { "Categories", N_("Categories") },
- { "Devices", N_("Devices") },
- { "Emblems", N_("Emblems") },
- { "Emotes", N_("Emotes") },
- { "International", N_("International") },
- { "MimeTypes", N_("MIME Types") },
- { "Places", N_("Places") },
- { "Status", N_("Status") },
-};
+static const struct
+{
+ const char *name;
+ const char *title;
+} standard_contexts[] =
+{
+ {
+ "Actions", N_("Actions")},
+ {
+ "Applications", N_("Applications")},
+ {
+ "Categories", N_("Categories")},
+ {
+ "Devices", N_("Devices")},
+ {
+ "Emblems", N_("Emblems")},
+ {
+ "Emotes", N_("Emotes")},
+ {
+ "International", N_("International")},
+ {
+ "MimeTypes", N_("MIME Types")},
+ {
+ "Places", N_("Places")},
+ {
+"Status", N_("Status")},};
/* Standard Icon Names */
-static const char* const standard_icon_names[] =
-{
+static const char *const standard_icon_names[] = {
/* Action Icons */
"address-book-new",
"application-exit",
@@ -137,7 +147,7 @@ static const char* const standard_icon_names[] =
"tools-check-spelling",
"view-fullscreen",
"view-refresh",
- "view-restore",
+ "view-restore",
"view-sort-ascending",
"view-sort-descending",
"window-close",
@@ -203,7 +213,7 @@ static const char* const standard_icon_names[] =
"input-mouse",
"media-flash",
"media-floppy",
- "media-optical",
+ "media-optical",
"media-tape",
"modem",
"multimedia-player",
@@ -221,7 +231,7 @@ static const char* const standard_icon_names[] =
"emblem-mail",
"emblem-photos",
"emblem-readonly",
- "emblem-shared",
+ "emblem-shared",
"emblem-symbolic-link",
"emblem-synchronized",
"emblem-system",
@@ -287,7 +297,7 @@ static const char* const standard_icon_names[] =
"dialog-password",
"dialog-question",
"dialog-warning",
- "folder-drag-accept",
+ "folder-drag-accept",
"folder-open",
"folder-visiting",
"image-loading",
@@ -300,7 +310,7 @@ static const char* const standard_icon_names[] =
"mail-signed-verified",
"media-playlist-repeat",
"media-playlist-shuffle",
- "network-error",
+ "network-error",
"network-idle",
"network-offline",
"network-receive",
@@ -310,7 +320,7 @@ static const char* const standard_icon_names[] =
"printer-printing",
"security-high",
"security-medium",
- "security-low",
+ "security-low",
"software-update-available",
"software-update-urgent",
"sync-error",
@@ -334,4 +344,3 @@ static const char* const standard_icon_names[] =
"weather-snow",
"weather-storm",
};
-
diff --git a/plugins/gtk+/glade-accels.c b/plugins/gtk+/glade-accels.c
index 3b52962..bd32252 100644
--- a/plugins/gtk+/glade-accels.c
+++ b/plugins/gtk+/glade-accels.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom
*
@@ -32,81 +31,81 @@
#define GLADE_RESPONSE_CLEAR 42
GList *
-glade_accel_list_copy (GList *accels)
+glade_accel_list_copy (GList * accels)
{
- GList *ret = NULL, *list;
- GladeAccelInfo *info, *dup_info;
+ GList *ret = NULL, *list;
+ GladeAccelInfo *info, *dup_info;
- for (list = accels; list; list = list->next)
- {
- info = list->data;
+ for (list = accels; list; list = list->next)
+ {
+ info = list->data;
- dup_info = g_new0 (GladeAccelInfo, 1);
- dup_info->signal = g_strdup (info->signal);
- dup_info->key = info->key;
- dup_info->modifiers = info->modifiers;
+ dup_info = g_new0 (GladeAccelInfo, 1);
+ dup_info->signal = g_strdup (info->signal);
+ dup_info->key = info->key;
+ dup_info->modifiers = info->modifiers;
- ret = g_list_prepend (ret, dup_info);
- }
+ ret = g_list_prepend (ret, dup_info);
+ }
- return g_list_reverse (ret);
+ return g_list_reverse (ret);
}
void
-glade_accel_list_free (GList *accels)
+glade_accel_list_free (GList * accels)
{
- GList *list;
- GladeAccelInfo *info;
+ GList *list;
+ GladeAccelInfo *info;
- for (list = accels; list; list = list->next)
- {
- info = list->data;
+ for (list = accels; list; list = list->next)
+ {
+ info = list->data;
- g_free (info->signal);
- g_free (info);
- }
- g_list_free (accels);
+ g_free (info->signal);
+ g_free (info);
+ }
+ g_list_free (accels);
}
GType
glade_accel_glist_get_type (void)
{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static
- ("GladeAccelGList",
- (GBoxedCopyFunc) glade_accel_list_copy,
- (GBoxedFreeFunc) glade_accel_list_free);
- return type_id;
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static
+ ("GladeAccelGList",
+ (GBoxedCopyFunc) glade_accel_list_copy,
+ (GBoxedFreeFunc) glade_accel_list_free);
+ return type_id;
}
/* This is not used to save in the glade file... and its a one-way conversion.
* its only usefull to show the values in the UI.
*/
gchar *
-glade_accels_make_string (GList *accels)
+glade_accels_make_string (GList * accels)
{
- GladeAccelInfo *info;
- GString *string;
- GList *list;
- gchar *accel_text;
+ GladeAccelInfo *info;
+ GString *string;
+ GList *list;
+ gchar *accel_text;
- string = g_string_new ("");
+ string = g_string_new ("");
- for (list = accels; list; list = list->next)
- {
- info = list->data;
+ for (list = accels; list; list = list->next)
+ {
+ info = list->data;
- accel_text = gtk_accelerator_name (info->key, info->modifiers);
- g_string_append (string, accel_text);
- g_free (accel_text);
+ accel_text = gtk_accelerator_name (info->key, info->modifiers);
+ g_string_append (string, accel_text);
+ g_free (accel_text);
- if (list->next)
- g_string_append (string, ", ");
- }
+ if (list->next)
+ g_string_append (string, ", ");
+ }
- return g_string_free (string, FALSE);
+ return g_string_free (string, FALSE);
}
@@ -114,31 +113,34 @@ glade_accels_make_string (GList *accels)
* GladeEditorProperty stuff here
**************************************************************/
-enum {
- ACCEL_COLUMN_SIGNAL = 0,
- ACCEL_COLUMN_REAL_SIGNAL,
- ACCEL_COLUMN_TEXT,
- ACCEL_COLUMN_WEIGHT,
- ACCEL_COLUMN_STYLE,
- ACCEL_COLUMN_FOREGROUND,
- ACCEL_COLUMN_VISIBLE,
- ACCEL_COLUMN_KEY_ENTERED,
- ACCEL_COLUMN_KEYCODE,
- ACCEL_COLUMN_MODIFIERS,
- ACCEL_NUM_COLUMNS
+enum
+{
+ ACCEL_COLUMN_SIGNAL = 0,
+ ACCEL_COLUMN_REAL_SIGNAL,
+ ACCEL_COLUMN_TEXT,
+ ACCEL_COLUMN_WEIGHT,
+ ACCEL_COLUMN_STYLE,
+ ACCEL_COLUMN_FOREGROUND,
+ ACCEL_COLUMN_VISIBLE,
+ ACCEL_COLUMN_KEY_ENTERED,
+ ACCEL_COLUMN_KEYCODE,
+ ACCEL_COLUMN_MODIFIERS,
+ ACCEL_NUM_COLUMNS
};
-typedef struct {
- GladeEditorProperty parent_instance;
-
- GtkWidget *entry;
- GList *parent_iters;
- GtkTreeModel *model;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
+
+ GtkWidget *entry;
+ GList *parent_iters;
+ GtkTreeModel *model;
} GladeEPropAccel;
-typedef struct {
- GtkTreeIter *iter;
- gchar *name; /* <-- dont free */
+typedef struct
+{
+ GtkTreeIter *iter;
+ gchar *name; /* <-- dont free */
} GladeEpropIterTab;
GLADE_MAKE_EPROP (GladeEPropAccel, glade_eprop_accel)
@@ -147,703 +149,716 @@ GLADE_MAKE_EPROP (GladeEPropAccel, glade_eprop_accel)
#define GLADE_IS_EPROP_ACCEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_ACCEL))
#define GLADE_IS_EPROP_ACCEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_ACCEL))
#define GLADE_EPROP_ACCEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_ACCEL, GladeEPropAccelClass))
-
-static void
-glade_eprop_accel_finalize (GObject *object)
+ static void glade_eprop_accel_finalize (GObject * object)
{
- /* Chain up */
- GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
+ /* Chain up */
+ GObjectClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-glade_eprop_accel_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_eprop_accel_load (GladeEditorProperty * eprop, GladeProperty * property)
{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
- gchar *accels;
-
- /* Chain up first */
- parent_class->load (eprop, property);
-
- if (property == NULL) return;
-
- if ((accels =
- glade_accels_make_string (g_value_get_boxed (property->value))) != NULL)
- {
- gtk_entry_set_text (GTK_ENTRY (eprop_accel->entry), accels);
- g_free (accels);
- }
- else
- gtk_entry_set_text (GTK_ENTRY (eprop_accel->entry), "");
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
+ gchar *accels;
+
+ /* Chain up first */
+ parent_class->load (eprop, property);
+
+ if (property == NULL)
+ return;
+
+ if ((accels =
+ glade_accels_make_string (g_value_get_boxed (property->value))) != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (eprop_accel->entry), accels);
+ g_free (accels);
+ }
+ else
+ gtk_entry_set_text (GTK_ENTRY (eprop_accel->entry), "");
}
static gint
-eprop_find_iter (GladeEpropIterTab *iter_tab,
- gchar *name)
+eprop_find_iter (GladeEpropIterTab * iter_tab, gchar * name)
{
- return strcmp (iter_tab->name, name);
+ return strcmp (iter_tab->name, name);
}
static void
-iter_tab_free (GladeEpropIterTab *iter_tab)
+iter_tab_free (GladeEpropIterTab * iter_tab)
{
- gtk_tree_iter_free (iter_tab->iter);
- g_free (iter_tab);
+ gtk_tree_iter_free (iter_tab->iter);
+ g_free (iter_tab);
}
static void
-glade_eprop_accel_populate_view (GladeEditorProperty *eprop,
- GtkTreeView *view)
+glade_eprop_accel_populate_view (GladeEditorProperty * eprop,
+ GtkTreeView * view)
{
- GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
- GladeSignalClass *sclass;
- GladeWidgetAdaptor *adaptor = glade_widget_adaptor_from_pclass (eprop->klass);
- GtkTreeStore *model = (GtkTreeStore *)gtk_tree_view_get_model (view);
- GtkTreeIter iter;
- GladeEpropIterTab *parent_tab;
- GladeAccelInfo *info;
- GList *list, *l, *found, *accelerators;
- gchar *name, *accel_text;
-
- accelerators = g_value_get_boxed (eprop->property->value);
-
- /* First make parent iters...
- */
- for (list = adaptor->signals; list; list = list->next)
- {
- sclass = list->data;
-
- /* Special case for GtkAction accelerators */
- if (adaptor->type == GTK_TYPE_ACTION ||
- g_type_is_a (adaptor->type, GTK_TYPE_ACTION))
- {
- if (g_strcmp0 (sclass->type, "GtkAction") != 0 ||
- g_strcmp0 (sclass->name, "activate") != 0)
- continue;
- }
- /* Only action signals have accelerators. */
- else if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
- continue;
-
- if (g_list_find_custom (eprop_accel->parent_iters,
- sclass->type,
- (GCompareFunc)eprop_find_iter) == NULL)
- {
- gtk_tree_store_append (model, &iter, NULL);
- gtk_tree_store_set (model, &iter,
- ACCEL_COLUMN_SIGNAL, sclass->type,
- ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
- ACCEL_COLUMN_VISIBLE, FALSE,
- -1);
-
- parent_tab = g_new0 (GladeEpropIterTab, 1);
- parent_tab->name = sclass->type;
- parent_tab->iter = gtk_tree_iter_copy (&iter);
-
- eprop_accel->parent_iters =
- g_list_prepend (eprop_accel->parent_iters,
- parent_tab);
- }
- }
-
- /* Now we populate...
- */
- for (list = adaptor->signals; list; list = list->next)
- {
- sclass = list->data;
-
- /* Special case for GtkAction accelerators */
- if (adaptor->type == GTK_TYPE_ACTION ||
- g_type_is_a (adaptor->type, GTK_TYPE_ACTION))
- {
- if (g_strcmp0 (sclass->type, "GtkAction") != 0 ||
- g_strcmp0 (sclass->name, "activate") != 0)
- continue;
- }
- /* Only action signals have accelerators. */
- else if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
- continue;
-
- if ((found = g_list_find_custom (eprop_accel->parent_iters,
- sclass->type,
- (GCompareFunc)eprop_find_iter)) != NULL)
- {
- parent_tab = found->data;
- name = g_strdup_printf (" %s", sclass->name);
-
- /* Populate from accelerator list
- */
- for (l = accelerators; l; l = l->next)
- {
- info = l->data;
-
- if (strcmp (info->signal, sclass->name))
- continue;
-
- accel_text = gtk_accelerator_name (info->key, info->modifiers);
-
- gtk_tree_store_append (model, &iter, parent_tab->iter);
- gtk_tree_store_set
- (model, &iter,
- ACCEL_COLUMN_SIGNAL, name,
- ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
- ACCEL_COLUMN_TEXT, accel_text,
- ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
- ACCEL_COLUMN_STYLE, PANGO_STYLE_NORMAL,
- ACCEL_COLUMN_FOREGROUND, "Black",
- ACCEL_COLUMN_VISIBLE, TRUE,
- ACCEL_COLUMN_KEYCODE, info->key,
- ACCEL_COLUMN_MODIFIERS, info->modifiers,
- ACCEL_COLUMN_KEY_ENTERED, TRUE,
- -1);
-
- g_free (accel_text);
- }
-
- /* Special case for GtkAction accelerators */
- if ((adaptor->type == GTK_TYPE_ACTION ||
- g_type_is_a (adaptor->type, GTK_TYPE_ACTION)) &&
- g_list_length (accelerators) > 0)
- continue;
-
- /* Append a new empty slot at the end */
- gtk_tree_store_append (model, &iter, parent_tab->iter);
- gtk_tree_store_set
- (model, &iter,
- ACCEL_COLUMN_SIGNAL, name,
- ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
- ACCEL_COLUMN_TEXT, _("<choose a key>"),
- ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
- ACCEL_COLUMN_STYLE, PANGO_STYLE_ITALIC,
- ACCEL_COLUMN_FOREGROUND, "Grey",
- ACCEL_COLUMN_VISIBLE, TRUE,
- ACCEL_COLUMN_KEYCODE, 0,
- ACCEL_COLUMN_MODIFIERS, 0,
- ACCEL_COLUMN_KEY_ENTERED, FALSE,
- -1);
-
- g_free (name);
- }
- }
+ GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
+ GladeSignalClass *sclass;
+ GladeWidgetAdaptor *adaptor = glade_widget_adaptor_from_pclass (eprop->klass);
+ GtkTreeStore *model = (GtkTreeStore *) gtk_tree_view_get_model (view);
+ GtkTreeIter iter;
+ GladeEpropIterTab *parent_tab;
+ GladeAccelInfo *info;
+ GList *list, *l, *found, *accelerators;
+ gchar *name, *accel_text;
+
+ accelerators = g_value_get_boxed (eprop->property->value);
+
+ /* First make parent iters...
+ */
+ for (list = adaptor->signals; list; list = list->next)
+ {
+ sclass = list->data;
+
+ /* Special case for GtkAction accelerators */
+ if (adaptor->type == GTK_TYPE_ACTION ||
+ g_type_is_a (adaptor->type, GTK_TYPE_ACTION))
+ {
+ if (g_strcmp0 (sclass->type, "GtkAction") != 0 ||
+ g_strcmp0 (sclass->name, "activate") != 0)
+ continue;
+ }
+ /* Only action signals have accelerators. */
+ else if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
+ continue;
+
+ if (g_list_find_custom (eprop_accel->parent_iters,
+ sclass->type,
+ (GCompareFunc) eprop_find_iter) == NULL)
+ {
+ gtk_tree_store_append (model, &iter, NULL);
+ gtk_tree_store_set (model, &iter,
+ ACCEL_COLUMN_SIGNAL, sclass->type,
+ ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD,
+ ACCEL_COLUMN_VISIBLE, FALSE, -1);
+
+ parent_tab = g_new0 (GladeEpropIterTab, 1);
+ parent_tab->name = sclass->type;
+ parent_tab->iter = gtk_tree_iter_copy (&iter);
+
+ eprop_accel->parent_iters =
+ g_list_prepend (eprop_accel->parent_iters, parent_tab);
+ }
+ }
+
+ /* Now we populate...
+ */
+ for (list = adaptor->signals; list; list = list->next)
+ {
+ sclass = list->data;
+
+ /* Special case for GtkAction accelerators */
+ if (adaptor->type == GTK_TYPE_ACTION ||
+ g_type_is_a (adaptor->type, GTK_TYPE_ACTION))
+ {
+ if (g_strcmp0 (sclass->type, "GtkAction") != 0 ||
+ g_strcmp0 (sclass->name, "activate") != 0)
+ continue;
+ }
+ /* Only action signals have accelerators. */
+ else if ((sclass->query.signal_flags & G_SIGNAL_ACTION) == 0)
+ continue;
+
+ if ((found = g_list_find_custom (eprop_accel->parent_iters,
+ sclass->type,
+ (GCompareFunc) eprop_find_iter)) != NULL)
+ {
+ parent_tab = found->data;
+ name = g_strdup_printf (" %s", sclass->name);
+
+ /* Populate from accelerator list
+ */
+ for (l = accelerators; l; l = l->next)
+ {
+ info = l->data;
+
+ if (strcmp (info->signal, sclass->name))
+ continue;
+
+ accel_text = gtk_accelerator_name (info->key, info->modifiers);
+
+ gtk_tree_store_append (model, &iter, parent_tab->iter);
+ gtk_tree_store_set
+ (model, &iter,
+ ACCEL_COLUMN_SIGNAL, name,
+ ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
+ ACCEL_COLUMN_TEXT, accel_text,
+ ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
+ ACCEL_COLUMN_STYLE, PANGO_STYLE_NORMAL,
+ ACCEL_COLUMN_FOREGROUND, "Black",
+ ACCEL_COLUMN_VISIBLE, TRUE,
+ ACCEL_COLUMN_KEYCODE, info->key,
+ ACCEL_COLUMN_MODIFIERS, info->modifiers,
+ ACCEL_COLUMN_KEY_ENTERED, TRUE, -1);
+
+ g_free (accel_text);
+ }
+
+ /* Special case for GtkAction accelerators */
+ if ((adaptor->type == GTK_TYPE_ACTION ||
+ g_type_is_a (adaptor->type, GTK_TYPE_ACTION)) &&
+ g_list_length (accelerators) > 0)
+ continue;
+
+ /* Append a new empty slot at the end */
+ gtk_tree_store_append (model, &iter, parent_tab->iter);
+ gtk_tree_store_set
+ (model, &iter,
+ ACCEL_COLUMN_SIGNAL, name,
+ ACCEL_COLUMN_REAL_SIGNAL, sclass->name,
+ ACCEL_COLUMN_TEXT, _("<choose a key>"),
+ ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
+ ACCEL_COLUMN_STYLE, PANGO_STYLE_ITALIC,
+ ACCEL_COLUMN_FOREGROUND, "Grey",
+ ACCEL_COLUMN_VISIBLE, TRUE,
+ ACCEL_COLUMN_KEYCODE, 0,
+ ACCEL_COLUMN_MODIFIERS, 0, ACCEL_COLUMN_KEY_ENTERED, FALSE, -1);
+
+ g_free (name);
+ }
+ }
}
void
-accel_edited (GtkCellRendererAccel *accel,
- gchar *path_string,
- guint accel_key,
- GdkModifierType accel_mods,
- guint hardware_keycode,
- GladeEPropAccel *eprop_accel)
+accel_edited (GtkCellRendererAccel * accel,
+ gchar * path_string,
+ guint accel_key,
+ GdkModifierType accel_mods,
+ guint hardware_keycode, GladeEPropAccel * eprop_accel)
{
- gboolean key_was_set;
- GtkTreeIter iter, parent_iter, new_iter;
- gchar *accel_text;
- GladeWidgetAdaptor *adaptor =
- glade_widget_adaptor_from_pclass (GLADE_EDITOR_PROPERTY (eprop_accel)->klass);
- gboolean is_action;
-
- if (!gtk_tree_model_get_iter_from_string (eprop_accel->model,
- &iter, path_string))
- return;
-
- is_action = (adaptor->type == GTK_TYPE_ACTION ||
- g_type_is_a (adaptor->type, GTK_TYPE_ACTION));
-
- gtk_tree_model_get (eprop_accel->model, &iter,
- ACCEL_COLUMN_KEY_ENTERED, &key_was_set,
- -1);
-
- accel_text = gtk_accelerator_name (accel_key, accel_mods);
-
- gtk_tree_store_set
- (GTK_TREE_STORE (eprop_accel->model), &iter,
- ACCEL_COLUMN_KEY_ENTERED, TRUE,
- ACCEL_COLUMN_STYLE, PANGO_STYLE_NORMAL,
- ACCEL_COLUMN_FOREGROUND, "Black",
- ACCEL_COLUMN_TEXT, accel_text,
- ACCEL_COLUMN_KEYCODE, accel_key,
- ACCEL_COLUMN_MODIFIERS, accel_mods,
- -1);
-
- g_free (accel_text);
-
- /* Append a new one if needed
- */
- if (is_action == FALSE && key_was_set == FALSE &&
- gtk_tree_model_iter_parent (eprop_accel->model,
- &parent_iter, &iter))
- {
- gchar *signal, *real_signal;
-
- gtk_tree_model_get (eprop_accel->model, &iter,
- ACCEL_COLUMN_SIGNAL, &signal,
- ACCEL_COLUMN_REAL_SIGNAL, &real_signal,
- -1);
-
- /* Append a new empty slot at the end */
- gtk_tree_store_insert_after (GTK_TREE_STORE (eprop_accel->model),
- &new_iter, &parent_iter, &iter);
- gtk_tree_store_set (GTK_TREE_STORE (eprop_accel->model), &new_iter,
- ACCEL_COLUMN_SIGNAL, signal,
- ACCEL_COLUMN_REAL_SIGNAL, real_signal,
- ACCEL_COLUMN_TEXT, _("<choose a key>"),
- ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
- ACCEL_COLUMN_STYLE, PANGO_STYLE_ITALIC,
- ACCEL_COLUMN_FOREGROUND, "Grey",
- ACCEL_COLUMN_VISIBLE, TRUE,
- ACCEL_COLUMN_KEYCODE, 0,
- ACCEL_COLUMN_MODIFIERS, 0,
- ACCEL_COLUMN_KEY_ENTERED, FALSE,
- -1);
- g_free (signal);
- g_free (real_signal);
- }
+ gboolean key_was_set;
+ GtkTreeIter iter, parent_iter, new_iter;
+ gchar *accel_text;
+ GladeWidgetAdaptor *adaptor =
+ glade_widget_adaptor_from_pclass (GLADE_EDITOR_PROPERTY (eprop_accel)->
+ klass);
+ gboolean is_action;
+
+ if (!gtk_tree_model_get_iter_from_string (eprop_accel->model,
+ &iter, path_string))
+ return;
+
+ is_action = (adaptor->type == GTK_TYPE_ACTION ||
+ g_type_is_a (adaptor->type, GTK_TYPE_ACTION));
+
+ gtk_tree_model_get (eprop_accel->model, &iter,
+ ACCEL_COLUMN_KEY_ENTERED, &key_was_set, -1);
+
+ accel_text = gtk_accelerator_name (accel_key, accel_mods);
+
+ gtk_tree_store_set
+ (GTK_TREE_STORE (eprop_accel->model), &iter,
+ ACCEL_COLUMN_KEY_ENTERED, TRUE,
+ ACCEL_COLUMN_STYLE, PANGO_STYLE_NORMAL,
+ ACCEL_COLUMN_FOREGROUND, "Black",
+ ACCEL_COLUMN_TEXT, accel_text,
+ ACCEL_COLUMN_KEYCODE, accel_key, ACCEL_COLUMN_MODIFIERS, accel_mods, -1);
+
+ g_free (accel_text);
+
+ /* Append a new one if needed
+ */
+ if (is_action == FALSE && key_was_set == FALSE &&
+ gtk_tree_model_iter_parent (eprop_accel->model, &parent_iter, &iter))
+ {
+ gchar *signal, *real_signal;
+
+ gtk_tree_model_get (eprop_accel->model, &iter,
+ ACCEL_COLUMN_SIGNAL, &signal,
+ ACCEL_COLUMN_REAL_SIGNAL, &real_signal, -1);
+
+ /* Append a new empty slot at the end */
+ gtk_tree_store_insert_after (GTK_TREE_STORE (eprop_accel->model),
+ &new_iter, &parent_iter, &iter);
+ gtk_tree_store_set (GTK_TREE_STORE (eprop_accel->model), &new_iter,
+ ACCEL_COLUMN_SIGNAL, signal,
+ ACCEL_COLUMN_REAL_SIGNAL, real_signal,
+ ACCEL_COLUMN_TEXT, _("<choose a key>"),
+ ACCEL_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL,
+ ACCEL_COLUMN_STYLE, PANGO_STYLE_ITALIC,
+ ACCEL_COLUMN_FOREGROUND, "Grey",
+ ACCEL_COLUMN_VISIBLE, TRUE,
+ ACCEL_COLUMN_KEYCODE, 0,
+ ACCEL_COLUMN_MODIFIERS, 0,
+ ACCEL_COLUMN_KEY_ENTERED, FALSE, -1);
+ g_free (signal);
+ g_free (real_signal);
+ }
}
void
-accel_cleared (GtkCellRendererAccel *accel,
- gchar *path_string,
- GladeEPropAccel *eprop_accel)
+accel_cleared (GtkCellRendererAccel * accel,
+ gchar * path_string, GladeEPropAccel * eprop_accel)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
+
+ if (!gtk_tree_model_get_iter_from_string (eprop_accel->model,
+ &iter, path_string))
+ return;
- if (!gtk_tree_model_get_iter_from_string (eprop_accel->model,
- &iter, path_string))
- return;
-
- gtk_tree_store_remove (GTK_TREE_STORE (eprop_accel->model), &iter);
+ gtk_tree_store_remove (GTK_TREE_STORE (eprop_accel->model), &iter);
}
static GtkWidget *
-glade_eprop_accel_view (GladeEditorProperty *eprop)
+glade_eprop_accel_view (GladeEditorProperty * eprop)
{
- GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
- GtkWidget *view_widget;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- eprop_accel->model = (GtkTreeModel *)gtk_tree_store_new
- (ACCEL_NUM_COLUMNS,
- G_TYPE_STRING, /* The GSignal name formatted for display */
- G_TYPE_STRING, /* The GSignal name */
- G_TYPE_STRING, /* The text to show in the accelerator cell */
- G_TYPE_INT, /* PangoWeight attribute for bold headers */
- G_TYPE_INT, /* PangoStyle attribute for italic grey unset items */
- G_TYPE_STRING, /* Foreground colour for italic grey unset items */
- G_TYPE_BOOLEAN, /* Visible attribute to hide items for header entries */
- G_TYPE_BOOLEAN, /* Whether the key has been entered for this row */
- G_TYPE_UINT, /* Hardware keycode */
- G_TYPE_INT); /* GdkModifierType */
-
- view_widget = gtk_tree_view_new_with_model (eprop_accel->model);
- gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view_widget), FALSE);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view_widget), FALSE);
-
- /********************* signal name column *********************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "editable", FALSE, NULL);
-
- column = gtk_tree_view_column_new_with_attributes
- (_("Signal"), renderer,
- "text", ACCEL_COLUMN_SIGNAL,
- "weight", ACCEL_COLUMN_WEIGHT,
- NULL);
-
-
- gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
-
- /********************* accel editor column *********************/
- renderer = gtk_cell_renderer_accel_new ();
- g_object_set (G_OBJECT (renderer),
- "editable", TRUE,
- NULL);
-
- g_signal_connect (renderer, "accel-edited",
- G_CALLBACK (accel_edited), eprop);
- g_signal_connect (renderer, "accel-cleared",
- G_CALLBACK (accel_cleared), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- (_("Accelerator Key"), renderer,
- "text", ACCEL_COLUMN_TEXT,
- "foreground", ACCEL_COLUMN_FOREGROUND,
- "style", ACCEL_COLUMN_STYLE,
- "visible", ACCEL_COLUMN_VISIBLE,
- NULL);
-
- gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
-
- return view_widget;
+ GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
+ GtkWidget *view_widget;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ eprop_accel->model = (GtkTreeModel *) gtk_tree_store_new (ACCEL_NUM_COLUMNS, G_TYPE_STRING, /* The GSignal name formatted for display */
+ G_TYPE_STRING, /* The GSignal name */
+ G_TYPE_STRING, /* The text to show in the accelerator cell */
+ G_TYPE_INT, /* PangoWeight attribute for bold headers */
+ G_TYPE_INT, /* PangoStyle attribute for italic grey unset items */
+ G_TYPE_STRING, /* Foreground colour for italic grey unset items */
+ G_TYPE_BOOLEAN, /* Visible attribute to hide items for header entries */
+ G_TYPE_BOOLEAN, /* Whether the key has been entered for this row */
+ G_TYPE_UINT, /* Hardware keycode */
+ G_TYPE_INT); /* GdkModifierType */
+
+ view_widget = gtk_tree_view_new_with_model (eprop_accel->model);
+ gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view_widget), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view_widget), FALSE);
+
+ /********************* signal name column *********************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Signal"), renderer,
+ "text", ACCEL_COLUMN_SIGNAL, "weight", ACCEL_COLUMN_WEIGHT, NULL);
+
+
+ gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
+
+ /********************* accel editor column *********************/
+ renderer = gtk_cell_renderer_accel_new ();
+ g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
+
+ g_signal_connect (renderer, "accel-edited", G_CALLBACK (accel_edited), eprop);
+ g_signal_connect (renderer, "accel-cleared",
+ G_CALLBACK (accel_cleared), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Accelerator Key"), renderer,
+ "text", ACCEL_COLUMN_TEXT,
+ "foreground", ACCEL_COLUMN_FOREGROUND,
+ "style", ACCEL_COLUMN_STYLE, "visible", ACCEL_COLUMN_VISIBLE, NULL);
+
+ gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
+
+ return view_widget;
}
static gboolean
-glade_eprop_accel_accum_accelerators (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- GList **ret)
+glade_eprop_accel_accum_accelerators (GtkTreeModel * model,
+ GtkTreePath * path,
+ GtkTreeIter * iter, GList ** ret)
{
- GladeAccelInfo *info;
- gchar *signal;
- GdkModifierType accel_mods;
- guint accel_key;
- gboolean entered = FALSE;
-
- gtk_tree_model_get (model, iter, ACCEL_COLUMN_KEY_ENTERED, &entered, -1);
- if (!entered) return FALSE;
-
- gtk_tree_model_get (model, iter,
- ACCEL_COLUMN_REAL_SIGNAL, &signal,
- ACCEL_COLUMN_KEYCODE, &accel_key,
- ACCEL_COLUMN_MODIFIERS, &accel_mods,
- -1);
-
- info = g_new0 (GladeAccelInfo, 1);
- info->signal = signal;
- info->key = accel_key;
- info->modifiers = accel_mods;
-
- *ret = g_list_prepend (*ret, info);
-
- return FALSE;
+ GladeAccelInfo *info;
+ gchar *signal;
+ GdkModifierType accel_mods;
+ guint accel_key;
+ gboolean entered = FALSE;
+
+ gtk_tree_model_get (model, iter, ACCEL_COLUMN_KEY_ENTERED, &entered, -1);
+ if (!entered)
+ return FALSE;
+
+ gtk_tree_model_get (model, iter,
+ ACCEL_COLUMN_REAL_SIGNAL, &signal,
+ ACCEL_COLUMN_KEYCODE, &accel_key,
+ ACCEL_COLUMN_MODIFIERS, &accel_mods, -1);
+
+ info = g_new0 (GladeAccelInfo, 1);
+ info->signal = signal;
+ info->key = accel_key;
+ info->modifiers = accel_mods;
+
+ *ret = g_list_prepend (*ret, info);
+
+ return FALSE;
}
static void
-glade_eprop_accel_show_dialog (GtkWidget *dialog_button,
- GladeEditorProperty *eprop)
+glade_eprop_accel_show_dialog (GtkWidget * dialog_button,
+ GladeEditorProperty * eprop)
{
- GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
- GtkWidget *dialog, *parent, *vbox, *sw, *tree_view;
- GladeProject *project;
- GValue value = { 0, };
- GList *accelerators = NULL;
- gint res;
-
- project = glade_widget_get_project (eprop->property->widget);
- parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
-
- dialog = gtk_dialog_new_with_buttons (_("Choose accelerator keys..."),
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- vbox, TRUE, TRUE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- tree_view = glade_eprop_accel_view (eprop);
- glade_eprop_accel_populate_view (eprop, GTK_TREE_VIEW (tree_view));
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
-
- gtk_widget_show (tree_view);
- gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
- /* Run the dialog */
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK)
- {
- gtk_tree_model_foreach
- (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
- (GtkTreeModelForeachFunc)
- glade_eprop_accel_accum_accelerators, &accelerators);
-
- g_value_init (&value, GLADE_TYPE_ACCEL_GLIST);
- g_value_take_boxed (&value, accelerators);
-
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
- }
- else if (res == GLADE_RESPONSE_CLEAR)
- {
- g_value_init (&value, GLADE_TYPE_ACCEL_GLIST);
- g_value_set_boxed (&value, NULL);
-
- glade_editor_property_commit (eprop, &value);
-
- g_value_unset (&value);
- }
-
- /* Clean up ...
- */
- gtk_widget_destroy (dialog);
-
- g_object_unref (G_OBJECT (eprop_accel->model));
- eprop_accel->model = NULL;
-
- if (eprop_accel->parent_iters)
- {
- g_list_foreach (eprop_accel->parent_iters, (GFunc)iter_tab_free, NULL);
- g_list_free (eprop_accel->parent_iters);
- eprop_accel->parent_iters = NULL;
- }
+ GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
+ GtkWidget *dialog, *parent, *vbox, *sw, *tree_view;
+ GladeProject *project;
+ GValue value = { 0, };
+ GList *accelerators = NULL;
+ gint res;
+
+ project = glade_widget_get_project (eprop->property->widget);
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
+
+ dialog = gtk_dialog_new_with_buttons (_("Choose accelerator keys..."),
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+
+ gtk_box_pack_start (GTK_BOX
+ (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox,
+ TRUE, TRUE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ tree_view = glade_eprop_accel_view (eprop);
+ glade_eprop_accel_populate_view (eprop, GTK_TREE_VIEW (tree_view));
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ gtk_widget_show (tree_view);
+ gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+ /* Run the dialog */
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+ gtk_tree_model_foreach
+ (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)),
+ (GtkTreeModelForeachFunc)
+ glade_eprop_accel_accum_accelerators, &accelerators);
+
+ g_value_init (&value, GLADE_TYPE_ACCEL_GLIST);
+ g_value_take_boxed (&value, accelerators);
+
+ glade_editor_property_commit (eprop, &value);
+ g_value_unset (&value);
+ }
+ else if (res == GLADE_RESPONSE_CLEAR)
+ {
+ g_value_init (&value, GLADE_TYPE_ACCEL_GLIST);
+ g_value_set_boxed (&value, NULL);
+
+ glade_editor_property_commit (eprop, &value);
+
+ g_value_unset (&value);
+ }
+
+ /* Clean up ...
+ */
+ gtk_widget_destroy (dialog);
+
+ g_object_unref (G_OBJECT (eprop_accel->model));
+ eprop_accel->model = NULL;
+
+ if (eprop_accel->parent_iters)
+ {
+ g_list_foreach (eprop_accel->parent_iters, (GFunc) iter_tab_free, NULL);
+ g_list_free (eprop_accel->parent_iters);
+ eprop_accel->parent_iters = NULL;
+ }
}
static GtkWidget *
-glade_eprop_accel_create_input (GladeEditorProperty *eprop)
+glade_eprop_accel_create_input (GladeEditorProperty * eprop)
{
- GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
- GtkWidget *hbox;
- GtkWidget *button;
+ GladeEPropAccel *eprop_accel = GLADE_EPROP_ACCEL (eprop);
+ GtkWidget *hbox;
+ GtkWidget *button;
- hbox = gtk_hbox_new (FALSE, 0);
- eprop_accel->entry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (eprop_accel->entry), FALSE);
- gtk_widget_show (eprop_accel->entry);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_accel->entry, TRUE, TRUE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
+ eprop_accel->entry = gtk_entry_new ();
+ gtk_editable_set_editable (GTK_EDITABLE (eprop_accel->entry), FALSE);
+ gtk_widget_show (eprop_accel->entry);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_accel->entry, TRUE, TRUE, 0);
- button = gtk_button_new_with_label ("...");
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("...");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_accel_show_dialog),
- eprop);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_accel_show_dialog), eprop);
- return hbox;
+ return hbox;
}
static GdkModifierType
-glade_gtk_parse_modifiers (const gchar *string)
+glade_gtk_parse_modifiers (const gchar * string)
{
- const gchar *pos = string;
- GdkModifierType modifiers = 0;
-
- while (pos && pos[0])
- {
- if (!strncmp(pos, "GDK_", 4)) {
- pos += 4;
- if (!strncmp(pos, "SHIFT_MASK", 10)) {
- modifiers |= GDK_SHIFT_MASK;
- pos += 10;
- } else if (!strncmp(pos, "LOCK_MASK", 9)) {
- modifiers |= GDK_LOCK_MASK;
- pos += 9;
- } else if (!strncmp(pos, "CONTROL_MASK", 12)) {
- modifiers |= GDK_CONTROL_MASK;
- pos += 12;
- } else if (!strncmp(pos, "MOD", 3) &&
- !strncmp(pos+4, "_MASK", 5)) {
- switch (pos[3]) {
- case '1':
- modifiers |= GDK_MOD1_MASK; break;
- case '2':
- modifiers |= GDK_MOD2_MASK; break;
- case '3':
- modifiers |= GDK_MOD3_MASK; break;
- case '4':
- modifiers |= GDK_MOD4_MASK; break;
- case '5':
- modifiers |= GDK_MOD5_MASK; break;
- }
- pos += 9;
- } else if (!strncmp(pos, "BUTTON", 6) &&
- !strncmp(pos+7, "_MASK", 5)) {
- switch (pos[6]) {
- case '1':
- modifiers |= GDK_BUTTON1_MASK; break;
- case '2':
- modifiers |= GDK_BUTTON2_MASK; break;
- case '3':
- modifiers |= GDK_BUTTON3_MASK; break;
- case '4':
- modifiers |= GDK_BUTTON4_MASK; break;
- case '5':
- modifiers |= GDK_BUTTON5_MASK; break;
- }
- pos += 12;
- } else if (!strncmp(pos, "RELEASE_MASK", 12)) {
- modifiers |= GDK_RELEASE_MASK;
- pos += 12;
- } else
- pos++;
- } else
- pos++;
- }
- return modifiers;
+ const gchar *pos = string;
+ GdkModifierType modifiers = 0;
+
+ while (pos && pos[0])
+ {
+ if (!strncmp (pos, "GDK_", 4))
+ {
+ pos += 4;
+ if (!strncmp (pos, "SHIFT_MASK", 10))
+ {
+ modifiers |= GDK_SHIFT_MASK;
+ pos += 10;
+ }
+ else if (!strncmp (pos, "LOCK_MASK", 9))
+ {
+ modifiers |= GDK_LOCK_MASK;
+ pos += 9;
+ }
+ else if (!strncmp (pos, "CONTROL_MASK", 12))
+ {
+ modifiers |= GDK_CONTROL_MASK;
+ pos += 12;
+ }
+ else if (!strncmp (pos, "MOD", 3) && !strncmp (pos + 4, "_MASK", 5))
+ {
+ switch (pos[3])
+ {
+ case '1':
+ modifiers |= GDK_MOD1_MASK;
+ break;
+ case '2':
+ modifiers |= GDK_MOD2_MASK;
+ break;
+ case '3':
+ modifiers |= GDK_MOD3_MASK;
+ break;
+ case '4':
+ modifiers |= GDK_MOD4_MASK;
+ break;
+ case '5':
+ modifiers |= GDK_MOD5_MASK;
+ break;
+ }
+ pos += 9;
+ }
+ else if (!strncmp (pos, "BUTTON", 6) &&
+ !strncmp (pos + 7, "_MASK", 5))
+ {
+ switch (pos[6])
+ {
+ case '1':
+ modifiers |= GDK_BUTTON1_MASK;
+ break;
+ case '2':
+ modifiers |= GDK_BUTTON2_MASK;
+ break;
+ case '3':
+ modifiers |= GDK_BUTTON3_MASK;
+ break;
+ case '4':
+ modifiers |= GDK_BUTTON4_MASK;
+ break;
+ case '5':
+ modifiers |= GDK_BUTTON5_MASK;
+ break;
+ }
+ pos += 12;
+ }
+ else if (!strncmp (pos, "RELEASE_MASK", 12))
+ {
+ modifiers |= GDK_RELEASE_MASK;
+ pos += 12;
+ }
+ else
+ pos++;
+ }
+ else
+ pos++;
+ }
+ return modifiers;
}
static gchar *
glade_gtk_modifier_string_from_bits (GdkModifierType modifiers)
{
- GString *string = g_string_new ("");
+ GString *string = g_string_new ("");
- if (modifiers & GDK_SHIFT_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_SHIFT_MASK");
+ if (modifiers & GDK_SHIFT_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_SHIFT_MASK");
}
- if (modifiers & GDK_LOCK_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_LOCK_MASK");
+ if (modifiers & GDK_LOCK_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_LOCK_MASK");
}
- if (modifiers & GDK_CONTROL_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_CONTROL_MASK");
+ if (modifiers & GDK_CONTROL_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_CONTROL_MASK");
}
- if (modifiers & GDK_MOD1_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_MOD1_MASK");
+ if (modifiers & GDK_MOD1_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_MOD1_MASK");
}
- if (modifiers & GDK_MOD2_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_MOD2_MASK");
+ if (modifiers & GDK_MOD2_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_MOD2_MASK");
}
- if (modifiers & GDK_MOD3_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_MOD3_MASK");
+ if (modifiers & GDK_MOD3_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_MOD3_MASK");
}
- if (modifiers & GDK_MOD4_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_MOD4_MASK");
+ if (modifiers & GDK_MOD4_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_MOD4_MASK");
}
- if (modifiers & GDK_MOD5_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_MOD5_MASK");
+ if (modifiers & GDK_MOD5_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_MOD5_MASK");
}
- if (modifiers & GDK_BUTTON1_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_BUTTON1_MASK");
+ if (modifiers & GDK_BUTTON1_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_BUTTON1_MASK");
}
- if (modifiers & GDK_BUTTON2_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_BUTTON2_MASK");
+ if (modifiers & GDK_BUTTON2_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_BUTTON2_MASK");
}
- if (modifiers & GDK_BUTTON3_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_BUTTON3_MASK");
+ if (modifiers & GDK_BUTTON3_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_BUTTON3_MASK");
}
- if (modifiers & GDK_BUTTON4_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_BUTTON4_MASK");
+ if (modifiers & GDK_BUTTON4_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_BUTTON4_MASK");
}
- if (modifiers & GDK_BUTTON5_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_BUTTON5_MASK");
+ if (modifiers & GDK_BUTTON5_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_BUTTON5_MASK");
}
- if (modifiers & GDK_RELEASE_MASK) {
- if (string->len > 0)
- g_string_append (string, " | ");
- g_string_append (string, "GDK_RELEASE_MASK");
+ if (modifiers & GDK_RELEASE_MASK)
+ {
+ if (string->len > 0)
+ g_string_append (string, " | ");
+ g_string_append (string, "GDK_RELEASE_MASK");
}
- if (string->len > 0)
- return g_string_free (string, FALSE);
+ if (string->len > 0)
+ return g_string_free (string, FALSE);
- g_string_free (string, TRUE);
- return NULL;
+ g_string_free (string, TRUE);
+ return NULL;
}
GladeAccelInfo *
-glade_accel_read (GladeXmlNode *node,
- gboolean require_signal)
+glade_accel_read (GladeXmlNode * node, gboolean require_signal)
{
- GladeAccelInfo *ainfo;
- gchar *key, *modifiers, *signal;
-
- g_return_val_if_fail (node != NULL, NULL);
-
- if (!glade_xml_node_verify (node, GLADE_TAG_ACCEL))
- return NULL;
-
- /* Get from xml... */
- key = glade_xml_get_property_string_required
- (node, GLADE_TAG_ACCEL_KEY, NULL);
- if (require_signal)
- signal = glade_xml_get_property_string_required (node, GLADE_TAG_ACCEL_SIGNAL, NULL);
- else
- signal = glade_xml_get_property_string (node, GLADE_TAG_ACCEL_SIGNAL);
-
- modifiers = glade_xml_get_property_string (node, GLADE_TAG_ACCEL_MODIFIERS);
-
- /* translate to GladeAccelInfo... */
- ainfo = g_new0 (GladeAccelInfo, 1);
- ainfo->key = gdk_keyval_from_name(key);
- ainfo->signal = signal; /* take string ownership... */
- ainfo->modifiers = glade_gtk_parse_modifiers (modifiers);
-
- g_free (modifiers);
-
- return ainfo;
+ GladeAccelInfo *ainfo;
+ gchar *key, *modifiers, *signal;
+
+ g_return_val_if_fail (node != NULL, NULL);
+
+ if (!glade_xml_node_verify (node, GLADE_TAG_ACCEL))
+ return NULL;
+
+ /* Get from xml... */
+ key = glade_xml_get_property_string_required
+ (node, GLADE_TAG_ACCEL_KEY, NULL);
+ if (require_signal)
+ signal =
+ glade_xml_get_property_string_required (node, GLADE_TAG_ACCEL_SIGNAL,
+ NULL);
+ else
+ signal = glade_xml_get_property_string (node, GLADE_TAG_ACCEL_SIGNAL);
+
+ modifiers = glade_xml_get_property_string (node, GLADE_TAG_ACCEL_MODIFIERS);
+
+ /* translate to GladeAccelInfo... */
+ ainfo = g_new0 (GladeAccelInfo, 1);
+ ainfo->key = gdk_keyval_from_name (key);
+ ainfo->signal = signal; /* take string ownership... */
+ ainfo->modifiers = glade_gtk_parse_modifiers (modifiers);
+
+ g_free (modifiers);
+
+ return ainfo;
}
GladeXmlNode *
-glade_accel_write (GladeAccelInfo *accel,
- GladeXmlContext *context,
- gboolean write_signal)
+glade_accel_write (GladeAccelInfo * accel,
+ GladeXmlContext * context, gboolean write_signal)
{
- GladeXmlNode *accel_node;
- gchar *modifiers;
+ GladeXmlNode *accel_node;
+ gchar *modifiers;
- g_return_val_if_fail (accel != NULL, NULL);
- g_return_val_if_fail (context != NULL, NULL);
+ g_return_val_if_fail (accel != NULL, NULL);
+ g_return_val_if_fail (context != NULL, NULL);
- accel_node = glade_xml_node_new (context, GLADE_TAG_ACCEL);
- modifiers = glade_gtk_modifier_string_from_bits (accel->modifiers);
+ accel_node = glade_xml_node_new (context, GLADE_TAG_ACCEL);
+ modifiers = glade_gtk_modifier_string_from_bits (accel->modifiers);
- glade_xml_node_set_property_string (accel_node, GLADE_TAG_ACCEL_KEY,
- gdk_keyval_name(accel->key));
+ glade_xml_node_set_property_string (accel_node, GLADE_TAG_ACCEL_KEY,
+ gdk_keyval_name (accel->key));
- if (write_signal)
- glade_xml_node_set_property_string (accel_node, GLADE_TAG_ACCEL_SIGNAL,
- accel->signal);
- glade_xml_node_set_property_string (accel_node, GLADE_TAG_ACCEL_MODIFIERS,
- modifiers);
+ if (write_signal)
+ glade_xml_node_set_property_string (accel_node, GLADE_TAG_ACCEL_SIGNAL,
+ accel->signal);
+ glade_xml_node_set_property_string (accel_node, GLADE_TAG_ACCEL_MODIFIERS,
+ modifiers);
- g_free (modifiers);
+ g_free (modifiers);
- return accel_node;
+ return accel_node;
}
-
diff --git a/plugins/gtk+/glade-accels.h b/plugins/gtk+/glade-accels.h
index 2ff33f6..adcb35a 100644
--- a/plugins/gtk+/glade-accels.h
+++ b/plugins/gtk+/glade-accels.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_ACCELS_H__
#define __GLADE_ACCELS_H__
diff --git a/plugins/gtk+/glade-activatable-editor.c b/plugins/gtk+/glade-activatable-editor.c
index 2bbd09e..49faf8e 100644
--- a/plugins/gtk+/glade-activatable-editor.c
+++ b/plugins/gtk+/glade-activatable-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,405 +27,423 @@
#include "glade-activatable-editor.h"
-static void glade_activatable_editor_finalize (GObject *object);
+static void glade_activatable_editor_finalize (GObject * object);
-static void glade_activatable_editor_editable_init (GladeEditableIface *iface);
+static void glade_activatable_editor_editable_init (GladeEditableIface * iface);
-static void glade_activatable_editor_grab_focus (GtkWidget *widget);
+static void glade_activatable_editor_grab_focus (GtkWidget * widget);
-G_DEFINE_TYPE_WITH_CODE (GladeActivatableEditor, glade_activatable_editor, GTK_TYPE_VBOX,
+G_DEFINE_TYPE_WITH_CODE (GladeActivatableEditor, glade_activatable_editor,
+ GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_activatable_editor_editable_init));
static void
-glade_activatable_editor_class_init (GladeActivatableEditorClass *klass)
+glade_activatable_editor_class_init (GladeActivatableEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_activatable_editor_finalize;
- widget_class->grab_focus = glade_activatable_editor_grab_focus;
+ object_class->finalize = glade_activatable_editor_finalize;
+ widget_class->grab_focus = glade_activatable_editor_grab_focus;
}
static void
-glade_activatable_editor_init (GladeActivatableEditor *self)
+glade_activatable_editor_init (GladeActivatableEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeActivatableEditor *activatable_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeActivatableEditor * activatable_editor)
{
- if (activatable_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (activatable_editor)))
- return;
+ if (activatable_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (activatable_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (activatable_editor), activatable_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (activatable_editor),
+ activatable_editor->loaded_widget);
}
static void
-project_finalized (GladeActivatableEditor *activatable_editor,
- GladeProject *where_project_was)
+project_finalized (GladeActivatableEditor * activatable_editor,
+ GladeProject * where_project_was)
{
- activatable_editor->loaded_widget = NULL;
+ activatable_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (activatable_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (activatable_editor), NULL);
}
static void
-glade_activatable_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_activatable_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (editable);
- GList *l;
-
- activatable_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (activatable_editor->loaded_widget)
- {
- /* watch custom-child and use-stock properties here for reloads !!! */
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (activatable_editor->loaded_widget->project),
- G_CALLBACK (project_changed), activatable_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (activatable_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- activatable_editor);
- }
-
- /* Mark our widget... */
- activatable_editor->loaded_widget = widget;
-
- if (activatable_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (activatable_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), activatable_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (activatable_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- activatable_editor);
- }
-
- /* load the embedded editable... */
- if (activatable_editor->embed)
- glade_editable_load (GLADE_EDITABLE (activatable_editor->embed), widget);
-
- for (l = activatable_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
- if (widget)
- {
- }
- activatable_editor->loading = FALSE;
+ GladeActivatableEditor *activatable_editor =
+ GLADE_ACTIVATABLE_EDITOR (editable);
+ GList *l;
+
+ activatable_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (activatable_editor->loaded_widget)
+ {
+ /* watch custom-child and use-stock properties here for reloads !!! */
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (activatable_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ activatable_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT
+ (activatable_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, activatable_editor);
+ }
+
+ /* Mark our widget... */
+ activatable_editor->loaded_widget = widget;
+
+ if (activatable_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (activatable_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed),
+ activatable_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (activatable_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, activatable_editor);
+ }
+
+ /* load the embedded editable... */
+ if (activatable_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (activatable_editor->embed), widget);
+
+ for (l = activatable_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+ if (widget)
+ {
+ }
+ activatable_editor->loading = FALSE;
}
static void
-glade_activatable_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_activatable_editor_set_show_name (GladeEditable * editable,
+ gboolean show_name)
{
- GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (editable);
+ GladeActivatableEditor *activatable_editor =
+ GLADE_ACTIVATABLE_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (activatable_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (activatable_editor->embed),
+ show_name);
}
static void
-glade_activatable_editor_editable_init (GladeEditableIface *iface)
+glade_activatable_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_activatable_editor_load;
- iface->set_show_name = glade_activatable_editor_set_show_name;
+ iface->load = glade_activatable_editor_load;
+ iface->set_show_name = glade_activatable_editor_set_show_name;
}
static void
-glade_activatable_editor_finalize (GObject *object)
+glade_activatable_editor_finalize (GObject * object)
{
- GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (object);
+ GladeActivatableEditor *activatable_editor =
+ GLADE_ACTIVATABLE_EDITOR (object);
- if (activatable_editor->properties)
- g_list_free (activatable_editor->properties);
- activatable_editor->properties = NULL;
- activatable_editor->embed = NULL;
+ if (activatable_editor->properties)
+ g_list_free (activatable_editor->properties);
+ activatable_editor->properties = NULL;
+ activatable_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_activatable_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_activatable_editor_parent_class)->finalize (object);
}
static void
-glade_activatable_editor_grab_focus (GtkWidget *widget)
+glade_activatable_editor_grab_focus (GtkWidget * widget)
{
- GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (widget);
+ GladeActivatableEditor *activatable_editor =
+ GLADE_ACTIVATABLE_EDITOR (widget);
- gtk_widget_grab_focus (activatable_editor->embed);
+ gtk_widget_grab_focus (activatable_editor->embed);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
static void
-reset_property (GladeWidget *gwidget,
- const gchar *property_name)
+reset_property (GladeWidget * gwidget, const gchar * property_name)
{
- GladeProperty *property;
- GValue value = { 0, };
-
- if ((property = glade_widget_get_property (gwidget, property_name)) != NULL)
- {
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
- }
+ GladeProperty *property;
+ GValue value = { 0, };
+
+ if ((property = glade_widget_get_property (gwidget, property_name)) != NULL)
+ {
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
+ }
}
static GladeWidget *
-get_image_widget (GladeWidget *widget)
+get_image_widget (GladeWidget * widget)
{
- GtkWidget *image = NULL;
+ GtkWidget *image = NULL;
- if (GTK_IS_IMAGE_MENU_ITEM (widget->object))
- image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget->object));
- return image ? glade_widget_get_from_gobject (image) : NULL;
+ if (GTK_IS_IMAGE_MENU_ITEM (widget->object))
+ image =
+ gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget->object));
+ return image ? glade_widget_get_from_gobject (image) : NULL;
}
static void
-reset_properties (GladeWidget *gwidget,
- GtkAction *action,
- gboolean use_appearance,
- gboolean use_appearance_changed)
+reset_properties (GladeWidget * gwidget,
+ GtkAction * action,
+ gboolean use_appearance, gboolean use_appearance_changed)
{
- reset_property (gwidget, "visible");
- reset_property (gwidget, "sensitive");
-
- if (GTK_IS_MENU_ITEM (gwidget->object))
- {
- if (!use_appearance_changed)
- reset_property (gwidget, "accel-group");
-
- if (use_appearance)
- {
- GladeWidget *image;
- GladeProperty *property;
-
- reset_property (gwidget, "stock");
- reset_property (gwidget, "use-underline");
- reset_property (gwidget, "use-stock");
-
- /* Delete image... */
- if ((image = get_image_widget (gwidget)) != NULL)
- {
- GList list = { 0, };
- list.data = image;
- glade_command_unlock_widget (image);
- glade_command_delete (&list);
- }
-
- property = glade_widget_get_property (gwidget, "label");
- glade_command_set_property (property, NULL);
- }
- else if (use_appearance_changed)
- {
- reset_property (gwidget, "stock");
- reset_property (gwidget, "use-underline");
- reset_property (gwidget, "use-stock");
-
- reset_property (gwidget, "label");
-
- }
- }
- else if (GTK_IS_TOOL_ITEM (gwidget->object))
- {
- reset_property (gwidget, "visible-horizontal");
- reset_property (gwidget, "visible-vertical");
- reset_property (gwidget, "is-important");
-
- if (use_appearance || use_appearance_changed)
- {
- reset_property (gwidget, "label-widget");
- reset_property (gwidget, "custom-label");
- reset_property (gwidget, "stock-id");
- reset_property (gwidget, "icon-name");
- reset_property (gwidget, "icon");
- reset_property (gwidget, "icon-widget");
- reset_property (gwidget, "image-mode");
- }
- }
- else if (GTK_IS_BUTTON (gwidget->object))
- {
- reset_property (gwidget, "active");
-
-
- if (use_appearance)
- {
-
- GtkWidget *button, *child;
- GladeWidget *gchild = NULL;
- GladeProperty *property;
-
- /* If theres a widget customly inside... command remove it first... */
- button = GTK_WIDGET (gwidget->object);
- child = gtk_bin_get_child (GTK_BIN (button));
- if (child)
- gchild = glade_widget_get_from_gobject (child);
-
- if (gchild && gchild->parent == gwidget)
- {
- GList widgets = { 0, };
- widgets.data = gchild;
- glade_command_delete (&widgets);
- }
-
- reset_property (gwidget, "custom-child");
- reset_property (gwidget, "stock");
- //reset_property (gwidget, "use-stock");
-
- property = glade_widget_get_property (gwidget, "label");
- glade_command_set_property (property, "");
-
- } else if (use_appearance_changed) {
- reset_property (gwidget, "label");
- reset_property (gwidget, "custom-child");
- reset_property (gwidget, "stock");
- //reset_property (gwidget, "use-stock");
- }
- }
- /* Make sure none of our property resets screw with the current selection,
- * since we rely on the selection during commit time.
- */
- glade_project_selection_set (gwidget->project, gwidget->object, TRUE);
+ reset_property (gwidget, "visible");
+ reset_property (gwidget, "sensitive");
+
+ if (GTK_IS_MENU_ITEM (gwidget->object))
+ {
+ if (!use_appearance_changed)
+ reset_property (gwidget, "accel-group");
+
+ if (use_appearance)
+ {
+ GladeWidget *image;
+ GladeProperty *property;
+
+ reset_property (gwidget, "stock");
+ reset_property (gwidget, "use-underline");
+ reset_property (gwidget, "use-stock");
+
+ /* Delete image... */
+ if ((image = get_image_widget (gwidget)) != NULL)
+ {
+ GList list = { 0, };
+ list.data = image;
+ glade_command_unlock_widget (image);
+ glade_command_delete (&list);
+ }
+
+ property = glade_widget_get_property (gwidget, "label");
+ glade_command_set_property (property, NULL);
+ }
+ else if (use_appearance_changed)
+ {
+ reset_property (gwidget, "stock");
+ reset_property (gwidget, "use-underline");
+ reset_property (gwidget, "use-stock");
+
+ reset_property (gwidget, "label");
+
+ }
+ }
+ else if (GTK_IS_TOOL_ITEM (gwidget->object))
+ {
+ reset_property (gwidget, "visible-horizontal");
+ reset_property (gwidget, "visible-vertical");
+ reset_property (gwidget, "is-important");
+
+ if (use_appearance || use_appearance_changed)
+ {
+ reset_property (gwidget, "label-widget");
+ reset_property (gwidget, "custom-label");
+ reset_property (gwidget, "stock-id");
+ reset_property (gwidget, "icon-name");
+ reset_property (gwidget, "icon");
+ reset_property (gwidget, "icon-widget");
+ reset_property (gwidget, "image-mode");
+ }
+ }
+ else if (GTK_IS_BUTTON (gwidget->object))
+ {
+ reset_property (gwidget, "active");
+
+
+ if (use_appearance)
+ {
+
+ GtkWidget *button, *child;
+ GladeWidget *gchild = NULL;
+ GladeProperty *property;
+
+ /* If theres a widget customly inside... command remove it first... */
+ button = GTK_WIDGET (gwidget->object);
+ child = gtk_bin_get_child (GTK_BIN (button));
+ if (child)
+ gchild = glade_widget_get_from_gobject (child);
+
+ if (gchild && gchild->parent == gwidget)
+ {
+ GList widgets = { 0, };
+ widgets.data = gchild;
+ glade_command_delete (&widgets);
+ }
+
+ reset_property (gwidget, "custom-child");
+ reset_property (gwidget, "stock");
+ //reset_property (gwidget, "use-stock");
+
+ property = glade_widget_get_property (gwidget, "label");
+ glade_command_set_property (property, "");
+
+ }
+ else if (use_appearance_changed)
+ {
+ reset_property (gwidget, "label");
+ reset_property (gwidget, "custom-child");
+ reset_property (gwidget, "stock");
+ //reset_property (gwidget, "use-stock");
+ }
+ }
+ /* Make sure none of our property resets screw with the current selection,
+ * since we rely on the selection during commit time.
+ */
+ glade_project_selection_set (gwidget->project, gwidget->object, TRUE);
}
static void
-related_action_pre_commit (GladeEditorProperty *property,
- GValue *value,
- GladeActivatableEditor *activatable_editor)
+related_action_pre_commit (GladeEditorProperty * property,
+ GValue * value,
+ GladeActivatableEditor * activatable_editor)
{
- GladeWidget *gwidget = activatable_editor->loaded_widget;
- GtkAction *action = g_value_get_object (value);
- gboolean use_appearance = FALSE;
+ GladeWidget *gwidget = activatable_editor->loaded_widget;
+ GtkAction *action = g_value_get_object (value);
+ gboolean use_appearance = FALSE;
- glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance);
+ glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance);
- glade_command_push_group (_("Setting %s action"), gwidget->name);
+ glade_command_push_group (_("Setting %s action"), gwidget->name);
- reset_properties (gwidget, action, use_appearance, FALSE);
+ reset_properties (gwidget, action, use_appearance, FALSE);
}
static void
-related_action_post_commit (GladeEditorProperty *property,
- GValue *value,
- GladeActivatableEditor *activatable_editor)
+related_action_post_commit (GladeEditorProperty * property,
+ GValue * value,
+ GladeActivatableEditor * activatable_editor)
{
- glade_command_pop_group ();
+ glade_command_pop_group ();
}
static void
-use_appearance_pre_commit (GladeEditorProperty *property,
- GValue *value,
- GladeActivatableEditor *activatable_editor)
+use_appearance_pre_commit (GladeEditorProperty * property,
+ GValue * value,
+ GladeActivatableEditor * activatable_editor)
{
- GladeWidget *gwidget = activatable_editor->loaded_widget;
- GtkAction *action = NULL;
- gboolean use_appearance = g_value_get_boolean (value);
+ GladeWidget *gwidget = activatable_editor->loaded_widget;
+ GtkAction *action = NULL;
+ gboolean use_appearance = g_value_get_boolean (value);
- glade_widget_property_get (gwidget, "related-action", &action);
+ glade_widget_property_get (gwidget, "related-action", &action);
- glade_command_push_group (use_appearance ?
- _("Setting %s to use action appearance") :
- _("Setting %s to not use action appearance"),
- gwidget->name);
+ glade_command_push_group (use_appearance ?
+ _("Setting %s to use action appearance") :
+ _("Setting %s to not use action appearance"),
+ gwidget->name);
- reset_properties (gwidget, action, use_appearance, TRUE);
+ reset_properties (gwidget, action, use_appearance, TRUE);
}
static void
-use_appearance_post_commit (GladeEditorProperty *property,
- GValue *value,
- GladeActivatableEditor *activatable_editor)
+use_appearance_post_commit (GladeEditorProperty * property,
+ GValue * value,
+ GladeActivatableEditor * activatable_editor)
{
- glade_command_pop_group ();
+ glade_command_pop_group ();
}
GtkWidget *
-glade_activatable_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_activatable_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditable * embed)
{
- GladeActivatableEditor *activatable_editor;
- GladeEditorProperty *eprop;
- GtkWidget *table, *frame, *alignment, *label;
- gchar *str;
- gint row = 0;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- activatable_editor = g_object_new (GLADE_TYPE_ACTIVATABLE_EDITOR, NULL);
- activatable_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (activatable_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- str = g_strdup_printf ("<b>%s</b>", _("Action"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (activatable_editor), frame, FALSE, FALSE, 4);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
-
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "related-action", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- activatable_editor->properties = g_list_prepend (activatable_editor->properties, eprop);
-
- g_signal_connect (G_OBJECT (eprop), "commit",
- G_CALLBACK (related_action_pre_commit), activatable_editor);
- g_signal_connect_after (G_OBJECT (eprop), "commit",
- G_CALLBACK (related_action_post_commit), activatable_editor);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "use-action-appearance", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- activatable_editor->properties = g_list_prepend (activatable_editor->properties, eprop);
-
- gtk_widget_show_all (GTK_WIDGET (activatable_editor));
-
- g_signal_connect (G_OBJECT (eprop), "commit",
- G_CALLBACK (use_appearance_pre_commit), activatable_editor);
- g_signal_connect_after (G_OBJECT (eprop), "commit",
- G_CALLBACK (use_appearance_post_commit), activatable_editor);
-
- return GTK_WIDGET (activatable_editor);
+ GladeActivatableEditor *activatable_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *table, *frame, *alignment, *label;
+ gchar *str;
+ gint row = 0;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ activatable_editor = g_object_new (GLADE_TYPE_ACTIVATABLE_EDITOR, NULL);
+ activatable_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (activatable_editor), GTK_WIDGET (embed), FALSE,
+ FALSE, 0);
+
+ str = g_strdup_printf ("<b>%s</b>", _("Action"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (activatable_editor), frame, FALSE, FALSE, 4);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "related-action",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ activatable_editor->properties =
+ g_list_prepend (activatable_editor->properties, eprop);
+
+ g_signal_connect (G_OBJECT (eprop), "commit",
+ G_CALLBACK (related_action_pre_commit), activatable_editor);
+ g_signal_connect_after (G_OBJECT (eprop), "commit",
+ G_CALLBACK (related_action_post_commit),
+ activatable_editor);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "use-action-appearance", FALSE,
+ TRUE);
+ table_attach (table, eprop->item_label, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ activatable_editor->properties =
+ g_list_prepend (activatable_editor->properties, eprop);
+
+ gtk_widget_show_all (GTK_WIDGET (activatable_editor));
+
+ g_signal_connect (G_OBJECT (eprop), "commit",
+ G_CALLBACK (use_appearance_pre_commit), activatable_editor);
+ g_signal_connect_after (G_OBJECT (eprop), "commit",
+ G_CALLBACK (use_appearance_post_commit),
+ activatable_editor);
+
+ return GTK_WIDGET (activatable_editor);
}
diff --git a/plugins/gtk+/glade-activatable-editor.h b/plugins/gtk+/glade-activatable-editor.h
index 1a66697..9383457 100644
--- a/plugins/gtk+/glade-activatable-editor.h
+++ b/plugins/gtk+/glade-activatable-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-attributes.c b/plugins/gtk+/glade-attributes.c
old mode 100755
new mode 100644
index 836b2ef..1eecdbc
--- a/plugins/gtk+/glade-attributes.c
+++ b/plugins/gtk+/glade-attributes.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* glade-attributes.c - Editing support for pango attributes
*
@@ -36,65 +35,66 @@
#define GLADE_RESPONSE_CLEAR 42
static GList *
-glade_attr_list_copy (GList *attrs)
+glade_attr_list_copy (GList * attrs)
{
- GList *ret = NULL, *list;
- GladeAttribute *attr, *dup_attr;
+ GList *ret = NULL, *list;
+ GladeAttribute *attr, *dup_attr;
- for (list = attrs; list; list = list->next)
- {
- attr = list->data;
+ for (list = attrs; list; list = list->next)
+ {
+ attr = list->data;
- dup_attr = g_new0 (GladeAttribute, 1);
- dup_attr->type = attr->type;
- dup_attr->start = attr->start;
- dup_attr->end = attr->end;
- g_value_init (&(dup_attr->value), G_VALUE_TYPE (&(attr->value)));
- g_value_copy (&(attr->value), &(dup_attr->value));
+ dup_attr = g_new0 (GladeAttribute, 1);
+ dup_attr->type = attr->type;
+ dup_attr->start = attr->start;
+ dup_attr->end = attr->end;
+ g_value_init (&(dup_attr->value), G_VALUE_TYPE (&(attr->value)));
+ g_value_copy (&(attr->value), &(dup_attr->value));
- ret = g_list_prepend (ret, dup_attr);
- }
+ ret = g_list_prepend (ret, dup_attr);
+ }
- return g_list_reverse (ret);
+ return g_list_reverse (ret);
}
void
-glade_attr_list_free (GList *attrs)
+glade_attr_list_free (GList * attrs)
{
- GList *list;
- GladeAttribute *attr;
+ GList *list;
+ GladeAttribute *attr;
- for (list = attrs; list; list = list->next)
- {
- attr = list->data;
+ for (list = attrs; list; list = list->next)
+ {
+ attr = list->data;
- g_value_unset (&(attr->value));
- g_free (attr);
- }
- g_list_free (attrs);
+ g_value_unset (&(attr->value));
+ g_free (attr);
+ }
+ g_list_free (attrs);
}
GType
glade_attr_glist_get_type (void)
{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static
- ("GladeAttrGList",
- (GBoxedCopyFunc) glade_attr_list_copy,
- (GBoxedFreeFunc) glade_attr_list_free);
- return type_id;
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static
+ ("GladeAttrGList",
+ (GBoxedCopyFunc) glade_attr_list_copy,
+ (GBoxedFreeFunc) glade_attr_list_free);
+ return type_id;
}
/**************************************************************
* GladeEditorProperty stuff here
**************************************************************/
-typedef struct {
- GladeEditorProperty parent_instance;
+typedef struct
+{
+ GladeEditorProperty parent_instance;
+
+ GtkTreeModel *model;
- GtkTreeModel *model;
-
} GladeEPropAttrs;
GLADE_MAKE_EPROP (GladeEPropAttrs, glade_eprop_attrs)
@@ -103,1024 +103,1018 @@ GLADE_MAKE_EPROP (GladeEPropAttrs, glade_eprop_attrs)
#define GLADE_IS_EPROP_ATTRS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_ATTRS))
#define GLADE_IS_EPROP_ATTRS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_ATTRS))
#define GLADE_EPROP_ATTRS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_ATTRS, GladeEPropAttrsClass))
-
-enum {
-
- /* Main Data */
- COLUMN_NAME, /* The title string for PangoAttrType */
- COLUMN_NAME_WEIGHT, /* For bold names */
- COLUMN_TYPE, /* The PangoAttrType */
- COLUMN_EDIT_TYPE, /* The AttrEditType (below) */
- COLUMN_VALUE, /* The value */
- COLUMN_START, /* attribute start value */
- COLUMN_END, /* attribute end value */
-
- /* Editor renderer related */
- COLUMN_TOGGLE_ACTIVE, /* whether the toggle renderer is being used */
- COLUMN_TOGGLE_DOWN, /* whether the toggle should be displayed in "downstate" */
-
- COLUMN_BUTTON_ACTIVE, /* whether the GladeCellRendererButton is to be used (to launch dialogs) */
- COLUMN_TEXT, /* text attribute value for all text derived renderers */
- COLUMN_TEXT_STYLE, /* whether to make italic */
- COLUMN_TEXT_FG, /* forground colour of the text */
-
- COLUMN_COMBO_ACTIVE, /* whether the combobox renderer is being used */
- COLUMN_COMBO_MODEL, /* the model for the dropdown list */
-
- COLUMN_SPIN_ACTIVE, /* whether the spin renderer is being used */
- COLUMN_SPIN_DIGITS, /* How many decimal points to show (used to edit float values) */
-
- NUM_COLUMNS
-};
-
-
-typedef enum {
- EDIT_TOGGLE = 0,
- EDIT_COMBO,
- EDIT_SPIN,
- EDIT_COLOR,
- EDIT_INVALID
-} AttrEditType;
+ enum
+ {
+
+ /* Main Data */
+ COLUMN_NAME, /* The title string for PangoAttrType */
+ COLUMN_NAME_WEIGHT, /* For bold names */
+ COLUMN_TYPE, /* The PangoAttrType */
+ COLUMN_EDIT_TYPE, /* The AttrEditType (below) */
+ COLUMN_VALUE, /* The value */
+ COLUMN_START, /* attribute start value */
+ COLUMN_END, /* attribute end value */
+
+ /* Editor renderer related */
+ COLUMN_TOGGLE_ACTIVE, /* whether the toggle renderer is being used */
+ COLUMN_TOGGLE_DOWN, /* whether the toggle should be displayed in "downstate" */
+
+ COLUMN_BUTTON_ACTIVE, /* whether the GladeCellRendererButton is to be used (to launch dialogs) */
+ COLUMN_TEXT, /* text attribute value for all text derived renderers */
+ COLUMN_TEXT_STYLE, /* whether to make italic */
+ COLUMN_TEXT_FG, /* forground colour of the text */
+
+ COLUMN_COMBO_ACTIVE, /* whether the combobox renderer is being used */
+ COLUMN_COMBO_MODEL, /* the model for the dropdown list */
+
+ COLUMN_SPIN_ACTIVE, /* whether the spin renderer is being used */
+ COLUMN_SPIN_DIGITS, /* How many decimal points to show (used to edit float values) */
+
+ NUM_COLUMNS
+ };
+
+
+ typedef enum
+ {
+ EDIT_TOGGLE = 0,
+ EDIT_COMBO,
+ EDIT_SPIN,
+ EDIT_COLOR,
+ EDIT_INVALID
+ } AttrEditType;
#define ACTIVATE_COLUMN_FROM_TYPE(type) \
((type) == EDIT_TOGGLE ? COLUMN_TOGGLE_ACTIVE : \
(type) == EDIT_SPIN ? COLUMN_SPIN_ACTIVE : \
(type) == EDIT_COMBO ? COLUMN_COMBO_ACTIVE: COLUMN_BUTTON_ACTIVE)
-static GtkListStore *
-get_enum_model_for_combo (PangoAttrType type)
+ static GtkListStore *get_enum_model_for_combo (PangoAttrType type)
{
- static GtkListStore *style_store = NULL,
- *weight_store = NULL, *variant_store = NULL,
- *stretch_store = NULL, *gravity_store = NULL,
- *gravity_hint_store = NULL, *default_store = NULL;
-
- switch (type)
- {
- case PANGO_ATTR_STYLE:
- if (!style_store)
- style_store = glade_utils_liststore_from_enum_type (PANGO_TYPE_STYLE, TRUE);
- return style_store;
-
- case PANGO_ATTR_WEIGHT:
- if (!weight_store)
- weight_store = glade_utils_liststore_from_enum_type (PANGO_TYPE_WEIGHT, TRUE);
- return weight_store;
-
- case PANGO_ATTR_VARIANT:
- if (!variant_store)
- variant_store = glade_utils_liststore_from_enum_type (PANGO_TYPE_VARIANT, TRUE);
- return variant_store;
-
- case PANGO_ATTR_STRETCH:
- if (!stretch_store)
- stretch_store = glade_utils_liststore_from_enum_type (PANGO_TYPE_STRETCH, TRUE);
- return stretch_store;
-
- case PANGO_ATTR_GRAVITY:
- if (!gravity_store)
- gravity_store = glade_utils_liststore_from_enum_type (PANGO_TYPE_GRAVITY, TRUE);
- return gravity_store;
-
- case PANGO_ATTR_GRAVITY_HINT:
- if (!gravity_hint_store)
- gravity_hint_store = glade_utils_liststore_from_enum_type (PANGO_TYPE_GRAVITY_HINT, TRUE);
- return gravity_hint_store;
-
- default:
- if (!default_store)
- default_store = gtk_list_store_new (1, G_TYPE_STRING);
- return default_store;
- }
+ static GtkListStore *style_store = NULL,
+ *weight_store = NULL, *variant_store = NULL,
+ *stretch_store = NULL, *gravity_store = NULL,
+ *gravity_hint_store = NULL, *default_store = NULL;
+
+ switch (type)
+ {
+ case PANGO_ATTR_STYLE:
+ if (!style_store)
+ style_store =
+ glade_utils_liststore_from_enum_type (PANGO_TYPE_STYLE, TRUE);
+ return style_store;
+
+ case PANGO_ATTR_WEIGHT:
+ if (!weight_store)
+ weight_store =
+ glade_utils_liststore_from_enum_type (PANGO_TYPE_WEIGHT, TRUE);
+ return weight_store;
+
+ case PANGO_ATTR_VARIANT:
+ if (!variant_store)
+ variant_store =
+ glade_utils_liststore_from_enum_type (PANGO_TYPE_VARIANT, TRUE);
+ return variant_store;
+
+ case PANGO_ATTR_STRETCH:
+ if (!stretch_store)
+ stretch_store =
+ glade_utils_liststore_from_enum_type (PANGO_TYPE_STRETCH, TRUE);
+ return stretch_store;
+
+ case PANGO_ATTR_GRAVITY:
+ if (!gravity_store)
+ gravity_store =
+ glade_utils_liststore_from_enum_type (PANGO_TYPE_GRAVITY, TRUE);
+ return gravity_store;
+
+ case PANGO_ATTR_GRAVITY_HINT:
+ if (!gravity_hint_store)
+ gravity_hint_store =
+ glade_utils_liststore_from_enum_type (PANGO_TYPE_GRAVITY_HINT,
+ TRUE);
+ return gravity_hint_store;
+
+ default:
+ if (!default_store)
+ default_store = gtk_list_store_new (1, G_TYPE_STRING);
+ return default_store;
+ }
}
static gboolean
-append_empty_row (GtkListStore *store,
- PangoAttrType type)
+append_empty_row (GtkListStore * store, PangoAttrType type)
{
- const gchar *name = NULL;
- GtkListStore *model = get_enum_model_for_combo (type);
- GtkTreeIter iter;
- AttrEditType edit_type = EDIT_INVALID;
-
- switch (type)
- {
- /* PangoAttrLanguage */
- case PANGO_ATTR_LANGUAGE:
-
- break;
- /* PangoAttrInt */
- case PANGO_ATTR_STYLE:
- edit_type = EDIT_COMBO;
- name = C_("textattr", "Style");
- break;
- case PANGO_ATTR_WEIGHT:
- edit_type = EDIT_COMBO;
- name = C_("textattr", "Weight");
- break;
- case PANGO_ATTR_VARIANT:
- edit_type = EDIT_COMBO;
- name = C_("textattr", "Variant");
- break;
- case PANGO_ATTR_STRETCH:
- edit_type = EDIT_COMBO;
- name = C_("textattr", "Stretch");
- break;
- case PANGO_ATTR_UNDERLINE:
- edit_type = EDIT_TOGGLE;
- name = C_("textattr", "Underline");
- break;
- case PANGO_ATTR_STRIKETHROUGH:
- edit_type = EDIT_TOGGLE;
- name = C_("textattr", "Strikethrough");
- break;
- case PANGO_ATTR_GRAVITY:
- edit_type = EDIT_COMBO;
- name = C_("textattr", "Gravity");
- break;
- case PANGO_ATTR_GRAVITY_HINT:
- edit_type = EDIT_COMBO;
- name = C_("textattr", "Gravity Hint");
- break;
-
- /* PangoAttrString */
- case PANGO_ATTR_FAMILY:
- /* Use a simple editable text renderer ? */
- break;
-
- /* PangoAttrSize */
- case PANGO_ATTR_SIZE:
- edit_type = EDIT_SPIN;
- name = C_("textattr", "Size");
- break;
- case PANGO_ATTR_ABSOLUTE_SIZE:
- edit_type = EDIT_SPIN;
- name = C_("textattr", "Absolute Size");
- break;
-
- /* PangoAttrColor */
- /* Colours need editors... */
- case PANGO_ATTR_FOREGROUND:
- edit_type = EDIT_COLOR;
- name = C_("textattr", "Foreground Color");
- break;
- case PANGO_ATTR_BACKGROUND:
- edit_type = EDIT_COLOR;
- name = C_("textattr", "Background Color");
- break;
- case PANGO_ATTR_UNDERLINE_COLOR:
- edit_type = EDIT_COLOR;
- name = C_("textattr", "Underline Color");
- break;
- case PANGO_ATTR_STRIKETHROUGH_COLOR:
- edit_type = EDIT_COLOR;
- name = C_("textattr", "Strikethrough Color");
- break;
-
- /* PangoAttrShape */
- case PANGO_ATTR_SHAPE:
- /* Unsupported for now */
- break;
- /* PangoAttrFloat */
- case PANGO_ATTR_SCALE:
- edit_type = EDIT_SPIN;
- name = C_("textattr", "Scale");
- break;
-
- case PANGO_ATTR_INVALID:
- case PANGO_ATTR_LETTER_SPACING:
- case PANGO_ATTR_RISE:
- case PANGO_ATTR_FALLBACK:
- case PANGO_ATTR_FONT_DESC:
- default:
- break;
- }
-
- if (name)
- {
- gtk_list_store_append (store, &iter);
-
- gtk_list_store_set (store, &iter,
- COLUMN_TOGGLE_ACTIVE, FALSE,
- COLUMN_SPIN_ACTIVE, FALSE,
- COLUMN_COMBO_ACTIVE, FALSE,
- COLUMN_BUTTON_ACTIVE, FALSE,
- -1);
-
- gtk_list_store_set (store, &iter,
- COLUMN_NAME, name,
- COLUMN_TYPE, type,
- COLUMN_EDIT_TYPE, edit_type,
- COLUMN_NAME_WEIGHT, PANGO_WEIGHT_NORMAL,
- COLUMN_TEXT, _("<Enter Value>"),
- COLUMN_TEXT_STYLE, PANGO_STYLE_ITALIC,
- COLUMN_TEXT_FG, "Grey",
- COLUMN_COMBO_MODEL, model,
- ACTIVATE_COLUMN_FROM_TYPE (edit_type), TRUE,
- -1);
- return TRUE;
- }
- return FALSE;
+ const gchar *name = NULL;
+ GtkListStore *model = get_enum_model_for_combo (type);
+ GtkTreeIter iter;
+ AttrEditType edit_type = EDIT_INVALID;
+
+ switch (type)
+ {
+ /* PangoAttrLanguage */
+ case PANGO_ATTR_LANGUAGE:
+
+ break;
+ /* PangoAttrInt */
+ case PANGO_ATTR_STYLE:
+ edit_type = EDIT_COMBO;
+ name = C_ ("textattr", "Style");
+ break;
+ case PANGO_ATTR_WEIGHT:
+ edit_type = EDIT_COMBO;
+ name = C_ ("textattr", "Weight");
+ break;
+ case PANGO_ATTR_VARIANT:
+ edit_type = EDIT_COMBO;
+ name = C_ ("textattr", "Variant");
+ break;
+ case PANGO_ATTR_STRETCH:
+ edit_type = EDIT_COMBO;
+ name = C_ ("textattr", "Stretch");
+ break;
+ case PANGO_ATTR_UNDERLINE:
+ edit_type = EDIT_TOGGLE;
+ name = C_ ("textattr", "Underline");
+ break;
+ case PANGO_ATTR_STRIKETHROUGH:
+ edit_type = EDIT_TOGGLE;
+ name = C_ ("textattr", "Strikethrough");
+ break;
+ case PANGO_ATTR_GRAVITY:
+ edit_type = EDIT_COMBO;
+ name = C_ ("textattr", "Gravity");
+ break;
+ case PANGO_ATTR_GRAVITY_HINT:
+ edit_type = EDIT_COMBO;
+ name = C_ ("textattr", "Gravity Hint");
+ break;
+
+ /* PangoAttrString */
+ case PANGO_ATTR_FAMILY:
+ /* Use a simple editable text renderer ? */
+ break;
+
+ /* PangoAttrSize */
+ case PANGO_ATTR_SIZE:
+ edit_type = EDIT_SPIN;
+ name = C_ ("textattr", "Size");
+ break;
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ edit_type = EDIT_SPIN;
+ name = C_ ("textattr", "Absolute Size");
+ break;
+
+ /* PangoAttrColor */
+ /* Colours need editors... */
+ case PANGO_ATTR_FOREGROUND:
+ edit_type = EDIT_COLOR;
+ name = C_ ("textattr", "Foreground Color");
+ break;
+ case PANGO_ATTR_BACKGROUND:
+ edit_type = EDIT_COLOR;
+ name = C_ ("textattr", "Background Color");
+ break;
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ edit_type = EDIT_COLOR;
+ name = C_ ("textattr", "Underline Color");
+ break;
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ edit_type = EDIT_COLOR;
+ name = C_ ("textattr", "Strikethrough Color");
+ break;
+
+ /* PangoAttrShape */
+ case PANGO_ATTR_SHAPE:
+ /* Unsupported for now */
+ break;
+ /* PangoAttrFloat */
+ case PANGO_ATTR_SCALE:
+ edit_type = EDIT_SPIN;
+ name = C_ ("textattr", "Scale");
+ break;
+
+ case PANGO_ATTR_INVALID:
+ case PANGO_ATTR_LETTER_SPACING:
+ case PANGO_ATTR_RISE:
+ case PANGO_ATTR_FALLBACK:
+ case PANGO_ATTR_FONT_DESC:
+ default:
+ break;
+ }
+
+ if (name)
+ {
+ gtk_list_store_append (store, &iter);
+
+ gtk_list_store_set (store, &iter,
+ COLUMN_TOGGLE_ACTIVE, FALSE,
+ COLUMN_SPIN_ACTIVE, FALSE,
+ COLUMN_COMBO_ACTIVE, FALSE,
+ COLUMN_BUTTON_ACTIVE, FALSE, -1);
+
+ gtk_list_store_set (store, &iter,
+ COLUMN_NAME, name,
+ COLUMN_TYPE, type,
+ COLUMN_EDIT_TYPE, edit_type,
+ COLUMN_NAME_WEIGHT, PANGO_WEIGHT_NORMAL,
+ COLUMN_TEXT, _("<Enter Value>"),
+ COLUMN_TEXT_STYLE, PANGO_STYLE_ITALIC,
+ COLUMN_TEXT_FG, "Grey",
+ COLUMN_COMBO_MODEL, model,
+ ACTIVATE_COLUMN_FROM_TYPE (edit_type), TRUE, -1);
+ return TRUE;
+ }
+ return FALSE;
}
static gboolean
-is_empty_row (GtkTreeModel *model,
- GtkTreeIter *iter)
+is_empty_row (GtkTreeModel * model, GtkTreeIter * iter)
{
- PangoAttrType attr_type;
- AttrEditType edit_type;
- gboolean bval;
- gchar *strval = NULL;
- gboolean empty_row = FALSE;
-
- /* First get the basic values */
- gtk_tree_model_get (model, iter,
- COLUMN_TYPE, &attr_type,
- COLUMN_EDIT_TYPE, &edit_type,
- COLUMN_TOGGLE_DOWN, &bval,
- COLUMN_TEXT, &strval,
- -1);
-
- /* Ignore all other types */
- switch (edit_type)
- {
- case EDIT_TOGGLE:
- if (!bval)
- empty_row = TRUE;
- break;
- case EDIT_COMBO:
- if (!strval || !strcmp (strval, _("Unset")) || !strcmp (strval, _("<Enter Value>")))
- empty_row = TRUE;
- break;
- case EDIT_SPIN:
- /* XXX Interesting... can we get the defaults ? what can we do to let the user
- * unset the value ??
- */
- if (!strval || !strcmp (strval, "0") || !strcmp (strval, _("<Enter Value>")))
- empty_row = TRUE;
- break;
- case EDIT_COLOR:
- if (!strval || strval[0] == '\0' || !strcmp (strval, _("<Enter Value>")))
- empty_row = TRUE;
- break;
- case EDIT_INVALID:
- default:
- break;
- }
- g_free (strval);
-
- return empty_row;
+ PangoAttrType attr_type;
+ AttrEditType edit_type;
+ gboolean bval;
+ gchar *strval = NULL;
+ gboolean empty_row = FALSE;
+
+ /* First get the basic values */
+ gtk_tree_model_get (model, iter,
+ COLUMN_TYPE, &attr_type,
+ COLUMN_EDIT_TYPE, &edit_type,
+ COLUMN_TOGGLE_DOWN, &bval, COLUMN_TEXT, &strval, -1);
+
+ /* Ignore all other types */
+ switch (edit_type)
+ {
+ case EDIT_TOGGLE:
+ if (!bval)
+ empty_row = TRUE;
+ break;
+ case EDIT_COMBO:
+ if (!strval || !strcmp (strval, _("Unset")) ||
+ !strcmp (strval, _("<Enter Value>")))
+ empty_row = TRUE;
+ break;
+ case EDIT_SPIN:
+ /* XXX Interesting... can we get the defaults ? what can we do to let the user
+ * unset the value ??
+ */
+ if (!strval || !strcmp (strval, "0") ||
+ !strcmp (strval, _("<Enter Value>")))
+ empty_row = TRUE;
+ break;
+ case EDIT_COLOR:
+ if (!strval || strval[0] == '\0' ||
+ !strcmp (strval, _("<Enter Value>")))
+ empty_row = TRUE;
+ break;
+ case EDIT_INVALID:
+ default:
+ break;
+ }
+ g_free (strval);
+
+ return empty_row;
}
static GType
type_from_attr_type (PangoAttrType type)
{
- GType gtype = 0;
-
- switch (type)
- {
- case PANGO_ATTR_LANGUAGE:
- case PANGO_ATTR_FAMILY:
- return G_TYPE_STRING;
-
- case PANGO_ATTR_STYLE: return PANGO_TYPE_STYLE;
- case PANGO_ATTR_WEIGHT: return PANGO_TYPE_WEIGHT;
- case PANGO_ATTR_VARIANT: return PANGO_TYPE_VARIANT;
- case PANGO_ATTR_STRETCH: return PANGO_TYPE_STRETCH;
- case PANGO_ATTR_GRAVITY: return PANGO_TYPE_GRAVITY;
- case PANGO_ATTR_GRAVITY_HINT: return PANGO_TYPE_GRAVITY_HINT;
-
- case PANGO_ATTR_UNDERLINE:
- case PANGO_ATTR_STRIKETHROUGH:
- return G_TYPE_BOOLEAN;
-
- case PANGO_ATTR_SIZE:
- case PANGO_ATTR_ABSOLUTE_SIZE:
- return G_TYPE_INT;
-
- case PANGO_ATTR_SCALE:
- return G_TYPE_DOUBLE;
-
- /* PangoAttrColor */
- case PANGO_ATTR_FOREGROUND:
- case PANGO_ATTR_BACKGROUND:
- case PANGO_ATTR_UNDERLINE_COLOR:
- case PANGO_ATTR_STRIKETHROUGH_COLOR:
- /* boxed colours */
- return GDK_TYPE_COLOR;
-
- /* PangoAttrShape */
- case PANGO_ATTR_SHAPE:
- /* Unsupported for now */
- break;
-
- case PANGO_ATTR_INVALID:
- case PANGO_ATTR_LETTER_SPACING:
- case PANGO_ATTR_RISE:
- case PANGO_ATTR_FALLBACK:
- case PANGO_ATTR_FONT_DESC:
- default:
- break;
- }
-
-
- return gtype;
+ GType gtype = 0;
+
+ switch (type)
+ {
+ case PANGO_ATTR_LANGUAGE:
+ case PANGO_ATTR_FAMILY:
+ return G_TYPE_STRING;
+
+ case PANGO_ATTR_STYLE:
+ return PANGO_TYPE_STYLE;
+ case PANGO_ATTR_WEIGHT:
+ return PANGO_TYPE_WEIGHT;
+ case PANGO_ATTR_VARIANT:
+ return PANGO_TYPE_VARIANT;
+ case PANGO_ATTR_STRETCH:
+ return PANGO_TYPE_STRETCH;
+ case PANGO_ATTR_GRAVITY:
+ return PANGO_TYPE_GRAVITY;
+ case PANGO_ATTR_GRAVITY_HINT:
+ return PANGO_TYPE_GRAVITY_HINT;
+
+ case PANGO_ATTR_UNDERLINE:
+ case PANGO_ATTR_STRIKETHROUGH:
+ return G_TYPE_BOOLEAN;
+
+ case PANGO_ATTR_SIZE:
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ return G_TYPE_INT;
+
+ case PANGO_ATTR_SCALE:
+ return G_TYPE_DOUBLE;
+
+ /* PangoAttrColor */
+ case PANGO_ATTR_FOREGROUND:
+ case PANGO_ATTR_BACKGROUND:
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ /* boxed colours */
+ return GDK_TYPE_COLOR;
+
+ /* PangoAttrShape */
+ case PANGO_ATTR_SHAPE:
+ /* Unsupported for now */
+ break;
+
+ case PANGO_ATTR_INVALID:
+ case PANGO_ATTR_LETTER_SPACING:
+ case PANGO_ATTR_RISE:
+ case PANGO_ATTR_FALLBACK:
+ case PANGO_ATTR_FONT_DESC:
+ default:
+ break;
+ }
+
+
+ return gtype;
}
gchar *
-glade_gtk_string_from_attr (GladeAttribute *gattr)
+glade_gtk_string_from_attr (GladeAttribute * gattr)
{
- gchar *ret = NULL;
- gint ival;
- gdouble fval;
- GdkColor *color;
-
- switch (gattr->type)
- {
- case PANGO_ATTR_LANGUAGE:
- case PANGO_ATTR_FAMILY:
- ret = g_value_dup_string (&(gattr->value));
- break;
-
- case PANGO_ATTR_STYLE:
- case PANGO_ATTR_WEIGHT:
- case PANGO_ATTR_VARIANT:
- case PANGO_ATTR_STRETCH:
- case PANGO_ATTR_GRAVITY:
- case PANGO_ATTR_GRAVITY_HINT:
-
- /* Enums ... */
- ival = g_value_get_enum (&(gattr->value));
- ret = glade_utils_enum_string_from_value (G_VALUE_TYPE (&(gattr->value)), ival);
- break;
-
-
- case PANGO_ATTR_UNDERLINE:
- case PANGO_ATTR_STRIKETHROUGH:
- /* Booleans */
- if (g_value_get_boolean (&(gattr->value)))
- ret = g_strdup_printf ("True");
- else
- ret = g_strdup_printf ("False");
- break;
-
- /* PangoAttrSize */
- case PANGO_ATTR_SIZE:
- case PANGO_ATTR_ABSOLUTE_SIZE:
- /* ints */
- ival = g_value_get_int (&(gattr->value));
- ret = g_strdup_printf ("%d", ival);
- break;
-
- /* PangoAttrFloat */
- case PANGO_ATTR_SCALE:
- /* doubles */
- fval = g_value_get_double (&(gattr->value));
- ret = g_strdup_printf ("%f", fval);
- break;
-
- /* PangoAttrColor */
- case PANGO_ATTR_FOREGROUND:
- case PANGO_ATTR_BACKGROUND:
- case PANGO_ATTR_UNDERLINE_COLOR:
- case PANGO_ATTR_STRIKETHROUGH_COLOR:
- /* boxed colours */
- color = g_value_get_boxed (&(gattr->value));
- ret = gdk_color_to_string (color);
- break;
-
- /* PangoAttrShape */
- case PANGO_ATTR_SHAPE:
- /* Unsupported for now */
- break;
-
- case PANGO_ATTR_INVALID:
- case PANGO_ATTR_LETTER_SPACING:
- case PANGO_ATTR_RISE:
- case PANGO_ATTR_FALLBACK:
- case PANGO_ATTR_FONT_DESC:
- default:
- break;
- }
-
- return ret;
+ gchar *ret = NULL;
+ gint ival;
+ gdouble fval;
+ GdkColor *color;
+
+ switch (gattr->type)
+ {
+ case PANGO_ATTR_LANGUAGE:
+ case PANGO_ATTR_FAMILY:
+ ret = g_value_dup_string (&(gattr->value));
+ break;
+
+ case PANGO_ATTR_STYLE:
+ case PANGO_ATTR_WEIGHT:
+ case PANGO_ATTR_VARIANT:
+ case PANGO_ATTR_STRETCH:
+ case PANGO_ATTR_GRAVITY:
+ case PANGO_ATTR_GRAVITY_HINT:
+
+ /* Enums ... */
+ ival = g_value_get_enum (&(gattr->value));
+ ret =
+ glade_utils_enum_string_from_value (G_VALUE_TYPE (&(gattr->value)),
+ ival);
+ break;
+
+
+ case PANGO_ATTR_UNDERLINE:
+ case PANGO_ATTR_STRIKETHROUGH:
+ /* Booleans */
+ if (g_value_get_boolean (&(gattr->value)))
+ ret = g_strdup_printf ("True");
+ else
+ ret = g_strdup_printf ("False");
+ break;
+
+ /* PangoAttrSize */
+ case PANGO_ATTR_SIZE:
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ /* ints */
+ ival = g_value_get_int (&(gattr->value));
+ ret = g_strdup_printf ("%d", ival);
+ break;
+
+ /* PangoAttrFloat */
+ case PANGO_ATTR_SCALE:
+ /* doubles */
+ fval = g_value_get_double (&(gattr->value));
+ ret = g_strdup_printf ("%f", fval);
+ break;
+
+ /* PangoAttrColor */
+ case PANGO_ATTR_FOREGROUND:
+ case PANGO_ATTR_BACKGROUND:
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ /* boxed colours */
+ color = g_value_get_boxed (&(gattr->value));
+ ret = gdk_color_to_string (color);
+ break;
+
+ /* PangoAttrShape */
+ case PANGO_ATTR_SHAPE:
+ /* Unsupported for now */
+ break;
+
+ case PANGO_ATTR_INVALID:
+ case PANGO_ATTR_LETTER_SPACING:
+ case PANGO_ATTR_RISE:
+ case PANGO_ATTR_FALLBACK:
+ case PANGO_ATTR_FONT_DESC:
+ default:
+ break;
+ }
+
+ return ret;
}
static gint
-enum_value_from_string (PangoAttrType type, const gchar *strval)
+enum_value_from_string (PangoAttrType type, const gchar * strval)
{
- GEnumClass *enum_class;
- GEnumValue *enum_value;
- gint value = 0;
-
- enum_class = g_type_class_ref (type_from_attr_type (type));
- if ((enum_value = g_enum_get_value_by_nick (enum_class, strval)) != NULL)
- value = enum_value->value;
- else
- g_critical ("Couldnt find enum value for %s, type %s",
- strval, g_type_name (type_from_attr_type (type)));
-
- g_type_class_unref (enum_class);
-
- return value;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+ gint value = 0;
+
+ enum_class = g_type_class_ref (type_from_attr_type (type));
+ if ((enum_value = g_enum_get_value_by_nick (enum_class, strval)) != NULL)
+ value = enum_value->value;
+ else
+ g_critical ("Couldnt find enum value for %s, type %s",
+ strval, g_type_name (type_from_attr_type (type)));
+
+ g_type_class_unref (enum_class);
+
+ return value;
}
GladeAttribute *
-glade_gtk_attribute_from_string (PangoAttrType type,
- const gchar *strval)
+glade_gtk_attribute_from_string (PangoAttrType type, const gchar * strval)
{
- GladeAttribute *gattr;
- GdkColor color;
-
- gattr = g_new0 (GladeAttribute, 1);
- gattr->type = type;
- gattr->start = 0;
- gattr->end = G_MAXUINT;
-
- switch (type)
- {
- case PANGO_ATTR_LANGUAGE:
- case PANGO_ATTR_FAMILY:
- case PANGO_ATTR_FONT_DESC:
- g_value_init (&(gattr->value), G_TYPE_STRING);
- g_value_set_string (&(gattr->value), strval);
- break;
-
- case PANGO_ATTR_STYLE:
- case PANGO_ATTR_WEIGHT:
- case PANGO_ATTR_VARIANT:
- case PANGO_ATTR_STRETCH:
- case PANGO_ATTR_GRAVITY:
- case PANGO_ATTR_GRAVITY_HINT:
-
- /* Enums ... */
- g_value_init (&(gattr->value), type_from_attr_type (type));
- g_value_set_enum (&(gattr->value), enum_value_from_string (type, strval));
- break;
-
-
- case PANGO_ATTR_UNDERLINE:
- case PANGO_ATTR_STRIKETHROUGH:
- /* Booleans */
- g_value_init (&(gattr->value), G_TYPE_BOOLEAN);
- g_value_set_boolean (&(gattr->value), TRUE);
- break;
-
- /* PangoAttrSize */
- case PANGO_ATTR_SIZE:
- case PANGO_ATTR_ABSOLUTE_SIZE:
- /* ints */
- g_value_init (&(gattr->value), G_TYPE_INT);
- g_value_set_int (&(gattr->value), strtol (strval, NULL, 10));
- break;
-
- /* PangoAttrFloat */
- case PANGO_ATTR_SCALE:
- /* doubles */
- g_value_init (&(gattr->value), G_TYPE_DOUBLE);
- g_value_set_double (&(gattr->value), strtod (strval, NULL));
- break;
-
- /* PangoAttrColor */
- case PANGO_ATTR_FOREGROUND:
- case PANGO_ATTR_BACKGROUND:
- case PANGO_ATTR_UNDERLINE_COLOR:
- case PANGO_ATTR_STRIKETHROUGH_COLOR:
- /* boxed colours */
- if (gdk_color_parse (strval, &color))
- {
- g_value_init (&(gattr->value), GDK_TYPE_COLOR);
- g_value_set_boxed (&(gattr->value), &color);
- }
- else
- g_critical ("Unable to parse color attribute '%s'", strval);
-
- break;
-
- /* PangoAttrShape */
- case PANGO_ATTR_SHAPE:
- /* Unsupported for now */
- break;
-
- case PANGO_ATTR_INVALID:
- case PANGO_ATTR_LETTER_SPACING:
- case PANGO_ATTR_RISE:
- case PANGO_ATTR_FALLBACK:
- default:
- break;
- }
-
- return gattr;
+ GladeAttribute *gattr;
+ GdkColor color;
+
+ gattr = g_new0 (GladeAttribute, 1);
+ gattr->type = type;
+ gattr->start = 0;
+ gattr->end = G_MAXUINT;
+
+ switch (type)
+ {
+ case PANGO_ATTR_LANGUAGE:
+ case PANGO_ATTR_FAMILY:
+ case PANGO_ATTR_FONT_DESC:
+ g_value_init (&(gattr->value), G_TYPE_STRING);
+ g_value_set_string (&(gattr->value), strval);
+ break;
+
+ case PANGO_ATTR_STYLE:
+ case PANGO_ATTR_WEIGHT:
+ case PANGO_ATTR_VARIANT:
+ case PANGO_ATTR_STRETCH:
+ case PANGO_ATTR_GRAVITY:
+ case PANGO_ATTR_GRAVITY_HINT:
+
+ /* Enums ... */
+ g_value_init (&(gattr->value), type_from_attr_type (type));
+ g_value_set_enum (&(gattr->value),
+ enum_value_from_string (type, strval));
+ break;
+
+
+ case PANGO_ATTR_UNDERLINE:
+ case PANGO_ATTR_STRIKETHROUGH:
+ /* Booleans */
+ g_value_init (&(gattr->value), G_TYPE_BOOLEAN);
+ g_value_set_boolean (&(gattr->value), TRUE);
+ break;
+
+ /* PangoAttrSize */
+ case PANGO_ATTR_SIZE:
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ /* ints */
+ g_value_init (&(gattr->value), G_TYPE_INT);
+ g_value_set_int (&(gattr->value), strtol (strval, NULL, 10));
+ break;
+
+ /* PangoAttrFloat */
+ case PANGO_ATTR_SCALE:
+ /* doubles */
+ g_value_init (&(gattr->value), G_TYPE_DOUBLE);
+ g_value_set_double (&(gattr->value), strtod (strval, NULL));
+ break;
+
+ /* PangoAttrColor */
+ case PANGO_ATTR_FOREGROUND:
+ case PANGO_ATTR_BACKGROUND:
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ /* boxed colours */
+ if (gdk_color_parse (strval, &color))
+ {
+ g_value_init (&(gattr->value), GDK_TYPE_COLOR);
+ g_value_set_boxed (&(gattr->value), &color);
+ }
+ else
+ g_critical ("Unable to parse color attribute '%s'", strval);
+
+ break;
+
+ /* PangoAttrShape */
+ case PANGO_ATTR_SHAPE:
+ /* Unsupported for now */
+ break;
+
+ case PANGO_ATTR_INVALID:
+ case PANGO_ATTR_LETTER_SPACING:
+ case PANGO_ATTR_RISE:
+ case PANGO_ATTR_FALLBACK:
+ default:
+ break;
+ }
+
+ return gattr;
}
static void
-sync_object (GladeEPropAttrs *eprop_attrs,
- gboolean use_command)
+sync_object (GladeEPropAttrs * eprop_attrs, gboolean use_command)
{
- GList *attributes = NULL;
- GladeAttribute *gattr;
- GtkTreeIter iter;
- PangoAttrType type;
- AttrEditType edit_type;
- gchar *strval = NULL;
- gboolean valid;
-
- valid = gtk_tree_model_iter_children (eprop_attrs->model, &iter, NULL);
-
- while (valid)
- {
-
- if (!is_empty_row (eprop_attrs->model, &iter))
- {
- gtk_tree_model_get (eprop_attrs->model, &iter,
- COLUMN_TYPE, &type,
- COLUMN_EDIT_TYPE, &edit_type,
- COLUMN_TEXT, &strval,
- -1);
-
- gattr = glade_gtk_attribute_from_string (type, (edit_type == EDIT_TOGGLE) ? "" : strval);
- strval = (g_free (strval), NULL);
-
- attributes = g_list_prepend (attributes, gattr);
-
- }
- valid = gtk_tree_model_iter_next (eprop_attrs->model, &iter);
- }
-
- if (use_command)
- {
- GValue value = { 0, };
-
- g_value_init (&value, GLADE_TYPE_ATTR_GLIST);
- g_value_take_boxed (&value, g_list_reverse (attributes));
- glade_editor_property_commit (GLADE_EDITOR_PROPERTY (eprop_attrs), &value);
- g_value_unset (&value);
- }
- else
- {
- glade_property_set (GLADE_EDITOR_PROPERTY (eprop_attrs)->property,
- g_list_reverse (attributes));
- glade_attr_list_free (attributes);
- }
+ GList *attributes = NULL;
+ GladeAttribute *gattr;
+ GtkTreeIter iter;
+ PangoAttrType type;
+ AttrEditType edit_type;
+ gchar *strval = NULL;
+ gboolean valid;
+
+ valid = gtk_tree_model_iter_children (eprop_attrs->model, &iter, NULL);
+
+ while (valid)
+ {
+
+ if (!is_empty_row (eprop_attrs->model, &iter))
+ {
+ gtk_tree_model_get (eprop_attrs->model, &iter,
+ COLUMN_TYPE, &type,
+ COLUMN_EDIT_TYPE, &edit_type,
+ COLUMN_TEXT, &strval, -1);
+
+ gattr =
+ glade_gtk_attribute_from_string (type,
+ (edit_type ==
+ EDIT_TOGGLE) ? "" : strval);
+ strval = (g_free (strval), NULL);
+
+ attributes = g_list_prepend (attributes, gattr);
+
+ }
+ valid = gtk_tree_model_iter_next (eprop_attrs->model, &iter);
+ }
+
+ if (use_command)
+ {
+ GValue value = { 0, };
+
+ g_value_init (&value, GLADE_TYPE_ATTR_GLIST);
+ g_value_take_boxed (&value, g_list_reverse (attributes));
+ glade_editor_property_commit (GLADE_EDITOR_PROPERTY (eprop_attrs),
+ &value);
+ g_value_unset (&value);
+ }
+ else
+ {
+ glade_property_set (GLADE_EDITOR_PROPERTY (eprop_attrs)->property,
+ g_list_reverse (attributes));
+ glade_attr_list_free (attributes);
+ }
}
static GtkTreeIter *
-get_row_by_type (GtkTreeModel *model,
- PangoAttrType type)
+get_row_by_type (GtkTreeModel * model, PangoAttrType type)
{
- GtkTreeIter iter, *ret_iter = NULL;
- gboolean valid;
- PangoAttrType iter_type;
-
- valid = gtk_tree_model_iter_children (model, &iter, NULL);
-
- while (valid)
- {
- gtk_tree_model_get (model, &iter,
- COLUMN_TYPE, &iter_type,
- -1);
-
- if (iter_type == type)
- {
- ret_iter = gtk_tree_iter_copy (&iter);
- break;
- }
- valid = gtk_tree_model_iter_next (model, &iter);
- }
- return ret_iter;
+ GtkTreeIter iter, *ret_iter = NULL;
+ gboolean valid;
+ PangoAttrType iter_type;
+
+ valid = gtk_tree_model_iter_children (model, &iter, NULL);
+
+ while (valid)
+ {
+ gtk_tree_model_get (model, &iter, COLUMN_TYPE, &iter_type, -1);
+
+ if (iter_type == type)
+ {
+ ret_iter = gtk_tree_iter_copy (&iter);
+ break;
+ }
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+ return ret_iter;
}
static void
-value_icon_activate (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- GladeEPropAttrs *eprop_attrs)
+value_icon_activate (GtkCellRendererToggle * cell_renderer,
+ gchar * path, GladeEPropAttrs * eprop_attrs)
{
- GtkWidget *dialog;
- GtkWidget *colorsel;
- GtkTreeIter iter;
- PangoAttrType type;
- AttrEditType edit_type;
- GdkColor color;
- gchar *text = NULL, *new_text;
+ GtkWidget *dialog;
+ GtkWidget *colorsel;
+ GtkTreeIter iter;
+ PangoAttrType type;
+ AttrEditType edit_type;
+ GdkColor color;
+ gchar *text = NULL, *new_text;
- /* Find type etc */
- if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
- return;
+ /* Find type etc */
+ if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
+ return;
- gtk_tree_model_get (eprop_attrs->model, &iter,
- COLUMN_TEXT, &text,
- COLUMN_TYPE, &type,
- COLUMN_EDIT_TYPE, &edit_type,
- -1);
+ gtk_tree_model_get (eprop_attrs->model, &iter,
+ COLUMN_TEXT, &text,
+ COLUMN_TYPE, &type, COLUMN_EDIT_TYPE, &edit_type, -1);
- /* Launch dialog etc. */
- switch (edit_type)
- {
- case EDIT_COLOR:
- dialog = gtk_color_selection_dialog_new (_("Select a color"));
+ /* Launch dialog etc. */
+ switch (edit_type)
+ {
+ case EDIT_COLOR:
+ dialog = gtk_color_selection_dialog_new (_("Select a color"));
- colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog));
+ colorsel =
+ gtk_color_selection_dialog_get_color_selection
+ (GTK_COLOR_SELECTION_DIALOG (dialog));
- /* Get response etc... */
- if (text && gdk_color_parse (text, &color))
- gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel), &color);
+ /* Get response etc... */
+ if (text && gdk_color_parse (text, &color))
+ gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel),
+ &color);
- gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color);
+ gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel),
+ &color);
- new_text = gdk_color_to_string (&color);
+ new_text = gdk_color_to_string (&color);
- gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
- COLUMN_TEXT, new_text,
- COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL,
- COLUMN_TEXT_FG, "Black",
- -1);
- g_free (new_text);
+ gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
+ COLUMN_TEXT, new_text,
+ COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL,
+ COLUMN_TEXT_FG, "Black", -1);
+ g_free (new_text);
- gtk_widget_destroy (dialog);
- break;
- default:
- break;
- }
+ gtk_widget_destroy (dialog);
+ break;
+ default:
+ break;
+ }
- sync_object (eprop_attrs, FALSE);
+ sync_object (eprop_attrs, FALSE);
- g_free (text);
+ g_free (text);
}
static void
-value_toggled (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- GladeEPropAttrs *eprop_attrs)
+value_toggled (GtkCellRendererToggle * cell_renderer,
+ gchar * path, GladeEPropAttrs * eprop_attrs)
{
- gboolean active;
- GtkTreeIter iter;
- PangoAttrType type;
+ gboolean active;
+ GtkTreeIter iter;
+ PangoAttrType type;
- if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
- return;
+ if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
+ return;
- gtk_tree_model_get (eprop_attrs->model, &iter,
- COLUMN_TOGGLE_DOWN, &active,
- COLUMN_TYPE, &type,
- -1);
+ gtk_tree_model_get (eprop_attrs->model, &iter,
+ COLUMN_TOGGLE_DOWN, &active, COLUMN_TYPE, &type, -1);
- gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
- COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_TOGGLE_DOWN, !active,
- -1);
+ gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
+ COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_TOGGLE_DOWN, !active, -1);
- sync_object (eprop_attrs, FALSE);
+ sync_object (eprop_attrs, FALSE);
}
static void
-value_combo_spin_edited (GtkCellRendererText *cell,
- const gchar *path,
- const gchar *new_text,
- GladeEPropAttrs *eprop_attrs)
+value_combo_spin_edited (GtkCellRendererText * cell,
+ const gchar * path,
+ const gchar * new_text, GladeEPropAttrs * eprop_attrs)
{
- GtkTreeIter iter;
- PangoAttrType type;
-
- if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
- return;
-
- gtk_tree_model_get (eprop_attrs->model, &iter,
- COLUMN_TYPE, &type,
- -1);
-
- /* Reset the column */
- if (new_text && strcmp (new_text, _("None")) == 0)
- {
- gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
- COLUMN_TEXT, _("<Enter Value>"),
- COLUMN_NAME_WEIGHT, PANGO_WEIGHT_NORMAL,
- COLUMN_TEXT_STYLE, PANGO_STYLE_ITALIC,
- COLUMN_TEXT_FG, "Grey",
- -1);
- }
- else
- gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
- COLUMN_TEXT, new_text,
- COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL,
- COLUMN_TEXT_FG, "Black",
- -1);
-
- sync_object (eprop_attrs, FALSE);
+ GtkTreeIter iter;
+ PangoAttrType type;
+
+ if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
+ return;
+
+ gtk_tree_model_get (eprop_attrs->model, &iter, COLUMN_TYPE, &type, -1);
+
+ /* Reset the column */
+ if (new_text && strcmp (new_text, _("None")) == 0)
+ {
+ gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
+ COLUMN_TEXT, _("<Enter Value>"),
+ COLUMN_NAME_WEIGHT, PANGO_WEIGHT_NORMAL,
+ COLUMN_TEXT_STYLE, PANGO_STYLE_ITALIC,
+ COLUMN_TEXT_FG, "Grey", -1);
+ }
+ else
+ gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
+ COLUMN_TEXT, new_text,
+ COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL,
+ COLUMN_TEXT_FG, "Black", -1);
+
+ sync_object (eprop_attrs, FALSE);
}
static GtkWidget *
-glade_eprop_attrs_view (GladeEditorProperty *eprop)
+glade_eprop_attrs_view (GladeEditorProperty * eprop)
{
- GladeEPropAttrs *eprop_attrs = GLADE_EPROP_ATTRS (eprop);
- GtkWidget *view_widget;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- GtkAdjustment *adjustment;
-
- eprop_attrs->model = (GtkTreeModel *)gtk_list_store_new
- (NUM_COLUMNS,
- /* Main Data */
- G_TYPE_STRING, // COLUMN_NAME
- G_TYPE_INT, // COLUMN_NAME_WEIGHT
- G_TYPE_INT, // COLUMN_TYPE
- G_TYPE_INT, // COLUMN_EDIT_TYPE
- G_TYPE_POINTER, // COLUMN_VALUE
- G_TYPE_UINT, // COLUMN_START
- G_TYPE_UINT, // COLUMN_END
- /* Editor renderer related */
- G_TYPE_BOOLEAN, // COLUMN_TOGGLE_ACTIVE
- G_TYPE_BOOLEAN, // COLUMN_TOGGLE_DOWN
- G_TYPE_BOOLEAN, // COLUMN_BUTTON_ACTIVE
- G_TYPE_STRING, // COLUMN_TEXT
- G_TYPE_INT, // COLUMN_TEXT_STYLE
- G_TYPE_STRING, // COLUMN_TEXT_FG
- G_TYPE_BOOLEAN, // COLUMN_COMBO_ACTIVE
- GTK_TYPE_LIST_STORE, // COLUMN_COMBO_MODEL
- G_TYPE_BOOLEAN, // COLUMN_SPIN_ACTIVE
- G_TYPE_UINT); // COLUMN_SPIN_DIGITS
-
- view_widget = gtk_tree_view_new_with_model (eprop_attrs->model);
- gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view_widget), FALSE);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view_widget), FALSE);
-
- /********************* attribute name column *********************/
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- column = gtk_tree_view_column_new_with_attributes
- (_("Attribute"), renderer,
- "text", COLUMN_NAME,
- "weight", COLUMN_NAME_WEIGHT,
- NULL);
-
- gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
-
- /********************* attribute value column *********************/
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Value"));
-
- /* Toggle renderer */
- renderer = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "activatable", COLUMN_TOGGLE_ACTIVE,
- "visible", COLUMN_TOGGLE_ACTIVE,
- "active", COLUMN_TOGGLE_DOWN,
- NULL);
- g_signal_connect (G_OBJECT (renderer), "toggled",
- G_CALLBACK (value_toggled), eprop);
-
-
- /* Text renderer */
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "editable", COLUMN_BUTTON_ACTIVE,
- "visible", COLUMN_BUTTON_ACTIVE,
- "text", COLUMN_TEXT,
- "style", COLUMN_TEXT_STYLE,
- "foreground", COLUMN_TEXT_FG,
- NULL);
-
- /* Icon renderer */
- renderer = glade_cell_renderer_icon_new ();
- g_object_set (G_OBJECT (renderer),
- "icon-name", GTK_STOCK_EDIT,
- NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "activatable", COLUMN_BUTTON_ACTIVE,
- "visible", COLUMN_BUTTON_ACTIVE,
- NULL);
-
- g_signal_connect (G_OBJECT (renderer), "activate",
- G_CALLBACK (value_icon_activate), eprop);
-
- /* Combo renderer */
- renderer = gtk_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "text-column", 0, "has-entry", FALSE, NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "editable", COLUMN_COMBO_ACTIVE,
- "visible", COLUMN_COMBO_ACTIVE,
- "model", COLUMN_COMBO_MODEL,
- "text", COLUMN_TEXT,
- "style", COLUMN_TEXT_STYLE,
- "foreground", COLUMN_TEXT_FG,
- NULL);
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_combo_spin_edited), eprop);
-
-
- /* Spin renderer */
- renderer = gtk_cell_renderer_spin_new ();
- adjustment = (GtkAdjustment *)gtk_adjustment_new (0, -G_MAXDOUBLE, G_MAXDOUBLE, 100, 100, 100);
- g_object_set (G_OBJECT (renderer), "adjustment", adjustment, NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "visible", COLUMN_SPIN_ACTIVE,
- "editable", COLUMN_SPIN_ACTIVE,
- "text", COLUMN_TEXT,
- "style", COLUMN_TEXT_STYLE,
- "foreground", COLUMN_TEXT_FG,
- "digits", COLUMN_SPIN_DIGITS,
- NULL);
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_combo_spin_edited), eprop);
-
- gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
-
- return view_widget;
+ GladeEPropAttrs *eprop_attrs = GLADE_EPROP_ATTRS (eprop);
+ GtkWidget *view_widget;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkAdjustment *adjustment;
+
+ eprop_attrs->model = (GtkTreeModel *) gtk_list_store_new (NUM_COLUMNS,
+ /* Main Data */
+ G_TYPE_STRING, // COLUMN_NAME
+ G_TYPE_INT, // COLUMN_NAME_WEIGHT
+ G_TYPE_INT, // COLUMN_TYPE
+ G_TYPE_INT, // COLUMN_EDIT_TYPE
+ G_TYPE_POINTER, // COLUMN_VALUE
+ G_TYPE_UINT, // COLUMN_START
+ G_TYPE_UINT, // COLUMN_END
+ /* Editor renderer related */
+ G_TYPE_BOOLEAN, // COLUMN_TOGGLE_ACTIVE
+ G_TYPE_BOOLEAN, // COLUMN_TOGGLE_DOWN
+ G_TYPE_BOOLEAN, // COLUMN_BUTTON_ACTIVE
+ G_TYPE_STRING, // COLUMN_TEXT
+ G_TYPE_INT, // COLUMN_TEXT_STYLE
+ G_TYPE_STRING, // COLUMN_TEXT_FG
+ G_TYPE_BOOLEAN, // COLUMN_COMBO_ACTIVE
+ GTK_TYPE_LIST_STORE, // COLUMN_COMBO_MODEL
+ G_TYPE_BOOLEAN, // COLUMN_SPIN_ACTIVE
+ G_TYPE_UINT); // COLUMN_SPIN_DIGITS
+
+ view_widget = gtk_tree_view_new_with_model (eprop_attrs->model);
+ gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view_widget), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view_widget), FALSE);
+
+ /********************* attribute name column *********************/
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Attribute"), renderer,
+ "text", COLUMN_NAME, "weight", COLUMN_NAME_WEIGHT, NULL);
+
+ gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
+
+ /********************* attribute value column *********************/
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_title (column, _("Value"));
+
+ /* Toggle renderer */
+ renderer = gtk_cell_renderer_toggle_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "activatable", COLUMN_TOGGLE_ACTIVE,
+ "visible", COLUMN_TOGGLE_ACTIVE,
+ "active", COLUMN_TOGGLE_DOWN, NULL);
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (value_toggled), eprop);
+
+
+ /* Text renderer */
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "editable", COLUMN_BUTTON_ACTIVE,
+ "visible", COLUMN_BUTTON_ACTIVE,
+ "text", COLUMN_TEXT,
+ "style", COLUMN_TEXT_STYLE,
+ "foreground", COLUMN_TEXT_FG, NULL);
+
+ /* Icon renderer */
+ renderer = glade_cell_renderer_icon_new ();
+ g_object_set (G_OBJECT (renderer), "icon-name", GTK_STOCK_EDIT, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "activatable", COLUMN_BUTTON_ACTIVE,
+ "visible", COLUMN_BUTTON_ACTIVE, NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "activate",
+ G_CALLBACK (value_icon_activate), eprop);
+
+ /* Combo renderer */
+ renderer = gtk_cell_renderer_combo_new ();
+ g_object_set (G_OBJECT (renderer), "text-column", 0, "has-entry", FALSE,
+ NULL);
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "editable", COLUMN_COMBO_ACTIVE,
+ "visible", COLUMN_COMBO_ACTIVE,
+ "model", COLUMN_COMBO_MODEL,
+ "text", COLUMN_TEXT,
+ "style", COLUMN_TEXT_STYLE,
+ "foreground", COLUMN_TEXT_FG, NULL);
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_combo_spin_edited), eprop);
+
+
+ /* Spin renderer */
+ renderer = gtk_cell_renderer_spin_new ();
+ adjustment =
+ (GtkAdjustment *) gtk_adjustment_new (0, -G_MAXDOUBLE, G_MAXDOUBLE, 100,
+ 100, 100);
+ g_object_set (G_OBJECT (renderer), "adjustment", adjustment, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "visible", COLUMN_SPIN_ACTIVE,
+ "editable", COLUMN_SPIN_ACTIVE,
+ "text", COLUMN_TEXT,
+ "style", COLUMN_TEXT_STYLE,
+ "foreground", COLUMN_TEXT_FG,
+ "digits", COLUMN_SPIN_DIGITS, NULL);
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_combo_spin_edited), eprop);
+
+ gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);
+
+ return view_widget;
}
static void
-glade_eprop_attrs_populate_view (GladeEditorProperty *eprop,
- GtkTreeView *view)
+glade_eprop_attrs_populate_view (GladeEditorProperty * eprop,
+ GtkTreeView * view)
{
- GList *attributes, *list;
- GtkListStore *model = (GtkListStore *)gtk_tree_view_get_model (view);
- GtkTreeIter *iter;
- GladeAttribute *gattr;
- gchar *text;
-
- attributes = g_value_get_boxed (eprop->property->value);
-
- append_empty_row (model, PANGO_ATTR_LANGUAGE);
- append_empty_row (model, PANGO_ATTR_STYLE);
- append_empty_row (model, PANGO_ATTR_WEIGHT);
- append_empty_row (model, PANGO_ATTR_VARIANT);
- append_empty_row (model, PANGO_ATTR_STRETCH);
- append_empty_row (model, PANGO_ATTR_UNDERLINE);
- append_empty_row (model, PANGO_ATTR_STRIKETHROUGH);
- append_empty_row (model, PANGO_ATTR_GRAVITY);
- append_empty_row (model, PANGO_ATTR_GRAVITY_HINT);
- append_empty_row (model, PANGO_ATTR_FAMILY);
- append_empty_row (model, PANGO_ATTR_SIZE);
- append_empty_row (model, PANGO_ATTR_ABSOLUTE_SIZE);
- append_empty_row (model, PANGO_ATTR_FOREGROUND);
- append_empty_row (model, PANGO_ATTR_BACKGROUND);
- append_empty_row (model, PANGO_ATTR_UNDERLINE_COLOR);
- append_empty_row (model, PANGO_ATTR_STRIKETHROUGH_COLOR);
- append_empty_row (model, PANGO_ATTR_SHAPE);
- append_empty_row (model, PANGO_ATTR_SCALE);
-
- /* XXX Populate here ...
- */
- for (list = attributes; list; list = list->next)
- {
- gattr = list->data;
-
- if ((iter = get_row_by_type (GTK_TREE_MODEL (model), gattr->type)))
- {
- text = glade_gtk_string_from_attr (gattr);
-
- gtk_list_store_set (GTK_LIST_STORE (model), iter,
- COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
- COLUMN_TEXT, text,
- COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL,
- COLUMN_TEXT_FG, "Black",
- -1);
-
- if (gattr->type == PANGO_ATTR_UNDERLINE ||
- gattr->type == PANGO_ATTR_STRIKETHROUGH)
- gtk_list_store_set (GTK_LIST_STORE (model), iter,
- COLUMN_TOGGLE_DOWN, g_value_get_boolean (&(gattr->value)),
- -1);
-
- g_free (text);
- gtk_tree_iter_free (iter);
- }
-
- }
+ GList *attributes, *list;
+ GtkListStore *model = (GtkListStore *) gtk_tree_view_get_model (view);
+ GtkTreeIter *iter;
+ GladeAttribute *gattr;
+ gchar *text;
+
+ attributes = g_value_get_boxed (eprop->property->value);
+
+ append_empty_row (model, PANGO_ATTR_LANGUAGE);
+ append_empty_row (model, PANGO_ATTR_STYLE);
+ append_empty_row (model, PANGO_ATTR_WEIGHT);
+ append_empty_row (model, PANGO_ATTR_VARIANT);
+ append_empty_row (model, PANGO_ATTR_STRETCH);
+ append_empty_row (model, PANGO_ATTR_UNDERLINE);
+ append_empty_row (model, PANGO_ATTR_STRIKETHROUGH);
+ append_empty_row (model, PANGO_ATTR_GRAVITY);
+ append_empty_row (model, PANGO_ATTR_GRAVITY_HINT);
+ append_empty_row (model, PANGO_ATTR_FAMILY);
+ append_empty_row (model, PANGO_ATTR_SIZE);
+ append_empty_row (model, PANGO_ATTR_ABSOLUTE_SIZE);
+ append_empty_row (model, PANGO_ATTR_FOREGROUND);
+ append_empty_row (model, PANGO_ATTR_BACKGROUND);
+ append_empty_row (model, PANGO_ATTR_UNDERLINE_COLOR);
+ append_empty_row (model, PANGO_ATTR_STRIKETHROUGH_COLOR);
+ append_empty_row (model, PANGO_ATTR_SHAPE);
+ append_empty_row (model, PANGO_ATTR_SCALE);
+
+ /* XXX Populate here ...
+ */
+ for (list = attributes; list; list = list->next)
+ {
+ gattr = list->data;
+
+ if ((iter = get_row_by_type (GTK_TREE_MODEL (model), gattr->type)))
+ {
+ text = glade_gtk_string_from_attr (gattr);
+
+ gtk_list_store_set (GTK_LIST_STORE (model), iter,
+ COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD,
+ COLUMN_TEXT, text,
+ COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL,
+ COLUMN_TEXT_FG, "Black", -1);
+
+ if (gattr->type == PANGO_ATTR_UNDERLINE ||
+ gattr->type == PANGO_ATTR_STRIKETHROUGH)
+ gtk_list_store_set (GTK_LIST_STORE (model), iter,
+ COLUMN_TOGGLE_DOWN,
+ g_value_get_boolean (&(gattr->value)), -1);
+
+ g_free (text);
+ gtk_tree_iter_free (iter);
+ }
+
+ }
}
static void
-glade_eprop_attrs_show_dialog (GtkWidget *dialog_button,
- GladeEditorProperty *eprop)
+glade_eprop_attrs_show_dialog (GtkWidget * dialog_button,
+ GladeEditorProperty * eprop)
{
- GladeEPropAttrs *eprop_attrs = GLADE_EPROP_ATTRS (eprop);
- GtkWidget *dialog, *parent, *vbox, *sw, *tree_view;
- GladeProject *project;
- GList *old_attributes;
- gint res;
-
- project = glade_widget_get_project (eprop->property->widget);
- parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
-
-
- /* Keep a copy for commit time... */
- old_attributes = g_value_dup_boxed (eprop->property->value);
-
- dialog = gtk_dialog_new_with_buttons (_("Setup Text Attributes"),
- GTK_WINDOW (parent),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_widget_show (vbox);
-
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- vbox, TRUE, TRUE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (sw);
- gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
- gtk_widget_set_size_request (sw, 400, 200);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-
- tree_view = glade_eprop_attrs_view (eprop);
- glade_eprop_attrs_populate_view (eprop, GTK_TREE_VIEW (tree_view));
-
- gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
-
- gtk_widget_show (tree_view);
- gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
- /* Run the dialog */
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- if (res == GTK_RESPONSE_OK)
- {
- /* Update from old attributes so that there a property change
- * sitting on the undo stack.
- */
- glade_property_set (eprop->property, old_attributes);
- sync_object (eprop_attrs, TRUE);
- }
- else if (res == GLADE_RESPONSE_CLEAR)
- {
- GValue value = { 0, };
- g_value_init (&value, GLADE_TYPE_ATTR_GLIST);
- g_value_set_boxed (&value, NULL);
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
- }
-
- /* Clean up ...
- */
- gtk_widget_destroy (dialog);
-
- g_object_unref (G_OBJECT (eprop_attrs->model));
- eprop_attrs->model = NULL;
-
- glade_attr_list_free (old_attributes);
+ GladeEPropAttrs *eprop_attrs = GLADE_EPROP_ATTRS (eprop);
+ GtkWidget *dialog, *parent, *vbox, *sw, *tree_view;
+ GladeProject *project;
+ GList *old_attributes;
+ gint res;
+
+ project = glade_widget_get_project (eprop->property->widget);
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
+
+
+ /* Keep a copy for commit time... */
+ old_attributes = g_value_dup_boxed (eprop->property->value);
+
+ dialog = gtk_dialog_new_with_buttons (_("Setup Text Attributes"),
+ GTK_WINDOW (parent),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLEAR, GLADE_RESPONSE_CLEAR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+
+ gtk_box_pack_start (GTK_BOX
+ (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox,
+ TRUE, TRUE, 0);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (sw);
+ gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+ gtk_widget_set_size_request (sw, 400, 200);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+
+ tree_view = glade_eprop_attrs_view (eprop);
+ glade_eprop_attrs_populate_view (eprop, GTK_TREE_VIEW (tree_view));
+
+ gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view));
+
+ gtk_widget_show (tree_view);
+ gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+ /* Run the dialog */
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res == GTK_RESPONSE_OK)
+ {
+ /* Update from old attributes so that there a property change
+ * sitting on the undo stack.
+ */
+ glade_property_set (eprop->property, old_attributes);
+ sync_object (eprop_attrs, TRUE);
+ }
+ else if (res == GLADE_RESPONSE_CLEAR)
+ {
+ GValue value = { 0, };
+ g_value_init (&value, GLADE_TYPE_ATTR_GLIST);
+ g_value_set_boxed (&value, NULL);
+ glade_editor_property_commit (eprop, &value);
+ g_value_unset (&value);
+ }
+
+ /* Clean up ...
+ */
+ gtk_widget_destroy (dialog);
+
+ g_object_unref (G_OBJECT (eprop_attrs->model));
+ eprop_attrs->model = NULL;
+
+ glade_attr_list_free (old_attributes);
}
static void
-glade_eprop_attrs_finalize (GObject *object)
+glade_eprop_attrs_finalize (GObject * object)
{
- /* Chain up */
- GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
+ /* Chain up */
+ GObjectClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-glade_eprop_attrs_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_eprop_attrs_load (GladeEditorProperty * eprop, GladeProperty * property)
{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (G_OBJECT_GET_CLASS (eprop));
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (eprop));
- /* No displayable attributes in eprop, just a button. */
- parent_class->load (eprop, property);
+ /* No displayable attributes in eprop, just a button. */
+ parent_class->load (eprop, property);
}
static GtkWidget *
-glade_eprop_attrs_create_input (GladeEditorProperty *eprop)
+glade_eprop_attrs_create_input (GladeEditorProperty * eprop)
{
- GtkWidget *hbox;
- GtkWidget *button;
+ GtkWidget *hbox;
+ GtkWidget *button;
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
- button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
- gtk_widget_show (button);
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
+ button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_attrs_show_dialog),
- eprop);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_attrs_show_dialog), eprop);
- return hbox;
+ return hbox;
}
diff --git a/plugins/gtk+/glade-attributes.h b/plugins/gtk+/glade-attributes.h
old mode 100755
new mode 100644
index be1bd39..93aae06
--- a/plugins/gtk+/glade-attributes.h
+++ b/plugins/gtk+/glade-attributes.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_ATTRIBUTES_H__
#define __GLADE_ATTRIBUTES_H__
diff --git a/plugins/gtk+/glade-button-editor.c b/plugins/gtk+/glade-button-editor.c
index 53e4351..5b988c0 100644
--- a/plugins/gtk+/glade-button-editor.c
+++ b/plugins/gtk+/glade-button-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,11 +27,11 @@
#include "glade-button-editor.h"
-static void glade_button_editor_finalize (GObject *object);
+static void glade_button_editor_finalize (GObject * object);
-static void glade_button_editor_editable_init (GladeEditableIface *iface);
+static void glade_button_editor_editable_init (GladeEditableIface * iface);
-static void glade_button_editor_grab_focus (GtkWidget *widget);
+static void glade_button_editor_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeButtonEditor, glade_button_editor, GTK_TYPE_VBOX,
@@ -41,494 +40,534 @@ G_DEFINE_TYPE_WITH_CODE (GladeButtonEditor, glade_button_editor, GTK_TYPE_VBOX,
static void
-glade_button_editor_class_init (GladeButtonEditorClass *klass)
+glade_button_editor_class_init (GladeButtonEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_button_editor_finalize;
- widget_class->grab_focus = glade_button_editor_grab_focus;
+ object_class->finalize = glade_button_editor_finalize;
+ widget_class->grab_focus = glade_button_editor_grab_focus;
}
static void
-glade_button_editor_init (GladeButtonEditor *self)
+glade_button_editor_init (GladeButtonEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeButtonEditor *button_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeButtonEditor * button_editor)
{
- if (button_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (button_editor)))
- return;
+ if (button_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (button_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (button_editor), button_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-project_finalized (GladeButtonEditor *button_editor,
- GladeProject *where_project_was)
+project_finalized (GladeButtonEditor * button_editor,
+ GladeProject * where_project_was)
{
- button_editor->loaded_widget = NULL;
+ button_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (button_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (button_editor), NULL);
}
static void
-glade_button_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_button_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable);
- GladeWidget *gchild = NULL;
- GtkWidget *child, *button;
- gboolean use_stock = FALSE, use_appearance = FALSE;
- GList *l;
-
- button_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (button_editor->loaded_widget)
- {
- /* watch custom-child and use-stock properties here for reloads !!! */
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (button_editor->loaded_widget->project),
- G_CALLBACK (project_changed), button_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (button_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- button_editor);
- }
-
- /* Mark our widget... */
- button_editor->loaded_widget = widget;
-
- if (button_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (button_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), button_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (button_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- button_editor);
- }
-
- /* load the embedded editable... */
- if (button_editor->embed)
- glade_editable_load (GLADE_EDITABLE (button_editor->embed), widget);
-
- for (l = button_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
-
- if (widget)
- {
- glade_widget_property_get (widget, "use-action-appearance", &use_appearance);
-
- button = GTK_WIDGET (widget->object);
- child = gtk_bin_get_child (GTK_BIN (button));
- if (child)
- gchild = glade_widget_get_from_gobject (child);
-
- /* Setup radio and sensitivity states */
- if ((gchild && gchild->parent) || // a widget is manually inside
- GLADE_IS_PLACEHOLDER (child)) // placeholder there, custom mode
- {
- /* Custom */
- gtk_widget_set_sensitive (button_editor->standard_frame, FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->custom_radio), TRUE);
- }
- else
- {
- /* Standard */
- gtk_widget_set_sensitive (button_editor->standard_frame, TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->standard_radio), TRUE);
-
- glade_widget_property_get (widget, "use-stock", &use_stock);
-
- if (use_stock)
- {
- gtk_widget_set_sensitive (button_editor->stock_frame, TRUE);
- gtk_widget_set_sensitive (button_editor->label_frame, FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->stock_radio), TRUE);
- }
- else
- {
- gtk_widget_set_sensitive (button_editor->stock_frame, FALSE);
- gtk_widget_set_sensitive (button_editor->label_frame, TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->label_radio), TRUE);
- }
- }
-
- if (use_appearance)
- gtk_widget_set_sensitive (button_editor->custom_radio, FALSE);
- else
- gtk_widget_set_sensitive (button_editor->custom_radio, TRUE);
-
- }
- button_editor->loading = FALSE;
+ GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable);
+ GladeWidget *gchild = NULL;
+ GtkWidget *child, *button;
+ gboolean use_stock = FALSE, use_appearance = FALSE;
+ GList *l;
+
+ button_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (button_editor->loaded_widget)
+ {
+ /* watch custom-child and use-stock properties here for reloads !!! */
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (button_editor->loaded_widget->project),
+ G_CALLBACK (project_changed),
+ button_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (button_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, button_editor);
+ }
+
+ /* Mark our widget... */
+ button_editor->loaded_widget = widget;
+
+ if (button_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (button_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), button_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (button_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, button_editor);
+ }
+
+ /* load the embedded editable... */
+ if (button_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (button_editor->embed), widget);
+
+ for (l = button_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+
+ if (widget)
+ {
+ glade_widget_property_get (widget, "use-action-appearance",
+ &use_appearance);
+
+ button = GTK_WIDGET (widget->object);
+ child = gtk_bin_get_child (GTK_BIN (button));
+ if (child)
+ gchild = glade_widget_get_from_gobject (child);
+
+ /* Setup radio and sensitivity states */
+ if ((gchild && gchild->parent) || // a widget is manually inside
+ GLADE_IS_PLACEHOLDER (child)) // placeholder there, custom mode
+ {
+ /* Custom */
+ gtk_widget_set_sensitive (button_editor->standard_frame, FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->custom_radio), TRUE);
+ }
+ else
+ {
+ /* Standard */
+ gtk_widget_set_sensitive (button_editor->standard_frame, TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->standard_radio), TRUE);
+
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+
+ if (use_stock)
+ {
+ gtk_widget_set_sensitive (button_editor->stock_frame, TRUE);
+ gtk_widget_set_sensitive (button_editor->label_frame, FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->stock_radio), TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (button_editor->stock_frame, FALSE);
+ gtk_widget_set_sensitive (button_editor->label_frame, TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->label_radio), TRUE);
+ }
+ }
+
+ if (use_appearance)
+ gtk_widget_set_sensitive (button_editor->custom_radio, FALSE);
+ else
+ gtk_widget_set_sensitive (button_editor->custom_radio, TRUE);
+
+ }
+ button_editor->loading = FALSE;
}
static void
-glade_button_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_button_editor_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable);
+ GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (button_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (button_editor->embed),
+ show_name);
}
static void
-glade_button_editor_editable_init (GladeEditableIface *iface)
+glade_button_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_button_editor_load;
- iface->set_show_name = glade_button_editor_set_show_name;
+ iface->load = glade_button_editor_load;
+ iface->set_show_name = glade_button_editor_set_show_name;
}
static void
-glade_button_editor_finalize (GObject *object)
+glade_button_editor_finalize (GObject * object)
{
- GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (object);
+ GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (object);
- if (button_editor->properties)
- g_list_free (button_editor->properties);
- button_editor->properties = NULL;
- button_editor->embed = NULL;
+ if (button_editor->properties)
+ g_list_free (button_editor->properties);
+ button_editor->properties = NULL;
+ button_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_button_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_button_editor_parent_class)->finalize (object);
}
static void
-glade_button_editor_grab_focus (GtkWidget *widget)
+glade_button_editor_grab_focus (GtkWidget * widget)
{
- GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (widget);
+ GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (widget);
- gtk_widget_grab_focus (button_editor->embed);
+ gtk_widget_grab_focus (button_editor->embed);
}
/* Secion control radio button callbacks: */
static void
-standard_toggled (GtkWidget *widget,
- GladeButtonEditor *button_editor)
+standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
{
- GladeProperty *property;
- GladeWidget *gchild = NULL;
- GtkWidget *child, *button;
- GValue value = { 0, };
- gboolean use_appearance = FALSE;
-
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
-
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->standard_radio)))
- return;
-
- button_editor->modifying = TRUE;
-
- glade_command_push_group (_("Setting %s to use standard configuration"),
- button_editor->loaded_widget->name);
-
- /* If theres a widget customly inside... command remove it first... */
- button = GTK_WIDGET (button_editor->loaded_widget->object);
- child = gtk_bin_get_child (GTK_BIN (button));
- if (child)
- gchild = glade_widget_get_from_gobject (child);
-
- if (gchild && gchild->parent == button_editor->loaded_widget)
- {
- GList widgets = { 0, };
- widgets.data = gchild;
- glade_command_delete (&widgets);
- }
-
- property = glade_widget_get_property (button_editor->loaded_widget, "custom-child");
- glade_command_set_property (property, FALSE);
-
- /* Setup reasonable defaults for button label. */
- property = glade_widget_get_property (button_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
-
- property = glade_widget_get_property (button_editor->loaded_widget, "use-stock");
- glade_command_set_property (property, FALSE);
-
- glade_widget_property_get (button_editor->loaded_widget, "use-action-appearance", &use_appearance);
- if (!use_appearance)
- {
- property = glade_widget_get_property (button_editor->loaded_widget, "label");
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
- }
-
- glade_command_pop_group ();
-
- button_editor->modifying = FALSE;
-
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ GladeProperty *property;
+ GladeWidget *gchild = NULL;
+ GtkWidget *child, *button;
+ GValue value = { 0, };
+ gboolean use_appearance = FALSE;
+
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
+
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->standard_radio)))
+ return;
+
+ button_editor->modifying = TRUE;
+
+ glade_command_push_group (_("Setting %s to use standard configuration"),
+ button_editor->loaded_widget->name);
+
+ /* If theres a widget customly inside... command remove it first... */
+ button = GTK_WIDGET (button_editor->loaded_widget->object);
+ child = gtk_bin_get_child (GTK_BIN (button));
+ if (child)
+ gchild = glade_widget_get_from_gobject (child);
+
+ if (gchild && gchild->parent == button_editor->loaded_widget)
+ {
+ GList widgets = { 0, };
+ widgets.data = gchild;
+ glade_command_delete (&widgets);
+ }
+
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "custom-child");
+ glade_command_set_property (property, FALSE);
+
+ /* Setup reasonable defaults for button label. */
+ property = glade_widget_get_property (button_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
+
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "use-stock");
+ glade_command_set_property (property, FALSE);
+
+ glade_widget_property_get (button_editor->loaded_widget,
+ "use-action-appearance", &use_appearance);
+ if (!use_appearance)
+ {
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "label");
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
+ }
+
+ glade_command_pop_group ();
+
+ button_editor->modifying = FALSE;
+
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-custom_toggled (GtkWidget *widget,
- GladeButtonEditor *button_editor)
+custom_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->custom_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->custom_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a custom child"),
- button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a custom child"),
+ button_editor->loaded_widget->name);
- /* clear out some things... */
- property = glade_widget_get_property (button_editor->loaded_widget, "image");
- glade_command_set_property (property, NULL);
+ /* clear out some things... */
+ property = glade_widget_get_property (button_editor->loaded_widget, "image");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "use-stock");
- glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "use-stock");
+ glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (button_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "label");
- glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "label");
+ glade_command_set_property (property, NULL);
- /* Add a placeholder via the custom-child property... */
- property = glade_widget_get_property (button_editor->loaded_widget, "custom-child");
- glade_command_set_property (property, TRUE);
+ /* Add a placeholder via the custom-child property... */
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "custom-child");
+ glade_command_set_property (property, TRUE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-stock_toggled (GtkWidget *widget,
- GladeButtonEditor *button_editor)
+stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
{
- GladeProperty *property;
- gboolean use_appearance = FALSE;
+ GladeProperty *property;
+ gboolean use_appearance = FALSE;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->stock_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->stock_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a stock button"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a stock button"),
+ button_editor->loaded_widget->name);
- /* clear out stuff... */
- property = glade_widget_get_property (button_editor->loaded_widget, "image");
- glade_command_set_property (property, NULL);
+ /* clear out stuff... */
+ property = glade_widget_get_property (button_editor->loaded_widget, "image");
+ glade_command_set_property (property, NULL);
- glade_widget_property_get (button_editor->loaded_widget, "use-action-appearance", &use_appearance);
- if (!use_appearance)
- {
- property = glade_widget_get_property (button_editor->loaded_widget, "label");
- glade_command_set_property (property, "");
- }
+ glade_widget_property_get (button_editor->loaded_widget,
+ "use-action-appearance", &use_appearance);
+ if (!use_appearance)
+ {
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "label");
+ glade_command_set_property (property, "");
+ }
- property = glade_widget_get_property (button_editor->loaded_widget, "use-stock");
- glade_command_set_property (property, TRUE);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "use-stock");
+ glade_command_set_property (property, TRUE);
- property = glade_widget_get_property (button_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-label_toggled (GtkWidget *widget,
- GladeButtonEditor *button_editor)
+label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
{
- GladeProperty *property;
- GValue value = { 0, };
- gboolean use_appearance = FALSE;
+ GladeProperty *property;
+ GValue value = { 0, };
+ gboolean use_appearance = FALSE;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->label_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->label_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a label and image"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a label and image"),
+ button_editor->loaded_widget->name);
- property = glade_widget_get_property (button_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "use-stock");
- glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "use-stock");
+ glade_command_set_property (property, FALSE);
- glade_widget_property_get (button_editor->loaded_widget, "use-action-appearance", &use_appearance);
- if (!use_appearance)
- {
- property = glade_widget_get_property (button_editor->loaded_widget, "label");
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
- }
+ glade_widget_property_get (button_editor->loaded_widget,
+ "use-action-appearance", &use_appearance);
+ if (!use_appearance)
+ {
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "label");
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
+ }
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
GtkWidget *
-glade_button_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_button_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed)
{
- GladeButtonEditor *button_editor;
- GladeEditorProperty *eprop;
- GtkWidget *vbox, *table, *frame;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- button_editor = g_object_new (GLADE_TYPE_BUTTON_EDITOR, NULL);
- button_editor->embed = GTK_WIDGET (embed);
-
- button_editor->standard_radio = gtk_radio_button_new_with_label (NULL, _("Configure button content"));
- button_editor->custom_radio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (button_editor->standard_radio), _("Add custom button content"));
-
- button_editor->stock_radio = gtk_radio_button_new_with_label (NULL, _("Stock button"));
- button_editor->label_radio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (button_editor->stock_radio), _("Label with optional image"));
-
- g_signal_connect (G_OBJECT (button_editor->standard_radio), "toggled",
- G_CALLBACK (standard_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->custom_radio), "toggled",
- G_CALLBACK (custom_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->stock_radio), "toggled",
- G_CALLBACK (stock_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->label_radio), "toggled",
- G_CALLBACK (label_toggled), button_editor);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (button_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- /* Standard frame... */
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), button_editor->standard_radio);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (button_editor), frame, FALSE, FALSE, 8);
-
- button_editor->standard_frame = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (button_editor->standard_frame), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), button_editor->standard_frame);
-
- vbox = gtk_vbox_new (FALSE, 8);
- gtk_container_add (GTK_CONTAINER (button_editor->standard_frame), vbox);
-
- /* Populate stock frame here... */
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_frame_set_label_widget (GTK_FRAME (frame), button_editor->stock_radio);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 4);
-
- button_editor->stock_frame = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (button_editor->stock_frame), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), button_editor->stock_frame);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (button_editor->stock_frame), table);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "stock", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "image-position", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Populate label frame here... */
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_frame_set_label_widget (GTK_FRAME (frame), button_editor->label_radio);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 4);
-
- button_editor->label_frame = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (button_editor->label_frame), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), button_editor->label_frame);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (button_editor->label_frame), table);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "use-underline", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "image", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 2);
- table_attach (table, GTK_WIDGET (eprop), 1, 2);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "image-position", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 3);
- table_attach (table, GTK_WIDGET (eprop), 1, 3);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Custom radio button on the bottom */
- gtk_box_pack_start (GTK_BOX (button_editor), button_editor->custom_radio, FALSE, FALSE, 0);
-
- gtk_widget_show_all (GTK_WIDGET (button_editor));
-
- return GTK_WIDGET (button_editor);
+ GladeButtonEditor *button_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *vbox, *table, *frame;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ button_editor = g_object_new (GLADE_TYPE_BUTTON_EDITOR, NULL);
+ button_editor->embed = GTK_WIDGET (embed);
+
+ button_editor->standard_radio =
+ gtk_radio_button_new_with_label (NULL, _("Configure button content"));
+ button_editor->custom_radio =
+ gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
+ (button_editor->
+ standard_radio),
+ _
+ ("Add custom button content"));
+
+ button_editor->stock_radio =
+ gtk_radio_button_new_with_label (NULL, _("Stock button"));
+ button_editor->label_radio =
+ gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
+ (button_editor->stock_radio),
+ _
+ ("Label with optional image"));
+
+ g_signal_connect (G_OBJECT (button_editor->standard_radio), "toggled",
+ G_CALLBACK (standard_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->custom_radio), "toggled",
+ G_CALLBACK (custom_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->stock_radio), "toggled",
+ G_CALLBACK (stock_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->label_radio), "toggled",
+ G_CALLBACK (label_toggled), button_editor);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (button_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
+
+ /* Standard frame... */
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), button_editor->standard_radio);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (button_editor), frame, FALSE, FALSE, 8);
+
+ button_editor->standard_frame = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (button_editor->standard_frame), 6,
+ 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), button_editor->standard_frame);
+
+ vbox = gtk_vbox_new (FALSE, 8);
+ gtk_container_add (GTK_CONTAINER (button_editor->standard_frame), vbox);
+
+ /* Populate stock frame here... */
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), button_editor->stock_radio);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 4);
+
+ button_editor->stock_frame = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (button_editor->stock_frame), 6, 0,
+ 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), button_editor->stock_frame);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (button_editor->stock_frame), table);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "stock", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "image-position",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Populate label frame here... */
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), button_editor->label_radio);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 4);
+
+ button_editor->label_frame = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (button_editor->label_frame), 6, 0,
+ 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), button_editor->label_frame);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (button_editor->label_frame), table);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "use-underline",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "image", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 2);
+ table_attach (table, GTK_WIDGET (eprop), 1, 2);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "image-position",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 3);
+ table_attach (table, GTK_WIDGET (eprop), 1, 3);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Custom radio button on the bottom */
+ gtk_box_pack_start (GTK_BOX (button_editor), button_editor->custom_radio,
+ FALSE, FALSE, 0);
+
+ gtk_widget_show_all (GTK_WIDGET (button_editor));
+
+ return GTK_WIDGET (button_editor);
}
diff --git a/plugins/gtk+/glade-button-editor.h b/plugins/gtk+/glade-button-editor.h
index e4544ad..837c4c5 100644
--- a/plugins/gtk+/glade-button-editor.h
+++ b/plugins/gtk+/glade-button-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-cell-renderer-editor.c b/plugins/gtk+/glade-cell-renderer-editor.c
index ac7811e..9b2ac73 100644
--- a/plugins/gtk+/glade-cell-renderer-editor.c
+++ b/plugins/gtk+/glade-cell-renderer-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -29,387 +28,423 @@
#include "glade-column-types.h"
-static void glade_cell_renderer_editor_finalize (GObject *object);
+static void glade_cell_renderer_editor_finalize (GObject * object);
-static void glade_cell_renderer_editor_editable_init (GladeEditableIface *iface);
+static void glade_cell_renderer_editor_editable_init (GladeEditableIface *
+ iface);
-static void glade_cell_renderer_editor_grab_focus (GtkWidget *widget);
+static void glade_cell_renderer_editor_grab_focus (GtkWidget * widget);
-typedef struct {
- GladeCellRendererEditor *editor;
+typedef struct
+{
+ GladeCellRendererEditor *editor;
- GtkWidget *attributes_check;
- GladePropertyClass *pclass;
- GladePropertyClass *attr_pclass;
- GladePropertyClass *use_attr_pclass;
+ GtkWidget *attributes_check;
+ GladePropertyClass *pclass;
+ GladePropertyClass *attr_pclass;
+ GladePropertyClass *use_attr_pclass;
- GtkWidget *use_prop_label;
- GtkWidget *use_attr_label;
- GtkWidget *use_prop_eprop;
- GtkWidget *use_attr_eprop;
+ GtkWidget *use_prop_label;
+ GtkWidget *use_attr_label;
+ GtkWidget *use_prop_eprop;
+ GtkWidget *use_attr_eprop;
} CheckTab;
-G_DEFINE_TYPE_WITH_CODE (GladeCellRendererEditor, glade_cell_renderer_editor, GTK_TYPE_VBOX,
+G_DEFINE_TYPE_WITH_CODE (GladeCellRendererEditor, glade_cell_renderer_editor,
+ GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_cell_renderer_editor_editable_init));
static void
-glade_cell_renderer_editor_class_init (GladeCellRendererEditorClass *klass)
+glade_cell_renderer_editor_class_init (GladeCellRendererEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_cell_renderer_editor_finalize;
- widget_class->grab_focus = glade_cell_renderer_editor_grab_focus;
+ object_class->finalize = glade_cell_renderer_editor_finalize;
+ widget_class->grab_focus = glade_cell_renderer_editor_grab_focus;
}
static void
-glade_cell_renderer_editor_init (GladeCellRendererEditor *self)
+glade_cell_renderer_editor_init (GladeCellRendererEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeCellRendererEditor *renderer_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeCellRendererEditor * renderer_editor)
{
- if (renderer_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (renderer_editor)))
- return;
+ if (renderer_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (renderer_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (renderer_editor), renderer_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (renderer_editor),
+ renderer_editor->loaded_widget);
}
static void
-project_finalized (GladeCellRendererEditor *renderer_editor,
- GladeProject *where_project_was)
+project_finalized (GladeCellRendererEditor * renderer_editor,
+ GladeProject * where_project_was)
{
- renderer_editor->loaded_widget = NULL;
+ renderer_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (renderer_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (renderer_editor), NULL);
}
static void
-glade_cell_renderer_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_cell_renderer_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeCellRendererEditor *renderer_editor = GLADE_CELL_RENDERER_EDITOR (editable);
- GList *l;
-
- renderer_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (renderer_editor->loaded_widget)
- {
- g_signal_handlers_disconnect_by_func (G_OBJECT (renderer_editor->loaded_widget->project),
- G_CALLBACK (project_changed), renderer_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (renderer_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- renderer_editor);
- }
-
- /* Mark our widget... */
- renderer_editor->loaded_widget = widget;
-
- if (renderer_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (renderer_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), renderer_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (renderer_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- renderer_editor);
- }
-
- /* load the embedded editable... */
- if (renderer_editor->embed)
- glade_editable_load (GLADE_EDITABLE (renderer_editor->embed), widget);
-
- for (l = renderer_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
- if (widget)
- {
- for (l = renderer_editor->checks; l; l = l->next)
- {
- CheckTab *tab = l->data;
- gboolean use_attr = FALSE;
-
- glade_widget_property_get (widget, tab->use_attr_pclass->id, &use_attr);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tab->attributes_check), use_attr);
-
-
- if (use_attr)
- {
- // gtk_widget_show (tab->use_attr_label);
- gtk_widget_show (tab->use_attr_eprop);
- //gtk_widget_hide (tab->use_prop_label);
- gtk_widget_hide (tab->use_prop_eprop);
- }
- else
- {
- gtk_widget_show (tab->use_prop_label);
- gtk_widget_show (tab->use_prop_eprop);
- gtk_widget_hide (tab->use_attr_label);
- gtk_widget_hide (tab->use_attr_eprop);
- }
- }
- }
- renderer_editor->loading = FALSE;
+ GladeCellRendererEditor *renderer_editor =
+ GLADE_CELL_RENDERER_EDITOR (editable);
+ GList *l;
+
+ renderer_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (renderer_editor->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (renderer_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ renderer_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (renderer_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, renderer_editor);
+ }
+
+ /* Mark our widget... */
+ renderer_editor->loaded_widget = widget;
+
+ if (renderer_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (renderer_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed),
+ renderer_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (renderer_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, renderer_editor);
+ }
+
+ /* load the embedded editable... */
+ if (renderer_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (renderer_editor->embed), widget);
+
+ for (l = renderer_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+ if (widget)
+ {
+ for (l = renderer_editor->checks; l; l = l->next)
+ {
+ CheckTab *tab = l->data;
+ gboolean use_attr = FALSE;
+
+ glade_widget_property_get (widget, tab->use_attr_pclass->id,
+ &use_attr);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (tab->attributes_check), use_attr);
+
+
+ if (use_attr)
+ {
+ // gtk_widget_show (tab->use_attr_label);
+ gtk_widget_show (tab->use_attr_eprop);
+ //gtk_widget_hide (tab->use_prop_label);
+ gtk_widget_hide (tab->use_prop_eprop);
+ }
+ else
+ {
+ gtk_widget_show (tab->use_prop_label);
+ gtk_widget_show (tab->use_prop_eprop);
+ gtk_widget_hide (tab->use_attr_label);
+ gtk_widget_hide (tab->use_attr_eprop);
+ }
+ }
+ }
+ renderer_editor->loading = FALSE;
}
static void
-glade_cell_renderer_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_cell_renderer_editor_set_show_name (GladeEditable * editable,
+ gboolean show_name)
{
- GladeCellRendererEditor *renderer_editor = GLADE_CELL_RENDERER_EDITOR (editable);
+ GladeCellRendererEditor *renderer_editor =
+ GLADE_CELL_RENDERER_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (renderer_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (renderer_editor->embed),
+ show_name);
}
static void
-glade_cell_renderer_editor_editable_init (GladeEditableIface *iface)
+glade_cell_renderer_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_cell_renderer_editor_load;
- iface->set_show_name = glade_cell_renderer_editor_set_show_name;
+ iface->load = glade_cell_renderer_editor_load;
+ iface->set_show_name = glade_cell_renderer_editor_set_show_name;
}
static void
-glade_cell_renderer_editor_finalize (GObject *object)
+glade_cell_renderer_editor_finalize (GObject * object)
{
- GladeCellRendererEditor *renderer_editor = GLADE_CELL_RENDERER_EDITOR (object);
+ GladeCellRendererEditor *renderer_editor =
+ GLADE_CELL_RENDERER_EDITOR (object);
- g_list_foreach (renderer_editor->checks, (GFunc)g_free, NULL);
- g_list_free (renderer_editor->checks);
- g_list_free (renderer_editor->properties);
+ g_list_foreach (renderer_editor->checks, (GFunc) g_free, NULL);
+ g_list_free (renderer_editor->checks);
+ g_list_free (renderer_editor->properties);
- renderer_editor->properties = NULL;
- renderer_editor->checks = NULL;
- renderer_editor->embed = NULL;
+ renderer_editor->properties = NULL;
+ renderer_editor->checks = NULL;
+ renderer_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_cell_renderer_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_cell_renderer_editor_parent_class)->finalize (object);
}
static void
-glade_cell_renderer_editor_grab_focus (GtkWidget *widget)
+glade_cell_renderer_editor_grab_focus (GtkWidget * widget)
{
- GladeCellRendererEditor *renderer_editor = GLADE_CELL_RENDERER_EDITOR (widget);
+ GladeCellRendererEditor *renderer_editor =
+ GLADE_CELL_RENDERER_EDITOR (widget);
- gtk_widget_grab_focus (renderer_editor->embed);
+ gtk_widget_grab_focus (renderer_editor->embed);
}
static void
-attributes_toggled (GtkWidget *widget,
- CheckTab *tab)
+attributes_toggled (GtkWidget * widget, CheckTab * tab)
{
- GladeCellRendererEditor *renderer_editor = tab->editor;
- GladeProperty *property;
- GValue value = { 0, };
-
- if (renderer_editor->loading || !renderer_editor->loaded_widget)
- return;
-
- renderer_editor->modifying = TRUE;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tab->attributes_check)))
- {
-
- glade_command_push_group (_("Setting %s to use the %s property as an attribute"),
- renderer_editor->loaded_widget->name, tab->pclass->id);
-
-
- property = glade_widget_get_property (renderer_editor->loaded_widget, tab->pclass->id);
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
-
- property = glade_widget_get_property (renderer_editor->loaded_widget, tab->use_attr_pclass->id);
- glade_command_set_property (property, TRUE);
-
- glade_command_pop_group ();
-
-
- }
- else
- {
- glade_command_push_group (_("Setting %s to use the %s property directly"),
- renderer_editor->loaded_widget->name, tab->pclass->id);
-
-
- property = glade_widget_get_property (renderer_editor->loaded_widget, tab->attr_pclass->id);
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
-
- property = glade_widget_get_property (renderer_editor->loaded_widget, tab->use_attr_pclass->id);
- glade_command_set_property (property, FALSE);
-
- glade_command_pop_group ();
- }
- renderer_editor->modifying = FALSE;
-
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (renderer_editor),
- renderer_editor->loaded_widget);
-}
-
-static gint
-property_class_comp (gconstpointer a, gconstpointer b)
-{
- const GladePropertyClass *ca = a, *cb = b;
-
- if (ca->pspec->owner_type == cb->pspec->owner_type)
- {
- gdouble result = ca->weight - cb->weight;
- /* Avoid cast to int */
- if (result < 0.0) return -1;
- else if (result > 0.0) return 1;
- else return 0;
- }
- else
- {
- if (g_type_is_a (ca->pspec->owner_type, cb->pspec->owner_type))
- return (ca->common || ca->packing) ? 1 : -1;
- else
- return (ca->common || ca->packing) ? -1 : 1;
- }
-}
-
-static GList *
-get_sorted_properties (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
-{
- GList *l, *list = NULL;
-
- for (l = adaptor->properties; l; l = g_list_next (l))
- {
- GladePropertyClass *klass = l->data;
-
- if (GLADE_PROPERTY_CLASS_IS_TYPE (klass, type) &&
- (glade_property_class_is_visible (klass)))
- {
- list = g_list_prepend (list, klass);
- }
- }
- return g_list_sort (list, property_class_comp);
-}
-
-
-GtkWidget *
-glade_cell_renderer_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type,
- GladeEditable *embed)
-{
- GladeCellRendererEditor *renderer_editor;
- GladeEditorProperty *eprop;
- GladePropertyClass *pclass, *attr_pclass, *use_attr_pclass;
- GList *list, *sorted;
- GtkWidget *hbox_left, *hbox_right, *grid;
- gchar *str;
- gint row = 0;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+ GladeCellRendererEditor *renderer_editor = tab->editor;
+ GladeProperty *property;
+ GValue value = { 0, };
- renderer_editor = g_object_new (GLADE_TYPE_CELL_RENDERER_EDITOR, NULL);
- renderer_editor->embed = GTK_WIDGET (embed);
+ if (renderer_editor->loading || !renderer_editor->loaded_widget)
+ return;
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (renderer_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
+ renderer_editor->modifying = TRUE;
- /* Next pack in a grid for all the renderers */
- grid = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
- gtk_box_pack_start (GTK_BOX (renderer_editor), grid, FALSE, FALSE, 0);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tab->attributes_check)))
+ {
- sorted = get_sorted_properties (adaptor, type);
+ glade_command_push_group (_
+ ("Setting %s to use the %s property as an attribute"),
+ renderer_editor->loaded_widget->name,
+ tab->pclass->id);
- /* For each normal property, if we have an attr- and use-attr- counterpart, load
- * a check button property pair into the table...
- */
- for (list = sorted; list; list = list->next)
- {
- gchar *attr_name;
- gchar *use_attr_name;
- pclass = list->data;
+ property =
+ glade_widget_get_property (renderer_editor->loaded_widget,
+ tab->pclass->id);
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
- if (pclass->virt)
- continue;
+ property =
+ glade_widget_get_property (renderer_editor->loaded_widget,
+ tab->use_attr_pclass->id);
+ glade_command_set_property (property, TRUE);
- attr_name = g_strdup_printf ("attr-%s", pclass->id);
- use_attr_name = g_strdup_printf ("use-attr-%s", pclass->id);
+ glade_command_pop_group ();
- attr_pclass = glade_widget_adaptor_get_property_class (adaptor, attr_name);
- use_attr_pclass = glade_widget_adaptor_get_property_class (adaptor, use_attr_name);
- if (attr_pclass && use_attr_pclass)
- {
- CheckTab *tab = g_new0 (CheckTab, 1);
+ }
+ else
+ {
+ glade_command_push_group (_("Setting %s to use the %s property directly"),
+ renderer_editor->loaded_widget->name,
+ tab->pclass->id);
- tab->editor = renderer_editor;
- tab->pclass = pclass;
- tab->attr_pclass = attr_pclass;
- tab->use_attr_pclass = use_attr_pclass;
- /* Label appearance... */
- hbox_left = gtk_hbox_new (FALSE, 0);
- hbox_right = gtk_hbox_new (FALSE, 0);
- gtk_widget_set_hexpand (hbox_right, TRUE);
+ property =
+ glade_widget_get_property (renderer_editor->loaded_widget,
+ tab->attr_pclass->id);
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
- tab->attributes_check = gtk_check_button_new ();
- str = g_strdup_printf (_("Retrieve %s from model (type %s)"),
- pclass->name, g_type_name (pclass->pspec->value_type));
- gtk_widget_set_tooltip_text (tab->attributes_check, str);
- g_free (str);
+ property =
+ glade_widget_get_property (renderer_editor->loaded_widget,
+ tab->use_attr_pclass->id);
+ glade_command_set_property (property, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox_left), tab->attributes_check, FALSE, FALSE, 4);
+ glade_command_pop_group ();
+ }
+ renderer_editor->modifying = FALSE;
- /* Edit property */
- eprop = glade_widget_adaptor_create_eprop (adaptor, pclass, TRUE);
- gtk_box_pack_start (GTK_BOX (hbox_left), eprop->item_label, TRUE, TRUE, 4);
- gtk_box_pack_start (GTK_BOX (hbox_right), GTK_WIDGET (eprop), FALSE, FALSE, 4);
- renderer_editor->properties = g_list_prepend (renderer_editor->properties, eprop);
-
- tab->use_prop_label = eprop->item_label;
- tab->use_prop_eprop = GTK_WIDGET (eprop);
-
- /* Edit attribute */
- eprop = glade_widget_adaptor_create_eprop (adaptor, attr_pclass, TRUE);
- gtk_box_pack_start (GTK_BOX (hbox_right), GTK_WIDGET (eprop), FALSE, FALSE, 4);
- renderer_editor->properties = g_list_prepend (renderer_editor->properties, eprop);
-
- gtk_grid_attach (GTK_GRID (grid), hbox_left, 0, row, 1, 1);
- gtk_grid_attach (GTK_GRID (grid), hbox_right, 1, row++, 1, 1);
-
- tab->use_attr_label = eprop->item_label;
- tab->use_attr_eprop = GTK_WIDGET (eprop);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (renderer_editor),
+ renderer_editor->loaded_widget);
+}
- g_signal_connect (G_OBJECT (tab->attributes_check), "toggled",
- G_CALLBACK (attributes_toggled), tab);
+static gint
+property_class_comp (gconstpointer a, gconstpointer b)
+{
+ const GladePropertyClass *ca = a, *cb = b;
+
+ if (ca->pspec->owner_type == cb->pspec->owner_type)
+ {
+ gdouble result = ca->weight - cb->weight;
+ /* Avoid cast to int */
+ if (result < 0.0)
+ return -1;
+ else if (result > 0.0)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ {
+ if (g_type_is_a (ca->pspec->owner_type, cb->pspec->owner_type))
+ return (ca->common || ca->packing) ? 1 : -1;
+ else
+ return (ca->common || ca->packing) ? -1 : 1;
+ }
+}
- renderer_editor->checks = g_list_prepend (renderer_editor->checks, tab);
- }
- g_free (attr_name);
- g_free (use_attr_name);
- }
- g_list_free (sorted);
+static GList *
+get_sorted_properties (GladeWidgetAdaptor * adaptor, GladeEditorPageType type)
+{
+ GList *l, *list = NULL;
+
+ for (l = adaptor->properties; l; l = g_list_next (l))
+ {
+ GladePropertyClass *klass = l->data;
+
+ if (GLADE_PROPERTY_CLASS_IS_TYPE (klass, type) &&
+ (glade_property_class_is_visible (klass)))
+ {
+ list = g_list_prepend (list, klass);
+ }
+ }
+ return g_list_sort (list, property_class_comp);
+}
- gtk_widget_show_all (GTK_WIDGET (renderer_editor));
- return GTK_WIDGET (renderer_editor);
+GtkWidget *
+glade_cell_renderer_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type, GladeEditable * embed)
+{
+ GladeCellRendererEditor *renderer_editor;
+ GladeEditorProperty *eprop;
+ GladePropertyClass *pclass, *attr_pclass, *use_attr_pclass;
+ GList *list, *sorted;
+ GtkWidget *hbox_left, *hbox_right, *grid;
+ gchar *str;
+ gint row = 0;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ renderer_editor = g_object_new (GLADE_TYPE_CELL_RENDERER_EDITOR, NULL);
+ renderer_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (renderer_editor), GTK_WIDGET (embed), FALSE,
+ FALSE, 0);
+
+ /* Next pack in a grid for all the renderers */
+ grid = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (grid),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
+ gtk_box_pack_start (GTK_BOX (renderer_editor), grid, FALSE, FALSE, 0);
+
+ sorted = get_sorted_properties (adaptor, type);
+
+ /* For each normal property, if we have an attr- and use-attr- counterpart, load
+ * a check button property pair into the table...
+ */
+ for (list = sorted; list; list = list->next)
+ {
+ gchar *attr_name;
+ gchar *use_attr_name;
+
+ pclass = list->data;
+
+ if (pclass->virt)
+ continue;
+
+ attr_name = g_strdup_printf ("attr-%s", pclass->id);
+ use_attr_name = g_strdup_printf ("use-attr-%s", pclass->id);
+
+ attr_pclass =
+ glade_widget_adaptor_get_property_class (adaptor, attr_name);
+ use_attr_pclass =
+ glade_widget_adaptor_get_property_class (adaptor, use_attr_name);
+
+ if (attr_pclass && use_attr_pclass)
+ {
+ CheckTab *tab = g_new0 (CheckTab, 1);
+
+ tab->editor = renderer_editor;
+ tab->pclass = pclass;
+ tab->attr_pclass = attr_pclass;
+ tab->use_attr_pclass = use_attr_pclass;
+
+ /* Label appearance... */
+ hbox_left = gtk_hbox_new (FALSE, 0);
+ hbox_right = gtk_hbox_new (FALSE, 0);
+ gtk_widget_set_hexpand (hbox_right, TRUE);
+
+ tab->attributes_check = gtk_check_button_new ();
+ str = g_strdup_printf (_("Retrieve %s from model (type %s)"),
+ pclass->name,
+ g_type_name (pclass->pspec->value_type));
+ gtk_widget_set_tooltip_text (tab->attributes_check, str);
+ g_free (str);
+
+ gtk_box_pack_start (GTK_BOX (hbox_left), tab->attributes_check, FALSE,
+ FALSE, 4);
+
+ /* Edit property */
+ eprop = glade_widget_adaptor_create_eprop (adaptor, pclass, TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox_left), eprop->item_label, TRUE,
+ TRUE, 4);
+ gtk_box_pack_start (GTK_BOX (hbox_right), GTK_WIDGET (eprop), FALSE,
+ FALSE, 4);
+ renderer_editor->properties =
+ g_list_prepend (renderer_editor->properties, eprop);
+
+ tab->use_prop_label = eprop->item_label;
+ tab->use_prop_eprop = GTK_WIDGET (eprop);
+
+ /* Edit attribute */
+ eprop =
+ glade_widget_adaptor_create_eprop (adaptor, attr_pclass, TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox_right), GTK_WIDGET (eprop), FALSE,
+ FALSE, 4);
+ renderer_editor->properties =
+ g_list_prepend (renderer_editor->properties, eprop);
+
+ gtk_grid_attach (GTK_GRID (grid), hbox_left, 0, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), hbox_right, 1, row++, 1, 1);
+
+ tab->use_attr_label = eprop->item_label;
+ tab->use_attr_eprop = GTK_WIDGET (eprop);
+
+ g_signal_connect (G_OBJECT (tab->attributes_check), "toggled",
+ G_CALLBACK (attributes_toggled), tab);
+
+ renderer_editor->checks =
+ g_list_prepend (renderer_editor->checks, tab);
+ }
+ g_free (attr_name);
+ g_free (use_attr_name);
+ }
+ g_list_free (sorted);
+
+ gtk_widget_show_all (GTK_WIDGET (renderer_editor));
+
+ return GTK_WIDGET (renderer_editor);
}
/***************************************************************************
@@ -417,12 +452,12 @@ glade_cell_renderer_editor_new (GladeWidgetAdaptor *adaptor,
***************************************************************************/
typedef struct
{
- GladeEditorProperty parent_instance;
+ GladeEditorProperty parent_instance;
- GtkTreeModel *columns;
+ GtkTreeModel *columns;
- GtkWidget *spin;
- GtkWidget *combo;
+ GtkWidget *spin;
+ GtkWidget *combo;
} GladeEPropCellAttribute;
GLADE_MAKE_EPROP (GladeEPropCellAttribute, glade_eprop_cell_attribute)
@@ -431,186 +466,188 @@ GLADE_MAKE_EPROP (GladeEPropCellAttribute, glade_eprop_cell_attribute)
#define GLADE_IS_EPROP_CELL_ATTRIBUTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_CELL_ATTRIBUTE))
#define GLADE_IS_EPROP_CELL_ATTRIBUTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_CELL_ATTRIBUTE))
#define GLADE_EPROP_CELL_ATTRIBUTE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_CELL_ATTRIBUTE, GladeEPropCellAttributeClass))
-
-static void
-glade_eprop_cell_attribute_finalize (GObject *object)
+ static void glade_eprop_cell_attribute_finalize (GObject * object)
{
- /* Chain up */
- GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
- //GladeEPropCellAttribute *eprop_attribute = GLADE_EPROP_CELL_ATTRIBUTE (object);
+ /* Chain up */
+ GObjectClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
+ //GladeEPropCellAttribute *eprop_attribute = GLADE_EPROP_CELL_ATTRIBUTE (object);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
GladeWidget *
-glade_cell_renderer_get_model (GladeWidget *renderer)
+glade_cell_renderer_get_model (GladeWidget * renderer)
{
- GladeWidget *model = NULL;
-
- /* Keep inline with all new cell layouts !!! */
- if (renderer->parent && GTK_IS_TREE_VIEW_COLUMN (renderer->parent->object))
- {
- GladeWidget *column = renderer->parent;
-
- if (column->parent && GTK_IS_TREE_VIEW (column->parent->object))
- {
- GladeWidget *view = column->parent;
- GtkTreeModel *real_model = NULL;
- glade_widget_property_get (view, "model", &real_model);
- if (real_model)
- model = glade_widget_get_from_gobject (real_model);
- }
- }
- else if (renderer->parent && GTK_IS_ICON_VIEW (renderer->parent->object))
- {
- GladeWidget *view = renderer->parent;
- GtkTreeModel *real_model = NULL;
- glade_widget_property_get (view, "model", &real_model);
- if (real_model)
- model = glade_widget_get_from_gobject (real_model);
- }
- else if (renderer->parent && GTK_IS_COMBO_BOX (renderer->parent->object))
- {
- GladeWidget *combo = renderer->parent;
- GtkTreeModel *real_model = NULL;
- glade_widget_property_get (combo, "model", &real_model);
- if (real_model)
- model = glade_widget_get_from_gobject (real_model);
- }
-
- return model;
+ GladeWidget *model = NULL;
+
+ /* Keep inline with all new cell layouts !!! */
+ if (renderer->parent && GTK_IS_TREE_VIEW_COLUMN (renderer->parent->object))
+ {
+ GladeWidget *column = renderer->parent;
+
+ if (column->parent && GTK_IS_TREE_VIEW (column->parent->object))
+ {
+ GladeWidget *view = column->parent;
+ GtkTreeModel *real_model = NULL;
+ glade_widget_property_get (view, "model", &real_model);
+ if (real_model)
+ model = glade_widget_get_from_gobject (real_model);
+ }
+ }
+ else if (renderer->parent && GTK_IS_ICON_VIEW (renderer->parent->object))
+ {
+ GladeWidget *view = renderer->parent;
+ GtkTreeModel *real_model = NULL;
+ glade_widget_property_get (view, "model", &real_model);
+ if (real_model)
+ model = glade_widget_get_from_gobject (real_model);
+ }
+ else if (renderer->parent && GTK_IS_COMBO_BOX (renderer->parent->object))
+ {
+ GladeWidget *combo = renderer->parent;
+ GtkTreeModel *real_model = NULL;
+ glade_widget_property_get (combo, "model", &real_model);
+ if (real_model)
+ model = glade_widget_get_from_gobject (real_model);
+ }
+
+ return model;
}
static void
-glade_eprop_cell_attribute_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_eprop_cell_attribute_load (GladeEditorProperty * eprop,
+ GladeProperty * property)
{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- GladeEPropCellAttribute *eprop_attribute = GLADE_EPROP_CELL_ATTRIBUTE (eprop);
-
- /* Chain up in a clean state... */
- parent_class->load (eprop, property);
-
- if (property)
- {
- GladeWidget *gmodel;
- GtkListStore *store = GTK_LIST_STORE (eprop_attribute->columns);
- GtkTreeIter iter;
-
- gtk_list_store_clear (store);
-
- /* Generate model and set active iter */
- if ((gmodel = glade_cell_renderer_get_model (property->widget)) != NULL)
- {
- GList *columns = NULL, *l;
-
- glade_widget_property_get (gmodel, "columns", &columns);
-
- gtk_list_store_append (store, &iter);
- /* translators: the adjective not the verb */
- gtk_list_store_set (store, &iter, 0, _("unset"), -1);
-
- for (l = columns; l; l = l->next)
- {
- GladeColumnType *column = l->data;
- gchar *str = g_strdup_printf ("%s - %s", column->column_name,
- column->type_name);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, str, -1);
-
- g_free (str);
- }
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_attribute->combo),
- CLAMP (g_value_get_int (property->value) + 1,
- 0, g_list_length (columns) + 1));
-
- gtk_widget_set_sensitive (eprop_attribute->combo, TRUE);
- }
- else
- {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, _("no model"), -1);
- gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_attribute->combo), 0);
- gtk_widget_set_sensitive (eprop_attribute->combo, FALSE);
- }
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_attribute->spin),
- (gdouble)g_value_get_int (property->value));
- }
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ GladeEPropCellAttribute *eprop_attribute = GLADE_EPROP_CELL_ATTRIBUTE (eprop);
+
+ /* Chain up in a clean state... */
+ parent_class->load (eprop, property);
+
+ if (property)
+ {
+ GladeWidget *gmodel;
+ GtkListStore *store = GTK_LIST_STORE (eprop_attribute->columns);
+ GtkTreeIter iter;
+
+ gtk_list_store_clear (store);
+
+ /* Generate model and set active iter */
+ if ((gmodel = glade_cell_renderer_get_model (property->widget)) != NULL)
+ {
+ GList *columns = NULL, *l;
+
+ glade_widget_property_get (gmodel, "columns", &columns);
+
+ gtk_list_store_append (store, &iter);
+ /* translators: the adjective not the verb */
+ gtk_list_store_set (store, &iter, 0, _("unset"), -1);
+
+ for (l = columns; l; l = l->next)
+ {
+ GladeColumnType *column = l->data;
+ gchar *str = g_strdup_printf ("%s - %s", column->column_name,
+ column->type_name);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, str, -1);
+
+ g_free (str);
+ }
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_attribute->combo),
+ CLAMP (g_value_get_int (property->value) +
+ 1, 0, g_list_length (columns) + 1));
+
+ gtk_widget_set_sensitive (eprop_attribute->combo, TRUE);
+ }
+ else
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("no model"), -1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (eprop_attribute->combo), 0);
+ gtk_widget_set_sensitive (eprop_attribute->combo, FALSE);
+ }
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_attribute->spin),
+ (gdouble) g_value_get_int (property->value));
+ }
}
static void
-combo_changed (GtkWidget *combo,
- GladeEditorProperty *eprop)
+combo_changed (GtkWidget * combo, GladeEditorProperty * eprop)
{
- GValue val = { 0, };
+ GValue val = { 0, };
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, (gint)gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) - 1);
- glade_editor_property_commit (eprop, &val);
- g_value_unset (&val);
+ g_value_init (&val, G_TYPE_INT);
+ g_value_set_int (&val,
+ (gint) gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) - 1);
+ glade_editor_property_commit (eprop, &val);
+ g_value_unset (&val);
}
static void
-spin_changed (GtkWidget *spin,
- GladeEditorProperty *eprop)
+spin_changed (GtkWidget * spin, GladeEditorProperty * eprop)
{
- GValue val = { 0, };
+ GValue val = { 0, };
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- g_value_init (&val, G_TYPE_INT);
- g_value_set_int (&val, gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin)));
- glade_editor_property_commit (eprop, &val);
- g_value_unset (&val);
+ g_value_init (&val, G_TYPE_INT);
+ g_value_set_int (&val, gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin)));
+ glade_editor_property_commit (eprop, &val);
+ g_value_unset (&val);
}
static GtkWidget *
-glade_eprop_cell_attribute_create_input (GladeEditorProperty *eprop)
+glade_eprop_cell_attribute_create_input (GladeEditorProperty * eprop)
{
- GladeEPropCellAttribute *eprop_attribute = GLADE_EPROP_CELL_ATTRIBUTE (eprop);
- GtkWidget *hbox;
- GtkAdjustment *adjustment;
- GtkCellRenderer *cell;
+ GladeEPropCellAttribute *eprop_attribute = GLADE_EPROP_CELL_ATTRIBUTE (eprop);
+ GtkWidget *hbox;
+ GtkAdjustment *adjustment;
+ GtkCellRenderer *cell;
- hbox = gtk_hbox_new (FALSE, 2);
+ hbox = gtk_hbox_new (FALSE, 2);
- adjustment = glade_property_class_make_adjustment (eprop->klass);
- eprop_attribute->spin = gtk_spin_button_new (adjustment, 1.0, 0);
+ adjustment = glade_property_class_make_adjustment (eprop->klass);
+ eprop_attribute->spin = gtk_spin_button_new (adjustment, 1.0, 0);
- eprop_attribute->columns = (GtkTreeModel *)gtk_list_store_new (1, G_TYPE_STRING);
- eprop_attribute->combo = gtk_combo_box_new_with_model (eprop_attribute->columns);
+ eprop_attribute->columns =
+ (GtkTreeModel *) gtk_list_store_new (1, G_TYPE_STRING);
+ eprop_attribute->combo =
+ gtk_combo_box_new_with_model (eprop_attribute->columns);
- gtk_combo_box_set_popup_fixed_width (GTK_COMBO_BOX (eprop_attribute->combo), FALSE);
+ gtk_combo_box_set_popup_fixed_width (GTK_COMBO_BOX (eprop_attribute->combo),
+ FALSE);
- /* Add cell renderer */
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell,
- "xpad", 0,
- "xalign", 0.0F,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width-chars", 10,
- NULL);
+ /* Add cell renderer */
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell,
+ "xpad", 0,
+ "xalign", 0.0F,
+ "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 10, NULL);
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (eprop_attribute->combo));
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (eprop_attribute->combo));
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (eprop_attribute->combo), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (eprop_attribute->combo), cell,
- "text", 0, NULL);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (eprop_attribute->combo), cell,
+ TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (eprop_attribute->combo),
+ cell, "text", 0, NULL);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_attribute->spin, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), eprop_attribute->combo, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_attribute->spin, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_attribute->combo, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (eprop_attribute->combo), "changed",
- G_CALLBACK (combo_changed), eprop);
- g_signal_connect (G_OBJECT (eprop_attribute->spin), "value-changed",
- G_CALLBACK (spin_changed), eprop);
+ g_signal_connect (G_OBJECT (eprop_attribute->combo), "changed",
+ G_CALLBACK (combo_changed), eprop);
+ g_signal_connect (G_OBJECT (eprop_attribute->spin), "value-changed",
+ G_CALLBACK (spin_changed), eprop);
- return hbox;
+ return hbox;
}
diff --git a/plugins/gtk+/glade-cell-renderer-editor.h b/plugins/gtk+/glade-cell-renderer-editor.h
index 5d96349..da9f842 100644
--- a/plugins/gtk+/glade-cell-renderer-editor.h
+++ b/plugins/gtk+/glade-cell-renderer-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-column-types.c b/plugins/gtk+/glade-column-types.c
index 3d884b0..6ddd1c6 100644
--- a/plugins/gtk+/glade-column-types.c
+++ b/plugins/gtk+/glade-column-types.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Juan Pablo Ugarte.
*
@@ -34,205 +33,214 @@
enum
{
- COLUMN_NAME,
- COLUMN_COLUMN_NAME,
- COLUMN_TYPE_EDITABLE,
- COLUMN_NAME_EDITABLE,
- COLUMN_TYPE_FOREGROUND,
- COLUMN_TYPE_STYLE,
- N_COLUMNS
+ COLUMN_NAME,
+ COLUMN_COLUMN_NAME,
+ COLUMN_TYPE_EDITABLE,
+ COLUMN_NAME_EDITABLE,
+ COLUMN_TYPE_FOREGROUND,
+ COLUMN_TYPE_STYLE,
+ N_COLUMNS
};
static GtkTreeModel *types_model = NULL;
-static gint
-find_by_type_name (const gchar *a, const gchar *b)
+static gint
+find_by_type_name (const gchar * a, const gchar * b)
{
- return strcmp (a, b);
+ return strcmp (a, b);
}
static void
-column_types_store_populate_enums_flags (GtkListStore *store,
- gboolean enums)
-{
- GtkTreeIter iter;
- GList *types = NULL, *list, *l;
- GList *adaptors = glade_widget_adaptor_list_adaptors ();
-
- for (list = adaptors; list; list = list->next)
- {
- GladeWidgetAdaptor *adaptor = list->data;
- GladePropertyClass *pclass;
-
- for (l = adaptor->properties; l; l = l->next)
- {
- pclass = l->data;
-
- /* special case out a few of these... */
- if (strcmp (g_type_name (pclass->pspec->value_type), "GladeGtkGnomeUIInfo") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeStock") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeStockImage") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeGtkImageType") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeGtkButtonType") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeGnomeDruidPagePosition") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeGnomeIconListSelectionMode") == 0 ||
- strcmp (g_type_name (pclass->pspec->value_type), "GladeGnomeMessageBoxType") == 0)
- continue;
-
- if ((enums ? G_TYPE_IS_ENUM (pclass->pspec->value_type) :
- G_TYPE_IS_FLAGS (pclass->pspec->value_type)) &&
- !g_list_find_custom (types, g_type_name (pclass->pspec->value_type),
- (GCompareFunc)find_by_type_name))
- types = g_list_prepend (types, g_strdup (g_type_name (pclass->pspec->value_type)));
-
- }
- }
- g_list_free (adaptors);
-
- types = g_list_sort (types, (GCompareFunc)find_by_type_name);
-
- for (l = types; l; l = l->next)
- {
- gchar *type_name = l->data;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COLUMN_NAME, type_name,
- -1);
- g_free (type_name);
- }
- g_list_free (types);
+column_types_store_populate_enums_flags (GtkListStore * store, gboolean enums)
+{
+ GtkTreeIter iter;
+ GList *types = NULL, *list, *l;
+ GList *adaptors = glade_widget_adaptor_list_adaptors ();
+
+ for (list = adaptors; list; list = list->next)
+ {
+ GladeWidgetAdaptor *adaptor = list->data;
+ GladePropertyClass *pclass;
+
+ for (l = adaptor->properties; l; l = l->next)
+ {
+ pclass = l->data;
+
+ /* special case out a few of these... */
+ if (strcmp
+ (g_type_name (pclass->pspec->value_type),
+ "GladeGtkGnomeUIInfo") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeStock") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeStockImage") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeGtkImageType") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeGtkButtonType") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeGnomeDruidPagePosition") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeGnomeIconListSelectionMode") == 0 ||
+ strcmp (g_type_name (pclass->pspec->value_type),
+ "GladeGnomeMessageBoxType") == 0)
+ continue;
+
+ if ((enums ? G_TYPE_IS_ENUM (pclass->pspec->value_type) :
+ G_TYPE_IS_FLAGS (pclass->pspec->value_type)) &&
+ !g_list_find_custom (types,
+ g_type_name (pclass->pspec->value_type),
+ (GCompareFunc) find_by_type_name))
+ types =
+ g_list_prepend (types,
+ g_strdup (g_type_name
+ (pclass->pspec->value_type)));
+
+ }
+ }
+ g_list_free (adaptors);
+
+ types = g_list_sort (types, (GCompareFunc) find_by_type_name);
+
+ for (l = types; l; l = l->next)
+ {
+ gchar *type_name = l->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, COLUMN_NAME, type_name, -1);
+ g_free (type_name);
+ }
+ g_list_free (types);
}
static void
-column_types_store_populate (GtkListStore *store)
-{
- GtkTreeIter iter;
- gint i;
- GType types[] = {
- G_TYPE_CHAR,
- G_TYPE_UCHAR,
- G_TYPE_BOOLEAN,
- G_TYPE_INT,
- G_TYPE_UINT,
- G_TYPE_LONG,
- G_TYPE_ULONG,
- G_TYPE_INT64,
- G_TYPE_UINT64,
- G_TYPE_FLOAT,
- G_TYPE_DOUBLE,
- G_TYPE_STRING,
- G_TYPE_POINTER,
- G_TYPE_OBJECT,
- GDK_TYPE_PIXBUF};
-
- for (i = 0; i < sizeof (types) / sizeof (GType); i++)
- {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COLUMN_NAME, g_type_name (types[i]),
- -1);
- }
-
- column_types_store_populate_enums_flags (store, TRUE);
- column_types_store_populate_enums_flags (store, FALSE);
+column_types_store_populate (GtkListStore * store)
+{
+ GtkTreeIter iter;
+ gint i;
+ GType types[] = {
+ G_TYPE_CHAR,
+ G_TYPE_UCHAR,
+ G_TYPE_BOOLEAN,
+ G_TYPE_INT,
+ G_TYPE_UINT,
+ G_TYPE_LONG,
+ G_TYPE_ULONG,
+ G_TYPE_INT64,
+ G_TYPE_UINT64,
+ G_TYPE_FLOAT,
+ G_TYPE_DOUBLE,
+ G_TYPE_STRING,
+ G_TYPE_POINTER,
+ G_TYPE_OBJECT,
+ GDK_TYPE_PIXBUF
+ };
+
+ for (i = 0; i < sizeof (types) / sizeof (GType); i++)
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COLUMN_NAME, g_type_name (types[i]), -1);
+ }
+
+ column_types_store_populate_enums_flags (store, TRUE);
+ column_types_store_populate_enums_flags (store, FALSE);
}
GList *
-glade_column_list_copy (GList *list)
-{
- GList *l, *retval = NULL;
-
- for (l = list; l; l = g_list_next (l))
- {
- GladeColumnType *data = l->data;
- GladeColumnType *new_data =
- glade_column_type_new (data->type_name, data->column_name);
-
- retval = g_list_prepend (retval, new_data);
- }
-
- return g_list_reverse (retval);
+glade_column_list_copy (GList * list)
+{
+ GList *l, *retval = NULL;
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GladeColumnType *data = l->data;
+ GladeColumnType *new_data =
+ glade_column_type_new (data->type_name, data->column_name);
+
+ retval = g_list_prepend (retval, new_data);
+ }
+
+ return g_list_reverse (retval);
}
GladeColumnType *
-glade_column_type_new (const gchar *type_name,
- const gchar *column_name)
+glade_column_type_new (const gchar * type_name, const gchar * column_name)
{
- GladeColumnType *column = g_slice_new0 (GladeColumnType);
+ GladeColumnType *column = g_slice_new0 (GladeColumnType);
- column->type_name = g_strdup (type_name);
- column->column_name = g_strdup (column_name);
+ column->type_name = g_strdup (type_name);
+ column->column_name = g_strdup (column_name);
- return column;
+ return column;
}
void
-glade_column_type_free (GladeColumnType *column)
+glade_column_type_free (GladeColumnType * column)
{
- g_free (column->type_name);
- g_free (column->column_name);
- g_slice_free (GladeColumnType, column);
+ g_free (column->type_name);
+ g_free (column->column_name);
+ g_slice_free (GladeColumnType, column);
}
void
-glade_column_list_free (GList *list)
+glade_column_list_free (GList * list)
{
- g_list_foreach (list, (GFunc)glade_column_type_free, NULL);
- g_list_free (list);
+ g_list_foreach (list, (GFunc) glade_column_type_free, NULL);
+ g_list_free (list);
}
GladeColumnType *
-glade_column_list_find_column (GList *list, const gchar *column_name)
-{
- GladeColumnType *column = NULL, *iter;
- GList *l;
-
- for (l = g_list_first (list); l; l = l->next)
- {
- iter = l->data;
- if (strcmp (column_name, iter->column_name) == 0)
- {
- column = iter;
- break;
- }
- }
-
- return column;
+glade_column_list_find_column (GList * list, const gchar * column_name)
+{
+ GladeColumnType *column = NULL, *iter;
+ GList *l;
+
+ for (l = g_list_first (list); l; l = l->next)
+ {
+ iter = l->data;
+ if (strcmp (column_name, iter->column_name) == 0)
+ {
+ column = iter;
+ break;
+ }
+ }
+
+ return column;
}
GType
glade_column_type_list_get_type (void)
{
- static GType type_id = 0;
+ static GType type_id = 0;
- if (!type_id)
- {
- type_id = g_boxed_type_register_static
- ("GladeColumnTypeList",
- (GBoxedCopyFunc) glade_column_list_copy,
- (GBoxedFreeFunc) glade_column_list_free);
- }
- return type_id;
+ if (!type_id)
+ {
+ type_id = g_boxed_type_register_static
+ ("GladeColumnTypeList",
+ (GBoxedCopyFunc) glade_column_list_copy,
+ (GBoxedFreeFunc) glade_column_list_free);
+ }
+ return type_id;
}
/**************************** GladeEditorProperty *****************************/
typedef struct
{
- GladeEditorProperty parent_instance;
+ GladeEditorProperty parent_instance;
- GtkListStore *store;
- GtkTreeView *view;
- GtkTreeSelection *selection;
+ GtkListStore *store;
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
- GladeNameContext *context;
+ GladeNameContext *context;
- gboolean adding_column;
- gboolean want_focus;
- gboolean setting_cursor;
+ gboolean adding_column;
+ gboolean want_focus;
+ gboolean setting_cursor;
- GtkTreeViewColumn *name_column;
- GtkTreeViewColumn *type_column;
+ GtkTreeViewColumn *name_column;
+ GtkTreeViewColumn *type_column;
} GladeEPropColumnTypes;
GLADE_MAKE_EPROP (GladeEPropColumnTypes, glade_eprop_column_types)
@@ -241,641 +249,647 @@ GLADE_MAKE_EPROP (GladeEPropColumnTypes, glade_eprop_column_types)
#define GLADE_IS_EPROP_COLUMN_TYPES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_COLUMN_TYPES))
#define GLADE_IS_EPROP_COLUMN_TYPES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_COLUMN_TYPES))
#define GLADE_EPROP_COLUMN_TYPES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_COLUMN_TYPES, GladeEPropColumnTypesClass))
-
-static void
-glade_eprop_column_types_finalize (GObject *object)
+ static void glade_eprop_column_types_finalize (GObject * object)
{
- /* Chain up */
- GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
+ /* Chain up */
+ GObjectClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gint
-get_extra_column (GNode *data_tree, GList *columns)
+get_extra_column (GNode * data_tree, GList * columns)
{
- GladeModelData *data;
- GNode *iter;
- gint idx = -1;
+ GladeModelData *data;
+ GNode *iter;
+ gint idx = -1;
- /* extra columns trail at the end so walk backwards... */
- for (iter = g_node_last_child (data_tree->children); iter; iter = iter->prev)
- {
- data = iter->data;
+ /* extra columns trail at the end so walk backwards... */
+ for (iter = g_node_last_child (data_tree->children); iter; iter = iter->prev)
+ {
+ data = iter->data;
- if (!glade_column_list_find_column (columns, data->name))
- {
- idx = g_node_child_position (data_tree->children, iter);
- break;
- }
+ if (!glade_column_list_find_column (columns, data->name))
+ {
+ idx = g_node_child_position (data_tree->children, iter);
+ break;
+ }
- }
- return idx;
+ }
+ return idx;
}
static void
-eprop_column_adjust_rows (GladeEditorProperty *eprop, GList *columns)
-{
- GladeColumnType *column;
- GNode *data_tree = NULL;
- GladeWidget *widget = eprop->property->widget;
- GList *list;
- GladeProperty *property;
- gint idx;
-
- property = glade_widget_get_property (widget, "data");
- glade_property_get (property, &data_tree);
- if (!data_tree)
- return;
- data_tree = glade_model_data_tree_copy (data_tree);
-
- /* Add mising columns and reorder... */
- for (list = g_list_last (columns); list; list = list->prev)
- {
- GType data_type;
-
- column = list->data;
-
- data_type = g_type_from_name (column->type_name);
-
- if ((idx = glade_model_data_column_index (data_tree, column->column_name)) < 0)
- {
- glade_model_data_insert_column (data_tree,
- data_type,
- column->column_name,
- 0);
-
- }
- else
- glade_model_data_reorder_column (data_tree, idx, 0);
-
- }
-
- /* Remove trailing obsolete */
- while ((idx = get_extra_column (data_tree, columns)) >= 0)
- glade_model_data_remove_column (data_tree, idx);
-
- glade_command_set_property (property, data_tree);
- glade_model_data_tree_free (data_tree);
+eprop_column_adjust_rows (GladeEditorProperty * eprop, GList * columns)
+{
+ GladeColumnType *column;
+ GNode *data_tree = NULL;
+ GladeWidget *widget = eprop->property->widget;
+ GList *list;
+ GladeProperty *property;
+ gint idx;
+
+ property = glade_widget_get_property (widget, "data");
+ glade_property_get (property, &data_tree);
+ if (!data_tree)
+ return;
+ data_tree = glade_model_data_tree_copy (data_tree);
+
+ /* Add mising columns and reorder... */
+ for (list = g_list_last (columns); list; list = list->prev)
+ {
+ GType data_type;
+
+ column = list->data;
+
+ data_type = g_type_from_name (column->type_name);
+
+ if ((idx =
+ glade_model_data_column_index (data_tree, column->column_name)) < 0)
+ {
+ glade_model_data_insert_column (data_tree,
+ data_type, column->column_name, 0);
+
+ }
+ else
+ glade_model_data_reorder_column (data_tree, idx, 0);
+
+ }
+
+ /* Remove trailing obsolete */
+ while ((idx = get_extra_column (data_tree, columns)) >= 0)
+ glade_model_data_remove_column (data_tree, idx);
+
+ glade_command_set_property (property, data_tree);
+ glade_model_data_tree_free (data_tree);
}
static void
-eprop_column_append (GladeEditorProperty *eprop,
- const gchar *type_name,
- const gchar *column_name)
+eprop_column_append (GladeEditorProperty * eprop,
+ const gchar * type_name, const gchar * column_name)
{
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GList *columns = NULL;
- GladeColumnType *data;
- GValue value = { 0, };
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GList *columns = NULL;
+ GladeColumnType *data;
+ GValue value = { 0, };
- glade_property_get (eprop->property, &columns);
- if (columns)
- columns = glade_column_list_copy (columns);
+ glade_property_get (eprop->property, &columns);
+ if (columns)
+ columns = glade_column_list_copy (columns);
- data = glade_column_type_new (type_name, column_name);
+ data = glade_column_type_new (type_name, column_name);
- columns = g_list_append (columns, data);
+ columns = g_list_append (columns, data);
- eprop_types->adding_column = TRUE;
- glade_command_push_group (_("Setting columns on %s"),
- glade_widget_get_name (eprop->property->widget));
+ eprop_types->adding_column = TRUE;
+ glade_command_push_group (_("Setting columns on %s"),
+ glade_widget_get_name (eprop->property->widget));
- g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
- g_value_take_boxed (&value, columns);
- glade_editor_property_commit (eprop, &value);
+ g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
+ g_value_take_boxed (&value, columns);
+ glade_editor_property_commit (eprop, &value);
- eprop_column_adjust_rows (eprop, columns);
- g_value_unset (&value);
+ eprop_column_adjust_rows (eprop, columns);
+ g_value_unset (&value);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- eprop_types->adding_column = FALSE;
+ eprop_types->adding_column = FALSE;
}
static gboolean
-eprop_treeview_key_press (GtkWidget *treeview,
- GdkEventKey *event,
- GladeEditorProperty *eprop)
+eprop_treeview_key_press (GtkWidget * treeview,
+ GdkEventKey * event, GladeEditorProperty * eprop)
{
- /* Remove from list and commit value, dont touch the liststore except in load() */
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GtkTreeIter iter;
- GList *columns = NULL;
- GladeColumnType *column;
- GValue value = { 0, };
- gchar *column_name;
+ /* Remove from list and commit value, dont touch the liststore except in load() */
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GtkTreeIter iter;
+ GList *columns = NULL;
+ GladeColumnType *column;
+ GValue value = { 0, };
+ gchar *column_name;
- if (event->keyval == GDK_KEY_Delete &&
- gtk_tree_selection_get_selected (eprop_types->selection, NULL, &iter))
- {
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter,
- COLUMN_COLUMN_NAME, &column_name, -1);
+ if (event->keyval == GDK_KEY_Delete &&
+ gtk_tree_selection_get_selected (eprop_types->selection, NULL, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter,
+ COLUMN_COLUMN_NAME, &column_name, -1);
- /* Cant delete the symbolic "add new" row */
- if (!column_name)
- return TRUE;
+ /* Cant delete the symbolic "add new" row */
+ if (!column_name)
+ return TRUE;
- glade_property_get (eprop->property, &columns);
- if (columns)
- columns = glade_column_list_copy (columns);
- g_assert (columns);
+ glade_property_get (eprop->property, &columns);
+ if (columns)
+ columns = glade_column_list_copy (columns);
+ g_assert (columns);
- /* Find and remove the offending column... */
- column = glade_column_list_find_column (columns, column_name);
- g_assert (column);
- columns = g_list_remove (columns, column);
- glade_column_type_free (column);
+ /* Find and remove the offending column... */
+ column = glade_column_list_find_column (columns, column_name);
+ g_assert (column);
+ columns = g_list_remove (columns, column);
+ glade_column_type_free (column);
- glade_command_push_group (_("Setting columns on %s"),
- glade_widget_get_name (eprop->property->widget));
+ glade_command_push_group (_("Setting columns on %s"),
+ glade_widget_get_name (eprop->property->
+ widget));
- eprop_types->want_focus = TRUE;
+ eprop_types->want_focus = TRUE;
- g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
- g_value_take_boxed (&value, columns);
- glade_editor_property_commit (eprop, &value);
+ g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
+ g_value_take_boxed (&value, columns);
+ glade_editor_property_commit (eprop, &value);
- eprop_column_adjust_rows (eprop, columns);
- g_value_unset (&value);
- glade_command_pop_group ();
+ eprop_column_adjust_rows (eprop, columns);
+ g_value_unset (&value);
+ glade_command_pop_group ();
- g_free (column_name);
+ g_free (column_name);
- eprop_types->want_focus = FALSE;
+ eprop_types->want_focus = FALSE;
- }
+ }
- return (event->keyval == GDK_KEY_Delete);
+ return (event->keyval == GDK_KEY_Delete);
}
static gboolean
-columns_changed_idle (GladeEditorProperty *eprop)
-{
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GladeColumnType *column;
- GValue value = { 0, };
- GList *new_list = NULL, *columns = NULL, *list;
- GtkTreeIter iter;
- gchar *column_name;
-
- glade_property_get (eprop->property, &columns);
- g_assert (columns);
- columns = glade_column_list_copy (columns);
-
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_types->store), &iter))
- {
- do
- {
- column_name = NULL;
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter,
- COLUMN_COLUMN_NAME, &column_name, -1);
- if (!column_name)
- continue;
-
- column = glade_column_list_find_column (columns, column_name);
- g_assert (column);
-
- new_list = g_list_prepend (new_list, column);
- g_free (column_name);
- }
- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_types->store), &iter));
- }
-
- /* any missing columns to free ? */
- for (list = columns; list; list = list->next)
- {
- if (!g_list_find (new_list, list->data))
- glade_column_type_free ((GladeColumnType *)list->data);
- }
- g_list_free (columns);
-
- glade_command_push_group (_("Setting columns on %s"),
- glade_widget_get_name (eprop->property->widget));
-
- g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
- g_value_take_boxed (&value, g_list_reverse (new_list));
- glade_editor_property_commit (eprop, &value);
-
- eprop_column_adjust_rows (eprop, new_list);
- g_value_unset (&value);
- glade_command_pop_group ();
-
- return FALSE;
+columns_changed_idle (GladeEditorProperty * eprop)
+{
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GladeColumnType *column;
+ GValue value = { 0, };
+ GList *new_list = NULL, *columns = NULL, *list;
+ GtkTreeIter iter;
+ gchar *column_name;
+
+ glade_property_get (eprop->property, &columns);
+ g_assert (columns);
+ columns = glade_column_list_copy (columns);
+
+ if (gtk_tree_model_get_iter_first
+ (GTK_TREE_MODEL (eprop_types->store), &iter))
+ {
+ do
+ {
+ column_name = NULL;
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter,
+ COLUMN_COLUMN_NAME, &column_name, -1);
+ if (!column_name)
+ continue;
+
+ column = glade_column_list_find_column (columns, column_name);
+ g_assert (column);
+
+ new_list = g_list_prepend (new_list, column);
+ g_free (column_name);
+ }
+ while (gtk_tree_model_iter_next
+ (GTK_TREE_MODEL (eprop_types->store), &iter));
+ }
+
+ /* any missing columns to free ? */
+ for (list = columns; list; list = list->next)
+ {
+ if (!g_list_find (new_list, list->data))
+ glade_column_type_free ((GladeColumnType *) list->data);
+ }
+ g_list_free (columns);
+
+ glade_command_push_group (_("Setting columns on %s"),
+ glade_widget_get_name (eprop->property->widget));
+
+ g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
+ g_value_take_boxed (&value, g_list_reverse (new_list));
+ glade_editor_property_commit (eprop, &value);
+
+ eprop_column_adjust_rows (eprop, new_list);
+ g_value_unset (&value);
+ glade_command_pop_group ();
+
+ return FALSE;
}
static void
-eprop_treeview_row_deleted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GladeEditorProperty *eprop)
+eprop_treeview_row_deleted (GtkTreeModel * tree_model,
+ GtkTreePath * path, GladeEditorProperty * eprop)
{
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- g_idle_add ((GSourceFunc)columns_changed_idle, eprop);
+ g_idle_add ((GSourceFunc) columns_changed_idle, eprop);
}
static void
-eprop_column_add_new (GladeEPropColumnTypes *eprop_types)
-{
- gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
- COLUMN_NAME, _("< define a new column >"),
- COLUMN_TYPE_EDITABLE, TRUE,
- COLUMN_NAME_EDITABLE, FALSE,
- COLUMN_TYPE_FOREGROUND, "Gray",
- COLUMN_TYPE_STYLE, PANGO_STYLE_ITALIC,
- -1);
+eprop_column_add_new (GladeEPropColumnTypes * eprop_types)
+{
+ gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
+ COLUMN_NAME, _("< define a new column >"),
+ COLUMN_TYPE_EDITABLE, TRUE,
+ COLUMN_NAME_EDITABLE, FALSE,
+ COLUMN_TYPE_FOREGROUND, "Gray",
+ COLUMN_TYPE_STYLE, PANGO_STYLE_ITALIC, -1);
}
static void
-eprop_column_load (GladeEPropColumnTypes *eprop_types,
- const gchar *type_name,
- const gchar *column_name)
-{
- gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
- COLUMN_NAME, type_name,
- COLUMN_COLUMN_NAME, column_name,
- COLUMN_TYPE_EDITABLE, FALSE,
- COLUMN_NAME_EDITABLE, TRUE,
- COLUMN_TYPE_FOREGROUND, "Black",
- COLUMN_TYPE_STYLE, PANGO_STYLE_NORMAL,
- -1);
+eprop_column_load (GladeEPropColumnTypes * eprop_types,
+ const gchar * type_name, const gchar * column_name)
+{
+ gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
+ COLUMN_NAME, type_name,
+ COLUMN_COLUMN_NAME, column_name,
+ COLUMN_TYPE_EDITABLE, FALSE,
+ COLUMN_NAME_EDITABLE, TRUE,
+ COLUMN_TYPE_FOREGROUND, "Black",
+ COLUMN_TYPE_STYLE, PANGO_STYLE_NORMAL, -1);
}
static void
-eprop_types_focus_cell (GladeEPropColumnTypes *eprop_types, gboolean use_path, gboolean add_cell, gboolean edit_cell)
-{
- /* Focus and edit the first column of a newly added row */
- if (eprop_types->store)
- {
- GtkTreePath *new_item_path;
- GtkTreeIter iter;
- gint n_children;
- gint needed_row;
-
- n_children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_types->store), NULL);
-
- needed_row = n_children - (add_cell ? 1 : 2);
-
- if (use_path)
- new_item_path = gtk_tree_path_new_from_string
- (g_object_get_data (G_OBJECT (eprop_types), "current-path-str"));
- else if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_types->store),
- &iter, NULL, needed_row))
- new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_types->store), &iter);
- else
- return;
-
- eprop_types->setting_cursor = TRUE;
-
- gtk_widget_grab_focus (GTK_WIDGET (eprop_types->view));
- gtk_tree_view_expand_to_path (eprop_types->view, new_item_path);
-
- gtk_tree_view_set_cursor (eprop_types->view, new_item_path,
- add_cell ? eprop_types->type_column : eprop_types->name_column,
- edit_cell);
-
- eprop_types->setting_cursor = FALSE;
-
- gtk_tree_path_free (new_item_path);
- }
+eprop_types_focus_cell (GladeEPropColumnTypes * eprop_types, gboolean use_path,
+ gboolean add_cell, gboolean edit_cell)
+{
+ /* Focus and edit the first column of a newly added row */
+ if (eprop_types->store)
+ {
+ GtkTreePath *new_item_path;
+ GtkTreeIter iter;
+ gint n_children;
+ gint needed_row;
+
+ n_children =
+ gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_types->store),
+ NULL);
+
+ needed_row = n_children - (add_cell ? 1 : 2);
+
+ if (use_path)
+ new_item_path = gtk_tree_path_new_from_string
+ (g_object_get_data (G_OBJECT (eprop_types), "current-path-str"));
+ else if (gtk_tree_model_iter_nth_child
+ (GTK_TREE_MODEL (eprop_types->store), &iter, NULL, needed_row))
+ new_item_path =
+ gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_types->store),
+ &iter);
+ else
+ return;
+
+ eprop_types->setting_cursor = TRUE;
+
+ gtk_widget_grab_focus (GTK_WIDGET (eprop_types->view));
+ gtk_tree_view_expand_to_path (eprop_types->view, new_item_path);
+
+ gtk_tree_view_set_cursor (eprop_types->view, new_item_path,
+ add_cell ? eprop_types->
+ type_column : eprop_types->name_column,
+ edit_cell);
+
+ eprop_types->setting_cursor = FALSE;
+
+ gtk_tree_path_free (new_item_path);
+ }
}
static gboolean
-eprop_types_focus_new (GladeEPropColumnTypes *eprop_types)
+eprop_types_focus_new (GladeEPropColumnTypes * eprop_types)
{
- eprop_types_focus_cell (eprop_types, FALSE, TRUE, FALSE);
- return FALSE;
+ eprop_types_focus_cell (eprop_types, FALSE, TRUE, FALSE);
+ return FALSE;
}
static gboolean
-eprop_types_focus_name (GladeEPropColumnTypes *eprop_types)
+eprop_types_focus_name (GladeEPropColumnTypes * eprop_types)
{
- eprop_types_focus_cell (eprop_types, FALSE, FALSE, TRUE);
- return FALSE;
+ eprop_types_focus_cell (eprop_types, FALSE, FALSE, TRUE);
+ return FALSE;
}
static gboolean
-eprop_types_focus_name_no_edit (GladeEPropColumnTypes *eprop_types)
+eprop_types_focus_name_no_edit (GladeEPropColumnTypes * eprop_types)
{
- eprop_types_focus_cell (eprop_types, TRUE, FALSE, FALSE);
- return FALSE;
+ eprop_types_focus_cell (eprop_types, TRUE, FALSE, FALSE);
+ return FALSE;
}
static void
-glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GList *l, *list = NULL;
-
- /* Chain up first */
- parent_class->load (eprop, property);
-
- if (eprop_types->context)
- glade_name_context_destroy (eprop_types->context);
- eprop_types->context = NULL;
-
- if (!property) return;
-
- eprop_types->context = glade_name_context_new ();
-
- g_signal_handlers_block_by_func (G_OBJECT (eprop_types->store),
- eprop_treeview_row_deleted, eprop);
-
- /* Clear Store */
- gtk_list_store_clear (eprop_types->store);
-
- glade_property_get (property, &list);
-
- for (l = list; l; l = g_list_next (l))
- {
- GladeColumnType *data = l->data;
-
- eprop_column_load (eprop_types, data->type_name, data->column_name);
- glade_name_context_add_name (eprop_types->context, data->column_name);
- }
-
- eprop_column_add_new (eprop_types);
-
- if (eprop_types->adding_column && list)
- g_idle_add ((GSourceFunc)eprop_types_focus_name, eprop_types);
- else if (eprop_types->want_focus)
- g_idle_add ((GSourceFunc)eprop_types_focus_new, eprop_types);
-
- g_signal_handlers_unblock_by_func (G_OBJECT (eprop_types->store),
- eprop_treeview_row_deleted, eprop);
+glade_eprop_column_types_load (GladeEditorProperty * eprop,
+ GladeProperty * property)
+{
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GList *l, *list = NULL;
+
+ /* Chain up first */
+ parent_class->load (eprop, property);
+
+ if (eprop_types->context)
+ glade_name_context_destroy (eprop_types->context);
+ eprop_types->context = NULL;
+
+ if (!property)
+ return;
+
+ eprop_types->context = glade_name_context_new ();
+
+ g_signal_handlers_block_by_func (G_OBJECT (eprop_types->store),
+ eprop_treeview_row_deleted, eprop);
+
+ /* Clear Store */
+ gtk_list_store_clear (eprop_types->store);
+
+ glade_property_get (property, &list);
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GladeColumnType *data = l->data;
+
+ eprop_column_load (eprop_types, data->type_name, data->column_name);
+ glade_name_context_add_name (eprop_types->context, data->column_name);
+ }
+
+ eprop_column_add_new (eprop_types);
+
+ if (eprop_types->adding_column && list)
+ g_idle_add ((GSourceFunc) eprop_types_focus_name, eprop_types);
+ else if (eprop_types->want_focus)
+ g_idle_add ((GSourceFunc) eprop_types_focus_new, eprop_types);
+
+ g_signal_handlers_unblock_by_func (G_OBJECT (eprop_types->store),
+ eprop_treeview_row_deleted, eprop);
}
static void
-column_name_edited (GtkCellRendererText *cell,
- const gchar *path,
- const gchar *new_column_name,
- GladeEditorProperty *eprop)
-{
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GtkTreeIter iter;
- gchar *old_column_name = NULL, *column_name;
- GList *columns = NULL;
- GladeColumnType *column;
- GValue value = { 0, };
- GNode *data_tree = NULL;
- GladeProperty *property;
-
- if (eprop_types->adding_column)
- return;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_types->store), &iter, path))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter, COLUMN_COLUMN_NAME, &old_column_name, -1);
-
- if (new_column_name && old_column_name &&
- strcmp (new_column_name, old_column_name) == 0)
- return;
-
- /* Attempt to rename the column, and commit if successfull... */
- glade_property_get (eprop->property, &columns);
- if (columns)
- columns = glade_column_list_copy (columns);
- g_assert (columns);
-
- column = glade_column_list_find_column (columns, old_column_name);
-
- /* Bookkeep the exclusive names... */
- if (!new_column_name || !new_column_name[0] ||
- glade_name_context_has_name (eprop_types->context, new_column_name))
- column_name = glade_name_context_new_name (eprop_types->context,
- new_column_name && new_column_name[0] ?
- new_column_name : "column");
- else
- column_name = g_strdup (new_column_name);
-
- glade_name_context_add_name (eprop_types->context, column_name);
- glade_name_context_release_name (eprop_types->context, old_column_name);
-
- /* Set real column name */
- g_free (column->column_name);
- column->column_name = column_name;
-
- /* The "columns" copy of this string doesnt last long... */
- column_name = g_strdup (column_name);
-
- glade_command_push_group (_("Setting columns on %s"),
- glade_widget_get_name (eprop->property->widget));
-
- eprop_types->want_focus = TRUE;
-
- g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
- g_value_take_boxed (&value, columns);
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
-
- property = glade_widget_get_property (eprop->property->widget, "data");
- glade_property_get (property, &data_tree);
- if (data_tree)
- {
- data_tree = glade_model_data_tree_copy (data_tree);
- glade_model_data_column_rename (data_tree, old_column_name, column_name);
- glade_command_set_property (property, data_tree);
- glade_model_data_tree_free (data_tree);
- }
- glade_command_pop_group ();
-
- eprop_types->want_focus = FALSE;
-
- g_free (old_column_name);
- g_free (column_name);
+column_name_edited (GtkCellRendererText * cell,
+ const gchar * path,
+ const gchar * new_column_name, GladeEditorProperty * eprop)
+{
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GtkTreeIter iter;
+ gchar *old_column_name = NULL, *column_name;
+ GList *columns = NULL;
+ GladeColumnType *column;
+ GValue value = { 0, };
+ GNode *data_tree = NULL;
+ GladeProperty *property;
+
+ if (eprop_types->adding_column)
+ return;
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_types->store), &iter, path))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_types->store), &iter,
+ COLUMN_COLUMN_NAME, &old_column_name, -1);
+
+ if (new_column_name && old_column_name &&
+ strcmp (new_column_name, old_column_name) == 0)
+ return;
+
+ /* Attempt to rename the column, and commit if successfull... */
+ glade_property_get (eprop->property, &columns);
+ if (columns)
+ columns = glade_column_list_copy (columns);
+ g_assert (columns);
+
+ column = glade_column_list_find_column (columns, old_column_name);
+
+ /* Bookkeep the exclusive names... */
+ if (!new_column_name || !new_column_name[0] ||
+ glade_name_context_has_name (eprop_types->context, new_column_name))
+ column_name = glade_name_context_new_name (eprop_types->context,
+ new_column_name &&
+ new_column_name[0] ?
+ new_column_name : "column");
+ else
+ column_name = g_strdup (new_column_name);
+
+ glade_name_context_add_name (eprop_types->context, column_name);
+ glade_name_context_release_name (eprop_types->context, old_column_name);
+
+ /* Set real column name */
+ g_free (column->column_name);
+ column->column_name = column_name;
+
+ /* The "columns" copy of this string doesnt last long... */
+ column_name = g_strdup (column_name);
+
+ glade_command_push_group (_("Setting columns on %s"),
+ glade_widget_get_name (eprop->property->widget));
+
+ eprop_types->want_focus = TRUE;
+
+ g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
+ g_value_take_boxed (&value, columns);
+ glade_editor_property_commit (eprop, &value);
+ g_value_unset (&value);
+
+ property = glade_widget_get_property (eprop->property->widget, "data");
+ glade_property_get (property, &data_tree);
+ if (data_tree)
+ {
+ data_tree = glade_model_data_tree_copy (data_tree);
+ glade_model_data_column_rename (data_tree, old_column_name, column_name);
+ glade_command_set_property (property, data_tree);
+ glade_model_data_tree_free (data_tree);
+ }
+ glade_command_pop_group ();
+
+ eprop_types->want_focus = FALSE;
+
+ g_free (old_column_name);
+ g_free (column_name);
}
static void
-column_type_edited (GtkCellRendererText *cell,
- const gchar *path,
- const gchar *type_name,
- GladeEditorProperty *eprop)
-{
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GtkTreeIter iter;
- gchar *column_name;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_types->store), &iter, path))
- return;
-
- if (type_name && type_name[0])
- {
- column_name = glade_name_context_new_name (eprop_types->context, type_name);
- eprop_column_append (eprop, type_name, column_name);
- g_free (column_name);
- }
- else
- {
- eprop_types->want_focus = TRUE;
- glade_editor_property_load (eprop, eprop->property);
- eprop_types->want_focus = FALSE;
- }
+column_type_edited (GtkCellRendererText * cell,
+ const gchar * path,
+ const gchar * type_name, GladeEditorProperty * eprop)
+{
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GtkTreeIter iter;
+ gchar *column_name;
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_types->store), &iter, path))
+ return;
+
+ if (type_name && type_name[0])
+ {
+ column_name =
+ glade_name_context_new_name (eprop_types->context, type_name);
+ eprop_column_append (eprop, type_name, column_name);
+ g_free (column_name);
+ }
+ else
+ {
+ eprop_types->want_focus = TRUE;
+ glade_editor_property_load (eprop, eprop->property);
+ eprop_types->want_focus = FALSE;
+ }
}
static void
-types_combo_editing_started (GtkCellRenderer *renderer,
- GtkCellEditable *editable,
- gchar *path,
- GladeEditorProperty *eprop)
+types_combo_editing_started (GtkCellRenderer * renderer,
+ GtkCellEditable * editable,
+ gchar * path, GladeEditorProperty * eprop)
{
- GtkEntryCompletion *completion = gtk_entry_completion_new ();
+ GtkEntryCompletion *completion = gtk_entry_completion_new ();
- g_object_set_data_full (G_OBJECT (eprop), "current-path-str", g_strdup (path), g_free);
+ g_object_set_data_full (G_OBJECT (eprop), "current-path-str", g_strdup (path),
+ g_free);
- gtk_entry_completion_set_model (completion, types_model);
- gtk_entry_completion_set_text_column (completion, 0);
- gtk_entry_completion_set_inline_completion (completion, TRUE);
- gtk_entry_set_completion (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable))), completion);
- g_object_unref (G_OBJECT (completion));
+ gtk_entry_completion_set_model (completion, types_model);
+ gtk_entry_completion_set_text_column (completion, 0);
+ gtk_entry_completion_set_inline_completion (completion, TRUE);
+ gtk_entry_set_completion (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable))),
+ completion);
+ g_object_unref (G_OBJECT (completion));
}
static void
-types_combo_editing_canceled (GtkCellRenderer *renderer,
- GladeEditorProperty *eprop)
+types_combo_editing_canceled (GtkCellRenderer * renderer,
+ GladeEditorProperty * eprop)
{
- g_idle_add ((GSourceFunc)eprop_types_focus_new, eprop);
+ g_idle_add ((GSourceFunc) eprop_types_focus_new, eprop);
}
static void
-types_name_editing_started (GtkCellRenderer *renderer,
- GtkCellEditable *editable,
- gchar *path_str,
- GladeEditorProperty *eprop)
+types_name_editing_started (GtkCellRenderer * renderer,
+ GtkCellEditable * editable,
+ gchar * path_str, GladeEditorProperty * eprop)
{
- g_object_set_data_full (G_OBJECT (eprop), "current-path-str", g_strdup (path_str), g_free);
+ g_object_set_data_full (G_OBJECT (eprop), "current-path-str",
+ g_strdup (path_str), g_free);
}
static void
-types_name_editing_canceled (GtkCellRenderer *renderer,
- GladeEditorProperty *eprop)
+types_name_editing_canceled (GtkCellRenderer * renderer,
+ GladeEditorProperty * eprop)
{
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- if (eprop_types->adding_column || eprop_types->setting_cursor)
- return;
+ if (eprop_types->adding_column || eprop_types->setting_cursor)
+ return;
- g_idle_add ((GSourceFunc)eprop_types_focus_name_no_edit, eprop);
+ g_idle_add ((GSourceFunc) eprop_types_focus_name_no_edit, eprop);
}
static GtkWidget *
-glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
+glade_eprop_column_types_create_input (GladeEditorProperty * eprop)
{
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GtkWidget *vbox, *swin, *label;
- GtkCellRenderer *cell;
- gchar *string;
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GtkWidget *vbox, *swin, *label;
+ GtkCellRenderer *cell;
+ gchar *string;
+
+ vbox = gtk_vbox_new (FALSE, 2);
- vbox = gtk_vbox_new (FALSE, 2);
-
/* hbox = gtk_hbox_new (FALSE, 4); */
- if (!types_model)
- {
- /* We make sure to do this after all the adaptors are parsed
- * because we load the enums/flags from the adaptors
- */
- types_model = (GtkTreeModel *)gtk_list_store_new (1,
- G_TYPE_STRING);
-
- column_types_store_populate (GTK_LIST_STORE (types_model));
- }
-
-
- string = g_strdup_printf ("<b>%s</b>", _("Add and remove columns:"));
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_misc_set_padding (GTK_MISC (label), 2, 4);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
-
- swin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin), GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
- gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
-
- eprop_types->store = gtk_list_store_new (N_COLUMNS,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_BOOLEAN,
- G_TYPE_STRING,
- PANGO_TYPE_STYLE);
-
- g_signal_connect (eprop_types->store, "row-deleted",
- G_CALLBACK (eprop_treeview_row_deleted),
- eprop);
-
- eprop_types->view = (GtkTreeView *)gtk_tree_view_new_with_model (GTK_TREE_MODEL (eprop_types->store));
- eprop_types->selection = gtk_tree_view_get_selection (eprop_types->view);
-
- gtk_tree_view_set_reorderable (eprop_types->view, TRUE);
- gtk_tree_view_set_enable_search (eprop_types->view, FALSE);
- //gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
-
- g_signal_connect (eprop_types->view, "key-press-event",
- G_CALLBACK (eprop_treeview_key_press),
- eprop);
-
-
- /* type column */
- cell = gtk_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (cell),
- "text-column", COLUMN_NAME,
- "model", types_model,
- NULL);
-
- g_signal_connect (G_OBJECT (cell), "editing-started",
- G_CALLBACK (types_combo_editing_started), eprop);
-
- g_signal_connect (G_OBJECT (cell), "editing-canceled",
- G_CALLBACK (types_combo_editing_canceled), eprop);
-
- g_signal_connect (G_OBJECT (cell), "edited",
- G_CALLBACK (column_type_edited), eprop);
-
- eprop_types->type_column =
- gtk_tree_view_column_new_with_attributes (_("Column type"), cell,
- "foreground", COLUMN_TYPE_FOREGROUND,
- "style", COLUMN_TYPE_STYLE,
- "editable", COLUMN_TYPE_EDITABLE,
- "text", COLUMN_NAME,
- NULL);
-
- gtk_tree_view_column_set_expand (eprop_types->type_column, TRUE);
- gtk_tree_view_append_column (eprop_types->view, eprop_types->type_column);
-
- /* name column */
- cell = gtk_cell_renderer_text_new ();
- g_signal_connect (G_OBJECT (cell), "edited",
- G_CALLBACK (column_name_edited), eprop);
-
- g_signal_connect (G_OBJECT (cell), "editing-started",
- G_CALLBACK (types_name_editing_started), eprop);
-
- g_signal_connect (G_OBJECT (cell), "editing-canceled",
- G_CALLBACK (types_name_editing_canceled), eprop);
-
- eprop_types->name_column =
- gtk_tree_view_column_new_with_attributes (_("Column name"), cell,
- "editable", COLUMN_NAME_EDITABLE,
- "text", COLUMN_COLUMN_NAME,
- NULL);
-
- gtk_tree_view_column_set_expand (eprop_types->name_column, TRUE);
-
- gtk_tree_view_append_column (eprop_types->view, eprop_types->name_column);
- gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_types->view));
-
- g_object_set (G_OBJECT (vbox), "height-request", 200, NULL);
-
- gtk_widget_show_all (vbox);
- return vbox;
+ if (!types_model)
+ {
+ /* We make sure to do this after all the adaptors are parsed
+ * because we load the enums/flags from the adaptors
+ */
+ types_model = (GtkTreeModel *) gtk_list_store_new (1, G_TYPE_STRING);
+
+ column_types_store_populate (GTK_LIST_STORE (types_model));
+ }
+
+
+ string = g_strdup_printf ("<b>%s</b>", _("Add and remove columns:"));
+ label = gtk_label_new (string);
+ g_free (string);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label), 2, 4);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
+
+ swin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
+
+ eprop_types->store = gtk_list_store_new (N_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
+ G_TYPE_STRING, PANGO_TYPE_STYLE);
+
+ g_signal_connect (eprop_types->store, "row-deleted",
+ G_CALLBACK (eprop_treeview_row_deleted), eprop);
+
+ eprop_types->view =
+ (GtkTreeView *)
+ gtk_tree_view_new_with_model (GTK_TREE_MODEL (eprop_types->store));
+ eprop_types->selection = gtk_tree_view_get_selection (eprop_types->view);
+
+ gtk_tree_view_set_reorderable (eprop_types->view, TRUE);
+ gtk_tree_view_set_enable_search (eprop_types->view, FALSE);
+ //gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+
+ g_signal_connect (eprop_types->view, "key-press-event",
+ G_CALLBACK (eprop_treeview_key_press), eprop);
+
+
+ /* type column */
+ cell = gtk_cell_renderer_combo_new ();
+ g_object_set (G_OBJECT (cell),
+ "text-column", COLUMN_NAME, "model", types_model, NULL);
+
+ g_signal_connect (G_OBJECT (cell), "editing-started",
+ G_CALLBACK (types_combo_editing_started), eprop);
+
+ g_signal_connect (G_OBJECT (cell), "editing-canceled",
+ G_CALLBACK (types_combo_editing_canceled), eprop);
+
+ g_signal_connect (G_OBJECT (cell), "edited",
+ G_CALLBACK (column_type_edited), eprop);
+
+ eprop_types->type_column =
+ gtk_tree_view_column_new_with_attributes (_("Column type"), cell,
+ "foreground",
+ COLUMN_TYPE_FOREGROUND, "style",
+ COLUMN_TYPE_STYLE, "editable",
+ COLUMN_TYPE_EDITABLE, "text",
+ COLUMN_NAME, NULL);
+
+ gtk_tree_view_column_set_expand (eprop_types->type_column, TRUE);
+ gtk_tree_view_append_column (eprop_types->view, eprop_types->type_column);
+
+ /* name column */
+ cell = gtk_cell_renderer_text_new ();
+ g_signal_connect (G_OBJECT (cell), "edited",
+ G_CALLBACK (column_name_edited), eprop);
+
+ g_signal_connect (G_OBJECT (cell), "editing-started",
+ G_CALLBACK (types_name_editing_started), eprop);
+
+ g_signal_connect (G_OBJECT (cell), "editing-canceled",
+ G_CALLBACK (types_name_editing_canceled), eprop);
+
+ eprop_types->name_column =
+ gtk_tree_view_column_new_with_attributes (_("Column name"), cell,
+ "editable",
+ COLUMN_NAME_EDITABLE, "text",
+ COLUMN_COLUMN_NAME, NULL);
+
+ gtk_tree_view_column_set_expand (eprop_types->name_column, TRUE);
+
+ gtk_tree_view_append_column (eprop_types->view, eprop_types->name_column);
+ gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_types->view));
+
+ g_object_set (G_OBJECT (vbox), "height-request", 200, NULL);
+
+ gtk_widget_show_all (vbox);
+ return vbox;
}
diff --git a/plugins/gtk+/glade-column-types.h b/plugins/gtk+/glade-column-types.h
index 1f818fe..0714e5c 100644
--- a/plugins/gtk+/glade-column-types.h
+++ b/plugins/gtk+/glade-column-types.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Juan Pablo Ugarte.
*
diff --git a/plugins/gtk+/glade-entry-editor.c b/plugins/gtk+/glade-entry-editor.c
index f3390e3..8be4982 100644
--- a/plugins/gtk+/glade-entry-editor.c
+++ b/plugins/gtk+/glade-entry-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -29,11 +28,11 @@
#include "glade-image-editor.h" // For GladeImageEditMode
-static void glade_entry_editor_finalize (GObject *object);
+static void glade_entry_editor_finalize (GObject * object);
-static void glade_entry_editor_editable_init (GladeEditableIface *iface);
+static void glade_entry_editor_editable_init (GladeEditableIface * iface);
-static void glade_entry_editor_grab_focus (GtkWidget *widget);
+static void glade_entry_editor_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeEntryEditor, glade_entry_editor, GTK_TYPE_VBOX,
@@ -42,244 +41,265 @@ G_DEFINE_TYPE_WITH_CODE (GladeEntryEditor, glade_entry_editor, GTK_TYPE_VBOX,
static void
-glade_entry_editor_class_init (GladeEntryEditorClass *klass)
+glade_entry_editor_class_init (GladeEntryEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_entry_editor_finalize;
- widget_class->grab_focus = glade_entry_editor_grab_focus;
+ object_class->finalize = glade_entry_editor_finalize;
+ widget_class->grab_focus = glade_entry_editor_grab_focus;
}
static void
-glade_entry_editor_init (GladeEntryEditor *self)
+glade_entry_editor_init (GladeEntryEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeEntryEditor *entry_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeEntryEditor * entry_editor)
{
- if (entry_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (entry_editor)))
- return;
+ if (entry_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (entry_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (entry_editor), entry_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-project_finalized (GladeEntryEditor *entry_editor,
- GladeProject *where_project_was)
+project_finalized (GladeEntryEditor * entry_editor,
+ GladeProject * where_project_was)
{
- entry_editor->loaded_widget = NULL;
+ entry_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (entry_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (entry_editor), NULL);
}
static void
-glade_entry_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_entry_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (editable);
- GladeImageEditMode icon_mode;
- gboolean use_buffer = FALSE;
- GList *l;
-
- entry_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (entry_editor->loaded_widget)
- {
- /* watch custom-child and use-stock properties here for reloads !!! */
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (entry_editor->loaded_widget->project),
- G_CALLBACK (project_changed), entry_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (entry_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- entry_editor);
- }
-
- /* Mark our widget... */
- entry_editor->loaded_widget = widget;
-
- if (entry_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (entry_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), entry_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (entry_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- entry_editor);
- }
-
- /* load the embedded editable... */
- if (entry_editor->embed)
- glade_editable_load (GLADE_EDITABLE (entry_editor->embed), widget);
-
- for (l = entry_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
-
- if (widget)
- {
- glade_widget_property_get (widget, "use-entry-buffer", &use_buffer);
- if (use_buffer)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->buffer_radio), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->text_radio), TRUE);
-
-
- glade_widget_property_get (widget, "primary-icon-mode", &icon_mode);
- switch (icon_mode)
- {
- case GLADE_IMAGE_MODE_STOCK:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->primary_stock_radio), TRUE);
- break;
- case GLADE_IMAGE_MODE_ICON:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->primary_icon_name_radio), TRUE);
- break;
- case GLADE_IMAGE_MODE_FILENAME:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->primary_pixbuf_radio), TRUE);
- break;
- default:
- break;
- }
-
- glade_widget_property_get (widget, "secondary-icon-mode", &icon_mode);
- switch (icon_mode)
- {
- case GLADE_IMAGE_MODE_STOCK:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->secondary_stock_radio), TRUE);
- break;
- case GLADE_IMAGE_MODE_ICON:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->secondary_icon_name_radio), TRUE);
- break;
- case GLADE_IMAGE_MODE_FILENAME:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry_editor->secondary_pixbuf_radio), TRUE);
- break;
- default:
- break;
- }
- }
- entry_editor->loading = FALSE;
+ GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (editable);
+ GladeImageEditMode icon_mode;
+ gboolean use_buffer = FALSE;
+ GList *l;
+
+ entry_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (entry_editor->loaded_widget)
+ {
+ /* watch custom-child and use-stock properties here for reloads !!! */
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (entry_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ entry_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (entry_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, entry_editor);
+ }
+
+ /* Mark our widget... */
+ entry_editor->loaded_widget = widget;
+
+ if (entry_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (entry_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), entry_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (entry_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, entry_editor);
+ }
+
+ /* load the embedded editable... */
+ if (entry_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (entry_editor->embed), widget);
+
+ for (l = entry_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+
+ if (widget)
+ {
+ glade_widget_property_get (widget, "use-entry-buffer", &use_buffer);
+ if (use_buffer)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->buffer_radio), TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->text_radio), TRUE);
+
+
+ glade_widget_property_get (widget, "primary-icon-mode", &icon_mode);
+ switch (icon_mode)
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->primary_stock_radio),
+ TRUE);
+ break;
+ case GLADE_IMAGE_MODE_ICON:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->
+ primary_icon_name_radio), TRUE);
+ break;
+ case GLADE_IMAGE_MODE_FILENAME:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->primary_pixbuf_radio),
+ TRUE);
+ break;
+ default:
+ break;
+ }
+
+ glade_widget_property_get (widget, "secondary-icon-mode", &icon_mode);
+ switch (icon_mode)
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->secondary_stock_radio),
+ TRUE);
+ break;
+ case GLADE_IMAGE_MODE_ICON:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->
+ secondary_icon_name_radio), TRUE);
+ break;
+ case GLADE_IMAGE_MODE_FILENAME:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (entry_editor->
+ secondary_pixbuf_radio), TRUE);
+ break;
+ default:
+ break;
+ }
+ }
+ entry_editor->loading = FALSE;
}
static void
-glade_entry_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_entry_editor_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (editable);
+ GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (entry_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (entry_editor->embed),
+ show_name);
}
static void
-glade_entry_editor_editable_init (GladeEditableIface *iface)
+glade_entry_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_entry_editor_load;
- iface->set_show_name = glade_entry_editor_set_show_name;
+ iface->load = glade_entry_editor_load;
+ iface->set_show_name = glade_entry_editor_set_show_name;
}
static void
-glade_entry_editor_finalize (GObject *object)
+glade_entry_editor_finalize (GObject * object)
{
- GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (object);
+ GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (object);
- if (entry_editor->properties)
- g_list_free (entry_editor->properties);
- entry_editor->properties = NULL;
- entry_editor->embed = NULL;
+ if (entry_editor->properties)
+ g_list_free (entry_editor->properties);
+ entry_editor->properties = NULL;
+ entry_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_entry_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_entry_editor_parent_class)->finalize (object);
}
static void
-glade_entry_editor_grab_focus (GtkWidget *widget)
+glade_entry_editor_grab_focus (GtkWidget * widget)
{
- GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (widget);
+ GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (widget);
- gtk_widget_grab_focus (entry_editor->embed);
+ gtk_widget_grab_focus (entry_editor->embed);
}
static void
-text_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+text_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->text_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->text_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use static text"), entry_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use static text"),
+ entry_editor->loaded_widget->name);
- property = glade_widget_get_property (entry_editor->loaded_widget, "buffer");
- glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (entry_editor->loaded_widget, "buffer");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (entry_editor->loaded_widget, "use-entry-buffer");
- glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ "use-entry-buffer");
+ glade_command_set_property (property, FALSE);
- /* Text will only take effect after setting the property under the hood */
- property = glade_widget_get_property (entry_editor->loaded_widget, "text");
- glade_command_set_property (property, NULL);
+ /* Text will only take effect after setting the property under the hood */
+ property = glade_widget_get_property (entry_editor->loaded_widget, "text");
+ glade_command_set_property (property, NULL);
- /* Incase the NULL text didnt change */
- glade_property_sync (property);
+ /* Incase the NULL text didnt change */
+ glade_property_sync (property);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-buffer_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+buffer_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->buffer_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->buffer_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an external buffer"), entry_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use an external buffer"),
+ entry_editor->loaded_widget->name);
- /* Reset the text while still in static text mode */
- property = glade_widget_get_property (entry_editor->loaded_widget, "text");
- glade_command_set_property (property, NULL);
+ /* Reset the text while still in static text mode */
+ property = glade_widget_get_property (entry_editor->loaded_widget, "text");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (entry_editor->loaded_widget, "use-entry-buffer");
- glade_command_set_property (property, TRUE);
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ "use-entry-buffer");
+ glade_command_set_property (property, TRUE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
@@ -289,465 +309,549 @@ buffer_toggled (GtkWidget *widget,
#define STOCK_NAME(primary) ((primary) ? "primary-icon-stock" : "secondary-icon-stock")
static void
-set_stock_mode (GladeEntryEditor *entry_editor, gboolean primary)
+set_stock_mode (GladeEntryEditor * entry_editor, gboolean primary)
{
- GladeProperty *property;
- GValue value = { 0, };
-
- property = glade_widget_get_property (entry_editor->loaded_widget, ICON_NAME_NAME (primary));
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (entry_editor->loaded_widget, PIXBUF_NAME (primary));
- glade_command_set_property (property, NULL);
-
- property = glade_widget_get_property (entry_editor->loaded_widget, STOCK_NAME (primary));
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
-
- property = glade_widget_get_property (entry_editor->loaded_widget, ICON_MODE_NAME (primary));
- glade_command_set_property (property, GLADE_IMAGE_MODE_STOCK);
+ GladeProperty *property;
+ GValue value = { 0, };
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ ICON_NAME_NAME (primary));
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ PIXBUF_NAME (primary));
+ glade_command_set_property (property, NULL);
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ STOCK_NAME (primary));
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ ICON_MODE_NAME (primary));
+ glade_command_set_property (property, GLADE_IMAGE_MODE_STOCK);
}
static void
-set_icon_name_mode (GladeEntryEditor *entry_editor, gboolean primary)
+set_icon_name_mode (GladeEntryEditor * entry_editor, gboolean primary)
{
- GladeProperty *property;
-
- property = glade_widget_get_property (entry_editor->loaded_widget, STOCK_NAME (primary));
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (entry_editor->loaded_widget, PIXBUF_NAME (primary));
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (entry_editor->loaded_widget, ICON_MODE_NAME (primary));
- glade_command_set_property (property, GLADE_IMAGE_MODE_ICON);
+ GladeProperty *property;
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ STOCK_NAME (primary));
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ PIXBUF_NAME (primary));
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ ICON_MODE_NAME (primary));
+ glade_command_set_property (property, GLADE_IMAGE_MODE_ICON);
}
static void
-set_pixbuf_mode (GladeEntryEditor *entry_editor, gboolean primary)
+set_pixbuf_mode (GladeEntryEditor * entry_editor, gboolean primary)
{
- GladeProperty *property;
-
- property = glade_widget_get_property (entry_editor->loaded_widget, STOCK_NAME (primary));
- glade_command_set_property (property, NULL);
-
- property = glade_widget_get_property (entry_editor->loaded_widget, ICON_NAME_NAME (primary));
- glade_command_set_property (property, NULL);
-
- property = glade_widget_get_property (entry_editor->loaded_widget, ICON_MODE_NAME (primary));
- glade_command_set_property (property, GLADE_IMAGE_MODE_FILENAME);
+ GladeProperty *property;
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ STOCK_NAME (primary));
+ glade_command_set_property (property, NULL);
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ ICON_NAME_NAME (primary));
+ glade_command_set_property (property, NULL);
+
+ property =
+ glade_widget_get_property (entry_editor->loaded_widget,
+ ICON_MODE_NAME (primary));
+ glade_command_set_property (property, GLADE_IMAGE_MODE_FILENAME);
}
static void
-primary_stock_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+primary_stock_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->primary_stock_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->primary_stock_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a primary icon from stock"), entry_editor->loaded_widget->name);
- set_stock_mode (entry_editor, TRUE);
- glade_command_pop_group ();
+ glade_command_push_group (_("Setting %s to use a primary icon from stock"),
+ entry_editor->loaded_widget->name);
+ set_stock_mode (entry_editor, TRUE);
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-primary_icon_name_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+primary_icon_name_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->primary_icon_name_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->primary_icon_name_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a primary icon from the icon theme"), entry_editor->loaded_widget->name);
- set_icon_name_mode (entry_editor, TRUE);
- glade_command_pop_group ();
+ glade_command_push_group (_
+ ("Setting %s to use a primary icon from the icon theme"),
+ entry_editor->loaded_widget->name);
+ set_icon_name_mode (entry_editor, TRUE);
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-primary_pixbuf_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+primary_pixbuf_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->primary_pixbuf_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->primary_pixbuf_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a primary icon from filename"), entry_editor->loaded_widget->name);
- set_pixbuf_mode (entry_editor, TRUE);
- glade_command_pop_group ();
+ glade_command_push_group (_("Setting %s to use a primary icon from filename"),
+ entry_editor->loaded_widget->name);
+ set_pixbuf_mode (entry_editor, TRUE);
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-secondary_stock_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+secondary_stock_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->secondary_stock_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->secondary_stock_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a secondary icon from stock"), entry_editor->loaded_widget->name);
- set_stock_mode (entry_editor, FALSE);
- glade_command_pop_group ();
+ glade_command_push_group (_("Setting %s to use a secondary icon from stock"),
+ entry_editor->loaded_widget->name);
+ set_stock_mode (entry_editor, FALSE);
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-secondary_icon_name_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+secondary_icon_name_toggled (GtkWidget * widget,
+ GladeEntryEditor * entry_editor)
{
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->secondary_icon_name_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->secondary_icon_name_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a secondary icon from the icon theme"), entry_editor->loaded_widget->name);
- set_icon_name_mode (entry_editor, FALSE);
- glade_command_pop_group ();
+ glade_command_push_group (_
+ ("Setting %s to use a secondary icon from the icon theme"),
+ entry_editor->loaded_widget->name);
+ set_icon_name_mode (entry_editor, FALSE);
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-secondary_pixbuf_toggled (GtkWidget *widget,
- GladeEntryEditor *entry_editor)
+secondary_pixbuf_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor)
{
- if (entry_editor->loading || !entry_editor->loaded_widget)
- return;
+ if (entry_editor->loading || !entry_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry_editor->secondary_pixbuf_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (entry_editor->secondary_pixbuf_radio)))
+ return;
- entry_editor->modifying = TRUE;
+ entry_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a secondary icon from filename"), entry_editor->loaded_widget->name);
- set_pixbuf_mode (entry_editor, FALSE);
- glade_command_pop_group ();
+ glade_command_push_group (_
+ ("Setting %s to use a secondary icon from filename"),
+ entry_editor->loaded_widget->name);
+ set_pixbuf_mode (entry_editor, FALSE);
+ glade_command_pop_group ();
- entry_editor->modifying = FALSE;
+ entry_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (entry_editor),
- entry_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (entry_editor),
+ entry_editor->loaded_widget);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
GtkWidget *
-glade_entry_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_entry_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed)
{
- GladeEntryEditor *entry_editor;
- GladeEditorProperty *eprop;
- GtkWidget *table, *frame, *alignment, *label, *hbox;
- gchar *str;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- entry_editor = g_object_new (GLADE_TYPE_ENTRY_EDITOR, NULL);
- entry_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (entry_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
-
- /* Text... */
- str = g_strdup_printf ("<b>%s</b>", _("Text"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Text */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "text", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->text_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->text_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Buffer */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "buffer", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->buffer_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (entry_editor->text_radio));
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->buffer_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Progress... */
- str = g_strdup_printf ("<b>%s</b>", _("Progress"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Fraction */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "progress-fraction", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Pulse */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "progress-pulse-step", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Primary icon... */
- str = g_strdup_printf ("<b>%s</b>", _("Primary icon"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Pixbuf */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, PIXBUF_NAME(TRUE), FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->primary_pixbuf_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->primary_pixbuf_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Stock */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, STOCK_NAME(TRUE), FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->primary_stock_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (entry_editor->primary_pixbuf_radio));
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->primary_stock_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Icon name */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, ICON_NAME_NAME(TRUE), FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->primary_icon_name_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (entry_editor->primary_pixbuf_radio));
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->primary_icon_name_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 2);
- table_attach (table, GTK_WIDGET (eprop), 1, 2);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Other primary icon related properties */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "primary-icon-activatable", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 3);
- table_attach (table, GTK_WIDGET (eprop), 1, 3);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "primary-icon-sensitive", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 4);
- table_attach (table, GTK_WIDGET (eprop), 1, 4);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "primary-icon-tooltip-text", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 5);
- table_attach (table, GTK_WIDGET (eprop), 1, 5);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "primary-icon-tooltip-markup", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 6);
- table_attach (table, GTK_WIDGET (eprop), 1, 6);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Secondary icon... */
- str = g_strdup_printf ("<b>%s</b>", _("Secondary icon"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Pixbuf */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, PIXBUF_NAME(FALSE), FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->secondary_pixbuf_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->secondary_pixbuf_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Stock */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, STOCK_NAME(FALSE), FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->secondary_stock_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (entry_editor->secondary_pixbuf_radio));
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->secondary_stock_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Icon name */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, ICON_NAME_NAME(FALSE), FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- entry_editor->secondary_icon_name_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (entry_editor->secondary_pixbuf_radio));
- gtk_box_pack_start (GTK_BOX (hbox), entry_editor->secondary_icon_name_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 2);
- table_attach (table, GTK_WIDGET (eprop), 1, 2);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- /* Other secondary icon related properties */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "secondary-icon-activatable", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 3);
- table_attach (table, GTK_WIDGET (eprop), 1, 3);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "secondary-icon-sensitive", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 4);
- table_attach (table, GTK_WIDGET (eprop), 1, 4);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "secondary-icon-tooltip-text", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 5);
- table_attach (table, GTK_WIDGET (eprop), 1, 5);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "secondary-icon-tooltip-markup", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 6);
- table_attach (table, GTK_WIDGET (eprop), 1, 6);
- entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
-
- gtk_widget_show_all (GTK_WIDGET (entry_editor));
-
-
- /* Connect radio button signals... */
- g_signal_connect (G_OBJECT (entry_editor->text_radio), "toggled",
- G_CALLBACK (text_toggled), entry_editor);
- g_signal_connect (G_OBJECT (entry_editor->buffer_radio), "toggled",
- G_CALLBACK (buffer_toggled), entry_editor);
-
- g_signal_connect (G_OBJECT (entry_editor->primary_stock_radio), "toggled",
- G_CALLBACK (primary_stock_toggled), entry_editor);
- g_signal_connect (G_OBJECT (entry_editor->primary_icon_name_radio), "toggled",
- G_CALLBACK (primary_icon_name_toggled), entry_editor);
- g_signal_connect (G_OBJECT (entry_editor->primary_pixbuf_radio), "toggled",
- G_CALLBACK (primary_pixbuf_toggled), entry_editor);
-
- g_signal_connect (G_OBJECT (entry_editor->secondary_stock_radio), "toggled",
- G_CALLBACK (secondary_stock_toggled), entry_editor);
- g_signal_connect (G_OBJECT (entry_editor->secondary_icon_name_radio), "toggled",
- G_CALLBACK (secondary_icon_name_toggled), entry_editor);
- g_signal_connect (G_OBJECT (entry_editor->secondary_pixbuf_radio), "toggled",
- G_CALLBACK (secondary_pixbuf_toggled), entry_editor);
-
- return GTK_WIDGET (entry_editor);
+ GladeEntryEditor *entry_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *table, *frame, *alignment, *label, *hbox;
+ gchar *str;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ entry_editor = g_object_new (GLADE_TYPE_ENTRY_EDITOR, NULL);
+ entry_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (entry_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
+
+
+ /* Text... */
+ str = g_strdup_printf ("<b>%s</b>", _("Text"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Text */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "text", FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->text_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->text_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Buffer */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "buffer", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->buffer_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (entry_editor->text_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->buffer_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Progress... */
+ str = g_strdup_printf ("<b>%s</b>", _("Progress"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Fraction */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "progress-fraction",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Pulse */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "progress-pulse-step",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Primary icon... */
+ str = g_strdup_printf ("<b>%s</b>", _("Primary icon"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Pixbuf */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, PIXBUF_NAME (TRUE),
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->primary_pixbuf_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->primary_pixbuf_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Stock */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, STOCK_NAME (TRUE),
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->primary_stock_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (entry_editor->primary_pixbuf_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->primary_stock_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Icon name */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, ICON_NAME_NAME (TRUE),
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->primary_icon_name_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (entry_editor->primary_pixbuf_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->primary_icon_name_radio,
+ FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 2);
+ table_attach (table, GTK_WIDGET (eprop), 1, 2);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Other primary icon related properties */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "primary-icon-activatable",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 3);
+ table_attach (table, GTK_WIDGET (eprop), 1, 3);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "primary-icon-sensitive",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 4);
+ table_attach (table, GTK_WIDGET (eprop), 1, 4);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "primary-icon-tooltip-text",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 5);
+ table_attach (table, GTK_WIDGET (eprop), 1, 5);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "primary-icon-tooltip-markup",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 6);
+ table_attach (table, GTK_WIDGET (eprop), 1, 6);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Secondary icon... */
+ str = g_strdup_printf ("<b>%s</b>", _("Secondary icon"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (entry_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Pixbuf */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, PIXBUF_NAME (FALSE),
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->secondary_pixbuf_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->secondary_pixbuf_radio,
+ FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Stock */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, STOCK_NAME (FALSE),
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->secondary_stock_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (entry_editor->secondary_pixbuf_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->secondary_stock_radio,
+ FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Icon name */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ ICON_NAME_NAME (FALSE), FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ entry_editor->secondary_icon_name_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (entry_editor->secondary_pixbuf_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), entry_editor->secondary_icon_name_radio,
+ FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 2);
+ table_attach (table, GTK_WIDGET (eprop), 1, 2);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ /* Other secondary icon related properties */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "secondary-icon-activatable",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 3);
+ table_attach (table, GTK_WIDGET (eprop), 1, 3);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "secondary-icon-sensitive",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 4);
+ table_attach (table, GTK_WIDGET (eprop), 1, 4);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "secondary-icon-tooltip-text",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 5);
+ table_attach (table, GTK_WIDGET (eprop), 1, 5);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor,
+ "secondary-icon-tooltip-markup",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 6);
+ table_attach (table, GTK_WIDGET (eprop), 1, 6);
+ entry_editor->properties = g_list_prepend (entry_editor->properties, eprop);
+
+ gtk_widget_show_all (GTK_WIDGET (entry_editor));
+
+
+ /* Connect radio button signals... */
+ g_signal_connect (G_OBJECT (entry_editor->text_radio), "toggled",
+ G_CALLBACK (text_toggled), entry_editor);
+ g_signal_connect (G_OBJECT (entry_editor->buffer_radio), "toggled",
+ G_CALLBACK (buffer_toggled), entry_editor);
+
+ g_signal_connect (G_OBJECT (entry_editor->primary_stock_radio), "toggled",
+ G_CALLBACK (primary_stock_toggled), entry_editor);
+ g_signal_connect (G_OBJECT (entry_editor->primary_icon_name_radio), "toggled",
+ G_CALLBACK (primary_icon_name_toggled), entry_editor);
+ g_signal_connect (G_OBJECT (entry_editor->primary_pixbuf_radio), "toggled",
+ G_CALLBACK (primary_pixbuf_toggled), entry_editor);
+
+ g_signal_connect (G_OBJECT (entry_editor->secondary_stock_radio), "toggled",
+ G_CALLBACK (secondary_stock_toggled), entry_editor);
+ g_signal_connect (G_OBJECT (entry_editor->secondary_icon_name_radio),
+ "toggled", G_CALLBACK (secondary_icon_name_toggled),
+ entry_editor);
+ g_signal_connect (G_OBJECT (entry_editor->secondary_pixbuf_radio), "toggled",
+ G_CALLBACK (secondary_pixbuf_toggled), entry_editor);
+
+ return GTK_WIDGET (entry_editor);
}
diff --git a/plugins/gtk+/glade-entry-editor.h b/plugins/gtk+/glade-entry-editor.h
index 2c33c77..368888d 100644
--- a/plugins/gtk+/glade-entry-editor.h
+++ b/plugins/gtk+/glade-entry-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 92001f2..bcb9698 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2004 - 2008 Tristan Van Berkom, Juan Pablo Ugarte et al.
@@ -68,53 +67,52 @@
GParamSpec *
gladegtk_icon_size_spec (void)
{
- return g_param_spec_enum ("icon-size", _("Icon Size"),
- _("Symbolic size to use for stock icon, icon set or named icon"),
- GTK_TYPE_ICON_SIZE,
- GTK_ICON_SIZE_BUTTON,
- G_PARAM_READWRITE);
+ return g_param_spec_enum ("icon-size", _("Icon Size"),
+ _
+ ("Symbolic size to use for stock icon, icon set or named icon"),
+ GTK_TYPE_ICON_SIZE, GTK_ICON_SIZE_BUTTON,
+ G_PARAM_READWRITE);
}
/* This function does absolutely nothing
* (and is for use in overriding post_create functions).
*/
void
-empty (GObject *container, GladeCreateReason reason)
+empty (GObject * container, GladeCreateReason reason)
{
}
/* This function is used to stop default handlers */
static void
-glade_gtk_stop_emission_POINTER (gpointer instance, gpointer dummy, gpointer data)
+glade_gtk_stop_emission_POINTER (gpointer instance, gpointer dummy,
+ gpointer data)
{
- g_signal_stop_emission (instance, GPOINTER_TO_UINT (data) , 0);
+ g_signal_stop_emission (instance, GPOINTER_TO_UINT (data), 0);
}
/* Initialize needed pspec types from here */
void
-glade_gtk_init (const gchar *name)
+glade_gtk_init (const gchar * name)
{
}
/* ----------------------------- GtkWidget ------------------------------ */
gboolean
-glade_gtk_widget_depends (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeWidget *another)
+glade_gtk_widget_depends (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeWidget * another)
{
- if (GTK_IS_ICON_FACTORY (another->object) ||
- GTK_IS_ACTION (another->object) ||
- GTK_IS_ACTION_GROUP (another->object))
- return TRUE;
+ if (GTK_IS_ICON_FACTORY (another->object) ||
+ GTK_IS_ACTION (another->object) || GTK_IS_ACTION_GROUP (another->object))
+ return TRUE;
- return GWA_GET_CLASS (G_TYPE_OBJECT)->depends (adaptor, widget, another);
+ return GWA_GET_CLASS (G_TYPE_OBJECT)->depends (adaptor, widget, another);
}
#define GLADE_TAG_A11Y_A11Y "accessibility"
-#define GLADE_TAG_A11Y_ACTION_NAME "action_name" /* We should make -/_ synonymous */
+#define GLADE_TAG_A11Y_ACTION_NAME "action_name" /* We should make -/_ synonymous */
#define GLADE_TAG_A11Y_DESC "description"
#define GLADE_TAG_A11Y_TARGET "target"
#define GLADE_TAG_A11Y_TYPE "type"
@@ -129,1867 +127,1813 @@ glade_gtk_widget_depends (GladeWidgetAdaptor *adaptor,
static const gchar *atk_relations_list[] = {
- "controlled-by",
- "controller-for",
- "labelled-by",
- "label-for",
- "member-of",
- "node-child-of",
- "flows-to",
- "flows-from",
- "subwindow-of",
- "embeds",
- "embedded-by",
- "popup-for",
- "parent-window-of",
- "described-by",
- "description-for",
- NULL
+ "controlled-by",
+ "controller-for",
+ "labelled-by",
+ "label-for",
+ "member-of",
+ "node-child-of",
+ "flows-to",
+ "flows-from",
+ "subwindow-of",
+ "embeds",
+ "embedded-by",
+ "popup-for",
+ "parent-window-of",
+ "described-by",
+ "description-for",
+ NULL
};
static void
-glade_gtk_read_accels (GladeWidget *widget,
- GladeXmlNode *node,
- gboolean require_signal)
+glade_gtk_read_accels (GladeWidget * widget,
+ GladeXmlNode * node, gboolean require_signal)
{
- GladeProperty *property;
- GladeXmlNode *prop;
- GladeAccelInfo *ainfo;
- GValue *value = NULL;
- GList *accels = NULL;
+ GladeProperty *property;
+ GladeXmlNode *prop;
+ GladeAccelInfo *ainfo;
+ GValue *value = NULL;
+ GList *accels = NULL;
- for (prop = glade_xml_node_get_children (node);
- prop; prop = glade_xml_node_next (prop))
- {
- if (!glade_xml_node_verify_silent (prop, GLADE_TAG_ACCEL))
- continue;
+ for (prop = glade_xml_node_get_children (node);
+ prop; prop = glade_xml_node_next (prop))
+ {
+ if (!glade_xml_node_verify_silent (prop, GLADE_TAG_ACCEL))
+ continue;
- if ((ainfo = glade_accel_read (prop, require_signal)) != NULL)
- accels = g_list_prepend (accels, ainfo);
- }
+ if ((ainfo = glade_accel_read (prop, require_signal)) != NULL)
+ accels = g_list_prepend (accels, ainfo);
+ }
- if (accels)
- {
- value = g_new0 (GValue, 1);
- g_value_init (value, GLADE_TYPE_ACCEL_GLIST);
- g_value_take_boxed (value, accels);
+ if (accels)
+ {
+ value = g_new0 (GValue, 1);
+ g_value_init (value, GLADE_TYPE_ACCEL_GLIST);
+ g_value_take_boxed (value, accels);
- property = glade_widget_get_property (widget, "accelerator");
- glade_property_set_value (property, value);
+ property = glade_widget_get_property (widget, "accelerator");
+ glade_property_set_value (property, value);
- g_value_unset (value);
- g_free (value);
- }
+ g_value_unset (value);
+ g_free (value);
+ }
}
static void
-glade_gtk_parse_atk_props (GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *prop;
- GladeProperty *property;
- GValue *gvalue;
- gchar *value, *name, *id, *comment;
- gint translatable;
- gboolean is_action;
-
- for (prop = glade_xml_node_get_children (node);
- prop; prop = glade_xml_node_next (prop))
- {
- if (glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_PROPERTY))
- is_action = FALSE;
- else if (glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_ACTION))
- is_action = TRUE;
- else
- continue;
-
- if (!is_action &&
- !(name = glade_xml_get_property_string_required
- (prop, GLADE_XML_TAG_NAME, NULL)))
- continue;
- else if (is_action &&
- !(name = glade_xml_get_property_string_required
- (prop, GLADE_TAG_A11Y_ACTION_NAME, NULL)))
- continue;
-
-
- /* Make sure we are working with dashes and
- * not underscores ...
- */
- id = glade_util_read_prop_name (name);
- g_free (name);
-
- /* We are namespacing the action properties internally
- * just incase they clash (all property names must be
- * unique...)
- */
- if (is_action)
- {
- name = g_strdup_printf ("atk-%s", id);
- g_free (id);
- id = name;
- }
-
- if ((property = glade_widget_get_property (widget, id)) != NULL)
- {
- /* Complex statement just getting the value here... */
- if ((!is_action &&
- !(value = glade_xml_get_content (prop))) ||
- (is_action &&
- !(value = glade_xml_get_property_string_required
- (prop, GLADE_TAG_A11Y_DESC, NULL))))
- {
- /* XXX should be a glade_xml_get_content_required()... */
- g_free (id);
- continue;
- }
-
- /* Set the parsed value on the property ... */
- gvalue = glade_property_class_make_gvalue_from_string
- (property->klass, value, widget->project, widget);
- glade_property_set_value (property, gvalue);
- g_value_unset (gvalue);
- g_free (gvalue);
-
- /* Deal with i18n... ... XXX Do i18n context !!! */
- translatable = glade_xml_get_property_boolean
- (prop, GLADE_TAG_TRANSLATABLE, FALSE);
- comment = glade_xml_get_property_string
- (prop, GLADE_TAG_COMMENT);
-
- glade_property_i18n_set_translatable
- (property, translatable);
- glade_property_i18n_set_comment
- (property, comment);
-
- g_free (comment);
- g_free (value);
- }
-
- g_free (id);
- }
-}
+glade_gtk_parse_atk_props (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode *prop;
+ GladeProperty *property;
+ GValue *gvalue;
+ gchar *value, *name, *id, *comment;
+ gint translatable;
+ gboolean is_action;
+
+ for (prop = glade_xml_node_get_children (node);
+ prop; prop = glade_xml_node_next (prop))
+ {
+ if (glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_PROPERTY))
+ is_action = FALSE;
+ else if (glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_ACTION))
+ is_action = TRUE;
+ else
+ continue;
+
+ if (!is_action &&
+ !(name = glade_xml_get_property_string_required
+ (prop, GLADE_XML_TAG_NAME, NULL)))
+ continue;
+ else if (is_action &&
+ !(name = glade_xml_get_property_string_required
+ (prop, GLADE_TAG_A11Y_ACTION_NAME, NULL)))
+ continue;
+
+
+ /* Make sure we are working with dashes and
+ * not underscores ...
+ */
+ id = glade_util_read_prop_name (name);
+ g_free (name);
+
+ /* We are namespacing the action properties internally
+ * just incase they clash (all property names must be
+ * unique...)
+ */
+ if (is_action)
+ {
+ name = g_strdup_printf ("atk-%s", id);
+ g_free (id);
+ id = name;
+ }
-static void
-glade_gtk_parse_atk_props_gtkbuilder (GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *child, *object_node;
- gchar *internal;
-
- /* Search for internal "accessible" child and redirect parse from there */
- for (child = glade_xml_node_get_children (node);
- child; child = glade_xml_node_next (child))
- {
- if (glade_xml_node_verify_silent (child, GLADE_XML_TAG_CHILD))
- {
- if ((internal =
- glade_xml_get_property_string (child, GLADE_XML_TAG_INTERNAL_CHILD)))
- {
- if (!strcmp (internal, GLADE_TAG_A11Y_INTERNAL_NAME) &&
- (object_node =
- glade_xml_search_child_required (child, GLADE_XML_TAG_WIDGET)))
- glade_gtk_parse_atk_props (widget, object_node);
-
- g_free (internal);
- }
- }
- }
+ if ((property = glade_widget_get_property (widget, id)) != NULL)
+ {
+ /* Complex statement just getting the value here... */
+ if ((!is_action &&
+ !(value = glade_xml_get_content (prop))) ||
+ (is_action &&
+ !(value = glade_xml_get_property_string_required
+ (prop, GLADE_TAG_A11Y_DESC, NULL))))
+ {
+ /* XXX should be a glade_xml_get_content_required()... */
+ g_free (id);
+ continue;
+ }
+
+ /* Set the parsed value on the property ... */
+ gvalue = glade_property_class_make_gvalue_from_string
+ (property->klass, value, widget->project, widget);
+ glade_property_set_value (property, gvalue);
+ g_value_unset (gvalue);
+ g_free (gvalue);
+
+ /* Deal with i18n... ... XXX Do i18n context !!! */
+ translatable = glade_xml_get_property_boolean
+ (prop, GLADE_TAG_TRANSLATABLE, FALSE);
+ comment = glade_xml_get_property_string (prop, GLADE_TAG_COMMENT);
+
+ glade_property_i18n_set_translatable (property, translatable);
+ glade_property_i18n_set_comment (property, comment);
+
+ g_free (comment);
+ g_free (value);
+ }
+
+ g_free (id);
+ }
}
static void
-glade_gtk_parse_atk_relation (GladeProperty *property,
- GladeXmlNode *node)
-{
- GladeXmlNode *prop;
- gchar *type, *target, *id, *tmp;
- gchar *string = NULL;
-
- for (prop = glade_xml_node_get_children (node);
- prop; prop = glade_xml_node_next (prop))
- {
- if (!glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_RELATION))
- continue;
-
- if (!(type =
- glade_xml_get_property_string_required
- (prop, GLADE_TAG_A11Y_TYPE, NULL)))
- continue;
-
- if (!(target =
- glade_xml_get_property_string_required
- (prop, GLADE_TAG_A11Y_TARGET, NULL)))
- {
- g_free (type);
- continue;
- }
-
- id = glade_util_read_prop_name (type);
-
- if (!strcmp (id, property->klass->id))
- {
- if (string == NULL)
- string = g_strdup (target);
- else
- {
- tmp = g_strdup_printf ("%s%s%s", string,
- GPC_OBJECT_DELIMITER, target);
- string = (g_free (string), tmp);
- }
-
- }
-
- g_free (id);
- g_free (type);
- g_free (target);
- }
-
-
- /* we must synchronize this directly after loading this project
- * (i.e. lookup the actual objects after they've been parsed and
- * are present). this is a feature of object and object list properties
- * that needs a better api.
- */
- if (string)
- {
- g_object_set_data_full (G_OBJECT (property), "glade-loaded-object",
- g_strdup (string), g_free);
- }
+glade_gtk_parse_atk_props_gtkbuilder (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode *child, *object_node;
+ gchar *internal;
+
+ /* Search for internal "accessible" child and redirect parse from there */
+ for (child = glade_xml_node_get_children (node);
+ child; child = glade_xml_node_next (child))
+ {
+ if (glade_xml_node_verify_silent (child, GLADE_XML_TAG_CHILD))
+ {
+ if ((internal =
+ glade_xml_get_property_string (child,
+ GLADE_XML_TAG_INTERNAL_CHILD)))
+ {
+ if (!strcmp (internal, GLADE_TAG_A11Y_INTERNAL_NAME) &&
+ (object_node =
+ glade_xml_search_child_required (child,
+ GLADE_XML_TAG_WIDGET)))
+ glade_gtk_parse_atk_props (widget, object_node);
+
+ g_free (internal);
+ }
+ }
+ }
}
static void
-glade_gtk_widget_read_atk_props (GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *atk_node;
- GladeProperty *property;
- gint i;
+glade_gtk_parse_atk_relation (GladeProperty * property, GladeXmlNode * node)
+{
+ GladeXmlNode *prop;
+ gchar *type, *target, *id, *tmp;
+ gchar *string = NULL;
+
+ for (prop = glade_xml_node_get_children (node);
+ prop; prop = glade_xml_node_next (prop))
+ {
+ if (!glade_xml_node_verify_silent (prop, GLADE_TAG_A11Y_RELATION))
+ continue;
+
+ if (!(type =
+ glade_xml_get_property_string_required
+ (prop, GLADE_TAG_A11Y_TYPE, NULL)))
+ continue;
+
+ if (!(target =
+ glade_xml_get_property_string_required
+ (prop, GLADE_TAG_A11Y_TARGET, NULL)))
+ {
+ g_free (type);
+ continue;
+ }
+
+ id = glade_util_read_prop_name (type);
- glade_gtk_parse_atk_props_gtkbuilder (widget, node);
+ if (!strcmp (id, property->klass->id))
+ {
+ if (string == NULL)
+ string = g_strdup (target);
+ else
+ {
+ tmp = g_strdup_printf ("%s%s%s", string,
+ GPC_OBJECT_DELIMITER, target);
+ string = (g_free (string), tmp);
+ }
+
+ }
- if ((atk_node =
- glade_xml_search_child (node, GLADE_TAG_A11Y_A11Y)) != NULL)
- {
- /* Properties & actions */
- glade_gtk_parse_atk_props (widget, atk_node);
+ g_free (id);
+ g_free (type);
+ g_free (target);
+ }
+
+
+ /* we must synchronize this directly after loading this project
+ * (i.e. lookup the actual objects after they've been parsed and
+ * are present). this is a feature of object and object list properties
+ * that needs a better api.
+ */
+ if (string)
+ {
+ g_object_set_data_full (G_OBJECT (property), "glade-loaded-object",
+ g_strdup (string), g_free);
+ }
+}
- /* Relations */
- for (i = 0; atk_relations_list[i]; i++)
- {
- if ((property =
- glade_widget_get_property (widget,
- atk_relations_list[i])))
- glade_gtk_parse_atk_relation (property, atk_node);
- else
- g_warning ("Couldnt find atk relation %s",
- atk_relations_list[i]);
- }
- }
+static void
+glade_gtk_widget_read_atk_props (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode *atk_node;
+ GladeProperty *property;
+ gint i;
+
+ glade_gtk_parse_atk_props_gtkbuilder (widget, node);
+
+ if ((atk_node = glade_xml_search_child (node, GLADE_TAG_A11Y_A11Y)) != NULL)
+ {
+ /* Properties & actions */
+ glade_gtk_parse_atk_props (widget, atk_node);
+
+ /* Relations */
+ for (i = 0; atk_relations_list[i]; i++)
+ {
+ if ((property =
+ glade_widget_get_property (widget, atk_relations_list[i])))
+ glade_gtk_parse_atk_relation (property, atk_node);
+ else
+ g_warning ("Couldnt find atk relation %s", atk_relations_list[i]);
+ }
+ }
}
void
-glade_gtk_widget_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_widget_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
- /* Read in accelerators */
- glade_gtk_read_accels (widget, node, TRUE);
+ /* Read in accelerators */
+ glade_gtk_read_accels (widget, node, TRUE);
- /* Read in atk props */
- glade_gtk_widget_read_atk_props (widget, node);
+ /* Read in atk props */
+ glade_gtk_widget_read_atk_props (widget, node);
}
static void
-glade_gtk_widget_write_atk_property (GladeProperty *property,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_atk_property (GladeProperty * property,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *prop_node;
- gchar *value;
+ GladeXmlNode *prop_node;
+ gchar *value;
- glade_property_get (property, &value);
- if (value && value[0])
- {
- prop_node = glade_xml_node_new (context, GLADE_TAG_A11Y_PROPERTY);
- glade_xml_node_append_child (node, prop_node);
+ glade_property_get (property, &value);
+ if (value && value[0])
+ {
+ prop_node = glade_xml_node_new (context, GLADE_TAG_A11Y_PROPERTY);
+ glade_xml_node_append_child (node, prop_node);
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_NAME,
- property->klass->id);
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_NAME, property->klass->id);
- glade_xml_set_content (prop_node, value);
+ glade_xml_set_content (prop_node, value);
- /* XXX Do context !!! */
- if (property->i18n_translatable)
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_TRANSLATABLE,
- GLADE_XML_TAG_I18N_TRUE);
+ /* XXX Do context !!! */
+ if (property->i18n_translatable)
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_TRANSLATABLE,
+ GLADE_XML_TAG_I18N_TRUE);
- if (property->i18n_comment)
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_COMMENT,
- property->i18n_comment);
- }
+ if (property->i18n_comment)
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_COMMENT,
+ property->i18n_comment);
+ }
}
static void
-glade_gtk_widget_write_atk_properties (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_atk_properties (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *child_node, *object_node;
- GladeProperty *name_prop, *desc_prop;
+ GladeXmlNode *child_node, *object_node;
+ GladeProperty *name_prop, *desc_prop;
- name_prop = glade_widget_get_property (widget, "AtkObject::accessible-name");
- desc_prop = glade_widget_get_property (widget, "AtkObject::accessible-description");
+ name_prop = glade_widget_get_property (widget, "AtkObject::accessible-name");
+ desc_prop =
+ glade_widget_get_property (widget, "AtkObject::accessible-description");
- /* Create internal child here if any of these properties are non-null */
- if (!glade_property_default (name_prop) ||
- !glade_property_default (desc_prop))
- {
- gchar *atkname = g_strdup_printf ("%s-atkobject", widget->name);
+ /* Create internal child here if any of these properties are non-null */
+ if (!glade_property_default (name_prop) ||
+ !glade_property_default (desc_prop))
+ {
+ gchar *atkname = g_strdup_printf ("%s-atkobject", widget->name);
- child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
- glade_xml_node_append_child (node, child_node);
+ child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
+ glade_xml_node_append_child (node, child_node);
- glade_xml_node_set_property_string (child_node,
- GLADE_XML_TAG_INTERNAL_CHILD,
- GLADE_TAG_A11Y_INTERNAL_NAME);
+ glade_xml_node_set_property_string (child_node,
+ GLADE_XML_TAG_INTERNAL_CHILD,
+ GLADE_TAG_A11Y_INTERNAL_NAME);
- object_node = glade_xml_node_new (context, GLADE_XML_TAG_WIDGET);
- glade_xml_node_append_child (child_node, object_node);
+ object_node = glade_xml_node_new (context, GLADE_XML_TAG_WIDGET);
+ glade_xml_node_append_child (child_node, object_node);
- glade_xml_node_set_property_string (object_node,
- GLADE_XML_TAG_CLASS,
- "AtkObject");
+ glade_xml_node_set_property_string (object_node,
+ GLADE_XML_TAG_CLASS, "AtkObject");
- glade_xml_node_set_property_string (object_node,
- GLADE_XML_TAG_ID,
- atkname);
-
- if (!glade_property_default (name_prop))
- glade_gtk_widget_write_atk_property (name_prop, context, object_node);
- if (!glade_property_default (desc_prop))
- glade_gtk_widget_write_atk_property (desc_prop, context, object_node);
+ glade_xml_node_set_property_string (object_node,
+ GLADE_XML_TAG_ID, atkname);
- g_free (atkname);
- }
+ if (!glade_property_default (name_prop))
+ glade_gtk_widget_write_atk_property (name_prop, context, object_node);
+ if (!glade_property_default (desc_prop))
+ glade_gtk_widget_write_atk_property (desc_prop, context, object_node);
+
+ g_free (atkname);
+ }
}
static void
-glade_gtk_widget_write_atk_relation (GladeProperty *property,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeXmlNode *prop_node;
- gchar *value, **split;
- gint i;
-
- if ((value = glade_widget_adaptor_string_from_value
- (GLADE_WIDGET_ADAPTOR (property->klass->handle),
- property->klass, property->value)) != NULL)
- {
- if ((split = g_strsplit (value, GPC_OBJECT_DELIMITER, 0)) != NULL)
- {
- for (i = 0; split[i] != NULL; i++)
- {
- prop_node = glade_xml_node_new (context,
- GLADE_TAG_A11Y_RELATION);
- glade_xml_node_append_child (node, prop_node);
-
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_A11Y_TYPE,
- property->klass->id);
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_A11Y_TARGET,
- split[i]);
- }
- g_strfreev (split);
- }
- }
+glade_gtk_widget_write_atk_relation (GladeProperty * property,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *prop_node;
+ gchar *value, **split;
+ gint i;
+
+ if ((value = glade_widget_adaptor_string_from_value
+ (GLADE_WIDGET_ADAPTOR (property->klass->handle),
+ property->klass, property->value)) != NULL)
+ {
+ if ((split = g_strsplit (value, GPC_OBJECT_DELIMITER, 0)) != NULL)
+ {
+ for (i = 0; split[i] != NULL; i++)
+ {
+ prop_node = glade_xml_node_new (context, GLADE_TAG_A11Y_RELATION);
+ glade_xml_node_append_child (node, prop_node);
+
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_A11Y_TYPE,
+ property->klass->id);
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_A11Y_TARGET,
+ split[i]);
+ }
+ g_strfreev (split);
+ }
+ }
}
static void
-glade_gtk_widget_write_atk_relations (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_atk_relations (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeProperty *property;
- gint i;
+ GladeProperty *property;
+ gint i;
- for (i = 0; atk_relations_list[i]; i++)
- {
- if ((property =
- glade_widget_get_property (widget,
- atk_relations_list[i])))
- glade_gtk_widget_write_atk_relation (property, context, node);
- else
- g_warning ("Couldnt find atk relation %s on widget %s",
- atk_relations_list[i], widget->name);
- }
+ for (i = 0; atk_relations_list[i]; i++)
+ {
+ if ((property =
+ glade_widget_get_property (widget, atk_relations_list[i])))
+ glade_gtk_widget_write_atk_relation (property, context, node);
+ else
+ g_warning ("Couldnt find atk relation %s on widget %s",
+ atk_relations_list[i], widget->name);
+ }
}
static void
-glade_gtk_widget_write_atk_action (GladeProperty *property,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_atk_action (GladeProperty * property,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *prop_node;
- gchar *value = NULL;
+ GladeXmlNode *prop_node;
+ gchar *value = NULL;
- glade_property_get (property, &value);
+ glade_property_get (property, &value);
- if (value && value[0])
- {
- prop_node = glade_xml_node_new (context, GLADE_TAG_A11Y_ACTION);
- glade_xml_node_append_child (node, prop_node);
+ if (value && value[0])
+ {
+ prop_node = glade_xml_node_new (context, GLADE_TAG_A11Y_ACTION);
+ glade_xml_node_append_child (node, prop_node);
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_A11Y_ACTION_NAME,
- &property->klass->id[4]);
- glade_xml_node_set_property_string (prop_node,
- GLADE_TAG_A11Y_DESC,
- value);
- }
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_A11Y_ACTION_NAME,
+ &property->klass->id[4]);
+ glade_xml_node_set_property_string (prop_node,
+ GLADE_TAG_A11Y_DESC, value);
+ }
}
static void
-glade_gtk_widget_write_atk_actions (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_atk_actions (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeProperty *property;
+ GladeProperty *property;
- if ((property = glade_widget_get_property (widget, "atk-click")) != NULL)
- glade_gtk_widget_write_atk_action (property, context, node);
- if ((property = glade_widget_get_property (widget, "atk-activate")) != NULL)
- glade_gtk_widget_write_atk_action (property, context, node);
- if ((property = glade_widget_get_property (widget, "atk-press")) != NULL)
- glade_gtk_widget_write_atk_action (property, context, node);
- if ((property = glade_widget_get_property (widget, "atk-release")) != NULL)
- glade_gtk_widget_write_atk_action (property, context, node);
+ if ((property = glade_widget_get_property (widget, "atk-click")) != NULL)
+ glade_gtk_widget_write_atk_action (property, context, node);
+ if ((property = glade_widget_get_property (widget, "atk-activate")) != NULL)
+ glade_gtk_widget_write_atk_action (property, context, node);
+ if ((property = glade_widget_get_property (widget, "atk-press")) != NULL)
+ glade_gtk_widget_write_atk_action (property, context, node);
+ if ((property = glade_widget_get_property (widget, "atk-release")) != NULL)
+ glade_gtk_widget_write_atk_action (property, context, node);
}
static void
-glade_gtk_widget_write_atk_props (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_atk_props (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *atk_node;
+ GladeXmlNode *atk_node;
- atk_node = glade_xml_node_new (context, GLADE_TAG_A11Y_A11Y);
+ atk_node = glade_xml_node_new (context, GLADE_TAG_A11Y_A11Y);
- glade_gtk_widget_write_atk_relations (widget, context, atk_node);
- glade_gtk_widget_write_atk_actions (widget, context, atk_node);
+ glade_gtk_widget_write_atk_relations (widget, context, atk_node);
+ glade_gtk_widget_write_atk_actions (widget, context, atk_node);
- if (!glade_xml_node_get_children (atk_node))
- glade_xml_node_delete (atk_node);
- else
- glade_xml_node_append_child (node, atk_node);
+ if (!glade_xml_node_get_children (atk_node))
+ glade_xml_node_delete (atk_node);
+ else
+ glade_xml_node_append_child (node, atk_node);
- glade_gtk_widget_write_atk_properties (widget, context, node);
+ glade_gtk_widget_write_atk_properties (widget, context, node);
}
static void
-glade_gtk_write_accels (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node,
- gboolean write_signal)
+glade_gtk_write_accels (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node, gboolean write_signal)
{
- GladeXmlNode *accel_node;
- GladeProperty *property;
- GList *list;
+ GladeXmlNode *accel_node;
+ GladeProperty *property;
+ GList *list;
- /* Some child widgets may have disabled the property */
- if (!(property = glade_widget_get_property (widget, "accelerator")))
- return;
+ /* Some child widgets may have disabled the property */
+ if (!(property = glade_widget_get_property (widget, "accelerator")))
+ return;
- for (list = g_value_get_boxed (property->value);
- list; list = list->next)
- {
- GladeAccelInfo *accel = list->data;
+ for (list = g_value_get_boxed (property->value); list; list = list->next)
+ {
+ GladeAccelInfo *accel = list->data;
- accel_node = glade_accel_write (accel, context, write_signal);
- glade_xml_node_append_child (node, accel_node);
- }
+ accel_node = glade_accel_write (accel, context, write_signal);
+ glade_xml_node_append_child (node, accel_node);
+ }
}
void
-glade_gtk_widget_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_widget_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
- /* The core takes care of signals */
- glade_gtk_write_accels (widget, context, node, TRUE);
- glade_gtk_widget_write_atk_props (widget, context, node);
+ /* The core takes care of signals */
+ glade_gtk_write_accels (widget, context, node, TRUE);
+ glade_gtk_widget_write_atk_props (widget, context, node);
}
GladeEditorProperty *
-glade_gtk_widget_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
-{
- GladeEditorProperty *eprop;
-
- /* chain up.. */
- if (klass->pspec->value_type == GLADE_TYPE_ACCEL_GLIST)
- eprop = g_object_new (GLADE_TYPE_EPROP_ACCEL,
- "property-class", klass,
- "use-command", use_command,
- NULL);
- else
- eprop = GWA_GET_CLASS
- (G_TYPE_OBJECT)->create_eprop (adaptor,
- klass,
- use_command);
- return eprop;
+glade_gtk_widget_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass, gboolean use_command)
+{
+ GladeEditorProperty *eprop;
+
+ /* chain up.. */
+ if (klass->pspec->value_type == GLADE_TYPE_ACCEL_GLIST)
+ eprop = g_object_new (GLADE_TYPE_EPROP_ACCEL,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ else
+ eprop = GWA_GET_CLASS
+ (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
+ return eprop;
}
gchar *
-glade_gtk_widget_string_from_value (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- const GValue *value)
+glade_gtk_widget_string_from_value (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ const GValue * value)
{
- if (klass->pspec->value_type == GLADE_TYPE_ACCEL_GLIST)
- return glade_accels_make_string (g_value_get_boxed (value));
- else
- return GWA_GET_CLASS
- (G_TYPE_OBJECT)->string_from_value (adaptor,
- klass,
- value);
+ if (klass->pspec->value_type == GLADE_TYPE_ACCEL_GLIST)
+ return glade_accels_make_string (g_value_get_boxed (value));
+ else
+ return GWA_GET_CLASS
+ (G_TYPE_OBJECT)->string_from_value (adaptor, klass, value);
}
static void
-widget_parent_changed (GtkWidget *widget,
- GParamSpec *pspec,
- GladeWidgetAdaptor *adaptor)
+widget_parent_changed (GtkWidget * widget,
+ GParamSpec * pspec, GladeWidgetAdaptor * adaptor)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (widget);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (widget);
- /* this could get called for a stale instance of an object
- * being rebuilt for a contruct-only property. */
- if (!gwidget)
- return;
+ /* this could get called for a stale instance of an object
+ * being rebuilt for a contruct-only property. */
+ if (!gwidget)
+ return;
- if (gwidget->parent && gwidget->parent->internal == NULL)
- glade_widget_set_action_sensitive (gwidget, "remove_parent", TRUE);
- else
- glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
+ if (gwidget->parent && gwidget->parent->internal == NULL)
+ glade_widget_set_action_sensitive (gwidget, "remove_parent", TRUE);
+ else
+ glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
}
void
-glade_gtk_widget_deep_post_create (GladeWidgetAdaptor *adaptor,
- GObject *widget,
- GladeCreateReason reason)
+glade_gtk_widget_deep_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * widget, GladeCreateReason reason)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (widget);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (widget);
+
+ /* Work around bug 472555 by resetting the default event mask,
+ * this way only user edits will be saved to the glade file. */
+ if (reason == GLADE_CREATE_USER)
+ glade_widget_property_reset (gwidget, "events");
- /* Work around bug 472555 by resetting the default event mask,
- * this way only user edits will be saved to the glade file. */
- if (reason == GLADE_CREATE_USER)
- glade_widget_property_reset (gwidget, "events");
-
- glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
+ glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
- if (GWA_IS_TOPLEVEL (adaptor) || gwidget->internal)
- glade_widget_set_action_sensitive (gwidget, "add_parent", FALSE);
+ if (GWA_IS_TOPLEVEL (adaptor) || gwidget->internal)
+ glade_widget_set_action_sensitive (gwidget, "add_parent", FALSE);
- /* Watch parents/projects and set actions sensitive/insensitive */
- if (gwidget->internal == NULL)
- g_signal_connect (G_OBJECT (widget), "notify::parent",
- G_CALLBACK (widget_parent_changed), adaptor);
-
+ /* Watch parents/projects and set actions sensitive/insensitive */
+ if (gwidget->internal == NULL)
+ g_signal_connect (G_OBJECT (widget), "notify::parent",
+ G_CALLBACK (widget_parent_changed), adaptor);
+
}
void
-glade_gtk_widget_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_widget_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- /* FIXME: is this still needed with the new gtk+ tooltips? */
- if (!strcmp (id, "tooltip"))
- {
- id = "tooltip-text";
- }
+ /* FIXME: is this still needed with the new gtk+ tooltips? */
+ if (!strcmp (id, "tooltip"))
+ {
+ id = "tooltip-text";
+ }
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
}
void
-glade_gtk_widget_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- GValue *value)
+glade_gtk_widget_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, GValue * value)
{
- if (!strcmp (id, "tooltip"))
- {
- id = "tooltip-text";
- }
-
- GWA_GET_CLASS (G_TYPE_OBJECT)->get_property (adaptor, object, id, value);
+ if (!strcmp (id, "tooltip"))
+ {
+ id = "tooltip-text";
+ }
+
+ GWA_GET_CLASS (G_TYPE_OBJECT)->get_property (adaptor, object, id, value);
+}
+
+static GList *
+create_command_property_list (GladeWidget * gnew, GList * saved_props)
+{
+ GList *l, *command_properties = NULL;
+
+ for (l = saved_props; l; l = l->next)
+ {
+ GladeProperty *property = l->data;
+ GladeProperty *orig_prop =
+ glade_widget_get_pack_property (gnew, property->klass->id);
+ GCSetPropData *pdata = g_new0 (GCSetPropData, 1);
+
+ pdata->property = orig_prop;
+ pdata->old_value = g_new0 (GValue, 1);
+ pdata->new_value = g_new0 (GValue, 1);
+
+ glade_property_get_value (orig_prop, pdata->old_value);
+ glade_property_get_value (property, pdata->new_value);
+
+ command_properties = g_list_prepend (command_properties, pdata);
+ }
+ return g_list_reverse (command_properties);
+}
+
+
+void
+glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * action_path)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object), *gparent;
+ GList this_widget = { 0, }, that_widget =
+ {
+ 0,};
+ GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (object));
+ GladeProject *project;
+
+ if (parent)
+ gparent = glade_widget_get_from_gobject (parent);
+ else
+ gparent = NULL;
+
+ if (strcmp (action_path, "preview") == 0)
+ {
+ project = glade_widget_get_project (gwidget);
+ glade_project_preview (project,
+ glade_widget_get_from_gobject ((gpointer) object));
+ }
+ else if (strcmp (action_path, "edit_separate") == 0)
+ {
+ GtkWidget *dialog = glade_editor_dialog_for_widget (gwidget);
+ gtk_widget_show_all (dialog);
+ }
+ else if (strcmp (action_path, "remove_parent") == 0)
+ {
+ GladeWidget *new_gparent;
+
+ g_return_if_fail (gparent);
+ new_gparent = gparent->parent;
+
+ glade_command_push_group (_("Removing parent of %s"), gwidget->name);
+
+ /* Remove "this" widget */
+ this_widget.data = gwidget;
+ glade_command_cut (&this_widget);
+
+ /* Delete the parent */
+ that_widget.data = gparent;
+ glade_command_delete (&that_widget);
+
+ /* Add "this" widget to the new parent */
+ glade_command_paste (&this_widget, new_gparent, NULL);
+
+ glade_command_pop_group ();
+ }
+ else if (strncmp (action_path, "add_parent/", 11) == 0)
+ {
+ GType new_type = 0;
+
+ if (strcmp (action_path + 11, "alignment") == 0)
+ new_type = GTK_TYPE_ALIGNMENT;
+ else if (strcmp (action_path + 11, "viewport") == 0)
+ new_type = GTK_TYPE_VIEWPORT;
+ else if (strcmp (action_path + 11, "eventbox") == 0)
+ new_type = GTK_TYPE_EVENT_BOX;
+ else if (strcmp (action_path + 11, "frame") == 0)
+ new_type = GTK_TYPE_FRAME;
+ else if (strcmp (action_path + 11, "aspect_frame") == 0)
+ new_type = GTK_TYPE_ASPECT_FRAME;
+ else if (strcmp (action_path + 11, "scrolled_window") == 0)
+ new_type = GTK_TYPE_SCROLLED_WINDOW;
+ else if (strcmp (action_path + 11, "expander") == 0)
+ new_type = GTK_TYPE_EXPANDER;
+ else if (strcmp (action_path + 11, "table") == 0)
+ new_type = GTK_TYPE_TABLE;
+ else if (strcmp (action_path + 11, "hbox") == 0)
+ new_type = GTK_TYPE_HBOX;
+ else if (strcmp (action_path + 11, "vbox") == 0)
+ new_type = GTK_TYPE_VBOX;
+ else if (strcmp (action_path + 11, "hpaned") == 0)
+ new_type = GTK_TYPE_HPANED;
+ else if (strcmp (action_path + 11, "vpaned") == 0)
+ new_type = GTK_TYPE_VPANED;
+
+
+ if (new_type)
+ {
+ GladeWidgetAdaptor *adaptor =
+ glade_widget_adaptor_get_by_type (new_type);
+ GList *saved_props, *prop_cmds;
+ GladeProject *project;
+
+ /* Dont add non-scrollable widgets to scrolled windows... */
+ if (gparent &&
+ glade_util_check_and_warn_scrollable (gparent, adaptor,
+ glade_app_get_window ()))
+ return;
+
+ glade_command_push_group (_("Adding parent %s for %s"),
+ adaptor->title, gwidget->name);
+
+ /* Record packing properties */
+ saved_props =
+ glade_widget_dup_properties (gwidget, gwidget->packing_properties,
+ FALSE, FALSE, FALSE);
+
+ /* Remove "this" widget */
+ this_widget.data = gwidget;
+ glade_command_cut (&this_widget);
+
+ if (gparent)
+ project = glade_widget_get_project (gparent);
+ else
+ project = glade_app_get_project ();
+
+ /* Create new widget and put it where the placeholder was */
+ if ((that_widget.data =
+ glade_command_create (adaptor, gparent, NULL, project)) != NULL)
+ {
+
+ /* Remove the alignment that we added in the frame's post_create... */
+ if (new_type == GTK_TYPE_FRAME)
+ {
+ GObject *frame = glade_widget_get_object (that_widget.data);
+ GladeWidget *galign =
+ glade_widget_get_from_gobject (gtk_bin_get_child
+ (GTK_BIN (frame)));
+ GList to_delete = { 0, };
+
+ to_delete.data = galign;
+ glade_command_delete (&to_delete);
+ }
+
+ /* Create heavy-duty glade-command properties stuff */
+ prop_cmds =
+ create_command_property_list (that_widget.data, saved_props);
+ g_list_foreach (saved_props, (GFunc) g_object_unref, NULL);
+ g_list_free (saved_props);
+
+ /* Apply the properties in an undoable way */
+ if (prop_cmds)
+ glade_command_set_properties_list (glade_widget_get_project
+ (gparent), prop_cmds);
+
+ /* Add "this" widget to the new parent */
+ glade_command_paste (&this_widget,
+ GLADE_WIDGET (that_widget.data), NULL);
+ }
+ else
+ /* Create parent was cancelled, paste back to parent */
+ glade_command_paste (&this_widget, gparent, NULL);
+
+ glade_command_pop_group ();
+ }
+ }
+ else if (strcmp (action_path, "sizegroup_add") == 0)
+ {
+ /* Ignore dummy */
+ }
+ else
+ GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
+ object, action_path);
}
static GList *
-create_command_property_list (GladeWidget *gnew, GList *saved_props)
-{
- GList *l, *command_properties = NULL;
-
- for (l = saved_props; l; l = l->next)
- {
- GladeProperty *property = l->data;
- GladeProperty *orig_prop = glade_widget_get_pack_property (gnew, property->klass->id);
- GCSetPropData *pdata = g_new0 (GCSetPropData, 1);
-
- pdata->property = orig_prop;
- pdata->old_value = g_new0 (GValue, 1);
- pdata->new_value = g_new0 (GValue, 1);
-
- glade_property_get_value (orig_prop, pdata->old_value);
- glade_property_get_value (property, pdata->new_value);
-
- command_properties = g_list_prepend (command_properties, pdata);
- }
- return g_list_reverse (command_properties);
-}
-
-
-void
-glade_gtk_widget_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
-{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object), *gparent;
- GList this_widget = { 0, }, that_widget = { 0, };
- GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (object));
- GladeProject *project;
-
- if (parent)
- gparent = glade_widget_get_from_gobject (parent);
- else
- gparent = NULL;
-
- if (strcmp (action_path, "preview") == 0)
- {
- project = glade_widget_get_project (gwidget);
- glade_project_preview (project,
- glade_widget_get_from_gobject((gpointer)object)
- );
- }
- else if (strcmp (action_path, "edit_separate") == 0)
- {
- GtkWidget *dialog =
- glade_editor_dialog_for_widget (gwidget);
- gtk_widget_show_all (dialog);
- }
- else if (strcmp (action_path, "remove_parent") == 0)
- {
- GladeWidget *new_gparent;
-
- g_return_if_fail (gparent);
- new_gparent = gparent->parent;
-
- glade_command_push_group (_("Removing parent of %s"),
- gwidget->name);
-
- /* Remove "this" widget */
- this_widget.data = gwidget;
- glade_command_cut (&this_widget);
-
- /* Delete the parent */
- that_widget.data = gparent;
- glade_command_delete (&that_widget);
-
- /* Add "this" widget to the new parent */
- glade_command_paste(&this_widget, new_gparent, NULL);
-
- glade_command_pop_group ();
- }
- else if (strncmp (action_path, "add_parent/", 11) == 0)
- {
- GType new_type = 0;
-
- if (strcmp (action_path + 11, "alignment") == 0)
- new_type = GTK_TYPE_ALIGNMENT;
- else if (strcmp (action_path + 11, "viewport") == 0)
- new_type = GTK_TYPE_VIEWPORT;
- else if (strcmp (action_path + 11, "eventbox") == 0)
- new_type = GTK_TYPE_EVENT_BOX;
- else if (strcmp (action_path + 11, "frame") == 0)
- new_type = GTK_TYPE_FRAME;
- else if (strcmp (action_path + 11, "aspect_frame") == 0)
- new_type = GTK_TYPE_ASPECT_FRAME;
- else if (strcmp (action_path + 11, "scrolled_window") == 0)
- new_type = GTK_TYPE_SCROLLED_WINDOW;
- else if (strcmp (action_path + 11, "expander") == 0)
- new_type = GTK_TYPE_EXPANDER;
- else if (strcmp (action_path + 11, "table") == 0)
- new_type = GTK_TYPE_TABLE;
- else if (strcmp (action_path + 11, "hbox") == 0)
- new_type = GTK_TYPE_HBOX;
- else if (strcmp (action_path + 11, "vbox") == 0)
- new_type = GTK_TYPE_VBOX;
- else if (strcmp (action_path + 11, "hpaned") == 0)
- new_type = GTK_TYPE_HPANED;
- else if (strcmp (action_path + 11, "vpaned") == 0)
- new_type = GTK_TYPE_VPANED;
-
-
- if (new_type)
- {
- GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (new_type);
- GList *saved_props, *prop_cmds;
- GladeProject *project;
-
- /* Dont add non-scrollable widgets to scrolled windows... */
- if (gparent &&
- glade_util_check_and_warn_scrollable (gparent, adaptor, glade_app_get_window()))
- return;
-
- glade_command_push_group (_("Adding parent %s for %s"),
- adaptor->title, gwidget->name);
-
- /* Record packing properties */
- saved_props = glade_widget_dup_properties (gwidget, gwidget->packing_properties, FALSE, FALSE, FALSE);
-
- /* Remove "this" widget */
- this_widget.data = gwidget;
- glade_command_cut (&this_widget);
-
- if (gparent)
- project = glade_widget_get_project (gparent);
- else
- project = glade_app_get_project ();
-
- /* Create new widget and put it where the placeholder was */
- if ((that_widget.data =
- glade_command_create (adaptor, gparent, NULL, project)) != NULL)
- {
-
- /* Remove the alignment that we added in the frame's post_create... */
- if (new_type == GTK_TYPE_FRAME)
- {
- GObject *frame = glade_widget_get_object (that_widget.data);
- GladeWidget *galign = glade_widget_get_from_gobject (gtk_bin_get_child (GTK_BIN (frame)));
- GList to_delete = { 0, };
-
- to_delete.data = galign;
- glade_command_delete (&to_delete);
- }
-
- /* Create heavy-duty glade-command properties stuff */
- prop_cmds = create_command_property_list (that_widget.data, saved_props);
- g_list_foreach (saved_props, (GFunc)g_object_unref, NULL);
- g_list_free (saved_props);
-
- /* Apply the properties in an undoable way */
- if (prop_cmds)
- glade_command_set_properties_list (glade_widget_get_project (gparent), prop_cmds);
-
- /* Add "this" widget to the new parent */
- glade_command_paste(&this_widget, GLADE_WIDGET (that_widget.data), NULL);
- }
- else
- /* Create parent was cancelled, paste back to parent */
- glade_command_paste(&this_widget, gparent, NULL);
-
- glade_command_pop_group ();
- }
- }
- else if (strcmp (action_path, "sizegroup_add") == 0)
- {
- /* Ignore dummy */
- }
- else
- GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
- object,
- action_path);
-}
-
-static GList *list_sizegroups (GladeWidget *gwidget)
-{
- GladeProject *project = glade_widget_get_project (gwidget);
- GList *groups = NULL;
- const GList *list;
-
- for (list = glade_project_get_objects (project); list; list = list->next)
- {
- GladeWidget *iter = glade_widget_get_from_gobject (list->data);
- if (GTK_IS_SIZE_GROUP (iter->object))
- groups = g_list_prepend (groups, iter);
- }
- return g_list_reverse (groups);
+list_sizegroups (GladeWidget * gwidget)
+{
+ GladeProject *project = glade_widget_get_project (gwidget);
+ GList *groups = NULL;
+ const GList *list;
+
+ for (list = glade_project_get_objects (project); list; list = list->next)
+ {
+ GladeWidget *iter = glade_widget_get_from_gobject (list->data);
+ if (GTK_IS_SIZE_GROUP (iter->object))
+ groups = g_list_prepend (groups, iter);
+ }
+ return g_list_reverse (groups);
}
static void
-glade_gtk_widget_add2group_cb (GtkMenuItem *item, GladeWidget *gwidget)
+glade_gtk_widget_add2group_cb (GtkMenuItem * item, GladeWidget * gwidget)
{
- GladeWidget *group = g_object_get_data (G_OBJECT (item), "glade-group-widget");
- GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SIZE_GROUP);
- GList *widget_list = NULL, *new_list;
- GladeProperty *property;
+ GladeWidget *group =
+ g_object_get_data (G_OBJECT (item), "glade-group-widget");
+ GladeWidgetAdaptor *adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_SIZE_GROUP);
+ GList *widget_list = NULL, *new_list;
+ GladeProperty *property;
- if (group)
- glade_command_push_group (_("Adding %s to Size Group %s"), gwidget->name, group->name);
- else
- glade_command_push_group (_("Adding %s to a new Size Group"), gwidget->name);
+ if (group)
+ glade_command_push_group (_("Adding %s to Size Group %s"), gwidget->name,
+ group->name);
+ else
+ glade_command_push_group (_("Adding %s to a new Size Group"),
+ gwidget->name);
- if (!group)
- /* Cant cancel a size group */
- group = glade_command_create (adaptor, NULL, NULL, glade_widget_get_project (gwidget));
-
- property = glade_widget_get_property (group, "widgets");
- glade_property_get (property, &widget_list);
- new_list = g_list_copy (widget_list);
- if (!g_list_find (widget_list, gwidget->object))
- new_list = g_list_append (new_list, gwidget->object);
- glade_command_set_property (property, new_list);
+ if (!group)
+ /* Cant cancel a size group */
+ group =
+ glade_command_create (adaptor, NULL, NULL,
+ glade_widget_get_project (gwidget));
- g_list_free (new_list);
-
- glade_command_pop_group ();
-}
+ property = glade_widget_get_property (group, "widgets");
+ glade_property_get (property, &widget_list);
+ new_list = g_list_copy (widget_list);
+ if (!g_list_find (widget_list, gwidget->object))
+ new_list = g_list_append (new_list, gwidget->object);
+ glade_command_set_property (property, new_list);
+ g_list_free (new_list);
-GtkWidget *
-glade_gtk_widget_action_submenu (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
-{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GList *groups, *list;
-
- if (strcmp (action_path, "sizegroup_add") == 0)
- {
- GtkWidget *menu = gtk_menu_new ();
- GtkWidget *separator, *item;
- GladeWidget *group;
-
- if ((groups = list_sizegroups (gwidget)) != NULL)
- {
- for (list = groups; list; list = list->next)
- {
- group = list->data;
- item = gtk_menu_item_new_with_label (group->name);
-
- g_object_set_data (G_OBJECT (item), "glade-group-widget", group);
- g_signal_connect (G_OBJECT (item), "activate",
- G_CALLBACK (glade_gtk_widget_add2group_cb), gwidget);
-
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
- g_list_free (groups);
-
- separator = gtk_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
- gtk_widget_show (separator);
- }
-
- /* Add trailing new... item */
- item = gtk_menu_item_new_with_label (_("New Size Group"));
- g_signal_connect (G_OBJECT (item), "activate",
- G_CALLBACK (glade_gtk_widget_add2group_cb), gwidget);
-
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- return menu;
- }
- else if (GWA_GET_CLASS (G_TYPE_OBJECT)->action_submenu)
- return GWA_GET_CLASS (G_TYPE_OBJECT)->action_submenu (adaptor,
- object,
- action_path);
-
- return NULL;
+ glade_command_pop_group ();
}
+GtkWidget *
+glade_gtk_widget_action_submenu (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * action_path)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GList *groups, *list;
+
+ if (strcmp (action_path, "sizegroup_add") == 0)
+ {
+ GtkWidget *menu = gtk_menu_new ();
+ GtkWidget *separator, *item;
+ GladeWidget *group;
+
+ if ((groups = list_sizegroups (gwidget)) != NULL)
+ {
+ for (list = groups; list; list = list->next)
+ {
+ group = list->data;
+ item = gtk_menu_item_new_with_label (group->name);
+
+ g_object_set_data (G_OBJECT (item), "glade-group-widget", group);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (glade_gtk_widget_add2group_cb),
+ gwidget);
+
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ }
+ g_list_free (groups);
+
+ separator = gtk_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
+ gtk_widget_show (separator);
+ }
-/* ----------------------------- GtkContainer ------------------------------ */
-void
-glade_gtk_container_post_create (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GladeCreateReason reason)
-{
- GList *children;
- g_return_if_fail (GTK_IS_CONTAINER (container));
-
- if (reason == GLADE_CREATE_USER)
- {
- if ((children = gtk_container_get_children (GTK_CONTAINER (container))) == NULL)
- gtk_container_add (GTK_CONTAINER (container), glade_placeholder_new ());
- else
- g_list_free (children);
- }
-}
+ /* Add trailing new... item */
+ item = gtk_menu_item_new_with_label (_("New Size Group"));
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (glade_gtk_widget_add2group_cb), gwidget);
-void
-glade_gtk_container_replace_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *current,
- GtkWidget *new_widget)
-{
- GParamSpec **param_spec;
- GladePropertyClass *pclass;
- GValue *value;
- guint nproperties;
- guint i;
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- if (gtk_widget_get_parent (current) != container)
- return;
+ return menu;
+ }
+ else if (GWA_GET_CLASS (G_TYPE_OBJECT)->action_submenu)
+ return GWA_GET_CLASS (G_TYPE_OBJECT)->action_submenu (adaptor,
+ object, action_path);
- param_spec = gtk_container_class_list_child_properties
- (G_OBJECT_GET_CLASS (container), &nproperties);
- value = g_malloc0 (sizeof(GValue) * nproperties);
+ return NULL;
+}
- for (i = 0; i < nproperties; i++)
- {
- g_value_init (&value[i], param_spec[i]->value_type);
- gtk_container_child_get_property
- (GTK_CONTAINER (container), current, param_spec[i]->name, &value[i]);
- }
- gtk_container_remove (GTK_CONTAINER (container), current);
- gtk_container_add (GTK_CONTAINER (container), new_widget);
- for (i = 0; i < nproperties; i++)
- {
- /* If the added widget is a placeholder then we
- * want to keep all the "tranfer-on-paste" properties
- * as default so that it looks fresh (transfer-on-paste
- * properties dont effect the position/slot inside a
- * contianer)
- */
- if (GLADE_IS_PLACEHOLDER (new_widget))
- {
- pclass = glade_widget_adaptor_get_pack_property_class
- (adaptor, param_spec[i]->name);
+/* ----------------------------- GtkContainer ------------------------------ */
+void
+glade_gtk_container_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * container, GladeCreateReason reason)
+{
+ GList *children;
+ g_return_if_fail (GTK_IS_CONTAINER (container));
+
+ if (reason == GLADE_CREATE_USER)
+ {
+ if ((children =
+ gtk_container_get_children (GTK_CONTAINER (container))) == NULL)
+ gtk_container_add (GTK_CONTAINER (container), glade_placeholder_new ());
+ else
+ g_list_free (children);
+ }
+}
+
+void
+glade_gtk_container_replace_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container,
+ GtkWidget * current, GtkWidget * new_widget)
+{
+ GParamSpec **param_spec;
+ GladePropertyClass *pclass;
+ GValue *value;
+ guint nproperties;
+ guint i;
+
+ if (gtk_widget_get_parent (current) != container)
+ return;
+
+ param_spec = gtk_container_class_list_child_properties
+ (G_OBJECT_GET_CLASS (container), &nproperties);
+ value = g_malloc0 (sizeof (GValue) * nproperties);
+
+ for (i = 0; i < nproperties; i++)
+ {
+ g_value_init (&value[i], param_spec[i]->value_type);
+ gtk_container_child_get_property
+ (GTK_CONTAINER (container), current, param_spec[i]->name, &value[i]);
+ }
+
+ gtk_container_remove (GTK_CONTAINER (container), current);
+ gtk_container_add (GTK_CONTAINER (container), new_widget);
+
+ for (i = 0; i < nproperties; i++)
+ {
+ /* If the added widget is a placeholder then we
+ * want to keep all the "tranfer-on-paste" properties
+ * as default so that it looks fresh (transfer-on-paste
+ * properties dont effect the position/slot inside a
+ * contianer)
+ */
+ if (GLADE_IS_PLACEHOLDER (new_widget))
+ {
+ pclass = glade_widget_adaptor_get_pack_property_class
+ (adaptor, param_spec[i]->name);
+
+ if (pclass && pclass->transfer_on_paste)
+ continue;
+ }
- if (pclass && pclass->transfer_on_paste)
- continue;
- }
+ gtk_container_child_set_property
+ (GTK_CONTAINER (container), new_widget, param_spec[i]->name,
+ &value[i]);
+ }
- gtk_container_child_set_property
- (GTK_CONTAINER (container), new_widget, param_spec[i]->name, &value[i]);
- }
-
- for (i = 0; i < nproperties; i++)
- g_value_unset (&value[i]);
+ for (i = 0; i < nproperties; i++)
+ g_value_unset (&value[i]);
- g_free (param_spec);
- g_free (value);
+ g_free (param_spec);
+ g_free (value);
}
void
-glade_gtk_container_add_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *child)
+glade_gtk_container_add_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container, GtkWidget * child)
{
- GtkWidget *container_child = NULL;
+ GtkWidget *container_child = NULL;
- if (GTK_IS_BIN (container))
- container_child = gtk_bin_get_child (GTK_BIN (container));
+ if (GTK_IS_BIN (container))
+ container_child = gtk_bin_get_child (GTK_BIN (container));
- /* Get a placeholder out of the way before adding the child if its a GtkBin
- */
- if (GTK_IS_BIN (container) && container_child != NULL &&
- GLADE_IS_PLACEHOLDER (container_child))
- gtk_container_remove (GTK_CONTAINER (container), container_child);
+ /* Get a placeholder out of the way before adding the child if its a GtkBin
+ */
+ if (GTK_IS_BIN (container) && container_child != NULL &&
+ GLADE_IS_PLACEHOLDER (container_child))
+ gtk_container_remove (GTK_CONTAINER (container), container_child);
- gtk_container_add (GTK_CONTAINER (container), child);
+ gtk_container_add (GTK_CONTAINER (container), child);
}
void
-glade_gtk_container_remove_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *child)
+glade_gtk_container_remove_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container, GtkWidget * child)
{
- GList *children;
- gtk_container_remove (GTK_CONTAINER (container), child);
+ GList *children;
+ gtk_container_remove (GTK_CONTAINER (container), child);
- /* If this is the last one, add a placeholder by default.
- */
- if ((children = gtk_container_get_children (GTK_CONTAINER (container))) == NULL)
- {
- gtk_container_add (GTK_CONTAINER (container), glade_placeholder_new ());
- }
- else
- g_list_free (children);
+ /* If this is the last one, add a placeholder by default.
+ */
+ if ((children =
+ gtk_container_get_children (GTK_CONTAINER (container))) == NULL)
+ {
+ gtk_container_add (GTK_CONTAINER (container), glade_placeholder_new ());
+ }
+ else
+ g_list_free (children);
}
void
-glade_gtk_container_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_container_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
{
- if (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (container))
- gtk_container_child_set_property (GTK_CONTAINER (container),
- GTK_WIDGET (child),
- property_name, value);
+ if (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (container))
+ gtk_container_child_set_property (GTK_CONTAINER (container),
+ GTK_WIDGET (child), property_name, value);
}
void
-glade_gtk_container_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
+glade_gtk_container_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
{
- if (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (container))
- gtk_container_child_get_property (GTK_CONTAINER (container),
- GTK_WIDGET (child),
- property_name, value);
+ if (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (container))
+ gtk_container_child_get_property (GTK_CONTAINER (container),
+ GTK_WIDGET (child), property_name, value);
}
GList *
-glade_gtk_container_get_children (GladeWidgetAdaptor *adaptor,
- GtkContainer *container)
+glade_gtk_container_get_children (GladeWidgetAdaptor * adaptor,
+ GtkContainer * container)
{
- return glade_util_container_get_all_children (container);
+ return glade_util_container_get_all_children (container);
}
GladeEditable *
-glade_gtk_container_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_container_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+ return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
}
/* ----------------------------- GtkBox ------------------------------ */
GladeWidget *
-glade_gtk_create_fixed_widget (GladeWidgetAdaptor *adaptor,
- const gchar *first_property_name,
- va_list var_args)
+glade_gtk_create_fixed_widget (GladeWidgetAdaptor * adaptor,
+ const gchar * first_property_name,
+ va_list var_args)
{
- return (GladeWidget *)g_object_new_valist (GLADE_TYPE_FIXED, first_property_name, var_args);
+ return (GladeWidget *) g_object_new_valist (GLADE_TYPE_FIXED,
+ first_property_name, var_args);
}
-typedef struct {
- GtkWidget *widget;
- gint position;
+typedef struct
+{
+ GtkWidget *widget;
+ gint position;
} GladeGtkBoxChild;
static GList *glade_gtk_box_original_positions = NULL;
static gboolean
-glade_gtk_box_configure_child (GladeFixed *fixed,
- GladeWidget *child,
- GdkRectangle *rect,
- GtkWidget *box)
-{
- GList *list, *children;
- GtkWidget *bchild;
- GtkAllocation allocation, bchild_allocation;
- gint point, trans_point, span,
- iter_span, position, old_position,
- offset, orig_offset;
- gboolean found = FALSE;
-
- gtk_widget_get_allocation (GTK_WIDGET (child->object), &allocation);
- if (GTK_IS_HBOX (box) || GTK_IS_HBUTTON_BOX (box))
- {
- point = fixed->mouse_x;
- span = allocation.width;
- offset = rect->x;
- orig_offset = fixed->child_x_origin;
- }
- else
- {
- point = fixed->mouse_y;
- span = allocation.height;
- offset = rect->y;
- orig_offset = fixed->child_y_origin;
- }
-
- glade_widget_pack_property_get
- (child, "position", &old_position);
-
- children = gtk_container_get_children (GTK_CONTAINER (box));
-
- for (list = children; list; list = list->next)
- {
- bchild = list->data;
-
- if (bchild == GTK_WIDGET (child->object))
- continue;
-
- /* Find the widget in the box where the center of
- * this rectangle fits... and set the position to that
- * position.
- */
-
- gtk_widget_get_allocation (GTK_WIDGET (bchild), &bchild_allocation);
- if (GTK_IS_HBOX (box) || GTK_IS_HBUTTON_BOX (box))
- {
- gtk_widget_translate_coordinates
- (GTK_WIDGET (box), bchild,
- point, 0, &trans_point, NULL);
-
- iter_span = bchild_allocation.width;
- }
- else
- {
- gtk_widget_translate_coordinates
- (GTK_WIDGET (box), bchild,
- 0, point, NULL, &trans_point);
- iter_span = bchild_allocation.height;
- }
+glade_gtk_box_configure_child (GladeFixed * fixed,
+ GladeWidget * child,
+ GdkRectangle * rect, GtkWidget * box)
+{
+ GList *list, *children;
+ GtkWidget *bchild;
+ GtkAllocation allocation, bchild_allocation;
+ gint point, trans_point, span,
+ iter_span, position, old_position, offset, orig_offset;
+ gboolean found = FALSE;
+
+ gtk_widget_get_allocation (GTK_WIDGET (child->object), &allocation);
+ if (GTK_IS_HBOX (box) || GTK_IS_HBUTTON_BOX (box))
+ {
+ point = fixed->mouse_x;
+ span = allocation.width;
+ offset = rect->x;
+ orig_offset = fixed->child_x_origin;
+ }
+ else
+ {
+ point = fixed->mouse_y;
+ span = allocation.height;
+ offset = rect->y;
+ orig_offset = fixed->child_y_origin;
+ }
+
+ glade_widget_pack_property_get (child, "position", &old_position);
+
+ children = gtk_container_get_children (GTK_CONTAINER (box));
+
+ for (list = children; list; list = list->next)
+ {
+ bchild = list->data;
+
+ if (bchild == GTK_WIDGET (child->object))
+ continue;
+
+ /* Find the widget in the box where the center of
+ * this rectangle fits... and set the position to that
+ * position.
+ */
+
+ gtk_widget_get_allocation (GTK_WIDGET (bchild), &bchild_allocation);
+ if (GTK_IS_HBOX (box) || GTK_IS_HBUTTON_BOX (box))
+ {
+ gtk_widget_translate_coordinates
+ (GTK_WIDGET (box), bchild, point, 0, &trans_point, NULL);
+
+ iter_span = bchild_allocation.width;
+ }
+ else
+ {
+ gtk_widget_translate_coordinates
+ (GTK_WIDGET (box), bchild, 0, point, NULL, &trans_point);
+ iter_span = bchild_allocation.height;
+ }
#if 0
- gtk_container_child_get (GTK_CONTAINER (box),
- bchild,
- "position", &position, NULL);
- g_print ("widget: %p pos %d, point %d, trans_point %d, iter_span %d\n",
- bchild, position, point, trans_point, iter_span);
+ gtk_container_child_get (GTK_CONTAINER (box),
+ bchild, "position", &position, NULL);
+ g_print ("widget: %p pos %d, point %d, trans_point %d, iter_span %d\n",
+ bchild, position, point, trans_point, iter_span);
#endif
- if (iter_span <= span)
- {
- found = trans_point >= 0 && trans_point < iter_span;
- }
- else
- {
- if (offset > orig_offset)
- found = trans_point >= iter_span - span &&
- trans_point < iter_span;
- else if (offset < orig_offset)
- found = trans_point >= 0 &&
- trans_point < span;
- }
-
- if (found)
- {
- gtk_container_child_get (GTK_CONTAINER (box),
- bchild,
- "position", &position, NULL);
+ if (iter_span <= span)
+ {
+ found = trans_point >= 0 && trans_point < iter_span;
+ }
+ else
+ {
+ if (offset > orig_offset)
+ found = trans_point >= iter_span - span && trans_point < iter_span;
+ else if (offset < orig_offset)
+ found = trans_point >= 0 && trans_point < span;
+ }
+
+ if (found)
+ {
+ gtk_container_child_get (GTK_CONTAINER (box),
+ bchild, "position", &position, NULL);
#if 0
- g_print ("setting position of %s from %d to %d, "
- "(point %d iter_span %d)\n",
- child->name, old_position, position, trans_point, iter_span);
+ g_print ("setting position of %s from %d to %d, "
+ "(point %d iter_span %d)\n",
+ child->name, old_position, position, trans_point, iter_span);
#endif
- glade_widget_pack_property_set
- (child, "position", position);
-
- break;
- }
+ glade_widget_pack_property_set (child, "position", position);
+
+ break;
+ }
- }
+ }
- g_list_free (children);
+ g_list_free (children);
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_gtk_box_configure_begin (GladeFixed *fixed,
- GladeWidget *child,
- GtkWidget *box)
+glade_gtk_box_configure_begin (GladeFixed * fixed,
+ GladeWidget * child, GtkWidget * box)
{
- GList *list, *children;
- GtkWidget *bchild;
+ GList *list, *children;
+ GtkWidget *bchild;
- g_assert (glade_gtk_box_original_positions == NULL);
+ g_assert (glade_gtk_box_original_positions == NULL);
- children = gtk_container_get_children (GTK_CONTAINER (box));
+ children = gtk_container_get_children (GTK_CONTAINER (box));
- for (list = children; list; list = list->next)
- {
- GladeGtkBoxChild *gbchild;
- GladeWidget *gchild;
-
- bchild = list->data;
- if ((gchild = glade_widget_get_from_gobject (bchild)) == NULL)
- continue;
+ for (list = children; list; list = list->next)
+ {
+ GladeGtkBoxChild *gbchild;
+ GladeWidget *gchild;
- gbchild = g_new0 (GladeGtkBoxChild, 1);
- gbchild->widget = bchild;
- glade_widget_pack_property_get (gchild, "position",
- &gbchild->position);
+ bchild = list->data;
+ if ((gchild = glade_widget_get_from_gobject (bchild)) == NULL)
+ continue;
- glade_gtk_box_original_positions =
- g_list_prepend (glade_gtk_box_original_positions, gbchild);
- }
+ gbchild = g_new0 (GladeGtkBoxChild, 1);
+ gbchild->widget = bchild;
+ glade_widget_pack_property_get (gchild, "position", &gbchild->position);
- g_list_free (children);
+ glade_gtk_box_original_positions =
+ g_list_prepend (glade_gtk_box_original_positions, gbchild);
+ }
- return TRUE;
+ g_list_free (children);
+
+ return TRUE;
}
static gboolean
-glade_gtk_box_configure_end (GladeFixed *fixed,
- GladeWidget *child,
- GtkWidget *box)
+glade_gtk_box_configure_end (GladeFixed * fixed,
+ GladeWidget * child, GtkWidget * box)
{
- GList *list, *l, *children;
- GList *prop_list = NULL;
+ GList *list, *l, *children;
+ GList *prop_list = NULL;
- children = gtk_container_get_children (GTK_CONTAINER (box));
+ children = gtk_container_get_children (GTK_CONTAINER (box));
- for (list = children; list; list = list->next)
- {
- GtkWidget *bchild = list->data;
+ for (list = children; list; list = list->next)
+ {
+ GtkWidget *bchild = list->data;
- for (l = glade_gtk_box_original_positions; l; l = l->next)
- {
- GladeGtkBoxChild *gbchild = l->data;
- GladeWidget *gchild =
- glade_widget_get_from_gobject (gbchild->widget);
+ for (l = glade_gtk_box_original_positions; l; l = l->next)
+ {
+ GladeGtkBoxChild *gbchild = l->data;
+ GladeWidget *gchild = glade_widget_get_from_gobject (gbchild->widget);
- if (bchild == gbchild->widget)
- {
- GCSetPropData *prop_data = g_new0 (GCSetPropData, 1);
- prop_data->property =
- glade_widget_get_pack_property
- (gchild, "position");
+ if (bchild == gbchild->widget)
+ {
+ GCSetPropData *prop_data = g_new0 (GCSetPropData, 1);
+ prop_data->property =
+ glade_widget_get_pack_property (gchild, "position");
- prop_data->old_value = g_new0 (GValue, 1);
- prop_data->new_value = g_new0 (GValue, 1);
+ prop_data->old_value = g_new0 (GValue, 1);
+ prop_data->new_value = g_new0 (GValue, 1);
- glade_property_get_value (prop_data->property,
- prop_data->new_value);
+ glade_property_get_value (prop_data->property,
+ prop_data->new_value);
- g_value_init (prop_data->old_value, G_TYPE_INT);
- g_value_set_int (prop_data->old_value, gbchild->position);
+ g_value_init (prop_data->old_value, G_TYPE_INT);
+ g_value_set_int (prop_data->old_value, gbchild->position);
- prop_list = g_list_prepend (prop_list, prop_data);
- break;
- }
- }
- }
+ prop_list = g_list_prepend (prop_list, prop_data);
+ break;
+ }
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- glade_command_push_group (_("Ordering children of %s"),
- GLADE_WIDGET (fixed)->name);
- glade_property_push_superuser ();
- if (prop_list)
- glade_command_set_properties_list (GLADE_WIDGET (fixed)->project,
- prop_list);
- glade_property_pop_superuser ();
- glade_command_pop_group ();
+ glade_command_push_group (_("Ordering children of %s"),
+ GLADE_WIDGET (fixed)->name);
+ glade_property_push_superuser ();
+ if (prop_list)
+ glade_command_set_properties_list (GLADE_WIDGET (fixed)->project,
+ prop_list);
+ glade_property_pop_superuser ();
+ glade_command_pop_group ();
- for (l = glade_gtk_box_original_positions; l; l = l->next)
- g_free (l->data);
+ for (l = glade_gtk_box_original_positions; l; l = l->next)
+ g_free (l->data);
- glade_gtk_box_original_positions =
- (g_list_free (glade_gtk_box_original_positions), NULL);
+ glade_gtk_box_original_positions =
+ (g_list_free (glade_gtk_box_original_positions), NULL);
- return TRUE;
+ return TRUE;
}
void
-glade_gtk_box_post_create (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GladeCreateReason reason)
+glade_gtk_box_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * container, GladeCreateReason reason)
{
- GladeWidget *gwidget =
- glade_widget_get_from_gobject (container);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (container);
- /* Implement drag in GtkBox but not resize.
- */
- g_object_set (gwidget,
- "can-resize", FALSE,
- NULL);
+ /* Implement drag in GtkBox but not resize.
+ */
+ g_object_set (gwidget, "can-resize", FALSE, NULL);
- g_signal_connect (G_OBJECT (gwidget), "configure-child",
- G_CALLBACK (glade_gtk_box_configure_child), container);
+ g_signal_connect (G_OBJECT (gwidget), "configure-child",
+ G_CALLBACK (glade_gtk_box_configure_child), container);
- g_signal_connect (G_OBJECT (gwidget), "configure-begin",
- G_CALLBACK (glade_gtk_box_configure_begin), container);
+ g_signal_connect (G_OBJECT (gwidget), "configure-begin",
+ G_CALLBACK (glade_gtk_box_configure_begin), container);
- g_signal_connect (G_OBJECT (gwidget), "configure-end",
- G_CALLBACK (glade_gtk_box_configure_end), container);
+ g_signal_connect (G_OBJECT (gwidget), "configure-end",
+ G_CALLBACK (glade_gtk_box_configure_end), container);
}
static gint
-sort_box_children (GtkWidget *widget_a, GtkWidget *widget_b)
+sort_box_children (GtkWidget * widget_a, GtkWidget * widget_b)
{
- GtkWidget *box;
- GladeWidget *gwidget_a, *gwidget_b;
- gint position_a, position_b;
+ GtkWidget *box;
+ GladeWidget *gwidget_a, *gwidget_b;
+ gint position_a, position_b;
- gwidget_a = glade_widget_get_from_gobject (widget_a);
- gwidget_b = glade_widget_get_from_gobject (widget_b);
+ gwidget_a = glade_widget_get_from_gobject (widget_a);
+ gwidget_b = glade_widget_get_from_gobject (widget_b);
- box = gtk_widget_get_parent (widget_a);
+ box = gtk_widget_get_parent (widget_a);
- if (gwidget_a)
- glade_widget_pack_property_get
- (gwidget_a, "position", &position_a);
- else
- gtk_container_child_get (GTK_CONTAINER (box),
- widget_a,
- "position", &position_a,
- NULL);
+ if (gwidget_a)
+ glade_widget_pack_property_get (gwidget_a, "position", &position_a);
+ else
+ gtk_container_child_get (GTK_CONTAINER (box),
+ widget_a, "position", &position_a, NULL);
- if (gwidget_b)
- glade_widget_pack_property_get
- (gwidget_b, "position", &position_b);
- else
- gtk_container_child_get (GTK_CONTAINER (box),
- widget_b,
- "position", &position_b,
- NULL);
- return position_a - position_b;
+ if (gwidget_b)
+ glade_widget_pack_property_get (gwidget_b, "position", &position_b);
+ else
+ gtk_container_child_get (GTK_CONTAINER (box),
+ widget_b, "position", &position_b, NULL);
+ return position_a - position_b;
}
GList *
-glade_gtk_box_get_children (GladeWidgetAdaptor *adaptor,
- GtkContainer *container)
-{
- GList *children = glade_util_container_get_all_children (container);
-
- return g_list_sort (children, (GCompareFunc)sort_box_children);
-}
-
-void
-glade_gtk_box_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- GladeWidget *gbox, *gchild, *gchild_iter;
- GList *children, *list;
- gboolean is_position;
- gint old_position, iter_position, new_position;
- static gboolean recursion = FALSE;
-
- g_return_if_fail (GTK_IS_BOX (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (property_name != NULL || value != NULL);
-
- gbox = glade_widget_get_from_gobject (container);
- gchild = glade_widget_get_from_gobject (child);
-
- g_return_if_fail (GLADE_IS_WIDGET (gbox));
-
- if (gtk_widget_get_parent (GTK_WIDGET (child)) != GTK_WIDGET (container))
- return;
-
- /* Get old position */
- if ((is_position = (strcmp (property_name, "position") == 0)) != FALSE)
- {
- gtk_container_child_get (GTK_CONTAINER (container),
- GTK_WIDGET (child),
- property_name, &old_position, NULL);
-
-
- /* Get the real value */
- new_position = g_value_get_int (value);
- }
-
- if (is_position && recursion == FALSE)
- {
- children = glade_widget_adaptor_get_children
- (gbox->adaptor, container);
-
- children = g_list_sort (children, (GCompareFunc)sort_box_children);
-
- for (list = children; list; list = list->next)
- {
- if ((gchild_iter =
- glade_widget_get_from_gobject (list->data)) == NULL)
- continue;
-
- if (gchild_iter == gchild)
- {
- gtk_box_reorder_child (GTK_BOX (container),
- GTK_WIDGET (child),
- new_position);
- continue;
- }
-
- /* Get the old value from glade */
- glade_widget_pack_property_get
- (gchild_iter, "position", &iter_position);
-
- /* Search for the child at the old position and update it */
- if (iter_position == new_position &&
- glade_property_superuser () == FALSE)
- {
- /* Update glade with the real value */
- recursion = TRUE;
- glade_widget_pack_property_set
- (gchild_iter, "position", old_position);
- recursion = FALSE;
- continue;
- }
- else
- {
- gtk_box_reorder_child (GTK_BOX (container),
- GTK_WIDGET (list->data),
- iter_position);
- }
- }
-
- for (list = children; list; list = list->next)
- {
- if ((gchild_iter =
- glade_widget_get_from_gobject (list->data)) == NULL)
- continue;
-
- /* Refresh values yet again */
- glade_widget_pack_property_get
- (gchild_iter, "position", &iter_position);
-
- gtk_box_reorder_child (GTK_BOX (container),
- GTK_WIDGET (list->data),
- iter_position);
-
- }
-
- if (children)
- g_list_free (children);
- }
-
- /* Chain Up */
- if (!is_position)
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container,
- child,
- property_name,
- value);
-
- gtk_container_check_resize (GTK_CONTAINER (container));
-
-}
-
-void
-glade_gtk_box_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- GValue *value)
-{
- if (!strcmp (id, "size"))
- {
- GtkBox *box = GTK_BOX (object);
- GList *children = gtk_container_get_children (GTK_CONTAINER (box));
-
- g_value_reset (value);
- g_value_set_int (value, g_list_length (children));
- g_list_free (children);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_property (adaptor, object, id, value);
+glade_gtk_box_get_children (GladeWidgetAdaptor * adaptor,
+ GtkContainer * container)
+{
+ GList *children = glade_util_container_get_all_children (container);
+
+ return g_list_sort (children, (GCompareFunc) sort_box_children);
+}
+
+void
+glade_gtk_box_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name, GValue * value)
+{
+ GladeWidget *gbox, *gchild, *gchild_iter;
+ GList *children, *list;
+ gboolean is_position;
+ gint old_position, iter_position, new_position;
+ static gboolean recursion = FALSE;
+
+ g_return_if_fail (GTK_IS_BOX (container));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (property_name != NULL || value != NULL);
+
+ gbox = glade_widget_get_from_gobject (container);
+ gchild = glade_widget_get_from_gobject (child);
+
+ g_return_if_fail (GLADE_IS_WIDGET (gbox));
+
+ if (gtk_widget_get_parent (GTK_WIDGET (child)) != GTK_WIDGET (container))
+ return;
+
+ /* Get old position */
+ if ((is_position = (strcmp (property_name, "position") == 0)) != FALSE)
+ {
+ gtk_container_child_get (GTK_CONTAINER (container),
+ GTK_WIDGET (child),
+ property_name, &old_position, NULL);
+
+
+ /* Get the real value */
+ new_position = g_value_get_int (value);
+ }
+
+ if (is_position && recursion == FALSE)
+ {
+ children = glade_widget_adaptor_get_children (gbox->adaptor, container);
+
+ children = g_list_sort (children, (GCompareFunc) sort_box_children);
+
+ for (list = children; list; list = list->next)
+ {
+ if ((gchild_iter =
+ glade_widget_get_from_gobject (list->data)) == NULL)
+ continue;
+
+ if (gchild_iter == gchild)
+ {
+ gtk_box_reorder_child (GTK_BOX (container),
+ GTK_WIDGET (child), new_position);
+ continue;
+ }
+
+ /* Get the old value from glade */
+ glade_widget_pack_property_get
+ (gchild_iter, "position", &iter_position);
+
+ /* Search for the child at the old position and update it */
+ if (iter_position == new_position &&
+ glade_property_superuser () == FALSE)
+ {
+ /* Update glade with the real value */
+ recursion = TRUE;
+ glade_widget_pack_property_set
+ (gchild_iter, "position", old_position);
+ recursion = FALSE;
+ continue;
+ }
+ else
+ {
+ gtk_box_reorder_child (GTK_BOX (container),
+ GTK_WIDGET (list->data), iter_position);
+ }
+ }
+
+ for (list = children; list; list = list->next)
+ {
+ if ((gchild_iter =
+ glade_widget_get_from_gobject (list->data)) == NULL)
+ continue;
+
+ /* Refresh values yet again */
+ glade_widget_pack_property_get
+ (gchild_iter, "position", &iter_position);
+
+ gtk_box_reorder_child (GTK_BOX (container),
+ GTK_WIDGET (list->data), iter_position);
+
+ }
+
+ if (children)
+ g_list_free (children);
+ }
+
+ /* Chain Up */
+ if (!is_position)
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container,
+ child, property_name, value);
+
+ gtk_container_check_resize (GTK_CONTAINER (container));
+
+}
+
+void
+glade_gtk_box_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * id, GValue * value)
+{
+ if (!strcmp (id, "size"))
+ {
+ GtkBox *box = GTK_BOX (object);
+ GList *children = gtk_container_get_children (GTK_CONTAINER (box));
+
+ g_value_reset (value);
+ g_value_set_int (value, g_list_length (children));
+ g_list_free (children);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_property (adaptor, object, id,
+ value);
}
static gint
-glade_gtk_box_get_first_blank (GtkBox *box)
+glade_gtk_box_get_first_blank (GtkBox * box)
{
- GList *child, *children;
- GladeWidget *gwidget;
- gint position;
+ GList *child, *children;
+ GladeWidget *gwidget;
+ gint position;
- children = gtk_container_get_children (GTK_CONTAINER (box));
+ children = gtk_container_get_children (GTK_CONTAINER (box));
- for (child = children, position = 0;
- child && child->data;
- child = child->next, position++)
- {
- GtkWidget *widget = child->data;
+ for (child = children, position = 0;
+ child && child->data; child = child->next, position++)
+ {
+ GtkWidget *widget = child->data;
- if ((gwidget = glade_widget_get_from_gobject (widget)) != NULL)
- {
- gint gwidget_position;
- GladeProperty *property =
- glade_widget_get_pack_property (gwidget, "position");
- gwidget_position = g_value_get_int (property->value);
+ if ((gwidget = glade_widget_get_from_gobject (widget)) != NULL)
+ {
+ gint gwidget_position;
+ GladeProperty *property =
+ glade_widget_get_pack_property (gwidget, "position");
+ gwidget_position = g_value_get_int (property->value);
- if (gwidget_position > position)
- break;
- }
- }
+ if (gwidget_position > position)
+ break;
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- return position;
+ return position;
}
static void
-glade_gtk_box_set_size (GObject *object, const GValue *value)
-{
- GtkBox *box;
- GList *child, *children;
- guint new_size, old_size, i;
-
- box = GTK_BOX (object);
- g_return_if_fail (GTK_IS_BOX (box));
-
- if (glade_util_object_is_loading (object))
- return;
-
- children = gtk_container_get_children (GTK_CONTAINER (box));
-
- old_size = g_list_length (children);
- new_size = g_value_get_int (value);
-
- if (old_size == new_size)
- {
- g_list_free (children);
- return;
- }
-
- /* Ensure placeholders first...
- */
- for (i = 0; i < new_size; i++)
- {
- if (g_list_length(children) < (i + 1))
- {
- GtkWidget *placeholder = glade_placeholder_new ();
- gint blank = glade_gtk_box_get_first_blank (box);
-
- gtk_container_add (GTK_CONTAINER (box), placeholder);
- gtk_box_reorder_child (box, placeholder, blank);
- }
- }
-
- /* The box has shrunk. Remove the widgets that are on those slots */
- for (child = g_list_last (children);
- child && old_size > new_size;
- child = g_list_last (children), old_size--)
- {
- GtkWidget *child_widget = child->data;
-
- /* Refuse to remove any widgets that are either GladeWidget objects
- * or internal to the hierarchic entity (may be a composite widget,
- * not all internal widgets have GladeWidgets).
- */
- if (glade_widget_get_from_gobject (child_widget) ||
- GLADE_IS_PLACEHOLDER (child_widget) == FALSE)
- break;
-
- g_object_ref (G_OBJECT (child_widget));
- gtk_container_remove (GTK_CONTAINER (box), child_widget);
- gtk_widget_destroy (child_widget);
- }
- g_list_free (children);
-
-}
-
-void
-glade_gtk_box_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "size"))
- glade_gtk_box_set_size (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
+glade_gtk_box_set_size (GObject * object, const GValue * value)
+{
+ GtkBox *box;
+ GList *child, *children;
+ guint new_size, old_size, i;
+
+ box = GTK_BOX (object);
+ g_return_if_fail (GTK_IS_BOX (box));
+
+ if (glade_util_object_is_loading (object))
+ return;
+
+ children = gtk_container_get_children (GTK_CONTAINER (box));
+
+ old_size = g_list_length (children);
+ new_size = g_value_get_int (value);
+
+ if (old_size == new_size)
+ {
+ g_list_free (children);
+ return;
+ }
+
+ /* Ensure placeholders first...
+ */
+ for (i = 0; i < new_size; i++)
+ {
+ if (g_list_length (children) < (i + 1))
+ {
+ GtkWidget *placeholder = glade_placeholder_new ();
+ gint blank = glade_gtk_box_get_first_blank (box);
+
+ gtk_container_add (GTK_CONTAINER (box), placeholder);
+ gtk_box_reorder_child (box, placeholder, blank);
+ }
+ }
+
+ /* The box has shrunk. Remove the widgets that are on those slots */
+ for (child = g_list_last (children);
+ child && old_size > new_size; child = g_list_last (children), old_size--)
+ {
+ GtkWidget *child_widget = child->data;
+
+ /* Refuse to remove any widgets that are either GladeWidget objects
+ * or internal to the hierarchic entity (may be a composite widget,
+ * not all internal widgets have GladeWidgets).
+ */
+ if (glade_widget_get_from_gobject (child_widget) ||
+ GLADE_IS_PLACEHOLDER (child_widget) == FALSE)
+ break;
+
+ g_object_ref (G_OBJECT (child_widget));
+ gtk_container_remove (GTK_CONTAINER (box), child_widget);
+ gtk_widget_destroy (child_widget);
+ }
+ g_list_free (children);
+
}
-static gboolean
-glade_gtk_box_verify_size (GObject *object, const GValue *value)
+void
+glade_gtk_box_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- GtkBox *box = GTK_BOX(object);
- GList *child, *children;
- gboolean will_orphan = FALSE;
- gint old_size;
- gint new_size = g_value_get_int (value);
+ if (!strcmp (id, "size"))
+ glade_gtk_box_set_size (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
+ value);
+}
- children = gtk_container_get_children (GTK_CONTAINER (box));
- old_size = g_list_length (children);
+static gboolean
+glade_gtk_box_verify_size (GObject * object, const GValue * value)
+{
+ GtkBox *box = GTK_BOX (object);
+ GList *child, *children;
+ gboolean will_orphan = FALSE;
+ gint old_size;
+ gint new_size = g_value_get_int (value);
+
+ children = gtk_container_get_children (GTK_CONTAINER (box));
+ old_size = g_list_length (children);
+
+ for (child = g_list_last (children);
+ child && old_size > new_size;
+ child = g_list_previous (child), old_size--)
+ {
+ GtkWidget *widget = child->data;
+ if (glade_widget_get_from_gobject (widget) != NULL)
+ {
+ /* In this case, refuse to shrink */
+ will_orphan = TRUE;
+ break;
+ }
+ }
- for (child = g_list_last (children);
- child && old_size > new_size;
- child = g_list_previous (child), old_size--)
- {
- GtkWidget *widget = child->data;
- if (glade_widget_get_from_gobject (widget) != NULL)
- {
- /* In this case, refuse to shrink */
- will_orphan = TRUE;
- break;
- }
- }
-
- g_list_free (children);
+ g_list_free (children);
- return will_orphan ? FALSE : new_size >= 0;
+ return will_orphan ? FALSE : new_size >= 0;
}
gboolean
-glade_gtk_box_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_box_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "size"))
- return glade_gtk_box_verify_size (object, value);
- else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
- return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
- id, value);
+ if (!strcmp (id, "size"))
+ return glade_gtk_box_verify_size (object, value);
+ else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
+ return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
+ id, value);
- return TRUE;
+ return TRUE;
}
static void
-fix_response_id_on_child (GladeWidget *gbox,
- GObject *child,
- gboolean add)
-{
- GladeWidget *gchild;
- const gchar *internal_name;
-
- gchild = glade_widget_get_from_gobject (child);
-
- /* Fix response id property on child buttons */
- if (gchild && GTK_IS_BUTTON (child))
- {
- if (add && (internal_name = glade_widget_get_internal (gbox)) &&
- !strcmp (internal_name, "action_area"))
- {
- glade_widget_property_set_sensitive (gchild, "response-id", TRUE, NULL);
- glade_widget_property_set_enabled (gchild, "response-id", TRUE);
- }
- else
- {
- glade_widget_property_set_sensitive (gchild, "response-id", FALSE,
- RESPID_INSENSITIVE_MSG);
- glade_widget_property_set_enabled (gchild, "response-id", FALSE);
-
- }
- }
-}
-
-
-void
-glade_gtk_box_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- GladeWidget *gbox, *gchild;
- GladeProject *project;
- GList *children;
- gint num_children;
-
- g_return_if_fail (GTK_IS_BOX (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- gbox = glade_widget_get_from_gobject (object);
- project = glade_widget_get_project (gbox);
-
- /*
- Try to remove the last placeholder if any, this way GtkBox`s size
- will not be changed.
- */
- if (glade_widget_superuser () == FALSE &&
- !GLADE_IS_PLACEHOLDER (child))
- {
- GList *l, *children;
- GtkBox *box = GTK_BOX (object);
-
- children = gtk_container_get_children (GTK_CONTAINER (box));
-
- for (l = g_list_last (children); l; l = g_list_previous (l))
- {
- GtkWidget *child_widget = l->data;
- if (GLADE_IS_PLACEHOLDER (child_widget))
- {
- gtk_container_remove (GTK_CONTAINER (box), child_widget);
- break;
- }
- }
- g_list_free (children);
- }
-
- gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
-
- children = gtk_container_get_children (GTK_CONTAINER (object));
- num_children = g_list_length (children);
- g_list_free (children);
-
- glade_widget_property_set (gbox, "size", num_children);
-
- gchild = glade_widget_get_from_gobject (child);
-
- /* The "Remove Slot" operation only makes sence on placeholders,
- * otherwise its a "Delete" operation on the child widget.
- */
- if (gchild)
- glade_widget_remove_pack_action (gchild, "remove_slot");
-
- /* Packing props arent around when parenting during a glade_widget_dup() */
- if (gchild && gchild->packing_properties)
- glade_widget_pack_property_set (gchild, "position", num_children - 1);
-
-
- fix_response_id_on_child (gbox, child, TRUE);
-}
-
-void
-glade_gtk_box_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- GladeWidget *gbox;
- gint size;
-
- g_return_if_fail (GTK_IS_BOX (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- gbox = glade_widget_get_from_gobject (object);
-
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
-
- if (glade_widget_superuser () == FALSE)
- {
- glade_widget_property_get (gbox, "size", &size);
- glade_widget_property_set (gbox, "size", size);
- }
+fix_response_id_on_child (GladeWidget * gbox, GObject * child, gboolean add)
+{
+ GladeWidget *gchild;
+ const gchar *internal_name;
+
+ gchild = glade_widget_get_from_gobject (child);
+
+ /* Fix response id property on child buttons */
+ if (gchild && GTK_IS_BUTTON (child))
+ {
+ if (add && (internal_name = glade_widget_get_internal (gbox)) &&
+ !strcmp (internal_name, "action_area"))
+ {
+ glade_widget_property_set_sensitive (gchild, "response-id", TRUE,
+ NULL);
+ glade_widget_property_set_enabled (gchild, "response-id", TRUE);
+ }
+ else
+ {
+ glade_widget_property_set_sensitive (gchild, "response-id", FALSE,
+ RESPID_INSENSITIVE_MSG);
+ glade_widget_property_set_enabled (gchild, "response-id", FALSE);
+
+ }
+ }
+}
+
+
+void
+glade_gtk_box_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GladeWidget *gbox, *gchild;
+ GladeProject *project;
+ GList *children;
+ gint num_children;
+
+ g_return_if_fail (GTK_IS_BOX (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ gbox = glade_widget_get_from_gobject (object);
+ project = glade_widget_get_project (gbox);
+
+ /*
+ Try to remove the last placeholder if any, this way GtkBox`s size
+ will not be changed.
+ */
+ if (glade_widget_superuser () == FALSE && !GLADE_IS_PLACEHOLDER (child))
+ {
+ GList *l, *children;
+ GtkBox *box = GTK_BOX (object);
+
+ children = gtk_container_get_children (GTK_CONTAINER (box));
+
+ for (l = g_list_last (children); l; l = g_list_previous (l))
+ {
+ GtkWidget *child_widget = l->data;
+ if (GLADE_IS_PLACEHOLDER (child_widget))
+ {
+ gtk_container_remove (GTK_CONTAINER (box), child_widget);
+ break;
+ }
+ }
+ g_list_free (children);
+ }
+
+ gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+
+ children = gtk_container_get_children (GTK_CONTAINER (object));
+ num_children = g_list_length (children);
+ g_list_free (children);
+
+ glade_widget_property_set (gbox, "size", num_children);
+
+ gchild = glade_widget_get_from_gobject (child);
+
+ /* The "Remove Slot" operation only makes sence on placeholders,
+ * otherwise its a "Delete" operation on the child widget.
+ */
+ if (gchild)
+ glade_widget_remove_pack_action (gchild, "remove_slot");
+
+ /* Packing props arent around when parenting during a glade_widget_dup() */
+ if (gchild && gchild->packing_properties)
+ glade_widget_pack_property_set (gchild, "position", num_children - 1);
+
+
+ fix_response_id_on_child (gbox, child, TRUE);
+}
- fix_response_id_on_child (gbox, child, FALSE);
+void
+glade_gtk_box_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GladeWidget *gbox;
+ gint size;
+
+ g_return_if_fail (GTK_IS_BOX (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ gbox = glade_widget_get_from_gobject (object);
+
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+
+ if (glade_widget_superuser () == FALSE)
+ {
+ glade_widget_property_get (gbox, "size", &size);
+ glade_widget_property_set (gbox, "size", size);
+ }
+
+ fix_response_id_on_child (gbox, child, FALSE);
}
void
-glade_gtk_box_replace_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *current,
- GObject *new_widget)
+glade_gtk_box_replace_child (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * current, GObject * new_widget)
{
- GladeWidget *gchild;
- GladeWidget *gbox;
+ GladeWidget *gchild;
+ GladeWidget *gbox;
- g_object_ref (G_OBJECT (current));
+ g_object_ref (G_OBJECT (current));
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor,
- container,
- current,
- new_widget);
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor,
+ container,
+ current, new_widget);
- if ((gchild = glade_widget_get_from_gobject (new_widget)) != NULL)
- /* The "Remove Slot" operation only makes sence on placeholders,
- * otherwise its a "Delete" operation on the child widget.
- */
- glade_widget_remove_pack_action (gchild, "remove_slot");
+ if ((gchild = glade_widget_get_from_gobject (new_widget)) != NULL)
+ /* The "Remove Slot" operation only makes sence on placeholders,
+ * otherwise its a "Delete" operation on the child widget.
+ */
+ glade_widget_remove_pack_action (gchild, "remove_slot");
- gbox = glade_widget_get_from_gobject (container);
- fix_response_id_on_child (gbox, current, FALSE);
- fix_response_id_on_child (gbox, new_widget, TRUE);
+ gbox = glade_widget_get_from_gobject (container);
+ fix_response_id_on_child (gbox, current, FALSE);
+ fix_response_id_on_child (gbox, new_widget, TRUE);
- g_object_unref (G_OBJECT (current));
+ g_object_unref (G_OBJECT (current));
}
GObject *
-glade_gtk_box_get_internal_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *name)
-{
- GList *children, *l;
- GObject *child = NULL;
-
- g_return_val_if_fail (GTK_IS_BOX (object), NULL);
-
- children = l = gtk_container_get_children (GTK_CONTAINER (object));
-
- while (l)
- {
- GladeWidget *gw = glade_widget_get_from_gobject (l->data);
-
- if (gw && gw->internal && strcmp (gw->internal, name) == 0)
- {
- child = G_OBJECT (l->data);
- break;
- }
-
- l= l->next;
- }
- g_list_free (children);
-
- return child;
+glade_gtk_box_get_internal_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * name)
+{
+ GList *children, *l;
+ GObject *child = NULL;
+
+ g_return_val_if_fail (GTK_IS_BOX (object), NULL);
+
+ children = l = gtk_container_get_children (GTK_CONTAINER (object));
+
+ while (l)
+ {
+ GladeWidget *gw = glade_widget_get_from_gobject (l->data);
+
+ if (gw && gw->internal && strcmp (gw->internal, name) == 0)
+ {
+ child = G_OBJECT (l->data);
+ break;
+ }
+
+ l = l->next;
+ }
+ g_list_free (children);
+
+ return child;
}
static void
-glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *size_prop,
- const gchar *group_format,
- gboolean remove,
- gboolean after);
-
-void
-glade_gtk_box_child_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *action_path)
-{
- if (strcmp (action_path, "insert_after") == 0)
- {
- glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
- object, "size",
- _("Insert placeholder to %s"),
- FALSE, TRUE);
- }
- else if (strcmp (action_path, "insert_before") == 0)
- {
- glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
- object, "size",
- _("Insert placeholder to %s"),
- FALSE, FALSE);
- }
- else if (strcmp (action_path, "remove_slot") == 0)
- {
- glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
- object, "size",
- _("Remove placeholder from %s"),
- TRUE, FALSE);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
- container,
- object,
- action_path);
+glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * size_prop,
+ const gchar * group_format,
+ gboolean remove,
+ gboolean after);
+
+void
+glade_gtk_box_child_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * action_path)
+{
+ if (strcmp (action_path, "insert_after") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "size",
+ _
+ ("Insert placeholder to %s"),
+ FALSE, TRUE);
+ }
+ else if (strcmp (action_path, "insert_before") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "size",
+ _
+ ("Insert placeholder to %s"),
+ FALSE, FALSE);
+ }
+ else if (strcmp (action_path, "remove_slot") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "size",
+ _
+ ("Remove placeholder from %s"),
+ TRUE, FALSE);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
+ container,
+ object,
+ action_path);
}
/* ----------------------------- GtkTable ------------------------------ */
-typedef struct {
- /* comparable part: */
- GladeWidget *widget;
- gint left_attach;
- gint right_attach;
- gint top_attach;
- gint bottom_attach;
+typedef struct
+{
+ /* comparable part: */
+ GladeWidget *widget;
+ gint left_attach;
+ gint right_attach;
+ gint top_attach;
+ gint bottom_attach;
} GladeGtkTableChild;
-typedef enum {
- DIR_UP,
- DIR_DOWN,
- DIR_LEFT,
- DIR_RIGHT
+typedef enum
+{
+ DIR_UP,
+ DIR_DOWN,
+ DIR_LEFT,
+ DIR_RIGHT
} GladeTableDir;
#define TABLE_CHILD_CMP_SIZE (sizeof (GladeWidget *) + (sizeof (gint) * 4))
@@ -1998,24 +1942,23 @@ static GladeGtkTableChild table_edit = { 0, };
static GladeGtkTableChild table_cur_attach = { 0, };
static void
-glade_gtk_table_get_child_attachments (GtkWidget *table,
- GtkWidget *child,
- GtkTableChild *tchild)
+glade_gtk_table_get_child_attachments (GtkWidget * table,
+ GtkWidget * child,
+ GtkTableChild * tchild)
{
- guint left, right, top, bottom;
+ guint left, right, top, bottom;
- gtk_container_child_get (GTK_CONTAINER (table), child,
- "left-attach", (guint *)&left,
- "right-attach", (guint *)&right,
- "bottom-attach", (guint *)&bottom,
- "top-attach", (guint *)&top,
- NULL);
+ gtk_container_child_get (GTK_CONTAINER (table), child,
+ "left-attach", (guint *) & left,
+ "right-attach", (guint *) & right,
+ "bottom-attach", (guint *) & bottom,
+ "top-attach", (guint *) & top, NULL);
- tchild->widget = child;
- tchild->left_attach = left;
- tchild->right_attach = right;
- tchild->top_attach = top;
- tchild->bottom_attach = bottom;
+ tchild->widget = child;
+ tchild->left_attach = left;
+ tchild->right_attach = right;
+ tchild->top_attach = top;
+ tchild->bottom_attach = bottom;
}
@@ -2024,1526 +1967,1457 @@ glade_gtk_table_get_child_attachments (GtkWidget *table,
* was found.
*/
static gint
-glade_gtk_table_get_row_col_from_point (GtkTable *table,
- gboolean row,
- gint point)
-{
- GtkTableChild tchild;
- GtkAllocation allocation;
- GList *list, *children;
- gint span, trans_point, size, base, end;
-
- children = gtk_container_get_children (GTK_CONTAINER (table));
-
- for (list = children;
- list;
- list = list->next)
- {
- glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
- GTK_WIDGET (list->data), &tchild);
-
- if (row)
- gtk_widget_translate_coordinates
- (GTK_WIDGET (table), tchild.widget,
- 0, point, NULL, &trans_point);
- else
- gtk_widget_translate_coordinates
- (GTK_WIDGET (table), tchild.widget,
- point, 0, &trans_point, NULL);
-
- gtk_widget_get_allocation (tchild.widget, &allocation);
- /* Find any widget in our row/column
- */
- end = row ? allocation.height : allocation.width;
-
- if (trans_point >= 0 &&
- /* should be trans_point < end ... test FIXME ! */
- trans_point < end)
- {
- base = row ? tchild.top_attach : tchild.left_attach;
- size = row ? allocation.height : allocation.width;
- span = row ? (tchild.bottom_attach - tchild.top_attach) :
- (tchild.right_attach - tchild.left_attach);
-
- return base + (trans_point * span / size);
- }
- }
- g_list_free (children);
-
- return -1;
+glade_gtk_table_get_row_col_from_point (GtkTable * table,
+ gboolean row, gint point)
+{
+ GtkTableChild tchild;
+ GtkAllocation allocation;
+ GList *list, *children;
+ gint span, trans_point, size, base, end;
+
+ children = gtk_container_get_children (GTK_CONTAINER (table));
+
+ for (list = children; list; list = list->next)
+ {
+ glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
+ GTK_WIDGET (list->data), &tchild);
+
+ if (row)
+ gtk_widget_translate_coordinates
+ (GTK_WIDGET (table), tchild.widget, 0, point, NULL, &trans_point);
+ else
+ gtk_widget_translate_coordinates
+ (GTK_WIDGET (table), tchild.widget, point, 0, &trans_point, NULL);
+
+ gtk_widget_get_allocation (tchild.widget, &allocation);
+ /* Find any widget in our row/column
+ */
+ end = row ? allocation.height : allocation.width;
+
+ if (trans_point >= 0 &&
+ /* should be trans_point < end ... test FIXME ! */
+ trans_point < end)
+ {
+ base = row ? tchild.top_attach : tchild.left_attach;
+ size = row ? allocation.height : allocation.width;
+ span = row ? (tchild.bottom_attach - tchild.top_attach) :
+ (tchild.right_attach - tchild.left_attach);
+
+ return base + (trans_point * span / size);
+ }
+ }
+ g_list_free (children);
+
+ return -1;
}
static gboolean
-glade_gtk_table_point_crosses_threshold (GtkTable *table,
- gboolean row,
- gint num,
- GladeTableDir dir,
- gint point)
-{
-
- GtkTableChild tchild;
- GtkAllocation allocation;
- GList *list, *children;
- gint span, trans_point, size, rowcol_size, base;
-
- children = gtk_container_get_children (GTK_CONTAINER (table));
-
- for (list = children; list; list = list->next)
- {
- glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
- GTK_WIDGET (list->data), &tchild);
-
- /* Find any widget in our row/column
- */
- if ((row && num >= tchild.top_attach && num < tchild.bottom_attach) ||
- (!row && num >= tchild.left_attach && num < tchild.right_attach))
- {
-
- if (row)
- gtk_widget_translate_coordinates
- (GTK_WIDGET (table), tchild.widget,
- 0, point, NULL, &trans_point);
- else
- gtk_widget_translate_coordinates
- (GTK_WIDGET (table), tchild.widget,
- point, 0, &trans_point, NULL);
-
- span = row ? (tchild.bottom_attach - tchild.top_attach) :
- (tchild.right_attach - tchild.left_attach);
- gtk_widget_get_allocation (tchild.widget, &allocation);
- size = row ? allocation.height : allocation.width;
-
- base = row ? tchild.top_attach : tchild.left_attach;
- rowcol_size = size / span;
- trans_point -= (num - base) * rowcol_size;
+glade_gtk_table_point_crosses_threshold (GtkTable * table,
+ gboolean row,
+ gint num,
+ GladeTableDir dir, gint point)
+{
+
+ GtkTableChild tchild;
+ GtkAllocation allocation;
+ GList *list, *children;
+ gint span, trans_point, size, rowcol_size, base;
+
+ children = gtk_container_get_children (GTK_CONTAINER (table));
+
+ for (list = children; list; list = list->next)
+ {
+ glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
+ GTK_WIDGET (list->data), &tchild);
+
+ /* Find any widget in our row/column
+ */
+ if ((row && num >= tchild.top_attach && num < tchild.bottom_attach) ||
+ (!row && num >= tchild.left_attach && num < tchild.right_attach))
+ {
+
+ if (row)
+ gtk_widget_translate_coordinates
+ (GTK_WIDGET (table), tchild.widget,
+ 0, point, NULL, &trans_point);
+ else
+ gtk_widget_translate_coordinates
+ (GTK_WIDGET (table), tchild.widget,
+ point, 0, &trans_point, NULL);
+
+ span = row ? (tchild.bottom_attach - tchild.top_attach) :
+ (tchild.right_attach - tchild.left_attach);
+ gtk_widget_get_allocation (tchild.widget, &allocation);
+ size = row ? allocation.height : allocation.width;
+
+ base = row ? tchild.top_attach : tchild.left_attach;
+ rowcol_size = size / span;
+ trans_point -= (num - base) * rowcol_size;
#if 0
- g_print ("dir: %s, widget size: %d, rowcol size: %d, "
- "requested rowcol: %d, widget base rowcol: %d, trim: %d, "
- "widget point: %d, thresh: %d\n",
- dir == DIR_UP ? "up" : dir == DIR_DOWN ? "down" :
- dir == DIR_LEFT ? "left" : "right",
- size, rowcol_size, num, base, (num - base) * rowcol_size,
- trans_point,
- dir == DIR_UP || dir == DIR_LEFT ?
- (rowcol_size / 2) :
- (rowcol_size / 2));
+ g_print ("dir: %s, widget size: %d, rowcol size: %d, "
+ "requested rowcol: %d, widget base rowcol: %d, trim: %d, "
+ "widget point: %d, thresh: %d\n",
+ dir == DIR_UP ? "up" : dir == DIR_DOWN ? "down" :
+ dir == DIR_LEFT ? "left" : "right",
+ size, rowcol_size, num, base, (num - base) * rowcol_size,
+ trans_point,
+ dir == DIR_UP || dir == DIR_LEFT ?
+ (rowcol_size / 2) : (rowcol_size / 2));
#endif
- switch (dir)
- {
- case DIR_UP:
- case DIR_LEFT:
- return trans_point <= (rowcol_size / 2);
- case DIR_DOWN:
- case DIR_RIGHT:
- return trans_point >= (rowcol_size / 2);
- default:
- break;
- }
- }
-
- }
-
- g_list_free (children);
-
- return FALSE;
+ switch (dir)
+ {
+ case DIR_UP:
+ case DIR_LEFT:
+ return trans_point <= (rowcol_size / 2);
+ case DIR_DOWN:
+ case DIR_RIGHT:
+ return trans_point >= (rowcol_size / 2);
+ default:
+ break;
+ }
+ }
+
+ }
+
+ g_list_free (children);
+
+ return FALSE;
}
static gboolean
-glade_gtk_table_get_attachments (GladeFixed *fixed,
- GtkTable *table,
- GdkRectangle *rect,
- GladeGtkTableChild *configure)
-{
- gint center_x, center_y, row, column;
- guint n_columns, n_rows;
- center_x = rect->x + (rect->width / 2);
- center_y = rect->y + (rect->height / 2);
-
- column = glade_gtk_table_get_row_col_from_point
- (table, FALSE, center_x);
-
- row = glade_gtk_table_get_row_col_from_point
- (table, TRUE, center_y);
-
- /* its a start, now try to grow when the rect extents
- * reach at least half way into the next row/column
- */
- configure->left_attach = column;
- configure->right_attach = column + 1;
- configure->top_attach = row;
- configure->bottom_attach = row +1;
-
- if (column >= 0 && row >= 0)
- {
-
- g_object_get (table,
- "n-columns", &n_columns,
- "n-rows", &n_rows,
- NULL);
-
- /* Check and expand left
- */
- while (configure->left_attach > 0)
- {
- if (rect->x < fixed->child_x_origin &&
- fixed->operation != GLADE_CURSOR_DRAG &&
- GLADE_FIXED_CURSOR_LEFT (fixed->operation) == FALSE)
- break;
-
- if (glade_gtk_table_point_crosses_threshold
- (table, FALSE, configure->left_attach -1,
- DIR_LEFT, rect->x) == FALSE)
- break;
-
- configure->left_attach--;
- }
-
- /* Check and expand right
- */
- while (configure->right_attach < n_columns)
- {
- if (rect->x + rect->width >
- fixed->child_x_origin + fixed->child_width_origin &&
- fixed->operation != GLADE_CURSOR_DRAG &&
- GLADE_FIXED_CURSOR_RIGHT (fixed->operation) == FALSE)
- break;
-
- if (glade_gtk_table_point_crosses_threshold
- (table, FALSE, configure->right_attach,
- DIR_RIGHT, rect->x + rect->width) == FALSE)
- break;
-
- configure->right_attach++;
- }
-
- /* Check and expand top
- */
- while (configure->top_attach > 0)
- {
- if (rect->y < fixed->child_y_origin &&
- fixed->operation != GLADE_CURSOR_DRAG &&
- GLADE_FIXED_CURSOR_TOP (fixed->operation) == FALSE)
- break;
-
- if (glade_gtk_table_point_crosses_threshold
- (table, TRUE, configure->top_attach -1,
- DIR_UP, rect->y) == FALSE)
- break;
-
- configure->top_attach--;
- }
-
- /* Check and expand bottom
- */
- while (configure->bottom_attach < n_rows)
- {
- if (rect->y + rect->height >
- fixed->child_y_origin + fixed->child_height_origin &&
- fixed->operation != GLADE_CURSOR_DRAG &&
- GLADE_FIXED_CURSOR_BOTTOM (fixed->operation) == FALSE)
- break;
-
- if (glade_gtk_table_point_crosses_threshold
- (table, TRUE, configure->bottom_attach,
- DIR_DOWN, rect->y + rect->height) == FALSE)
- break;
-
- configure->bottom_attach++;
- }
- }
-
- /* Keep the same row/col span when performing a drag
- */
- if (fixed->operation == GLADE_CURSOR_DRAG)
- {
- gint col_span = table_edit.right_attach - table_edit.left_attach;
- gint row_span = table_edit.bottom_attach - table_edit.top_attach;
-
- if (rect->x < fixed->child_x_origin)
- configure->right_attach = configure->left_attach + col_span;
- else
- configure->left_attach = configure->right_attach - col_span;
-
- if (rect->y < fixed->child_y_origin)
- configure->bottom_attach = configure->top_attach + row_span;
- else
- configure->top_attach = configure->bottom_attach - row_span;
- } else if (fixed->operation == GLADE_CURSOR_RESIZE_RIGHT) {
- configure->left_attach = table_edit.left_attach;
- configure->top_attach = table_edit.top_attach;
- configure->bottom_attach = table_edit.bottom_attach;
- } else if (fixed->operation == GLADE_CURSOR_RESIZE_LEFT) {
- configure->right_attach = table_edit.right_attach;
- configure->top_attach = table_edit.top_attach;
- configure->bottom_attach = table_edit.bottom_attach;
- } else if (fixed->operation == GLADE_CURSOR_RESIZE_TOP) {
- configure->left_attach = table_edit.left_attach;
- configure->right_attach = table_edit.right_attach;
- configure->bottom_attach = table_edit.bottom_attach;
- } else if (fixed->operation == GLADE_CURSOR_RESIZE_BOTTOM) {
- configure->left_attach = table_edit.left_attach;
- configure->right_attach = table_edit.right_attach;
- configure->top_attach = table_edit.top_attach;
- }
-
- return column >= 0 && row >= 0;
+glade_gtk_table_get_attachments (GladeFixed * fixed,
+ GtkTable * table,
+ GdkRectangle * rect,
+ GladeGtkTableChild * configure)
+{
+ gint center_x, center_y, row, column;
+ guint n_columns, n_rows;
+ center_x = rect->x + (rect->width / 2);
+ center_y = rect->y + (rect->height / 2);
+
+ column = glade_gtk_table_get_row_col_from_point (table, FALSE, center_x);
+
+ row = glade_gtk_table_get_row_col_from_point (table, TRUE, center_y);
+
+ /* its a start, now try to grow when the rect extents
+ * reach at least half way into the next row/column
+ */
+ configure->left_attach = column;
+ configure->right_attach = column + 1;
+ configure->top_attach = row;
+ configure->bottom_attach = row + 1;
+
+ if (column >= 0 && row >= 0)
+ {
+
+ g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL);
+
+ /* Check and expand left
+ */
+ while (configure->left_attach > 0)
+ {
+ if (rect->x < fixed->child_x_origin &&
+ fixed->operation != GLADE_CURSOR_DRAG &&
+ GLADE_FIXED_CURSOR_LEFT (fixed->operation) == FALSE)
+ break;
+
+ if (glade_gtk_table_point_crosses_threshold
+ (table, FALSE, configure->left_attach - 1,
+ DIR_LEFT, rect->x) == FALSE)
+ break;
+
+ configure->left_attach--;
+ }
+
+ /* Check and expand right
+ */
+ while (configure->right_attach < n_columns)
+ {
+ if (rect->x + rect->width >
+ fixed->child_x_origin + fixed->child_width_origin &&
+ fixed->operation != GLADE_CURSOR_DRAG &&
+ GLADE_FIXED_CURSOR_RIGHT (fixed->operation) == FALSE)
+ break;
+
+ if (glade_gtk_table_point_crosses_threshold
+ (table, FALSE, configure->right_attach,
+ DIR_RIGHT, rect->x + rect->width) == FALSE)
+ break;
+
+ configure->right_attach++;
+ }
+
+ /* Check and expand top
+ */
+ while (configure->top_attach > 0)
+ {
+ if (rect->y < fixed->child_y_origin &&
+ fixed->operation != GLADE_CURSOR_DRAG &&
+ GLADE_FIXED_CURSOR_TOP (fixed->operation) == FALSE)
+ break;
+
+ if (glade_gtk_table_point_crosses_threshold
+ (table, TRUE, configure->top_attach - 1,
+ DIR_UP, rect->y) == FALSE)
+ break;
+
+ configure->top_attach--;
+ }
+
+ /* Check and expand bottom
+ */
+ while (configure->bottom_attach < n_rows)
+ {
+ if (rect->y + rect->height >
+ fixed->child_y_origin + fixed->child_height_origin &&
+ fixed->operation != GLADE_CURSOR_DRAG &&
+ GLADE_FIXED_CURSOR_BOTTOM (fixed->operation) == FALSE)
+ break;
+
+ if (glade_gtk_table_point_crosses_threshold
+ (table, TRUE, configure->bottom_attach,
+ DIR_DOWN, rect->y + rect->height) == FALSE)
+ break;
+
+ configure->bottom_attach++;
+ }
+ }
+
+ /* Keep the same row/col span when performing a drag
+ */
+ if (fixed->operation == GLADE_CURSOR_DRAG)
+ {
+ gint col_span = table_edit.right_attach - table_edit.left_attach;
+ gint row_span = table_edit.bottom_attach - table_edit.top_attach;
+
+ if (rect->x < fixed->child_x_origin)
+ configure->right_attach = configure->left_attach + col_span;
+ else
+ configure->left_attach = configure->right_attach - col_span;
+
+ if (rect->y < fixed->child_y_origin)
+ configure->bottom_attach = configure->top_attach + row_span;
+ else
+ configure->top_attach = configure->bottom_attach - row_span;
+ }
+ else if (fixed->operation == GLADE_CURSOR_RESIZE_RIGHT)
+ {
+ configure->left_attach = table_edit.left_attach;
+ configure->top_attach = table_edit.top_attach;
+ configure->bottom_attach = table_edit.bottom_attach;
+ }
+ else if (fixed->operation == GLADE_CURSOR_RESIZE_LEFT)
+ {
+ configure->right_attach = table_edit.right_attach;
+ configure->top_attach = table_edit.top_attach;
+ configure->bottom_attach = table_edit.bottom_attach;
+ }
+ else if (fixed->operation == GLADE_CURSOR_RESIZE_TOP)
+ {
+ configure->left_attach = table_edit.left_attach;
+ configure->right_attach = table_edit.right_attach;
+ configure->bottom_attach = table_edit.bottom_attach;
+ }
+ else if (fixed->operation == GLADE_CURSOR_RESIZE_BOTTOM)
+ {
+ configure->left_attach = table_edit.left_attach;
+ configure->right_attach = table_edit.right_attach;
+ configure->top_attach = table_edit.top_attach;
+ }
+
+ return column >= 0 && row >= 0;
}
static gboolean
-glade_gtk_table_configure_child (GladeFixed *fixed,
- GladeWidget *child,
- GdkRectangle *rect,
- GtkWidget *table)
-{
- GladeGtkTableChild configure = { child, };
-
- /* Sometimes we are unable to find a widget in the appropriate column,
- * usually because a placeholder hasnt had its size allocation yet.
- */
- if (glade_gtk_table_get_attachments (fixed, GTK_TABLE (table), rect, &configure))
- {
- if (memcmp (&configure, &table_cur_attach, TABLE_CHILD_CMP_SIZE) != 0)
- {
-
- glade_property_push_superuser ();
- glade_widget_pack_property_set (child, "left-attach",
- configure.left_attach);
- glade_widget_pack_property_set (child, "right-attach",
- configure.right_attach);
- glade_widget_pack_property_set (child, "top-attach",
- configure.top_attach);
- glade_widget_pack_property_set (child, "bottom-attach",
- configure.bottom_attach);
- glade_property_pop_superuser ();
-
- memcpy (&table_cur_attach, &configure, TABLE_CHILD_CMP_SIZE);
- }
- }
- return TRUE;
+glade_gtk_table_configure_child (GladeFixed * fixed,
+ GladeWidget * child,
+ GdkRectangle * rect, GtkWidget * table)
+{
+ GladeGtkTableChild configure = { child, };
+
+ /* Sometimes we are unable to find a widget in the appropriate column,
+ * usually because a placeholder hasnt had its size allocation yet.
+ */
+ if (glade_gtk_table_get_attachments
+ (fixed, GTK_TABLE (table), rect, &configure))
+ {
+ if (memcmp (&configure, &table_cur_attach, TABLE_CHILD_CMP_SIZE) != 0)
+ {
+
+ glade_property_push_superuser ();
+ glade_widget_pack_property_set (child, "left-attach",
+ configure.left_attach);
+ glade_widget_pack_property_set (child, "right-attach",
+ configure.right_attach);
+ glade_widget_pack_property_set (child, "top-attach",
+ configure.top_attach);
+ glade_widget_pack_property_set (child, "bottom-attach",
+ configure.bottom_attach);
+ glade_property_pop_superuser ();
+
+ memcpy (&table_cur_attach, &configure, TABLE_CHILD_CMP_SIZE);
+ }
+ }
+ return TRUE;
}
static gboolean
-glade_gtk_table_configure_begin (GladeFixed *fixed,
- GladeWidget *child,
- GtkWidget *table)
+glade_gtk_table_configure_begin (GladeFixed * fixed,
+ GladeWidget * child, GtkWidget * table)
{
- table_edit.widget = child;
+ table_edit.widget = child;
- glade_widget_pack_property_get (child, "left-attach",
- &table_edit.left_attach);
- glade_widget_pack_property_get (child, "right-attach",
- &table_edit.right_attach);
- glade_widget_pack_property_get (child, "top-attach",
- &table_edit.top_attach);
- glade_widget_pack_property_get (child, "bottom-attach",
- &table_edit.bottom_attach);
+ glade_widget_pack_property_get (child, "left-attach",
+ &table_edit.left_attach);
+ glade_widget_pack_property_get (child, "right-attach",
+ &table_edit.right_attach);
+ glade_widget_pack_property_get (child, "top-attach", &table_edit.top_attach);
+ glade_widget_pack_property_get (child, "bottom-attach",
+ &table_edit.bottom_attach);
- memcpy (&table_cur_attach, &table_edit, TABLE_CHILD_CMP_SIZE);
+ memcpy (&table_cur_attach, &table_edit, TABLE_CHILD_CMP_SIZE);
- return TRUE;
+ return TRUE;
}
static gboolean
-glade_gtk_table_configure_end (GladeFixed *fixed,
- GladeWidget *child,
- GtkWidget *table)
-{
- GladeGtkTableChild new_child = { child, };
-
- glade_widget_pack_property_get (child, "left-attach",
- &new_child.left_attach);
- glade_widget_pack_property_get (child, "right-attach",
- &new_child.right_attach);
- glade_widget_pack_property_get (child, "top-attach",
- &new_child.top_attach);
- glade_widget_pack_property_get (child, "bottom-attach",
- &new_child.bottom_attach);
-
- /* Compare the meaningfull part of the current edit. */
- if (memcmp (&new_child, &table_edit, TABLE_CHILD_CMP_SIZE) != 0)
- {
- GValue left_attach_value = { 0, };
- GValue right_attach_value = { 0, };
- GValue top_attach_value = { 0, };
- GValue bottom_attach_value = { 0, };
-
- GValue new_left_attach_value = { 0, };
- GValue new_right_attach_value = { 0, };
- GValue new_top_attach_value = { 0, };
- GValue new_bottom_attach_value = { 0, };
-
- GladeProperty *left_attach_prop, *right_attach_prop,
- *top_attach_prop, *bottom_attach_prop;
-
- left_attach_prop = glade_widget_get_pack_property (child, "left-attach");
- right_attach_prop = glade_widget_get_pack_property (child, "right-attach");
- top_attach_prop = glade_widget_get_pack_property (child, "top-attach");
- bottom_attach_prop = glade_widget_get_pack_property (child, "bottom-attach");
-
- g_return_val_if_fail (GLADE_IS_PROPERTY (left_attach_prop), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (right_attach_prop), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (top_attach_prop), FALSE);
- g_return_val_if_fail (GLADE_IS_PROPERTY (bottom_attach_prop), FALSE);
-
- glade_property_get_value (left_attach_prop, &new_left_attach_value);
- glade_property_get_value (right_attach_prop, &new_right_attach_value);
- glade_property_get_value (top_attach_prop, &new_top_attach_value);
- glade_property_get_value (bottom_attach_prop, &new_bottom_attach_value);
-
- g_value_init (&left_attach_value, G_TYPE_UINT);
- g_value_init (&right_attach_value, G_TYPE_UINT);
- g_value_init (&top_attach_value, G_TYPE_UINT);
- g_value_init (&bottom_attach_value, G_TYPE_UINT);
-
- g_value_set_uint (&left_attach_value, table_edit.left_attach);
- g_value_set_uint (&right_attach_value, table_edit.right_attach);
- g_value_set_uint (&top_attach_value, table_edit.top_attach);
- g_value_set_uint (&bottom_attach_value, table_edit.bottom_attach);
-
- glade_command_push_group (_("Placing %s inside %s"),
- child->name,
- GLADE_WIDGET (fixed)->name);
- glade_command_set_properties
- (left_attach_prop, &left_attach_value, &new_left_attach_value,
- right_attach_prop, &right_attach_value, &new_right_attach_value,
- top_attach_prop, &top_attach_value, &new_top_attach_value,
- bottom_attach_prop, &bottom_attach_value, &new_bottom_attach_value,
- NULL);
- glade_command_pop_group ();
-
- g_value_unset (&left_attach_value);
- g_value_unset (&right_attach_value);
- g_value_unset (&top_attach_value);
- g_value_unset (&bottom_attach_value);
- g_value_unset (&new_left_attach_value);
- g_value_unset (&new_right_attach_value);
- g_value_unset (&new_top_attach_value);
- g_value_unset (&new_bottom_attach_value);
- }
-
- return TRUE;
-}
-
-void
-glade_gtk_table_post_create (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GladeCreateReason reason)
-{
- GladeWidget *gwidget =
- glade_widget_get_from_gobject (container);
-
- g_signal_connect (G_OBJECT (gwidget), "configure-child",
- G_CALLBACK (glade_gtk_table_configure_child), container);
-
- g_signal_connect (G_OBJECT (gwidget), "configure-begin",
- G_CALLBACK (glade_gtk_table_configure_begin), container);
-
- g_signal_connect (G_OBJECT (gwidget), "configure-end",
- G_CALLBACK (glade_gtk_table_configure_end), container);
+glade_gtk_table_configure_end (GladeFixed * fixed,
+ GladeWidget * child, GtkWidget * table)
+{
+ GladeGtkTableChild new_child = { child, };
+
+ glade_widget_pack_property_get (child, "left-attach", &new_child.left_attach);
+ glade_widget_pack_property_get (child, "right-attach",
+ &new_child.right_attach);
+ glade_widget_pack_property_get (child, "top-attach", &new_child.top_attach);
+ glade_widget_pack_property_get (child, "bottom-attach",
+ &new_child.bottom_attach);
+
+ /* Compare the meaningfull part of the current edit. */
+ if (memcmp (&new_child, &table_edit, TABLE_CHILD_CMP_SIZE) != 0)
+ {
+ GValue left_attach_value = { 0, };
+ GValue right_attach_value = { 0, };
+ GValue top_attach_value = { 0, };
+ GValue bottom_attach_value = { 0, };
+
+ GValue new_left_attach_value = { 0, };
+ GValue new_right_attach_value = { 0, };
+ GValue new_top_attach_value = { 0, };
+ GValue new_bottom_attach_value = { 0, };
+
+ GladeProperty *left_attach_prop, *right_attach_prop,
+ *top_attach_prop, *bottom_attach_prop;
+
+ left_attach_prop = glade_widget_get_pack_property (child, "left-attach");
+ right_attach_prop =
+ glade_widget_get_pack_property (child, "right-attach");
+ top_attach_prop = glade_widget_get_pack_property (child, "top-attach");
+ bottom_attach_prop =
+ glade_widget_get_pack_property (child, "bottom-attach");
+
+ g_return_val_if_fail (GLADE_IS_PROPERTY (left_attach_prop), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (right_attach_prop), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (top_attach_prop), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROPERTY (bottom_attach_prop), FALSE);
+
+ glade_property_get_value (left_attach_prop, &new_left_attach_value);
+ glade_property_get_value (right_attach_prop, &new_right_attach_value);
+ glade_property_get_value (top_attach_prop, &new_top_attach_value);
+ glade_property_get_value (bottom_attach_prop, &new_bottom_attach_value);
+
+ g_value_init (&left_attach_value, G_TYPE_UINT);
+ g_value_init (&right_attach_value, G_TYPE_UINT);
+ g_value_init (&top_attach_value, G_TYPE_UINT);
+ g_value_init (&bottom_attach_value, G_TYPE_UINT);
+
+ g_value_set_uint (&left_attach_value, table_edit.left_attach);
+ g_value_set_uint (&right_attach_value, table_edit.right_attach);
+ g_value_set_uint (&top_attach_value, table_edit.top_attach);
+ g_value_set_uint (&bottom_attach_value, table_edit.bottom_attach);
+
+ glade_command_push_group (_("Placing %s inside %s"),
+ child->name, GLADE_WIDGET (fixed)->name);
+ glade_command_set_properties
+ (left_attach_prop, &left_attach_value, &new_left_attach_value,
+ right_attach_prop, &right_attach_value, &new_right_attach_value,
+ top_attach_prop, &top_attach_value, &new_top_attach_value,
+ bottom_attach_prop, &bottom_attach_value, &new_bottom_attach_value,
+ NULL);
+ glade_command_pop_group ();
+
+ g_value_unset (&left_attach_value);
+ g_value_unset (&right_attach_value);
+ g_value_unset (&top_attach_value);
+ g_value_unset (&bottom_attach_value);
+ g_value_unset (&new_left_attach_value);
+ g_value_unset (&new_right_attach_value);
+ g_value_unset (&new_top_attach_value);
+ g_value_unset (&new_bottom_attach_value);
+ }
+
+ return TRUE;
+}
+
+void
+glade_gtk_table_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * container, GladeCreateReason reason)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (container);
+
+ g_signal_connect (G_OBJECT (gwidget), "configure-child",
+ G_CALLBACK (glade_gtk_table_configure_child), container);
+
+ g_signal_connect (G_OBJECT (gwidget), "configure-begin",
+ G_CALLBACK (glade_gtk_table_configure_begin), container);
+
+ g_signal_connect (G_OBJECT (gwidget), "configure-end",
+ G_CALLBACK (glade_gtk_table_configure_end), container);
}
static gboolean
-glade_gtk_table_has_child (GtkTable *table, guint left_attach, guint top_attach)
+glade_gtk_table_has_child (GtkTable * table, guint left_attach,
+ guint top_attach)
{
- GList *list, *children;
- gboolean ret = FALSE;
+ GList *list, *children;
+ gboolean ret = FALSE;
- children = gtk_container_get_children (GTK_CONTAINER (table));
+ children = gtk_container_get_children (GTK_CONTAINER (table));
- for (list = children;
- list && list->data;
- list = list->next)
- {
- GtkTableChild child;
+ for (list = children; list && list->data; list = list->next)
+ {
+ GtkTableChild child;
- glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
- GTK_WIDGET (list->data), &child);
+ glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
+ GTK_WIDGET (list->data), &child);
- if (left_attach >= child.left_attach && left_attach < child.right_attach &&
- top_attach >= child.top_attach && top_attach < child.bottom_attach)
- {
- ret = TRUE;
- break;
- }
- }
+ if (left_attach >= child.left_attach && left_attach < child.right_attach
+ && top_attach >= child.top_attach && top_attach < child.bottom_attach)
+ {
+ ret = TRUE;
+ break;
+ }
+ }
- g_list_free (children);
+ g_list_free (children);
- return ret;
+ return ret;
}
static gboolean
-glade_gtk_table_widget_exceeds_bounds (GtkTable *table, gint n_rows, gint n_cols)
+glade_gtk_table_widget_exceeds_bounds (GtkTable * table, gint n_rows,
+ gint n_cols)
{
- GList *list, *children;
- gboolean ret = FALSE;
+ GList *list, *children;
+ gboolean ret = FALSE;
- children = gtk_container_get_children (GTK_CONTAINER (table));
+ children = gtk_container_get_children (GTK_CONTAINER (table));
- for (list = children;
- list && list->data;
- list = list->next)
- {
- GtkTableChild child;
+ for (list = children; list && list->data; list = list->next)
+ {
+ GtkTableChild child;
- glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
- GTK_WIDGET (list->data), &child);
+ glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
+ GTK_WIDGET (list->data), &child);
- if (GLADE_IS_PLACEHOLDER(child.widget) == FALSE &&
- (child.right_attach > n_cols ||
- child.bottom_attach > n_rows))
- {
- ret = TRUE;
- break;
- }
- }
- return ret;
+ if (GLADE_IS_PLACEHOLDER (child.widget) == FALSE &&
+ (child.right_attach > n_cols || child.bottom_attach > n_rows))
+ {
+ ret = TRUE;
+ break;
+ }
+ }
+ return ret;
}
static void
-glade_gtk_table_refresh_placeholders (GtkTable *table)
-{
- GList *list, *children;
- guint n_columns, n_rows;
- gint i, j;
-
- g_object_get (table,
- "n-columns", &n_columns,
- "n-rows", &n_rows,
- NULL);
-
- children = gtk_container_get_children (GTK_CONTAINER (table));
-
- for (list = children; list && list->data; list = list->next)
- {
- if (GLADE_IS_PLACEHOLDER (list->data))
- gtk_container_remove (GTK_CONTAINER (table),
- GTK_WIDGET (list->data));
- }
- g_list_free (children);
-
- for (i = 0; i < n_columns; i++)
- for (j = 0; j < n_rows; j++)
- if (glade_gtk_table_has_child (table, i, j) == FALSE)
- {
- gtk_table_attach_defaults (table,
- glade_placeholder_new (),
- i, i + 1, j, j + 1);
- }
- gtk_container_check_resize (GTK_CONTAINER (table));
+glade_gtk_table_refresh_placeholders (GtkTable * table)
+{
+ GList *list, *children;
+ guint n_columns, n_rows;
+ gint i, j;
+
+ g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL);
+
+ children = gtk_container_get_children (GTK_CONTAINER (table));
+
+ for (list = children; list && list->data; list = list->next)
+ {
+ if (GLADE_IS_PLACEHOLDER (list->data))
+ gtk_container_remove (GTK_CONTAINER (table), GTK_WIDGET (list->data));
+ }
+ g_list_free (children);
+
+ for (i = 0; i < n_columns; i++)
+ for (j = 0; j < n_rows; j++)
+ if (glade_gtk_table_has_child (table, i, j) == FALSE)
+ {
+ gtk_table_attach_defaults (table,
+ glade_placeholder_new (),
+ i, i + 1, j, j + 1);
+ }
+ gtk_container_check_resize (GTK_CONTAINER (table));
}
static void
-gtk_table_children_callback (GtkWidget *widget,
- gpointer client_data)
+gtk_table_children_callback (GtkWidget * widget, gpointer client_data)
{
- GList **children;
+ GList **children;
- children = (GList**) client_data;
- *children = g_list_prepend (*children, widget);
+ children = (GList **) client_data;
+ *children = g_list_prepend (*children, widget);
}
GList *
-glade_gtk_table_get_children (GladeWidgetAdaptor *adaptor,
- GtkContainer *container)
+glade_gtk_table_get_children (GladeWidgetAdaptor * adaptor,
+ GtkContainer * container)
{
- GList *children = NULL;
+ GList *children = NULL;
- g_return_val_if_fail (GTK_IS_TABLE (container), NULL);
+ g_return_val_if_fail (GTK_IS_TABLE (container), NULL);
- gtk_container_forall (container,
- gtk_table_children_callback,
- &children);
+ gtk_container_forall (container, gtk_table_children_callback, &children);
- /* GtkTable has the children list already reversed */
- return children;
+ /* GtkTable has the children list already reversed */
+ return children;
}
void
-glade_gtk_table_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_table_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_TABLE (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (GTK_IS_TABLE (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
- gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+ gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
- glade_gtk_table_refresh_placeholders (GTK_TABLE (object));
+ glade_gtk_table_refresh_placeholders (GTK_TABLE (object));
}
void
-glade_gtk_table_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_table_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_TABLE (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
-
- glade_gtk_table_refresh_placeholders (GTK_TABLE (object));
+ g_return_if_fail (GTK_IS_TABLE (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+
+ glade_gtk_table_refresh_placeholders (GTK_TABLE (object));
}
void
-glade_gtk_table_replace_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *current,
- GtkWidget *new_widget)
+glade_gtk_table_replace_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container,
+ GtkWidget * current, GtkWidget * new_widget)
{
- g_return_if_fail (GTK_IS_TABLE (container));
- g_return_if_fail (GTK_IS_WIDGET (current));
- g_return_if_fail (GTK_IS_WIDGET (new_widget));
-
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->replace_child (adaptor,
- G_OBJECT (container),
- G_OBJECT (current),
- G_OBJECT (new_widget));
-
- /* If we are replacing a GladeWidget, we must refresh placeholders
- * because the widget may have spanned multiple rows/columns, we must
- * not do so in the case we are pasting multiple widgets into a table,
- * where destroying placeholders results in default packing properties
- * (since the remaining placeholder templates no longer exist, only the
- * first pasted widget would have proper packing properties).
- */
- if (glade_widget_get_from_gobject (new_widget) == NULL)
- glade_gtk_table_refresh_placeholders (GTK_TABLE (container));
+ g_return_if_fail (GTK_IS_TABLE (container));
+ g_return_if_fail (GTK_IS_WIDGET (current));
+ g_return_if_fail (GTK_IS_WIDGET (new_widget));
+
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->replace_child (adaptor,
+ G_OBJECT (container),
+ G_OBJECT (current),
+ G_OBJECT (new_widget));
+
+ /* If we are replacing a GladeWidget, we must refresh placeholders
+ * because the widget may have spanned multiple rows/columns, we must
+ * not do so in the case we are pasting multiple widgets into a table,
+ * where destroying placeholders results in default packing properties
+ * (since the remaining placeholder templates no longer exist, only the
+ * first pasted widget would have proper packing properties).
+ */
+ if (glade_widget_get_from_gobject (new_widget) == NULL)
+ glade_gtk_table_refresh_placeholders (GTK_TABLE (container));
}
static void
-glade_gtk_table_set_n_common (GObject *object, const GValue *value, gboolean for_rows)
-{
- GladeWidget *widget;
- GtkTable *table;
- guint new_size, old_size, n_columns, n_rows;
-
- table = GTK_TABLE (object);
- g_return_if_fail (GTK_IS_TABLE (table));
-
- g_object_get (table,
- "n-columns", &n_columns,
- "n-rows", &n_rows,
- NULL);
-
- new_size = g_value_get_uint (value);
- old_size = for_rows ? n_rows : n_columns;
-
- if (new_size < 1)
- return;
-
- if (glade_gtk_table_widget_exceeds_bounds
- (table,
- for_rows ? new_size : n_rows,
- for_rows ? n_columns : new_size))
- /* Refuse to shrink if it means orphaning widgets */
- return;
-
- widget = glade_widget_get_from_gobject (GTK_WIDGET (table));
- g_return_if_fail (widget != NULL);
-
- if (for_rows)
- gtk_table_resize (table, new_size, n_columns);
- else
- gtk_table_resize (table, n_rows, new_size);
-
- /* Fill table with placeholders */
- glade_gtk_table_refresh_placeholders (table);
-
- if (new_size < old_size)
- {
- /* Remove from the bottom up */
- GList *list, *children;
- GList *list_to_free = NULL;
-
- children = gtk_container_get_children (GTK_CONTAINER (table));
-
- for (list = children;
- list && list->data;
- list = list->next)
- {
- GtkTableChild child;
- guint start, end;
-
- glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
- GTK_WIDGET (list->data), &child);
-
- start = for_rows ? child.top_attach : child.left_attach;
- end = for_rows ? child.bottom_attach : child.right_attach;
-
- /* We need to completely remove it */
- if (start >= new_size)
- {
- list_to_free = g_list_prepend (list_to_free, child.widget);
- continue;
- }
-
- /* If the widget spans beyond the new border,
- * we should resize it to fit on the new table */
- if (end > new_size)
- gtk_container_child_set
- (GTK_CONTAINER (table), GTK_WIDGET (child.widget),
- for_rows ? "bottom_attach" : "right_attach",
- new_size, NULL);
- }
-
- g_list_free (children);
-
- if (list_to_free)
- {
- for (list = g_list_first(list_to_free);
- list && list->data;
- list = list->next)
- {
- g_object_ref (G_OBJECT (list->data));
- gtk_container_remove (GTK_CONTAINER (table),
- GTK_WIDGET(list->data));
- /* This placeholder is no longer valid, force destroy */
- gtk_widget_destroy (GTK_WIDGET(list->data));
- }
- g_list_free (list_to_free);
- }
- gtk_table_resize (table,
- for_rows ? new_size : n_rows,
- for_rows ? n_columns : new_size);
- }
-}
-
-void
-glade_gtk_table_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "n-rows"))
- glade_gtk_table_set_n_common (object, value, TRUE);
- else if (!strcmp (id, "n-columns"))
- glade_gtk_table_set_n_common (object, value, FALSE);
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
- id, value);
-}
-
-static gboolean
-glade_gtk_table_verify_n_common (GObject *object, const GValue *value, gboolean for_rows)
-{
- GtkTable *table = GTK_TABLE(object);
- guint n_columns, n_rows, new_size = g_value_get_uint (value);
-
- g_object_get (table,
- "n-columns", &n_columns,
- "n-rows", &n_rows,
- NULL);
-
- if (glade_gtk_table_widget_exceeds_bounds
- (table,
- for_rows ? new_size : n_rows,
- for_rows ? n_columns : new_size))
- /* Refuse to shrink if it means orphaning widgets */
- return FALSE;
-
- return TRUE;
+glade_gtk_table_set_n_common (GObject * object, const GValue * value,
+ gboolean for_rows)
+{
+ GladeWidget *widget;
+ GtkTable *table;
+ guint new_size, old_size, n_columns, n_rows;
+
+ table = GTK_TABLE (object);
+ g_return_if_fail (GTK_IS_TABLE (table));
+
+ g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL);
+
+ new_size = g_value_get_uint (value);
+ old_size = for_rows ? n_rows : n_columns;
+
+ if (new_size < 1)
+ return;
+
+ if (glade_gtk_table_widget_exceeds_bounds
+ (table, for_rows ? new_size : n_rows, for_rows ? n_columns : new_size))
+ /* Refuse to shrink if it means orphaning widgets */
+ return;
+
+ widget = glade_widget_get_from_gobject (GTK_WIDGET (table));
+ g_return_if_fail (widget != NULL);
+
+ if (for_rows)
+ gtk_table_resize (table, new_size, n_columns);
+ else
+ gtk_table_resize (table, n_rows, new_size);
+
+ /* Fill table with placeholders */
+ glade_gtk_table_refresh_placeholders (table);
+
+ if (new_size < old_size)
+ {
+ /* Remove from the bottom up */
+ GList *list, *children;
+ GList *list_to_free = NULL;
+
+ children = gtk_container_get_children (GTK_CONTAINER (table));
+
+ for (list = children; list && list->data; list = list->next)
+ {
+ GtkTableChild child;
+ guint start, end;
+
+ glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
+ GTK_WIDGET (list->data),
+ &child);
+
+ start = for_rows ? child.top_attach : child.left_attach;
+ end = for_rows ? child.bottom_attach : child.right_attach;
+
+ /* We need to completely remove it */
+ if (start >= new_size)
+ {
+ list_to_free = g_list_prepend (list_to_free, child.widget);
+ continue;
+ }
+
+ /* If the widget spans beyond the new border,
+ * we should resize it to fit on the new table */
+ if (end > new_size)
+ gtk_container_child_set
+ (GTK_CONTAINER (table), GTK_WIDGET (child.widget),
+ for_rows ? "bottom_attach" : "right_attach", new_size, NULL);
+ }
+
+ g_list_free (children);
+
+ if (list_to_free)
+ {
+ for (list = g_list_first (list_to_free);
+ list && list->data; list = list->next)
+ {
+ g_object_ref (G_OBJECT (list->data));
+ gtk_container_remove (GTK_CONTAINER (table),
+ GTK_WIDGET (list->data));
+ /* This placeholder is no longer valid, force destroy */
+ gtk_widget_destroy (GTK_WIDGET (list->data));
+ }
+ g_list_free (list_to_free);
+ }
+ gtk_table_resize (table,
+ for_rows ? new_size : n_rows,
+ for_rows ? n_columns : new_size);
+ }
+}
+
+void
+glade_gtk_table_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ if (!strcmp (id, "n-rows"))
+ glade_gtk_table_set_n_common (object, value, TRUE);
+ else if (!strcmp (id, "n-columns"))
+ glade_gtk_table_set_n_common (object, value, FALSE);
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
+ id, value);
+}
+
+static gboolean
+glade_gtk_table_verify_n_common (GObject * object, const GValue * value,
+ gboolean for_rows)
+{
+ GtkTable *table = GTK_TABLE (object);
+ guint n_columns, n_rows, new_size = g_value_get_uint (value);
+
+ g_object_get (table, "n-columns", &n_columns, "n-rows", &n_rows, NULL);
+
+ if (glade_gtk_table_widget_exceeds_bounds
+ (table, for_rows ? new_size : n_rows, for_rows ? n_columns : new_size))
+ /* Refuse to shrink if it means orphaning widgets */
+ return FALSE;
+
+ return TRUE;
}
gboolean
-glade_gtk_table_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_table_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "n-rows"))
- return glade_gtk_table_verify_n_common (object, value, TRUE);
- else if (!strcmp (id, "n-columns"))
- return glade_gtk_table_verify_n_common (object, value, FALSE);
- else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
- id, value);
+ if (!strcmp (id, "n-rows"))
+ return glade_gtk_table_verify_n_common (object, value, TRUE);
+ else if (!strcmp (id, "n-columns"))
+ return glade_gtk_table_verify_n_common (object, value, FALSE);
+ else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
+ id, value);
- return TRUE;
+ return TRUE;
}
void
-glade_gtk_table_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
+glade_gtk_table_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name, GValue * value)
{
- g_return_if_fail (GTK_IS_TABLE (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (property_name != NULL && value != NULL);
+ g_return_if_fail (GTK_IS_TABLE (container));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (property_name != NULL && value != NULL);
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
-
- if (strcmp (property_name, "bottom-attach") == 0 ||
- strcmp (property_name, "left-attach") == 0 ||
- strcmp (property_name, "right-attach") == 0 ||
- strcmp (property_name, "top-attach") == 0)
- {
- /* Refresh placeholders */
- glade_gtk_table_refresh_placeholders (GTK_TABLE (container));
- }
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
+
+ if (strcmp (property_name, "bottom-attach") == 0 ||
+ strcmp (property_name, "left-attach") == 0 ||
+ strcmp (property_name, "right-attach") == 0 ||
+ strcmp (property_name, "top-attach") == 0)
+ {
+ /* Refresh placeholders */
+ glade_gtk_table_refresh_placeholders (GTK_TABLE (container));
+ }
}
static gboolean
-glade_gtk_table_verify_attach_common (GObject *object,
- GValue *value,
- guint *val,
- const gchar *prop,
- guint *prop_val,
- const gchar *parent_prop,
- guint *parent_val)
-{
- GladeWidget *widget, *parent;
-
- widget = glade_widget_get_from_gobject (object);
- g_return_val_if_fail (GLADE_IS_WIDGET (widget), TRUE);
- parent = glade_widget_get_parent (widget);
- g_return_val_if_fail (GLADE_IS_WIDGET (parent), TRUE);
-
- *val = g_value_get_uint (value);
- glade_widget_property_get (widget, prop, prop_val);
- glade_widget_property_get (parent, parent_prop, parent_val);
-
- return FALSE;
+glade_gtk_table_verify_attach_common (GObject * object,
+ GValue * value,
+ guint * val,
+ const gchar * prop,
+ guint * prop_val,
+ const gchar * parent_prop,
+ guint * parent_val)
+{
+ GladeWidget *widget, *parent;
+
+ widget = glade_widget_get_from_gobject (object);
+ g_return_val_if_fail (GLADE_IS_WIDGET (widget), TRUE);
+ parent = glade_widget_get_parent (widget);
+ g_return_val_if_fail (GLADE_IS_WIDGET (parent), TRUE);
+
+ *val = g_value_get_uint (value);
+ glade_widget_property_get (widget, prop, prop_val);
+ glade_widget_property_get (parent, parent_prop, parent_val);
+
+ return FALSE;
}
static gboolean
-glade_gtk_table_verify_left_top_attach (GObject *object,
- GValue *value,
- const gchar *prop,
- const gchar *parent_prop)
-{
- guint val, prop_val, parent_val;
-
- if (glade_gtk_table_verify_attach_common (object, value, &val,
- prop, &prop_val,
- parent_prop, &parent_val))
- return FALSE;
-
- if (val >= parent_val || val >= prop_val)
- return FALSE;
-
- return TRUE;
+glade_gtk_table_verify_left_top_attach (GObject * object,
+ GValue * value,
+ const gchar * prop,
+ const gchar * parent_prop)
+{
+ guint val, prop_val, parent_val;
+
+ if (glade_gtk_table_verify_attach_common (object, value, &val,
+ prop, &prop_val,
+ parent_prop, &parent_val))
+ return FALSE;
+
+ if (val >= parent_val || val >= prop_val)
+ return FALSE;
+
+ return TRUE;
}
static gboolean
-glade_gtk_table_verify_right_bottom_attach (GObject *object,
- GValue *value,
- const gchar *prop,
- const gchar *parent_prop)
-{
- guint val, prop_val, parent_val;
-
- if (glade_gtk_table_verify_attach_common (object, value, &val,
- prop, &prop_val,
- parent_prop, &parent_val))
- return FALSE;
-
- if (val <= prop_val || val > parent_val)
- return FALSE;
-
- return TRUE;
+glade_gtk_table_verify_right_bottom_attach (GObject * object,
+ GValue * value,
+ const gchar * prop,
+ const gchar * parent_prop)
+{
+ guint val, prop_val, parent_val;
+
+ if (glade_gtk_table_verify_attach_common (object, value, &val,
+ prop, &prop_val,
+ parent_prop, &parent_val))
+ return FALSE;
+
+ if (val <= prop_val || val > parent_val)
+ return FALSE;
+
+ return TRUE;
}
gboolean
-glade_gtk_table_child_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *id,
- GValue *value)
-{
- if (!strcmp (id, "left-attach"))
- return glade_gtk_table_verify_left_top_attach (child,
- value,
- "right-attach",
- "n-columns");
- else if (!strcmp (id, "right-attach"))
- return glade_gtk_table_verify_right_bottom_attach (child,
- value,
- "left-attach",
- "n-columns");
- else if (!strcmp (id, "top-attach"))
- return glade_gtk_table_verify_left_top_attach (child,
- value,
- "bottom-attach",
- "n-rows");
- else if (!strcmp (id, "bottom-attach"))
- return glade_gtk_table_verify_right_bottom_attach (child,
- value,
- "top-attach",
- "n-rows");
- else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_verify_property)
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_verify_property (adaptor,
- container, child,
- id, value);
-
- return TRUE;
+glade_gtk_table_child_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * id, GValue * value)
+{
+ if (!strcmp (id, "left-attach"))
+ return glade_gtk_table_verify_left_top_attach (child,
+ value,
+ "right-attach", "n-columns");
+ else if (!strcmp (id, "right-attach"))
+ return glade_gtk_table_verify_right_bottom_attach (child,
+ value,
+ "left-attach",
+ "n-columns");
+ else if (!strcmp (id, "top-attach"))
+ return glade_gtk_table_verify_left_top_attach (child,
+ value,
+ "bottom-attach", "n-rows");
+ else if (!strcmp (id, "bottom-attach"))
+ return glade_gtk_table_verify_right_bottom_attach (child,
+ value,
+ "top-attach", "n-rows");
+ else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_verify_property)
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_verify_property (adaptor,
+ container, child,
+ id, value);
+
+ return TRUE;
}
static void
-glade_gtk_table_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *group_format,
- const gchar *n_row_col,
- const gchar *attach1, /* should be smaller (top/left) attachment */
- const gchar *attach2, /* should be larger (bot/right) attachment */
- gboolean remove,
- gboolean after)
-{
- GladeWidget *parent;
- GList *children, *l;
- gint child_pos, size, offset;
-
- gtk_container_child_get (GTK_CONTAINER (container),
- GTK_WIDGET (object),
- after ? attach2 : attach1, &child_pos, NULL);
-
- parent = glade_widget_get_from_gobject (container);
- glade_command_push_group (group_format, glade_widget_get_name (parent));
-
- children = glade_widget_adaptor_get_children (adaptor, container);
- /* Make sure widgets does not get destroyed */
- g_list_foreach (children, (GFunc) g_object_ref, NULL);
-
- glade_widget_property_get (parent, n_row_col, &size);
-
- if (remove)
- {
- GList *del = NULL;
- /* Remove children first */
- for (l = children; l; l = g_list_next (l))
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
- gint pos1, pos2;
-
- /* Skip placeholders */
- if (gchild == NULL) continue;
-
- glade_widget_pack_property_get (gchild, attach1, &pos1);
- glade_widget_pack_property_get (gchild, attach2, &pos2);
- if ((pos1+1 == pos2) && ((after ? pos2 : pos1) == child_pos))
- {
- del = g_list_prepend (del, gchild);
- }
- }
- if (del)
- {
- glade_command_delete (del);
- g_list_free (del);
- }
- offset = -1;
- }
- else
- {
- /* Expand the table */
- glade_command_set_property (glade_widget_get_property (parent, n_row_col),
- size + 1);
- offset = 1;
- }
-
- /* Reorder children */
- for (l = children; l; l = g_list_next (l))
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
- gint pos;
-
- /* Skip placeholders */
- if (gchild == NULL) continue;
-
- /* if removing, do top/left before bot/right */
- if (remove)
- {
- /* adjust top-left attachment*/
- glade_widget_pack_property_get (gchild, attach1, &pos);
- if(pos > child_pos || (after && pos == child_pos))
- {
- glade_command_set_property (glade_widget_get_pack_property (gchild, attach1), pos+offset);
- }
-
- /* adjust bottom-right attachment*/
- glade_widget_pack_property_get (gchild, attach2, &pos);
- if(pos > child_pos || (after && pos == child_pos))
- {
- glade_command_set_property (glade_widget_get_pack_property (gchild, attach2), pos+offset);
- }
-
- }
- /* if inserting, do bot/right before top/left */
- else
- {
- /* adjust bottom-right attachment*/
- glade_widget_pack_property_get (gchild, attach2, &pos);
- if(pos > child_pos)
- {
- glade_command_set_property (glade_widget_get_pack_property (gchild, attach2), pos+offset);
- }
-
- /* adjust top-left attachment*/
- glade_widget_pack_property_get (gchild, attach1, &pos);
- if(pos >= child_pos)
- {
- glade_command_set_property (glade_widget_get_pack_property (gchild, attach1), pos+offset);
- }
- }
- }
-
- if (remove)
- {
- /* Shrink the table */
- glade_command_set_property (glade_widget_get_property (parent, n_row_col),
- size - 1);
- }
-
- g_list_foreach (children, (GFunc) g_object_unref, NULL);
- g_list_free (children);
-
- glade_command_pop_group ();
-}
-
-void
-glade_gtk_table_child_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *action_path)
-{
- if (strcmp (action_path, "insert_row/after") == 0)
- {
- glade_gtk_table_child_insert_remove_action (adaptor, container, object,
- _("Insert Row on %s"),
- "n-rows","top-attach",
- "bottom-attach",
- FALSE, TRUE);
- }
- else if (strcmp (action_path, "insert_row/before") == 0)
- {
- glade_gtk_table_child_insert_remove_action (adaptor, container, object,
- _("Insert Row on %s"),
- "n-rows","top-attach",
- "bottom-attach",
- FALSE, FALSE);
- }
- else if (strcmp (action_path, "insert_column/after") == 0)
- {
- glade_gtk_table_child_insert_remove_action (adaptor, container, object,
- _("Insert Column on %s"),
- "n-columns","left-attach",
- "right-attach",
- FALSE, TRUE);
- }
- else if (strcmp (action_path, "insert_column/before") == 0)
- {
- glade_gtk_table_child_insert_remove_action (adaptor, container, object,
- _("Insert Column on %s"),
- "n-columns","left-attach",
- "right-attach",
- FALSE, FALSE);
- }
- else if (strcmp (action_path, "remove_column") == 0)
- {
- glade_gtk_table_child_insert_remove_action (adaptor, container, object,
- _("Remove Column on %s"),
- "n-columns","left-attach",
- "right-attach",
- TRUE, FALSE);
- }
- else if (strcmp (action_path, "remove_row") == 0)
- {
- glade_gtk_table_child_insert_remove_action (adaptor, container, object,
- _("Remove Row on %s"),
- "n-rows","top-attach",
- "bottom-attach",
- TRUE, FALSE);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
- container,
- object,
- action_path);
+glade_gtk_table_child_insert_remove_action (GladeWidgetAdaptor * adaptor, GObject * container, GObject * object, const gchar * group_format, const gchar * n_row_col, const gchar * attach1, /* should be smaller (top/left) attachment */
+ const gchar * attach2, /* should be larger (bot/right) attachment */
+ gboolean remove, gboolean after)
+{
+ GladeWidget *parent;
+ GList *children, *l;
+ gint child_pos, size, offset;
+
+ gtk_container_child_get (GTK_CONTAINER (container),
+ GTK_WIDGET (object),
+ after ? attach2 : attach1, &child_pos, NULL);
+
+ parent = glade_widget_get_from_gobject (container);
+ glade_command_push_group (group_format, glade_widget_get_name (parent));
+
+ children = glade_widget_adaptor_get_children (adaptor, container);
+ /* Make sure widgets does not get destroyed */
+ g_list_foreach (children, (GFunc) g_object_ref, NULL);
+
+ glade_widget_property_get (parent, n_row_col, &size);
+
+ if (remove)
+ {
+ GList *del = NULL;
+ /* Remove children first */
+ for (l = children; l; l = g_list_next (l))
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
+ gint pos1, pos2;
+
+ /* Skip placeholders */
+ if (gchild == NULL)
+ continue;
+
+ glade_widget_pack_property_get (gchild, attach1, &pos1);
+ glade_widget_pack_property_get (gchild, attach2, &pos2);
+ if ((pos1 + 1 == pos2) && ((after ? pos2 : pos1) == child_pos))
+ {
+ del = g_list_prepend (del, gchild);
+ }
+ }
+ if (del)
+ {
+ glade_command_delete (del);
+ g_list_free (del);
+ }
+ offset = -1;
+ }
+ else
+ {
+ /* Expand the table */
+ glade_command_set_property (glade_widget_get_property (parent, n_row_col),
+ size + 1);
+ offset = 1;
+ }
+
+ /* Reorder children */
+ for (l = children; l; l = g_list_next (l))
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
+ gint pos;
+
+ /* Skip placeholders */
+ if (gchild == NULL)
+ continue;
+
+ /* if removing, do top/left before bot/right */
+ if (remove)
+ {
+ /* adjust top-left attachment */
+ glade_widget_pack_property_get (gchild, attach1, &pos);
+ if (pos > child_pos || (after && pos == child_pos))
+ {
+ glade_command_set_property (glade_widget_get_pack_property
+ (gchild, attach1), pos + offset);
+ }
+
+ /* adjust bottom-right attachment */
+ glade_widget_pack_property_get (gchild, attach2, &pos);
+ if (pos > child_pos || (after && pos == child_pos))
+ {
+ glade_command_set_property (glade_widget_get_pack_property
+ (gchild, attach2), pos + offset);
+ }
+
+ }
+ /* if inserting, do bot/right before top/left */
+ else
+ {
+ /* adjust bottom-right attachment */
+ glade_widget_pack_property_get (gchild, attach2, &pos);
+ if (pos > child_pos)
+ {
+ glade_command_set_property (glade_widget_get_pack_property
+ (gchild, attach2), pos + offset);
+ }
+
+ /* adjust top-left attachment */
+ glade_widget_pack_property_get (gchild, attach1, &pos);
+ if (pos >= child_pos)
+ {
+ glade_command_set_property (glade_widget_get_pack_property
+ (gchild, attach1), pos + offset);
+ }
+ }
+ }
+
+ if (remove)
+ {
+ /* Shrink the table */
+ glade_command_set_property (glade_widget_get_property (parent, n_row_col),
+ size - 1);
+ }
+
+ g_list_foreach (children, (GFunc) g_object_unref, NULL);
+ g_list_free (children);
+
+ glade_command_pop_group ();
+}
+
+void
+glade_gtk_table_child_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * action_path)
+{
+ if (strcmp (action_path, "insert_row/after") == 0)
+ {
+ glade_gtk_table_child_insert_remove_action (adaptor, container, object,
+ _("Insert Row on %s"),
+ "n-rows", "top-attach",
+ "bottom-attach", FALSE, TRUE);
+ }
+ else if (strcmp (action_path, "insert_row/before") == 0)
+ {
+ glade_gtk_table_child_insert_remove_action (adaptor, container, object,
+ _("Insert Row on %s"),
+ "n-rows", "top-attach",
+ "bottom-attach",
+ FALSE, FALSE);
+ }
+ else if (strcmp (action_path, "insert_column/after") == 0)
+ {
+ glade_gtk_table_child_insert_remove_action (adaptor, container, object,
+ _("Insert Column on %s"),
+ "n-columns", "left-attach",
+ "right-attach", FALSE, TRUE);
+ }
+ else if (strcmp (action_path, "insert_column/before") == 0)
+ {
+ glade_gtk_table_child_insert_remove_action (adaptor, container, object,
+ _("Insert Column on %s"),
+ "n-columns", "left-attach",
+ "right-attach", FALSE, FALSE);
+ }
+ else if (strcmp (action_path, "remove_column") == 0)
+ {
+ glade_gtk_table_child_insert_remove_action (adaptor, container, object,
+ _("Remove Column on %s"),
+ "n-columns", "left-attach",
+ "right-attach", TRUE, FALSE);
+ }
+ else if (strcmp (action_path, "remove_row") == 0)
+ {
+ glade_gtk_table_child_insert_remove_action (adaptor, container, object,
+ _("Remove Row on %s"),
+ "n-rows", "top-attach",
+ "bottom-attach", TRUE, FALSE);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
+ container,
+ object,
+ action_path);
}
/* ----------------------------- GtkFrame ------------------------------ */
void
-glade_gtk_frame_post_create (GladeWidgetAdaptor *adaptor,
- GObject *frame,
- GladeCreateReason reason)
-{
- static GladeWidgetAdaptor *label_adaptor = NULL, *alignment_adaptor = NULL;
- GladeWidget *gframe, *glabel, *galignment;
- GtkWidget *label;
- gchar *label_text;
-
- if (reason != GLADE_CREATE_USER)
- return;
-
- g_return_if_fail (GTK_IS_FRAME (frame));
- gframe = glade_widget_get_from_gobject (frame);
- g_return_if_fail (GLADE_IS_WIDGET (gframe));
-
- /* If we didnt put this object here or if frame is an aspect frame... */
- if (((label = gtk_frame_get_label_widget (GTK_FRAME (frame))) == NULL ||
- (glade_widget_get_from_gobject (label) == NULL)) &&
- (GTK_IS_ASPECT_FRAME (frame) == FALSE))
- {
-
- if (label_adaptor == NULL)
- label_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
- if (alignment_adaptor == NULL)
- alignment_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_ALIGNMENT);
-
- /* add label (as an internal child) */
- glabel = glade_widget_adaptor_create_widget (label_adaptor, FALSE,
- "parent", gframe,
- "project", glade_widget_get_project (gframe),
- NULL);
-
- label_text = g_strdup_printf ("<b>%s</b>", glade_widget_get_name (gframe));
- glade_widget_property_set (glabel, "label", label_text);
- glade_widget_property_set (glabel, "use-markup", "TRUE");
- g_free (label_text);
-
- g_object_set_data (glabel->object, "special-child-type", "label_item");
- glade_widget_add_child (gframe, glabel, FALSE);
-
- /* add alignment */
- galignment = glade_widget_adaptor_create_widget (alignment_adaptor, FALSE,
- "parent", gframe,
- "project", glade_widget_get_project (gframe),
- NULL);
-
- glade_widget_property_set (galignment, "left-padding", 12);
- glade_widget_add_child (gframe, galignment, FALSE);
- }
-
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, frame, reason);
-}
-
-void
-glade_gtk_frame_replace_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *current,
- GtkWidget *new_widget)
-{
- gchar *special_child_type;
-
- special_child_type =
- g_object_get_data (G_OBJECT (current), "special-child-type");
-
- if (special_child_type && !strcmp (special_child_type, "label_item"))
- {
- g_object_set_data (G_OBJECT (new_widget), "special-child-type", "label_item");
- gtk_frame_set_label_widget (GTK_FRAME (container), new_widget);
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->replace_child (adaptor,
- G_OBJECT (container),
- G_OBJECT (current),
- G_OBJECT (new_widget));
-}
-
-void
-glade_gtk_frame_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- GtkWidget *bin_child;
- gchar *special_child_type;
-
- special_child_type = g_object_get_data (child, "special-child-type");
-
- if (special_child_type && !strcmp (special_child_type, "label"))
- {
- g_object_set_data (child,
- "special-child-type",
- "label_item");
- gtk_frame_set_label_widget (GTK_FRAME (object),
- GTK_WIDGET (child));
- }
- else if (special_child_type &&
- !strcmp (special_child_type, "label_item"))
- {
- gtk_frame_set_label_widget (GTK_FRAME (object),
- GTK_WIDGET (child));
- }
- else
- {
- /* Get a placeholder out of the way before adding the child
- */
- bin_child = gtk_bin_get_child (GTK_BIN (object));
- if (bin_child)
- {
- if (GLADE_IS_PLACEHOLDER (bin_child))
- gtk_container_remove (GTK_CONTAINER (object), bin_child);
- else
- {
- g_critical ("Cant add more than one widget to a GtkFrame");
- return;
- }
- }
- gtk_container_add (GTK_CONTAINER (object),
- GTK_WIDGET (child));
- }
-}
-
-void
-glade_gtk_frame_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- gchar *special_child_type;
-
- special_child_type = g_object_get_data (child, "special-child-type");
- if (special_child_type &&
- !strcmp (special_child_type, "label_item"))
- {
- gtk_frame_set_label_widget (GTK_FRAME (object),
- glade_placeholder_new ());
- }
- else
- {
- gtk_container_remove (GTK_CONTAINER (object),
- GTK_WIDGET (child));
- gtk_container_add (GTK_CONTAINER (object),
- glade_placeholder_new ());
- }
+glade_gtk_frame_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * frame, GladeCreateReason reason)
+{
+ static GladeWidgetAdaptor *label_adaptor = NULL, *alignment_adaptor = NULL;
+ GladeWidget *gframe, *glabel, *galignment;
+ GtkWidget *label;
+ gchar *label_text;
+
+ if (reason != GLADE_CREATE_USER)
+ return;
+
+ g_return_if_fail (GTK_IS_FRAME (frame));
+ gframe = glade_widget_get_from_gobject (frame);
+ g_return_if_fail (GLADE_IS_WIDGET (gframe));
+
+ /* If we didnt put this object here or if frame is an aspect frame... */
+ if (((label = gtk_frame_get_label_widget (GTK_FRAME (frame))) == NULL ||
+ (glade_widget_get_from_gobject (label) == NULL)) &&
+ (GTK_IS_ASPECT_FRAME (frame) == FALSE))
+ {
+
+ if (label_adaptor == NULL)
+ label_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
+ if (alignment_adaptor == NULL)
+ alignment_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_ALIGNMENT);
+
+ /* add label (as an internal child) */
+ glabel = glade_widget_adaptor_create_widget (label_adaptor, FALSE,
+ "parent", gframe,
+ "project",
+ glade_widget_get_project
+ (gframe), NULL);
+
+ label_text =
+ g_strdup_printf ("<b>%s</b>", glade_widget_get_name (gframe));
+ glade_widget_property_set (glabel, "label", label_text);
+ glade_widget_property_set (glabel, "use-markup", "TRUE");
+ g_free (label_text);
+
+ g_object_set_data (glabel->object, "special-child-type", "label_item");
+ glade_widget_add_child (gframe, glabel, FALSE);
+
+ /* add alignment */
+ galignment = glade_widget_adaptor_create_widget (alignment_adaptor, FALSE,
+ "parent", gframe,
+ "project",
+ glade_widget_get_project
+ (gframe), NULL);
+
+ glade_widget_property_set (galignment, "left-padding", 12);
+ glade_widget_add_child (gframe, galignment, FALSE);
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, frame, reason);
+}
+
+void
+glade_gtk_frame_replace_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container,
+ GtkWidget * current, GtkWidget * new_widget)
+{
+ gchar *special_child_type;
+
+ special_child_type =
+ g_object_get_data (G_OBJECT (current), "special-child-type");
+
+ if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ g_object_set_data (G_OBJECT (new_widget), "special-child-type",
+ "label_item");
+ gtk_frame_set_label_widget (GTK_FRAME (container), new_widget);
+ return;
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->replace_child (adaptor,
+ G_OBJECT (container),
+ G_OBJECT (current),
+ G_OBJECT (new_widget));
+}
+
+void
+glade_gtk_frame_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GtkWidget *bin_child;
+ gchar *special_child_type;
+
+ special_child_type = g_object_get_data (child, "special-child-type");
+
+ if (special_child_type && !strcmp (special_child_type, "label"))
+ {
+ g_object_set_data (child, "special-child-type", "label_item");
+ gtk_frame_set_label_widget (GTK_FRAME (object), GTK_WIDGET (child));
+ }
+ else if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ gtk_frame_set_label_widget (GTK_FRAME (object), GTK_WIDGET (child));
+ }
+ else
+ {
+ /* Get a placeholder out of the way before adding the child
+ */
+ bin_child = gtk_bin_get_child (GTK_BIN (object));
+ if (bin_child)
+ {
+ if (GLADE_IS_PLACEHOLDER (bin_child))
+ gtk_container_remove (GTK_CONTAINER (object), bin_child);
+ else
+ {
+ g_critical ("Cant add more than one widget to a GtkFrame");
+ return;
+ }
+ }
+ gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+ }
+}
+
+void
+glade_gtk_frame_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gchar *special_child_type;
+
+ special_child_type = g_object_get_data (child, "special-child-type");
+ if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ gtk_frame_set_label_widget (GTK_FRAME (object), glade_placeholder_new ());
+ }
+ else
+ {
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+ gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
+ }
}
static gboolean
-write_special_child_label_item (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node,
- GladeWriteWidgetFunc write_func)
-{
- gchar *special_child_type = NULL;
- GObject *child;
-
- child = widget->object;
- if (child)
- special_child_type = g_object_get_data (child, "special-child-type");
-
- if (special_child_type && !strcmp (special_child_type, "label_item"))
- {
- g_object_set_data (child,
- "special-child-type",
- "label");
- write_func (adaptor, widget, context, node);
- g_object_set_data (child,
- "special-child-type",
- "label_item");
- return TRUE;
- }
- else
- return FALSE;
-}
-
-void
-glade_gtk_frame_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
-
- if (!write_special_child_label_item (adaptor, widget, context, node,
- GWA_GET_CLASS(GTK_TYPE_CONTAINER)->write_child))
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->write_child (adaptor,
- widget,
- context,
- node);
+write_special_child_label_item (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node,
+ GladeWriteWidgetFunc write_func)
+{
+ gchar *special_child_type = NULL;
+ GObject *child;
+
+ child = widget->object;
+ if (child)
+ special_child_type = g_object_get_data (child, "special-child-type");
+
+ if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ g_object_set_data (child, "special-child-type", "label");
+ write_func (adaptor, widget, context, node);
+ g_object_set_data (child, "special-child-type", "label_item");
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+void
+glade_gtk_frame_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+
+ if (!write_special_child_label_item (adaptor, widget, context, node,
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->
+ write_child))
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->write_child (adaptor, widget, context, node);
}
/* ----------------------------- GtkNotebook ------------------------------ */
-typedef struct
+typedef struct
{
- gint pages;
- gint page;
+ gint pages;
+ gint page;
- GList *children;
- GList *tabs;
+ GList *children;
+ GList *tabs;
- GList *extra_children;
- GList *extra_tabs;
+ GList *extra_children;
+ GList *extra_tabs;
} NotebookChildren;
static gboolean glade_gtk_notebook_setting_position = FALSE;
static gint
-notebook_child_compare_func (GtkWidget *widget_a, GtkWidget *widget_b)
+notebook_child_compare_func (GtkWidget * widget_a, GtkWidget * widget_b)
{
- GladeWidget *gwidget_a, *gwidget_b;
- gint pos_a = 0, pos_b = 0;
+ GladeWidget *gwidget_a, *gwidget_b;
+ gint pos_a = 0, pos_b = 0;
+
+ gwidget_a = glade_widget_get_from_gobject (widget_a);
+ gwidget_b = glade_widget_get_from_gobject (widget_b);
+
+ g_assert (gwidget_a && gwidget_b);
+
+ glade_widget_pack_property_get (gwidget_a, "position", &pos_a);
+ glade_widget_pack_property_get (gwidget_b, "position", &pos_b);
- gwidget_a = glade_widget_get_from_gobject (widget_a);
- gwidget_b = glade_widget_get_from_gobject (widget_b);
-
- g_assert (gwidget_a && gwidget_b);
-
- glade_widget_pack_property_get (gwidget_a, "position", &pos_a);
- glade_widget_pack_property_get (gwidget_b, "position", &pos_b);
-
- return pos_a - pos_b;
+ return pos_a - pos_b;
}
static gint
-notebook_find_child (GtkWidget *check,
- gpointer cmp_pos_p)
+notebook_find_child (GtkWidget * check, gpointer cmp_pos_p)
{
- GladeWidget *gcheck;
- gint position = 0, cmp_pos = GPOINTER_TO_INT (cmp_pos_p);
-
- gcheck = glade_widget_get_from_gobject (check);
- g_assert (gcheck);
-
- glade_widget_pack_property_get (gcheck, "position", &position);
+ GladeWidget *gcheck;
+ gint position = 0, cmp_pos = GPOINTER_TO_INT (cmp_pos_p);
- return position - cmp_pos;
+ gcheck = glade_widget_get_from_gobject (check);
+ g_assert (gcheck);
+
+ glade_widget_pack_property_get (gcheck, "position", &position);
+
+ return position - cmp_pos;
}
static gint
-notebook_search_tab (GtkNotebook *notebook,
- GtkWidget *tab)
+notebook_search_tab (GtkNotebook * notebook, GtkWidget * tab)
{
- GtkWidget *page;
- gint i;
+ GtkWidget *page;
+ gint i;
- for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++)
- {
- page = gtk_notebook_get_nth_page (notebook, i);
+ for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++)
+ {
+ page = gtk_notebook_get_nth_page (notebook, i);
- if (tab == gtk_notebook_get_tab_label (notebook, page))
- return i;
- }
- g_critical ("Unable to find tab position in a notebook");
- return -1;
+ if (tab == gtk_notebook_get_tab_label (notebook, page))
+ return i;
+ }
+ g_critical ("Unable to find tab position in a notebook");
+ return -1;
}
static GtkWidget *
-notebook_get_filler (NotebookChildren *nchildren, gboolean page)
-{
- GtkWidget *widget = NULL;
-
- if (page && nchildren->extra_children)
- {
- widget = nchildren->extra_children->data;
- nchildren->extra_children =
- g_list_remove (nchildren->extra_children, widget);
- g_assert (widget);
- }
- else if (!page && nchildren->extra_tabs)
- {
- widget = nchildren->extra_tabs->data;
- nchildren->extra_tabs =
- g_list_remove (nchildren->extra_tabs, widget);
- g_assert (widget);
- }
-
- if (widget == NULL)
- {
- /* Need explicit reference here */
- widget = glade_placeholder_new ();
-
- g_object_ref (G_OBJECT (widget));
-
- if (!page)
- g_object_set_data (G_OBJECT (widget),
- "special-child-type", "tab");
-
- }
- return widget;
+notebook_get_filler (NotebookChildren * nchildren, gboolean page)
+{
+ GtkWidget *widget = NULL;
+
+ if (page && nchildren->extra_children)
+ {
+ widget = nchildren->extra_children->data;
+ nchildren->extra_children =
+ g_list_remove (nchildren->extra_children, widget);
+ g_assert (widget);
+ }
+ else if (!page && nchildren->extra_tabs)
+ {
+ widget = nchildren->extra_tabs->data;
+ nchildren->extra_tabs = g_list_remove (nchildren->extra_tabs, widget);
+ g_assert (widget);
+ }
+
+ if (widget == NULL)
+ {
+ /* Need explicit reference here */
+ widget = glade_placeholder_new ();
+
+ g_object_ref (G_OBJECT (widget));
+
+ if (!page)
+ g_object_set_data (G_OBJECT (widget), "special-child-type", "tab");
+
+ }
+ return widget;
}
static GtkWidget *
-notebook_get_page (NotebookChildren *nchildren, gint position)
+notebook_get_page (NotebookChildren * nchildren, gint position)
{
- GList *node;
- GtkWidget *widget = NULL;
+ GList *node;
+ GtkWidget *widget = NULL;
- if ((node = g_list_find_custom
- (nchildren->children,
- GINT_TO_POINTER (position),
- (GCompareFunc)notebook_find_child)) != NULL)
- {
- widget = node->data;
- nchildren->children =
- g_list_remove (nchildren->children, widget);
- }
- else
- widget = notebook_get_filler (nchildren, TRUE);
+ if ((node = g_list_find_custom
+ (nchildren->children,
+ GINT_TO_POINTER (position),
+ (GCompareFunc) notebook_find_child)) != NULL)
+ {
+ widget = node->data;
+ nchildren->children = g_list_remove (nchildren->children, widget);
+ }
+ else
+ widget = notebook_get_filler (nchildren, TRUE);
- return widget;
+ return widget;
}
static GtkWidget *
-notebook_get_tab (NotebookChildren *nchildren, gint position)
+notebook_get_tab (NotebookChildren * nchildren, gint position)
{
- GList *node;
- GtkWidget *widget = NULL;
+ GList *node;
+ GtkWidget *widget = NULL;
- if ((node = g_list_find_custom
- (nchildren->tabs,
- GINT_TO_POINTER (position),
- (GCompareFunc)notebook_find_child)) != NULL)
- {
- widget = node->data;
- nchildren->tabs =
- g_list_remove (nchildren->tabs, widget);
- }
- else
- widget = notebook_get_filler (nchildren, FALSE);
+ if ((node = g_list_find_custom
+ (nchildren->tabs,
+ GINT_TO_POINTER (position),
+ (GCompareFunc) notebook_find_child)) != NULL)
+ {
+ widget = node->data;
+ nchildren->tabs = g_list_remove (nchildren->tabs, widget);
+ }
+ else
+ widget = notebook_get_filler (nchildren, FALSE);
- return widget;
+ return widget;
}
static NotebookChildren *
-glade_gtk_notebook_extract_children (GtkWidget *notebook)
-{
- NotebookChildren *nchildren;
- gchar *special_child_type;
- GList *list, *children =
- glade_util_container_get_all_children (GTK_CONTAINER (notebook));
- GladeWidget *gchild;
- GtkWidget *page;
- gint position = 0;
-
- nchildren = g_new0 (NotebookChildren, 1);
- nchildren->pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
- nchildren->page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- /* Ref all the project widgets and build returned list first */
- for (list = children; list; list = list->next)
- {
- if ((gchild = glade_widget_get_from_gobject (list->data)) != NULL)
- {
- special_child_type =
- g_object_get_data (G_OBJECT (list->data),
- "special-child-type");
-
- glade_widget_pack_property_get (gchild, "position", &position);
-
- g_object_ref (G_OBJECT (list->data));
-
- /* Sort it into the proper struct member
- */
- if (special_child_type == NULL)
- {
- if (g_list_find_custom (nchildren->children,
- GINT_TO_POINTER (position),
- (GCompareFunc)notebook_find_child))
- nchildren->extra_children =
- g_list_insert_sorted
- (nchildren->extra_children, list->data,
- (GCompareFunc)notebook_child_compare_func);
- else
- nchildren->children =
- g_list_insert_sorted
- (nchildren->children, list->data,
- (GCompareFunc)notebook_child_compare_func);
- } else {
- if (g_list_find_custom (nchildren->tabs,
- GINT_TO_POINTER (position),
- (GCompareFunc)notebook_find_child))
- nchildren->extra_tabs =
- g_list_insert_sorted
- (nchildren->extra_tabs, list->data,
- (GCompareFunc)notebook_child_compare_func);
- else
- nchildren->tabs =
- g_list_insert_sorted
- (nchildren->tabs, list->data,
- (GCompareFunc)notebook_child_compare_func);
- }
- }
- }
-
- /* Remove all pages, resulting in the unparenting of all widgets including tab-labels.
- */
- while (gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 0)
- {
- page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0);
-
- /* Explicitly remove the tab label first */
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), page, NULL);
- gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), 0);
- }
-
- if (children)
- g_list_free (children);
-
- return nchildren;
+glade_gtk_notebook_extract_children (GtkWidget * notebook)
+{
+ NotebookChildren *nchildren;
+ gchar *special_child_type;
+ GList *list, *children =
+ glade_util_container_get_all_children (GTK_CONTAINER (notebook));
+ GladeWidget *gchild;
+ GtkWidget *page;
+ gint position = 0;
+
+ nchildren = g_new0 (NotebookChildren, 1);
+ nchildren->pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+ nchildren->page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+
+ /* Ref all the project widgets and build returned list first */
+ for (list = children; list; list = list->next)
+ {
+ if ((gchild = glade_widget_get_from_gobject (list->data)) != NULL)
+ {
+ special_child_type =
+ g_object_get_data (G_OBJECT (list->data), "special-child-type");
+
+ glade_widget_pack_property_get (gchild, "position", &position);
+
+ g_object_ref (G_OBJECT (list->data));
+
+ /* Sort it into the proper struct member
+ */
+ if (special_child_type == NULL)
+ {
+ if (g_list_find_custom (nchildren->children,
+ GINT_TO_POINTER (position),
+ (GCompareFunc) notebook_find_child))
+ nchildren->extra_children =
+ g_list_insert_sorted
+ (nchildren->extra_children, list->data,
+ (GCompareFunc) notebook_child_compare_func);
+ else
+ nchildren->children =
+ g_list_insert_sorted
+ (nchildren->children, list->data,
+ (GCompareFunc) notebook_child_compare_func);
+ }
+ else
+ {
+ if (g_list_find_custom (nchildren->tabs,
+ GINT_TO_POINTER (position),
+ (GCompareFunc) notebook_find_child))
+ nchildren->extra_tabs =
+ g_list_insert_sorted
+ (nchildren->extra_tabs, list->data,
+ (GCompareFunc) notebook_child_compare_func);
+ else
+ nchildren->tabs =
+ g_list_insert_sorted
+ (nchildren->tabs, list->data,
+ (GCompareFunc) notebook_child_compare_func);
+ }
+ }
+ }
+
+ /* Remove all pages, resulting in the unparenting of all widgets including tab-labels.
+ */
+ while (gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 0)
+ {
+ page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0);
+
+ /* Explicitly remove the tab label first */
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), page, NULL);
+ gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), 0);
+ }
+
+ if (children)
+ g_list_free (children);
+
+ return nchildren;
}
static void
-glade_gtk_notebook_insert_children (GtkWidget *notebook, NotebookChildren *nchildren)
+glade_gtk_notebook_insert_children (GtkWidget * notebook,
+ NotebookChildren * nchildren)
{
- gint i;
-
- /*********************************************************
+ gint i;
+
+ /*********************************************************
INSERT PAGES
*********************************************************/
- for (i = 0; i < nchildren->pages; i++)
- {
- GtkWidget *page = notebook_get_page (nchildren, i);
- GtkWidget *tab = notebook_get_tab (nchildren, i);
-
- gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), page, NULL, i);
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), page, tab);
-
- g_object_unref (G_OBJECT (page));
- g_object_unref (G_OBJECT (tab));
- }
-
- /* Stay on the same page */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), nchildren->page);
-
- /* Free the original lists now */
- if (nchildren->children)
- g_list_free (nchildren->children);
-
- if (nchildren->tabs)
- g_list_free (nchildren->tabs);
-
- if (nchildren->children ||
- nchildren->tabs ||
- nchildren->extra_children ||
- nchildren->extra_tabs)
- g_critical ("Unbalanced children when inserting notebook children"
- " (pages: %d tabs: %d extra pages: %d extra tabs %d)",
- g_list_length (nchildren->children),
- g_list_length (nchildren->tabs),
- g_list_length (nchildren->extra_children),
- g_list_length (nchildren->extra_tabs));
-
- g_free (nchildren);
+ for (i = 0; i < nchildren->pages; i++)
+ {
+ GtkWidget *page = notebook_get_page (nchildren, i);
+ GtkWidget *tab = notebook_get_tab (nchildren, i);
+
+ gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), page, NULL, i);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), page, tab);
+
+ g_object_unref (G_OBJECT (page));
+ g_object_unref (G_OBJECT (tab));
+ }
+
+ /* Stay on the same page */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), nchildren->page);
+
+ /* Free the original lists now */
+ if (nchildren->children)
+ g_list_free (nchildren->children);
+
+ if (nchildren->tabs)
+ g_list_free (nchildren->tabs);
+
+ if (nchildren->children ||
+ nchildren->tabs || nchildren->extra_children || nchildren->extra_tabs)
+ g_critical ("Unbalanced children when inserting notebook children"
+ " (pages: %d tabs: %d extra pages: %d extra tabs %d)",
+ g_list_length (nchildren->children),
+ g_list_length (nchildren->tabs),
+ g_list_length (nchildren->extra_children),
+ g_list_length (nchildren->extra_tabs));
+
+ g_free (nchildren);
}
static void
-glade_gtk_notebook_switch_page (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- gpointer user_data)
+glade_gtk_notebook_switch_page (GtkNotebook * notebook,
+ GtkWidget * page,
+ guint page_num, gpointer user_data)
{
- GladeWidget *gnotebook = glade_widget_get_from_gobject (notebook);
+ GladeWidget *gnotebook = glade_widget_get_from_gobject (notebook);
- glade_widget_property_set (gnotebook, "page", page_num);
+ glade_widget_property_set (gnotebook, "page", page_num);
}
@@ -3551,1675 +3425,1706 @@ glade_gtk_notebook_switch_page (GtkNotebook *notebook,
* the selected widget.
*/
static void
-glade_gtk_notebook_selection_changed (GladeProject *project,
- GladeWidget *gwidget)
-{
- GladeWidget *selected;
- GList *list;
- gint i;
- GtkWidget *page;
-
- if ((list = glade_project_selection_get (project)) != NULL &&
- g_list_length (list) == 1)
- {
- selected = glade_widget_get_from_gobject (list->data);
-
- /* Check if selected widget is inside the notebook */
- if (GTK_IS_WIDGET (selected->object) &&
- gtk_widget_is_ancestor (GTK_WIDGET (selected->object),
- GTK_WIDGET (gwidget->object)))
- {
- /* Find and activate the page */
- for (i = 0; i < gtk_notebook_get_n_pages (GTK_NOTEBOOK (gwidget->object)); i++)
- {
- page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (gwidget->object), i);
- if (GTK_WIDGET (selected->object) == page ||
- gtk_widget_is_ancestor (GTK_WIDGET (selected->object),
- GTK_WIDGET (page)))
- {
- glade_widget_property_set (gwidget, "page", i);
- return;
- }
- }
- }
- }
+glade_gtk_notebook_selection_changed (GladeProject * project,
+ GladeWidget * gwidget)
+{
+ GladeWidget *selected;
+ GList *list;
+ gint i;
+ GtkWidget *page;
+
+ if ((list = glade_project_selection_get (project)) != NULL &&
+ g_list_length (list) == 1)
+ {
+ selected = glade_widget_get_from_gobject (list->data);
+
+ /* Check if selected widget is inside the notebook */
+ if (GTK_IS_WIDGET (selected->object) &&
+ gtk_widget_is_ancestor (GTK_WIDGET (selected->object),
+ GTK_WIDGET (gwidget->object)))
+ {
+ /* Find and activate the page */
+ for (i = 0;
+ i < gtk_notebook_get_n_pages (GTK_NOTEBOOK (gwidget->object));
+ i++)
+ {
+ page =
+ gtk_notebook_get_nth_page (GTK_NOTEBOOK (gwidget->object), i);
+ if (GTK_WIDGET (selected->object) == page ||
+ gtk_widget_is_ancestor (GTK_WIDGET (selected->object),
+ GTK_WIDGET (page)))
+ {
+ glade_widget_property_set (gwidget, "page", i);
+ return;
+ }
+ }
+ }
+ }
}
static void
-glade_gtk_notebook_project_changed (GladeWidget *gwidget,
- GParamSpec *pspec,
- gpointer userdata)
+glade_gtk_notebook_project_changed (GladeWidget * gwidget,
+ GParamSpec * pspec, gpointer userdata)
{
- GladeProject
- *project = glade_widget_get_project (gwidget),
- *old_project = g_object_get_data (G_OBJECT (gwidget), "notebook-project-ptr");
-
- if (old_project)
- g_signal_handlers_disconnect_by_func (G_OBJECT (old_project),
- G_CALLBACK (glade_gtk_notebook_selection_changed),
- gwidget);
+ GladeProject
+ * project = glade_widget_get_project (gwidget),
+ *old_project =
+ g_object_get_data (G_OBJECT (gwidget), "notebook-project-ptr");
+
+ if (old_project)
+ g_signal_handlers_disconnect_by_func (G_OBJECT (old_project),
+ G_CALLBACK
+ (glade_gtk_notebook_selection_changed),
+ gwidget);
- if (project)
- g_signal_connect (G_OBJECT (project), "selection-changed",
- G_CALLBACK (glade_gtk_notebook_selection_changed), gwidget);
+ if (project)
+ g_signal_connect (G_OBJECT (project), "selection-changed",
+ G_CALLBACK (glade_gtk_notebook_selection_changed),
+ gwidget);
- g_object_set_data (G_OBJECT (gwidget), "notebook-project-ptr", project);
+ g_object_set_data (G_OBJECT (gwidget), "notebook-project-ptr", project);
}
void
-glade_gtk_notebook_post_create (GladeWidgetAdaptor *adaptor,
- GObject *notebook,
- GladeCreateReason reason)
+glade_gtk_notebook_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * notebook, GladeCreateReason reason)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (notebook);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (notebook);
- gtk_notebook_popup_disable (GTK_NOTEBOOK (notebook));
+ gtk_notebook_popup_disable (GTK_NOTEBOOK (notebook));
- g_signal_connect (G_OBJECT (gwidget), "notify::project",
- G_CALLBACK (glade_gtk_notebook_project_changed), NULL);
+ g_signal_connect (G_OBJECT (gwidget), "notify::project",
+ G_CALLBACK (glade_gtk_notebook_project_changed), NULL);
- glade_gtk_notebook_project_changed (gwidget, NULL, NULL);
+ glade_gtk_notebook_project_changed (gwidget, NULL, NULL);
- g_signal_connect (G_OBJECT (notebook), "switch-page",
- G_CALLBACK (glade_gtk_notebook_switch_page), NULL);
+ g_signal_connect (G_OBJECT (notebook), "switch-page",
+ G_CALLBACK (glade_gtk_notebook_switch_page), NULL);
}
static gint
-glade_gtk_notebook_get_first_blank_page (GtkNotebook *notebook)
-{
- GladeWidget *gwidget;
- GtkWidget *widget;
- gint position;
-
- for (position = 0; position < gtk_notebook_get_n_pages (notebook); position++)
- {
- widget = gtk_notebook_get_nth_page (notebook, position);
- if ((gwidget = glade_widget_get_from_gobject (widget)) != NULL)
- {
- GladeProperty *property =
- glade_widget_get_property (gwidget, "position");
- gint gwidget_position = g_value_get_int (property->value);
-
- if ((gwidget_position - position) > 0)
- return position;
- }
- }
- return position;
+glade_gtk_notebook_get_first_blank_page (GtkNotebook * notebook)
+{
+ GladeWidget *gwidget;
+ GtkWidget *widget;
+ gint position;
+
+ for (position = 0; position < gtk_notebook_get_n_pages (notebook); position++)
+ {
+ widget = gtk_notebook_get_nth_page (notebook, position);
+ if ((gwidget = glade_widget_get_from_gobject (widget)) != NULL)
+ {
+ GladeProperty *property =
+ glade_widget_get_property (gwidget, "position");
+ gint gwidget_position = g_value_get_int (property->value);
+
+ if ((gwidget_position - position) > 0)
+ return position;
+ }
+ }
+ return position;
}
static GladeWidget *
-glade_gtk_notebook_generate_tab (GladeWidget *notebook,
- gint page_id)
+glade_gtk_notebook_generate_tab (GladeWidget * notebook, gint page_id)
{
- static GladeWidgetAdaptor *wadaptor = NULL;
- gchar *str;
- GladeWidget *glabel;
+ static GladeWidgetAdaptor *wadaptor = NULL;
+ gchar *str;
+ GladeWidget *glabel;
+
+ if (wadaptor == NULL)
+ wadaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
- if (wadaptor == NULL)
- wadaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
+ glabel = glade_widget_adaptor_create_widget (wadaptor, FALSE,
+ "parent", notebook,
+ "project",
+ glade_widget_get_project
+ (notebook), NULL);
- glabel = glade_widget_adaptor_create_widget (wadaptor, FALSE,
- "parent", notebook,
- "project", glade_widget_get_project (notebook),
- NULL);
-
- str = g_strdup_printf ("page %d", page_id);
- glade_widget_property_set (glabel, "label", str);
- g_free (str);
-
- g_object_set_data (glabel->object, "special-child-type", "tab");
- gtk_widget_show (GTK_WIDGET (glabel->object));
+ str = g_strdup_printf ("page %d", page_id);
+ glade_widget_property_set (glabel, "label", str);
+ g_free (str);
- return glabel;
+ g_object_set_data (glabel->object, "special-child-type", "tab");
+ gtk_widget_show (GTK_WIDGET (glabel->object));
+
+ return glabel;
}
static void
-glade_gtk_notebook_set_n_pages (GObject *object, const GValue *value)
-{
- GladeWidget *widget;
- GtkNotebook *notebook;
- GtkWidget *child_widget, *tab_widget;
- gint new_size, i;
- gint old_size;
-
- notebook = GTK_NOTEBOOK (object);
- g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
-
- widget = glade_widget_get_from_gobject (GTK_WIDGET (notebook));
- g_return_if_fail (widget != NULL);
-
- new_size = g_value_get_int (value);
- old_size = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
-
- /* Ensure base size of notebook */
- if (glade_widget_superuser () == FALSE)
- {
- for (i = gtk_notebook_get_n_pages (notebook); i < new_size; i++)
- {
- gint position = glade_gtk_notebook_get_first_blank_page (notebook);
- GtkWidget *placeholder = glade_placeholder_new ();
- GladeWidget *gtab;
-
- gtk_notebook_insert_page (notebook, placeholder, NULL, position);
-
- /* XXX Ugly hack amongst many, this one only creates project widgets
- * when the 'n-pages' of a notebook is initially set, otherwise it puts
- * placeholders. (this makes the job easier when doing "insert before/after")
- */
- if (old_size == 0 && new_size > 1)
- {
- gtab = glade_gtk_notebook_generate_tab (widget, position + 1);
-
- /* Must pass through GladeWidget api so that packing props
- * are correctly assigned.
- */
- glade_widget_add_child (widget, gtab, FALSE);
- }
- else
- {
- GtkWidget *tab_placeholder = glade_placeholder_new ();
-
- g_object_set_data (G_OBJECT (tab_placeholder), "special-child-type", "tab");
-
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), placeholder,
- tab_placeholder);
- }
- }
- }
-
- /*
- * Thing to remember is that GtkNotebook starts the
- * page numbers from 0, not 1 (C-style). So we need to do
- * old_size-1, where we're referring to "nth" widget.
- */
- while (old_size > new_size) {
- /* Get the last page and remove it (project objects have been cleared by
- * the action code already). */
- child_widget = gtk_notebook_get_nth_page (notebook, old_size-1);
- tab_widget = gtk_notebook_get_tab_label (notebook, child_widget);
-
- /* Ok there shouldnt be widget in the content area, that's
- * the placeholder, we should clean up the project widget that
- * we put in the tab here though (this happens in the case where
- * we undo increasing the "pages" property).
- */
- if (glade_widget_get_from_gobject (child_widget))
- g_critical ("Bug in notebook_set_n_pages()");
-
- gtk_notebook_remove_page (notebook, old_size-1);
-
- old_size--;
- }
-}
-
-void
-glade_gtk_notebook_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "pages"))
- glade_gtk_notebook_set_n_pages (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
- id, value);
+glade_gtk_notebook_set_n_pages (GObject * object, const GValue * value)
+{
+ GladeWidget *widget;
+ GtkNotebook *notebook;
+ GtkWidget *child_widget, *tab_widget;
+ gint new_size, i;
+ gint old_size;
+
+ notebook = GTK_NOTEBOOK (object);
+ g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
+
+ widget = glade_widget_get_from_gobject (GTK_WIDGET (notebook));
+ g_return_if_fail (widget != NULL);
+
+ new_size = g_value_get_int (value);
+ old_size = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+
+ /* Ensure base size of notebook */
+ if (glade_widget_superuser () == FALSE)
+ {
+ for (i = gtk_notebook_get_n_pages (notebook); i < new_size; i++)
+ {
+ gint position = glade_gtk_notebook_get_first_blank_page (notebook);
+ GtkWidget *placeholder = glade_placeholder_new ();
+ GladeWidget *gtab;
+
+ gtk_notebook_insert_page (notebook, placeholder, NULL, position);
+
+ /* XXX Ugly hack amongst many, this one only creates project widgets
+ * when the 'n-pages' of a notebook is initially set, otherwise it puts
+ * placeholders. (this makes the job easier when doing "insert before/after")
+ */
+ if (old_size == 0 && new_size > 1)
+ {
+ gtab = glade_gtk_notebook_generate_tab (widget, position + 1);
+
+ /* Must pass through GladeWidget api so that packing props
+ * are correctly assigned.
+ */
+ glade_widget_add_child (widget, gtab, FALSE);
+ }
+ else
+ {
+ GtkWidget *tab_placeholder = glade_placeholder_new ();
+
+ g_object_set_data (G_OBJECT (tab_placeholder),
+ "special-child-type", "tab");
+
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), placeholder,
+ tab_placeholder);
+ }
+ }
+ }
+
+ /*
+ * Thing to remember is that GtkNotebook starts the
+ * page numbers from 0, not 1 (C-style). So we need to do
+ * old_size-1, where we're referring to "nth" widget.
+ */
+ while (old_size > new_size)
+ {
+ /* Get the last page and remove it (project objects have been cleared by
+ * the action code already). */
+ child_widget = gtk_notebook_get_nth_page (notebook, old_size - 1);
+ tab_widget = gtk_notebook_get_tab_label (notebook, child_widget);
+
+ /* Ok there shouldnt be widget in the content area, that's
+ * the placeholder, we should clean up the project widget that
+ * we put in the tab here though (this happens in the case where
+ * we undo increasing the "pages" property).
+ */
+ if (glade_widget_get_from_gobject (child_widget))
+ g_critical ("Bug in notebook_set_n_pages()");
+
+ gtk_notebook_remove_page (notebook, old_size - 1);
+
+ old_size--;
+ }
+}
+
+void
+glade_gtk_notebook_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ if (!strcmp (id, "pages"))
+ glade_gtk_notebook_set_n_pages (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
+ id, value);
}
static gboolean
-glade_gtk_notebook_verify_n_pages (GObject *object, const GValue *value)
-{
- GtkNotebook *notebook = GTK_NOTEBOOK(object);
- GtkWidget *child_widget, *tab_widget;
- gint old_size, new_size = g_value_get_int (value);
-
- for (old_size = gtk_notebook_get_n_pages (notebook);
- old_size > new_size; old_size--) {
- /* Get the last widget. */
- child_widget = gtk_notebook_get_nth_page (notebook, old_size-1);
- tab_widget = gtk_notebook_get_tab_label (notebook, child_widget);
-
- /*
- * If we got it, and its not a placeholder, remove it
- * from project.
- */
- if (glade_widget_get_from_gobject (child_widget) ||
- glade_widget_get_from_gobject (tab_widget))
- return FALSE;
- }
- return TRUE;
+glade_gtk_notebook_verify_n_pages (GObject * object, const GValue * value)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK (object);
+ GtkWidget *child_widget, *tab_widget;
+ gint old_size, new_size = g_value_get_int (value);
+
+ for (old_size = gtk_notebook_get_n_pages (notebook);
+ old_size > new_size; old_size--)
+ {
+ /* Get the last widget. */
+ child_widget = gtk_notebook_get_nth_page (notebook, old_size - 1);
+ tab_widget = gtk_notebook_get_tab_label (notebook, child_widget);
+
+ /*
+ * If we got it, and its not a placeholder, remove it
+ * from project.
+ */
+ if (glade_widget_get_from_gobject (child_widget) ||
+ glade_widget_get_from_gobject (tab_widget))
+ return FALSE;
+ }
+ return TRUE;
}
gboolean
-glade_gtk_notebook_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "pages"))
- return glade_gtk_notebook_verify_n_pages (object, value);
- else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
- id, value);
-
- return TRUE;
-}
-
-void
-glade_gtk_notebook_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- GtkNotebook *notebook;
- gint num_page, position = 0;
- GtkWidget *last_page;
- GladeWidget *gwidget;
- gchar *special_child_type;
-
- notebook = GTK_NOTEBOOK (object);
-
- num_page = gtk_notebook_get_n_pages (notebook);
- gwidget = glade_widget_get_from_gobject (object);
-
- /* Just append pages blindly when loading/dupping
- */
- if (glade_widget_superuser ())
- {
- special_child_type = g_object_get_data (child, "special-child-type");
- if (special_child_type &&
- !strcmp (special_child_type, "tab"))
- {
- last_page = gtk_notebook_get_nth_page (notebook, num_page - 1);
- gtk_notebook_set_tab_label (notebook, last_page,
- GTK_WIDGET (child));
- }
- else
- {
- gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
-
- glade_widget_property_set (gwidget, "pages", num_page + 1);
-
- gwidget = glade_widget_get_from_gobject (child);
- if (gwidget && gwidget->packing_properties)
- glade_widget_pack_property_set (gwidget, "position", num_page);
- }
- }
- else
- {
- NotebookChildren *nchildren;
-
- /* Just destroy placeholders */
- if (GLADE_IS_PLACEHOLDER (child))
- gtk_widget_destroy (GTK_WIDGET (child));
- else
- {
- gwidget = glade_widget_get_from_gobject (child);
- g_assert (gwidget);
-
- glade_widget_pack_property_get (gwidget, "position", &position);
-
- nchildren = glade_gtk_notebook_extract_children (GTK_WIDGET (notebook));
-
- if (g_object_get_data (child, "special-child-type") != NULL)
- {
- if (g_list_find_custom (nchildren->tabs,
- GINT_TO_POINTER (position),
- (GCompareFunc)notebook_find_child))
- nchildren->extra_tabs =
- g_list_insert_sorted
- (nchildren->extra_tabs, child,
- (GCompareFunc)notebook_child_compare_func);
- else
- nchildren->tabs =
- g_list_insert_sorted
- (nchildren->tabs, child,
- (GCompareFunc)notebook_child_compare_func);
- }
- else
- {
- if (g_list_find_custom (nchildren->children,
- GINT_TO_POINTER (position),
- (GCompareFunc)notebook_find_child))
- nchildren->extra_children =
- g_list_insert_sorted
- (nchildren->extra_children, child,
- (GCompareFunc)notebook_child_compare_func);
- else
- nchildren->children =
- g_list_insert_sorted
- (nchildren->children, child,
- (GCompareFunc)notebook_child_compare_func);
- }
-
- /* Takes an explicit reference when sitting on the list */
- g_object_ref (child);
-
- glade_gtk_notebook_insert_children (GTK_WIDGET (notebook), nchildren);
- }
- }
-}
-
-void
-glade_gtk_notebook_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- NotebookChildren *nchildren;
-
- nchildren = glade_gtk_notebook_extract_children (GTK_WIDGET (object));
-
- if (g_list_find (nchildren->children, child))
- {
- nchildren->children =
- g_list_remove (nchildren->children, child);
- g_object_unref (child);
- }
- else if (g_list_find (nchildren->extra_children, child))
- {
- nchildren->extra_children =
- g_list_remove (nchildren->extra_children, child);
- g_object_unref (child);
- }
- else if (g_list_find (nchildren->tabs, child))
- {
- nchildren->tabs =
- g_list_remove (nchildren->tabs, child);
- g_object_unref (child);
- }
- else if (g_list_find (nchildren->extra_tabs, child))
- {
- nchildren->extra_tabs =
- g_list_remove (nchildren->extra_tabs, child);
- g_object_unref (child);
- }
-
- glade_gtk_notebook_insert_children (GTK_WIDGET (object), nchildren);
-
-}
-
-void
-glade_gtk_notebook_replace_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *current,
- GtkWidget *new_widget)
-{
- GtkNotebook *notebook;
- GladeWidget *gcurrent, *gnew;
- gint position = 0;
-
- notebook = GTK_NOTEBOOK (container);
-
- if ((gcurrent = glade_widget_get_from_gobject (current)) != NULL)
- glade_widget_pack_property_get (gcurrent, "position", &position);
- else
- {
- if ((position = gtk_notebook_page_num (notebook, current)) < 0)
- {
- position = notebook_search_tab (notebook, current);
- g_assert (position >= 0);
- }
- }
-
- if (g_object_get_data (G_OBJECT (current), "special-child-type"))
- g_object_set_data (G_OBJECT (new_widget), "special-child-type", "tab");
-
- glade_gtk_notebook_remove_child (adaptor,
- G_OBJECT (container),
- G_OBJECT (current));
-
- if (GLADE_IS_PLACEHOLDER (new_widget) == FALSE)
- {
- gnew = glade_widget_get_from_gobject (new_widget);
-
- glade_gtk_notebook_add_child (adaptor,
- G_OBJECT (container),
- G_OBJECT (new_widget));
-
- if (glade_widget_pack_property_set (gnew, "position", position) == FALSE)
- g_critical ("No position property found on new widget");
- }
- else
- gtk_widget_destroy (GTK_WIDGET (new_widget));
-}
+glade_gtk_notebook_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ if (!strcmp (id, "pages"))
+ return glade_gtk_notebook_verify_n_pages (object, value);
+ else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
+ id, value);
+
+ return TRUE;
+}
+
+void
+glade_gtk_notebook_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GtkNotebook *notebook;
+ gint num_page, position = 0;
+ GtkWidget *last_page;
+ GladeWidget *gwidget;
+ gchar *special_child_type;
+
+ notebook = GTK_NOTEBOOK (object);
+
+ num_page = gtk_notebook_get_n_pages (notebook);
+ gwidget = glade_widget_get_from_gobject (object);
+
+ /* Just append pages blindly when loading/dupping
+ */
+ if (glade_widget_superuser ())
+ {
+ special_child_type = g_object_get_data (child, "special-child-type");
+ if (special_child_type && !strcmp (special_child_type, "tab"))
+ {
+ last_page = gtk_notebook_get_nth_page (notebook, num_page - 1);
+ gtk_notebook_set_tab_label (notebook, last_page, GTK_WIDGET (child));
+ }
+ else
+ {
+ gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+
+ glade_widget_property_set (gwidget, "pages", num_page + 1);
+
+ gwidget = glade_widget_get_from_gobject (child);
+ if (gwidget && gwidget->packing_properties)
+ glade_widget_pack_property_set (gwidget, "position", num_page);
+ }
+ }
+ else
+ {
+ NotebookChildren *nchildren;
+
+ /* Just destroy placeholders */
+ if (GLADE_IS_PLACEHOLDER (child))
+ gtk_widget_destroy (GTK_WIDGET (child));
+ else
+ {
+ gwidget = glade_widget_get_from_gobject (child);
+ g_assert (gwidget);
+
+ glade_widget_pack_property_get (gwidget, "position", &position);
+
+ nchildren =
+ glade_gtk_notebook_extract_children (GTK_WIDGET (notebook));
+
+ if (g_object_get_data (child, "special-child-type") != NULL)
+ {
+ if (g_list_find_custom (nchildren->tabs,
+ GINT_TO_POINTER (position),
+ (GCompareFunc) notebook_find_child))
+ nchildren->extra_tabs =
+ g_list_insert_sorted
+ (nchildren->extra_tabs, child,
+ (GCompareFunc) notebook_child_compare_func);
+ else
+ nchildren->tabs =
+ g_list_insert_sorted
+ (nchildren->tabs, child,
+ (GCompareFunc) notebook_child_compare_func);
+ }
+ else
+ {
+ if (g_list_find_custom (nchildren->children,
+ GINT_TO_POINTER (position),
+ (GCompareFunc) notebook_find_child))
+ nchildren->extra_children =
+ g_list_insert_sorted
+ (nchildren->extra_children, child,
+ (GCompareFunc) notebook_child_compare_func);
+ else
+ nchildren->children =
+ g_list_insert_sorted
+ (nchildren->children, child,
+ (GCompareFunc) notebook_child_compare_func);
+ }
+
+ /* Takes an explicit reference when sitting on the list */
+ g_object_ref (child);
+
+ glade_gtk_notebook_insert_children (GTK_WIDGET (notebook), nchildren);
+ }
+ }
+}
+
+void
+glade_gtk_notebook_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ NotebookChildren *nchildren;
+
+ nchildren = glade_gtk_notebook_extract_children (GTK_WIDGET (object));
+
+ if (g_list_find (nchildren->children, child))
+ {
+ nchildren->children = g_list_remove (nchildren->children, child);
+ g_object_unref (child);
+ }
+ else if (g_list_find (nchildren->extra_children, child))
+ {
+ nchildren->extra_children =
+ g_list_remove (nchildren->extra_children, child);
+ g_object_unref (child);
+ }
+ else if (g_list_find (nchildren->tabs, child))
+ {
+ nchildren->tabs = g_list_remove (nchildren->tabs, child);
+ g_object_unref (child);
+ }
+ else if (g_list_find (nchildren->extra_tabs, child))
+ {
+ nchildren->extra_tabs = g_list_remove (nchildren->extra_tabs, child);
+ g_object_unref (child);
+ }
+
+ glade_gtk_notebook_insert_children (GTK_WIDGET (object), nchildren);
+
+}
+
+void
+glade_gtk_notebook_replace_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container,
+ GtkWidget * current, GtkWidget * new_widget)
+{
+ GtkNotebook *notebook;
+ GladeWidget *gcurrent, *gnew;
+ gint position = 0;
+
+ notebook = GTK_NOTEBOOK (container);
+
+ if ((gcurrent = glade_widget_get_from_gobject (current)) != NULL)
+ glade_widget_pack_property_get (gcurrent, "position", &position);
+ else
+ {
+ if ((position = gtk_notebook_page_num (notebook, current)) < 0)
+ {
+ position = notebook_search_tab (notebook, current);
+ g_assert (position >= 0);
+ }
+ }
+
+ if (g_object_get_data (G_OBJECT (current), "special-child-type"))
+ g_object_set_data (G_OBJECT (new_widget), "special-child-type", "tab");
+
+ glade_gtk_notebook_remove_child (adaptor,
+ G_OBJECT (container), G_OBJECT (current));
+
+ if (GLADE_IS_PLACEHOLDER (new_widget) == FALSE)
+ {
+ gnew = glade_widget_get_from_gobject (new_widget);
+
+ glade_gtk_notebook_add_child (adaptor,
+ G_OBJECT (container),
+ G_OBJECT (new_widget));
+
+ if (glade_widget_pack_property_set (gnew, "position", position) == FALSE)
+ g_critical ("No position property found on new widget");
+ }
+ else
+ gtk_widget_destroy (GTK_WIDGET (new_widget));
+}
gboolean
-glade_gtk_notebook_child_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *id,
- GValue *value)
-{
- if (!strcmp (id, "position"))
- return g_value_get_int (value) >= 0 &&
- g_value_get_int (value) <
- gtk_notebook_get_n_pages (GTK_NOTEBOOK (container));
- else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_verify_property)
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_verify_property (adaptor,
- container, child,
- id, value);
-
- return TRUE;
-}
-
-void
-glade_gtk_notebook_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
-{
- NotebookChildren *nchildren;
-
- if (strcmp (property_name, "position") == 0)
- {
- /* If we are setting this internally, avoid feedback. */
- if (glade_gtk_notebook_setting_position ||
- glade_widget_superuser ())
- return;
-
- /* Just rebuild the notebook, property values are already set at this point */
- nchildren = glade_gtk_notebook_extract_children (GTK_WIDGET (container));
- glade_gtk_notebook_insert_children (GTK_WIDGET (container), nchildren);
- }
- /* packing properties are unsupported on tabs ... except "position" */
- else if (g_object_get_data (child, "special-child-type") == NULL)
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
-}
-
-void
-glade_gtk_notebook_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- gint position;
-
- if (strcmp (property_name, "position") == 0)
- {
- if (g_object_get_data (child, "special-child-type") != NULL)
- {
- if ((position = notebook_search_tab (GTK_NOTEBOOK (container),
- GTK_WIDGET (child))) >= 0)
- g_value_set_int (value, position);
- else
- g_value_set_int (value, 0);
- }
- else
- gtk_container_child_get_property (GTK_CONTAINER (container),
- GTK_WIDGET (child),
- property_name,
- value);
- }
- /* packing properties are unsupported on tabs ... except "position" */
- else if (g_object_get_data (child, "special-child-type") == NULL)
- gtk_container_child_get_property (GTK_CONTAINER (container),
- GTK_WIDGET (child),
- property_name,
- value);
+glade_gtk_notebook_child_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * id, GValue * value)
+{
+ if (!strcmp (id, "position"))
+ return g_value_get_int (value) >= 0 &&
+ g_value_get_int (value) <
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK (container));
+ else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_verify_property)
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_verify_property (adaptor,
+ container, child,
+ id, value);
+
+ return TRUE;
+}
+
+void
+glade_gtk_notebook_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
+{
+ NotebookChildren *nchildren;
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ /* If we are setting this internally, avoid feedback. */
+ if (glade_gtk_notebook_setting_position || glade_widget_superuser ())
+ return;
+
+ /* Just rebuild the notebook, property values are already set at this point */
+ nchildren = glade_gtk_notebook_extract_children (GTK_WIDGET (container));
+ glade_gtk_notebook_insert_children (GTK_WIDGET (container), nchildren);
+ }
+ /* packing properties are unsupported on tabs ... except "position" */
+ else if (g_object_get_data (child, "special-child-type") == NULL)
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
+}
+
+void
+glade_gtk_notebook_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ gint position;
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ if (g_object_get_data (child, "special-child-type") != NULL)
+ {
+ if ((position = notebook_search_tab (GTK_NOTEBOOK (container),
+ GTK_WIDGET (child))) >= 0)
+ g_value_set_int (value, position);
+ else
+ g_value_set_int (value, 0);
+ }
+ else
+ gtk_container_child_get_property (GTK_CONTAINER (container),
+ GTK_WIDGET (child),
+ property_name, value);
+ }
+ /* packing properties are unsupported on tabs ... except "position" */
+ else if (g_object_get_data (child, "special-child-type") == NULL)
+ gtk_container_child_get_property (GTK_CONTAINER (container),
+ GTK_WIDGET (child), property_name, value);
}
static void
-glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *size_prop,
- const gchar *group_format,
- gboolean remove,
- gboolean after)
-{
- GladeWidget *parent;
- GList *children, *l;
- gint child_pos, size, offset;
-
- if (GTK_IS_NOTEBOOK (container) &&
- g_object_get_data (object, "special-child-type"))
- /* Its a Tab! */
- child_pos = notebook_search_tab (GTK_NOTEBOOK (container),
- GTK_WIDGET (object));
- else
- gtk_container_child_get (GTK_CONTAINER (container),
- GTK_WIDGET (object),
- "position", &child_pos, NULL);
-
- parent = glade_widget_get_from_gobject (container);
- glade_command_push_group (group_format, glade_widget_get_name (parent));
-
- /* Make sure widgets does not get destroyed */
- children = glade_widget_adaptor_get_children (adaptor, container);
- g_list_foreach (children, (GFunc) g_object_ref, NULL);
-
- glade_widget_property_get (parent, size_prop, &size);
-
- if (remove)
- {
- GList *del = NULL;
- offset = -1;
- /* Remove children first */
- for (l = children; l; l = g_list_next (l))
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
- gint pos;
-
- /* Skip placeholders */
- if (gchild == NULL) continue;
-
- glade_widget_pack_property_get (gchild, "position", &pos);
- if (pos == child_pos) del = g_list_prepend (del, gchild);
- }
- if (del)
- {
- glade_command_delete (del);
- g_list_free (del);
- }
- }
- else
- {
- /* Expand container */
- glade_command_set_property (glade_widget_get_property (parent, size_prop),
- size + 1);
- offset = 1;
- }
-
- /* Reoder children (fix the position property tracking widget positions) */
- for (l = g_list_last (children); l; l = g_list_previous (l))
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
- gint pos;
-
- /* Skip placeholders */
- if (gchild == NULL) continue;
-
- glade_widget_pack_property_get (gchild, "position", &pos);
- if ((after) ? pos > child_pos : pos >= child_pos)
- glade_command_set_property (glade_widget_get_pack_property (gchild, "position"),
- pos + offset);
- }
-
- if (remove)
- {
- /* Shrink container */
- glade_command_set_property (glade_widget_get_property (parent, size_prop),
- size - 1);
- }
- /* If it's a notebook we need to create an undoable tab now */
- else if (GTK_IS_NOTEBOOK (container))
- {
- gint new_pos = after ? child_pos + 1 : child_pos;
- GtkWidget *new_page;
- GtkWidget *tab_placeholder;
- GladeWidget *gtab;
- GList list = { 0, };
-
- new_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (container), new_pos);
-
- /* Deleting the project widget gives us a real placeholder now */
- new_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (container), new_pos);
- tab_placeholder = gtk_notebook_get_tab_label (GTK_NOTEBOOK (container), new_page);
- gtab = glade_gtk_notebook_generate_tab (parent, new_pos + 1);
- list.data = gtab;
-
- glade_command_paste (&list, parent, GLADE_PLACEHOLDER (tab_placeholder));
- }
-
- g_list_foreach (children, (GFunc) g_object_unref, NULL);
- g_list_free (children);
- glade_command_pop_group ();
-}
-
-void
-glade_gtk_notebook_child_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *object,
- const gchar *action_path)
-{
- if (strcmp (action_path, "insert_page_after") == 0)
- {
- glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
- object, "pages",
- _("Insert page on %s"),
- FALSE, TRUE);
- }
- else if (strcmp (action_path, "insert_page_before") == 0)
- {
- glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
- object, "pages",
- _("Insert page on %s"),
- FALSE, FALSE);
- }
- else if (strcmp (action_path, "remove_page") == 0)
- {
- glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
- object, "pages",
- _("Remove page from %s"),
- TRUE, TRUE);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
- container,
- object,
- action_path);
+glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * size_prop,
+ const gchar * group_format,
+ gboolean remove,
+ gboolean after)
+{
+ GladeWidget *parent;
+ GList *children, *l;
+ gint child_pos, size, offset;
+
+ if (GTK_IS_NOTEBOOK (container) &&
+ g_object_get_data (object, "special-child-type"))
+ /* Its a Tab! */
+ child_pos = notebook_search_tab (GTK_NOTEBOOK (container),
+ GTK_WIDGET (object));
+ else
+ gtk_container_child_get (GTK_CONTAINER (container),
+ GTK_WIDGET (object), "position", &child_pos, NULL);
+
+ parent = glade_widget_get_from_gobject (container);
+ glade_command_push_group (group_format, glade_widget_get_name (parent));
+
+ /* Make sure widgets does not get destroyed */
+ children = glade_widget_adaptor_get_children (adaptor, container);
+ g_list_foreach (children, (GFunc) g_object_ref, NULL);
+
+ glade_widget_property_get (parent, size_prop, &size);
+
+ if (remove)
+ {
+ GList *del = NULL;
+ offset = -1;
+ /* Remove children first */
+ for (l = children; l; l = g_list_next (l))
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
+ gint pos;
+
+ /* Skip placeholders */
+ if (gchild == NULL)
+ continue;
+
+ glade_widget_pack_property_get (gchild, "position", &pos);
+ if (pos == child_pos)
+ del = g_list_prepend (del, gchild);
+ }
+ if (del)
+ {
+ glade_command_delete (del);
+ g_list_free (del);
+ }
+ }
+ else
+ {
+ /* Expand container */
+ glade_command_set_property (glade_widget_get_property (parent, size_prop),
+ size + 1);
+ offset = 1;
+ }
+
+ /* Reoder children (fix the position property tracking widget positions) */
+ for (l = g_list_last (children); l; l = g_list_previous (l))
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (l->data);
+ gint pos;
+
+ /* Skip placeholders */
+ if (gchild == NULL)
+ continue;
+
+ glade_widget_pack_property_get (gchild, "position", &pos);
+ if ((after) ? pos > child_pos : pos >= child_pos)
+ glade_command_set_property (glade_widget_get_pack_property
+ (gchild, "position"), pos + offset);
+ }
+
+ if (remove)
+ {
+ /* Shrink container */
+ glade_command_set_property (glade_widget_get_property (parent, size_prop),
+ size - 1);
+ }
+ /* If it's a notebook we need to create an undoable tab now */
+ else if (GTK_IS_NOTEBOOK (container))
+ {
+ gint new_pos = after ? child_pos + 1 : child_pos;
+ GtkWidget *new_page;
+ GtkWidget *tab_placeholder;
+ GladeWidget *gtab;
+ GList list = { 0, };
+
+ new_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (container), new_pos);
+
+ /* Deleting the project widget gives us a real placeholder now */
+ new_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (container), new_pos);
+ tab_placeholder =
+ gtk_notebook_get_tab_label (GTK_NOTEBOOK (container), new_page);
+ gtab = glade_gtk_notebook_generate_tab (parent, new_pos + 1);
+ list.data = gtab;
+
+ glade_command_paste (&list, parent, GLADE_PLACEHOLDER (tab_placeholder));
+ }
+
+ g_list_foreach (children, (GFunc) g_object_unref, NULL);
+ g_list_free (children);
+ glade_command_pop_group ();
+}
+
+void
+glade_gtk_notebook_child_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * object,
+ const gchar * action_path)
+{
+ if (strcmp (action_path, "insert_page_after") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "pages",
+ _("Insert page on %s"),
+ FALSE, TRUE);
+ }
+ else if (strcmp (action_path, "insert_page_before") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "pages",
+ _("Insert page on %s"),
+ FALSE, FALSE);
+ }
+ else if (strcmp (action_path, "remove_page") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "pages",
+ _
+ ("Remove page from %s"),
+ TRUE, TRUE);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
+ container,
+ object,
+ action_path);
}
/* ----------------------------- GtkPaned ------------------------------ */
void
-glade_gtk_paned_post_create (GladeWidgetAdaptor *adaptor,
- GObject *paned,
- GladeCreateReason reason)
-{
- g_return_if_fail (GTK_IS_PANED (paned));
-
- if (reason == GLADE_CREATE_USER && gtk_paned_get_child1 (GTK_PANED (paned)) == NULL)
- gtk_paned_add1 (GTK_PANED (paned), glade_placeholder_new ());
-
- if (reason == GLADE_CREATE_USER && gtk_paned_get_child2 (GTK_PANED (paned)) == NULL)
- gtk_paned_add2 (GTK_PANED (paned), glade_placeholder_new ());
-}
-
-void
-glade_gtk_paned_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- GtkPaned *paned;
- GtkWidget *child1, *child2;
- gboolean loading;
-
- g_return_if_fail (GTK_IS_PANED (object));
-
- paned = GTK_PANED (object);
- loading = glade_util_object_is_loading (object);
-
- child1 = gtk_paned_get_child1 (paned);
- child2 = gtk_paned_get_child2 (paned);
-
- if (loading == FALSE)
- {
- /* Remove a placeholder */
- if (child1 && GLADE_IS_PLACEHOLDER (child1))
- {
- gtk_container_remove (GTK_CONTAINER (object), child1);
- child1 = NULL;
- }
- else if (child2 && GLADE_IS_PLACEHOLDER (child2))
- {
- gtk_container_remove (GTK_CONTAINER (object), child2);
- child2 = NULL;
- }
- }
-
- /* Add the child */
- if (child1 == NULL)
- gtk_paned_add1 (paned, GTK_WIDGET (child));
- else if (child2 == NULL)
- gtk_paned_add2 (paned, GTK_WIDGET (child));
-
- if (GLADE_IS_PLACEHOLDER (child) == FALSE && loading)
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
-
- if (gchild && gchild->packing_properties)
- {
- if (child1 == NULL)
- glade_widget_pack_property_set (gchild, "first", TRUE);
- else if (child2 == NULL)
- glade_widget_pack_property_set (gchild, "first", FALSE);
- }
- }
-}
-
-void
-glade_gtk_paned_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
-
- glade_gtk_paned_post_create (adaptor, object, GLADE_CREATE_USER);
-}
-
-void
-glade_gtk_paned_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "first") == 0)
- {
- GtkPaned *paned = GTK_PANED (container);
- gboolean first = g_value_get_boolean (value);
- GtkWidget *place, *wchild = GTK_WIDGET (child);
-
- place = (first) ? gtk_paned_get_child1 (paned) :
- gtk_paned_get_child2 (paned);
-
- if (place && GLADE_IS_PLACEHOLDER (place))
- gtk_container_remove (GTK_CONTAINER (container), place);
-
- g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (container), wchild);
- if (first)
- gtk_paned_add1 (paned, wchild);
- else
- gtk_paned_add2 (paned, wchild);
- g_object_unref (child);
-
- /* Ensure placeholders */
- if (glade_util_object_is_loading (child) == FALSE)
- {
- if ((place = gtk_paned_get_child1 (paned)) == NULL)
- gtk_paned_add1 (paned, glade_placeholder_new ());
-
- if ((place = gtk_paned_get_child2 (paned)) == NULL)
- gtk_paned_add2 (paned, glade_placeholder_new ());
- }
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
-}
-
-void
-glade_gtk_paned_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- if (strcmp (property_name, "first") == 0)
- g_value_set_boolean (value, GTK_WIDGET (child) ==
- gtk_paned_get_child1 (GTK_PANED (container)));
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container, child,
- property_name, value);
+glade_gtk_paned_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * paned, GladeCreateReason reason)
+{
+ g_return_if_fail (GTK_IS_PANED (paned));
+
+ if (reason == GLADE_CREATE_USER &&
+ gtk_paned_get_child1 (GTK_PANED (paned)) == NULL)
+ gtk_paned_add1 (GTK_PANED (paned), glade_placeholder_new ());
+
+ if (reason == GLADE_CREATE_USER &&
+ gtk_paned_get_child2 (GTK_PANED (paned)) == NULL)
+ gtk_paned_add2 (GTK_PANED (paned), glade_placeholder_new ());
+}
+
+void
+glade_gtk_paned_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GtkPaned *paned;
+ GtkWidget *child1, *child2;
+ gboolean loading;
+
+ g_return_if_fail (GTK_IS_PANED (object));
+
+ paned = GTK_PANED (object);
+ loading = glade_util_object_is_loading (object);
+
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+
+ if (loading == FALSE)
+ {
+ /* Remove a placeholder */
+ if (child1 && GLADE_IS_PLACEHOLDER (child1))
+ {
+ gtk_container_remove (GTK_CONTAINER (object), child1);
+ child1 = NULL;
+ }
+ else if (child2 && GLADE_IS_PLACEHOLDER (child2))
+ {
+ gtk_container_remove (GTK_CONTAINER (object), child2);
+ child2 = NULL;
+ }
+ }
+
+ /* Add the child */
+ if (child1 == NULL)
+ gtk_paned_add1 (paned, GTK_WIDGET (child));
+ else if (child2 == NULL)
+ gtk_paned_add2 (paned, GTK_WIDGET (child));
+
+ if (GLADE_IS_PLACEHOLDER (child) == FALSE && loading)
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
+
+ if (gchild && gchild->packing_properties)
+ {
+ if (child1 == NULL)
+ glade_widget_pack_property_set (gchild, "first", TRUE);
+ else if (child2 == NULL)
+ glade_widget_pack_property_set (gchild, "first", FALSE);
+ }
+ }
+}
+
+void
+glade_gtk_paned_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+
+ glade_gtk_paned_post_create (adaptor, object, GLADE_CREATE_USER);
+}
+
+void
+glade_gtk_paned_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
+{
+ if (strcmp (property_name, "first") == 0)
+ {
+ GtkPaned *paned = GTK_PANED (container);
+ gboolean first = g_value_get_boolean (value);
+ GtkWidget *place, *wchild = GTK_WIDGET (child);
+
+ place = (first) ? gtk_paned_get_child1 (paned) :
+ gtk_paned_get_child2 (paned);
+
+ if (place && GLADE_IS_PLACEHOLDER (place))
+ gtk_container_remove (GTK_CONTAINER (container), place);
+
+ g_object_ref (child);
+ gtk_container_remove (GTK_CONTAINER (container), wchild);
+ if (first)
+ gtk_paned_add1 (paned, wchild);
+ else
+ gtk_paned_add2 (paned, wchild);
+ g_object_unref (child);
+
+ /* Ensure placeholders */
+ if (glade_util_object_is_loading (child) == FALSE)
+ {
+ if ((place = gtk_paned_get_child1 (paned)) == NULL)
+ gtk_paned_add1 (paned, glade_placeholder_new ());
+
+ if ((place = gtk_paned_get_child2 (paned)) == NULL)
+ gtk_paned_add2 (paned, glade_placeholder_new ());
+ }
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
+}
+
+void
+glade_gtk_paned_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name, GValue * value)
+{
+ if (strcmp (property_name, "first") == 0)
+ g_value_set_boolean (value, GTK_WIDGET (child) ==
+ gtk_paned_get_child1 (GTK_PANED (container)));
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container, child,
+ property_name, value);
}
/* ----------------------------- GtkExpander ------------------------------ */
void
-glade_gtk_expander_post_create (GladeWidgetAdaptor *adaptor,
- GObject *expander,
- GladeCreateReason reason)
-{
- static GladeWidgetAdaptor *wadaptor = NULL;
- GladeWidget *gexpander, *glabel;
- GtkWidget *label;
-
- if (wadaptor == NULL)
- wadaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
-
- if (reason != GLADE_CREATE_USER) return;
-
- g_return_if_fail (GTK_IS_EXPANDER (expander));
- gexpander = glade_widget_get_from_gobject (expander);
- g_return_if_fail (GLADE_IS_WIDGET (gexpander));
-
- /* If we didnt put this object here... */
- if ((label = gtk_expander_get_label_widget (GTK_EXPANDER (expander))) == NULL ||
- (glade_widget_get_from_gobject (label) == NULL))
- {
- glabel = glade_widget_adaptor_create_widget (wadaptor, FALSE,
- "parent", gexpander,
- "project", glade_widget_get_project (gexpander),
- NULL);
-
- glade_widget_property_set (glabel, "label", "expander");
-
- g_object_set_data (glabel->object, "special-child-type", "label_item");
- glade_widget_add_child (gexpander, glabel, FALSE);
- }
-
- gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
-
- gtk_container_add (GTK_CONTAINER (expander), glade_placeholder_new ());
-
-}
-
-void
-glade_gtk_expander_replace_child (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *current,
- GtkWidget *new_widget)
-{
- gchar *special_child_type;
-
- special_child_type =
- g_object_get_data (G_OBJECT (current), "special-child-type");
-
- if (special_child_type && !strcmp (special_child_type, "label_item"))
- {
- g_object_set_data (G_OBJECT (new_widget), "special-child-type", "label_item");
- gtk_expander_set_label_widget (GTK_EXPANDER (container), new_widget);
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->replace_child (adaptor,
- G_OBJECT (container),
- G_OBJECT (current),
- G_OBJECT (new_widget));
-}
-
-
-void
-glade_gtk_expander_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- gchar *special_child_type;
-
- special_child_type = g_object_get_data (child, "special-child-type");
-
- if (special_child_type &&
- !strcmp (special_child_type, "label"))
- {
- g_object_set_data (child,
- "special-child-type",
- "label_item");
- gtk_expander_set_label_widget (GTK_EXPANDER (object),
- GTK_WIDGET (child));
- }
- else if (special_child_type &&
- !strcmp (special_child_type, "label_item"))
- {
- gtk_expander_set_label_widget (GTK_EXPANDER (object),
- GTK_WIDGET (child));
- }
- else
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, object, child);
-}
-
-void
-glade_gtk_expander_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
-{
- gchar *special_child_type;
-
- special_child_type = g_object_get_data (child, "special-child-type");
- if (special_child_type &&
- !strcmp (special_child_type, "label_item"))
- {
- gtk_expander_set_label_widget (GTK_EXPANDER (object),
- glade_placeholder_new ());
- }
- else
- {
- gtk_container_remove (GTK_CONTAINER (object),
- GTK_WIDGET (child));
- gtk_container_add (GTK_CONTAINER (object),
- glade_placeholder_new ());
- }
-}
+glade_gtk_expander_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * expander, GladeCreateReason reason)
+{
+ static GladeWidgetAdaptor *wadaptor = NULL;
+ GladeWidget *gexpander, *glabel;
+ GtkWidget *label;
+
+ if (wadaptor == NULL)
+ wadaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
+
+ if (reason != GLADE_CREATE_USER)
+ return;
+
+ g_return_if_fail (GTK_IS_EXPANDER (expander));
+ gexpander = glade_widget_get_from_gobject (expander);
+ g_return_if_fail (GLADE_IS_WIDGET (gexpander));
+
+ /* If we didnt put this object here... */
+ if ((label = gtk_expander_get_label_widget (GTK_EXPANDER (expander))) == NULL
+ || (glade_widget_get_from_gobject (label) == NULL))
+ {
+ glabel = glade_widget_adaptor_create_widget (wadaptor, FALSE,
+ "parent", gexpander,
+ "project",
+ glade_widget_get_project
+ (gexpander), NULL);
+
+ glade_widget_property_set (glabel, "label", "expander");
+
+ g_object_set_data (glabel->object, "special-child-type", "label_item");
+ glade_widget_add_child (gexpander, glabel, FALSE);
+ }
+
+ gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
+
+ gtk_container_add (GTK_CONTAINER (expander), glade_placeholder_new ());
+
+}
void
-glade_gtk_expander_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_expander_replace_child (GladeWidgetAdaptor * adaptor,
+ GtkWidget * container,
+ GtkWidget * current, GtkWidget * new_widget)
{
+ gchar *special_child_type;
+
+ special_child_type =
+ g_object_get_data (G_OBJECT (current), "special-child-type");
+
+ if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ g_object_set_data (G_OBJECT (new_widget), "special-child-type",
+ "label_item");
+ gtk_expander_set_label_widget (GTK_EXPANDER (container), new_widget);
+ return;
+ }
- if (!write_special_child_label_item (adaptor, widget, context, node,
- GWA_GET_CLASS(GTK_TYPE_CONTAINER)->write_child))
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->write_child (adaptor,
- widget,
- context,
- node);
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->replace_child (adaptor,
+ G_OBJECT (container),
+ G_OBJECT (current),
+ G_OBJECT (new_widget));
+}
+
+
+void
+glade_gtk_expander_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gchar *special_child_type;
+
+ special_child_type = g_object_get_data (child, "special-child-type");
+
+ if (special_child_type && !strcmp (special_child_type, "label"))
+ {
+ g_object_set_data (child, "special-child-type", "label_item");
+ gtk_expander_set_label_widget (GTK_EXPANDER (object), GTK_WIDGET (child));
+ }
+ else if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ gtk_expander_set_label_widget (GTK_EXPANDER (object), GTK_WIDGET (child));
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, object, child);
+}
+
+void
+glade_gtk_expander_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gchar *special_child_type;
+
+ special_child_type = g_object_get_data (child, "special-child-type");
+ if (special_child_type && !strcmp (special_child_type, "label_item"))
+ {
+ gtk_expander_set_label_widget (GTK_EXPANDER (object),
+ glade_placeholder_new ());
+ }
+ else
+ {
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+ gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
+ }
+}
+
+void
+glade_gtk_expander_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+
+ if (!write_special_child_label_item (adaptor, widget, context, node,
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->
+ write_child))
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->write_child (adaptor, widget, context, node);
}
/* -------------------------------- GtkEntry -------------------------------- */
gboolean
-glade_gtk_entry_depends (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeWidget *another)
+glade_gtk_entry_depends (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeWidget * another)
{
- if (GTK_IS_ENTRY_BUFFER (another->object))
- return TRUE;
+ if (GTK_IS_ENTRY_BUFFER (another->object))
+ return TRUE;
- return GWA_GET_CLASS (GTK_TYPE_WIDGET)->depends (adaptor, widget, another);
+ return GWA_GET_CLASS (GTK_TYPE_WIDGET)->depends (adaptor, widget, another);
}
static void
-glade_gtk_entry_changed (GtkEditable *editable, GladeWidget *gentry)
+glade_gtk_entry_changed (GtkEditable * editable, GladeWidget * gentry)
{
- const gchar *text, *text_prop;
- GladeProperty *prop;
- gboolean use_buffer;
+ const gchar *text, *text_prop;
+ GladeProperty *prop;
+ gboolean use_buffer;
+
+ if (glade_widget_superuser ())
+ return;
- if (glade_widget_superuser ())
- return;
+ text = gtk_entry_get_text (GTK_ENTRY (editable));
- text = gtk_entry_get_text (GTK_ENTRY (editable));
-
- glade_widget_property_get (gentry, "text", &text_prop);
- glade_widget_property_get (gentry, "use-entry-buffer", &use_buffer);
-
- if (use_buffer == FALSE && g_strcmp0 (text, text_prop))
- {
- if ((prop = glade_widget_get_property (gentry, "text")))
- glade_command_set_property (prop, text);
- }
+ glade_widget_property_get (gentry, "text", &text_prop);
+ glade_widget_property_get (gentry, "use-entry-buffer", &use_buffer);
+
+ if (use_buffer == FALSE && g_strcmp0 (text, text_prop))
+ {
+ if ((prop = glade_widget_get_property (gentry, "text")))
+ glade_command_set_property (prop, text);
+ }
}
void
-glade_gtk_entry_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_entry_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *gentry;
-
- g_return_if_fail (GTK_IS_ENTRY (object));
- gentry = glade_widget_get_from_gobject (object);
- g_return_if_fail (GLADE_IS_WIDGET (gentry));
-
- g_signal_connect (object, "changed",
- G_CALLBACK (glade_gtk_entry_changed), gentry);
+ GladeWidget *gentry;
+
+ g_return_if_fail (GTK_IS_ENTRY (object));
+ gentry = glade_widget_get_from_gobject (object);
+ g_return_if_fail (GLADE_IS_WIDGET (gentry));
+
+ g_signal_connect (object, "changed",
+ G_CALLBACK (glade_gtk_entry_changed), gentry);
}
GladeEditable *
-glade_gtk_entry_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
-{
- GladeEditable *editable;
-
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type);
-
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_entry_editor_new (adaptor, editable);
-
- return editable;
-}
-
-
-void
-glade_gtk_entry_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- GladeImageEditMode mode;
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GladeProperty *property = glade_widget_get_property (gwidget, id);
-
- if (!strcmp (id, "use-entry-buffer"))
- {
- glade_widget_property_set_sensitive (gwidget, "text", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "buffer", FALSE, NOT_SELECTED_MSG);
-
- if (g_value_get_boolean (value))
- glade_widget_property_set_sensitive (gwidget, "buffer", TRUE, NULL);
- else
- glade_widget_property_set_sensitive (gwidget, "text", TRUE, NULL);
- }
- else if (!strcmp (id, "primary-icon-mode"))
- {
- mode = g_value_get_int (value);
-
- glade_widget_property_set_sensitive (gwidget, "primary-icon-stock", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "primary-icon-name", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "primary-icon-pixbuf", FALSE, NOT_SELECTED_MSG);
-
- switch (mode) {
- case GLADE_IMAGE_MODE_STOCK:
- glade_widget_property_set_sensitive (gwidget, "primary-icon-stock", TRUE, NULL);
- break;
- case GLADE_IMAGE_MODE_ICON:
- glade_widget_property_set_sensitive (gwidget, "primary-icon-name", TRUE, NULL);
- break;
- case GLADE_IMAGE_MODE_FILENAME:
- glade_widget_property_set_sensitive (gwidget, "primary-icon-pixbuf", TRUE, NULL);
- break;
- }
- }
- else if (!strcmp (id, "secondary-icon-mode"))
- {
- mode = g_value_get_int (value);
-
- glade_widget_property_set_sensitive (gwidget, "secondary-icon-stock", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "secondary-icon-name", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "secondary-icon-pixbuf", FALSE, NOT_SELECTED_MSG);
-
- switch (mode) {
- case GLADE_IMAGE_MODE_STOCK:
- glade_widget_property_set_sensitive (gwidget, "secondary-icon-stock", TRUE, NULL);
- break;
- case GLADE_IMAGE_MODE_ICON:
- glade_widget_property_set_sensitive (gwidget, "secondary-icon-name", TRUE, NULL);
- break;
- case GLADE_IMAGE_MODE_FILENAME:
- glade_widget_property_set_sensitive (gwidget, "secondary-icon-pixbuf", TRUE, NULL);
- break;
- }
- }
- else if (!strcmp (id, "primary-icon-tooltip-text") ||
- !strcmp (id, "primary-icon-tooltip-markup"))
- {
- /* Avoid a silly crash in GTK+ */
- if (gtk_entry_get_icon_storage_type (GTK_ENTRY (object),
- GTK_ENTRY_ICON_PRIMARY) != GTK_IMAGE_EMPTY)
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
- }
- else if (!strcmp (id, "secondary-icon-tooltip-text") ||
- !strcmp (id, "secondary-icon-tooltip-markup"))
- {
- /* Avoid a silly crash in GTK+ */
- if (gtk_entry_get_icon_storage_type (GTK_ENTRY (object),
- GTK_ENTRY_ICON_SECONDARY) != GTK_IMAGE_EMPTY)
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
- }
- else if (!strcmp (id, "text"))
- {
- g_signal_handlers_block_by_func (object, glade_gtk_entry_changed, gwidget);
-
- if (g_value_get_string (value))
- gtk_entry_set_text (GTK_ENTRY (object), g_value_get_string (value));
- else
- gtk_entry_set_text (GTK_ENTRY (object), "");
-
- g_signal_handlers_unblock_by_func (object, glade_gtk_entry_changed, gwidget);
-
- }
- else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
-}
-
-void
-glade_gtk_entry_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeProperty *property;
-
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
-
- if (glade_widget_property_original_default (widget, "text") == FALSE)
- {
- property = glade_widget_get_property (widget, "text");
- glade_widget_property_set (widget, "use-entry-buffer", FALSE);
-
- glade_property_sync (property);
- }
- else
- {
- gint target_minor, target_major;
-
- glade_project_get_target_version (widget->project, "gtk+", &target_major, &target_minor);
-
- property = glade_widget_get_property (widget, "buffer");
-
- /* Only default to the buffer setting if the project version supports it. */
- if (GPC_VERSION_CHECK (property->klass, target_major, target_minor))
- {
- glade_widget_property_set (widget, "use-entry-buffer", TRUE);
- glade_property_sync (property);
- }
- else
- glade_widget_property_set (widget, "use-entry-buffer", FALSE);
- }
-
- if (glade_widget_property_original_default (widget, "primary-icon-name") == FALSE)
- {
- property = glade_widget_get_property (widget, "primary-icon-name");
- glade_widget_property_set (widget, "primary-icon-mode", GLADE_IMAGE_MODE_ICON);
- }
- else if (glade_widget_property_original_default (widget, "primary-icon-pixbuf") == FALSE)
- {
- property = glade_widget_get_property (widget, "primary-icon-pixbuf");
- glade_widget_property_set (widget, "primary-icon-mode", GLADE_IMAGE_MODE_FILENAME);
- }
- else/* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
- {
- property = glade_widget_get_property (widget, "primary-icon-stock");
- glade_widget_property_set (widget, "primary-icon-mode", GLADE_IMAGE_MODE_STOCK);
- }
-
- glade_property_sync (property);
-
- if (glade_widget_property_original_default (widget, "secondary-icon-name") == FALSE)
- {
- property = glade_widget_get_property (widget, "secondary-icon-name");
- glade_widget_property_set (widget, "secondary-icon-mode", GLADE_IMAGE_MODE_ICON);
- }
- else if (glade_widget_property_original_default (widget, "secondary-icon-pixbuf") == FALSE)
- {
- property = glade_widget_get_property (widget, "secondary-icon-pixbuf");
- glade_widget_property_set (widget, "secondary-icon-mode", GLADE_IMAGE_MODE_FILENAME);
- }
- else/* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
- {
- property = glade_widget_get_property (widget, "secondary-icon-stock");
- glade_widget_property_set (widget, "secondary-icon-mode", GLADE_IMAGE_MODE_STOCK);
- }
-
- glade_property_sync (property);
+glade_gtk_entry_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
+{
+ GladeEditable *editable;
+
+ /* Get base editable */
+ editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type);
+
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_entry_editor_new (adaptor, editable);
+
+ return editable;
+}
+
+
+void
+glade_gtk_entry_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ GladeImageEditMode mode;
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GladeProperty *property = glade_widget_get_property (gwidget, id);
+
+ if (!strcmp (id, "use-entry-buffer"))
+ {
+ glade_widget_property_set_sensitive (gwidget, "text", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "buffer", FALSE,
+ NOT_SELECTED_MSG);
+
+ if (g_value_get_boolean (value))
+ glade_widget_property_set_sensitive (gwidget, "buffer", TRUE, NULL);
+ else
+ glade_widget_property_set_sensitive (gwidget, "text", TRUE, NULL);
+ }
+ else if (!strcmp (id, "primary-icon-mode"))
+ {
+ mode = g_value_get_int (value);
+
+ glade_widget_property_set_sensitive (gwidget, "primary-icon-stock", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "primary-icon-name", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "primary-icon-pixbuf",
+ FALSE, NOT_SELECTED_MSG);
+
+ switch (mode)
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ glade_widget_property_set_sensitive (gwidget, "primary-icon-stock",
+ TRUE, NULL);
+ break;
+ case GLADE_IMAGE_MODE_ICON:
+ glade_widget_property_set_sensitive (gwidget, "primary-icon-name",
+ TRUE, NULL);
+ break;
+ case GLADE_IMAGE_MODE_FILENAME:
+ glade_widget_property_set_sensitive (gwidget, "primary-icon-pixbuf",
+ TRUE, NULL);
+ break;
+ }
+ }
+ else if (!strcmp (id, "secondary-icon-mode"))
+ {
+ mode = g_value_get_int (value);
+
+ glade_widget_property_set_sensitive (gwidget, "secondary-icon-stock",
+ FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "secondary-icon-name",
+ FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "secondary-icon-pixbuf",
+ FALSE, NOT_SELECTED_MSG);
+
+ switch (mode)
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ glade_widget_property_set_sensitive (gwidget,
+ "secondary-icon-stock", TRUE,
+ NULL);
+ break;
+ case GLADE_IMAGE_MODE_ICON:
+ glade_widget_property_set_sensitive (gwidget, "secondary-icon-name",
+ TRUE, NULL);
+ break;
+ case GLADE_IMAGE_MODE_FILENAME:
+ glade_widget_property_set_sensitive (gwidget,
+ "secondary-icon-pixbuf", TRUE,
+ NULL);
+ break;
+ }
+ }
+ else if (!strcmp (id, "primary-icon-tooltip-text") ||
+ !strcmp (id, "primary-icon-tooltip-markup"))
+ {
+ /* Avoid a silly crash in GTK+ */
+ if (gtk_entry_get_icon_storage_type (GTK_ENTRY (object),
+ GTK_ENTRY_ICON_PRIMARY) !=
+ GTK_IMAGE_EMPTY)
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id,
+ value);
+ }
+ else if (!strcmp (id, "secondary-icon-tooltip-text") ||
+ !strcmp (id, "secondary-icon-tooltip-markup"))
+ {
+ /* Avoid a silly crash in GTK+ */
+ if (gtk_entry_get_icon_storage_type (GTK_ENTRY (object),
+ GTK_ENTRY_ICON_SECONDARY) !=
+ GTK_IMAGE_EMPTY)
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id,
+ value);
+ }
+ else if (!strcmp (id, "text"))
+ {
+ g_signal_handlers_block_by_func (object, glade_gtk_entry_changed,
+ gwidget);
+
+ if (g_value_get_string (value))
+ gtk_entry_set_text (GTK_ENTRY (object), g_value_get_string (value));
+ else
+ gtk_entry_set_text (GTK_ENTRY (object), "");
+
+ g_signal_handlers_unblock_by_func (object, glade_gtk_entry_changed,
+ gwidget);
+
+ }
+ else if (GPC_VERSION_CHECK
+ (property->klass, gtk_major_version, gtk_minor_version + 1))
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
+}
+
+void
+glade_gtk_entry_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeProperty *property;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
+
+ if (glade_widget_property_original_default (widget, "text") == FALSE)
+ {
+ property = glade_widget_get_property (widget, "text");
+ glade_widget_property_set (widget, "use-entry-buffer", FALSE);
+
+ glade_property_sync (property);
+ }
+ else
+ {
+ gint target_minor, target_major;
+
+ glade_project_get_target_version (widget->project, "gtk+", &target_major,
+ &target_minor);
+
+ property = glade_widget_get_property (widget, "buffer");
+
+ /* Only default to the buffer setting if the project version supports it. */
+ if (GPC_VERSION_CHECK (property->klass, target_major, target_minor))
+ {
+ glade_widget_property_set (widget, "use-entry-buffer", TRUE);
+ glade_property_sync (property);
+ }
+ else
+ glade_widget_property_set (widget, "use-entry-buffer", FALSE);
+ }
+
+ if (glade_widget_property_original_default (widget, "primary-icon-name") ==
+ FALSE)
+ {
+ property = glade_widget_get_property (widget, "primary-icon-name");
+ glade_widget_property_set (widget, "primary-icon-mode",
+ GLADE_IMAGE_MODE_ICON);
+ }
+ else if (glade_widget_property_original_default
+ (widget, "primary-icon-pixbuf") == FALSE)
+ {
+ property = glade_widget_get_property (widget, "primary-icon-pixbuf");
+ glade_widget_property_set (widget, "primary-icon-mode",
+ GLADE_IMAGE_MODE_FILENAME);
+ }
+ else /* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
+ {
+ property = glade_widget_get_property (widget, "primary-icon-stock");
+ glade_widget_property_set (widget, "primary-icon-mode",
+ GLADE_IMAGE_MODE_STOCK);
+ }
+
+ glade_property_sync (property);
+
+ if (glade_widget_property_original_default (widget, "secondary-icon-name") ==
+ FALSE)
+ {
+ property = glade_widget_get_property (widget, "secondary-icon-name");
+ glade_widget_property_set (widget, "secondary-icon-mode",
+ GLADE_IMAGE_MODE_ICON);
+ }
+ else if (glade_widget_property_original_default
+ (widget, "secondary-icon-pixbuf") == FALSE)
+ {
+ property = glade_widget_get_property (widget, "secondary-icon-pixbuf");
+ glade_widget_property_set (widget, "secondary-icon-mode",
+ GLADE_IMAGE_MODE_FILENAME);
+ }
+ else /* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
+ {
+ property = glade_widget_get_property (widget, "secondary-icon-stock");
+ glade_widget_property_set (widget, "secondary-icon-mode",
+ GLADE_IMAGE_MODE_STOCK);
+ }
+
+ glade_property_sync (property);
}
/* ----------------------------- GtkFixed/GtkLayout ------------------------------ */
#if 0
static void
-glade_gtk_fixed_layout_finalize(GdkPixmap *backing)
+glade_gtk_fixed_layout_finalize (GdkPixmap * backing)
{
- g_object_unref(backing);
+ g_object_unref (backing);
}
#endif
static void
-glade_gtk_fixed_layout_realize (GtkWidget *widget)
+glade_gtk_fixed_layout_realize (GtkWidget * widget)
{
#if _FIXME_FIXME_CAIRO_
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (fixed_bg_xpm);
- GdkPixmap *backing;
-
- gdk_pixbuf_render_pixmap_and_mask (pixbuf, &backing, NULL, 1);
-
- if (GTK_IS_LAYOUT (widget))
- gdk_window_set_back_pixmap (gtk_layout_get_bin_window (GTK_LAYOUT (widget)),
- backing, FALSE);
- else
- gdk_window_set_back_pixmap (gtk_widget_get_window (widget), backing, FALSE);
-
- /* For cleanup later
- */
- g_object_weak_ref(G_OBJECT(widget),
- (GWeakNotify)glade_gtk_fixed_layout_finalize, backing);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (fixed_bg_xpm);
+ GdkPixmap *backing;
+
+ gdk_pixbuf_render_pixmap_and_mask (pixbuf, &backing, NULL, 1);
+
+ if (GTK_IS_LAYOUT (widget))
+ gdk_window_set_back_pixmap (gtk_layout_get_bin_window (GTK_LAYOUT (widget)),
+ backing, FALSE);
+ else
+ gdk_window_set_back_pixmap (gtk_widget_get_window (widget), backing, FALSE);
+
+ /* For cleanup later
+ */
+ g_object_weak_ref (G_OBJECT (widget),
+ (GWeakNotify) glade_gtk_fixed_layout_finalize, backing);
#endif
}
static void
-glade_gtk_fixed_layout_sync_size_requests (GtkWidget *widget)
+glade_gtk_fixed_layout_sync_size_requests (GtkWidget * widget)
{
- GList *children, *l;
+ GList *children, *l;
+
+ if ((children = gtk_container_get_children (GTK_CONTAINER (widget))) != NULL)
+ {
+ for (l = children; l; l = l->next)
+ {
+ GtkWidget *child = l->data;
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
+ gint width = -1, height = -1;
- if ((children = gtk_container_get_children (GTK_CONTAINER (widget))) != NULL)
- {
- for (l = children; l; l = l->next)
- {
- GtkWidget *child = l->data;
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
- gint width = -1, height = -1;
+ if (!gchild)
+ continue;
- if (!gchild)
- continue;
+ glade_widget_property_get (gchild, "width-request", &width);
+ glade_widget_property_get (gchild, "height-request", &height);
- glade_widget_property_get (gchild, "width-request", &width);
- glade_widget_property_get (gchild, "height-request", &height);
-
- gtk_widget_set_size_request (child, width, height);
-
- }
- g_list_free (children);
- }
+ gtk_widget_set_size_request (child, width, height);
+
+ }
+ g_list_free (children);
+ }
}
void
-glade_gtk_fixed_layout_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_fixed_layout_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- /* This is needed at least to set a backing pixmap. */
- gtk_widget_set_has_window (GTK_WIDGET (object), FALSE);
+ /* This is needed at least to set a backing pixmap. */
+ gtk_widget_set_has_window (GTK_WIDGET (object), FALSE);
- /* For backing pixmap
- */
- g_signal_connect_after(object, "realize",
- G_CALLBACK(glade_gtk_fixed_layout_realize), NULL);
+ /* For backing pixmap
+ */
+ g_signal_connect_after (object, "realize",
+ G_CALLBACK (glade_gtk_fixed_layout_realize), NULL);
- /* Sync up size request at project load time */
- if (reason == GLADE_CREATE_LOAD)
- g_signal_connect_after(object, "realize",
- G_CALLBACK(glade_gtk_fixed_layout_sync_size_requests), NULL);
+ /* Sync up size request at project load time */
+ if (reason == GLADE_CREATE_LOAD)
+ g_signal_connect_after (object, "realize",
+ G_CALLBACK
+ (glade_gtk_fixed_layout_sync_size_requests), NULL);
}
void
-glade_gtk_fixed_layout_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_fixed_layout_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_CONTAINER (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (GTK_IS_CONTAINER (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
- gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+ gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
}
void
-glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_CONTAINER (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (GTK_IS_CONTAINER (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
}
/* ----------------------------- GtkWindow ------------------------------ */
static void
-glade_gtk_window_read_accel_groups (GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *groups_node;
- GladeProperty *property;
- gchar *string = NULL;
-
- if ((groups_node =
- glade_xml_search_child (node, GLADE_TAG_ACCEL_GROUPS)) != NULL)
- {
- GladeXmlNode *node;
-
- for (node = glade_xml_node_get_children (groups_node);
- node; node = glade_xml_node_next (node))
- {
- gchar *group_name, *tmp;
-
- if (!glade_xml_node_verify (node, GLADE_TAG_ACCEL_GROUP))
- continue;
-
- group_name = glade_xml_get_property_string_required
- (node, GLADE_TAG_NAME, NULL);
-
- if (string == NULL)
- string = group_name;
- else if (group_name != NULL)
- {
- tmp = g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER, group_name);
- string = (g_free (string), tmp);
- g_free (group_name);
- }
- }
- }
-
- if (string)
- {
- property = glade_widget_get_property (widget, "accel-groups");
- g_assert (property);
-
- /* we must synchronize this directly after loading this project
- * (i.e. lookup the actual objects after they've been parsed and
- * are present).
- */
- g_object_set_data_full (G_OBJECT (property),
- "glade-loaded-object",
- string, g_free);
- }
-}
-
-void
-glade_gtk_window_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
-
- glade_gtk_window_read_accel_groups (widget, node);
-}
+glade_gtk_window_read_accel_groups (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode *groups_node;
+ GladeProperty *property;
+ gchar *string = NULL;
+
+ if ((groups_node =
+ glade_xml_search_child (node, GLADE_TAG_ACCEL_GROUPS)) != NULL)
+ {
+ GladeXmlNode *node;
+
+ for (node = glade_xml_node_get_children (groups_node);
+ node; node = glade_xml_node_next (node))
+ {
+ gchar *group_name, *tmp;
+
+ if (!glade_xml_node_verify (node, GLADE_TAG_ACCEL_GROUP))
+ continue;
+
+ group_name = glade_xml_get_property_string_required
+ (node, GLADE_TAG_NAME, NULL);
+
+ if (string == NULL)
+ string = group_name;
+ else if (group_name != NULL)
+ {
+ tmp =
+ g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER,
+ group_name);
+ string = (g_free (string), tmp);
+ g_free (group_name);
+ }
+ }
+ }
+ if (string)
+ {
+ property = glade_widget_get_property (widget, "accel-groups");
+ g_assert (property);
-static void
-glade_gtk_window_write_accel_groups (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+ /* we must synchronize this directly after loading this project
+ * (i.e. lookup the actual objects after they've been parsed and
+ * are present).
+ */
+ g_object_set_data_full (G_OBJECT (property),
+ "glade-loaded-object", string, g_free);
+ }
+}
+
+void
+glade_gtk_window_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeXmlNode *groups_node, *group_node;
- GList *groups = NULL, *list;
- GladeWidget *agroup;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
+
+ glade_gtk_window_read_accel_groups (widget, node);
+}
- groups_node = glade_xml_node_new (context, GLADE_TAG_ACCEL_GROUPS);
- if (glade_widget_property_get (widget, "accel-groups", &groups))
- {
- for (list = groups; list; list = list->next)
- {
- agroup = glade_widget_get_from_gobject (list->data);
- group_node = glade_xml_node_new (context, GLADE_TAG_ACCEL_GROUP);
- glade_xml_node_append_child (groups_node, group_node);
- glade_xml_node_set_property_string (group_node, GLADE_TAG_NAME, agroup->name);
- }
- }
+static void
+glade_gtk_window_write_accel_groups (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *groups_node, *group_node;
+ GList *groups = NULL, *list;
+ GladeWidget *agroup;
+
+ groups_node = glade_xml_node_new (context, GLADE_TAG_ACCEL_GROUPS);
+
+ if (glade_widget_property_get (widget, "accel-groups", &groups))
+ {
+ for (list = groups; list; list = list->next)
+ {
+ agroup = glade_widget_get_from_gobject (list->data);
+ group_node = glade_xml_node_new (context, GLADE_TAG_ACCEL_GROUP);
+ glade_xml_node_append_child (groups_node, group_node);
+ glade_xml_node_set_property_string (group_node, GLADE_TAG_NAME,
+ agroup->name);
+ }
+ }
+
+ if (!glade_xml_node_get_children (groups_node))
+ glade_xml_node_delete (groups_node);
+ else
+ glade_xml_node_append_child (node, groups_node);
- if (!glade_xml_node_get_children (groups_node))
- glade_xml_node_delete (groups_node);
- else
- glade_xml_node_append_child (node, groups_node);
-
}
void
-glade_gtk_window_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_window_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context,
+ node);
- glade_gtk_window_write_accel_groups (widget, context, node);
+ glade_gtk_window_write_accel_groups (widget, context, node);
}
/* ----------------------------- GtkDialog(s) ------------------------------ */
static void
-glade_gtk_dialog_stop_offending_signals (GtkWidget *widget)
-{
- static gpointer hierarchy = NULL, screen;
-
- if (hierarchy == NULL)
- {
- hierarchy = GUINT_TO_POINTER (g_signal_lookup ("hierarchy-changed",
- GTK_TYPE_WIDGET));
- screen = GUINT_TO_POINTER (g_signal_lookup ("screen-changed",
- GTK_TYPE_WIDGET));
- }
-
- g_signal_connect (widget, "hierarchy-changed",
- G_CALLBACK (glade_gtk_stop_emission_POINTER),
- hierarchy);
- g_signal_connect (widget, "screen-changed",
- G_CALLBACK (glade_gtk_stop_emission_POINTER),
- screen);
+glade_gtk_dialog_stop_offending_signals (GtkWidget * widget)
+{
+ static gpointer hierarchy = NULL, screen;
+
+ if (hierarchy == NULL)
+ {
+ hierarchy = GUINT_TO_POINTER (g_signal_lookup ("hierarchy-changed",
+ GTK_TYPE_WIDGET));
+ screen = GUINT_TO_POINTER (g_signal_lookup ("screen-changed",
+ GTK_TYPE_WIDGET));
+ }
+
+ g_signal_connect (widget, "hierarchy-changed",
+ G_CALLBACK (glade_gtk_stop_emission_POINTER), hierarchy);
+ g_signal_connect (widget, "screen-changed",
+ G_CALLBACK (glade_gtk_stop_emission_POINTER), screen);
}
static void
-glade_gtk_file_chooser_default_forall (GtkWidget *widget, gpointer data)
-{
- /* Since GtkFileChooserDefault is not exposed we check if its a
- * GtkFileChooser
- */
- if (GTK_IS_FILE_CHOOSER (widget))
- {
-
- /* Finally we can connect to the signals we want to stop its
- * default handler. Since both signals has the same signature
- * we use one callback for both :)
- */
- glade_gtk_dialog_stop_offending_signals (widget);
- }
+glade_gtk_file_chooser_default_forall (GtkWidget * widget, gpointer data)
+{
+ /* Since GtkFileChooserDefault is not exposed we check if its a
+ * GtkFileChooser
+ */
+ if (GTK_IS_FILE_CHOOSER (widget))
+ {
+
+ /* Finally we can connect to the signals we want to stop its
+ * default handler. Since both signals has the same signature
+ * we use one callback for both :)
+ */
+ glade_gtk_dialog_stop_offending_signals (widget);
+ }
}
static void
-glade_gtk_file_chooser_forall (GtkWidget *widget, gpointer data)
-{
- /* GtkFileChooserWidget packs a GtkFileChooserDefault */
- if (GTK_IS_FILE_CHOOSER_WIDGET (widget))
- gtk_container_forall (GTK_CONTAINER (widget),
- glade_gtk_file_chooser_default_forall,
- NULL);
-}
-
-void
-glade_gtk_dialog_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GtkDialog *dialog = GTK_DIALOG (object);
- GladeWidget *widget;
- GladeWidget *vbox_widget, *actionarea_widget, *colorsel, *fontsel;
- GladeWidget *ok_button = NULL, *cancel_button = NULL,
- *help_button = NULL, *apply_button = NULL;
-
- g_return_if_fail (GTK_IS_DIALOG (dialog));
-
- widget = glade_widget_get_from_gobject (GTK_WIDGET (dialog));
- if (!widget)
- return;
-
- if (reason == GLADE_CREATE_USER)
- {
- /* HIG complient border-width defaults on dialogs */
- glade_widget_property_set (widget, "border-width", 5);
- }
-
- if (GTK_IS_COLOR_SELECTION_DIALOG (object))
- {
- GtkWidget *child;
-
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_OK);
- ok_button = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "ok_button", "colorsel", FALSE, reason);
-
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_CANCEL);
- cancel_button = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "cancel_button", "colorsel", FALSE, reason);
-
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_HELP);
- help_button = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "help_button", "colorsel", FALSE, reason);
-
- child = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog));
- colorsel = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "color_selection", "colorsel", FALSE, reason);
-
- /* Set this to 1 at load time, if there are any children then
- * size will adjust appropriately (otherwise the default "3" gets
- * set and we end up with extra placeholders).
- */
- if (reason == GLADE_CREATE_LOAD)
- glade_widget_property_set (colorsel, "size", 1);
-
- }
- else if (GTK_IS_FONT_SELECTION_DIALOG (object))
- {
- GtkWidget *child;
-
- child = gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG (dialog));
- ok_button = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "ok_button", "fontsel", FALSE, reason);
-
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_APPLY);
- apply_button = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "apply_button", "fontsel", FALSE, reason);
-
- child = gtk_font_selection_dialog_get_cancel_button (GTK_FONT_SELECTION_DIALOG (dialog));
- cancel_button = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "cancel_button", "fontsel", FALSE, reason);
+glade_gtk_file_chooser_forall (GtkWidget * widget, gpointer data)
+{
+ /* GtkFileChooserWidget packs a GtkFileChooserDefault */
+ if (GTK_IS_FILE_CHOOSER_WIDGET (widget))
+ gtk_container_forall (GTK_CONTAINER (widget),
+ glade_gtk_file_chooser_default_forall, NULL);
+}
+
+void
+glade_gtk_dialog_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
+{
+ GtkDialog *dialog = GTK_DIALOG (object);
+ GladeWidget *widget;
+ GladeWidget *vbox_widget, *actionarea_widget, *colorsel, *fontsel;
+ GladeWidget *ok_button = NULL, *cancel_button = NULL,
+ *help_button = NULL, *apply_button = NULL;
+
+ g_return_if_fail (GTK_IS_DIALOG (dialog));
+
+ widget = glade_widget_get_from_gobject (GTK_WIDGET (dialog));
+ if (!widget)
+ return;
+
+ if (reason == GLADE_CREATE_USER)
+ {
+ /* HIG complient border-width defaults on dialogs */
+ glade_widget_property_set (widget, "border-width", 5);
+ }
+
+ if (GTK_IS_COLOR_SELECTION_DIALOG (object))
+ {
+ GtkWidget *child;
+
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_OK);
+ ok_button = glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (child), "ok_button", "colorsel", FALSE, reason);
+
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_CANCEL);
+ cancel_button = glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (child),
+ "cancel_button", "colorsel", FALSE, reason);
+
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_HELP);
+ help_button = glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (child), "help_button", "colorsel", FALSE, reason);
+
+ child =
+ gtk_color_selection_dialog_get_color_selection
+ (GTK_COLOR_SELECTION_DIALOG (dialog));
+ colorsel =
+ glade_widget_adaptor_create_internal (widget, G_OBJECT (child),
+ "color_selection", "colorsel",
+ FALSE, reason);
+
+ /* Set this to 1 at load time, if there are any children then
+ * size will adjust appropriately (otherwise the default "3" gets
+ * set and we end up with extra placeholders).
+ */
+ if (reason == GLADE_CREATE_LOAD)
+ glade_widget_property_set (colorsel, "size", 1);
+
+ }
+ else if (GTK_IS_FONT_SELECTION_DIALOG (object))
+ {
+ GtkWidget *child;
+
+ child =
+ gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG
+ (dialog));
+ ok_button =
+ glade_widget_adaptor_create_internal (widget, G_OBJECT (child),
+ "ok_button", "fontsel", FALSE,
+ reason);
+
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_APPLY);
+ apply_button = glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (child), "apply_button", "fontsel", FALSE, reason);
+
+ child =
+ gtk_font_selection_dialog_get_cancel_button (GTK_FONT_SELECTION_DIALOG
+ (dialog));
+ cancel_button =
+ glade_widget_adaptor_create_internal (widget, G_OBJECT (child),
+ "cancel_button", "fontsel",
+ FALSE, reason);
#if GTK_CHECK_VERSION (2, 24, 0)
- child = gtk_font_selection_dialog_get_font_selection
- (GTK_FONT_SELECTION_DIALOG (dialog));
+ child = gtk_font_selection_dialog_get_font_selection
+ (GTK_FONT_SELECTION_DIALOG (dialog));
#else
- child = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel;
+ child = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel;
#endif
- fontsel = glade_widget_adaptor_create_internal
- (widget, G_OBJECT (child),
- "font_selection", "fontsel", FALSE, reason);
-
- /* Set this to 1 at load time, if there are any children then
- * size will adjust appropriately (otherwise the default "3" gets
- * set and we end up with extra placeholders).
- */
- if (reason == GLADE_CREATE_LOAD)
- glade_widget_property_set (fontsel, "size", 2);
- }
- else
- {
- /* We need to stop default emissions of "hierarchy-changed" and
- * "screen-changed" of GtkFileChooserDefault to avoid an abort()
- * when doing a reparent.
- * GtkFileChooserDialog packs a GtkFileChooserWidget in
- * his internal vbox.
- */
- if (GTK_IS_FILE_CHOOSER_DIALOG (object))
- gtk_container_forall (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)),
- glade_gtk_file_chooser_forall,
- NULL);
-
- vbox_widget = glade_widget_adaptor_create_internal
- (widget, G_OBJECT(gtk_dialog_get_content_area (dialog)),
- "vbox", "dialog", FALSE, reason);
-
- actionarea_widget = glade_widget_adaptor_create_internal
- (vbox_widget, G_OBJECT(gtk_dialog_get_action_area (dialog)),
- "action_area", "dialog", FALSE, reason);
-
- /* These properties are controlled by the GtkDialog style properties:
- * "content-area-border", "button-spacing" and "action-area-border",
- * so we must disable thier use.
- */
- glade_widget_remove_property (vbox_widget, "border-width");
- glade_widget_remove_property (actionarea_widget, "border-width");
- glade_widget_remove_property (actionarea_widget, "spacing");
-
- /* Only set these on the original create. */
- if (reason == GLADE_CREATE_USER)
- {
-
- /* HIG complient spacing defaults on dialogs */
- glade_widget_property_set (vbox_widget, "spacing", 2);
-
- if (GTK_IS_MESSAGE_DIALOG (object))
- glade_widget_property_set (vbox_widget, "size", 2);
- else if (GTK_IS_ABOUT_DIALOG (object))
- glade_widget_property_set (vbox_widget, "size", 3);
- else if (GTK_IS_FILE_CHOOSER_DIALOG (object))
- glade_widget_property_set (vbox_widget, "size", 3);
- else
- glade_widget_property_set (vbox_widget, "size", 2);
-
- glade_widget_property_set (actionarea_widget, "size", 2);
- glade_widget_property_set (actionarea_widget, "layout-style", GTK_BUTTONBOX_END);
- }
- }
+ fontsel = glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (child),
+ "font_selection", "fontsel", FALSE, reason);
+
+ /* Set this to 1 at load time, if there are any children then
+ * size will adjust appropriately (otherwise the default "3" gets
+ * set and we end up with extra placeholders).
+ */
+ if (reason == GLADE_CREATE_LOAD)
+ glade_widget_property_set (fontsel, "size", 2);
+ }
+ else
+ {
+ /* We need to stop default emissions of "hierarchy-changed" and
+ * "screen-changed" of GtkFileChooserDefault to avoid an abort()
+ * when doing a reparent.
+ * GtkFileChooserDialog packs a GtkFileChooserWidget in
+ * his internal vbox.
+ */
+ if (GTK_IS_FILE_CHOOSER_DIALOG (object))
+ gtk_container_forall (GTK_CONTAINER
+ (gtk_dialog_get_content_area (dialog)),
+ glade_gtk_file_chooser_forall, NULL);
+
+ vbox_widget = glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (gtk_dialog_get_content_area (dialog)),
+ "vbox", "dialog", FALSE, reason);
+
+ actionarea_widget = glade_widget_adaptor_create_internal
+ (vbox_widget, G_OBJECT (gtk_dialog_get_action_area (dialog)),
+ "action_area", "dialog", FALSE, reason);
+
+ /* These properties are controlled by the GtkDialog style properties:
+ * "content-area-border", "button-spacing" and "action-area-border",
+ * so we must disable thier use.
+ */
+ glade_widget_remove_property (vbox_widget, "border-width");
+ glade_widget_remove_property (actionarea_widget, "border-width");
+ glade_widget_remove_property (actionarea_widget, "spacing");
+
+ /* Only set these on the original create. */
+ if (reason == GLADE_CREATE_USER)
+ {
+
+ /* HIG complient spacing defaults on dialogs */
+ glade_widget_property_set (vbox_widget, "spacing", 2);
+
+ if (GTK_IS_MESSAGE_DIALOG (object))
+ glade_widget_property_set (vbox_widget, "size", 2);
+ else if (GTK_IS_ABOUT_DIALOG (object))
+ glade_widget_property_set (vbox_widget, "size", 3);
+ else if (GTK_IS_FILE_CHOOSER_DIALOG (object))
+ glade_widget_property_set (vbox_widget, "size", 3);
+ else
+ glade_widget_property_set (vbox_widget, "size", 2);
+
+ glade_widget_property_set (actionarea_widget, "size", 2);
+ glade_widget_property_set (actionarea_widget, "layout-style",
+ GTK_BUTTONBOX_END);
+ }
+ }
}
GtkWidget *
-glade_gtk_dialog_get_internal_child (GladeWidgetAdaptor *adaptor,
- GtkDialog *dialog,
- const gchar *name)
-{
- GtkWidget *child = NULL;
-
- g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
-
- if (GTK_IS_COLOR_SELECTION_DIALOG (dialog))
- {
- if (strcmp ("ok_button", name) == 0)
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_OK);
- else if (strcmp ("cancel_button", name) == 0)
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_CANCEL);
- else if (strcmp ("help_button", name) == 0)
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_HELP);
- else if (strcmp ("color_selection", name) == 0)
- child = gtk_color_selection_dialog_get_color_selection
- (GTK_COLOR_SELECTION_DIALOG (dialog));
- }
- else if (GTK_IS_FONT_SELECTION_DIALOG (dialog))
- {
-
- if (strcmp ("ok_button", name) == 0)
- child = gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG (dialog));
- else if (strcmp ("apply_button", name) == 0)
- child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_APPLY);
- else if (strcmp ("cancel_button", name) == 0)
- child = gtk_font_selection_dialog_get_cancel_button
- (GTK_FONT_SELECTION_DIALOG (dialog));
- else if (strcmp ("font_selection", name) == 0)
- {
+glade_gtk_dialog_get_internal_child (GladeWidgetAdaptor * adaptor,
+ GtkDialog * dialog, const gchar * name)
+{
+ GtkWidget *child = NULL;
+
+ g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
+
+ if (GTK_IS_COLOR_SELECTION_DIALOG (dialog))
+ {
+ if (strcmp ("ok_button", name) == 0)
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_OK);
+ else if (strcmp ("cancel_button", name) == 0)
+ child =
+ gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_CANCEL);
+ else if (strcmp ("help_button", name) == 0)
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_HELP);
+ else if (strcmp ("color_selection", name) == 0)
+ child = gtk_color_selection_dialog_get_color_selection
+ (GTK_COLOR_SELECTION_DIALOG (dialog));
+ }
+ else if (GTK_IS_FONT_SELECTION_DIALOG (dialog))
+ {
+
+ if (strcmp ("ok_button", name) == 0)
+ child =
+ gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG
+ (dialog));
+ else if (strcmp ("apply_button", name) == 0)
+ child = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_APPLY);
+ else if (strcmp ("cancel_button", name) == 0)
+ child = gtk_font_selection_dialog_get_cancel_button
+ (GTK_FONT_SELECTION_DIALOG (dialog));
+ else if (strcmp ("font_selection", name) == 0)
+ {
#if GTK_CHECK_VERSION (2, 24, 0)
- child = gtk_font_selection_dialog_get_font_selection
- (GTK_FONT_SELECTION_DIALOG (dialog));
+ child = gtk_font_selection_dialog_get_font_selection
+ (GTK_FONT_SELECTION_DIALOG (dialog));
#else
- child = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel;
+ child = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel;
#endif
- }
- }
- else
- {
- /* Default generic dialog handling
- */
- if (strcmp ("vbox", name) == 0)
- child = gtk_dialog_get_content_area (dialog);
- else if (strcmp ("action_area", name) == 0)
- child = gtk_dialog_get_action_area (dialog);
- }
+ }
+ }
+ else
+ {
+ /* Default generic dialog handling
+ */
+ if (strcmp ("vbox", name) == 0)
+ child = gtk_dialog_get_content_area (dialog);
+ else if (strcmp ("action_area", name) == 0)
+ child = gtk_dialog_get_action_area (dialog);
+ }
- return child;
+ return child;
}
GList *
-glade_gtk_dialog_get_children (GladeWidgetAdaptor *adaptor,
- GtkDialog *dialog)
+glade_gtk_dialog_get_children (GladeWidgetAdaptor * adaptor, GtkDialog * dialog)
{
- GList *list = NULL;
+ GList *list = NULL;
- g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
+ g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
- list = glade_util_container_get_all_children (GTK_CONTAINER (dialog));
+ list = glade_util_container_get_all_children (GTK_CONTAINER (dialog));
- if (GTK_IS_COLOR_SELECTION_DIALOG (dialog))
- {
- GtkWidget *widget;
-
- widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_OK);
- if (widget) list = g_list_prepend (list, widget);
+ if (GTK_IS_COLOR_SELECTION_DIALOG (dialog))
+ {
+ GtkWidget *widget;
- widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_CANCEL);
- if (widget) list = g_list_prepend (list, widget);
+ widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_OK);
+ if (widget)
+ list = g_list_prepend (list, widget);
- widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_HELP);
- if (widget) list = g_list_prepend (list, widget);
+ widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_CANCEL);
+ if (widget)
+ list = g_list_prepend (list, widget);
- widget = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog));
- if (widget) list = g_list_prepend (list, widget);
- }
- else if (GTK_IS_FONT_SELECTION_DIALOG (dialog))
- {
- GtkWidget *widget;
+ widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_HELP);
+ if (widget)
+ list = g_list_prepend (list, widget);
- widget = gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG (dialog));
- if (widget) list = g_list_prepend (list, widget);
+ widget =
+ gtk_color_selection_dialog_get_color_selection
+ (GTK_COLOR_SELECTION_DIALOG (dialog));
+ if (widget)
+ list = g_list_prepend (list, widget);
+ }
+ else if (GTK_IS_FONT_SELECTION_DIALOG (dialog))
+ {
+ GtkWidget *widget;
- widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_APPLY);
- if (widget) list = g_list_prepend (list, widget);
+ widget =
+ gtk_font_selection_dialog_get_ok_button (GTK_FONT_SELECTION_DIALOG
+ (dialog));
+ if (widget)
+ list = g_list_prepend (list, widget);
- widget = gtk_font_selection_dialog_get_cancel_button (GTK_FONT_SELECTION_DIALOG (dialog));
- if (widget) list = g_list_prepend (list, widget);
+ widget = gtk_dialog_get_widget_for_response (dialog, GTK_RESPONSE_APPLY);
+ if (widget)
+ list = g_list_prepend (list, widget);
+
+ widget =
+ gtk_font_selection_dialog_get_cancel_button (GTK_FONT_SELECTION_DIALOG
+ (dialog));
+ if (widget)
+ list = g_list_prepend (list, widget);
#if GTK_CHECK_VERSION (2, 24, 0)
- widget = gtk_font_selection_dialog_get_font_selection (GTK_FONT_SELECTION_DIALOG (dialog));
+ widget =
+ gtk_font_selection_dialog_get_font_selection
+ (GTK_FONT_SELECTION_DIALOG (dialog));
#else
- widget = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel;
+ widget = GTK_FONT_SELECTION_DIALOG (dialog)->fontsel;
#endif
- if (widget) list = g_list_prepend (list, widget);
- }
- return list;
+ if (widget)
+ list = g_list_prepend (list, widget);
+ }
+ return list;
}
@@ -5229,323 +5134,331 @@ glade_gtk_dialog_get_children (GladeWidgetAdaptor *adaptor,
static void
-glade_gtk_dialog_read_responses (GladeWidget *widget,
- GladeXmlNode *widgets_node)
-{
- GladeXmlNode *node;
- GladeWidget *action_widget;
-
- for (node = glade_xml_node_get_children (widgets_node);
- node; node = glade_xml_node_next (node))
- {
- gchar *widget_name, *response;
-
- if (!glade_xml_node_verify (node, GLADE_TAG_ACTION_WIDGET))
- continue;
-
- response = glade_xml_get_property_string_required (node, GLADE_TAG_RESPONSE, NULL);
- widget_name = glade_xml_get_content (node);
-
- if ((action_widget =
- glade_project_get_widget_by_name (widget->project, widget, widget_name)) != NULL)
- {
- glade_widget_property_set (action_widget, "response-id",
- g_ascii_strtoll (response, NULL, 10));
- }
+glade_gtk_dialog_read_responses (GladeWidget * widget,
+ GladeXmlNode * widgets_node)
+{
+ GladeXmlNode *node;
+ GladeWidget *action_widget;
+
+ for (node = glade_xml_node_get_children (widgets_node);
+ node; node = glade_xml_node_next (node))
+ {
+ gchar *widget_name, *response;
+
+ if (!glade_xml_node_verify (node, GLADE_TAG_ACTION_WIDGET))
+ continue;
+
+ response =
+ glade_xml_get_property_string_required (node, GLADE_TAG_RESPONSE,
+ NULL);
+ widget_name = glade_xml_get_content (node);
+
+ if ((action_widget =
+ glade_project_get_widget_by_name (widget->project, widget,
+ widget_name)) != NULL)
+ {
+ glade_widget_property_set (action_widget, "response-id",
+ g_ascii_strtoll (response, NULL, 10));
+ }
- g_free (response);
- g_free (widget_name);
- }
+ g_free (response);
+ g_free (widget_name);
+ }
}
void
-glade_gtk_dialog_read_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_dialog_read_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeXmlNode *widgets_node;
+ GladeXmlNode *widgets_node;
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->read_child (adaptor, widget, node);
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->read_child (adaptor, widget, node);
- node = glade_xml_node_get_parent (node);
+ node = glade_xml_node_get_parent (node);
- if ((widgets_node = glade_xml_search_child (node, GLADE_TAG_ACTION_WIDGETS)) != NULL)
- glade_gtk_dialog_read_responses (widget, widgets_node);
+ if ((widgets_node =
+ glade_xml_search_child (node, GLADE_TAG_ACTION_WIDGETS)) != NULL)
+ glade_gtk_dialog_read_responses (widget, widgets_node);
}
static void
-glade_gtk_dialog_write_responses (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_dialog_write_responses (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *widget_node;
- GtkDialog *dialog = GTK_DIALOG (widget->object);
- GList *l, *action_widgets =
- gtk_container_get_children (GTK_CONTAINER (gtk_dialog_get_action_area (dialog)));
+ GladeXmlNode *widget_node;
+ GtkDialog *dialog = GTK_DIALOG (widget->object);
+ GList *l, *action_widgets =
+ gtk_container_get_children (GTK_CONTAINER
+ (gtk_dialog_get_action_area (dialog)));
+
+ for (l = action_widgets; l; l = l->next)
+ {
+ GladeWidget *action_widget;
+ GladeProperty *property;
+ gchar *str;
- for (l = action_widgets; l; l = l->next)
- {
- GladeWidget *action_widget;
- GladeProperty *property;
- gchar *str;
+ if ((action_widget = glade_widget_get_from_gobject (l->data)) == NULL)
+ continue;
- if ((action_widget = glade_widget_get_from_gobject (l->data)) == NULL)
- continue;
+ if ((property =
+ glade_widget_get_property (action_widget, "response-id")) == NULL)
+ continue;
- if ((property = glade_widget_get_property (action_widget, "response-id")) == NULL)
- continue;
-
- widget_node = glade_xml_node_new (context, GLADE_TAG_ACTION_WIDGET);
- glade_xml_node_append_child (node, widget_node);
+ widget_node = glade_xml_node_new (context, GLADE_TAG_ACTION_WIDGET);
+ glade_xml_node_append_child (node, widget_node);
- str = glade_property_class_make_string_from_gvalue (property->klass, property->value);
+ str =
+ glade_property_class_make_string_from_gvalue (property->klass,
+ property->value);
- glade_xml_node_set_property_string (widget_node, GLADE_TAG_RESPONSE, str);
- glade_xml_set_content (widget_node, action_widget->name);
+ glade_xml_node_set_property_string (widget_node, GLADE_TAG_RESPONSE, str);
+ glade_xml_set_content (widget_node, action_widget->name);
- g_free (str);
- }
+ g_free (str);
+ }
- g_list_free (action_widgets);
+ g_list_free (action_widgets);
}
void
-glade_gtk_dialog_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_dialog_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- GladeXmlNode *widgets_node;
- GladeWidget *parent;
- GladeProject *project;
+ GladeXmlNode *widgets_node;
+ GladeWidget *parent;
+ GladeProject *project;
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_child (adaptor, widget, context, node);
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_child (adaptor, widget, context,
+ node);
- parent = widget->parent;
- project = widget->project;
+ parent = widget->parent;
+ project = widget->project;
- if (parent && GTK_IS_DIALOG (parent->object))
- {
- widgets_node = glade_xml_node_new (context, GLADE_TAG_ACTION_WIDGETS);
+ if (parent && GTK_IS_DIALOG (parent->object))
+ {
+ widgets_node = glade_xml_node_new (context, GLADE_TAG_ACTION_WIDGETS);
- glade_gtk_dialog_write_responses (parent, context, widgets_node);
+ glade_gtk_dialog_write_responses (parent, context, widgets_node);
- if (!glade_xml_node_get_children (widgets_node))
- glade_xml_node_delete (widgets_node);
- else
- glade_xml_node_append_child (node, widgets_node);
- }
+ if (!glade_xml_node_get_children (widgets_node))
+ glade_xml_node_delete (widgets_node);
+ else
+ glade_xml_node_append_child (node, widgets_node);
+ }
}
/*--------------------------- GtkMessageDialog ---------------------------------*/
static gboolean
-glade_gtk_message_dialog_reset_image (GtkMessageDialog *dialog)
+glade_gtk_message_dialog_reset_image (GtkMessageDialog * dialog)
{
- GtkWidget *image;
- gint message_type;
+ GtkWidget *image;
+ gint message_type;
- g_object_get (dialog, "message-type", &message_type, NULL);
- if (message_type != GTK_MESSAGE_OTHER)
- return FALSE;
+ g_object_get (dialog, "message-type", &message_type, NULL);
+ if (message_type != GTK_MESSAGE_OTHER)
+ return FALSE;
- image = gtk_message_dialog_get_image (dialog);
- if (glade_widget_get_from_gobject (image))
- {
- gtk_message_dialog_set_image (dialog,
- gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG));
- gtk_widget_show (image);
+ image = gtk_message_dialog_get_image (dialog);
+ if (glade_widget_get_from_gobject (image))
+ {
+ gtk_message_dialog_set_image (dialog,
+ gtk_image_new_from_stock (NULL,
+ GTK_ICON_SIZE_DIALOG));
+ gtk_widget_show (image);
- return TRUE;
- }
- else
- return FALSE;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-enum {
- MD_IMAGE_ACTION_INVALID,
- MD_IMAGE_ACTION_RESET,
- MD_IMAGE_ACTION_SET
+enum
+{
+ MD_IMAGE_ACTION_INVALID,
+ MD_IMAGE_ACTION_RESET,
+ MD_IMAGE_ACTION_SET
};
static gint
-glade_gtk_message_dialog_image_determine_action (GtkMessageDialog *dialog,
- const GValue *value,
- GtkWidget **image,
- GladeWidget **gimage)
-{
- GtkWidget *dialog_image = gtk_message_dialog_get_image (dialog);
-
- *image = g_value_get_object (value);
-
- if (*image == NULL)
- if (glade_widget_get_from_gobject (dialog_image))
- return MD_IMAGE_ACTION_RESET;
- else
- return MD_IMAGE_ACTION_INVALID;
- else
- {
- *image = GTK_WIDGET (*image);
- if (dialog_image == *image)
- return MD_IMAGE_ACTION_INVALID;
- if (gtk_widget_get_parent (*image))
- return MD_IMAGE_ACTION_INVALID;
-
- *gimage = glade_widget_get_from_gobject (*image);
-
- if (!*gimage)
- {
- g_warning ("Setting property to an object outside the project");
- return MD_IMAGE_ACTION_INVALID;
- }
-
- if (glade_widget_get_parent (*gimage) || GWA_IS_TOPLEVEL ((*gimage)->adaptor))
- return MD_IMAGE_ACTION_INVALID;
-
- return MD_IMAGE_ACTION_SET;
- }
-}
-
-void
-glade_gtk_message_dialog_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (object);
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
-
- g_return_if_fail (gwidget);
-
- if (strcmp (id, "image") == 0)
- {
- GtkWidget *image = NULL;
- GladeWidget *gimage = NULL;
- gint rslt;
-
- rslt = glade_gtk_message_dialog_image_determine_action (dialog, value,
- &image, &gimage);
- switch (rslt)
- {
- case MD_IMAGE_ACTION_INVALID:
- return;
- case MD_IMAGE_ACTION_RESET:
- glade_gtk_message_dialog_reset_image (dialog);
- return;
- case MD_IMAGE_ACTION_SET:
- break; /* continue setting the property */
- }
-
- if (gtk_widget_get_parent (image))
- g_critical ("Image should have no parent now");
-
- gtk_message_dialog_set_image (dialog, image);
-
- {
- /* syncing "message-type" property */
- GladeProperty *property;
-
- property = glade_widget_get_property (gwidget, "message-type");
- if (!glade_property_equals (property, GTK_MESSAGE_OTHER))
- glade_command_set_property (property, GTK_MESSAGE_OTHER);
- }
- }
- else
- {
- /* We must reset the image to internal,
- * external image would otherwise become internal
- */
- if (!strcmp (id, "message-type") &&
- g_value_get_enum (value) != GTK_MESSAGE_OTHER)
- {
- GladeProperty *property;
-
- property = glade_widget_get_property (gwidget, "image");
- if (!glade_property_equals (property, NULL))
- glade_command_set_property (property, NULL);
- }
- /* Chain up, even if property us message-type because
- * it's not fully handled here
- */
- GWA_GET_CLASS (GTK_TYPE_DIALOG)->set_property (adaptor, object,
- id, value);
- }
+glade_gtk_message_dialog_image_determine_action (GtkMessageDialog * dialog,
+ const GValue * value,
+ GtkWidget ** image,
+ GladeWidget ** gimage)
+{
+ GtkWidget *dialog_image = gtk_message_dialog_get_image (dialog);
+
+ *image = g_value_get_object (value);
+
+ if (*image == NULL)
+ if (glade_widget_get_from_gobject (dialog_image))
+ return MD_IMAGE_ACTION_RESET;
+ else
+ return MD_IMAGE_ACTION_INVALID;
+ else
+ {
+ *image = GTK_WIDGET (*image);
+ if (dialog_image == *image)
+ return MD_IMAGE_ACTION_INVALID;
+ if (gtk_widget_get_parent (*image))
+ return MD_IMAGE_ACTION_INVALID;
+
+ *gimage = glade_widget_get_from_gobject (*image);
+
+ if (!*gimage)
+ {
+ g_warning ("Setting property to an object outside the project");
+ return MD_IMAGE_ACTION_INVALID;
+ }
+
+ if (glade_widget_get_parent (*gimage) ||
+ GWA_IS_TOPLEVEL ((*gimage)->adaptor))
+ return MD_IMAGE_ACTION_INVALID;
+
+ return MD_IMAGE_ACTION_SET;
+ }
+}
+
+void
+glade_gtk_message_dialog_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (object);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+
+ g_return_if_fail (gwidget);
+
+ if (strcmp (id, "image") == 0)
+ {
+ GtkWidget *image = NULL;
+ GladeWidget *gimage = NULL;
+ gint rslt;
+
+ rslt = glade_gtk_message_dialog_image_determine_action (dialog, value,
+ &image, &gimage);
+ switch (rslt)
+ {
+ case MD_IMAGE_ACTION_INVALID:
+ return;
+ case MD_IMAGE_ACTION_RESET:
+ glade_gtk_message_dialog_reset_image (dialog);
+ return;
+ case MD_IMAGE_ACTION_SET:
+ break; /* continue setting the property */
+ }
+
+ if (gtk_widget_get_parent (image))
+ g_critical ("Image should have no parent now");
+
+ gtk_message_dialog_set_image (dialog, image);
+
+ {
+ /* syncing "message-type" property */
+ GladeProperty *property;
+
+ property = glade_widget_get_property (gwidget, "message-type");
+ if (!glade_property_equals (property, GTK_MESSAGE_OTHER))
+ glade_command_set_property (property, GTK_MESSAGE_OTHER);
+ }
+ }
+ else
+ {
+ /* We must reset the image to internal,
+ * external image would otherwise become internal
+ */
+ if (!strcmp (id, "message-type") &&
+ g_value_get_enum (value) != GTK_MESSAGE_OTHER)
+ {
+ GladeProperty *property;
+
+ property = glade_widget_get_property (gwidget, "image");
+ if (!glade_property_equals (property, NULL))
+ glade_command_set_property (property, NULL);
+ }
+ /* Chain up, even if property us message-type because
+ * it's not fully handled here
+ */
+ GWA_GET_CLASS (GTK_TYPE_DIALOG)->set_property (adaptor, object,
+ id, value);
+ }
}
gboolean
-glade_gtk_message_dialog_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "image"))
- {
- GtkWidget *image; GladeWidget *gimage;
-
- gboolean retval = MD_IMAGE_ACTION_INVALID !=
- glade_gtk_message_dialog_image_determine_action (GTK_MESSAGE_DIALOG (object),
- value, &image, &gimage);
-
- return retval;
- }
- else
- if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
- return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
- id, value);
- else
- return TRUE;
-}
-
-void
-glade_gtk_message_dialog_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- GValue *value)
-{
- if (!strcmp (property_name, "image"))
- {
- GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (object);
- GtkWidget *image = gtk_message_dialog_get_image (dialog);
-
- if (!glade_widget_get_from_gobject (image))
- g_value_set_object (value, NULL);
- else
- g_value_set_object (value, image);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_DIALOG)->get_property (adaptor, object,
- property_name, value);
+glade_gtk_message_dialog_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id,
+ const GValue * value)
+{
+ if (!strcmp (id, "image"))
+ {
+ GtkWidget *image;
+ GladeWidget *gimage;
+
+ gboolean retval = MD_IMAGE_ACTION_INVALID !=
+ glade_gtk_message_dialog_image_determine_action (GTK_MESSAGE_DIALOG
+ (object),
+ value, &image,
+ &gimage);
+
+ return retval;
+ }
+ else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property)
+ return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object,
+ id, value);
+ else
+ return TRUE;
+}
+
+void
+glade_gtk_message_dialog_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ GValue * value)
+{
+ if (!strcmp (property_name, "image"))
+ {
+ GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (object);
+ GtkWidget *image = gtk_message_dialog_get_image (dialog);
+
+ if (!glade_widget_get_from_gobject (image))
+ g_value_set_object (value, NULL);
+ else
+ g_value_set_object (value, image);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_DIALOG)->get_property (adaptor, object,
+ property_name, value);
}
/* ----------------------------- GtkFileChooserWidget ------------------------------ */
void
-glade_gtk_file_chooser_widget_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_file_chooser_widget_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ GladeCreateReason reason)
{
- gtk_container_forall (GTK_CONTAINER (object),
- glade_gtk_file_chooser_default_forall,
- NULL);
+ gtk_container_forall (GTK_CONTAINER (object),
+ glade_gtk_file_chooser_default_forall, NULL);
}
void
-glade_gtk_file_chooser_button_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_file_chooser_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id,
+ const GValue * value)
{
- /* Avoid a warning */
- if (!strcmp (id, "action"))
- {
- if (g_value_get_enum (value) == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER ||
- g_value_get_enum (value) == GTK_FILE_CHOOSER_ACTION_SAVE)
- return;
- }
+ /* Avoid a warning */
+ if (!strcmp (id, "action"))
+ {
+ if (g_value_get_enum (value) == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER ||
+ g_value_get_enum (value) == GTK_FILE_CHOOSER_ACTION_SAVE)
+ return;
+ }
- GWA_GET_CLASS (GTK_TYPE_BOX)->set_property (adaptor,
- object,
- id, value);
+ GWA_GET_CLASS (GTK_TYPE_BOX)->set_property (adaptor, object, id, value);
}
/* ----------------------------- GtkFontButton ------------------------------ */
@@ -5553,1309 +5466,1347 @@ glade_gtk_file_chooser_button_set_property (GladeWidgetAdaptor *adaptor,
* glade property through the glade-command api.
*/
static void
-glade_gtk_font_button_refresh_font_name (GtkFontButton *button,
- GladeWidget *gbutton)
+glade_gtk_font_button_refresh_font_name (GtkFontButton * button,
+ GladeWidget * gbutton)
{
- GladeProperty *property;
-
- if ((property =
- glade_widget_get_property (gbutton, "font-name")) != NULL)
- glade_command_set_property (property,
- gtk_font_button_get_font_name (button));
+ GladeProperty *property;
+
+ if ((property = glade_widget_get_property (gbutton, "font-name")) != NULL)
+ glade_command_set_property (property,
+ gtk_font_button_get_font_name (button));
}
/* ----------------------------- GtkColorButton ------------------------------ */
static void
-glade_gtk_color_button_refresh_color (GtkColorButton *button,
- GladeWidget *gbutton)
+glade_gtk_color_button_refresh_color (GtkColorButton * button,
+ GladeWidget * gbutton)
{
- GladeProperty *property;
- GdkColor color = { 0, };
-
- if ((property = glade_widget_get_property (gbutton, "color")) != NULL)
- glade_command_set_property (property, &color);
+ GladeProperty *property;
+ GdkColor color = { 0, };
+
+ if ((property = glade_widget_get_property (gbutton, "color")) != NULL)
+ glade_command_set_property (property, &color);
}
void
-glade_gtk_color_button_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_color_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "color"))
- {
- if (g_value_get_boxed (value))
- gtk_color_button_set_color (GTK_COLOR_BUTTON (object),
- (GdkColor *)g_value_get_boxed (value));
- }
- else
- GWA_GET_CLASS (GTK_TYPE_BUTTON)->set_property (adaptor,
- object,
- id, value);
+ if (!strcmp (id, "color"))
+ {
+ if (g_value_get_boxed (value))
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (object),
+ (GdkColor *) g_value_get_boxed (value));
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_BUTTON)->set_property (adaptor, object, id, value);
}
/* ----------------------------- GtkButton ------------------------------ */
-static void
-sync_use_appearance (GladeWidget *gwidget)
+static void
+sync_use_appearance (GladeWidget * gwidget)
{
- GladeProperty *prop = glade_widget_get_property (gwidget, "use-action-appearance");
- gboolean use_appearance = FALSE;
+ GladeProperty *prop =
+ glade_widget_get_property (gwidget, "use-action-appearance");
+ gboolean use_appearance = FALSE;
- /* This is the kind of thing we avoid doing at project load time ;-) */
- if (glade_widget_superuser ())
- return;
+ /* This is the kind of thing we avoid doing at project load time ;-) */
+ if (glade_widget_superuser ())
+ return;
- glade_property_get (prop, &use_appearance);
- if (use_appearance)
- {
- glade_property_set (prop, FALSE);
- glade_property_set (prop, TRUE);
- }
+ glade_property_get (prop, &use_appearance);
+ if (use_appearance)
+ {
+ glade_property_set (prop, FALSE);
+ glade_property_set (prop, TRUE);
+ }
}
/* shared between menuitems and toolitems too */
static void
-evaluate_activatable_property_sensitivity (GObject *object,
- const gchar *id,
- const GValue *value)
-{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
-
- if (!strcmp (id, "related-action"))
- {
- GtkAction *action = g_value_get_object (value);
-
- if (action)
- {
- glade_widget_property_set_sensitive (gwidget, "visible", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "sensitive", FALSE, ACTION_APPEARANCE_MSG);
-
- glade_widget_property_set_sensitive (gwidget, "accel-group", FALSE, ACTION_APPEARANCE_MSG);
- } else {
- glade_widget_property_set_sensitive (gwidget, "visible", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "sensitive", TRUE, NULL);
-
- glade_widget_property_set_sensitive (gwidget, "accel-group", TRUE, NULL);
- }
-
- }
- else if (!strcmp (id, "use-action-appearance"))
- {
- gboolean use_appearance = g_value_get_boolean (value);
-
-
- if (use_appearance)
- {
- glade_widget_property_set_sensitive (gwidget, "label", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "use-underline", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "stock", FALSE, ACTION_APPEARANCE_MSG);
- //glade_widget_property_set_sensitive (gwidget, "use-stock", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "image", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "custom-child", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "stock-id", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "label-widget", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "icon-name", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "icon-widget", FALSE, ACTION_APPEARANCE_MSG);
- glade_widget_property_set_sensitive (gwidget, "icon", FALSE, ACTION_APPEARANCE_MSG);
- } else {
- glade_widget_property_set_sensitive (gwidget, "label", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "use-underline", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "stock", TRUE, NULL);
- //glade_widget_property_set_sensitive (gwidget, "use-stock", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "image", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "custom-child", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "stock-id", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "label-widget", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "icon-name", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "icon-widget", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "icon", TRUE, NULL);
- }
- }
+evaluate_activatable_property_sensitivity (GObject * object,
+ const gchar * id,
+ const GValue * value)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+
+ if (!strcmp (id, "related-action"))
+ {
+ GtkAction *action = g_value_get_object (value);
+
+ if (action)
+ {
+ glade_widget_property_set_sensitive (gwidget, "visible", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "sensitive", FALSE,
+ ACTION_APPEARANCE_MSG);
+
+ glade_widget_property_set_sensitive (gwidget, "accel-group", FALSE,
+ ACTION_APPEARANCE_MSG);
+ }
+ else
+ {
+ glade_widget_property_set_sensitive (gwidget, "visible", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "sensitive", TRUE,
+ NULL);
+
+ glade_widget_property_set_sensitive (gwidget, "accel-group", TRUE,
+ NULL);
+ }
+
+ }
+ else if (!strcmp (id, "use-action-appearance"))
+ {
+ gboolean use_appearance = g_value_get_boolean (value);
+
+
+ if (use_appearance)
+ {
+ glade_widget_property_set_sensitive (gwidget, "label", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "use-underline", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "stock", FALSE,
+ ACTION_APPEARANCE_MSG);
+ //glade_widget_property_set_sensitive (gwidget, "use-stock", FALSE, ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "image", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "custom-child", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "stock-id", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "label-widget", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "icon-name", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "icon-widget", FALSE,
+ ACTION_APPEARANCE_MSG);
+ glade_widget_property_set_sensitive (gwidget, "icon", FALSE,
+ ACTION_APPEARANCE_MSG);
+ }
+ else
+ {
+ glade_widget_property_set_sensitive (gwidget, "label", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "use-underline", TRUE,
+ NULL);
+ glade_widget_property_set_sensitive (gwidget, "stock", TRUE, NULL);
+ //glade_widget_property_set_sensitive (gwidget, "use-stock", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "image", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "custom-child", TRUE,
+ NULL);
+ glade_widget_property_set_sensitive (gwidget, "stock-id", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "label-widget", TRUE,
+ NULL);
+ glade_widget_property_set_sensitive (gwidget, "icon-name", TRUE,
+ NULL);
+ glade_widget_property_set_sensitive (gwidget, "icon-widget", TRUE,
+ NULL);
+ glade_widget_property_set_sensitive (gwidget, "icon", TRUE, NULL);
+ }
+ }
}
GladeEditable *
-glade_gtk_button_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_button_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
-
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
-
- if (type == GLADE_PAGE_GENERAL)
- {
- editable = (GladeEditable *)glade_activatable_editor_new (adaptor, editable);
- return (GladeEditable *)glade_button_editor_new (adaptor, editable);
- }
- return editable;
+ GladeEditable *editable;
+
+ /* Get base editable */
+ editable =
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+
+ if (type == GLADE_PAGE_GENERAL)
+ {
+ editable =
+ (GladeEditable *) glade_activatable_editor_new (adaptor, editable);
+ return (GladeEditable *) glade_button_editor_new (adaptor, editable);
+ }
+ return editable;
}
void
-glade_gtk_button_post_create (GladeWidgetAdaptor *adaptor,
- GObject *button,
- GladeCreateReason reason)
+glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * button, GladeCreateReason reason)
{
- GladeWidget *gbutton = glade_widget_get_from_gobject (button);
+ GladeWidget *gbutton = glade_widget_get_from_gobject (button);
+
+ g_return_if_fail (GTK_IS_BUTTON (button));
+ g_return_if_fail (GLADE_IS_WIDGET (gbutton));
- g_return_if_fail (GTK_IS_BUTTON (button));
- g_return_if_fail (GLADE_IS_WIDGET (gbutton));
+ if (GTK_IS_FONT_BUTTON (button))
+ g_signal_connect
+ (button, "font-set",
+ G_CALLBACK (glade_gtk_font_button_refresh_font_name), gbutton);
+ else if (GTK_IS_COLOR_BUTTON (button))
+ g_signal_connect
+ (button, "color-set",
+ G_CALLBACK (glade_gtk_color_button_refresh_color), gbutton);
- if (GTK_IS_FONT_BUTTON (button))
- g_signal_connect
- (button, "font-set",
- G_CALLBACK (glade_gtk_font_button_refresh_font_name), gbutton);
- else if (GTK_IS_COLOR_BUTTON (button))
- g_signal_connect
- (button, "color-set",
- G_CALLBACK (glade_gtk_color_button_refresh_color), gbutton);
-
- /* Disabled response-id until its in an action area */
- glade_widget_property_set_sensitive (gbutton, "response-id", FALSE,
- RESPID_INSENSITIVE_MSG);
- glade_widget_property_set_enabled (gbutton, "response-id", FALSE);
-}
-
-void
-glade_gtk_button_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- GladeProperty *property = glade_widget_get_property (widget, id);
-
- evaluate_activatable_property_sensitivity (object, id, value);
-
- if (strcmp (id, "custom-child") == 0)
- {
- GtkWidget *child = gtk_bin_get_child (GTK_BIN (object));
-
- if (g_value_get_boolean (value))
- {
- if (child)
- gtk_container_remove (GTK_CONTAINER (object), child);
-
- gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
- }
- else if (child && GLADE_IS_PLACEHOLDER (child))
- gtk_container_remove (GTK_CONTAINER (object), child);
- }
- else if (strcmp (id, "stock") == 0)
- {
- gboolean use_stock = FALSE;
- glade_widget_property_get (widget, "use-stock", &use_stock);
- if (use_stock)
- gtk_button_set_label (GTK_BUTTON (object), g_value_get_string (value));
- }
- else if (strcmp (id, "use-stock") == 0)
- {
- /* I guess its my bug in GTK+, we need to resync the appearance property
- * on GtkButton when the GtkButton:use-stock property changes.
- */
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
- id, value);
- sync_use_appearance (widget);
- }
- else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
- id, value);
-}
-
-void
-glade_gtk_button_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- gboolean use_stock;
- gchar *label = NULL;
-
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->read_widget (adaptor, widget, node);
-
- /* Update the stock property */
- glade_widget_property_get (widget, "use-stock", &use_stock);
- if (use_stock)
- {
- glade_widget_property_get (widget, "label", &label);
- glade_widget_property_set (widget, "stock", label);
- }
-}
-
-void
-glade_gtk_button_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeProperty *prop;
- gboolean use_stock;
- gchar *stock = NULL;
-
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* Do not save GtkColorButton and GtkFontButton label property */
- if (!(GTK_IS_COLOR_BUTTON (widget->object) || GTK_IS_FONT_BUTTON (widget->object)))
- {
- /* Make a copy of the GladeProperty,
- * override its value and ensure non-translatable if use-stock is TRUE
- */
- prop = glade_widget_get_property (widget, "label");
- prop = glade_property_dup (prop, widget);
- glade_widget_property_get (widget, "use-stock", &use_stock);
- if (use_stock)
- {
- glade_widget_property_get (widget, "stock", &stock);
- glade_property_i18n_set_translatable (prop, FALSE);
- glade_property_set (prop, stock);
- }
- glade_property_write (prop, context, node);
- g_object_unref (G_OBJECT (prop));
- }
-
- /* Write out other normal properties and any other class derived custom properties after ... */
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_widget (adaptor, widget, context, node);
+ /* Disabled response-id until its in an action area */
+ glade_widget_property_set_sensitive (gbutton, "response-id", FALSE,
+ RESPID_INSENSITIVE_MSG);
+ glade_widget_property_set_enabled (gbutton, "response-id", FALSE);
+}
+
+void
+glade_gtk_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ GladeProperty *property = glade_widget_get_property (widget, id);
+
+ evaluate_activatable_property_sensitivity (object, id, value);
+
+ if (strcmp (id, "custom-child") == 0)
+ {
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (object));
+
+ if (g_value_get_boolean (value))
+ {
+ if (child)
+ gtk_container_remove (GTK_CONTAINER (object), child);
+
+ gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
+ }
+ else if (child && GLADE_IS_PLACEHOLDER (child))
+ gtk_container_remove (GTK_CONTAINER (object), child);
+ }
+ else if (strcmp (id, "stock") == 0)
+ {
+ gboolean use_stock = FALSE;
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+ if (use_stock)
+ gtk_button_set_label (GTK_BUTTON (object), g_value_get_string (value));
+ }
+ else if (strcmp (id, "use-stock") == 0)
+ {
+ /* I guess its my bug in GTK+, we need to resync the appearance property
+ * on GtkButton when the GtkButton:use-stock property changes.
+ */
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
+ id, value);
+ sync_use_appearance (widget);
+ }
+ else if (GPC_VERSION_CHECK
+ (property->klass, gtk_major_version, gtk_minor_version + 1))
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
+ value);
+}
+
+void
+glade_gtk_button_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ gboolean use_stock;
+ gchar *label = NULL;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->read_widget (adaptor, widget, node);
+
+ /* Update the stock property */
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+ if (use_stock)
+ {
+ glade_widget_property_get (widget, "label", &label);
+ glade_widget_property_set (widget, "stock", label);
+ }
+}
+
+void
+glade_gtk_button_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+ GladeProperty *prop;
+ gboolean use_stock;
+ gchar *stock = NULL;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* Do not save GtkColorButton and GtkFontButton label property */
+ if (!
+ (GTK_IS_COLOR_BUTTON (widget->object) ||
+ GTK_IS_FONT_BUTTON (widget->object)))
+ {
+ /* Make a copy of the GladeProperty,
+ * override its value and ensure non-translatable if use-stock is TRUE
+ */
+ prop = glade_widget_get_property (widget, "label");
+ prop = glade_property_dup (prop, widget);
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+ if (use_stock)
+ {
+ glade_widget_property_get (widget, "stock", &stock);
+ glade_property_i18n_set_translatable (prop, FALSE);
+ glade_property_set (prop, stock);
+ }
+ glade_property_write (prop, context, node);
+ g_object_unref (G_OBJECT (prop));
+ }
+
+ /* Write out other normal properties and any other class derived custom properties after ... */
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->write_widget (adaptor, widget, context,
+ node);
}
/* ----------------------------- GtkImage ------------------------------ */
void
-glade_gtk_image_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_image_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
-
- if (glade_widget_property_original_default (widget, "icon-name") == FALSE)
- {
- property = glade_widget_get_property (widget, "icon-name");
- glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_ICON);
- }
- else if (glade_widget_property_original_default (widget, "pixbuf") == FALSE)
- {
- property = glade_widget_get_property (widget, "pixbuf");
- glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_FILENAME);
- }
- else/* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
- {
- property = glade_widget_get_property (widget, "stock");
- glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_STOCK);
- }
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
- glade_property_sync (property);
+ if (glade_widget_property_original_default (widget, "icon-name") == FALSE)
+ {
+ property = glade_widget_get_property (widget, "icon-name");
+ glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_ICON);
+ }
+ else if (glade_widget_property_original_default (widget, "pixbuf") == FALSE)
+ {
+ property = glade_widget_get_property (widget, "pixbuf");
+ glade_widget_property_set (widget, "image-mode",
+ GLADE_IMAGE_MODE_FILENAME);
+ }
+ else /* if (glade_widget_property_original_default (widget, "stock") == FALSE) */
+ {
+ property = glade_widget_get_property (widget, "stock");
+ glade_widget_property_set (widget, "image-mode", GLADE_IMAGE_MODE_STOCK);
+ }
+
+ glade_property_sync (property);
}
void
-glade_gtk_image_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_image_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- GladeXmlNode *prop_node;
- GladeProperty *size_prop;
- GtkIconSize icon_size;
- gchar *value;
+ GladeXmlNode *prop_node;
+ GladeProperty *size_prop;
+ GtkIconSize icon_size;
+ gchar *value;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and write all the normal properties (including "use-stock")... */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context, node);
+ /* First chain up and write all the normal properties (including "use-stock")... */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context,
+ node);
- /* We have to save icon-size as an integer, the core will take care of
- * loading the int value though.
- */
- size_prop = glade_widget_get_property (widget, "icon-size");
- if (!glade_property_original_default (size_prop))
- {
- prop_node = glade_xml_node_new (context, GLADE_TAG_PROPERTY);
- glade_xml_node_append_child (node, prop_node);
+ /* We have to save icon-size as an integer, the core will take care of
+ * loading the int value though.
+ */
+ size_prop = glade_widget_get_property (widget, "icon-size");
+ if (!glade_property_original_default (size_prop))
+ {
+ prop_node = glade_xml_node_new (context, GLADE_TAG_PROPERTY);
+ glade_xml_node_append_child (node, prop_node);
- glade_xml_node_set_property_string (prop_node, GLADE_TAG_NAME, size_prop->klass->id);
+ glade_xml_node_set_property_string (prop_node, GLADE_TAG_NAME,
+ size_prop->klass->id);
- glade_property_get (size_prop, &icon_size);
- value = g_strdup_printf ("%d", icon_size);
- glade_xml_set_content (prop_node, value);
- g_free (value);
- }
+ glade_property_get (size_prop, &icon_size);
+ value = g_strdup_printf ("%d", icon_size);
+ glade_xml_set_content (prop_node, value);
+ g_free (value);
+ }
}
static void
-glade_gtk_image_set_image_mode (GObject *object, const GValue *value)
-{
- GladeWidget *gwidget;
- GladeImageEditMode type;
-
- gwidget = glade_widget_get_from_gobject (object);
- g_return_if_fail (GTK_IS_IMAGE (object));
- g_return_if_fail (GLADE_IS_WIDGET (gwidget));
-
- glade_widget_property_set_sensitive (gwidget, "stock", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "icon-name", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "pixbuf", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gwidget, "icon-size", FALSE,
- _("This property only applies to stock images"));
- glade_widget_property_set_sensitive (gwidget, "pixel-size", FALSE,
- _("This property only applies to named icons"));
-
- switch ((type = g_value_get_int (value)))
- {
- case GLADE_IMAGE_MODE_STOCK:
- glade_widget_property_set_sensitive (gwidget, "stock", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "icon-size", TRUE, NULL);
- break;
-
- case GLADE_IMAGE_MODE_ICON:
- glade_widget_property_set_sensitive (gwidget, "icon-name", TRUE, NULL);
- glade_widget_property_set_sensitive (gwidget, "pixel-size", TRUE, NULL);
- break;
-
- case GLADE_IMAGE_MODE_FILENAME:
- glade_widget_property_set_sensitive (gwidget, "pixbuf", TRUE, NULL);
- default:
- break;
- }
-}
-
-void
-glade_gtk_image_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- GValue *value)
-{
- if (!strcmp (id, "icon-size"))
- {
- /* Make the int an enum... */
- GValue int_value = { 0, };
- g_value_init (&int_value, G_TYPE_INT);
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->get_property (adaptor, object, id, &int_value);
- g_value_set_enum (value, g_value_get_int (&int_value));
- g_value_unset (&int_value);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object,
- id, value);
-}
-
-void
-glade_gtk_image_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "image-mode"))
- glade_gtk_image_set_image_mode (object, value);
- else if (!strcmp (id, "icon-size"))
- {
- /* Make the enum an int... */
- GValue int_value = { 0, };
- g_value_init (&int_value, G_TYPE_INT);
- g_value_set_int (&int_value, g_value_get_enum (value));
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, &int_value);
- g_value_unset (&int_value);
- }
- else
- {
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- GladeImageEditMode mode = 0;
-
- glade_widget_property_get (widget, "image-mode", &mode);
-
- /* avoid setting properties in the wrong mode... */
- switch (mode)
- {
- case GLADE_IMAGE_MODE_STOCK:
- if (!strcmp (id, "icon-name") ||
- !strcmp (id, "pixbuf"))
- return;
- break;
- case GLADE_IMAGE_MODE_ICON:
- if (!strcmp (id, "stock") ||
- !strcmp (id, "pixbuf"))
- return;
- break;
- case GLADE_IMAGE_MODE_FILENAME:
- if (!strcmp (id, "stock") ||
- !strcmp (id, "icon-name"))
- return;
- default:
- break;
- }
-
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object,
- id, value);
- }
+glade_gtk_image_set_image_mode (GObject * object, const GValue * value)
+{
+ GladeWidget *gwidget;
+ GladeImageEditMode type;
+
+ gwidget = glade_widget_get_from_gobject (object);
+ g_return_if_fail (GTK_IS_IMAGE (object));
+ g_return_if_fail (GLADE_IS_WIDGET (gwidget));
+
+ glade_widget_property_set_sensitive (gwidget, "stock", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "icon-name", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "pixbuf", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gwidget, "icon-size", FALSE,
+ _
+ ("This property only applies to stock images"));
+ glade_widget_property_set_sensitive (gwidget, "pixel-size", FALSE,
+ _
+ ("This property only applies to named icons"));
+
+ switch ((type = g_value_get_int (value)))
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ glade_widget_property_set_sensitive (gwidget, "stock", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "icon-size", TRUE, NULL);
+ break;
+
+ case GLADE_IMAGE_MODE_ICON:
+ glade_widget_property_set_sensitive (gwidget, "icon-name", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "pixel-size", TRUE, NULL);
+ break;
+
+ case GLADE_IMAGE_MODE_FILENAME:
+ glade_widget_property_set_sensitive (gwidget, "pixbuf", TRUE, NULL);
+ default:
+ break;
+ }
+}
+
+void
+glade_gtk_image_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, GValue * value)
+{
+ if (!strcmp (id, "icon-size"))
+ {
+ /* Make the int an enum... */
+ GValue int_value = { 0, };
+ g_value_init (&int_value, G_TYPE_INT);
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->get_property (adaptor, object, id,
+ &int_value);
+ g_value_set_enum (value, g_value_get_int (&int_value));
+ g_value_unset (&int_value);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
+}
+
+void
+glade_gtk_image_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ if (!strcmp (id, "image-mode"))
+ glade_gtk_image_set_image_mode (object, value);
+ else if (!strcmp (id, "icon-size"))
+ {
+ /* Make the enum an int... */
+ GValue int_value = { 0, };
+ g_value_init (&int_value, G_TYPE_INT);
+ g_value_set_int (&int_value, g_value_get_enum (value));
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id,
+ &int_value);
+ g_value_unset (&int_value);
+ }
+ else
+ {
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ GladeImageEditMode mode = 0;
+
+ glade_widget_property_get (widget, "image-mode", &mode);
+
+ /* avoid setting properties in the wrong mode... */
+ switch (mode)
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ if (!strcmp (id, "icon-name") || !strcmp (id, "pixbuf"))
+ return;
+ break;
+ case GLADE_IMAGE_MODE_ICON:
+ if (!strcmp (id, "stock") || !strcmp (id, "pixbuf"))
+ return;
+ break;
+ case GLADE_IMAGE_MODE_FILENAME:
+ if (!strcmp (id, "stock") || !strcmp (id, "icon-name"))
+ return;
+ default:
+ break;
+ }
+
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object,
+ id, value);
+ }
}
GladeEditable *
-glade_gtk_image_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_image_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_image_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_image_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
/* ----------------------------- GtkMenu ------------------------------ */
GObject *
-glade_gtk_menu_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+glade_gtk_menu_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
{
- GladeWidgetAdaptor *adaptor;
- GObject *ret_obj;
-
- ret_obj = GWA_GET_OCLASS(GTK_TYPE_CONTAINER)->constructor
- (type, n_construct_properties, construct_properties);
+ GladeWidgetAdaptor *adaptor;
+ GObject *ret_obj;
- adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
+ ret_obj = GWA_GET_OCLASS (GTK_TYPE_CONTAINER)->constructor
+ (type, n_construct_properties, construct_properties);
- glade_widget_adaptor_action_remove (adaptor, "add_parent");
- glade_widget_adaptor_action_remove (adaptor, "remove_parent");
+ adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
- return ret_obj;
+ glade_widget_adaptor_action_remove (adaptor, "add_parent");
+ glade_widget_adaptor_action_remove (adaptor, "remove_parent");
+
+ return ret_obj;
}
/* ----------------------------- GtkMenuShell ------------------------------ */
void
-glade_gtk_menu_shell_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_menu_shell_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
-
- g_return_if_fail (GTK_IS_MENU_SHELL (object));
- g_return_if_fail (GTK_IS_MENU_ITEM (child));
- gtk_menu_shell_append (GTK_MENU_SHELL (object), GTK_WIDGET (child));
+ g_return_if_fail (GTK_IS_MENU_SHELL (object));
+ g_return_if_fail (GTK_IS_MENU_ITEM (child));
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (object), GTK_WIDGET (child));
}
void
-glade_gtk_menu_shell_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_menu_shell_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_MENU_SHELL (object));
- g_return_if_fail (GTK_IS_MENU_ITEM (child));
-
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+ g_return_if_fail (GTK_IS_MENU_SHELL (object));
+ g_return_if_fail (GTK_IS_MENU_ITEM (child));
+
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
}
static gint
-glade_gtk_menu_shell_get_item_position (GObject *container, GObject *child)
-{
- gint position = 0;
- GList *list = gtk_container_get_children (GTK_CONTAINER (container));
-
- while (list)
- {
- if (G_OBJECT (list->data) == child) break;
-
- list = list->next;
- position++;
- }
-
- g_list_free (list);
-
- return position;
-}
-
-void
-glade_gtk_menu_shell_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- g_return_if_fail (GTK_IS_MENU_SHELL (container));
- g_return_if_fail (GTK_IS_MENU_ITEM (child));
-
- if (strcmp (property_name, "position") == 0)
- {
- g_value_set_int (value,
- glade_gtk_menu_shell_get_item_position (container,
- child));
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container,
- child,
- property_name,
- value);
-}
-
-void
-glade_gtk_menu_shell_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- g_return_if_fail (GTK_IS_MENU_SHELL (container));
- g_return_if_fail (GTK_IS_MENU_ITEM (child));
- g_return_if_fail (property_name != NULL || value != NULL);
-
- if (strcmp (property_name, "position") == 0)
- {
- GladeWidget *gitem;
- gint position;
-
- gitem = glade_widget_get_from_gobject (child);
- g_return_if_fail (GLADE_IS_WIDGET (gitem));
-
- position = g_value_get_int (value);
-
- if (position < 0)
- {
- position = glade_gtk_menu_shell_get_item_position (container, child);
- g_value_set_int (value, position);
- }
-
- g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
- gtk_menu_shell_insert (GTK_MENU_SHELL (container), GTK_WIDGET (child), position);
- g_object_unref (child);
-
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
+glade_gtk_menu_shell_get_item_position (GObject * container, GObject * child)
+{
+ gint position = 0;
+ GList *list = gtk_container_get_children (GTK_CONTAINER (container));
+
+ while (list)
+ {
+ if (G_OBJECT (list->data) == child)
+ break;
+
+ list = list->next;
+ position++;
+ }
+
+ g_list_free (list);
+
+ return position;
+}
+
+void
+glade_gtk_menu_shell_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GTK_IS_MENU_SHELL (container));
+ g_return_if_fail (GTK_IS_MENU_ITEM (child));
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ g_value_set_int (value,
+ glade_gtk_menu_shell_get_item_position (container,
+ child));
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container,
+ child, property_name, value);
+}
+
+void
+glade_gtk_menu_shell_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GTK_IS_MENU_SHELL (container));
+ g_return_if_fail (GTK_IS_MENU_ITEM (child));
+ g_return_if_fail (property_name != NULL || value != NULL);
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ GladeWidget *gitem;
+ gint position;
+
+ gitem = glade_widget_get_from_gobject (child);
+ g_return_if_fail (GLADE_IS_WIDGET (gitem));
+
+ position = g_value_get_int (value);
+
+ if (position < 0)
+ {
+ position = glade_gtk_menu_shell_get_item_position (container, child);
+ g_value_set_int (value, position);
+ }
+
+ g_object_ref (child);
+ gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
+ gtk_menu_shell_insert (GTK_MENU_SHELL (container), GTK_WIDGET (child),
+ position);
+ g_object_unref (child);
+
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
}
static gchar *
-glade_gtk_menu_shell_tool_item_get_display_name (GladeBaseEditor *editor,
- GladeWidget *gchild,
- gpointer user_data)
-{
- GObject *child = glade_widget_get_object (gchild);
- gchar *name;
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (child) ||
- GTK_IS_SEPARATOR_TOOL_ITEM (child))
- name = _("<separator>");
- else if (GTK_IS_MENU_ITEM (child))
- glade_widget_property_get (gchild, "label", &name);
- else if (GTK_IS_TOOL_BUTTON (child))
- {
- glade_widget_property_get (gchild, "label", &name);
- if (name == NULL || strlen (name) == 0)
- glade_widget_property_get (gchild, "stock-id", &name);
- }
- else
- name = _("<custom>");
-
- return g_strdup (name);
+glade_gtk_menu_shell_tool_item_get_display_name (GladeBaseEditor * editor,
+ GladeWidget * gchild,
+ gpointer user_data)
+{
+ GObject *child = glade_widget_get_object (gchild);
+ gchar *name;
+
+ if (GTK_IS_SEPARATOR_MENU_ITEM (child) || GTK_IS_SEPARATOR_TOOL_ITEM (child))
+ name = _("<separator>");
+ else if (GTK_IS_MENU_ITEM (child))
+ glade_widget_property_get (gchild, "label", &name);
+ else if (GTK_IS_TOOL_BUTTON (child))
+ {
+ glade_widget_property_get (gchild, "label", &name);
+ if (name == NULL || strlen (name) == 0)
+ glade_widget_property_get (gchild, "stock-id", &name);
+ }
+ else
+ name = _("<custom>");
+
+ return g_strdup (name);
}
static GladeWidget *
-glade_gtk_menu_shell_item_get_parent (GladeWidget *gparent, GObject *parent)
-{
- GtkWidget *submenu = NULL;
-
- if (GTK_IS_MENU_TOOL_BUTTON (parent))
- submenu = gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (parent));
- else if (GTK_IS_MENU_ITEM (parent))
- submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent));
-
- if (submenu)
- gparent = glade_widget_get_from_gobject (submenu);
- else
- gparent = glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_MENU),
- gparent, NULL, glade_widget_get_project (gparent));
-
- return gparent;
-}
-
-static GladeWidget *
-glade_gtk_menu_shell_build_child (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GType type,
- gpointer data)
-{
- GObject *parent = glade_widget_get_object (gparent);
- GladeWidget *gitem_new;
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (parent))
- return NULL;
-
- /* Get or build real parent */
- if (GTK_IS_MENU_ITEM (parent) || GTK_IS_MENU_TOOL_BUTTON (parent))
- gparent = glade_gtk_menu_shell_item_get_parent (gparent, parent);
-
- /* Build child */
- gitem_new = glade_command_create (glade_widget_adaptor_get_by_type (type),
- gparent, NULL,
- glade_widget_get_project (gparent));
-
- if (type != GTK_TYPE_SEPARATOR_MENU_ITEM)
- {
- glade_widget_property_set (gitem_new, "label",
- glade_widget_get_name (gitem_new));
- glade_widget_property_set (gitem_new, "use-underline", TRUE);
- }
-
- return gitem_new;
+glade_gtk_menu_shell_item_get_parent (GladeWidget * gparent, GObject * parent)
+{
+ GtkWidget *submenu = NULL;
+
+ if (GTK_IS_MENU_TOOL_BUTTON (parent))
+ submenu = gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (parent));
+ else if (GTK_IS_MENU_ITEM (parent))
+ submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent));
+
+ if (submenu)
+ gparent = glade_widget_get_from_gobject (submenu);
+ else
+ gparent =
+ glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_MENU),
+ gparent, NULL,
+ glade_widget_get_project (gparent));
+
+ return gparent;
+}
+
+static GladeWidget *
+glade_gtk_menu_shell_build_child (GladeBaseEditor * editor,
+ GladeWidget * gparent,
+ GType type, gpointer data)
+{
+ GObject *parent = glade_widget_get_object (gparent);
+ GladeWidget *gitem_new;
+
+ if (GTK_IS_SEPARATOR_MENU_ITEM (parent))
+ return NULL;
+
+ /* Get or build real parent */
+ if (GTK_IS_MENU_ITEM (parent) || GTK_IS_MENU_TOOL_BUTTON (parent))
+ gparent = glade_gtk_menu_shell_item_get_parent (gparent, parent);
+
+ /* Build child */
+ gitem_new = glade_command_create (glade_widget_adaptor_get_by_type (type),
+ gparent, NULL,
+ glade_widget_get_project (gparent));
+
+ if (type != GTK_TYPE_SEPARATOR_MENU_ITEM)
+ {
+ glade_widget_property_set (gitem_new, "label",
+ glade_widget_get_name (gitem_new));
+ glade_widget_property_set (gitem_new, "use-underline", TRUE);
+ }
+
+ return gitem_new;
}
static gboolean
-glade_gtk_menu_shell_delete_child (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GladeWidget *gchild,
- gpointer data)
-{
- GObject *item = glade_widget_get_object (gparent);
- GtkWidget *submenu = NULL;
- GList list = {0, };
- gint n_children = 0;
-
- if (GTK_IS_MENU_ITEM (item) &&
- (submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item))))
- {
- GList *l = gtk_container_get_children (GTK_CONTAINER (submenu));
- n_children = g_list_length (l);
- g_list_free (l);
- }
-
- if (submenu && n_children == 1)
- list.data = glade_widget_get_parent (gchild);
- else
- list.data = gchild;
-
- /* Remove widget */
- glade_command_delete (&list);
-
- return TRUE;
+glade_gtk_menu_shell_delete_child (GladeBaseEditor * editor,
+ GladeWidget * gparent,
+ GladeWidget * gchild, gpointer data)
+{
+ GObject *item = glade_widget_get_object (gparent);
+ GtkWidget *submenu = NULL;
+ GList list = { 0, };
+ gint n_children = 0;
+
+ if (GTK_IS_MENU_ITEM (item) &&
+ (submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item))))
+ {
+ GList *l = gtk_container_get_children (GTK_CONTAINER (submenu));
+ n_children = g_list_length (l);
+ g_list_free (l);
+ }
+
+ if (submenu && n_children == 1)
+ list.data = glade_widget_get_parent (gchild);
+ else
+ list.data = gchild;
+
+ /* Remove widget */
+ glade_command_delete (&list);
+
+ return TRUE;
}
static gboolean
-glade_gtk_menu_shell_move_child (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GladeWidget *gchild,
- gpointer data)
-{
- GObject *parent = glade_widget_get_object (gparent);
- GObject *child = glade_widget_get_object (gchild);
- GladeWidget *old_parent = gchild->parent;
- GList list = {0, };
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (parent) ||
- GTK_IS_SEPARATOR_TOOL_ITEM (parent))
- return FALSE;
-
- if (GTK_IS_MENU_ITEM (child) && GTK_IS_TOOLBAR (parent))
- return FALSE;
-
- if (GTK_IS_TOOL_ITEM (child) &&
- (GTK_IS_MENU (parent) || GTK_IS_MENU_BAR (parent) || GTK_IS_MENU_ITEM (parent)))
- return FALSE;
-
- if (GTK_IS_TOOL_ITEM (parent) &&
- (!GTK_IS_MENU_TOOL_BUTTON (parent) || !GTK_IS_MENU_ITEM (child)))
- return FALSE;
-
- if (GTK_IS_MENU_ITEM (parent) || GTK_IS_MENU_TOOL_BUTTON (parent))
- gparent = glade_gtk_menu_shell_item_get_parent (gparent, parent);
-
- if (gparent != glade_widget_get_parent (gchild))
- {
- list.data = gchild;
- glade_command_dnd (&list, gparent, NULL);
- }
-
- /* Delete dangling childless menus */
- if (GTK_IS_MENU (old_parent->object) &&
- old_parent->parent && GTK_IS_MENU_ITEM (old_parent->parent->object))
- {
- GList del = { 0, }, *children;
-
- children = gtk_container_get_children (GTK_CONTAINER (old_parent->object));
- if (!children)
- {
- del.data = old_parent;
- glade_command_delete (&del);
- }
- g_list_free (children);
- }
-
- return TRUE;
+glade_gtk_menu_shell_move_child (GladeBaseEditor * editor,
+ GladeWidget * gparent,
+ GladeWidget * gchild, gpointer data)
+{
+ GObject *parent = glade_widget_get_object (gparent);
+ GObject *child = glade_widget_get_object (gchild);
+ GladeWidget *old_parent = gchild->parent;
+ GList list = { 0, };
+
+ if (GTK_IS_SEPARATOR_MENU_ITEM (parent) ||
+ GTK_IS_SEPARATOR_TOOL_ITEM (parent))
+ return FALSE;
+
+ if (GTK_IS_MENU_ITEM (child) && GTK_IS_TOOLBAR (parent))
+ return FALSE;
+
+ if (GTK_IS_TOOL_ITEM (child) &&
+ (GTK_IS_MENU (parent) || GTK_IS_MENU_BAR (parent) ||
+ GTK_IS_MENU_ITEM (parent)))
+ return FALSE;
+
+ if (GTK_IS_TOOL_ITEM (parent) &&
+ (!GTK_IS_MENU_TOOL_BUTTON (parent) || !GTK_IS_MENU_ITEM (child)))
+ return FALSE;
+
+ if (GTK_IS_MENU_ITEM (parent) || GTK_IS_MENU_TOOL_BUTTON (parent))
+ gparent = glade_gtk_menu_shell_item_get_parent (gparent, parent);
+
+ if (gparent != glade_widget_get_parent (gchild))
+ {
+ list.data = gchild;
+ glade_command_dnd (&list, gparent, NULL);
+ }
+
+ /* Delete dangling childless menus */
+ if (GTK_IS_MENU (old_parent->object) &&
+ old_parent->parent && GTK_IS_MENU_ITEM (old_parent->parent->object))
+ {
+ GList del = { 0, }
+ , *children;
+
+ children =
+ gtk_container_get_children (GTK_CONTAINER (old_parent->object));
+ if (!children)
+ {
+ del.data = old_parent;
+ glade_command_delete (&del);
+ }
+ g_list_free (children);
+ }
+
+ return TRUE;
}
static gboolean
-glade_gtk_menu_shell_change_type (GladeBaseEditor *editor,
- GladeWidget *gchild,
- GType type,
- gpointer data)
-{
- GObject *child = glade_widget_get_object (gchild);
-
-
- if ((type == GTK_TYPE_SEPARATOR_MENU_ITEM &&
- gtk_menu_item_get_submenu (GTK_MENU_ITEM (child))) ||
- (GTK_IS_MENU_TOOL_BUTTON (child) &&
- gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (child))))
- return TRUE;
-
- /* Delete the internal image of an image menu item before going ahead and changing types. */
- if (GTK_IS_IMAGE_MENU_ITEM (child))
- {
- GList list = { 0, };
- GtkWidget *image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (child));
- GladeWidget *widget;
-
- if (image && (widget = glade_widget_get_from_gobject (image)))
- {
- list.data = widget;
- glade_command_unlock_widget (widget);
- glade_command_delete (&list);
- }
- }
-
- return FALSE;
+glade_gtk_menu_shell_change_type (GladeBaseEditor * editor,
+ GladeWidget * gchild,
+ GType type, gpointer data)
+{
+ GObject *child = glade_widget_get_object (gchild);
+
+
+ if ((type == GTK_TYPE_SEPARATOR_MENU_ITEM &&
+ gtk_menu_item_get_submenu (GTK_MENU_ITEM (child))) ||
+ (GTK_IS_MENU_TOOL_BUTTON (child) &&
+ gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (child))))
+ return TRUE;
+
+ /* Delete the internal image of an image menu item before going ahead and changing types. */
+ if (GTK_IS_IMAGE_MENU_ITEM (child))
+ {
+ GList list = { 0, };
+ GtkWidget *image =
+ gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (child));
+ GladeWidget *widget;
+
+ if (image && (widget = glade_widget_get_from_gobject (image)))
+ {
+ list.data = widget;
+ glade_command_unlock_widget (widget);
+ glade_command_delete (&list);
+ }
+ }
+
+ return FALSE;
}
static void
-glade_gtk_toolbar_child_selected (GladeBaseEditor *editor,
- GladeWidget *gchild,
- gpointer data)
+glade_gtk_toolbar_child_selected (GladeBaseEditor * editor,
+ GladeWidget * gchild, gpointer data)
{
- GObject *child = glade_widget_get_object (gchild);
- GType type = G_OBJECT_TYPE (child);
-
- glade_base_editor_add_label (editor, _("Tool Item"));
-
- glade_base_editor_add_default_properties (editor, gchild);
-
- glade_base_editor_add_label (editor, _("Properties"));
- glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
-
- if (type == GTK_TYPE_SEPARATOR_TOOL_ITEM) return;
+ GObject *child = glade_widget_get_object (gchild);
+ GType type = G_OBJECT_TYPE (child);
+
+ glade_base_editor_add_label (editor, _("Tool Item"));
+
+ glade_base_editor_add_default_properties (editor, gchild);
+
+ glade_base_editor_add_label (editor, _("Properties"));
+ glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
- glade_base_editor_add_label (editor, _("Packing"));
- glade_base_editor_add_properties (editor, gchild, TRUE,
- "expand", "homogeneous", NULL);
+ if (type == GTK_TYPE_SEPARATOR_TOOL_ITEM)
+ return;
+
+ glade_base_editor_add_label (editor, _("Packing"));
+ glade_base_editor_add_properties (editor, gchild, TRUE,
+ "expand", "homogeneous", NULL);
}
static void
-glade_gtk_menu_shell_tool_item_child_selected (GladeBaseEditor *editor,
- GladeWidget *gchild,
- gpointer data)
-{
- GObject *child = glade_widget_get_object (gchild);
- GType type = G_OBJECT_TYPE (child);
-
- if (GTK_IS_TOOL_ITEM (child))
- {
- glade_gtk_toolbar_child_selected (editor, gchild, data);
- return;
- }
- glade_base_editor_add_label (editor, _("Menu Item"));
-
- glade_base_editor_add_default_properties (editor, gchild);
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (child)) return;
-
- glade_base_editor_add_label (editor, _("Properties"));
-
- if (type != GTK_TYPE_IMAGE_MENU_ITEM)
- glade_base_editor_add_properties (editor, gchild, FALSE, "label", "tooltip", NULL);
-
- if (type == GTK_TYPE_IMAGE_MENU_ITEM)
- glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
- else if (type == GTK_TYPE_CHECK_MENU_ITEM)
- glade_base_editor_add_properties (editor, gchild, FALSE,
- "active", "draw-as-radio",
- "inconsistent", NULL);
- else if (type == GTK_TYPE_RADIO_MENU_ITEM)
- glade_base_editor_add_properties (editor, gchild, FALSE,
- "active", "group", NULL);
+glade_gtk_menu_shell_tool_item_child_selected (GladeBaseEditor * editor,
+ GladeWidget * gchild,
+ gpointer data)
+{
+ GObject *child = glade_widget_get_object (gchild);
+ GType type = G_OBJECT_TYPE (child);
+
+ if (GTK_IS_TOOL_ITEM (child))
+ {
+ glade_gtk_toolbar_child_selected (editor, gchild, data);
+ return;
+ }
+ glade_base_editor_add_label (editor, _("Menu Item"));
+
+ glade_base_editor_add_default_properties (editor, gchild);
+
+ if (GTK_IS_SEPARATOR_MENU_ITEM (child))
+ return;
+
+ glade_base_editor_add_label (editor, _("Properties"));
+
+ if (type != GTK_TYPE_IMAGE_MENU_ITEM)
+ glade_base_editor_add_properties (editor, gchild, FALSE, "label", "tooltip",
+ NULL);
+
+ if (type == GTK_TYPE_IMAGE_MENU_ITEM)
+ glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
+ else if (type == GTK_TYPE_CHECK_MENU_ITEM)
+ glade_base_editor_add_properties (editor, gchild, FALSE,
+ "active", "draw-as-radio",
+ "inconsistent", NULL);
+ else if (type == GTK_TYPE_RADIO_MENU_ITEM)
+ glade_base_editor_add_properties (editor, gchild, FALSE,
+ "active", "group", NULL);
}
static void
-glade_gtk_menu_shell_launch_editor (GObject *object, gchar *title)
-{
- GladeBaseEditor *editor;
- GtkWidget *window;
-
- /* Editor */
- editor = glade_base_editor_new (object, NULL,
- _("Normal item"), GTK_TYPE_MENU_ITEM,
- _("Image item"), GTK_TYPE_IMAGE_MENU_ITEM,
- _("Check item"), GTK_TYPE_CHECK_MENU_ITEM,
- _("Radio item"), GTK_TYPE_RADIO_MENU_ITEM,
- _("Separator item"), GTK_TYPE_SEPARATOR_MENU_ITEM,
- NULL);
-
- glade_base_editor_append_types (editor, GTK_TYPE_MENU_ITEM,
- _("Normal item"), GTK_TYPE_MENU_ITEM,
- _("Image item"), GTK_TYPE_IMAGE_MENU_ITEM,
- _("Check item"), GTK_TYPE_CHECK_MENU_ITEM,
- _("Radio item"), GTK_TYPE_RADIO_MENU_ITEM,
- _("Separator item"), GTK_TYPE_SEPARATOR_MENU_ITEM,
- NULL);
-
- g_signal_connect (editor, "get-display-name", G_CALLBACK (glade_gtk_menu_shell_tool_item_get_display_name), NULL);
- g_signal_connect (editor, "child-selected", G_CALLBACK (glade_gtk_menu_shell_tool_item_child_selected), NULL);
- g_signal_connect (editor, "change-type", G_CALLBACK (glade_gtk_menu_shell_change_type), NULL);
- g_signal_connect (editor, "build-child", G_CALLBACK (glade_gtk_menu_shell_build_child), NULL);
- g_signal_connect (editor, "delete-child", G_CALLBACK (glade_gtk_menu_shell_delete_child), NULL);
- g_signal_connect (editor, "move-child", G_CALLBACK (glade_gtk_menu_shell_move_child), NULL);
-
- gtk_widget_show (GTK_WIDGET (editor));
-
- window = glade_base_editor_pack_new_window (editor, title, NULL);
- gtk_widget_show (window);
-}
-
-void
-glade_gtk_menu_shell_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
-{
- if (strcmp (action_path, "launch_editor") == 0)
- {
- if (GTK_IS_MENU_BAR (object))
- glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
- else if (GTK_IS_MENU (object))
- glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
- object,
- action_path);
-
- gtk_menu_shell_deactivate (GTK_MENU_SHELL (object));
+glade_gtk_menu_shell_launch_editor (GObject * object, gchar * title)
+{
+ GladeBaseEditor *editor;
+ GtkWidget *window;
+
+ /* Editor */
+ editor = glade_base_editor_new (object, NULL,
+ _("Normal item"), GTK_TYPE_MENU_ITEM,
+ _("Image item"), GTK_TYPE_IMAGE_MENU_ITEM,
+ _("Check item"), GTK_TYPE_CHECK_MENU_ITEM,
+ _("Radio item"), GTK_TYPE_RADIO_MENU_ITEM,
+ _("Separator item"),
+ GTK_TYPE_SEPARATOR_MENU_ITEM, NULL);
+
+ glade_base_editor_append_types (editor, GTK_TYPE_MENU_ITEM,
+ _("Normal item"), GTK_TYPE_MENU_ITEM,
+ _("Image item"), GTK_TYPE_IMAGE_MENU_ITEM,
+ _("Check item"), GTK_TYPE_CHECK_MENU_ITEM,
+ _("Radio item"), GTK_TYPE_RADIO_MENU_ITEM,
+ _("Separator item"),
+ GTK_TYPE_SEPARATOR_MENU_ITEM, NULL);
+
+ g_signal_connect (editor, "get-display-name",
+ G_CALLBACK
+ (glade_gtk_menu_shell_tool_item_get_display_name), NULL);
+ g_signal_connect (editor, "child-selected",
+ G_CALLBACK (glade_gtk_menu_shell_tool_item_child_selected),
+ NULL);
+ g_signal_connect (editor, "change-type",
+ G_CALLBACK (glade_gtk_menu_shell_change_type), NULL);
+ g_signal_connect (editor, "build-child",
+ G_CALLBACK (glade_gtk_menu_shell_build_child), NULL);
+ g_signal_connect (editor, "delete-child",
+ G_CALLBACK (glade_gtk_menu_shell_delete_child), NULL);
+ g_signal_connect (editor, "move-child",
+ G_CALLBACK (glade_gtk_menu_shell_move_child), NULL);
+
+ gtk_widget_show (GTK_WIDGET (editor));
+
+ window = glade_base_editor_pack_new_window (editor, title, NULL);
+ gtk_widget_show (window);
+}
+
+void
+glade_gtk_menu_shell_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
+{
+ if (strcmp (action_path, "launch_editor") == 0)
+ {
+ if (GTK_IS_MENU_BAR (object))
+ glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
+ else if (GTK_IS_MENU (object))
+ glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
+ object, action_path);
+
+ gtk_menu_shell_deactivate (GTK_MENU_SHELL (object));
}
/* ----------------------------- GtkMenuItem ------------------------------ */
/* ... shared with toolitems ... */
GladeEditable *
-glade_gtk_activatable_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_activatable_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable =
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_activatable_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_activatable_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
void
-glade_gtk_menu_item_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
+glade_gtk_menu_item_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
{
- GObject *obj = NULL, *shell = NULL;
- GladeWidget *w = glade_widget_get_from_gobject (object);
-
- while ((w = glade_widget_get_parent (w)))
- {
- obj = glade_widget_get_object (w);
- if (GTK_IS_MENU_SHELL (obj)) shell = obj;
- }
+ GObject *obj = NULL, *shell = NULL;
+ GladeWidget *w = glade_widget_get_from_gobject (object);
+
+ while ((w = glade_widget_get_parent (w)))
+ {
+ obj = glade_widget_get_object (w);
+ if (GTK_IS_MENU_SHELL (obj))
+ shell = obj;
+ }
- if (strcmp (action_path, "launch_editor") == 0)
- {
- if (shell)
- object = shell;
+ if (strcmp (action_path, "launch_editor") == 0)
+ {
+ if (shell)
+ object = shell;
- if (GTK_IS_MENU_BAR (object))
- glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
- else if (GTK_IS_MENU (object))
- glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
- object,
- action_path);
+ if (GTK_IS_MENU_BAR (object))
+ glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar"));
+ else if (GTK_IS_MENU (object))
+ glade_gtk_menu_shell_launch_editor (object, _("Edit Menu"));
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
+ object, action_path);
- if (shell)
- gtk_menu_shell_deactivate (GTK_MENU_SHELL (shell));
+ if (shell)
+ gtk_menu_shell_deactivate (GTK_MENU_SHELL (shell));
}
GObject *
-glade_gtk_menu_item_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+glade_gtk_menu_item_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
{
- GladeWidgetAdaptor *adaptor;
- GObject *ret_obj;
+ GladeWidgetAdaptor *adaptor;
+ GObject *ret_obj;
- ret_obj = GWA_GET_OCLASS(GTK_TYPE_CONTAINER)->constructor
- (type, n_construct_properties, construct_properties);
+ ret_obj = GWA_GET_OCLASS (GTK_TYPE_CONTAINER)->constructor
+ (type, n_construct_properties, construct_properties);
- adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
+ adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
- glade_widget_adaptor_action_remove (adaptor, "add_parent");
- glade_widget_adaptor_action_remove (adaptor, "remove_parent");
+ glade_widget_adaptor_action_remove (adaptor, "add_parent");
+ glade_widget_adaptor_action_remove (adaptor, "remove_parent");
- return ret_obj;
+ return ret_obj;
}
void
-glade_gtk_menu_item_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_menu_item_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *gitem;
+ GladeWidget *gitem;
+
+ gitem = glade_widget_get_from_gobject (object);
- gitem = glade_widget_get_from_gobject (object);
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (object)) return;
-
- if (gtk_bin_get_child (GTK_BIN (object)) == NULL)
- {
- GtkWidget *label = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_container_add (GTK_CONTAINER (object), label);
- }
+ if (GTK_IS_SEPARATOR_MENU_ITEM (object))
+ return;
+
+ if (gtk_bin_get_child (GTK_BIN (object)) == NULL)
+ {
+ GtkWidget *label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_container_add (GTK_CONTAINER (object), label);
+ }
}
GList *
-glade_gtk_menu_item_get_children (GladeWidgetAdaptor *adaptor,
- GObject *object)
+glade_gtk_menu_item_get_children (GladeWidgetAdaptor * adaptor,
+ GObject * object)
{
- GList *list = NULL;
- GtkWidget *child;
-
- g_return_val_if_fail (GTK_IS_MENU_ITEM (object), NULL);
-
- if ((child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object))))
- list = g_list_append (list, child);
+ GList *list = NULL;
+ GtkWidget *child;
+
+ g_return_val_if_fail (GTK_IS_MENU_ITEM (object), NULL);
- return list;
+ if ((child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object))))
+ list = g_list_append (list, child);
+
+ return list;
}
void
-glade_gtk_menu_item_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object, GObject *child)
+glade_gtk_menu_item_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_MENU_ITEM (object));
- g_return_if_fail (GTK_IS_MENU (child));
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (object))
- {
- g_warning ("You shouldn't try to add a GtkMenu to a GtkSeparatorMenuItem");
- return;
- }
-
- g_object_set_data (child,
- "special-child-type",
- "submenu");
+ g_return_if_fail (GTK_IS_MENU_ITEM (object));
+ g_return_if_fail (GTK_IS_MENU (child));
+
+ if (GTK_IS_SEPARATOR_MENU_ITEM (object))
+ {
+ g_warning
+ ("You shouldn't try to add a GtkMenu to a GtkSeparatorMenuItem");
+ return;
+ }
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (object), GTK_WIDGET (child));
+ g_object_set_data (child, "special-child-type", "submenu");
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (object), GTK_WIDGET (child));
}
void
-glade_gtk_menu_item_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object, GObject *child)
+glade_gtk_menu_item_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_MENU_ITEM (object));
- g_return_if_fail (GTK_IS_MENU (child));
-
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (object), NULL);
+ g_return_if_fail (GTK_IS_MENU_ITEM (object));
+ g_return_if_fail (GTK_IS_MENU (child));
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (object), NULL);
}
static void
-glade_gtk_menu_item_set_label (GObject *object, const GValue *value)
+glade_gtk_menu_item_set_label (GObject * object, const GValue * value)
{
- GladeWidget *gitem;
- GtkWidget *label;
- gboolean use_underline;
+ GladeWidget *gitem;
+ GtkWidget *label;
+ gboolean use_underline;
- gitem = glade_widget_get_from_gobject (object);
+ gitem = glade_widget_get_from_gobject (object);
- label = gtk_bin_get_child (GTK_BIN (object));
- gtk_label_set_text (GTK_LABEL (label), g_value_get_string (value));
+ label = gtk_bin_get_child (GTK_BIN (object));
+ gtk_label_set_text (GTK_LABEL (label), g_value_get_string (value));
- /* Update underline incase... */
- glade_widget_property_get (gitem, "use-underline", &use_underline);
- gtk_label_set_use_underline (GTK_LABEL (label), use_underline);
+ /* Update underline incase... */
+ glade_widget_property_get (gitem, "use-underline", &use_underline);
+ gtk_label_set_use_underline (GTK_LABEL (label), use_underline);
}
static void
-glade_gtk_menu_item_set_use_underline (GObject *object, const GValue *value)
+glade_gtk_menu_item_set_use_underline (GObject * object, const GValue * value)
{
- GtkWidget *label;
+ GtkWidget *label;
- label = gtk_bin_get_child (GTK_BIN (object));
- gtk_label_set_use_underline (GTK_LABEL (label), g_value_get_boolean (value));
+ label = gtk_bin_get_child (GTK_BIN (object));
+ gtk_label_set_use_underline (GTK_LABEL (label), g_value_get_boolean (value));
}
void
-glade_gtk_menu_item_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_menu_item_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GladeProperty *property = glade_widget_get_property (gwidget, id);
-
- evaluate_activatable_property_sensitivity (object, id, value);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GladeProperty *property = glade_widget_get_property (gwidget, id);
+
+ evaluate_activatable_property_sensitivity (object, id, value);
- if (!strcmp (id, "use-underline"))
- glade_gtk_menu_item_set_use_underline (object, value);
- else if (!strcmp (id, "label"))
- glade_gtk_menu_item_set_label (object, value);
- else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
- id, value);
+ if (!strcmp (id, "use-underline"))
+ glade_gtk_menu_item_set_use_underline (object, value);
+ else if (!strcmp (id, "label"))
+ glade_gtk_menu_item_set_label (object, value);
+ else if (GPC_VERSION_CHECK
+ (property->klass, gtk_major_version, gtk_minor_version + 1))
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
+ value);
}
/* ----------------------------- GtkImageMenuItem ------------------------------ */
GList *
-glade_gtk_image_menu_item_get_children (GladeWidgetAdaptor *adaptor,
- GObject *object)
+glade_gtk_image_menu_item_get_children (GladeWidgetAdaptor * adaptor,
+ GObject * object)
{
- GList *list = NULL;
- GtkWidget *child;
- GladeWidget *gitem;
-
- gitem = glade_widget_get_from_gobject (object);
-
- if ((child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object))))
- list = g_list_append (list, child);
-
- return list;
+ GList *list = NULL;
+ GtkWidget *child;
+ GladeWidget *gitem;
+
+ gitem = glade_widget_get_from_gobject (object);
+
+ if ((child = gtk_menu_item_get_submenu (GTK_MENU_ITEM (object))))
+ list = g_list_append (list, child);
+
+ return list;
}
void
-glade_gtk_image_menu_item_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object, GObject *child)
+glade_gtk_image_menu_item_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_MENU_ITEM (object));
+ g_return_if_fail (GTK_IS_MENU_ITEM (object));
- if (GTK_IS_IMAGE (child))
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), GTK_WIDGET (child));
- else
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->add (adaptor, object, child);
+ if (GTK_IS_IMAGE (child))
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object),
+ GTK_WIDGET (child));
+ else
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->add (adaptor, object, child);
}
void
-glade_gtk_image_menu_item_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object, GObject *child)
+glade_gtk_image_menu_item_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- g_return_if_fail (GTK_IS_MENU_ITEM (object));
-
- if (GTK_IS_IMAGE (child))
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), NULL);
- else
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->remove (adaptor, object, child);
+ g_return_if_fail (GTK_IS_MENU_ITEM (object));
+
+ if (GTK_IS_IMAGE (child))
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), NULL);
+ else
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->remove (adaptor, object, child);
}
static void
-glade_gtk_image_menu_item_set_use_stock (GObject *object, const GValue *value)
+glade_gtk_image_menu_item_set_use_stock (GObject * object, const GValue * value)
{
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- gboolean use_stock;
-
- use_stock = g_value_get_boolean (value);
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ gboolean use_stock;
- /* Set some things */
- if (use_stock)
- {
- glade_widget_property_set_sensitive (widget, "stock", TRUE, NULL);
- glade_widget_property_set_sensitive (widget, "accel-group", TRUE, NULL);
- }
- else
- {
- glade_widget_property_set_sensitive (widget, "stock", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (widget, "accel-group", FALSE, NOT_SELECTED_MSG);
- }
+ use_stock = g_value_get_boolean (value);
- gtk_image_menu_item_set_use_stock (GTK_IMAGE_MENU_ITEM (object), use_stock);
+ /* Set some things */
+ if (use_stock)
+ {
+ glade_widget_property_set_sensitive (widget, "stock", TRUE, NULL);
+ glade_widget_property_set_sensitive (widget, "accel-group", TRUE, NULL);
+ }
+ else
+ {
+ glade_widget_property_set_sensitive (widget, "stock", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (widget, "accel-group", FALSE,
+ NOT_SELECTED_MSG);
+ }
- sync_use_appearance (widget);
+ gtk_image_menu_item_set_use_stock (GTK_IMAGE_MENU_ITEM (object), use_stock);
+
+ sync_use_appearance (widget);
}
static gboolean
-glade_gtk_image_menu_item_set_label (GObject *object, const GValue *value)
+glade_gtk_image_menu_item_set_label (GObject * object, const GValue * value)
{
- GladeWidget *gitem;
- GtkWidget *label;
- gboolean use_underline = FALSE, use_stock = FALSE;
- const gchar *text;
+ GladeWidget *gitem;
+ GtkWidget *label;
+ gboolean use_underline = FALSE, use_stock = FALSE;
+ const gchar *text;
+
+ gitem = glade_widget_get_from_gobject (object);
+ label = gtk_bin_get_child (GTK_BIN (object));
- gitem = glade_widget_get_from_gobject (object);
- label = gtk_bin_get_child (GTK_BIN (object));
+ glade_widget_property_get (gitem, "use-stock", &use_stock);
+ glade_widget_property_get (gitem, "use-underline", &use_underline);
+ text = g_value_get_string (value);
- glade_widget_property_get (gitem, "use-stock", &use_stock);
- glade_widget_property_get (gitem, "use-underline", &use_underline);
- text = g_value_get_string (value);
+ /* In "use-stock" mode we dont have a GladeWidget child image */
+ if (use_stock)
+ {
+ GtkWidget *image;
+ GtkStockItem item;
- /* In "use-stock" mode we dont have a GladeWidget child image */
- if (use_stock)
- {
- GtkWidget *image;
- GtkStockItem item;
+ image =
+ gtk_image_new_from_stock (g_value_get_string (value),
+ GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), image);
- image = gtk_image_new_from_stock (g_value_get_string (value), GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), image);
+ if (use_underline)
+ gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
- if (use_underline)
- gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+ /* Get the label string... */
+ if (text && gtk_stock_lookup (text, &item))
+ gtk_label_set_label (GTK_LABEL (label), item.label);
+ else
+ gtk_label_set_label (GTK_LABEL (label), text ? text : "");
- /* Get the label string... */
- if (text && gtk_stock_lookup (text, &item))
- gtk_label_set_label (GTK_LABEL (label), item.label);
- else
- gtk_label_set_label (GTK_LABEL (label), text ? text : "");
+ return TRUE;
+ }
- return TRUE;
- }
-
- return FALSE;
+ return FALSE;
}
static void
-glade_gtk_image_menu_item_set_stock (GObject *object, const GValue *value)
+glade_gtk_image_menu_item_set_stock (GObject * object, const GValue * value)
{
- GladeWidget *gitem;
- gboolean use_stock = FALSE;
+ GladeWidget *gitem;
+ gboolean use_stock = FALSE;
- gitem = glade_widget_get_from_gobject (object);
+ gitem = glade_widget_get_from_gobject (object);
- glade_widget_property_get (gitem, "use-stock", &use_stock);
+ glade_widget_property_get (gitem, "use-stock", &use_stock);
- /* Forward the work along to the label handler... */
- if (use_stock)
- glade_gtk_image_menu_item_set_label (object, value);
+ /* Forward the work along to the label handler... */
+ if (use_stock)
+ glade_gtk_image_menu_item_set_label (object, value);
}
void
-glade_gtk_image_menu_item_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_image_menu_item_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "stock"))
- glade_gtk_image_menu_item_set_stock (object, value);
- else if (!strcmp (id, "use-stock"))
- glade_gtk_image_menu_item_set_use_stock (object, value);
- else if (!strcmp (id, "label"))
- {
- if (!glade_gtk_image_menu_item_set_label (object, value))
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
- id, value);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
- id, value);
+ if (!strcmp (id, "stock"))
+ glade_gtk_image_menu_item_set_stock (object, value);
+ else if (!strcmp (id, "use-stock"))
+ glade_gtk_image_menu_item_set_use_stock (object, value);
+ else if (!strcmp (id, "label"))
+ {
+ if (!glade_gtk_image_menu_item_set_label (object, value))
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
+ id, value);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
+ id, value);
}
static void
-glade_gtk_image_menu_item_parse_finished (GladeProject *project,
- GladeWidget *widget)
+glade_gtk_image_menu_item_parse_finished (GladeProject * project,
+ GladeWidget * widget)
{
- GladeWidget *gimage;
- GtkWidget *image = NULL;
- glade_widget_property_get (widget, "image", &image);
-
- if (image && (gimage = glade_widget_get_from_gobject (image)))
- glade_widget_lock (widget, gimage);
+ GladeWidget *gimage;
+ GtkWidget *image = NULL;
+ glade_widget_property_get (widget, "image", &image);
+
+ if (image && (gimage = glade_widget_get_from_gobject (image)))
+ glade_widget_lock (widget, gimage);
}
void
-glade_gtk_image_menu_item_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_image_menu_item_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlNode * node)
{
- GladeProperty *property;
- gboolean use_stock;
- gchar *label = NULL;
+ GladeProperty *property;
+ gboolean use_stock;
+ gchar *label = NULL;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->read_widget (adaptor, widget, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->read_widget (adaptor, widget, node);
- glade_widget_property_get (widget, "use-stock", &use_stock);
- if (use_stock)
- {
- property = glade_widget_get_property (widget, "label");
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+ if (use_stock)
+ {
+ property = glade_widget_get_property (widget, "label");
- glade_property_get (property, &label);
- glade_widget_property_set (widget, "use-underline", TRUE);
- glade_widget_property_set (widget, "stock", label);
- glade_property_sync (property);
- }
+ glade_property_get (property, &label);
+ glade_widget_property_set (widget, "use-underline", TRUE);
+ glade_widget_property_set (widget, "stock", label);
+ glade_property_sync (property);
+ }
- /* Update sensitivity of related properties... */
- property = glade_widget_get_property (widget, "use-stock");
- glade_property_sync (property);
+ /* Update sensitivity of related properties... */
+ property = glade_widget_get_property (widget, "use-stock");
+ glade_property_sync (property);
- /* Run this after the load so that image is resolved. */
- g_signal_connect (G_OBJECT (widget->project), "parse-finished",
- G_CALLBACK (glade_gtk_image_menu_item_parse_finished),
- widget);
+ /* Run this after the load so that image is resolved. */
+ g_signal_connect (G_OBJECT (widget->project), "parse-finished",
+ G_CALLBACK (glade_gtk_image_menu_item_parse_finished),
+ widget);
}
void
-glade_gtk_image_menu_item_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_image_menu_item_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeProperty *label_prop;
- gboolean use_stock;
- gchar *stock;
+ GladeProperty *label_prop;
+ gboolean use_stock;
+ gchar *stock;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* Make a copy of the GladeProperty, override its value if use-stock is TRUE */
- label_prop = glade_widget_get_property (widget, "label");
- label_prop = glade_property_dup (label_prop, widget);
- glade_widget_property_get (widget, "use-stock", &use_stock);
- if (use_stock)
- {
- glade_widget_property_get (widget, "stock", &stock);
- glade_property_set (label_prop, stock);
- glade_property_i18n_set_translatable (label_prop, FALSE);
- }
- glade_property_write (label_prop, context, node);
- g_object_unref (G_OBJECT (label_prop));
+ /* Make a copy of the GladeProperty, override its value if use-stock is TRUE */
+ label_prop = glade_widget_get_property (widget, "label");
+ label_prop = glade_property_dup (label_prop, widget);
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+ if (use_stock)
+ {
+ glade_widget_property_get (widget, "stock", &stock);
+ glade_property_set (label_prop, stock);
+ glade_property_i18n_set_translatable (label_prop, FALSE);
+ }
+ glade_property_write (label_prop, context, node);
+ g_object_unref (G_OBJECT (label_prop));
- /* Chain up and write all the normal properties ... */
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->write_widget (adaptor, widget, context, node);
+ /* Chain up and write all the normal properties ... */
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->write_widget (adaptor, widget, context,
+ node);
}
@@ -6864,1453 +6815,1503 @@ glade_gtk_image_menu_item_write_widget (GladeWidgetAdaptor *adaptor,
*/
GladeEditable *
-glade_gtk_image_menu_item_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_image_menu_item_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable =
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_image_item_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_image_item_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
/* ----------------------------- GtkRadioMenuItem ------------------------------ */
static void
-glade_gtk_radio_menu_item_set_group (GObject *object, const GValue *value)
+glade_gtk_radio_menu_item_set_group (GObject * object, const GValue * value)
{
- GObject *val;
-
- g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (object));
-
- if ((val = g_value_get_object (value)))
- {
- GSList *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (val));
-
- if (! g_slist_find (group, GTK_RADIO_MENU_ITEM (object)))
- gtk_radio_menu_item_set_group (GTK_RADIO_MENU_ITEM (object), group);
- }
+ GObject *val;
+
+ g_return_if_fail (GTK_IS_RADIO_MENU_ITEM (object));
+
+ if ((val = g_value_get_object (value)))
+ {
+ GSList *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (val));
+
+ if (!g_slist_find (group, GTK_RADIO_MENU_ITEM (object)))
+ gtk_radio_menu_item_set_group (GTK_RADIO_MENU_ITEM (object), group);
+ }
}
void
-glade_gtk_radio_menu_item_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_radio_menu_item_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "group"))
- glade_gtk_radio_menu_item_set_group (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
- id, value);
+ if (!strcmp (id, "group"))
+ glade_gtk_radio_menu_item_set_group (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
+ id, value);
}
/* ----------------------------- GtkMenuBar ------------------------------ */
-static GladeWidget *
-glade_gtk_menu_bar_append_new_submenu (GladeWidget *parent, GladeProject *project)
-{
- static GladeWidgetAdaptor *submenu_adaptor = NULL;
- GladeWidget *gsubmenu;
-
- if (submenu_adaptor == NULL)
- submenu_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU);
-
- gsubmenu = glade_widget_adaptor_create_widget (submenu_adaptor, FALSE,
- "parent", parent,
- "project", project,
- NULL);
-
- glade_widget_add_child (parent, gsubmenu, FALSE);
-
- return gsubmenu;
-}
-
-static GladeWidget *
-glade_gtk_menu_bar_append_new_item (GladeWidget *parent,
- GladeProject *project,
- const gchar *label,
- gboolean use_stock)
-{
- static GladeWidgetAdaptor *item_adaptor = NULL, *image_item_adaptor, *separator_adaptor;
- GladeWidget *gitem;
-
- if (item_adaptor == NULL)
- {
- item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_ITEM);
- image_item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM);
- separator_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SEPARATOR_MENU_ITEM);
- }
-
- if (label)
- {
- gitem = glade_widget_adaptor_create_widget ((use_stock) ? image_item_adaptor : item_adaptor,
- FALSE, "parent", parent,
- "project", project,
- NULL);
-
- glade_widget_property_set (gitem, "use-underline", TRUE);
-
- if (use_stock)
- {
- glade_widget_property_set (gitem, "use-stock", TRUE);
- glade_widget_property_set (gitem, "stock", label);
- }
- else
- glade_widget_property_set (gitem, "label", label);
- }
- else
- {
- gitem = glade_widget_adaptor_create_widget (separator_adaptor,
- FALSE, "parent", parent,
- "project", project,
- NULL);
- }
-
- glade_widget_add_child (parent, gitem, FALSE);
-
- return gitem;
-}
-
-void
-glade_gtk_menu_bar_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GladeProject *project;
- GladeWidget *gmenubar, *gitem, *gsubmenu;
-
- g_return_if_fail (GTK_IS_MENU_BAR (object));
- gmenubar = glade_widget_get_from_gobject (object);
- g_return_if_fail (GLADE_IS_WIDGET (gmenubar));
-
- if (reason != GLADE_CREATE_USER) return;
-
- project = glade_widget_get_project (gmenubar);
-
- /* File */
- gitem = glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_File"), FALSE);
- gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-new", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-open", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save-as", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, NULL, FALSE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-quit", TRUE);
-
- /* Edit */
- gitem = glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Edit"), FALSE);
- gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-cut", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-copy", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-paste", TRUE);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-delete", TRUE);
-
- /* View */
- gitem = glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_View"), FALSE);
-
- /* Help */
- gitem = glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Help"), FALSE);
- gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
- glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-about", TRUE);
+static GladeWidget *
+glade_gtk_menu_bar_append_new_submenu (GladeWidget * parent,
+ GladeProject * project)
+{
+ static GladeWidgetAdaptor *submenu_adaptor = NULL;
+ GladeWidget *gsubmenu;
+
+ if (submenu_adaptor == NULL)
+ submenu_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU);
+
+ gsubmenu = glade_widget_adaptor_create_widget (submenu_adaptor, FALSE,
+ "parent", parent,
+ "project", project, NULL);
+
+ glade_widget_add_child (parent, gsubmenu, FALSE);
+
+ return gsubmenu;
+}
+
+static GladeWidget *
+glade_gtk_menu_bar_append_new_item (GladeWidget * parent,
+ GladeProject * project,
+ const gchar * label, gboolean use_stock)
+{
+ static GladeWidgetAdaptor *item_adaptor =
+ NULL, *image_item_adaptor, *separator_adaptor;
+ GladeWidget *gitem;
+
+ if (item_adaptor == NULL)
+ {
+ item_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU_ITEM);
+ image_item_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM);
+ separator_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_SEPARATOR_MENU_ITEM);
+ }
+
+ if (label)
+ {
+ gitem =
+ glade_widget_adaptor_create_widget ((use_stock) ? image_item_adaptor :
+ item_adaptor, FALSE, "parent",
+ parent, "project", project, NULL);
+
+ glade_widget_property_set (gitem, "use-underline", TRUE);
+
+ if (use_stock)
+ {
+ glade_widget_property_set (gitem, "use-stock", TRUE);
+ glade_widget_property_set (gitem, "stock", label);
+ }
+ else
+ glade_widget_property_set (gitem, "label", label);
+ }
+ else
+ {
+ gitem = glade_widget_adaptor_create_widget (separator_adaptor,
+ FALSE, "parent", parent,
+ "project", project, NULL);
+ }
+
+ glade_widget_add_child (parent, gitem, FALSE);
+
+ return gitem;
+}
+
+void
+glade_gtk_menu_bar_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
+{
+ GladeProject *project;
+ GladeWidget *gmenubar, *gitem, *gsubmenu;
+
+ g_return_if_fail (GTK_IS_MENU_BAR (object));
+ gmenubar = glade_widget_get_from_gobject (object);
+ g_return_if_fail (GLADE_IS_WIDGET (gmenubar));
+
+ if (reason != GLADE_CREATE_USER)
+ return;
+
+ project = glade_widget_get_project (gmenubar);
+
+ /* File */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_File"), FALSE);
+ gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-new", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-open", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-save-as", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, NULL, FALSE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-quit", TRUE);
+
+ /* Edit */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Edit"), FALSE);
+ gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-cut", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-copy", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-paste", TRUE);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-delete", TRUE);
+
+ /* View */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_View"), FALSE);
+
+ /* Help */
+ gitem =
+ glade_gtk_menu_bar_append_new_item (gmenubar, project, _("_Help"), FALSE);
+ gsubmenu = glade_gtk_menu_bar_append_new_submenu (gitem, project);
+ glade_gtk_menu_bar_append_new_item (gsubmenu, project, "gtk-about", TRUE);
}
/* ----------------------------- GtkToolBar ------------------------------ */
/* need to unset/reset toolbar style when property is disabled/enabled */
static void
-property_toolbar_style_notify_enabled (GladeProperty *property,
- GParamSpec *spec,
- GtkToolbar *toolbar)
-{
- GtkToolbarStyle style;
-
- if (glade_property_get_enabled (property))
- {
- glade_property_get (property, &style);
- gtk_toolbar_set_style (toolbar, style);
- }
- else
- gtk_toolbar_unset_style (toolbar);
-}
-
-void
-glade_gtk_toolbar_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GladeWidget *widget;
- GladeProperty *toolbar_style_property;
-
- widget = glade_widget_get_from_gobject (object);
- toolbar_style_property = glade_widget_get_property (widget, "toolbar-style");
-
- g_signal_connect (toolbar_style_property, "notify::enabled",
- G_CALLBACK (property_toolbar_style_notify_enabled),
- object);
-}
-
-void
-glade_gtk_toolbar_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- g_return_if_fail (GTK_IS_TOOLBAR (container));
- if (GTK_IS_TOOL_ITEM (child) == FALSE) return;
-
- if (strcmp (property_name, "position") == 0)
- {
- g_value_set_int (value,
- gtk_toolbar_get_item_index (GTK_TOOLBAR (container),
- GTK_TOOL_ITEM (child)));
- }
- else
- { /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container, child,
- property_name, value);
- }
-}
-
-void
-glade_gtk_toolbar_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- g_return_if_fail (GTK_IS_TOOLBAR (container));
- g_return_if_fail (GTK_IS_TOOL_ITEM (child));
-
- g_return_if_fail (property_name != NULL || value != NULL);
-
- if (strcmp (property_name, "position") == 0)
- {
- GtkToolbar *toolbar = GTK_TOOLBAR (container);
- gint position, size;
-
- position = g_value_get_int (value);
- size = gtk_toolbar_get_n_items (toolbar);
-
- if (position >= size) position = size - 1;
-
- g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
- gtk_toolbar_insert (toolbar, GTK_TOOL_ITEM (child), position);
- g_object_unref (child);
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
-}
-
-void
-glade_gtk_toolbar_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object, GObject *child)
-{
- GtkToolbar *toolbar;
- GtkToolItem *item;
-
- g_return_if_fail (GTK_IS_TOOLBAR (object));
- g_return_if_fail (GTK_IS_TOOL_ITEM (child));
-
- toolbar = GTK_TOOLBAR (object);
- item = GTK_TOOL_ITEM (child);
-
- gtk_toolbar_insert (toolbar, item, -1);
-
- if (glade_util_object_is_loading (object))
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
-
- /* Packing props arent around when parenting during a glade_widget_dup() */
- if (gchild && gchild->packing_properties)
- glade_widget_pack_property_set (gchild, "position",
- gtk_toolbar_get_item_index (toolbar, item));
- }
-}
-
-void
-glade_gtk_toolbar_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object, GObject *child)
-{
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+property_toolbar_style_notify_enabled (GladeProperty * property,
+ GParamSpec * spec, GtkToolbar * toolbar)
+{
+ GtkToolbarStyle style;
+
+ if (glade_property_get_enabled (property))
+ {
+ glade_property_get (property, &style);
+ gtk_toolbar_set_style (toolbar, style);
+ }
+ else
+ gtk_toolbar_unset_style (toolbar);
+}
+
+void
+glade_gtk_toolbar_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
+{
+ GladeWidget *widget;
+ GladeProperty *toolbar_style_property;
+
+ widget = glade_widget_get_from_gobject (object);
+ toolbar_style_property = glade_widget_get_property (widget, "toolbar-style");
+
+ g_signal_connect (toolbar_style_property, "notify::enabled",
+ G_CALLBACK (property_toolbar_style_notify_enabled), object);
+}
+
+void
+glade_gtk_toolbar_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GTK_IS_TOOLBAR (container));
+ if (GTK_IS_TOOL_ITEM (child) == FALSE)
+ return;
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ g_value_set_int (value,
+ gtk_toolbar_get_item_index (GTK_TOOLBAR (container),
+ GTK_TOOL_ITEM (child)));
+ }
+ else
+ { /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container, child,
+ property_name, value);
+ }
+}
+
+void
+glade_gtk_toolbar_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GTK_IS_TOOLBAR (container));
+ g_return_if_fail (GTK_IS_TOOL_ITEM (child));
+
+ g_return_if_fail (property_name != NULL || value != NULL);
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ GtkToolbar *toolbar = GTK_TOOLBAR (container);
+ gint position, size;
+
+ position = g_value_get_int (value);
+ size = gtk_toolbar_get_n_items (toolbar);
+
+ if (position >= size)
+ position = size - 1;
+
+ g_object_ref (child);
+ gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
+ gtk_toolbar_insert (toolbar, GTK_TOOL_ITEM (child), position);
+ g_object_unref (child);
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
+}
+
+void
+glade_gtk_toolbar_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GtkToolbar *toolbar;
+ GtkToolItem *item;
+
+ g_return_if_fail (GTK_IS_TOOLBAR (object));
+ g_return_if_fail (GTK_IS_TOOL_ITEM (child));
+
+ toolbar = GTK_TOOLBAR (object);
+ item = GTK_TOOL_ITEM (child);
+
+ gtk_toolbar_insert (toolbar, item, -1);
+
+ if (glade_util_object_is_loading (object))
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
+
+ /* Packing props arent around when parenting during a glade_widget_dup() */
+ if (gchild && gchild->packing_properties)
+ glade_widget_pack_property_set (gchild, "position",
+ gtk_toolbar_get_item_index (toolbar,
+ item));
+ }
+}
+
+void
+glade_gtk_toolbar_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
}
static void
-glade_gtk_toolbar_launch_editor (GladeWidgetAdaptor *adaptor,
- GObject *toolbar)
-{
- GladeBaseEditor *editor;
- GtkWidget *window;
-
- /* Editor */
- editor = glade_base_editor_new (toolbar, NULL,
- _("Button"), GTK_TYPE_TOOL_BUTTON,
- _("Toggle"), GTK_TYPE_TOGGLE_TOOL_BUTTON,
- _("Radio"), GTK_TYPE_RADIO_TOOL_BUTTON,
- _("Menu"), GTK_TYPE_MENU_TOOL_BUTTON,
- _("Custom"), GTK_TYPE_TOOL_ITEM,
- _("Separator"), GTK_TYPE_SEPARATOR_TOOL_ITEM,
- NULL);
-
-
- glade_base_editor_append_types (editor, GTK_TYPE_MENU_TOOL_BUTTON,
- _("Normal"), GTK_TYPE_MENU_ITEM,
- _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
- _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
- _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
- _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
- NULL);
-
- glade_base_editor_append_types (editor, GTK_TYPE_MENU_ITEM,
- _("Normal"), GTK_TYPE_MENU_ITEM,
- _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
- _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
- _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
- _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
- NULL);
-
- g_signal_connect (editor, "get-display-name", G_CALLBACK (glade_gtk_menu_shell_tool_item_get_display_name), NULL);
- g_signal_connect (editor, "child-selected", G_CALLBACK (glade_gtk_menu_shell_tool_item_child_selected), NULL);
- g_signal_connect (editor, "change-type", G_CALLBACK (glade_gtk_menu_shell_change_type), NULL);
- g_signal_connect (editor, "build-child", G_CALLBACK (glade_gtk_menu_shell_build_child), NULL);
- g_signal_connect (editor, "delete-child", G_CALLBACK (glade_gtk_menu_shell_delete_child), NULL);
- g_signal_connect (editor, "move-child", G_CALLBACK (glade_gtk_menu_shell_move_child), NULL);
-
- gtk_widget_show (GTK_WIDGET (editor));
-
- window = glade_base_editor_pack_new_window (editor, _("Tool Bar Editor"), NULL);
- gtk_widget_show (window);
-}
-
-void
-glade_gtk_toolbar_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
-{
- if (strcmp (action_path, "launch_editor") == 0)
- {
- glade_gtk_toolbar_launch_editor (adaptor, object);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
- object,
- action_path);
+glade_gtk_toolbar_launch_editor (GladeWidgetAdaptor * adaptor,
+ GObject * toolbar)
+{
+ GladeBaseEditor *editor;
+ GtkWidget *window;
+
+ /* Editor */
+ editor = glade_base_editor_new (toolbar, NULL,
+ _("Button"), GTK_TYPE_TOOL_BUTTON,
+ _("Toggle"), GTK_TYPE_TOGGLE_TOOL_BUTTON,
+ _("Radio"), GTK_TYPE_RADIO_TOOL_BUTTON,
+ _("Menu"), GTK_TYPE_MENU_TOOL_BUTTON,
+ _("Custom"), GTK_TYPE_TOOL_ITEM,
+ _("Separator"), GTK_TYPE_SEPARATOR_TOOL_ITEM,
+ NULL);
+
+
+ glade_base_editor_append_types (editor, GTK_TYPE_MENU_TOOL_BUTTON,
+ _("Normal"), GTK_TYPE_MENU_ITEM,
+ _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
+ _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
+ _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
+ _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
+ NULL);
+
+ glade_base_editor_append_types (editor, GTK_TYPE_MENU_ITEM,
+ _("Normal"), GTK_TYPE_MENU_ITEM,
+ _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
+ _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
+ _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
+ _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
+ NULL);
+
+ g_signal_connect (editor, "get-display-name",
+ G_CALLBACK
+ (glade_gtk_menu_shell_tool_item_get_display_name), NULL);
+ g_signal_connect (editor, "child-selected",
+ G_CALLBACK (glade_gtk_menu_shell_tool_item_child_selected),
+ NULL);
+ g_signal_connect (editor, "change-type",
+ G_CALLBACK (glade_gtk_menu_shell_change_type), NULL);
+ g_signal_connect (editor, "build-child",
+ G_CALLBACK (glade_gtk_menu_shell_build_child), NULL);
+ g_signal_connect (editor, "delete-child",
+ G_CALLBACK (glade_gtk_menu_shell_delete_child), NULL);
+ g_signal_connect (editor, "move-child",
+ G_CALLBACK (glade_gtk_menu_shell_move_child), NULL);
+
+ gtk_widget_show (GTK_WIDGET (editor));
+
+ window =
+ glade_base_editor_pack_new_window (editor, _("Tool Bar Editor"), NULL);
+ gtk_widget_show (window);
+}
+
+void
+glade_gtk_toolbar_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * action_path)
+{
+ if (strcmp (action_path, "launch_editor") == 0)
+ {
+ glade_gtk_toolbar_launch_editor (adaptor, object);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
+ object, action_path);
}
/* ----------------------------- GtkToolItem ------------------------------ */
GObject *
-glade_gtk_tool_item_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_properties)
+glade_gtk_tool_item_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_properties)
{
- GladeWidgetAdaptor *adaptor;
- GObject *ret_obj;
-
- ret_obj = GWA_GET_OCLASS(GTK_TYPE_CONTAINER)->constructor
- (type, n_construct_properties, construct_properties);
+ GladeWidgetAdaptor *adaptor;
+ GObject *ret_obj;
+
+ ret_obj = GWA_GET_OCLASS (GTK_TYPE_CONTAINER)->constructor
+ (type, n_construct_properties, construct_properties);
- adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
+ adaptor = GLADE_WIDGET_ADAPTOR (ret_obj);
- glade_widget_adaptor_action_remove (adaptor, "add_parent");
- glade_widget_adaptor_action_remove (adaptor, "remove_parent");
+ glade_widget_adaptor_action_remove (adaptor, "add_parent");
+ glade_widget_adaptor_action_remove (adaptor, "remove_parent");
- return ret_obj;
+ return ret_obj;
}
void
-glade_gtk_tool_item_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_tool_item_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- g_return_if_fail (GTK_IS_TOOL_ITEM (object));
-
- if (GTK_IS_SEPARATOR_TOOL_ITEM (object)) return;
-
- if (reason == GLADE_CREATE_USER &&
- gtk_bin_get_child (GTK_BIN (object)) == NULL)
- gtk_container_add (GTK_CONTAINER (object),
- glade_placeholder_new ());
+ g_return_if_fail (GTK_IS_TOOL_ITEM (object));
+
+ if (GTK_IS_SEPARATOR_TOOL_ITEM (object))
+ return;
+
+ if (reason == GLADE_CREATE_USER &&
+ gtk_bin_get_child (GTK_BIN (object)) == NULL)
+ gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
}
void
-glade_gtk_tool_item_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_tool_item_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GladeProperty *property = glade_widget_get_property (gwidget, id);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GladeProperty *property = glade_widget_get_property (gwidget, id);
- //evaluate_activatable_property_sensitivity (object, id, value);
- if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
- object,
- id, value);
+ //evaluate_activatable_property_sensitivity (object, id, value);
+ if (GPC_VERSION_CHECK
+ (property->klass, gtk_major_version, gtk_minor_version + 1))
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id,
+ value);
}
/* ----------------------------- GtkToolButton ------------------------------ */
GladeEditable *
-glade_gtk_tool_button_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_tool_button_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable =
+ GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_tool_button_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_tool_button_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
static void
-glade_gtk_tool_button_set_image_mode (GObject *object, const GValue *value)
-{
- GladeWidget *gbutton;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
- gbutton = glade_widget_get_from_gobject (object);
-
- glade_widget_property_set_sensitive (gbutton, "stock-id", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "icon-name", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "icon-widget", FALSE, NOT_SELECTED_MSG);
-
- switch (g_value_get_int (value))
- {
- case GLADE_TB_MODE_STOCK:
- glade_widget_property_set_sensitive (gbutton, "stock-id", TRUE, NULL);
- break;
- case GLADE_TB_MODE_ICON:
- glade_widget_property_set_sensitive (gbutton, "icon-name", TRUE, NULL);
- break;
- case GLADE_TB_MODE_CUSTOM:
- glade_widget_property_set_sensitive (gbutton, "icon-widget", TRUE, NULL);
- break;
- default:
- break;
- }
+glade_gtk_tool_button_set_image_mode (GObject * object, const GValue * value)
+{
+ GladeWidget *gbutton;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+ gbutton = glade_widget_get_from_gobject (object);
+
+ glade_widget_property_set_sensitive (gbutton, "stock-id", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "icon-name", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "icon-widget", FALSE,
+ NOT_SELECTED_MSG);
+
+ switch (g_value_get_int (value))
+ {
+ case GLADE_TB_MODE_STOCK:
+ glade_widget_property_set_sensitive (gbutton, "stock-id", TRUE, NULL);
+ break;
+ case GLADE_TB_MODE_ICON:
+ glade_widget_property_set_sensitive (gbutton, "icon-name", TRUE, NULL);
+ break;
+ case GLADE_TB_MODE_CUSTOM:
+ glade_widget_property_set_sensitive (gbutton, "icon-widget", TRUE,
+ NULL);
+ break;
+ default:
+ break;
+ }
}
static void
-glade_gtk_tool_button_set_custom_label (GObject *object, const GValue *value)
+glade_gtk_tool_button_set_custom_label (GObject * object, const GValue * value)
{
- GladeWidget *gbutton;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
- gbutton = glade_widget_get_from_gobject (object);
+ GladeWidget *gbutton;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+ gbutton = glade_widget_get_from_gobject (object);
- glade_widget_property_set_sensitive (gbutton, "label", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "label-widget", FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "label", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "label-widget", FALSE,
+ NOT_SELECTED_MSG);
- if (g_value_get_boolean (value))
- glade_widget_property_set_sensitive (gbutton, "label-widget", TRUE, NULL);
- else
- glade_widget_property_set_sensitive (gbutton, "label", TRUE, NULL);
+ if (g_value_get_boolean (value))
+ glade_widget_property_set_sensitive (gbutton, "label-widget", TRUE, NULL);
+ else
+ glade_widget_property_set_sensitive (gbutton, "label", TRUE, NULL);
}
static void
-glade_gtk_tool_button_set_label (GObject *object, const GValue *value)
+glade_gtk_tool_button_set_label (GObject * object, const GValue * value)
{
- const gchar *label;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
-
- label = g_value_get_string (value);
-
- if (label && strlen (label) == 0) label = NULL;
-
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (object), label);
+ const gchar *label;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+
+ label = g_value_get_string (value);
+
+ if (label && strlen (label) == 0)
+ label = NULL;
+
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (object), label);
}
static void
-glade_gtk_tool_button_set_stock_id (GObject *object, const GValue *value)
+glade_gtk_tool_button_set_stock_id (GObject * object, const GValue * value)
{
- const gchar *stock_id;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
-
- stock_id = g_value_get_string (value);
-
- if (stock_id && strlen (stock_id) == 0) stock_id = NULL;
-
- gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id);
+ const gchar *stock_id;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+
+ stock_id = g_value_get_string (value);
+
+ if (stock_id && strlen (stock_id) == 0)
+ stock_id = NULL;
+
+ gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id);
}
static void
-glade_gtk_tool_button_set_icon_name (GObject *object, const GValue *value)
+glade_gtk_tool_button_set_icon_name (GObject * object, const GValue * value)
{
- const gchar *name;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+ const gchar *name;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
- name = g_value_get_string (value);
+ name = g_value_get_string (value);
- if (name && strlen (name) == 0) name = NULL;
-
- gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (object), name);
+ if (name && strlen (name) == 0)
+ name = NULL;
+
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (object), name);
}
void
-glade_gtk_tool_button_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_tool_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "image-mode"))
- glade_gtk_tool_button_set_image_mode (object, value);
- else if (!strcmp (id, "icon-name"))
- glade_gtk_tool_button_set_icon_name (object, value);
- else if (!strcmp (id, "stock-id"))
- glade_gtk_tool_button_set_stock_id (object, value);
- else if (!strcmp (id, "label"))
- glade_gtk_tool_button_set_label (object, value);
- else if (!strcmp (id, "custom-label"))
- glade_gtk_tool_button_set_custom_label (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->set_property (adaptor,
- object,
- id, value);
+ if (!strcmp (id, "image-mode"))
+ glade_gtk_tool_button_set_image_mode (object, value);
+ else if (!strcmp (id, "icon-name"))
+ glade_gtk_tool_button_set_icon_name (object, value);
+ else if (!strcmp (id, "stock-id"))
+ glade_gtk_tool_button_set_stock_id (object, value);
+ else if (!strcmp (id, "label"))
+ glade_gtk_tool_button_set_label (object, value);
+ else if (!strcmp (id, "custom-label"))
+ glade_gtk_tool_button_set_custom_label (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->set_property (adaptor,
+ object, id, value);
}
static void
-glade_gtk_tool_button_parse_finished (GladeProject *project,
- GladeWidget *widget)
-{
- gchar *stock_str = NULL, *icon_name = NULL;
- gint stock_id = 0;
- GtkWidget *label_widget = NULL, *image_widget = NULL;
-
- glade_widget_property_get (widget, "stock-id", &stock_str);
- glade_widget_property_get (widget, "icon-name", &icon_name);
- glade_widget_property_get (widget, "icon-widget", &image_widget);
- glade_widget_property_get (widget, "label-widget", &label_widget);
-
- if (label_widget)
- glade_widget_property_set (widget, "custom-label", TRUE);
- else
- glade_widget_property_set (widget, "custom-label", FALSE);
-
- if (image_widget)
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_CUSTOM);
- else if (icon_name)
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_ICON);
- else if (stock_str)
- {
- /* Update the stock property */
- stock_id = glade_utils_enum_value_from_string (GLADE_TYPE_STOCK_IMAGE, stock_str);
- if (stock_id < 0)
- stock_id = 0;
- glade_widget_property_set (widget, "glade-stock", stock_id);
-
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
- }
- else
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
-}
-
-void
-glade_gtk_tool_button_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node);
-
- /* Run this after the load so that icon-widget is resolved. */
- g_signal_connect (glade_widget_get_project (widget),
- "parse-finished",
- G_CALLBACK (glade_gtk_tool_button_parse_finished),
- widget);
+glade_gtk_tool_button_parse_finished (GladeProject * project,
+ GladeWidget * widget)
+{
+ gchar *stock_str = NULL, *icon_name = NULL;
+ gint stock_id = 0;
+ GtkWidget *label_widget = NULL, *image_widget = NULL;
+
+ glade_widget_property_get (widget, "stock-id", &stock_str);
+ glade_widget_property_get (widget, "icon-name", &icon_name);
+ glade_widget_property_get (widget, "icon-widget", &image_widget);
+ glade_widget_property_get (widget, "label-widget", &label_widget);
+
+ if (label_widget)
+ glade_widget_property_set (widget, "custom-label", TRUE);
+ else
+ glade_widget_property_set (widget, "custom-label", FALSE);
+
+ if (image_widget)
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_CUSTOM);
+ else if (icon_name)
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_ICON);
+ else if (stock_str)
+ {
+ /* Update the stock property */
+ stock_id =
+ glade_utils_enum_value_from_string (GLADE_TYPE_STOCK_IMAGE,
+ stock_str);
+ if (stock_id < 0)
+ stock_id = 0;
+ glade_widget_property_set (widget, "glade-stock", stock_id);
+
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
+ }
+ else
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
+}
+
+void
+glade_gtk_tool_button_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node);
+
+ /* Run this after the load so that icon-widget is resolved. */
+ g_signal_connect (glade_widget_get_project (widget),
+ "parse-finished",
+ G_CALLBACK (glade_gtk_tool_button_parse_finished), widget);
}
/* ----------------------------- GtkMenuToolButton ------------------------------ */
GList *
-glade_gtk_menu_tool_button_get_children (GladeWidgetAdaptor *adaptor, GtkMenuToolButton *button)
+glade_gtk_menu_tool_button_get_children (GladeWidgetAdaptor * adaptor,
+ GtkMenuToolButton * button)
{
- GList *list = NULL;
- GtkWidget *menu = gtk_menu_tool_button_get_menu (button);
+ GList *list = NULL;
+ GtkWidget *menu = gtk_menu_tool_button_get_menu (button);
- list = glade_util_container_get_all_children (GTK_CONTAINER (button));
+ list = glade_util_container_get_all_children (GTK_CONTAINER (button));
- /* Ensure that we only return one 'menu' */
- if (menu && g_list_find (list, menu) == NULL)
- list = g_list_append (list, menu);
+ /* Ensure that we only return one 'menu' */
+ if (menu && g_list_find (list, menu) == NULL)
+ list = g_list_append (list, menu);
- return list;
+ return list;
}
void
-glade_gtk_menu_tool_button_add_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_menu_tool_button_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- if (GTK_IS_MENU (child))
- {
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (object), GTK_WIDGET (child));
- }
- else
- GWA_GET_CLASS (GTK_TYPE_TOOL_BUTTON)->add (adaptor, object, child);
+ if (GTK_IS_MENU (child))
+ {
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (object),
+ GTK_WIDGET (child));
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_TOOL_BUTTON)->add (adaptor, object, child);
}
void
-glade_gtk_menu_tool_button_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GObject *child)
+glade_gtk_menu_tool_button_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
{
- if (GTK_IS_MENU (child))
- {
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (object), NULL);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_TOOL_BUTTON)->remove (adaptor, object, child);
+ if (GTK_IS_MENU (child))
+ {
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (object), NULL);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_TOOL_BUTTON)->remove (adaptor, object, child);
}
/* ----------------------------- GtkLabel ------------------------------ */
void
-glade_gtk_label_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_label_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *glabel = glade_widget_get_from_gobject (object);
+ GladeWidget *glabel = glade_widget_get_from_gobject (object);
- if (reason == GLADE_CREATE_USER)
- glade_widget_property_set_sensitive (glabel, "mnemonic-widget", FALSE, MNEMONIC_INSENSITIVE_MSG);
+ if (reason == GLADE_CREATE_USER)
+ glade_widget_property_set_sensitive (glabel, "mnemonic-widget", FALSE,
+ MNEMONIC_INSENSITIVE_MSG);
}
static void
-glade_gtk_label_set_label (GObject *object, const GValue *value)
+glade_gtk_label_set_label (GObject * object, const GValue * value)
{
- GladeWidget *glabel;
- gboolean use_markup = FALSE, use_underline = FALSE;
+ GladeWidget *glabel;
+ gboolean use_markup = FALSE, use_underline = FALSE;
+
+ glabel = glade_widget_get_from_gobject (object);
+ glade_widget_property_get (glabel, "use-markup", &use_markup);
+
+ if (use_markup)
+ gtk_label_set_markup (GTK_LABEL (object), g_value_get_string (value));
+ else
+ gtk_label_set_text (GTK_LABEL (object), g_value_get_string (value));
- glabel = glade_widget_get_from_gobject (object);
- glade_widget_property_get (glabel, "use-markup", &use_markup);
-
- if (use_markup)
- gtk_label_set_markup (GTK_LABEL (object), g_value_get_string (value));
- else
- gtk_label_set_text (GTK_LABEL (object), g_value_get_string (value));
-
- glade_widget_property_get (glabel, "use-underline", &use_underline);
- if (use_underline)
- gtk_label_set_use_underline (GTK_LABEL (object), use_underline);
+ glade_widget_property_get (glabel, "use-underline", &use_underline);
+ if (use_underline)
+ gtk_label_set_use_underline (GTK_LABEL (object), use_underline);
}
static void
-glade_gtk_label_set_attributes (GObject *object, const GValue *value)
-{
- GladeAttribute *gattr;
- PangoAttribute *attribute;
- PangoLanguage *language;
- PangoAttrList *attrs = NULL;
- GdkColor *color;
- GList *list;
-
- for (list = g_value_get_boxed (value); list; list = list->next)
- {
- gattr = list->data;
-
- attribute = NULL;
-
- switch (gattr->type)
- {
- /* PangoAttrLanguage */
- case PANGO_ATTR_LANGUAGE:
- if ((language = pango_language_from_string (g_value_get_string (&gattr->value))))
- attribute = pango_attr_language_new (language);
- break;
- /* PangoAttrInt */
- case PANGO_ATTR_STYLE:
- attribute = pango_attr_style_new (g_value_get_enum (&(gattr->value)));
- break;
- case PANGO_ATTR_WEIGHT:
- attribute = pango_attr_weight_new (g_value_get_enum (&(gattr->value)));
- break;
- case PANGO_ATTR_VARIANT:
- attribute = pango_attr_variant_new (g_value_get_enum (&(gattr->value)));
- break;
- case PANGO_ATTR_STRETCH:
- attribute = pango_attr_stretch_new (g_value_get_enum (&(gattr->value)));
- break;
- case PANGO_ATTR_UNDERLINE:
- attribute = pango_attr_underline_new (g_value_get_boolean (&(gattr->value)));
- break;
- case PANGO_ATTR_STRIKETHROUGH:
- attribute = pango_attr_strikethrough_new (g_value_get_boolean (&(gattr->value)));
- break;
- case PANGO_ATTR_GRAVITY:
- attribute = pango_attr_gravity_new (g_value_get_enum (&(gattr->value)));
- break;
- case PANGO_ATTR_GRAVITY_HINT:
- attribute = pango_attr_gravity_hint_new (g_value_get_enum (&(gattr->value)));
- break;
-
- /* PangoAttrString */
- case PANGO_ATTR_FAMILY:
- attribute = pango_attr_family_new (g_value_get_string (&(gattr->value)));
- break;
-
- /* PangoAttrSize */
- case PANGO_ATTR_SIZE:
- attribute = pango_attr_size_new (g_value_get_int (&(gattr->value)));
- break;
- case PANGO_ATTR_ABSOLUTE_SIZE:
- attribute = pango_attr_size_new_absolute (g_value_get_int (&(gattr->value)));
- break;
-
- /* PangoAttrColor */
- case PANGO_ATTR_FOREGROUND:
- color = g_value_get_boxed (&(gattr->value));
- attribute = pango_attr_foreground_new (color->red, color->green, color->blue);
- break;
- case PANGO_ATTR_BACKGROUND:
- color = g_value_get_boxed (&(gattr->value));
- attribute = pango_attr_background_new (color->red, color->green, color->blue);
- break;
- case PANGO_ATTR_UNDERLINE_COLOR:
- color = g_value_get_boxed (&(gattr->value));
- attribute = pango_attr_underline_color_new (color->red, color->green, color->blue);
- break;
- case PANGO_ATTR_STRIKETHROUGH_COLOR:
- color = g_value_get_boxed (&(gattr->value));
- attribute = pango_attr_strikethrough_color_new (color->red, color->green, color->blue);
- break;
-
- /* PangoAttrShape */
- case PANGO_ATTR_SHAPE:
- /* Unsupported for now */
- break;
- /* PangoAttrFloat */
- case PANGO_ATTR_SCALE:
- attribute = pango_attr_scale_new (g_value_get_double (&(gattr->value)));
- break;
-
- case PANGO_ATTR_INVALID:
- case PANGO_ATTR_LETTER_SPACING:
- case PANGO_ATTR_RISE:
- case PANGO_ATTR_FALLBACK:
- case PANGO_ATTR_FONT_DESC:
- default:
- break;
- }
-
- if (attribute)
- {
- if (!attrs)
- attrs = pango_attr_list_new ();
- pango_attr_list_insert (attrs, attribute);
-
- }
- }
-
- gtk_label_set_attributes (GTK_LABEL (object), attrs);
+glade_gtk_label_set_attributes (GObject * object, const GValue * value)
+{
+ GladeAttribute *gattr;
+ PangoAttribute *attribute;
+ PangoLanguage *language;
+ PangoAttrList *attrs = NULL;
+ GdkColor *color;
+ GList *list;
+
+ for (list = g_value_get_boxed (value); list; list = list->next)
+ {
+ gattr = list->data;
+
+ attribute = NULL;
+
+ switch (gattr->type)
+ {
+ /* PangoAttrLanguage */
+ case PANGO_ATTR_LANGUAGE:
+ if ((language =
+ pango_language_from_string (g_value_get_string
+ (&gattr->value))))
+ attribute = pango_attr_language_new (language);
+ break;
+ /* PangoAttrInt */
+ case PANGO_ATTR_STYLE:
+ attribute =
+ pango_attr_style_new (g_value_get_enum (&(gattr->value)));
+ break;
+ case PANGO_ATTR_WEIGHT:
+ attribute =
+ pango_attr_weight_new (g_value_get_enum (&(gattr->value)));
+ break;
+ case PANGO_ATTR_VARIANT:
+ attribute =
+ pango_attr_variant_new (g_value_get_enum (&(gattr->value)));
+ break;
+ case PANGO_ATTR_STRETCH:
+ attribute =
+ pango_attr_stretch_new (g_value_get_enum (&(gattr->value)));
+ break;
+ case PANGO_ATTR_UNDERLINE:
+ attribute =
+ pango_attr_underline_new (g_value_get_boolean
+ (&(gattr->value)));
+ break;
+ case PANGO_ATTR_STRIKETHROUGH:
+ attribute =
+ pango_attr_strikethrough_new (g_value_get_boolean
+ (&(gattr->value)));
+ break;
+ case PANGO_ATTR_GRAVITY:
+ attribute =
+ pango_attr_gravity_new (g_value_get_enum (&(gattr->value)));
+ break;
+ case PANGO_ATTR_GRAVITY_HINT:
+ attribute =
+ pango_attr_gravity_hint_new (g_value_get_enum
+ (&(gattr->value)));
+ break;
+
+ /* PangoAttrString */
+ case PANGO_ATTR_FAMILY:
+ attribute =
+ pango_attr_family_new (g_value_get_string (&(gattr->value)));
+ break;
+
+ /* PangoAttrSize */
+ case PANGO_ATTR_SIZE:
+ attribute = pango_attr_size_new (g_value_get_int (&(gattr->value)));
+ break;
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ attribute =
+ pango_attr_size_new_absolute (g_value_get_int
+ (&(gattr->value)));
+ break;
+
+ /* PangoAttrColor */
+ case PANGO_ATTR_FOREGROUND:
+ color = g_value_get_boxed (&(gattr->value));
+ attribute =
+ pango_attr_foreground_new (color->red, color->green,
+ color->blue);
+ break;
+ case PANGO_ATTR_BACKGROUND:
+ color = g_value_get_boxed (&(gattr->value));
+ attribute =
+ pango_attr_background_new (color->red, color->green,
+ color->blue);
+ break;
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ color = g_value_get_boxed (&(gattr->value));
+ attribute =
+ pango_attr_underline_color_new (color->red, color->green,
+ color->blue);
+ break;
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ color = g_value_get_boxed (&(gattr->value));
+ attribute =
+ pango_attr_strikethrough_color_new (color->red, color->green,
+ color->blue);
+ break;
+
+ /* PangoAttrShape */
+ case PANGO_ATTR_SHAPE:
+ /* Unsupported for now */
+ break;
+ /* PangoAttrFloat */
+ case PANGO_ATTR_SCALE:
+ attribute =
+ pango_attr_scale_new (g_value_get_double (&(gattr->value)));
+ break;
+
+ case PANGO_ATTR_INVALID:
+ case PANGO_ATTR_LETTER_SPACING:
+ case PANGO_ATTR_RISE:
+ case PANGO_ATTR_FALLBACK:
+ case PANGO_ATTR_FONT_DESC:
+ default:
+ break;
+ }
+
+ if (attribute)
+ {
+ if (!attrs)
+ attrs = pango_attr_list_new ();
+ pango_attr_list_insert (attrs, attribute);
+
+ }
+ }
+
+ gtk_label_set_attributes (GTK_LABEL (object), attrs);
}
static void
-glade_gtk_label_set_content_mode (GObject *object, const GValue *value)
-{
- GladeLabelContentMode mode = g_value_get_int (value);
- GladeWidget *glabel;
-
- glabel = glade_widget_get_from_gobject (object);
-
- glade_widget_property_set_sensitive (glabel, "glade-attributes", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (glabel, "use-markup", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (glabel, "pattern", FALSE, NOT_SELECTED_MSG);
-
- switch (mode)
- {
- case GLADE_LABEL_MODE_ATTRIBUTES:
- glade_widget_property_set_sensitive (glabel, "glade-attributes", TRUE, NULL);
- break;
- case GLADE_LABEL_MODE_MARKUP:
- glade_widget_property_set_sensitive (glabel, "use-markup", TRUE, NULL);
- break;
- case GLADE_LABEL_MODE_PATTERN:
- glade_widget_property_set_sensitive (glabel, "pattern", TRUE, NULL);
- break;
- default:
- break;
- }
+glade_gtk_label_set_content_mode (GObject * object, const GValue * value)
+{
+ GladeLabelContentMode mode = g_value_get_int (value);
+ GladeWidget *glabel;
+
+ glabel = glade_widget_get_from_gobject (object);
+
+ glade_widget_property_set_sensitive (glabel, "glade-attributes", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (glabel, "use-markup", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (glabel, "pattern", FALSE,
+ NOT_SELECTED_MSG);
+
+ switch (mode)
+ {
+ case GLADE_LABEL_MODE_ATTRIBUTES:
+ glade_widget_property_set_sensitive (glabel, "glade-attributes", TRUE,
+ NULL);
+ break;
+ case GLADE_LABEL_MODE_MARKUP:
+ glade_widget_property_set_sensitive (glabel, "use-markup", TRUE, NULL);
+ break;
+ case GLADE_LABEL_MODE_PATTERN:
+ glade_widget_property_set_sensitive (glabel, "pattern", TRUE, NULL);
+ break;
+ default:
+ break;
+ }
}
static void
-glade_gtk_label_set_use_max_width (GObject *object, const GValue *value)
+glade_gtk_label_set_use_max_width (GObject * object, const GValue * value)
{
- GladeWidget *glabel;
-
- glabel = glade_widget_get_from_gobject (object);
+ GladeWidget *glabel;
- glade_widget_property_set_sensitive (glabel, "width-chars", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (glabel, "max-width-chars", FALSE, NOT_SELECTED_MSG);
+ glabel = glade_widget_get_from_gobject (object);
- if (g_value_get_boolean (value))
- glade_widget_property_set_sensitive (glabel, "max-width-chars", TRUE, NULL);
- else
- glade_widget_property_set_sensitive (glabel, "width-chars", TRUE, NULL);
+ glade_widget_property_set_sensitive (glabel, "width-chars", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (glabel, "max-width-chars", FALSE,
+ NOT_SELECTED_MSG);
+
+ if (g_value_get_boolean (value))
+ glade_widget_property_set_sensitive (glabel, "max-width-chars", TRUE, NULL);
+ else
+ glade_widget_property_set_sensitive (glabel, "width-chars", TRUE, NULL);
}
static void
-glade_gtk_label_set_wrap_mode (GObject *object, const GValue *value)
+glade_gtk_label_set_wrap_mode (GObject * object, const GValue * value)
{
- GladeLabelWrapMode mode = g_value_get_int (value);
- GladeWidget *glabel;
-
- glabel = glade_widget_get_from_gobject (object);
+ GladeLabelWrapMode mode = g_value_get_int (value);
+ GladeWidget *glabel;
+
+ glabel = glade_widget_get_from_gobject (object);
- glade_widget_property_set_sensitive (glabel, "single-line-mode", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (glabel, "wrap-mode", FALSE, NOT_SELECTED_MSG);
-
- if (mode == GLADE_LABEL_SINGLE_LINE)
- glade_widget_property_set_sensitive (glabel, "single-line-mode", TRUE, NULL);
- else if (mode == GLADE_LABEL_WRAP_MODE)
- glade_widget_property_set_sensitive (glabel, "wrap-mode", TRUE, NULL);
+ glade_widget_property_set_sensitive (glabel, "single-line-mode", FALSE,
+ NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (glabel, "wrap-mode", FALSE,
+ NOT_SELECTED_MSG);
+
+ if (mode == GLADE_LABEL_SINGLE_LINE)
+ glade_widget_property_set_sensitive (glabel, "single-line-mode", TRUE,
+ NULL);
+ else if (mode == GLADE_LABEL_WRAP_MODE)
+ glade_widget_property_set_sensitive (glabel, "wrap-mode", TRUE, NULL);
}
static void
-glade_gtk_label_set_use_underline (GObject *object, const GValue *value)
+glade_gtk_label_set_use_underline (GObject * object, const GValue * value)
{
- GladeWidget *glabel;
-
- glabel = glade_widget_get_from_gobject (object);
+ GladeWidget *glabel;
+
+ glabel = glade_widget_get_from_gobject (object);
- if (g_value_get_boolean (value))
- glade_widget_property_set_sensitive (glabel, "mnemonic-widget", TRUE, NULL);
- else
- glade_widget_property_set_sensitive (glabel, "mnemonic-widget", FALSE, MNEMONIC_INSENSITIVE_MSG);
+ if (g_value_get_boolean (value))
+ glade_widget_property_set_sensitive (glabel, "mnemonic-widget", TRUE, NULL);
+ else
+ glade_widget_property_set_sensitive (glabel, "mnemonic-widget", FALSE,
+ MNEMONIC_INSENSITIVE_MSG);
- gtk_label_set_use_underline (GTK_LABEL (object), g_value_get_boolean (value));
+ gtk_label_set_use_underline (GTK_LABEL (object), g_value_get_boolean (value));
}
static void
-glade_gtk_label_set_ellipsize (GObject *object, const GValue *value)
+glade_gtk_label_set_ellipsize (GObject * object, const GValue * value)
{
- GladeWidget *glabel;
- const gchar *insensitive_msg = _("This property does not apply when Ellipsize is set.");
-
- glabel = glade_widget_get_from_gobject (object);
+ GladeWidget *glabel;
+ const gchar *insensitive_msg =
+ _("This property does not apply when Ellipsize is set.");
+
+ glabel = glade_widget_get_from_gobject (object);
- if (!glade_widget_property_original_default (glabel, "ellipsize"))
- glade_widget_property_set_sensitive (glabel, "angle", FALSE, insensitive_msg);
- else
- glade_widget_property_set_sensitive (glabel, "angle", TRUE, NULL);
+ if (!glade_widget_property_original_default (glabel, "ellipsize"))
+ glade_widget_property_set_sensitive (glabel, "angle", FALSE,
+ insensitive_msg);
+ else
+ glade_widget_property_set_sensitive (glabel, "angle", TRUE, NULL);
- gtk_label_set_ellipsize (GTK_LABEL (object), g_value_get_enum (value));
+ gtk_label_set_ellipsize (GTK_LABEL (object), g_value_get_enum (value));
}
static void
-glade_gtk_label_set_angle (GObject *object, const GValue *value)
-{
- GladeWidget *glabel;
- const gchar *insensitive_msg = _("This property does not apply when Angle is set.");
-
- glabel = glade_widget_get_from_gobject (object);
-
- if (!glade_widget_property_original_default (glabel, "angle"))
- glade_widget_property_set_sensitive (glabel, "ellipsize", FALSE, insensitive_msg);
- else
- glade_widget_property_set_sensitive (glabel, "ellipsize", TRUE, NULL);
-
- gtk_label_set_angle (GTK_LABEL (object), g_value_get_double (value));
-}
-
-void
-glade_gtk_label_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
-{
- if (!strcmp (id, "label"))
- glade_gtk_label_set_label (object, value);
- else if (!strcmp (id, "glade-attributes"))
- glade_gtk_label_set_attributes (object, value);
- else if (!strcmp (id, "label-content-mode"))
- glade_gtk_label_set_content_mode (object, value);
- else if (!strcmp (id, "use-max-width"))
- glade_gtk_label_set_use_max_width (object, value);
- else if (!strcmp (id, "label-wrap-mode"))
- glade_gtk_label_set_wrap_mode (object, value);
- else if (!strcmp (id, "use-underline"))
- glade_gtk_label_set_use_underline (object, value);
- else if (!strcmp (id, "ellipsize"))
- glade_gtk_label_set_ellipsize (object, value);
- else if (!strcmp (id, "angle"))
- glade_gtk_label_set_angle (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
+glade_gtk_label_set_angle (GObject * object, const GValue * value)
+{
+ GladeWidget *glabel;
+ const gchar *insensitive_msg =
+ _("This property does not apply when Angle is set.");
+
+ glabel = glade_widget_get_from_gobject (object);
+
+ if (!glade_widget_property_original_default (glabel, "angle"))
+ glade_widget_property_set_sensitive (glabel, "ellipsize", FALSE,
+ insensitive_msg);
+ else
+ glade_widget_property_set_sensitive (glabel, "ellipsize", TRUE, NULL);
+
+ gtk_label_set_angle (GTK_LABEL (object), g_value_get_double (value));
+}
+
+void
+glade_gtk_label_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ if (!strcmp (id, "label"))
+ glade_gtk_label_set_label (object, value);
+ else if (!strcmp (id, "glade-attributes"))
+ glade_gtk_label_set_attributes (object, value);
+ else if (!strcmp (id, "label-content-mode"))
+ glade_gtk_label_set_content_mode (object, value);
+ else if (!strcmp (id, "use-max-width"))
+ glade_gtk_label_set_use_max_width (object, value);
+ else if (!strcmp (id, "label-wrap-mode"))
+ glade_gtk_label_set_wrap_mode (object, value);
+ else if (!strcmp (id, "use-underline"))
+ glade_gtk_label_set_use_underline (object, value);
+ else if (!strcmp (id, "ellipsize"))
+ glade_gtk_label_set_ellipsize (object, value);
+ else if (!strcmp (id, "angle"))
+ glade_gtk_label_set_angle (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
}
static void
-glade_gtk_parse_attributes (GladeWidget *widget,
- GladeXmlNode *node)
-{
- PangoAttrType attr_type;
- GladeXmlNode *prop;
- GladeAttribute *attr;
- GList *attrs = NULL;
- gchar *name, *value;
-
- for (prop = glade_xml_node_get_children (node);
- prop; prop = glade_xml_node_next (prop))
- {
- if (!glade_xml_node_verify (prop, GLADE_TAG_ATTRIBUTE))
- continue;
-
- if (!(name = glade_xml_get_property_string_required
- (prop, GLADE_XML_TAG_NAME, NULL)))
- continue;
-
- if (!(value = glade_xml_get_property_string_required
- (prop, GLADE_TAG_VALUE, NULL)))
- {
- /* for a while, Glade was broken and was storing
- * attributes in the node contents */
- if (!(value = glade_xml_get_content (prop)))
- {
- g_free (name);
- continue;
- }
- }
-
- if ((attr_type =
- glade_utils_enum_value_from_string (PANGO_TYPE_ATTR_TYPE, name)) == 0)
- continue;
-
- /* Parse attribute and add to list */
- if ((attr = glade_gtk_attribute_from_string (attr_type, value)) != NULL)
- attrs = g_list_prepend (attrs, attr);
-
- /* XXX deal with start/end here ... */
-
- g_free (name);
- g_free (value);
- }
-
- glade_widget_property_set (widget, "glade-attributes", g_list_reverse (attrs));
- glade_attr_list_free (attrs);
+glade_gtk_parse_attributes (GladeWidget * widget, GladeXmlNode * node)
+{
+ PangoAttrType attr_type;
+ GladeXmlNode *prop;
+ GladeAttribute *attr;
+ GList *attrs = NULL;
+ gchar *name, *value;
+
+ for (prop = glade_xml_node_get_children (node);
+ prop; prop = glade_xml_node_next (prop))
+ {
+ if (!glade_xml_node_verify (prop, GLADE_TAG_ATTRIBUTE))
+ continue;
+
+ if (!(name = glade_xml_get_property_string_required
+ (prop, GLADE_XML_TAG_NAME, NULL)))
+ continue;
+
+ if (!(value = glade_xml_get_property_string_required
+ (prop, GLADE_TAG_VALUE, NULL)))
+ {
+ /* for a while, Glade was broken and was storing
+ * attributes in the node contents */
+ if (!(value = glade_xml_get_content (prop)))
+ {
+ g_free (name);
+ continue;
+ }
+ }
+
+ if ((attr_type =
+ glade_utils_enum_value_from_string (PANGO_TYPE_ATTR_TYPE,
+ name)) == 0)
+ continue;
+
+ /* Parse attribute and add to list */
+ if ((attr = glade_gtk_attribute_from_string (attr_type, value)) != NULL)
+ attrs = g_list_prepend (attrs, attr);
+
+ /* XXX deal with start/end here ... */
+
+ g_free (name);
+ g_free (value);
+ }
+
+ glade_widget_property_set (widget, "glade-attributes",
+ g_list_reverse (attrs));
+ glade_attr_list_free (attrs);
}
static void
-glade_gtk_label_read_attributes (GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_label_read_attributes (GladeWidget * widget, GladeXmlNode * node)
{
- GladeXmlNode *attrs_node;
+ GladeXmlNode *attrs_node;
- if ((attrs_node =
- glade_xml_search_child (node, GLADE_TAG_ATTRIBUTES)) != NULL)
- {
- /* Generic attributes parsing */
- glade_gtk_parse_attributes (widget, attrs_node);
- }
+ if ((attrs_node =
+ glade_xml_search_child (node, GLADE_TAG_ATTRIBUTES)) != NULL)
+ {
+ /* Generic attributes parsing */
+ glade_gtk_parse_attributes (widget, attrs_node);
+ }
}
void
-glade_gtk_label_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_label_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeProperty *prop;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ GladeProperty *prop;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->read_widget (adaptor, widget, node);
- glade_gtk_label_read_attributes (widget, node);
+ glade_gtk_label_read_attributes (widget, node);
- /* sync label property after a load... */
- prop = glade_widget_get_property (widget, "label");
- glade_gtk_label_set_label (widget->object, prop->value);
+ /* sync label property after a load... */
+ prop = glade_widget_get_property (widget, "label");
+ glade_gtk_label_set_label (widget->object, prop->value);
- /* Resolve "label-content-mode" virtual control property */
- if (!glade_widget_property_original_default (widget, "use-markup"))
- glade_widget_property_set (widget, "label-content-mode", GLADE_LABEL_MODE_MARKUP);
- else if (!glade_widget_property_original_default (widget, "pattern"))
- glade_widget_property_set (widget, "label-content-mode", GLADE_LABEL_MODE_PATTERN);
- else
- glade_widget_property_set (widget, "label-content-mode", GLADE_LABEL_MODE_ATTRIBUTES);
+ /* Resolve "label-content-mode" virtual control property */
+ if (!glade_widget_property_original_default (widget, "use-markup"))
+ glade_widget_property_set (widget, "label-content-mode",
+ GLADE_LABEL_MODE_MARKUP);
+ else if (!glade_widget_property_original_default (widget, "pattern"))
+ glade_widget_property_set (widget, "label-content-mode",
+ GLADE_LABEL_MODE_PATTERN);
+ else
+ glade_widget_property_set (widget, "label-content-mode",
+ GLADE_LABEL_MODE_ATTRIBUTES);
- /* Resolve "label-wrap-mode" virtual control property */
- if (!glade_widget_property_original_default (widget, "single-line-mode"))
- glade_widget_property_set (widget, "label-wrap-mode", GLADE_LABEL_SINGLE_LINE);
- else if (!glade_widget_property_original_default (widget, "wrap"))
- glade_widget_property_set (widget, "label-wrap-mode", GLADE_LABEL_WRAP_MODE);
- else
- glade_widget_property_set (widget, "label-wrap-mode", GLADE_LABEL_WRAP_FREE);
+ /* Resolve "label-wrap-mode" virtual control property */
+ if (!glade_widget_property_original_default (widget, "single-line-mode"))
+ glade_widget_property_set (widget, "label-wrap-mode",
+ GLADE_LABEL_SINGLE_LINE);
+ else if (!glade_widget_property_original_default (widget, "wrap"))
+ glade_widget_property_set (widget, "label-wrap-mode",
+ GLADE_LABEL_WRAP_MODE);
+ else
+ glade_widget_property_set (widget, "label-wrap-mode",
+ GLADE_LABEL_WRAP_FREE);
- /* Resolve "use-max-width" virtual control property */
- if (!glade_widget_property_original_default (widget, "max-width-chars"))
- glade_widget_property_set (widget, "use-max-width", TRUE);
- else
- glade_widget_property_set (widget, "use-max-width", TRUE);
-
- if (glade_widget_property_original_default (widget, "use-markup"))
- glade_widget_property_set_sensitive (widget, "mnemonic-widget",
- FALSE, MNEMONIC_INSENSITIVE_MSG);
+ /* Resolve "use-max-width" virtual control property */
+ if (!glade_widget_property_original_default (widget, "max-width-chars"))
+ glade_widget_property_set (widget, "use-max-width", TRUE);
+ else
+ glade_widget_property_set (widget, "use-max-width", TRUE);
+
+ if (glade_widget_property_original_default (widget, "use-markup"))
+ glade_widget_property_set_sensitive (widget, "mnemonic-widget",
+ FALSE, MNEMONIC_INSENSITIVE_MSG);
}
static void
-glade_gtk_label_write_attributes (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_label_write_attributes (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *attr_node;
- GList *attrs = NULL, *l;
- GladeAttribute *gattr;
- gchar *attr_type;
- gchar *attr_value;
+ GladeXmlNode *attr_node;
+ GList *attrs = NULL, *l;
+ GladeAttribute *gattr;
+ gchar *attr_type;
+ gchar *attr_value;
- if (!glade_widget_property_get (widget, "glade-attributes", &attrs) || !attrs)
- return;
+ if (!glade_widget_property_get (widget, "glade-attributes", &attrs) || !attrs)
+ return;
- for (l = attrs; l; l = l->next)
- {
- gattr = l->data;
+ for (l = attrs; l; l = l->next)
+ {
+ gattr = l->data;
- attr_type = glade_utils_enum_string_from_value (PANGO_TYPE_ATTR_TYPE, gattr->type);
- attr_value = glade_gtk_string_from_attr (gattr);
+ attr_type =
+ glade_utils_enum_string_from_value (PANGO_TYPE_ATTR_TYPE,
+ gattr->type);
+ attr_value = glade_gtk_string_from_attr (gattr);
- attr_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTE);
- glade_xml_node_append_child (node, attr_node);
+ attr_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTE);
+ glade_xml_node_append_child (node, attr_node);
- glade_xml_node_set_property_string (attr_node, GLADE_TAG_NAME, attr_type);
- glade_xml_node_set_property_string (attr_node, GLADE_TAG_VALUE, attr_value);
- }
+ glade_xml_node_set_property_string (attr_node, GLADE_TAG_NAME, attr_type);
+ glade_xml_node_set_property_string (attr_node, GLADE_TAG_VALUE,
+ attr_value);
+ }
}
void
-glade_gtk_label_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_label_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
{
- GladeXmlNode *attrs_node;
+ GladeXmlNode *attrs_node;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->write_widget (adaptor, widget, context,
+ node);
- attrs_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTES);
+ attrs_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTES);
- glade_gtk_label_write_attributes (widget, context, attrs_node);
+ glade_gtk_label_write_attributes (widget, context, attrs_node);
- if (!glade_xml_node_get_children (attrs_node))
- glade_xml_node_delete (attrs_node);
- else
- glade_xml_node_append_child (node, attrs_node);
+ if (!glade_xml_node_get_children (attrs_node))
+ glade_xml_node_delete (attrs_node);
+ else
+ glade_xml_node_append_child (node, attrs_node);
}
gchar *
-glade_gtk_label_string_from_value (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- const GValue *value)
-{
- if (klass->pspec->value_type == GLADE_TYPE_ATTR_GLIST)
- {
- GList *l, *list = g_value_get_boxed (value);
- GString *string = g_string_new ("");
- gchar *str;
-
- for (l = list; l; l = g_list_next (l))
- {
- GladeAttribute *attr = l->data;
-
- /* Return something usefull at least to for the backend to compare */
- gchar *attr_str = glade_gtk_string_from_attr (attr);
- g_string_append_printf (string, "%d=%s ", attr->type, attr_str);
- g_free (attr_str);
- }
- str = string->str;
- g_string_free (string, FALSE);
- return str;
- }
- else
- return GWA_GET_CLASS
- (GTK_TYPE_WIDGET)->string_from_value (adaptor,
- klass,
- value);
+glade_gtk_label_string_from_value (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ const GValue * value)
+{
+ if (klass->pspec->value_type == GLADE_TYPE_ATTR_GLIST)
+ {
+ GList *l, *list = g_value_get_boxed (value);
+ GString *string = g_string_new ("");
+ gchar *str;
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GladeAttribute *attr = l->data;
+
+ /* Return something usefull at least to for the backend to compare */
+ gchar *attr_str = glade_gtk_string_from_attr (attr);
+ g_string_append_printf (string, "%d=%s ", attr->type, attr_str);
+ g_free (attr_str);
+ }
+ str = string->str;
+ g_string_free (string, FALSE);
+ return str;
+ }
+ else
+ return GWA_GET_CLASS
+ (GTK_TYPE_WIDGET)->string_from_value (adaptor, klass, value);
}
GladeEditorProperty *
-glade_gtk_label_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
-{
- GladeEditorProperty *eprop;
-
- /* chain up.. */
- if (klass->pspec->value_type == GLADE_TYPE_ATTR_GLIST)
- {
- eprop = g_object_new (GLADE_TYPE_EPROP_ATTRS,
- "property-class", klass,
- "use-command", use_command,
- NULL);
- }
- else
- eprop = GWA_GET_CLASS
- (GTK_TYPE_WIDGET)->create_eprop (adaptor,
- klass,
- use_command);
- return eprop;
+glade_gtk_label_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass, gboolean use_command)
+{
+ GladeEditorProperty *eprop;
+
+ /* chain up.. */
+ if (klass->pspec->value_type == GLADE_TYPE_ATTR_GLIST)
+ {
+ eprop = g_object_new (GLADE_TYPE_EPROP_ATTRS,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ }
+ else
+ eprop = GWA_GET_CLASS
+ (GTK_TYPE_WIDGET)->create_eprop (adaptor, klass, use_command);
+ return eprop;
}
GladeEditable *
-glade_gtk_label_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_label_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_label_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_label_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
/* ----------------------------- GtkTextBuffer ------------------------------ */
static void
-glade_gtk_entry_buffer_changed (GtkTextBuffer *buffer,
- GParamSpec *pspec,
- GladeWidget *gbuffy)
+glade_gtk_entry_buffer_changed (GtkTextBuffer * buffer,
+ GParamSpec * pspec, GladeWidget * gbuffy)
{
- const gchar *text_prop = NULL;
- GladeProperty *prop;
- gchar *text = NULL;
-
- if (glade_widget_superuser ())
- return;
+ const gchar *text_prop = NULL;
+ GladeProperty *prop;
+ gchar *text = NULL;
- g_object_get (buffer, "text", &text, NULL);
+ if (glade_widget_superuser ())
+ return;
- if ((prop = glade_widget_get_property (gbuffy, "text")))
- {
- glade_property_get (prop, &text_prop);
+ g_object_get (buffer, "text", &text, NULL);
- if (text_prop == NULL || g_strcmp0 (text, text_prop))
- glade_command_set_property (prop, text);
- }
- g_free (text);
+ if ((prop = glade_widget_get_property (gbuffy, "text")))
+ {
+ glade_property_get (prop, &text_prop);
+
+ if (text_prop == NULL || g_strcmp0 (text, text_prop))
+ glade_command_set_property (prop, text);
+ }
+ g_free (text);
}
void
-glade_gtk_entry_buffer_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_entry_buffer_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *gbuffy;
-
- gbuffy = glade_widget_get_from_gobject (object);
-
- g_signal_connect (object, "notify::text",
- G_CALLBACK (glade_gtk_entry_buffer_changed),
- gbuffy);
+ GladeWidget *gbuffy;
+
+ gbuffy = glade_widget_get_from_gobject (object);
+
+ g_signal_connect (object, "notify::text",
+ G_CALLBACK (glade_gtk_entry_buffer_changed), gbuffy);
}
void
-glade_gtk_entry_buffer_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_entry_buffer_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GladeProperty *property = glade_widget_get_property (gwidget, id);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GladeProperty *property = glade_widget_get_property (gwidget, id);
- if (!strcmp (id, "text"))
- {
- g_signal_handlers_block_by_func (object, glade_gtk_entry_buffer_changed, gwidget);
+ if (!strcmp (id, "text"))
+ {
+ g_signal_handlers_block_by_func (object, glade_gtk_entry_buffer_changed,
+ gwidget);
- if (g_value_get_string (value))
- gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object), g_value_get_string (value), -1);
- else
- gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object), "", -1);
+ if (g_value_get_string (value))
+ gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object),
+ g_value_get_string (value), -1);
+ else
+ gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object), "", -1);
- g_signal_handlers_unblock_by_func (object, glade_gtk_entry_buffer_changed, gwidget);
+ g_signal_handlers_unblock_by_func (object, glade_gtk_entry_buffer_changed,
+ gwidget);
- }
- else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
+ }
+ else if (GPC_VERSION_CHECK
+ (property->klass, gtk_major_version, gtk_minor_version + 1))
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
}
/* ----------------------------- GtkTextBuffer ------------------------------ */
static void
-glade_gtk_text_buffer_changed (GtkTextBuffer *buffer, GladeWidget *gbuffy)
+glade_gtk_text_buffer_changed (GtkTextBuffer * buffer, GladeWidget * gbuffy)
{
- const gchar *text_prop = NULL;
- GladeProperty *prop;
- gchar *text = NULL;
-
- g_object_get (buffer, "text", &text, NULL);
+ const gchar *text_prop = NULL;
+ GladeProperty *prop;
+ gchar *text = NULL;
- if ((prop = glade_widget_get_property (gbuffy, "text")))
- {
- glade_property_get (prop, &text_prop);
+ g_object_get (buffer, "text", &text, NULL);
- if (g_strcmp0 (text, text_prop))
- glade_command_set_property (prop, text);
- }
- g_free (text);
+ if ((prop = glade_widget_get_property (gbuffy, "text")))
+ {
+ glade_property_get (prop, &text_prop);
+
+ if (g_strcmp0 (text, text_prop))
+ glade_command_set_property (prop, text);
+ }
+ g_free (text);
}
void
-glade_gtk_text_buffer_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_text_buffer_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *gbuffy;
-
- gbuffy = glade_widget_get_from_gobject (object);
-
- g_signal_connect (object, "changed",
- G_CALLBACK (glade_gtk_text_buffer_changed),
- gbuffy);
+ GladeWidget *gbuffy;
+
+ gbuffy = glade_widget_get_from_gobject (object);
+
+ g_signal_connect (object, "changed",
+ G_CALLBACK (glade_gtk_text_buffer_changed), gbuffy);
}
void
-glade_gtk_text_buffer_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_text_buffer_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GladeProperty *property = glade_widget_get_property (gwidget, id);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GladeProperty *property = glade_widget_get_property (gwidget, id);
- if (!strcmp (id, "text"))
- {
- g_signal_handlers_block_by_func (object, glade_gtk_text_buffer_changed, gwidget);
+ if (!strcmp (id, "text"))
+ {
+ g_signal_handlers_block_by_func (object, glade_gtk_text_buffer_changed,
+ gwidget);
- if (g_value_get_string (value))
- gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object), g_value_get_string (value), -1);
- else
- gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object), "", -1);
+ if (g_value_get_string (value))
+ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object),
+ g_value_get_string (value), -1);
+ else
+ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object), "", -1);
- g_signal_handlers_unblock_by_func (object, glade_gtk_text_buffer_changed, gwidget);
+ g_signal_handlers_unblock_by_func (object, glade_gtk_text_buffer_changed,
+ gwidget);
- }
- else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
+ }
+ else if (GPC_VERSION_CHECK
+ (property->klass, gtk_major_version, gtk_minor_version + 1))
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
}
/* ----------------------------- GtkTextView ------------------------------ */
static gboolean
-glade_gtk_text_view_stop_double_click (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
+glade_gtk_text_view_stop_double_click (GtkWidget * widget,
+ GdkEventButton * event,
+ gpointer user_data)
{
- /* Return True if the event is double or triple click */
- return (event->type == GDK_2BUTTON_PRESS ||
- event->type == GDK_3BUTTON_PRESS);
+ /* Return True if the event is double or triple click */
+ return (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS);
}
void
-glade_gtk_text_view_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_text_view_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *gtext;
-
- gtext = glade_widget_get_from_gobject (object);
+ GladeWidget *gtext;
+
+ gtext = glade_widget_get_from_gobject (object);
- /* This makes gtk_text_view_set_buffer() stop complaing */
- gtk_drag_dest_set (GTK_WIDGET (object), 0, NULL, 0, 0);
+ /* This makes gtk_text_view_set_buffer() stop complaing */
+ gtk_drag_dest_set (GTK_WIDGET (object), 0, NULL, 0, 0);
- /* Glade hangs when a TextView gets a double click. So we stop them */
- g_signal_connect (object, "button-press-event",
- G_CALLBACK (glade_gtk_text_view_stop_double_click),
- NULL);
+ /* Glade hangs when a TextView gets a double click. So we stop them */
+ g_signal_connect (object, "button-press-event",
+ G_CALLBACK (glade_gtk_text_view_stop_double_click), NULL);
}
void
-glade_gtk_text_view_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_text_view_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- if (strcmp (property_name, "buffer") == 0)
- {
- if (!g_value_get_object (value))
- return;
- }
+ if (strcmp (property_name, "buffer") == 0)
+ {
+ if (!g_value_get_object (value))
+ return;
+ }
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
- object,
- property_name,
- value);
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
+ object,
+ property_name, value);
}
/* ----------------------------- GtkComboBox ------------------------------ */
void
-glade_gtk_combo_box_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_combo_box_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *widget = glade_widget_get_from_gobject (object);
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
- if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)))
- glade_widget_adaptor_create_internal
- (widget, G_OBJECT (gtk_bin_get_child (GTK_BIN (object))),
- "entry", "comboboxentry", FALSE, reason);
+ if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)))
+ glade_widget_adaptor_create_internal
+ (widget, G_OBJECT (gtk_bin_get_child (GTK_BIN (object))),
+ "entry", "comboboxentry", FALSE, reason);
}
void
-glade_gtk_combo_box_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_combo_box_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "entry-text-column"))
- {
- /* Avoid warnings */
- if (g_value_get_int (value) >= 0)
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
- object,
- id, value);
- }
- else if (!strcmp (id, "text-column"))
- {
- if (g_value_get_int (value) >= 0)
- gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object),
- g_value_get_int (value));
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
- object,
- id, value);
+ if (!strcmp (id, "entry-text-column"))
+ {
+ /* Avoid warnings */
+ if (g_value_get_int (value) >= 0)
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
+ object, id, value);
+ }
+ else if (!strcmp (id, "text-column"))
+ {
+ if (g_value_get_int (value) >= 0)
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (object),
+ g_value_get_int (value));
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor,
+ object, id, value);
}
-GList *glade_gtk_cell_layout_get_children (GladeWidgetAdaptor *adaptor, GObject *container);
+GList *glade_gtk_cell_layout_get_children (GladeWidgetAdaptor * adaptor,
+ GObject * container);
GList *
-glade_gtk_combo_box_get_children (GladeWidgetAdaptor *adaptor, GtkComboBox *combo)
+glade_gtk_combo_box_get_children (GladeWidgetAdaptor * adaptor,
+ GtkComboBox * combo)
{
- GList *list = NULL;
+ GList *list = NULL;
- list = glade_gtk_cell_layout_get_children (adaptor, G_OBJECT (combo));
+ list = glade_gtk_cell_layout_get_children (adaptor, G_OBJECT (combo));
- /* return the internal entry.
- *
- * FIXME: for recent gtk+ we have no comboboxentry
- * but a "has-entry" property instead
- */
- if (gtk_combo_box_get_has_entry (combo))
- list = g_list_append (list, gtk_bin_get_child (GTK_BIN (combo)));
+ /* return the internal entry.
+ *
+ * FIXME: for recent gtk+ we have no comboboxentry
+ * but a "has-entry" property instead
+ */
+ if (gtk_combo_box_get_has_entry (combo))
+ list = g_list_append (list, gtk_bin_get_child (GTK_BIN (combo)));
- return list;
+ return list;
}
GObject *
-glade_gtk_combo_box_get_internal_child (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *name)
+glade_gtk_combo_box_get_internal_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * name)
{
- GObject *child = NULL;
- g_return_val_if_fail (GTK_IS_COMBO_BOX (object), NULL);
-
- if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)) && strcmp ("entry", name) == 0)
- child = G_OBJECT (gtk_bin_get_child (GTK_BIN (object)));
+ GObject *child = NULL;
+ g_return_val_if_fail (GTK_IS_COMBO_BOX (object), NULL);
- return child;
+ if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (object)) &&
+ strcmp ("entry", name) == 0)
+ child = G_OBJECT (gtk_bin_get_child (GTK_BIN (object)));
+
+ return child;
}
/* ----------------------------- GtkSpinButton ------------------------------ */
static void
-glade_gtk_spin_button_set_adjustment (GObject *object, const GValue *value)
+glade_gtk_spin_button_set_adjustment (GObject * object, const GValue * value)
{
- GObject *adjustment;
- GtkAdjustment *adj;
-
- g_return_if_fail (GTK_IS_SPIN_BUTTON (object));
-
- adjustment = g_value_get_object (value);
-
- if (adjustment && GTK_IS_ADJUSTMENT (adjustment))
- {
- adj = GTK_ADJUSTMENT (adjustment);
+ GObject *adjustment;
+ GtkAdjustment *adj;
+
+ g_return_if_fail (GTK_IS_SPIN_BUTTON (object));
+
+ adjustment = g_value_get_object (value);
- if (gtk_adjustment_get_page_size (adj) > 0)
- {
- GladeWidget *gadj = glade_widget_get_from_gobject (adj);
+ if (adjustment && GTK_IS_ADJUSTMENT (adjustment))
+ {
+ adj = GTK_ADJUSTMENT (adjustment);
- /* Silently set any spin-button adjustment page size to 0 */
- glade_widget_property_set (gadj, "page-size", 0.0F);
- gtk_adjustment_set_page_size (adj, 0);
- }
+ if (gtk_adjustment_get_page_size (adj) > 0)
+ {
+ GladeWidget *gadj = glade_widget_get_from_gobject (adj);
- gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (object), adj);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (object),
- gtk_adjustment_get_value (adj));
- }
+ /* Silently set any spin-button adjustment page size to 0 */
+ glade_widget_property_set (gadj, "page-size", 0.0F);
+ gtk_adjustment_set_page_size (adj, 0);
+ }
+
+ gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (object), adj);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (object),
+ gtk_adjustment_get_value (adj));
+ }
}
void
-glade_gtk_spin_button_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *id,
- const GValue *value)
+glade_gtk_spin_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
{
- if (!strcmp (id, "adjustment"))
- glade_gtk_spin_button_set_adjustment (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_ENTRY)->set_property (adaptor,
- object,
- id, value);
+ if (!strcmp (id, "adjustment"))
+ glade_gtk_spin_button_set_adjustment (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_ENTRY)->set_property (adaptor, object, id, value);
}
/* ------------------------------ GtkAssistant ------------------------------ */
static void
-glade_gtk_assistant_append_new_page (GladeWidget *parent,
- GladeProject *project,
- const gchar *label,
- GtkAssistantPageType type)
-{
- static GladeWidgetAdaptor *adaptor = NULL;
- GladeWidget *page;
-
- if (adaptor == NULL)
- adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
-
- page = glade_widget_adaptor_create_widget (adaptor, FALSE,
- "parent", parent,
- "project", project,
- NULL);
-
- glade_widget_add_child (parent, page, FALSE);
-
- glade_widget_property_set (page, "label", label);
- glade_widget_pack_property_set (page, "page-type", type);
+glade_gtk_assistant_append_new_page (GladeWidget * parent,
+ GladeProject * project,
+ const gchar * label,
+ GtkAssistantPageType type)
+{
+ static GladeWidgetAdaptor *adaptor = NULL;
+ GladeWidget *page;
+
+ if (adaptor == NULL)
+ adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_LABEL);
+
+ page = glade_widget_adaptor_create_widget (adaptor, FALSE,
+ "parent", parent,
+ "project", project, NULL);
+
+ glade_widget_add_child (parent, page, FALSE);
+
+ glade_widget_property_set (page, "label", label);
+ glade_widget_pack_property_set (page, "page-type", type);
}
+
/*
GtkAssistant is a very weird widget, why is it derived from GtkWindow
instead of GtkNotebook I do not know!
@@ -8319,482 +8320,480 @@ glade_gtk_assistant_append_new_page (GladeWidget *parent,
update its navigation buttons!
*/
static void
-glade_gtk_assistant_update_page_type (GtkAssistant *assistant)
-{
- gint i, current, pages;
- GtkWidget *page;
-
- current = gtk_assistant_get_current_page (assistant);
- pages = gtk_assistant_get_n_pages (assistant) - 1;
- if (pages < 0) return;
-
- /* Last Page */
- page = gtk_assistant_get_nth_page (assistant, pages);
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM);
-
- /* First page */
- page = gtk_assistant_get_nth_page (assistant, 0);
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_INTRO);
-
- /* In betwen pages */
- for (i = 1; i < pages; i++)
- {
- page = gtk_assistant_get_nth_page (assistant, i);
- gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
-
- }
-
- /* Now we have set page-type in every page, force button update */
- for (i = 0; i <= pages; i++)
- {
- page = gtk_assistant_get_nth_page (assistant, i);
- gtk_assistant_set_page_complete (assistant, page, TRUE);
- gtk_assistant_set_current_page (assistant, i);
- gtk_assistant_update_buttons_state (assistant);
- }
-
- if (current >= 0) gtk_assistant_set_current_page (assistant, current);
+glade_gtk_assistant_update_page_type (GtkAssistant * assistant)
+{
+ gint i, current, pages;
+ GtkWidget *page;
+
+ current = gtk_assistant_get_current_page (assistant);
+ pages = gtk_assistant_get_n_pages (assistant) - 1;
+ if (pages < 0)
+ return;
+
+ /* Last Page */
+ page = gtk_assistant_get_nth_page (assistant, pages);
+ gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM);
+
+ /* First page */
+ page = gtk_assistant_get_nth_page (assistant, 0);
+ gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_INTRO);
+
+ /* In betwen pages */
+ for (i = 1; i < pages; i++)
+ {
+ page = gtk_assistant_get_nth_page (assistant, i);
+ gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
+
+ }
+
+ /* Now we have set page-type in every page, force button update */
+ for (i = 0; i <= pages; i++)
+ {
+ page = gtk_assistant_get_nth_page (assistant, i);
+ gtk_assistant_set_page_complete (assistant, page, TRUE);
+ gtk_assistant_set_current_page (assistant, i);
+ gtk_assistant_update_buttons_state (assistant);
+ }
+
+ if (current >= 0)
+ gtk_assistant_set_current_page (assistant, current);
}
static gint
-glade_gtk_assistant_get_page (GtkAssistant *assistant, GtkWidget *page)
+glade_gtk_assistant_get_page (GtkAssistant * assistant, GtkWidget * page)
{
- gint i, pages = gtk_assistant_get_n_pages (assistant);
-
- for (i = 0; i < pages; i++)
- if (gtk_assistant_get_nth_page (assistant, i) == page)
- return i;
-
- return -1;
+ gint i, pages = gtk_assistant_get_n_pages (assistant);
+
+ for (i = 0; i < pages; i++)
+ if (gtk_assistant_get_nth_page (assistant, i) == page)
+ return i;
+
+ return -1;
}
static void
-glade_gtk_assistant_update_position (GtkAssistant *assistant)
+glade_gtk_assistant_update_position (GtkAssistant * assistant)
{
- gint i, pages = gtk_assistant_get_n_pages (assistant);
-
- for (i = 0; i < pages; i++)
- {
- GtkWidget *page = gtk_assistant_get_nth_page (assistant, i);
- GladeWidget *gpage = glade_widget_get_from_gobject (G_OBJECT (page));
- if (gpage) glade_widget_pack_property_set (gpage, "position", i);
- }
+ gint i, pages = gtk_assistant_get_n_pages (assistant);
+
+ for (i = 0; i < pages; i++)
+ {
+ GtkWidget *page = gtk_assistant_get_nth_page (assistant, i);
+ GladeWidget *gpage = glade_widget_get_from_gobject (G_OBJECT (page));
+ if (gpage)
+ glade_widget_pack_property_set (gpage, "position", i);
+ }
}
static void
-glade_gtk_assistant_parse_finished (GladeProject *project,
- GObject *object)
-{
- GtkAssistant *assistant = GTK_ASSISTANT (object);
- gint pages = gtk_assistant_get_n_pages (assistant);
-
- if (pages)
- {
- /* also sets pages "complete" and thus allows navigation under glade */
- glade_gtk_assistant_update_page_type (assistant);
-
- gtk_assistant_set_current_page (assistant, 0);
- glade_widget_property_set (glade_widget_get_from_gobject (object),
- "n-pages", pages);
- }
-}
-
-void
-glade_gtk_assistant_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GladeWidget *parent = glade_widget_get_from_gobject (object);
- GladeProject *project = glade_widget_get_project (parent);
-
- if (reason == GLADE_CREATE_LOAD)
- {
- g_signal_connect (project, "parse-finished",
- G_CALLBACK (glade_gtk_assistant_parse_finished),
- object);
- return;
- }
-
- if (reason == GLADE_CREATE_USER)
- {
- glade_gtk_assistant_append_new_page (parent, project,
- _("Introduction page"),
- GTK_ASSISTANT_PAGE_INTRO);
-
- glade_gtk_assistant_append_new_page (parent, project,
- _("Content page"),
- GTK_ASSISTANT_PAGE_CONTENT);
-
- glade_gtk_assistant_append_new_page (parent, project,
- _("Confirmation page"),
- GTK_ASSISTANT_PAGE_CONFIRM);
-
- gtk_assistant_set_current_page (GTK_ASSISTANT (object), 0);
-
- glade_widget_property_set (parent, "n-pages", 3);
- }
-}
-
-void
-glade_gtk_assistant_add_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
-{
- GtkAssistant *assistant = GTK_ASSISTANT (container);
- GtkWidget *widget = GTK_WIDGET (child);
-
- gtk_assistant_append_page (assistant, widget);
-}
-
-void
-glade_gtk_assistant_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
-{
- GtkAssistant *assistant = GTK_ASSISTANT (container);
- GladeWidget *gassistant = glade_widget_get_from_gobject (container);
-
- gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
- glade_widget_property_set (gassistant, "n-pages",
- gtk_assistant_get_n_pages (assistant));
-}
-
-void
-glade_gtk_assistant_replace_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *current,
- GObject *new_object)
-{
- GtkAssistant *assistant = GTK_ASSISTANT (container);
- GtkWidget *page = GTK_WIDGET (new_object), *old_page = GTK_WIDGET (current);
- gint pos = glade_gtk_assistant_get_page (assistant, old_page);
- gboolean set_current = gtk_assistant_get_current_page (assistant) == pos;
-
- gtk_container_remove (GTK_CONTAINER (container), old_page);
-
- gtk_assistant_insert_page (assistant, page, pos);
- glade_gtk_assistant_update_page_type (assistant);
-
- if (set_current) gtk_assistant_set_current_page (assistant, pos);
+glade_gtk_assistant_parse_finished (GladeProject * project, GObject * object)
+{
+ GtkAssistant *assistant = GTK_ASSISTANT (object);
+ gint pages = gtk_assistant_get_n_pages (assistant);
+
+ if (pages)
+ {
+ /* also sets pages "complete" and thus allows navigation under glade */
+ glade_gtk_assistant_update_page_type (assistant);
+
+ gtk_assistant_set_current_page (assistant, 0);
+ glade_widget_property_set (glade_widget_get_from_gobject (object),
+ "n-pages", pages);
+ }
}
-gboolean
-glade_gtk_assistant_verify_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "n-pages") == 0)
- return g_value_get_int (value) >=
- gtk_assistant_get_n_pages (GTK_ASSISTANT (object));
-
- /* Chain Up */
- if (GWA_GET_CLASS (GTK_TYPE_WINDOW)->verify_property == NULL)
- return TRUE;
- return GWA_GET_CLASS (GTK_TYPE_WINDOW)->verify_property (adaptor,
- object,
- property_name,
- value);
-}
-
-void
-glade_gtk_assistant_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "n-pages") == 0)
- {
- GtkAssistant *assistant = GTK_ASSISTANT (object);
- gint size, i;
-
- for (i = gtk_assistant_get_n_pages (GTK_ASSISTANT (object)),
- size = g_value_get_int (value); i < size; i++)
- gtk_assistant_append_page (assistant, glade_placeholder_new ());
-
- glade_gtk_assistant_update_page_type (assistant);
-
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_WINDOW)->set_property (adaptor,
- object,
- property_name,
- value);
-}
-
-void
-glade_gtk_assistant_get_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- GValue *value)
-{
- if (strcmp (property_name, "n-pages") == 0)
- {
- g_value_set_int (value,
- gtk_assistant_get_n_pages (GTK_ASSISTANT (object)));
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_WINDOW)->get_property (adaptor,
- object,
- property_name,
- value);
-}
-
-void
-glade_gtk_assistant_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "position") == 0)
- {
- GtkAssistant *assistant = GTK_ASSISTANT (container);
- GtkWidget *widget = GTK_WIDGET (child);
- gint pos, size;
- gboolean set_current;
-
- if ((pos = g_value_get_int (value)) < 0) return;
- if (pos == glade_gtk_assistant_get_page (assistant, widget))
- return;
- set_current = gtk_assistant_get_current_page (assistant) ==
- glade_gtk_assistant_get_page (assistant, widget);
-
- size = gtk_assistant_get_n_pages (assistant);
-
- g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (container), widget);
- gtk_assistant_insert_page (assistant, widget, pos);
- g_object_unref (child);
-
- if (set_current) gtk_assistant_set_current_page (assistant, pos);
-
- glade_gtk_assistant_update_page_type (assistant);
-
- glade_gtk_assistant_update_position (assistant);
-
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_WINDOW)->child_set_property (adaptor,
- container,
- child,
- property_name,
- value);
-}
-
-void
-glade_gtk_assistant_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- if (strcmp (property_name, "position") == 0)
- {
- gint pos;
- pos = glade_gtk_assistant_get_page (GTK_ASSISTANT (container),
- GTK_WIDGET (child));
- if (pos >= 0) g_value_set_int (value, pos);
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_WINDOW)->child_get_property (adaptor,
- container,
- child,
- property_name,
- value);
+void
+glade_gtk_assistant_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
+{
+ GladeWidget *parent = glade_widget_get_from_gobject (object);
+ GladeProject *project = glade_widget_get_project (parent);
+
+ if (reason == GLADE_CREATE_LOAD)
+ {
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (glade_gtk_assistant_parse_finished),
+ object);
+ return;
+ }
+
+ if (reason == GLADE_CREATE_USER)
+ {
+ glade_gtk_assistant_append_new_page (parent, project,
+ _("Introduction page"),
+ GTK_ASSISTANT_PAGE_INTRO);
+
+ glade_gtk_assistant_append_new_page (parent, project,
+ _("Content page"),
+ GTK_ASSISTANT_PAGE_CONTENT);
+
+ glade_gtk_assistant_append_new_page (parent, project,
+ _("Confirmation page"),
+ GTK_ASSISTANT_PAGE_CONFIRM);
+
+ gtk_assistant_set_current_page (GTK_ASSISTANT (object), 0);
+
+ glade_widget_property_set (parent, "n-pages", 3);
+ }
}
-/*--------------------------- GtkRadioButton ---------------------------------*/
void
-glade_gtk_radio_button_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "group") == 0)
- {
- GtkRadioButton *radio = g_value_get_object (value);
- /* g_object_set () on this property produces a bogus warning,
- * so we better use the API GtkRadioButton provides.
- */
- gtk_radio_button_set_group (GTK_RADIO_BUTTON (object),
- radio ? gtk_radio_button_get_group (radio) : NULL);
- return;
- }
-
- /* Chain Up */
- GWA_GET_CLASS (GTK_TYPE_CHECK_BUTTON)->set_property (adaptor,
- object,
- property_name,
- value);
+glade_gtk_assistant_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
+{
+ GtkAssistant *assistant = GTK_ASSISTANT (container);
+ GtkWidget *widget = GTK_WIDGET (child);
+
+ gtk_assistant_append_page (assistant, widget);
+}
+
+void
+glade_gtk_assistant_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
+{
+ GtkAssistant *assistant = GTK_ASSISTANT (container);
+ GladeWidget *gassistant = glade_widget_get_from_gobject (container);
+
+ gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (child));
+ glade_widget_property_set (gassistant, "n-pages",
+ gtk_assistant_get_n_pages (assistant));
+}
+
+void
+glade_gtk_assistant_replace_child (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * current, GObject * new_object)
+{
+ GtkAssistant *assistant = GTK_ASSISTANT (container);
+ GtkWidget *page = GTK_WIDGET (new_object), *old_page = GTK_WIDGET (current);
+ gint pos = glade_gtk_assistant_get_page (assistant, old_page);
+ gboolean set_current = gtk_assistant_get_current_page (assistant) == pos;
+
+ gtk_container_remove (GTK_CONTAINER (container), old_page);
+
+ gtk_assistant_insert_page (assistant, page, pos);
+ glade_gtk_assistant_update_page_type (assistant);
+
+ if (set_current)
+ gtk_assistant_set_current_page (assistant, pos);
}
-/*--------------------------- GtkSizeGroup ---------------------------------*/
gboolean
-glade_gtk_size_group_depends (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeWidget *another)
+glade_gtk_assistant_verify_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- if (GTK_IS_WIDGET (another->object))
- return TRUE;
+ if (strcmp (property_name, "n-pages") == 0)
+ return g_value_get_int (value) >=
+ gtk_assistant_get_n_pages (GTK_ASSISTANT (object));
- return GWA_GET_CLASS (G_TYPE_OBJECT)->depends (adaptor, widget, another);
+ /* Chain Up */
+ if (GWA_GET_CLASS (GTK_TYPE_WINDOW)->verify_property == NULL)
+ return TRUE;
+ return GWA_GET_CLASS (GTK_TYPE_WINDOW)->verify_property (adaptor,
+ object,
+ property_name,
+ value);
}
-#define GLADE_TAG_SIZEGROUP_WIDGETS "widgets"
-#define GLADE_TAG_SIZEGROUP_WIDGET "widget"
+void
+glade_gtk_assistant_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
+{
+ if (strcmp (property_name, "n-pages") == 0)
+ {
+ GtkAssistant *assistant = GTK_ASSISTANT (object);
+ gint size, i;
-static void
-glade_gtk_size_group_read_widgets (GladeWidget *widget,
- GladeXmlNode *node)
+ for (i = gtk_assistant_get_n_pages (GTK_ASSISTANT (object)),
+ size = g_value_get_int (value); i < size; i++)
+ gtk_assistant_append_page (assistant, glade_placeholder_new ());
+
+ glade_gtk_assistant_update_page_type (assistant);
+
+ return;
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_WINDOW)->set_property (adaptor,
+ object, property_name, value);
+}
+
+void
+glade_gtk_assistant_get_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name, GValue * value)
+{
+ if (strcmp (property_name, "n-pages") == 0)
+ {
+ g_value_set_int (value,
+ gtk_assistant_get_n_pages (GTK_ASSISTANT (object)));
+ return;
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_WINDOW)->get_property (adaptor,
+ object, property_name, value);
+}
+
+void
+glade_gtk_assistant_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
{
- GladeXmlNode *widgets_node;
- GladeProperty *property;
- gchar *string = NULL;
+ if (strcmp (property_name, "position") == 0)
+ {
+ GtkAssistant *assistant = GTK_ASSISTANT (container);
+ GtkWidget *widget = GTK_WIDGET (child);
+ gint pos, size;
+ gboolean set_current;
- if ((widgets_node =
- glade_xml_search_child (node, GLADE_TAG_SIZEGROUP_WIDGETS)) != NULL)
- {
- GladeXmlNode *node;
+ if ((pos = g_value_get_int (value)) < 0)
+ return;
+ if (pos == glade_gtk_assistant_get_page (assistant, widget))
+ return;
+ set_current = gtk_assistant_get_current_page (assistant) ==
+ glade_gtk_assistant_get_page (assistant, widget);
- for (node = glade_xml_node_get_children (widgets_node);
- node; node = glade_xml_node_next (node))
- {
- gchar *widget_name, *tmp;
-
- if (!glade_xml_node_verify (node, GLADE_TAG_SIZEGROUP_WIDGET))
- continue;
+ size = gtk_assistant_get_n_pages (assistant);
- widget_name = glade_xml_get_property_string_required
- (node, GLADE_TAG_NAME, NULL);
-
- if (string == NULL)
- string = widget_name;
- else if (widget_name != NULL)
- {
- tmp = g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER, widget_name);
- string = (g_free (string), tmp);
- g_free (widget_name);
- }
- }
- }
+ g_object_ref (child);
+ gtk_container_remove (GTK_CONTAINER (container), widget);
+ gtk_assistant_insert_page (assistant, widget, pos);
+ g_object_unref (child);
+ if (set_current)
+ gtk_assistant_set_current_page (assistant, pos);
- if (string)
- {
- property = glade_widget_get_property (widget, "widgets");
- g_assert (property);
+ glade_gtk_assistant_update_page_type (assistant);
- /* we must synchronize this directly after loading this project
- * (i.e. lookup the actual objects after they've been parsed and
- * are present).
- */
- g_object_set_data_full (G_OBJECT (property),
- "glade-loaded-object",
- string, g_free);
- }
+ glade_gtk_assistant_update_position (assistant);
+
+ return;
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_WINDOW)->child_set_property (adaptor,
+ container,
+ child,
+ property_name, value);
}
void
-glade_gtk_size_group_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_assistant_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (strcmp (property_name, "position") == 0)
+ {
+ gint pos;
+ pos = glade_gtk_assistant_get_page (GTK_ASSISTANT (container),
+ GTK_WIDGET (child));
+ if (pos >= 0)
+ g_value_set_int (value, pos);
+ return;
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_WINDOW)->child_get_property (adaptor,
+ container,
+ child,
+ property_name, value);
+}
+
+/*--------------------------- GtkRadioButton ---------------------------------*/
+void
+glade_gtk_radio_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
+{
+ if (strcmp (property_name, "group") == 0)
+ {
+ GtkRadioButton *radio = g_value_get_object (value);
+ /* g_object_set () on this property produces a bogus warning,
+ * so we better use the API GtkRadioButton provides.
+ */
+ gtk_radio_button_set_group (GTK_RADIO_BUTTON (object),
+ radio ? gtk_radio_button_get_group (radio) :
+ NULL);
+ return;
+ }
+
+ /* Chain Up */
+ GWA_GET_CLASS (GTK_TYPE_CHECK_BUTTON)->set_property (adaptor,
+ object,
+ property_name, value);
+}
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+/*--------------------------- GtkSizeGroup ---------------------------------*/
+gboolean
+glade_gtk_size_group_depends (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeWidget * another)
+{
+ if (GTK_IS_WIDGET (another->object))
+ return TRUE;
- glade_gtk_size_group_read_widgets (widget, node);
+ return GWA_GET_CLASS (G_TYPE_OBJECT)->depends (adaptor, widget, another);
}
+#define GLADE_TAG_SIZEGROUP_WIDGETS "widgets"
+#define GLADE_TAG_SIZEGROUP_WIDGET "widget"
static void
-glade_gtk_size_group_write_widgets (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_size_group_read_widgets (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode *widgets_node;
+ GladeProperty *property;
+ gchar *string = NULL;
+
+ if ((widgets_node =
+ glade_xml_search_child (node, GLADE_TAG_SIZEGROUP_WIDGETS)) != NULL)
+ {
+ GladeXmlNode *node;
+
+ for (node = glade_xml_node_get_children (widgets_node);
+ node; node = glade_xml_node_next (node))
+ {
+ gchar *widget_name, *tmp;
+
+ if (!glade_xml_node_verify (node, GLADE_TAG_SIZEGROUP_WIDGET))
+ continue;
+
+ widget_name = glade_xml_get_property_string_required
+ (node, GLADE_TAG_NAME, NULL);
+
+ if (string == NULL)
+ string = widget_name;
+ else if (widget_name != NULL)
+ {
+ tmp =
+ g_strdup_printf ("%s%s%s", string, GPC_OBJECT_DELIMITER,
+ widget_name);
+ string = (g_free (string), tmp);
+ g_free (widget_name);
+ }
+ }
+ }
+
+
+ if (string)
+ {
+ property = glade_widget_get_property (widget, "widgets");
+ g_assert (property);
+
+ /* we must synchronize this directly after loading this project
+ * (i.e. lookup the actual objects after they've been parsed and
+ * are present).
+ */
+ g_object_set_data_full (G_OBJECT (property),
+ "glade-loaded-object", string, g_free);
+ }
+}
+
+void
+glade_gtk_size_group_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeXmlNode *widgets_node, *widget_node;
- GList *widgets = NULL, *list;
- GladeWidget *awidget;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+
+ glade_gtk_size_group_read_widgets (widget, node);
+}
- widgets_node = glade_xml_node_new (context, GLADE_TAG_SIZEGROUP_WIDGETS);
- if (glade_widget_property_get (widget, "widgets", &widgets))
- {
- for (list = widgets; list; list = list->next)
- {
- awidget = glade_widget_get_from_gobject (list->data);
- widget_node = glade_xml_node_new (context, GLADE_TAG_SIZEGROUP_WIDGET);
- glade_xml_node_append_child (widgets_node, widget_node);
- glade_xml_node_set_property_string (widget_node, GLADE_TAG_NAME, awidget->name);
- }
- }
+static void
+glade_gtk_size_group_write_widgets (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *widgets_node, *widget_node;
+ GList *widgets = NULL, *list;
+ GladeWidget *awidget;
+
+ widgets_node = glade_xml_node_new (context, GLADE_TAG_SIZEGROUP_WIDGETS);
+
+ if (glade_widget_property_get (widget, "widgets", &widgets))
+ {
+ for (list = widgets; list; list = list->next)
+ {
+ awidget = glade_widget_get_from_gobject (list->data);
+ widget_node =
+ glade_xml_node_new (context, GLADE_TAG_SIZEGROUP_WIDGET);
+ glade_xml_node_append_child (widgets_node, widget_node);
+ glade_xml_node_set_property_string (widget_node, GLADE_TAG_NAME,
+ awidget->name);
+ }
+ }
+
+ if (!glade_xml_node_get_children (widgets_node))
+ glade_xml_node_delete (widgets_node);
+ else
+ glade_xml_node_append_child (node, widgets_node);
- if (!glade_xml_node_get_children (widgets_node))
- glade_xml_node_delete (widgets_node);
- else
- glade_xml_node_append_child (node, widgets_node);
-
}
void
-glade_gtk_size_group_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_size_group_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
- glade_gtk_size_group_write_widgets (widget, context, node);
+ glade_gtk_size_group_write_widgets (widget, context, node);
}
void
-glade_gtk_size_group_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_size_group_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- if (!strcmp (property_name, "widgets"))
- {
- GSList *sg_widgets, *slist;
- GList *widgets, *list;
+ if (!strcmp (property_name, "widgets"))
+ {
+ GSList *sg_widgets, *slist;
+ GList *widgets, *list;
- /* remove old widgets */
- if ((sg_widgets = gtk_size_group_get_widgets (GTK_SIZE_GROUP (object))) != NULL)
- {
- /* copy since we are modifying an internal list */
- sg_widgets = g_slist_copy (sg_widgets);
- for (slist = sg_widgets; slist; slist = slist->next)
- gtk_size_group_remove_widget (GTK_SIZE_GROUP (object), GTK_WIDGET (slist->data));
- g_slist_free (sg_widgets);
- }
+ /* remove old widgets */
+ if ((sg_widgets =
+ gtk_size_group_get_widgets (GTK_SIZE_GROUP (object))) != NULL)
+ {
+ /* copy since we are modifying an internal list */
+ sg_widgets = g_slist_copy (sg_widgets);
+ for (slist = sg_widgets; slist; slist = slist->next)
+ gtk_size_group_remove_widget (GTK_SIZE_GROUP (object),
+ GTK_WIDGET (slist->data));
+ g_slist_free (sg_widgets);
+ }
- /* add new widgets */
- if ((widgets = g_value_get_boxed (value)) != NULL)
- {
- for (list = widgets; list; list = list->next)
- gtk_size_group_add_widget (GTK_SIZE_GROUP (object), GTK_WIDGET (list->data));
- }
- }
- else
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object,
- property_name, value);
+ /* add new widgets */
+ if ((widgets = g_value_get_boxed (value)) != NULL)
+ {
+ for (list = widgets; list; list = list->next)
+ gtk_size_group_add_widget (GTK_SIZE_GROUP (object),
+ GTK_WIDGET (list->data));
+ }
+ }
+ else
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object,
+ property_name, value);
}
/*--------------------------- GtkIconFactory ---------------------------------*/
@@ -8808,394 +8807,404 @@ glade_gtk_size_group_set_property (GladeWidgetAdaptor *adaptor,
#define GLADE_TAG_SIZE "size"
void
-glade_gtk_icon_factory_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_icon_factory_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- gtk_icon_factory_add_default (GTK_ICON_FACTORY (object));
+ gtk_icon_factory_add_default (GTK_ICON_FACTORY (object));
}
static void
-glade_gtk_icon_factory_read_sources (GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeIconSources *sources;
- GtkIconSource *source;
- GladeXmlNode *sources_node, *source_node;
- GValue *value;
- GList *list;
- gchar *current_icon_name = NULL;
- GdkPixbuf *pixbuf;
-
- if ((sources_node = glade_xml_search_child (node, GLADE_TAG_SOURCES)) == NULL)
- return;
-
- sources = glade_icon_sources_new ();
-
- /* Here we expect all icon sets to remain together in the list. */
- for (source_node = glade_xml_node_get_children (sources_node); source_node;
- source_node = glade_xml_node_next (source_node))
- {
- gchar *icon_name;
- gchar *str;
-
- if (!glade_xml_node_verify (source_node, GLADE_TAG_SOURCE))
- continue;
-
- if (!(icon_name =
- glade_xml_get_property_string_required (source_node, GLADE_TAG_STOCK_ID, NULL)))
- continue;
-
- if (!(str = glade_xml_get_property_string_required (source_node, GLADE_TAG_FILENAME, NULL)))
- {
- g_free (icon_name);
- continue;
- }
-
- if (!current_icon_name || strcmp (current_icon_name, icon_name) != 0)
- current_icon_name = (g_free (current_icon_name), g_strdup (icon_name));
-
- source = gtk_icon_source_new ();
-
- /* Deal with the filename... */
- value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, str,
- widget->project, widget);
- pixbuf = g_value_dup_object (value);
- g_value_unset (value);
- g_free (value);
-
- gtk_icon_source_set_pixbuf (source, pixbuf);
- g_object_unref (G_OBJECT (pixbuf));
- g_free (str);
-
- /* Now the attributes... */
- if ((str = glade_xml_get_property_string (source_node, GLADE_TAG_DIRECTION)) != NULL)
- {
- GtkTextDirection direction =
- glade_utils_enum_value_from_string (GTK_TYPE_TEXT_DIRECTION, str);
- gtk_icon_source_set_direction_wildcarded (source, FALSE);
- gtk_icon_source_set_direction (source, direction);
- g_free (str);
- }
-
- if ((str = glade_xml_get_property_string (source_node, GLADE_TAG_SIZE)) != NULL)
- {
- GtkIconSize size =
- glade_utils_enum_value_from_string (GTK_TYPE_ICON_SIZE, str);
- gtk_icon_source_set_size_wildcarded (source, FALSE);
- gtk_icon_source_set_size (source, size);
- g_free (str);
- }
-
- if ((str = glade_xml_get_property_string (source_node, GLADE_TAG_STATE)) != NULL)
- {
- GtkStateType state =
- glade_utils_enum_value_from_string (GTK_TYPE_STATE_TYPE, str);
- gtk_icon_source_set_state_wildcarded (source, FALSE);
- gtk_icon_source_set_state (source, state);
- g_free (str);
- }
-
- if ((list = g_hash_table_lookup (sources->sources, g_strdup (current_icon_name))) != NULL)
- {
- GList *new_list = g_list_append (list, source);
-
- /* Warning: if we use g_list_prepend() the returned pointer will be different
- * so we would have to replace the list pointer in the hash table.
- * But before doing that we have to steal the old list pointer otherwise
- * we would have to make a copy then add the new icon to finally replace the hash table
- * value.
- * Anyways if we choose to prepend we would have to reverse the list outside this loop
- * so its better to append.
- */
- if (new_list != list)
- {
- /* current g_list_append() returns the same pointer so this is not needed */
- g_hash_table_steal (sources->sources, current_icon_name);
- g_hash_table_insert (sources->sources, g_strdup (current_icon_name), new_list);
- }
- }
- else
- {
- list = g_list_append (NULL, source);
- g_hash_table_insert (sources->sources, g_strdup (current_icon_name), list);
- }
- }
-
- if (g_hash_table_size (sources->sources) > 0)
- glade_widget_property_set (widget, "sources", sources);
-
- glade_icon_sources_free (sources);
-}
-
-void
-glade_gtk_icon_factory_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in any normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
-
- glade_gtk_icon_factory_read_sources (widget, node);
-}
-
-typedef struct {
- GladeXmlContext *context;
- GladeXmlNode *node;
-} SourceWriteTab;
+glade_gtk_icon_factory_read_sources (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeIconSources *sources;
+ GtkIconSource *source;
+ GladeXmlNode *sources_node, *source_node;
+ GValue *value;
+ GList *list;
+ gchar *current_icon_name = NULL;
+ GdkPixbuf *pixbuf;
+
+ if ((sources_node = glade_xml_search_child (node, GLADE_TAG_SOURCES)) == NULL)
+ return;
+
+ sources = glade_icon_sources_new ();
+
+ /* Here we expect all icon sets to remain together in the list. */
+ for (source_node = glade_xml_node_get_children (sources_node); source_node;
+ source_node = glade_xml_node_next (source_node))
+ {
+ gchar *icon_name;
+ gchar *str;
+
+ if (!glade_xml_node_verify (source_node, GLADE_TAG_SOURCE))
+ continue;
+
+ if (!(icon_name =
+ glade_xml_get_property_string_required (source_node,
+ GLADE_TAG_STOCK_ID, NULL)))
+ continue;
+
+ if (!
+ (str =
+ glade_xml_get_property_string_required (source_node,
+ GLADE_TAG_FILENAME, NULL)))
+ {
+ g_free (icon_name);
+ continue;
+ }
-static void
-write_icon_sources (gchar *icon_name,
- GList *sources,
- SourceWriteTab *tab)
-{
- GladeXmlNode *source_node;
- GtkIconSource *source;
- GList *l;
- gchar *string;
+ if (!current_icon_name || strcmp (current_icon_name, icon_name) != 0)
+ current_icon_name = (g_free (current_icon_name), g_strdup (icon_name));
+
+ source = gtk_icon_source_new ();
+
+ /* Deal with the filename... */
+ value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, str,
+ widget->project, widget);
+ pixbuf = g_value_dup_object (value);
+ g_value_unset (value);
+ g_free (value);
+
+ gtk_icon_source_set_pixbuf (source, pixbuf);
+ g_object_unref (G_OBJECT (pixbuf));
+ g_free (str);
+
+ /* Now the attributes... */
+ if ((str =
+ glade_xml_get_property_string (source_node,
+ GLADE_TAG_DIRECTION)) != NULL)
+ {
+ GtkTextDirection direction =
+ glade_utils_enum_value_from_string (GTK_TYPE_TEXT_DIRECTION, str);
+ gtk_icon_source_set_direction_wildcarded (source, FALSE);
+ gtk_icon_source_set_direction (source, direction);
+ g_free (str);
+ }
+
+ if ((str =
+ glade_xml_get_property_string (source_node, GLADE_TAG_SIZE)) != NULL)
+ {
+ GtkIconSize size =
+ glade_utils_enum_value_from_string (GTK_TYPE_ICON_SIZE, str);
+ gtk_icon_source_set_size_wildcarded (source, FALSE);
+ gtk_icon_source_set_size (source, size);
+ g_free (str);
+ }
+
+ if ((str =
+ glade_xml_get_property_string (source_node,
+ GLADE_TAG_STATE)) != NULL)
+ {
+ GtkStateType state =
+ glade_utils_enum_value_from_string (GTK_TYPE_STATE_TYPE, str);
+ gtk_icon_source_set_state_wildcarded (source, FALSE);
+ gtk_icon_source_set_state (source, state);
+ g_free (str);
+ }
+
+ if ((list =
+ g_hash_table_lookup (sources->sources,
+ g_strdup (current_icon_name))) != NULL)
+ {
+ GList *new_list = g_list_append (list, source);
+
+ /* Warning: if we use g_list_prepend() the returned pointer will be different
+ * so we would have to replace the list pointer in the hash table.
+ * But before doing that we have to steal the old list pointer otherwise
+ * we would have to make a copy then add the new icon to finally replace the hash table
+ * value.
+ * Anyways if we choose to prepend we would have to reverse the list outside this loop
+ * so its better to append.
+ */
+ if (new_list != list)
+ {
+ /* current g_list_append() returns the same pointer so this is not needed */
+ g_hash_table_steal (sources->sources, current_icon_name);
+ g_hash_table_insert (sources->sources,
+ g_strdup (current_icon_name), new_list);
+ }
+ }
+ else
+ {
+ list = g_list_append (NULL, source);
+ g_hash_table_insert (sources->sources, g_strdup (current_icon_name),
+ list);
+ }
+ }
+
+ if (g_hash_table_size (sources->sources) > 0)
+ glade_widget_property_set (widget, "sources", sources);
+
+ glade_icon_sources_free (sources);
+}
- GdkPixbuf *pixbuf;
+void
+glade_gtk_icon_factory_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- for (l = sources; l; l = l->next)
- {
- source = l->data;
+ /* First chain up and read in any normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
- source_node = glade_xml_node_new (tab->context, GLADE_TAG_SOURCE);
- glade_xml_node_append_child (tab->node, source_node);
+ glade_gtk_icon_factory_read_sources (widget, node);
+}
- glade_xml_node_set_property_string (source_node, GLADE_TAG_STOCK_ID, icon_name);
+typedef struct
+{
+ GladeXmlContext *context;
+ GladeXmlNode *node;
+} SourceWriteTab;
- if (!gtk_icon_source_get_direction_wildcarded (source))
- {
- GtkTextDirection direction = gtk_icon_source_get_direction (source);
- string = glade_utils_enum_string_from_value (GTK_TYPE_TEXT_DIRECTION, direction);
- glade_xml_node_set_property_string (source_node, GLADE_TAG_DIRECTION, string);
- g_free (string);
- }
+static void
+write_icon_sources (gchar * icon_name, GList * sources, SourceWriteTab * tab)
+{
+ GladeXmlNode *source_node;
+ GtkIconSource *source;
+ GList *l;
+ gchar *string;
+
+ GdkPixbuf *pixbuf;
+
+ for (l = sources; l; l = l->next)
+ {
+ source = l->data;
+
+ source_node = glade_xml_node_new (tab->context, GLADE_TAG_SOURCE);
+ glade_xml_node_append_child (tab->node, source_node);
+
+ glade_xml_node_set_property_string (source_node, GLADE_TAG_STOCK_ID,
+ icon_name);
+
+ if (!gtk_icon_source_get_direction_wildcarded (source))
+ {
+ GtkTextDirection direction = gtk_icon_source_get_direction (source);
+ string =
+ glade_utils_enum_string_from_value (GTK_TYPE_TEXT_DIRECTION,
+ direction);
+ glade_xml_node_set_property_string (source_node, GLADE_TAG_DIRECTION,
+ string);
+ g_free (string);
+ }
- if (!gtk_icon_source_get_size_wildcarded (source))
- {
- GtkIconSize size = gtk_icon_source_get_size (source);
- string = glade_utils_enum_string_from_value (GTK_TYPE_ICON_SIZE, size);
- glade_xml_node_set_property_string (source_node, GLADE_TAG_SIZE, string);
- g_free (string);
- }
+ if (!gtk_icon_source_get_size_wildcarded (source))
+ {
+ GtkIconSize size = gtk_icon_source_get_size (source);
+ string =
+ glade_utils_enum_string_from_value (GTK_TYPE_ICON_SIZE, size);
+ glade_xml_node_set_property_string (source_node, GLADE_TAG_SIZE,
+ string);
+ g_free (string);
+ }
- if (!gtk_icon_source_get_state_wildcarded (source))
- {
- GtkStateType state = gtk_icon_source_get_state (source);
- string = glade_utils_enum_string_from_value (GTK_TYPE_STATE_TYPE, state);
- glade_xml_node_set_property_string (source_node, GLADE_TAG_STATE, string);
- g_free (string);
- }
+ if (!gtk_icon_source_get_state_wildcarded (source))
+ {
+ GtkStateType state = gtk_icon_source_get_state (source);
+ string =
+ glade_utils_enum_string_from_value (GTK_TYPE_STATE_TYPE, state);
+ glade_xml_node_set_property_string (source_node, GLADE_TAG_STATE,
+ string);
+ g_free (string);
+ }
- pixbuf = gtk_icon_source_get_pixbuf (source);
- string = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
+ pixbuf = gtk_icon_source_get_pixbuf (source);
+ string = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
- glade_xml_node_set_property_string (source_node,
- GLADE_TAG_FILENAME,
- string);
- }
+ glade_xml_node_set_property_string (source_node,
+ GLADE_TAG_FILENAME, string);
+ }
}
static void
-glade_gtk_icon_factory_write_sources (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_icon_factory_write_sources (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *sources_node;
- GladeIconSources *sources = NULL;
- SourceWriteTab tab;
+ GladeXmlNode *sources_node;
+ GladeIconSources *sources = NULL;
+ SourceWriteTab tab;
- glade_widget_property_get (widget, "sources", &sources);
- if (!sources)
- return;
+ glade_widget_property_get (widget, "sources", &sources);
+ if (!sources)
+ return;
- sources_node = glade_xml_node_new (context, GLADE_TAG_SOURCES);
+ sources_node = glade_xml_node_new (context, GLADE_TAG_SOURCES);
- tab.context = context;
- tab.node = sources_node;
- g_hash_table_foreach (sources->sources, (GHFunc)write_icon_sources, &tab);
+ tab.context = context;
+ tab.node = sources_node;
+ g_hash_table_foreach (sources->sources, (GHFunc) write_icon_sources, &tab);
- if (!glade_xml_node_get_children (sources_node))
- glade_xml_node_delete (sources_node);
- else
- glade_xml_node_append_child (node, sources_node);
+ if (!glade_xml_node_get_children (sources_node))
+ glade_xml_node_delete (sources_node);
+ else
+ glade_xml_node_append_child (node, sources_node);
}
void
-glade_gtk_icon_factory_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_icon_factory_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* First chain up and write all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+ /* First chain up and write all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
- glade_gtk_icon_factory_write_sources (widget, context, node);
+ glade_gtk_icon_factory_write_sources (widget, context, node);
}
static void
-apply_icon_sources (gchar *icon_name,
- GList *sources,
- GtkIconFactory *factory)
+apply_icon_sources (gchar * icon_name,
+ GList * sources, GtkIconFactory * factory)
{
- GtkIconSource *source;
- GtkIconSet *set;
- GList *l;
+ GtkIconSource *source;
+ GtkIconSet *set;
+ GList *l;
- set = gtk_icon_set_new ();
+ set = gtk_icon_set_new ();
- for (l = sources; l; l = l->next)
- {
- source = gtk_icon_source_copy ((GtkIconSource *)l->data);
- gtk_icon_set_add_source (set, source);
- }
+ for (l = sources; l; l = l->next)
+ {
+ source = gtk_icon_source_copy ((GtkIconSource *) l->data);
+ gtk_icon_set_add_source (set, source);
+ }
- gtk_icon_factory_add (factory, icon_name, set);
+ gtk_icon_factory_add (factory, icon_name, set);
}
static void
-glade_gtk_icon_factory_set_sources (GObject *object, const GValue *value)
+glade_gtk_icon_factory_set_sources (GObject * object, const GValue * value)
{
- GladeIconSources *sources = g_value_get_boxed (value);
- if (sources)
- g_hash_table_foreach (sources->sources, (GHFunc)apply_icon_sources, object);
+ GladeIconSources *sources = g_value_get_boxed (value);
+ if (sources)
+ g_hash_table_foreach (sources->sources, (GHFunc) apply_icon_sources,
+ object);
}
void
-glade_gtk_icon_factory_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_icon_factory_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- if (strcmp (property_name, "sources") == 0)
- {
- glade_gtk_icon_factory_set_sources (object, value);
- }
- else
- /* Chain Up */
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
- object,
- property_name,
- value);
+ if (strcmp (property_name, "sources") == 0)
+ {
+ glade_gtk_icon_factory_set_sources (object, value);
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
+ object, property_name, value);
}
static void
-serialize_icon_sources (gchar *icon_name,
- GList *sources,
- GString *string)
-{
- GList *l;
-
- for (l = sources; l; l = g_list_next (l))
- {
- GtkIconSource *source = l->data;
- GdkPixbuf *pixbuf;
- gchar *str;
-
- pixbuf = gtk_icon_source_get_pixbuf (source);
- str = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
-
- g_string_append_printf (string, "%s[%s] ", icon_name, str);
-
- if (!gtk_icon_source_get_direction_wildcarded (source))
- {
- GtkTextDirection direction = gtk_icon_source_get_direction (source);
- str = glade_utils_enum_string_from_value (GTK_TYPE_TEXT_DIRECTION, direction);
- g_string_append_printf (string, "dir-%s ", str);
- g_free (str);
- }
-
- if (!gtk_icon_source_get_size_wildcarded (source))
- {
- GtkIconSize size = gtk_icon_source_get_size (source);
- str = glade_utils_enum_string_from_value (GTK_TYPE_ICON_SIZE, size);
- g_string_append_printf (string, "size-%s ", str);
- g_free (str);
- }
-
- if (!gtk_icon_source_get_state_wildcarded (source))
- {
- GtkStateType state = gtk_icon_source_get_state (source);
- str = glade_utils_enum_string_from_value (GTK_TYPE_STATE_TYPE, state);
- g_string_append_printf (string, "state-%s ", str);
- g_free (str);
- }
-
- g_string_append_printf (string, "| ");
- }
+serialize_icon_sources (gchar * icon_name, GList * sources, GString * string)
+{
+ GList *l;
+
+ for (l = sources; l; l = g_list_next (l))
+ {
+ GtkIconSource *source = l->data;
+ GdkPixbuf *pixbuf;
+ gchar *str;
+
+ pixbuf = gtk_icon_source_get_pixbuf (source);
+ str = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
+
+ g_string_append_printf (string, "%s[%s] ", icon_name, str);
+
+ if (!gtk_icon_source_get_direction_wildcarded (source))
+ {
+ GtkTextDirection direction = gtk_icon_source_get_direction (source);
+ str =
+ glade_utils_enum_string_from_value (GTK_TYPE_TEXT_DIRECTION,
+ direction);
+ g_string_append_printf (string, "dir-%s ", str);
+ g_free (str);
+ }
+
+ if (!gtk_icon_source_get_size_wildcarded (source))
+ {
+ GtkIconSize size = gtk_icon_source_get_size (source);
+ str = glade_utils_enum_string_from_value (GTK_TYPE_ICON_SIZE, size);
+ g_string_append_printf (string, "size-%s ", str);
+ g_free (str);
+ }
+
+ if (!gtk_icon_source_get_state_wildcarded (source))
+ {
+ GtkStateType state = gtk_icon_source_get_state (source);
+ str = glade_utils_enum_string_from_value (GTK_TYPE_STATE_TYPE, state);
+ g_string_append_printf (string, "state-%s ", str);
+ g_free (str);
+ }
+
+ g_string_append_printf (string, "| ");
+ }
}
gchar *
-glade_gtk_icon_factory_string_from_value (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- const GValue *value)
+glade_gtk_icon_factory_string_from_value (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ const GValue * value)
{
- GString *string;
+ GString *string;
- if (klass->pspec->value_type == GLADE_TYPE_ICON_SOURCES)
- {
- GladeIconSources *sources = g_value_get_boxed (value);
- if (!sources)
- return g_strdup ("");
+ if (klass->pspec->value_type == GLADE_TYPE_ICON_SOURCES)
+ {
+ GladeIconSources *sources = g_value_get_boxed (value);
+ if (!sources)
+ return g_strdup ("");
- string = g_string_new ("");
- g_hash_table_foreach (sources->sources, (GHFunc)serialize_icon_sources, string);
+ string = g_string_new ("");
+ g_hash_table_foreach (sources->sources, (GHFunc) serialize_icon_sources,
+ string);
- return g_string_free (string, FALSE);
- }
- else
- return GWA_GET_CLASS
- (G_TYPE_OBJECT)->string_from_value (adaptor,
- klass,
- value);
+ return g_string_free (string, FALSE);
+ }
+ else
+ return GWA_GET_CLASS
+ (G_TYPE_OBJECT)->string_from_value (adaptor, klass, value);
}
GladeEditorProperty *
-glade_gtk_icon_factory_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
+glade_gtk_icon_factory_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ gboolean use_command)
{
- GladeEditorProperty *eprop;
+ GladeEditorProperty *eprop;
- if (klass->pspec->value_type == GLADE_TYPE_ICON_SOURCES)
- eprop = g_object_new (GLADE_TYPE_EPROP_ICON_SOURCES,
- "property-class", klass,
- "use-command", use_command,
- NULL);
- else
- eprop = GWA_GET_CLASS
- (G_TYPE_OBJECT)->create_eprop (adaptor,
- klass,
- use_command);
- return eprop;
+ if (klass->pspec->value_type == GLADE_TYPE_ICON_SOURCES)
+ eprop = g_object_new (GLADE_TYPE_EPROP_ICON_SOURCES,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ else
+ eprop = GWA_GET_CLASS
+ (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
+ return eprop;
}
GladeEditable *
-glade_gtk_icon_factory_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_icon_factory_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_icon_factory_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_icon_factory_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
@@ -9210,1537 +9219,1562 @@ glade_gtk_icon_factory_create_editable (GladeWidgetAdaptor *adaptor,
#define GLADE_TAG_COL "col"
-static gboolean
-glade_gtk_cell_layout_has_renderer (GtkCellLayout *layout,
- GtkCellRenderer *renderer)
+static gboolean
+glade_gtk_cell_layout_has_renderer (GtkCellLayout * layout,
+ GtkCellRenderer * renderer)
{
- GList *cells = gtk_cell_layout_get_cells (layout);
- gboolean has_renderer;
+ GList *cells = gtk_cell_layout_get_cells (layout);
+ gboolean has_renderer;
- has_renderer = (g_list_find (cells, renderer) != NULL);
+ has_renderer = (g_list_find (cells, renderer) != NULL);
- g_list_free (cells);
+ g_list_free (cells);
- return has_renderer;
+ return has_renderer;
}
static gboolean
-glade_gtk_cell_renderer_sync_attributes (GObject *object)
-{
-
- GtkCellLayout *layout;
- GtkCellRenderer *cell;
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- GladeWidget *gmodel;
- GladeProperty *property;
- gchar *attr_prop_name;
- GList *l, *column_list = NULL;
- gint columns = 0;
- static gint attr_len = 0;
-
- if (!attr_len)
- attr_len = strlen ("attr-");
+glade_gtk_cell_renderer_sync_attributes (GObject * object)
+{
+
+ GtkCellLayout *layout;
+ GtkCellRenderer *cell;
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ GladeWidget *gmodel;
+ GladeProperty *property;
+ gchar *attr_prop_name;
+ GList *l, *column_list = NULL;
+ gint columns = 0;
+ static gint attr_len = 0;
+
+ if (!attr_len)
+ attr_len = strlen ("attr-");
+
+ /* Apply attributes to renderer when bound to a model in runtime */
+ widget = glade_widget_get_from_gobject (object);
+
+ if (widget->parent == NULL)
+ return FALSE;
+
+ /* When creating widgets, sometimes the parent is set before parenting happens,
+ * here we have to be careful for that..
+ */
+ layout = GTK_CELL_LAYOUT (widget->parent->object);
+ cell = GTK_CELL_RENDERER (object);
+
+ if (!glade_gtk_cell_layout_has_renderer (layout, cell))
+ return FALSE;
+
+ if ((gmodel = glade_cell_renderer_get_model (widget)) == NULL)
+ return FALSE;
+
+ glade_widget_property_get (gmodel, "columns", &column_list);
+ columns = g_list_length (column_list);
+
+ gtk_cell_layout_clear_attributes (layout, cell);
+
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
+
+ if (strncmp (property->klass->id, "attr-", attr_len) == 0)
+ {
+ GladeProperty *attr_prop;
+ gint column = g_value_get_int (property->value);
+
+ attr_prop_name = &property->klass->id[attr_len];
+ attr_prop = glade_widget_get_property (widget, attr_prop_name);
+
+ if (column >= 0 && column < columns)
+ {
+ GladeColumnType *column_type =
+ (GladeColumnType *) g_list_nth_data (column_list, column);
+ GType column_gtype = g_type_from_name (column_type->type_name);
+
+ if (column_gtype &&
+ g_value_type_transformable (column_gtype,
+ attr_prop->klass->pspec->
+ value_type))
+ gtk_cell_layout_add_attribute (layout, cell, attr_prop_name,
+ column);
+ }
+ }
+ }
- /* Apply attributes to renderer when bound to a model in runtime */
- widget = glade_widget_get_from_gobject (object);
-
- if (widget->parent == NULL) return FALSE;
+ return FALSE;
+}
- /* When creating widgets, sometimes the parent is set before parenting happens,
- * here we have to be careful for that..
- */
- layout = GTK_CELL_LAYOUT (widget->parent->object);
- cell = GTK_CELL_RENDERER (object);
- if (!glade_gtk_cell_layout_has_renderer (layout, cell))
- return FALSE;
+static gboolean
+glade_gtk_cell_layout_sync_attributes (GObject * layout)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (layout);
+ GObject *cell;
+ GList *children, *l;
- if ((gmodel = glade_cell_renderer_get_model (widget)) == NULL)
- return FALSE;
+ children = glade_widget_adaptor_get_children (gwidget->adaptor, layout);
+ for (l = children; l; l = l->next)
+ {
+ cell = l->data;
+ if (!GTK_IS_CELL_RENDERER (cell))
+ continue;
- glade_widget_property_get (gmodel, "columns", &column_list);
- columns = g_list_length (column_list);
+ glade_gtk_cell_renderer_sync_attributes (cell);
+ }
+ g_list_free (children);
- gtk_cell_layout_clear_attributes (layout, cell);
+ return FALSE;
+}
- for (l = widget->properties; l; l = l->next)
- {
- property = l->data;
+static void
+glade_gtk_store_set_columns (GObject * object, const GValue * value)
+{
+ GList *l;
+ gint i, n;
+ GType *types;
- if (strncmp (property->klass->id, "attr-", attr_len) == 0)
- {
- GladeProperty *attr_prop;
- gint column = g_value_get_int (property->value);
+ for (i = 0, l = g_value_get_boxed (value), n = g_list_length (l), types =
+ g_new (GType, n); l; l = g_list_next (l), i++)
+ {
+ GladeColumnType *data = l->data;
- attr_prop_name = &property->klass->id[attr_len];
- attr_prop = glade_widget_get_property (widget, attr_prop_name);
+ if (g_type_from_name (data->type_name) != G_TYPE_INVALID)
+ types[i] = g_type_from_name (data->type_name);
+ else
+ types[i] = G_TYPE_POINTER;
+ }
- if (column >= 0 && column < columns)
- {
- GladeColumnType *column_type = (GladeColumnType *)g_list_nth_data (column_list, column);
- GType column_gtype = g_type_from_name (column_type->type_name);
+ if (GTK_IS_LIST_STORE (object))
+ gtk_list_store_set_column_types (GTK_LIST_STORE (object), n, types);
+ else
+ gtk_tree_store_set_column_types (GTK_TREE_STORE (object), n, types);
- if (column_gtype &&
- g_value_type_transformable (column_gtype, attr_prop->klass->pspec->value_type))
- gtk_cell_layout_add_attribute (layout, cell, attr_prop_name, column);
- }
- }
- }
+ g_free (types);
+}
- return FALSE;
+static void
+glade_gtk_store_set_data (GObject * object, const GValue * value)
+{
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GList *columns = NULL;
+ GNode *data_tree, *row, *iter;
+ gint colnum;
+ GtkTreeIter row_iter;
+ GladeModelData *data;
+ GType column_type;
+
+ if (GTK_IS_LIST_STORE (object))
+ gtk_list_store_clear (GTK_LIST_STORE (object));
+ else
+ gtk_tree_store_clear (GTK_TREE_STORE (object));
+
+ glade_widget_property_get (gwidget, "columns", &columns);
+ data_tree = g_value_get_boxed (value);
+
+ /* Nothing to enter without columns defined */
+ if (!data_tree || !columns)
+ return;
+
+ for (row = data_tree->children; row; row = row->next)
+ {
+ if (GTK_IS_LIST_STORE (object))
+ gtk_list_store_append (GTK_LIST_STORE (object), &row_iter);
+ else
+ /* (for now no child data... ) */
+ gtk_tree_store_append (GTK_TREE_STORE (object), &row_iter, NULL);
+
+ for (colnum = 0, iter = row->children; iter; colnum++, iter = iter->next)
+ {
+ data = iter->data;
+
+ if (!g_list_nth (columns, colnum))
+ break;
+
+ /* Abort if theres a type mismatch, the widget's being rebuilt
+ * and a sync will come soon with the right values
+ */
+ column_type =
+ gtk_tree_model_get_column_type (GTK_TREE_MODEL (object), colnum);
+ if (G_VALUE_TYPE (&data->value) != column_type)
+ continue;
+
+ if (GTK_IS_LIST_STORE (object))
+ gtk_list_store_set_value (GTK_LIST_STORE (object),
+ &row_iter, colnum, &data->value);
+ else
+ gtk_tree_store_set_value (GTK_TREE_STORE (object),
+ &row_iter, colnum, &data->value);
+ }
+ }
}
+void
+glade_gtk_store_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name, const GValue * value)
+{
+ if (strcmp (property_name, "columns") == 0)
+ {
+ glade_gtk_store_set_columns (object, value);
+ }
+ else if (strcmp (property_name, "data") == 0)
+ {
+ glade_gtk_store_set_data (object, value);
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
+ object, property_name, value);
+}
-static gboolean
-glade_gtk_cell_layout_sync_attributes (GObject *layout)
+GladeEditorProperty *
+glade_gtk_store_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass, gboolean use_command)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (layout);
- GObject *cell;
- GList *children, *l;
+ GladeEditorProperty *eprop;
- children = glade_widget_adaptor_get_children (gwidget->adaptor, layout);
- for (l = children; l; l = l->next)
- {
- cell = l->data;
- if (!GTK_IS_CELL_RENDERER (cell))
- continue;
+ /* chain up.. */
+ if (klass->pspec->value_type == GLADE_TYPE_COLUMN_TYPE_LIST)
+ eprop = g_object_new (GLADE_TYPE_EPROP_COLUMN_TYPES,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ else if (klass->pspec->value_type == GLADE_TYPE_MODEL_DATA_TREE)
+ eprop = g_object_new (GLADE_TYPE_EPROP_MODEL_DATA,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ else
+ eprop = GWA_GET_CLASS
+ (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
+ return eprop;
+}
- glade_gtk_cell_renderer_sync_attributes (cell);
- }
- g_list_free (children);
- return FALSE;
+static void
+glade_gtk_store_columns_changed (GladeProperty * property,
+ GValue * old_value,
+ GValue * new_value, GladeWidget * store)
+{
+ GList *l, *list, *children;
+
+ /* Reset the attributes for all cell renderers referring to this store */
+ for (l = store->prop_refs; l; l = l->next)
+ {
+ GladeWidget *referring_widget = GLADE_PROPERTY (l->data)->widget;
+
+ if (GTK_IS_CELL_LAYOUT (referring_widget->object))
+ glade_gtk_cell_layout_sync_attributes (referring_widget->object);
+ else if (GTK_IS_TREE_VIEW (referring_widget->object))
+ {
+ children =
+ glade_widget_adaptor_get_children (referring_widget->adaptor,
+ referring_widget->object);
+
+ for (list = children; list; list = list->next)
+ {
+ /* Clear the GtkTreeViewColumns... */
+ if (GTK_IS_CELL_LAYOUT (list->data))
+ glade_gtk_cell_layout_sync_attributes (G_OBJECT (list->data));
+ }
+
+ g_list_free (children);
+ }
+ }
}
-static void
-glade_gtk_store_set_columns (GObject *object,
- const GValue *value)
+void
+glade_gtk_store_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GList *l;
- gint i, n;
- GType *types;
-
- for (i = 0, l = g_value_get_boxed (value), n = g_list_length (l), types = g_new (GType, n);
- l; l = g_list_next (l), i++)
- {
- GladeColumnType *data = l->data;
-
- if (g_type_from_name (data->type_name) != G_TYPE_INVALID)
- types[i] = g_type_from_name (data->type_name);
- else
- types[i] = G_TYPE_POINTER;
- }
+ GladeWidget *gwidget;
+ GladeProperty *property;
- if (GTK_IS_LIST_STORE (object))
- gtk_list_store_set_column_types (GTK_LIST_STORE (object), n, types);
- else
- gtk_tree_store_set_column_types (GTK_TREE_STORE (object), n, types);
+ if (reason == GLADE_CREATE_REBUILD)
+ return;
- g_free (types);
-}
-
-static void
-glade_gtk_store_set_data (GObject *object,
- const GValue *value)
-{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- GList *columns = NULL;
- GNode *data_tree, *row, *iter;
- gint colnum;
- GtkTreeIter row_iter;
- GladeModelData *data;
- GType column_type;
-
- if (GTK_IS_LIST_STORE (object))
- gtk_list_store_clear (GTK_LIST_STORE (object));
- else
- gtk_tree_store_clear (GTK_TREE_STORE (object));
-
- glade_widget_property_get (gwidget, "columns", &columns);
- data_tree = g_value_get_boxed (value);
-
- /* Nothing to enter without columns defined */
- if (!data_tree || !columns)
- return;
-
- for (row = data_tree->children; row; row = row->next)
- {
- if (GTK_IS_LIST_STORE (object))
- gtk_list_store_append (GTK_LIST_STORE (object), &row_iter);
- else
- /* (for now no child data... ) */
- gtk_tree_store_append (GTK_TREE_STORE (object), &row_iter, NULL);
-
- for (colnum = 0, iter = row->children; iter;
- colnum++, iter = iter->next)
- {
- data = iter->data;
-
- if (!g_list_nth (columns, colnum))
- break;
-
- /* Abort if theres a type mismatch, the widget's being rebuilt
- * and a sync will come soon with the right values
- */
- column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (object), colnum);
- if (G_VALUE_TYPE (&data->value) != column_type)
- continue;
-
- if (GTK_IS_LIST_STORE (object))
- gtk_list_store_set_value (GTK_LIST_STORE (object),
- &row_iter,
- colnum, &data->value);
- else
- gtk_tree_store_set_value (GTK_TREE_STORE (object),
- &row_iter,
- colnum, &data->value);
- }
- }
-}
-
-void
-glade_gtk_store_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "columns") == 0)
- {
- glade_gtk_store_set_columns (object, value);
- }
- else if (strcmp (property_name, "data") == 0)
- {
- glade_gtk_store_set_data (object, value);
- }
- else
- /* Chain Up */
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
- object,
- property_name,
- value);
-}
+ gwidget = glade_widget_get_from_gobject (object);
+ property = glade_widget_get_property (gwidget, "columns");
-GladeEditorProperty *
-glade_gtk_store_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
-{
- GladeEditorProperty *eprop;
-
- /* chain up.. */
- if (klass->pspec->value_type == GLADE_TYPE_COLUMN_TYPE_LIST)
- eprop = g_object_new (GLADE_TYPE_EPROP_COLUMN_TYPES,
- "property-class", klass,
- "use-command", use_command,
- NULL);
- else if (klass->pspec->value_type == GLADE_TYPE_MODEL_DATA_TREE)
- eprop = g_object_new (GLADE_TYPE_EPROP_MODEL_DATA,
- "property-class", klass,
- "use-command", use_command,
- NULL);
- else
- eprop = GWA_GET_CLASS
- (G_TYPE_OBJECT)->create_eprop (adaptor,
- klass,
- use_command);
- return eprop;
-}
-
-
-static void
-glade_gtk_store_columns_changed (GladeProperty *property,
- GValue *old_value,
- GValue *new_value,
- GladeWidget *store)
-{
- GList *l, *list, *children;
-
- /* Reset the attributes for all cell renderers referring to this store */
- for (l = store->prop_refs; l; l = l->next)
- {
- GladeWidget *referring_widget = GLADE_PROPERTY (l->data)->widget;
-
- if (GTK_IS_CELL_LAYOUT (referring_widget->object))
- glade_gtk_cell_layout_sync_attributes (referring_widget->object);
- else if (GTK_IS_TREE_VIEW (referring_widget->object))
- {
- children = glade_widget_adaptor_get_children (referring_widget->adaptor,
- referring_widget->object);
-
- for (list = children; list; list = list->next)
- {
- /* Clear the GtkTreeViewColumns... */
- if (GTK_IS_CELL_LAYOUT (list->data))
- glade_gtk_cell_layout_sync_attributes (G_OBJECT (list->data));
- }
-
- g_list_free (children);
- }
- }
-}
-
-void
-glade_gtk_store_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GladeWidget *gwidget;
- GladeProperty *property;
-
- if (reason == GLADE_CREATE_REBUILD)
- return;
-
- gwidget = glade_widget_get_from_gobject (object);
- property = glade_widget_get_property (gwidget, "columns");
-
- /* Here we watch the value-changed signal on the "columns" property, we need
- * to reset all the Cell Renderer attributes when the underlying "columns" change,
- * the reason we do it from "value-changed" is because GladeWidget prop references
- * are unavailable while rebuilding an object, and the liststore needs to be rebuilt
- * in order to set the columns.
- *
- * This signal will be envoked after applying the new column types to the store
- * and before the views get any signal to update themselves from the changed model,
- * perfect time to reset the attributes.
- */
- g_signal_connect (G_OBJECT (property), "value-changed",
- G_CALLBACK (glade_gtk_store_columns_changed), gwidget);
+ /* Here we watch the value-changed signal on the "columns" property, we need
+ * to reset all the Cell Renderer attributes when the underlying "columns" change,
+ * the reason we do it from "value-changed" is because GladeWidget prop references
+ * are unavailable while rebuilding an object, and the liststore needs to be rebuilt
+ * in order to set the columns.
+ *
+ * This signal will be envoked after applying the new column types to the store
+ * and before the views get any signal to update themselves from the changed model,
+ * perfect time to reset the attributes.
+ */
+ g_signal_connect (G_OBJECT (property), "value-changed",
+ G_CALLBACK (glade_gtk_store_columns_changed), gwidget);
}
GladeEditable *
-glade_gtk_store_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_store_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *)glade_store_editor_new (adaptor, editable);
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_store_editor_new (adaptor, editable);
- return editable;
+ return editable;
}
gchar *
-glade_gtk_store_string_from_value (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- const GValue *value)
-{
- GString *string;
-
- if (klass->pspec->value_type == GLADE_TYPE_COLUMN_TYPE_LIST)
- {
- GList *l;
- string = g_string_new ("");
- for (l = g_value_get_boxed (value); l; l = g_list_next (l))
- {
- GladeColumnType *data = l->data;
- g_string_append_printf (string, (g_list_next (l)) ? "%s:%s|" : "%s:%s",
- data->type_name, data->column_name);
- }
- return g_string_free (string, FALSE);
- }
- else if (klass->pspec->value_type == GLADE_TYPE_MODEL_DATA_TREE)
- {
- GladeModelData *data;
- GNode *data_tree, *row, *iter;
- gint rownum;
- gchar *str;
- gboolean is_last;
-
- /* Return a unique string for the backend to compare */
- data_tree = g_value_get_boxed (value);
-
- if (!data_tree || !data_tree->children)
- return g_strdup ("");
-
- string = g_string_new ("");
- for (rownum = 0, row = data_tree->children; row;
- rownum++, row = row->next)
- {
- for (iter = row->children; iter; iter = iter->next)
- {
- data = iter->data;
-
- if (!G_VALUE_TYPE (&data->value) ||
- G_VALUE_TYPE (&data->value) == G_TYPE_INVALID)
- str = g_strdup ("(virtual)");
- else if (G_VALUE_TYPE (&data->value) != G_TYPE_POINTER)
- str = glade_utils_string_from_value (&data->value);
- else
- str = g_strdup ("(null)");
-
- is_last = !row->next && !iter->next;
- g_string_append_printf (string, "%s[%d]:%s",
- data->name, rownum, str);
-
- if (data->i18n_translatable)
- g_string_append_printf (string, " translatable");
- if (data->i18n_context)
- g_string_append_printf (string, " i18n-context:%s", data->i18n_context);
- if (data->i18n_comment)
- g_string_append_printf (string, " i18n-comment:%s", data->i18n_comment);
-
- if (!is_last)
- g_string_append_printf (string, "|");
-
- g_free (str);
- }
- }
- return g_string_free (string, FALSE);
- }
- else
- return GWA_GET_CLASS
- (G_TYPE_OBJECT)->string_from_value (adaptor,
- klass,
- value);
+glade_gtk_store_string_from_value (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ const GValue * value)
+{
+ GString *string;
+
+ if (klass->pspec->value_type == GLADE_TYPE_COLUMN_TYPE_LIST)
+ {
+ GList *l;
+ string = g_string_new ("");
+ for (l = g_value_get_boxed (value); l; l = g_list_next (l))
+ {
+ GladeColumnType *data = l->data;
+ g_string_append_printf (string,
+ (g_list_next (l)) ? "%s:%s|" : "%s:%s",
+ data->type_name, data->column_name);
+ }
+ return g_string_free (string, FALSE);
+ }
+ else if (klass->pspec->value_type == GLADE_TYPE_MODEL_DATA_TREE)
+ {
+ GladeModelData *data;
+ GNode *data_tree, *row, *iter;
+ gint rownum;
+ gchar *str;
+ gboolean is_last;
+
+ /* Return a unique string for the backend to compare */
+ data_tree = g_value_get_boxed (value);
+
+ if (!data_tree || !data_tree->children)
+ return g_strdup ("");
+
+ string = g_string_new ("");
+ for (rownum = 0, row = data_tree->children; row;
+ rownum++, row = row->next)
+ {
+ for (iter = row->children; iter; iter = iter->next)
+ {
+ data = iter->data;
+
+ if (!G_VALUE_TYPE (&data->value) ||
+ G_VALUE_TYPE (&data->value) == G_TYPE_INVALID)
+ str = g_strdup ("(virtual)");
+ else if (G_VALUE_TYPE (&data->value) != G_TYPE_POINTER)
+ str = glade_utils_string_from_value (&data->value);
+ else
+ str = g_strdup ("(null)");
+
+ is_last = !row->next && !iter->next;
+ g_string_append_printf (string, "%s[%d]:%s",
+ data->name, rownum, str);
+
+ if (data->i18n_translatable)
+ g_string_append_printf (string, " translatable");
+ if (data->i18n_context)
+ g_string_append_printf (string, " i18n-context:%s",
+ data->i18n_context);
+ if (data->i18n_comment)
+ g_string_append_printf (string, " i18n-comment:%s",
+ data->i18n_comment);
+
+ if (!is_last)
+ g_string_append_printf (string, "|");
+
+ g_free (str);
+ }
+ }
+ return g_string_free (string, FALSE);
+ }
+ else
+ return GWA_GET_CLASS
+ (G_TYPE_OBJECT)->string_from_value (adaptor, klass, value);
}
static void
-glade_gtk_store_write_columns (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeXmlNode *columns_node;
- GladeProperty *prop;
- GList *l;
-
- prop = glade_widget_get_property (widget, "columns");
-
- columns_node = glade_xml_node_new (context, GLADE_TAG_COLUMNS);
-
- for (l = g_value_get_boxed (prop->value); l; l = g_list_next (l))
- {
- GladeColumnType *data = l->data;
- GladeXmlNode *column_node, *comment_node;
-
- /* Write column names in comments... */
- gchar *comment = g_strdup_printf (" column-name %s ", data->column_name);
- comment_node = glade_xml_node_new_comment (context, comment);
- glade_xml_node_append_child (columns_node, comment_node);
- g_free (comment);
-
- column_node = glade_xml_node_new (context, GLADE_TAG_COLUMN);
- glade_xml_node_append_child (columns_node, column_node);
- glade_xml_node_set_property_string (column_node, GLADE_TAG_TYPE,
- data->type_name);
- }
-
- if (!glade_xml_node_get_children (columns_node))
- glade_xml_node_delete (columns_node);
- else
- glade_xml_node_append_child (node, columns_node);
+glade_gtk_store_write_columns (GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+ GladeXmlNode *columns_node;
+ GladeProperty *prop;
+ GList *l;
+
+ prop = glade_widget_get_property (widget, "columns");
+
+ columns_node = glade_xml_node_new (context, GLADE_TAG_COLUMNS);
+
+ for (l = g_value_get_boxed (prop->value); l; l = g_list_next (l))
+ {
+ GladeColumnType *data = l->data;
+ GladeXmlNode *column_node, *comment_node;
+
+ /* Write column names in comments... */
+ gchar *comment = g_strdup_printf (" column-name %s ", data->column_name);
+ comment_node = glade_xml_node_new_comment (context, comment);
+ glade_xml_node_append_child (columns_node, comment_node);
+ g_free (comment);
+
+ column_node = glade_xml_node_new (context, GLADE_TAG_COLUMN);
+ glade_xml_node_append_child (columns_node, column_node);
+ glade_xml_node_set_property_string (column_node, GLADE_TAG_TYPE,
+ data->type_name);
+ }
+
+ if (!glade_xml_node_get_children (columns_node))
+ glade_xml_node_delete (columns_node);
+ else
+ glade_xml_node_append_child (node, columns_node);
}
static void
-glade_gtk_store_write_data (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- GladeXmlNode *data_node, *col_node, *row_node;
- GList *columns = NULL;
- GladeModelData *data;
- GNode *data_tree = NULL, *row, *iter;
- gint colnum;
-
- glade_widget_property_get (widget, "data", &data_tree);
- glade_widget_property_get (widget, "columns", &columns);
-
- /* XXX log errors about data not fitting columns here when
- * loggin is available
- */
- if (!data_tree || !columns)
- return;
-
- data_node = glade_xml_node_new (context, GLADE_TAG_DATA);
-
- for (row = data_tree->children; row; row = row->next)
- {
- row_node = glade_xml_node_new (context, GLADE_TAG_ROW);
- glade_xml_node_append_child (data_node, row_node);
-
- for (colnum = 0, iter = row->children; iter;
- colnum++, iter = iter->next)
- {
- gchar *string, *column_number;
-
- data = iter->data;
-
- /* Skip non-serializable data */
- if (G_VALUE_TYPE (&data->value) == 0 ||
- G_VALUE_TYPE (&data->value) == G_TYPE_POINTER)
- continue;
-
- string = glade_utils_string_from_value (&data->value);
-
- /* XXX Log error: data col j exceeds columns on row i */
- if (!g_list_nth (columns, colnum))
- break;
-
- column_number = g_strdup_printf ("%d", colnum);
-
- col_node = glade_xml_node_new (context, GLADE_TAG_COL);
- glade_xml_node_append_child (row_node, col_node);
- glade_xml_node_set_property_string (col_node, GLADE_TAG_ID,
- column_number);
- glade_xml_set_content (col_node, string);
-
- if (data->i18n_translatable)
- glade_xml_node_set_property_string (col_node,
- GLADE_TAG_TRANSLATABLE,
- GLADE_XML_TAG_I18N_TRUE);
- if (data->i18n_context)
- glade_xml_node_set_property_string (col_node,
- GLADE_TAG_CONTEXT,
- data->i18n_context);
- if (data->i18n_comment)
- glade_xml_node_set_property_string (col_node,
- GLADE_TAG_COMMENT,
- data->i18n_comment);
-
-
- g_free (column_number);
- g_free (string);
- }
- }
-
- if (!glade_xml_node_get_children (data_node))
- glade_xml_node_delete (data_node);
- else
- glade_xml_node_append_child (node, data_node);
-}
-
-
-void
-glade_gtk_store_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
-{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and write all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
-
- glade_gtk_store_write_columns (widget, context, node);
- glade_gtk_store_write_data (widget, context, node);
+glade_gtk_store_write_data (GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+ GladeXmlNode *data_node, *col_node, *row_node;
+ GList *columns = NULL;
+ GladeModelData *data;
+ GNode *data_tree = NULL, *row, *iter;
+ gint colnum;
+
+ glade_widget_property_get (widget, "data", &data_tree);
+ glade_widget_property_get (widget, "columns", &columns);
+
+ /* XXX log errors about data not fitting columns here when
+ * loggin is available
+ */
+ if (!data_tree || !columns)
+ return;
+
+ data_node = glade_xml_node_new (context, GLADE_TAG_DATA);
+
+ for (row = data_tree->children; row; row = row->next)
+ {
+ row_node = glade_xml_node_new (context, GLADE_TAG_ROW);
+ glade_xml_node_append_child (data_node, row_node);
+
+ for (colnum = 0, iter = row->children; iter; colnum++, iter = iter->next)
+ {
+ gchar *string, *column_number;
+
+ data = iter->data;
+
+ /* Skip non-serializable data */
+ if (G_VALUE_TYPE (&data->value) == 0 ||
+ G_VALUE_TYPE (&data->value) == G_TYPE_POINTER)
+ continue;
+
+ string = glade_utils_string_from_value (&data->value);
+
+ /* XXX Log error: data col j exceeds columns on row i */
+ if (!g_list_nth (columns, colnum))
+ break;
+
+ column_number = g_strdup_printf ("%d", colnum);
+
+ col_node = glade_xml_node_new (context, GLADE_TAG_COL);
+ glade_xml_node_append_child (row_node, col_node);
+ glade_xml_node_set_property_string (col_node, GLADE_TAG_ID,
+ column_number);
+ glade_xml_set_content (col_node, string);
+
+ if (data->i18n_translatable)
+ glade_xml_node_set_property_string (col_node,
+ GLADE_TAG_TRANSLATABLE,
+ GLADE_XML_TAG_I18N_TRUE);
+ if (data->i18n_context)
+ glade_xml_node_set_property_string (col_node,
+ GLADE_TAG_CONTEXT,
+ data->i18n_context);
+ if (data->i18n_comment)
+ glade_xml_node_set_property_string (col_node,
+ GLADE_TAG_COMMENT,
+ data->i18n_comment);
+
+
+ g_free (column_number);
+ g_free (string);
+ }
+ }
+
+ if (!glade_xml_node_get_children (data_node))
+ glade_xml_node_delete (data_node);
+ else
+ glade_xml_node_append_child (node, data_node);
+}
+
+
+void
+glade_gtk_store_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context, GladeXmlNode * node)
+{
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and write all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+
+ glade_gtk_store_write_columns (widget, context, node);
+ glade_gtk_store_write_data (widget, context, node);
}
static void
-glade_gtk_store_read_columns (GladeWidget *widget, GladeXmlNode *node)
-{
- GladeNameContext *context;
- GladeXmlNode *columns_node;
- GladeProperty *property;
- GladeXmlNode *prop;
- GList *types = NULL;
- GValue value = {0,};
- gchar column_name[256];
-
- column_name[0] = '\0';
- column_name[255] = '\0';
-
- if ((columns_node = glade_xml_search_child (node, GLADE_TAG_COLUMNS)) == NULL)
- return;
-
- context = glade_name_context_new ();
-
- for (prop = glade_xml_node_get_children_with_comments (columns_node); prop;
- prop = glade_xml_node_next_with_comments (prop))
- {
- GladeColumnType *data;
- gchar *type, *comment_str, buffer[256];
-
- if (!glade_xml_node_verify_silent (prop, GLADE_TAG_COLUMN) &&
- !glade_xml_node_is_comment (prop)) continue;
-
- if (glade_xml_node_is_comment (prop))
- {
- comment_str = glade_xml_get_content (prop);
- if (sscanf (comment_str, " column-name %s", buffer) == 1)
- strncpy (column_name, buffer, 255);
-
- g_free (comment_str);
- continue;
- }
-
- type = glade_xml_get_property_string_required (prop, GLADE_TAG_TYPE, NULL);
-
- data = glade_column_type_new (type, NULL);
- data->type_name = g_strdup (type);
- data->column_name = column_name[0] ? g_strdup (column_name) : g_ascii_strdown (type, -1);
-
- if (glade_name_context_has_name (context, data->column_name))
- {
- gchar *name = glade_name_context_new_name (context, data->column_name);
- g_free (data->column_name);
- data->column_name = name;
- }
- glade_name_context_add_name (context, data->column_name);
-
- types = g_list_prepend (types, data);
- g_free (type);
-
- column_name[0] = '\0';
- }
-
- property = glade_widget_get_property (widget, "columns");
- g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
- g_value_take_boxed (&value, g_list_reverse (types));
- glade_property_set_value (property, &value);
- g_value_unset (&value);
+glade_gtk_store_read_columns (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeNameContext *context;
+ GladeXmlNode *columns_node;
+ GladeProperty *property;
+ GladeXmlNode *prop;
+ GList *types = NULL;
+ GValue value = { 0, };
+ gchar column_name[256];
+
+ column_name[0] = '\0';
+ column_name[255] = '\0';
+
+ if ((columns_node = glade_xml_search_child (node, GLADE_TAG_COLUMNS)) == NULL)
+ return;
+
+ context = glade_name_context_new ();
+
+ for (prop = glade_xml_node_get_children_with_comments (columns_node); prop;
+ prop = glade_xml_node_next_with_comments (prop))
+ {
+ GladeColumnType *data;
+ gchar *type, *comment_str, buffer[256];
+
+ if (!glade_xml_node_verify_silent (prop, GLADE_TAG_COLUMN) &&
+ !glade_xml_node_is_comment (prop))
+ continue;
+
+ if (glade_xml_node_is_comment (prop))
+ {
+ comment_str = glade_xml_get_content (prop);
+ if (sscanf (comment_str, " column-name %s", buffer) == 1)
+ strncpy (column_name, buffer, 255);
+
+ g_free (comment_str);
+ continue;
+ }
+
+ type =
+ glade_xml_get_property_string_required (prop, GLADE_TAG_TYPE, NULL);
+
+ data = glade_column_type_new (type, NULL);
+ data->type_name = g_strdup (type);
+ data->column_name =
+ column_name[0] ? g_strdup (column_name) : g_ascii_strdown (type, -1);
+
+ if (glade_name_context_has_name (context, data->column_name))
+ {
+ gchar *name =
+ glade_name_context_new_name (context, data->column_name);
+ g_free (data->column_name);
+ data->column_name = name;
+ }
+ glade_name_context_add_name (context, data->column_name);
+
+ types = g_list_prepend (types, data);
+ g_free (type);
+
+ column_name[0] = '\0';
+ }
+
+ property = glade_widget_get_property (widget, "columns");
+ g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
+ g_value_take_boxed (&value, g_list_reverse (types));
+ glade_property_set_value (property, &value);
+ g_value_unset (&value);
}
static void
-glade_gtk_store_read_data (GladeWidget *widget, GladeXmlNode *node)
-{
- GladeXmlNode *data_node, *row_node, *col_node;
- GNode *data_tree, *row, *item;
- GladeModelData *data;
- GValue *value;
- GList *column_types = NULL;
- GladeColumnType *column_type;
- gint colnum;
-
- if ((data_node = glade_xml_search_child (node, GLADE_TAG_DATA)) == NULL)
- return;
-
- /* XXX FIXME: Warn that columns werent there when parsing */
- if (!glade_widget_property_get (widget, "columns", &column_types) || !column_types)
- return;
-
- /* Create root... */
- data_tree = g_node_new (NULL);
-
- for (row_node = glade_xml_node_get_children (data_node); row_node;
- row_node = glade_xml_node_next (row_node))
- {
- gchar *value_str;
-
- if (!glade_xml_node_verify (row_node, GLADE_TAG_ROW))
- continue;
-
- row = g_node_new (NULL);
- g_node_append (data_tree, row);
-
- /* XXX FIXME: we are assuming that the columns are listed in order */
- for (colnum = 0, col_node = glade_xml_node_get_children (row_node); col_node;
- col_node = glade_xml_node_next (col_node))
- {
- gint read_column;
-
- if (!glade_xml_node_verify (col_node, GLADE_TAG_COL))
- continue;
-
- read_column = glade_xml_get_property_int (col_node, GLADE_TAG_ID, -1);
- if (read_column < 0)
- {
- g_critical ("Parsed negative column id");
- continue;
- }
-
- /* Catch up for gaps in the list where unserializable types are involved */
- while (colnum < read_column)
- {
- column_type = g_list_nth_data (column_types, colnum);
-
- data = glade_model_data_new (G_TYPE_INVALID, column_type->column_name);
-
- item = g_node_new (data);
- g_node_append (row, item);
-
- colnum++;
- }
-
- if (!(column_type = g_list_nth_data (column_types, colnum)))
- /* XXX Log this too... */
- continue;
-
- /* Ignore unloaded column types for the workspace */
- if (g_type_from_name (column_type->type_name) != G_TYPE_INVALID)
- {
- /* XXX Do we need object properties to somehow work at load time here ??
- * should we be doing this part in "finished" ? ... todo thinkso...
- */
- value_str = glade_xml_get_content (col_node);
- value = glade_utils_value_from_string
- (g_type_from_name (column_type->type_name), value_str, widget->project, widget);
- g_free (value_str);
-
- data = glade_model_data_new (g_type_from_name (column_type->type_name),
- column_type->column_name);
-
- g_value_copy (value, &data->value);
- g_value_unset (value);
- g_free (value);
- }
- else
- {
- data = glade_model_data_new (G_TYPE_INVALID, column_type->column_name);
- }
-
- data->i18n_translatable = glade_xml_get_property_boolean (col_node, GLADE_TAG_TRANSLATABLE, FALSE);
- data->i18n_context = glade_xml_get_property_string (col_node, GLADE_TAG_CONTEXT);
- data->i18n_comment = glade_xml_get_property_string (col_node, GLADE_TAG_COMMENT);
-
- item = g_node_new (data);
- g_node_append (row, item);
-
- /* dont increment colnum on invalid xml tags... */
- colnum++;
- }
- }
-
- if (data_tree->children)
- glade_widget_property_set (widget, "data", data_tree);
-
- glade_model_data_tree_free (data_tree);
-}
-
-void
-glade_gtk_store_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
-
- glade_gtk_store_read_columns (widget, node);
-
- if (GTK_IS_LIST_STORE (widget->object))
- glade_gtk_store_read_data (widget, node);
+glade_gtk_store_read_data (GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode *data_node, *row_node, *col_node;
+ GNode *data_tree, *row, *item;
+ GladeModelData *data;
+ GValue *value;
+ GList *column_types = NULL;
+ GladeColumnType *column_type;
+ gint colnum;
+
+ if ((data_node = glade_xml_search_child (node, GLADE_TAG_DATA)) == NULL)
+ return;
+
+ /* XXX FIXME: Warn that columns werent there when parsing */
+ if (!glade_widget_property_get (widget, "columns", &column_types) ||
+ !column_types)
+ return;
+
+ /* Create root... */
+ data_tree = g_node_new (NULL);
+
+ for (row_node = glade_xml_node_get_children (data_node); row_node;
+ row_node = glade_xml_node_next (row_node))
+ {
+ gchar *value_str;
+
+ if (!glade_xml_node_verify (row_node, GLADE_TAG_ROW))
+ continue;
+
+ row = g_node_new (NULL);
+ g_node_append (data_tree, row);
+
+ /* XXX FIXME: we are assuming that the columns are listed in order */
+ for (colnum = 0, col_node = glade_xml_node_get_children (row_node);
+ col_node; col_node = glade_xml_node_next (col_node))
+ {
+ gint read_column;
+
+ if (!glade_xml_node_verify (col_node, GLADE_TAG_COL))
+ continue;
+
+ read_column = glade_xml_get_property_int (col_node, GLADE_TAG_ID, -1);
+ if (read_column < 0)
+ {
+ g_critical ("Parsed negative column id");
+ continue;
+ }
+
+ /* Catch up for gaps in the list where unserializable types are involved */
+ while (colnum < read_column)
+ {
+ column_type = g_list_nth_data (column_types, colnum);
+
+ data =
+ glade_model_data_new (G_TYPE_INVALID,
+ column_type->column_name);
+
+ item = g_node_new (data);
+ g_node_append (row, item);
+
+ colnum++;
+ }
+
+ if (!(column_type = g_list_nth_data (column_types, colnum)))
+ /* XXX Log this too... */
+ continue;
+
+ /* Ignore unloaded column types for the workspace */
+ if (g_type_from_name (column_type->type_name) != G_TYPE_INVALID)
+ {
+ /* XXX Do we need object properties to somehow work at load time here ??
+ * should we be doing this part in "finished" ? ... todo thinkso...
+ */
+ value_str = glade_xml_get_content (col_node);
+ value = glade_utils_value_from_string
+ (g_type_from_name (column_type->type_name), value_str,
+ widget->project, widget);
+ g_free (value_str);
+
+ data =
+ glade_model_data_new (g_type_from_name
+ (column_type->type_name),
+ column_type->column_name);
+
+ g_value_copy (value, &data->value);
+ g_value_unset (value);
+ g_free (value);
+ }
+ else
+ {
+ data =
+ glade_model_data_new (G_TYPE_INVALID,
+ column_type->column_name);
+ }
+
+ data->i18n_translatable =
+ glade_xml_get_property_boolean (col_node, GLADE_TAG_TRANSLATABLE,
+ FALSE);
+ data->i18n_context =
+ glade_xml_get_property_string (col_node, GLADE_TAG_CONTEXT);
+ data->i18n_comment =
+ glade_xml_get_property_string (col_node, GLADE_TAG_COMMENT);
+
+ item = g_node_new (data);
+ g_node_append (row, item);
+
+ /* dont increment colnum on invalid xml tags... */
+ colnum++;
+ }
+ }
+
+ if (data_tree->children)
+ glade_widget_property_set (widget, "data", data_tree);
+
+ glade_model_data_tree_free (data_tree);
+}
+
+void
+glade_gtk_store_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+
+ glade_gtk_store_read_columns (widget, node);
+
+ if (GTK_IS_LIST_STORE (widget->object))
+ glade_gtk_store_read_data (widget, node);
}
/*--------------------------- GtkCellRenderer ---------------------------------*/
-static void glade_gtk_treeview_launch_editor (GObject *treeview);
-
-void
-glade_gtk_cell_renderer_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
-{
- if (strcmp (action_path, "launch_editor") == 0)
- {
- GladeWidget *w = glade_widget_get_from_gobject (object);
-
- while ((w = glade_widget_get_parent (w)))
- {
- if (GTK_IS_TREE_VIEW (w->object))
- {
- glade_gtk_treeview_launch_editor (w->object);
- break;
- }
- }
- }
- else
- GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
- object,
- action_path);
-}
-
-void
-glade_gtk_cell_renderer_deep_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GladePropertyClass *pclass;
- GladeProperty *property;
- GladeWidget *widget;
- GList *l;
-
- widget = glade_widget_get_from_gobject (object);
-
- for (l = adaptor->properties; l; l = l->next)
- {
- pclass = l->data;
-
- if (strncmp (pclass->id, "use-attr-", strlen ("use-attr-")) == 0)
- {
- property = glade_widget_get_property (widget, pclass->id);
- glade_property_sync (property);
- }
- }
-
- g_idle_add ((GSourceFunc)glade_gtk_cell_renderer_sync_attributes, widget->object);
+static void glade_gtk_treeview_launch_editor (GObject * treeview);
+
+void
+glade_gtk_cell_renderer_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
+{
+ if (strcmp (action_path, "launch_editor") == 0)
+ {
+ GladeWidget *w = glade_widget_get_from_gobject (object);
+
+ while ((w = glade_widget_get_parent (w)))
+ {
+ if (GTK_IS_TREE_VIEW (w->object))
+ {
+ glade_gtk_treeview_launch_editor (w->object);
+ break;
+ }
+ }
+ }
+ else
+ GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
+ object, action_path);
+}
+
+void
+glade_gtk_cell_renderer_deep_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ GladeCreateReason reason)
+{
+ GladePropertyClass *pclass;
+ GladeProperty *property;
+ GladeWidget *widget;
+ GList *l;
+
+ widget = glade_widget_get_from_gobject (object);
+
+ for (l = adaptor->properties; l; l = l->next)
+ {
+ pclass = l->data;
+
+ if (strncmp (pclass->id, "use-attr-", strlen ("use-attr-")) == 0)
+ {
+ property = glade_widget_get_property (widget, pclass->id);
+ glade_property_sync (property);
+ }
+ }
+
+ g_idle_add ((GSourceFunc) glade_gtk_cell_renderer_sync_attributes,
+ widget->object);
}
GladeEditorProperty *
-glade_gtk_cell_renderer_create_eprop (GladeWidgetAdaptor *adaptor,
- GladePropertyClass *klass,
- gboolean use_command)
+glade_gtk_cell_renderer_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass,
+ gboolean use_command)
{
- GladeEditorProperty *eprop;
+ GladeEditorProperty *eprop;
- if (strncmp (klass->id, "attr-", strlen ("attr-")) == 0)
- eprop = g_object_new (GLADE_TYPE_EPROP_CELL_ATTRIBUTE,
- "property-class", klass,
- "use-command", use_command,
- NULL);
- else
- eprop = GWA_GET_CLASS
- (G_TYPE_OBJECT)->create_eprop (adaptor,
- klass,
- use_command);
- return eprop;
+ if (strncmp (klass->id, "attr-", strlen ("attr-")) == 0)
+ eprop = g_object_new (GLADE_TYPE_EPROP_CELL_ATTRIBUTE,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ else
+ eprop = GWA_GET_CLASS
+ (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
+ return eprop;
}
GladeEditable *
-glade_gtk_cell_renderer_create_editable (GladeWidgetAdaptor *adaptor,
- GladeEditorPageType type)
+glade_gtk_cell_renderer_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
{
- GladeEditable *editable;
+ GladeEditable *editable;
- /* Get base editable */
- editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
+ /* Get base editable */
+ editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
- if (type == GLADE_PAGE_GENERAL || type == GLADE_PAGE_COMMON)
- return (GladeEditable *)glade_cell_renderer_editor_new (adaptor, type, editable);
+ if (type == GLADE_PAGE_GENERAL || type == GLADE_PAGE_COMMON)
+ return (GladeEditable *) glade_cell_renderer_editor_new (adaptor, type,
+ editable);
- return editable;
+ return editable;
}
static void
-glade_gtk_cell_renderer_set_use_attribute (GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_cell_renderer_set_use_attribute (GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- gchar *attr_prop_name, *prop_msg, *attr_msg;
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ gchar *attr_prop_name, *prop_msg, *attr_msg;
- attr_prop_name = g_strdup_printf ("attr-%s", property_name);
+ attr_prop_name = g_strdup_printf ("attr-%s", property_name);
- prop_msg = g_strdup_printf (_("%s is set to load %s from the model"),
- widget->name, property_name);
- attr_msg = g_strdup_printf (_("%s is set to manipulate %s directly"),
- widget->name, attr_prop_name);
+ prop_msg = g_strdup_printf (_("%s is set to load %s from the model"),
+ widget->name, property_name);
+ attr_msg = g_strdup_printf (_("%s is set to manipulate %s directly"),
+ widget->name, attr_prop_name);
- glade_widget_property_set_sensitive (widget, property_name, FALSE, prop_msg);
- glade_widget_property_set_sensitive (widget, attr_prop_name, FALSE, attr_msg);
+ glade_widget_property_set_sensitive (widget, property_name, FALSE, prop_msg);
+ glade_widget_property_set_sensitive (widget, attr_prop_name, FALSE, attr_msg);
- if (g_value_get_boolean (value))
- glade_widget_property_set_sensitive (widget, attr_prop_name, TRUE, NULL);
- else
- {
- GladeProperty *property = glade_widget_get_property (widget, property_name);
+ if (g_value_get_boolean (value))
+ glade_widget_property_set_sensitive (widget, attr_prop_name, TRUE, NULL);
+ else
+ {
+ GladeProperty *property =
+ glade_widget_get_property (widget, property_name);
- glade_property_set_sensitive (property, TRUE, NULL);
- glade_property_sync (property);
- }
+ glade_property_set_sensitive (property, TRUE, NULL);
+ glade_property_sync (property);
+ }
- g_free (prop_msg);
- g_free (attr_msg);
- g_free (attr_prop_name);
+ g_free (prop_msg);
+ g_free (attr_msg);
+ g_free (attr_prop_name);
}
static GladeProperty *
-glade_gtk_cell_renderer_attribute_switch (GladeWidget *gwidget,
- const gchar *property_name)
+glade_gtk_cell_renderer_attribute_switch (GladeWidget * gwidget,
+ const gchar * property_name)
{
- GladeProperty *property;
- gchar *use_attr_name = g_strdup_printf ("use-attr-%s", property_name);
+ GladeProperty *property;
+ gchar *use_attr_name = g_strdup_printf ("use-attr-%s", property_name);
- property = glade_widget_get_property (gwidget, use_attr_name);
- g_free (use_attr_name);
+ property = glade_widget_get_property (gwidget, use_attr_name);
+ g_free (use_attr_name);
- return property;
+ return property;
}
static gboolean
-glade_gtk_cell_renderer_property_enabled (GObject *object,
- const gchar *property_name)
+glade_gtk_cell_renderer_property_enabled (GObject * object,
+ const gchar * property_name)
{
- GladeProperty *property;
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- gboolean use_attr = TRUE;
+ GladeProperty *property;
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ gboolean use_attr = TRUE;
- if ((property =
- glade_gtk_cell_renderer_attribute_switch (gwidget, property_name)) != NULL)
- glade_property_get (property, &use_attr);
+ if ((property =
+ glade_gtk_cell_renderer_attribute_switch (gwidget,
+ property_name)) != NULL)
+ glade_property_get (property, &use_attr);
- return !use_attr;
+ return !use_attr;
}
void
-glade_gtk_cell_renderer_set_property (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_cell_renderer_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * property_name,
+ const GValue * value)
{
- static gint use_attr_len = 0;
- static gint attr_len = 0;
+ static gint use_attr_len = 0;
+ static gint attr_len = 0;
- if (!attr_len)
- {
- use_attr_len = strlen ("use-attr-");
- attr_len = strlen ("attr-");
- }
+ if (!attr_len)
+ {
+ use_attr_len = strlen ("use-attr-");
+ attr_len = strlen ("attr-");
+ }
- if (strncmp (property_name, "use-attr-", use_attr_len) == 0)
- glade_gtk_cell_renderer_set_use_attribute (object, &property_name[use_attr_len], value);
- else if (strncmp (property_name, "attr-", attr_len) == 0)
- glade_gtk_cell_renderer_sync_attributes (object);
- else if (glade_gtk_cell_renderer_property_enabled (object, property_name))
- /* Chain Up */
- GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
- object,
- property_name,
- value);
+ if (strncmp (property_name, "use-attr-", use_attr_len) == 0)
+ glade_gtk_cell_renderer_set_use_attribute (object,
+ &property_name[use_attr_len],
+ value);
+ else if (strncmp (property_name, "attr-", attr_len) == 0)
+ glade_gtk_cell_renderer_sync_attributes (object);
+ else if (glade_gtk_cell_renderer_property_enabled (object, property_name))
+ /* Chain Up */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor,
+ object, property_name, value);
}
static void
-glade_gtk_cell_renderer_write_properties (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_cell_renderer_write_properties (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeProperty *property, *prop;
- gchar *attr_name;
- GList *l;
- static gint attr_len = 0;
+ GladeProperty *property, *prop;
+ gchar *attr_name;
+ GList *l;
+ static gint attr_len = 0;
- if (!attr_len)
- attr_len = strlen ("attr-");
+ if (!attr_len)
+ attr_len = strlen ("attr-");
- for (l = widget->properties; l; l = l->next)
- {
- property = l->data;
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
- if (strncmp (property->klass->id, "attr-", attr_len) == 0)
- {
- gchar *use_attr_str;
- gboolean use_attr = FALSE;
+ if (strncmp (property->klass->id, "attr-", attr_len) == 0)
+ {
+ gchar *use_attr_str;
+ gboolean use_attr = FALSE;
- use_attr_str = g_strdup_printf ("use-%s", property->klass->id);
- glade_widget_property_get (widget, use_attr_str, &use_attr);
+ use_attr_str = g_strdup_printf ("use-%s", property->klass->id);
+ glade_widget_property_get (widget, use_attr_str, &use_attr);
- attr_name = &property->klass->id[attr_len];
- prop = glade_widget_get_property (widget, attr_name);
+ attr_name = &property->klass->id[attr_len];
+ prop = glade_widget_get_property (widget, attr_name);
- if (!use_attr && prop)
- glade_property_write (prop, context, node);
+ if (!use_attr && prop)
+ glade_property_write (prop, context, node);
- g_free (use_attr_str);
- }
- }
+ g_free (use_attr_str);
+ }
+ }
}
void
-glade_gtk_cell_renderer_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_cell_renderer_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* Write our normal properties, then chain up to write any other normal properties,
- * then attributes
- */
- glade_gtk_cell_renderer_write_properties (widget, context, node);
+ /* Write our normal properties, then chain up to write any other normal properties,
+ * then attributes
+ */
+ glade_gtk_cell_renderer_write_properties (widget, context, node);
- GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
}
static void
-glade_gtk_cell_renderer_parse_finished (GladeProject *project,
- GladeWidget *widget)
-{
- GladeProperty *property;
- GList *l;
- static gint attr_len = 0, use_attr_len = 0;
-
- /* Set "use-attr-*" everywhere that the object property is non-default
- *
- * We do this in the finished handler because some properties may be
- * object type properties (which may be anywhere in the glade file).
- */
- if (!attr_len)
- {
- attr_len = strlen ("attr-");
- use_attr_len = strlen ("use-attr-");
- }
-
- for (l = widget->properties; l; l = l->next)
- {
- GladeProperty *switch_prop;
- property = l->data;
-
- if (strncmp (property->klass->id, "attr-", attr_len) != 0 &&
- strncmp (property->klass->id, "use-attr-", use_attr_len) != 0 &&
- (switch_prop =
- glade_gtk_cell_renderer_attribute_switch (widget, property->klass->id)) != NULL)
- {
- if (glade_property_original_default (property))
- glade_property_set (switch_prop, TRUE);
- else
- glade_property_set (switch_prop, FALSE);
- }
- }
-}
-
-void
-glade_gtk_cell_renderer_read_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
-
- /* First chain up and read in all the properties... */
- GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
-
- g_signal_connect (widget->project, "parse-finished",
- G_CALLBACK (glade_gtk_cell_renderer_parse_finished),
- widget);
+glade_gtk_cell_renderer_parse_finished (GladeProject * project,
+ GladeWidget * widget)
+{
+ GladeProperty *property;
+ GList *l;
+ static gint attr_len = 0, use_attr_len = 0;
+
+ /* Set "use-attr-*" everywhere that the object property is non-default
+ *
+ * We do this in the finished handler because some properties may be
+ * object type properties (which may be anywhere in the glade file).
+ */
+ if (!attr_len)
+ {
+ attr_len = strlen ("attr-");
+ use_attr_len = strlen ("use-attr-");
+ }
+
+ for (l = widget->properties; l; l = l->next)
+ {
+ GladeProperty *switch_prop;
+ property = l->data;
+
+ if (strncmp (property->klass->id, "attr-", attr_len) != 0 &&
+ strncmp (property->klass->id, "use-attr-", use_attr_len) != 0 &&
+ (switch_prop =
+ glade_gtk_cell_renderer_attribute_switch (widget,
+ property->klass->id)) !=
+ NULL)
+ {
+ if (glade_property_original_default (property))
+ glade_property_set (switch_prop, TRUE);
+ else
+ glade_property_set (switch_prop, FALSE);
+ }
+ }
+}
+
+void
+glade_gtk_cell_renderer_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ /* First chain up and read in all the properties... */
+ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+
+ g_signal_connect (widget->project, "parse-finished",
+ G_CALLBACK (glade_gtk_cell_renderer_parse_finished),
+ widget);
}
/*--------------------------- GtkCellLayout ---------------------------------*/
void
-glade_gtk_cell_layout_add_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_gtk_cell_layout_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- GladeWidget *gmodel = NULL;
- GladeWidget *grenderer = glade_widget_get_from_gobject (child);
+ GladeWidget *gmodel = NULL;
+ GladeWidget *grenderer = glade_widget_get_from_gobject (child);
- if (GTK_IS_ICON_VIEW (container) &&
- (gmodel = glade_cell_renderer_get_model (grenderer)) != NULL)
- gtk_icon_view_set_model (GTK_ICON_VIEW (container), NULL);
+ if (GTK_IS_ICON_VIEW (container) &&
+ (gmodel = glade_cell_renderer_get_model (grenderer)) != NULL)
+ gtk_icon_view_set_model (GTK_ICON_VIEW (container), NULL);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (container), GTK_CELL_RENDERER (child), TRUE);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (container),
+ GTK_CELL_RENDERER (child), TRUE);
- if (gmodel)
- gtk_icon_view_set_model (GTK_ICON_VIEW (container), GTK_TREE_MODEL (gmodel->object));
+ if (gmodel)
+ gtk_icon_view_set_model (GTK_ICON_VIEW (container),
+ GTK_TREE_MODEL (gmodel->object));
- glade_gtk_cell_renderer_sync_attributes (child);
+ glade_gtk_cell_renderer_sync_attributes (child);
}
void
-glade_gtk_cell_layout_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_gtk_cell_layout_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- GtkCellLayout *layout = GTK_CELL_LAYOUT (container);
- GList *l, *children = gtk_cell_layout_get_cells (layout);
-
- /* Add a reference to every cell except the one we want to remove */
- for (l = children; l; l = g_list_next (l))
- if (l->data != child)
- g_object_ref (l->data);
- else
- l->data = NULL;
+ GtkCellLayout *layout = GTK_CELL_LAYOUT (container);
+ GList *l, *children = gtk_cell_layout_get_cells (layout);
- /* remove every cell */
- gtk_cell_layout_clear (layout);
+ /* Add a reference to every cell except the one we want to remove */
+ for (l = children; l; l = g_list_next (l))
+ if (l->data != child)
+ g_object_ref (l->data);
+ else
+ l->data = NULL;
- /* pack others cell renderers */
- for (l = children; l; l = g_list_next (l))
- {
- if (l->data == NULL) continue;
-
- gtk_cell_layout_pack_start (layout,
- GTK_CELL_RENDERER (l->data), TRUE);
+ /* remove every cell */
+ gtk_cell_layout_clear (layout);
- /* Remove our transient reference */
- g_object_unref (l->data);
- }
+ /* pack others cell renderers */
+ for (l = children; l; l = g_list_next (l))
+ {
+ if (l->data == NULL)
+ continue;
- g_list_free (children);
+ gtk_cell_layout_pack_start (layout, GTK_CELL_RENDERER (l->data), TRUE);
+
+ /* Remove our transient reference */
+ g_object_unref (l->data);
+ }
+
+ g_list_free (children);
}
GList *
-glade_gtk_cell_layout_get_children (GladeWidgetAdaptor *adaptor,
- GObject *container)
+glade_gtk_cell_layout_get_children (GladeWidgetAdaptor * adaptor,
+ GObject * container)
{
- return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (container));
+ return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (container));
}
void
-glade_gtk_cell_layout_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- if (strcmp (property_name, "position") == 0)
- {
- GList *cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (container));
+glade_gtk_cell_layout_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ if (strcmp (property_name, "position") == 0)
+ {
+ GList *cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (container));
- /* We have to fake it, assume we are loading and always return the last item */
- g_value_set_int (value, g_list_length (cells) - 1);
+ /* We have to fake it, assume we are loading and always return the last item */
+ g_value_set_int (value, g_list_length (cells) - 1);
- g_list_free (cells);
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container, child,
- property_name, value);
+ g_list_free (cells);
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container, child,
+ property_name, value);
}
void
-glade_gtk_cell_layout_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
+glade_gtk_cell_layout_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
{
- if (strcmp (property_name, "position") == 0)
- {
- /* Need verify on position property !!! XXX */
- gtk_cell_layout_reorder (GTK_CELL_LAYOUT (container), GTK_CELL_RENDERER (child),
- g_value_get_int (value));
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
+ if (strcmp (property_name, "position") == 0)
+ {
+ /* Need verify on position property !!! XXX */
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (container),
+ GTK_CELL_RENDERER (child),
+ g_value_get_int (value));
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
}
static void
-glade_gtk_cell_renderer_read_attributes (GladeWidget *widget, GladeXmlNode *node)
-{
- GladeXmlNode *attrs_node;
- GladeProperty *attr_prop, *use_attr_prop;
- GladeXmlNode *prop;
- gchar *name, *column_str, *attr_prop_name, *use_attr_name;
-
- if ((attrs_node = glade_xml_search_child (node, GLADE_TAG_ATTRIBUTES)) == NULL)
- return;
-
- for (prop = glade_xml_node_get_children (attrs_node); prop;
- prop = glade_xml_node_next (prop))
- {
-
- if (!glade_xml_node_verify_silent (prop, GLADE_TAG_ATTRIBUTE)) continue;
-
- name = glade_xml_get_property_string_required (prop, GLADE_TAG_NAME, NULL);
- column_str = glade_xml_get_content (prop);
- attr_prop_name = g_strdup_printf ("attr-%s", name);
- use_attr_name = g_strdup_printf ("use-attr-%s", name);
-
- attr_prop = glade_widget_get_property (widget, attr_prop_name);
- use_attr_prop = glade_widget_get_property (widget, use_attr_name);
-
- if (attr_prop && use_attr_prop)
- {
- gboolean use_attribute = FALSE;
- glade_property_get (use_attr_prop, &use_attribute);
-
- if (use_attribute)
- glade_property_set (attr_prop, g_ascii_strtoll (column_str, NULL, 10));
- }
-
- g_free (name);
- g_free (column_str);
- g_free (attr_prop_name);
- g_free (use_attr_name);
-
- }
-}
-
-void
-glade_gtk_cell_layout_read_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
-{
- GladeXmlNode *widget_node;
- GladeWidget *child_widget;
- gchar *internal_name;
-
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
- return;
-
- internal_name = glade_xml_get_property_string (node, GLADE_XML_TAG_INTERNAL_CHILD);
-
- if ((widget_node =
- glade_xml_search_child (node, GLADE_XML_TAG_WIDGET)) != NULL)
- {
-
- if (internal_name)
- g_warning ("Cell layout reading internal %s\n", internal_name);
-
- /* Combo box is a special brand of cell-layout, it can also have the internal entry */
- if ((child_widget = glade_widget_read (widget->project,
- widget, widget_node,
- internal_name)) != NULL)
- {
- /* Dont set any packing properties on internal children here,
- * its possible but just not relevant for known celllayouts...
- * i.e. maybe GtkTreeViewColumn will expose the internal button ?
- * but no need for packing properties there either.
- */
- if (!internal_name)
- {
- glade_widget_add_child (widget, child_widget, FALSE);
-
- glade_gtk_cell_renderer_read_attributes (child_widget, node);
-
- g_idle_add ((GSourceFunc)glade_gtk_cell_renderer_sync_attributes,
- child_widget->object);
- }
- }
- }
- g_free (internal_name);
+glade_gtk_cell_renderer_read_attributes (GladeWidget * widget,
+ GladeXmlNode * node)
+{
+ GladeXmlNode *attrs_node;
+ GladeProperty *attr_prop, *use_attr_prop;
+ GladeXmlNode *prop;
+ gchar *name, *column_str, *attr_prop_name, *use_attr_name;
+
+ if ((attrs_node =
+ glade_xml_search_child (node, GLADE_TAG_ATTRIBUTES)) == NULL)
+ return;
+
+ for (prop = glade_xml_node_get_children (attrs_node); prop;
+ prop = glade_xml_node_next (prop))
+ {
+
+ if (!glade_xml_node_verify_silent (prop, GLADE_TAG_ATTRIBUTE))
+ continue;
+
+ name =
+ glade_xml_get_property_string_required (prop, GLADE_TAG_NAME, NULL);
+ column_str = glade_xml_get_content (prop);
+ attr_prop_name = g_strdup_printf ("attr-%s", name);
+ use_attr_name = g_strdup_printf ("use-attr-%s", name);
+
+ attr_prop = glade_widget_get_property (widget, attr_prop_name);
+ use_attr_prop = glade_widget_get_property (widget, use_attr_name);
+
+ if (attr_prop && use_attr_prop)
+ {
+ gboolean use_attribute = FALSE;
+ glade_property_get (use_attr_prop, &use_attribute);
+
+ if (use_attribute)
+ glade_property_set (attr_prop,
+ g_ascii_strtoll (column_str, NULL, 10));
+ }
+
+ g_free (name);
+ g_free (column_str);
+ g_free (attr_prop_name);
+ g_free (use_attr_name);
+
+ }
}
-static void
-glade_gtk_cell_renderer_write_attributes (GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+void
+glade_gtk_cell_layout_read_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeProperty *property;
- GladeXmlNode *attrs_node;
- gchar *attr_name;
- GList *l;
- static gint attr_len = 0;
+ GladeXmlNode *widget_node;
+ GladeWidget *child_widget;
+ gchar *internal_name;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
+ return;
+
+ internal_name =
+ glade_xml_get_property_string (node, GLADE_XML_TAG_INTERNAL_CHILD);
- if (!attr_len)
- attr_len = strlen ("attr-");
+ if ((widget_node =
+ glade_xml_search_child (node, GLADE_XML_TAG_WIDGET)) != NULL)
+ {
- attrs_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTES);
+ if (internal_name)
+ g_warning ("Cell layout reading internal %s\n", internal_name);
- for (l = widget->properties; l; l = l->next)
- {
- property = l->data;
+ /* Combo box is a special brand of cell-layout, it can also have the internal entry */
+ if ((child_widget = glade_widget_read (widget->project,
+ widget, widget_node,
+ internal_name)) != NULL)
+ {
+ /* Dont set any packing properties on internal children here,
+ * its possible but just not relevant for known celllayouts...
+ * i.e. maybe GtkTreeViewColumn will expose the internal button ?
+ * but no need for packing properties there either.
+ */
+ if (!internal_name)
+ {
+ glade_widget_add_child (widget, child_widget, FALSE);
- if (strncmp (property->klass->id, "attr-", attr_len) == 0)
- {
- GladeXmlNode *attr_node;
- gchar *column_str, *use_attr_str;
- gboolean use_attr = FALSE;
+ glade_gtk_cell_renderer_read_attributes (child_widget, node);
- use_attr_str = g_strdup_printf ("use-%s", property->klass->id);
- glade_widget_property_get (widget, use_attr_str, &use_attr);
+ g_idle_add ((GSourceFunc) glade_gtk_cell_renderer_sync_attributes,
+ child_widget->object);
+ }
+ }
+ }
+ g_free (internal_name);
+}
- if (use_attr && g_value_get_int (property->value) >= 0)
- {
- column_str = g_strdup_printf ("%d", g_value_get_int (property->value));
- attr_name = &property->klass->id[attr_len];
-
- attr_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTE);
- glade_xml_node_append_child (attrs_node, attr_node);
- glade_xml_node_set_property_string (attr_node, GLADE_TAG_NAME,
- attr_name);
- glade_xml_set_content (attr_node, column_str);
- g_free (column_str);
- }
- g_free (use_attr_str);
- }
- }
+static void
+glade_gtk_cell_renderer_write_attributes (GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
+{
+ GladeProperty *property;
+ GladeXmlNode *attrs_node;
+ gchar *attr_name;
+ GList *l;
+ static gint attr_len = 0;
+
+ if (!attr_len)
+ attr_len = strlen ("attr-");
+
+ attrs_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTES);
+
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
+
+ if (strncmp (property->klass->id, "attr-", attr_len) == 0)
+ {
+ GladeXmlNode *attr_node;
+ gchar *column_str, *use_attr_str;
+ gboolean use_attr = FALSE;
+
+ use_attr_str = g_strdup_printf ("use-%s", property->klass->id);
+ glade_widget_property_get (widget, use_attr_str, &use_attr);
+
+ if (use_attr && g_value_get_int (property->value) >= 0)
+ {
+ column_str =
+ g_strdup_printf ("%d", g_value_get_int (property->value));
+ attr_name = &property->klass->id[attr_len];
+
+ attr_node = glade_xml_node_new (context, GLADE_TAG_ATTRIBUTE);
+ glade_xml_node_append_child (attrs_node, attr_node);
+ glade_xml_node_set_property_string (attr_node, GLADE_TAG_NAME,
+ attr_name);
+ glade_xml_set_content (attr_node, column_str);
+ g_free (column_str);
+ }
+ g_free (use_attr_str);
+ }
+ }
- if (!glade_xml_node_get_children (attrs_node))
- glade_xml_node_delete (attrs_node);
- else
- glade_xml_node_append_child (node, attrs_node);
+ if (!glade_xml_node_get_children (attrs_node))
+ glade_xml_node_delete (attrs_node);
+ else
+ glade_xml_node_append_child (node, attrs_node);
}
void
-glade_gtk_cell_layout_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_cell_layout_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *child_node;
+ GladeXmlNode *child_node;
- child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
- glade_xml_node_append_child (node, child_node);
+ child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
+ glade_xml_node_append_child (node, child_node);
- /* ComboBox can have an internal entry */
- if (widget->internal)
- glade_xml_node_set_property_string (child_node,
- GLADE_XML_TAG_INTERNAL_CHILD,
- widget->internal);
+ /* ComboBox can have an internal entry */
+ if (widget->internal)
+ glade_xml_node_set_property_string (child_node,
+ GLADE_XML_TAG_INTERNAL_CHILD,
+ widget->internal);
- /* Write out the widget */
- glade_widget_write (widget, context, child_node);
+ /* Write out the widget */
+ glade_widget_write (widget, context, child_node);
- glade_gtk_cell_renderer_write_attributes (widget, context, child_node);
+ glade_gtk_cell_renderer_write_attributes (widget, context, child_node);
}
static gchar *
-glade_gtk_cell_layout_get_display_name (GladeBaseEditor *editor,
- GladeWidget *gchild,
- gpointer user_data)
+glade_gtk_cell_layout_get_display_name (GladeBaseEditor * editor,
+ GladeWidget * gchild,
+ gpointer user_data)
{
- GObject *child = glade_widget_get_object (gchild);
- gchar *name;
-
- if (GTK_IS_TREE_VIEW_COLUMN (child))
- glade_widget_property_get (gchild, "title", &name);
- else
- name = gchild->name;
-
- return g_strdup (name);
+ GObject *child = glade_widget_get_object (gchild);
+ gchar *name;
+
+ if (GTK_IS_TREE_VIEW_COLUMN (child))
+ glade_widget_property_get (gchild, "title", &name);
+ else
+ name = gchild->name;
+
+ return g_strdup (name);
}
static void
-glade_gtk_cell_layout_child_selected (GladeBaseEditor *editor,
- GladeWidget *gchild,
- gpointer data)
-{
- GObject *child = glade_widget_get_object (gchild);
-
- glade_base_editor_add_label (editor, GTK_IS_TREE_VIEW_COLUMN (child) ?
- _("Tree View Column") : _("Cell Renderer"));
-
- glade_base_editor_add_default_properties (editor, gchild);
-
- glade_base_editor_add_label (editor, GTK_IS_TREE_VIEW_COLUMN (child) ?
- _("Properties") : _("Properties and Attributes"));
- glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
-
- if (GTK_IS_CELL_RENDERER (child))
- {
- glade_base_editor_add_label (editor, _("Common Properties and Attributes"));
- glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_COMMON);
- }
+glade_gtk_cell_layout_child_selected (GladeBaseEditor * editor,
+ GladeWidget * gchild, gpointer data)
+{
+ GObject *child = glade_widget_get_object (gchild);
+
+ glade_base_editor_add_label (editor, GTK_IS_TREE_VIEW_COLUMN (child) ?
+ _("Tree View Column") : _("Cell Renderer"));
+
+ glade_base_editor_add_default_properties (editor, gchild);
+
+ glade_base_editor_add_label (editor, GTK_IS_TREE_VIEW_COLUMN (child) ?
+ _("Properties") :
+ _("Properties and Attributes"));
+ glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
+
+ if (GTK_IS_CELL_RENDERER (child))
+ {
+ glade_base_editor_add_label (editor,
+ _("Common Properties and Attributes"));
+ glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_COMMON);
+ }
}
static gboolean
-glade_gtk_cell_layout_move_child (GladeBaseEditor *editor,
- GladeWidget *gparent,
- GladeWidget *gchild,
- gpointer data)
-{
- GObject *parent = glade_widget_get_object (gparent);
- GObject *child = glade_widget_get_object (gchild);
- GList list = { 0, };
-
- if (GTK_IS_TREE_VIEW (parent) && !GTK_IS_TREE_VIEW_COLUMN (child))
- return FALSE;
- if (GTK_IS_CELL_LAYOUT (parent) && !GTK_IS_CELL_RENDERER (child))
- return FALSE;
- if (GTK_IS_CELL_RENDERER (parent))
- return FALSE;
-
- if (gparent != glade_widget_get_parent (gchild))
- {
- list.data = gchild;
- glade_command_dnd (&list, gparent, NULL);
- }
-
- return TRUE;
+glade_gtk_cell_layout_move_child (GladeBaseEditor * editor,
+ GladeWidget * gparent,
+ GladeWidget * gchild, gpointer data)
+{
+ GObject *parent = glade_widget_get_object (gparent);
+ GObject *child = glade_widget_get_object (gchild);
+ GList list = { 0, };
+
+ if (GTK_IS_TREE_VIEW (parent) && !GTK_IS_TREE_VIEW_COLUMN (child))
+ return FALSE;
+ if (GTK_IS_CELL_LAYOUT (parent) && !GTK_IS_CELL_RENDERER (child))
+ return FALSE;
+ if (GTK_IS_CELL_RENDERER (parent))
+ return FALSE;
+
+ if (gparent != glade_widget_get_parent (gchild))
+ {
+ list.data = gchild;
+ glade_command_dnd (&list, gparent, NULL);
+ }
+
+ return TRUE;
}
static void
-glade_gtk_cell_layout_launch_editor (GObject *layout)
-{
- GladeWidget *widget = glade_widget_get_from_gobject (layout);
- GladeBaseEditor *editor;
- GladeEditable *layout_editor;
- GtkWidget *window;
-
- layout_editor = glade_widget_adaptor_create_editable (widget->adaptor, GLADE_PAGE_GENERAL);
- layout_editor = (GladeEditable *)glade_tree_view_editor_new (widget->adaptor, layout_editor);
-
- /* Editor */
- editor = glade_base_editor_new (layout, layout_editor,
- _("Text"), GTK_TYPE_CELL_RENDERER_TEXT,
- _("Accelerator"), GTK_TYPE_CELL_RENDERER_ACCEL,
- _("Combo"), GTK_TYPE_CELL_RENDERER_COMBO,
- _("Spin"), GTK_TYPE_CELL_RENDERER_SPIN,
- _("Pixbuf"), GTK_TYPE_CELL_RENDERER_PIXBUF,
- _("Progress"), GTK_TYPE_CELL_RENDERER_PROGRESS,
- _("Toggle"), GTK_TYPE_CELL_RENDERER_TOGGLE,
- _("Spinner"), GTK_TYPE_CELL_RENDERER_SPINNER,
- NULL);
-
- g_signal_connect (editor, "get-display-name", G_CALLBACK (glade_gtk_cell_layout_get_display_name), NULL);
- g_signal_connect (editor, "child-selected", G_CALLBACK (glade_gtk_cell_layout_child_selected), NULL);
- g_signal_connect (editor, "move-child", G_CALLBACK (glade_gtk_cell_layout_move_child), NULL);
-
- gtk_widget_show (GTK_WIDGET (editor));
-
- window = glade_base_editor_pack_new_window (editor,
- GTK_IS_ICON_VIEW (layout) ?
- _("Icon View Editor") : _("Combo Editor"),
- NULL);
- gtk_widget_show (window);
+glade_gtk_cell_layout_launch_editor (GObject * layout)
+{
+ GladeWidget *widget = glade_widget_get_from_gobject (layout);
+ GladeBaseEditor *editor;
+ GladeEditable *layout_editor;
+ GtkWidget *window;
+
+ layout_editor =
+ glade_widget_adaptor_create_editable (widget->adaptor,
+ GLADE_PAGE_GENERAL);
+ layout_editor =
+ (GladeEditable *) glade_tree_view_editor_new (widget->adaptor,
+ layout_editor);
+
+ /* Editor */
+ editor = glade_base_editor_new (layout, layout_editor,
+ _("Text"), GTK_TYPE_CELL_RENDERER_TEXT,
+ _("Accelerator"),
+ GTK_TYPE_CELL_RENDERER_ACCEL, _("Combo"),
+ GTK_TYPE_CELL_RENDERER_COMBO, _("Spin"),
+ GTK_TYPE_CELL_RENDERER_SPIN, _("Pixbuf"),
+ GTK_TYPE_CELL_RENDERER_PIXBUF, _("Progress"),
+ GTK_TYPE_CELL_RENDERER_PROGRESS, _("Toggle"),
+ GTK_TYPE_CELL_RENDERER_TOGGLE, _("Spinner"),
+ GTK_TYPE_CELL_RENDERER_SPINNER, NULL);
+
+ g_signal_connect (editor, "get-display-name",
+ G_CALLBACK (glade_gtk_cell_layout_get_display_name), NULL);
+ g_signal_connect (editor, "child-selected",
+ G_CALLBACK (glade_gtk_cell_layout_child_selected), NULL);
+ g_signal_connect (editor, "move-child",
+ G_CALLBACK (glade_gtk_cell_layout_move_child), NULL);
+
+ gtk_widget_show (GTK_WIDGET (editor));
+
+ window = glade_base_editor_pack_new_window (editor,
+ GTK_IS_ICON_VIEW (layout) ?
+ _("Icon View Editor") :
+ _("Combo Editor"), NULL);
+ gtk_widget_show (window);
}
static void
-glade_gtk_cell_layout_launch_editor_action (GObject *object)
+glade_gtk_cell_layout_launch_editor_action (GObject * object)
{
- GladeWidget *w = glade_widget_get_from_gobject (object);
-
- do
- {
- if (GTK_IS_TREE_VIEW (w->object))
- {
- glade_gtk_treeview_launch_editor (w->object);
- break;
- }
- else if (GTK_IS_ICON_VIEW (w->object))
- {
- glade_gtk_cell_layout_launch_editor (w->object);
- break;
- }
- else if (GTK_IS_COMBO_BOX (w->object))
- {
- glade_gtk_cell_layout_launch_editor (w->object);
- break;
- }
+ GladeWidget *w = glade_widget_get_from_gobject (object);
- } while ((w = glade_widget_get_parent (w)));
+ do
+ {
+ if (GTK_IS_TREE_VIEW (w->object))
+ {
+ glade_gtk_treeview_launch_editor (w->object);
+ break;
+ }
+ else if (GTK_IS_ICON_VIEW (w->object))
+ {
+ glade_gtk_cell_layout_launch_editor (w->object);
+ break;
+ }
+ else if (GTK_IS_COMBO_BOX (w->object))
+ {
+ glade_gtk_cell_layout_launch_editor (w->object);
+ break;
+ }
+
+ }
+ while ((w = glade_widget_get_parent (w)));
}
void
-glade_gtk_cell_layout_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
+glade_gtk_cell_layout_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
{
- if (strcmp (action_path, "launch_editor") == 0)
- glade_gtk_cell_layout_launch_editor_action (object);
- else
- GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
- object,
- action_path);
+ if (strcmp (action_path, "launch_editor") == 0)
+ glade_gtk_cell_layout_launch_editor_action (object);
+ else
+ GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
+ object, action_path);
}
void
-glade_gtk_cell_layout_action_activate_as_widget (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
+glade_gtk_cell_layout_action_activate_as_widget (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * action_path)
{
- if (strcmp (action_path, "launch_editor") == 0)
- glade_gtk_cell_layout_launch_editor_action (object);
- else
- GWA_GET_CLASS (GTK_TYPE_WIDGET)->action_activate (adaptor,
- object,
- action_path);
+ if (strcmp (action_path, "launch_editor") == 0)
+ glade_gtk_cell_layout_launch_editor_action (object);
+ else
+ GWA_GET_CLASS (GTK_TYPE_WIDGET)->action_activate (adaptor,
+ object, action_path);
}
/*--------------------------- GtkTreeView ---------------------------------*/
static void
-glade_gtk_treeview_launch_editor (GObject *treeview)
+glade_gtk_treeview_launch_editor (GObject * treeview)
{
- GladeWidget *widget = glade_widget_get_from_gobject (treeview);
- GladeBaseEditor *editor;
- GladeEditable *treeview_editor;
- GtkWidget *window;
+ GladeWidget *widget = glade_widget_get_from_gobject (treeview);
+ GladeBaseEditor *editor;
+ GladeEditable *treeview_editor;
+ GtkWidget *window;
+
+ treeview_editor =
+ glade_widget_adaptor_create_editable (widget->adaptor,
+ GLADE_PAGE_GENERAL);
+ treeview_editor =
+ (GladeEditable *) glade_tree_view_editor_new (widget->adaptor,
+ treeview_editor);
- treeview_editor = glade_widget_adaptor_create_editable (widget->adaptor, GLADE_PAGE_GENERAL);
- treeview_editor = (GladeEditable *)glade_tree_view_editor_new (widget->adaptor, treeview_editor);
+ /* Editor */
+ editor = glade_base_editor_new (treeview, treeview_editor,
+ _("Column"), GTK_TYPE_TREE_VIEW_COLUMN, NULL);
- /* Editor */
- editor = glade_base_editor_new (treeview, treeview_editor,
- _("Column"), GTK_TYPE_TREE_VIEW_COLUMN,
- NULL);
+ glade_base_editor_append_types (editor, GTK_TYPE_TREE_VIEW_COLUMN,
+ _("Text"), GTK_TYPE_CELL_RENDERER_TEXT,
+ _("Accelerator"),
+ GTK_TYPE_CELL_RENDERER_ACCEL, _("Combo"),
+ GTK_TYPE_CELL_RENDERER_COMBO, _("Spin"),
+ GTK_TYPE_CELL_RENDERER_SPIN, _("Pixbuf"),
+ GTK_TYPE_CELL_RENDERER_PIXBUF, _("Progress"),
+ GTK_TYPE_CELL_RENDERER_PROGRESS, _("Toggle"),
+ GTK_TYPE_CELL_RENDERER_TOGGLE, _("Spinner"),
+ GTK_TYPE_CELL_RENDERER_SPINNER, NULL);
- glade_base_editor_append_types (editor, GTK_TYPE_TREE_VIEW_COLUMN,
- _("Text"), GTK_TYPE_CELL_RENDERER_TEXT,
- _("Accelerator"), GTK_TYPE_CELL_RENDERER_ACCEL,
- _("Combo"), GTK_TYPE_CELL_RENDERER_COMBO,
- _("Spin"), GTK_TYPE_CELL_RENDERER_SPIN,
- _("Pixbuf"), GTK_TYPE_CELL_RENDERER_PIXBUF,
- _("Progress"), GTK_TYPE_CELL_RENDERER_PROGRESS,
- _("Toggle"), GTK_TYPE_CELL_RENDERER_TOGGLE,
- _("Spinner"), GTK_TYPE_CELL_RENDERER_SPINNER,
- NULL);
+ g_signal_connect (editor, "get-display-name",
+ G_CALLBACK (glade_gtk_cell_layout_get_display_name), NULL);
+ g_signal_connect (editor, "child-selected",
+ G_CALLBACK (glade_gtk_cell_layout_child_selected), NULL);
+ g_signal_connect (editor, "move-child",
+ G_CALLBACK (glade_gtk_cell_layout_move_child), NULL);
- g_signal_connect (editor, "get-display-name", G_CALLBACK (glade_gtk_cell_layout_get_display_name), NULL);
- g_signal_connect (editor, "child-selected", G_CALLBACK (glade_gtk_cell_layout_child_selected), NULL);
- g_signal_connect (editor, "move-child", G_CALLBACK (glade_gtk_cell_layout_move_child), NULL);
+ gtk_widget_show (GTK_WIDGET (editor));
- gtk_widget_show (GTK_WIDGET (editor));
-
- window = glade_base_editor_pack_new_window (editor, _("Tree View Editor"), NULL);
- gtk_widget_show (window);
+ window =
+ glade_base_editor_pack_new_window (editor, _("Tree View Editor"), NULL);
+ gtk_widget_show (window);
}
void
-glade_gtk_treeview_action_activate (GladeWidgetAdaptor *adaptor,
- GObject *object,
- const gchar *action_path)
+glade_gtk_treeview_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * action_path)
{
- if (strcmp (action_path, "launch_editor") == 0)
- {
- glade_gtk_treeview_launch_editor (object);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
- object,
- action_path);
+ if (strcmp (action_path, "launch_editor") == 0)
+ {
+ glade_gtk_treeview_launch_editor (object);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
+ object, action_path);
}
static gint
-glade_gtk_treeview_get_column_index (GtkTreeView *view,
- GtkTreeViewColumn *column)
-{
- GtkTreeViewColumn *iter;
- gint i;
-
- for (i = 0; (iter = gtk_tree_view_get_column (view, i)) != NULL; i++)
- if (iter == column)
- return i;
-
- return -1;
-}
-
-void
-glade_gtk_treeview_get_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- GValue *value)
-{
- if (strcmp (property_name, "position") == 0)
- g_value_set_int (value,
- glade_gtk_treeview_get_column_index (GTK_TREE_VIEW (container),
- GTK_TREE_VIEW_COLUMN (child)));
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container, child,
- property_name, value);
-}
-
-void
-glade_gtk_treeview_set_child_property (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child,
- const gchar *property_name,
- const GValue *value)
-{
- if (strcmp (property_name, "position") == 0)
- {
-
- gtk_tree_view_remove_column (GTK_TREE_VIEW (container),
- GTK_TREE_VIEW_COLUMN (child));
- gtk_tree_view_insert_column (GTK_TREE_VIEW (container),
- GTK_TREE_VIEW_COLUMN (child),
- g_value_get_int (value));
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
+glade_gtk_treeview_get_column_index (GtkTreeView * view,
+ GtkTreeViewColumn * column)
+{
+ GtkTreeViewColumn *iter;
+ gint i;
+
+ for (i = 0; (iter = gtk_tree_view_get_column (view, i)) != NULL; i++)
+ if (iter == column)
+ return i;
+
+ return -1;
+}
+
+void
+glade_gtk_treeview_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ if (strcmp (property_name, "position") == 0)
+ g_value_set_int (value,
+ glade_gtk_treeview_get_column_index (GTK_TREE_VIEW
+ (container),
+ GTK_TREE_VIEW_COLUMN
+ (child)));
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container, child,
+ property_name, value);
+}
+
+void
+glade_gtk_treeview_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
+{
+ if (strcmp (property_name, "position") == 0)
+ {
+
+ gtk_tree_view_remove_column (GTK_TREE_VIEW (container),
+ GTK_TREE_VIEW_COLUMN (child));
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (container),
+ GTK_TREE_VIEW_COLUMN (child),
+ g_value_get_int (value));
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
}
GList *
-glade_gtk_treeview_get_children (GladeWidgetAdaptor *adaptor,
- GtkTreeView *view)
+glade_gtk_treeview_get_children (GladeWidgetAdaptor * adaptor,
+ GtkTreeView * view)
{
- return gtk_tree_view_get_columns (view);
+ return gtk_tree_view_get_columns (view);
}
/* XXX FIXME: We should hide the actual "fixed-height-mode" setting from
@@ -10751,246 +10785,239 @@ glade_gtk_treeview_get_children (GladeWidgetAdaptor *adaptor,
_("Columns must have a fixed size inside a treeview with fixed height mode set")
void
-glade_gtk_treeview_add_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_gtk_treeview_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- GtkTreeView *view = GTK_TREE_VIEW (container);
- GtkTreeViewColumn *column;
- GladeWidget *gcolumn;
+ GtkTreeView *view = GTK_TREE_VIEW (container);
+ GtkTreeViewColumn *column;
+ GladeWidget *gcolumn;
- if (!GTK_IS_TREE_VIEW_COLUMN (child))
- return;
+ if (!GTK_IS_TREE_VIEW_COLUMN (child))
+ return;
- if (gtk_tree_view_get_fixed_height_mode (view))
- {
- gcolumn = glade_widget_get_from_gobject (child);
- glade_widget_property_set (gcolumn, "sizing", GTK_TREE_VIEW_COLUMN_FIXED);
- glade_widget_property_set_sensitive (gcolumn, "sizing", FALSE,
- INSENSITIVE_COLUMN_SIZING_MSG);
- }
+ if (gtk_tree_view_get_fixed_height_mode (view))
+ {
+ gcolumn = glade_widget_get_from_gobject (child);
+ glade_widget_property_set (gcolumn, "sizing", GTK_TREE_VIEW_COLUMN_FIXED);
+ glade_widget_property_set_sensitive (gcolumn, "sizing", FALSE,
+ INSENSITIVE_COLUMN_SIZING_MSG);
+ }
- column = GTK_TREE_VIEW_COLUMN (child);
- gtk_tree_view_append_column (view, column);
+ column = GTK_TREE_VIEW_COLUMN (child);
+ gtk_tree_view_append_column (view, column);
- glade_gtk_cell_layout_sync_attributes (G_OBJECT (column));
+ glade_gtk_cell_layout_sync_attributes (G_OBJECT (column));
}
void
-glade_gtk_treeview_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_gtk_treeview_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- GtkTreeView *view = GTK_TREE_VIEW (container);
- GtkTreeViewColumn *column;
+ GtkTreeView *view = GTK_TREE_VIEW (container);
+ GtkTreeViewColumn *column;
- if (!GTK_IS_TREE_VIEW_COLUMN (child))
- return;
+ if (!GTK_IS_TREE_VIEW_COLUMN (child))
+ return;
- column = GTK_TREE_VIEW_COLUMN (child);
- gtk_tree_view_remove_column (view, column);
+ column = GTK_TREE_VIEW_COLUMN (child);
+ gtk_tree_view_remove_column (view, column);
}
void
-glade_gtk_treeview_replace_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *current,
- GObject *new_column)
+glade_gtk_treeview_replace_child (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * current, GObject * new_column)
{
- GtkTreeView *view = GTK_TREE_VIEW (container);
- GList *columns;
- GtkTreeViewColumn *column;
- GladeWidget *gcolumn;
- gint index;
+ GtkTreeView *view = GTK_TREE_VIEW (container);
+ GList *columns;
+ GtkTreeViewColumn *column;
+ GladeWidget *gcolumn;
+ gint index;
- if (!GTK_IS_TREE_VIEW_COLUMN (current))
- return;
+ if (!GTK_IS_TREE_VIEW_COLUMN (current))
+ return;
- column = GTK_TREE_VIEW_COLUMN (current);
+ column = GTK_TREE_VIEW_COLUMN (current);
- columns = gtk_tree_view_get_columns (view);
- index = g_list_index (columns, column);
- g_list_free (columns);
+ columns = gtk_tree_view_get_columns (view);
+ index = g_list_index (columns, column);
+ g_list_free (columns);
- gtk_tree_view_remove_column (view, column);
- column = GTK_TREE_VIEW_COLUMN (new_column);
+ gtk_tree_view_remove_column (view, column);
+ column = GTK_TREE_VIEW_COLUMN (new_column);
- gtk_tree_view_insert_column (view, column, index);
+ gtk_tree_view_insert_column (view, column, index);
- if (gtk_tree_view_get_fixed_height_mode (view))
- {
- gcolumn = glade_widget_get_from_gobject (column);
- glade_widget_property_set (gcolumn, "sizing", GTK_TREE_VIEW_COLUMN_FIXED);
- glade_widget_property_set_sensitive (gcolumn, "sizing", FALSE,
- INSENSITIVE_COLUMN_SIZING_MSG);
- }
+ if (gtk_tree_view_get_fixed_height_mode (view))
+ {
+ gcolumn = glade_widget_get_from_gobject (column);
+ glade_widget_property_set (gcolumn, "sizing", GTK_TREE_VIEW_COLUMN_FIXED);
+ glade_widget_property_set_sensitive (gcolumn, "sizing", FALSE,
+ INSENSITIVE_COLUMN_SIZING_MSG);
+ }
- glade_gtk_cell_layout_sync_attributes (G_OBJECT (column));
+ glade_gtk_cell_layout_sync_attributes (G_OBJECT (column));
}
gboolean
-glade_gtk_treeview_depends (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeWidget *another)
+glade_gtk_treeview_depends (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeWidget * another)
{
- if (GTK_IS_TREE_MODEL (another->object))
- return TRUE;
+ if (GTK_IS_TREE_MODEL (another->object))
+ return TRUE;
- return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->depends (adaptor, widget, another);
+ return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->depends (adaptor, widget, another);
}
/*--------------------------- GtkAdjustment ---------------------------------*/
void
-glade_gtk_adjustment_write_widget (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_adjustment_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeProperty *prop;
+ GladeProperty *prop;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
- return;
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
- /* Ensure proper order of adjustment properties by writing them here. */
- prop = glade_widget_get_property (widget, "lower");
- glade_property_write (prop, context, node);
+ /* Ensure proper order of adjustment properties by writing them here. */
+ prop = glade_widget_get_property (widget, "lower");
+ glade_property_write (prop, context, node);
- prop = glade_widget_get_property (widget, "upper");
- glade_property_write (prop, context, node);
+ prop = glade_widget_get_property (widget, "upper");
+ glade_property_write (prop, context, node);
- prop = glade_widget_get_property (widget, "value");
- glade_property_write (prop, context, node);
+ prop = glade_widget_get_property (widget, "value");
+ glade_property_write (prop, context, node);
- GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
}
/*--------------------------- GtkAction ---------------------------------*/
void
-glade_gtk_action_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_action_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
- if (reason == GLADE_CREATE_REBUILD)
- return;
+ if (reason == GLADE_CREATE_REBUILD)
+ return;
- if (!gtk_action_get_name (GTK_ACTION (object)))
- glade_widget_property_set (gwidget, "name", "untitled");
+ if (!gtk_action_get_name (GTK_ACTION (object)))
+ glade_widget_property_set (gwidget, "name", "untitled");
}
/*--------------------------- GtkActionGroup ---------------------------------*/
void
-glade_gtk_action_group_add_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_gtk_action_group_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- if (GTK_IS_ACTION (child))
- {
- /* Dont really add/remove actions (because name conflicts inside groups)
- */
- GladeWidget *ggroup = glade_widget_get_from_gobject (container);
- GladeWidget *gaction = glade_widget_get_from_gobject (child);
- GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
+ if (GTK_IS_ACTION (child))
+ {
+ /* Dont really add/remove actions (because name conflicts inside groups)
+ */
+ GladeWidget *ggroup = glade_widget_get_from_gobject (container);
+ GladeWidget *gaction = glade_widget_get_from_gobject (child);
+ GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
- actions = g_list_copy (actions);
- actions = g_list_prepend (actions, child);
+ actions = g_list_copy (actions);
+ actions = g_list_prepend (actions, child);
- g_object_set_data_full (G_OBJECT (ggroup), "glade-actions", actions,
- (GDestroyNotify)g_list_free);
+ g_object_set_data_full (G_OBJECT (ggroup), "glade-actions", actions,
+ (GDestroyNotify) g_list_free);
- glade_widget_property_set_sensitive (gaction, "accelerator", TRUE, NULL);
- }
+ glade_widget_property_set_sensitive (gaction, "accelerator", TRUE, NULL);
+ }
}
void
-glade_gtk_action_group_remove_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *child)
+glade_gtk_action_group_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * container, GObject * child)
{
- if (GTK_IS_ACTION (child))
- {
- /* Dont really add/remove actions (because name conflicts inside groups)
- */
- const gchar *insensitive_msg = _("The accelerator can only be set when inside an Action Group.");
- GladeWidget *ggroup = glade_widget_get_from_gobject (container);
- GladeWidget *gaction = glade_widget_get_from_gobject (child);
- GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
+ if (GTK_IS_ACTION (child))
+ {
+ /* Dont really add/remove actions (because name conflicts inside groups)
+ */
+ const gchar *insensitive_msg =
+ _("The accelerator can only be set when inside an Action Group.");
+ GladeWidget *ggroup = glade_widget_get_from_gobject (container);
+ GladeWidget *gaction = glade_widget_get_from_gobject (child);
+ GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
- actions = g_list_copy (actions);
- actions = g_list_remove (actions, child);
+ actions = g_list_copy (actions);
+ actions = g_list_remove (actions, child);
- g_object_set_data_full (G_OBJECT (ggroup), "glade-actions", actions,
- (GDestroyNotify)g_list_free);
+ g_object_set_data_full (G_OBJECT (ggroup), "glade-actions", actions,
+ (GDestroyNotify) g_list_free);
- glade_widget_property_set_sensitive (gaction, "accelerator", FALSE, insensitive_msg);
- }
+ glade_widget_property_set_sensitive (gaction, "accelerator", FALSE,
+ insensitive_msg);
+ }
}
void
-glade_gtk_action_group_replace_child (GladeWidgetAdaptor *adaptor,
- GObject *container,
- GObject *current,
- GObject *new_action)
+glade_gtk_action_group_replace_child (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * current, GObject * new_action)
{
- glade_gtk_action_group_remove_child (adaptor, container, current);
- glade_gtk_action_group_add_child (adaptor, container, new_action);
+ glade_gtk_action_group_remove_child (adaptor, container, current);
+ glade_gtk_action_group_add_child (adaptor, container, new_action);
}
GList *
-glade_gtk_action_group_get_children (GladeWidgetAdaptor *adaptor,
- GObject *container)
+glade_gtk_action_group_get_children (GladeWidgetAdaptor * adaptor,
+ GObject * container)
{
- GladeWidget *ggroup = glade_widget_get_from_gobject (container);
- GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
+ GladeWidget *ggroup = glade_widget_get_from_gobject (container);
+ GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
- return g_list_copy (actions);
+ return g_list_copy (actions);
}
void
-glade_gtk_action_group_read_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlNode *node)
+glade_gtk_action_group_read_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
{
- GladeXmlNode *widget_node;
- GladeWidget *child_widget;
+ GladeXmlNode *widget_node;
+ GladeWidget *child_widget;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
+ return;
- if (!glade_xml_node_verify (node, GLADE_XML_TAG_CHILD))
- return;
-
- if ((widget_node =
- glade_xml_search_child (node, GLADE_XML_TAG_WIDGET)) != NULL)
- {
- if ((child_widget = glade_widget_read (widget->project,
- widget, widget_node,
- NULL)) != NULL)
- {
- glade_widget_add_child (widget, child_widget, FALSE);
+ if ((widget_node =
+ glade_xml_search_child (node, GLADE_XML_TAG_WIDGET)) != NULL)
+ {
+ if ((child_widget = glade_widget_read (widget->project,
+ widget, widget_node,
+ NULL)) != NULL)
+ {
+ glade_widget_add_child (widget, child_widget, FALSE);
- /* Read in accelerator */
- glade_gtk_read_accels (child_widget, node, FALSE);
- }
- }
+ /* Read in accelerator */
+ glade_gtk_read_accels (child_widget, node, FALSE);
+ }
+ }
}
void
-glade_gtk_action_group_write_child (GladeWidgetAdaptor *adaptor,
- GladeWidget *widget,
- GladeXmlContext *context,
- GladeXmlNode *node)
+glade_gtk_action_group_write_child (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget,
+ GladeXmlContext * context,
+ GladeXmlNode * node)
{
- GladeXmlNode *child_node;
+ GladeXmlNode *child_node;
- child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
- glade_xml_node_append_child (node, child_node);
+ child_node = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
+ glade_xml_node_append_child (node, child_node);
- /* Write out the widget */
- glade_widget_write (widget, context, child_node);
+ /* Write out the widget */
+ glade_widget_write (widget, context, child_node);
- /* Write accelerator here */
- glade_gtk_write_accels (widget, context, child_node, FALSE);
+ /* Write accelerator here */
+ glade_gtk_write_accels (widget, context, child_node, FALSE);
}
diff --git a/plugins/gtk+/glade-gtk.h b/plugins/gtk+/glade-gtk.h
index d4e0a30..d85e4a6 100644
--- a/plugins/gtk+/glade-gtk.h
+++ b/plugins/gtk+/glade-gtk.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_GTK_H__
#define __GLADE_GTK_H__
diff --git a/plugins/gtk+/glade-icon-factory-editor.c b/plugins/gtk+/glade-icon-factory-editor.c
index 222bf02..a34d12f 100644
--- a/plugins/gtk+/glade-icon-factory-editor.c
+++ b/plugins/gtk+/glade-icon-factory-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,181 +27,190 @@
#include "glade-icon-factory-editor.h"
-static void glade_icon_factory_editor_finalize (GObject *object);
+static void glade_icon_factory_editor_finalize (GObject * object);
-static void glade_icon_factory_editor_editable_init (GladeEditableIface *iface);
+static void glade_icon_factory_editor_editable_init (GladeEditableIface *
+ iface);
-static void glade_icon_factory_editor_grab_focus (GtkWidget *widget);
+static void glade_icon_factory_editor_grab_focus (GtkWidget * widget);
-G_DEFINE_TYPE_WITH_CODE (GladeIconFactoryEditor, glade_icon_factory_editor, GTK_TYPE_VBOX,
+G_DEFINE_TYPE_WITH_CODE (GladeIconFactoryEditor, glade_icon_factory_editor,
+ GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_icon_factory_editor_editable_init));
static void
-glade_icon_factory_editor_class_init (GladeIconFactoryEditorClass *klass)
+glade_icon_factory_editor_class_init (GladeIconFactoryEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_icon_factory_editor_finalize;
- widget_class->grab_focus = glade_icon_factory_editor_grab_focus;
+ object_class->finalize = glade_icon_factory_editor_finalize;
+ widget_class->grab_focus = glade_icon_factory_editor_grab_focus;
}
static void
-glade_icon_factory_editor_init (GladeIconFactoryEditor *self)
+glade_icon_factory_editor_init (GladeIconFactoryEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeIconFactoryEditor *factory_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeIconFactoryEditor * factory_editor)
{
- if (!gtk_widget_get_mapped (GTK_WIDGET (factory_editor)))
- return;
+ if (!gtk_widget_get_mapped (GTK_WIDGET (factory_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (factory_editor), factory_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (factory_editor),
+ factory_editor->loaded_widget);
}
static void
-project_finalized (GladeIconFactoryEditor *factory_editor,
- GladeProject *where_project_was)
+project_finalized (GladeIconFactoryEditor * factory_editor,
+ GladeProject * where_project_was)
{
- factory_editor->loaded_widget = NULL;
+ factory_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (factory_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (factory_editor), NULL);
}
static void
-glade_icon_factory_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_icon_factory_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable);
- GList *l;
-
- /* Since we watch the project*/
- if (factory_editor->loaded_widget)
- {
- g_signal_handlers_disconnect_by_func (G_OBJECT (factory_editor->loaded_widget->project),
- G_CALLBACK (project_changed), factory_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (factory_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- factory_editor);
- }
-
- /* Mark our widget... */
- factory_editor->loaded_widget = widget;
-
- if (factory_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (factory_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), factory_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (factory_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- factory_editor);
- }
-
- /* load the embedded editable... */
- if (factory_editor->embed)
- glade_editable_load (GLADE_EDITABLE (factory_editor->embed), widget);
-
- for (l = factory_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable);
+ GList *l;
+
+ /* Since we watch the project */
+ if (factory_editor->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (factory_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ factory_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (factory_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, factory_editor);
+ }
+
+ /* Mark our widget... */
+ factory_editor->loaded_widget = widget;
+
+ if (factory_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (factory_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed),
+ factory_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (factory_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, factory_editor);
+ }
+
+ /* load the embedded editable... */
+ if (factory_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (factory_editor->embed), widget);
+
+ for (l = factory_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
}
static void
-glade_icon_factory_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_icon_factory_editor_set_show_name (GladeEditable * editable,
+ gboolean show_name)
{
- GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable);
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (factory_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (factory_editor->embed),
+ show_name);
}
static void
-glade_icon_factory_editor_editable_init (GladeEditableIface *iface)
+glade_icon_factory_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_icon_factory_editor_load;
- iface->set_show_name = glade_icon_factory_editor_set_show_name;
+ iface->load = glade_icon_factory_editor_load;
+ iface->set_show_name = glade_icon_factory_editor_set_show_name;
}
static void
-glade_icon_factory_editor_finalize (GObject *object)
+glade_icon_factory_editor_finalize (GObject * object)
{
- GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (object);
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (object);
- if (factory_editor->properties)
- g_list_free (factory_editor->properties);
- factory_editor->properties = NULL;
- factory_editor->embed = NULL;
+ if (factory_editor->properties)
+ g_list_free (factory_editor->properties);
+ factory_editor->properties = NULL;
+ factory_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_icon_factory_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_icon_factory_editor_parent_class)->finalize (object);
}
static void
-glade_icon_factory_editor_grab_focus (GtkWidget *widget)
+glade_icon_factory_editor_grab_focus (GtkWidget * widget)
{
- GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (widget);
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (widget);
- gtk_widget_grab_focus (factory_editor->embed);
+ gtk_widget_grab_focus (factory_editor->embed);
}
GtkWidget *
-glade_icon_factory_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_icon_factory_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditable * embed)
{
- GladeIconFactoryEditor *factory_editor;
- GladeEditorProperty *eprop;
- GtkWidget *label, *alignment, *frame, *vbox;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- factory_editor = g_object_new (GLADE_TYPE_ICON_FACTORY_EDITOR, NULL);
- factory_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (factory_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- /* Label item in frame label widget on top... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "sources", FALSE, TRUE);
- factory_editor->properties = g_list_prepend (factory_editor->properties, eprop);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (factory_editor), frame, FALSE, FALSE, 12);
-
- /* Alignment/Vbox in frame... */
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (alignment), vbox);
-
- /* Add descriptive label */
- label = gtk_label_new (_("First add a stock name in the entry below, "
- "then add and define sources for that icon "
- "in the treeview."));
- gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
- gtk_label_set_line_wrap_mode (GTK_LABEL(label), PANGO_WRAP_WORD);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8);
-
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 8);
-
- gtk_widget_show_all (GTK_WIDGET (factory_editor));
-
- return GTK_WIDGET (factory_editor);
+ GladeIconFactoryEditor *factory_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *label, *alignment, *frame, *vbox;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ factory_editor = g_object_new (GLADE_TYPE_ICON_FACTORY_EDITOR, NULL);
+ factory_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (factory_editor), GTK_WIDGET (embed), FALSE,
+ FALSE, 0);
+
+ /* Label item in frame label widget on top... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "sources", FALSE,
+ TRUE);
+ factory_editor->properties =
+ g_list_prepend (factory_editor->properties, eprop);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (factory_editor), frame, FALSE, FALSE, 12);
+
+ /* Alignment/Vbox in frame... */
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+ /* Add descriptive label */
+ label = gtk_label_new (_("First add a stock name in the entry below, "
+ "then add and define sources for that icon "
+ "in the treeview."));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8);
+
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 8);
+
+ gtk_widget_show_all (GTK_WIDGET (factory_editor));
+
+ return GTK_WIDGET (factory_editor);
}
diff --git a/plugins/gtk+/glade-icon-factory-editor.h b/plugins/gtk+/glade-icon-factory-editor.h
index dca9cc8..571758e 100644
--- a/plugins/gtk+/glade-icon-factory-editor.h
+++ b/plugins/gtk+/glade-icon-factory-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-icon-sources.c b/plugins/gtk+/glade-icon-sources.c
index d259517..9b6da8a 100644
--- a/plugins/gtk+/glade-icon-sources.c
+++ b/plugins/gtk+/glade-icon-sources.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -30,110 +29,109 @@
#include "glade-icon-sources.h"
static GList *
-icon_set_copy (GList *set)
+icon_set_copy (GList * set)
{
- GList *dup_set = NULL, *l;
- GtkIconSource *source;
-
- for (l = set; l; l = l->next)
- {
- source = gtk_icon_source_copy ((GtkIconSource *)l->data);
- dup_set = g_list_prepend (dup_set, source);
- }
- return g_list_reverse (dup_set);
+ GList *dup_set = NULL, *l;
+ GtkIconSource *source;
+
+ for (l = set; l; l = l->next)
+ {
+ source = gtk_icon_source_copy ((GtkIconSource *) l->data);
+ dup_set = g_list_prepend (dup_set, source);
+ }
+ return g_list_reverse (dup_set);
}
static void
-icon_set_free (GList *list)
+icon_set_free (GList * list)
{
- g_list_foreach (list, (GFunc)gtk_icon_source_free, NULL);
- g_list_free (list);
+ g_list_foreach (list, (GFunc) gtk_icon_source_free, NULL);
+ g_list_free (list);
}
GladeIconSources *
glade_icon_sources_new (void)
{
- GladeIconSources *sources = g_new0 (GladeIconSources, 1);
+ GladeIconSources *sources = g_new0 (GladeIconSources, 1);
- sources->sources = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify)g_free,
- (GDestroyNotify)icon_set_free);
- return sources;
+ sources->sources = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) icon_set_free);
+ return sources;
}
static void
-icon_sources_dup (gchar *icon_name,
- GList *set,
- GladeIconSources *dup)
+icon_sources_dup (gchar * icon_name, GList * set, GladeIconSources * dup)
{
- GList *dup_set = icon_set_copy (set);
- g_hash_table_insert (dup->sources, g_strdup (icon_name), dup_set);
+ GList *dup_set = icon_set_copy (set);
+ g_hash_table_insert (dup->sources, g_strdup (icon_name), dup_set);
}
GladeIconSources *
-glade_icon_sources_copy (GladeIconSources *sources)
+glade_icon_sources_copy (GladeIconSources * sources)
{
- if (!sources)
- return NULL;
+ if (!sources)
+ return NULL;
- GladeIconSources *dup = glade_icon_sources_new ();
+ GladeIconSources *dup = glade_icon_sources_new ();
- g_hash_table_foreach (sources->sources, (GHFunc)icon_sources_dup, dup);
+ g_hash_table_foreach (sources->sources, (GHFunc) icon_sources_dup, dup);
- return dup;
+ return dup;
}
void
-glade_icon_sources_free (GladeIconSources *sources)
+glade_icon_sources_free (GladeIconSources * sources)
{
- if (sources)
- {
- g_hash_table_destroy (sources->sources);
- g_free (sources);
- }
+ if (sources)
+ {
+ g_hash_table_destroy (sources->sources);
+ g_free (sources);
+ }
}
GType
glade_icon_sources_get_type (void)
{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static
- ("GladeIconSources",
- (GBoxedCopyFunc) glade_icon_sources_copy,
- (GBoxedFreeFunc) glade_icon_sources_free);
- return type_id;
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static
+ ("GladeIconSources",
+ (GBoxedCopyFunc) glade_icon_sources_copy,
+ (GBoxedFreeFunc) glade_icon_sources_free);
+ return type_id;
}
/**************************** GladeEditorProperty *****************************/
-enum {
- COLUMN_TEXT, /* Used for display/editing purposes */
- COLUMN_TEXT_WEIGHT, /* Whether the text is bold (icon-name parent rows) */
- COLUMN_TEXT_EDITABLE, /* parent icon-name displays are not editable */
- COLUMN_ICON_NAME, /* store the icon name regardless */
- COLUMN_LIST_INDEX, /* denotes the position in the GList of the actual property value (or -1) */
- COLUMN_DIRECTION_ACTIVE,
- COLUMN_DIRECTION,
- COLUMN_SIZE_ACTIVE,
- COLUMN_SIZE,
- COLUMN_STATE_ACTIVE,
- COLUMN_STATE,
- NUM_COLUMNS
+enum
+{
+ COLUMN_TEXT, /* Used for display/editing purposes */
+ COLUMN_TEXT_WEIGHT, /* Whether the text is bold (icon-name parent rows) */
+ COLUMN_TEXT_EDITABLE, /* parent icon-name displays are not editable */
+ COLUMN_ICON_NAME, /* store the icon name regardless */
+ COLUMN_LIST_INDEX, /* denotes the position in the GList of the actual property value (or -1) */
+ COLUMN_DIRECTION_ACTIVE,
+ COLUMN_DIRECTION,
+ COLUMN_SIZE_ACTIVE,
+ COLUMN_SIZE,
+ COLUMN_STATE_ACTIVE,
+ COLUMN_STATE,
+ NUM_COLUMNS
};
typedef struct
{
- GladeEditorProperty parent_instance;
+ GladeEditorProperty parent_instance;
- GtkTreeView *view;
- GtkTreeStore *store;
- GtkListStore *icon_names_store;
- GtkTreeViewColumn *filename_column;
- GtkWidget *combo;
+ GtkTreeView *view;
+ GtkTreeStore *store;
+ GtkListStore *icon_names_store;
+ GtkTreeViewColumn *filename_column;
+ GtkWidget *combo;
} GladeEPropIconSources;
GLADE_MAKE_EPROP (GladeEPropIconSources, glade_eprop_icon_sources)
@@ -142,850 +140,869 @@ GLADE_MAKE_EPROP (GladeEPropIconSources, glade_eprop_icon_sources)
#define GLADE_IS_EPROP_ICON_SOURCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_ICON_SOURCES))
#define GLADE_IS_EPROP_ICON_SOURCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_ICON_SOURCES))
#define GLADE_EPROP_ICON_SOURCES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_ICON_SOURCES, GladeEPropIconSourcesClass))
-
-static void
-glade_eprop_icon_sources_finalize (GObject *object)
+ static void glade_eprop_icon_sources_finalize (GObject * object)
{
- /* Chain up */
- GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
- //GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (object);
+ /* Chain up */
+ GObjectClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
+ //GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (object);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-populate_store_foreach (const gchar *icon_name,
- GList *sources,
- GladeEPropIconSources *eprop_sources)
+populate_store_foreach (const gchar * icon_name,
+ GList * sources, GladeEPropIconSources * eprop_sources)
{
- GtkIconSource *source;
- GtkTreeIter parent_iter, iter;
- GList *l;
-
- /* Update the comboboxentry's store here... */
- gtk_list_store_append (eprop_sources->icon_names_store, &iter);
- gtk_list_store_set (eprop_sources->icon_names_store, &iter, 0, icon_name, -1);
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter);
-
- /* Dont set COLUMN_ICON_NAME here */
- gtk_tree_store_append (eprop_sources->store, &parent_iter, NULL);
- gtk_tree_store_set (eprop_sources->store, &parent_iter,
- COLUMN_TEXT, icon_name,
- COLUMN_TEXT_EDITABLE, FALSE,
- COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_BOLD,
- -1);
-
- for (l = sources; l; l = l->next)
- {
- GdkPixbuf *pixbuf;
- gchar *str;
-
- source = l->data;
- pixbuf = gtk_icon_source_get_pixbuf (source);
- str = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
-
- gtk_tree_store_append (eprop_sources->store, &iter, &parent_iter);
- gtk_tree_store_set (eprop_sources->store, &iter,
- COLUMN_ICON_NAME, icon_name,
- COLUMN_LIST_INDEX, g_list_index (sources, source),
- COLUMN_TEXT, str,
- COLUMN_TEXT_EDITABLE, TRUE,
- COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL,
- -1);
-
- if (!gtk_icon_source_get_direction_wildcarded (source))
- {
- GtkTextDirection direction = gtk_icon_source_get_direction (source);
- str = glade_utils_enum_string_from_value_displayable (GTK_TYPE_TEXT_DIRECTION, direction);
- gtk_tree_store_set (eprop_sources->store, &iter,
- COLUMN_DIRECTION_ACTIVE, TRUE,
- COLUMN_DIRECTION, str,
- -1);
- g_free (str);
- }
-
- if (!gtk_icon_source_get_size_wildcarded (source))
- {
- GtkIconSize size = gtk_icon_source_get_size (source);
- str = glade_utils_enum_string_from_value_displayable (GTK_TYPE_ICON_SIZE, size);
- gtk_tree_store_set (eprop_sources->store, &iter,
- COLUMN_SIZE_ACTIVE, TRUE,
- COLUMN_SIZE, str,
- -1);
- g_free (str);
- }
-
- if (!gtk_icon_source_get_state_wildcarded (source))
- {
- GtkStateType state = gtk_icon_source_get_state (source);
- str = glade_utils_enum_string_from_value_displayable (GTK_TYPE_STATE_TYPE, state);
- gtk_tree_store_set (eprop_sources->store, &iter,
- COLUMN_STATE_ACTIVE, TRUE,
- COLUMN_STATE, str,
- -1);
- g_free (str);
- }
-
- if (!l->next)
- {
- GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_sources->store),
- &iter);
- gtk_tree_view_expand_to_path (GTK_TREE_VIEW (eprop_sources->view),
- path);
- gtk_tree_path_free (path);
- }
- }
+ GtkIconSource *source;
+ GtkTreeIter parent_iter, iter;
+ GList *l;
+
+ /* Update the comboboxentry's store here... */
+ gtk_list_store_append (eprop_sources->icon_names_store, &iter);
+ gtk_list_store_set (eprop_sources->icon_names_store, &iter, 0, icon_name, -1);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter);
+
+ /* Dont set COLUMN_ICON_NAME here */
+ gtk_tree_store_append (eprop_sources->store, &parent_iter, NULL);
+ gtk_tree_store_set (eprop_sources->store, &parent_iter,
+ COLUMN_TEXT, icon_name,
+ COLUMN_TEXT_EDITABLE, FALSE,
+ COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
+
+ for (l = sources; l; l = l->next)
+ {
+ GdkPixbuf *pixbuf;
+ gchar *str;
+
+ source = l->data;
+ pixbuf = gtk_icon_source_get_pixbuf (source);
+ str = g_object_get_data (G_OBJECT (pixbuf), "GladeFileName");
+
+ gtk_tree_store_append (eprop_sources->store, &iter, &parent_iter);
+ gtk_tree_store_set (eprop_sources->store, &iter,
+ COLUMN_ICON_NAME, icon_name,
+ COLUMN_LIST_INDEX, g_list_index (sources, source),
+ COLUMN_TEXT, str,
+ COLUMN_TEXT_EDITABLE, TRUE,
+ COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL, -1);
+
+ if (!gtk_icon_source_get_direction_wildcarded (source))
+ {
+ GtkTextDirection direction = gtk_icon_source_get_direction (source);
+ str =
+ glade_utils_enum_string_from_value_displayable
+ (GTK_TYPE_TEXT_DIRECTION, direction);
+ gtk_tree_store_set (eprop_sources->store, &iter,
+ COLUMN_DIRECTION_ACTIVE, TRUE, COLUMN_DIRECTION,
+ str, -1);
+ g_free (str);
+ }
+
+ if (!gtk_icon_source_get_size_wildcarded (source))
+ {
+ GtkIconSize size = gtk_icon_source_get_size (source);
+ str =
+ glade_utils_enum_string_from_value_displayable
+ (GTK_TYPE_ICON_SIZE, size);
+ gtk_tree_store_set (eprop_sources->store, &iter, COLUMN_SIZE_ACTIVE,
+ TRUE, COLUMN_SIZE, str, -1);
+ g_free (str);
+ }
+
+ if (!gtk_icon_source_get_state_wildcarded (source))
+ {
+ GtkStateType state = gtk_icon_source_get_state (source);
+ str =
+ glade_utils_enum_string_from_value_displayable
+ (GTK_TYPE_STATE_TYPE, state);
+ gtk_tree_store_set (eprop_sources->store, &iter, COLUMN_STATE_ACTIVE,
+ TRUE, COLUMN_STATE, str, -1);
+ g_free (str);
+ }
+
+ if (!l->next)
+ {
+ GtkTreePath *path =
+ gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_sources->store),
+ &iter);
+ gtk_tree_view_expand_to_path (GTK_TREE_VIEW (eprop_sources->view),
+ path);
+ gtk_tree_path_free (path);
+ }
+ }
}
static void
-populate_store (GladeEPropIconSources *eprop_sources)
+populate_store (GladeEPropIconSources * eprop_sources)
{
- GladeIconSources *sources = NULL;
+ GladeIconSources *sources = NULL;
- gtk_tree_store_clear (eprop_sources->store);
- gtk_list_store_clear (eprop_sources->icon_names_store);
+ gtk_tree_store_clear (eprop_sources->store);
+ gtk_list_store_clear (eprop_sources->icon_names_store);
- if (!GLADE_EDITOR_PROPERTY (eprop_sources)->property)
- return;
+ if (!GLADE_EDITOR_PROPERTY (eprop_sources)->property)
+ return;
- glade_property_get (GLADE_EDITOR_PROPERTY (eprop_sources)->property, &sources);
+ glade_property_get (GLADE_EDITOR_PROPERTY (eprop_sources)->property,
+ &sources);
- if (sources)
- g_hash_table_foreach (sources->sources, (GHFunc)populate_store_foreach, eprop_sources);
+ if (sources)
+ g_hash_table_foreach (sources->sources, (GHFunc) populate_store_foreach,
+ eprop_sources);
}
static void
-glade_eprop_icon_sources_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_eprop_icon_sources_load (GladeEditorProperty * eprop,
+ GladeProperty * property)
{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- /* Chain up in a clean state... */
- parent_class->load (eprop, property);
+ /* Chain up in a clean state... */
+ parent_class->load (eprop, property);
- populate_store (eprop_sources);
+ populate_store (eprop_sources);
- gtk_widget_queue_draw (GTK_WIDGET (eprop_sources->view));
+ gtk_widget_queue_draw (GTK_WIDGET (eprop_sources->view));
}
static gboolean
-reload_icon_sources_idle (GladeEditorProperty *eprop)
+reload_icon_sources_idle (GladeEditorProperty * eprop)
{
- glade_editor_property_load (eprop, eprop->property);
- return FALSE;
+ glade_editor_property_load (eprop, eprop->property);
+ return FALSE;
}
static void
-add_clicked (GtkWidget *button,
- GladeEPropIconSources *eprop_sources)
+add_clicked (GtkWidget * button, GladeEPropIconSources * eprop_sources)
{
- /* Remember to set focus on the cell and activate it ! */
- GtkTreeIter *parent_iter = NULL, iter, new_parent_iter;
- GtkTreePath *new_item_path;
- gchar *icon_name;
- gchar *selected_icon_name = NULL;
- gint index;
-
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter))
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->icon_names_store), &iter,
- 0, &selected_icon_name, -1);
-
- if (!selected_icon_name)
- return;
-
- /* Find the right parent iter to add a child to... */
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_sources->store), &iter))
- {
- do {
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_TEXT, &icon_name,
- -1);
-
- if (icon_name &&
- strcmp (icon_name, selected_icon_name) == 0)
- parent_iter = gtk_tree_iter_copy (&iter);
-
- g_free (icon_name);
-
- } while (parent_iter == NULL &&
- gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_sources->store), &iter));
- }
-
- /* check if we're already adding one here... */
- if (parent_iter &&
- gtk_tree_model_iter_children (GTK_TREE_MODEL (eprop_sources->store), &iter, parent_iter))
- {
- do {
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_LIST_INDEX, &index,
- -1);
-
- /* Iter is set, expand and return. */
- if (index < 0)
- goto expand_to_path_and_focus;
-
- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_sources->store), &iter));
- }
-
-
- if (!parent_iter)
- {
- /* Dont set COLUMN_ICON_NAME here */
- gtk_tree_store_append (eprop_sources->store, &new_parent_iter, NULL);
- gtk_tree_store_set (eprop_sources->store, &new_parent_iter,
- COLUMN_TEXT, selected_icon_name,
- COLUMN_TEXT_EDITABLE, FALSE,
- COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_BOLD,
- -1);
- parent_iter = gtk_tree_iter_copy (&new_parent_iter);
- }
-
- gtk_tree_store_append (eprop_sources->store, &iter, parent_iter);
- gtk_tree_store_set (eprop_sources->store, &iter,
- COLUMN_ICON_NAME, selected_icon_name,
- COLUMN_TEXT_EDITABLE, TRUE,
- COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL,
- COLUMN_LIST_INDEX, -1,
- -1);
-
- /* By now iter is valid. */
- expand_to_path_and_focus:
- new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_sources->store), &iter);
-
- gtk_widget_grab_focus (GTK_WIDGET (eprop_sources->view));
- gtk_tree_view_expand_to_path (eprop_sources->view, new_item_path);
- gtk_tree_view_set_cursor (eprop_sources->view, new_item_path,
- eprop_sources->filename_column, TRUE);
-
- g_free (selected_icon_name);
- gtk_tree_iter_free (parent_iter);
+ /* Remember to set focus on the cell and activate it ! */
+ GtkTreeIter *parent_iter = NULL, iter, new_parent_iter;
+ GtkTreePath *new_item_path;
+ gchar *icon_name;
+ gchar *selected_icon_name = NULL;
+ gint index;
+
+ if (gtk_combo_box_get_active_iter
+ (GTK_COMBO_BOX (eprop_sources->combo), &iter))
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->icon_names_store), &iter,
+ 0, &selected_icon_name, -1);
+
+ if (!selected_icon_name)
+ return;
+
+ /* Find the right parent iter to add a child to... */
+ if (gtk_tree_model_get_iter_first
+ (GTK_TREE_MODEL (eprop_sources->store), &iter))
+ {
+ do
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_TEXT, &icon_name, -1);
+
+ if (icon_name && strcmp (icon_name, selected_icon_name) == 0)
+ parent_iter = gtk_tree_iter_copy (&iter);
+
+ g_free (icon_name);
+
+ }
+ while (parent_iter == NULL &&
+ gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_sources->store),
+ &iter));
+ }
+
+ /* check if we're already adding one here... */
+ if (parent_iter &&
+ gtk_tree_model_iter_children (GTK_TREE_MODEL (eprop_sources->store),
+ &iter, parent_iter))
+ {
+ do
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_LIST_INDEX, &index, -1);
+
+ /* Iter is set, expand and return. */
+ if (index < 0)
+ goto expand_to_path_and_focus;
+
+ }
+ while (gtk_tree_model_iter_next
+ (GTK_TREE_MODEL (eprop_sources->store), &iter));
+ }
+
+
+ if (!parent_iter)
+ {
+ /* Dont set COLUMN_ICON_NAME here */
+ gtk_tree_store_append (eprop_sources->store, &new_parent_iter, NULL);
+ gtk_tree_store_set (eprop_sources->store, &new_parent_iter,
+ COLUMN_TEXT, selected_icon_name,
+ COLUMN_TEXT_EDITABLE, FALSE,
+ COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
+ parent_iter = gtk_tree_iter_copy (&new_parent_iter);
+ }
+
+ gtk_tree_store_append (eprop_sources->store, &iter, parent_iter);
+ gtk_tree_store_set (eprop_sources->store, &iter,
+ COLUMN_ICON_NAME, selected_icon_name,
+ COLUMN_TEXT_EDITABLE, TRUE,
+ COLUMN_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL,
+ COLUMN_LIST_INDEX, -1, -1);
+
+ /* By now iter is valid. */
+expand_to_path_and_focus:
+ new_item_path =
+ gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_sources->store), &iter);
+
+ gtk_widget_grab_focus (GTK_WIDGET (eprop_sources->view));
+ gtk_tree_view_expand_to_path (eprop_sources->view, new_item_path);
+ gtk_tree_view_set_cursor (eprop_sources->view, new_item_path,
+ eprop_sources->filename_column, TRUE);
+
+ g_free (selected_icon_name);
+ gtk_tree_iter_free (parent_iter);
}
static GtkIconSource *
-get_icon_source (GladeIconSources *sources,
- const gchar *icon_name,
- gint index)
+get_icon_source (GladeIconSources * sources,
+ const gchar * icon_name, gint index)
{
- GList *source_list =
- g_hash_table_lookup (sources->sources, icon_name);
-
- if (source_list)
- {
- if (index < 0)
- return NULL;
- else
- return (GtkIconSource *)g_list_nth_data (source_list, index);
- }
- return NULL;
+ GList *source_list = g_hash_table_lookup (sources->sources, icon_name);
+
+ if (source_list)
+ {
+ if (index < 0)
+ return NULL;
+ else
+ return (GtkIconSource *) g_list_nth_data (source_list, index);
+ }
+ return NULL;
}
static void
-update_icon_sources (GladeEditorProperty *eprop,
- GladeIconSources *icon_sources)
+update_icon_sources (GladeEditorProperty * eprop,
+ GladeIconSources * icon_sources)
{
- GValue value = { 0, };
-
- g_value_init (&value, GLADE_TYPE_ICON_SOURCES);
- g_value_take_boxed (&value, icon_sources);
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
+ GValue value = { 0, };
+
+ g_value_init (&value, GLADE_TYPE_ICON_SOURCES);
+ g_value_take_boxed (&value, icon_sources);
+ glade_editor_property_commit (eprop, &value);
+ g_value_unset (&value);
}
static void
-delete_clicked (GtkWidget *button,
- GladeEditorProperty *eprop)
+delete_clicked (GtkWidget * button, GladeEditorProperty * eprop)
{
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- GtkTreeIter iter;
- GladeIconSources *icon_sources = NULL;
- GList *list, *sources, *new_list_head;
- gchar *icon_name;
- gint index = 0;
-
- /* NOTE: This will trigger row-deleted below... */
- if (!gtk_tree_selection_get_selected
- (gtk_tree_view_get_selection (eprop_sources->view), NULL, &iter))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_ICON_NAME, &icon_name,
- COLUMN_LIST_INDEX, &index,
- -1);
-
- /* Could be the user pressed add and then delete without touching the
- * new item.
- */
- if (index < 0)
- {
- g_idle_add ((GSourceFunc)reload_icon_sources_idle, eprop);
- return;
- }
-
- glade_property_get (eprop->property, &icon_sources);
- if (icon_sources)
- {
- icon_sources = glade_icon_sources_copy (icon_sources);
-
- if ((sources = g_hash_table_lookup (icon_sources->sources, icon_name)) != NULL)
- {
- new_list_head = icon_set_copy (sources);
-
- list = g_list_nth (new_list_head, index);
- new_list_head = g_list_remove_link (new_list_head, list);
-
- gtk_icon_source_free ((GtkIconSource *)list->data);
- g_list_free (list);
-
- /* We copied all that above cause this will free the old list */
- g_hash_table_insert (icon_sources->sources, g_strdup (icon_name),
- new_list_head);
-
- }
- update_icon_sources (eprop, icon_sources);
- }
- g_free (icon_name);
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ GtkTreeIter iter;
+ GladeIconSources *icon_sources = NULL;
+ GList *list, *sources, *new_list_head;
+ gchar *icon_name;
+ gint index = 0;
+
+ /* NOTE: This will trigger row-deleted below... */
+ if (!gtk_tree_selection_get_selected
+ (gtk_tree_view_get_selection (eprop_sources->view), NULL, &iter))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_ICON_NAME, &icon_name,
+ COLUMN_LIST_INDEX, &index, -1);
+
+ /* Could be the user pressed add and then delete without touching the
+ * new item.
+ */
+ if (index < 0)
+ {
+ g_idle_add ((GSourceFunc) reload_icon_sources_idle, eprop);
+ return;
+ }
+
+ glade_property_get (eprop->property, &icon_sources);
+ if (icon_sources)
+ {
+ icon_sources = glade_icon_sources_copy (icon_sources);
+
+ if ((sources =
+ g_hash_table_lookup (icon_sources->sources, icon_name)) != NULL)
+ {
+ new_list_head = icon_set_copy (sources);
+
+ list = g_list_nth (new_list_head, index);
+ new_list_head = g_list_remove_link (new_list_head, list);
+
+ gtk_icon_source_free ((GtkIconSource *) list->data);
+ g_list_free (list);
+
+ /* We copied all that above cause this will free the old list */
+ g_hash_table_insert (icon_sources->sources, g_strdup (icon_name),
+ new_list_head);
+
+ }
+ update_icon_sources (eprop, icon_sources);
+ }
+ g_free (icon_name);
}
static void
-value_filename_edited (GtkCellRendererText *cell,
- const gchar *path,
- const gchar *new_text,
- GladeEditorProperty *eprop)
+value_filename_edited (GtkCellRendererText * cell,
+ const gchar * path,
+ const gchar * new_text, GladeEditorProperty * eprop)
{
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- GtkTreeIter iter;
- GladeIconSources *icon_sources = NULL;
- GtkIconSource *source;
- gchar *icon_name;
- gint index = -1;
- GValue *value;
- GdkPixbuf *pixbuf;
- GList *source_list;
-
- if (!new_text || !new_text[0])
- {
- g_idle_add ((GSourceFunc)reload_icon_sources_idle, eprop);
- return;
- }
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_ICON_NAME, &icon_name,
- COLUMN_LIST_INDEX, &index,
- -1);
-
- /* get new pixbuf value... */
- value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, new_text,
- eprop->property->widget->project,
- eprop->property->widget);
- pixbuf = g_value_get_object (value);
-
-
- glade_property_get (eprop->property, &icon_sources);
- if (icon_sources)
- {
- icon_sources = glade_icon_sources_copy (icon_sources);
-
- if (index >= 0 && (source = get_icon_source (icon_sources, icon_name, index)) != NULL)
- gtk_icon_source_set_pixbuf (source, pixbuf);
- else
- {
-
- source = gtk_icon_source_new ();
- gtk_icon_source_set_pixbuf (source, pixbuf);
-
- if ((source_list = g_hash_table_lookup (icon_sources->sources,
- icon_name)) != NULL)
- {
- source_list = g_list_append (source_list, source);
- }
- else
- {
- source_list = g_list_prepend (NULL, source);
- g_hash_table_insert (icon_sources->sources, g_strdup (icon_name), source_list);
- }
- }
- }
- else
- {
- icon_sources = glade_icon_sources_new ();
- source = gtk_icon_source_new ();
- gtk_icon_source_set_pixbuf (source, pixbuf);
-
- source_list = g_list_prepend (NULL, source);
- g_hash_table_insert (icon_sources->sources, g_strdup (icon_name), source_list);
- }
-
- g_value_unset (value);
- g_free (value);
-
- update_icon_sources (eprop, icon_sources);
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ GtkTreeIter iter;
+ GladeIconSources *icon_sources = NULL;
+ GtkIconSource *source;
+ gchar *icon_name;
+ gint index = -1;
+ GValue *value;
+ GdkPixbuf *pixbuf;
+ GList *source_list;
+
+ if (!new_text || !new_text[0])
+ {
+ g_idle_add ((GSourceFunc) reload_icon_sources_idle, eprop);
+ return;
+ }
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_ICON_NAME, &icon_name,
+ COLUMN_LIST_INDEX, &index, -1);
+
+ /* get new pixbuf value... */
+ value = glade_utils_value_from_string (GDK_TYPE_PIXBUF, new_text,
+ eprop->property->widget->project,
+ eprop->property->widget);
+ pixbuf = g_value_get_object (value);
+
+
+ glade_property_get (eprop->property, &icon_sources);
+ if (icon_sources)
+ {
+ icon_sources = glade_icon_sources_copy (icon_sources);
+
+ if (index >= 0 &&
+ (source = get_icon_source (icon_sources, icon_name, index)) != NULL)
+ gtk_icon_source_set_pixbuf (source, pixbuf);
+ else
+ {
+
+ source = gtk_icon_source_new ();
+ gtk_icon_source_set_pixbuf (source, pixbuf);
+
+ if ((source_list = g_hash_table_lookup (icon_sources->sources,
+ icon_name)) != NULL)
+ {
+ source_list = g_list_append (source_list, source);
+ }
+ else
+ {
+ source_list = g_list_prepend (NULL, source);
+ g_hash_table_insert (icon_sources->sources, g_strdup (icon_name),
+ source_list);
+ }
+ }
+ }
+ else
+ {
+ icon_sources = glade_icon_sources_new ();
+ source = gtk_icon_source_new ();
+ gtk_icon_source_set_pixbuf (source, pixbuf);
+
+ source_list = g_list_prepend (NULL, source);
+ g_hash_table_insert (icon_sources->sources, g_strdup (icon_name),
+ source_list);
+ }
+
+ g_value_unset (value);
+ g_free (value);
+
+ update_icon_sources (eprop, icon_sources);
}
static void
-value_attribute_toggled (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- GladeEditorProperty *eprop)
+value_attribute_toggled (GtkCellRendererToggle * cell_renderer,
+ gchar * path, GladeEditorProperty * eprop)
{
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- GtkTreeIter iter;
- GladeIconSources *icon_sources = NULL;
- GtkIconSource *source;
- gchar *icon_name;
- gint index, edit_column;
- gboolean edit_column_active = FALSE;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
- return;
-
- edit_column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell_renderer), "attribute-column"));
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_ICON_NAME, &icon_name,
- COLUMN_LIST_INDEX, &index,
- edit_column, &edit_column_active,
- -1);
-
- glade_property_get (eprop->property, &icon_sources);
-
- if (icon_sources)
- icon_sources = glade_icon_sources_copy (icon_sources);
-
- if (icon_sources && (source = get_icon_source (icon_sources, icon_name, index)) != NULL)
- {
- /* Note the reverse meaning of active toggles vs. wildcarded sources... */
- switch (edit_column)
- {
- case COLUMN_DIRECTION_ACTIVE:
- gtk_icon_source_set_direction_wildcarded (source, edit_column_active);
- break;
- case COLUMN_SIZE_ACTIVE:
- gtk_icon_source_set_size_wildcarded (source, edit_column_active);
- break;
- case COLUMN_STATE_ACTIVE:
- gtk_icon_source_set_state_wildcarded (source, edit_column_active);
- break;
- default:
- break;
- }
-
- update_icon_sources (eprop, icon_sources);
- g_free (icon_name);
- return;
- }
-
- if (icon_sources)
- glade_icon_sources_free (icon_sources);
- g_free (icon_name);
- return;
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ GtkTreeIter iter;
+ GladeIconSources *icon_sources = NULL;
+ GtkIconSource *source;
+ gchar *icon_name;
+ gint index, edit_column;
+ gboolean edit_column_active = FALSE;
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
+ return;
+
+ edit_column =
+ GPOINTER_TO_INT (g_object_get_data
+ (G_OBJECT (cell_renderer), "attribute-column"));
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_ICON_NAME, &icon_name, COLUMN_LIST_INDEX, &index,
+ edit_column, &edit_column_active, -1);
+
+ glade_property_get (eprop->property, &icon_sources);
+
+ if (icon_sources)
+ icon_sources = glade_icon_sources_copy (icon_sources);
+
+ if (icon_sources &&
+ (source = get_icon_source (icon_sources, icon_name, index)) != NULL)
+ {
+ /* Note the reverse meaning of active toggles vs. wildcarded sources... */
+ switch (edit_column)
+ {
+ case COLUMN_DIRECTION_ACTIVE:
+ gtk_icon_source_set_direction_wildcarded (source,
+ edit_column_active);
+ break;
+ case COLUMN_SIZE_ACTIVE:
+ gtk_icon_source_set_size_wildcarded (source, edit_column_active);
+ break;
+ case COLUMN_STATE_ACTIVE:
+ gtk_icon_source_set_state_wildcarded (source, edit_column_active);
+ break;
+ default:
+ break;
+ }
+
+ update_icon_sources (eprop, icon_sources);
+ g_free (icon_name);
+ return;
+ }
+
+ if (icon_sources)
+ glade_icon_sources_free (icon_sources);
+ g_free (icon_name);
+ return;
}
static void
-value_attribute_edited (GtkCellRendererText *cell,
- const gchar *path,
- const gchar *new_text,
- GladeEditorProperty *eprop)
+value_attribute_edited (GtkCellRendererText * cell,
+ const gchar * path,
+ const gchar * new_text, GladeEditorProperty * eprop)
{
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- GtkTreeIter iter;
- GladeIconSources *icon_sources = NULL;
- GtkIconSource *source;
- gchar *icon_name;
- gint index, edit_column;
-
- if (!new_text || !new_text[0])
- return;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
- return;
-
- edit_column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "attribute-column"));
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_ICON_NAME, &icon_name,
- COLUMN_LIST_INDEX, &index,
- -1);
-
- glade_property_get (eprop->property, &icon_sources);
-
- if (icon_sources)
- icon_sources = glade_icon_sources_copy (icon_sources);
-
- if (icon_sources && (source = get_icon_source (icon_sources, icon_name, index)) != NULL)
- {
- GtkTextDirection direction;
- GtkIconSize size;
- GtkStateType state;
-
- switch (edit_column)
- {
- case COLUMN_DIRECTION:
- direction = glade_utils_enum_value_from_string (GTK_TYPE_TEXT_DIRECTION, new_text);
- gtk_icon_source_set_direction (source, direction);
- break;
- case COLUMN_SIZE:
- size = glade_utils_enum_value_from_string (GTK_TYPE_ICON_SIZE, new_text);
- gtk_icon_source_set_size (source, size);
- break;
- case COLUMN_STATE:
- state = glade_utils_enum_value_from_string (GTK_TYPE_STATE_TYPE, new_text);
- gtk_icon_source_set_state (source, state);
- break;
- default:
- break;
- }
-
- update_icon_sources (eprop, icon_sources);
- g_free (icon_name);
- return;
- }
-
- if (icon_sources)
- glade_icon_sources_free (icon_sources);
- g_free (icon_name);
- return;
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ GtkTreeIter iter;
+ GladeIconSources *icon_sources = NULL;
+ GtkIconSource *source;
+ gchar *icon_name;
+ gint index, edit_column;
+
+ if (!new_text || !new_text[0])
+ return;
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
+ return;
+
+ edit_column =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "attribute-column"));
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_ICON_NAME, &icon_name, COLUMN_LIST_INDEX, &index,
+ -1);
+
+ glade_property_get (eprop->property, &icon_sources);
+
+ if (icon_sources)
+ icon_sources = glade_icon_sources_copy (icon_sources);
+
+ if (icon_sources &&
+ (source = get_icon_source (icon_sources, icon_name, index)) != NULL)
+ {
+ GtkTextDirection direction;
+ GtkIconSize size;
+ GtkStateType state;
+
+ switch (edit_column)
+ {
+ case COLUMN_DIRECTION:
+ direction =
+ glade_utils_enum_value_from_string (GTK_TYPE_TEXT_DIRECTION,
+ new_text);
+ gtk_icon_source_set_direction (source, direction);
+ break;
+ case COLUMN_SIZE:
+ size =
+ glade_utils_enum_value_from_string (GTK_TYPE_ICON_SIZE,
+ new_text);
+ gtk_icon_source_set_size (source, size);
+ break;
+ case COLUMN_STATE:
+ state =
+ glade_utils_enum_value_from_string (GTK_TYPE_STATE_TYPE,
+ new_text);
+ gtk_icon_source_set_state (source, state);
+ break;
+ default:
+ break;
+ }
+
+ update_icon_sources (eprop, icon_sources);
+ g_free (icon_name);
+ return;
+ }
+
+ if (icon_sources)
+ glade_icon_sources_free (icon_sources);
+ g_free (icon_name);
+ return;
}
static gboolean
-icon_sources_query_tooltip (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_mode,
- GtkTooltip *tooltip,
- GladeEPropIconSources *eprop_sources)
+icon_sources_query_tooltip (GtkWidget * widget,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip * tooltip,
+ GladeEPropIconSources * eprop_sources)
{
- GtkTreePath *path = NULL;
- GtkTreeIter iter;
- GtkTreeViewColumn *column = NULL;
- gint bin_x = x, bin_y = y, col;
- gchar *icon_name = NULL;
- gboolean show_now = FALSE;
-
- if (keyboard_mode)
- return FALSE;
-
- gtk_tree_view_convert_widget_to_bin_window_coords (eprop_sources->view,
- x, y, &bin_x, &bin_y);
-
- if (gtk_tree_view_get_path_at_pos (eprop_sources->view,
- bin_x, bin_y,
- &path, &column, NULL, NULL))
- {
- if (gtk_tree_model_get_iter (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
- {
- col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (column), "column-id"));
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
- COLUMN_ICON_NAME, &icon_name, -1);
-
- /* no tooltips on the parent rows */
- if (icon_name)
- {
- gchar *tooltip_text = NULL;
- show_now = TRUE;
-
- switch (col)
- {
- case COLUMN_TEXT:
- tooltip_text =
- g_strdup_printf (_("Enter a filename or a relative or full path for this "
- "source of '%s' (Glade will only ever load them in "
- "the runtime from your project directory)."),
- icon_name);
- break;
- case COLUMN_DIRECTION_ACTIVE:
- tooltip_text =
- g_strdup_printf (_("Set whether you want to specify a text direction "
- "for this source of '%s'"), icon_name);
- break;
- case COLUMN_DIRECTION:
- tooltip_text =
- g_strdup_printf (_("Set the text direction for this source of '%s'"),
- icon_name);
- break;
- case COLUMN_SIZE_ACTIVE:
- tooltip_text =
- g_strdup_printf (_("Set whether you want to specify an icon size "
- "for this source of '%s'"), icon_name);
- break;
- case COLUMN_SIZE:
- tooltip_text =
- g_strdup_printf (_("Set the icon size for this source of '%s'"),
- icon_name);
- break;
- case COLUMN_STATE_ACTIVE:
- tooltip_text =
- g_strdup_printf (_("Set whether you want to specify a state "
- "for this source of '%s'"), icon_name);
- break;
- case COLUMN_STATE:
- tooltip_text =
- g_strdup_printf (_("Set the state for this source of '%s'"),
- icon_name);
- default:
- break;
-
- }
-
- gtk_tooltip_set_text (tooltip, tooltip_text);
- g_free (tooltip_text);
- g_free (icon_name);
-
-
- gtk_tree_view_set_tooltip_cell (eprop_sources->view,
- tooltip, path, column, NULL);
-
- }
- }
- gtk_tree_path_free (path);
- }
- return show_now;
+ GtkTreePath *path = NULL;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column = NULL;
+ gint bin_x = x, bin_y = y, col;
+ gchar *icon_name = NULL;
+ gboolean show_now = FALSE;
+
+ if (keyboard_mode)
+ return FALSE;
+
+ gtk_tree_view_convert_widget_to_bin_window_coords (eprop_sources->view,
+ x, y, &bin_x, &bin_y);
+
+ if (gtk_tree_view_get_path_at_pos (eprop_sources->view,
+ bin_x, bin_y, &path, &column, NULL, NULL))
+ {
+ if (gtk_tree_model_get_iter
+ (GTK_TREE_MODEL (eprop_sources->store), &iter, path))
+ {
+ col =
+ GPOINTER_TO_INT (g_object_get_data
+ (G_OBJECT (column), "column-id"));
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_sources->store), &iter,
+ COLUMN_ICON_NAME, &icon_name, -1);
+
+ /* no tooltips on the parent rows */
+ if (icon_name)
+ {
+ gchar *tooltip_text = NULL;
+ show_now = TRUE;
+
+ switch (col)
+ {
+ case COLUMN_TEXT:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Enter a filename or a relative or full path for this "
+ "source of '%s' (Glade will only ever load them in "
+ "the runtime from your project directory)."),
+ icon_name);
+ break;
+ case COLUMN_DIRECTION_ACTIVE:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Set whether you want to specify a text direction "
+ "for this source of '%s'"),
+ icon_name);
+ break;
+ case COLUMN_DIRECTION:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Set the text direction for this source of '%s'"),
+ icon_name);
+ break;
+ case COLUMN_SIZE_ACTIVE:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Set whether you want to specify an icon size "
+ "for this source of '%s'"),
+ icon_name);
+ break;
+ case COLUMN_SIZE:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Set the icon size for this source of '%s'"),
+ icon_name);
+ break;
+ case COLUMN_STATE_ACTIVE:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Set whether you want to specify a state "
+ "for this source of '%s'"),
+ icon_name);
+ break;
+ case COLUMN_STATE:
+ tooltip_text =
+ g_strdup_printf (_
+ ("Set the state for this source of '%s'"),
+ icon_name);
+ default:
+ break;
+
+ }
+
+ gtk_tooltip_set_text (tooltip, tooltip_text);
+ g_free (tooltip_text);
+ g_free (icon_name);
+
+
+ gtk_tree_view_set_tooltip_cell (eprop_sources->view,
+ tooltip, path, column, NULL);
+
+ }
+ }
+ gtk_tree_path_free (path);
+ }
+ return show_now;
}
static GtkTreeView *
-build_view (GladeEditorProperty *eprop)
+build_view (GladeEditorProperty * eprop)
{
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- static GtkListStore *direction_store = NULL, *size_store = NULL, *state_store = NULL;
- GtkTreeView *view = (GtkTreeView *)gtk_tree_view_new ();
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- if (!direction_store)
- {
- direction_store = glade_utils_liststore_from_enum_type (GTK_TYPE_TEXT_DIRECTION, FALSE);
- size_store = glade_utils_liststore_from_enum_type (GTK_TYPE_ICON_SIZE, FALSE);
- state_store = glade_utils_liststore_from_enum_type (GTK_TYPE_STATE_TYPE, FALSE);
- }
-
- /* Filename / icon name column/renderer */
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_filename_edited), eprop);
-
- eprop_sources->filename_column =
- gtk_tree_view_column_new_with_attributes (_("File Name"), renderer,
- "text", COLUMN_TEXT,
- "weight", COLUMN_TEXT_WEIGHT,
- "editable", COLUMN_TEXT_EDITABLE,
- NULL);
- gtk_tree_view_column_set_expand (eprop_sources->filename_column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), eprop_sources->filename_column);
-
- g_object_set_data (G_OBJECT (eprop_sources->filename_column), "column-id",
- GINT_TO_POINTER (COLUMN_TEXT));
-
- /********************* Size *********************/
- /* Attribute active portion */
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
- g_object_set_data (G_OBJECT (renderer), "attribute-column",
- GINT_TO_POINTER (COLUMN_SIZE_ACTIVE));
- g_signal_connect (G_OBJECT (renderer), "toggled",
- G_CALLBACK (value_attribute_toggled), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- ("dummy", renderer,
- "visible", COLUMN_TEXT_EDITABLE,
- "active", COLUMN_SIZE_ACTIVE,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
- g_object_set_data (G_OBJECT (column), "column-id",
- GINT_TO_POINTER (COLUMN_SIZE_ACTIVE));
-
- /* Attribute portion */
- renderer = gtk_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "editable", TRUE, "has-entry", FALSE,
- "text-column", 0, "model", size_store, NULL);
- g_object_set_data (G_OBJECT (renderer), "attribute-column",
- GINT_TO_POINTER (COLUMN_SIZE));
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_attribute_edited), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- ("dummy", renderer,
- "visible", COLUMN_TEXT_EDITABLE,
- "editable", COLUMN_SIZE_ACTIVE,
- "text", COLUMN_SIZE,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
- g_object_set_data (G_OBJECT (column), "column-id",
- GINT_TO_POINTER (COLUMN_SIZE));
-
-
- /********************* State *********************/
- /* Attribute active portion */
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
- g_object_set_data (G_OBJECT (renderer), "attribute-column",
- GINT_TO_POINTER (COLUMN_STATE_ACTIVE));
- g_signal_connect (G_OBJECT (renderer), "toggled",
- G_CALLBACK (value_attribute_toggled), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- ("dummy", renderer,
- "visible", COLUMN_TEXT_EDITABLE,
- "active", COLUMN_STATE_ACTIVE,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
- g_object_set_data (G_OBJECT (column), "column-id",
- GINT_TO_POINTER (COLUMN_STATE_ACTIVE));
-
- /* Attribute portion */
- renderer = gtk_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "editable", TRUE, "has-entry", FALSE,
- "text-column", 0, "model", state_store, NULL);
- g_object_set_data (G_OBJECT (renderer), "attribute-column",
- GINT_TO_POINTER (COLUMN_STATE));
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_attribute_edited), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- ("dummy", renderer,
- "visible", COLUMN_TEXT_EDITABLE,
- "editable", COLUMN_STATE_ACTIVE,
- "text", COLUMN_STATE,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
- g_object_set_data (G_OBJECT (column), "column-id",
- GINT_TO_POINTER (COLUMN_STATE));
-
-
- /********************* Direction *********************/
- /* Attribute active portion */
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
- g_object_set_data (G_OBJECT (renderer), "attribute-column",
- GINT_TO_POINTER (COLUMN_DIRECTION_ACTIVE));
- g_signal_connect (G_OBJECT (renderer), "toggled",
- G_CALLBACK (value_attribute_toggled), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- ("dummy", renderer,
- "visible", COLUMN_TEXT_EDITABLE,
- "active", COLUMN_DIRECTION_ACTIVE,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
- g_object_set_data (G_OBJECT (column), "column-id",
- GINT_TO_POINTER (COLUMN_DIRECTION_ACTIVE));
-
- /* Attribute portion */
- renderer = gtk_cell_renderer_combo_new ();
- g_object_set (G_OBJECT (renderer), "editable", TRUE, "has-entry", FALSE,
- "text-column", 0, "model", direction_store, NULL);
- g_object_set_data (G_OBJECT (renderer), "attribute-column",
- GINT_TO_POINTER (COLUMN_DIRECTION));
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_attribute_edited), eprop);
-
- column = gtk_tree_view_column_new_with_attributes
- ("dummy", renderer,
- "visible", COLUMN_TEXT_EDITABLE,
- "editable", COLUMN_DIRECTION_ACTIVE,
- "text", COLUMN_DIRECTION,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
- g_object_set_data (G_OBJECT (column), "column-id",
- GINT_TO_POINTER (COLUMN_DIRECTION));
-
-
- /* Connect ::query-tooltip here for fancy tooltips... */
- g_object_set (G_OBJECT (view), "has-tooltip", TRUE, NULL);
- g_signal_connect (G_OBJECT (view), "query-tooltip",
- G_CALLBACK (icon_sources_query_tooltip), eprop);
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
- gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view), FALSE);
-
- return view;
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ static GtkListStore *direction_store = NULL, *size_store =
+ NULL, *state_store = NULL;
+ GtkTreeView *view = (GtkTreeView *) gtk_tree_view_new ();
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+ if (!direction_store)
+ {
+ direction_store =
+ glade_utils_liststore_from_enum_type (GTK_TYPE_TEXT_DIRECTION, FALSE);
+ size_store =
+ glade_utils_liststore_from_enum_type (GTK_TYPE_ICON_SIZE, FALSE);
+ state_store =
+ glade_utils_liststore_from_enum_type (GTK_TYPE_STATE_TYPE, FALSE);
+ }
+
+ /* Filename / icon name column/renderer */
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_filename_edited), eprop);
+
+ eprop_sources->filename_column =
+ gtk_tree_view_column_new_with_attributes (_("File Name"), renderer,
+ "text", COLUMN_TEXT,
+ "weight", COLUMN_TEXT_WEIGHT,
+ "editable",
+ COLUMN_TEXT_EDITABLE, NULL);
+ gtk_tree_view_column_set_expand (eprop_sources->filename_column, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view),
+ eprop_sources->filename_column);
+
+ g_object_set_data (G_OBJECT (eprop_sources->filename_column), "column-id",
+ GINT_TO_POINTER (COLUMN_TEXT));
+
+ /********************* Size *********************/
+ /* Attribute active portion */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+ g_object_set_data (G_OBJECT (renderer), "attribute-column",
+ GINT_TO_POINTER (COLUMN_SIZE_ACTIVE));
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (value_attribute_toggled), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ ("dummy", renderer,
+ "visible", COLUMN_TEXT_EDITABLE, "active", COLUMN_SIZE_ACTIVE, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
+ g_object_set_data (G_OBJECT (column), "column-id",
+ GINT_TO_POINTER (COLUMN_SIZE_ACTIVE));
+
+ /* Attribute portion */
+ renderer = gtk_cell_renderer_combo_new ();
+ g_object_set (G_OBJECT (renderer), "editable", TRUE, "has-entry", FALSE,
+ "text-column", 0, "model", size_store, NULL);
+ g_object_set_data (G_OBJECT (renderer), "attribute-column",
+ GINT_TO_POINTER (COLUMN_SIZE));
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_attribute_edited), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ ("dummy", renderer,
+ "visible", COLUMN_TEXT_EDITABLE,
+ "editable", COLUMN_SIZE_ACTIVE, "text", COLUMN_SIZE, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
+ g_object_set_data (G_OBJECT (column), "column-id",
+ GINT_TO_POINTER (COLUMN_SIZE));
+
+
+ /********************* State *********************/
+ /* Attribute active portion */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+ g_object_set_data (G_OBJECT (renderer), "attribute-column",
+ GINT_TO_POINTER (COLUMN_STATE_ACTIVE));
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (value_attribute_toggled), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ ("dummy", renderer,
+ "visible", COLUMN_TEXT_EDITABLE, "active", COLUMN_STATE_ACTIVE, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
+ g_object_set_data (G_OBJECT (column), "column-id",
+ GINT_TO_POINTER (COLUMN_STATE_ACTIVE));
+
+ /* Attribute portion */
+ renderer = gtk_cell_renderer_combo_new ();
+ g_object_set (G_OBJECT (renderer), "editable", TRUE, "has-entry", FALSE,
+ "text-column", 0, "model", state_store, NULL);
+ g_object_set_data (G_OBJECT (renderer), "attribute-column",
+ GINT_TO_POINTER (COLUMN_STATE));
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_attribute_edited), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ ("dummy", renderer,
+ "visible", COLUMN_TEXT_EDITABLE,
+ "editable", COLUMN_STATE_ACTIVE, "text", COLUMN_STATE, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
+ g_object_set_data (G_OBJECT (column), "column-id",
+ GINT_TO_POINTER (COLUMN_STATE));
+
+
+ /********************* Direction *********************/
+ /* Attribute active portion */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+ g_object_set_data (G_OBJECT (renderer), "attribute-column",
+ GINT_TO_POINTER (COLUMN_DIRECTION_ACTIVE));
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (value_attribute_toggled), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ ("dummy", renderer,
+ "visible", COLUMN_TEXT_EDITABLE,
+ "active", COLUMN_DIRECTION_ACTIVE, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
+ g_object_set_data (G_OBJECT (column), "column-id",
+ GINT_TO_POINTER (COLUMN_DIRECTION_ACTIVE));
+
+ /* Attribute portion */
+ renderer = gtk_cell_renderer_combo_new ();
+ g_object_set (G_OBJECT (renderer), "editable", TRUE, "has-entry", FALSE,
+ "text-column", 0, "model", direction_store, NULL);
+ g_object_set_data (G_OBJECT (renderer), "attribute-column",
+ GINT_TO_POINTER (COLUMN_DIRECTION));
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_attribute_edited), eprop);
+
+ column = gtk_tree_view_column_new_with_attributes
+ ("dummy", renderer,
+ "visible", COLUMN_TEXT_EDITABLE,
+ "editable", COLUMN_DIRECTION_ACTIVE, "text", COLUMN_DIRECTION, NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
+ g_object_set_data (G_OBJECT (column), "column-id",
+ GINT_TO_POINTER (COLUMN_DIRECTION));
+
+
+ /* Connect ::query-tooltip here for fancy tooltips... */
+ g_object_set (G_OBJECT (view), "has-tooltip", TRUE, NULL);
+ g_signal_connect (G_OBJECT (view), "query-tooltip",
+ G_CALLBACK (icon_sources_query_tooltip), eprop);
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
+ gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (view), FALSE);
+
+ return view;
}
static void
-icon_name_entry_activated (GtkEntry *entry,
- GladeEPropIconSources *eprop_sources)
+icon_name_entry_activated (GtkEntry * entry,
+ GladeEPropIconSources * eprop_sources)
{
- GtkTreeIter iter;
- const gchar *text = gtk_entry_get_text (entry);
+ GtkTreeIter iter;
+ const gchar *text = gtk_entry_get_text (entry);
- if (!text || !text[0])
- return;
+ if (!text || !text[0])
+ return;
- gtk_list_store_append (eprop_sources->icon_names_store, &iter);
- gtk_list_store_set (eprop_sources->icon_names_store, &iter,
- 0, text, -1);
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter);
+ gtk_list_store_append (eprop_sources->icon_names_store, &iter);
+ gtk_list_store_set (eprop_sources->icon_names_store, &iter, 0, text, -1);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter);
}
static GtkWidget *
-glade_eprop_icon_sources_create_input (GladeEditorProperty *eprop)
+glade_eprop_icon_sources_create_input (GladeEditorProperty * eprop)
{
- GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- GtkWidget *vbox, *hbox, *button, *swin;
-
- vbox = gtk_vbox_new (FALSE, 2);
- hbox = gtk_hbox_new (FALSE, 4);
-
- /* hbox with comboboxentry add/remove source buttons on the right... */
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- eprop_sources->icon_names_store = gtk_list_store_new (1, G_TYPE_STRING);
- eprop_sources->combo = gtk_combo_box_new_with_entry ();
- gtk_combo_box_set_model (GTK_COMBO_BOX (eprop_sources->combo),
- GTK_TREE_MODEL (eprop_sources->icon_names_store));
- g_signal_connect (G_OBJECT (gtk_bin_get_child (GTK_BIN (eprop_sources->combo))), "activate",
- G_CALLBACK (icon_name_entry_activated), eprop);
-
- gtk_box_pack_start (GTK_BOX (hbox), eprop_sources->combo, TRUE, TRUE, 0);
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (GTK_STOCK_ADD,
- GTK_ICON_SIZE_BUTTON));
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (add_clicked),
- eprop_sources);
-
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON));
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (delete_clicked),
- eprop_sources);
-
- /* Pack treeview/swindow on the left... */
- swin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin), GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
- gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
-
- eprop_sources->view = build_view (eprop);
- gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_sources->view));
-
- g_object_set (G_OBJECT (vbox), "height-request", 350, NULL);
-
- eprop_sources->store = gtk_tree_store_new (NUM_COLUMNS,
- G_TYPE_STRING, // COLUMN_TEXT
- G_TYPE_INT, // COLUMN_TEXT_WEIGHT
- G_TYPE_BOOLEAN, // COLUMN_TEXT_EDITABLE
- G_TYPE_STRING, // COLUMN_ICON_NAME
- G_TYPE_INT, // COLUMN_LIST_INDEX
- G_TYPE_BOOLEAN, // COLUMN_DIRECTION_ACTIVE
- G_TYPE_STRING, // COLUMN_DIRECTION
- G_TYPE_BOOLEAN, // COLUMN_SIZE_ACTIVE
- G_TYPE_STRING, // COLUMN_SIZE
- G_TYPE_BOOLEAN, // COLUMN_STATE_ACTIVE,
- G_TYPE_STRING); // COLUMN_STATE
-
- gtk_tree_view_set_model (eprop_sources->view, GTK_TREE_MODEL (eprop_sources->store));
- g_object_unref (G_OBJECT (eprop_sources->store)); // <-- pass ownership here
-
- gtk_widget_show_all (vbox);
- return vbox;
+ GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
+ GtkWidget *vbox, *hbox, *button, *swin;
+
+ vbox = gtk_vbox_new (FALSE, 2);
+ hbox = gtk_hbox_new (FALSE, 4);
+
+ /* hbox with comboboxentry add/remove source buttons on the right... */
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+ eprop_sources->icon_names_store = gtk_list_store_new (1, G_TYPE_STRING);
+ eprop_sources->combo = gtk_combo_box_new_with_entry ();
+ gtk_combo_box_set_model (GTK_COMBO_BOX (eprop_sources->combo),
+ GTK_TREE_MODEL (eprop_sources->icon_names_store));
+ g_signal_connect (G_OBJECT
+ (gtk_bin_get_child (GTK_BIN (eprop_sources->combo))),
+ "activate", G_CALLBACK (icon_name_entry_activated), eprop);
+
+ gtk_box_pack_start (GTK_BOX (hbox), eprop_sources->combo, TRUE, TRUE, 0);
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_ADD,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (add_clicked), eprop_sources);
+
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_REMOVE,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (delete_clicked), eprop_sources);
+
+ /* Pack treeview/swindow on the left... */
+ swin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
+
+ eprop_sources->view = build_view (eprop);
+ gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_sources->view));
+
+ g_object_set (G_OBJECT (vbox), "height-request", 350, NULL);
+
+ eprop_sources->store = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, // COLUMN_TEXT
+ G_TYPE_INT, // COLUMN_TEXT_WEIGHT
+ G_TYPE_BOOLEAN, // COLUMN_TEXT_EDITABLE
+ G_TYPE_STRING, // COLUMN_ICON_NAME
+ G_TYPE_INT, // COLUMN_LIST_INDEX
+ G_TYPE_BOOLEAN, // COLUMN_DIRECTION_ACTIVE
+ G_TYPE_STRING, // COLUMN_DIRECTION
+ G_TYPE_BOOLEAN, // COLUMN_SIZE_ACTIVE
+ G_TYPE_STRING, // COLUMN_SIZE
+ G_TYPE_BOOLEAN, // COLUMN_STATE_ACTIVE,
+ G_TYPE_STRING); // COLUMN_STATE
+
+ gtk_tree_view_set_model (eprop_sources->view,
+ GTK_TREE_MODEL (eprop_sources->store));
+ g_object_unref (G_OBJECT (eprop_sources->store)); // <-- pass ownership here
+
+ gtk_widget_show_all (vbox);
+ return vbox;
}
diff --git a/plugins/gtk+/glade-icon-sources.h b/plugins/gtk+/glade-icon-sources.h
index b671293..5d05f59 100644
--- a/plugins/gtk+/glade-icon-sources.h
+++ b/plugins/gtk+/glade-icon-sources.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-image-editor.c b/plugins/gtk+/glade-image-editor.c
index c3f4450..6123ab1 100644
--- a/plugins/gtk+/glade-image-editor.c
+++ b/plugins/gtk+/glade-image-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,11 +27,11 @@
#include "glade-image-editor.h"
-static void glade_image_editor_finalize (GObject *object);
+static void glade_image_editor_finalize (GObject * object);
-static void glade_image_editor_editable_init (GladeEditableIface *iface);
+static void glade_image_editor_editable_init (GladeEditableIface * iface);
-static void glade_image_editor_grab_focus (GtkWidget *widget);
+static void glade_image_editor_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeImageEditor, glade_image_editor, GTK_TYPE_VBOX,
@@ -41,392 +40,415 @@ G_DEFINE_TYPE_WITH_CODE (GladeImageEditor, glade_image_editor, GTK_TYPE_VBOX,
static void
-glade_image_editor_class_init (GladeImageEditorClass *klass)
+glade_image_editor_class_init (GladeImageEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_image_editor_finalize;
- widget_class->grab_focus = glade_image_editor_grab_focus;
+ object_class->finalize = glade_image_editor_finalize;
+ widget_class->grab_focus = glade_image_editor_grab_focus;
}
static void
-glade_image_editor_init (GladeImageEditor *self)
+glade_image_editor_init (GladeImageEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeImageEditor *image_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeImageEditor * image_editor)
{
- if (image_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (image_editor)))
- return;
+ if (image_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (image_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (image_editor), image_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (image_editor),
+ image_editor->loaded_widget);
}
static void
-project_finalized (GladeImageEditor *image_editor,
- GladeProject *where_project_was)
+project_finalized (GladeImageEditor * image_editor,
+ GladeProject * where_project_was)
{
- image_editor->loaded_widget = NULL;
+ image_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (image_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (image_editor), NULL);
}
static void
-glade_image_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_image_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (editable);
- GladeImageEditMode image_mode = 0;
- GList *l;
-
- image_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (image_editor->loaded_widget)
- {
- /* watch custom-child and use-stock properties here for reloads !!! */
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (image_editor->loaded_widget->project),
- G_CALLBACK (project_changed), image_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (image_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- image_editor);
- }
-
- /* Mark our widget... */
- image_editor->loaded_widget = widget;
-
- if (image_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (image_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), image_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (image_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- image_editor);
- }
-
- /* load the embedded editable... */
- if (image_editor->embed)
- glade_editable_load (GLADE_EDITABLE (image_editor->embed), widget);
-
- for (l = image_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
- if (widget)
- {
- glade_widget_property_get (widget, "image-mode", &image_mode);
-
- switch (image_mode)
- {
- case GLADE_IMAGE_MODE_STOCK:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (image_editor->stock_radio), TRUE);
- break;
- case GLADE_IMAGE_MODE_ICON:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (image_editor->icon_radio), TRUE);
- break;
- case GLADE_IMAGE_MODE_FILENAME:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (image_editor->file_radio), TRUE);
- break;
- default:
- break;
- }
- }
- image_editor->loading = FALSE;
+ GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (editable);
+ GladeImageEditMode image_mode = 0;
+ GList *l;
+
+ image_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (image_editor->loaded_widget)
+ {
+ /* watch custom-child and use-stock properties here for reloads !!! */
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (image_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ image_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (image_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, image_editor);
+ }
+
+ /* Mark our widget... */
+ image_editor->loaded_widget = widget;
+
+ if (image_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (image_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), image_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (image_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, image_editor);
+ }
+
+ /* load the embedded editable... */
+ if (image_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (image_editor->embed), widget);
+
+ for (l = image_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+ if (widget)
+ {
+ glade_widget_property_get (widget, "image-mode", &image_mode);
+
+ switch (image_mode)
+ {
+ case GLADE_IMAGE_MODE_STOCK:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (image_editor->stock_radio), TRUE);
+ break;
+ case GLADE_IMAGE_MODE_ICON:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (image_editor->icon_radio), TRUE);
+ break;
+ case GLADE_IMAGE_MODE_FILENAME:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (image_editor->file_radio), TRUE);
+ break;
+ default:
+ break;
+ }
+ }
+ image_editor->loading = FALSE;
}
static void
-glade_image_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_image_editor_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (editable);
+ GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (image_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (image_editor->embed),
+ show_name);
}
static void
-glade_image_editor_editable_init (GladeEditableIface *iface)
+glade_image_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_image_editor_load;
- iface->set_show_name = glade_image_editor_set_show_name;
+ iface->load = glade_image_editor_load;
+ iface->set_show_name = glade_image_editor_set_show_name;
}
static void
-glade_image_editor_finalize (GObject *object)
+glade_image_editor_finalize (GObject * object)
{
- GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (object);
+ GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (object);
- if (image_editor->properties)
- g_list_free (image_editor->properties);
- image_editor->properties = NULL;
- image_editor->embed = NULL;
+ if (image_editor->properties)
+ g_list_free (image_editor->properties);
+ image_editor->properties = NULL;
+ image_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_image_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_image_editor_parent_class)->finalize (object);
}
static void
-glade_image_editor_grab_focus (GtkWidget *widget)
+glade_image_editor_grab_focus (GtkWidget * widget)
{
- GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (widget);
+ GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (widget);
- gtk_widget_grab_focus (image_editor->embed);
+ gtk_widget_grab_focus (image_editor->embed);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
static void
-set_stock_mode (GladeImageEditor *image_editor)
+set_stock_mode (GladeImageEditor * image_editor)
{
- GladeProperty *property;
- GValue value = { 0, };
-
- property = glade_widget_get_property (image_editor->loaded_widget, "icon-name");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (image_editor->loaded_widget, "pixbuf");
- glade_command_set_property (property, NULL);
-
- property = glade_widget_get_property (image_editor->loaded_widget, "stock");
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
-
- property = glade_widget_get_property (image_editor->loaded_widget, "image-mode");
- glade_command_set_property (property, GLADE_IMAGE_MODE_STOCK);
+ GladeProperty *property;
+ GValue value = { 0, };
+
+ property =
+ glade_widget_get_property (image_editor->loaded_widget, "icon-name");
+ glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (image_editor->loaded_widget, "pixbuf");
+ glade_command_set_property (property, NULL);
+
+ property = glade_widget_get_property (image_editor->loaded_widget, "stock");
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
+
+ property =
+ glade_widget_get_property (image_editor->loaded_widget, "image-mode");
+ glade_command_set_property (property, GLADE_IMAGE_MODE_STOCK);
}
static void
-set_icon_mode (GladeImageEditor *image_editor)
+set_icon_mode (GladeImageEditor * image_editor)
{
- GladeProperty *property;
-
- property = glade_widget_get_property (image_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (image_editor->loaded_widget, "pixbuf");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (image_editor->loaded_widget, "image-mode");
- glade_command_set_property (property, GLADE_IMAGE_MODE_ICON);
+ GladeProperty *property;
+
+ property = glade_widget_get_property (image_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (image_editor->loaded_widget, "pixbuf");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (image_editor->loaded_widget, "image-mode");
+ glade_command_set_property (property, GLADE_IMAGE_MODE_ICON);
}
static void
-set_file_mode (GladeImageEditor *image_editor)
+set_file_mode (GladeImageEditor * image_editor)
{
- GladeProperty *property;
-
- property = glade_widget_get_property (image_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (image_editor->loaded_widget, "icon-name");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (image_editor->loaded_widget, "image-mode");
- glade_command_set_property (property, GLADE_IMAGE_MODE_FILENAME);
+ GladeProperty *property;
+
+ property = glade_widget_get_property (image_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (image_editor->loaded_widget, "icon-name");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (image_editor->loaded_widget, "image-mode");
+ glade_command_set_property (property, GLADE_IMAGE_MODE_FILENAME);
}
static void
-stock_toggled (GtkWidget *widget,
- GladeImageEditor *image_editor)
+stock_toggled (GtkWidget * widget, GladeImageEditor * image_editor)
{
- if (image_editor->loading || !image_editor->loaded_widget)
- return;
+ if (image_editor->loading || !image_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (image_editor->stock_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (image_editor->stock_radio)))
+ return;
- image_editor->modifying = TRUE;
+ image_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an image from stock"), image_editor->loaded_widget->name);
- set_stock_mode (image_editor);
- glade_command_pop_group ();
+ glade_command_push_group (_("Setting %s to use an image from stock"),
+ image_editor->loaded_widget->name);
+ set_stock_mode (image_editor);
+ glade_command_pop_group ();
- image_editor->modifying = FALSE;
+ image_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (image_editor),
- image_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (image_editor),
+ image_editor->loaded_widget);
}
static void
-icon_toggled (GtkWidget *widget,
- GladeImageEditor *image_editor)
+icon_toggled (GtkWidget * widget, GladeImageEditor * image_editor)
{
- if (image_editor->loading || !image_editor->loaded_widget)
- return;
+ if (image_editor->loading || !image_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (image_editor->icon_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (image_editor->icon_radio)))
+ return;
- image_editor->modifying = TRUE;
+ image_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an image from the icon theme"), image_editor->loaded_widget->name);
- set_icon_mode (image_editor);
- glade_command_pop_group ();
+ glade_command_push_group (_("Setting %s to use an image from the icon theme"),
+ image_editor->loaded_widget->name);
+ set_icon_mode (image_editor);
+ glade_command_pop_group ();
- image_editor->modifying = FALSE;
+ image_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (image_editor),
- image_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (image_editor),
+ image_editor->loaded_widget);
}
static void
-file_toggled (GtkWidget *widget,
- GladeImageEditor *image_editor)
+file_toggled (GtkWidget * widget, GladeImageEditor * image_editor)
{
- if (image_editor->loading || !image_editor->loaded_widget)
- return;
+ if (image_editor->loading || !image_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (image_editor->file_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (image_editor->file_radio)))
+ return;
- image_editor->modifying = TRUE;
+ image_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an image from filename"), image_editor->loaded_widget->name);
- set_file_mode (image_editor);
- glade_command_pop_group ();
+ glade_command_push_group (_("Setting %s to use an image from filename"),
+ image_editor->loaded_widget->name);
+ set_file_mode (image_editor);
+ glade_command_pop_group ();
- image_editor->modifying = FALSE;
+ image_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (image_editor),
- image_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (image_editor),
+ image_editor->loaded_widget);
}
GtkWidget *
-glade_image_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_image_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed)
{
- GladeImageEditor *image_editor;
- GladeEditorProperty *eprop;
- GtkWidget *table, *frame, *alignment, *label, *hbox;
- gchar *str;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- image_editor = g_object_new (GLADE_TYPE_IMAGE_EDITOR, NULL);
- image_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (image_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- /* Image content frame... */
- str = g_strdup_printf ("<b>%s</b>", _("Edit Image"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (image_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Stock image... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "stock", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- image_editor->stock_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), image_editor->stock_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- image_editor->properties = g_list_prepend (image_editor->properties, eprop);
-
- /* Icon theme image... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-name", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- image_editor->icon_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (image_editor->stock_radio));
- gtk_box_pack_start (GTK_BOX (hbox), image_editor->icon_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- image_editor->properties = g_list_prepend (image_editor->properties, eprop);
-
- /* Filename... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "pixbuf", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- image_editor->file_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (image_editor->stock_radio));
- gtk_box_pack_start (GTK_BOX (hbox), image_editor->file_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 2);
- table_attach (table, GTK_WIDGET (eprop), 1, 2);
- image_editor->properties = g_list_prepend (image_editor->properties, eprop);
-
- /* Image size frame... */
- str = g_strdup_printf ("<b>%s</b>", _("Set Image Size"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (image_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Icon Size... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-size", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- image_editor->properties = g_list_prepend (image_editor->properties, eprop);
-
- /* Pixel Size... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "pixel-size", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- image_editor->properties = g_list_prepend (image_editor->properties, eprop);
-
- /* Connect radio button signals... */
- g_signal_connect (G_OBJECT (image_editor->stock_radio), "toggled",
- G_CALLBACK (stock_toggled), image_editor);
- g_signal_connect (G_OBJECT (image_editor->icon_radio), "toggled",
- G_CALLBACK (icon_toggled), image_editor);
- g_signal_connect (G_OBJECT (image_editor->file_radio), "toggled",
- G_CALLBACK (file_toggled), image_editor);
-
- gtk_widget_show_all (GTK_WIDGET (image_editor));
-
- return GTK_WIDGET (image_editor);
+ GladeImageEditor *image_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *table, *frame, *alignment, *label, *hbox;
+ gchar *str;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ image_editor = g_object_new (GLADE_TYPE_IMAGE_EDITOR, NULL);
+ image_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (image_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
+
+ /* Image content frame... */
+ str = g_strdup_printf ("<b>%s</b>", _("Edit Image"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (image_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Stock image... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "stock", FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ image_editor->stock_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), image_editor->stock_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ image_editor->properties = g_list_prepend (image_editor->properties, eprop);
+
+ /* Icon theme image... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-name", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ image_editor->icon_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (image_editor->stock_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), image_editor->icon_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ image_editor->properties = g_list_prepend (image_editor->properties, eprop);
+
+ /* Filename... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "pixbuf", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ image_editor->file_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (image_editor->stock_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), image_editor->file_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 2);
+ table_attach (table, GTK_WIDGET (eprop), 1, 2);
+ image_editor->properties = g_list_prepend (image_editor->properties, eprop);
+
+ /* Image size frame... */
+ str = g_strdup_printf ("<b>%s</b>", _("Set Image Size"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (image_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Icon Size... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-size", FALSE,
+ TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ image_editor->properties = g_list_prepend (image_editor->properties, eprop);
+
+ /* Pixel Size... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "pixel-size", FALSE,
+ TRUE);
+ table_attach (table, eprop->item_label, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ image_editor->properties = g_list_prepend (image_editor->properties, eprop);
+
+ /* Connect radio button signals... */
+ g_signal_connect (G_OBJECT (image_editor->stock_radio), "toggled",
+ G_CALLBACK (stock_toggled), image_editor);
+ g_signal_connect (G_OBJECT (image_editor->icon_radio), "toggled",
+ G_CALLBACK (icon_toggled), image_editor);
+ g_signal_connect (G_OBJECT (image_editor->file_radio), "toggled",
+ G_CALLBACK (file_toggled), image_editor);
+
+ gtk_widget_show_all (GTK_WIDGET (image_editor));
+
+ return GTK_WIDGET (image_editor);
}
diff --git a/plugins/gtk+/glade-image-editor.h b/plugins/gtk+/glade-image-editor.h
index 11b655f..e589cf2 100644
--- a/plugins/gtk+/glade-image-editor.h
+++ b/plugins/gtk+/glade-image-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-image-item-editor.c b/plugins/gtk+/glade-image-item-editor.c
index 531437f..abbdb53 100644
--- a/plugins/gtk+/glade-image-item-editor.c
+++ b/plugins/gtk+/glade-image-item-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,408 +27,428 @@
#include "glade-image-item-editor.h"
-static void glade_image_item_editor_finalize (GObject *object);
+static void glade_image_item_editor_finalize (GObject * object);
-static void glade_image_item_editor_editable_init (GladeEditableIface *iface);
+static void glade_image_item_editor_editable_init (GladeEditableIface * iface);
-static void glade_image_item_editor_grab_focus (GtkWidget *widget);
+static void glade_image_item_editor_grab_focus (GtkWidget * widget);
-G_DEFINE_TYPE_WITH_CODE (GladeImageItemEditor, glade_image_item_editor, GTK_TYPE_VBOX,
+G_DEFINE_TYPE_WITH_CODE (GladeImageItemEditor, glade_image_item_editor,
+ GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_image_item_editor_editable_init));
static void
-glade_image_item_editor_class_init (GladeImageItemEditorClass *klass)
+glade_image_item_editor_class_init (GladeImageItemEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_image_item_editor_finalize;
- widget_class->grab_focus = glade_image_item_editor_grab_focus;
+ object_class->finalize = glade_image_item_editor_finalize;
+ widget_class->grab_focus = glade_image_item_editor_grab_focus;
}
static void
-glade_image_item_editor_init (GladeImageItemEditor *self)
+glade_image_item_editor_init (GladeImageItemEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeImageItemEditor *item_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeImageItemEditor * item_editor)
{
- if (item_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (item_editor)))
- return;
+ if (item_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (item_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (item_editor), item_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (item_editor),
+ item_editor->loaded_widget);
}
static void
-project_finalized (GladeImageItemEditor *item_editor,
- GladeProject *where_project_was)
+project_finalized (GladeImageItemEditor * item_editor,
+ GladeProject * where_project_was)
{
- item_editor->loaded_widget = NULL;
+ item_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (item_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (item_editor), NULL);
}
static GladeWidget *
-get_image_widget (GladeWidget *widget)
+get_image_widget (GladeWidget * widget)
{
- GtkWidget *image;
- image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget->object));
- return image ? glade_widget_get_from_gobject (image) : NULL;
+ GtkWidget *image;
+ image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget->object));
+ return image ? glade_widget_get_from_gobject (image) : NULL;
}
static void
-glade_image_item_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_image_item_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (editable);
- GladeWidget *image_widget;
- GList *l;
- gboolean use_stock = FALSE;
-
- item_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (item_editor->loaded_widget)
- {
- g_signal_handlers_disconnect_by_func (G_OBJECT (item_editor->loaded_widget->project),
- G_CALLBACK (project_changed), item_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (item_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- item_editor);
- }
-
- /* Mark our widget... */
- item_editor->loaded_widget = widget;
-
- if (item_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (item_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), item_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (item_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- item_editor);
- }
-
- /* load the embedded editable... */
- if (item_editor->embed)
- glade_editable_load (GLADE_EDITABLE (item_editor->embed), widget);
-
- if (item_editor->embed_image)
- {
- /* Finalize safe code here... */
- if (widget && (image_widget = get_image_widget (widget)))
- glade_editable_load (GLADE_EDITABLE (item_editor->embed_image), image_widget);
- else
- glade_editable_load (GLADE_EDITABLE (item_editor->embed_image), NULL);
- }
- for (l = item_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
- if (widget)
- {
- glade_widget_property_get (widget, "use-stock", &use_stock);
-
- gtk_widget_set_sensitive (item_editor->embed_frame, !use_stock);
- gtk_widget_set_sensitive (item_editor->label_frame, !use_stock);
-
- if (use_stock)
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (item_editor->stock_radio), TRUE);
- else
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (item_editor->custom_radio), TRUE);
- }
- item_editor->loading = FALSE;
+ GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (editable);
+ GladeWidget *image_widget;
+ GList *l;
+ gboolean use_stock = FALSE;
+
+ item_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (item_editor->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (item_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ item_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (item_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, item_editor);
+ }
+
+ /* Mark our widget... */
+ item_editor->loaded_widget = widget;
+
+ if (item_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (item_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), item_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (item_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, item_editor);
+ }
+
+ /* load the embedded editable... */
+ if (item_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (item_editor->embed), widget);
+
+ if (item_editor->embed_image)
+ {
+ /* Finalize safe code here... */
+ if (widget && (image_widget = get_image_widget (widget)))
+ glade_editable_load (GLADE_EDITABLE (item_editor->embed_image),
+ image_widget);
+ else
+ glade_editable_load (GLADE_EDITABLE (item_editor->embed_image), NULL);
+ }
+ for (l = item_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+ if (widget)
+ {
+ glade_widget_property_get (widget, "use-stock", &use_stock);
+
+ gtk_widget_set_sensitive (item_editor->embed_frame, !use_stock);
+ gtk_widget_set_sensitive (item_editor->label_frame, !use_stock);
+
+ if (use_stock)
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (item_editor->stock_radio), TRUE);
+ else
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (item_editor->custom_radio), TRUE);
+ }
+ item_editor->loading = FALSE;
}
static void
-glade_image_item_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_image_item_editor_set_show_name (GladeEditable * editable,
+ gboolean show_name)
{
- GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (editable);
+ GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (item_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (item_editor->embed), show_name);
}
static void
-glade_image_item_editor_editable_init (GladeEditableIface *iface)
+glade_image_item_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_image_item_editor_load;
- iface->set_show_name = glade_image_item_editor_set_show_name;
+ iface->load = glade_image_item_editor_load;
+ iface->set_show_name = glade_image_item_editor_set_show_name;
}
static void
-glade_image_item_editor_finalize (GObject *object)
+glade_image_item_editor_finalize (GObject * object)
{
- GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (object);
+ GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (object);
- if (item_editor->properties)
- g_list_free (item_editor->properties);
- item_editor->properties = NULL;
- item_editor->embed_image = NULL;
- item_editor->embed = NULL;
+ if (item_editor->properties)
+ g_list_free (item_editor->properties);
+ item_editor->properties = NULL;
+ item_editor->embed_image = NULL;
+ item_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_image_item_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_image_item_editor_parent_class)->finalize (object);
}
static void
-glade_image_item_editor_grab_focus (GtkWidget *widget)
+glade_image_item_editor_grab_focus (GtkWidget * widget)
{
- GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (widget);
+ GladeImageItemEditor *item_editor = GLADE_IMAGE_ITEM_EDITOR (widget);
- gtk_widget_grab_focus (item_editor->embed);
+ gtk_widget_grab_focus (item_editor->embed);
}
static void
-stock_toggled (GtkWidget *widget,
- GladeImageItemEditor *item_editor)
+stock_toggled (GtkWidget * widget, GladeImageItemEditor * item_editor)
{
- GladeProperty *property;
- GladeWidget *image, *loaded;
+ GladeProperty *property;
+ GladeWidget *image, *loaded;
- if (item_editor->loading || !item_editor->loaded_widget)
- return;
+ if (item_editor->loading || !item_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (item_editor->stock_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (item_editor->stock_radio)))
+ return;
- item_editor->modifying = TRUE;
- loaded = item_editor->loaded_widget;
+ item_editor->modifying = TRUE;
+ loaded = item_editor->loaded_widget;
- glade_command_push_group (_("Setting %s to use a stock item"), loaded->name);
+ glade_command_push_group (_("Setting %s to use a stock item"), loaded->name);
- property = glade_widget_get_property (loaded, "label");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (loaded, "use-underline");
- glade_command_set_property (property, FALSE);
+ property = glade_widget_get_property (loaded, "label");
+ glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (loaded, "use-underline");
+ glade_command_set_property (property, FALSE);
- /* Delete image... */
- if ((image = get_image_widget (loaded)) != NULL)
- {
- GList list = { 0, };
- list.data = image;
- glade_command_unlock_widget (image);
- glade_command_delete (&list);
- glade_project_selection_set (loaded->project, loaded->object, TRUE);
- }
+ /* Delete image... */
+ if ((image = get_image_widget (loaded)) != NULL)
+ {
+ GList list = { 0, };
+ list.data = image;
+ glade_command_unlock_widget (image);
+ glade_command_delete (&list);
+ glade_project_selection_set (loaded->project, loaded->object, TRUE);
+ }
- property = glade_widget_get_property (loaded, "use-stock");
- glade_command_set_property (property, TRUE);
+ property = glade_widget_get_property (loaded, "use-stock");
+ glade_command_set_property (property, TRUE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- item_editor->modifying = FALSE;
+ item_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (item_editor), item_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (item_editor),
+ item_editor->loaded_widget);
}
static void
-custom_toggled (GtkWidget *widget,
- GladeImageItemEditor *item_editor)
+custom_toggled (GtkWidget * widget, GladeImageItemEditor * item_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (item_editor->loading || !item_editor->loaded_widget)
- return;
+ if (item_editor->loading || !item_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (item_editor->custom_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (item_editor->custom_radio)))
+ return;
- item_editor->modifying = TRUE;
+ item_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a label and image"), item_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a label and image"),
+ item_editor->loaded_widget->name);
- /* First clear stock... */
- property = glade_widget_get_property (item_editor->loaded_widget, "stock");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (item_editor->loaded_widget, "use-stock");
- glade_command_set_property (property, FALSE);
+ /* First clear stock... */
+ property = glade_widget_get_property (item_editor->loaded_widget, "stock");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (item_editor->loaded_widget, "use-stock");
+ glade_command_set_property (property, FALSE);
- /* Now setup default label and create image... */
- property = glade_widget_get_property (item_editor->loaded_widget, "label");
- glade_command_set_property (property, item_editor->loaded_widget->adaptor->generic_name);
- property = glade_widget_get_property (item_editor->loaded_widget, "use-underline");
- glade_command_set_property (property, FALSE);
+ /* Now setup default label and create image... */
+ property = glade_widget_get_property (item_editor->loaded_widget, "label");
+ glade_command_set_property (property,
+ item_editor->loaded_widget->adaptor->
+ generic_name);
+ property =
+ glade_widget_get_property (item_editor->loaded_widget, "use-underline");
+ glade_command_set_property (property, FALSE);
- /* There shouldnt be an image widget here... */
- if (!get_image_widget (item_editor->loaded_widget))
- {
- /* item_editor->loaded_widget may be set to NULL after the create_command. */
- GladeWidget *loaded = item_editor->loaded_widget;
- GladeWidget *image;
+ /* There shouldnt be an image widget here... */
+ if (!get_image_widget (item_editor->loaded_widget))
+ {
+ /* item_editor->loaded_widget may be set to NULL after the create_command. */
+ GladeWidget *loaded = item_editor->loaded_widget;
+ GladeWidget *image;
- property = glade_widget_get_property (loaded, "image");
+ property = glade_widget_get_property (loaded, "image");
- image = glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE),
- NULL, NULL, glade_widget_get_project (loaded));
+ image =
+ glade_command_create (glade_widget_adaptor_get_by_type
+ (GTK_TYPE_IMAGE), NULL, NULL,
+ glade_widget_get_project (loaded));
- glade_command_set_property (property, image->object);
+ glade_command_set_property (property, image->object);
- /* Make sure nobody deletes this... */
- glade_command_lock_widget (loaded, image);
+ /* Make sure nobody deletes this... */
+ glade_command_lock_widget (loaded, image);
- /* reload widget by selection ;-) */
- glade_project_selection_set (loaded->project, loaded->object, TRUE);
- }
- glade_command_pop_group ();
+ /* reload widget by selection ;-) */
+ glade_project_selection_set (loaded->project, loaded->object, TRUE);
+ }
+ glade_command_pop_group ();
- item_editor->modifying = FALSE;
+ item_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (item_editor),
- item_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (item_editor),
+ item_editor->loaded_widget);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
GtkWidget *
-glade_image_item_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_image_item_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditable * embed)
{
- GladeImageItemEditor *item_editor;
- GladeEditorProperty *eprop;
- GtkWidget *label, *alignment, *frame, *main_table, *table, *vbox;
- gchar *str;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- item_editor = g_object_new (GLADE_TYPE_IMAGE_ITEM_EDITOR, NULL);
- item_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (item_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- /* Put a radio button to control use-stock here on top... */
- main_table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (main_table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (main_table), 4);
- gtk_box_pack_start (GTK_BOX (item_editor), main_table, FALSE, FALSE, 8);
-
- item_editor->stock_radio = gtk_radio_button_new_with_label (NULL, _("Stock Item:"));
- table_attach (main_table, item_editor->stock_radio, 0, 0);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_grid_attach (GTK_GRID (main_table), alignment, 0, 1, 2, 1);
- gtk_widget_set_hexpand (alignment, TRUE);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* The stock item */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "stock", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- item_editor->properties = g_list_prepend (item_editor->properties, eprop);
-
- /* An accel group for the item's accelerator */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "accel-group", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- item_editor->properties = g_list_prepend (item_editor->properties, eprop);
-
- /* Now put a radio button in the same table for the custom image editing */
- item_editor->custom_radio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (item_editor->stock_radio),
- _("Custom label and image:"));
- table_attach (main_table, item_editor->custom_radio, 0, 2);
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_grid_attach (GTK_GRID (main_table), vbox, 0, 3, 2, 1);
- gtk_widget_set_hexpand (vbox, TRUE);
-
- /* Label area frame... */
- str = g_strdup_printf ("<b>%s</b>", _("Edit Label"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 12);
- item_editor->label_frame = frame;
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* The menu label... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- item_editor->properties = g_list_prepend (item_editor->properties, eprop);
-
- /* Whether to use-underline... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "use-underline", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- item_editor->properties = g_list_prepend (item_editor->properties, eprop);
-
- /* Internal Image area... */
- str = g_strdup_printf ("<b>%s</b>", _("Edit Image"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 12);
- item_editor->embed_frame = frame;
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- item_editor->embed_image = (GtkWidget *)glade_widget_adaptor_create_editable
- (glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE), GLADE_PAGE_GENERAL);
- glade_editable_set_show_name (GLADE_EDITABLE (item_editor->embed_image), FALSE);
- gtk_container_add (GTK_CONTAINER (alignment), item_editor->embed_image);
-
- /* Now hook up to our signals... */
- g_signal_connect (G_OBJECT (item_editor->stock_radio), "toggled",
- G_CALLBACK (stock_toggled), item_editor);
- g_signal_connect (G_OBJECT (item_editor->custom_radio), "toggled",
- G_CALLBACK (custom_toggled), item_editor);
-
-
- gtk_widget_show_all (GTK_WIDGET (item_editor));
-
- return GTK_WIDGET (item_editor);
+ GladeImageItemEditor *item_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *label, *alignment, *frame, *main_table, *table, *vbox;
+ gchar *str;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ item_editor = g_object_new (GLADE_TYPE_IMAGE_ITEM_EDITOR, NULL);
+ item_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (item_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
+
+ /* Put a radio button to control use-stock here on top... */
+ main_table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (main_table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (main_table), 4);
+ gtk_box_pack_start (GTK_BOX (item_editor), main_table, FALSE, FALSE, 8);
+
+ item_editor->stock_radio =
+ gtk_radio_button_new_with_label (NULL, _("Stock Item:"));
+ table_attach (main_table, item_editor->stock_radio, 0, 0);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_grid_attach (GTK_GRID (main_table), alignment, 0, 1, 2, 1);
+ gtk_widget_set_hexpand (alignment, TRUE);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* The stock item */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "stock", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ item_editor->properties = g_list_prepend (item_editor->properties, eprop);
+
+ /* An accel group for the item's accelerator */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "accel-group", FALSE,
+ TRUE);
+ table_attach (table, eprop->item_label, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ item_editor->properties = g_list_prepend (item_editor->properties, eprop);
+
+ /* Now put a radio button in the same table for the custom image editing */
+ item_editor->custom_radio = gtk_radio_button_new_with_label_from_widget
+ (GTK_RADIO_BUTTON (item_editor->stock_radio),
+ _("Custom label and image:"));
+ table_attach (main_table, item_editor->custom_radio, 0, 2);
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_grid_attach (GTK_GRID (main_table), vbox, 0, 3, 2, 1);
+ gtk_widget_set_hexpand (vbox, TRUE);
+
+ /* Label area frame... */
+ str = g_strdup_printf ("<b>%s</b>", _("Edit Label"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 12);
+ item_editor->label_frame = frame;
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* The menu label... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ item_editor->properties = g_list_prepend (item_editor->properties, eprop);
+
+ /* Whether to use-underline... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "use-underline",
+ FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ item_editor->properties = g_list_prepend (item_editor->properties, eprop);
+
+ /* Internal Image area... */
+ str = g_strdup_printf ("<b>%s</b>", _("Edit Image"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 12);
+ item_editor->embed_frame = frame;
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ item_editor->embed_image = (GtkWidget *) glade_widget_adaptor_create_editable
+ (glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE), GLADE_PAGE_GENERAL);
+ glade_editable_set_show_name (GLADE_EDITABLE (item_editor->embed_image),
+ FALSE);
+ gtk_container_add (GTK_CONTAINER (alignment), item_editor->embed_image);
+
+ /* Now hook up to our signals... */
+ g_signal_connect (G_OBJECT (item_editor->stock_radio), "toggled",
+ G_CALLBACK (stock_toggled), item_editor);
+ g_signal_connect (G_OBJECT (item_editor->custom_radio), "toggled",
+ G_CALLBACK (custom_toggled), item_editor);
+
+
+ gtk_widget_show_all (GTK_WIDGET (item_editor));
+
+ return GTK_WIDGET (item_editor);
}
diff --git a/plugins/gtk+/glade-image-item-editor.h b/plugins/gtk+/glade-image-item-editor.h
index 9ec84fe..bcef41d 100644
--- a/plugins/gtk+/glade-image-item-editor.h
+++ b/plugins/gtk+/glade-image-item-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-label-editor.c b/plugins/gtk+/glade-label-editor.c
index 0fb9f12..56f0554 100644
--- a/plugins/gtk+/glade-label-editor.c
+++ b/plugins/gtk+/glade-label-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,11 +27,11 @@
#include "glade-label-editor.h"
-static void glade_label_editor_finalize (GObject *object);
+static void glade_label_editor_finalize (GObject * object);
-static void glade_label_editor_editable_init (GladeEditableIface *iface);
+static void glade_label_editor_editable_init (GladeEditableIface * iface);
-static void glade_label_editor_grab_focus (GtkWidget *widget);
+static void glade_label_editor_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeLabelEditor, glade_label_editor, GTK_TYPE_VBOX,
@@ -41,189 +40,203 @@ G_DEFINE_TYPE_WITH_CODE (GladeLabelEditor, glade_label_editor, GTK_TYPE_VBOX,
static void
-glade_label_editor_class_init (GladeLabelEditorClass *klass)
+glade_label_editor_class_init (GladeLabelEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_label_editor_finalize;
- widget_class->grab_focus = glade_label_editor_grab_focus;
+ object_class->finalize = glade_label_editor_finalize;
+ widget_class->grab_focus = glade_label_editor_grab_focus;
}
static void
-glade_label_editor_init (GladeLabelEditor *self)
+glade_label_editor_init (GladeLabelEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeLabelEditor *label_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeLabelEditor * label_editor)
{
- if (label_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (label_editor)))
- return;
+ if (label_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (label_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (label_editor), label_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-project_finalized (GladeLabelEditor *label_editor,
- GladeProject *where_project_was)
+project_finalized (GladeLabelEditor * label_editor,
+ GladeProject * where_project_was)
{
- label_editor->loaded_widget = NULL;
+ label_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (label_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (label_editor), NULL);
}
static void
-glade_label_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_label_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (editable);
- GList *l;
-
- label_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (label_editor->loaded_widget)
- {
- /* watch custom-child and use-stock properties here for reloads !!! */
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (label_editor->loaded_widget->project),
- G_CALLBACK (project_changed), label_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (label_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- label_editor);
- }
-
- /* Mark our widget... */
- label_editor->loaded_widget = widget;
-
- if (label_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (label_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), label_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (label_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- label_editor);
- }
-
- /* load the embedded editable... */
- if (label_editor->embed)
- glade_editable_load (GLADE_EDITABLE (label_editor->embed), widget);
-
- for (l = label_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
- if (widget)
- {
- GladeLabelContentMode content_mode;
- GladeLabelWrapMode wrap_mode;
- static PangoAttrList *bold_attr_list = NULL;
- gboolean use_max_width;
-
- if (!bold_attr_list)
- {
- PangoAttribute *attr;
- bold_attr_list = pango_attr_list_new ();
- attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
- pango_attr_list_insert (bold_attr_list, attr);
- }
-
- glade_widget_property_get (widget, "label-content-mode", &content_mode);
- glade_widget_property_get (widget, "label-wrap-mode", &wrap_mode);
- glade_widget_property_get (widget, "use-max-width", &use_max_width);
-
- switch (content_mode)
- {
- case GLADE_LABEL_MODE_ATTRIBUTES:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->attributes_radio), TRUE);
- break;
- case GLADE_LABEL_MODE_MARKUP:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->markup_radio), TRUE);
- break;
- case GLADE_LABEL_MODE_PATTERN:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->pattern_radio), TRUE);
- break;
- default:
- break;
- }
-
- if (wrap_mode == GLADE_LABEL_WRAP_FREE)
- gtk_label_set_attributes (GTK_LABEL (label_editor->wrap_free_label), bold_attr_list);
- else
- gtk_label_set_attributes (GTK_LABEL (label_editor->wrap_free_label), NULL);
-
- switch (wrap_mode)
- {
- case GLADE_LABEL_WRAP_FREE:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->wrap_free_radio), TRUE);
- break;
- case GLADE_LABEL_SINGLE_LINE:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->single_radio), TRUE);
- break;
- case GLADE_LABEL_WRAP_MODE:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->wrap_mode_radio), TRUE);
- break;
- default:
- break;
- }
-
- if (use_max_width)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->max_width_radio), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (label_editor->width_radio), TRUE);
-
- }
- label_editor->loading = FALSE;
+ GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (editable);
+ GList *l;
+
+ label_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (label_editor->loaded_widget)
+ {
+ /* watch custom-child and use-stock properties here for reloads !!! */
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (label_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ label_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (label_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, label_editor);
+ }
+
+ /* Mark our widget... */
+ label_editor->loaded_widget = widget;
+
+ if (label_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (label_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), label_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (label_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, label_editor);
+ }
+
+ /* load the embedded editable... */
+ if (label_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (label_editor->embed), widget);
+
+ for (l = label_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+ if (widget)
+ {
+ GladeLabelContentMode content_mode;
+ GladeLabelWrapMode wrap_mode;
+ static PangoAttrList *bold_attr_list = NULL;
+ gboolean use_max_width;
+
+ if (!bold_attr_list)
+ {
+ PangoAttribute *attr;
+ bold_attr_list = pango_attr_list_new ();
+ attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert (bold_attr_list, attr);
+ }
+
+ glade_widget_property_get (widget, "label-content-mode", &content_mode);
+ glade_widget_property_get (widget, "label-wrap-mode", &wrap_mode);
+ glade_widget_property_get (widget, "use-max-width", &use_max_width);
+
+ switch (content_mode)
+ {
+ case GLADE_LABEL_MODE_ATTRIBUTES:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->attributes_radio),
+ TRUE);
+ break;
+ case GLADE_LABEL_MODE_MARKUP:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->markup_radio), TRUE);
+ break;
+ case GLADE_LABEL_MODE_PATTERN:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->pattern_radio), TRUE);
+ break;
+ default:
+ break;
+ }
+
+ if (wrap_mode == GLADE_LABEL_WRAP_FREE)
+ gtk_label_set_attributes (GTK_LABEL (label_editor->wrap_free_label),
+ bold_attr_list);
+ else
+ gtk_label_set_attributes (GTK_LABEL (label_editor->wrap_free_label),
+ NULL);
+
+ switch (wrap_mode)
+ {
+ case GLADE_LABEL_WRAP_FREE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->wrap_free_radio),
+ TRUE);
+ break;
+ case GLADE_LABEL_SINGLE_LINE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->single_radio), TRUE);
+ break;
+ case GLADE_LABEL_WRAP_MODE:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->wrap_mode_radio),
+ TRUE);
+ break;
+ default:
+ break;
+ }
+
+ if (use_max_width)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->max_width_radio), TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (label_editor->width_radio), TRUE);
+
+ }
+ label_editor->loading = FALSE;
}
static void
-glade_label_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_label_editor_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (editable);
+ GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (label_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (label_editor->embed),
+ show_name);
}
static void
-glade_label_editor_editable_init (GladeEditableIface *iface)
+glade_label_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_label_editor_load;
- iface->set_show_name = glade_label_editor_set_show_name;
+ iface->load = glade_label_editor_load;
+ iface->set_show_name = glade_label_editor_set_show_name;
}
static void
-glade_label_editor_finalize (GObject *object)
+glade_label_editor_finalize (GObject * object)
{
- GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (object);
+ GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (object);
- if (label_editor->properties)
- g_list_free (label_editor->properties);
- label_editor->properties = NULL;
- label_editor->embed = NULL;
+ if (label_editor->properties)
+ g_list_free (label_editor->properties);
+ label_editor->properties = NULL;
+ label_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_label_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_label_editor_parent_class)->finalize (object);
}
static void
-glade_label_editor_grab_focus (GtkWidget *widget)
+glade_label_editor_grab_focus (GtkWidget * widget)
{
- GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (widget);
+ GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (widget);
- gtk_widget_grab_focus (label_editor->embed);
+ gtk_widget_grab_focus (label_editor->embed);
}
@@ -231,102 +244,118 @@ glade_label_editor_grab_focus (GtkWidget *widget)
label-content-mode radios
**********************************************************************/
static void
-attributes_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+attributes_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->attributes_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->attributes_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an attribute list"), label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use an attribute list"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "use-markup");
- glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (label_editor->loaded_widget, "pattern");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (label_editor->loaded_widget, "label-content-mode");
- glade_command_set_property (property, GLADE_LABEL_MODE_ATTRIBUTES);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "use-markup");
+ glade_command_set_property (property, FALSE);
+ property = glade_widget_get_property (label_editor->loaded_widget, "pattern");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "label-content-mode");
+ glade_command_set_property (property, GLADE_LABEL_MODE_ATTRIBUTES);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-markup_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+markup_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->markup_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->markup_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a Pango markup string"), label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a Pango markup string"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "pattern");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (label_editor->loaded_widget, "glade-attributes");
- glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (label_editor->loaded_widget, "pattern");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "glade-attributes");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (label_editor->loaded_widget, "use-markup");
- glade_command_set_property (property, TRUE);
- property = glade_widget_get_property (label_editor->loaded_widget, "label-content-mode");
- glade_command_set_property (property, GLADE_LABEL_MODE_MARKUP);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "use-markup");
+ glade_command_set_property (property, TRUE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "label-content-mode");
+ glade_command_set_property (property, GLADE_LABEL_MODE_MARKUP);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-pattern_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+pattern_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->pattern_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->pattern_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a pattern string"), label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a pattern string"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "glade-attributes");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (label_editor->loaded_widget, "use-markup");
- glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (label_editor->loaded_widget, "label-content-mode");
- glade_command_set_property (property, GLADE_LABEL_MODE_PATTERN);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "glade-attributes");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "use-markup");
+ glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "label-content-mode");
+ glade_command_set_property (property, GLADE_LABEL_MODE_PATTERN);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
/**********************************************************************
@@ -334,429 +363,483 @@ pattern_toggled (GtkWidget *widget,
**********************************************************************/
static void
-width_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+width_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->width_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->width_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to set desired width in characters"),
- label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to set desired width in characters"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "max-width-chars");
- glade_command_set_property (property, -1);
- property = glade_widget_get_property (label_editor->loaded_widget, "use-max-width");
- glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "max-width-chars");
+ glade_command_set_property (property, -1);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "use-max-width");
+ glade_command_set_property (property, FALSE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-max_width_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+max_width_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->max_width_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->max_width_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to set maximum width in characters"),
- label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to set maximum width in characters"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "width-chars");
- glade_command_set_property (property, -1);
- property = glade_widget_get_property (label_editor->loaded_widget, "use-max-width");
- glade_command_set_property (property, TRUE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "width-chars");
+ glade_command_set_property (property, -1);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "use-max-width");
+ glade_command_set_property (property, TRUE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
/**********************************************************************
label-wrap-mode radios
**********************************************************************/
static void
-wrap_free_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+wrap_free_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->wrap_free_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->wrap_free_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use normal line wrapping"), label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use normal line wrapping"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "single-line-mode");
- glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (label_editor->loaded_widget, "wrap-mode");
- glade_command_set_property (property, PANGO_WRAP_WORD);
- property = glade_widget_get_property (label_editor->loaded_widget, "wrap");
- glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "single-line-mode");
+ glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "wrap-mode");
+ glade_command_set_property (property, PANGO_WRAP_WORD);
+ property = glade_widget_get_property (label_editor->loaded_widget, "wrap");
+ glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (label_editor->loaded_widget, "label-wrap-mode");
- glade_command_set_property (property, GLADE_LABEL_WRAP_FREE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "label-wrap-mode");
+ glade_command_set_property (property, GLADE_LABEL_WRAP_FREE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-single_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+single_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->single_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->single_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a single line"), label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a single line"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "wrap-mode");
- glade_command_set_property (property, PANGO_WRAP_WORD);
- property = glade_widget_get_property (label_editor->loaded_widget, "wrap");
- glade_command_set_property (property, FALSE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget, "wrap-mode");
+ glade_command_set_property (property, PANGO_WRAP_WORD);
+ property = glade_widget_get_property (label_editor->loaded_widget, "wrap");
+ glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (label_editor->loaded_widget, "single-line-mode");
- glade_command_set_property (property, TRUE);
- property = glade_widget_get_property (label_editor->loaded_widget, "label-wrap-mode");
- glade_command_set_property (property, GLADE_LABEL_SINGLE_LINE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "single-line-mode");
+ glade_command_set_property (property, TRUE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "label-wrap-mode");
+ glade_command_set_property (property, GLADE_LABEL_SINGLE_LINE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-wrap_mode_toggled (GtkWidget *widget,
- GladeLabelEditor *label_editor)
+wrap_mode_toggled (GtkWidget * widget, GladeLabelEditor * label_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (label_editor->loading || !label_editor->loaded_widget)
- return;
+ if (label_editor->loading || !label_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (label_editor->wrap_mode_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (label_editor->wrap_mode_radio)))
+ return;
- label_editor->modifying = TRUE;
+ label_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use specific Pango word wrapping"),
- label_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use specific Pango word wrapping"),
+ label_editor->loaded_widget->name);
- property = glade_widget_get_property (label_editor->loaded_widget, "single-line-mode");
- glade_command_set_property (property, FALSE);
- property = glade_widget_get_property (label_editor->loaded_widget, "wrap");
- glade_command_set_property (property, TRUE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "single-line-mode");
+ glade_command_set_property (property, FALSE);
+ property = glade_widget_get_property (label_editor->loaded_widget, "wrap");
+ glade_command_set_property (property, TRUE);
- property = glade_widget_get_property (label_editor->loaded_widget, "label-wrap-mode");
- glade_command_set_property (property, GLADE_LABEL_WRAP_MODE);
+ property =
+ glade_widget_get_property (label_editor->loaded_widget,
+ "label-wrap-mode");
+ glade_command_set_property (property, GLADE_LABEL_WRAP_MODE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- label_editor->modifying = FALSE;
+ label_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (label_editor),
- label_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (label_editor),
+ label_editor->loaded_widget);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
static void
-append_label_appearance (GladeLabelEditor *label_editor,
- GladeWidgetAdaptor *adaptor)
+append_label_appearance (GladeLabelEditor * label_editor,
+ GladeWidgetAdaptor * adaptor)
{
- GladeEditorProperty *eprop, *markup_property;
- GtkWidget *table, *frame, *alignment, *label, *hbox;
- gchar *str;
-
- /* Label appearance... */
- str = g_strdup_printf ("<b>%s</b>", _("Edit label appearance"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (label_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Edit the label itself... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* Edit by attributes... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "glade-attributes", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->attributes_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->attributes_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* Edit with label as pango markup strings... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "use-markup", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->markup_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (label_editor->attributes_radio));
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->markup_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 2);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
- markup_property = eprop; /* Its getting into a hidden row on the bottom... */
-
- /* Add underscores from pattern string... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "pattern", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->pattern_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (label_editor->attributes_radio));
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->pattern_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 3);
- table_attach (table, GTK_WIDGET (eprop), 1, 3);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* Tie the invisible editor property to the table's life-cycle */
- g_object_set_data_full (G_OBJECT (table), "glade-markup-property-destroy-me",
- markup_property, (GDestroyNotify)gtk_widget_destroy);
+ GladeEditorProperty *eprop, *markup_property;
+ GtkWidget *table, *frame, *alignment, *label, *hbox;
+ gchar *str;
+
+ /* Label appearance... */
+ str = g_strdup_printf ("<b>%s</b>", _("Edit label appearance"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (label_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Edit the label itself... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* Edit by attributes... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "glade-attributes",
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->attributes_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->attributes_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* Edit with label as pango markup strings... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "use-markup", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->markup_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (label_editor->attributes_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->markup_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 2);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+ markup_property = eprop; /* Its getting into a hidden row on the bottom... */
+
+ /* Add underscores from pattern string... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "pattern", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->pattern_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (label_editor->attributes_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->pattern_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 3);
+ table_attach (table, GTK_WIDGET (eprop), 1, 3);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* Tie the invisible editor property to the table's life-cycle */
+ g_object_set_data_full (G_OBJECT (table), "glade-markup-property-destroy-me",
+ markup_property, (GDestroyNotify) gtk_widget_destroy);
}
static void
-append_label_formatting (GladeLabelEditor *label_editor,
- GladeWidgetAdaptor *adaptor)
+append_label_formatting (GladeLabelEditor * label_editor,
+ GladeWidgetAdaptor * adaptor)
{
- GladeEditorProperty *eprop;
- GtkWidget *table, *frame, *alignment, *label, *hbox;
- gchar *str;
- gint row = 0;
-
- /* Label formatting... */
- str = g_strdup_printf ("<b>%s</b>", _("Format label"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (label_editor), frame, FALSE, FALSE, 0);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* ellipsize... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "ellipsize", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* justify... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "justify", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* angle... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "angle", FALSE, TRUE);
- table_attach (table, eprop->item_label, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* width-chars ... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "width-chars", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->width_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->width_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* max-width-chars ... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "max-width-chars", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->max_width_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (label_editor->width_radio));
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->max_width_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+ GladeEditorProperty *eprop;
+ GtkWidget *table, *frame, *alignment, *label, *hbox;
+ gchar *str;
+ gint row = 0;
+
+ /* Label formatting... */
+ str = g_strdup_printf ("<b>%s</b>", _("Format label"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (label_editor), frame, FALSE, FALSE, 0);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* ellipsize... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "ellipsize", FALSE,
+ TRUE);
+ table_attach (table, eprop->item_label, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* justify... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "justify", FALSE,
+ TRUE);
+ table_attach (table, eprop->item_label, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* angle... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "angle", FALSE, TRUE);
+ table_attach (table, eprop->item_label, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* width-chars ... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "width-chars", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->width_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->width_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* max-width-chars ... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "max-width-chars",
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->max_width_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (label_editor->width_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->max_width_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
}
static void
-append_label_wrapping (GladeLabelEditor *label_editor,
- GladeWidgetAdaptor *adaptor)
+append_label_wrapping (GladeLabelEditor * label_editor,
+ GladeWidgetAdaptor * adaptor)
{
- GladeEditorProperty *eprop, *single_line_eprop;
- GtkWidget *table, *frame, *alignment, *label, *hbox;
- gchar *str;
- gint row = 0;
-
- /* Line Wrapping... */
- str = g_strdup_printf ("<b>%s</b>", _("Text line wrapping"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (label_editor), frame, FALSE, FALSE, 0);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Append defaut epropless radio... */
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->wrap_free_radio = gtk_radio_button_new (NULL);
- label_editor->wrap_free_label = gtk_label_new (_("Text wraps normally"));
- gtk_misc_set_alignment (GTK_MISC (label_editor->wrap_free_label), 0.0F, 0.5F);
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->wrap_free_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->wrap_free_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, row++);
-
- /* single-line-mode ... */
- single_line_eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "single-line-mode", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->single_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (label_editor->wrap_free_radio));
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->single_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), single_line_eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, single_line_eprop);
-
- /* wrap-mode ... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "wrap-mode", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- label_editor->wrap_mode_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (label_editor->wrap_free_radio));
- gtk_box_pack_start (GTK_BOX (hbox), label_editor->wrap_mode_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, row);
- table_attach (table, GTK_WIDGET (eprop), 1, row++);
- label_editor->properties = g_list_prepend (label_editor->properties, eprop);
-
- /* Tie the invisible editor property to the table's life-cycle */
- g_object_set_data_full (G_OBJECT (table), "glade-single-line-property-destroy-me",
- single_line_eprop, (GDestroyNotify)gtk_widget_destroy);
+ GladeEditorProperty *eprop, *single_line_eprop;
+ GtkWidget *table, *frame, *alignment, *label, *hbox;
+ gchar *str;
+ gint row = 0;
+
+ /* Line Wrapping... */
+ str = g_strdup_printf ("<b>%s</b>", _("Text line wrapping"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (label_editor), frame, FALSE, FALSE, 0);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Append defaut epropless radio... */
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->wrap_free_radio = gtk_radio_button_new (NULL);
+ label_editor->wrap_free_label = gtk_label_new (_("Text wraps normally"));
+ gtk_misc_set_alignment (GTK_MISC (label_editor->wrap_free_label), 0.0F, 0.5F);
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->wrap_free_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->wrap_free_label, TRUE, TRUE,
+ 2);
+ table_attach (table, hbox, 0, row++);
+
+ /* single-line-mode ... */
+ single_line_eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "single-line-mode",
+ FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->single_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (label_editor->wrap_free_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->single_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), single_line_eprop->item_label, TRUE, TRUE,
+ 2);
+ table_attach (table, hbox, 0, row++);
+ label_editor->properties =
+ g_list_prepend (label_editor->properties, single_line_eprop);
+
+ /* wrap-mode ... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "wrap-mode", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ label_editor->wrap_mode_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (label_editor->wrap_free_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), label_editor->wrap_mode_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, row);
+ table_attach (table, GTK_WIDGET (eprop), 1, row++);
+ label_editor->properties = g_list_prepend (label_editor->properties, eprop);
+
+ /* Tie the invisible editor property to the table's life-cycle */
+ g_object_set_data_full (G_OBJECT (table),
+ "glade-single-line-property-destroy-me",
+ single_line_eprop,
+ (GDestroyNotify) gtk_widget_destroy);
}
GtkWidget *
-glade_label_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_label_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed)
{
- GladeLabelEditor *label_editor;
+ GladeLabelEditor *label_editor;
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
- label_editor = g_object_new (GLADE_TYPE_LABEL_EDITOR, NULL);
- label_editor->embed = GTK_WIDGET (embed);
+ label_editor = g_object_new (GLADE_TYPE_LABEL_EDITOR, NULL);
+ label_editor->embed = GTK_WIDGET (embed);
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (label_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (label_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
- append_label_appearance (label_editor, adaptor);
- append_label_formatting (label_editor, adaptor);
- append_label_wrapping (label_editor, adaptor);
+ append_label_appearance (label_editor, adaptor);
+ append_label_formatting (label_editor, adaptor);
+ append_label_wrapping (label_editor, adaptor);
- /* Connect to our radio buttons.... */
- g_signal_connect (G_OBJECT (label_editor->attributes_radio), "toggled",
- G_CALLBACK (attributes_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->markup_radio), "toggled",
- G_CALLBACK (markup_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->pattern_radio), "toggled",
- G_CALLBACK (pattern_toggled), label_editor);
+ /* Connect to our radio buttons.... */
+ g_signal_connect (G_OBJECT (label_editor->attributes_radio), "toggled",
+ G_CALLBACK (attributes_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->markup_radio), "toggled",
+ G_CALLBACK (markup_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->pattern_radio), "toggled",
+ G_CALLBACK (pattern_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->width_radio), "toggled",
- G_CALLBACK (width_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->max_width_radio), "toggled",
- G_CALLBACK (max_width_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->width_radio), "toggled",
+ G_CALLBACK (width_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->max_width_radio), "toggled",
+ G_CALLBACK (max_width_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->wrap_free_radio), "toggled",
- G_CALLBACK (wrap_free_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->single_radio), "toggled",
- G_CALLBACK (single_toggled), label_editor);
- g_signal_connect (G_OBJECT (label_editor->wrap_mode_radio), "toggled",
- G_CALLBACK (wrap_mode_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->wrap_free_radio), "toggled",
+ G_CALLBACK (wrap_free_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->single_radio), "toggled",
+ G_CALLBACK (single_toggled), label_editor);
+ g_signal_connect (G_OBJECT (label_editor->wrap_mode_radio), "toggled",
+ G_CALLBACK (wrap_mode_toggled), label_editor);
- gtk_widget_show_all (GTK_WIDGET (label_editor));
+ gtk_widget_show_all (GTK_WIDGET (label_editor));
- return GTK_WIDGET (label_editor);
+ return GTK_WIDGET (label_editor);
}
diff --git a/plugins/gtk+/glade-label-editor.h b/plugins/gtk+/glade-label-editor.h
index ac432b8..e501d34 100644
--- a/plugins/gtk+/glade-label-editor.h
+++ b/plugins/gtk+/glade-label-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-model-data.c b/plugins/gtk+/glade-model-data.c
index 993c31d..86a7ed6 100644
--- a/plugins/gtk+/glade-model-data.c
+++ b/plugins/gtk+/glade-model-data.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -32,246 +31,241 @@
#include "glade-column-types.h"
GladeModelData *
-glade_model_data_new (GType type, const gchar *column_name)
+glade_model_data_new (GType type, const gchar * column_name)
{
- GladeModelData *data = g_new0 (GladeModelData, 1);
-
- if (type != 0)
- g_value_init (&data->value, type);
+ GladeModelData *data = g_new0 (GladeModelData, 1);
- if (type == G_TYPE_STRING)
- data->i18n_translatable = TRUE;
+ if (type != 0)
+ g_value_init (&data->value, type);
- data->name = g_strdup (column_name);
+ if (type == G_TYPE_STRING)
+ data->i18n_translatable = TRUE;
- return data;
+ data->name = g_strdup (column_name);
+
+ return data;
}
GladeModelData *
-glade_model_data_copy (GladeModelData *data)
+glade_model_data_copy (GladeModelData * data)
{
- if (!data)
- return NULL;
+ if (!data)
+ return NULL;
+
+ GladeModelData *dup = g_new0 (GladeModelData, 1);
- GladeModelData *dup = g_new0 (GladeModelData, 1);
-
- if (G_VALUE_TYPE (&data->value) != 0)
- {
- g_value_init (&dup->value, G_VALUE_TYPE (&data->value));
- g_value_copy (&data->value, &dup->value);
- }
+ if (G_VALUE_TYPE (&data->value) != 0)
+ {
+ g_value_init (&dup->value, G_VALUE_TYPE (&data->value));
+ g_value_copy (&data->value, &dup->value);
+ }
- dup->name = g_strdup (data->name);
+ dup->name = g_strdup (data->name);
- dup->i18n_translatable = data->i18n_translatable;
- dup->i18n_context = g_strdup (data->i18n_context);
- dup->i18n_comment = g_strdup (data->i18n_comment);
+ dup->i18n_translatable = data->i18n_translatable;
+ dup->i18n_context = g_strdup (data->i18n_context);
+ dup->i18n_comment = g_strdup (data->i18n_comment);
- return dup;
+ return dup;
}
void
-glade_model_data_free (GladeModelData *data)
+glade_model_data_free (GladeModelData * data)
{
- if (data)
- {
- if (G_VALUE_TYPE (&data->value) != 0)
- g_value_unset (&data->value);
-
- g_free (data->name);
- g_free (data->i18n_context);
- g_free (data->i18n_comment);
- g_free (data);
- }
+ if (data)
+ {
+ if (G_VALUE_TYPE (&data->value) != 0)
+ g_value_unset (&data->value);
+
+ g_free (data->name);
+ g_free (data->i18n_context);
+ g_free (data->i18n_comment);
+ g_free (data);
+ }
}
GNode *
-glade_model_data_tree_copy (GNode *node)
+glade_model_data_tree_copy (GNode * node)
{
- return g_node_copy_deep (node, (GCopyFunc)glade_model_data_copy, NULL);
+ return g_node_copy_deep (node, (GCopyFunc) glade_model_data_copy, NULL);
}
static void
-model_data_traverse_free (GNode *node,
- gpointer data)
+model_data_traverse_free (GNode * node, gpointer data)
{
- glade_model_data_free ((GladeModelData *)node->data);
+ glade_model_data_free ((GladeModelData *) node->data);
}
void
-glade_model_data_tree_free (GNode *node)
+glade_model_data_tree_free (GNode * node)
{
- if (node)
- {
- g_node_traverse (node, G_IN_ORDER, G_TRAVERSE_ALL, -1,
- (GNodeTraverseFunc)model_data_traverse_free, NULL);
- g_node_destroy (node);
- }
+ if (node)
+ {
+ g_node_traverse (node, G_IN_ORDER, G_TRAVERSE_ALL, -1,
+ (GNodeTraverseFunc) model_data_traverse_free, NULL);
+ g_node_destroy (node);
+ }
}
GladeModelData *
-glade_model_data_tree_get_data (GNode *data_tree, gint row, gint colnum)
+glade_model_data_tree_get_data (GNode * data_tree, gint row, gint colnum)
{
- GNode *node;
+ GNode *node;
- g_return_val_if_fail (data_tree != NULL, NULL);
+ g_return_val_if_fail (data_tree != NULL, NULL);
- if ((node = g_node_nth_child (data_tree, row)) != NULL)
- if ((node = g_node_nth_child (node, colnum)) != NULL)
- return (GladeModelData *)node->data;
+ if ((node = g_node_nth_child (data_tree, row)) != NULL)
+ if ((node = g_node_nth_child (node, colnum)) != NULL)
+ return (GladeModelData *) node->data;
- return NULL;
+ return NULL;
}
void
-glade_model_data_insert_column (GNode *node,
- GType type,
- const gchar *column_name,
- gint nth)
+glade_model_data_insert_column (GNode * node,
+ GType type, const gchar * column_name, gint nth)
{
- GNode *row, *item;
- GladeModelData *data;
+ GNode *row, *item;
+ GladeModelData *data;
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- for (row = node->children; row; row = row->next)
- {
- g_return_if_fail (nth >= 0 && nth <= g_node_n_children (row));
+ for (row = node->children; row; row = row->next)
+ {
+ g_return_if_fail (nth >= 0 && nth <= g_node_n_children (row));
- data = glade_model_data_new (type, column_name);
- item = g_node_new (data);
- g_node_insert (row, nth, item);
- }
+ data = glade_model_data_new (type, column_name);
+ item = g_node_new (data);
+ g_node_insert (row, nth, item);
+ }
}
void
-glade_model_data_remove_column (GNode *node,
- gint nth)
+glade_model_data_remove_column (GNode * node, gint nth)
{
- GNode *row, *item;
- GladeModelData *data;
+ GNode *row, *item;
+ GladeModelData *data;
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- for (row = node->children; row; row = row->next)
- {
- g_return_if_fail (nth >= 0 && nth < g_node_n_children (row));
+ for (row = node->children; row; row = row->next)
+ {
+ g_return_if_fail (nth >= 0 && nth < g_node_n_children (row));
- item = g_node_nth_child (row, nth);
- data = item->data;
+ item = g_node_nth_child (row, nth);
+ data = item->data;
- glade_model_data_free (data);
- g_node_destroy (item);
- }
+ glade_model_data_free (data);
+ g_node_destroy (item);
+ }
}
void
-glade_model_data_reorder_column (GNode *node,
- gint column,
- gint nth)
+glade_model_data_reorder_column (GNode * node, gint column, gint nth)
{
- GNode *row, *item;
+ GNode *row, *item;
- g_return_if_fail (node != NULL);
+ g_return_if_fail (node != NULL);
- for (row = node->children; row; row = row->next)
- {
- g_return_if_fail (nth >= 0 && nth < g_node_n_children (row));
+ for (row = node->children; row; row = row->next)
+ {
+ g_return_if_fail (nth >= 0 && nth < g_node_n_children (row));
- item = g_node_nth_child (row, column);
+ item = g_node_nth_child (row, column);
- g_node_unlink (item);
- g_node_insert (row, nth, item);
- }
+ g_node_unlink (item);
+ g_node_insert (row, nth, item);
+ }
}
gint
-glade_model_data_column_index (GNode *node,
- const gchar *column_name)
+glade_model_data_column_index (GNode * node, const gchar * column_name)
{
- gint i;
- GNode *item;
- GladeModelData *data;
-
- g_return_val_if_fail (node != NULL, -1);
-
- for (i = 0, item = node->children->children; item; i++, item = item->next)
- {
- data = item->data;
- if (strcmp (data->name, column_name) == 0)
- return i;
- }
- return -1;
+ gint i;
+ GNode *item;
+ GladeModelData *data;
+
+ g_return_val_if_fail (node != NULL, -1);
+
+ for (i = 0, item = node->children->children; item; i++, item = item->next)
+ {
+ data = item->data;
+ if (strcmp (data->name, column_name) == 0)
+ return i;
+ }
+ return -1;
}
void
-glade_model_data_column_rename (GNode *node,
- const gchar *column_name,
- const gchar *new_name)
+glade_model_data_column_rename (GNode * node,
+ const gchar * column_name,
+ const gchar * new_name)
{
- gint idx;
- GNode *row, *iter;
- GladeModelData *data;
-
- g_return_if_fail (node != NULL);
-
- if ((idx = glade_model_data_column_index (node, column_name)) < 0)
- return;
-
- for (row = node->children; row; row = row->next)
- {
- iter = g_node_nth_child (row, idx);
- data = iter->data;
- g_free (data->name);
- data->name = g_strdup (new_name);
- }
+ gint idx;
+ GNode *row, *iter;
+ GladeModelData *data;
+
+ g_return_if_fail (node != NULL);
+
+ if ((idx = glade_model_data_column_index (node, column_name)) < 0)
+ return;
+
+ for (row = node->children; row; row = row->next)
+ {
+ iter = g_node_nth_child (row, idx);
+ data = iter->data;
+ g_free (data->name);
+ data->name = g_strdup (new_name);
+ }
}
GType
glade_model_data_tree_get_type (void)
{
- static GType type_id = 0;
-
- if (!type_id)
- type_id = g_boxed_type_register_static
- ("GladeModelDataTree",
- (GBoxedCopyFunc) glade_model_data_tree_copy,
- (GBoxedFreeFunc) glade_model_data_tree_free);
- return type_id;
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static
+ ("GladeModelDataTree",
+ (GBoxedCopyFunc) glade_model_data_tree_copy,
+ (GBoxedFreeFunc) glade_model_data_tree_free);
+ return type_id;
}
/**************************** GladeEditorProperty *****************************/
-enum {
- COLUMN_ROW = 0, /* row number */
- NUM_COLUMNS
+enum
+{
+ COLUMN_ROW = 0, /* row number */
+ NUM_COLUMNS
};
-typedef enum {
- SEQ_NONE,
- SEQ_HORIZONTAL,
- SEQ_VERTICAL
+typedef enum
+{
+ SEQ_NONE,
+ SEQ_HORIZONTAL,
+ SEQ_VERTICAL
} EditSequence;
typedef struct
{
- GladeEditorProperty parent_instance;
+ GladeEditorProperty parent_instance;
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeSelection *selection;
- GNode *pending_data_tree;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
+ GNode *pending_data_tree;
- EditSequence sequence;
+ EditSequence sequence;
- /* Used for setting focus on newly added rows */
- gboolean adding_row;
- gboolean want_focus;
- gboolean want_next_focus;
- gboolean setting_focus;
- gint editing_row;
- gint editing_column;
+ /* Used for setting focus on newly added rows */
+ gboolean adding_row;
+ gboolean want_focus;
+ gboolean want_next_focus;
+ gboolean setting_focus;
+ gint editing_row;
+ gint editing_column;
- guint next_focus_idle;
+ guint next_focus_idle;
} GladeEPropModelData;
GLADE_MAKE_EPROP (GladeEPropModelData, glade_eprop_model_data)
@@ -280,996 +274,1002 @@ GLADE_MAKE_EPROP (GladeEPropModelData, glade_eprop_model_data)
#define GLADE_IS_EPROP_MODEL_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_MODEL_DATA))
#define GLADE_IS_EPROP_MODEL_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_MODEL_DATA))
#define GLADE_EPROP_MODEL_DATA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_MODEL_DATA, GladeEPropModelDataClass))
+ static void eprop_data_focus_editing_cell (GladeEPropModelData *
+ eprop_data);
-
-static void eprop_data_focus_editing_cell (GladeEPropModelData *eprop_data);
-
-static void
-append_row (GNode *node, GList *columns)
+ static void append_row (GNode * node, GList * columns)
{
- GladeModelData *data;
- GladeColumnType *column;
- GNode *row;
- GList *list;
-
- g_assert (node && columns);
-
- row = g_node_new (NULL);
- g_node_append (node, row);
-
- for (list = columns; list; list = list->next)
- {
- column = list->data;
- data = glade_model_data_new (g_type_from_name (column->type_name), column->column_name);
- g_node_append_data (row, data);
- }
+ GladeModelData *data;
+ GladeColumnType *column;
+ GNode *row;
+ GList *list;
+
+ g_assert (node && columns);
+
+ row = g_node_new (NULL);
+ g_node_append (node, row);
+
+ for (list = columns; list; list = list->next)
+ {
+ column = list->data;
+ data =
+ glade_model_data_new (g_type_from_name (column->type_name),
+ column->column_name);
+ g_node_append_data (row, data);
+ }
}
static void
-clear_view (GladeEditorProperty *eprop)
+clear_view (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GtkTreeViewColumn *column;
-
- /* Clear columns ... */
- while ((column = gtk_tree_view_get_column (eprop_data->view, 0)) != NULL)
- gtk_tree_view_remove_column (eprop_data->view, column);
-
- /* Clear store ... (this will unref the old store) */
- gtk_tree_view_set_model (eprop_data->view, NULL);
-
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GtkTreeViewColumn *column;
+
+ /* Clear columns ... */
+ while ((column = gtk_tree_view_get_column (eprop_data->view, 0)) != NULL)
+ gtk_tree_view_remove_column (eprop_data->view, column);
+
+ /* Clear store ... (this will unref the old store) */
+ gtk_tree_view_set_model (eprop_data->view, NULL);
+
}
static gboolean
-update_data_tree_idle (GladeEditorProperty *eprop)
+update_data_tree_idle (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GValue value = { 0, };
-
- g_value_init (&value, GLADE_TYPE_MODEL_DATA_TREE);
- g_value_take_boxed (&value, eprop_data->pending_data_tree);
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
-
- eprop_data->pending_data_tree = NULL;
- return FALSE;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GValue value = { 0, };
+
+ g_value_init (&value, GLADE_TYPE_MODEL_DATA_TREE);
+ g_value_take_boxed (&value, eprop_data->pending_data_tree);
+ glade_editor_property_commit (eprop, &value);
+ g_value_unset (&value);
+
+ eprop_data->pending_data_tree = NULL;
+ return FALSE;
}
static gboolean
-update_and_focus_data_tree_idle (GladeEditorProperty *eprop)
+update_and_focus_data_tree_idle (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- eprop_data->want_focus = TRUE;
- eprop_data->want_next_focus = TRUE;
-
- update_data_tree_idle (eprop);
+ eprop_data->want_focus = TRUE;
+ eprop_data->want_next_focus = TRUE;
- /* XXX Have to load it regardless if it changed, this is a slow and redundant way... */
- glade_editor_property_load (eprop, eprop->property);
+ update_data_tree_idle (eprop);
- eprop_data->want_next_focus = FALSE;
- eprop_data->want_focus = FALSE;
+ /* XXX Have to load it regardless if it changed, this is a slow and redundant way... */
+ glade_editor_property_load (eprop, eprop->property);
- return FALSE;
+ eprop_data->want_next_focus = FALSE;
+ eprop_data->want_focus = FALSE;
+
+ return FALSE;
}
static gboolean
-focus_next_data_tree_idle (GladeEditorProperty *eprop)
+focus_next_data_tree_idle (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+
+ eprop_data->want_focus = TRUE;
+ eprop_data->want_next_focus = TRUE;
- eprop_data->want_focus = TRUE;
- eprop_data->want_next_focus = TRUE;
+ eprop_data_focus_editing_cell (eprop_data);
- eprop_data_focus_editing_cell (eprop_data);
+ eprop_data->want_next_focus = FALSE;
+ eprop_data->want_focus = FALSE;
- eprop_data->want_next_focus = FALSE;
- eprop_data->want_focus = FALSE;
+ eprop_data->next_focus_idle = 0;
- eprop_data->next_focus_idle = 0;
-
- return FALSE;
+ return FALSE;
}
static gboolean
-focus_data_tree_idle (GladeEditorProperty *eprop)
+focus_data_tree_idle (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- eprop_data->want_focus = TRUE;
- eprop_data_focus_editing_cell (eprop_data);
- eprop_data->want_focus = FALSE;
+ eprop_data->want_focus = TRUE;
+ eprop_data_focus_editing_cell (eprop_data);
+ eprop_data->want_focus = FALSE;
- return FALSE;
+ return FALSE;
}
static void
-glade_eprop_model_data_add_row (GladeEditorProperty *eprop)
+glade_eprop_model_data_add_row (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GValue value = { 0, };
- GNode *node = NULL;
- GList *columns = NULL;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GValue value = { 0, };
+ GNode *node = NULL;
+ GList *columns = NULL;
- glade_property_get (eprop->property, &node);
- glade_widget_property_get (eprop->property->widget, "columns", &columns);
+ glade_property_get (eprop->property, &node);
+ glade_widget_property_get (eprop->property->widget, "columns", &columns);
- if (!columns)
- return;
+ if (!columns)
+ return;
- clear_view (eprop);
+ clear_view (eprop);
- if (!node)
- node = g_node_new (NULL);
- else
- node = glade_model_data_tree_copy (node);
+ if (!node)
+ node = g_node_new (NULL);
+ else
+ node = glade_model_data_tree_copy (node);
- append_row (node, columns);
+ append_row (node, columns);
- eprop_data->adding_row = TRUE;
+ eprop_data->adding_row = TRUE;
- g_value_init (&value, GLADE_TYPE_MODEL_DATA_TREE);
- g_value_take_boxed (&value, node);
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
+ g_value_init (&value, GLADE_TYPE_MODEL_DATA_TREE);
+ g_value_take_boxed (&value, node);
+ glade_editor_property_commit (eprop, &value);
+ g_value_unset (&value);
- eprop_data->adding_row = FALSE;
+ eprop_data->adding_row = FALSE;
}
static void
-glade_eprop_model_data_delete_selected (GladeEditorProperty *eprop)
+glade_eprop_model_data_delete_selected (GladeEditorProperty * eprop)
{
- GtkTreeIter iter;
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GNode *data_tree = NULL, *row;
- gint rownum = -1;
-
- /* NOTE: This will trigger row-deleted below... */
- if (!gtk_tree_selection_get_selected (eprop_data->selection, NULL, &iter))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
- COLUMN_ROW, &rownum,
- -1);
- g_assert (rownum >= 0);
-
- /* if theres a sected row, theres data... */
- glade_property_get (eprop->property, &data_tree);
- g_assert (data_tree);
-
- data_tree = glade_model_data_tree_copy (data_tree);
- row = g_node_nth_child (data_tree, rownum);
-
- g_node_unlink (row);
- glade_model_data_tree_free (row);
-
- if (eprop_data->pending_data_tree)
- glade_model_data_tree_free (eprop_data->pending_data_tree);
-
- eprop_data->pending_data_tree = data_tree;
- g_idle_add ((GSourceFunc)update_data_tree_idle, eprop);
+ GtkTreeIter iter;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GNode *data_tree = NULL, *row;
+ gint rownum = -1;
+
+ /* NOTE: This will trigger row-deleted below... */
+ if (!gtk_tree_selection_get_selected (eprop_data->selection, NULL, &iter))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &rownum, -1);
+ g_assert (rownum >= 0);
+
+ /* if theres a sected row, theres data... */
+ glade_property_get (eprop->property, &data_tree);
+ g_assert (data_tree);
+
+ data_tree = glade_model_data_tree_copy (data_tree);
+ row = g_node_nth_child (data_tree, rownum);
+
+ g_node_unlink (row);
+ glade_model_data_tree_free (row);
+
+ if (eprop_data->pending_data_tree)
+ glade_model_data_tree_free (eprop_data->pending_data_tree);
+
+ eprop_data->pending_data_tree = data_tree;
+ g_idle_add ((GSourceFunc) update_data_tree_idle, eprop);
}
static void
-glade_eprop_model_data_add_clicked (GtkWidget *button,
- GladeEditorProperty *eprop)
+glade_eprop_model_data_add_clicked (GtkWidget * button,
+ GladeEditorProperty * eprop)
{
- glade_eprop_model_data_add_row (eprop);
+ glade_eprop_model_data_add_row (eprop);
}
static void
-glade_eprop_model_data_delete_clicked (GtkWidget *button,
- GladeEditorProperty *eprop)
+glade_eprop_model_data_delete_clicked (GtkWidget * button,
+ GladeEditorProperty * eprop)
{
- glade_eprop_model_data_delete_selected (eprop);
+ glade_eprop_model_data_delete_selected (eprop);
}
static void
-glade_eprop_model_sequence_changed (GtkWidget *combo,
- GladeEditorProperty *eprop)
+glade_eprop_model_sequence_changed (GtkWidget * combo,
+ GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- eprop_data->sequence = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+ eprop_data->sequence = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
}
static gboolean
-eprop_treeview_key_press (GtkWidget *treeview,
- GdkEventKey *event,
- GladeEditorProperty *eprop)
+eprop_treeview_key_press (GtkWidget * treeview,
+ GdkEventKey * event, GladeEditorProperty * eprop)
{
- if (event->keyval == GDK_KEY_Delete)
- {
- glade_eprop_model_data_delete_selected (eprop);
- return TRUE;
- }
- else if ((event->state & GDK_CONTROL_MASK) != 0 &&
- (event->keyval == GDK_KEY_n || event->keyval == GDK_KEY_N))
- {
- glade_eprop_model_data_add_row (eprop);
- return TRUE;
- }
-
- return FALSE;
-}
+ if (event->keyval == GDK_KEY_Delete)
+ {
+ glade_eprop_model_data_delete_selected (eprop);
+ return TRUE;
+ }
+ else if ((event->state & GDK_CONTROL_MASK) != 0 &&
+ (event->keyval == GDK_KEY_n || event->keyval == GDK_KEY_N))
+ {
+ glade_eprop_model_data_add_row (eprop);
+ return TRUE;
+ }
+
+ return FALSE;
+}
static gboolean
-data_changed_idle (GladeEditorProperty *eprop)
+data_changed_idle (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GNode *data_tree = NULL, *new_tree, *row;
- GtkTreeIter iter;
- gint rownum;
-
- glade_property_get (eprop->property, &data_tree);
- g_assert (data_tree);
-
- new_tree = g_node_new (NULL);
-
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_data->store), &iter))
- {
- do
- {
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
- COLUMN_ROW, &rownum, -1);
-
-
- if ((row = g_node_nth_child (data_tree, rownum)) != NULL)
- {
- /* Make a new tree by copying row by row... */
- row = glade_model_data_tree_copy (row);
- g_node_append (new_tree, row);
- }
- }
- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (eprop_data->store), &iter));
- }
-
- /* Were already in an idle, no need to idle from here... */
- if (eprop_data->pending_data_tree)
- glade_model_data_tree_free (eprop_data->pending_data_tree);
- eprop_data->pending_data_tree = new_tree;
- update_data_tree_idle (eprop);
-
- return FALSE;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GNode *data_tree = NULL, *new_tree, *row;
+ GtkTreeIter iter;
+ gint rownum;
+
+ glade_property_get (eprop->property, &data_tree);
+ g_assert (data_tree);
+
+ new_tree = g_node_new (NULL);
+
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (eprop_data->store), &iter))
+ {
+ do
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &rownum, -1);
+
+
+ if ((row = g_node_nth_child (data_tree, rownum)) != NULL)
+ {
+ /* Make a new tree by copying row by row... */
+ row = glade_model_data_tree_copy (row);
+ g_node_append (new_tree, row);
+ }
+ }
+ while (gtk_tree_model_iter_next
+ (GTK_TREE_MODEL (eprop_data->store), &iter));
+ }
+
+ /* Were already in an idle, no need to idle from here... */
+ if (eprop_data->pending_data_tree)
+ glade_model_data_tree_free (eprop_data->pending_data_tree);
+ eprop_data->pending_data_tree = new_tree;
+ update_data_tree_idle (eprop);
+
+ return FALSE;
}
static void
-eprop_treeview_row_deleted (GtkTreeModel *tree_model,
- GtkTreePath *path,
- GladeEditorProperty *eprop)
+eprop_treeview_row_deleted (GtkTreeModel * tree_model,
+ GtkTreePath * path, GladeEditorProperty * eprop)
{
- if (eprop->loading) return;
+ if (eprop->loading)
+ return;
- g_idle_add ((GSourceFunc)data_changed_idle, eprop);
+ g_idle_add ((GSourceFunc) data_changed_idle, eprop);
}
static void
-glade_eprop_model_data_finalize (GObject *object)
+glade_eprop_model_data_finalize (GObject * object)
{
- /* Chain up */
- GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
- //GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (object);
+ /* Chain up */
+ GObjectClass *parent_class =
+ g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
+ //GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (object);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GtkListStore *
-eprop_model_data_generate_store (GladeEditorProperty *eprop)
+eprop_model_data_generate_store (GladeEditorProperty * eprop)
{
- GtkListStore *store = NULL;
- GladeModelData *iter_data, *row_data;
- GNode *data_tree = NULL, *iter_node, *row_node;
- GArray *gtypes = g_array_new (FALSE, TRUE, sizeof (GType));
- GtkTreeIter iter;
- gint column_num, row_num;
- GType index_type = G_TYPE_INT, string_type = G_TYPE_STRING, pointer_type = G_TYPE_POINTER;
-
- glade_property_get (eprop->property, &data_tree);
-
- if (!data_tree || !data_tree->children || !data_tree->children->children)
- return NULL;
-
- /* Generate store with tailored column types */
- g_array_append_val (gtypes, index_type);
- for (iter_node = data_tree->children->children; iter_node; iter_node = iter_node->next)
- {
- iter_data = iter_node->data;
- if (G_VALUE_TYPE (&iter_data->value) == 0)
- g_array_append_val (gtypes, pointer_type);
- else if (G_VALUE_TYPE (&iter_data->value) == GDK_TYPE_PIXBUF)
- g_array_append_val (gtypes, string_type);
- else
- g_array_append_val (gtypes, G_VALUE_TYPE (&iter_data->value));
- }
- store = gtk_list_store_newv (gtypes->len, (GType *)gtypes->data);
- g_array_free (gtypes, TRUE);
-
- /* Now populate the store with data */
- for (row_num = 0, row_node = data_tree->children; row_node;
- row_num++, row_node = row_node->next)
- {
- row_data = row_node->data;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, COLUMN_ROW, row_num, -1);
-
- for (column_num = NUM_COLUMNS, iter_node = row_node->children; iter_node;
- column_num++, iter_node = iter_node->next)
- {
- iter_data = iter_node->data;
-
- if (G_VALUE_TYPE (&iter_data->value) == 0)
- continue;
-
- /* Special case, show the filename in the cellrenderertext */
- if (G_VALUE_TYPE (&iter_data->value) == GDK_TYPE_PIXBUF)
- {
- GObject *object = g_value_get_object (&iter_data->value);
- gchar *filename = NULL;
- if (object)
- filename = g_object_get_data (object, "GladeFileName");
-
- gtk_list_store_set (store, &iter,
- column_num, filename,
- -1);
- }
- else
- gtk_list_store_set_value (store, &iter, column_num, &iter_data->value);
- }
- }
- return store;
+ GtkListStore *store = NULL;
+ GladeModelData *iter_data, *row_data;
+ GNode *data_tree = NULL, *iter_node, *row_node;
+ GArray *gtypes = g_array_new (FALSE, TRUE, sizeof (GType));
+ GtkTreeIter iter;
+ gint column_num, row_num;
+ GType index_type = G_TYPE_INT, string_type = G_TYPE_STRING, pointer_type =
+ G_TYPE_POINTER;
+
+ glade_property_get (eprop->property, &data_tree);
+
+ if (!data_tree || !data_tree->children || !data_tree->children->children)
+ return NULL;
+
+ /* Generate store with tailored column types */
+ g_array_append_val (gtypes, index_type);
+ for (iter_node = data_tree->children->children; iter_node;
+ iter_node = iter_node->next)
+ {
+ iter_data = iter_node->data;
+ if (G_VALUE_TYPE (&iter_data->value) == 0)
+ g_array_append_val (gtypes, pointer_type);
+ else if (G_VALUE_TYPE (&iter_data->value) == GDK_TYPE_PIXBUF)
+ g_array_append_val (gtypes, string_type);
+ else
+ g_array_append_val (gtypes, G_VALUE_TYPE (&iter_data->value));
+ }
+ store = gtk_list_store_newv (gtypes->len, (GType *) gtypes->data);
+ g_array_free (gtypes, TRUE);
+
+ /* Now populate the store with data */
+ for (row_num = 0, row_node = data_tree->children; row_node;
+ row_num++, row_node = row_node->next)
+ {
+ row_data = row_node->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, COLUMN_ROW, row_num, -1);
+
+ for (column_num = NUM_COLUMNS, iter_node = row_node->children; iter_node;
+ column_num++, iter_node = iter_node->next)
+ {
+ iter_data = iter_node->data;
+
+ if (G_VALUE_TYPE (&iter_data->value) == 0)
+ continue;
+
+ /* Special case, show the filename in the cellrenderertext */
+ if (G_VALUE_TYPE (&iter_data->value) == GDK_TYPE_PIXBUF)
+ {
+ GObject *object = g_value_get_object (&iter_data->value);
+ gchar *filename = NULL;
+ if (object)
+ filename = g_object_get_data (object, "GladeFileName");
+
+ gtk_list_store_set (store, &iter, column_num, filename, -1);
+ }
+ else
+ gtk_list_store_set_value (store, &iter, column_num,
+ &iter_data->value);
+ }
+ }
+ return store;
}
static void
-value_toggled (GtkCellRendererToggle *cell,
- gchar *path,
- GladeEditorProperty *eprop)
+value_toggled (GtkCellRendererToggle * cell,
+ gchar * path, GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GtkTreeIter iter;
- gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
- gint row;
- GNode *data_tree = NULL;
- GladeModelData *data;
- gboolean active;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GtkTreeIter iter;
+ gint colnum =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
+ gint row;
+ GNode *data_tree = NULL;
+ GladeModelData *data;
+ gboolean active;
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path))
- return;
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_data->store), &iter, path))
+ return;
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
- COLUMN_ROW, &row,
- NUM_COLUMNS + colnum, &active,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &row, NUM_COLUMNS + colnum, &active, -1);
- glade_property_get (eprop->property, &data_tree);
+ glade_property_get (eprop->property, &data_tree);
- /* if we are editing, then there is data in the datatree */
- g_assert (data_tree);
+ /* if we are editing, then there is data in the datatree */
+ g_assert (data_tree);
- data_tree = glade_model_data_tree_copy (data_tree);
+ data_tree = glade_model_data_tree_copy (data_tree);
- data = glade_model_data_tree_get_data (data_tree, row, colnum);
+ data = glade_model_data_tree_get_data (data_tree, row, colnum);
- g_value_set_boolean (&data->value, !active);
+ g_value_set_boolean (&data->value, !active);
- eprop_data->editing_row = row;
- eprop_data->editing_column = colnum;
- if (eprop_data->pending_data_tree)
- glade_model_data_tree_free (eprop_data->pending_data_tree);
+ eprop_data->editing_row = row;
+ eprop_data->editing_column = colnum;
+ if (eprop_data->pending_data_tree)
+ glade_model_data_tree_free (eprop_data->pending_data_tree);
- eprop_data->pending_data_tree = data_tree;
- g_idle_add ((GSourceFunc)update_and_focus_data_tree_idle, eprop);
+ eprop_data->pending_data_tree = data_tree;
+ g_idle_add ((GSourceFunc) update_and_focus_data_tree_idle, eprop);
}
static void
-value_i18n_activate (GladeCellRendererIcon *cell,
- const gchar *path,
- GladeEditorProperty *eprop)
+value_i18n_activate (GladeCellRendererIcon * cell,
+ const gchar * path, GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GtkTreeIter iter;
- gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
- gint row;
- GNode *data_tree = NULL;
- GladeModelData *data;
- gchar *new_text;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path))
- return;
-
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
- COLUMN_ROW, &row,
- -1);
-
- glade_property_get (eprop->property, &data_tree);
-
- /* if we are editing, then there is data in the datatree */
- g_assert (data_tree);
-
- data_tree = glade_model_data_tree_copy (data_tree);
-
- data = glade_model_data_tree_get_data (data_tree, row, colnum);
- g_assert (G_VALUE_TYPE (&data->value) == G_TYPE_STRING);
-
- new_text = g_value_dup_string (&data->value);
-
- if (glade_editor_property_show_i18n_dialog (NULL,
- &new_text,
- &data->i18n_context,
- &data->i18n_comment,
- &data->i18n_translatable))
- {
- g_value_set_string (&data->value, new_text);
-
- eprop_data->editing_row = row;
- eprop_data->editing_column = colnum;
- if (eprop_data->pending_data_tree)
- glade_model_data_tree_free (eprop_data->pending_data_tree);
-
- eprop_data->pending_data_tree = data_tree;
- g_idle_add ((GSourceFunc)update_and_focus_data_tree_idle, eprop);
- }
- else
- glade_model_data_tree_free (data_tree);
-
- g_free (new_text);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GtkTreeIter iter;
+ gint colnum =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
+ gint row;
+ GNode *data_tree = NULL;
+ GladeModelData *data;
+ gchar *new_text;
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_data->store), &iter, path))
+ return;
+
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &row, -1);
+
+ glade_property_get (eprop->property, &data_tree);
+
+ /* if we are editing, then there is data in the datatree */
+ g_assert (data_tree);
+
+ data_tree = glade_model_data_tree_copy (data_tree);
+
+ data = glade_model_data_tree_get_data (data_tree, row, colnum);
+ g_assert (G_VALUE_TYPE (&data->value) == G_TYPE_STRING);
+
+ new_text = g_value_dup_string (&data->value);
+
+ if (glade_editor_property_show_i18n_dialog (NULL,
+ &new_text,
+ &data->i18n_context,
+ &data->i18n_comment,
+ &data->i18n_translatable))
+ {
+ g_value_set_string (&data->value, new_text);
+
+ eprop_data->editing_row = row;
+ eprop_data->editing_column = colnum;
+ if (eprop_data->pending_data_tree)
+ glade_model_data_tree_free (eprop_data->pending_data_tree);
+
+ eprop_data->pending_data_tree = data_tree;
+ g_idle_add ((GSourceFunc) update_and_focus_data_tree_idle, eprop);
+ }
+ else
+ glade_model_data_tree_free (data_tree);
+
+ g_free (new_text);
}
static void
-value_text_edited (GtkCellRendererText *cell,
- const gchar *path,
- const gchar *new_text,
- GladeEditorProperty *eprop)
+value_text_edited (GtkCellRendererText * cell,
+ const gchar * path,
+ const gchar * new_text, GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GtkTreeIter iter;
- gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
- gint row;
- GNode *data_tree = NULL;
- GladeModelData *data;
- GValue *value;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
- COLUMN_ROW, &row,
- -1);
-
- glade_property_get (eprop->property, &data_tree);
-
- /* if we are editing, then there is data in the datatree */
- g_assert (data_tree);
-
- data_tree = glade_model_data_tree_copy (data_tree);
-
- data = glade_model_data_tree_get_data (data_tree, row, colnum);
-
- /* Untranslate string and update value in tree. */
- if (G_VALUE_HOLDS_ENUM (&data->value) || G_VALUE_HOLDS_FLAGS (&data->value))
- value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value),
- glade_get_value_from_displayable
- (G_VALUE_TYPE (&data->value), new_text),
- eprop->property->widget->project,
- eprop->property->widget);
- else
- value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value), new_text,
- eprop->property->widget->project,
- eprop->property->widget);
-
-
- g_value_copy (value, &data->value);
- g_value_unset (value);
- g_free (value);
-
- eprop_data->editing_row = row;
- eprop_data->editing_column = colnum;
- if (eprop_data->pending_data_tree)
- glade_model_data_tree_free (eprop_data->pending_data_tree);
-
- eprop_data->pending_data_tree = data_tree;
- g_idle_add ((GSourceFunc)update_and_focus_data_tree_idle, eprop);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GtkTreeIter iter;
+ gint colnum =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
+ gint row;
+ GNode *data_tree = NULL;
+ GladeModelData *data;
+ GValue *value;
+
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_data->store), &iter, path))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &row, -1);
+
+ glade_property_get (eprop->property, &data_tree);
+
+ /* if we are editing, then there is data in the datatree */
+ g_assert (data_tree);
+
+ data_tree = glade_model_data_tree_copy (data_tree);
+
+ data = glade_model_data_tree_get_data (data_tree, row, colnum);
+
+ /* Untranslate string and update value in tree. */
+ if (G_VALUE_HOLDS_ENUM (&data->value) || G_VALUE_HOLDS_FLAGS (&data->value))
+ value = glade_utils_value_from_string (G_VALUE_TYPE (&data->value),
+ glade_get_value_from_displayable
+ (G_VALUE_TYPE (&data->value),
+ new_text),
+ eprop->property->widget->project,
+ eprop->property->widget);
+ else
+ value =
+ glade_utils_value_from_string (G_VALUE_TYPE (&data->value), new_text,
+ eprop->property->widget->project,
+ eprop->property->widget);
+
+
+ g_value_copy (value, &data->value);
+ g_value_unset (value);
+ g_free (value);
+
+ eprop_data->editing_row = row;
+ eprop_data->editing_column = colnum;
+ if (eprop_data->pending_data_tree)
+ glade_model_data_tree_free (eprop_data->pending_data_tree);
+
+ eprop_data->pending_data_tree = data_tree;
+ g_idle_add ((GSourceFunc) update_and_focus_data_tree_idle, eprop);
}
-static void
-enum_flags_format_cell_data (GtkCellLayout *cell_layout,
- GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- gpointer data)
+static void
+enum_flags_format_cell_data (GtkCellLayout * cell_layout,
+ GtkCellRenderer * cell,
+ GtkTreeModel * tree_model,
+ GtkTreeIter * iter, gpointer data)
{
- gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
- GValue value = { 0, };
- gchar *string;
+ gint colnum =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
+ GValue value = { 0, };
+ gchar *string;
+
+ gtk_tree_model_get_value (tree_model, iter, NUM_COLUMNS + colnum, &value);
- gtk_tree_model_get_value (tree_model, iter,
- NUM_COLUMNS + colnum, &value);
+ string = glade_utils_string_from_value (&value);
- string = glade_utils_string_from_value (&value);
+ g_object_set (cell, "text", string && string[0] ?
+ glade_get_displayable_value (G_VALUE_TYPE (&value),
+ string) : "", NULL);
- g_object_set (cell, "text", string && string[0] ?
- glade_get_displayable_value (G_VALUE_TYPE (&value), string) : "", NULL);
-
- g_free (string);
+ g_free (string);
- g_value_unset (&value);
+ g_value_unset (&value);
}
static void
-data_editing_started (GtkCellRenderer *cell,
- GtkCellEditable *editable,
- gchar *path,
- GladeEditorProperty *eprop)
+data_editing_started (GtkCellRenderer * cell,
+ GtkCellEditable * editable,
+ gchar * path, GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
- gint row;
- GtkTreeIter iter;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ gint colnum =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
+ gint row;
+ GtkTreeIter iter;
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path))
- return;
+ if (!gtk_tree_model_get_iter_from_string
+ (GTK_TREE_MODEL (eprop_data->store), &iter, path))
+ return;
- gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
- COLUMN_ROW, &row,
- -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &row, -1);
- eprop_data->editing_row = row;
- eprop_data->editing_column = colnum;
+ eprop_data->editing_row = row;
+ eprop_data->editing_column = colnum;
}
static void
-data_editing_canceled (GtkCellRenderer *renderer,
- GladeEditorProperty *eprop)
+data_editing_canceled (GtkCellRenderer * renderer, GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- if (eprop_data->setting_focus)
- return;
+ if (eprop_data->setting_focus)
+ return;
- g_idle_add ((GSourceFunc)focus_data_tree_idle, eprop);
+ g_idle_add ((GSourceFunc) focus_data_tree_idle, eprop);
}
static GtkTreeViewColumn *
-eprop_model_generate_column (GladeEditorProperty *eprop,
- gint colnum,
- GladeModelData *data)
+eprop_model_generate_column (GladeEditorProperty * eprop,
+ gint colnum, GladeModelData * data)
{
- GtkTreeViewColumn *column = gtk_tree_view_column_new ();
- GtkCellRenderer *renderer = NULL;
- GtkAdjustment *adjustment;
- GtkListStore *store;
- GType type = G_TYPE_INVALID;
-
- gtk_tree_view_column_set_title (column, data->name);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_column_set_expand (column, TRUE);
-
- type = G_VALUE_TYPE (&data->value);
-
- /* Support enum and flag types, and a hardcoded list of fundamental types */
- if (type == G_TYPE_CHAR ||
- type == G_TYPE_UCHAR ||
- type == G_TYPE_STRING ||
- type == GDK_TYPE_PIXBUF)
- {
- /* Text renderer */
- renderer = gtk_cell_renderer_text_new ();
-
- g_object_set (G_OBJECT (renderer),
- "editable", TRUE,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "width", 90,
- NULL);
-
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", NUM_COLUMNS + colnum,
- NULL);
-
- if (type == G_TYPE_CHAR ||
- type == G_TYPE_UCHAR)
- {
- /* XXX restrict to 1 char !! */
- }
-
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_text_edited), eprop);
-
- /* Trigger i18n dialog from here */
- if (type == G_TYPE_STRING)
- {
- GtkCellRenderer *icon_renderer = glade_cell_renderer_icon_new ();
-
- g_object_set (G_OBJECT (icon_renderer),
- "activatable", TRUE,
- "icon-name", GTK_STOCK_EDIT,
- NULL);
-
- gtk_tree_view_column_pack_start (column, icon_renderer, FALSE);
-
- g_object_set_data (G_OBJECT (icon_renderer), "column-number", GINT_TO_POINTER (colnum));
- g_signal_connect (G_OBJECT (icon_renderer), "activate",
- G_CALLBACK (value_i18n_activate), eprop);
- }
-
- }
- else if (type == G_TYPE_BOOLEAN)
- {
- /* Toggle renderer */
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "active", NUM_COLUMNS + colnum,
- NULL);
- g_signal_connect (G_OBJECT (renderer), "toggled",
- G_CALLBACK (value_toggled), eprop);
- }
- /* Check renderer */
- else if (type == G_TYPE_INT ||
- type == G_TYPE_UINT ||
- type == G_TYPE_LONG ||
- type == G_TYPE_ULONG ||
- type == G_TYPE_INT64 ||
- type == G_TYPE_UINT64 ||
- type == G_TYPE_FLOAT ||
- type == G_TYPE_DOUBLE)
- {
- /* Spin renderer */
- renderer = gtk_cell_renderer_spin_new ();
- adjustment = (GtkAdjustment *)gtk_adjustment_new (0, -G_MAXDOUBLE, G_MAXDOUBLE, 100, 100, 0);
- g_object_set (G_OBJECT (renderer),
- "editable", TRUE,
- "adjustment", adjustment,
- NULL);
-
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", NUM_COLUMNS + colnum,
- NULL);
-
- if (type == G_TYPE_FLOAT ||
- type == G_TYPE_DOUBLE)
- g_object_set (G_OBJECT (renderer), "digits", 2, NULL);
-
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_text_edited), eprop);
-
- }
- else if (G_TYPE_IS_ENUM (type))
- {
- /* Combo renderer */
- renderer = gtk_cell_renderer_combo_new ();
- store = glade_utils_liststore_from_enum_type (type, FALSE);
- g_object_set (G_OBJECT (renderer),
- "editable", TRUE,
- "text-column", 0,
- "has-entry", FALSE,
- "model", store,
- NULL);
- gtk_tree_view_column_pack_start (column, renderer, TRUE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", NUM_COLUMNS + colnum,
- NULL);
-
-
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column),
- renderer,
- (GtkCellLayoutDataFunc)enum_flags_format_cell_data,
- NULL, NULL);
-
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (value_text_edited), eprop);
-
- }
- else if (G_TYPE_IS_FLAGS (type))
- {
- /* Export a flags dialog from glade-editor-property... */
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", NUM_COLUMNS + colnum,
- NULL);
-
- }
- else /* All uneditable types at this point (currently we dont do object data here, TODO) */
- {
- /* text renderer and object dialog (or raw text for pixbuf) */
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
- gtk_tree_view_column_pack_start (column, renderer, FALSE);
- }
-
- g_signal_connect (G_OBJECT (renderer), "editing-started",
- G_CALLBACK (data_editing_started), eprop);
-
- g_signal_connect (G_OBJECT (renderer), "editing-canceled",
- G_CALLBACK (data_editing_canceled), eprop);
-
- g_object_set_data (G_OBJECT (renderer), "column-number", GINT_TO_POINTER (colnum));
- g_object_set_data_full (G_OBJECT (column), "column-type", g_memdup (&type, sizeof (GType)), g_free);
-
- return column;
+ GtkTreeViewColumn *column = gtk_tree_view_column_new ();
+ GtkCellRenderer *renderer = NULL;
+ GtkAdjustment *adjustment;
+ GtkListStore *store;
+ GType type = G_TYPE_INVALID;
+
+ gtk_tree_view_column_set_title (column, data->name);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_expand (column, TRUE);
+
+ type = G_VALUE_TYPE (&data->value);
+
+ /* Support enum and flag types, and a hardcoded list of fundamental types */
+ if (type == G_TYPE_CHAR ||
+ type == G_TYPE_UCHAR || type == G_TYPE_STRING || type == GDK_TYPE_PIXBUF)
+ {
+ /* Text renderer */
+ renderer = gtk_cell_renderer_text_new ();
+
+ g_object_set (G_OBJECT (renderer),
+ "editable", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END, "width", 90, NULL);
+
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", NUM_COLUMNS + colnum, NULL);
+
+ if (type == G_TYPE_CHAR || type == G_TYPE_UCHAR)
+ {
+ /* XXX restrict to 1 char !! */
+ }
+
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_text_edited), eprop);
+
+ /* Trigger i18n dialog from here */
+ if (type == G_TYPE_STRING)
+ {
+ GtkCellRenderer *icon_renderer = glade_cell_renderer_icon_new ();
+
+ g_object_set (G_OBJECT (icon_renderer),
+ "activatable", TRUE, "icon-name", GTK_STOCK_EDIT, NULL);
+
+ gtk_tree_view_column_pack_start (column, icon_renderer, FALSE);
+
+ g_object_set_data (G_OBJECT (icon_renderer), "column-number",
+ GINT_TO_POINTER (colnum));
+ g_signal_connect (G_OBJECT (icon_renderer), "activate",
+ G_CALLBACK (value_i18n_activate), eprop);
+ }
+
+ }
+ else if (type == G_TYPE_BOOLEAN)
+ {
+ /* Toggle renderer */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "active", NUM_COLUMNS + colnum,
+ NULL);
+ g_signal_connect (G_OBJECT (renderer), "toggled",
+ G_CALLBACK (value_toggled), eprop);
+ }
+ /* Check renderer */
+ else if (type == G_TYPE_INT ||
+ type == G_TYPE_UINT ||
+ type == G_TYPE_LONG ||
+ type == G_TYPE_ULONG ||
+ type == G_TYPE_INT64 ||
+ type == G_TYPE_UINT64 ||
+ type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE)
+ {
+ /* Spin renderer */
+ renderer = gtk_cell_renderer_spin_new ();
+ adjustment =
+ (GtkAdjustment *) gtk_adjustment_new (0, -G_MAXDOUBLE, G_MAXDOUBLE,
+ 100, 100, 0);
+ g_object_set (G_OBJECT (renderer), "editable", TRUE, "adjustment",
+ adjustment, NULL);
+
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", NUM_COLUMNS + colnum, NULL);
+
+ if (type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE)
+ g_object_set (G_OBJECT (renderer), "digits", 2, NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_text_edited), eprop);
+
+ }
+ else if (G_TYPE_IS_ENUM (type))
+ {
+ /* Combo renderer */
+ renderer = gtk_cell_renderer_combo_new ();
+ store = glade_utils_liststore_from_enum_type (type, FALSE);
+ g_object_set (G_OBJECT (renderer),
+ "editable", TRUE,
+ "text-column", 0, "has-entry", FALSE, "model", store, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", NUM_COLUMNS + colnum, NULL);
+
+
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column),
+ renderer,
+ (GtkCellLayoutDataFunc)
+ enum_flags_format_cell_data, NULL,
+ NULL);
+
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (value_text_edited), eprop);
+
+ }
+ else if (G_TYPE_IS_FLAGS (type))
+ {
+ /* Export a flags dialog from glade-editor-property... */
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", NUM_COLUMNS + colnum, NULL);
+
+ }
+ else /* All uneditable types at this point (currently we dont do object data here, TODO) */
+ {
+ /* text renderer and object dialog (or raw text for pixbuf) */
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ }
+
+ g_signal_connect (G_OBJECT (renderer), "editing-started",
+ G_CALLBACK (data_editing_started), eprop);
+
+ g_signal_connect (G_OBJECT (renderer), "editing-canceled",
+ G_CALLBACK (data_editing_canceled), eprop);
+
+ g_object_set_data (G_OBJECT (renderer), "column-number",
+ GINT_TO_POINTER (colnum));
+ g_object_set_data_full (G_OBJECT (column), "column-type",
+ g_memdup (&type, sizeof (GType)), g_free);
+
+ return column;
}
static void
-eprop_model_data_generate_columns (GladeEditorProperty *eprop)
+eprop_model_data_generate_columns (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GladeModelData *iter_data;
- GtkTreeViewColumn *column;
- GNode *data_tree = NULL, *iter_node;
- gint colnum;
-
- glade_property_get (eprop->property, &data_tree);
-
- if (!data_tree || !data_tree->children || !data_tree->children->children)
- return;
-
- /* Append new columns */
- for (colnum = 0, iter_node = data_tree->children->children; iter_node;
- colnum++, iter_node = iter_node->next)
- {
- iter_data = iter_node->data;
-
- column = eprop_model_generate_column (eprop, colnum, iter_data);
- gtk_tree_view_append_column (eprop_data->view, column);
- }
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GladeModelData *iter_data;
+ GtkTreeViewColumn *column;
+ GNode *data_tree = NULL, *iter_node;
+ gint colnum;
+
+ glade_property_get (eprop->property, &data_tree);
+
+ if (!data_tree || !data_tree->children || !data_tree->children->children)
+ return;
+
+ /* Append new columns */
+ for (colnum = 0, iter_node = data_tree->children->children; iter_node;
+ colnum++, iter_node = iter_node->next)
+ {
+ iter_data = iter_node->data;
+
+ column = eprop_model_generate_column (eprop, colnum, iter_data);
+ gtk_tree_view_append_column (eprop_data->view, column);
+ }
}
static void
-eprop_data_focus_new (GladeEPropModelData *eprop_data)
+eprop_data_focus_new (GladeEPropModelData * eprop_data)
{
- /* Focus and edit the first column of a newly added row */
- if (eprop_data->store)
- {
- GtkTreePath *new_item_path;
- GtkTreeIter iter;
- GtkTreeViewColumn *column;
- gint n_children;
-
- n_children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_data->store), NULL);
-
- if ((column = gtk_tree_view_get_column (eprop_data->view, eprop_data->editing_column)) != NULL &&
- n_children > 0 && gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_data->store),
- &iter, NULL, n_children - 1))
-
- {
- GType *column_type = g_object_get_data (G_OBJECT (column), "column-type");
-
- new_item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store), &iter);
-
- eprop_data->setting_focus = TRUE;
-
- gtk_widget_grab_focus (GTK_WIDGET (eprop_data->view));
- gtk_tree_view_expand_to_path (eprop_data->view, new_item_path);
- gtk_tree_view_set_cursor (eprop_data->view, new_item_path,
- column, *column_type != G_TYPE_BOOLEAN);
-
- eprop_data->setting_focus = FALSE;
-
- gtk_tree_path_free (new_item_path);
- }
- }
+ /* Focus and edit the first column of a newly added row */
+ if (eprop_data->store)
+ {
+ GtkTreePath *new_item_path;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column;
+ gint n_children;
+
+ n_children =
+ gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_data->store),
+ NULL);
+
+ if ((column =
+ gtk_tree_view_get_column (eprop_data->view,
+ eprop_data->editing_column)) != NULL &&
+ n_children > 0 &&
+ gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_data->store),
+ &iter, NULL, n_children - 1))
+
+ {
+ GType *column_type =
+ g_object_get_data (G_OBJECT (column), "column-type");
+
+ new_item_path =
+ gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store),
+ &iter);
+
+ eprop_data->setting_focus = TRUE;
+
+ gtk_widget_grab_focus (GTK_WIDGET (eprop_data->view));
+ gtk_tree_view_expand_to_path (eprop_data->view, new_item_path);
+ gtk_tree_view_set_cursor (eprop_data->view, new_item_path,
+ column, *column_type != G_TYPE_BOOLEAN);
+
+ eprop_data->setting_focus = FALSE;
+
+ gtk_tree_path_free (new_item_path);
+ }
+ }
}
static void
-eprop_data_focus_editing_cell (GladeEPropModelData *eprop_data)
+eprop_data_focus_editing_cell (GladeEPropModelData * eprop_data)
{
- /* Focus and edit the first column of a newly added row */
- if (!eprop_data->setting_focus && eprop_data->store && eprop_data->want_focus &&
- eprop_data->editing_column >= 0 && eprop_data->editing_row >= 0)
- {
- GtkTreePath *item_path;
- GtkTreeIter iter;
- GtkTreeViewColumn *column;
- gint row, col, rows, cols;
- GList *column_list;
-
- column_list = gtk_tree_view_get_columns (eprop_data->view);
- cols = g_list_length (column_list);
- g_list_free (column_list);
-
- rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_data->store), NULL);
-
- col = eprop_data->editing_column;
- row = eprop_data->editing_row;
-
- if (eprop_data->want_next_focus)
- {
- switch (eprop_data->sequence)
- {
- case SEQ_HORIZONTAL:
- if (++col >= cols)
- {
- col = 0;
- if (++row >= rows)
- row = 0;
- }
- break;
- case SEQ_VERTICAL:
- if (++row >= rows)
- {
- row = 0;
- if (++col >= cols)
- col = 0;
- }
- break;
- case SEQ_NONE:
- default:
- break;
- }
- }
-
- if ((column = gtk_tree_view_get_column (eprop_data->view, col)) != NULL &&
- gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_data->store), &iter, NULL, row))
- {
- GType *column_type = g_object_get_data (G_OBJECT (column), "column-type");
-
- item_path = gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store), &iter);
-
- eprop_data->setting_focus = TRUE;
-
- gtk_widget_grab_focus (GTK_WIDGET (eprop_data->view));
- gtk_tree_view_expand_to_path (eprop_data->view, item_path);
- gtk_tree_view_set_cursor (eprop_data->view, item_path, column,
- eprop_data->want_next_focus &&
- eprop_data->sequence != SEQ_NONE &&
- *column_type != G_TYPE_BOOLEAN);
-
- gtk_tree_path_free (item_path);
-
- eprop_data->setting_focus = FALSE;
- }
- }
+ /* Focus and edit the first column of a newly added row */
+ if (!eprop_data->setting_focus && eprop_data->store && eprop_data->want_focus
+ && eprop_data->editing_column >= 0 && eprop_data->editing_row >= 0)
+ {
+ GtkTreePath *item_path;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column;
+ gint row, col, rows, cols;
+ GList *column_list;
+
+ column_list = gtk_tree_view_get_columns (eprop_data->view);
+ cols = g_list_length (column_list);
+ g_list_free (column_list);
+
+ rows =
+ gtk_tree_model_iter_n_children (GTK_TREE_MODEL (eprop_data->store),
+ NULL);
+
+ col = eprop_data->editing_column;
+ row = eprop_data->editing_row;
+
+ if (eprop_data->want_next_focus)
+ {
+ switch (eprop_data->sequence)
+ {
+ case SEQ_HORIZONTAL:
+ if (++col >= cols)
+ {
+ col = 0;
+ if (++row >= rows)
+ row = 0;
+ }
+ break;
+ case SEQ_VERTICAL:
+ if (++row >= rows)
+ {
+ row = 0;
+ if (++col >= cols)
+ col = 0;
+ }
+ break;
+ case SEQ_NONE:
+ default:
+ break;
+ }
+ }
+
+ if ((column = gtk_tree_view_get_column (eprop_data->view, col)) != NULL &&
+ gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (eprop_data->store),
+ &iter, NULL, row))
+ {
+ GType *column_type =
+ g_object_get_data (G_OBJECT (column), "column-type");
+
+ item_path =
+ gtk_tree_model_get_path (GTK_TREE_MODEL (eprop_data->store),
+ &iter);
+
+ eprop_data->setting_focus = TRUE;
+
+ gtk_widget_grab_focus (GTK_WIDGET (eprop_data->view));
+ gtk_tree_view_expand_to_path (eprop_data->view, item_path);
+ gtk_tree_view_set_cursor (eprop_data->view, item_path, column,
+ eprop_data->want_next_focus &&
+ eprop_data->sequence != SEQ_NONE &&
+ *column_type != G_TYPE_BOOLEAN);
+
+ gtk_tree_path_free (item_path);
+
+ eprop_data->setting_focus = FALSE;
+ }
+ }
}
static void
-glade_eprop_model_data_load (GladeEditorProperty *eprop,
- GladeProperty *property)
+glade_eprop_model_data_load (GladeEditorProperty * eprop,
+ GladeProperty * property)
{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
-
- clear_view (eprop);
-
- /* Chain up in a clean state... */
- parent_class->load (eprop, property);
-
- gtk_tree_view_set_model (eprop_data->view, NULL);
- if (!property)
- return;
-
- if ((eprop_data->store = eprop_model_data_generate_store (eprop)) != NULL)
- {
- eprop_data->selection = gtk_tree_view_get_selection (eprop_data->view);
-
- /* Pass ownership of the store to the view... */
- gtk_tree_view_set_model (eprop_data->view, GTK_TREE_MODEL (eprop_data->store));
- g_object_unref (G_OBJECT (eprop_data->store));
-
- g_signal_connect (G_OBJECT (eprop_data->store), "row-deleted",
- G_CALLBACK (eprop_treeview_row_deleted),
- eprop);
- }
-
- /* Create new columns with renderers */
- eprop_model_data_generate_columns (eprop);
-
- if (eprop_data->store)
- {
- if (eprop_data->adding_row)
- eprop_data_focus_new (eprop_data);
- else if (eprop_data->want_focus &&
- eprop_data->editing_row >= 0 && eprop_data->editing_column >= 0)
- {
- if (eprop_data->want_next_focus && eprop_data->next_focus_idle == 0)
- eprop_data->next_focus_idle =
- g_idle_add ((GSourceFunc)focus_next_data_tree_idle, eprop);
- else
- eprop_data_focus_editing_cell (eprop_data);
- }
- }
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+
+ clear_view (eprop);
+
+ /* Chain up in a clean state... */
+ parent_class->load (eprop, property);
+
+ gtk_tree_view_set_model (eprop_data->view, NULL);
+ if (!property)
+ return;
+
+ if ((eprop_data->store = eprop_model_data_generate_store (eprop)) != NULL)
+ {
+ eprop_data->selection = gtk_tree_view_get_selection (eprop_data->view);
+
+ /* Pass ownership of the store to the view... */
+ gtk_tree_view_set_model (eprop_data->view,
+ GTK_TREE_MODEL (eprop_data->store));
+ g_object_unref (G_OBJECT (eprop_data->store));
+
+ g_signal_connect (G_OBJECT (eprop_data->store), "row-deleted",
+ G_CALLBACK (eprop_treeview_row_deleted), eprop);
+ }
+
+ /* Create new columns with renderers */
+ eprop_model_data_generate_columns (eprop);
+
+ if (eprop_data->store)
+ {
+ if (eprop_data->adding_row)
+ eprop_data_focus_new (eprop_data);
+ else if (eprop_data->want_focus &&
+ eprop_data->editing_row >= 0 && eprop_data->editing_column >= 0)
+ {
+ if (eprop_data->want_next_focus && eprop_data->next_focus_idle == 0)
+ eprop_data->next_focus_idle =
+ g_idle_add ((GSourceFunc) focus_next_data_tree_idle, eprop);
+ else
+ eprop_data_focus_editing_cell (eprop_data);
+ }
+ }
}
static GtkWidget *
-glade_eprop_model_data_create_input (GladeEditorProperty *eprop)
+glade_eprop_model_data_create_input (GladeEditorProperty * eprop)
{
- GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GtkWidget *vbox, *hbox, *button, *swin, *label, *combo;
- gchar *string;
-
- vbox = gtk_vbox_new (FALSE, 2);
-
- hbox = gtk_hbox_new (FALSE, 4);
-
- eprop_data->sequence = SEQ_NONE;
-
- /* hbox with add/remove row buttons on the right... */
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
- string = g_strdup_printf ("<b>%s</b>", _("Add and remove rows:"));
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_misc_set_padding (GTK_MISC (label), 2, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON));
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_model_data_add_clicked),
- eprop_data);
-
- button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON));
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (glade_eprop_model_data_delete_clicked),
- eprop_data);
-
- /* separator... */
- label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- string = g_strdup_printf ("<b>%s</b>", _("Sequential editing:"));
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_misc_set_padding (GTK_MISC (label), 2, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Off"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Horizontal"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Vertical"));
-
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), eprop_data->sequence);
-
- gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
-
- g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (glade_eprop_model_sequence_changed),
- eprop_data);
-
-
- /* Pack treeview/swindow on the left... */
- swin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin), GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
- gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
-
- eprop_data->view = (GtkTreeView *)gtk_tree_view_new ();
-
- g_signal_connect (eprop_data->view, "key-press-event",
- G_CALLBACK (eprop_treeview_key_press),
- eprop);
-
- gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (eprop_data->view), GTK_TREE_VIEW_GRID_LINES_BOTH);
- gtk_tree_view_set_reorderable (GTK_TREE_VIEW (eprop_data->view), TRUE);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (eprop_data->view), TRUE);
- gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_data->view));
-
- g_object_set (G_OBJECT (vbox), "height-request", 300, NULL);
-
- gtk_widget_show_all (vbox);
- return vbox;
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GtkWidget *vbox, *hbox, *button, *swin, *label, *combo;
+ gchar *string;
+
+ vbox = gtk_vbox_new (FALSE, 2);
+
+ hbox = gtk_hbox_new (FALSE, 4);
+
+ eprop_data->sequence = SEQ_NONE;
+
+ /* hbox with add/remove row buttons on the right... */
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+ string = g_strdup_printf ("<b>%s</b>", _("Add and remove rows:"));
+ label = gtk_label_new (string);
+ g_free (string);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label), 2, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_ADD,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_model_data_add_clicked),
+ eprop_data);
+
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_REMOVE,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (glade_eprop_model_data_delete_clicked),
+ eprop_data);
+
+ /* separator... */
+ label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ string = g_strdup_printf ("<b>%s</b>", _("Sequential editing:"));
+ label = gtk_label_new (string);
+ g_free (string);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label), 2, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Off"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Horizontal"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Vertical"));
+
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), eprop_data->sequence);
+
+ gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
+
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (glade_eprop_model_sequence_changed),
+ eprop_data);
+
+
+ /* Pack treeview/swindow on the left... */
+ swin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
+
+ eprop_data->view = (GtkTreeView *) gtk_tree_view_new ();
+
+ g_signal_connect (eprop_data->view, "key-press-event",
+ G_CALLBACK (eprop_treeview_key_press), eprop);
+
+ gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (eprop_data->view),
+ GTK_TREE_VIEW_GRID_LINES_BOTH);
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (eprop_data->view), TRUE);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (eprop_data->view), TRUE);
+ gtk_container_add (GTK_CONTAINER (swin), GTK_WIDGET (eprop_data->view));
+
+ g_object_set (G_OBJECT (vbox), "height-request", 300, NULL);
+
+ gtk_widget_show_all (vbox);
+ return vbox;
}
diff --git a/plugins/gtk+/glade-model-data.h b/plugins/gtk+/glade-model-data.h
index 63b6f40..b2add4a 100644
--- a/plugins/gtk+/glade-model-data.h
+++ b/plugins/gtk+/glade-model-data.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-store-editor.c b/plugins/gtk+/glade-store-editor.c
index 1c601cd..6f6675a 100644
--- a/plugins/gtk+/glade-store-editor.c
+++ b/plugins/gtk+/glade-store-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,11 +27,11 @@
#include "glade-store-editor.h"
-static void glade_store_editor_finalize (GObject *object);
+static void glade_store_editor_finalize (GObject * object);
-static void glade_store_editor_editable_init (GladeEditableIface *iface);
+static void glade_store_editor_editable_init (GladeEditableIface * iface);
-static void glade_store_editor_grab_focus (GtkWidget *widget);
+static void glade_store_editor_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeStoreEditor, glade_store_editor, GTK_TYPE_VBOX,
@@ -41,198 +40,206 @@ G_DEFINE_TYPE_WITH_CODE (GladeStoreEditor, glade_store_editor, GTK_TYPE_VBOX,
static void
-glade_store_editor_class_init (GladeStoreEditorClass *klass)
+glade_store_editor_class_init (GladeStoreEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_store_editor_finalize;
- widget_class->grab_focus = glade_store_editor_grab_focus;
+ object_class->finalize = glade_store_editor_finalize;
+ widget_class->grab_focus = glade_store_editor_grab_focus;
}
static void
-glade_store_editor_init (GladeStoreEditor *self)
+glade_store_editor_init (GladeStoreEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeStoreEditor *store_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeStoreEditor * store_editor)
{
- if (!gtk_widget_get_mapped (GTK_WIDGET (store_editor)))
- return;
+ if (!gtk_widget_get_mapped (GTK_WIDGET (store_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (store_editor), store_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (store_editor),
+ store_editor->loaded_widget);
}
static void
-project_finalized (GladeStoreEditor *store_editor,
- GladeProject *where_project_was)
+project_finalized (GladeStoreEditor * store_editor,
+ GladeProject * where_project_was)
{
- store_editor->loaded_widget = NULL;
+ store_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (store_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (store_editor), NULL);
}
static void
-glade_store_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_store_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (editable);
- GList *l;
-
- /* Since we watch the project*/
- if (store_editor->loaded_widget)
- {
- /* watch custom-child and use-stock properties here for reloads !!! */
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (store_editor->loaded_widget->project),
- G_CALLBACK (project_changed), store_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (store_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- store_editor);
- }
-
- /* Mark our widget... */
- store_editor->loaded_widget = widget;
-
- if (store_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (store_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), store_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (store_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- store_editor);
- }
-
- /* load the embedded editable... */
- if (store_editor->embed)
- glade_editable_load (GLADE_EDITABLE (store_editor->embed), widget);
-
- for (l = store_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
+ GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (editable);
+ GList *l;
+
+ /* Since we watch the project */
+ if (store_editor->loaded_widget)
+ {
+ /* watch custom-child and use-stock properties here for reloads !!! */
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (store_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ store_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (store_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, store_editor);
+ }
+
+ /* Mark our widget... */
+ store_editor->loaded_widget = widget;
+
+ if (store_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (store_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), store_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (store_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, store_editor);
+ }
+
+ /* load the embedded editable... */
+ if (store_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (store_editor->embed), widget);
+
+ for (l = store_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
}
static void
-glade_store_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_store_editor_set_show_name (GladeEditable * editable, gboolean show_name)
{
- GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (editable);
+ GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (store_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (store_editor->embed),
+ show_name);
}
static void
-glade_store_editor_editable_init (GladeEditableIface *iface)
+glade_store_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_store_editor_load;
- iface->set_show_name = glade_store_editor_set_show_name;
+ iface->load = glade_store_editor_load;
+ iface->set_show_name = glade_store_editor_set_show_name;
}
static void
-glade_store_editor_finalize (GObject *object)
+glade_store_editor_finalize (GObject * object)
{
- GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (object);
+ GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (object);
- if (store_editor->properties)
- g_list_free (store_editor->properties);
- store_editor->properties = NULL;
- store_editor->embed = NULL;
+ if (store_editor->properties)
+ g_list_free (store_editor->properties);
+ store_editor->properties = NULL;
+ store_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_store_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_store_editor_parent_class)->finalize (object);
}
static void
-glade_store_editor_grab_focus (GtkWidget *widget)
+glade_store_editor_grab_focus (GtkWidget * widget)
{
- GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (widget);
+ GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (widget);
- gtk_widget_grab_focus (store_editor->embed);
+ gtk_widget_grab_focus (store_editor->embed);
}
GtkWidget *
-glade_store_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_store_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed)
{
- GladeStoreEditor *store_editor;
- GladeEditorProperty *eprop;
- GtkWidget *frame, *alignment, *label, *vbox;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- /* Pack the parent on top... */
- store_editor = g_object_new (GLADE_TYPE_STORE_EDITOR, NULL);
- store_editor->embed = GTK_WIDGET (embed);
- gtk_box_pack_start (GTK_BOX (store_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- /* -------------- The columns area here -------------- */
- /* Label item in frame label widget on top.. */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "columns", FALSE, TRUE);
- store_editor->properties = g_list_prepend (store_editor->properties, eprop);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (store_editor), frame, FALSE, FALSE, 12);
-
- /* Alignment/Vbox in frame... */
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (alignment), vbox);
-
- /* Add descriptive label */
- label = gtk_label_new (_("Define columns for your liststore; "
- "giving them meaningful names will help you to retrieve "
- "them when setting cell renderer attributes (press the "
- "Delete key to remove the selected column)"));
- gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
- gtk_label_set_line_wrap_mode (GTK_LABEL(label), PANGO_WRAP_WORD);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
-
-
- if (adaptor->type == GTK_TYPE_LIST_STORE ||
- g_type_is_a (adaptor->type, GTK_TYPE_LIST_STORE))
- {
- /* -------------- The data area here -------------- */
- /* Label item in frame label widget on top.. */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "data", FALSE, TRUE);
- store_editor->properties = g_list_prepend (store_editor->properties, eprop);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (store_editor), frame, FALSE, FALSE, 12);
-
- /* Alignment/Vbox in frame... */
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (alignment), vbox);
-
- /* Add descriptive label */
- label = gtk_label_new (_("Add remove and edit rows of data (you can optionally use Ctrl+N to add "
- "new rows and the Delete key to remove the selected row)"));
- gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
- gtk_label_set_line_wrap_mode (GTK_LABEL(label), PANGO_WRAP_WORD);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
- }
-
- gtk_widget_show_all (GTK_WIDGET (store_editor));
-
- return GTK_WIDGET (store_editor);
+ GladeStoreEditor *store_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *frame, *alignment, *label, *vbox;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ /* Pack the parent on top... */
+ store_editor = g_object_new (GLADE_TYPE_STORE_EDITOR, NULL);
+ store_editor->embed = GTK_WIDGET (embed);
+ gtk_box_pack_start (GTK_BOX (store_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
+
+ /* -------------- The columns area here -------------- */
+ /* Label item in frame label widget on top.. */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "columns", FALSE,
+ TRUE);
+ store_editor->properties = g_list_prepend (store_editor->properties, eprop);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (store_editor), frame, FALSE, FALSE, 12);
+
+ /* Alignment/Vbox in frame... */
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+ /* Add descriptive label */
+ label = gtk_label_new (_("Define columns for your liststore; "
+ "giving them meaningful names will help you to retrieve "
+ "them when setting cell renderer attributes (press the "
+ "Delete key to remove the selected column)"));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
+
+
+ if (adaptor->type == GTK_TYPE_LIST_STORE ||
+ g_type_is_a (adaptor->type, GTK_TYPE_LIST_STORE))
+ {
+ /* -------------- The data area here -------------- */
+ /* Label item in frame label widget on top.. */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "data", FALSE,
+ TRUE);
+ store_editor->properties =
+ g_list_prepend (store_editor->properties, eprop);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (store_editor), frame, FALSE, FALSE, 12);
+
+ /* Alignment/Vbox in frame... */
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+ /* Add descriptive label */
+ label =
+ gtk_label_new (_
+ ("Add remove and edit rows of data (you can optionally use Ctrl+N to add "
+ "new rows and the Delete key to remove the selected row)"));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
+ }
+
+ gtk_widget_show_all (GTK_WIDGET (store_editor));
+
+ return GTK_WIDGET (store_editor);
}
diff --git a/plugins/gtk+/glade-store-editor.h b/plugins/gtk+/glade-store-editor.h
index 6e9d4ee..a6425b2 100644
--- a/plugins/gtk+/glade-store-editor.h
+++ b/plugins/gtk+/glade-store-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-text-button.c b/plugins/gtk+/glade-text-button.c
index 0961c05..79308c2 100644
--- a/plugins/gtk+/glade-text-button.c
+++ b/plugins/gtk+/glade-text-button.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -32,14 +31,14 @@
typedef struct
{
- gchar *button_text;
+ gchar *button_text;
} GladeTextButtonPrivate;
-static void glade_text_button_finalize (GObject *object);
+static void glade_text_button_finalize (GObject * object);
-static void glade_text_button_cell_editable_init (GtkCellEditableIface *iface);
+static void glade_text_button_cell_editable_init (GtkCellEditableIface * iface);
-static void glade_text_button_grab_focus (GtkWidget *widget);
+static void glade_text_button_grab_focus (GtkWidget * widget);
G_DEFINE_TYPE_WITH_CODE (GladeTextButton, glade_text_button, GTK_TYPE_ALIGNMENT,
@@ -48,114 +47,112 @@ G_DEFINE_TYPE_WITH_CODE (GladeTextButton, glade_text_button, GTK_TYPE_ALIGNMENT,
static void
-glade_text_button_class_init (GladeTextButtonClass *klass)
+glade_text_button_class_init (GladeTextButtonClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_text_button_finalize;
- widget_class->grab_focus = glade_text_button_grab_focus;
+ object_class->finalize = glade_text_button_finalize;
+ widget_class->grab_focus = glade_text_button_grab_focus;
- g_type_class_add_private (object_class, sizeof (GladeTextButtonPrivate));
+ g_type_class_add_private (object_class, sizeof (GladeTextButtonPrivate));
}
static void
-glade_text_button_init (GladeTextButton *self)
+glade_text_button_init (GladeTextButton * self)
{
- GtkWidget *image;
-
- gtk_alignment_set_padding (GTK_ALIGNMENT (self), 1, 1, 2, 2);
-
- self->hbox = gtk_hbox_new (FALSE, 2);
-
- gtk_container_add (GTK_CONTAINER (self), self->hbox);
-
- self->entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (self->hbox), self->entry, TRUE, TRUE, 0);
-
- self->button = gtk_button_new ();
- gtk_box_pack_start (GTK_BOX (self->hbox), self->button, FALSE, FALSE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_EDIT,
- GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
- gtk_container_add (GTK_CONTAINER (self->button), image);
+ GtkWidget *image;
+
+ gtk_alignment_set_padding (GTK_ALIGNMENT (self), 1, 1, 2, 2);
+
+ self->hbox = gtk_hbox_new (FALSE, 2);
+
+ gtk_container_add (GTK_CONTAINER (self), self->hbox);
+
+ self->entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (self->hbox), self->entry, TRUE, TRUE, 0);
+
+ self->button = gtk_button_new ();
+ gtk_box_pack_start (GTK_BOX (self->hbox), self->button, FALSE, FALSE, 0);
+
+ image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (self->button), image);
}
static void
-glade_text_button_clicked (GtkWidget *widget,
- GladeTextButton *button)
+glade_text_button_clicked (GtkWidget * widget, GladeTextButton * button)
{
- gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
- gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
}
/* GtkCellEditable method implementations
*/
static void
-glade_text_button_entry_activated (GtkEntry *entry, GladeTextButton *button)
+glade_text_button_entry_activated (GtkEntry * entry, GladeTextButton * button)
{
- gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
- gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
}
static gboolean
-glade_text_button_key_press_event (GtkEntry *entry,
- GdkEventKey *key_event,
- GladeTextButton *button)
+glade_text_button_key_press_event (GtkEntry * entry,
+ GdkEventKey * key_event,
+ GladeTextButton * button)
{
- if (key_event->keyval == GDK_KEY_Escape)
- {
- g_object_get (entry,
- "editing-canceled", TRUE,
- NULL);
- gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
- gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
-
- return TRUE;
- }
-
- /* override focus */
- if (key_event->keyval == GDK_KEY_Up || key_event->keyval == GDK_KEY_Down)
- {
- gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
- gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
- return TRUE;
- }
- return FALSE;
+ if (key_event->keyval == GDK_KEY_Escape)
+ {
+ g_object_get (entry, "editing-canceled", TRUE, NULL);
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+
+ return TRUE;
+ }
+
+ /* override focus */
+ if (key_event->keyval == GDK_KEY_Up || key_event->keyval == GDK_KEY_Down)
+ {
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+ return TRUE;
+ }
+ return FALSE;
}
static void
-glade_text_button_start_editing (GtkCellEditable *cell_editable,
- GdkEvent *event)
+glade_text_button_start_editing (GtkCellEditable * cell_editable,
+ GdkEvent * event)
{
- g_signal_connect (GLADE_TEXT_BUTTON (cell_editable)->button, "clicked",
- G_CALLBACK (glade_text_button_clicked), cell_editable);
- g_signal_connect (GLADE_TEXT_BUTTON (cell_editable)->entry, "activate",
- G_CALLBACK (glade_text_button_entry_activated), cell_editable);
- g_signal_connect (cell_editable, "key-press-event",
- G_CALLBACK (glade_text_button_key_press_event), cell_editable);
+ g_signal_connect (GLADE_TEXT_BUTTON (cell_editable)->button, "clicked",
+ G_CALLBACK (glade_text_button_clicked), cell_editable);
+ g_signal_connect (GLADE_TEXT_BUTTON (cell_editable)->entry, "activate",
+ G_CALLBACK (glade_text_button_entry_activated),
+ cell_editable);
+ g_signal_connect (cell_editable, "key-press-event",
+ G_CALLBACK (glade_text_button_key_press_event),
+ cell_editable);
}
static void
-glade_text_button_cell_editable_init (GtkCellEditableIface *iface)
+glade_text_button_cell_editable_init (GtkCellEditableIface * iface)
{
- iface->start_editing = glade_text_button_start_editing;
+ iface->start_editing = glade_text_button_start_editing;
}
static void
-glade_text_button_finalize (GObject *object)
+glade_text_button_finalize (GObject * object)
{
- G_OBJECT_CLASS (glade_text_button_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_text_button_parent_class)->finalize (object);
}
static void
-glade_text_button_grab_focus (GtkWidget *widget)
+glade_text_button_grab_focus (GtkWidget * widget)
{
- GladeTextButton *text_button = GLADE_TEXT_BUTTON (widget);
+ GladeTextButton *text_button = GLADE_TEXT_BUTTON (widget);
- gtk_widget_grab_focus (text_button->entry);
+ gtk_widget_grab_focus (text_button->entry);
}
/**
@@ -169,5 +166,5 @@ glade_text_button_grab_focus (GtkWidget *widget)
GtkWidget *
glade_text_button_new (void)
{
- return g_object_new (GLADE_TYPE_TEXT_BUTTON, NULL);
+ return g_object_new (GLADE_TYPE_TEXT_BUTTON, NULL);
}
diff --git a/plugins/gtk+/glade-text-button.h b/plugins/gtk+/glade-text-button.h
index eb69c35..20d500c 100644
--- a/plugins/gtk+/glade-text-button.h
+++ b/plugins/gtk+/glade-text-button.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-tool-button-editor.c b/plugins/gtk+/glade-tool-button-editor.c
index fa71a53..eab6c9d 100644
--- a/plugins/gtk+/glade-tool-button-editor.c
+++ b/plugins/gtk+/glade-tool-button-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -28,489 +27,528 @@
#include "glade-tool-button-editor.h"
-static void glade_tool_button_editor_finalize (GObject *object);
+static void glade_tool_button_editor_finalize (GObject * object);
-static void glade_tool_button_editor_editable_init (GladeEditableIface *iface);
+static void glade_tool_button_editor_editable_init (GladeEditableIface * iface);
-static void glade_tool_button_editor_grab_focus (GtkWidget *widget);
+static void glade_tool_button_editor_grab_focus (GtkWidget * widget);
-G_DEFINE_TYPE_WITH_CODE (GladeToolButtonEditor, glade_tool_button_editor, GTK_TYPE_VBOX,
+G_DEFINE_TYPE_WITH_CODE (GladeToolButtonEditor, glade_tool_button_editor,
+ GTK_TYPE_VBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_tool_button_editor_editable_init));
static void
-glade_tool_button_editor_class_init (GladeToolButtonEditorClass *klass)
+glade_tool_button_editor_class_init (GladeToolButtonEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_tool_button_editor_finalize;
- widget_class->grab_focus = glade_tool_button_editor_grab_focus;
+ object_class->finalize = glade_tool_button_editor_finalize;
+ widget_class->grab_focus = glade_tool_button_editor_grab_focus;
}
static void
-glade_tool_button_editor_init (GladeToolButtonEditor *self)
+glade_tool_button_editor_init (GladeToolButtonEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeToolButtonEditor *button_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeToolButtonEditor * button_editor)
{
- if (button_editor->modifying ||
- !gtk_widget_get_mapped (GTK_WIDGET (button_editor)))
- return;
+ if (button_editor->modifying ||
+ !gtk_widget_get_mapped (GTK_WIDGET (button_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (button_editor), button_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-project_finalized (GladeToolButtonEditor *button_editor,
- GladeProject *where_project_was)
+project_finalized (GladeToolButtonEditor * button_editor,
+ GladeProject * where_project_was)
{
- button_editor->loaded_widget = NULL;
+ button_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (button_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (button_editor), NULL);
}
static void
-glade_tool_button_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_tool_button_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (editable);
- gboolean custom_label = FALSE, use_appearance = FALSE;
- GladeToolButtonImageMode image_mode = 0;
- GList *l;
-
- button_editor->loading = TRUE;
-
- /* Since we watch the project*/
- if (button_editor->loaded_widget)
- {
- g_signal_handlers_disconnect_by_func (G_OBJECT (button_editor->loaded_widget->project),
- G_CALLBACK (project_changed), button_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (button_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- button_editor);
- }
-
- /* Mark our widget... */
- button_editor->loaded_widget = widget;
-
- if (button_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (button_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), button_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (button_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- button_editor);
- }
-
- /* load the embedded editable... */
- if (button_editor->embed)
- glade_editable_load (GLADE_EDITABLE (button_editor->embed), widget);
-
- for (l = button_editor->properties; l; l = l->next)
- glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
-
- if (widget)
- {
- glade_widget_property_get (widget, "image-mode", &image_mode);
- glade_widget_property_get (widget, "custom-label", &custom_label);
- glade_widget_property_get (widget, "use-action-appearance", &use_appearance);
-
- if (custom_label)
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (button_editor->custom_label_radio), TRUE);
- else
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (button_editor->standard_label_radio), TRUE);
-
- switch (image_mode)
- {
- case GLADE_TB_MODE_STOCK:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->stock_radio), TRUE);
- break;
- case GLADE_TB_MODE_ICON:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->icon_radio), TRUE);
- break;
- case GLADE_TB_MODE_CUSTOM:
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_editor->custom_radio), TRUE);
- break;
- default:
- break;
- }
-
- if (use_appearance)
- {
- gtk_widget_set_sensitive (button_editor->label_table, FALSE);
- gtk_widget_set_sensitive (button_editor->image_table, FALSE);
- }
- else
- {
- gtk_widget_set_sensitive (button_editor->label_table, TRUE);
- gtk_widget_set_sensitive (button_editor->image_table, TRUE);
- }
- }
- button_editor->loading = FALSE;
+ GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (editable);
+ gboolean custom_label = FALSE, use_appearance = FALSE;
+ GladeToolButtonImageMode image_mode = 0;
+ GList *l;
+
+ button_editor->loading = TRUE;
+
+ /* Since we watch the project */
+ if (button_editor->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (button_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ button_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (button_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, button_editor);
+ }
+
+ /* Mark our widget... */
+ button_editor->loaded_widget = widget;
+
+ if (button_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (button_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), button_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (button_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, button_editor);
+ }
+
+ /* load the embedded editable... */
+ if (button_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (button_editor->embed), widget);
+
+ for (l = button_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data),
+ widget);
+
+ if (widget)
+ {
+ glade_widget_property_get (widget, "image-mode", &image_mode);
+ glade_widget_property_get (widget, "custom-label", &custom_label);
+ glade_widget_property_get (widget, "use-action-appearance",
+ &use_appearance);
+
+ if (custom_label)
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (button_editor->custom_label_radio), TRUE);
+ else
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (button_editor->standard_label_radio), TRUE);
+
+ switch (image_mode)
+ {
+ case GLADE_TB_MODE_STOCK:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->stock_radio), TRUE);
+ break;
+ case GLADE_TB_MODE_ICON:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->icon_radio), TRUE);
+ break;
+ case GLADE_TB_MODE_CUSTOM:
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (button_editor->custom_radio), TRUE);
+ break;
+ default:
+ break;
+ }
+
+ if (use_appearance)
+ {
+ gtk_widget_set_sensitive (button_editor->label_table, FALSE);
+ gtk_widget_set_sensitive (button_editor->image_table, FALSE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (button_editor->label_table, TRUE);
+ gtk_widget_set_sensitive (button_editor->image_table, TRUE);
+ }
+ }
+ button_editor->loading = FALSE;
}
static void
-standard_label_toggled (GtkWidget *widget,
- GladeToolButtonEditor *button_editor)
+standard_label_toggled (GtkWidget * widget,
+ GladeToolButtonEditor * button_editor)
{
- GladeProperty *property;
- GValue value = { 0, };
+ GladeProperty *property;
+ GValue value = { 0, };
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->standard_label_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->standard_label_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use standard label text"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use standard label text"),
+ button_editor->loaded_widget->name);
- property = glade_widget_get_property (button_editor->loaded_widget, "label-widget");
- glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "label-widget");
+ glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "label");
- glade_property_get_default (property, &value);
- glade_command_set_property_value (property, &value);
- g_value_unset (&value);
- property = glade_widget_get_property (button_editor->loaded_widget, "custom-label");
- glade_command_set_property (property, FALSE);
+ property = glade_widget_get_property (button_editor->loaded_widget, "label");
+ glade_property_get_default (property, &value);
+ glade_command_set_property_value (property, &value);
+ g_value_unset (&value);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "custom-label");
+ glade_command_set_property (property, FALSE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-custom_label_toggled (GtkWidget *widget,
- GladeToolButtonEditor *button_editor)
+custom_label_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->custom_label_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->custom_label_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use a custom label widget"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use a custom label widget"),
+ button_editor->loaded_widget->name);
- property = glade_widget_get_property (button_editor->loaded_widget, "label");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "custom-label");
- glade_command_set_property (property, TRUE);
+ property = glade_widget_get_property (button_editor->loaded_widget, "label");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "custom-label");
+ glade_command_set_property (property, TRUE);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-stock_toggled (GtkWidget *widget,
- GladeToolButtonEditor *button_editor)
+stock_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->stock_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->stock_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an image from stock"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use an image from stock"),
+ button_editor->loaded_widget->name);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon-name");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon-widget");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "image-mode");
- glade_command_set_property (property, GLADE_TB_MODE_STOCK);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "icon-name");
+ glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "icon");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "icon-widget");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "image-mode");
+ glade_command_set_property (property, GLADE_TB_MODE_STOCK);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-icon_toggled (GtkWidget *widget,
- GladeToolButtonEditor *button_editor)
+icon_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->icon_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->icon_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an image from the icon theme"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use an image from the icon theme"),
+ button_editor->loaded_widget->name);
- property = glade_widget_get_property (button_editor->loaded_widget, "stock-id");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon-widget");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "image-mode");
- glade_command_set_property (property, GLADE_TB_MODE_ICON);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "stock-id");
+ glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "icon");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "icon-widget");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "image-mode");
+ glade_command_set_property (property, GLADE_TB_MODE_ICON);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-custom_toggled (GtkWidget *widget,
- GladeToolButtonEditor *button_editor)
+custom_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor)
{
- GladeProperty *property;
+ GladeProperty *property;
- if (button_editor->loading || !button_editor->loaded_widget)
- return;
+ if (button_editor->loading || !button_editor->loaded_widget)
+ return;
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_editor->custom_radio)))
- return;
+ if (!gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (button_editor->custom_radio)))
+ return;
- button_editor->modifying = TRUE;
+ button_editor->modifying = TRUE;
- glade_command_push_group (_("Setting %s to use an image from the icon theme"), button_editor->loaded_widget->name);
+ glade_command_push_group (_("Setting %s to use an image from the icon theme"),
+ button_editor->loaded_widget->name);
- property = glade_widget_get_property (button_editor->loaded_widget, "stock-id");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon-name");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "icon");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (button_editor->loaded_widget, "image-mode");
- glade_command_set_property (property, GLADE_TB_MODE_CUSTOM);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "stock-id");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "icon-name");
+ glade_command_set_property (property, NULL);
+ property = glade_widget_get_property (button_editor->loaded_widget, "icon");
+ glade_command_set_property (property, NULL);
+ property =
+ glade_widget_get_property (button_editor->loaded_widget, "image-mode");
+ glade_command_set_property (property, GLADE_TB_MODE_CUSTOM);
- glade_command_pop_group ();
+ glade_command_pop_group ();
- button_editor->modifying = FALSE;
+ button_editor->modifying = FALSE;
- /* reload buttons and sensitivity and stuff... */
- glade_editable_load (GLADE_EDITABLE (button_editor),
- button_editor->loaded_widget);
+ /* reload buttons and sensitivity and stuff... */
+ glade_editable_load (GLADE_EDITABLE (button_editor),
+ button_editor->loaded_widget);
}
static void
-glade_tool_button_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_tool_button_editor_set_show_name (GladeEditable * editable,
+ gboolean show_name)
{
- GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (editable);
+ GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (button_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (button_editor->embed),
+ show_name);
}
static void
-glade_tool_button_editor_editable_init (GladeEditableIface *iface)
+glade_tool_button_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_tool_button_editor_load;
- iface->set_show_name = glade_tool_button_editor_set_show_name;
+ iface->load = glade_tool_button_editor_load;
+ iface->set_show_name = glade_tool_button_editor_set_show_name;
}
static void
-glade_tool_button_editor_finalize (GObject *object)
+glade_tool_button_editor_finalize (GObject * object)
{
- GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (object);
+ GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (object);
- if (button_editor->properties)
- g_list_free (button_editor->properties);
- button_editor->properties = NULL;
- button_editor->embed = NULL;
+ if (button_editor->properties)
+ g_list_free (button_editor->properties);
+ button_editor->properties = NULL;
+ button_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_tool_button_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_tool_button_editor_parent_class)->finalize (object);
}
static void
-glade_tool_button_editor_grab_focus (GtkWidget *widget)
+glade_tool_button_editor_grab_focus (GtkWidget * widget)
{
- GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (widget);
+ GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (widget);
- gtk_widget_grab_focus (button_editor->embed);
+ gtk_widget_grab_focus (button_editor->embed);
}
static void
-table_attach (GtkWidget *table,
- GtkWidget *child,
- gint pos, gint row)
+table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row)
{
- gtk_grid_attach (GTK_GRID (table), child,
- pos, row, 1, 1);
+ gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1);
- if (pos)
- gtk_widget_set_hexpand (child, TRUE);
+ if (pos)
+ gtk_widget_set_hexpand (child, TRUE);
}
GtkWidget *
-glade_tool_button_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_tool_button_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditable * embed)
{
- GladeToolButtonEditor *button_editor;
- GladeEditorProperty *eprop;
- GtkWidget *label, *alignment, *frame, *table, *hbox;
- gchar *str;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- button_editor = g_object_new (GLADE_TYPE_TOOL_BUTTON_EDITOR, NULL);
- button_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on top... */
- gtk_box_pack_start (GTK_BOX (button_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
-
- /* Label area frame... */
- str = g_strdup_printf ("<b>%s</b>", _("Edit Label"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (button_editor), frame, FALSE, FALSE, 12);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- button_editor->label_table = table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
-
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Standard label... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- button_editor->standard_label_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), button_editor->standard_label_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Custom label... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "label-widget", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- button_editor->custom_label_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (button_editor->standard_label_radio));
- gtk_box_pack_start (GTK_BOX (hbox), button_editor->custom_label_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Image area frame... */
- str = g_strdup_printf ("<b>%s</b>", _("Edit Image"));
- label = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- g_free (str);
- frame = gtk_frame_new (NULL);
- gtk_frame_set_label_widget (GTK_FRAME (frame), label);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (button_editor), frame, FALSE, FALSE, 8);
-
- alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
- gtk_container_add (GTK_CONTAINER (frame), alignment);
-
- button_editor->image_table = table = gtk_grid_new ();
- gtk_orientable_set_orientation (GTK_ORIENTABLE (table), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_row_spacing (GTK_GRID (table), 4);
-
- gtk_container_add (GTK_CONTAINER (alignment), table);
-
- /* Stock image... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "stock-id", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- button_editor->stock_radio = gtk_radio_button_new (NULL);
- gtk_box_pack_start (GTK_BOX (hbox), button_editor->stock_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 0);
- table_attach (table, GTK_WIDGET (eprop), 1, 0);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Icon theme image... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-name", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- button_editor->icon_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (button_editor->stock_radio));
- gtk_box_pack_start (GTK_BOX (hbox), button_editor->icon_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 1);
- table_attach (table, GTK_WIDGET (eprop), 1, 1);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Custom embedded image widget... */
- eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-widget", FALSE, TRUE);
- hbox = gtk_hbox_new (FALSE, 0);
- button_editor->custom_radio = gtk_radio_button_new_from_widget
- (GTK_RADIO_BUTTON (button_editor->stock_radio));
- gtk_box_pack_start (GTK_BOX (hbox), button_editor->custom_radio, FALSE, FALSE, 2);
- gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
- table_attach (table, hbox, 0, 2);
- table_attach (table, GTK_WIDGET (eprop), 1, 2);
- button_editor->properties = g_list_prepend (button_editor->properties, eprop);
-
- /* Connect radio button signals... */
- g_signal_connect (G_OBJECT (button_editor->standard_label_radio), "toggled",
- G_CALLBACK (standard_label_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->custom_label_radio), "toggled",
- G_CALLBACK (custom_label_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->stock_radio), "toggled",
- G_CALLBACK (stock_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->icon_radio), "toggled",
- G_CALLBACK (icon_toggled), button_editor);
- g_signal_connect (G_OBJECT (button_editor->custom_radio), "toggled",
- G_CALLBACK (custom_toggled), button_editor);
-
- gtk_widget_show_all (GTK_WIDGET (button_editor));
-
- return GTK_WIDGET (button_editor);
+ GladeToolButtonEditor *button_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *label, *alignment, *frame, *table, *hbox;
+ gchar *str;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ button_editor = g_object_new (GLADE_TYPE_TOOL_BUTTON_EDITOR, NULL);
+ button_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (button_editor), GTK_WIDGET (embed), FALSE, FALSE,
+ 0);
+
+ /* Label area frame... */
+ str = g_strdup_printf ("<b>%s</b>", _("Edit Label"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (button_editor), frame, FALSE, FALSE, 12);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ button_editor->label_table = table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Standard label... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "label", FALSE, TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ button_editor->standard_label_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), button_editor->standard_label_radio,
+ FALSE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Custom label... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "label-widget", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ button_editor->custom_label_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (button_editor->standard_label_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), button_editor->custom_label_radio, FALSE,
+ FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Image area frame... */
+ str = g_strdup_printf ("<b>%s</b>", _("Edit Image"));
+ label = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ g_free (str);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (button_editor), frame, FALSE, FALSE, 8);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ button_editor->image_table = table = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (table),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 4);
+
+ gtk_container_add (GTK_CONTAINER (alignment), table);
+
+ /* Stock image... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "stock-id", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ button_editor->stock_radio = gtk_radio_button_new (NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), button_editor->stock_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 0);
+ table_attach (table, GTK_WIDGET (eprop), 1, 0);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Icon theme image... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-name", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ button_editor->icon_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (button_editor->stock_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), button_editor->icon_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 1);
+ table_attach (table, GTK_WIDGET (eprop), 1, 1);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Custom embedded image widget... */
+ eprop =
+ glade_widget_adaptor_create_eprop_by_name (adaptor, "icon-widget", FALSE,
+ TRUE);
+ hbox = gtk_hbox_new (FALSE, 0);
+ button_editor->custom_radio = gtk_radio_button_new_from_widget
+ (GTK_RADIO_BUTTON (button_editor->stock_radio));
+ gtk_box_pack_start (GTK_BOX (hbox), button_editor->custom_radio, FALSE, FALSE,
+ 2);
+ gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 2);
+ table_attach (table, hbox, 0, 2);
+ table_attach (table, GTK_WIDGET (eprop), 1, 2);
+ button_editor->properties = g_list_prepend (button_editor->properties, eprop);
+
+ /* Connect radio button signals... */
+ g_signal_connect (G_OBJECT (button_editor->standard_label_radio), "toggled",
+ G_CALLBACK (standard_label_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->custom_label_radio), "toggled",
+ G_CALLBACK (custom_label_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->stock_radio), "toggled",
+ G_CALLBACK (stock_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->icon_radio), "toggled",
+ G_CALLBACK (icon_toggled), button_editor);
+ g_signal_connect (G_OBJECT (button_editor->custom_radio), "toggled",
+ G_CALLBACK (custom_toggled), button_editor);
+
+ gtk_widget_show_all (GTK_WIDGET (button_editor));
+
+ return GTK_WIDGET (button_editor);
}
diff --git a/plugins/gtk+/glade-tool-button-editor.h b/plugins/gtk+/glade-tool-button-editor.h
index 21bc122..5ecdd1b 100644
--- a/plugins/gtk+/glade-tool-button-editor.h
+++ b/plugins/gtk+/glade-tool-button-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/gtk+/glade-treeview-editor.c b/plugins/gtk+/glade-treeview-editor.c
index cfcb96e..6bf3ed7 100644
--- a/plugins/gtk+/glade-treeview-editor.c
+++ b/plugins/gtk+/glade-treeview-editor.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
@@ -27,238 +26,257 @@
#include "glade-treeview-editor.h"
-static void glade_tree_view_editor_finalize (GObject *object);
+static void glade_tree_view_editor_finalize (GObject * object);
-static void glade_tree_view_editor_editable_init (GladeEditableIface *iface);
+static void glade_tree_view_editor_editable_init (GladeEditableIface * iface);
-static void glade_tree_view_editor_realize (GtkWidget *widget);
-static void glade_tree_view_editor_grab_focus (GtkWidget *widget);
+static void glade_tree_view_editor_realize (GtkWidget * widget);
+static void glade_tree_view_editor_grab_focus (GtkWidget * widget);
-G_DEFINE_TYPE_WITH_CODE (GladeTreeViewEditor, glade_tree_view_editor, GTK_TYPE_HBOX,
+G_DEFINE_TYPE_WITH_CODE (GladeTreeViewEditor, glade_tree_view_editor,
+ GTK_TYPE_HBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_tree_view_editor_editable_init));
static void
-glade_tree_view_editor_class_init (GladeTreeViewEditorClass *klass)
+glade_tree_view_editor_class_init (GladeTreeViewEditorClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = glade_tree_view_editor_finalize;
+ object_class->finalize = glade_tree_view_editor_finalize;
- widget_class->realize = glade_tree_view_editor_realize;
- widget_class->grab_focus = glade_tree_view_editor_grab_focus;
+ widget_class->realize = glade_tree_view_editor_realize;
+ widget_class->grab_focus = glade_tree_view_editor_grab_focus;
}
static void
-glade_tree_view_editor_init (GladeTreeViewEditor *self)
+glade_tree_view_editor_init (GladeTreeViewEditor * self)
{
}
static void
-project_changed (GladeProject *project,
- GladeCommand *command,
- gboolean execute,
- GladeTreeViewEditor *view_editor)
+project_changed (GladeProject * project,
+ GladeCommand * command,
+ gboolean execute, GladeTreeViewEditor * view_editor)
{
- if (!gtk_widget_get_mapped (GTK_WIDGET (view_editor)))
- return;
+ if (!gtk_widget_get_mapped (GTK_WIDGET (view_editor)))
+ return;
- /* Reload on all commands */
- glade_editable_load (GLADE_EDITABLE (view_editor), view_editor->loaded_widget);
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (view_editor),
+ view_editor->loaded_widget);
}
static void
-project_finalized (GladeTreeViewEditor *view_editor,
- GladeProject *where_project_was)
+project_finalized (GladeTreeViewEditor * view_editor,
+ GladeProject * where_project_was)
{
- view_editor->loaded_widget = NULL;
+ view_editor->loaded_widget = NULL;
- glade_editable_load (GLADE_EDITABLE (view_editor), NULL);
+ glade_editable_load (GLADE_EDITABLE (view_editor), NULL);
}
static GladeWidget *
-get_model_widget (GladeWidget *view)
+get_model_widget (GladeWidget * view)
{
- GtkTreeModel *model = NULL;
+ GtkTreeModel *model = NULL;
- if (GTK_IS_TREE_VIEW (view->object))
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (view->object));
- else if (GTK_IS_ICON_VIEW (view->object))
- model = gtk_icon_view_get_model (GTK_ICON_VIEW (view->object));
- else if (GTK_IS_COMBO_BOX (view->object))
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (view->object));
+ if (GTK_IS_TREE_VIEW (view->object))
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (view->object));
+ else if (GTK_IS_ICON_VIEW (view->object))
+ model = gtk_icon_view_get_model (GTK_ICON_VIEW (view->object));
+ else if (GTK_IS_COMBO_BOX (view->object))
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (view->object));
- if (model)
- return glade_widget_get_from_gobject (model);
-
- return NULL;
+ if (model)
+ return glade_widget_get_from_gobject (model);
+
+ return NULL;
}
static void
-glade_tree_view_editor_load (GladeEditable *editable,
- GladeWidget *widget)
+glade_tree_view_editor_load (GladeEditable * editable, GladeWidget * widget)
{
- GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable);
- GladeWidget *model_widget;
-
- /* Since we watch the project*/
- if (view_editor->loaded_widget)
- {
- g_signal_handlers_disconnect_by_func (G_OBJECT (view_editor->loaded_widget->project),
- G_CALLBACK (project_changed), view_editor);
-
- /* The widget could die unexpectedly... */
- g_object_weak_unref (G_OBJECT (view_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- view_editor);
- }
-
- /* Mark our widget... */
- view_editor->loaded_widget = widget;
-
- if (view_editor->loaded_widget)
- {
- /* This fires for undo/redo */
- g_signal_connect (G_OBJECT (view_editor->loaded_widget->project), "changed",
- G_CALLBACK (project_changed), view_editor);
-
- /* The widget/project could die unexpectedly... */
- g_object_weak_ref (G_OBJECT (view_editor->loaded_widget->project),
- (GWeakNotify)project_finalized,
- view_editor);
- }
-
- /* load the embedded editable... */
- if (view_editor->embed)
- glade_editable_load (GLADE_EDITABLE (view_editor->embed), widget);
-
- if (view_editor->embed_list_store && view_editor->embed_tree_store)
- {
- gtk_widget_hide (view_editor->no_model_message);
- gtk_widget_hide (view_editor->embed_list_store);
- gtk_widget_hide (view_editor->embed_tree_store);
- glade_editable_load (GLADE_EDITABLE (view_editor->embed_list_store), NULL);
- glade_editable_load (GLADE_EDITABLE (view_editor->embed_tree_store), NULL);
-
- /* Finalize safe code here... */
- if (widget && (model_widget = get_model_widget (widget)))
- {
- if (GTK_IS_LIST_STORE (model_widget->object))
- {
- gtk_widget_show (view_editor->embed_list_store);
- glade_editable_load (GLADE_EDITABLE (view_editor->embed_list_store), model_widget);
- }
- else if (GTK_IS_TREE_STORE (model_widget->object))
- {
- gtk_widget_show (view_editor->embed_tree_store);
- glade_editable_load (GLADE_EDITABLE (view_editor->embed_tree_store), model_widget);
- }
- else
- gtk_widget_show (view_editor->no_model_message);
- }
- else
- gtk_widget_show (view_editor->no_model_message);
- }
+ GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable);
+ GladeWidget *model_widget;
+
+ /* Since we watch the project */
+ if (view_editor->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT
+ (view_editor->loaded_widget->
+ project),
+ G_CALLBACK (project_changed),
+ view_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (view_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, view_editor);
+ }
+
+ /* Mark our widget... */
+ view_editor->loaded_widget = widget;
+
+ if (view_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (view_editor->loaded_widget->project),
+ "changed", G_CALLBACK (project_changed), view_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (view_editor->loaded_widget->project),
+ (GWeakNotify) project_finalized, view_editor);
+ }
+
+ /* load the embedded editable... */
+ if (view_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (view_editor->embed), widget);
+
+ if (view_editor->embed_list_store && view_editor->embed_tree_store)
+ {
+ gtk_widget_hide (view_editor->no_model_message);
+ gtk_widget_hide (view_editor->embed_list_store);
+ gtk_widget_hide (view_editor->embed_tree_store);
+ glade_editable_load (GLADE_EDITABLE (view_editor->embed_list_store),
+ NULL);
+ glade_editable_load (GLADE_EDITABLE (view_editor->embed_tree_store),
+ NULL);
+
+ /* Finalize safe code here... */
+ if (widget && (model_widget = get_model_widget (widget)))
+ {
+ if (GTK_IS_LIST_STORE (model_widget->object))
+ {
+ gtk_widget_show (view_editor->embed_list_store);
+ glade_editable_load (GLADE_EDITABLE
+ (view_editor->embed_list_store),
+ model_widget);
+ }
+ else if (GTK_IS_TREE_STORE (model_widget->object))
+ {
+ gtk_widget_show (view_editor->embed_tree_store);
+ glade_editable_load (GLADE_EDITABLE
+ (view_editor->embed_tree_store),
+ model_widget);
+ }
+ else
+ gtk_widget_show (view_editor->no_model_message);
+ }
+ else
+ gtk_widget_show (view_editor->no_model_message);
+ }
}
static void
-glade_tree_view_editor_set_show_name (GladeEditable *editable,
- gboolean show_name)
+glade_tree_view_editor_set_show_name (GladeEditable * editable,
+ gboolean show_name)
{
- GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable);
+ GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable);
- glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed), show_name);
+ glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed), show_name);
}
static void
-glade_tree_view_editor_editable_init (GladeEditableIface *iface)
+glade_tree_view_editor_editable_init (GladeEditableIface * iface)
{
- iface->load = glade_tree_view_editor_load;
- iface->set_show_name = glade_tree_view_editor_set_show_name;
+ iface->load = glade_tree_view_editor_load;
+ iface->set_show_name = glade_tree_view_editor_set_show_name;
}
static void
-glade_tree_view_editor_finalize (GObject *object)
+glade_tree_view_editor_finalize (GObject * object)
{
- GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (object);
+ GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (object);
- view_editor->embed_tree_store = NULL;
- view_editor->embed_list_store = NULL;
- view_editor->embed = NULL;
+ view_editor->embed_tree_store = NULL;
+ view_editor->embed_list_store = NULL;
+ view_editor->embed = NULL;
- glade_editable_load (GLADE_EDITABLE (object), NULL);
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
- G_OBJECT_CLASS (glade_tree_view_editor_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_tree_view_editor_parent_class)->finalize (object);
}
static void
-glade_tree_view_editor_realize (GtkWidget *widget)
+glade_tree_view_editor_realize (GtkWidget * widget)
{
- GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (widget);
+ GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (widget);
- GTK_WIDGET_CLASS (glade_tree_view_editor_parent_class)->realize (widget);
+ GTK_WIDGET_CLASS (glade_tree_view_editor_parent_class)->realize (widget);
- glade_editable_load (GLADE_EDITABLE (view_editor), view_editor->loaded_widget);
+ glade_editable_load (GLADE_EDITABLE (view_editor),
+ view_editor->loaded_widget);
}
static void
-glade_tree_view_editor_grab_focus (GtkWidget *widget)
+glade_tree_view_editor_grab_focus (GtkWidget * widget)
{
- GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (widget);
+ GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (widget);
- gtk_widget_grab_focus (view_editor->embed);
+ gtk_widget_grab_focus (view_editor->embed);
}
GtkWidget *
-glade_tree_view_editor_new (GladeWidgetAdaptor *adaptor,
- GladeEditable *embed)
+glade_tree_view_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed)
{
- GladeTreeViewEditor *view_editor;
- GtkWidget *vbox, *separator;
- gchar *str;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
-
- view_editor = g_object_new (GLADE_TYPE_TREE_VIEW_EDITOR, NULL);
- view_editor->embed = GTK_WIDGET (embed);
-
- /* Pack the parent on the left... */
- gtk_box_pack_start (GTK_BOX (view_editor), GTK_WIDGET (embed), TRUE, TRUE, 8);
-
- separator = gtk_vseparator_new ();
- gtk_box_pack_start (GTK_BOX (view_editor), separator, FALSE, FALSE, 0);
-
- /* ...and the vbox with datastore/label on the right */
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (view_editor), vbox, TRUE, TRUE, 8);
-
- str = g_strdup_printf ("<b>%s</b>", _("Choose a Data Model and define some\n"
- "columns in the data store first"));
- view_editor->no_model_message = gtk_label_new (str);
- gtk_label_set_use_markup (GTK_LABEL (view_editor->no_model_message), TRUE);
- gtk_label_set_justify (GTK_LABEL (view_editor->no_model_message), GTK_JUSTIFY_CENTER);
-
- g_free (str);
-
- gtk_box_pack_start (GTK_BOX (vbox), view_editor->no_model_message, TRUE, TRUE, 0);
-
- view_editor->embed_list_store = (GtkWidget *)glade_widget_adaptor_create_editable
- (glade_widget_adaptor_get_by_type (GTK_TYPE_LIST_STORE), GLADE_PAGE_GENERAL);
- glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed_list_store), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), view_editor->embed_list_store, TRUE, TRUE, 0);
-
- view_editor->embed_tree_store = (GtkWidget *)glade_widget_adaptor_create_editable
- (glade_widget_adaptor_get_by_type (GTK_TYPE_TREE_STORE), GLADE_PAGE_GENERAL);
- glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed_tree_store), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), view_editor->embed_tree_store, TRUE, TRUE, 0);
-
- gtk_widget_show_all (GTK_WIDGET (view_editor));
-
- return GTK_WIDGET (view_editor);
+ GladeTreeViewEditor *view_editor;
+ GtkWidget *vbox, *separator;
+ gchar *str;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ view_editor = g_object_new (GLADE_TYPE_TREE_VIEW_EDITOR, NULL);
+ view_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on the left... */
+ gtk_box_pack_start (GTK_BOX (view_editor), GTK_WIDGET (embed), TRUE, TRUE, 8);
+
+ separator = gtk_vseparator_new ();
+ gtk_box_pack_start (GTK_BOX (view_editor), separator, FALSE, FALSE, 0);
+
+ /* ...and the vbox with datastore/label on the right */
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (view_editor), vbox, TRUE, TRUE, 8);
+
+ str = g_strdup_printf ("<b>%s</b>", _("Choose a Data Model and define some\n"
+ "columns in the data store first"));
+ view_editor->no_model_message = gtk_label_new (str);
+ gtk_label_set_use_markup (GTK_LABEL (view_editor->no_model_message), TRUE);
+ gtk_label_set_justify (GTK_LABEL (view_editor->no_model_message),
+ GTK_JUSTIFY_CENTER);
+
+ g_free (str);
+
+ gtk_box_pack_start (GTK_BOX (vbox), view_editor->no_model_message, TRUE, TRUE,
+ 0);
+
+ view_editor->embed_list_store =
+ (GtkWidget *)
+ glade_widget_adaptor_create_editable (glade_widget_adaptor_get_by_type
+ (GTK_TYPE_LIST_STORE),
+ GLADE_PAGE_GENERAL);
+ glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed_list_store),
+ FALSE);
+ gtk_box_pack_start (GTK_BOX (vbox), view_editor->embed_list_store, TRUE, TRUE,
+ 0);
+
+ view_editor->embed_tree_store =
+ (GtkWidget *)
+ glade_widget_adaptor_create_editable (glade_widget_adaptor_get_by_type
+ (GTK_TYPE_TREE_STORE),
+ GLADE_PAGE_GENERAL);
+ glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed_tree_store),
+ FALSE);
+ gtk_box_pack_start (GTK_BOX (vbox), view_editor->embed_tree_store, TRUE, TRUE,
+ 0);
+
+ gtk_widget_show_all (GTK_WIDGET (view_editor));
+
+ return GTK_WIDGET (view_editor);
}
diff --git a/plugins/gtk+/glade-treeview-editor.h b/plugins/gtk+/glade-treeview-editor.h
index 569a2dc..cdc7bff 100644
--- a/plugins/gtk+/glade-treeview-editor.h
+++ b/plugins/gtk+/glade-treeview-editor.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
diff --git a/plugins/python/glade-python.c b/plugins/python/glade-python.c
index abfee38..d746730 100644
--- a/plugins/python/glade-python.c
+++ b/plugins/python/glade-python.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2006-2008 Juan Pablo Ugarte.
*
@@ -30,98 +29,101 @@
static void
python_init (void)
{
- char *argv[1];
-
- if (Py_IsInitialized ()) return;
+ char *argv[1];
- Py_InitializeEx (0);
+ if (Py_IsInitialized ())
+ return;
- argv[0] = g_get_prgname ();
-
- PySys_SetArgv (1, argv);
+ Py_InitializeEx (0);
+
+ argv[0] = g_get_prgname ();
+
+ PySys_SetArgv (1, argv);
}
static void
glade_python_init_pygtk_check (gint req_major, gint req_minor, gint req_micro)
{
- PyObject *gobject, *mdict, *version;
- int found_major, found_minor, found_micro;
-
- init_pygobject();
-
- gobject = PyImport_ImportModule("gobject");
- mdict = PyModule_GetDict(gobject);
- version = PyDict_GetItemString(mdict, "pygtk_version");
- if (!version)
- {
- PyErr_SetString(PyExc_ImportError, "PyGObject version too old");
- return;
- }
- if (!PyArg_ParseTuple(version, "iii", &found_major, &found_minor, &found_micro))
- return;
- if (req_major != found_major || req_minor > found_minor ||
- (req_minor == found_minor && req_micro > found_micro))
- {
- PyErr_Format(PyExc_ImportError,
- "PyGObject version mismatch, %d.%d.%d is required, "
- "found %d.%d.%d.", req_major, req_minor, req_micro,
- found_major, found_minor, found_micro);
- return;
- }
+ PyObject *gobject, *mdict, *version;
+ int found_major, found_minor, found_micro;
+
+ init_pygobject ();
+
+ gobject = PyImport_ImportModule ("gobject");
+ mdict = PyModule_GetDict (gobject);
+ version = PyDict_GetItemString (mdict, "pygtk_version");
+ if (!version)
+ {
+ PyErr_SetString (PyExc_ImportError, "PyGObject version too old");
+ return;
+ }
+ if (!PyArg_ParseTuple
+ (version, "iii", &found_major, &found_minor, &found_micro))
+ return;
+ if (req_major != found_major || req_minor > found_minor ||
+ (req_minor == found_minor && req_micro > found_micro))
+ {
+ PyErr_Format (PyExc_ImportError,
+ "PyGObject version mismatch, %d.%d.%d is required, "
+ "found %d.%d.%d.", req_major, req_minor, req_micro,
+ found_major, found_minor, found_micro);
+ return;
+ }
}
static void
glade_python_setup ()
{
- gchar *command;
-
- Py_SetProgramName (PACKAGE_NAME);
-
- /* Initialize the Python interpreter */
- python_init ();
-
- /* Check and init pygobject >= 2.12.0 */
- PyErr_Clear ();
- glade_python_init_pygtk_check (PYGTK_REQUIRED_MAJOR, PYGTK_REQUIRED_MINOR, PYGTK_REQUIRED_MICRO);
- if (PyErr_Occurred ())
- {
- PyObject *ptype, *pvalue, *ptraceback;
- PyErr_Fetch(&ptype, &pvalue, &ptraceback);
- g_warning ("Unable to load pygobject module >= %d.%d.%d, "
- "please make sure it is in python's path (sys.path). "
- "(use PYTHONPATH env variable to specify non default paths)\n%s",
- PYGTK_REQUIRED_MAJOR, PYGTK_REQUIRED_MINOR, PYGTK_REQUIRED_MICRO,
- PyString_AsString (pvalue));
- PyErr_Clear ();
- Py_Finalize ();
- return;
- }
-
- pyg_disable_warning_redirections ();
-
- /* Set path */
- command = g_strdup_printf ("import sys; sys.path+=['.', '%s', '%s'];\n",
- g_getenv (GLADE_ENV_CATALOG_PATH),
- glade_app_get_modules_dir ());
- PyRun_SimpleString (command);
- g_free (command);
+ gchar *command;
+
+ Py_SetProgramName (PACKAGE_NAME);
+
+ /* Initialize the Python interpreter */
+ python_init ();
+
+ /* Check and init pygobject >= 2.12.0 */
+ PyErr_Clear ();
+ glade_python_init_pygtk_check (PYGTK_REQUIRED_MAJOR, PYGTK_REQUIRED_MINOR,
+ PYGTK_REQUIRED_MICRO);
+ if (PyErr_Occurred ())
+ {
+ PyObject *ptype, *pvalue, *ptraceback;
+ PyErr_Fetch (&ptype, &pvalue, &ptraceback);
+ g_warning ("Unable to load pygobject module >= %d.%d.%d, "
+ "please make sure it is in python's path (sys.path). "
+ "(use PYTHONPATH env variable to specify non default paths)\n%s",
+ PYGTK_REQUIRED_MAJOR, PYGTK_REQUIRED_MINOR,
+ PYGTK_REQUIRED_MICRO, PyString_AsString (pvalue));
+ PyErr_Clear ();
+ Py_Finalize ();
+ return;
+ }
+
+ pyg_disable_warning_redirections ();
+
+ /* Set path */
+ command = g_strdup_printf ("import sys; sys.path+=['.', '%s', '%s'];\n",
+ g_getenv (GLADE_ENV_CATALOG_PATH),
+ glade_app_get_modules_dir ());
+ PyRun_SimpleString (command);
+ g_free (command);
}
void
-glade_python_init (const gchar *name)
+glade_python_init (const gchar * name)
{
- static gboolean init = TRUE;
- gchar *import_sentence;
-
- if (init)
- {
- glade_python_setup ();
- init = FALSE;
- }
-
- /* Yeah, we use the catalog name as the library */
- import_sentence = g_strdup_printf ("import %s;", name);
- PyRun_SimpleString (import_sentence);
- g_free (import_sentence);
+ static gboolean init = TRUE;
+ gchar *import_sentence;
+
+ if (init)
+ {
+ glade_python_setup ();
+ init = FALSE;
+ }
+
+ /* Yeah, we use the catalog name as the library */
+ import_sentence = g_strdup_printf ("import %s;", name);
+ PyRun_SimpleString (import_sentence);
+ g_free (import_sentence);
}
diff --git a/src/glade-close-button.c b/src/glade-close-button.c
index b8a0f4a..b302ade 100644
--- a/src/glade-close-button.c
+++ b/src/glade-close-button.c
@@ -23,55 +23,50 @@
#include "glade-close-button.h"
G_DEFINE_TYPE (GladeCloseButton, glade_close_button, GTK_TYPE_BUTTON)
-
-static void
-glade_close_button_class_init (GladeCloseButtonClass *klass)
+ static void glade_close_button_class_init (GladeCloseButtonClass * klass)
{
}
static void
-glade_close_button_init (GladeCloseButton *button)
+glade_close_button_init (GladeCloseButton * button)
{
- GtkWidget *image;
- GtkCssProvider *provider;
+ GtkWidget *image;
+ GtkCssProvider *provider;
- gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
- /* make it as small as possible */
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- "* {\n"
- " -GtkButton-default-border : 0;\n"
- " -GtkButton-default-outside-border : 0;\n"
- " -GtkButton-inner-border : 0;\n"
- " -GtkWidget-focus-line-width : 0;\n"
- " -GtkWidget-focus-padding : 0;\n"
- " padding : 0;\n"
- "}", -1, NULL);
+ /* make it as small as possible */
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ "* {\n"
+ " -GtkButton-default-border : 0;\n"
+ " -GtkButton-default-outside-border : 0;\n"
+ " -GtkButton-inner-border : 0;\n"
+ " -GtkWidget-focus-line-width : 0;\n"
+ " -GtkWidget-focus-padding : 0;\n"
+ " padding : 0;\n" "}", -1, NULL);
- gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (button)),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
+ gtk_style_context_add_provider (gtk_widget_get_style_context
+ (GTK_WIDGET (button)),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
- image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
- GTK_ICON_SIZE_MENU);
+ image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
+ gtk_widget_show (image);
- gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_container_add (GTK_CONTAINER (button), image);
}
GtkWidget *
glade_close_button_new ()
{
- GladeCloseButton *button;
+ GladeCloseButton *button;
- button = g_object_new (GLADE_TYPE_CLOSE_BUTTON,
- "relief", GTK_RELIEF_NONE,
- "focus-on-click", FALSE,
- NULL);
+ button = g_object_new (GLADE_TYPE_CLOSE_BUTTON,
+ "relief", GTK_RELIEF_NONE,
+ "focus-on-click", FALSE, NULL);
- return GTK_WIDGET (button);
+ return GTK_WIDGET (button);
}
-
diff --git a/src/glade-window.c b/src/glade-window.c
index e6bbbd9..9b2a6ec 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2007 Vincent Geddes.
@@ -72,2635 +71,2685 @@
GLADE_TYPE_WINDOW, \
GladeWindowPrivate))
-enum {
- DOCK_PALETTE,
- DOCK_INSPECTOR,
- DOCK_EDITOR,
- N_DOCKS
+enum
+{
+ DOCK_PALETTE,
+ DOCK_INSPECTOR,
+ DOCK_EDITOR,
+ N_DOCKS
};
-typedef struct {
- GtkWidget *widget; /* the widget with scrollbars */
- GtkWidget *paned; /* GtkPaned in the main window containing which part */
- gboolean first_child; /* whether this widget is packed with gtk_paned_pack1() */
- gboolean detached; /* whether this widget should be floating */
- gboolean maximized; /* whether this widget should be maximized */
- char *title; /* window title, untranslated */
- char *id; /* id to use in config file */
- GdkRectangle window_pos; /* x and y == G_MININT means unset */
+typedef struct
+{
+ GtkWidget *widget; /* the widget with scrollbars */
+ GtkWidget *paned; /* GtkPaned in the main window containing which part */
+ gboolean first_child; /* whether this widget is packed with gtk_paned_pack1() */
+ gboolean detached; /* whether this widget should be floating */
+ gboolean maximized; /* whether this widget should be maximized */
+ char *title; /* window title, untranslated */
+ char *id; /* id to use in config file */
+ GdkRectangle window_pos; /* x and y == G_MININT means unset */
} ToolDock;
struct _GladeWindowPrivate
{
- GladeApp *app;
-
- GtkWidget *main_vbox;
-
- GtkWidget *notebook;
- GladeDesignView *active_view;
- gint num_tabs;
-
- GtkWidget *inspectors_notebook;
-
- GtkWidget *statusbar; /* A pointer to the status bar. */
- guint statusbar_menu_context_id; /* The context id of the menu bar */
- guint statusbar_actions_context_id; /* The context id of actions messages */
-
- GtkUIManager *ui; /* The UIManager */
- guint projects_list_menu_ui_id; /* Merge id for projects list menu */
-
- GtkActionGroup *static_actions; /* All the static actions */
- GtkActionGroup *project_actions; /* All the project actions */
- GtkActionGroup *projects_list_menu_actions; /* Projects list menu actions */
-
- GtkRecentManager *recent_manager;
- GtkWidget *recent_menu;
-
- gchar *default_path; /* the default path for open/save operations */
-
- GtkToggleToolButton *selector_button; /* the widget selector button (replaces the one in the palette) */
- GtkToolButton *preview_button; /* the project preview button (replaces the one in the palette) */
- GtkToggleToolButton *drag_resize_button; /* sets the pointer to drag/resize mode */
- gboolean setting_pointer_mode; /* avoid feedback signal loops */
-
- GtkToolItem *undo; /* customized buttons for undo/redo with history */
- GtkToolItem *redo;
-
- GtkWidget *toolbar; /* Actions are added to the toolbar */
- gint actions_start; /* start of action items */
-
- GtkWidget *center_pane;
- /* paned windows that tools get docked into/out of */
- GtkWidget *left_pane;
- GtkWidget *right_pane;
-
- GdkRectangle position;
- ToolDock docks[N_DOCKS];
-};
+ GladeApp *app;
-static void refresh_undo_redo (GladeWindow *window);
+ GtkWidget *main_vbox;
-static void recent_chooser_item_activated_cb (GtkRecentChooser *chooser,
- GladeWindow *window);
+ GtkWidget *notebook;
+ GladeDesignView *active_view;
+ gint num_tabs;
-static void check_reload_project (GladeWindow *window,
- GladeProject *project);
+ GtkWidget *inspectors_notebook;
-static void glade_window_config_save (GladeWindow *window);
+ GtkWidget *statusbar; /* A pointer to the status bar. */
+ guint statusbar_menu_context_id; /* The context id of the menu bar */
+ guint statusbar_actions_context_id; /* The context id of actions messages */
+ GtkUIManager *ui; /* The UIManager */
+ guint projects_list_menu_ui_id; /* Merge id for projects list menu */
-G_DEFINE_TYPE (GladeWindow, glade_window, GTK_TYPE_WINDOW)
+ GtkActionGroup *static_actions; /* All the static actions */
+ GtkActionGroup *project_actions; /* All the project actions */
+ GtkActionGroup *projects_list_menu_actions; /* Projects list menu actions */
+ GtkRecentManager *recent_manager;
+ GtkWidget *recent_menu;
-/* the following functions are taken from gedit-utils.c */
+ gchar *default_path; /* the default path for open/save operations */
-static gchar *
-str_middle_truncate (const gchar *string,
- guint truncate_length)
+ GtkToggleToolButton *selector_button; /* the widget selector button (replaces the one in the palette) */
+ GtkToolButton *preview_button; /* the project preview button (replaces the one in the palette) */
+ GtkToggleToolButton *drag_resize_button; /* sets the pointer to drag/resize mode */
+ gboolean setting_pointer_mode; /* avoid feedback signal loops */
+
+ GtkToolItem *undo; /* customized buttons for undo/redo with history */
+ GtkToolItem *redo;
+
+ GtkWidget *toolbar; /* Actions are added to the toolbar */
+ gint actions_start; /* start of action items */
+
+ GtkWidget *center_pane;
+ /* paned windows that tools get docked into/out of */
+ GtkWidget *left_pane;
+ GtkWidget *right_pane;
+
+ GdkRectangle position;
+ ToolDock docks[N_DOCKS];
+};
+
+static void refresh_undo_redo (GladeWindow * window);
+
+static void recent_chooser_item_activated_cb (GtkRecentChooser * chooser,
+ GladeWindow * window);
+
+static void check_reload_project (GladeWindow * window, GladeProject * project);
+
+static void glade_window_config_save (GladeWindow * window);
+
+
+G_DEFINE_TYPE (GladeWindow, glade_window, GTK_TYPE_WINDOW)
+/* the following functions are taken from gedit-utils.c */
+ static gchar *str_middle_truncate (const gchar * string,
+ guint truncate_length)
{
- GString *truncated;
- guint length;
- guint n_chars;
- guint num_left_chars;
- guint right_offset;
- guint delimiter_length;
- const gchar *delimiter = "\342\200\246";
+ GString *truncated;
+ guint length;
+ guint n_chars;
+ guint num_left_chars;
+ guint right_offset;
+ guint delimiter_length;
+ const gchar *delimiter = "\342\200\246";
+
+ g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (string != NULL, NULL);
+ length = strlen (string);
- length = strlen (string);
+ g_return_val_if_fail (g_utf8_validate (string, length, NULL), NULL);
- g_return_val_if_fail (g_utf8_validate (string, length, NULL), NULL);
+ /* It doesnt make sense to truncate strings to less than
+ * the size of the delimiter plus 2 characters (one on each
+ * side)
+ */
+ delimiter_length = g_utf8_strlen (delimiter, -1);
+ if (truncate_length < (delimiter_length + 2))
+ {
+ return g_strdup (string);
+ }
- /* It doesnt make sense to truncate strings to less than
- * the size of the delimiter plus 2 characters (one on each
- * side)
- */
- delimiter_length = g_utf8_strlen (delimiter, -1);
- if (truncate_length < (delimiter_length + 2)) {
- return g_strdup (string);
- }
+ n_chars = g_utf8_strlen (string, length);
- n_chars = g_utf8_strlen (string, length);
+ /* Make sure the string is not already small enough. */
+ if (n_chars <= truncate_length)
+ {
+ return g_strdup (string);
+ }
- /* Make sure the string is not already small enough. */
- if (n_chars <= truncate_length) {
- return g_strdup (string);
- }
+ /* Find the 'middle' where the truncation will occur. */
+ num_left_chars = (truncate_length - delimiter_length) / 2;
+ right_offset = n_chars - truncate_length + num_left_chars + delimiter_length;
- /* Find the 'middle' where the truncation will occur. */
- num_left_chars = (truncate_length - delimiter_length) / 2;
- right_offset = n_chars - truncate_length + num_left_chars + delimiter_length;
+ truncated = g_string_new_len (string,
+ g_utf8_offset_to_pointer (string,
+ num_left_chars) -
+ string);
+ g_string_append (truncated, delimiter);
+ g_string_append (truncated, g_utf8_offset_to_pointer (string, right_offset));
- truncated = g_string_new_len (string,
- g_utf8_offset_to_pointer (string, num_left_chars) - string);
- g_string_append (truncated, delimiter);
- g_string_append (truncated, g_utf8_offset_to_pointer (string, right_offset));
-
- return g_string_free (truncated, FALSE);
+ return g_string_free (truncated, FALSE);
}
/*
* Doubles underscore to avoid spurious menu accels - taken from gedit-utils.c
*/
-static gchar *
-escape_underscores (const gchar* text,
- gssize length)
+static gchar *
+escape_underscores (const gchar * text, gssize length)
{
- GString *str;
- const gchar *p;
- const gchar *end;
+ GString *str;
+ const gchar *p;
+ const gchar *end;
- g_return_val_if_fail (text != NULL, NULL);
+ g_return_val_if_fail (text != NULL, NULL);
- if (length < 0)
- length = strlen (text);
+ if (length < 0)
+ length = strlen (text);
- str = g_string_sized_new (length);
+ str = g_string_sized_new (length);
- p = text;
- end = text + length;
+ p = text;
+ end = text + length;
- while (p != end)
- {
- const gchar *next;
- next = g_utf8_next_char (p);
+ while (p != end)
+ {
+ const gchar *next;
+ next = g_utf8_next_char (p);
- switch (*p)
- {
- case '_':
- g_string_append (str, "__");
- break;
- default:
- g_string_append_len (str, p, next - p);
- break;
- }
+ switch (*p)
+ {
+ case '_':
+ g_string_append (str, "__");
+ break;
+ default:
+ g_string_append_len (str, p, next - p);
+ break;
+ }
- p = next;
- }
+ p = next;
+ }
- return g_string_free (str, FALSE);
+ return g_string_free (str, FALSE);
}
typedef enum
{
- FORMAT_NAME_MARK_UNSAVED = 1 << 0,
- FORMAT_NAME_ESCAPE_UNDERSCORES = 1 << 1,
- FORMAT_NAME_MIDDLE_TRUNCATE = 1 << 2
+ FORMAT_NAME_MARK_UNSAVED = 1 << 0,
+ FORMAT_NAME_ESCAPE_UNDERSCORES = 1 << 1,
+ FORMAT_NAME_MIDDLE_TRUNCATE = 1 << 2
} FormatNameFlags;
#define MAX_TITLE_LENGTH 100
static gchar *
-get_formatted_project_name_for_display (GladeProject *project, FormatNameFlags format_flags)
+get_formatted_project_name_for_display (GladeProject * project,
+ FormatNameFlags format_flags)
{
- gchar *name, *pass1, *pass2, *pass3;
-
- g_return_val_if_fail (project != NULL, NULL);
-
- name = glade_project_get_name (project);
-
- if ((format_flags & FORMAT_NAME_MARK_UNSAVED)
- && glade_project_get_modified (project))
- pass1 = g_strdup_printf ("*%s", name);
- else
- pass1 = g_strdup (name);
-
- if (format_flags & FORMAT_NAME_ESCAPE_UNDERSCORES)
- pass2 = escape_underscores (pass1, -1);
- else
- pass2 = g_strdup (pass1);
-
- if (format_flags & FORMAT_NAME_MIDDLE_TRUNCATE)
- pass3 = str_middle_truncate (pass2, MAX_TITLE_LENGTH);
- else
- pass3 = g_strdup (pass2);
+ gchar *name, *pass1, *pass2, *pass3;
+
+ g_return_val_if_fail (project != NULL, NULL);
+
+ name = glade_project_get_name (project);
+
+ if ((format_flags & FORMAT_NAME_MARK_UNSAVED)
+ && glade_project_get_modified (project))
+ pass1 = g_strdup_printf ("*%s", name);
+ else
+ pass1 = g_strdup (name);
- g_free (name);
- g_free (pass1);
- g_free (pass2);
-
- return pass3;
+ if (format_flags & FORMAT_NAME_ESCAPE_UNDERSCORES)
+ pass2 = escape_underscores (pass1, -1);
+ else
+ pass2 = g_strdup (pass1);
+
+ if (format_flags & FORMAT_NAME_MIDDLE_TRUNCATE)
+ pass3 = str_middle_truncate (pass2, MAX_TITLE_LENGTH);
+ else
+ pass3 = g_strdup (pass2);
+
+ g_free (name);
+ g_free (pass1);
+ g_free (pass2);
+
+ return pass3;
}
static void
-refresh_title (GladeWindow *window)
+refresh_title (GladeWindow * window)
{
- GladeProject *project;
- gchar *title, *name = NULL;
+ GladeProject *project;
+ gchar *title, *name = NULL;
+
+ if (window->priv->active_view)
+ {
+ project = glade_design_view_get_project (window->priv->active_view);
- if (window->priv->active_view)
- {
- project = glade_design_view_get_project (window->priv->active_view);
+ name = get_formatted_project_name_for_display (project,
+ FORMAT_NAME_MARK_UNSAVED |
+ FORMAT_NAME_MIDDLE_TRUNCATE);
- name = get_formatted_project_name_for_display (project,
- FORMAT_NAME_MARK_UNSAVED |
- FORMAT_NAME_MIDDLE_TRUNCATE);
-
- if (glade_project_get_readonly (project) != FALSE)
- title = g_strdup_printf ("%s %s", name, READONLY_INDICATOR);
- else
- title = g_strdup_printf ("%s", name);
-
- g_free (name);
- }
- else
- {
- title = g_strdup (_("User Interface Designer"));
- }
-
- gtk_window_set_title (GTK_WINDOW (window), title);
+ if (glade_project_get_readonly (project) != FALSE)
+ title = g_strdup_printf ("%s %s", name, READONLY_INDICATOR);
+ else
+ title = g_strdup_printf ("%s", name);
- g_free (title);
+ g_free (name);
+ }
+ else
+ {
+ title = g_strdup (_("User Interface Designer"));
+ }
+
+ gtk_window_set_title (GTK_WINDOW (window), title);
+
+ g_free (title);
}
-static const gchar*
-get_default_path (GladeWindow *window)
+static const gchar *
+get_default_path (GladeWindow * window)
{
- return window->priv->default_path;
+ return window->priv->default_path;
}
static void
-update_default_path (GladeWindow *window, const gchar *filename)
+update_default_path (GladeWindow * window, const gchar * filename)
{
- gchar *path;
-
- g_return_if_fail (filename != NULL);
+ gchar *path;
- path = g_path_get_dirname (filename);
+ g_return_if_fail (filename != NULL);
- g_free (window->priv->default_path);
- window->priv->default_path = g_strdup (path);
+ path = g_path_get_dirname (filename);
- g_free (path);
+ g_free (window->priv->default_path);
+ window->priv->default_path = g_strdup (path);
+
+ g_free (path);
}
static GtkWidget *
-create_recent_chooser_menu (GladeWindow *window, GtkRecentManager *manager)
+create_recent_chooser_menu (GladeWindow * window, GtkRecentManager * manager)
{
- GtkWidget *recent_menu;
- GtkRecentFilter *filter;
+ GtkWidget *recent_menu;
+ GtkRecentFilter *filter;
- recent_menu = gtk_recent_chooser_menu_new_for_manager (manager);
+ recent_menu = gtk_recent_chooser_menu_new_for_manager (manager);
- gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (recent_menu), TRUE);
- gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (recent_menu), FALSE);
- gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu), GTK_RECENT_SORT_MRU);
- gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (recent_menu), TRUE);
+ gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (recent_menu), TRUE);
+ gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (recent_menu), FALSE);
+ gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recent_menu),
+ GTK_RECENT_SORT_MRU);
+ gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU
+ (recent_menu), TRUE);
- filter = gtk_recent_filter_new ();
- gtk_recent_filter_add_application (filter, g_get_application_name());
- gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (recent_menu), filter);
+ filter = gtk_recent_filter_new ();
+ gtk_recent_filter_add_application (filter, g_get_application_name ());
+ gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (recent_menu), filter);
- return recent_menu;
+ return recent_menu;
}
static void
-activate_action (GtkToolButton *toolbutton,
- GladeWidgetAction *action)
+activate_action (GtkToolButton * toolbutton, GladeWidgetAction * action)
{
- GladeWidget *widget;
-
- if ((widget = g_object_get_data (G_OBJECT (toolbutton), "glade-widget")))
- glade_widget_adaptor_action_activate (widget->adaptor,
- widget->object,
- action->klass->path);
+ GladeWidget *widget;
+
+ if ((widget = g_object_get_data (G_OBJECT (toolbutton), "glade-widget")))
+ glade_widget_adaptor_action_activate (widget->adaptor,
+ widget->object, action->klass->path);
}
static void
-action_notify_sensitive (GObject *gobject,
- GParamSpec *arg1,
- GtkWidget *item)
+action_notify_sensitive (GObject * gobject, GParamSpec * arg1, GtkWidget * item)
{
- GladeWidgetAction *action = GLADE_WIDGET_ACTION (gobject);
- gtk_widget_set_sensitive (item, action->sensitive);
+ GladeWidgetAction *action = GLADE_WIDGET_ACTION (gobject);
+ gtk_widget_set_sensitive (item, action->sensitive);
}
static void
-action_disconnect (gpointer data, GClosure *closure)
+action_disconnect (gpointer data, GClosure * closure)
{
- g_signal_handlers_disconnect_matched (data, G_SIGNAL_MATCH_FUNC,
- 0, 0, NULL,
- action_notify_sensitive,
- NULL);
+ g_signal_handlers_disconnect_matched (data, G_SIGNAL_MATCH_FUNC,
+ 0, 0, NULL,
+ action_notify_sensitive, NULL);
}
static void
-clean_actions (GladeWindow *window)
+clean_actions (GladeWindow * window)
{
- GtkContainer *container = GTK_CONTAINER (window->priv->toolbar);
- GtkToolbar *bar = GTK_TOOLBAR (window->priv->toolbar);
- GtkToolItem *item;
-
- if (window->priv->actions_start)
- {
- while ((item = gtk_toolbar_get_nth_item (bar, window->priv->actions_start)))
- gtk_container_remove (container, GTK_WIDGET (item));
- }
+ GtkContainer *container = GTK_CONTAINER (window->priv->toolbar);
+ GtkToolbar *bar = GTK_TOOLBAR (window->priv->toolbar);
+ GtkToolItem *item;
+
+ if (window->priv->actions_start)
+ {
+ while ((item =
+ gtk_toolbar_get_nth_item (bar, window->priv->actions_start)))
+ gtk_container_remove (container, GTK_WIDGET (item));
+ }
}
static void
-add_actions (GladeWindow *window,
- GladeWidget *widget,
- GList *actions)
+add_actions (GladeWindow * window, GladeWidget * widget, GList * actions)
{
- GtkToolbar *bar = GTK_TOOLBAR (window->priv->toolbar);
- GtkToolItem *item = gtk_separator_tool_item_new ();
- gint n = 0;
- GList *l;
+ GtkToolbar *bar = GTK_TOOLBAR (window->priv->toolbar);
+ GtkToolItem *item = gtk_separator_tool_item_new ();
+ gint n = 0;
+ GList *l;
+
+ gtk_toolbar_insert (bar, item, -1);
+ gtk_widget_show (GTK_WIDGET (item));
+
+ if (window->priv->actions_start == 0)
+ window->priv->actions_start = gtk_toolbar_get_item_index (bar, item);
+
+ for (l = actions; l; l = g_list_next (l))
+ {
+ GladeWidgetAction *a = l->data;
+
+ if (!a->klass->important)
+ continue;
- gtk_toolbar_insert (bar, item, -1);
- gtk_widget_show (GTK_WIDGET (item));
+ if (a->actions)
+ {
+ g_warning
+ ("Trying to add a group action to the toolbar is unsupported");
+ continue;
+ }
- if (window->priv->actions_start == 0)
- window->priv->actions_start = gtk_toolbar_get_item_index (bar, item);
-
- for (l = actions; l; l = g_list_next (l))
- {
- GladeWidgetAction *a = l->data;
-
- if (!a->klass->important) continue;
-
- if (a->actions)
- {
- g_warning ("Trying to add a group action to the toolbar is unsupported");
- continue;
- }
+ item =
+ gtk_tool_button_new_from_stock ((a->klass->stock) ? a->klass->
+ stock : "gtk-execute");
+ if (a->klass->label)
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), a->klass->label);
- item = gtk_tool_button_new_from_stock ((a->klass->stock) ? a->klass->stock : "gtk-execute");
- if (a->klass->label)
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (item),
- a->klass->label);
-
- g_object_set_data (G_OBJECT (item), "glade-widget", widget);
+ g_object_set_data (G_OBJECT (item), "glade-widget", widget);
- /* We use destroy_data to keep track of notify::sensitive callbacks
- * on the action object and disconnect them when the toolbar item
- * gets destroyed.
- */
- g_signal_connect_data (item, "clicked",
- G_CALLBACK (activate_action),
- a, action_disconnect, 0);
-
- gtk_widget_set_sensitive (GTK_WIDGET (item), a->sensitive);
+ /* We use destroy_data to keep track of notify::sensitive callbacks
+ * on the action object and disconnect them when the toolbar item
+ * gets destroyed.
+ */
+ g_signal_connect_data (item, "clicked",
+ G_CALLBACK (activate_action),
+ a, action_disconnect, 0);
- g_signal_connect (a, "notify::sensitive",
- G_CALLBACK (activate_action),
- GTK_WIDGET (item));
-
- gtk_toolbar_insert (bar, item, -1);
- gtk_tool_item_set_homogeneous (item, FALSE);
- gtk_widget_show (GTK_WIDGET (item));
- n++;
- }
-
- if (n == 0)
- clean_actions (window);
-}
-
-static void
-project_selection_changed_cb (GladeProject *project, GladeWindow *window)
-{
- GladeWidget *glade_widget = NULL;
- GList *list;
- gint num;
+ gtk_widget_set_sensitive (GTK_WIDGET (item), a->sensitive);
- /* This is sometimes called with a NULL project (to make the label
- * insensitive with no projects loaded)
- */
- g_return_if_fail (GLADE_IS_WINDOW (window));
-
- /* Only update the toolbar & workspace if the selection has changed on
- * the currently active project.
- */
- if (project && (project == glade_app_get_project ()))
- {
- list = glade_project_selection_get (project);
- num = g_list_length (list);
-
- if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
- {
- glade_widget = glade_widget_get_from_gobject (G_OBJECT (list->data));
-
- glade_widget_show (glade_widget);
-
- clean_actions (window);
- if (glade_widget->actions)
- add_actions (window, glade_widget, glade_widget->actions);
- }
- }
+ g_signal_connect (a, "notify::sensitive",
+ G_CALLBACK (activate_action), GTK_WIDGET (item));
+
+ gtk_toolbar_insert (bar, item, -1);
+ gtk_tool_item_set_homogeneous (item, FALSE);
+ gtk_widget_show (GTK_WIDGET (item));
+ n++;
+ }
+
+ if (n == 0)
+ clean_actions (window);
+}
+
+static void
+project_selection_changed_cb (GladeProject * project, GladeWindow * window)
+{
+ GladeWidget *glade_widget = NULL;
+ GList *list;
+ gint num;
+
+ /* This is sometimes called with a NULL project (to make the label
+ * insensitive with no projects loaded)
+ */
+ g_return_if_fail (GLADE_IS_WINDOW (window));
+
+ /* Only update the toolbar & workspace if the selection has changed on
+ * the currently active project.
+ */
+ if (project && (project == glade_app_get_project ()))
+ {
+ list = glade_project_selection_get (project);
+ num = g_list_length (list);
+
+ if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
+ {
+ glade_widget = glade_widget_get_from_gobject (G_OBJECT (list->data));
+
+ glade_widget_show (glade_widget);
+
+ clean_actions (window);
+ if (glade_widget->actions)
+ add_actions (window, glade_widget, glade_widget->actions);
+ }
+ }
}
static GladeDesignView *
-get_active_view (GladeWindow *window)
+get_active_view (GladeWindow * window)
{
- g_return_val_if_fail (GLADE_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GLADE_IS_WINDOW (window), NULL);
- return window->priv->active_view;
+ return window->priv->active_view;
}
static gchar *
-format_project_list_item_tooltip (GladeProject *project)
+format_project_list_item_tooltip (GladeProject * project)
+{
+ gchar *tooltip, *path, *name;
+
+ if (glade_project_get_path (project))
+ {
+ path =
+ glade_utils_replace_home_dir_with_tilde (glade_project_get_path
+ (project));
+
+ if (glade_project_get_readonly (project))
+ {
+ /* translators: referring to the action of activating a file named '%s'.
+ * we also indicate to users that the file may be read-only with
+ * the second '%s' */
+ tooltip = g_strdup_printf (_("Activate '%s' %s"),
+ path, READONLY_INDICATOR);
+ }
+ else
+ {
+ /* translators: referring to the action of activating a file named '%s' */
+ tooltip = g_strdup_printf (_("Activate '%s'"), path);
+ }
+ g_free (path);
+ }
+ else
+ {
+ name = glade_project_get_name (project);
+ /* FIXME add hint for translators */
+ tooltip = g_strdup_printf (_("Activate '%s'"), name);
+ g_free (name);
+ }
+
+ return tooltip;
+}
+
+static void
+refresh_notebook_tab_for_project (GladeWindow * window, GladeProject * project)
{
- gchar *tooltip, *path, *name;
+ GtkWidget *tab_label, *label, *view, *eventbox;
+ GList *children, *l;
+ gchar *str;
+
+ children =
+ gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
+ for (l = children; l; l = l->next)
+ {
+ view = l->data;
+
+ if (project == glade_design_view_get_project (GLADE_DESIGN_VIEW (view)))
+ {
+ gchar *path, *deps;
+
+ tab_label =
+ gtk_notebook_get_tab_label (GTK_NOTEBOOK (window->priv->notebook),
+ view);
+ label = g_object_get_data (G_OBJECT (tab_label), "tab-label");
+ eventbox = g_object_get_data (G_OBJECT (tab_label), "tab-event-box");
+
+ str = get_formatted_project_name_for_display (project,
+ FORMAT_NAME_MARK_UNSAVED
+ |
+ FORMAT_NAME_MIDDLE_TRUNCATE);
+ gtk_label_set_text (GTK_LABEL (label), str);
+ g_free (str);
- if (glade_project_get_path (project))
- {
- path = glade_utils_replace_home_dir_with_tilde (glade_project_get_path (project));
-
- if (glade_project_get_readonly (project))
- {
- /* translators: referring to the action of activating a file named '%s'.
- * we also indicate to users that the file may be read-only with
- * the second '%s' */
- tooltip = g_strdup_printf (_("Activate '%s' %s"),
- path,
- READONLY_INDICATOR);
- }
- else
- {
- /* translators: referring to the action of activating a file named '%s' */
- tooltip = g_strdup_printf (_("Activate '%s'"), path);
- }
- g_free (path);
- }
- else
- {
- name = glade_project_get_name (project);
- /* FIXME add hint for translators */
- tooltip = g_strdup_printf (_("Activate '%s'"), name);
- g_free (name);
- }
-
- return tooltip;
+ if (glade_project_get_path (project))
+ path =
+ glade_utils_replace_home_dir_with_tilde (glade_project_get_path
+ (project));
+ else
+ path = glade_project_get_name (project);
+
+
+ deps = glade_project_display_dependencies (project);
+ str = g_markup_printf_escaped (" <b>%s</b> %s \n"
+ " %s \n"
+ " <b>%s</b> %s ",
+ _("Name:"), path,
+ glade_project_get_readonly (project) ?
+ READONLY_INDICATOR : "",
+ _("Requires:"), deps);
+
+ gtk_widget_set_tooltip_markup (eventbox, str);
+
+ g_free (path);
+ g_free (deps);
+ g_free (str);
+
+ break;
+ }
+ }
+ g_list_free (children);
}
-static void
-refresh_notebook_tab_for_project (GladeWindow *window, GladeProject *project)
+static void
+refresh_notebook_tabs (GladeWindow * window)
{
- GtkWidget *tab_label, *label, *view, *eventbox;
- GList *children, *l;
- gchar *str;
-
- children = gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
- for (l = children; l; l = l->next)
- {
- view = l->data;
-
- if (project == glade_design_view_get_project (GLADE_DESIGN_VIEW (view)))
- {
- gchar *path, *deps;
-
- tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (window->priv->notebook), view);
- label = g_object_get_data (G_OBJECT (tab_label), "tab-label");
- eventbox = g_object_get_data (G_OBJECT (tab_label), "tab-event-box");
-
- str = get_formatted_project_name_for_display (project,
- FORMAT_NAME_MARK_UNSAVED |
- FORMAT_NAME_MIDDLE_TRUNCATE);
- gtk_label_set_text (GTK_LABEL (label), str);
- g_free (str);
-
- if (glade_project_get_path (project))
- path = glade_utils_replace_home_dir_with_tilde (glade_project_get_path (project));
- else
- path = glade_project_get_name (project);
+ GList *list;
+ for (list = glade_app_get_projects (); list; list = list->next)
+ refresh_notebook_tab_for_project (window, GLADE_PROJECT (list->data));
+}
- deps = glade_project_display_dependencies (project);
- str = g_markup_printf_escaped (" <b>%s</b> %s \n"
- " %s \n"
- " <b>%s</b> %s ",
- _("Name:"), path,
- glade_project_get_readonly (project) ? READONLY_INDICATOR : "",
- _("Requires:"), deps);
+static void
+project_targets_changed_cb (GladeProject * project, GladeWindow * window)
+{
+ refresh_notebook_tab_for_project (window, project);
+}
+
+static void
+refresh_projects_list_item (GladeWindow * window, GladeProject * project)
+{
+ GtkAction *action;
+ gchar *project_name;
+ gchar *tooltip;
- gtk_widget_set_tooltip_markup (eventbox, str);
-
- g_free (path);
- g_free (deps);
- g_free (str);
-
- break;
- }
- }
- g_list_free (children);
-}
-
-static void
-refresh_notebook_tabs (GladeWindow *window)
-{
- GList *list;
-
- for (list = glade_app_get_projects (); list; list = list->next)
- refresh_notebook_tab_for_project (window, GLADE_PROJECT (list->data));
-}
-
-static void
-project_targets_changed_cb (GladeProject *project, GladeWindow *window)
-{
- refresh_notebook_tab_for_project (window, project);
-}
-
-static void
-refresh_projects_list_item (GladeWindow *window, GladeProject *project)
-{
- GtkAction *action;
- gchar *project_name;
- gchar *tooltip;
-
- /* Get associated action */
- action = GTK_ACTION (g_object_get_data (G_OBJECT (project), "project-list-action"));
-
- /* Set action label */
- project_name = get_formatted_project_name_for_display (project,
- FORMAT_NAME_MARK_UNSAVED |
- FORMAT_NAME_ESCAPE_UNDERSCORES |
- FORMAT_NAME_MIDDLE_TRUNCATE);
-
- g_object_set (action, "label", project_name, NULL);
+ /* Get associated action */
+ action =
+ GTK_ACTION (g_object_get_data
+ (G_OBJECT (project), "project-list-action"));
- /* Set action tooltip */
- tooltip = format_project_list_item_tooltip (project);
- g_object_set (action, "tooltip", tooltip, NULL);
-
- g_free (tooltip);
- g_free (project_name);
+ /* Set action label */
+ project_name = get_formatted_project_name_for_display (project,
+ FORMAT_NAME_MARK_UNSAVED
+ |
+ FORMAT_NAME_ESCAPE_UNDERSCORES
+ |
+ FORMAT_NAME_MIDDLE_TRUNCATE);
+
+ g_object_set (action, "label", project_name, NULL);
+
+ /* Set action tooltip */
+ tooltip = format_project_list_item_tooltip (project);
+ g_object_set (action, "tooltip", tooltip, NULL);
+
+ g_free (tooltip);
+ g_free (project_name);
}
static void
-refresh_next_prev_project_sensitivity (GladeWindow *window)
+refresh_next_prev_project_sensitivity (GladeWindow * window)
{
- GladeDesignView *view;
- GtkAction *action;
- gint view_number;
-
- view = get_active_view (window);
+ GladeDesignView *view;
+ GtkAction *action;
+ gint view_number;
+
+ view = get_active_view (window);
- if (view != NULL)
- {
- view_number = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (view));
- g_return_if_fail (view_number >= 0);
-
- action = gtk_action_group_get_action (window->priv->project_actions, "PreviousProject");
- gtk_action_set_sensitive (action, view_number != 0);
-
- action = gtk_action_group_get_action (window->priv->project_actions, "NextProject");
- gtk_action_set_sensitive (action,
- view_number < gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) - 1);
- }
- else
- {
- action = gtk_action_group_get_action (window->priv->project_actions, "PreviousProject");
- gtk_action_set_sensitive (action, FALSE);
-
- action = gtk_action_group_get_action (window->priv->project_actions, "NextProject");
- gtk_action_set_sensitive (action, FALSE);
- }
+ if (view != NULL)
+ {
+ view_number =
+ gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
+ GTK_WIDGET (view));
+ g_return_if_fail (view_number >= 0);
+
+ action =
+ gtk_action_group_get_action (window->priv->project_actions,
+ "PreviousProject");
+ gtk_action_set_sensitive (action, view_number != 0);
+
+ action =
+ gtk_action_group_get_action (window->priv->project_actions,
+ "NextProject");
+ gtk_action_set_sensitive (action,
+ view_number <
+ gtk_notebook_get_n_pages (GTK_NOTEBOOK
+ (window->priv->
+ notebook)) - 1);
+ }
+ else
+ {
+ action =
+ gtk_action_group_get_action (window->priv->project_actions,
+ "PreviousProject");
+ gtk_action_set_sensitive (action, FALSE);
+
+ action =
+ gtk_action_group_get_action (window->priv->project_actions,
+ "NextProject");
+ gtk_action_set_sensitive (action, FALSE);
+ }
}
static void
-new_cb (GtkAction *action, GladeWindow *window)
+new_cb (GtkAction * action, GladeWindow * window)
{
- glade_window_new_project (window);
+ glade_window_new_project (window);
}
static void
-project_notify_handler_cb (GladeProject *project, GParamSpec *spec, GladeWindow *window)
+project_notify_handler_cb (GladeProject * project, GParamSpec * spec,
+ GladeWindow * window)
{
- GtkAction *action;
+ GtkAction *action;
- if (strcmp (spec->name, "path") == 0 ||
- strcmp (spec->name, "format") == 0)
- refresh_notebook_tab_for_project (window, project);
- else if (strcmp (spec->name, "modified") == 0)
- {
- refresh_title (window);
- refresh_projects_list_item (window, project);
- }
- else if (strcmp (spec->name, "read-only") == 0)
- {
- refresh_notebook_tab_for_project (window, project);
+ if (strcmp (spec->name, "path") == 0 || strcmp (spec->name, "format") == 0)
+ refresh_notebook_tab_for_project (window, project);
+ else if (strcmp (spec->name, "modified") == 0)
+ {
+ refresh_title (window);
+ refresh_projects_list_item (window, project);
+ }
+ else if (strcmp (spec->name, "read-only") == 0)
+ {
+ refresh_notebook_tab_for_project (window, project);
- action = gtk_action_group_get_action (window->priv->project_actions, "Save");
- gtk_action_set_sensitive (action,
- !glade_project_get_readonly (project));
- }
- else if (strcmp (spec->name, "has-selection") == 0 &&
- (project == glade_app_get_project ()))
- {
- action = gtk_action_group_get_action (window->priv->project_actions, "Cut");
- gtk_action_set_sensitive (action,
- glade_project_get_has_selection (project));
+ action =
+ gtk_action_group_get_action (window->priv->project_actions, "Save");
+ gtk_action_set_sensitive (action, !glade_project_get_readonly (project));
+ }
+ else if (strcmp (spec->name, "has-selection") == 0 &&
+ (project == glade_app_get_project ()))
+ {
+ action =
+ gtk_action_group_get_action (window->priv->project_actions, "Cut");
+ gtk_action_set_sensitive (action,
+ glade_project_get_has_selection (project));
- action = gtk_action_group_get_action (window->priv->project_actions, "Copy");
- gtk_action_set_sensitive (action,
- glade_project_get_has_selection (project));
+ action =
+ gtk_action_group_get_action (window->priv->project_actions, "Copy");
+ gtk_action_set_sensitive (action,
+ glade_project_get_has_selection (project));
- action = gtk_action_group_get_action (window->priv->project_actions, "Delete");
- gtk_action_set_sensitive (action,
- glade_project_get_has_selection (project));
- }
+ action =
+ gtk_action_group_get_action (window->priv->project_actions, "Delete");
+ gtk_action_set_sensitive (action,
+ glade_project_get_has_selection (project));
+ }
}
static void
-clipboard_notify_handler_cb (GladeClipboard *clipboard, GParamSpec *spec, GladeWindow *window)
+clipboard_notify_handler_cb (GladeClipboard * clipboard, GParamSpec * spec,
+ GladeWindow * window)
{
- GtkAction *action;
+ GtkAction *action;
- if (strcmp (spec->name, "has-selection") == 0)
- {
- action = gtk_action_group_get_action (window->priv->project_actions, "Paste");
- gtk_action_set_sensitive (action,
- glade_clipboard_get_has_selection (clipboard));
- }
+ if (strcmp (spec->name, "has-selection") == 0)
+ {
+ action =
+ gtk_action_group_get_action (window->priv->project_actions, "Paste");
+ gtk_action_set_sensitive (action,
+ glade_clipboard_get_has_selection (clipboard));
+ }
}
static void
-on_selector_button_toggled (GtkToggleToolButton *button, GladeWindow *window)
+on_selector_button_toggled (GtkToggleToolButton * button, GladeWindow * window)
{
- if (window->priv->setting_pointer_mode)
- return;
+ if (window->priv->setting_pointer_mode)
+ return;
- if (gtk_toggle_tool_button_get_active (window->priv->selector_button))
- {
- glade_palette_deselect_current_item (glade_app_get_palette(), FALSE);
- glade_app_set_pointer_mode (GLADE_POINTER_SELECT);
- }
- else
- gtk_toggle_tool_button_set_active (window->priv->selector_button, TRUE);
+ if (gtk_toggle_tool_button_get_active (window->priv->selector_button))
+ {
+ glade_palette_deselect_current_item (glade_app_get_palette (), FALSE);
+ glade_app_set_pointer_mode (GLADE_POINTER_SELECT);
+ }
+ else
+ gtk_toggle_tool_button_set_active (window->priv->selector_button, TRUE);
}
static void
-on_preview_button_clicked (GtkToggleToolButton *button, GladeWindow *window)
+on_preview_button_clicked (GtkToggleToolButton * button, GladeWindow * window)
{
- GladeProject *project;
+ GladeProject *project;
- const GList *objects;
+ const GList *objects;
- GtkWidget *widget = NULL;
- GtkWidget *window_to_preview = NULL;
- GladeWidget *glade_widget = NULL;
+ GtkWidget *widget = NULL;
+ GtkWidget *window_to_preview = NULL;
+ GladeWidget *glade_widget = NULL;
- project = glade_design_view_get_project (window->priv->active_view);
+ project = glade_design_view_get_project (window->priv->active_view);
- if (project == NULL)
- return;
+ if (project == NULL)
+ return;
- objects = glade_project_get_objects (project);
+ objects = glade_project_get_objects (project);
- while (objects != NULL)
- {
- if (GTK_IS_WIDGET (objects->data))
- {
- widget = GTK_WIDGET(objects->data);
- if (GTK_IS_WINDOW (widget))
- {
- window_to_preview = widget;
- break;
- }
- }
- objects = objects->next;
- }
+ while (objects != NULL)
+ {
+ if (GTK_IS_WIDGET (objects->data))
+ {
+ widget = GTK_WIDGET (objects->data);
+ if (GTK_IS_WINDOW (widget))
+ {
+ window_to_preview = widget;
+ break;
+ }
+ }
+ objects = objects->next;
+ }
- if (widget != NULL)
- {
- glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
- }
+ if (widget != NULL)
+ {
+ glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
+ }
- if (window_to_preview != NULL) widget = window_to_preview;
- glade_project_preview (project,
- glade_widget_get_from_gobject((gpointer)widget)
- );
+ if (window_to_preview != NULL)
+ widget = window_to_preview;
+ glade_project_preview (project,
+ glade_widget_get_from_gobject ((gpointer) widget));
}
static void
-on_drag_resize_button_toggled (GtkToggleToolButton *button, GladeWindow *window)
+on_drag_resize_button_toggled (GtkToggleToolButton * button,
+ GladeWindow * window)
{
- if (window->priv->setting_pointer_mode)
- return;
+ if (window->priv->setting_pointer_mode)
+ return;
- if (gtk_toggle_tool_button_get_active (window->priv->drag_resize_button))
- glade_app_set_pointer_mode (GLADE_POINTER_DRAG_RESIZE);
- else
- gtk_toggle_tool_button_set_active (window->priv->drag_resize_button, TRUE);
+ if (gtk_toggle_tool_button_get_active (window->priv->drag_resize_button))
+ glade_app_set_pointer_mode (GLADE_POINTER_DRAG_RESIZE);
+ else
+ gtk_toggle_tool_button_set_active (window->priv->drag_resize_button, TRUE);
}
static void
-on_pointer_mode_changed (GladeApp *app,
- GParamSpec *pspec,
- GladeWindow *window)
+on_pointer_mode_changed (GladeApp * app,
+ GParamSpec * pspec, GladeWindow * window)
{
- window->priv->setting_pointer_mode = TRUE;
+ window->priv->setting_pointer_mode = TRUE;
- if (glade_app_get_pointer_mode () == GLADE_POINTER_SELECT)
- gtk_toggle_tool_button_set_active (window->priv->selector_button, TRUE);
- else
- gtk_toggle_tool_button_set_active (window->priv->selector_button, FALSE);
+ if (glade_app_get_pointer_mode () == GLADE_POINTER_SELECT)
+ gtk_toggle_tool_button_set_active (window->priv->selector_button, TRUE);
+ else
+ gtk_toggle_tool_button_set_active (window->priv->selector_button, FALSE);
- if (glade_app_get_pointer_mode () == GLADE_POINTER_DRAG_RESIZE)
- gtk_toggle_tool_button_set_active (window->priv->drag_resize_button, TRUE);
- else
- gtk_toggle_tool_button_set_active (window->priv->drag_resize_button, FALSE);
+ if (glade_app_get_pointer_mode () == GLADE_POINTER_DRAG_RESIZE)
+ gtk_toggle_tool_button_set_active (window->priv->drag_resize_button, TRUE);
+ else
+ gtk_toggle_tool_button_set_active (window->priv->drag_resize_button, FALSE);
- window->priv->setting_pointer_mode = FALSE;
+ window->priv->setting_pointer_mode = FALSE;
}
static void
-set_sensitivity_according_to_project (GladeWindow *window, GladeProject *project)
+set_sensitivity_according_to_project (GladeWindow * window,
+ GladeProject * project)
{
- GtkAction *action;
+ GtkAction *action;
- action = gtk_action_group_get_action (window->priv->project_actions, "Save");
- gtk_action_set_sensitive (action,
- !glade_project_get_readonly (project));
+ action = gtk_action_group_get_action (window->priv->project_actions, "Save");
+ gtk_action_set_sensitive (action, !glade_project_get_readonly (project));
- action = gtk_action_group_get_action (window->priv->project_actions, "Cut");
- gtk_action_set_sensitive (action,
- glade_project_get_has_selection (project));
+ action = gtk_action_group_get_action (window->priv->project_actions, "Cut");
+ gtk_action_set_sensitive (action, glade_project_get_has_selection (project));
- action = gtk_action_group_get_action (window->priv->project_actions, "Copy");
- gtk_action_set_sensitive (action,
- glade_project_get_has_selection (project));
+ action = gtk_action_group_get_action (window->priv->project_actions, "Copy");
+ gtk_action_set_sensitive (action, glade_project_get_has_selection (project));
- action = gtk_action_group_get_action (window->priv->project_actions, "Paste");
- gtk_action_set_sensitive (action,
- glade_clipboard_get_has_selection
- (glade_app_get_clipboard ()));
+ action = gtk_action_group_get_action (window->priv->project_actions, "Paste");
+ gtk_action_set_sensitive (action,
+ glade_clipboard_get_has_selection
+ (glade_app_get_clipboard ()));
- action = gtk_action_group_get_action (window->priv->project_actions, "Delete");
- gtk_action_set_sensitive (action,
- glade_project_get_has_selection (project));
+ action =
+ gtk_action_group_get_action (window->priv->project_actions, "Delete");
+ gtk_action_set_sensitive (action, glade_project_get_has_selection (project));
- refresh_next_prev_project_sensitivity (window);
+ refresh_next_prev_project_sensitivity (window);
}
static void
-recent_add (GladeWindow *window, const gchar *path)
+recent_add (GladeWindow * window, const gchar * path)
{
- GtkRecentData *recent_data;
- gchar *uri;
- GError *error = NULL;
+ GtkRecentData *recent_data;
+ gchar *uri;
+ GError *error = NULL;
- uri = g_filename_to_uri (path, NULL, &error);
- if (error)
- {
- g_warning ("Could not convert uri \"%s\" to a local path: %s", uri, error->message);
- g_error_free (error);
- return;
- }
+ uri = g_filename_to_uri (path, NULL, &error);
+ if (error)
+ {
+ g_warning ("Could not convert uri \"%s\" to a local path: %s", uri,
+ error->message);
+ g_error_free (error);
+ return;
+ }
- recent_data = g_slice_new (GtkRecentData);
+ recent_data = g_slice_new (GtkRecentData);
- recent_data->display_name = NULL;
- recent_data->description = NULL;
- recent_data->mime_type = "application/x-glade";
- recent_data->app_name = (gchar *) g_get_application_name ();
- recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
- recent_data->groups = NULL;
- recent_data->is_private = FALSE;
+ recent_data->display_name = NULL;
+ recent_data->description = NULL;
+ recent_data->mime_type = "application/x-glade";
+ recent_data->app_name = (gchar *) g_get_application_name ();
+ recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
+ recent_data->groups = NULL;
+ recent_data->is_private = FALSE;
- gtk_recent_manager_add_full (window->priv->recent_manager,
- uri,
- recent_data);
+ gtk_recent_manager_add_full (window->priv->recent_manager, uri, recent_data);
- g_free (uri);
- g_free (recent_data->app_exec);
- g_slice_free (GtkRecentData, recent_data);
+ g_free (uri);
+ g_free (recent_data->app_exec);
+ g_slice_free (GtkRecentData, recent_data);
}
static void
-recent_remove (GladeWindow *window, const gchar *path)
+recent_remove (GladeWindow * window, const gchar * path)
{
- gchar *uri;
- GError *error = NULL;
+ gchar *uri;
+ GError *error = NULL;
+
+ uri = g_filename_to_uri (path, NULL, &error);
+ if (error)
+ {
+ g_warning ("Could not convert uri \"%s\" to a local path: %s", uri,
+ error->message);
+ g_error_free (error);
+ return;
+ }
- uri = g_filename_to_uri (path, NULL, &error);
- if (error)
- {
- g_warning ("Could not convert uri \"%s\" to a local path: %s", uri, error->message);
- g_error_free (error);
- return;
- }
+ gtk_recent_manager_remove_item (window->priv->recent_manager, uri, NULL);
- gtk_recent_manager_remove_item (window->priv->recent_manager,
- uri,
- NULL);
-
- g_free (uri);
+ g_free (uri);
}
/* switch to a project and check if we need to reload it.
*
*/
static void
-switch_to_project (GladeWindow *window, GladeProject *project)
-{
- GladeWindowPrivate *priv = window->priv;
- guint i, n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
-
- /* increase project popularity */
- recent_add (window, glade_project_get_path (project));
- update_default_path (window, glade_project_get_path (project));
-
- for (i = 0; i < n; i++)
- {
- GladeProject *project_i;
- GtkWidget *view;
-
- view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), i);
- project_i = glade_design_view_get_project (GLADE_DESIGN_VIEW (view));
-
- if (project == project_i)
- {
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i);
- break;
- }
- }
- check_reload_project (window, project);
-}
-
-static void
-projects_list_menu_activate_cb (GtkAction *action, GladeWindow *window)
-{
- gint n;
-
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) == FALSE)
- return;
-
- n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), n);
-}
+switch_to_project (GladeWindow * window, GladeProject * project)
+{
+ GladeWindowPrivate *priv = window->priv;
+ guint i, n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+
+ /* increase project popularity */
+ recent_add (window, glade_project_get_path (project));
+ update_default_path (window, glade_project_get_path (project));
+
+ for (i = 0; i < n; i++)
+ {
+ GladeProject *project_i;
+ GtkWidget *view;
+
+ view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), i);
+ project_i = glade_design_view_get_project (GLADE_DESIGN_VIEW (view));
+
+ if (project == project_i)
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i);
+ break;
+ }
+ }
+ check_reload_project (window, project);
+}
+
+static void
+projects_list_menu_activate_cb (GtkAction * action, GladeWindow * window)
+{
+ gint n;
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) == FALSE)
+ return;
+
+ n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), n);
+}
static void
-refresh_projects_list_menu (GladeWindow *window)
+refresh_projects_list_menu (GladeWindow * window)
{
- GladeWindowPrivate *p = window->priv;
- GList *actions, *l;
- GSList *group = NULL;
- gint n, i;
- guint id;
+ GladeWindowPrivate *p = window->priv;
+ GList *actions, *l;
+ GSList *group = NULL;
+ gint n, i;
+ guint id;
- if (p->projects_list_menu_ui_id != 0)
- gtk_ui_manager_remove_ui (p->ui, p->projects_list_menu_ui_id);
+ if (p->projects_list_menu_ui_id != 0)
+ gtk_ui_manager_remove_ui (p->ui, p->projects_list_menu_ui_id);
- /* Remove all current actions */
- actions = gtk_action_group_list_actions (p->projects_list_menu_actions);
- for (l = actions; l != NULL; l = l->next)
- {
- g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
- G_CALLBACK (projects_list_menu_activate_cb), window);
- gtk_action_group_remove_action (p->projects_list_menu_actions, GTK_ACTION (l->data));
- }
- g_list_free (actions);
+ /* Remove all current actions */
+ actions = gtk_action_group_list_actions (p->projects_list_menu_actions);
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
+ G_CALLBACK
+ (projects_list_menu_activate_cb),
+ window);
+ gtk_action_group_remove_action (p->projects_list_menu_actions,
+ GTK_ACTION (l->data));
+ }
+ g_list_free (actions);
- n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (p->notebook));
+ n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (p->notebook));
- id = (n > 0) ? gtk_ui_manager_new_merge_id (p->ui) : 0;
+ id = (n > 0) ? gtk_ui_manager_new_merge_id (p->ui) : 0;
- /* Add an action for each project */
- for (i = 0; i < n; i++)
- {
- GtkWidget *view;
- GladeProject *project;
- GtkRadioAction *action;
- gchar action_name[32];
- gchar *project_name;
- gchar *tooltip;
- gchar accel[7];
+ /* Add an action for each project */
+ for (i = 0; i < n; i++)
+ {
+ GtkWidget *view;
+ GladeProject *project;
+ GtkRadioAction *action;
+ gchar action_name[32];
+ gchar *project_name;
+ gchar *tooltip;
+ gchar accel[7];
- view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
- project = glade_design_view_get_project (GLADE_DESIGN_VIEW (view));
+ view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
+ project = glade_design_view_get_project (GLADE_DESIGN_VIEW (view));
- /* NOTE: the action is associated to the position of the tab in
- * the notebook not to the tab itself! This is needed to work
- * around the gtk+ bug #170727: gtk leaves around the accels
- * of the action. Since the accel depends on the tab position
- * the problem is worked around, action with the same name always
- * get the same accel.
- */
- g_snprintf (action_name, sizeof (action_name), "Tab_%d", i);
- project_name = get_formatted_project_name_for_display (project,
- FORMAT_NAME_MARK_UNSAVED |
- FORMAT_NAME_MIDDLE_TRUNCATE |
- FORMAT_NAME_ESCAPE_UNDERSCORES);
- tooltip = format_project_list_item_tooltip (project);
+ /* NOTE: the action is associated to the position of the tab in
+ * the notebook not to the tab itself! This is needed to work
+ * around the gtk+ bug #170727: gtk leaves around the accels
+ * of the action. Since the accel depends on the tab position
+ * the problem is worked around, action with the same name always
+ * get the same accel.
+ */
+ g_snprintf (action_name, sizeof (action_name), "Tab_%d", i);
+ project_name = get_formatted_project_name_for_display (project,
+ FORMAT_NAME_MARK_UNSAVED
+ |
+ FORMAT_NAME_MIDDLE_TRUNCATE
+ |
+ FORMAT_NAME_ESCAPE_UNDERSCORES);
+ tooltip = format_project_list_item_tooltip (project);
- /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
- if (i < 10)
- g_snprintf (accel, sizeof (accel), "<alt>%d", (i + 1) % 10);
- else
- accel[0] = '\0';
+ /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
+ if (i < 10)
+ g_snprintf (accel, sizeof (accel), "<alt>%d", (i + 1) % 10);
+ else
+ accel[0] = '\0';
- action = gtk_radio_action_new (action_name,
- project_name,
- tooltip,
- NULL,
- i);
+ action = gtk_radio_action_new (action_name,
+ project_name, tooltip, NULL, i);
- /* Link action and project */
- g_object_set_data (G_OBJECT (project), "project-list-action", action);
- g_object_set_data (G_OBJECT (action), "project", project);
+ /* Link action and project */
+ g_object_set_data (G_OBJECT (project), "project-list-action", action);
+ g_object_set_data (G_OBJECT (action), "project", project);
- /* note that group changes each time we add an action, so it must be updated */
- gtk_radio_action_set_group (action, group);
- group = gtk_radio_action_get_group (action);
+ /* note that group changes each time we add an action, so it must be updated */
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
- gtk_action_group_add_action_with_accel (p->projects_list_menu_actions,
- GTK_ACTION (action),
- accel);
+ gtk_action_group_add_action_with_accel (p->projects_list_menu_actions,
+ GTK_ACTION (action), accel);
- g_signal_connect (action, "activate",
- G_CALLBACK (projects_list_menu_activate_cb),
- window);
+ g_signal_connect (action, "activate",
+ G_CALLBACK (projects_list_menu_activate_cb), window);
- gtk_ui_manager_add_ui (p->ui, id,
- "/MenuBar/ProjectMenu/ProjectsListPlaceholder",
- action_name, action_name,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
+ gtk_ui_manager_add_ui (p->ui, id,
+ "/MenuBar/ProjectMenu/ProjectsListPlaceholder",
+ action_name, action_name,
+ GTK_UI_MANAGER_MENUITEM, FALSE);
- if (GLADE_DESIGN_VIEW (view) == p->active_view)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ if (GLADE_DESIGN_VIEW (view) == p->active_view)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- g_object_unref (action);
+ g_object_unref (action);
- g_free (project_name);
- g_free (tooltip);
- }
+ g_free (project_name);
+ g_free (tooltip);
+ }
- p->projects_list_menu_ui_id = id;
+ p->projects_list_menu_ui_id = id;
}
static void
-open_cb (GtkAction *action, GladeWindow *window)
-{
- GtkWidget *filechooser;
- gchar *path = NULL, *default_path;
+open_cb (GtkAction * action, GladeWindow * window)
+{
+ GtkWidget *filechooser;
+ gchar *path = NULL, *default_path;
+
+ filechooser = glade_util_file_dialog_new (_("Open\342\200\246"), NULL,
+ GTK_WINDOW (window),
+ GLADE_FILE_DIALOG_ACTION_OPEN);
- filechooser = glade_util_file_dialog_new (_("Open\342\200\246"), NULL,
- GTK_WINDOW (window),
- GLADE_FILE_DIALOG_ACTION_OPEN);
+ default_path = g_strdup (get_default_path (window));
+ if (default_path != NULL)
+ {
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser),
+ default_path);
+ g_free (default_path);
+ }
- default_path = g_strdup (get_default_path (window));
- if (default_path != NULL)
- {
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser), default_path);
- g_free (default_path);
- }
+ if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_OK)
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
- if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
+ gtk_widget_destroy (filechooser);
- gtk_widget_destroy (filechooser);
+ if (!path)
+ return;
- if (!path)
- return;
-
- glade_window_open_project (window, path);
- g_free (path);
+ glade_window_open_project (window, path);
+ g_free (path);
}
static gboolean
-check_loading_project_for_save (GladeProject *project)
-{
- if (glade_project_is_loading (project))
- {
- gchar *name = glade_project_get_name (project);
-
- glade_util_ui_message (glade_app_get_window(),
- GLADE_UI_INFO, NULL,
- _("Project %s is still loading."), name);
- g_free (name);
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-save (GladeWindow *window, GladeProject *project, const gchar *path)
-{
- GError *error = NULL;
- gchar *display_name, *display_path = g_strdup (path);
- time_t mtime;
- GtkWidget *dialog;
- GtkWidget *button;
- gint response;
-
- if (check_loading_project_for_save (project))
- return;
-
- /* check for external modification to the project file */
- mtime = glade_util_get_file_mtime (glade_project_get_path (project), NULL);
-
- if (mtime > glade_project_get_file_mtime (project)) {
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- _("The file %s has been modified since reading it"),
- glade_project_get_path (project));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you save it, all the external changes could be lost. Save it anyway?"));
-
- gtk_window_set_title (GTK_WINDOW (dialog), "");
-
- button = gtk_button_new_with_mnemonic (_("_Save Anyway"));
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (GTK_STOCK_SAVE,
- GTK_ICON_SIZE_BUTTON));
- gtk_widget_show (button);
-
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_ACCEPT);
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Don't Save"), GTK_RESPONSE_REJECT);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
-
- if (response == GTK_RESPONSE_REJECT)
- {
- g_free (display_path);
- return;
- }
- }
-
- /* Interestingly; we cannot use `path' after glade_project_reset_path
- * because we are getting called with glade_project_get_path (project) as an argument.
- */
- if (!glade_project_save (project, path, &error))
- {
- /* Reset path so future saves will prompt the file chooser */
- glade_project_reset_path (project);
-
- if (error)
- {
- glade_util_ui_message (GTK_WIDGET (window), GLADE_UI_ERROR, NULL,
- _("Failed to save %s: %s"),
- display_path, error->message);
- g_error_free (error);
- }
- g_free (display_path);
- return;
- }
-
- /* Get display_name here, it could have changed with "Save As..." */
- display_name = glade_project_get_name (project);
-
- recent_add (window, glade_project_get_path (project));
- update_default_path (window, glade_project_get_path (project));
-
- /* refresh names */
- refresh_title (window);
- refresh_projects_list_item (window, project);
- refresh_notebook_tab_for_project (window, project);
-
- glade_util_flash_message (window->priv->statusbar,
- window->priv->statusbar_actions_context_id,
- _("Project '%s' saved"), display_name);
-
- g_free (display_path);
- g_free (display_name);
-}
-
-static void
-save_as (GladeWindow *window)
-{
- GladeProject *project, *another_project;
- GtkWidget *filechooser;
- GtkWidget *dialog;
- gchar *path = NULL;
- gchar *real_path, *ch, *project_name;
-
- project = glade_design_view_get_project (window->priv->active_view);
-
- if (project == NULL)
- return;
-
- if (check_loading_project_for_save (project))
- return;
-
- filechooser = glade_util_file_dialog_new (_("Save As\342\200\246"), project,
- GTK_WINDOW (window),
- GLADE_FILE_DIALOG_ACTION_SAVE);
-
- if (glade_project_get_path (project))
- {
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser), glade_project_get_path (project));
- }
- else
- {
- gchar *default_path = g_strdup (get_default_path (window));
- if (default_path != NULL)
- {
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser), default_path);
- g_free (default_path);
- }
-
- project_name = glade_project_get_name (project);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), project_name);
- g_free (project_name);
- }
-
- if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
-
- gtk_widget_destroy (filechooser);
-
- if (!path)
- return;
-
- ch = strrchr (path, '.');
- if (!ch || strchr (ch, G_DIR_SEPARATOR))
- real_path = g_strconcat (path, ".glade", NULL);
- else
- real_path = g_strdup (path);
-
- g_free (path);
-
- /* checks if selected path is actually writable */
- if (glade_util_file_is_writeable (real_path) == FALSE)
- {
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Could not save the file %s"),
- real_path);
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("You do not have the permissions "
- "necessary to save the file."));
-
- gtk_window_set_title (GTK_WINDOW (dialog), "");
-
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
-
- gtk_widget_show (dialog);
- g_free (real_path);
- return;
- }
-
- /* checks if another open project is using selected path */
- if ((another_project = glade_app_get_project_by_path (real_path)) != NULL)
- {
- if (project != another_project) {
-
- glade_util_ui_message (GTK_WIDGET (window),
- GLADE_UI_ERROR, NULL,
- _("Could not save file %s. Another project with that path is open."),
- real_path);
-
- g_free (real_path);
- return;
- }
-
- }
-
- save (window, project, real_path);
-
- g_free (real_path);
-}
-
-static void
-save_cb (GtkAction *action, GladeWindow *window)
-{
- GladeProject *project;
-
- project = glade_design_view_get_project (window->priv->active_view);
-
- if (project == NULL)
- {
- /* Just in case the menu-item or button is not insensitive */
- glade_util_ui_message (GTK_WIDGET (window), GLADE_UI_WARN, NULL,
- _("No open projects to save"));
- return;
- }
-
- if (glade_project_get_path (project) != NULL)
- {
- save (window, project, glade_project_get_path (project));
- return;
- }
-
- /* If instead we dont have a path yet, fire up a file selector */
- save_as (window);
-}
-
-static void
-save_as_cb (GtkAction *action, GladeWindow *window)
-{
- save_as (window);
+check_loading_project_for_save (GladeProject * project)
+{
+ if (glade_project_is_loading (project))
+ {
+ gchar *name = glade_project_get_name (project);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ _("Project %s is still loading."), name);
+ g_free (name);
+ return TRUE;
+ }
+ return FALSE;
}
+
+static void
+save (GladeWindow * window, GladeProject * project, const gchar * path)
+{
+ GError *error = NULL;
+ gchar *display_name, *display_path = g_strdup (path);
+ time_t mtime;
+ GtkWidget *dialog;
+ GtkWidget *button;
+ gint response;
+
+ if (check_loading_project_for_save (project))
+ return;
+
+ /* check for external modification to the project file */
+ mtime = glade_util_get_file_mtime (glade_project_get_path (project), NULL);
+
+ if (mtime > glade_project_get_file_mtime (project))
+ {
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _
+ ("The file %s has been modified since reading it"),
+ glade_project_get_path (project));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("If you save it, all the external changes could be lost. Save it anyway?"));
+
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+
+ button = gtk_button_new_with_mnemonic (_("_Save Anyway"));
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_SAVE,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_widget_show (button);
+
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
+ GTK_RESPONSE_ACCEPT);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Don't Save"),
+ GTK_RESPONSE_REJECT);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ GTK_RESPONSE_REJECT);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_REJECT)
+ {
+ g_free (display_path);
+ return;
+ }
+ }
+
+ /* Interestingly; we cannot use `path' after glade_project_reset_path
+ * because we are getting called with glade_project_get_path (project) as an argument.
+ */
+ if (!glade_project_save (project, path, &error))
+ {
+ /* Reset path so future saves will prompt the file chooser */
+ glade_project_reset_path (project);
+
+ if (error)
+ {
+ glade_util_ui_message (GTK_WIDGET (window), GLADE_UI_ERROR, NULL,
+ _("Failed to save %s: %s"),
+ display_path, error->message);
+ g_error_free (error);
+ }
+ g_free (display_path);
+ return;
+ }
+
+ /* Get display_name here, it could have changed with "Save As..." */
+ display_name = glade_project_get_name (project);
+
+ recent_add (window, glade_project_get_path (project));
+ update_default_path (window, glade_project_get_path (project));
+
+ /* refresh names */
+ refresh_title (window);
+ refresh_projects_list_item (window, project);
+ refresh_notebook_tab_for_project (window, project);
+
+ glade_util_flash_message (window->priv->statusbar,
+ window->priv->statusbar_actions_context_id,
+ _("Project '%s' saved"), display_name);
+
+ g_free (display_path);
+ g_free (display_name);
+}
+
+static void
+save_as (GladeWindow * window)
+{
+ GladeProject *project, *another_project;
+ GtkWidget *filechooser;
+ GtkWidget *dialog;
+ gchar *path = NULL;
+ gchar *real_path, *ch, *project_name;
+
+ project = glade_design_view_get_project (window->priv->active_view);
+
+ if (project == NULL)
+ return;
+
+ if (check_loading_project_for_save (project))
+ return;
+
+ filechooser = glade_util_file_dialog_new (_("Save As\342\200\246"), project,
+ GTK_WINDOW (window),
+ GLADE_FILE_DIALOG_ACTION_SAVE);
+
+ if (glade_project_get_path (project))
+ {
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser),
+ glade_project_get_path (project));
+ }
+ else
+ {
+ gchar *default_path = g_strdup (get_default_path (window));
+ if (default_path != NULL)
+ {
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser),
+ default_path);
+ g_free (default_path);
+ }
+
+ project_name = glade_project_get_name (project);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser),
+ project_name);
+ g_free (project_name);
+ }
+
+ if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_OK)
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
+
+ gtk_widget_destroy (filechooser);
+
+ if (!path)
+ return;
+
+ ch = strrchr (path, '.');
+ if (!ch || strchr (ch, G_DIR_SEPARATOR))
+ real_path = g_strconcat (path, ".glade", NULL);
+ else
+ real_path = g_strdup (path);
+
+ g_free (path);
+
+ /* checks if selected path is actually writable */
+ if (glade_util_file_is_writeable (real_path) == FALSE)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Could not save the file %s"),
+ real_path);
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("You do not have the permissions "
+ "necessary to save the file."));
+
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), dialog);
+
+ gtk_widget_show (dialog);
+ g_free (real_path);
+ return;
+ }
+
+ /* checks if another open project is using selected path */
+ if ((another_project = glade_app_get_project_by_path (real_path)) != NULL)
+ {
+ if (project != another_project)
+ {
+
+ glade_util_ui_message (GTK_WIDGET (window),
+ GLADE_UI_ERROR, NULL,
+ _
+ ("Could not save file %s. Another project with that path is open."),
+ real_path);
+
+ g_free (real_path);
+ return;
+ }
+
+ }
+
+ save (window, project, real_path);
+
+ g_free (real_path);
+}
+
+static void
+save_cb (GtkAction * action, GladeWindow * window)
+{
+ GladeProject *project;
+
+ project = glade_design_view_get_project (window->priv->active_view);
+
+ if (project == NULL)
+ {
+ /* Just in case the menu-item or button is not insensitive */
+ glade_util_ui_message (GTK_WIDGET (window), GLADE_UI_WARN, NULL,
+ _("No open projects to save"));
+ return;
+ }
+
+ if (glade_project_get_path (project) != NULL)
+ {
+ save (window, project, glade_project_get_path (project));
+ return;
+ }
+
+ /* If instead we dont have a path yet, fire up a file selector */
+ save_as (window);
+}
+
+static void
+save_as_cb (GtkAction * action, GladeWindow * window)
+{
+ save_as (window);
+}
+
static gboolean
-confirm_close_project (GladeWindow *window, GladeProject *project)
-{
- GtkWidget *dialog;
- gboolean close = FALSE;
- gchar *msg, *project_name = NULL;
- gint ret;
- GError *error = NULL;
-
- project_name = glade_project_get_name (project);
-
- msg = g_strdup_printf (_("Save changes to project \"%s\" before closing?"),
- project_name);
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- "%s",
- msg);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s",
- _("Your changes will be lost if you don't save them."));
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Close _without Saving"), GTK_RESPONSE_NO,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_YES,
- GTK_RESPONSE_CANCEL,
- GTK_RESPONSE_NO,
- -1);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
-
- ret = gtk_dialog_run (GTK_DIALOG (dialog));
- switch (ret) {
- case GTK_RESPONSE_YES:
- /* if YES we save the project: note we cannot use save_cb
- * since it saves the current project, while the modified
- * project we are saving may be not the current one.
- */
- if (glade_project_get_path (project) != NULL)
- {
- if ((close = glade_project_save
- (project, glade_project_get_path (project), &error)) == FALSE)
- {
-
- glade_util_ui_message
- (GTK_WIDGET (window), GLADE_UI_ERROR, NULL,
- _("Failed to save %s to %s: %s"),
- project_name, glade_project_get_path (project), error->message);
- g_error_free (error);
- }
- }
- else
- {
- GtkWidget *filechooser;
- gchar *path = NULL;
- gchar *default_path;
-
- filechooser =
- glade_util_file_dialog_new (_("Save\342\200\246"), project,
- GTK_WINDOW (window),
- GLADE_FILE_DIALOG_ACTION_SAVE);
-
- default_path = g_strdup (get_default_path (window));
- if (default_path != NULL)
- {
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filechooser), default_path);
- g_free (default_path);
- }
-
- gtk_file_chooser_set_current_name
- (GTK_FILE_CHOOSER (filechooser), project_name);
-
-
- if (gtk_dialog_run (GTK_DIALOG(filechooser)) == GTK_RESPONSE_OK)
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
-
- gtk_widget_destroy (filechooser);
-
- if (!path)
- break;
-
- save (window, project, path);
-
- g_free (path);
-
- close = FALSE;
- }
- break;
- case GTK_RESPONSE_NO:
- close = TRUE;
- break;
- case GTK_RESPONSE_CANCEL:
- case GTK_RESPONSE_DELETE_EVENT:
- close = FALSE;
- break;
- default:
- g_assert_not_reached ();
- close = FALSE;
- }
+confirm_close_project (GladeWindow * window, GladeProject * project)
+{
+ GtkWidget *dialog;
+ gboolean close = FALSE;
+ gchar *msg, *project_name = NULL;
+ gint ret;
+ GError *error = NULL;
+
+ project_name = glade_project_get_name (project);
+
+ msg = g_strdup_printf (_("Save changes to project \"%s\" before closing?"),
+ project_name);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE, "%s", msg);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s",
+ _
+ ("Your changes will be lost if you don't save them."));
+ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("Close _without Saving"), GTK_RESPONSE_NO,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_YES,
+ GTK_RESPONSE_CANCEL,
+ GTK_RESPONSE_NO, -1);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
+
+ ret = gtk_dialog_run (GTK_DIALOG (dialog));
+ switch (ret)
+ {
+ case GTK_RESPONSE_YES:
+ /* if YES we save the project: note we cannot use save_cb
+ * since it saves the current project, while the modified
+ * project we are saving may be not the current one.
+ */
+ if (glade_project_get_path (project) != NULL)
+ {
+ if ((close = glade_project_save
+ (project, glade_project_get_path (project), &error)) == FALSE)
+ {
+
+ glade_util_ui_message
+ (GTK_WIDGET (window), GLADE_UI_ERROR, NULL,
+ _("Failed to save %s to %s: %s"),
+ project_name, glade_project_get_path (project),
+ error->message);
+ g_error_free (error);
+ }
+ }
+ else
+ {
+ GtkWidget *filechooser;
+ gchar *path = NULL;
+ gchar *default_path;
+
+ filechooser =
+ glade_util_file_dialog_new (_("Save\342\200\246"), project,
+ GTK_WINDOW (window),
+ GLADE_FILE_DIALOG_ACTION_SAVE);
+
+ default_path = g_strdup (get_default_path (window));
+ if (default_path != NULL)
+ {
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER
+ (filechooser),
+ default_path);
+ g_free (default_path);
+ }
+
+ gtk_file_chooser_set_current_name
+ (GTK_FILE_CHOOSER (filechooser), project_name);
+
+
+ if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_OK)
+ path =
+ gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
+ (filechooser));
+
+ gtk_widget_destroy (filechooser);
- g_free (msg);
- g_free (project_name);
- gtk_widget_destroy (dialog);
-
- return close;
+ if (!path)
+ break;
+
+ save (window, project, path);
+
+ g_free (path);
+
+ close = FALSE;
+ }
+ break;
+ case GTK_RESPONSE_NO:
+ close = TRUE;
+ break;
+ case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
+ close = FALSE;
+ break;
+ default:
+ g_assert_not_reached ();
+ close = FALSE;
+ }
+
+ g_free (msg);
+ g_free (project_name);
+ gtk_widget_destroy (dialog);
+
+ return close;
}
static void
-do_close (GladeWindow *window, GladeProject *project)
+do_close (GladeWindow * window, GladeProject * project)
{
- GladeDesignView *view;
- gint n;
+ GladeDesignView *view;
+ gint n;
+
+ view = glade_design_view_get_from_project (project);
+
+ if (glade_project_is_loading (project))
+ {
+ glade_project_cancel_load (project);
+ return;
+ }
+
+ n = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
+ GTK_WIDGET (view));
- view = glade_design_view_get_from_project (project);
+ g_object_ref (view);
- if (glade_project_is_loading (project))
- {
- glade_project_cancel_load (project);
- return;
- }
-
- n = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (view));
-
- g_object_ref (view);
-
- gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->notebook), n);
-
- g_object_unref (view);
+ gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->notebook), n);
+
+ g_object_unref (view);
}
static void
-close_cb (GtkAction *action, GladeWindow *window)
+close_cb (GtkAction * action, GladeWindow * window)
{
- GladeDesignView *view;
- GladeProject *project;
- gboolean close;
-
- view = window->priv->active_view;
+ GladeDesignView *view;
+ GladeProject *project;
+ gboolean close;
+
+ view = window->priv->active_view;
- project = glade_design_view_get_project (view);
+ project = glade_design_view_get_project (view);
- if (view == NULL)
- return;
+ if (view == NULL)
+ return;
- if (glade_project_get_modified (project))
- {
- close = confirm_close_project (window, project);
- if (!close)
- return;
- }
- do_close (window, project);
+ if (glade_project_get_modified (project))
+ {
+ close = confirm_close_project (window, project);
+ if (!close)
+ return;
+ }
+ do_close (window, project);
}
static void
-quit_cb (GtkAction *action, GladeWindow *window)
+quit_cb (GtkAction * action, GladeWindow * window)
{
- GList *list, *projects;
+ GList *list, *projects;
- projects = g_list_copy (glade_app_get_projects ());
+ projects = g_list_copy (glade_app_get_projects ());
- for (list = projects; list; list = list->next)
- {
- GladeProject *project = GLADE_PROJECT (list->data);
+ for (list = projects; list; list = list->next)
+ {
+ GladeProject *project = GLADE_PROJECT (list->data);
- if (glade_project_get_modified (project))
- {
- gboolean quit = confirm_close_project (window, project);
- if (!quit)
- {
- g_list_free (projects);
- return;
- }
- }
- }
+ if (glade_project_get_modified (project))
+ {
+ gboolean quit = confirm_close_project (window, project);
+ if (!quit)
+ {
+ g_list_free (projects);
+ return;
+ }
+ }
+ }
- for (list = projects; list; list = list->next)
- {
- GladeProject *project = GLADE_PROJECT (glade_app_get_projects ()->data);
- do_close (window, project);
- }
+ for (list = projects; list; list = list->next)
+ {
+ GladeProject *project = GLADE_PROJECT (glade_app_get_projects ()->data);
+ do_close (window, project);
+ }
- glade_window_config_save (window);
+ glade_window_config_save (window);
- g_list_free (projects);
+ g_list_free (projects);
- gtk_main_quit ();
+ gtk_main_quit ();
}
static void
-copy_cb (GtkAction *action, GladeWindow *window)
+copy_cb (GtkAction * action, GladeWindow * window)
{
- glade_app_command_copy ();
+ glade_app_command_copy ();
}
static void
-cut_cb (GtkAction *action, GladeWindow *window)
+cut_cb (GtkAction * action, GladeWindow * window)
{
- glade_app_command_cut ();
+ glade_app_command_cut ();
}
static void
-paste_cb (GtkAction *action, GladeWindow *window)
+paste_cb (GtkAction * action, GladeWindow * window)
{
- glade_app_command_paste (NULL);
+ glade_app_command_paste (NULL);
}
static void
-delete_cb (GtkAction *action, GladeWindow *window)
+delete_cb (GtkAction * action, GladeWindow * window)
{
- if (!glade_app_get_project ())
- {
- g_warning ("delete should not be sensitive: we don't have a project");
- return;
- }
- glade_app_command_delete ();
+ if (!glade_app_get_project ())
+ {
+ g_warning ("delete should not be sensitive: we don't have a project");
+ return;
+ }
+ glade_app_command_delete ();
}
static void
-preferences_cb (GtkAction *action, GladeWindow *window)
+preferences_cb (GtkAction * action, GladeWindow * window)
{
- GladeProject *project;
+ GladeProject *project;
- if (!window->priv->active_view)
- return;
+ if (!window->priv->active_view)
+ return;
- project = glade_design_view_get_project (window->priv->active_view);
+ project = glade_design_view_get_project (window->priv->active_view);
- glade_project_preferences (project);
+ glade_project_preferences (project);
}
static void
-undo_cb (GtkAction *action, GladeWindow *window)
+undo_cb (GtkAction * action, GladeWindow * window)
{
- if (!glade_app_get_project ())
- {
- g_warning ("undo should not be sensitive: we don't have a project");
- return;
- }
- glade_app_command_undo ();
+ if (!glade_app_get_project ())
+ {
+ g_warning ("undo should not be sensitive: we don't have a project");
+ return;
+ }
+ glade_app_command_undo ();
}
static void
-redo_cb (GtkAction *action, GladeWindow *window)
+redo_cb (GtkAction * action, GladeWindow * window)
{
- if (!glade_app_get_project ())
- {
- g_warning ("redo should not be sensitive: we don't have a project");
- return;
- }
- glade_app_command_redo ();
+ if (!glade_app_get_project ())
+ {
+ g_warning ("redo should not be sensitive: we don't have a project");
+ return;
+ }
+ glade_app_command_redo ();
}
static void
-doc_search_cb (GladeEditor *editor,
- const gchar *book,
- const gchar *page,
- const gchar *search,
- GladeWindow *window)
+doc_search_cb (GladeEditor * editor,
+ const gchar * book,
+ const gchar * page, const gchar * search, GladeWindow * window)
{
- glade_util_search_devhelp (book, page, search);
+ glade_util_search_devhelp (book, page, search);
}
static void
-previous_project_cb (GtkAction *action, GladeWindow *window)
+previous_project_cb (GtkAction * action, GladeWindow * window)
{
- gtk_notebook_prev_page (GTK_NOTEBOOK (window->priv->notebook));
+ gtk_notebook_prev_page (GTK_NOTEBOOK (window->priv->notebook));
}
static void
-next_project_cb (GtkAction *action, GladeWindow *window)
+next_project_cb (GtkAction * action, GladeWindow * window)
{
- gtk_notebook_next_page (GTK_NOTEBOOK (window->priv->notebook));
+ gtk_notebook_next_page (GTK_NOTEBOOK (window->priv->notebook));
}
static void
-notebook_switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- GladeWindow *window)
+notebook_switch_page_cb (GtkNotebook * notebook,
+ GtkWidget * page, guint page_num, GladeWindow * window)
{
- GladeDesignView *view;
- GladeProject *project;
- GtkAction *action;
- gchar *action_name;
+ GladeDesignView *view;
+ GladeProject *project;
+ GtkAction *action;
+ gchar *action_name;
+
+ view = GLADE_DESIGN_VIEW (gtk_notebook_get_nth_page (notebook, page_num));
+
+ /* CHECK: I don't know why but it seems notebook_switch_page is called
+ two times every time the user change the active tab */
+ if (view == window->priv->active_view)
+ return;
- view = GLADE_DESIGN_VIEW (gtk_notebook_get_nth_page (notebook, page_num));
+ window->priv->active_view = view;
- /* CHECK: I don't know why but it seems notebook_switch_page is called
- two times every time the user change the active tab */
- if (view == window->priv->active_view)
- return;
+ project = glade_design_view_get_project (view);
- window->priv->active_view = view;
-
- project = glade_design_view_get_project (view);
+ /* FIXME: this does not feel good */
+ glade_app_set_project (project);
- /* FIXME: this does not feel good */
- glade_app_set_project (project);
+ refresh_title (window);
+ set_sensitivity_according_to_project (window, project);
- refresh_title (window);
- set_sensitivity_according_to_project (window, project);
-
- /* switch to the project's inspector */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), page_num);
-
- /* activate the corresponding item in the project menu */
- action_name = g_strdup_printf ("Tab_%d", page_num);
- action = gtk_action_group_get_action (window->priv->projects_list_menu_actions,
- action_name);
+ /* switch to the project's inspector */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK
+ (window->priv->inspectors_notebook), page_num);
- /* sometimes the action doesn't exist yet, and the proper action
- * is set active during the documents list menu creation
- * CHECK: would it be nicer if active_view was a property and we monitored the notify signal?
- */
- if (action != NULL)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ /* activate the corresponding item in the project menu */
+ action_name = g_strdup_printf ("Tab_%d", page_num);
+ action =
+ gtk_action_group_get_action (window->priv->projects_list_menu_actions,
+ action_name);
- g_free (action_name);
+ /* sometimes the action doesn't exist yet, and the proper action
+ * is set active during the documents list menu creation
+ * CHECK: would it be nicer if active_view was a property and we monitored the notify signal?
+ */
+ if (action != NULL)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+ g_free (action_name);
}
static void
-set_widget_sensitive_on_load (GladeProject *project,
- GtkWidget *widget)
+set_widget_sensitive_on_load (GladeProject * project, GtkWidget * widget)
{
- gtk_widget_set_sensitive (widget, TRUE);
+ gtk_widget_set_sensitive (widget, TRUE);
}
static void
-notebook_tab_added_cb (GtkNotebook *notebook,
- GladeDesignView *view,
- guint page_num,
- GladeWindow *window)
+notebook_tab_added_cb (GtkNotebook * notebook,
+ GladeDesignView * view,
+ guint page_num, GladeWindow * window)
{
- GladeProject *project;
- GtkWidget *inspector;
+ GladeProject *project;
+ GtkWidget *inspector;
+
+ ++window->priv->num_tabs;
+
+ project = glade_design_view_get_project (view);
+
+ g_signal_connect (G_OBJECT (project), "notify::modified",
+ G_CALLBACK (project_notify_handler_cb), window);
+ g_signal_connect (G_OBJECT (project), "notify::path",
+ G_CALLBACK (project_notify_handler_cb), window);
+ g_signal_connect (G_OBJECT (project), "notify::format",
+ G_CALLBACK (project_notify_handler_cb), window);
+ g_signal_connect (G_OBJECT (project), "notify::has-selection",
+ G_CALLBACK (project_notify_handler_cb), window);
+ g_signal_connect (G_OBJECT (project), "notify::read-only",
+ G_CALLBACK (project_notify_handler_cb), window);
+ g_signal_connect (G_OBJECT (project), "selection-changed",
+ G_CALLBACK (project_selection_changed_cb), window);
+ g_signal_connect (G_OBJECT (project), "targets-changed",
+ G_CALLBACK (project_targets_changed_cb), window);
- ++window->priv->num_tabs;
-
- project = glade_design_view_get_project (view);
+ /* create inspector */
+ inspector = glade_inspector_new ();
+ gtk_widget_show (inspector);
+ glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
- g_signal_connect (G_OBJECT (project), "notify::modified",
- G_CALLBACK (project_notify_handler_cb),
- window);
- g_signal_connect (G_OBJECT (project), "notify::path",
- G_CALLBACK (project_notify_handler_cb),
- window);
- g_signal_connect (G_OBJECT (project), "notify::format",
- G_CALLBACK (project_notify_handler_cb),
- window);
- g_signal_connect (G_OBJECT (project), "notify::has-selection",
- G_CALLBACK (project_notify_handler_cb),
- window);
- g_signal_connect (G_OBJECT (project), "notify::read-only",
- G_CALLBACK (project_notify_handler_cb),
- window);
- g_signal_connect (G_OBJECT (project), "selection-changed",
- G_CALLBACK (project_selection_changed_cb),
- window);
- g_signal_connect (G_OBJECT (project), "targets-changed",
- G_CALLBACK (project_targets_changed_cb),
- window);
+ if (GPOINTER_TO_INT
+ (g_object_get_data (G_OBJECT (view), "view-added-while-loading")))
+ {
+ gtk_widget_set_sensitive (inspector, FALSE);
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (set_widget_sensitive_on_load), inspector);
+ }
- /* create inspector */
- inspector = glade_inspector_new ();
- gtk_widget_show (inspector);
- glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
+ gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->inspectors_notebook),
+ inspector, NULL);
- if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "view-added-while-loading")))
- {
- gtk_widget_set_sensitive (inspector, FALSE);
- g_signal_connect (project, "parse-finished",
- G_CALLBACK (set_widget_sensitive_on_load), inspector);
- }
- gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), inspector, NULL);
-
+ set_sensitivity_according_to_project (window, project);
- set_sensitivity_according_to_project (window, project);
+ refresh_projects_list_menu (window);
- refresh_projects_list_menu (window);
+ refresh_title (window);
- refresh_title (window);
+ project_selection_changed_cb (glade_app_get_project (), window);
- project_selection_changed_cb (glade_app_get_project (), window);
-
- if (window->priv->num_tabs > 0)
- gtk_action_group_set_sensitive (window->priv->project_actions, TRUE);
+ if (window->priv->num_tabs > 0)
+ gtk_action_group_set_sensitive (window->priv->project_actions, TRUE);
}
static void
-notebook_tab_removed_cb (GtkNotebook *notebook,
- GladeDesignView *view,
- guint page_num,
- GladeWindow *window)
+notebook_tab_removed_cb (GtkNotebook * notebook,
+ GladeDesignView * view,
+ guint page_num, GladeWindow * window)
{
- GladeProject *project;
+ GladeProject *project;
- --window->priv->num_tabs;
+ --window->priv->num_tabs;
- if (window->priv->num_tabs == 0)
- window->priv->active_view = NULL;
+ if (window->priv->num_tabs == 0)
+ window->priv->active_view = NULL;
- project = glade_design_view_get_project (view);
+ project = glade_design_view_get_project (view);
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (project_notify_handler_cb),
- window);
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (project_selection_changed_cb),
- window);
- g_signal_handlers_disconnect_by_func (G_OBJECT (project),
- G_CALLBACK (project_targets_changed_cb),
- window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK (project_notify_handler_cb),
+ window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK
+ (project_selection_changed_cb), window);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+ G_CALLBACK (project_targets_changed_cb),
+ window);
- gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), page_num);
+ gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->inspectors_notebook),
+ page_num);
- clean_actions (window);
+ clean_actions (window);
- /* FIXME: this function needs to be preferably called somewhere else */
- glade_app_remove_project (project);
+ /* FIXME: this function needs to be preferably called somewhere else */
+ glade_app_remove_project (project);
- refresh_projects_list_menu (window);
+ refresh_projects_list_menu (window);
- refresh_title (window);
+ refresh_title (window);
- project_selection_changed_cb (glade_app_get_project (), window);
-
- if (window->priv->active_view)
- set_sensitivity_according_to_project (window, glade_design_view_get_project (window->priv->active_view));
- else
- gtk_action_group_set_sensitive (window->priv->project_actions, FALSE);
+ project_selection_changed_cb (glade_app_get_project (), window);
+
+ if (window->priv->active_view)
+ set_sensitivity_according_to_project (window,
+ glade_design_view_get_project
+ (window->priv->active_view));
+ else
+ gtk_action_group_set_sensitive (window->priv->project_actions, FALSE);
}
static void
-recent_chooser_item_activated_cb (GtkRecentChooser *chooser, GladeWindow *window)
+recent_chooser_item_activated_cb (GtkRecentChooser * chooser,
+ GladeWindow * window)
{
- gchar *uri, *path;
- GError *error = NULL;
+ gchar *uri, *path;
+ GError *error = NULL;
- uri = gtk_recent_chooser_get_current_uri (chooser);
+ uri = gtk_recent_chooser_get_current_uri (chooser);
- path = g_filename_from_uri (uri, NULL, NULL);
- if (error)
- {
- g_warning ("Could not convert uri \"%s\" to a local path: %s", uri, error->message);
- g_error_free (error);
- return;
- }
+ path = g_filename_from_uri (uri, NULL, NULL);
+ if (error)
+ {
+ g_warning ("Could not convert uri \"%s\" to a local path: %s", uri,
+ error->message);
+ g_error_free (error);
+ return;
+ }
- glade_window_open_project (window, path);
+ glade_window_open_project (window, path);
- g_free (uri);
- g_free (path);
+ g_free (uri);
+ g_free (path);
}
static void
-palette_appearance_change_cb (GtkRadioAction *action,
- GtkRadioAction *current,
- GladeWindow *window)
+palette_appearance_change_cb (GtkRadioAction * action,
+ GtkRadioAction * current, GladeWindow * window)
{
- gint value;
+ gint value;
- value = gtk_radio_action_get_current_value (action);
+ value = gtk_radio_action_get_current_value (action);
- glade_palette_set_item_appearance (glade_app_get_palette (), value);
+ glade_palette_set_item_appearance (glade_app_get_palette (), value);
}
static void
-palette_toggle_small_icons_cb (GtkAction *action, GladeWindow *window)
+palette_toggle_small_icons_cb (GtkAction * action, GladeWindow * window)
{
- glade_palette_set_use_small_item_icons (glade_app_get_palette(),
- gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ glade_palette_set_use_small_item_icons (glade_app_get_palette (),
+ gtk_toggle_action_get_active
+ (GTK_TOGGLE_ACTION (action)));
}
static gboolean
-on_dock_deleted (GtkWidget *widget,
- GdkEvent *event,
- GtkAction *dock_action)
+on_dock_deleted (GtkWidget * widget, GdkEvent * event, GtkAction * dock_action)
{
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (dock_action), TRUE);
- return TRUE;
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (dock_action), TRUE);
+ return TRUE;
}
static gboolean
-on_dock_resized (GtkWidget *window,
- GdkEventConfigure *event,
- ToolDock *dock)
+on_dock_resized (GtkWidget * window, GdkEventConfigure * event, ToolDock * dock)
{
- GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (gtk_widget_get_toplevel (dock->widget)));
- dock->maximized = gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED;
+ GdkWindow *gdk_window =
+ gtk_widget_get_window (GTK_WIDGET
+ (gtk_widget_get_toplevel (dock->widget)));
+ dock->maximized =
+ gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED;
- if(!dock->maximized) {
- dock->window_pos.width = event->width;
- dock->window_pos.height = event->height;
+ if (!dock->maximized)
+ {
+ dock->window_pos.width = event->width;
+ dock->window_pos.height = event->height;
- gtk_window_get_position (GTK_WINDOW (window),
- &dock->window_pos.x,
- &dock->window_pos.y);
- }
+ gtk_window_get_position (GTK_WINDOW (window),
+ &dock->window_pos.x, &dock->window_pos.y);
+ }
- return FALSE;
+ return FALSE;
}
static void
-toggle_dock_cb (GtkAction *action, GladeWindow *window)
+toggle_dock_cb (GtkAction * action, GladeWindow * window)
{
- GtkWidget *toplevel, *alignment;
- ToolDock *dock;
- guint dock_type;
+ GtkWidget *toplevel, *alignment;
+ ToolDock *dock;
+ guint dock_type;
- dock_type = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (action), "glade-dock-type"));
- g_return_if_fail (dock_type < N_DOCKS);
+ dock_type =
+ GPOINTER_TO_UINT (g_object_get_data
+ (G_OBJECT (action), "glade-dock-type"));
+ g_return_if_fail (dock_type < N_DOCKS);
- dock = &window->priv->docks[dock_type];
+ dock = &window->priv->docks[dock_type];
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- {
- toplevel = gtk_widget_get_toplevel (dock->widget);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ {
+ toplevel = gtk_widget_get_toplevel (dock->widget);
- g_object_ref (dock->widget);
- gtk_container_remove (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (toplevel))),
- dock->widget);
+ g_object_ref (dock->widget);
+ gtk_container_remove (GTK_CONTAINER
+ (gtk_bin_get_child (GTK_BIN (toplevel))),
+ dock->widget);
- if (dock->first_child)
- gtk_paned_pack1 (GTK_PANED (dock->paned), dock->widget, FALSE, FALSE);
- else
- gtk_paned_pack2 (GTK_PANED (dock->paned), dock->widget, FALSE, FALSE);
- g_object_unref (dock->widget);
+ if (dock->first_child)
+ gtk_paned_pack1 (GTK_PANED (dock->paned), dock->widget, FALSE, FALSE);
+ else
+ gtk_paned_pack2 (GTK_PANED (dock->paned), dock->widget, FALSE, FALSE);
+ g_object_unref (dock->widget);
- gtk_widget_show (dock->paned);
- dock->detached = FALSE;
+ gtk_widget_show (dock->paned);
+ dock->detached = FALSE;
- gtk_widget_destroy (toplevel);
- } else {
- toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_destroy (toplevel);
+ }
+ else
+ {
+ toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- /* Add a little padding on top to match the bottom */
- alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
- 4, 0, 0, 0);
- gtk_container_add (GTK_CONTAINER (toplevel), alignment);
- gtk_widget_show (alignment);
+ /* Add a little padding on top to match the bottom */
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 4, 0, 0, 0);
+ gtk_container_add (GTK_CONTAINER (toplevel), alignment);
+ gtk_widget_show (alignment);
- gtk_window_set_default_size (GTK_WINDOW (toplevel),
- dock->window_pos.width,
- dock->window_pos.height);
+ gtk_window_set_default_size (GTK_WINDOW (toplevel),
+ dock->window_pos.width,
+ dock->window_pos.height);
- if (dock->window_pos.x > G_MININT && dock->window_pos.y > G_MININT)
- gtk_window_move (GTK_WINDOW (toplevel),
- dock->window_pos.x,
- dock->window_pos.y);
+ if (dock->window_pos.x > G_MININT && dock->window_pos.y > G_MININT)
+ gtk_window_move (GTK_WINDOW (toplevel),
+ dock->window_pos.x, dock->window_pos.y);
- gtk_window_set_title (GTK_WINDOW (toplevel), dock->title);
- g_object_ref (dock->widget);
- gtk_container_remove (GTK_CONTAINER (dock->paned), dock->widget);
- gtk_container_add (GTK_CONTAINER (alignment), dock->widget);
- g_object_unref (dock->widget);
+ gtk_window_set_title (GTK_WINDOW (toplevel), dock->title);
+ g_object_ref (dock->widget);
+ gtk_container_remove (GTK_CONTAINER (dock->paned), dock->widget);
+ gtk_container_add (GTK_CONTAINER (alignment), dock->widget);
+ g_object_unref (dock->widget);
- g_signal_connect (G_OBJECT (toplevel), "delete-event",
- G_CALLBACK (on_dock_deleted), action);
- g_signal_connect (G_OBJECT (toplevel), "configure-event",
- G_CALLBACK (on_dock_resized), dock);
+ g_signal_connect (G_OBJECT (toplevel), "delete-event",
+ G_CALLBACK (on_dock_deleted), action);
+ g_signal_connect (G_OBJECT (toplevel), "configure-event",
+ G_CALLBACK (on_dock_resized), dock);
- if (!gtk_paned_get_child1 (GTK_PANED (dock->paned)) &&
- !gtk_paned_get_child2 (GTK_PANED (dock->paned)))
- gtk_widget_hide (dock->paned);
+ if (!gtk_paned_get_child1 (GTK_PANED (dock->paned)) &&
+ !gtk_paned_get_child2 (GTK_PANED (dock->paned)))
+ gtk_widget_hide (dock->paned);
- gtk_window_add_accel_group (GTK_WINDOW (toplevel),
- gtk_ui_manager_get_accel_group (window->priv->ui));
+ gtk_window_add_accel_group (GTK_WINDOW (toplevel),
+ gtk_ui_manager_get_accel_group (window->priv->
+ ui));
- g_signal_connect (G_OBJECT (toplevel), "key-press-event",
- G_CALLBACK (glade_utils_hijack_key_press), window);
+ g_signal_connect (G_OBJECT (toplevel), "key-press-event",
+ G_CALLBACK (glade_utils_hijack_key_press), window);
- dock->detached = TRUE;
+ dock->detached = TRUE;
- gtk_window_present (GTK_WINDOW (toplevel));
- }
+ gtk_window_present (GTK_WINDOW (toplevel));
+ }
}
static void
-toggle_toolbar_cb (GtkAction *action, GladeWindow *window)
+toggle_toolbar_cb (GtkAction * action, GladeWindow * window)
{
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- gtk_widget_show (window->priv->toolbar);
- else
- gtk_widget_hide (window->priv->toolbar);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ gtk_widget_show (window->priv->toolbar);
+ else
+ gtk_widget_hide (window->priv->toolbar);
}
static void
-toggle_statusbar_cb (GtkAction *action, GladeWindow *window)
+toggle_statusbar_cb (GtkAction * action, GladeWindow * window)
{
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- gtk_widget_show (window->priv->statusbar);
- else
- gtk_widget_hide (window->priv->statusbar);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ gtk_widget_show (window->priv->statusbar);
+ else
+ gtk_widget_hide (window->priv->statusbar);
}
static void
-toggle_tabs_cb (GtkAction *action, GladeWindow *window)
+toggle_tabs_cb (GtkAction * action, GladeWindow * window)
{
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), TRUE);
- else
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), TRUE);
+ else
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
}
static void
-show_help_cb (GtkAction *action, GladeWindow *window)
+show_help_cb (GtkAction * action, GladeWindow * window)
{
- gboolean retval;
+ gboolean retval;
- retval = glade_util_url_show ("ghelp:glade");
- if (retval)
- return;
+ retval = glade_util_url_show ("ghelp:glade");
+ if (retval)
+ return;
- /* fallback to displaying online user manual */
- glade_util_url_show (URL_USER_MANUAL);
+ /* fallback to displaying online user manual */
+ glade_util_url_show (URL_USER_MANUAL);
}
-static void
-show_developer_manual_cb (GtkAction *action, GladeWindow *window)
+static void
+show_developer_manual_cb (GtkAction * action, GladeWindow * window)
{
- if (glade_util_have_devhelp ())
- {
- glade_util_search_devhelp ("gladeui", NULL, NULL);
- return;
- }
+ if (glade_util_have_devhelp ())
+ {
+ glade_util_search_devhelp ("gladeui", NULL, NULL);
+ return;
+ }
- /* fallback to displaying online developer manual */
- glade_util_url_show (URL_DEVELOPER_MANUAL);
+ /* fallback to displaying online developer manual */
+ glade_util_url_show (URL_DEVELOPER_MANUAL);
}
-static void
-about_cb (GtkAction *action, GladeWindow *window)
+static void
+about_cb (GtkAction * action, GladeWindow * window)
{
- static const gchar * const authors[] =
- { "Chema Celorio <chema ximian com>",
- "Joaquin Cuenca Abela <e98cuenc yahoo com>",
- "Paolo Borelli <pborelli katamail com>",
- "Archit Baweja <bighead users sourceforge net>",
- "Shane Butler <shane_b operamail com>",
- "Tristan Van Berkom <tvb gnome org>",
- "Ivan Wong <email ivanwong info>",
- "Juan Pablo Ugarte <juanpablougarte gmail com>",
- "Vincent Geddes <vincent geddes gmail com>",
- NULL };
-
- static const gchar * const artists[] =
- { "Vincent Geddes <vgeddes gnome org>",
- "Andreas Nilsson <andreas andreasn se>",
- NULL };
-
- static const gchar * const documenters[] =
- { "GNOME Documentation Team <gnome-doc-list gnome org>",
- "Sun GNOME Documentation Team <gdocteam sun com>",
- NULL };
+ static const gchar *const authors[] = { "Chema Celorio <chema ximian com>",
+ "Joaquin Cuenca Abela <e98cuenc yahoo com>",
+ "Paolo Borelli <pborelli katamail com>",
+ "Archit Baweja <bighead users sourceforge net>",
+ "Shane Butler <shane_b operamail com>",
+ "Tristan Van Berkom <tvb gnome org>",
+ "Ivan Wong <email ivanwong info>",
+ "Juan Pablo Ugarte <juanpablougarte gmail com>",
+ "Vincent Geddes <vincent geddes gmail com>",
+ NULL
+ };
+
+ static const gchar *const artists[] = { "Vincent Geddes <vgeddes gnome org>",
+ "Andreas Nilsson <andreas andreasn se>",
+ NULL
+ };
- static const gchar license[] =
- N_("Glade is free software; you can redistribute it and/or modify "
- "it under the terms of the GNU General Public License as "
- "published by the Free Software Foundation; either version 2 of the "
- "License, or (at your option) any later version."
- "\n\n"
- "Glade is distributed in the hope that it will be useful, "
- "but WITHOUT ANY WARRANTY; without even the implied warranty of "
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
- "GNU General Public License for more details."
- "\n\n"
- "You should have received a copy of the GNU General Public License "
- "along with Glade; if not, write to the Free Software "
- "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
- "MA 02110-1301, USA.");
+ static const gchar *const documenters[] =
+ { "GNOME Documentation Team <gnome-doc-list gnome org>",
+ "Sun GNOME Documentation Team <gdocteam sun com>",
+ NULL
+ };
- static const gchar copyright[] =
- "Copyright \xc2\xa9 2001-2006 Ximian, Inc.\n"
- "Copyright \xc2\xa9 2001-2006 Joaquin Cuenca Abela, Paolo Borelli, et al.\n"
- "Copyright \xc2\xa9 2001-2010 Tristan Van Berkom, Juan Pablo Ugarte, et al.";
-
- gtk_show_about_dialog (GTK_WINDOW (window),
- "name", g_get_application_name (),
- "logo-icon-name", "glade-3",
- "authors", authors,
- "artists", artists,
- "documenters", documenters,
- "translator-credits", _("translator-credits"),
- "comments", _("A user interface designer for GTK+ and GNOME."),
- "license", _(license),
- "wrap-license", TRUE,
- "copyright", copyright,
- "version", PACKAGE_VERSION,
- "website", PACKAGE_URL,
- NULL);
+ static const gchar license[] =
+ N_("Glade is free software; you can redistribute it and/or modify "
+ "it under the terms of the GNU General Public License as "
+ "published by the Free Software Foundation; either version 2 of the "
+ "License, or (at your option) any later version."
+ "\n\n"
+ "Glade is distributed in the hope that it will be useful, "
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
+ "GNU General Public License for more details."
+ "\n\n"
+ "You should have received a copy of the GNU General Public License "
+ "along with Glade; if not, write to the Free Software "
+ "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, "
+ "MA 02110-1301, USA.");
+
+ static const gchar copyright[] =
+ "Copyright \xc2\xa9 2001-2006 Ximian, Inc.\n"
+ "Copyright \xc2\xa9 2001-2006 Joaquin Cuenca Abela, Paolo Borelli, et al.\n"
+ "Copyright \xc2\xa9 2001-2010 Tristan Van Berkom, Juan Pablo Ugarte, et al.";
+
+ gtk_show_about_dialog (GTK_WINDOW (window),
+ "name", g_get_application_name (),
+ "logo-icon-name", "glade-3",
+ "authors", authors,
+ "artists", artists,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ "comments",
+ _("A user interface designer for GTK+ and GNOME."),
+ "license", _(license), "wrap-license", TRUE,
+ "copyright", copyright, "version", PACKAGE_VERSION,
+ "website", PACKAGE_URL, NULL);
}
static const gchar ui_info[] =
-"<ui>"
-" <menubar name='MenuBar'>"
-" <menu action='FileMenu'>"
-" <menuitem action='New'/>"
-" <menuitem action='Open'/>"
-" <menuitem action='OpenRecent'/>"
-" <separator/>"
-" <menuitem action='Save'/>"
-" <menuitem action='SaveAs'/>"
-" <separator/>"
-" <menuitem action='Close'/>"
-" <menuitem action='Quit'/>"
-" </menu>"
-" <menu action='EditMenu'>"
-" <menuitem action='Undo'/>"
-" <menuitem action='Redo'/>"
-" <separator/>"
-" <menuitem action='Cut'/>"
-" <menuitem action='Copy'/>"
-" <menuitem action='Paste'/>"
-" <menuitem action='Delete'/>"
-" <separator/>"
-" <menuitem action='Preferences'/>"
-" </menu>"
-" <menu action='ViewMenu'>"
-" <menuitem action='ToolbarVisible'/>"
-" <menuitem action='StatusbarVisible'/>"
-" <menuitem action='ProjectTabsVisible'/>"
-" <menu action='PaletteAppearance'>"
-" <menuitem action='IconsAndLabels'/>"
-" <menuitem action='IconsOnly'/>"
-" <menuitem action='LabelsOnly'/>"
-" <separator/>"
-" <menuitem action='UseSmallIcons'/>"
-" </menu>"
-" <separator/>"
-" <menuitem action='DockPalette'/>"
-" <menuitem action='DockInspector'/>"
-" <menuitem action='DockEditor'/>"
-" </menu>"
-" <menu action='ProjectMenu'>"
-" <menuitem action='PreviousProject'/>"
-" <menuitem action='NextProject'/>"
-" <separator/>"
-" <placeholder name='ProjectsListPlaceholder'/>"
-" </menu>"
-" <menu action='HelpMenu'>"
-" <menuitem action='HelpContents'/>"
-" <menuitem action='DeveloperReference'/>"
-" <separator/>"
-" <menuitem action='About'/>"
-" </menu>"
-" </menubar>"
-" <toolbar name='ToolBar'>"
-" <toolitem action='New'/>"
-" <toolitem action='Open'/>"
-" <toolitem action='Save'/>"
-" <separator/>"
-" <toolitem action='Cut'/>"
-" <toolitem action='Copy'/>"
-" <toolitem action='Paste'/>"
-" </toolbar>"
-"</ui>";
+ "<ui>"
+ " <menubar name='MenuBar'>"
+ " <menu action='FileMenu'>"
+ " <menuitem action='New'/>"
+ " <menuitem action='Open'/>"
+ " <menuitem action='OpenRecent'/>"
+ " <separator/>"
+ " <menuitem action='Save'/>"
+ " <menuitem action='SaveAs'/>"
+ " <separator/>"
+ " <menuitem action='Close'/>"
+ " <menuitem action='Quit'/>"
+ " </menu>"
+ " <menu action='EditMenu'>"
+ " <menuitem action='Undo'/>"
+ " <menuitem action='Redo'/>"
+ " <separator/>"
+ " <menuitem action='Cut'/>"
+ " <menuitem action='Copy'/>"
+ " <menuitem action='Paste'/>"
+ " <menuitem action='Delete'/>"
+ " <separator/>"
+ " <menuitem action='Preferences'/>"
+ " </menu>"
+ " <menu action='ViewMenu'>"
+ " <menuitem action='ToolbarVisible'/>"
+ " <menuitem action='StatusbarVisible'/>"
+ " <menuitem action='ProjectTabsVisible'/>"
+ " <menu action='PaletteAppearance'>"
+ " <menuitem action='IconsAndLabels'/>"
+ " <menuitem action='IconsOnly'/>"
+ " <menuitem action='LabelsOnly'/>"
+ " <separator/>"
+ " <menuitem action='UseSmallIcons'/>"
+ " </menu>"
+ " <separator/>"
+ " <menuitem action='DockPalette'/>"
+ " <menuitem action='DockInspector'/>"
+ " <menuitem action='DockEditor'/>"
+ " </menu>"
+ " <menu action='ProjectMenu'>"
+ " <menuitem action='PreviousProject'/>"
+ " <menuitem action='NextProject'/>"
+ " <separator/>"
+ " <placeholder name='ProjectsListPlaceholder'/>"
+ " </menu>"
+ " <menu action='HelpMenu'>"
+ " <menuitem action='HelpContents'/>"
+ " <menuitem action='DeveloperReference'/>"
+ " <separator/>"
+ " <menuitem action='About'/>"
+ " </menu>"
+ " </menubar>"
+ " <toolbar name='ToolBar'>"
+ " <toolitem action='New'/>"
+ " <toolitem action='Open'/>"
+ " <toolitem action='Save'/>"
+ " <separator/>"
+ " <toolitem action='Cut'/>"
+ " <toolitem action='Copy'/>"
+ " <toolitem action='Paste'/>" " </toolbar>" "</ui>";
static GtkActionEntry static_entries[] = {
- { "FileMenu", NULL, N_("_File") },
- { "EditMenu", NULL, N_("_Edit") },
- { "ViewMenu", NULL, N_("_View") },
- { "ProjectMenu", NULL, N_("_Projects") },
- { "HelpMenu", NULL, N_("_Help") },
- { "UndoMenu", NULL, NULL },
- { "RedoMenu", NULL, NULL },
-
- /* FileMenu */
- { "New", GTK_STOCK_NEW, NULL, "<control>N",
- N_("Create a new project"), G_CALLBACK (new_cb) },
-
- { "Open", GTK_STOCK_OPEN, N_("_Open\342\200\246") ,"<control>O",
- N_("Open a project"), G_CALLBACK (open_cb) },
-
- { "OpenRecent", NULL, N_("Open _Recent") },
-
- { "Quit", GTK_STOCK_QUIT, NULL, "<control>Q",
- N_("Quit the program"), G_CALLBACK (quit_cb) },
-
- /* ViewMenu */
- { "PaletteAppearance", NULL, N_("Palette _Appearance") },
-
- /* HelpMenu */
- { "About", GTK_STOCK_ABOUT, NULL, NULL,
- N_("About this application"), G_CALLBACK (about_cb) },
-
- { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
- N_("Display the user manual"), G_CALLBACK (show_help_cb) },
-
- { "DeveloperReference", NULL, N_("_Developer Reference"), NULL,
- N_("Display the developer reference manual"), G_CALLBACK (show_developer_manual_cb) }
+ {"FileMenu", NULL, N_("_File")},
+ {"EditMenu", NULL, N_("_Edit")},
+ {"ViewMenu", NULL, N_("_View")},
+ {"ProjectMenu", NULL, N_("_Projects")},
+ {"HelpMenu", NULL, N_("_Help")},
+ {"UndoMenu", NULL, NULL},
+ {"RedoMenu", NULL, NULL},
+
+ /* FileMenu */
+ {"New", GTK_STOCK_NEW, NULL, "<control>N",
+ N_("Create a new project"), G_CALLBACK (new_cb)},
+
+ {"Open", GTK_STOCK_OPEN, N_("_Open\342\200\246"), "<control>O",
+ N_("Open a project"), G_CALLBACK (open_cb)},
+
+ {"OpenRecent", NULL, N_("Open _Recent")},
+
+ {"Quit", GTK_STOCK_QUIT, NULL, "<control>Q",
+ N_("Quit the program"), G_CALLBACK (quit_cb)},
+
+ /* ViewMenu */
+ {"PaletteAppearance", NULL, N_("Palette _Appearance")},
+
+ /* HelpMenu */
+ {"About", GTK_STOCK_ABOUT, NULL, NULL,
+ N_("About this application"), G_CALLBACK (about_cb)},
+
+ {"HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
+ N_("Display the user manual"), G_CALLBACK (show_help_cb)},
+
+ {"DeveloperReference", NULL, N_("_Developer Reference"), NULL,
+ N_("Display the developer reference manual"),
+ G_CALLBACK (show_developer_manual_cb)}
};
static guint n_static_entries = G_N_ELEMENTS (static_entries);
static GtkActionEntry project_entries[] = {
- /* FileMenu */
- { "Save", GTK_STOCK_SAVE, NULL, "<control>S",
- N_("Save the current project"), G_CALLBACK (save_cb) },
-
- { "SaveAs", GTK_STOCK_SAVE_AS, N_("Save _As\342\200\246"), NULL,
- N_("Save the current project with a different name"), G_CALLBACK (save_as_cb) },
-
- { "Close", GTK_STOCK_CLOSE, NULL, "<control>W",
- N_("Close the current project"), G_CALLBACK (close_cb) },
-
- /* EditMenu */
- { "Undo", GTK_STOCK_UNDO, NULL, "<control>Z",
- N_("Undo the last action"), G_CALLBACK (undo_cb) },
-
- { "Redo", GTK_STOCK_REDO, NULL, "<shift><control>Z",
- N_("Redo the last action"), G_CALLBACK (redo_cb) },
-
- { "Cut", GTK_STOCK_CUT, NULL, NULL,
- N_("Cut the selection"), G_CALLBACK (cut_cb) },
-
- { "Copy", GTK_STOCK_COPY, NULL, NULL,
- N_("Copy the selection"), G_CALLBACK (copy_cb) },
-
- { "Paste", GTK_STOCK_PASTE, NULL, NULL,
- N_("Paste the clipboard"), G_CALLBACK (paste_cb) },
-
- { "Delete", GTK_STOCK_DELETE, NULL, "Delete",
- N_("Delete the selection"), G_CALLBACK (delete_cb) },
-
- { "Preferences", GTK_STOCK_PREFERENCES, NULL, "<control>P",
- N_("Modify project preferences"), G_CALLBACK (preferences_cb) },
-
- /* ProjectsMenu */
- { "PreviousProject", NULL, N_("_Previous Project"), "<control>Page_Up",
- N_("Activate previous project"), G_CALLBACK (previous_project_cb) },
-
- { "NextProject", NULL, N_("_Next Project"), "<control>Page_Down",
- N_("Activate next project"), G_CALLBACK (next_project_cb) }
+ /* FileMenu */
+ {"Save", GTK_STOCK_SAVE, NULL, "<control>S",
+ N_("Save the current project"), G_CALLBACK (save_cb)},
+
+ {"SaveAs", GTK_STOCK_SAVE_AS, N_("Save _As\342\200\246"), NULL,
+ N_("Save the current project with a different name"),
+ G_CALLBACK (save_as_cb)},
+
+ {"Close", GTK_STOCK_CLOSE, NULL, "<control>W",
+ N_("Close the current project"), G_CALLBACK (close_cb)},
+
+ /* EditMenu */
+ {"Undo", GTK_STOCK_UNDO, NULL, "<control>Z",
+ N_("Undo the last action"), G_CALLBACK (undo_cb)},
+
+ {"Redo", GTK_STOCK_REDO, NULL, "<shift><control>Z",
+ N_("Redo the last action"), G_CALLBACK (redo_cb)},
+
+ {"Cut", GTK_STOCK_CUT, NULL, NULL,
+ N_("Cut the selection"), G_CALLBACK (cut_cb)},
+
+ {"Copy", GTK_STOCK_COPY, NULL, NULL,
+ N_("Copy the selection"), G_CALLBACK (copy_cb)},
+
+ {"Paste", GTK_STOCK_PASTE, NULL, NULL,
+ N_("Paste the clipboard"), G_CALLBACK (paste_cb)},
+
+ {"Delete", GTK_STOCK_DELETE, NULL, "Delete",
+ N_("Delete the selection"), G_CALLBACK (delete_cb)},
+
+ {"Preferences", GTK_STOCK_PREFERENCES, NULL, "<control>P",
+ N_("Modify project preferences"), G_CALLBACK (preferences_cb)},
+
+ /* ProjectsMenu */
+ {"PreviousProject", NULL, N_("_Previous Project"), "<control>Page_Up",
+ N_("Activate previous project"), G_CALLBACK (previous_project_cb)},
+
+ {"NextProject", NULL, N_("_Next Project"), "<control>Page_Down",
+ N_("Activate next project"), G_CALLBACK (next_project_cb)}
};
+
static guint n_project_entries = G_N_ELEMENTS (project_entries);
static GtkToggleActionEntry view_entries[] = {
- { "UseSmallIcons", NULL, N_("_Use Small Icons"), NULL,
- N_("Show items using small icons"),
- G_CALLBACK (palette_toggle_small_icons_cb), FALSE },
+ {"UseSmallIcons", NULL, N_("_Use Small Icons"), NULL,
+ N_("Show items using small icons"),
+ G_CALLBACK (palette_toggle_small_icons_cb), FALSE},
- { "DockPalette", NULL, N_("Dock _Palette"), NULL,
- N_("Dock the palette into the main window"),
- G_CALLBACK (toggle_dock_cb), TRUE },
+ {"DockPalette", NULL, N_("Dock _Palette"), NULL,
+ N_("Dock the palette into the main window"),
+ G_CALLBACK (toggle_dock_cb), TRUE},
- { "DockInspector", NULL, N_("Dock _Inspector"), NULL,
- N_("Dock the inspector into the main window"),
- G_CALLBACK (toggle_dock_cb), TRUE },
+ {"DockInspector", NULL, N_("Dock _Inspector"), NULL,
+ N_("Dock the inspector into the main window"),
+ G_CALLBACK (toggle_dock_cb), TRUE},
- { "DockEditor", NULL, N_("Dock Prop_erties"), NULL,
- N_("Dock the editor into the main window"),
- G_CALLBACK (toggle_dock_cb), TRUE },
+ {"DockEditor", NULL, N_("Dock Prop_erties"), NULL,
+ N_("Dock the editor into the main window"),
+ G_CALLBACK (toggle_dock_cb), TRUE},
- { "ToolbarVisible", NULL, N_("Tool_bar"), NULL,
- N_("Show the toolbar"),
- G_CALLBACK (toggle_toolbar_cb), TRUE },
+ {"ToolbarVisible", NULL, N_("Tool_bar"), NULL,
+ N_("Show the toolbar"),
+ G_CALLBACK (toggle_toolbar_cb), TRUE},
- { "StatusbarVisible", NULL, N_("_Statusbar"), NULL,
- N_("Show the statusbar"),
- G_CALLBACK (toggle_statusbar_cb), TRUE },
+ {"StatusbarVisible", NULL, N_("_Statusbar"), NULL,
+ N_("Show the statusbar"),
+ G_CALLBACK (toggle_statusbar_cb), TRUE},
- { "ProjectTabsVisible", NULL, N_("Project _Tabs"), NULL,
- N_("Show notebook tabs for loaded projects"),
- G_CALLBACK (toggle_tabs_cb), TRUE },
+ {"ProjectTabsVisible", NULL, N_("Project _Tabs"), NULL,
+ N_("Show notebook tabs for loaded projects"),
+ G_CALLBACK (toggle_tabs_cb), TRUE},
};
+
static guint n_view_entries = G_N_ELEMENTS (view_entries);
static GtkRadioActionEntry radio_entries[] = {
- { "IconsAndLabels", NULL, N_("Text beside icons"), NULL,
- N_("Display items as text beside icons"), GLADE_ITEM_ICON_AND_LABEL },
+ {"IconsAndLabels", NULL, N_("Text beside icons"), NULL,
+ N_("Display items as text beside icons"), GLADE_ITEM_ICON_AND_LABEL},
- { "IconsOnly", NULL, N_("_Icons only"), NULL,
- N_("Display items as icons only"), GLADE_ITEM_ICON_ONLY },
+ {"IconsOnly", NULL, N_("_Icons only"), NULL,
+ N_("Display items as icons only"), GLADE_ITEM_ICON_ONLY},
- { "LabelsOnly", NULL, N_("_Text only"), NULL,
- N_("Display items as text only"), GLADE_ITEM_LABEL_ONLY },
+ {"LabelsOnly", NULL, N_("_Text only"), NULL,
+ N_("Display items as text only"), GLADE_ITEM_LABEL_ONLY},
};
+
static guint n_radio_entries = G_N_ELEMENTS (radio_entries);
static void
-menu_item_selected_cb (GtkWidget *item, GladeWindow *window)
+menu_item_selected_cb (GtkWidget * item, GladeWindow * window)
{
- GtkAction *action;
- gchar *tooltip;
+ GtkAction *action;
+ gchar *tooltip;
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item));
- g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
+ action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item));
+ g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
- if (tooltip != NULL)
- gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->statusbar_menu_context_id, tooltip);
+ if (tooltip != NULL)
+ gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->statusbar_menu_context_id, tooltip);
- g_free (tooltip);
+ g_free (tooltip);
}
/* FIXME: GtkItem does not exist anymore? */
static void
-menu_item_deselected_cb (gpointer item, GladeWindow *window)
+menu_item_deselected_cb (gpointer item, GladeWindow * window)
{
- gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->statusbar_menu_context_id);
+ gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->statusbar_menu_context_id);
}
static void
-ui_connect_proxy_cb (GtkUIManager *ui,
- GtkAction *action,
- GtkWidget *proxy,
- GladeWindow *window)
-{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_connect(G_OBJECT(proxy), "select",
- G_CALLBACK (menu_item_selected_cb), window);
- g_signal_connect(G_OBJECT(proxy), "deselect",
- G_CALLBACK (menu_item_deselected_cb), window);
- }
+ui_connect_proxy_cb (GtkUIManager * ui,
+ GtkAction * action,
+ GtkWidget * proxy, GladeWindow * window)
+{
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_connect (G_OBJECT (proxy), "select",
+ G_CALLBACK (menu_item_selected_cb), window);
+ g_signal_connect (G_OBJECT (proxy), "deselect",
+ G_CALLBACK (menu_item_deselected_cb), window);
+ }
}
static void
-ui_disconnect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy,
- GladeWindow *window)
+ui_disconnect_proxy_cb (GtkUIManager * manager,
+ GtkAction * action,
+ GtkWidget * proxy, GladeWindow * window)
{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_selected_cb), window);
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_deselected_cb), window);
- }
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_selected_cb), window);
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_deselected_cb), window);
+ }
}
static GtkWidget *
-construct_menu (GladeWindow *window)
-{
- GError *error = NULL;
-
- window->priv->static_actions = gtk_action_group_new (ACTION_GROUP_STATIC);
- gtk_action_group_set_translation_domain (window->priv->static_actions, GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (window->priv->static_actions,
- static_entries,
- n_static_entries,
- window);
- gtk_action_group_add_toggle_actions (window->priv->static_actions,
- view_entries,
- n_view_entries,
- window);
- gtk_action_group_add_radio_actions (window->priv->static_actions, radio_entries,
- n_radio_entries, GLADE_ITEM_ICON_ONLY,
- G_CALLBACK (palette_appearance_change_cb), window);
-
- window->priv->project_actions = gtk_action_group_new (ACTION_GROUP_PROJECT);
- gtk_action_group_set_translation_domain (window->priv->project_actions, GETTEXT_PACKAGE);
-
- gtk_action_group_add_actions (window->priv->project_actions,
- project_entries,
- n_project_entries,
- window);
-
- window->priv->projects_list_menu_actions =
- gtk_action_group_new (ACTION_GROUP_PROJECTS_LIST_MENU);
- gtk_action_group_set_translation_domain (window->priv->projects_list_menu_actions,
- GETTEXT_PACKAGE);
-
- window->priv->ui = gtk_ui_manager_new ();
-
- g_signal_connect(G_OBJECT(window->priv->ui), "connect-proxy",
- G_CALLBACK (ui_connect_proxy_cb), window);
- g_signal_connect(G_OBJECT(window->priv->ui), "disconnect-proxy",
- G_CALLBACK (ui_disconnect_proxy_cb), window);
-
- gtk_ui_manager_insert_action_group (window->priv->ui, window->priv->static_actions, 0);
- gtk_ui_manager_insert_action_group (window->priv->ui, window->priv->project_actions, 1);
- gtk_ui_manager_insert_action_group (window->priv->ui, window->priv->projects_list_menu_actions, 3);
-
- gtk_window_add_accel_group (GTK_WINDOW (window),
- gtk_ui_manager_get_accel_group (window->priv->ui));
-
- glade_app_set_accel_group (gtk_ui_manager_get_accel_group (window->priv->ui));
-
- if (!gtk_ui_manager_add_ui_from_string (window->priv->ui, ui_info, -1, &error))
- {
- g_message ("Building menus failed: %s", error->message);
- g_error_free (error);
- }
-
- return gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar");
+construct_menu (GladeWindow * window)
+{
+ GError *error = NULL;
+
+ window->priv->static_actions = gtk_action_group_new (ACTION_GROUP_STATIC);
+ gtk_action_group_set_translation_domain (window->priv->static_actions,
+ GETTEXT_PACKAGE);
+
+ gtk_action_group_add_actions (window->priv->static_actions,
+ static_entries, n_static_entries, window);
+ gtk_action_group_add_toggle_actions (window->priv->static_actions,
+ view_entries, n_view_entries, window);
+ gtk_action_group_add_radio_actions (window->priv->static_actions,
+ radio_entries, n_radio_entries,
+ GLADE_ITEM_ICON_ONLY,
+ G_CALLBACK (palette_appearance_change_cb),
+ window);
+
+ window->priv->project_actions = gtk_action_group_new (ACTION_GROUP_PROJECT);
+ gtk_action_group_set_translation_domain (window->priv->project_actions,
+ GETTEXT_PACKAGE);
+
+ gtk_action_group_add_actions (window->priv->project_actions,
+ project_entries, n_project_entries, window);
+
+ window->priv->projects_list_menu_actions =
+ gtk_action_group_new (ACTION_GROUP_PROJECTS_LIST_MENU);
+ gtk_action_group_set_translation_domain (window->priv->
+ projects_list_menu_actions,
+ GETTEXT_PACKAGE);
+
+ window->priv->ui = gtk_ui_manager_new ();
+
+ g_signal_connect (G_OBJECT (window->priv->ui), "connect-proxy",
+ G_CALLBACK (ui_connect_proxy_cb), window);
+ g_signal_connect (G_OBJECT (window->priv->ui), "disconnect-proxy",
+ G_CALLBACK (ui_disconnect_proxy_cb), window);
+
+ gtk_ui_manager_insert_action_group (window->priv->ui,
+ window->priv->static_actions, 0);
+ gtk_ui_manager_insert_action_group (window->priv->ui,
+ window->priv->project_actions, 1);
+ gtk_ui_manager_insert_action_group (window->priv->ui,
+ window->priv->projects_list_menu_actions,
+ 3);
+
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ gtk_ui_manager_get_accel_group (window->priv->
+ ui));
+
+ glade_app_set_accel_group (gtk_ui_manager_get_accel_group (window->priv->ui));
+
+ if (!gtk_ui_manager_add_ui_from_string
+ (window->priv->ui, ui_info, -1, &error))
+ {
+ g_message ("Building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+
+ return gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar");
}
enum
{
- TARGET_URI_LIST
+ TARGET_URI_LIST
};
-static GtkTargetEntry drop_types[] =
-{
- {"text/uri-list", 0, TARGET_URI_LIST}
+static GtkTargetEntry drop_types[] = {
+ {"text/uri-list", 0, TARGET_URI_LIST}
};
static void
-drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x, gint y,
- GtkSelectionData *selection_data,
- guint info, guint time, GladeWindow *window)
+drag_data_received (GtkWidget * widget,
+ GdkDragContext * context,
+ gint x, gint y,
+ GtkSelectionData * selection_data,
+ guint info, guint time, GladeWindow * window)
{
- gchar **uris, **str;
- const guchar *data;
+ gchar **uris, **str;
+ const guchar *data;
- if (info != TARGET_URI_LIST)
- return;
+ if (info != TARGET_URI_LIST)
+ return;
- data = gtk_selection_data_get_data (selection_data);
+ data = gtk_selection_data_get_data (selection_data);
- uris = g_uri_list_extract_uris ((gchar *) data);
+ uris = g_uri_list_extract_uris ((gchar *) data);
- for (str = uris; *str; str++)
- {
- GError *error = NULL;
- gchar *path = g_filename_from_uri (*str, NULL, &error);
+ for (str = uris; *str; str++)
+ {
+ GError *error = NULL;
+ gchar *path = g_filename_from_uri (*str, NULL, &error);
- if (path)
- {
- glade_window_open_project (window, path);
- }
- else
- {
- g_warning ("Could not convert uri to local path: %s", error->message);
+ if (path)
+ {
+ glade_window_open_project (window, path);
+ }
+ else
+ {
+ g_warning ("Could not convert uri to local path: %s", error->message);
- g_error_free (error);
- }
- g_free (path);
- }
- g_strfreev (uris);
+ g_error_free (error);
+ }
+ g_free (path);
+ }
+ g_strfreev (uris);
}
static gboolean
-delete_event (GtkWindow *w, GdkEvent *event, GladeWindow *window)
+delete_event (GtkWindow * w, GdkEvent * event, GladeWindow * window)
{
- quit_cb (NULL, window);
-
- /* return TRUE to stop other handlers */
- return TRUE;
+ quit_cb (NULL, window);
+
+ /* return TRUE to stop other handlers */
+ return TRUE;
}
static GtkWidget *
-create_selector_tool_button (GtkToolbar *toolbar)
-{
- GtkToolItem *button;
- GtkWidget *image;
- gchar *image_path;
-
- image_path = g_build_filename (glade_app_get_pixmaps_dir (), "selector.png", NULL);
- image = gtk_image_new_from_file (image_path);
- g_free (image_path);
-
- button = gtk_toggle_tool_button_new ();
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (button), TRUE);
-
- gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), image);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), _("Select"));
-
- gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
- _("Select widgets in the workspace"));
-
- gtk_widget_show (GTK_WIDGET (button));
- gtk_widget_show (image);
-
- return GTK_WIDGET (button);
+create_selector_tool_button (GtkToolbar * toolbar)
+{
+ GtkToolItem *button;
+ GtkWidget *image;
+ gchar *image_path;
+
+ image_path =
+ g_build_filename (glade_app_get_pixmaps_dir (), "selector.png", NULL);
+ image = gtk_image_new_from_file (image_path);
+ g_free (image_path);
+
+ button = gtk_toggle_tool_button_new ();
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (button), TRUE);
+
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), image);
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), _("Select"));
+
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
+ _("Select widgets in the workspace"));
+
+ gtk_widget_show (GTK_WIDGET (button));
+ gtk_widget_show (image);
+
+ return GTK_WIDGET (button);
}
static GtkWidget *
-create_preview_tool_button (GtkToolbar *toolbar)
+create_preview_tool_button (GtkToolbar * toolbar)
{
- GtkToolItem *button;
- button = gtk_tool_button_new_from_stock (GTK_STOCK_EXECUTE);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON(button), _("Preview snapshot"));
+ GtkToolItem *button;
+ button = gtk_tool_button_new_from_stock (GTK_STOCK_EXECUTE);
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), _("Preview snapshot"));
- gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
- _("Previews snapshot of project"));
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
+ _("Previews snapshot of project"));
- gtk_widget_show (GTK_WIDGET (button));
+ gtk_widget_show (GTK_WIDGET (button));
- return GTK_WIDGET (button);
+ return GTK_WIDGET (button);
}
static GtkWidget *
-create_drag_resize_tool_button (GtkToolbar *toolbar)
+create_drag_resize_tool_button (GtkToolbar * toolbar)
{
- GtkToolItem *button;
- GtkWidget *image;
- gchar *image_path;
-
- image_path = g_build_filename (glade_app_get_pixmaps_dir (), "drag-resize.png", NULL);
- image = gtk_image_new_from_file (image_path);
- g_free (image_path);
-
- button = gtk_toggle_tool_button_new ();
- gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (button), TRUE);
-
- gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), image);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), _("Drag Resize"));
-
- gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
- _("Drag and resize widgets in the workspace"));
-
- gtk_widget_show (GTK_WIDGET (button));
- gtk_widget_show (image);
-
- return GTK_WIDGET (button);
+ GtkToolItem *button;
+ GtkWidget *image;
+ gchar *image_path;
+
+ image_path =
+ g_build_filename (glade_app_get_pixmaps_dir (), "drag-resize.png", NULL);
+ image = gtk_image_new_from_file (image_path);
+ g_free (image_path);
+
+ button = gtk_toggle_tool_button_new ();
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (button), TRUE);
+
+ gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), image);
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), _("Drag Resize"));
+
+ gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
+ _
+ ("Drag and resize widgets in the workspace"));
+
+ gtk_widget_show (GTK_WIDGET (button));
+ gtk_widget_show (image);
+
+ return GTK_WIDGET (button);
}
-static void
-tab_close_button_clicked_cb (GtkWidget *close_button,
- GladeProject *project)
+static void
+tab_close_button_clicked_cb (GtkWidget * close_button, GladeProject * project)
{
- GladeWindow *window = GLADE_WINDOW (glade_app_get_window ());
- gboolean close;
+ GladeWindow *window = GLADE_WINDOW (glade_app_get_window ());
+ gboolean close;
- if (glade_project_get_modified (project))
- {
- close = confirm_close_project (window, project);
- if (!close)
- return;
- }
- do_close (window, project);
+ if (glade_project_get_modified (project))
+ {
+ close = confirm_close_project (window, project);
+ if (!close)
+ return;
+ }
+ do_close (window, project);
}
static void
-project_load_progress_cb (GladeProject *project,
- gint total,
- gint step,
- GtkProgressBar *progress)
+project_load_progress_cb (GladeProject * project,
+ gint total, gint step, GtkProgressBar * progress)
{
- gchar *name;
+ gchar *name;
+
+ name = glade_project_get_name (project);
- name = glade_project_get_name (project);
+ /* translators: "project name (objects loaded in total objects)" */
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), name);
+ g_free (name);
- /* translators: "project name (objects loaded in total objects)" */
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), name);
- g_free (name);
-
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), step * 1.0 / total);
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress),
+ step * 1.0 / total);
- while (gtk_events_pending ())
- gtk_main_iteration ();
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
}
static void
-project_load_finished_cb (GladeProject *project,
- GtkWidget *tab_label)
+project_load_finished_cb (GladeProject * project, GtkWidget * tab_label)
{
- GtkWidget *progress, *label;
+ GtkWidget *progress, *label;
- progress = g_object_get_data (G_OBJECT (tab_label), "tab-progress");
- label = g_object_get_data (G_OBJECT (tab_label), "tab-label");
+ progress = g_object_get_data (G_OBJECT (tab_label), "tab-progress");
+ label = g_object_get_data (G_OBJECT (tab_label), "tab-label");
- gtk_widget_hide (progress);
- gtk_widget_show (label);
+ gtk_widget_hide (progress);
+ gtk_widget_show (label);
}
static GtkWidget *
-create_notebook_tab (GladeWindow *window, GladeProject *project, gboolean for_file)
+create_notebook_tab (GladeWindow * window, GladeProject * project,
+ gboolean for_file)
{
- GtkWidget *tab_label, *ebox, *hbox, *close_button, *label, *dummy_label;
- GtkWidget *progress;
+ GtkWidget *tab_label, *ebox, *hbox, *close_button, *label, *dummy_label;
+ GtkWidget *progress;
- tab_label = gtk_hbox_new (FALSE, 4);
-
- ebox = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
- gtk_box_pack_start (GTK_BOX (tab_label), ebox, TRUE, TRUE, 0);
+ tab_label = gtk_hbox_new (FALSE, 4);
- hbox = gtk_hbox_new (FALSE, 4);
- gtk_container_add (GTK_CONTAINER (ebox), hbox);
+ ebox = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
+ gtk_box_pack_start (GTK_BOX (tab_label), ebox, TRUE, TRUE, 0);
- close_button = glade_close_button_new ();
- gtk_widget_set_tooltip_text (close_button, _("Close document"));
- gtk_box_pack_start (GTK_BOX (tab_label), close_button, FALSE, FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 4);
+ gtk_container_add (GTK_CONTAINER (ebox), hbox);
- g_signal_connect (close_button,
- "clicked",
- G_CALLBACK (tab_close_button_clicked_cb),
- project);
+ close_button = glade_close_button_new ();
+ gtk_widget_set_tooltip_text (close_button, _("Close document"));
+ gtk_box_pack_start (GTK_BOX (tab_label), close_button, FALSE, FALSE, 0);
- label = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_misc_set_padding (GTK_MISC (label), 0, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ g_signal_connect (close_button,
+ "clicked",
+ G_CALLBACK (tab_close_button_clicked_cb), project);
- progress = gtk_progress_bar_new ();
- gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (progress), TRUE);
- gtk_widget_add_events (progress,
- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
- gtk_widget_set_name (progress, "glade-tab-label-progress");
- gtk_box_pack_start (GTK_BOX (hbox), progress, FALSE, FALSE, 0);
- g_signal_connect (project, "load-progress",
- G_CALLBACK (project_load_progress_cb), progress);
+ label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label), 0, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- dummy_label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (hbox), dummy_label, TRUE, TRUE, 0);
+ progress = gtk_progress_bar_new ();
+ gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (progress), TRUE);
+ gtk_widget_add_events (progress,
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
+ gtk_widget_set_name (progress, "glade-tab-label-progress");
+ gtk_box_pack_start (GTK_BOX (hbox), progress, FALSE, FALSE, 0);
+ g_signal_connect (project, "load-progress",
+ G_CALLBACK (project_load_progress_cb), progress);
- gtk_widget_show (ebox);
- gtk_widget_show (hbox);
- gtk_widget_show (close_button);
- gtk_widget_show (dummy_label);
+ dummy_label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (hbox), dummy_label, TRUE, TRUE, 0);
- if (for_file)
- {
- gtk_widget_show (progress);
+ gtk_widget_show (ebox);
+ gtk_widget_show (hbox);
+ gtk_widget_show (close_button);
+ gtk_widget_show (dummy_label);
- g_signal_connect (project, "parse-finished",
- G_CALLBACK (project_load_finished_cb), tab_label);
- }
- else
- gtk_widget_show (label);
+ if (for_file)
+ {
+ gtk_widget_show (progress);
- g_object_set_data (G_OBJECT (tab_label), "tab-progress", progress);
- g_object_set_data (G_OBJECT (tab_label), "tab-event-box", ebox);
- g_object_set_data (G_OBJECT (tab_label), "tab-label", label);
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (project_load_finished_cb), tab_label);
+ }
+ else
+ gtk_widget_show (label);
- return tab_label;
+ g_object_set_data (G_OBJECT (tab_label), "tab-progress", progress);
+ g_object_set_data (G_OBJECT (tab_label), "tab-event-box", ebox);
+ g_object_set_data (G_OBJECT (tab_label), "tab-label", label);
+
+ return tab_label;
}
static void
-add_project (GladeWindow *window, GladeProject *project, gboolean for_file)
+add_project (GladeWindow * window, GladeProject * project, gboolean for_file)
{
- GtkWidget *view, *label;
+ GtkWidget *view, *label;
+
+ g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GLADE_IS_PROJECT (project));
-
- view = glade_design_view_new (project);
- gtk_widget_show (view);
+ view = glade_design_view_new (project);
+ gtk_widget_show (view);
- g_object_set_data (G_OBJECT (view), "view-added-while-loading", GINT_TO_POINTER (for_file));
+ g_object_set_data (G_OBJECT (view), "view-added-while-loading",
+ GINT_TO_POINTER (for_file));
- /* Update preview button */
- gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button), FALSE);
+ /* Update preview button */
+ gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button), FALSE);
- /* Pass ownership of the project to the app */
- glade_app_add_project (project);
- g_object_unref (project);
+ /* Pass ownership of the project to the app */
+ glade_app_add_project (project);
+ g_object_unref (project);
- /* Custom notebook tab label (will be refreshed later) */
- label = create_notebook_tab (window, project, for_file);
+ /* Custom notebook tab label (will be refreshed later) */
+ label = create_notebook_tab (window, project, for_file);
- gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (view), label);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), -1);
+ gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->notebook),
+ GTK_WIDGET (view), label);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), -1);
- refresh_notebook_tab_for_project (window, project);
+ refresh_notebook_tab_for_project (window, project);
}
void
-glade_window_new_project (GladeWindow *window)
+glade_window_new_project (GladeWindow * window)
{
- GladeProject *project;
-
- g_return_if_fail (GLADE_IS_WINDOW (window));
+ GladeProject *project;
- project = glade_project_new ();
- if (!project)
- {
- glade_util_ui_message (GTK_WIDGET (window),
- GLADE_UI_ERROR, NULL,
- _("Could not create a new project."));
- return;
- }
- add_project (window, project, FALSE);
+ g_return_if_fail (GLADE_IS_WINDOW (window));
+
+ project = glade_project_new ();
+ if (!project)
+ {
+ glade_util_ui_message (GTK_WIDGET (window),
+ GLADE_UI_ERROR, NULL,
+ _("Could not create a new project."));
+ return;
+ }
+ add_project (window, project, FALSE);
}
static gboolean
-open_project (GladeWindow *window, const gchar *path)
-{
- GladeProject *project;
-
- project = glade_project_new ();
-
- add_project (window, project, TRUE);
- update_default_path (window, path);
-
- if (!glade_project_load_from_file (project, path))
- {
- do_close (window, project);
-
- recent_remove (window, path);
- return FALSE;
- }
-
- /* increase project popularity */
- recent_add (window, glade_project_get_path (project));
-
- return TRUE;
-}
-
-static void
-check_reload_project (GladeWindow *window, GladeProject *project)
-{
- gchar *path;
- gint ret;
- GtkWidget *dialog;
- GtkWidget *button;
- gint response;
-
- /* Reopen the project if it has external modifications.
- * Prompt for permission to reopen.
- */
- if ((glade_util_get_file_mtime (glade_project_get_path (project), NULL)
- <= glade_project_get_file_mtime (project)))
- {
- return;
- }
-
- if (glade_project_get_modified (project))
- {
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- _("The project %s has unsaved changes"),
- glade_project_get_path (project));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you reload it, all unsaved changes "
- "could be lost. Reload it anyway?"));
- }
- else
- {
- dialog = gtk_message_dialog_new (GTK_WINDOW (window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- _("The project file %s has been externally modified"),
- glade_project_get_path (project));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Do you want to reload the project?"));
-
- }
-
- gtk_window_set_title (GTK_WINDOW (dialog), "");
-
- button = gtk_button_new_with_mnemonic (_("_Reload"));
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_stock (GTK_STOCK_REFRESH,
- GTK_ICON_SIZE_BUTTON));
- gtk_widget_show (button);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_ACCEPT);
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT,
- GTK_RESPONSE_REJECT,
- -1);
-
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (dialog);
-
- if (response == GTK_RESPONSE_REJECT)
- {
- return;
- }
-
- /* Reopen */
- path = g_strdup (glade_project_get_path (project));
-
- do_close (window, project);
- ret = open_project (window, path);
- g_free (path);
+open_project (GladeWindow * window, const gchar * path)
+{
+ GladeProject *project;
+
+ project = glade_project_new ();
+
+ add_project (window, project, TRUE);
+ update_default_path (window, path);
+
+ if (!glade_project_load_from_file (project, path))
+ {
+ do_close (window, project);
+
+ recent_remove (window, path);
+ return FALSE;
+ }
+
+ /* increase project popularity */
+ recent_add (window, glade_project_get_path (project));
+
+ return TRUE;
+}
+
+static void
+check_reload_project (GladeWindow * window, GladeProject * project)
+{
+ gchar *path;
+ gint ret;
+ GtkWidget *dialog;
+ GtkWidget *button;
+ gint response;
+
+ /* Reopen the project if it has external modifications.
+ * Prompt for permission to reopen.
+ */
+ if ((glade_util_get_file_mtime (glade_project_get_path (project), NULL)
+ <= glade_project_get_file_mtime (project)))
+ {
+ return;
+ }
+
+ if (glade_project_get_modified (project))
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _("The project %s has unsaved changes"),
+ glade_project_get_path (project));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("If you reload it, all unsaved changes "
+ "could be lost. Reload it anyway?"));
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _
+ ("The project file %s has been externally modified"),
+ glade_project_get_path (project));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _
+ ("Do you want to reload the project?"));
+
+ }
+
+ gtk_window_set_title (GTK_WINDOW (dialog), "");
+
+ button = gtk_button_new_with_mnemonic (_("_Reload"));
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_REFRESH,
+ GTK_ICON_SIZE_BUTTON));
+ gtk_widget_show (button);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
+ GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_ACCEPT,
+ GTK_RESPONSE_REJECT, -1);
+
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_REJECT)
+ {
+ return;
+ }
+
+ /* Reopen */
+ path = g_strdup (glade_project_get_path (project));
+
+ do_close (window, project);
+ ret = open_project (window, path);
+ g_free (path);
}
/**
@@ -2714,798 +2763,822 @@ check_reload_project (GladeWindow *window, GladeProject *project)
* Returns: #TRUE if the project was opened
*/
gboolean
-glade_window_open_project (GladeWindow *window,
- const gchar *path)
+glade_window_open_project (GladeWindow * window, const gchar * path)
{
- GladeProject *project;
+ GladeProject *project;
- g_return_val_if_fail (GLADE_IS_WINDOW (window), FALSE);
- g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (GLADE_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
- /* dont allow a project to be opened twice */
- project = glade_app_get_project_by_path (path);
- if (project)
- {
- /* just switch to the project */
- switch_to_project (window, project);
- return TRUE;
- }
- else
- {
- return open_project (window, path);
- }
+ /* dont allow a project to be opened twice */
+ project = glade_app_get_project_by_path (path);
+ if (project)
+ {
+ /* just switch to the project */
+ switch_to_project (window, project);
+ return TRUE;
+ }
+ else
+ {
+ return open_project (window, path);
+ }
}
static void
-change_menu_label (GladeWindow *window,
- const gchar *path,
- const gchar *action_label,
- const gchar *action_description)
+change_menu_label (GladeWindow * window,
+ const gchar * path,
+ const gchar * action_label, const gchar * action_description)
{
- GtkBin *bin;
- GtkLabel *label;
- gchar *text;
- gchar *tmp_text;
+ GtkBin *bin;
+ GtkLabel *label;
+ gchar *text;
+ gchar *tmp_text;
+
+ g_assert (GLADE_IS_WINDOW (window));
+ g_return_if_fail (path != NULL);
+ g_return_if_fail (action_label != NULL);
- g_assert (GLADE_IS_WINDOW (window));
- g_return_if_fail (path != NULL);
- g_return_if_fail (action_label != NULL);
+ bin = GTK_BIN (gtk_ui_manager_get_widget (window->priv->ui, path));
+ label = GTK_LABEL (gtk_bin_get_child (bin));
- bin = GTK_BIN (gtk_ui_manager_get_widget (window->priv->ui, path));
- label = GTK_LABEL (gtk_bin_get_child (bin));
+ if (action_description == NULL)
+ text = g_strdup (action_label);
+ else
+ {
+ tmp_text = escape_underscores (action_description, -1);
+ text = g_strdup_printf ("%s: %s", action_label, tmp_text);
+ g_free (tmp_text);
+ }
- if (action_description == NULL)
- text = g_strdup (action_label);
- else
- {
- tmp_text = escape_underscores (action_description, -1);
- text = g_strdup_printf ("%s: %s", action_label, tmp_text);
- g_free (tmp_text);
- }
-
- gtk_label_set_text_with_mnemonic (label, text);
+ gtk_label_set_text_with_mnemonic (label, text);
- g_free (text);
+ g_free (text);
}
static void
-refresh_undo_redo (GladeWindow *window)
+refresh_undo_redo (GladeWindow * window)
{
- GladeCommand *undo = NULL, *redo = NULL;
- GladeProject *project;
- GtkAction *action;
- gchar *tooltip;
+ GladeCommand *undo = NULL, *redo = NULL;
+ GladeProject *project;
+ GtkAction *action;
+ gchar *tooltip;
- project = glade_app_get_project ();
+ project = glade_app_get_project ();
- if (project != NULL)
- {
- undo = glade_project_next_undo_item (project);
- redo = glade_project_next_redo_item (project);
- }
+ if (project != NULL)
+ {
+ undo = glade_project_next_undo_item (project);
+ redo = glade_project_next_redo_item (project);
+ }
- /* Refresh Undo */
- action = gtk_action_group_get_action (window->priv->project_actions, "Undo");
- gtk_action_set_sensitive (action, undo != NULL);
-
- change_menu_label
- (window, "/MenuBar/EditMenu/Undo", _("_Undo"), undo ? undo->description : NULL);
+ /* Refresh Undo */
+ action = gtk_action_group_get_action (window->priv->project_actions, "Undo");
+ gtk_action_set_sensitive (action, undo != NULL);
- tooltip = g_strdup_printf (_("Undo: %s"), undo ? undo->description : _("the last action"));
- g_object_set (action, "tooltip", tooltip, NULL);
- g_free (tooltip);
+ change_menu_label
+ (window, "/MenuBar/EditMenu/Undo", _("_Undo"),
+ undo ? undo->description : NULL);
- /* Refresh Redo */
- action = gtk_action_group_get_action (window->priv->project_actions, "Redo");
- gtk_action_set_sensitive (action, redo != NULL);
+ tooltip =
+ g_strdup_printf (_("Undo: %s"),
+ undo ? undo->description : _("the last action"));
+ g_object_set (action, "tooltip", tooltip, NULL);
+ g_free (tooltip);
- change_menu_label
- (window, "/MenuBar/EditMenu/Redo", _("_Redo"), redo ? redo->description : NULL);
+ /* Refresh Redo */
+ action = gtk_action_group_get_action (window->priv->project_actions, "Redo");
+ gtk_action_set_sensitive (action, redo != NULL);
- tooltip = g_strdup_printf (_("Redo: %s"), redo ? redo->description : _("the last action"));
- g_object_set (action, "tooltip", tooltip, NULL);
- g_free (tooltip);
+ change_menu_label
+ (window, "/MenuBar/EditMenu/Redo", _("_Redo"),
+ redo ? redo->description : NULL);
- /* Refresh menus */
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (window->priv->undo), glade_project_undo_items (project));
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (window->priv->redo), glade_project_redo_items (project));
+ tooltip =
+ g_strdup_printf (_("Redo: %s"),
+ redo ? redo->description : _("the last action"));
+ g_object_set (action, "tooltip", tooltip, NULL);
+ g_free (tooltip);
+
+ /* Refresh menus */
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (window->priv->undo),
+ glade_project_undo_items (project));
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (window->priv->redo),
+ glade_project_redo_items (project));
}
static void
-update_ui (GladeApp *app, GladeWindow *window)
+update_ui (GladeApp * app, GladeWindow * window)
{
- GladeProject *project;
- if (window->priv->active_view)
- {
- project = glade_design_view_get_project (window->priv->active_view);
- gtk_widget_set_sensitive ( GTK_WIDGET (window->priv->preview_button),
- glade_project_get_previewable (project));
- gtk_widget_queue_draw (GTK_WIDGET (window->priv->active_view));
- }
+ GladeProject *project;
+ if (window->priv->active_view)
+ {
+ project = glade_design_view_get_project (window->priv->active_view);
+ gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button),
+ glade_project_get_previewable (project));
+ gtk_widget_queue_draw (GTK_WIDGET (window->priv->active_view));
+ }
- refresh_undo_redo (window);
+ refresh_undo_redo (window);
- refresh_notebook_tabs (window);
+ refresh_notebook_tabs (window);
}
static void
-glade_window_dispose (GObject *object)
+glade_window_dispose (GObject * object)
{
- GladeWindow *window = GLADE_WINDOW (object);
-
- if (window->priv->app)
- {
- g_object_unref (window->priv->app);
- window->priv->app = NULL;
- }
+ GladeWindow *window = GLADE_WINDOW (object);
+
+ if (window->priv->app)
+ {
+ g_object_unref (window->priv->app);
+ window->priv->app = NULL;
+ }
- G_OBJECT_CLASS (glade_window_parent_class)->dispose (object);
+ G_OBJECT_CLASS (glade_window_parent_class)->dispose (object);
}
static void
-glade_window_finalize (GObject *object)
+glade_window_finalize (GObject * object)
{
- guint i;
+ guint i;
- g_free (GLADE_WINDOW (object)->priv->default_path);
+ g_free (GLADE_WINDOW (object)->priv->default_path);
- for (i = 0; i < N_DOCKS; i++)
- {
- ToolDock *dock = &GLADE_WINDOW (object)->priv->docks[i];
- g_free (dock->title);
- g_free (dock->id);
- }
+ for (i = 0; i < N_DOCKS; i++)
+ {
+ ToolDock *dock = &GLADE_WINDOW (object)->priv->docks[i];
+ g_free (dock->title);
+ g_free (dock->id);
+ }
- G_OBJECT_CLASS (glade_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (glade_window_parent_class)->finalize (object);
}
static gboolean
-glade_window_configure_event (GtkWidget *widget,
- GdkEventConfigure *event)
+glade_window_configure_event (GtkWidget * widget, GdkEventConfigure * event)
{
- GladeWindow *window = GLADE_WINDOW (widget);
- gboolean retval;
+ GladeWindow *window = GLADE_WINDOW (widget);
+ gboolean retval;
- gboolean is_maximized;
- GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
- is_maximized = gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED;
+ gboolean is_maximized;
+ GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+ is_maximized = gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED;
- if (!is_maximized)
- {
- window->priv->position.width = event->width;
- window->priv->position.height = event->height;
- }
+ if (!is_maximized)
+ {
+ window->priv->position.width = event->width;
+ window->priv->position.height = event->height;
+ }
- retval = GTK_WIDGET_CLASS(glade_window_parent_class)->configure_event (widget, event);
+ retval =
+ GTK_WIDGET_CLASS (glade_window_parent_class)->configure_event (widget,
+ event);
- if (!is_maximized)
- {
- gtk_window_get_position (GTK_WINDOW (widget),
- &window->priv->position.x,
- &window->priv->position.y);
- }
+ if (!is_maximized)
+ {
+ gtk_window_get_position (GTK_WINDOW (widget),
+ &window->priv->position.x,
+ &window->priv->position.y);
+ }
- return retval;
+ return retval;
}
static void
-key_file_set_window_position (GKeyFile *config,
- GdkRectangle *position,
- const char *id,
- gboolean detached,
- gboolean save_detached,
- gboolean maximized)
+key_file_set_window_position (GKeyFile * config,
+ GdkRectangle * position,
+ const char *id,
+ gboolean detached,
+ gboolean save_detached, gboolean maximized)
{
- char *key_x, *key_y, *key_width, *key_height, *key_detached, *key_maximized;
+ char *key_x, *key_y, *key_width, *key_height, *key_detached, *key_maximized;
- key_x = g_strdup_printf ("%s-" CONFIG_KEY_X, id);
- key_y = g_strdup_printf ("%s-" CONFIG_KEY_Y, id);
- key_width = g_strdup_printf ("%s-" CONFIG_KEY_WIDTH, id);
- key_height = g_strdup_printf ("%s-" CONFIG_KEY_HEIGHT, id);
- key_detached = g_strdup_printf ("%s-" CONFIG_KEY_DETACHED, id);
- key_maximized = g_strdup_printf ("%s-" CONFIG_KEY_MAXIMIZED, id);
+ key_x = g_strdup_printf ("%s-" CONFIG_KEY_X, id);
+ key_y = g_strdup_printf ("%s-" CONFIG_KEY_Y, id);
+ key_width = g_strdup_printf ("%s-" CONFIG_KEY_WIDTH, id);
+ key_height = g_strdup_printf ("%s-" CONFIG_KEY_HEIGHT, id);
+ key_detached = g_strdup_printf ("%s-" CONFIG_KEY_DETACHED, id);
+ key_maximized = g_strdup_printf ("%s-" CONFIG_KEY_MAXIMIZED, id);
- /* we do not want to save position of docks which
- * were never detached */
- if (position->x > G_MININT)
- g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS,
- key_x, position->x);
- if (position->y > G_MININT)
- g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS,
- key_y, position->y);
+ /* we do not want to save position of docks which
+ * were never detached */
+ if (position->x > G_MININT)
+ g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS, key_x, position->x);
+ if (position->y > G_MININT)
+ g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS, key_y, position->y);
- g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS,
- key_width, position->width);
- g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS,
- key_height, position->height);
+ g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS,
+ key_width, position->width);
+ g_key_file_set_integer (config, CONFIG_GROUP_WINDOWS,
+ key_height, position->height);
- if (save_detached)
- g_key_file_set_boolean (config, CONFIG_GROUP_WINDOWS,
- key_detached, detached);
+ if (save_detached)
+ g_key_file_set_boolean (config, CONFIG_GROUP_WINDOWS,
+ key_detached, detached);
- g_key_file_set_boolean (config, CONFIG_GROUP_WINDOWS,
- key_maximized, maximized);
+ g_key_file_set_boolean (config, CONFIG_GROUP_WINDOWS,
+ key_maximized, maximized);
- g_free (key_maximized);
- g_free (key_detached);
- g_free (key_height);
- g_free (key_width);
- g_free (key_y);
- g_free (key_x);
+ g_free (key_maximized);
+ g_free (key_detached);
+ g_free (key_height);
+ g_free (key_width);
+ g_free (key_y);
+ g_free (key_x);
}
static void
-save_windows_config (GladeWindow *window, GKeyFile *config)
+save_windows_config (GladeWindow * window, GKeyFile * config)
{
- guint i;
- GdkWindow *gdk_window;
- gboolean maximized;
+ guint i;
+ GdkWindow *gdk_window;
+ gboolean maximized;
- for (i = 0; i < N_DOCKS; ++i)
- {
- ToolDock *dock = &window->priv->docks[i];
- key_file_set_window_position (config, &dock->window_pos, dock->id,
- dock->detached, TRUE, dock->maximized);
- }
+ for (i = 0; i < N_DOCKS; ++i)
+ {
+ ToolDock *dock = &window->priv->docks[i];
+ key_file_set_window_position (config, &dock->window_pos, dock->id,
+ dock->detached, TRUE, dock->maximized);
+ }
- gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
- maximized = gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED;
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+ maximized = gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_MAXIMIZED;
- key_file_set_window_position (config, &window->priv->position,
- "main", FALSE, FALSE, maximized);
+ key_file_set_window_position (config, &window->priv->position,
+ "main", FALSE, FALSE, maximized);
- g_key_file_set_boolean (config,
- CONFIG_GROUP_WINDOWS,
- CONFIG_KEY_SHOW_TOOLBAR,
- gtk_widget_get_visible (window->priv->toolbar));
+ g_key_file_set_boolean (config,
+ CONFIG_GROUP_WINDOWS,
+ CONFIG_KEY_SHOW_TOOLBAR,
+ gtk_widget_get_visible (window->priv->toolbar));
- g_key_file_set_boolean (config,
- CONFIG_GROUP_WINDOWS,
- CONFIG_KEY_SHOW_STATUS,
- gtk_widget_get_visible (window->priv->statusbar));
+ g_key_file_set_boolean (config,
+ CONFIG_GROUP_WINDOWS,
+ CONFIG_KEY_SHOW_STATUS,
+ gtk_widget_get_visible (window->priv->statusbar));
- g_key_file_set_boolean (config,
- CONFIG_GROUP_WINDOWS,
- CONFIG_KEY_SHOW_TABS,
- gtk_notebook_get_show_tabs (GTK_NOTEBOOK (window->priv->notebook)));
+ g_key_file_set_boolean (config,
+ CONFIG_GROUP_WINDOWS,
+ CONFIG_KEY_SHOW_TABS,
+ gtk_notebook_get_show_tabs (GTK_NOTEBOOK
+ (window->priv->
+ notebook)));
}
-static void
-save_paned_position (GKeyFile *config, GtkWidget *paned, const gchar *name)
+static void
+save_paned_position (GKeyFile * config, GtkWidget * paned, const gchar * name)
{
- g_key_file_set_integer (config, name, "position",
- gtk_paned_get_position (GTK_PANED (paned)));
+ g_key_file_set_integer (config, name, "position",
+ gtk_paned_get_position (GTK_PANED (paned)));
}
static void
-glade_window_config_save (GladeWindow *window)
+glade_window_config_save (GladeWindow * window)
{
- GKeyFile *config = glade_app_get_config ();
+ GKeyFile *config = glade_app_get_config ();
+
+ save_windows_config (window, config);
- save_windows_config (window, config);
-
- /* Save main window paned positions */
- save_paned_position (config, window->priv->center_pane, "center_pane");
- save_paned_position (config, window->priv->left_pane, "left_pane");
- save_paned_position (config, window->priv->right_pane, "right_pane");
-
- glade_app_config_save ();
+ /* Save main window paned positions */
+ save_paned_position (config, window->priv->center_pane, "center_pane");
+ save_paned_position (config, window->priv->left_pane, "left_pane");
+ save_paned_position (config, window->priv->right_pane, "right_pane");
+
+ glade_app_config_save ();
}
static int
-key_file_get_int (GKeyFile *config,
- const char *group,
- const char *key,
- int default_value)
+key_file_get_int (GKeyFile * config,
+ const char *group, const char *key, int default_value)
{
- if (g_key_file_has_key (config, group, key, NULL))
- return g_key_file_get_integer (config, group, key, NULL);
- else
- return default_value;
+ if (g_key_file_has_key (config, group, key, NULL))
+ return g_key_file_get_integer (config, group, key, NULL);
+ else
+ return default_value;
}
static void
-key_file_get_window_position (GKeyFile *config,
- const char *id,
- GdkRectangle *pos,
- gboolean *detached,
- gboolean *maximized)
+key_file_get_window_position (GKeyFile * config,
+ const char *id,
+ GdkRectangle * pos,
+ gboolean * detached, gboolean * maximized)
{
- char *key_x, *key_y, *key_width, *key_height, *key_detached, *key_maximized;
+ char *key_x, *key_y, *key_width, *key_height, *key_detached, *key_maximized;
- key_x = g_strdup_printf ("%s-" CONFIG_KEY_X, id);
- key_y = g_strdup_printf ("%s-" CONFIG_KEY_Y, id);
- key_width = g_strdup_printf ("%s-" CONFIG_KEY_WIDTH, id);
- key_height = g_strdup_printf ("%s-" CONFIG_KEY_HEIGHT, id);
- key_detached = g_strdup_printf ("%s-" CONFIG_KEY_DETACHED, id);
- key_maximized = g_strdup_printf ("%s-" CONFIG_KEY_MAXIMIZED, id);
+ key_x = g_strdup_printf ("%s-" CONFIG_KEY_X, id);
+ key_y = g_strdup_printf ("%s-" CONFIG_KEY_Y, id);
+ key_width = g_strdup_printf ("%s-" CONFIG_KEY_WIDTH, id);
+ key_height = g_strdup_printf ("%s-" CONFIG_KEY_HEIGHT, id);
+ key_detached = g_strdup_printf ("%s-" CONFIG_KEY_DETACHED, id);
+ key_maximized = g_strdup_printf ("%s-" CONFIG_KEY_MAXIMIZED, id);
- pos->x = key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_x, pos->x);
- pos->y = key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_y, pos->y);
- pos->width = key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_width, pos->width);
- pos->height = key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_height, pos->height);
+ pos->x = key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_x, pos->x);
+ pos->y = key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_y, pos->y);
+ pos->width =
+ key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_width, pos->width);
+ pos->height =
+ key_file_get_int (config, CONFIG_GROUP_WINDOWS, key_height, pos->height);
- if (detached)
- {
- if (g_key_file_has_key (config, CONFIG_GROUP_WINDOWS, key_detached, NULL))
- *detached = g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, key_detached, NULL);
- else
- *detached = FALSE;
- }
+ if (detached)
+ {
+ if (g_key_file_has_key (config, CONFIG_GROUP_WINDOWS, key_detached, NULL))
+ *detached =
+ g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, key_detached,
+ NULL);
+ else
+ *detached = FALSE;
+ }
- if (maximized)
- {
- if (g_key_file_has_key (config, CONFIG_GROUP_WINDOWS, key_maximized, NULL))
- *maximized = g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, key_maximized, NULL);
- else
- *maximized = FALSE;
- }
+ if (maximized)
+ {
+ if (g_key_file_has_key
+ (config, CONFIG_GROUP_WINDOWS, key_maximized, NULL))
+ *maximized =
+ g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, key_maximized,
+ NULL);
+ else
+ *maximized = FALSE;
+ }
- g_free (key_x);
- g_free (key_y);
- g_free (key_width);
- g_free (key_height);
- g_free (key_detached);
- g_free (key_maximized);
+ g_free (key_x);
+ g_free (key_y);
+ g_free (key_width);
+ g_free (key_height);
+ g_free (key_detached);
+ g_free (key_maximized);
}
static void
-load_paned_position (GKeyFile *config, GtkWidget *pane, const gchar *name, gint default_position)
+load_paned_position (GKeyFile * config, GtkWidget * pane, const gchar * name,
+ gint default_position)
{
- gtk_paned_set_position (GTK_PANED (pane),
- key_file_get_int (config, name, "position", default_position));
+ gtk_paned_set_position (GTK_PANED (pane),
+ key_file_get_int (config, name, "position",
+ default_position));
}
static gboolean
-fix_paned_positions_idle (GladeWindow *window)
+fix_paned_positions_idle (GladeWindow * window)
{
- /* When initially maximized/fullscreened we need to deffer this operation
- */
- GKeyFile *config = glade_app_get_config ();
-
- load_paned_position (config, window->priv->left_pane, "left_pane", 200);
- load_paned_position (config, window->priv->center_pane, "center_pane", 400);
- load_paned_position (config, window->priv->right_pane, "right_pane", 220);
+ /* When initially maximized/fullscreened we need to deffer this operation
+ */
+ GKeyFile *config = glade_app_get_config ();
- return FALSE;
-}
+ load_paned_position (config, window->priv->left_pane, "left_pane", 200);
+ load_paned_position (config, window->priv->center_pane, "center_pane", 400);
+ load_paned_position (config, window->priv->right_pane, "right_pane", 220);
+
+ return FALSE;
+}
static void
-glade_window_set_initial_size (GladeWindow *window, GKeyFile *config)
+glade_window_set_initial_size (GladeWindow * window, GKeyFile * config)
{
- GdkRectangle position = {
- G_MININT, G_MININT, GLADE_WINDOW_DEFAULT_WIDTH, GLADE_WINDOW_DEFAULT_HEIGHT
- };
+ GdkRectangle position = {
+ G_MININT, G_MININT, GLADE_WINDOW_DEFAULT_WIDTH, GLADE_WINDOW_DEFAULT_HEIGHT
+ };
- gboolean maximized;
+ gboolean maximized;
- key_file_get_window_position (config, "main", &position, NULL, &maximized);
- if (maximized)
- {
- gtk_window_maximize (GTK_WINDOW (window));
- g_idle_add ((GSourceFunc)fix_paned_positions_idle, window);
- }
+ key_file_get_window_position (config, "main", &position, NULL, &maximized);
+ if (maximized)
+ {
+ gtk_window_maximize (GTK_WINDOW (window));
+ g_idle_add ((GSourceFunc) fix_paned_positions_idle, window);
+ }
- if (position.width <= 0 || position.height <= 0)
- {
- position.width = GLADE_WINDOW_DEFAULT_WIDTH;
- position.height = GLADE_WINDOW_DEFAULT_HEIGHT;
- }
+ if (position.width <= 0 || position.height <= 0)
+ {
+ position.width = GLADE_WINDOW_DEFAULT_WIDTH;
+ position.height = GLADE_WINDOW_DEFAULT_HEIGHT;
+ }
- gtk_window_set_default_size (GTK_WINDOW (window), position.width, position.height);
+ gtk_window_set_default_size (GTK_WINDOW (window), position.width,
+ position.height);
- if (position.x > G_MININT && position.y > G_MININT)
- gtk_window_move (GTK_WINDOW (window), position.x, position.y);
+ if (position.x > G_MININT && position.y > G_MININT)
+ gtk_window_move (GTK_WINDOW (window), position.x, position.y);
}
static void
-glade_window_config_load (GladeWindow *window)
+glade_window_config_load (GladeWindow * window)
{
- GKeyFile *config = glade_app_get_config ();
- gboolean show_toolbar, show_tabs, show_status;
- GtkAction *action;
- GError *error = NULL;
+ GKeyFile *config = glade_app_get_config ();
+ gboolean show_toolbar, show_tabs, show_status;
+ GtkAction *action;
+ GError *error = NULL;
- /* Initial main dimensions */
- glade_window_set_initial_size (window, config);
+ /* Initial main dimensions */
+ glade_window_set_initial_size (window, config);
- /* toolbar and tabs */
- if ((show_toolbar =
- g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, CONFIG_KEY_SHOW_TOOLBAR, &error)) == FALSE &&
- error != NULL)
- {
- show_toolbar = TRUE;
- error = (g_error_free (error), NULL);
- }
+ /* toolbar and tabs */
+ if ((show_toolbar =
+ g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS,
+ CONFIG_KEY_SHOW_TOOLBAR, &error)) == FALSE &&
+ error != NULL)
+ {
+ show_toolbar = TRUE;
+ error = (g_error_free (error), NULL);
+ }
- if ((show_tabs =
- g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, CONFIG_KEY_SHOW_TABS, &error)) == FALSE &&
- error != NULL)
- {
- show_tabs = TRUE;
- error = (g_error_free (error), NULL);
- }
+ if ((show_tabs =
+ g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS,
+ CONFIG_KEY_SHOW_TABS, &error)) == FALSE &&
+ error != NULL)
+ {
+ show_tabs = TRUE;
+ error = (g_error_free (error), NULL);
+ }
- if ((show_status =
- g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS, CONFIG_KEY_SHOW_STATUS, &error)) == FALSE &&
- error != NULL)
- {
- show_status = TRUE;
- error = (g_error_free (error), NULL);
- }
+ if ((show_status =
+ g_key_file_get_boolean (config, CONFIG_GROUP_WINDOWS,
+ CONFIG_KEY_SHOW_STATUS, &error)) == FALSE &&
+ error != NULL)
+ {
+ show_status = TRUE;
+ error = (g_error_free (error), NULL);
+ }
- if (show_toolbar)
- gtk_widget_show (window->priv->toolbar);
- else
- gtk_widget_hide (window->priv->toolbar);
+ if (show_toolbar)
+ gtk_widget_show (window->priv->toolbar);
+ else
+ gtk_widget_hide (window->priv->toolbar);
- if (show_status)
- gtk_widget_show (window->priv->statusbar);
- else
- gtk_widget_hide (window->priv->statusbar);
+ if (show_status)
+ gtk_widget_show (window->priv->statusbar);
+ else
+ gtk_widget_hide (window->priv->statusbar);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), show_tabs);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), show_tabs);
- action = gtk_action_group_get_action (window->priv->static_actions, "ToolbarVisible");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_toolbar);
+ action =
+ gtk_action_group_get_action (window->priv->static_actions,
+ "ToolbarVisible");
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_toolbar);
- action = gtk_action_group_get_action (window->priv->static_actions, "ProjectTabsVisible");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_tabs);
+ action =
+ gtk_action_group_get_action (window->priv->static_actions,
+ "ProjectTabsVisible");
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_tabs);
- action = gtk_action_group_get_action (window->priv->static_actions, "StatusbarVisible");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_tabs);
+ action =
+ gtk_action_group_get_action (window->priv->static_actions,
+ "StatusbarVisible");
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_tabs);
- /* Paned positions */
- load_paned_position (config, window->priv->left_pane, "left_pane", 200);
- load_paned_position (config, window->priv->center_pane, "center_pane", 400);
- load_paned_position (config, window->priv->right_pane, "right_pane", 220);
+ /* Paned positions */
+ load_paned_position (config, window->priv->left_pane, "left_pane", 200);
+ load_paned_position (config, window->priv->center_pane, "center_pane", 400);
+ load_paned_position (config, window->priv->right_pane, "right_pane", 220);
}
-
-static void
-show_dock_first_time (GladeWindow *window,
- guint dock_type,
- const char *action_id)
-{
- GKeyFile *config;
- int detached = -1;
- gboolean maximized;
- GtkAction *action;
- ToolDock *dock;
-
- action = gtk_action_group_get_action (window->priv->static_actions, action_id);
- g_object_set_data (G_OBJECT (action), "glade-dock-type", GUINT_TO_POINTER (dock_type));
-
- dock = &window->priv->docks[dock_type];
- config = glade_app_get_config ();
-
- key_file_get_window_position (config, dock->id, &dock->window_pos, &detached, &maximized);
-
- if (detached == 1)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
-
- if (maximized) gtk_window_maximize (GTK_WINDOW (gtk_widget_get_toplevel (dock->widget)));
-}
-
-static void
-setup_dock (ToolDock *dock,
- GtkWidget *dock_widget,
- guint default_width,
- guint default_height,
- const char *window_title,
- const char *id,
- GtkWidget *paned,
- gboolean first_child)
-{
- dock->widget = dock_widget;
- dock->window_pos.x = dock->window_pos.y = G_MININT;
- dock->window_pos.width = default_width;
- dock->window_pos.height = default_height;
- dock->title = g_strdup (window_title);
- dock->id = g_strdup (id);
- dock->paned = paned;
- dock->first_child = first_child;
- dock->detached = FALSE;
- dock->maximized = FALSE;
-}
-
-static void
-glade_window_init (GladeWindow *window)
-{
- GladeWindowPrivate *priv;
-
- GtkWidget *vbox;
- GtkWidget *hpaned1;
- GtkWidget *hpaned2;
- GtkWidget *vpaned;
- GtkWidget *menubar;
- GtkWidget *palette;
- GtkWidget *dockitem;
- GtkWidget *widget;
- GtkWidget *sep;
- GtkAction *undo_action, *redo_action;
-
- window->priv = priv = GLADE_WINDOW_GET_PRIVATE (window);
-
- priv->default_path = NULL;
-
- priv->app = glade_app_new ();
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window), vbox);
-
- /* menubar */
- menubar = construct_menu (window);
- gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
- gtk_widget_show (menubar);
-
- /* toolbar */
- priv->toolbar = gtk_ui_manager_get_widget (priv->ui, "/ToolBar");
- gtk_box_pack_start (GTK_BOX (vbox), priv->toolbar, FALSE, TRUE, 0);
- gtk_widget_show (priv->toolbar);
-
- /* undo/redo buttons */
- priv->undo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_UNDO);
- priv->redo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_REDO);
- gtk_widget_show (GTK_WIDGET (priv->undo));
- gtk_widget_show (GTK_WIDGET (priv->redo));
- gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (priv->undo),
- _("Go back in undo history"));
- gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (priv->redo),
- _("Go forward in undo history"));
-
- sep = GTK_WIDGET (gtk_separator_tool_item_new ());
- gtk_widget_show (sep);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (sep), 3);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (priv->undo), 4);
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (priv->redo), 5);
-
- undo_action = gtk_ui_manager_get_action (priv->ui, "/MenuBar/EditMenu/Undo");
- redo_action = gtk_ui_manager_get_action (priv->ui, "/MenuBar/EditMenu/Redo");
-
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->undo), undo_action);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->redo), redo_action);
-
- /* main contents */
- hpaned1 = gtk_hpaned_new ();
- hpaned2 = gtk_hpaned_new ();
- vpaned = gtk_vpaned_new ();
- priv->center_pane = hpaned1;
- priv->left_pane = hpaned2;
- priv->right_pane = vpaned;
-
- gtk_container_set_border_width (GTK_CONTAINER (hpaned1), 2);
-
- gtk_box_pack_start (GTK_BOX (vbox), hpaned1, TRUE, TRUE, 0);
- gtk_paned_pack1 (GTK_PANED (hpaned1), hpaned2, TRUE, FALSE);
- gtk_paned_pack2 (GTK_PANED (hpaned1), vpaned, FALSE, FALSE);
-
- /* divider position between tree and editor */
- gtk_paned_set_position (GTK_PANED (vpaned), 150);
-
- gtk_widget_show_all (hpaned1);
- gtk_widget_show_all (hpaned2);
- gtk_widget_show_all (vpaned);
-
- /* notebook */
- priv->notebook = gtk_notebook_new ();
- gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE);
-
- /* Show tabs (user preference) */
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), TRUE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
- gtk_paned_pack2 (GTK_PANED (hpaned2), priv->notebook, TRUE, FALSE);
- gtk_widget_show (priv->notebook);
-
- /* palette */
- palette = GTK_WIDGET (glade_app_get_palette ());
- glade_palette_set_show_selector_button (GLADE_PALETTE (palette), FALSE);
- gtk_paned_pack1 (GTK_PANED (hpaned2), palette, FALSE, FALSE);
- setup_dock (&priv->docks[DOCK_PALETTE], palette, 200, 540,
- _("Palette"), "palette", hpaned2, TRUE);
- gtk_widget_show (palette);
-
- /* inspectors */
- priv->inspectors_notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->inspectors_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->inspectors_notebook), FALSE);
- gtk_widget_show (priv->inspectors_notebook);
- gtk_paned_pack1 (GTK_PANED (vpaned), priv->inspectors_notebook, FALSE, FALSE);
- setup_dock (&priv->docks[DOCK_INSPECTOR], priv->inspectors_notebook, 300, 540,
- _("Inspector"), "inspector", vpaned, TRUE);
-
- /* editor */
- dockitem = GTK_WIDGET (glade_app_get_editor ());
- gtk_paned_pack2 (GTK_PANED (vpaned), dockitem, TRUE, FALSE);
- gtk_widget_show_all (dockitem);
- setup_dock (&priv->docks[DOCK_EDITOR], dockitem, 500, 700,
- _("Properties"), "properties", vpaned, FALSE);
-
- show_dock_first_time (window, DOCK_PALETTE, "DockPalette");
- show_dock_first_time (window, DOCK_INSPECTOR, "DockInspector");
- show_dock_first_time (window, DOCK_EDITOR, "DockEditor");
-
- /* status bar */
- priv->statusbar = gtk_statusbar_new ();
- priv->statusbar_menu_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
- "menu");
- priv->statusbar_actions_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
- "actions");
- gtk_box_pack_end (GTK_BOX (vbox), priv->statusbar, FALSE, TRUE, 0);
- gtk_widget_show (priv->statusbar);
-
-
- gtk_widget_show (vbox);
-
- /* recent files */
- priv->recent_manager = gtk_recent_manager_get_default ();
-
- priv->recent_menu = create_recent_chooser_menu (window, priv->recent_manager);
-
- g_signal_connect (priv->recent_menu,
- "item-activated",
- G_CALLBACK (recent_chooser_item_activated_cb),
- window);
-
- widget = gtk_ui_manager_get_widget (priv->ui, "/MenuBar/FileMenu/OpenRecent");
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), priv->recent_menu);
-
- /* palette selector & drag/resize buttons */
- sep = GTK_WIDGET (gtk_separator_tool_item_new());
- gtk_widget_show (GTK_WIDGET (sep));
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (sep), -1);
-
- priv->selector_button =
- GTK_TOGGLE_TOOL_BUTTON (create_selector_tool_button (GTK_TOOLBAR (priv->toolbar)));
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
- GTK_TOOL_ITEM (priv->selector_button), -1);
-
- priv->preview_button =
- GTK_TOOL_BUTTON (create_preview_tool_button (GTK_TOOLBAR (priv->toolbar)));
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
- GTK_TOOL_ITEM (priv->preview_button), -1);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->preview_button), FALSE);
-
- priv->drag_resize_button =
- GTK_TOGGLE_TOOL_BUTTON (create_drag_resize_tool_button
- (GTK_TOOLBAR (priv->toolbar)));
- gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
- GTK_TOOL_ITEM (priv->drag_resize_button), -1);
-
- gtk_toggle_tool_button_set_active (priv->selector_button, TRUE);
- gtk_toggle_tool_button_set_active (priv->drag_resize_button, FALSE);
-
- g_signal_connect (G_OBJECT (priv->selector_button), "toggled",
- G_CALLBACK (on_selector_button_toggled), window);
- g_signal_connect (G_OBJECT (priv->preview_button), "clicked",
- G_CALLBACK (on_preview_button_clicked), window);
- g_signal_connect (G_OBJECT (priv->drag_resize_button), "toggled",
- G_CALLBACK (on_drag_resize_button_toggled), window);
- g_signal_connect (G_OBJECT (glade_app_get()), "notify::pointer-mode",
- G_CALLBACK (on_pointer_mode_changed), window);
-
-
- /* support for opening a file by dragging onto the project window */
- gtk_drag_dest_set (GTK_WIDGET (window),
- GTK_DEST_DEFAULT_ALL,
- drop_types, G_N_ELEMENTS (drop_types),
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
- g_signal_connect (G_OBJECT (window), "drag-data-received",
- G_CALLBACK (drag_data_received), window);
-
- g_signal_connect (G_OBJECT (window), "delete_event",
- G_CALLBACK (delete_event), window);
-
-
- /* GtkNotebook signals */
- g_signal_connect (priv->notebook,
- "switch-page",
- G_CALLBACK (notebook_switch_page_cb),
- window);
- g_signal_connect (priv->notebook,
- "page-added",
- G_CALLBACK (notebook_tab_added_cb),
- window);
- g_signal_connect (priv->notebook,
- "page-removed",
- G_CALLBACK (notebook_tab_removed_cb),
- window);
-
- /* GtkWindow events */
- g_signal_connect (G_OBJECT (window), "key-press-event",
- G_CALLBACK (glade_utils_hijack_key_press), window);
-
- /* GladeApp signals */
- g_signal_connect (G_OBJECT (priv->app), "update-ui",
- G_CALLBACK (update_ui),
- window);
-
- /* Clipboard signals */
- g_signal_connect (G_OBJECT (glade_app_get_clipboard ()), "notify::has-selection",
- G_CALLBACK (clipboard_notify_handler_cb),
- window);
-
- glade_app_set_window (GTK_WIDGET (window));
-
- glade_window_config_load (window);
+
+static void
+show_dock_first_time (GladeWindow * window,
+ guint dock_type, const char *action_id)
+{
+ GKeyFile *config;
+ int detached = -1;
+ gboolean maximized;
+ GtkAction *action;
+ ToolDock *dock;
+
+ action =
+ gtk_action_group_get_action (window->priv->static_actions, action_id);
+ g_object_set_data (G_OBJECT (action), "glade-dock-type",
+ GUINT_TO_POINTER (dock_type));
+
+ dock = &window->priv->docks[dock_type];
+ config = glade_app_get_config ();
+
+ key_file_get_window_position (config, dock->id, &dock->window_pos, &detached,
+ &maximized);
+
+ if (detached == 1)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
+
+ if (maximized)
+ gtk_window_maximize (GTK_WINDOW (gtk_widget_get_toplevel (dock->widget)));
+}
+
+static void
+setup_dock (ToolDock * dock,
+ GtkWidget * dock_widget,
+ guint default_width,
+ guint default_height,
+ const char *window_title,
+ const char *id, GtkWidget * paned, gboolean first_child)
+{
+ dock->widget = dock_widget;
+ dock->window_pos.x = dock->window_pos.y = G_MININT;
+ dock->window_pos.width = default_width;
+ dock->window_pos.height = default_height;
+ dock->title = g_strdup (window_title);
+ dock->id = g_strdup (id);
+ dock->paned = paned;
+ dock->first_child = first_child;
+ dock->detached = FALSE;
+ dock->maximized = FALSE;
+}
+
+static void
+glade_window_init (GladeWindow * window)
+{
+ GladeWindowPrivate *priv;
+
+ GtkWidget *vbox;
+ GtkWidget *hpaned1;
+ GtkWidget *hpaned2;
+ GtkWidget *vpaned;
+ GtkWidget *menubar;
+ GtkWidget *palette;
+ GtkWidget *dockitem;
+ GtkWidget *widget;
+ GtkWidget *sep;
+ GtkAction *undo_action, *redo_action;
+
+ window->priv = priv = GLADE_WINDOW_GET_PRIVATE (window);
+
+ priv->default_path = NULL;
+
+ priv->app = glade_app_new ();
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ /* menubar */
+ menubar = construct_menu (window);
+ gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
+ gtk_widget_show (menubar);
+
+ /* toolbar */
+ priv->toolbar = gtk_ui_manager_get_widget (priv->ui, "/ToolBar");
+ gtk_box_pack_start (GTK_BOX (vbox), priv->toolbar, FALSE, TRUE, 0);
+ gtk_widget_show (priv->toolbar);
+
+ /* undo/redo buttons */
+ priv->undo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_UNDO);
+ priv->redo = gtk_menu_tool_button_new_from_stock (GTK_STOCK_REDO);
+ gtk_widget_show (GTK_WIDGET (priv->undo));
+ gtk_widget_show (GTK_WIDGET (priv->redo));
+ gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON
+ (priv->undo),
+ _("Go back in undo history"));
+ gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON
+ (priv->redo),
+ _("Go forward in undo history"));
+
+ sep = GTK_WIDGET (gtk_separator_tool_item_new ());
+ gtk_widget_show (sep);
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (sep), 3);
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (priv->undo),
+ 4);
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (priv->redo),
+ 5);
+
+ undo_action = gtk_ui_manager_get_action (priv->ui, "/MenuBar/EditMenu/Undo");
+ redo_action = gtk_ui_manager_get_action (priv->ui, "/MenuBar/EditMenu/Redo");
+
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->undo),
+ undo_action);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->redo),
+ redo_action);
+
+ /* main contents */
+ hpaned1 = gtk_hpaned_new ();
+ hpaned2 = gtk_hpaned_new ();
+ vpaned = gtk_vpaned_new ();
+ priv->center_pane = hpaned1;
+ priv->left_pane = hpaned2;
+ priv->right_pane = vpaned;
+
+ gtk_container_set_border_width (GTK_CONTAINER (hpaned1), 2);
+
+ gtk_box_pack_start (GTK_BOX (vbox), hpaned1, TRUE, TRUE, 0);
+ gtk_paned_pack1 (GTK_PANED (hpaned1), hpaned2, TRUE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (hpaned1), vpaned, FALSE, FALSE);
+
+ /* divider position between tree and editor */
+ gtk_paned_set_position (GTK_PANED (vpaned), 150);
+
+ gtk_widget_show_all (hpaned1);
+ gtk_widget_show_all (hpaned2);
+ gtk_widget_show_all (vpaned);
+
+ /* notebook */
+ priv->notebook = gtk_notebook_new ();
+ gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE);
+
+ /* Show tabs (user preference) */
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), TRUE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
+ gtk_paned_pack2 (GTK_PANED (hpaned2), priv->notebook, TRUE, FALSE);
+ gtk_widget_show (priv->notebook);
+
+ /* palette */
+ palette = GTK_WIDGET (glade_app_get_palette ());
+ glade_palette_set_show_selector_button (GLADE_PALETTE (palette), FALSE);
+ gtk_paned_pack1 (GTK_PANED (hpaned2), palette, FALSE, FALSE);
+ setup_dock (&priv->docks[DOCK_PALETTE], palette, 200, 540,
+ _("Palette"), "palette", hpaned2, TRUE);
+ gtk_widget_show (palette);
+
+ /* inspectors */
+ priv->inspectors_notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->inspectors_notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->inspectors_notebook),
+ FALSE);
+ gtk_widget_show (priv->inspectors_notebook);
+ gtk_paned_pack1 (GTK_PANED (vpaned), priv->inspectors_notebook, FALSE, FALSE);
+ setup_dock (&priv->docks[DOCK_INSPECTOR], priv->inspectors_notebook, 300, 540,
+ _("Inspector"), "inspector", vpaned, TRUE);
+
+ /* editor */
+ dockitem = GTK_WIDGET (glade_app_get_editor ());
+ gtk_paned_pack2 (GTK_PANED (vpaned), dockitem, TRUE, FALSE);
+ gtk_widget_show_all (dockitem);
+ setup_dock (&priv->docks[DOCK_EDITOR], dockitem, 500, 700,
+ _("Properties"), "properties", vpaned, FALSE);
+
+ show_dock_first_time (window, DOCK_PALETTE, "DockPalette");
+ show_dock_first_time (window, DOCK_INSPECTOR, "DockInspector");
+ show_dock_first_time (window, DOCK_EDITOR, "DockEditor");
+
+ /* status bar */
+ priv->statusbar = gtk_statusbar_new ();
+ priv->statusbar_menu_context_id =
+ gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "menu");
+ priv->statusbar_actions_context_id =
+ gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "actions");
+ gtk_box_pack_end (GTK_BOX (vbox), priv->statusbar, FALSE, TRUE, 0);
+ gtk_widget_show (priv->statusbar);
+
+
+ gtk_widget_show (vbox);
+
+ /* recent files */
+ priv->recent_manager = gtk_recent_manager_get_default ();
+
+ priv->recent_menu = create_recent_chooser_menu (window, priv->recent_manager);
+
+ g_signal_connect (priv->recent_menu,
+ "item-activated",
+ G_CALLBACK (recent_chooser_item_activated_cb), window);
+
+ widget = gtk_ui_manager_get_widget (priv->ui, "/MenuBar/FileMenu/OpenRecent");
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), priv->recent_menu);
+
+ /* palette selector & drag/resize buttons */
+ sep = GTK_WIDGET (gtk_separator_tool_item_new ());
+ gtk_widget_show (GTK_WIDGET (sep));
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), GTK_TOOL_ITEM (sep), -1);
+
+ priv->selector_button =
+ GTK_TOGGLE_TOOL_BUTTON (create_selector_tool_button
+ (GTK_TOOLBAR (priv->toolbar)));
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
+ GTK_TOOL_ITEM (priv->selector_button), -1);
+
+ priv->preview_button =
+ GTK_TOOL_BUTTON (create_preview_tool_button
+ (GTK_TOOLBAR (priv->toolbar)));
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
+ GTK_TOOL_ITEM (priv->preview_button), -1);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->preview_button), FALSE);
+
+ priv->drag_resize_button =
+ GTK_TOGGLE_TOOL_BUTTON (create_drag_resize_tool_button
+ (GTK_TOOLBAR (priv->toolbar)));
+ gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
+ GTK_TOOL_ITEM (priv->drag_resize_button), -1);
+
+ gtk_toggle_tool_button_set_active (priv->selector_button, TRUE);
+ gtk_toggle_tool_button_set_active (priv->drag_resize_button, FALSE);
+
+ g_signal_connect (G_OBJECT (priv->selector_button), "toggled",
+ G_CALLBACK (on_selector_button_toggled), window);
+ g_signal_connect (G_OBJECT (priv->preview_button), "clicked",
+ G_CALLBACK (on_preview_button_clicked), window);
+ g_signal_connect (G_OBJECT (priv->drag_resize_button), "toggled",
+ G_CALLBACK (on_drag_resize_button_toggled), window);
+ g_signal_connect (G_OBJECT (glade_app_get ()), "notify::pointer-mode",
+ G_CALLBACK (on_pointer_mode_changed), window);
+
+
+ /* support for opening a file by dragging onto the project window */
+ gtk_drag_dest_set (GTK_WIDGET (window),
+ GTK_DEST_DEFAULT_ALL,
+ drop_types, G_N_ELEMENTS (drop_types),
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
+ g_signal_connect (G_OBJECT (window), "drag-data-received",
+ G_CALLBACK (drag_data_received), window);
+
+ g_signal_connect (G_OBJECT (window), "delete_event",
+ G_CALLBACK (delete_event), window);
+
+
+ /* GtkNotebook signals */
+ g_signal_connect (priv->notebook,
+ "switch-page",
+ G_CALLBACK (notebook_switch_page_cb), window);
+ g_signal_connect (priv->notebook,
+ "page-added", G_CALLBACK (notebook_tab_added_cb), window);
+ g_signal_connect (priv->notebook,
+ "page-removed",
+ G_CALLBACK (notebook_tab_removed_cb), window);
+
+ /* GtkWindow events */
+ g_signal_connect (G_OBJECT (window), "key-press-event",
+ G_CALLBACK (glade_utils_hijack_key_press), window);
+
+ /* GladeApp signals */
+ g_signal_connect (G_OBJECT (priv->app), "update-ui",
+ G_CALLBACK (update_ui), window);
+
+ /* Clipboard signals */
+ g_signal_connect (G_OBJECT (glade_app_get_clipboard ()),
+ "notify::has-selection",
+ G_CALLBACK (clipboard_notify_handler_cb), window);
+
+ glade_app_set_window (GTK_WIDGET (window));
+
+ glade_window_config_load (window);
#ifdef MAC_INTEGRATION
- {
- /* Fix up the menubar for MacOSX Quartz builds */
- gtk_widget_hide (menubar);
- ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (menubar));
-
- widget = gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/FileMenu/Quit");
- ige_mac_menu_set_quit_menu_item (GTK_MENU_ITEM (widget));
- }
+ {
+ /* Fix up the menubar for MacOSX Quartz builds */
+ gtk_widget_hide (menubar);
+ ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (menubar));
+
+ widget =
+ gtk_ui_manager_get_widget (window->priv->ui, "/MenuBar/FileMenu/Quit");
+ ige_mac_menu_set_quit_menu_item (GTK_MENU_ITEM (widget));
+ }
#endif
}
static void
-glade_window_class_init (GladeWindowClass *klass)
+glade_window_class_init (GladeWindowClass * klass)
{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkCssProvider *provider;
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkCssProvider *provider;
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
- object_class->dispose = glade_window_dispose;
- object_class->finalize = glade_window_finalize;
+ object_class->dispose = glade_window_dispose;
+ object_class->finalize = glade_window_finalize;
- widget_class->configure_event = glade_window_configure_event;
+ widget_class->configure_event = glade_window_configure_event;
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- "GtkProgressBar#glade-tab-label-progress {\n"
- " -GtkProgressBar-min-horizontal-bar-width : 1;\n"
- " -GtkProgressBar-min-horizontal-bar-height : 1;\n"
- " -GtkProgressBar-xspacing : 4;\n"
- " -GtkProgressBar-yspacing : 0;\n"
- " padding : 0;\n"
- " }",
- -1, NULL);
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ "GtkProgressBar#glade-tab-label-progress {\n"
+ " -GtkProgressBar-min-horizontal-bar-width : 1;\n"
+ " -GtkProgressBar-min-horizontal-bar-height : 1;\n"
+ " -GtkProgressBar-xspacing : 4;\n"
+ " -GtkProgressBar-yspacing : 0;\n"
+ " padding : 0;\n" " }", -1, NULL);
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
- g_type_class_add_private (klass, sizeof (GladeWindowPrivate));
+ g_type_class_add_private (klass, sizeof (GladeWindowPrivate));
}
GtkWidget *
glade_window_new (void)
{
- return g_object_new (GLADE_TYPE_WINDOW, NULL);
+ return g_object_new (GLADE_TYPE_WINDOW, NULL);
}
void
-glade_window_check_devhelp (GladeWindow *window)
-{
- g_return_if_fail (GLADE_IS_WINDOW (window));
-
- if (glade_util_have_devhelp ())
- {
- GladeEditor *editor = glade_app_get_editor ();
- glade_editor_show_info (editor);
-
- g_signal_handlers_disconnect_by_func (editor, doc_search_cb, window);
-
- g_signal_connect (editor, "gtk-doc-search",
- G_CALLBACK (doc_search_cb), window);
-
- }
-}
+glade_window_check_devhelp (GladeWindow * window)
+{
+ g_return_if_fail (GLADE_IS_WINDOW (window));
+ if (glade_util_have_devhelp ())
+ {
+ GladeEditor *editor = glade_app_get_editor ();
+ glade_editor_show_info (editor);
+
+ g_signal_handlers_disconnect_by_func (editor, doc_search_cb, window);
+
+ g_signal_connect (editor, "gtk-doc-search",
+ G_CALLBACK (doc_search_cb), window);
+
+ }
+}
diff --git a/src/glade-window.h b/src/glade-window.h
index 5194f95..d3fae18 100644
--- a/src/glade-window.h
+++ b/src/glade-window.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2007 Vincent Geddes.
diff --git a/src/main.c b/src/main.c
index 4e440e3..e7b440b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
@@ -46,145 +45,145 @@
static gboolean version = FALSE, without_devhelp = FALSE;
static gchar **files = NULL;
-static GOptionEntry option_entries[] =
-{
- { "version", '\0', 0, G_OPTION_ARG_NONE, &version,
- N_("Output version information and exit"), NULL },
-
- { "without-devhelp", '\0', 0, G_OPTION_ARG_NONE, &without_devhelp,
- N_("Disable Devhelp integration"), NULL },
-
- { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
- NULL, N_("[FILE...]") },
-
- { NULL }
+static GOptionEntry option_entries[] = {
+ {"version", '\0', 0, G_OPTION_ARG_NONE, &version,
+ N_("Output version information and exit"), NULL},
+
+ {"without-devhelp", '\0', 0, G_OPTION_ARG_NONE, &without_devhelp,
+ N_("Disable Devhelp integration"), NULL},
+
+ {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
+ NULL, N_("[FILE...]")},
+
+ {NULL}
};
/* Debugging arguments */
static gboolean verbose = FALSE;
-static GOptionEntry debug_option_entries[] =
-{
- { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("be verbose"), NULL },
- { NULL }
+static GOptionEntry debug_option_entries[] = {
+ {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("be verbose"), NULL},
+ {NULL}
};
int
main (int argc, char *argv[])
{
- GladeWindow *window;
- GOptionContext *option_context;
- GOptionGroup *option_group;
- GError *error = NULL;
+ GladeWindow *window;
+ GOptionContext *option_context;
+ GOptionGroup *option_group;
+ GError *error = NULL;
- if (!g_thread_supported ())
- g_thread_init (NULL);
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
#ifdef ENABLE_NLS
- setlocale (LC_ALL, "");
- bindtextdomain (GETTEXT_PACKAGE, glade_app_get_locale_dir ());
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, glade_app_get_locale_dir ());
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
#endif
- /* Set up option groups */
- option_context = g_option_context_new (NULL);
-
- g_option_context_set_summary (option_context, N_("Create or edit user interface designs for GTK+ or GNOME applications."));
- g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);
-
- option_group = g_option_group_new ("glade",
- N_("Glade options"),
- N_("Glade options"),
- NULL, NULL);
- g_option_group_add_entries (option_group, option_entries);
- g_option_context_set_main_group (option_context, option_group);
- g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
-
- option_group = g_option_group_new ("debug",
- N_("Glade debug options"),
- N_("Show Glade debug options"),
- NULL, NULL);
- g_option_group_add_entries (option_group, debug_option_entries);
- g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
- g_option_context_add_group (option_context, option_group);
-
- /* Add Gtk option group */
- g_option_context_add_group (option_context, gtk_get_option_group (FALSE));
-
- /* Parse command line */
- if (!g_option_context_parse (option_context, &argc, &argv, &error))
- {
- g_option_context_free (option_context);
-
- if (error)
- {
- g_print ("%s\n", error->message);
- g_error_free (error);
- }
- else
- g_print ("An unknown error occurred\n");
-
- return -1;
- }
-
- g_option_context_free (option_context);
- option_context = NULL;
-
- if (version != FALSE)
- {
- /* Print version information and exit */
- g_print ("%s\n", PACKAGE_STRING);
- return 0;
- }
-
- /* Pass NULL here since we parsed the gtk+ args already...
- * from this point on we need a DISPLAY variable to be set.
- */
- gtk_init (NULL, NULL);
-
- /* Check for gmodule support */
- if (!g_module_supported ())
- {
- g_warning (_("gmodule support not found. gmodule support is required "
- "for glade to work"));
- return -1;
- }
-
- g_set_application_name (APPLICATION_NAME);
- gtk_window_set_default_icon_name ("glade-3");
-
- glade_setup_log_handlers ();
-
-
- window = GLADE_WINDOW (glade_window_new ());
-
- if (without_devhelp == FALSE)
- glade_window_check_devhelp (window);
-
- gtk_widget_show (GTK_WIDGET (window));
-
- /* load files specified on commandline */
- if (files != NULL)
- {
- guint i;
-
- for (i=0; files[i] ; ++i)
- {
- if (g_file_test (files[i], G_FILE_TEST_EXISTS) != FALSE)
- glade_window_open_project (window, files[i]);
- else
- g_warning (_("Unable to open '%s', the file does not exist.\n"), files[i]);
- }
- g_strfreev (files);
- }
-
- if (glade_app_get_project () == NULL)
- glade_window_new_project (window);
-
- gtk_main ();
-
- return 0;
+ /* Set up option groups */
+ option_context = g_option_context_new (NULL);
+
+ g_option_context_set_summary (option_context,
+ N_
+ ("Create or edit user interface designs for GTK+ or GNOME applications."));
+ g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);
+
+ option_group = g_option_group_new ("glade",
+ N_("Glade options"),
+ N_("Glade options"), NULL, NULL);
+ g_option_group_add_entries (option_group, option_entries);
+ g_option_context_set_main_group (option_context, option_group);
+ g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+
+ option_group = g_option_group_new ("debug",
+ N_("Glade debug options"),
+ N_("Show Glade debug options"),
+ NULL, NULL);
+ g_option_group_add_entries (option_group, debug_option_entries);
+ g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+ g_option_context_add_group (option_context, option_group);
+
+ /* Add Gtk option group */
+ g_option_context_add_group (option_context, gtk_get_option_group (FALSE));
+
+ /* Parse command line */
+ if (!g_option_context_parse (option_context, &argc, &argv, &error))
+ {
+ g_option_context_free (option_context);
+
+ if (error)
+ {
+ g_print ("%s\n", error->message);
+ g_error_free (error);
+ }
+ else
+ g_print ("An unknown error occurred\n");
+
+ return -1;
+ }
+
+ g_option_context_free (option_context);
+ option_context = NULL;
+
+ if (version != FALSE)
+ {
+ /* Print version information and exit */
+ g_print ("%s\n", PACKAGE_STRING);
+ return 0;
+ }
+
+ /* Pass NULL here since we parsed the gtk+ args already...
+ * from this point on we need a DISPLAY variable to be set.
+ */
+ gtk_init (NULL, NULL);
+
+ /* Check for gmodule support */
+ if (!g_module_supported ())
+ {
+ g_warning (_("gmodule support not found. gmodule support is required "
+ "for glade to work"));
+ return -1;
+ }
+
+ g_set_application_name (APPLICATION_NAME);
+ gtk_window_set_default_icon_name ("glade-3");
+
+ glade_setup_log_handlers ();
+
+
+ window = GLADE_WINDOW (glade_window_new ());
+
+ if (without_devhelp == FALSE)
+ glade_window_check_devhelp (window);
+
+ gtk_widget_show (GTK_WIDGET (window));
+
+ /* load files specified on commandline */
+ if (files != NULL)
+ {
+ guint i;
+
+ for (i = 0; files[i]; ++i)
+ {
+ if (g_file_test (files[i], G_FILE_TEST_EXISTS) != FALSE)
+ glade_window_open_project (window, files[i]);
+ else
+ g_warning (_("Unable to open '%s', the file does not exist.\n"),
+ files[i]);
+ }
+ g_strfreev (files);
+ }
+
+ if (glade_app_get_project () == NULL)
+ glade_window_new_project (window);
+
+ gtk_main ();
+
+ return 0;
}
#ifdef G_OS_WIN32
@@ -199,11 +198,9 @@ main (int argc, char *argv[])
int _stdcall
WinMain (struct HINSTANCE__ *hInstance,
- struct HINSTANCE__ *hPrevInstance,
- char *lpszCmdLine,
- int nCmdShow)
+ struct HINSTANCE__ *hPrevInstance, char *lpszCmdLine, int nCmdShow)
{
- return main (__argc, __argv);
+ return main (__argc, __argv);
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]