Toplevel embeding fix patch
Juan Pablo Ugarte <[email protected]> Sun, 25 Apr 2010 16:32:47 -0700
| Newsgroups | gmane.comp.gnome.glade.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello guys, this patch replaces the old toplevel embeding hack by extending the "parent" catalog class property. This lets us make glade use a GtkEventBox as the runtime widget instead of a GtkWindow. The only downside is that we cant rely on the type of the object at runtime, so i had to replace all the GTK_IS_WINDOW. I will appreciate if you guys could test it and send me some feedback greets Juan Pablo _______________________________________________ Glade-devel maillist - [email protected] http://lists.ximian.com/mailman/listinfo/glade-devel
embed_fix.patch
(application/octet-stream, 27.1 KB)
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index 3570c40..0757f7f 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -683,23 +683,12 @@ glade_app_config_save ()
void
glade_app_set_transient_parent (GtkWindow *parent)
{
- GList *projects, *objects;
GladeApp *app;
g_return_if_fail (GTK_IS_WINDOW (parent));
app = glade_app_get ();
app->priv->transient_parent = parent;
-
- /* Loop over all projects/widgets and set_transient_for the toplevels.
- */
- for (projects = glade_app_get_projects (); /* projects */
- projects; projects = projects->next)
- for (objects = (GList *) glade_project_get_objects (GLADE_PROJECT (projects->data)); /* widgets */
- objects; objects = objects->next)
- if (GTK_IS_WINDOW (objects->data))
- gtk_window_set_transient_for
- (GTK_WINDOW (objects->data), parent);
}
GtkWindow *
@@ -1015,7 +1004,8 @@ glade_app_add_project (GladeProject *project)
{
GObject *obj = G_OBJECT (node->data);
- if (GTK_IS_WINDOW (obj))
+ 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));
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index ab4ef03..5c00b31 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -997,7 +997,7 @@ glade_command_add (GList *widgets,
* fix the bugs as they pop up.
*/
widget = GLADE_WIDGET (widgets->data);
- if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE)
+ if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
me->project = glade_placeholder_get_project (placeholder);
else
me->project = glade_app_get_project();
@@ -1023,9 +1023,9 @@ glade_command_add (GList *widgets,
/* Parent */
if (parent == NULL)
cdata->parent = glade_widget_get_parent (widget);
- else if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE)
+ else if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
cdata->parent = glade_placeholder_get_parent (placeholder);
- else if (GTK_IS_WINDOW (widget->object) == FALSE)
+ else if (GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
cdata->parent = parent;
/* Placeholder */
@@ -1896,9 +1896,9 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
g_return_if_fail (widgets != NULL);
-/* if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE) */
+/* if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE) */
/* target_project = glade_placeholder_get_project (placeholder); */
-/* else if (parent && GTK_IS_WINDOW (widget->object) == FALSE) */
+/* else if (parent && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE) */
/* target_project = glade_widget_get_project (parent); */
/* else */
/* target_project = glade_app_get_project(); */
@@ -2439,7 +2439,7 @@ find_format_rejected_object (GObject *object, gpointer fmtptr)
/* ... and widget is a non GtkWidget object */
!GTK_IS_WIDGET (widget->object) ||
/* ... and its a non-window toplevel */
- (!widget->parent && !GTK_IS_WINDOW (widget->object) && !widget->internal))))
+ (!widget->parent && g_strcmp0 (widget->adaptor->name, "GtkWindow") && !widget->internal))))
return 0;
return -1;
diff --git a/gladeui/glade-cursor.c b/gladeui/glade-cursor.c
index 21587b4..a08c00b 100644
--- a/gladeui/glade-cursor.c
+++ b/gladeui/glade-cursor.c
@@ -75,7 +75,8 @@ set_cursor (GdkCursor *gdk_cursor)
{
GObject *object = list->data;
- if (GTK_IS_WINDOW (object))
+ if (GTK_IS_WIDGET (object) &&
+ gtk_widget_get_has_window (GTK_WIDGET (object)))
{
set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
}
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index d3b3a96..b1e4963 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -324,13 +324,6 @@ glade_palette_toggled (GladePalette *palette)
* disabled so no chance of creating a non-window toplevel here
*/
widget = glade_palette_create_root_widget (palette, adaptor);
-
- /* if this is a top level widget set the accel group */
- if (widget && glade_app_get_accel_group () && GTK_IS_WINDOW (widget->object))
- {
- gtk_window_add_accel_group (GTK_WINDOW (widget->object),
- glade_app_get_accel_group ());
- }
}
}
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 5c8679f..f6c33ab 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -498,9 +498,14 @@ glade_popup_create_menu (GladeWidget *widget,
/* paste is placholder specific when the popup is on a placeholder */
sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());
non_window = FALSE;
+
for (list = glade_app_get_clipboard ()->selection; list; list = list->next)
- if (!GTK_IS_WINDOW (GLADE_WIDGET (list->data)->object))
+ {
+ GladeWidget *gwidget = GLADE_WIDGET (list->data);
+ if (!GTK_IS_WIDGET (gwidget->object) ||
+ !gtk_widget_get_has_window (GTK_WIDGET (gwidget->object)))
non_window = TRUE;
+ }
if (placeholder)
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index 87bf8c9..80cef70 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -200,7 +200,7 @@ glade_property_class_free (GladePropertyClass *property_class)
}
-static GValue *
+GValue *
glade_property_class_get_default_from_spec (GParamSpec *spec)
{
GValue *value;
diff --git a/gladeui/glade-property-class.h b/gladeui/glade-property-class.h
index b2ec3ef..cedeceb 100644
--- a/gladeui/glade-property-class.h
+++ b/gladeui/glade-property-class.h
@@ -278,6 +278,8 @@ gint glade_property_class_compare (GladePropertyC
const GValue *value2,
GladeProjectFormat fmt);
+GValue *glade_property_class_get_default_from_spec (GParamSpec *spec);
+
G_END_DECLS
#endif /* __GLADE_PROPERTY_CLASS_H__ */
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 262d412..318369d 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -346,14 +346,14 @@ gwa_add_signals (GladeWidgetAdaptor *adaptor, GList **signals, GType type)
}
static GList *
-gwa_list_signals (GladeWidgetAdaptor *adaptor)
+gwa_list_signals (GladeWidgetAdaptor *adaptor, GType real_type)
{
GList *signals = NULL;
GType type, parent, *i, *p;
- g_return_val_if_fail (adaptor->type != 0, NULL);
+ g_return_val_if_fail (real_type != 0, NULL);
- for (type = adaptor->type; g_type_is_a (type, G_TYPE_OBJECT); type = parent)
+ for (type = real_type; g_type_is_a (type, G_TYPE_OBJECT); type = parent)
{
parent = g_type_parent (type);
@@ -593,7 +593,7 @@ glade_widget_adaptor_constructor (GType type,
if ((object_class = g_type_class_ref (adaptor->type)))
{
/* Build signals & properties */
- adaptor->signals = gwa_list_signals (adaptor);
+ adaptor->signals = gwa_list_signals (adaptor, adaptor->type);
gwa_inherit_signals (adaptor);
gwa_setup_properties (adaptor, object_class, FALSE);
@@ -1854,6 +1854,189 @@ gwa_update_properties_from_node (GladeWidgetAdaptor *adaptor,
}
}
+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;
+}
+
+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++)
+ {
+ GList *list;
+ GladePropertyClass *property_class;
+ gboolean updated;
+
+ /* 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,
@@ -2051,9 +2234,10 @@ static GType
generate_type (const char *name,
const char *parent_name)
{
- GType parent_type;
+ 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);
@@ -2063,12 +2247,29 @@ generate_type (const char *name,
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 g_type_register_static (parent_type, name, type_info, 0);
+ return retval;
}
@@ -2091,7 +2292,7 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
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;
+ GType object_type, adaptor_type, parent_type, real_type;
gchar *missing_icon = NULL;
GWADerivedClassData data;
@@ -2106,7 +2307,7 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
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)
@@ -2245,6 +2446,23 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
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.
+ */
+ real_type = g_type_from_name (adaptor->name);
+ if (adaptor->type != real_type)
+ {
+ adaptor->signals = gwa_list_signals (adaptor, real_type);
+
+ gwa_update_properties_from_type (adaptor, real_type,
+ &adaptor->properties, FALSE);
+ gwa_update_properties_from_type (adaptor, real_type,
+ &adaptor->packing_props, TRUE);
+ }
+
/* Perform a stoopid fallback just incase */
if (adaptor->generic_name == NULL)
adaptor->generic_name = g_strdup ("widget");
@@ -2255,7 +2473,7 @@ glade_widget_adaptor_from_catalog (GladeCatalog *catalog,
adaptor->priv->book = g_strdup (glade_catalog_get_book (catalog));
gwa_extend_with_node (adaptor, class_node, module, glade_catalog_get_domain (catalog));
-
+
if (!glade_catalog_supports_libglade (catalog))
GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->libglade_unsupported = TRUE;
if (!glade_catalog_supports_gtkbuilder (catalog))
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 7bd82eb..69c6f4d 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -63,8 +63,6 @@ static void glade_widget_set_adaptor (GladeWidget *w
GladeWidgetAdaptor *adaptor);
static void glade_widget_set_properties (GladeWidget *widget,
GList *properties);
-static gboolean glade_window_is_embedded (GtkWindow *window);
-static gboolean glade_widget_embed (GladeWidget *widget);
enum
{
@@ -1522,20 +1520,11 @@ glade_widget_dup_internal (GladeWidget *main_target,
for (l = gwidget->properties; l; l = l->next)
glade_property_load (GLADE_PROPERTY (l->data));
- /* Special case GtkWindow here and ensure the pasted window
- * has the same size as the 'Cut' one.
- */
- if (GTK_IS_WINDOW (gwidget->object))
- {
- gint width, height;
- g_assert (GTK_IS_WINDOW (template_widget->object));
-
- gtk_window_get_size (GTK_WINDOW (template_widget->object),
- &width, &height);
- gtk_window_resize (GTK_WINDOW (gwidget->object),
- width, height);
- }
-
+ 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;
}
@@ -1969,12 +1958,6 @@ glade_widget_show (GladeWidget *widget)
/* Position window at saved coordinates or in the center */
if (GTK_IS_WIDGET (widget->object) && !widget->parent)
{
- if (GTK_IS_WINDOW (widget->object) && !glade_widget_embed (widget))
- {
- g_warning ("Unable to embed %s\n", widget->name);
- return;
- }
-
/* Maybe a property references this widget internally, show that widget instead */
if ((property = glade_widget_get_parentless_widget_ref (widget)) != NULL)
{
@@ -4193,142 +4176,6 @@ glade_widget_remove_pack_action (GladeWidget *widget, const gchar *action_path)
glade_widget_action_lookup (&widget->packing_actions, action_path, TRUE);
}
-/*******************************************************************************
- * Toplevel GladeWidget Embedding *
- ******************************************************************************
- *
- * Overrides realize() and size_allocate() by signal connection on GtkWindows.
- *
- * This is high crack code and should be replaced by a more robust implementation
- * in GTK+ proper.
- *
- */
-
-static GQuark
-embedded_window_get_quark ()
-{
- static GQuark embedded_window_quark = 0;
-
- if (embedded_window_quark == 0)
- embedded_window_quark = g_quark_from_string ("GladeEmbedWindow");
-
- return embedded_window_quark;
-}
-
-static gboolean
-glade_window_is_embedded (GtkWindow *window)
-{
- return GPOINTER_TO_INT (g_object_get_qdata ((GObject *) window, embedded_window_get_quark ()));
-}
-
-static void
-embedded_window_realize_handler (GtkWidget *widget)
-{
- GtkAllocation allocation;
- GtkStyle *style;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- gtk_widget_set_realized (widget, TRUE);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
-
- gtk_widget_get_allocation (widget, &allocation);
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
-
- attributes.event_mask = gtk_widget_get_events (widget) |
- GDK_EXPOSURE_MASK |
- GDK_FOCUS_CHANGE_MASK |
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_STRUCTURE_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- /* destroy the previously created window */
- window = gtk_widget_get_window (widget);
- if (GDK_IS_WINDOW (window))
- {
- gdk_window_hide (window);
- }
-
- window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gtk_widget_set_window (widget, window);
-
- gdk_window_enable_synchronized_configure (window);
-
- gdk_window_set_user_data (window, GTK_WINDOW (widget));
-
- gtk_widget_style_attach (widget);
- style = gtk_widget_get_style (widget);
- gtk_style_set_background (style, window, GTK_STATE_NORMAL);
-}
-
-static void
-embedded_window_size_allocate_handler (GtkWidget *widget)
-{
- GtkAllocation allocation;
-
- if (gtk_widget_get_realized (widget))
- {
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation.x,
- allocation.y,
- allocation.width,
- allocation.height);
- }
-}
-
-/**
- * glade_widget_embed:
- * @window: a #GtkWindow
- *
- * Embeds a window by signal connection method
- */
-static gboolean
-glade_widget_embed (GladeWidget *gwidget)
-{
- GtkWindow *window;
- GtkWidget *widget;
-
- g_return_val_if_fail (GLADE_IS_WIDGET (gwidget), FALSE);
- g_return_val_if_fail (GTK_IS_WINDOW (gwidget->object), FALSE);
-
- window = GTK_WINDOW (gwidget->object);
- widget = GTK_WIDGET (window);
-
- if (glade_window_is_embedded (window)) return TRUE;
-
- if (gtk_widget_get_realized (widget)) gtk_widget_unrealize (widget);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_TOPLEVEL);
- gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_PARENT);
-
- g_signal_connect (window, "realize",
- G_CALLBACK (embedded_window_realize_handler), NULL);
- g_signal_connect (window, "size-allocate",
- G_CALLBACK (embedded_window_size_allocate_handler), NULL);
-
- /* mark window as embedded */
- g_object_set_qdata (G_OBJECT (window), embedded_window_get_quark (),
- GINT_TO_POINTER (TRUE));
-
- return TRUE;
-}
-
-
-
/**
* glade_widget_create_editor_property:
* @widget: A #GladeWidget
diff --git a/plugins/gtk+/glade-convert.c b/plugins/gtk+/glade-convert.c
index 6874462..c2c465c 100644
--- a/plugins/gtk+/glade-convert.c
+++ b/plugins/gtk+/glade-convert.c
@@ -796,14 +796,13 @@ convert_menus_finished (GladeProject *project,
if (accel_group == NULL)
{
GladeWidget *toplevel = glade_widget_get_toplevel (widget);
-
+ GladeProperty *groups_prop;
+
accel_group = glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_ACCEL_GROUP),
NULL, NULL, project);
-
- if (GTK_IS_WINDOW (toplevel->object))
+ if ((groups_prop = glade_widget_get_property (toplevel, "accel-groups")))
{
- GladeProperty *groups_prop = glade_widget_get_property (toplevel, "accel-groups");
GList *list = g_list_append (NULL, accel_group->object);
glade_command_set_property (groups_prop, list);
g_list_free (list);
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 189b350..e4de386 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -952,7 +952,7 @@ glade_gtk_widget_deep_post_create (GladeWidgetAdaptor *adaptor,
glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
- if (GTK_IS_WINDOW (widget) || gwidget->internal)
+ if (GWA_IS_TOPLEVEL (adaptor) || gwidget->internal)
glade_widget_set_action_sensitive (gwidget, "add_parent", FALSE);
@@ -4982,29 +4982,6 @@ glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor *adaptor,
}
/* ----------------------------- GtkWindow ------------------------------ */
-static gint
-glade_gtk_widget_show_on_delete (GtkWidget *widget,
- gpointer user_data)
-{
- gtk_widget_show (widget);
- return TRUE;
-}
-
-void
-glade_gtk_window_deep_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
-{
- GtkWindow *window = GTK_WINDOW (object);
-
- g_return_if_fail (GTK_IS_WINDOW (window));
-
- /* Chain her up first */
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->deep_post_create (adaptor, object, reason);
-
- g_signal_connect (object, "delete-event", G_CALLBACK (glade_gtk_widget_show_on_delete), NULL);
-}
-
static void
glade_gtk_window_read_accel_groups (GladeWidget *widget,
GladeXmlNode *node)
@@ -5617,8 +5594,8 @@ glade_gtk_message_dialog_image_determine_action (GtkMessageDialog *dialog,
g_warning ("Setting property to an object outside the project");
return MD_IMAGE_ACTION_INVALID;
}
-
- if (glade_widget_get_parent (*gimage) || GTK_IS_WINDOW (*image))
+
+ if (glade_widget_get_parent (*gimage) || GWA_IS_TOPLEVEL ((*gimage)->adaptor))
return MD_IMAGE_ACTION_INVALID;
return MD_IMAGE_ACTION_SET;
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index a2b61f5..5a09fc2 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -334,9 +334,10 @@ embedded in another object</_tooltip>
</property>
</packing-properties>
</glade-widget-class>
+
+ <glade-widget-class name="GtkEventBox" generic-name="eventbox" _title="Event Box"/>
- <glade-widget-class name="GtkWindow" generic-name="window" _title="Window" toplevel="True" default-width="440" default-height="250">
- <deep-post-create-function>glade_gtk_window_deep_post_create</deep-post-create-function>
+ <glade-widget-class name="GtkWindow" generic-name="window" parent="GtkEventBox" _title="Window" toplevel="True" default-width="440" default-height="250">
<read-widget-function>glade_gtk_window_read_widget</read-widget-function>
<write-widget-function>glade_gtk_window_write_widget</write-widget-function>
@@ -348,6 +349,11 @@ embedded in another object</_tooltip>
<value-type>GtkAccelGroup</value-type>
</parameter-spec>
</property>
+ <!-- Disable GtkEventBox properties -->
+ <property id="above-child" disabled="True" />
+ <property id="visible-window" disabled="True" />
+
+ <!-- GtkWindow properties -->
<property id="opacity" since="2.12" ignore="True"/>
<property id="startup-id" since="2.12"/>
<property id="deletable" since="2.10"/>
@@ -1546,8 +1552,6 @@ embedded in another object</_tooltip>
<glade-widget-class name="GtkDrawingArea" generic-name="drawingarea" _title="Drawing Area"/>
- <glade-widget-class name="GtkEventBox" generic-name="eventbox" _title="Event Box"/>
-
<glade-widget-class name="GtkExpander" generic-name="expander" _title="Expander">
<post-create-function>glade_gtk_expander_post_create</post-create-function>
<add-child-function>glade_gtk_expander_add_child</add-child-function>