[gnome-builder] omnibar: fix signal emission warning



commit 0a6722dbfe814830b832794a147fbdaa4610c96b
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jul 7 16:42:13 2021 -0700

    omnibar: fix signal emission warning
    
    Fixes the following warning:
    
    sys:1: Warning: invalid (NULL) pointer instance
    sys:1: Warning: g_signal_emit_by_name: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
    
    The issue was due to the eventbox requesting motion signals and the button
    which ended up inside it also grabbing events for the button. I mean, I'd
    expect this to actually work, but easy enough to work around it.

 src/libide/gui/ide-omni-bar.c  |  8 ++--
 src/libide/gui/ide-omni-bar.h  |  2 +-
 src/libide/gui/ide-omni-bar.ui | 83 ++++++++++++++++++++++--------------------
 3 files changed, 50 insertions(+), 43 deletions(-)
---
diff --git a/src/libide/gui/ide-omni-bar.c b/src/libide/gui/ide-omni-bar.c
index d515a8f6d..5525e8d32 100644
--- a/src/libide/gui/ide-omni-bar.c
+++ b/src/libide/gui/ide-omni-bar.c
@@ -34,12 +34,13 @@
 
 struct _IdeOmniBar
 {
-  GtkEventBox           parent_instance;
+  GtkBin                parent_instance;
 
   PeasExtensionSet     *addins;
   GtkGesture           *gesture;
   GtkEventController   *motion;
 
+  GtkEventBox          *entry_event_box;
   GtkStack             *top_stack;
   GtkPopover           *popover;
   DzlEntryBox          *entry_box;
@@ -65,7 +66,7 @@ DZL_DEFINE_ACTION_GROUP (IdeOmniBar, ide_omni_bar, {
   { "move-previous", ide_omni_bar_move_previous },
 })
 
-G_DEFINE_TYPE_WITH_CODE (IdeOmniBar, ide_omni_bar, GTK_TYPE_EVENT_BOX,
+G_DEFINE_TYPE_WITH_CODE (IdeOmniBar, ide_omni_bar, GTK_TYPE_BIN,
                          G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, ide_omni_bar_init_action_group)
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
 
@@ -446,6 +447,7 @@ ide_omni_bar_class_init (IdeOmniBarClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/libide-gui/ui/ide-omni-bar.ui");
   gtk_widget_class_set_css_name (widget_class, "omnibar");
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, entry_box);
+  gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, entry_event_box);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, inner_box);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, notification_stack);
   gtk_widget_class_bind_template_child (widget_class, IdeOmniBar, notifications_list_box);
@@ -490,7 +492,7 @@ ide_omni_bar_init (IdeOmniBar *self)
                             G_CALLBACK (ide_omni_bar_motion_leave_cb),
                             self);
 
-  self->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self));
+  self->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self->entry_event_box));
   gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->gesture), FALSE);
   gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (self->gesture), TRUE);
   gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->gesture), GDK_BUTTON_PRIMARY);
diff --git a/src/libide/gui/ide-omni-bar.h b/src/libide/gui/ide-omni-bar.h
index ef4a9e484..95bd0dedd 100644
--- a/src/libide/gui/ide-omni-bar.h
+++ b/src/libide/gui/ide-omni-bar.h
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
 #define IDE_TYPE_OMNI_BAR (ide_omni_bar_get_type())
 
 IDE_AVAILABLE_IN_3_32
-G_DECLARE_FINAL_TYPE (IdeOmniBar, ide_omni_bar, IDE, OMNI_BAR, GtkEventBox)
+G_DECLARE_FINAL_TYPE (IdeOmniBar, ide_omni_bar, IDE, OMNI_BAR, GtkBin)
 
 IDE_AVAILABLE_IN_3_32
 GtkWidget *ide_omni_bar_new                 (void);
diff --git a/src/libide/gui/ide-omni-bar.ui b/src/libide/gui/ide-omni-bar.ui
index 53591ff36..1bcad100e 100644
--- a/src/libide/gui/ide-omni-bar.ui
+++ b/src/libide/gui/ide-omni-bar.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="IdeOmniBar" parent="GtkEventBox">
+  <template class="IdeOmniBar" parent="GtkBin">
     <child>
       <object class="DzlPriorityBox" id="outer_box">
         <property name="hexpand">true</property>
@@ -27,66 +27,71 @@
                   </object>
                 </child>
                 <child>
-                  <object class="DzlPriorityBox" id="inner_box">
-                    <property name="margin-top">1</property>
-                    <property name="spacing">3</property>
+                  <object class="GtkEventBox" id="entry_event_box">
                     <property name="visible">true</property>
                     <child>
-                      <object class="GtkBox">
-                        <property name="hexpand">false</property>
-                        <property name="vexpand">false</property>
-                        <property name="valign">center</property>
-                        <property name="orientation">vertical</property>
+                      <object class="DzlPriorityBox" id="inner_box">
+                        <property name="margin-top">1</property>
+                        <property name="spacing">3</property>
                         <property name="visible">true</property>
-                        <style>
-                          <class name="pan"/>>
-                        </style>
                         <child>
-                          <object class="GtkButton">
-                            <property name="action-name">omnibar.move-previous</property>
+                          <object class="GtkBox">
+                            <property name="hexpand">false</property>
+                            <property name="vexpand">false</property>
+                            <property name="valign">center</property>
+                            <property name="orientation">vertical</property>
                             <property name="visible">true</property>
+                            <style>
+                              <class name="pan"/>>
+                            </style>
                             <child>
-                              <object class="GtkImage">
-                                <property name="icon-name">pan-up-symbolic</property>
-                                <property name="pixel-size">12</property>
+                              <object class="GtkButton">
+                                <property name="action-name">omnibar.move-previous</property>
                                 <property name="visible">true</property>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="icon-name">pan-up-symbolic</property>
+                                    <property name="pixel-size">12</property>
+                                    <property name="visible">true</property>
+                                  </object>
+                                </child>
                               </object>
                             </child>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="action-name">omnibar.move-next</property>
-                            <property name="visible">true</property>
                             <child>
-                              <object class="GtkImage">
-                                <property name="icon-name">pan-down-symbolic</property>
-                                <property name="pixel-size">12</property>
+                              <object class="GtkButton">
+                                <property name="action-name">omnibar.move-next</property>
                                 <property name="visible">true</property>
+                                <child>
+                                  <object class="GtkImage">
+                                    <property name="icon-name">pan-down-symbolic</property>
+                                    <property name="pixel-size">12</property>
+                                    <property name="visible">true</property>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>
                         </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkStack" id="top_stack">
-                        <property name="margin-start">3</property>
-                        <property name="margin-end">3</property>
-                        <property name="hexpand">true</property>
-                        <property name="visible">true</property>
                         <child>
-                          <object class="IdeNotificationStack" id="notification_stack">
+                          <object class="GtkStack" id="top_stack">
+                            <property name="margin-start">3</property>
+                            <property name="margin-end">3</property>
+                            <property name="hexpand">true</property>
                             <property name="visible">true</property>
+                            <child>
+                              <object class="IdeNotificationStack" id="notification_stack">
+                                <property name="visible">true</property>
+                              </object>
+                              <packing>
+                                <property name="name">notifications</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
-                            <property name="name">notifications</property>
+                            <property name="expand">true</property>
                           </packing>
                         </child>
                       </object>
-                      <packing>
-                        <property name="expand">true</property>
-                      </packing>
                     </child>
                   </object>
                 </child>


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