Commit d2bedbab authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

GtkPopover: rework support code to fix bugs and warnings

Use a derived class with overrided methods for the runtime

Fix bug #793757 "Gtk-CRITICAL **: _gtk_window_add_popover: assertion '_gtk_widget_get_parent (popover) == NULL' failed"
parent 7eb1012b
......@@ -27,6 +27,68 @@
#include "glade-popover-editor.h"
#define GLADE_TYPE_GTK_POPOVER glade_gtk_popover_get_type ()
G_DECLARE_FINAL_TYPE (GladeGtkPopover, glade_gtk_popover, GLADE, GTK_POPOVER, GtkPopover)
struct _GladeGtkPopover
{
GtkPopover parent_instance;
};
G_DEFINE_TYPE (GladeGtkPopover, glade_gtk_popover, GTK_TYPE_POPOVER)
static void
glade_gtk_popover_init (GladeGtkPopover *popover)
{
gtk_popover_set_modal (GTK_POPOVER (popover), FALSE);
gtk_popover_set_relative_to (GTK_POPOVER (popover), NULL);
}
static void
glade_gtk_popover_map (GtkWidget *widget)
{
GtkWidgetClass *klass = g_type_class_peek_parent (glade_gtk_popover_parent_class);
klass->map (widget);
}
static void
glade_gtk_popover_unmap (GtkWidget *widget)
{
GtkWidgetClass *klass = g_type_class_peek_parent (glade_gtk_popover_parent_class);
klass->unmap (widget);
}
static gboolean
glade_gtk_popover_button_event (GtkWidget *widget, GdkEventButton *event)
{
return TRUE;
}
static gint
glade_gtk_popover_key_press_event (GtkWidget *popover, GdkEventKey *event)
{
if (event->keyval == GDK_KEY_Escape)
return TRUE;
return FALSE;
}
static void
glade_gtk_popover_class_init (GladeGtkPopoverClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
/* Ignore some events causing the popover to disappear from the workspace */
widget_class->key_press_event = glade_gtk_popover_key_press_event;
widget_class->button_press_event = glade_gtk_popover_button_event;
widget_class->button_release_event = glade_gtk_popover_button_event;
/* Make some warning go away */
widget_class->map = glade_gtk_popover_map;
widget_class->unmap = glade_gtk_popover_unmap;
}
GObject *
glade_gtk_popover_constructor (GType type,
guint n_construct_properties,
......@@ -56,25 +118,3 @@ glade_gtk_popover_create_editable (GladeWidgetAdaptor * adaptor,
return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type);
}
static gint
popover_key_press (GtkWidget *popover,
GdkEventKey *event,
gpointer user_data)
{
if (event->keyval == GDK_KEY_Escape)
return TRUE;
return FALSE;
}
void
glade_gtk_popover_post_create (GladeWidgetAdaptor * adaptor,
GObject *popover, GladeCreateReason reason)
{
/* Ignore some events causing the popover to disappear from the workspace
*/
g_signal_connect (popover, "key-press-event",
G_CALLBACK (popover_key_press), NULL);
GWA_GET_CLASS (GTK_TYPE_CONTAINER)->post_create (adaptor, popover, reason);
}
......@@ -3042,6 +3042,8 @@
<property id="menu-model" disabled="True"/>
<property id="popup" ignore="True"/>
<property id="align-widget" ignore="True"/>
<property id="popover" ignore="True" since="3.12"/>
<property id="use-popover" ignore="True" since="3.12"/>
</properties>
</glade-widget-class>
......@@ -3507,13 +3509,18 @@
</packing-properties>
</glade-widget-class>
<glade-widget-class name="GtkPopover" generic-name="popover" _title="Popover" toplevel="True" since="3.12">
<glade-widget-class name="GtkPopover"
get-type-function="glade_gtk_popover_get_type"
generic-name="popover"
_title="Popover"
toplevel="True"
since="3.12">
<constructor-function>glade_gtk_popover_constructor</constructor-function>
<create-editable-function>glade_gtk_popover_create_editable</create-editable-function>
<post-create-function>glade_gtk_popover_post_create</post-create-function>
<properties>
<property id="visible" default="False"/>
<property id="relative-to" ignore="True" custom-layout="True"/>
<property id="pointing-to" disabled="True"/>
<property id="constrain-to" ignore="True" custom-layout="True" since="3.20">
<displayable-values>
<!-- GtkPopoverConstraint enumeration value -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment