[glade/searchbar] Support GtkSearchBar



commit c3ed37c02fbdef6684bd7a0893098d2ff2157409
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 13 22:11:32 2014 -0400

    Support GtkSearchBar
    
    This widget has been around since 3.10, high time that glade
    starts supporting it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738493

 plugins/gtk+/Makefile.am                          |    1 +
 plugins/gtk+/glade-gtk-searchbar.c                |  109 +++++++++++++++++++++
 plugins/gtk+/gtk+.xml.in                          |   13 +++
 plugins/gtk+/icons/16x16/Makefile.am              |    1 +
 plugins/gtk+/icons/16x16/widget-gtk-searchbar.png |  Bin 0 -> 257 bytes
 plugins/gtk+/icons/22x22/Makefile.am              |    1 +
 plugins/gtk+/icons/22x22/widget-gtk-searchbar.png |  Bin 0 -> 229 bytes
 7 files changed, 125 insertions(+), 0 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 6f17c31..99b1978 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -101,6 +101,7 @@ libgladegtk_la_SOURCES =            \
        glade-gtk-scale.c               \
        glade-gtk-scrollbar.c           \
        glade-gtk-scrolled-window.c     \
+       glade-gtk-searchbar.c           \
        glade-gtk-size-group.c          \
        glade-gtk-spin-button.c         \
        glade-gtk-switch.c              \
diff --git a/plugins/gtk+/glade-gtk-searchbar.c b/plugins/gtk+/glade-gtk-searchbar.c
new file mode 100644
index 0000000..da955fc
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-searchbar.c
@@ -0,0 +1,109 @@
+/*
+ * glade-gtk-searchbar.c
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Author:
+ *   Matthias Clasen <mclasen redhat com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public 
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+#include "glade-gtk.h"
+
+void
+glade_gtk_search_bar_post_create (GladeWidgetAdaptor *adaptor,
+                              GObject *widget,
+                              GladeCreateReason reason)
+{
+  if (reason == GLADE_CREATE_USER)
+    {
+      GtkWidget *child;
+      child = glade_placeholder_new ();
+      gtk_container_add (GTK_CONTAINER (widget), child);
+      g_object_set_data (G_OBJECT (widget), "child", child);
+    }
+}
+
+gboolean
+glade_gtk_search_bar_add_verify (GladeWidgetAdaptor *adaptor,
+                              GtkWidget          *container,
+                              GtkWidget          *child,
+                              gboolean            user_feedback)
+{
+  GObject *current;
+  current = g_object_get_data (G_OBJECT (container), "child");
+  if (!GLADE_IS_PLACEHOLDER (current))
+    {
+      if (user_feedback)
+        {
+          glade_util_ui_message (glade_app_get_window (),
+                                 GLADE_UI_INFO, NULL,
+                                 _("Search bar is already full"));
+
+        }
+
+      return FALSE;
+    }
+
+  return TRUE; 
+}
+
+void
+glade_gtk_search_bar_add_child (GladeWidgetAdaptor *adaptor,
+                                GObject            *object,
+                                GObject            *child)
+{
+  GObject *current;
+  current = g_object_get_data (G_OBJECT (object), "child");
+  gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (current))), GTK_WIDGET (current));
+  gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+  g_object_set_data (G_OBJECT (object), "child", child);
+}
+
+void
+glade_gtk_search_bar_remove_child (GladeWidgetAdaptor *adaptor,
+                                GObject            *object,
+                                GObject            *child)
+{
+  GObject *current;
+  GtkWidget *new_child;
+
+  current = g_object_get_data (G_OBJECT (object), "child");
+  if (current == child)
+    {
+      gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (child))), GTK_WIDGET (child));
+      new_child = glade_placeholder_new ();
+      gtk_container_add (GTK_CONTAINER (object), new_child);
+      g_object_set_data (G_OBJECT (object), "child", new_child);
+    }
+}
+
+void
+glade_gtk_search_bar_replace_child (GladeWidgetAdaptor * adaptor,
+                                   GtkWidget * container,
+                                   GtkWidget * current, GtkWidget * new_widget)
+{
+  if (current == (GtkWidget *)g_object_get_data (G_OBJECT (container), "child"))
+    {
+      gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (current))), GTK_WIDGET 
(current));
+      gtk_container_add (GTK_CONTAINER (container), new_widget);
+      g_object_set_data (G_OBJECT (container), "child", new_widget);
+    }
+}
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index bf5b006..d1059ad 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1595,6 +1595,18 @@
         </properties>
       </glade-widget-class>
       
+      <glade-widget-class name="GtkSearchBar" generic-name="searchbar" _title="Search Bar" since="3.10">
+        <post-create-function>glade_gtk_search_bar_post_create</post-create-function>
+        <add-child-verify-function>glade_gtk_search_bar_add_verify</add-child-verify-function>
+        <add-child-function>glade_gtk_search_bar_add_child</add-child-function>
+        <remove-child-function>glade_gtk_search_bar_remove_child</remove-child-function>
+        <replace-child-function>glade_gtk_search_bar_replace_child</replace-child-function>
+        <properties>
+          <property id="search-mode-enabled" save="False" default="True"/>
+        </properties>
+
+      </glade-widget-class>
+
       <glade-widget-class name="GtkButton" generic-name="button" _title="Button">
         <post-create-function>glade_gtk_button_post_create</post-create-function>
         <create-editable-function>glade_gtk_button_create_editable</create-editable-function>
@@ -5141,6 +5153,7 @@
       <glade-widget-class-ref name="GtkScrolledWindow"/>
       <glade-widget-class-ref name="GtkAlignment"/>
       <glade-widget-class-ref name="GtkRevealer" />
+      <glade-widget-class-ref name="GtkSearchBar" />
     </glade-widget-group>
     
     <glade-widget-group name="gtk-control-display" _title="Control and Display">
diff --git a/plugins/gtk+/icons/16x16/Makefile.am b/plugins/gtk+/icons/16x16/Makefile.am
index baaeba7..1ff862a 100644
--- a/plugins/gtk+/icons/16x16/Makefile.am
+++ b/plugins/gtk+/icons/16x16/Makefile.am
@@ -80,6 +80,7 @@ icons_DATA = \
        widget-gtk-placessidebar.png \
        widget-gtk-printdialog.png \
        widget-gtk-progressbar.png \
+       widget-gtk-searchbar.png \
        widget-gtk-levelbar.png \
        widget-gtk-radiobutton.png \
        widget-gtk-radiomenuitem.png \
diff --git a/plugins/gtk+/icons/16x16/widget-gtk-searchbar.png 
b/plugins/gtk+/icons/16x16/widget-gtk-searchbar.png
new file mode 100644
index 0000000..a3a91c2
Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-searchbar.png differ
diff --git a/plugins/gtk+/icons/22x22/Makefile.am b/plugins/gtk+/icons/22x22/Makefile.am
index ff45e33..e80866f 100644
--- a/plugins/gtk+/icons/22x22/Makefile.am
+++ b/plugins/gtk+/icons/22x22/Makefile.am
@@ -80,6 +80,7 @@ icons_DATA = \
        widget-gtk-placessidebar.png \
        widget-gtk-printdialog.png \
        widget-gtk-progressbar.png \
+       widget-gtk-searchbar.png \
        widget-gtk-levelbar.png \
        widget-gtk-radiobutton.png \
        widget-gtk-radiomenuitem.png \
diff --git a/plugins/gtk+/icons/22x22/widget-gtk-searchbar.png 
b/plugins/gtk+/icons/22x22/widget-gtk-searchbar.png
new file mode 100644
index 0000000..773cba2
Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-searchbar.png differ


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