1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 
3 /*
4  *  GThumb
5  *
6  *  Copyright (C) 2013 The Free Software Foundation, Inc.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <config.h>
23 #include <gtk/gtk.h>
24 #include "gth-location-bar.h"
25 #include "gth-location-chooser.h"
26 
27 
28 #define LOCATION_BAR_MARGIN 3
29 
30 
31 struct _GthLocationBarPrivate {
32 	GtkWidget *location_chooser;
33 	GtkWidget *action_area;
34 };
35 
36 
G_DEFINE_TYPE_WITH_CODE(GthLocationBar,gth_location_bar,GTK_TYPE_BOX,G_ADD_PRIVATE (GthLocationBar))37 G_DEFINE_TYPE_WITH_CODE (GthLocationBar,
38 			 gth_location_bar,
39 			 GTK_TYPE_BOX,
40 			 G_ADD_PRIVATE (GthLocationBar))
41 
42 
43 static void
44 gth_location_bar_class_init (GthLocationBarClass *klass)
45 {
46 	/* void */
47 }
48 
49 
50 static void
gth_location_bar_init(GthLocationBar * self)51 gth_location_bar_init (GthLocationBar *self)
52 {
53 	GtkWidget *box;
54 
55 	gtk_widget_set_can_focus (GTK_WIDGET (self), FALSE);
56 
57 	self->priv = gth_location_bar_get_instance_private (self);
58 
59 	gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL);
60 	gtk_widget_set_margin_top (GTK_WIDGET (self), LOCATION_BAR_MARGIN);
61 	gtk_widget_set_margin_bottom (GTK_WIDGET (self), LOCATION_BAR_MARGIN);
62 	gtk_widget_set_margin_end (GTK_WIDGET (self), LOCATION_BAR_MARGIN);
63 	gtk_widget_set_margin_start (GTK_WIDGET (self), LOCATION_BAR_MARGIN);
64 
65 	/* location chooser */
66 
67 	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
68 	gtk_widget_show (box);
69 	self->priv->location_chooser = g_object_new (GTH_TYPE_LOCATION_CHOOSER,
70 						     "show-entry-points", FALSE,
71 						     "show-other", FALSE,
72 						     "relief", GTK_RELIEF_NONE,
73 						     NULL);
74 	gtk_widget_show (self->priv->location_chooser);
75 	gtk_box_pack_start (GTK_BOX (box), self->priv->location_chooser, FALSE, FALSE, 0);
76 	gtk_box_pack_start (GTK_BOX (self), box, TRUE, TRUE, 0);
77 
78 	/* action area */
79 
80 	self->priv->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
81 	gtk_widget_show (self->priv->action_area);
82 	gtk_box_pack_end (GTK_BOX (self), self->priv->action_area, FALSE, FALSE, 0);
83 }
84 
85 
86 GtkWidget *
gth_location_bar_new(void)87 gth_location_bar_new (void)
88 {
89 	return g_object_new (GTH_TYPE_LOCATION_BAR, NULL);
90 }
91 
92 
93 GtkWidget *
gth_location_bar_get_chooser(GthLocationBar * self)94 gth_location_bar_get_chooser (GthLocationBar *self)
95 {
96 	return self->priv->location_chooser;
97 }
98 
99 
100 GtkWidget *
gth_location_bar_get_action_area(GthLocationBar * self)101 gth_location_bar_get_action_area (GthLocationBar *self)
102 {
103 	return self->priv->action_area;
104 }
105