gucharmap r1810 - trunk/gucharmap



Author: chpe
Date: Sun Jun 15 21:35:10 2008
New Revision: 1810
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1810&view=rev

Log:
Add more API to the charmap so I can remove more callers of gucharmap_charmap_get_chartable.


Modified:
   trunk/gucharmap/Makefile.am
   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/Makefile.am
==============================================================================
--- trunk/gucharmap/Makefile.am	(original)
+++ trunk/gucharmap/Makefile.am	Sun Jun 15 21:35:10 2008
@@ -1,5 +1,5 @@
-##
 ## Copyright  2003  Noah Levitt
+## Copyright  2008  Christian Persch
 ##
 ## This program is free software; you can redistribute it and/or modify it
 ## under the terms of the GNU General Public License as published by the

Modified: trunk/gucharmap/gucharmap-charmap.c
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.c	(original)
+++ trunk/gucharmap/gucharmap-charmap.c	Sun Jun 15 21:35:10 2008
@@ -61,7 +61,9 @@
   PROP_CHAPTERS_MODEL,
   PROP_ACTIVE_CHAPTER,
   PROP_ACTIVE_CHARACTER,
+  PROP_ACTIVE_CODEPOINT_LIST,
   PROP_ACTIVE_PAGE,
+  PROP_SNAP_POW2,
   PROP_FONT_DESC
 };
 
@@ -106,12 +108,18 @@
     case PROP_ACTIVE_CHARACTER:
       g_value_set_uint (value, gucharmap_charmap_get_active_character (charmap));
       break;
+    case PROP_ACTIVE_CODEPOINT_LIST:
+      g_value_set_object (value, gucharmap_charmap_get_active_codepoint_list (charmap));
+      break;
     case PROP_ACTIVE_PAGE:
       g_value_set_uint (value, gucharmap_charmap_get_active_page (charmap));
       break;
     case PROP_FONT_DESC:
       g_value_set_boxed (value, gucharmap_charmap_get_font_desc (charmap));
       break;
+    case PROP_SNAP_POW2:
+      g_value_set_boolean (value, gucharmap_charmap_get_snap_pow2 (charmap));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -144,6 +152,10 @@
     case PROP_FONT_DESC:
       gucharmap_charmap_set_font_desc (charmap, g_value_get_boxed (value));
       break;
+    case PROP_SNAP_POW2:
+      gucharmap_charmap_set_snap_pow2 (charmap, g_value_get_boolean (value));
+      break;
+    case PROP_ACTIVE_CODEPOINT_LIST: /* read-only */
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -210,6 +222,16 @@
 
   g_object_class_install_property
     (object_class,
+     PROP_ACTIVE_CODEPOINT_LIST,
+     g_param_spec_object ("active-codepoint-list", NULL, NULL,
+                          GUCHARMAP_TYPE_CODEPOINT_LIST,
+                          G_PARAM_READABLE |
+                          G_PARAM_STATIC_NAME |
+                          G_PARAM_STATIC_NICK |
+                          G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property
+    (object_class,
      PROP_ACTIVE_PAGE,
      g_param_spec_uint ("active-page", NULL, NULL,
                         0,
@@ -230,6 +252,16 @@
                          G_PARAM_STATIC_NICK |
                          G_PARAM_STATIC_BLURB));
 
+  g_object_class_install_property
+    (object_class,
+     PROP_SNAP_POW2,
+     g_param_spec_boolean ("snap-power-2", NULL, NULL,
+                           FALSE,
+                           G_PARAM_READWRITE |
+                           G_PARAM_STATIC_NAME |
+                           G_PARAM_STATIC_NICK |
+                           G_PARAM_STATIC_BLURB));
+
   g_type_class_add_private (object_class, sizeof (GucharmapCharmapPrivate));
 }
 
@@ -771,6 +803,24 @@
 }
 
 static void
+chartable_notify_cb (GtkWidget *widget,
+                     GParamSpec *pspec,
+                     GObject *charmap)
+{
+  const char *prop_name;
+
+  if (pspec->name == I_("codepoint-list"))
+    prop_name = "active-codepoint-list";
+  else if (pspec->name == I_("snap-pow2"))
+    prop_name = pspec->name;
+  else
+    return;
+
+  /* Forward the notification */
+  g_object_notify (charmap, prop_name);
+}
+
+static void
 follow_if_link (GucharmapCharmap *charmap,
                 GtkTextIter *iter)
 {
@@ -1047,6 +1097,10 @@
                     G_CALLBACK (chartable_sync_active_char), charmap);
   g_signal_connect (chartable, "notify::font-desc",
                     G_CALLBACK (chartable_sync_font_desc), charmap);
+  g_signal_connect (chartable, "notify::codepoint-list",
+                    G_CALLBACK (chartable_notify_cb), charmap);
+  g_signal_connect (chartable, "notify::snap-pow2",
+                    G_CALLBACK (chartable_notify_cb), charmap);
 
   gtk_container_add (GTK_CONTAINER (scrolled_window), chartable);
   gtk_widget_show (chartable);
@@ -1325,3 +1379,43 @@
   return priv->active_page;
 }
 
