]> git.sur5r.net Git - glabels/blob - src/ui-sidebar.c
Imported Upstream version 3.0.0
[glabels] / src / ui-sidebar.c
1 /*
2  *  ui-sidebar.c
3  *  Copyright (C) 2003-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
7  *  gLabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  gLabels is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22
23 #include "ui-sidebar.h"
24
25 #include <glib/gi18n.h>
26
27 #include "ui-util.h"
28 #include "object-editor.h"
29
30 #include "debug.h"
31
32
33 /*===========================================================================*/
34 /* Private macros and constants.                                             */
35 /*===========================================================================*/
36
37 #define DEFAULT_SIDEBAR_WIDTH 340
38
39
40 /*===========================================================================*/
41 /* Private data types                                                        */
42 /*===========================================================================*/
43
44 struct _glUISidebarPrivate {
45
46         GtkWidget           *editor;
47 };
48
49 /*===========================================================================*/
50 /* Private globals                                                           */
51 /*===========================================================================*/
52
53
54 /*===========================================================================*/
55 /* Local function prototypes                                                 */
56 /*===========================================================================*/
57
58 static void     gl_ui_sidebar_finalize      (GObject              *object);
59
60 static void     gl_ui_sidebar_construct     (glUISidebar          *sidebar);
61
62
63 /****************************************************************************/
64 /* Boilerplate Object stuff.                                                */
65 /****************************************************************************/
66 G_DEFINE_TYPE (glUISidebar, gl_ui_sidebar, GTK_TYPE_VBOX)
67
68
69 static void
70 gl_ui_sidebar_class_init (glUISidebarClass *class)
71 {
72         GObjectClass   *object_class     = G_OBJECT_CLASS (class);
73
74         gl_debug (DEBUG_UI, "START");
75
76         gl_ui_sidebar_parent_class = g_type_class_peek_parent (class);
77
78         object_class->finalize = gl_ui_sidebar_finalize;
79
80         gl_debug (DEBUG_UI, "END");
81 }
82
83
84 static void
85 gl_ui_sidebar_init (glUISidebar *sidebar)
86 {
87         gl_debug (DEBUG_UI, "START");
88
89         sidebar->priv = g_new0 (glUISidebarPrivate, 1);
90
91         gl_debug (DEBUG_UI, "END");
92 }
93
94
95 static void
96 gl_ui_sidebar_finalize (GObject *object)
97 {
98         glUISidebar *sidebar = GL_UI_SIDEBAR (object);
99
100         gl_debug (DEBUG_UI, "START");
101
102         g_return_if_fail (object != NULL);
103         g_return_if_fail (GL_IS_UI_SIDEBAR (object));
104
105         g_free (sidebar->priv);
106
107         G_OBJECT_CLASS (gl_ui_sidebar_parent_class)->finalize (object);
108
109         gl_debug (DEBUG_UI, "END");
110 }
111
112
113 /****************************************************************************/
114 /* Create a NEW sidebar.                                                    */
115 /****************************************************************************/
116 GtkWidget *
117 gl_ui_sidebar_new (void)
118 {
119         glUISidebar *sidebar;
120
121         gl_debug (DEBUG_UI, "START");
122
123         sidebar = g_object_new (gl_ui_sidebar_get_type (), NULL);
124
125         gl_ui_sidebar_construct (sidebar);
126
127         gl_debug (DEBUG_UI, "END");
128
129         return GTK_WIDGET(sidebar);
130 }
131
132
133 /******************************************************************************/
134 /* Initialize property toolbar.                                               */
135 /******************************************************************************/
136 static void
137 gl_ui_sidebar_construct (glUISidebar       *sidebar)
138 {
139         gl_debug (DEBUG_UI, "START");
140
141         sidebar->priv->editor = gl_object_editor_new ();
142         gtk_widget_show (sidebar->priv->editor);
143
144         gtk_box_pack_start (GTK_BOX (sidebar), sidebar->priv->editor, FALSE, FALSE, 0);
145         gtk_widget_set_vexpand (GTK_WIDGET (sidebar->priv->editor), FALSE);
146         gtk_widget_set_hexpand (GTK_WIDGET (sidebar->priv->editor), FALSE);
147
148         gl_debug (DEBUG_UI, "END");
149 }
150
151
152 /****************************************************************************/
153 /* Set label associated with sidebar.                                       */
154 /****************************************************************************/
155 void
156 gl_ui_sidebar_set_label (glUISidebar *sidebar,
157                          glLabel     *label)
158 {
159         gl_debug (DEBUG_UI, "START");
160
161         g_return_if_fail (label && GL_IS_LABEL (label));
162
163         gl_object_editor_set_label (GL_OBJECT_EDITOR (sidebar->priv->editor), label);
164
165         gl_debug (DEBUG_UI, "END");
166 }
167
168
169
170 /*
171  * Local Variables:       -- emacs
172  * mode: C                -- emacs
173  * c-basic-offset: 8      -- emacs
174  * tab-width: 8           -- emacs
175  * indent-tabs-mode: nil  -- emacs
176  * End:                   -- emacs
177  */