[gimp] app: enable image new's resolution chain button only if xres == yres



commit 3abb84022a7cdccc910f747c8714efdf5e979f3f
Author: Michael Natterer <mitch gimp org>
Date:   Fri Apr 18 18:43:32 2014 +0200

    app: enable image new's resolution chain button only if xres == yres

 app/dialogs/image-new-dialog.c   |   22 +++++++++++++++-------
 app/widgets/gimptemplateeditor.c |   30 +++++++++++++++++++++++-------
 app/widgets/gimptemplateeditor.h |    4 ++++
 3 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c
index 2897d33..4cc3609 100644
--- a/app/dialogs/image-new-dialog.c
+++ b/app/dialogs/image-new-dialog.c
@@ -192,11 +192,7 @@ image_new_dialog_set (GtkWidget    *widget,
       template = gimp_image_new_get_last_template (dialog->context->gimp,
                                                    image);
 
-      /*  make sure the resolution values are copied first (see bug #546924)  */
-      gimp_config_sync (G_OBJECT (template), G_OBJECT (dialog->template),
-                        GIMP_TEMPLATE_PARAM_COPY_FIRST);
-      gimp_config_sync (G_OBJECT (template), G_OBJECT (dialog->template),
-                        0);
+      image_new_template_changed (dialog->context, template, dialog);
 
       g_object_unref (template);
     }
@@ -246,11 +242,23 @@ image_new_template_changed (GimpContext    *context,
                             GimpTemplate   *template,
                             ImageNewDialog *dialog)
 {
-  gchar *comment;
+  GimpTemplateEditor *editor;
+  GtkWidget          *chain;
+  gdouble             xres, yres;
+  gchar              *comment;
 
-  if (!template)
+  if (! template)
     return;
 
+  editor = GIMP_TEMPLATE_EDITOR (dialog->editor);
+  chain  = gimp_template_editor_get_resolution_chain (editor);
+
+  xres = gimp_template_get_resolution_x (template);
+  yres = gimp_template_get_resolution_y (template);
+
+  gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain),
+                                ABS (xres - yres) < GIMP_MIN_RESOLUTION);
+
   comment = (gchar *) gimp_template_get_comment (template);
 
   if (! comment || ! strlen (comment))
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index a1c8f84..e4343c5 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -64,6 +64,7 @@ struct _GimpTemplateEditorPrivate
   GtkWidget     *pixel_label;
   GtkWidget     *more_label;
   GtkWidget     *resolution_se;
+  GtkWidget     *chain_button;
 };
 
 #define GET_PRIVATE(editor) \
@@ -140,7 +141,6 @@ gimp_template_editor_constructed (GObject *object)
   GtkWidget                 *height;
   GtkWidget                 *xres;
   GtkWidget                 *yres;
-  GtkWidget                 *chainbutton;
   GtkWidget                 *combo;
   GtkWidget                 *scrolled_window;
   GtkWidget                 *text_view;
@@ -359,20 +359,20 @@ gimp_template_editor_constructed (GObject *object)
                                   FALSE);
 
   /*  the resolution chainbutton  */
-  chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
-  gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), chainbutton,
-                             1, 2, 0, 2);
-  gtk_widget_show (chainbutton);
+  private->chain_button = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
+  gtk_table_attach_defaults (GTK_TABLE (private->resolution_se),
+                             private->chain_button, 1, 2, 0, 2);
+  gtk_widget_show (private->chain_button);
 
   gimp_prop_coordinates_connect (G_OBJECT (template),
                                  "xresolution", "yresolution",
                                  "resolution-unit",
-                                 private->resolution_se, chainbutton,
+                                 private->resolution_se, private->chain_button,
                                  1.0, 1.0);
 
   focus_chain = g_list_prepend (focus_chain,
                                 GIMP_SIZE_ENTRY (private->resolution_se)->unitmenu);
-  focus_chain = g_list_prepend (focus_chain, chainbutton);
+  focus_chain = g_list_prepend (focus_chain, private->chain_button);
   focus_chain = g_list_prepend (focus_chain, yres);
   focus_chain = g_list_prepend (focus_chain, xres);
 
@@ -557,6 +557,22 @@ gimp_template_editor_get_size_se (GimpTemplateEditor *editor)
   return GET_PRIVATE (editor)->size_se;
 }
 
+GtkWidget *
+gimp_template_editor_get_resolution_se (GimpTemplateEditor *editor)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor), NULL);
+
+  return GET_PRIVATE (editor)->resolution_se;
+}
+
+GtkWidget *
+gimp_template_editor_get_resolution_chain (GimpTemplateEditor *editor)
+{
+  g_return_val_if_fail (GIMP_IS_TEMPLATE_EDITOR (editor), NULL);
+
+  return GET_PRIVATE (editor)->chain_button;
+}
+
 
 /*  private functions  */
 
diff --git a/app/widgets/gimptemplateeditor.h b/app/widgets/gimptemplateeditor.h
index 0c47833..efbad74 100644
--- a/app/widgets/gimptemplateeditor.h
+++ b/app/widgets/gimptemplateeditor.h
@@ -54,6 +54,10 @@ GimpTemplate * gimp_template_editor_get_template  (GimpTemplateEditor *editor);
 void           gimp_template_editor_show_advanced (GimpTemplateEditor *editor,
                                                    gboolean            expanded);
 GtkWidget    * gimp_template_editor_get_size_se   (GimpTemplateEditor *editor);
+GtkWidget    * gimp_template_editor_get_resolution_se
+                                                  (GimpTemplateEditor *editor);
+GtkWidget    * gimp_template_editor_get_resolution_chain
+                                                  (GimpTemplateEditor *editor);
 
 
 #endif  /*  __GIMP_TEMPLATE_EDITOR_H__  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]