]> git.sur5r.net Git - glabels/blob - src/new-label-dialog.c
Removed non-existent filenames from po/POTFILES.in
[glabels] / src / new-label-dialog.c
1 /*
2  *  new-label-dialog.c
3  *  Copyright (C) 2006-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 "new-label-dialog.h"
24
25 #include <glib/gi18n.h>
26 #include <gtk/gtk.h>
27
28 #include "hig.h"
29 #include "wdgt-media-select.h"
30 #include "rotate-label-button.h"
31
32 #include "debug.h"
33
34
35 /*===========================================*/
36 /* Private data types                        */
37 /*===========================================*/
38
39 struct _glNewLabelDialogPrivate {
40
41         GtkWidget  *media_select;
42         GtkWidget  *rotate_label;
43
44 };
45
46
47 /*===========================================*/
48 /* Private globals                           */
49 /*===========================================*/
50
51
52 /*===========================================*/
53 /* Local function prototypes                 */
54 /*===========================================*/
55
56 static void       gl_new_label_dialog_finalize        (GObject               *object);
57
58 static void       template_changed_cb                 (glWdgtMediaSelect     *select,
59                                                        gpointer               data);
60
61
62 /*****************************************************************************/
63 /* Boilerplate object stuff.                                                 */
64 /*****************************************************************************/
65 G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_DIALOG);
66
67
68 /*****************************************************************************/
69 /* Class Init Function.                                                      */
70 /*****************************************************************************/
71 static void
72 gl_new_label_dialog_class_init (glNewLabelDialogClass *class)
73 {
74         GObjectClass *object_class = G_OBJECT_CLASS (class);
75
76         gl_debug (DEBUG_FILE, "");
77         
78         gl_new_label_dialog_parent_class = g_type_class_peek_parent (class);
79
80         object_class->finalize = gl_new_label_dialog_finalize;          
81 }
82
83
84 /*****************************************************************************/
85 /* Object Instance Init Function.                                            */
86 /*****************************************************************************/
87 static void
88 gl_new_label_dialog_init (glNewLabelDialog *dialog)
89 {
90         GtkWidget    *label;
91         GtkWidget    *frame;
92         gchar        *name;
93
94         gl_debug (DEBUG_FILE, "START");
95
96         g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (dialog));
97
98         dialog->priv = g_new0 (glNewLabelDialogPrivate, 1);
99
100         gtk_container_set_border_width (GTK_CONTAINER (dialog), GL_HIG_PAD1);
101
102         gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
103         gtk_dialog_add_buttons (GTK_DIALOG (dialog),
104                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
105                                 GTK_STOCK_OK, GTK_RESPONSE_OK,
106                                 NULL);
107         gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
108         gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
109         gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
110
111
112         label = gtk_label_new (_("<b>Media type</b>"));
113         gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
114         frame = gtk_frame_new ("");
115         gtk_frame_set_label_widget (GTK_FRAME (frame), label);
116         gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
117         gtk_box_pack_start (GTK_BOX( GTK_DIALOG (dialog)->vbox), frame, FALSE, FALSE, GL_HIG_PAD1);
118
119         dialog->priv->media_select = gl_wdgt_media_select_new ();
120         gtk_container_add (GTK_CONTAINER (frame), dialog->priv->media_select);
121
122         label = gtk_label_new (_("<b>Label orientation</b>"));
123         gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
124         frame = gtk_frame_new ("");
125         gtk_frame_set_label_widget (GTK_FRAME (frame), label);
126         gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
127         gtk_box_pack_start (GTK_BOX( GTK_DIALOG (dialog)->vbox), frame, FALSE, FALSE, 0);
128
129         dialog->priv->rotate_label = gl_rotate_label_button_new ();
130         gtk_container_add (GTK_CONTAINER (frame), dialog->priv->rotate_label);
131
132         /* Sync template name from media select with rotate widget. */
133         name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
134         gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
135                                                   name);
136
137         g_signal_connect (G_OBJECT (dialog->priv->media_select), "changed",
138                           G_CALLBACK (template_changed_cb), dialog);
139
140         gl_debug (DEBUG_FILE, "END");
141 }
142
143
144 /*****************************************************************************/
145 /* Finalize Function.                                                        */
146 /*****************************************************************************/
147 static void 
148 gl_new_label_dialog_finalize (GObject *object)
149 {
150         glNewLabelDialog* dialog = GL_NEW_LABEL_DIALOG (object);;
151         
152         gl_debug (DEBUG_FILE, "START");
153
154         g_return_if_fail (object != NULL);
155         g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (dialog));
156         g_return_if_fail (dialog->priv != NULL);
157
158         g_free (dialog->priv);
159
160         G_OBJECT_CLASS (gl_new_label_dialog_parent_class)->finalize (object);
161
162         gl_debug (DEBUG_FILE, "END");
163
164 }
165
166
167 /*****************************************************************************/
168 /* NEW object properties dialog.                                             */
169 /*****************************************************************************/
170 GtkWidget *
171 gl_new_label_dialog_new (GtkWindow    *win)
172 {
173         GtkWidget *dialog;
174
175         gl_debug (DEBUG_FILE, "");
176
177         dialog = GTK_WIDGET (g_object_new (GL_TYPE_NEW_LABEL_DIALOG, NULL));
178
179         gtk_window_set_transient_for (GTK_WINDOW (dialog), win);
180
181         return dialog;
182 }
183
184
185 /*---------------------------------------------------------------------------*/
186 /* PRIVATE.  New template changed callback.                                  */
187 /*---------------------------------------------------------------------------*/
188 static void
189 template_changed_cb (glWdgtMediaSelect *select,
190                      gpointer           data)
191 {
192         glNewLabelDialog  *dialog = GL_NEW_LABEL_DIALOG (data);
193         gchar             *name;
194
195         gl_debug (DEBUG_FILE, "START");
196
197         name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (select));
198
199         gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
200                                                   name);
201
202         gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
203                                            GTK_RESPONSE_OK,
204                                            (name != NULL));
205
206         g_free (name);
207
208         gl_debug (DEBUG_FILE, "END");
209 }
210
211
212 /*****************************************************************************/
213 /* Get template name.                                                        */
214 /*****************************************************************************/
215 gchar *
216 gl_new_label_dialog_get_template_name (glNewLabelDialog *dialog)
217 {
218         gchar *name;
219
220         name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
221
222         return name;
223 }
224
225
226 /*****************************************************************************/
227 /* Set template name.                                                        */
228 /*****************************************************************************/
229 void
230 gl_new_label_dialog_set_template_name (glNewLabelDialog *dialog,
231                                        gchar            *name)
232 {
233         gl_wdgt_media_select_set_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select), name);
234 }
235
236
237 /*****************************************************************************/
238 /* Get current filter parameters.                                            */
239 /*****************************************************************************/
240 void
241 gl_new_label_dialog_get_filter_parameters (glNewLabelDialog *dialog,
242                                            gchar           **page_size_id,
243                                            gchar           **category_id)
244 {
245         gl_wdgt_media_select_get_filter_parameters (
246                 GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
247                 page_size_id, category_id);
248 }
249
250
251 /*****************************************************************************/
252 /* Set current filter parameters.                                            */
253 /*****************************************************************************/
254 void
255 gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *dialog,
256                                            const gchar      *page_size_id,
257                                            const gchar      *category_id)
258 {
259         gl_wdgt_media_select_set_filter_parameters (
260                 GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
261                 page_size_id, category_id);
262 }
263
264
265 /*****************************************************************************/
266 /* Get rotate state.                                                         */
267 /*****************************************************************************/
268 gboolean
269 gl_new_label_dialog_get_rotate_state (glNewLabelDialog *dialog)
270 {
271         return gl_rotate_label_button_get_state (
272                 GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label));
273 }
274
275
276 /*****************************************************************************/
277 /* Set rotate state.                                                         */
278 /*****************************************************************************/
279 void
280 gl_new_label_dialog_set_rotate_state (glNewLabelDialog *dialog,
281                                       gboolean          state)
282 {
283         gl_rotate_label_button_set_state (
284                 GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label), state);
285 }
286
287
288
289 /*
290  * Local Variables:       -- emacs
291  * mode: C                -- emacs
292  * c-basic-offset: 8      -- emacs
293  * tab-width: 8           -- emacs
294  * indent-tabs-mode: nil  -- emacs
295  * End:                   -- emacs
296  */