Commit 78097b2f authored by Tristan Van Berkom's avatar Tristan Van Berkom

* gladeui/glade-palette.[ch], gladeui/glade-project.[ch], gladeui/glade-app.[ch],

	  src/glade-window.c:
	  - Removed glade_app_get_palette()
	  - Moved "pointer-mode" property from GladeApp to GladeProject
	  - Palette now in charge of driving pointer mode on the project it's registered to
	  - GladeWindow now watches/sets the pointer mode on the currently set project (with
	    its "selector" and "drag/resize" toolbuttons).
parent cee72078
2011-01-04 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-palette.[ch], gladeui/glade-project.[ch], gladeui/glade-app.[ch],
src/glade-window.c:
- Removed glade_app_get_palette()
- Moved "pointer-mode" property from GladeApp to GladeProject
- Palette now in charge of driving pointer mode on the project it's registered to
- GladeWindow now watches/sets the pointer mode on the currently set project (with
its "selector" and "drag/resize" toolbuttons).
2011-01-03 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-app.[ch]:
......
......@@ -62,17 +62,10 @@ enum
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_POINTER_MODE
};
struct _GladeAppPrivate
{
GtkWidget *window;
GladePalette *palette; /* See glade-palette */
GladeClipboard *clipboard; /* See glade-clipboard */
GList *catalogs; /* See glade-catalog */
......@@ -85,8 +78,6 @@ struct _GladeAppPrivate
* GladeWidgets.
*/
GtkAccelGroup *accel_group; /* Default acceleration group for this app */
GladePointerMode pointer_mode; /* Current mode for the pointer in the workspace */
};
static guint glade_app_signals[LAST_SIGNAL] = { 0 };
......@@ -105,26 +96,6 @@ static void glade_init_check (void);
G_DEFINE_TYPE (GladeApp, glade_app, G_TYPE_OBJECT);
GType
glade_pointer_mode_get_type (void)
{
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;
}
/*****************************************************************
* GObjectClass *
*****************************************************************/
......@@ -158,11 +129,6 @@ glade_app_dispose (GObject * app)
{
GladeAppPrivate *priv = GLADE_APP_GET_PRIVATE (app);
if (priv->palette)
{
g_object_unref (priv->palette);
priv->palette = NULL;
}
if (priv->clipboard)
{
g_object_unref (priv->clipboard);
......@@ -194,40 +160,6 @@ glade_app_finalize (GObject * 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_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)
{
GladeApp *app = GLADE_APP (object);
switch (property_id)
{
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 *
*****************************************************************/
......@@ -373,10 +305,6 @@ glade_app_init (GladeApp * app)
/* 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 clipboard */
app->priv->clipboard = glade_clipboard_new ();
......@@ -394,12 +322,8 @@ glade_app_class_init (GladeAppClass * 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->signal_editor_created = glade_app_signal_editor_created_default;
klass->show_properties = NULL;
klass->hide_properties = NULL;
/**
* GladeApp::signal-editor-created:
......@@ -438,13 +362,6 @@ glade_app_class_init (GladeAppClass * klass)
G_TYPE_NONE, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
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));
}
......@@ -654,13 +571,6 @@ glade_app_get_window (void)
return app->priv->window;
}
GladePalette *
glade_app_get_palette (void)
{
GladeApp *app = glade_app_get ();
return app->priv->palette;
}
GladeClipboard *
glade_app_get_clipboard (void)
{
......@@ -745,35 +655,10 @@ glade_app_get_project_by_path (const gchar * project_path)
return NULL;
}
void
glade_app_show_properties (gboolean raise)
{
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);
}
void
glade_app_hide_properties (void)
{
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);
}
void
glade_app_add_project (GladeProject * project)
{
GladeApp *app;
GladeDesignView *view;
GladeDesignLayout *layout;
g_return_if_fail (GLADE_IS_PROJECT (project));
......@@ -785,31 +670,6 @@ glade_app_add_project (GladeProject * project)
/* Take a reference for GladeApp here... */
app->priv->projects = g_list_append (app->priv->projects, g_object_ref (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);
}
void
......@@ -822,14 +682,6 @@ glade_app_remove_project (GladeProject * project)
app->priv->projects = g_list_remove (app->priv->projects, project);
/* 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);
}
/* Its safe to just release the project as the project emits a
* "close" signal and everyone is responsable for cleaning up at
* that point.
......@@ -837,38 +689,6 @@ glade_app_remove_project (GladeProject * project)
g_object_unref (project);
}
/**
* glade_app_set_pointer_mode:
* @mode: A #GladePointerMode
*
* Sets the #GladePointerMode
*/
void
glade_app_set_pointer_mode (GladePointerMode mode)
{
GladeApp *app = glade_app_get ();
app->priv->pointer_mode = mode;
g_object_notify (G_OBJECT (app), "pointer-mode");
}
/**
* glade_app_get_pointer_mode:
*
* Gets the current #GladePointerMode
*
* Returns: The #GladePointerMode
*/
GladePointerMode
glade_app_get_pointer_mode (void)
{
GladeApp *app = glade_app_get ();
return app->priv->pointer_mode;
}
/*
* glade_app_set_accel_group:
*
......
......@@ -36,8 +36,6 @@ G_BEGIN_DECLS
#define GLADE_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_APP))
#define GLADE_APP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_APP, GladeAppClass))
#define GLADE_TYPE_POINTER_MODE (glade_pointer_mode_get_type())
#define GLADE_ENV_CATALOG_PATH "GLADE_CATALOG_PATH"
#define GLADE_ENV_MODULE_PATH "GLADE_MODULE_PATH"
......@@ -45,42 +43,19 @@ typedef struct _GladeApp GladeApp;
typedef struct _GladeAppPrivate GladeAppPrivate;
typedef struct _GladeAppClass GladeAppClass;
/**
* GladePointerMode:
* @GLADE_POINTER_SELECT: Mouse pointer used for selecting widgets
* @GLADE_POINTER_ADD_WIDGET: Mouse pointer used for adding widgets
* @GLADE_POINTER_DRAG_RESIZE: Mouse pointer used for dragging and
* resizing widgets in containers
*
* Indicates what the pointer is used for in the workspace.
*/
enum _GladePointerMode
{
GLADE_POINTER_SELECT = 0,
GLADE_POINTER_ADD_WIDGET,
GLADE_POINTER_DRAG_RESIZE
};
typedef enum _GladePointerMode GladePointerMode;
struct _GladeApp
{
GObject parent_instance;
GladeAppPrivate *priv;
GObject parent_instance;
GladeAppPrivate *priv;
};
struct _GladeAppClass
{
GObjectClass parent_class;
/* class methods */
void (* show_properties) (GladeApp* app,
gboolean raise);
void (* hide_properties) (GladeApp* app);
/* signals */
void (* signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
GObjectClass parent_class;
/* signals */
void (* signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
};
......@@ -88,8 +63,6 @@ GType glade_app_get_type (void) G_GNUC_CONST;
GladeApp* glade_app_new (void);
GType glade_pointer_mode_get_type (void) G_GNUC_CONST;
GladeApp* glade_app_get (void);
void glade_app_set_window (GtkWidget *window);
......@@ -102,14 +75,8 @@ GList *glade_app_get_catalogs (void);
GladeCatalog *glade_app_get_catalog (const gchar *name);
GladePalette* glade_app_get_palette (void);
GladeClipboard* glade_app_get_clipboard (void);
GladePointerMode glade_app_get_pointer_mode (void);
void glade_app_set_pointer_mode (GladePointerMode mode);
void glade_app_add_project (GladeProject *project);
void glade_app_remove_project (GladeProject *project);
......@@ -122,10 +89,6 @@ gboolean glade_app_is_project_loaded (const gchar *project_path);
GladeProject* glade_app_get_project_by_path (const gchar *project_path);
void glade_app_show_properties (gboolean raise);
void glade_app_hide_properties (void);
gint glade_app_config_save (void);
void glade_app_set_transient_parent (GtkWindow *parent);
......
......@@ -55,29 +55,22 @@ set_cursor_recurse (GtkWidget * widget, GdkCursor * gdk_cursor)
}
}
static void
set_cursor (GdkCursor * gdk_cursor)
set_cursor (GladeProject *project,
GdkCursor *gdk_cursor)
{
GladeProject *project;
GList *list, *projects;
GList *list;
for (projects = glade_app_get_projects ();
projects; projects = projects->next)
for (list = (GList *) glade_project_get_objects (project);
list; list = list->next)
{
project = projects->data;
for (list = (GList *) glade_project_get_objects (project);
list; list = list->next)
{
GObject *object = list->data;
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);
}
}
if (GTK_IS_WIDGET (object) &&
gtk_widget_get_has_window (GTK_WIDGET (object)))
{
set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
}
}
}
......@@ -90,7 +83,9 @@ 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 (GladeProject *project,
GdkWindow *window,
GladeCursorType type)
{
GladeWidgetAdaptor *adaptor;
GdkCursor *the_cursor = NULL;
......@@ -103,13 +98,12 @@ glade_cursor_set (GdkWindow * window, GladeCursorType type)
break;
case GLADE_CURSOR_ADD_WIDGET:
if ((adaptor =
glade_palette_get_current_item (glade_app_get_palette ())) != NULL)
glade_project_get_add_item (project)) != NULL)
{
g_object_get (adaptor, "cursor", &the_cursor, NULL);
if (the_cursor == NULL)
the_cursor = cursor->add_widget;
}
else
the_cursor = cursor->add_widget;
......@@ -145,7 +139,7 @@ glade_cursor_set (GdkWindow * window, GladeCursorType type)
break;
}
set_cursor (cursor->selector);
set_cursor (project, cursor->selector);
gdk_window_set_cursor (window, the_cursor);
}
......
......@@ -45,8 +45,10 @@ typedef enum {
GLADE_CURSOR_DRAG
} GladeCursorType;
void glade_cursor_init (void);
void glade_cursor_set (GdkWindow *window, GladeCursorType type);
void glade_cursor_init (void);
void glade_cursor_set (GladeProject *project,
GdkWindow *window,
GladeCursorType type);
const GdkPixbuf* glade_cursor_get_add_widget_pixbuf (void);
G_END_DECLS
......
......@@ -557,11 +557,12 @@ glade_fixed_handle_child_event (GladeFixed * fixed,
GtkWidget *fixed_widget, *child_widget;
gint fixed_x, fixed_y, child_x, child_y;
gboolean handled = FALSE, sig_handled;
GladeProject *project = glade_widget_get_project (GLADE_WIDGET (fixed));
fixed_widget = GTK_WIDGET (glade_widget_get_object (GLADE_WIDGET (fixed)));
child_widget = GTK_WIDGET (glade_widget_get_object (child));
pointer_mode = glade_app_get_pointer_mode ();
pointer_mode = glade_project_get_pointer_mode (project);
/* when widget->window points to a parent window, these calculations
* would be wrong if we based them on the GTK_WIDGET (fixed)->window,
......@@ -590,16 +591,16 @@ glade_fixed_handle_child_event (GladeFixed * fixed,
{
if ((event_state & GDK_SHIFT_MASK) ||
pointer_mode == GLADE_POINTER_DRAG_RESIZE)
glade_cursor_set (((GdkEventAny *) event)->window, operation);
glade_cursor_set (project, ((GdkEventAny *) event)->window, operation);
else if (pointer_mode == GLADE_POINTER_SELECT)
glade_cursor_set (((GdkEventAny *) event)->window,
glade_cursor_set (project, ((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_cursor_set (project, ((GdkEventAny *) event)->window, operation);
glade_fixed_cancel_operation (fixed, operation);
handled = TRUE;
......@@ -611,7 +612,7 @@ glade_fixed_handle_child_event (GladeFixed * fixed,
&fixed->mouse_x, &fixed->mouse_y);
glade_fixed_configure_widget (fixed, child);
glade_cursor_set (((GdkEventAny *) event)->window,
glade_cursor_set (project, ((GdkEventAny *) event)->window,
fixed->operation);
handled = TRUE;
}
......@@ -631,7 +632,7 @@ glade_fixed_handle_child_event (GladeFixed * fixed,
glade_fixed_save_state (fixed, child);
fixed->operation = operation;
glade_cursor_set (((GdkEventAny *) event)->window,
glade_cursor_set (project, ((GdkEventAny *) event)->window,
fixed->operation);
g_signal_emit (G_OBJECT (fixed),
......@@ -647,9 +648,9 @@ glade_fixed_handle_child_event (GladeFixed * fixed,
if ((event_state & GDK_SHIFT_MASK) ||
pointer_mode == GLADE_POINTER_DRAG_RESIZE)
glade_cursor_set (((GdkEventAny *) event)->window, operation);
glade_cursor_set (project, ((GdkEventAny *) event)->window, operation);
else
glade_cursor_set (((GdkEventAny *) event)->window,
glade_cursor_set (project, ((GdkEventAny *) event)->window,
GLADE_CURSOR_SELECTOR);
glade_fixed_cancel_operation (fixed, operation);
......@@ -667,6 +668,7 @@ glade_fixed_child_event (GladeWidget * gwidget,
GdkEvent * event, GladeFixed * fixed)
{
GtkWidget *event_widget;
GladeProject *project = glade_widget_get_project (gwidget);
/* Get the basic event info... */
gdk_window_get_user_data (((GdkEventAny *) event)->window,
......@@ -686,9 +688,9 @@ glade_fixed_child_event (GladeWidget * gwidget,
* the palette.
*/
if (GLADE_IS_FIXED (gwidget) &&
glade_app_get_pointer_mode () == GLADE_POINTER_ADD_WIDGET)
glade_project_get_pointer_mode (project) == GLADE_POINTER_ADD_WIDGET)
{
glade_cursor_set (((GdkEventAny *) event)->window,
glade_cursor_set (project, ((GdkEventAny *) event)->window,
GLADE_CURSOR_ADD_WIDGET);
return FALSE;
}
......@@ -795,9 +797,10 @@ glade_fixed_event (GladeWidget * gwidget_fixed, GdkEvent * event)
GladeFixed *fixed = GLADE_FIXED (gwidget_fixed);
GladeWidgetAdaptor *adaptor;
GtkWidget *event_widget;
GladeProject *project = glade_widget_get_project (gwidget_fixed);
gboolean handled = FALSE;
adaptor = glade_palette_get_current_item (glade_app_get_palette ());
adaptor = glade_project_get_add_item (project);
/* Get the event widget and the deep widget */
gdk_window_get_user_data (((GdkEventAny *) event)->window,
......@@ -843,24 +846,23 @@ glade_fixed_event (GladeWidget * gwidget_fixed, GdkEvent * event)
glade_widget_get_project (GLADE_WIDGET (fixed)));
fixed->creating = FALSE;
glade_palette_deselect_current_item (glade_app_get_palette (),
TRUE);
glade_project_set_add_item (project, NULL);
handled = TRUE;
}
}
break;
case GDK_MOTION_NOTIFY:
if (glade_app_get_pointer_mode () == GLADE_POINTER_ADD_WIDGET)
if (glade_project_get_pointer_mode (project) == GLADE_POINTER_ADD_WIDGET)
{
glade_cursor_set (((GdkEventAny *) event)->window,
glade_cursor_set (project, ((GdkEventAny *) event)->window,
GLADE_CURSOR_ADD_WIDGET);
handled = TRUE;
}
else if (GLADE_IS_FIXED (glade_widget_get_parent (gwidget_fixed)) == FALSE &&
glade_app_get_pointer_mode () == GLADE_POINTER_SELECT)
glade_cursor_set (((GdkEventAny *) event)->window,
glade_project_get_pointer_mode (project) == GLADE_POINTER_SELECT)
glade_cursor_set (project, ((GdkEventAny *) event)->window,
GLADE_CURSOR_SELECTOR);
break;
default:
......
This diff is collapsed.
......@@ -56,7 +56,6 @@ struct _GladePaletteClass
{
GtkVBoxClass parent_class;
void (* toggled) (GladePalette *palette);
void (* refresh) (GladePalette *palette);
};
......@@ -70,17 +69,12 @@ typedef enum
GType glade_palette_get_type (void) G_GNUC_CONST;
GtkWidget *glade_palette_new (const GList *catalogs);
GtkWidget *glade_palette_new (void);
GladeProject *glade_palette_get_project (GladePalette *palette);
void glade_palette_set_project (GladePalette *palette,
GladeProject *project);
void glade_palette_deselect_current_item (GladePalette *palette,
gboolean sticky_aware);
GladeWidgetAdaptor *glade_palette_get_current_item (GladePalette *palette);
GladeItemAppearance glade_palette_get_item_appearance (GladePalette *palette);
void glade_palette_set_item_appearance (GladePalette *palette,
......@@ -96,9 +90,6 @@ void glade_palette_set_show_selector_button (GladePalette *palette,
gboolean glade_palette_get_show_selector_button (GladePalette *palette);
GladeWidget *glade_palette_create_root_widget (GladePalette *palette,
GladeWidgetAdaptor *adaptor);
G_END_DECLS
#endif /* __GLADE_PALETTE_H__ */
......
......@@ -407,6 +407,7 @@ glade_placeholder_motion_notify_event (GtkWidget * widget,
{
GladePointerMode pointer_mode;
GladeWidget *gparent, *gparent_parent = NULL;
GladeProject *project;
g_return_val_if_fail (GLADE_IS_PLACEHOLDER (widget), FALSE);
......@@ -414,7 +415,8 @@ glade_placeholder_motion_notify_event (GtkWidget * widget,
if (gparent)
gparent_parent = glade_widget_get_parent (gparent);
pointer_mode = glade_app_get_pointer_mode ();
project = glade_placeholder_get_project (GLADE_PLACEHOLDER (widget));
pointer_mode = glade_project_get_pointer_mode (project);
if (pointer_mode == GLADE_POINTER_SELECT &&
/* If we are the child of a widget that is in a GladeFixed, then
......@@ -423,9 +425,9 @@ glade_placeholder_motion_notify_event (GtkWidget * widget,
* concurrencies I suppose).
*/
(gparent_parent && GLADE_IS_FIXED (gparent_parent)) == FALSE)
glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR);
glade_cursor_set (project, event->window, GLADE_CURSOR_SELECTOR);
else if (pointer_mode == GLADE_POINTER_ADD_WIDGET)
glade_cursor_set (event->window, GLADE_CURSOR_ADD_WIDGET);
glade_cursor_set (project, event->window, GLADE_CURSOR_ADD_WIDGET);
return FALSE;
}
......@@ -433,19 +435,16 @@ glade_placeholder_motion_notify_event (GtkWidget * widget,
static gboolean
glade_placeholder_button_press (GtkWidget * widget, GdkEventButton * event)
{
GladePlaceholder *placeholder;
GladeProject *project;
GladePlaceholder *placeholder;
GladeProject *project;
GladeWidgetAdaptor *adaptor;
GladePalette *palette;
gboolean handled = FALSE;
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);
project = glade_placeholder_get_project (placeholder);
adaptor = glade_project_get_add_item (project);
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
......@@ -464,11 +463,10 @@ glade_placeholder_button_press (GtkWidget * widget, GdkEventButton * event)
*/
glade_command_create (adaptor, parent, placeholder, project);
glade_palette_deselect_current_item (glade_app_get_palette (),
TRUE);
glade_project_set_add_item (project, NULL);
/* reset the cursor */
glade_cursor_set (event->window, GLADE_CURSOR_SELECTOR);
glade_cursor_set (project, event->window, GLADE_CURSOR_SELECTOR);
}
handled = TRUE;
}
......
......@@ -94,35 +94,37 @@ glade_popup_placeholder_add_cb (GtkMenuItem * item,
GladePlaceholder * placeholder)
{
GladeWidgetAdaptor *adaptor;
GladeWidget *parent;
GladeWidget *parent;
GladeProject *project;
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);
project = glade_placeholder_get_project (placeholder);
adaptor = glade_project_get_add_item (project);
g_return_if_fail (adaptor != NULL);
if (!glade_util_check_and_warn_scrollable
(parent, adaptor, glade_app_get_window ()))
{
glade_command_create (adaptor, parent,
placeholder,
glade_placeholder_get_project (placeholder));
project);
glade_palette_deselect_current_item (glade_app_get_palette (), TRUE);
glade_project_set_add_item (project, NULL);
}
}
typedef struct {
GladeWidgetAdaptor *adaptor;
GladeProject *project;
} RootAddData;
static void
glade_popup_root_add_cb (GtkMenuItem * item, gpointer * user_data)
glade_popup_root_add_cb (GtkMenuItem *item,
RootAddData *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);
glade_command_create (data->adaptor, NULL, NULL, data->project);
}
static void
......@@ -414,20 +416,29 @@ glade_popup_create_menu (GladeWidget *widget,
GladeProject *project,