+GucharmapCodepointList *
+gucharmap_charmap_get_active_codepoint_list (GucharmapCharmap *charmap)
+{
+  GucharmapCharmapPrivate *priv = charmap->priv;
+
+  return gucharmap_chartable_get_codepoint_list (priv->chartable);
+}
+
+/**
+ * gucharmap_charmap_set_snap_pow2:
+ * @charmap: a #GucharmapCharmap
+ * @snap: whether to enable or disable snapping
+ *
+ * Sets whether the number columns the character table shows should
+ * always be a power of 2.
+ */
+void
+gucharmap_charmap_set_snap_pow2 (GucharmapCharmap *charmap,
+                                 gboolean snap)
+{
+  GucharmapCharmapPrivate *priv = charmap->priv;
+
+  /* This will cause us to emit our prop notification too */
+  gucharmap_chartable_set_snap_pow2 (priv->chartable, snap);
+}
+
+/**
+ * gucharmap_charmap_get_snap_pow2:
+ * @charmap: a #GucharmapCharmap
+ *
+ * Returns whether the number of columns the character table shows is
+ * always a power of 2.
+ */
+gboolean
+gucharmap_charmap_get_snap_pow2 (GucharmapCharmap *charmap)
+{
+  GucharmapCharmapPrivate *priv = charmap->priv;
+
+  return gucharmap_chartable_get_snap_pow2 (priv->chartable);
+}

Modified: trunk/gucharmap/gucharmap-charmap.h
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.h	(original)
+++ trunk/gucharmap/gucharmap-charmap.h	Sun Jun 15 21:35:10 2008
@@ -88,6 +88,8 @@
 
 GucharmapChaptersModel * gucharmap_charmap_get_chapters_model (GucharmapCharmap       *charmap);
 
+GucharmapCodepointList * gucharmap_charmap_get_active_codepoint_list (GucharmapCharmap *charmap);
+
 GucharmapCodepointList * gucharmap_charmap_get_book_codepoint_list (GucharmapCharmap *charmap);
 
 void     gucharmap_charmap_set_chapters_visible (GucharmapCharmap *charmap,
@@ -112,6 +114,10 @@
 
 int  gucharmap_charmap_get_active_page (GucharmapCharmap *charmap);
 
+void gucharmap_charmap_set_snap_pow2 (GucharmapCharmap *charmap,
+                                      gboolean snap);
+gboolean gucharmap_charmap_get_snap_pow2 (GucharmapCharmap *charmap);
+
 /* private; FIXMEchpe remove */
 GucharmapChartable *     gucharmap_charmap_get_chartable      (GucharmapCharmap  *charmap);
 

Modified: trunk/gucharmap/gucharmap-chartable.c
==============================================================================
--- trunk/gucharmap/gucharmap-chartable.c	(original)
+++ trunk/gucharmap/gucharmap-chartable.c	Sun Jun 15 21:35:10 2008
@@ -2488,6 +2488,21 @@
 }
 
 /**
+ * gucharmap_chartable_get_snap_pow2:
+ * @chartable: a #GucharmapChartable
+ *
+ * Returns whether the number of columns the character table shows is
+ * always a power of 2.
+ */
+gboolean
+gucharmap_chartable_get_snap_pow2 (GucharmapChartable *chartable)
+{
+  GucharmapChartablePrivate *priv = chartable->priv;
+
+  return priv->snap_pow2_enabled;
+}
+
+/**
  * gucharmap_chartable_get_active_character:
  * @chartable: a #GucharmapChartable
  * @list: a #GucharmapCodepointList

Modified: trunk/gucharmap/gucharmap-chartable.h
==============================================================================
--- trunk/gucharmap/gucharmap-chartable.h	(original)
+++ trunk/gucharmap/gucharmap-chartable.h	Sun Jun 15 21:35:10 2008
@@ -80,6 +80,7 @@
 gboolean gucharmap_chartable_get_zoom_enabled (GucharmapChartable *chartable);
 void gucharmap_chartable_set_snap_pow2 (GucharmapChartable *chartable,
                                         gboolean snap);
+gboolean gucharmap_chartable_get_snap_pow2 (GucharmapChartable *chartable);
 void gucharmap_chartable_set_codepoint_list (GucharmapChartable         *chartable,
                                              GucharmapCodepointList *list);
 GucharmapCodepointList * gucharmap_chartable_get_codepoint_list (GucharmapChartable *chartable);

Modified: trunk/gucharmap/gucharmap-window.c
==============================================================================
--- trunk/gucharmap/gucharmap-window.c	(original)
+++ trunk/gucharmap/gucharmap-window.c	Sun Jun 15 21:35:10 2008
@@ -98,9 +98,8 @@
   GtkPrintOperationResult rv;
   GError *error = NULL;
 
-  chartable = gucharmap_charmap_get_chartable (guw->charmap);
-  g_object_get (chartable,
-                "codepoint-list", &codepoint_list,
+  g_object_get (guw->charmap,
+                "active-codepoint-list", &codepoint_list,
                 "font-desc", &font_desc,
                 NULL);
 
@@ -386,7 +385,7 @@
                 GucharmapWindow  *guw)
 {
   gboolean is_active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-  gucharmap_chartable_set_snap_pow2 (gucharmap_charmap_get_chartable (guw->charmap), is_active);
+  gucharmap_charmap_set_snap_pow2 (guw->charmap, is_active);
   gucharmap_settings_set_snap_pow2 (is_active);
 }
 
@@ -975,7 +974,7 @@
   gtk_widget_show (hbox);
 
   /* FIXMEchpe!! */
-  chartable =gucharmap_charmap_get_chartable (guw->charmap);
+  chartable = gucharmap_charmap_get_chartable (guw->charmap);
   g_signal_connect (chartable, "activate", G_CALLBACK (insert_character_in_text_to_copy), guw);
 
   /* Finally the statusbar */



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