3 * Copyright (C) 2006-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
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.
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.
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/>.
23 #include "new-label-dialog.h"
25 #include <glib/gi18n.h>
29 #include "wdgt-media-select.h"
30 #include "rotate-label-button.h"
35 /*===========================================*/
36 /* Private data types */
37 /*===========================================*/
39 struct _glNewLabelDialogPrivate {
41 GtkWidget *media_select;
42 GtkWidget *rotate_label;
47 /*===========================================*/
49 /*===========================================*/
52 /*===========================================*/
53 /* Local function prototypes */
54 /*===========================================*/
56 static void gl_new_label_dialog_finalize (GObject *object);
58 static void template_changed_cb (glWdgtMediaSelect *select,
62 /*****************************************************************************/
63 /* Boilerplate object stuff. */
64 /*****************************************************************************/
65 G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_DIALOG);
68 /*****************************************************************************/
69 /* Class Init Function. */
70 /*****************************************************************************/
72 gl_new_label_dialog_class_init (glNewLabelDialogClass *class)
74 GObjectClass *object_class = G_OBJECT_CLASS (class);
76 gl_debug (DEBUG_FILE, "");
78 gl_new_label_dialog_parent_class = g_type_class_peek_parent (class);
80 object_class->finalize = gl_new_label_dialog_finalize;
84 /*****************************************************************************/
85 /* Object Instance Init Function. */
86 /*****************************************************************************/
88 gl_new_label_dialog_init (glNewLabelDialog *dialog)
94 gl_debug (DEBUG_FILE, "START");
96 g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (dialog));
98 dialog->priv = g_new0 (glNewLabelDialogPrivate, 1);
100 gtk_container_set_border_width (GTK_CONTAINER (dialog), GL_HIG_PAD1);
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,
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);
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);
119 dialog->priv->media_select = gl_wdgt_media_select_new ();
120 gtk_container_add (GTK_CONTAINER (frame), dialog->priv->media_select);
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);
129 dialog->priv->rotate_label = gl_rotate_label_button_new ();
130 gtk_container_add (GTK_CONTAINER (frame), dialog->priv->rotate_label);
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),
137 g_signal_connect (G_OBJECT (dialog->priv->media_select), "changed",
138 G_CALLBACK (template_changed_cb), dialog);
140 gl_debug (DEBUG_FILE, "END");
144 /*****************************************************************************/
145 /* Finalize Function. */
146 /*****************************************************************************/
148 gl_new_label_dialog_finalize (GObject *object)
150 glNewLabelDialog* dialog = GL_NEW_LABEL_DIALOG (object);;
152 gl_debug (DEBUG_FILE, "START");
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);
158 g_free (dialog->priv);
160 G_OBJECT_CLASS (gl_new_label_dialog_parent_class)->finalize (object);
162 gl_debug (DEBUG_FILE, "END");
167 /*****************************************************************************/
168 /* NEW object properties dialog. */
169 /*****************************************************************************/
171 gl_new_label_dialog_new (GtkWindow *win)
175 gl_debug (DEBUG_FILE, "");
177 dialog = GTK_WIDGET (g_object_new (GL_TYPE_NEW_LABEL_DIALOG, NULL));
179 gtk_window_set_transient_for (GTK_WINDOW (dialog), win);
185 /*---------------------------------------------------------------------------*/
186 /* PRIVATE. New template changed callback. */
187 /*---------------------------------------------------------------------------*/
189 template_changed_cb (glWdgtMediaSelect *select,
192 glNewLabelDialog *dialog = GL_NEW_LABEL_DIALOG (data);
195 gl_debug (DEBUG_FILE, "START");
197 name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (select));
199 gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
202 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
208 gl_debug (DEBUG_FILE, "END");
212 /*****************************************************************************/
213 /* Get template name. */
214 /*****************************************************************************/
216 gl_new_label_dialog_get_template_name (glNewLabelDialog *dialog)
220 name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
226 /*****************************************************************************/
227 /* Set template name. */
228 /*****************************************************************************/
230 gl_new_label_dialog_set_template_name (glNewLabelDialog *dialog,
233 gl_wdgt_media_select_set_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select), name);
237 /*****************************************************************************/
238 /* Get current filter parameters. */
239 /*****************************************************************************/
241 gl_new_label_dialog_get_filter_parameters (glNewLabelDialog *dialog,
242 gchar **page_size_id,
245 gl_wdgt_media_select_get_filter_parameters (
246 GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
247 page_size_id, category_id);
251 /*****************************************************************************/
252 /* Set current filter parameters. */
253 /*****************************************************************************/
255 gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *dialog,
256 const gchar *page_size_id,
257 const gchar *category_id)
259 gl_wdgt_media_select_set_filter_parameters (
260 GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
261 page_size_id, category_id);
265 /*****************************************************************************/
266 /* Get rotate state. */
267 /*****************************************************************************/
269 gl_new_label_dialog_get_rotate_state (glNewLabelDialog *dialog)
271 return gl_rotate_label_button_get_state (
272 GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label));
276 /*****************************************************************************/
277 /* Set rotate state. */
278 /*****************************************************************************/
280 gl_new_label_dialog_set_rotate_state (glNewLabelDialog *dialog,
283 gl_rotate_label_button_set_state (
284 GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label), state);
290 * Local Variables: -- emacs
292 * c-basic-offset: 8 -- emacs
293 * tab-width: 8 -- emacs
294 * indent-tabs-mode: nil -- emacs