summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-10-13 22:11:32 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-10-25 16:21:44 -0400
commit621ff59f06eeafc90cec75894c1b4ffab1a3effe (patch)
tree8576be385b11944a35b8f8dcacb37d54547acc7d
parent52a763b57a818cf2fc8c7d062b2102cbcd20116f (diff)
downloadglade-621ff59f06eeafc90cec75894c1b4ffab1a3effe.tar.gz
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
-rw-r--r--plugins/gtk+/Makefile.am1
-rw-r--r--plugins/gtk+/glade-gtk-searchbar.c109
-rw-r--r--plugins/gtk+/gtk+.xml.in13
-rw-r--r--plugins/gtk+/icons/16x16/Makefile.am1
-rw-r--r--plugins/gtk+/icons/16x16/widget-gtk-searchbar.pngbin0 -> 257 bytes
-rw-r--r--plugins/gtk+/icons/22x22/Makefile.am1
-rw-r--r--plugins/gtk+/icons/22x22/widget-gtk-searchbar.pngbin0 -> 229 bytes
7 files changed, 125 insertions, 0 deletions
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 6f17c31d..99b1978e 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 00000000..da955fcb
--- /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 c302d829..fe90fb6e 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1606,6 +1606,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>
@@ -5152,6 +5164,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 baaeba77..1ff862ae 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 00000000..a3a91c2e
--- /dev/null
+++ b/plugins/gtk+/icons/16x16/widget-gtk-searchbar.png
Binary files differ
diff --git a/plugins/gtk+/icons/22x22/Makefile.am b/plugins/gtk+/icons/22x22/Makefile.am
index ff45e33a..e80866fc 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 00000000..773cba26
--- /dev/null
+++ b/plugins/gtk+/icons/22x22/widget-gtk-searchbar.png
Binary files differ