[glade/wip/beniofel/popover] Popover: stop emission of some signals



commit c471c45ab957f1632dd986a4794c1de15d976845
Author: Ben Iofel <iofelben gmail com>
Date:   Tue Nov 3 21:33:28 2015 -0500

    Popover: stop emission of some signals

 plugins/gtk+/glade-gtk-popover.c |   55 ++++++++++++++++++++++++++++++++++++++
 plugins/gtk+/gtk+.xml.in         |    1 +
 2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-popover.c b/plugins/gtk+/glade-gtk-popover.c
index b60e6ff..54719c4 100644
--- a/plugins/gtk+/glade-gtk-popover.c
+++ b/plugins/gtk+/glade-gtk-popover.c
@@ -46,6 +46,61 @@ glade_gtk_popover_constructor (GType type,
   return ret_obj;
 }
 
+static void
+glade_gtk_stop_emission_POINTER (gpointer instance, gpointer dummy,
+                                 gpointer data)
+{
+  g_signal_stop_emission (instance, GPOINTER_TO_UINT (data), 0);
+}
+
+static void
+glade_gtk_popover_stop_offending_signals (GtkWidget * widget)
+{
+  static gpointer button_press = NULL,
+                  button_release,
+                  key_press;
+
+  if (button_press == NULL)
+    {
+      button_press = GUINT_TO_POINTER (g_signal_lookup ("button-press-event", GTK_TYPE_WIDGET));
+      button_release = GUINT_TO_POINTER (g_signal_lookup ("button-release-event", GTK_TYPE_WIDGET));
+      key_press = GUINT_TO_POINTER (g_signal_lookup ("key-press-event", GTK_TYPE_WIDGET));
+    }
+
+  g_signal_connect (widget, "button-press-event",
+                    G_CALLBACK (glade_gtk_stop_emission_POINTER), button_press);
+  g_signal_connect (widget, "button-release-event",
+                    G_CALLBACK (glade_gtk_stop_emission_POINTER), button_release);
+  g_signal_connect (widget, "key-press-event",
+                    G_CALLBACK (glade_gtk_stop_emission_POINTER), key_press);
+}
+
+/*
+static void
+hacky_stuff (GtkWidget *widget,
+              gpointer   userdata)
+{
+  g_return_if_fail (GTK_IS_POPOVER (widget));
+  GtkWidget *parent = gtk_widget_get_parent (widget);
+  gtk_popover_set_relative_to (GTK_POPOVER (widget), parent);
+}
+*/
+
+void
+glade_gtk_popover_post_create (GladeWidgetAdaptor *adaptor,
+                               GObject            *object,
+                               GladeCreateReason   reason)
+{
+  if (reason == GLADE_CREATE_USER)
+    {
+      gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
+    }
+
+  glade_gtk_popover_stop_offending_signals (GTK_WIDGET (object));
+  gtk_popover_set_modal (GTK_POPOVER (object), FALSE);
+  /* g_signal_connect (object, "map", G_CALLBACK (hacky_stuff), NULL); */
+}
+
 GladeEditable *
 glade_gtk_popover_create_editable (GladeWidgetAdaptor * adaptor,
                                    GladeEditorPageType  type)
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 0c23e3d..dee71d3 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -3360,6 +3360,7 @@
       
       <glade-widget-class name="GtkPopover" generic-name="popover" _title="Popover" toplevel="True" 
since="3.12">
         <constructor-function>glade_gtk_popover_constructor</constructor-function>
+        <post-create-function>glade_gtk_popover_post_create</post-create-function>
         <create-editable-function>glade_gtk_popover_create_editable</create-editable-function>
         <properties>
           <property id="visible" default="False"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]