]> git.sur5r.net Git - glabels/commitdiff
Added FileProperties dialog.
authorJim Evins <evins@snaught.com>
Sat, 28 Jun 2003 14:25:49 +0000 (14:25 +0000)
committerJim Evins <evins@snaught.com>
Sat, 28 Jun 2003 14:25:49 +0000 (14:25 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@266 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/commands.c
glabels2/src/commands.h
glabels2/src/file.c
glabels2/src/file.h
glabels2/src/glabels-ui.xml
glabels2/src/ui.c
glabels2/src/xml-template.c

index 7812764c681350958986d096392a5d59578c955b..3d4bd9a8a5326a01031e68d0162b747e97cc909e 100644 (file)
@@ -55,6 +55,21 @@ gl_cmd_file_new (BonoboUIComponent *uic,
        gl_file_new (GTK_WINDOW(window));
 }
 
+/****************************************************************************/
+/* File->Properties command.                                                */
+/****************************************************************************/
+void 
+gl_cmd_file_properties (BonoboUIComponent *uic,
+                       gpointer           user_data,
+                       const gchar       *verbname)
+{
+       glWindow *window = GL_WINDOW (user_data);
+
+       gl_debug (DEBUG_COMMANDS, "");
+       
+       gl_file_properties (GL_VIEW(window->view)->label, GTK_WINDOW(window));
+}
+
 /****************************************************************************/
 /* File->Open command.                                                      */
 /****************************************************************************/
index 4da034c26b91783f3507fb639e147e0491d22224..88e450fb4ef979e995831a036baf805c2bbc27a3 100644 (file)
@@ -31,6 +31,10 @@ void gl_cmd_file_new             (BonoboUIComponent *uic,
                                  gpointer           user_data,
                                  const gchar       *verbname);
 
+void gl_cmd_file_properties      (BonoboUIComponent *uic,
+                                 gpointer           user_data,
+                                 const gchar       *verbname);
+
 void gl_cmd_file_open            (BonoboUIComponent *uic,
                                  gpointer           user_data,
                                  const gchar       *verbname);
index 6f68aee04b5c15a9256e230e67e19150aa703f16..cebbda0b287e742613b636d701c4340d4d165ea8 100644 (file)
@@ -50,21 +50,30 @@ static gchar *save_path = NULL;
 /*===========================================*/
 /* Local function prototypes.                */
 /*===========================================*/
-static void create_new_dialog_widgets (glHigDialog       *dlg);
-static void new_template_changed      (glWdgtMediaSelect *select,
-                                      gpointer           data);
-static void new_response              (GtkDialog         *dlg,
-                                      gint               response,
-                                      gpointer           user_data);
-static void open_ok                   (GtkWidget         *widget,
-                                      GtkFileSelection  *fsel);
-
-static void save_as_ok_cb             (GtkWidget         *widget,
-                                      GtkFileSelection  *fsel);
-static void save_as_cancel_cb         (GtkWidget         *widget,
-                                      GtkFileSelection  *fsel);
-static void save_as_destroy_cb        (GtkWidget         *widget,
-                                      gboolean          *destroy_flag);
+static void create_new_dialog_widgets        (glHigDialog       *dlg);
+static void new_template_changed             (glWdgtMediaSelect *select,
+                                             gpointer           data);
+static void new_response                     (GtkDialog         *dlg,
+                                             gint               response,
+                                             gpointer           user_data);
+
+static void create_properties_dialog_widgets (glHigDialog       *dlg,
+                                             glLabel           *label);
+static void properties_template_changed      (glWdgtMediaSelect *select,
+                                             gpointer           data);
+static void properties_response              (GtkDialog         *dlg,
+                                             gint               response,
+                                             gpointer           user_data);
+
+static void open_ok                          (GtkWidget         *widget,
+                                             GtkFileSelection  *fsel);
+
+static void save_as_ok_cb                    (GtkWidget         *widget,
+                                             GtkFileSelection  *fsel);
+static void save_as_cancel_cb                (GtkWidget         *widget,
+                                             GtkFileSelection  *fsel);
+static void save_as_destroy_cb               (GtkWidget         *widget,
+                                             gboolean          *destroy_flag);
 
 \f
 /*****************************************************************************/
@@ -231,6 +240,170 @@ new_response (GtkDialog *dlg,
        gl_debug (DEBUG_FILE, "END");
 }
 
+\f
+/*****************************************************************************/
+/* "Properties" menu callback.                                               */
+/*****************************************************************************/
+void
+gl_file_properties (glLabel   *label,
+                   GtkWindow *window)
+{
+       GtkWidget    *dlg;
+
+       gl_debug (DEBUG_FILE, "START");
+
+       g_return_if_fail (label && GL_IS_LABEL (label));
+       g_return_if_fail (window && GTK_IS_WINDOW (window));
+
+       dlg = gl_hig_dialog_new_with_buttons (_("Label properties"),
+                                             window,
+                                             GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+                                             GTK_STOCK_OK, GTK_RESPONSE_OK,
+                                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                             NULL);
+
+       create_properties_dialog_widgets (GL_HIG_DIALOG (dlg), label);
+
+       g_object_set_data (G_OBJECT (dlg), "label", label);
+
+       g_signal_connect (G_OBJECT(dlg), "response",
+                         G_CALLBACK (properties_response), dlg);
+
+        gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+       gtk_widget_show_all (GTK_WIDGET (dlg));
+
+       gl_debug (DEBUG_FILE, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Create widgets.                                                 */
+/*---------------------------------------------------------------------------*/
+static void
+create_properties_dialog_widgets (glHigDialog *dlg,
+                                 glLabel     *label)
+{
+       GtkWidget  *wframe, *template_entry, *rotate_sel;
+       glTemplate *template;
+       gboolean    rotate_flag;
+
+       gl_debug (DEBUG_FILE, "START");
+
+       wframe = gl_hig_category_new (_("Media Type"));
+       gl_hig_dialog_add_widget (dlg, wframe);
+
+       template_entry = gl_wdgt_media_select_new ();
+       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), template_entry);
+
+       wframe = gl_hig_category_new (_("Label orientation"));
+       gl_hig_dialog_add_widget (dlg, wframe);
+
+       rotate_sel = gl_wdgt_rotate_label_new ();
+       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), rotate_sel);
+
+       g_object_set_data (G_OBJECT (dlg), "template_entry", template_entry);
+       g_object_set_data (G_OBJECT (dlg), "rotate_sel", rotate_sel);
+
+       g_signal_connect (G_OBJECT (template_entry), "changed",
+                         G_CALLBACK (properties_template_changed), rotate_sel);
+
+       template = gl_label_get_template (label);
+       rotate_flag = gl_label_get_rotate_flag (label);
+
+       gl_debug (DEBUG_FILE, "%s, %s", template->page_size, template->name->data);
+
+       if (template->page_size != NULL) {
+               gl_wdgt_media_select_set_page_size (GL_WDGT_MEDIA_SELECT (template_entry),
+                                                   template->page_size);
+       }
+       if (template->name->data != NULL) {
+               gl_wdgt_media_select_set_name (GL_WDGT_MEDIA_SELECT (template_entry),
+                                              template->name->data);
+               gl_wdgt_rotate_label_set_template_name (GL_WDGT_ROTATE_LABEL
+                                                   (rotate_sel), template->name->data);
+       } else {
+               sheet_name =
+                   gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (template_entry));
+               gl_wdgt_rotate_label_set_template_name (GL_WDGT_ROTATE_LABEL
+                                                   (rotate_sel), sheet_name);
+       }
+       gl_wdgt_rotate_label_set_state (GL_WDGT_ROTATE_LABEL (rotate_sel), rotate_flag);
+
+       gl_debug (DEBUG_FILE, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Properties template changed callback.                           */
+/*---------------------------------------------------------------------------*/
+static void
+properties_template_changed (glWdgtMediaSelect *select,
+                            gpointer           data)
+{
+       glWdgtRotateLabel *rotate_sel = GL_WDGT_ROTATE_LABEL (data);
+       gchar             *name;
+
+       gl_debug (DEBUG_FILE, "START");
+
+       name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (select));
+
+       gl_wdgt_rotate_label_set_template_name (GL_WDGT_ROTATE_LABEL (rotate_sel),
+                                               name);
+
+       g_free (name);
+
+       gl_debug (DEBUG_FILE, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Properties "ok" button callback.                                */
+/*---------------------------------------------------------------------------*/
+static void
+properties_response (GtkDialog *dlg,
+                    gint       response,
+                    gpointer   user_data)
+{
+       GtkWidget  *template_entry, *rotate_sel;
+       glTemplate *template;
+       glLabel    *label;
+       gint        ret;
+       glWindow   *window;
+
+       gl_debug (DEBUG_FILE, "START");
+
+       switch (response) {
+       case GTK_RESPONSE_OK:
+               template_entry =
+                       GTK_WIDGET (g_object_get_data (G_OBJECT (dlg),
+                                                      "template_entry"));
+               rotate_sel = GTK_WIDGET (g_object_get_data (G_OBJECT (dlg),
+                                                           "rotate_sel"));
+
+               if (page_size != NULL)
+                       g_free (page_size);
+               page_size =
+                       gl_wdgt_media_select_get_page_size (GL_WDGT_MEDIA_SELECT (template_entry));
+
+               if (sheet_name != NULL)
+                       g_free (sheet_name);
+               sheet_name =
+                       gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (template_entry));
+
+               rotate_flag =
+                       gl_wdgt_rotate_label_get_state (GL_WDGT_ROTATE_LABEL (rotate_sel));
+
+               template = gl_template_from_name (sheet_name);
+
+               label = GL_LABEL(g_object_get_data (G_OBJECT (dlg), "label"));
+               gl_label_set_template (label, template);
+               gl_label_set_rotate_flag (label, rotate_flag);
+
+               break;
+       }
+
+       gtk_widget_destroy (GTK_WIDGET (dlg));
+
+       gl_debug (DEBUG_FILE, "END");
+}
+
 /*****************************************************************************/
 /* "Open" menu callback.                                                     */
 /*****************************************************************************/
index f6b67368c74f58dcabcd448ff1d84716c7b23746..d7fb086f3cd8aca9b2252ee87429fc6c5c9d063c 100644 (file)
@@ -34,6 +34,10 @@ G_BEGIN_DECLS
 void     gl_file_new         (GtkWindow       *window);
 
 
+void     gl_file_properties  (glLabel         *label,
+                             GtkWindow       *window);
+
+
 void     gl_file_open        (GtkWindow       *window);
 
 
index 9720ebb440ed30510fc3e03d6947ffb41f2dbb3f..9c0e78a7b3481435bd8cf67086dca038f6a3c4a4 100644 (file)
@@ -4,6 +4,9 @@
         <cmd name="FileNew" _label="New"
        _tip="Create a new document" pixtype="stock" pixname="gtk-new" accel="*Control*N"/>
         
+        <cmd name="FileProperties" _label="Properties"
+       _tip="Create a new document" pixtype="stock" pixname="gtk-properties"/>
+        
         <cmd name="FileOpen" _label="Open"
        _tip="Open a file" pixtype="stock" pixname="gtk-open" accel="*Control*O"/>
        
 
        <placeholder name="FileOps_2" delimit="top"/>
 
+       <separator/>
+
+        <menuitem name="FileProperties" verb="" _label="Proper_ties"/>
+
        <separator/>
        
         <menuitem name="FileClose" verb="" _label="_Close"/>
index e4f876efc2afa0baf3ec1946a32eac8fab33bd50..f0a9c4147e83204f3fb9c503efc7a5a5544e5b70 100644 (file)
@@ -49,6 +49,7 @@
 
 static BonoboUIVerb gl_ui_verbs [] = {
        BONOBO_UI_VERB ("FileNew",               gl_cmd_file_new),
+       BONOBO_UI_VERB ("FileProperties",        gl_cmd_file_properties),
        BONOBO_UI_VERB ("FileOpen",              gl_cmd_file_open),
        BONOBO_UI_VERB ("FileSave",              gl_cmd_file_save),
        BONOBO_UI_VERB ("FileSaveAs",            gl_cmd_file_save_as),
@@ -95,6 +96,7 @@ static BonoboUIVerb gl_ui_verbs [] = {
 };
 
 static gchar* doc_verbs [] = {
+       "/commands/FileProperties",
        "/commands/FileSave",
        "/commands/FileSaveAs",
        "/commands/FilePrint",
index 79ad7ef3242306a216ec63cc98e04bb392435e27..ac00dbb573e5071cbc6aca2afcca34b095d6030f 100644 (file)
@@ -158,6 +158,8 @@ gl_xml_template_parse_sheet (xmlNodePtr sheet_node)
                        g_warning (_("Unknown page size id \"%s\", trying as name"),
                                   template->page_size);
                        paper = gl_paper_from_name (template->page_size);
+                       g_free (template->page_size);
+                       template->page_size = g_strdup (paper->id);
                }
                if (paper != NULL) {
                        template->page_width  = paper->width;