[file-roller] location bar: use the style of a primary toolbar



commit 3b5ae32e942ce4d1e5e0603b041143505fa12412
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Dec 23 16:47:09 2013 +0100

    location bar: use the style of a primary toolbar

 po/POTFILES.in        |    2 +
 src/Makefile.am       |    2 +
 src/fr-location-bar.c |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/fr-location-bar.h |   50 ++++++++++++++++++++++
 src/fr-window.c       |   17 ++++----
 5 files changed, 172 insertions(+), 8 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f49066b..bfe3f3b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -96,6 +96,8 @@ src/fr-init.c
 src/fr-init.h
 src/fr-list-model.c
 src/fr-list-model.h
+src/fr-location-bar.c
+src/fr-location-bar.h
 src/fr-new-archive-dialog.c
 src/fr-new-archive-dialog.h
 src/fr-process.c
diff --git a/src/Makefile.am b/src/Makefile.am
index b765976..4631967 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -134,6 +134,8 @@ COMMON_SOURCES =                    \
        fr-init.h                       \
        fr-list-model.c                 \
        fr-list-model.h                 \
+       fr-location-bar.c               \
+       fr-location-bar.h               \
        fr-new-archive-dialog.c         \
        fr-new-archive-dialog.h         \
        fr-process.c                    \
diff --git a/src/fr-location-bar.c b/src/fr-location-bar.c
new file mode 100644
index 0000000..83e26fd
--- /dev/null
+++ b/src/fr-location-bar.c
@@ -0,0 +1,109 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  File-Roller
+ *
+ *  Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include "fr-location-bar.h"
+
+
+struct _FrLocationBarPrivate {
+       int dummy;
+};
+
+
+G_DEFINE_TYPE (FrLocationBar, fr_location_bar, GTK_TYPE_BOX)
+
+
+static gboolean
+fr_location_bar_draw (GtkWidget    *widget,
+                     cairo_t      *cr)
+{
+       GtkStyleContext *context;
+       guint            border_width;
+
+       context = gtk_widget_get_style_context (widget);
+       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+       gtk_render_background (context,
+                              cr,
+                              border_width,
+                              border_width,
+                              gtk_widget_get_allocated_width (widget) - 2 * border_width,
+                              gtk_widget_get_allocated_height (widget) - 2 * border_width);
+       gtk_render_frame (context,
+                         cr,
+                         border_width,
+                         border_width,
+                         gtk_widget_get_allocated_width (widget) - 2 * border_width,
+                         gtk_widget_get_allocated_height (widget) - 2 * border_width);
+
+       GTK_WIDGET_CLASS (fr_location_bar_parent_class)->draw (widget, cr);
+
+       return FALSE;
+}
+
+
+static void
+fr_location_bar_class_init (FrLocationBarClass *klass)
+{
+       GtkWidgetClass *widget_class;
+
+       g_type_class_add_private (klass, sizeof (FrLocationBarPrivate));
+
+       widget_class = GTK_WIDGET_CLASS (klass);
+       widget_class->draw = fr_location_bar_draw;
+}
+
+
+static const char *css =
+".location-bar {\n"
+"      border-width: 0 0 1px 0;\n" /* remove the top border, already provided by the headerbar */
+"}";
+
+
+static void
+fr_location_bar_init (FrLocationBar *self)
+{
+       GtkStyleContext *style_context;
+       GtkCssProvider  *css_provider;
+
+       self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FR_TYPE_LOCATION_BAR, FrLocationBarPrivate);
+       self->priv->dummy = 0;
+
+       gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL);
+       gtk_box_set_spacing (GTK_BOX (self), 6);
+
+       style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
+       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_TOOLBAR);
+       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+       gtk_style_context_add_class (style_context, "location-bar");
+
+       css_provider = gtk_css_provider_new ();
+       gtk_css_provider_load_from_data (css_provider, css, -1, NULL);
+       gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+                                                  GTK_STYLE_PROVIDER (css_provider),
+                                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+}
+
+
+GtkWidget *
+fr_location_bar_new (void)
+{
+       return (GtkWidget *) g_object_new (FR_TYPE_LOCATION_BAR, NULL);
+}
diff --git a/src/fr-location-bar.h b/src/fr-location-bar.h
new file mode 100644
index 0000000..09c3f3a
--- /dev/null
+++ b/src/fr-location-bar.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  File-Roller
+ *
+ *  Copyright (C) 2013 The Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FR_LOCATION_BAR_H
+#define FR_LOCATION_BAR_H
+
+#include <gtk/gtk.h>
+
+#define FR_TYPE_LOCATION_BAR            (fr_location_bar_get_type ())
+#define FR_LOCATION_BAR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_LOCATION_BAR, 
FrLocationBar))
+#define FR_LOCATION_BAR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_LOCATION_BAR, 
FrLocationBarClass))
+#define FR_IS_LOCATION_BAR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_LOCATION_BAR))
+#define FR_IS_LOCATION_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_LOCATION_BAR))
+#define FR_LOCATION_BAR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), FR_TYPE_LOCATION_BAR, 
FrLocationBarClass))
+
+typedef struct _FrLocationBar FrLocationBar;
+typedef struct _FrLocationBarClass FrLocationBarClass;
+typedef struct _FrLocationBarPrivate FrLocationBarPrivate;
+
+struct _FrLocationBar {
+       GtkBox parent_instance;
+       FrLocationBarPrivate *priv;
+};
+
+struct _FrLocationBarClass {
+       GtkBoxClass parent_class;
+};
+
+GType          fr_location_bar_get_type        (void);
+GtkWidget *    fr_location_bar_new             (void);
+
+#endif /* FR_LOCATION_BAR_H */
diff --git a/src/fr-window.c b/src/fr-window.c
index 46a00f7..89f73b0 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -41,6 +41,7 @@
 #include "eggtreemultidnd.h"
 #include "fr-marshal.h"
 #include "fr-list-model.h"
