gucharmap r1633 - trunk/gucharmap



Author: chpe
Date: Fri Mar 21 10:47:24 2008
New Revision: 1633
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1633&view=rev

Log:
Set the new font in the charmap widget, and make that set the font of
the chartable instead of going directly to the chartable.


Modified:
   trunk/gucharmap/gucharmap-charmap.c
   trunk/gucharmap/gucharmap-charmap.h
   trunk/gucharmap/gucharmap-chartable.c
   trunk/gucharmap/gucharmap-chartable.h
   trunk/gucharmap/gucharmap-window.c

Modified: trunk/gucharmap/gucharmap-charmap.c
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.c	(original)
+++ trunk/gucharmap/gucharmap-charmap.c	Fri Mar 21 10:47:24 2008
@@ -37,8 +37,11 @@
   GucharmapChartable *chartable;
   GtkTextView *details_view;
 
+  PangoFontDescription *font_desc;
+
   GdkCursor *hand_cursor;
   GdkCursor *regular_cursor;
+
   guint hovering_over_link   : 1;
   guint showing_details_page : 1;
   guint last_character_set   : 1;
@@ -84,6 +87,9 @@
   gdk_cursor_unref (charmap->hand_cursor);
   gdk_cursor_unref (charmap->regular_cursor);
 
+  if (charmap->font_desc)
+    pango_font_description_free (charmap->font_desc);
+
   G_OBJECT_CLASS (gucharmap_charmap_parent_class)->finalize (object);
 }
 
@@ -137,6 +143,18 @@
 }
 
 static void
+gucharmap_charmap_set_font_desc_internal (GucharmapCharmap *charmap, 
+                                          PangoFontDescription *font_desc)
+{
+  if (charmap->font_desc)
+    pango_font_description_free (charmap->font_desc);
+
+  charmap->font_desc = font_desc; /* adopted */
+
+  gucharmap_chartable_set_font_desc (charmap->chartable, font_desc);
+}
+
+static void
 insert_vanilla_detail (GucharmapCharmap *charmap, 
                        GtkTextBuffer *buffer,
                        GtkTextIter *iter,
@@ -933,11 +951,53 @@
   return g_object_new (gucharmap_charmap_get_type (), NULL);
 }
 
+/**
+ * gucharmap_chartable_set_font:
+ * @chartable: a #GucharmapChartable
+ * @font_name:
+ *
+ * Sets @font_name as the font to use to display the character table.
+ */
 void
 gucharmap_charmap_set_font (GucharmapCharmap *charmap, 
                             const gchar *font_name)
 {
-  gucharmap_chartable_set_font (charmap->chartable, font_name);
+  PangoFontDescription *font_desc;
+
+  g_return_if_fail (GUCHARMAP_IS_CHARMAP (charmap));
+  g_return_if_fail (font_name != NULL);
+
+  font_desc = pango_font_description_from_string (font_name);
+  if (charmap->font_desc &&
+      pango_font_description_equal (font_desc, charmap->font_desc))
+    {
+      pango_font_description_free (font_desc);
+      return;
+    }
+
+  gucharmap_charmap_set_font_desc_internal (charmap, font_desc /* adopting */);
+}
+
+/**
+ * gucharmap_chartable_set_font_desc:
+ * @chartable: a #GucharmapChartable
+ * @font_desc: a #PangoFontDescription
+ *
+ * Sets @font_desc as the font to use to display the character table.
+ */
+void
+gucharmap_charmap_set_font_desc (GucharmapCharmap *charmap,
+                                 PangoFontDescription *font_desc)
+{
+  g_return_if_fail (GUCHARMAP_IS_CHARMAP (charmap));
+  g_return_if_fail (font_desc != NULL);
+
+  if (charmap->font_desc &&
+      pango_font_description_equal (font_desc, charmap->font_desc))
+    return;
+
+  gucharmap_charmap_set_font_desc_internal (charmap,
+                                            pango_font_description_copy (font_desc));
 }
 
 void

Modified: trunk/gucharmap/gucharmap-charmap.h
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.h	(original)
+++ trunk/gucharmap/gucharmap-charmap.h	Fri Mar 21 10:47:24 2008
@@ -44,12 +44,16 @@
 
 GtkWidget *           gucharmap_charmap_new                (void);
 
