[gimp] app: add a GimpText property and construct param to GimpTextStyleEditor



commit ecbfb4a9e87bd8c90f26f1dc1545b15e447c834f
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 18 21:16:53 2011 +0100

    app: add a GimpText property and construct param to GimpTextStyleEditor
    
    which will be used to get default values from.

 app/tools/gimptextoptions.c       |    4 +++-
 app/tools/gimptextoptions.h       |    1 +
 app/tools/gimptexttool-editor.c   |    4 +++-
 app/widgets/gimptexteditor.c      |    6 +++++-
 app/widgets/gimptexteditor.h      |    1 +
 app/widgets/gimptextstyleeditor.c |   24 ++++++++++++++++++++++++
 app/widgets/gimptextstyleeditor.h |    2 ++
 7 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c
index 2e94511..b9b9657 100644
--- a/app/tools/gimptextoptions.c
+++ b/app/tools/gimptextoptions.c
@@ -654,6 +654,7 @@ gimp_text_options_editor_new (GtkWindow       *parent,
                               GimpTextOptions *options,
                               GimpMenuFactory *menu_factory,
                               const gchar     *title,
+                              GimpText        *text,
                               GimpTextBuffer  *text_buffer,
                               gdouble          xres,
                               gdouble          yres)
@@ -665,10 +666,11 @@ gimp_text_options_editor_new (GtkWindow       *parent,
   g_return_val_if_fail (GIMP_IS_TEXT_OPTIONS (options), NULL);
   g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
   g_return_val_if_fail (title != NULL, NULL);
+  g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);
   g_return_val_if_fail (GIMP_IS_TEXT_BUFFER (text_buffer), NULL);
 
   editor = gimp_text_editor_new (title, parent, gimp, menu_factory,
-                                 text_buffer, xres, yres);
+                                 text, text_buffer, xres, yres);
 
   font_name = gimp_context_get_font_name (GIMP_CONTEXT (options));
 
diff --git a/app/tools/gimptextoptions.h b/app/tools/gimptextoptions.h
index bee86f8..a1f7e2f 100644
--- a/app/tools/gimptextoptions.h
+++ b/app/tools/gimptextoptions.h
@@ -71,6 +71,7 @@ GtkWidget * gimp_text_options_editor_new   (GtkWindow       *parent,
                                             GimpTextOptions *options,
                                             GimpMenuFactory *menu_factory,
                                             const gchar     *title,
+                                            GimpText        *text,
                                             GimpTextBuffer  *text_buffer,
                                             gdouble          xres,
                                             gdouble          yres);
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 9517542..4707cbc 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -183,6 +183,7 @@ gimp_text_tool_editor_start (GimpTextTool *text_tool)
         gimp_image_get_resolution (text_tool->image, &xres, &yres);
 
       text_tool->style_editor = gimp_text_style_editor_new (gimp,
+                                                            text_tool->proxy,
                                                             text_tool->buffer,
                                                             gimp->fonts,
                                                             xres, yres);
@@ -1156,7 +1157,8 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
     gimp_text_options_editor_new (parent, tool->tool_info->gimp, options,
                                   gimp_dialog_factory_get_menu_factory (dialog_factory),
                                   _("GIMP Text Editor"),
-                                  text_tool->buffer, xres, yres);
+                                  text_tool->proxy, text_tool->buffer,
+                                  xres, yres);
 
   g_object_add_weak_pointer (G_OBJECT (text_tool->editor_dialog),
                              (gpointer) &text_tool->editor_dialog);
diff --git a/app/widgets/gimptexteditor.c b/app/widgets/gimptexteditor.c
index 7eed3db..f4590da 100644
--- a/app/widgets/gimptexteditor.c
+++ b/app/widgets/gimptexteditor.c
@@ -29,6 +29,8 @@
 #include "core/gimp.h"
 #include "core/gimpmarshal.h"
 
+#include "text/gimptext.h"
+
 #include "gimphelp-ids.h"
 #include "gimpmenufactory.h"
 #include "gimptextbuffer.h"
@@ -132,6 +134,7 @@ gimp_text_editor_new (const gchar     *title,
                       GtkWindow       *parent,
                       Gimp            *gimp,
                       GimpMenuFactory *menu_factory,
+                      GimpText        *text,
                       GimpTextBuffer  *text_buffer,
                       gdouble          xres,
                       gdouble          yres)
