[gimp] app: add a GimpTextStyleEditor to the text tool's editor dialog



commit df731912a51839b8c143a23fc8461c342290db2f
Author: Michael Natterer <mitch gimp org>
Date:   Fri Mar 18 12:58:32 2011 +0100

    app: add a GimpTextStyleEditor to the text tool's editor dialog
    
    so it's an alternative to on-screen editing for esoteric use cases
    that can do everything on-screen editing is capable of.

 app/tools/gimptextoptions.c     |   10 ++++++++--
 app/tools/gimptextoptions.h     |    5 ++++-
 app/tools/gimptexttool-editor.c |   10 ++++++++--
 app/widgets/gimptexteditor.c    |   15 ++++++++++++++-
 app/widgets/gimptexteditor.h    |    5 ++++-
 5 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c
index 74553a8..2e94511 100644
--- a/app/tools/gimptextoptions.c
+++ b/app/tools/gimptextoptions.c
@@ -27,6 +27,7 @@
 
 #include "config/gimpconfig-utils.h"
 
+#include "core/gimp.h"
 #include "core/gimpviewable.h"
 
 #include "text/gimptext.h"
@@ -649,20 +650,25 @@ gimp_text_options_editor_notify_font (GimpTextOptions *options,
 
 GtkWidget *
 gimp_text_options_editor_new (GtkWindow       *parent,
+                              Gimp            *gimp,
                               GimpTextOptions *options,
                               GimpMenuFactory *menu_factory,
                               const gchar     *title,
-                              GimpTextBuffer  *text_buffer)
+                              GimpTextBuffer  *text_buffer,
+                              gdouble          xres,
+                              gdouble          yres)
 {
   GtkWidget   *editor;
   const gchar *font_name;
 
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
   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_BUFFER (text_buffer), NULL);
 
-  editor = gimp_text_editor_new (title, parent, menu_factory, text_buffer);
+  editor = gimp_text_editor_new (title, parent, gimp, menu_factory,
+                                 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 63602b2..bee86f8 100644
--- a/app/tools/gimptextoptions.h
+++ b/app/tools/gimptextoptions.h
@@ -67,10 +67,13 @@ void        gimp_text_options_connect_text (GimpTextOptions *options,
 GtkWidget * gimp_text_options_gui          (GimpToolOptions *tool_options);
 
 GtkWidget * gimp_text_options_editor_new   (GtkWindow       *parent,
+                                            Gimp            *gimp,
                                             GimpTextOptions *options,
                                             GimpMenuFactory *menu_factory,
                                             const gchar     *title,
-                                            GimpTextBuffer  *text_buffer);
+                                            GimpTextBuffer  *text_buffer,
+                                            gdouble          xres,
+                                            gdouble          yres);
 
 
 #endif /* __GIMP_TEXT_OPTIONS_H__ */
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index a81e205..9517542 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -32,6 +32,7 @@
 
 #include "core/gimp.h"
 #include "core/gimpimage.h"
+#include "core/gimptoolinfo.h"
 
 #include "text/gimptext.h"
 #include "text/gimptextlayout.h"
@@ -1130,6 +1131,8 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
   GimpTextOptions   *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
   GimpDialogFactory *dialog_factory;
   GtkWindow         *parent  = NULL;
+  gdouble            xres    = 1.0;
+  gdouble            yres    = 1.0;
 
   if (text_tool->editor_dialog)
     {
@@ -1146,11 +1149,14 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
       parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell)));
     }
 
+  if (text_tool->image)
+    gimp_image_get_resolution (text_tool->image, &xres, &yres);
+
   text_tool->editor_dialog =
-    gimp_text_options_editor_new (parent, options,
+    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);
+                                  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 b3fdff9..7eed3db 100644
--- a/app/widgets/gimptexteditor.c
+++ b/app/widgets/gimptexteditor.c
@@ -26,12 +26,14 @@
 
 #include "widgets-types.h"
 
+#include "core/gimp.h"
 #include "core/gimpmarshal.h"
 
 #include "gimphelp-ids.h"
 #include "gimpmenufactory.h"
 #include "gimptextbuffer.h"
 #include "gimptexteditor.h"
+#include "gimptextstyleeditor.h"
 #include "gimpuimanager.h"
 
 #include "gimp-intl.h"
@@ -128,16 +130,21 @@ gimp_text_editor_finalize (GObject *object)
 GtkWidget *
 gimp_text_editor_new (const gchar     *title,
                       GtkWindow       *parent,
+                      Gimp            *gimp,
                       GimpMenuFactory *menu_factory,
-                      GimpTextBuffer  *text_buffer)
+                      GimpTextBuffer  *text_buffer,
+                      gdouble          xres,
+                      gdouble          yres)
 {
   GimpTextEditor *editor;
   GtkWidget      *content_area;
   GtkWidget      *toolbar;
+  GtkWidget      *style_editor;
   GtkWidget      *scrolled_window;
 
   g_return_val_if_fail (title != NULL, NULL);
   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_BUFFER (text_buffer), NULL);
 
@@ -175,6 +182,12 @@ gimp_text_editor_new (const gchar     *title,
       gtk_widget_show (toolbar);
     }
 
+  style_editor = gimp_text_style_editor_new (gimp, text_buffer,
+                                             gimp->fonts,
+                                             xres, yres);
+  gtk_box_pack_start (GTK_BOX (content_area), style_editor, FALSE, FALSE, 0);
+  gtk_widget_show (style_editor);
+
   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                   GTK_POLICY_AUTOMATIC,
diff --git a/app/widgets/gimptexteditor.h b/app/widgets/gimptexteditor.h
index 25b7a79..00a07f9 100644
--- a/app/widgets/gimptexteditor.h
+++ b/app/widgets/gimptexteditor.h
@@ -55,8 +55,11 @@ struct _GimpTextEditorClass
 GType               gimp_text_editor_get_type      (void) G_GNUC_CONST;
 GtkWidget         * gimp_text_editor_new           (const gchar       *title,
                                                     GtkWindow         *parent,
+                                                    Gimp              *gimp,
                                                     GimpMenuFactory   *menu_factory,
-                                                    GimpTextBuffer    *text_buffer);
+                                                    GimpTextBuffer    *text_buffer,
+                                                    gdouble            xres,
+                                                    gdouble            yres);
 
 void                gimp_text_editor_set_text      (GimpTextEditor    *editor,
                                                     const gchar       *text,



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