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)
95 gl_debug (DEBUG_FILE, "START");
97 g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (dialog));
99 dialog->priv = g_new0 (glNewLabelDialogPrivate, 1);
101 gtk_container_set_border_width (GTK_CONTAINER (dialog), GL_HIG_PAD1);
103 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
104 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
105 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
106 GTK_STOCK_OK, GTK_RESPONSE_OK,
108 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
109 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
110 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
112 vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
114 label = gtk_label_new (_("<b>Media type</b>"));
115 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
116 frame = gtk_frame_new ("");
117 gtk_frame_set_label_widget (GTK_FRAME (frame), label);
118 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
119 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, GL_HIG_PAD1);
121 dialog->priv->media_select = gl_wdgt_media_select_new ();
122 gtk_container_add (GTK_CONTAINER (frame), dialog->priv->media_select);
124 label = gtk_label_new (_("<b>Label orientation</b>"));
125 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
126 frame = gtk_frame_new ("");
127 gtk_frame_set_label_widget (GTK_FRAME (frame), label);
128 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
129 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
131 dialog->priv->rotate_label = gl_rotate_label_button_new ();
132 gtk_container_add (GTK_CONTAINER (frame), dialog->priv->rotate_label);
134 /* Sync template name from media select with rotate widget. */
135 name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
136 gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
139 g_signal_connect (G_OBJECT (dialog->priv->media_select), "changed",
140 G_CALLBACK (template_changed_cb), dialog);
142 gl_debug (DEBUG_FILE, "END");
146 /*****************************************************************************/
147 /* Finalize Function. */
148 /*****************************************************************************/
150 gl_new_label_dialog_finalize (GObject *object)
152 glNewLabelDialog* dialog = GL_NEW_LABEL_DIALOG (object);;
154 gl_debug (DEBUG_FILE, "START");
156 g_return_if_fail (object != NULL);
157 g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (dialog));
158 g_return_if_fail (dialog->priv != NULL);
160 g_free (dialog->priv);
162 G_OBJECT_CLASS (gl_new_label_dialog_parent_class)->finalize (object);
164 gl_debug (DEBUG_FILE, "END");
169 /*****************************************************************************/
170 /* NEW object properties dialog. */
171 /*****************************************************************************/
173 gl_new_label_dialog_new (GtkWindow *win)
177 gl_debug (DEBUG_FILE, "");
179 dialog = GTK_WIDGET (g_object_new (GL_TYPE_NEW_LABEL_DIALOG, NULL));
181 gtk_window_set_transient_for (GTK_WINDOW (dialog), win);
187 /*---------------------------------------------------------------------------*/
188 /* PRIVATE. New template changed callback. */
189 /*---------------------------------------------------------------------------*/
191 template_changed_cb (glWdgtMediaSelect *select,
194 glNewLabelDialog *dialog = GL_NEW_LABEL_DIALOG (data);
197 gl_debug (DEBUG_FILE, "START");
199 name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (select));
201 gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
204 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
210 gl_debug (DEBUG_FILE, "END");
214 /*****************************************************************************/
215 /* Get template name. */
216 /*****************************************************************************/
218 gl_new_label_dialog_get_template_name (glNewLabelDialog *dialog)
222 name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
228 /*****************************************************************************/
229 /* Set template name. */
230 /*****************************************************************************/
232 gl_new_label_dialog_set_template_name (glNewLabelDialog *dialog,
235 gl_wdgt_media_select_set_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select), name);
239 /*****************************************************************************/
240 /* Get current filter parameters. */
241 /*****************************************************************************/
243 gl_new_label_dialog_get_filter_parameters (glNewLabelDialog *dialog,
244 gchar **page_size_id,
247 gl_wdgt_media_select_get_filter_parameters (
248 GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
249 page_size_id, category_id);
253 /*****************************************************************************/
254 /* Set current filter parameters. */
255 /*****************************************************************************/
257 gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *dialog,
258 const gchar *page_size_id,
259 const gchar *category_id)
261 gl_wdgt_media_select_set_filter_parameters (
262 GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
263 page_size_id, category_id);
267 /*****************************************************************************/
268 /* Get rotate state. */
269 /*****************************************************************************/
271 gl_new_label_dialog_get_rotate_state (glNewLabelDialog *dialog)
273 return gl_rotate_label_button_get_state (
274 GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label));
278 /*****************************************************************************/
279 /* Set rotate state. */
280 /*****************************************************************************/
282 gl_new_label_dialog_set_rotate_state (glNewLabelDialog *dialog,
285 gl_rotate_label_button_set_state (
286 GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label), state);
292 * Local Variables: -- emacs
294 * c-basic-offset: 8 -- emacs
295 * tab-width: 8 -- emacs
296 * indent-tabs-mode: nil -- emacs