@@ -146,6 +149,7 @@ gimp_text_editor_new (const gchar     *title,
   g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
   g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
+  g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);
   g_return_val_if_fail (GIMP_IS_TEXT_BUFFER (text_buffer), NULL);
 
   editor = g_object_new (GIMP_TYPE_TEXT_EDITOR,
@@ -182,7 +186,7 @@ gimp_text_editor_new (const gchar     *title,
       gtk_widget_show (toolbar);
     }
 
-  style_editor = gimp_text_style_editor_new (gimp, text_buffer,
+  style_editor = gimp_text_style_editor_new (gimp, text, text_buffer,
                                              gimp->fonts,
                                              xres, yres);
   gtk_box_pack_start (GTK_BOX (content_area), style_editor, FALSE, FALSE, 0);
diff --git a/app/widgets/gimptexteditor.h b/app/widgets/gimptexteditor.h
index 00a07f9..5b4662c 100644
--- a/app/widgets/gimptexteditor.h
+++ b/app/widgets/gimptexteditor.h
@@ -57,6 +57,7 @@ GtkWidget         * gimp_text_editor_new           (const gchar       *title,
                                                     GtkWindow         *parent,
                                                     Gimp              *gimp,
                                                     GimpMenuFactory   *menu_factory,
+                                                    GimpText          *text,
                                                     GimpTextBuffer    *text_buffer,
                                                     gdouble            xres,
                                                     gdouble            yres);
diff --git a/app/widgets/gimptextstyleeditor.c b/app/widgets/gimptextstyleeditor.c
index 83c3bc3..08de96a 100644
--- a/app/widgets/gimptextstyleeditor.c
+++ b/app/widgets/gimptextstyleeditor.c
@@ -33,6 +33,7 @@
 #include "core/gimpcontext.h"
 
 #include "text/gimpfontlist.h"
+#include "text/gimptext.h"
 
 #include "gimpcolorpanel.h"
 #include "gimpcontainerentry.h"
@@ -48,6 +49,7 @@ enum
 {
   PROP_0,
   PROP_GIMP,
+  PROP_TEXT,
   PROP_BUFFER,
   PROP_FONTS,
   PROP_RESOLUTION_X,
@@ -135,6 +137,13 @@ gimp_text_style_editor_class_init (GimpTextStyleEditorClass *klass)
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));
 
+  g_object_class_install_property (object_class, PROP_TEXT,
+                                   g_param_spec_object ("text",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_TEXT,
+                                                        GIMP_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
   g_object_class_install_property (object_class, PROP_BUFFER,
                                    g_param_spec_object ("buffer",
                                                         NULL, NULL,
@@ -370,6 +379,12 @@ gimp_text_style_editor_finalize (GObject *object)
       editor->context = NULL;
     }
 
+  if (editor->text)
+    {
+      g_object_unref (editor->text);
+      editor->text = NULL;
+    }
+
   if (editor->buffer)
     {
       g_object_unref (editor->buffer);
@@ -398,6 +413,9 @@ gimp_text_style_editor_set_property (GObject      *object,
     case PROP_GIMP:
       editor->gimp = g_value_get_object (value); /* don't ref */
       break;
+    case PROP_TEXT:
+      editor->text = g_value_dup_object (value);
+      break;
     case PROP_BUFFER:
       editor->buffer = g_value_dup_object (value);
       break;
@@ -430,6 +448,9 @@ gimp_text_style_editor_get_property (GObject    *object,
     case PROP_GIMP:
       g_value_set_object (value, editor->gimp);
       break;
+    case PROP_TEXT:
+      g_value_set_object (value, editor->text);
+      break;
     case PROP_BUFFER:
       g_value_set_object (value, editor->buffer);
       break;
@@ -454,18 +475,21 @@ gimp_text_style_editor_get_property (GObject    *object,
 
 GtkWidget *
 gimp_text_style_editor_new (Gimp           *gimp,
+                            GimpText       *text,
                             GimpTextBuffer *buffer,
                             GimpContainer  *fonts,
                             gdouble         resolution_x,
                             gdouble         resolution_y)
 {
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+  g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);
   g_return_val_if_fail (GIMP_IS_TEXT_BUFFER (buffer), NULL);
   g_return_val_if_fail (resolution_x > 0.0, NULL);
   g_return_val_if_fail (resolution_y > 0.0, NULL);
 
   return g_object_new (GIMP_TYPE_TEXT_STYLE_EDITOR,
                        "gimp",         gimp,
+                       "text",         text,
                        "buffer",       buffer,
                        "fonts",        fonts,
                        "resolution-x", resolution_x,
diff --git a/app/widgets/gimptextstyleeditor.h b/app/widgets/gimptextstyleeditor.h
index 02ad7de..de78861 100644
--- a/app/widgets/gimptextstyleeditor.h
+++ b/app/widgets/gimptextstyleeditor.h
@@ -39,6 +39,7 @@ struct _GimpTextStyleEditor
   Gimp           *gimp;
   GimpContext    *context;
 
+  GimpText       *text; /* read-only for default values */
   GimpTextBuffer *buffer;
 
   GimpContainer  *fonts;
@@ -77,6 +78,7 @@ struct _GimpTextStyleEditorClass
 GType       gimp_text_style_editor_get_type  (void) G_GNUC_CONST;
 
 GtkWidget * gimp_text_style_editor_new       (Gimp                 *gimp,
+                                              GimpText             *text,
                                               GimpTextBuffer       *buffer,
                                               GimpContainer        *fonts,
                                               gdouble               resolution_x,



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