summaryrefslogtreecommitdiff
path: root/gtk/gtksearchbar.c
diff options
context:
space:
mode:
authorWilliam Jon McCann <william.jon.mccann@gmail.com>2013-10-09 19:10:40 -0400
committerWilliam Jon McCann <william.jon.mccann@gmail.com>2013-10-10 16:06:49 -0400
commitf2d229e2ce62bee336c791119d0ebcba8d14cb05 (patch)
tree99dd9216db6237500f8688853b0b0984e8fa5744 /gtk/gtksearchbar.c
parentd5c36c62ed3a0763399fd9fc3bdcd3a9fce166c5 (diff)
downloadgtk+-f2d229e2ce62bee336c791119d0ebcba8d14cb05.tar.gz
search-bar: make independent of toolbar styling
Don't use a toolbar as an implementation detail of the search bar to make styling them differently a bit easier.
Diffstat (limited to 'gtk/gtksearchbar.c')
-rw-r--r--gtk/gtksearchbar.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c
index 417bc46ff8..b68b057717 100644
--- a/gtk/gtksearchbar.c
+++ b/gtk/gtksearchbar.c
@@ -30,8 +30,6 @@
#include "gtkentry.h"
#include "gtkentryprivate.h"
#include "gtkintl.h"
-#include "gtktoolbar.h"
-#include "gtktoolitem.h"
#include "gtkstylecontext.h"
#include "gtksearchbar.h"
@@ -71,7 +69,7 @@
typedef struct {
/* Template widgets */
GtkWidget *revealer;
- GtkWidget *toolbar;
+ GtkWidget *tool_box;
GtkWidget *box_center;
GtkWidget *close_button;
@@ -286,7 +284,7 @@ gtk_search_bar_add (GtkContainer *container,
/* When constructing the widget, we want the revealer to be added
* as the first child of the search bar, as an implementation detail.
* After that, the child added by the application should be added
- * to the toolbar's box_center.
+ * to box_center.
*/
if (priv->box_center == NULL)
{
@@ -364,6 +362,25 @@ gtk_search_bar_dispose (GObject *object)
G_OBJECT_CLASS (gtk_search_bar_parent_class)->dispose (object);
}
+static gboolean
+gtk_search_bar_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ gint width, height;
+ GtkStyleContext *context;
+
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_render_background (context, cr, 0, 0, width, height);
+ gtk_render_frame (context, cr, 0, 0, width, height);
+
+ GTK_WIDGET_CLASS (gtk_search_bar_parent_class)->draw (widget, cr);
+
+ return FALSE;
+}
+
static void
gtk_search_bar_class_init (GtkSearchBarClass *klass)
{
@@ -374,6 +391,7 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass)
object_class->dispose = gtk_search_bar_dispose;
object_class->set_property = gtk_search_bar_set_property;
object_class->get_property = gtk_search_bar_get_property;
+ widget_class->draw = gtk_search_bar_draw;
container_class->add = gtk_search_bar_add;
@@ -404,7 +422,7 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass)
g_object_class_install_properties (object_class, LAST_PROPERTY, widget_props);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/gtksearchbar.ui");
- gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, toolbar);
+ gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, tool_box);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, revealer);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, box_center);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkSearchBar, close_button);
@@ -414,10 +432,11 @@ static void
gtk_search_bar_init (GtkSearchBar *bar)
{
GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
+ GtkStyleContext *context;
gtk_widget_init_template (GTK_WIDGET (bar));
- gtk_widget_show_all (priv->toolbar);
+ gtk_widget_show_all (priv->tool_box);
g_signal_connect (priv->revealer, "notify::reveal-child",
G_CALLBACK (reveal_child_changed_cb), bar);
@@ -425,6 +444,11 @@ gtk_search_bar_init (GtkSearchBar *bar)
gtk_widget_set_no_show_all (priv->close_button, TRUE);
g_signal_connect (priv->close_button, "clicked",
G_CALLBACK (close_button_clicked_cb), bar);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (bar));
+ gtk_style_context_add_class (context, "search-bar");
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+
};
/**