+#include "fr-location-bar.h"
 #include "fr-archive.h"
 #include "fr-command.h"
 #include "fr-error.h"
@@ -5293,6 +5294,7 @@ fr_window_construct (FrWindow *window)
        GtkWidget          *list_scrolled_window;
        gboolean            rtl;
        GtkWidget          *navigation_commands;
+       GtkWidget          *location_bar_content;
        GtkWidget          *location_box;
        GtkWidget          *filter_box;
        GtkWidget          *tree_scrolled_window;
@@ -5654,10 +5656,11 @@ fr_window_construct (FrWindow *window)
 
        /* location bar */
 
-       window->priv->location_bar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-       gtk_widget_set_margin_top (window->priv->location_bar, 5);
-       gtk_widget_set_margin_bottom (window->priv->location_bar, 5);
-       gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar), 
GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+       window->priv->location_bar = fr_location_bar_new ();
+
+       location_bar_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+       gtk_container_set_border_width (GTK_CONTAINER (location_bar_content), 4);
+       gtk_box_pack_start (GTK_BOX (window->priv->location_bar), location_bar_content, TRUE, TRUE, 0);
 
        rtl = gtk_widget_get_direction (window->priv->headerbar) == GTK_TEXT_DIR_RTL;
        navigation_commands = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -5676,10 +5679,9 @@ fr_window_construct (FrWindow *window)
                            FALSE,
                            FALSE,
                            0);
-       /*gtk_style_context_add_class (gtk_widget_get_style_context (navigation_commands), 
GTK_STYLE_CLASS_LINKED);*/
        gtk_widget_show_all (navigation_commands);
        gtk_widget_set_margin_right (navigation_commands, 12);
-       gtk_box_pack_start (GTK_BOX (window->priv->location_bar), navigation_commands, FALSE, FALSE, 5);
+       gtk_box_pack_start (GTK_BOX (location_bar_content), navigation_commands, FALSE, FALSE, 5);
 
        /* current location */
 
@@ -5689,7 +5691,6 @@ fr_window_construct (FrWindow *window)
        gtk_box_pack_start (GTK_BOX (location_box), window->priv->location_label, FALSE, FALSE, 5);
 
        window->priv->location_entry = gtk_entry_new ();
-       gtk_entry_set_has_frame (GTK_ENTRY (window->priv->location_entry), FALSE);
        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->location_entry),
                                           GTK_ENTRY_ICON_PRIMARY,
                                           "folder-symbolic");
@@ -5698,7 +5699,7 @@ fr_window_construct (FrWindow *window)
                          G_CALLBACK (location_entry_key_press_event_cb),
                          window);
        gtk_box_pack_start (GTK_BOX (location_box), window->priv->location_entry, TRUE, TRUE, 5);
-       gtk_box_pack_start (GTK_BOX (window->priv->location_bar), location_box, TRUE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX (location_bar_content), location_box, TRUE, TRUE, 0);
 
        gtk_widget_show_all (window->priv->location_bar);
        fr_window_attach (FR_WINDOW (window), window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR);


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