[glide] Implement font name setting



commit 0bc7d543720872f58eadae25bab4020a1636eed9
Author: Robert Carr <racarr Valentine localdomain>
Date:   Sun May 2 02:11:56 2010 -0400

    Implement font name setting

 src/glide-inspector-text-priv.h |    2 ++
 src/glide-inspector-text.c      |   35 +++++++++++++++++++++++++++++++++++
 src/glide-text.c                |    9 +++++++++
 3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/src/glide-inspector-text-priv.h b/src/glide-inspector-text-priv.h
index dae7660..e0819bd 100644
--- a/src/glide-inspector-text-priv.h
+++ b/src/glide-inspector-text-priv.h
@@ -31,6 +31,8 @@ struct _GlideInspectorTextPrivate
   GtkWidget *font_button;
   
   gboolean ignore_set;
+  
+  gulong font_notify_id;
 };
 
 G_END_DECLS
diff --git a/src/glide-inspector-text.c b/src/glide-inspector-text.c
index 9bcdec0..644be52 100644
--- a/src/glide-inspector-text.c
+++ b/src/glide-inspector-text.c
@@ -47,6 +47,30 @@ glide_inspector_text_update_fontname (GlideInspectorText *ins)
   ins->priv->ignore_set = FALSE;
 }
 
+static void
+glide_inspector_text_fontname_changed (GObject *object,
+				       GParamSpec *pspec,
+				       gpointer user_data)
+{
+  GlideInspectorText *ins = (GlideInspectorText *)user_data;
+  glide_inspector_text_update_fontname (ins);
+}
+
+static void
+glide_inspector_text_font_set (GtkFontButton *widg,
+			       gpointer user_data)
+{
+  GlideInspectorText *ins = (GlideInspectorText *)user_data;
+  
+  if (ins->priv->ignore_set)
+    return;
+  
+  glide_actor_start_undo (ins->priv->actor, "Modify actor font.");
+  glide_text_set_font_name (GLIDE_TEXT (ins->priv->actor),
+			    gtk_font_button_get_font_name (widg));
+  glide_actor_end_undo (ins->priv->actor);
+}
+
 
 static void
 glide_inspector_text_finalize (GObject *object)
@@ -108,6 +132,7 @@ glide_inspector_text_make_font_box (GlideInspectorText *ins)
   gtk_box_pack_start (GTK_BOX(ret), align, TRUE, TRUE, 0);
   
   ins->priv->font_button = button;
+  g_signal_connect (button, "font-set", G_CALLBACK (glide_inspector_text_font_set), ins);
   return ret;
 }
 
@@ -172,6 +197,12 @@ void
 glide_inspector_text_set_actor (GlideInspectorText *inspector,
 				 GlideActor *actor)
 {
+  if (inspector->priv->font_notify_id)
+    {
+      g_signal_handler_disconnect (inspector->priv->actor,
+				   inspector->priv->font_notify_id);
+      inspector->priv->font_notify_id = 0;
+    }
   inspector->priv->actor = actor;
   
   if (!GLIDE_IS_TEXT (actor))
@@ -182,6 +213,10 @@ glide_inspector_text_set_actor (GlideInspectorText *inspector,
     {
       gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
       glide_inspector_text_update_fontname (inspector);
+      
+      inspector->priv->font_notify_id = g_signal_connect (actor, "notify::font-name",
+							   G_CALLBACK (glide_inspector_text_fontname_changed),
+							   inspector);
     }
   
   g_object_notify (G_OBJECT (inspector), "actor");
diff --git a/src/glide-text.c b/src/glide-text.c
index ef421e4..0908b26 100644
--- a/src/glide-text.c
+++ b/src/glide-text.c
@@ -1739,6 +1739,13 @@ glide_text_key_release (ClutterActor *actor,
     glide_undo_manager_end_actor_action (glide_actor_get_undo_manager (GLIDE_ACTOR (text)),
 					 GLIDE_ACTOR (text));
     text->priv->resize_key_down = FALSE;
+
+    if (text->priv->font_name)
+      {
+	g_free (text->priv->font_name);
+      }
+    text->priv->font_name = pango_font_description_to_string (text->priv->font_desc);
+    g_object_notify (G_OBJECT (text), "font-name");
     
     return TRUE;
   }
@@ -2535,6 +2542,7 @@ glide_text_increase_font_size (GlideText         *self,
 					 "Increase font size");
 
   pango_font_description_set_size (self->priv->font_desc, size+1024);
+  
 			  
   glide_text_dirty_cache (self);
   glide_text_update_actor_size (self);
@@ -4016,6 +4024,7 @@ glide_text_set_font_description_internal (GlideText          *self,
   /* update the font name string we use */
   g_free (priv->font_name);
   priv->font_name = pango_font_description_to_string (priv->font_desc);
+  g_object_notify (G_OBJECT (self), "font-name");
 
   glide_text_dirty_cache (self);
 



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