-void                  gucharmap_charmap_set_font           (GucharmapCharmap  *charmap, 
-                                                            const gchar       *font_name);
 void                  gucharmap_charmap_go_to_character    (GucharmapCharmap  *charmap,
                                                             gunichar           uc);
 
-GucharmapChartable *      gucharmap_charmap_get_chartable     (GucharmapCharmap  *charmap);
+void                     gucharmap_charmap_set_font           (GucharmapCharmap  *charmap,
+                                                               const gchar       *font_name);
+
+void                     gucharmap_charmap_set_font_desc      (GucharmapCharmap  *charmap,
+                                                               PangoFontDescription *font_desc);
+
+GucharmapChartable *     gucharmap_charmap_get_chartable      (GucharmapCharmap  *charmap);
 
 GucharmapChaptersView *  gucharmap_charmap_get_chapters_view  (GucharmapCharmap       *charmap);
 

Modified: trunk/gucharmap/gucharmap-chartable.c
==============================================================================
--- trunk/gucharmap/gucharmap-chartable.c	(original)
+++ trunk/gucharmap/gucharmap-chartable.c	Fri Mar 21 10:47:24 2008
@@ -112,8 +112,8 @@
 /* utility functions */
 
 static void
-gucharmap_chartable_set_font_desc (GucharmapChartable *chartable,
-                                   PangoFontDescription *font_desc /* adopting */)
+gucharmap_chartable_set_font_desc_internal (GucharmapChartable *chartable,
+                                            PangoFontDescription *font_desc /* adopting */)
 {
   int font_size;
 
@@ -1985,6 +1985,7 @@
 {
   PangoFontDescription *font_desc;
 
+  g_return_if_fail (GUCHARMAP_IS_CHARTABLE (chartable));
   g_return_if_fail (font_name != NULL);
 
   font_desc = pango_font_description_from_string (font_name);
@@ -1999,6 +2000,28 @@
 }
 
 /**
+ * gucharmap_chartable_set_font_desc:
+ * @chartable: a #GucharmapChartable
+ * @font_desc: a #PangoFontDescription
+ *
+ * Sets @font_desc as the font to use to display the character table.
+ */
+void
+gucharmap_chartable_set_font_desc (GucharmapChartable *chartable,
+                                   PangoFontDescription *font_desc)
+{
+  g_return_if_fail (GUCHARMAP_IS_CHARTABLE (chartable));
+  g_return_if_fail (font_desc != NULL);
+
+  if (chartable->font_desc &&
+      pango_font_description_equal (font_desc, chartable->font_desc))
+    return;
+
+  gucharmap_chartable_set_font_desc_internal (chartable,
+                                              pango_font_description_copy (font_desc));
+}
+
+/**
  * gucharmap_chartable_get_active_character:
  * @chartable: a #GucharmapChartable
  *

Modified: trunk/gucharmap/gucharmap-chartable.h
==============================================================================
--- trunk/gucharmap/gucharmap-chartable.h	(original)
+++ trunk/gucharmap/gucharmap-chartable.h	Fri Mar 21 10:47:24 2008
@@ -41,6 +41,8 @@
 GtkWidget * gucharmap_chartable_new (void);
 void gucharmap_chartable_set_font (GucharmapChartable *chartable, 
                                    const gchar *font_name);
+void gucharmap_chartable_set_font_desc (GucharmapChartable *chartable, 
+                                        PangoFontDescription *font_desc);
 gunichar gucharmap_chartable_get_active_character (GucharmapChartable *chartable);
 void gucharmap_chartable_set_active_character (GucharmapChartable *chartable, 
                                                gunichar uc);

Modified: trunk/gucharmap/gucharmap-window.c
==============================================================================
--- trunk/gucharmap/gucharmap-window.c	(original)
+++ trunk/gucharmap/gucharmap-window.c	Fri Mar 21 10:47:24 2008
@@ -777,8 +777,7 @@
 {
   gchar *font_name = gucharmap_mini_font_selection_get_font_name (fontsel);
 
-  /* FIXMEchpe! set font in the charmap instead */
-  gucharmap_chartable_set_font (gucharmap_charmap_get_chartable (guw->charmap), font_name);
+  gucharmap_charmap_set_font (guw->charmap, font_name);
   gucharmap_settings_set_font (font_name);
 
   g_free (font_name);



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