From 0ca5b099e53d322cecc92d9210de4a33bbd2d6ab Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Wed, 26 Mar 2003 01:30:05 +0000 Subject: [PATCH] connect the preview on the context's font object with the font property of 2003-03-26 Sven Neumann * app/tools/gimptextoptions.c: connect the preview on the context's font object with the font property of the text object associated to the text tool options. --- ChangeLog | 6 ++++ app/tools/gimptextoptions.c | 64 +++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/ChangeLog b/ChangeLog index eaa5995f6e..55e3508859 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-03-26 Sven Neumann + + * app/tools/gimptextoptions.c: connect the preview on the + context's font object with the font property of the text object + associated to the text tool options. + 2003-03-26 Michael Natterer * app/widgets/gimpdnd.[ch]: added GimpFont DND. diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index 39a851e516..34d8e153ef 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -30,6 +30,7 @@ #include "core/gimp.h" #include "core/gimpcontext.h" +#include "core/gimpcontainer.h" #include "core/gimptoolinfo.h" #include "text/gimptext.h" @@ -61,6 +62,13 @@ static void gimp_text_options_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static void gimp_text_options_notify_font (GimpContext *context, + GParamSpec *pspec, + GimpText *text); +static void gimp_text_notify_font (GimpText *text, + GParamSpec *pspec, + GimpContext *context); + static void gimp_text_options_font_clicked (GtkWidget *widget, GimpContext *context); @@ -122,6 +130,13 @@ gimp_text_options_init (GimpTextOptions *options) options->text = GIMP_TEXT (text); options->buffer = gimp_prop_text_buffer_new (text, "text", -1); + + g_signal_connect_object (options, "notify::font", + G_CALLBACK (gimp_text_options_notify_font), + text, 0); + g_signal_connect_object (text, "notify::font", + G_CALLBACK (gimp_text_notify_font), + options, 0); } static void @@ -145,6 +160,55 @@ gimp_text_options_get_property (GObject *object, } } +static void +gimp_text_options_notify_font (GimpContext *context, + GParamSpec *pspec, + GimpText *text) +{ + GimpFont *font = gimp_context_get_font (context); + + g_signal_handlers_block_by_func (text, + gimp_text_notify_font, + context); + + g_object_set (text, + "font", gimp_object_get_name (GIMP_OBJECT (font)), + NULL); + + g_signal_handlers_unblock_by_func (text, + gimp_text_notify_font, + context); +} + +static void +gimp_text_notify_font (GimpText *text, + GParamSpec *pspec, + GimpContext *context) +{ + GimpObject *font; + gchar *value; + + g_object_get (text, + "font", &value, + NULL); + + font = gimp_container_get_child_by_name (context->gimp->fonts, value); + + g_free (value); + + g_signal_handlers_block_by_func (context, + gimp_text_options_notify_font, + text); + + g_object_set (context, + "font", font, + NULL); + + g_signal_handlers_unblock_by_func (context, + gimp_text_options_notify_font, + text); +} + GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options) {