gucharmap r1630 - trunk/gucharmap



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

Log:
Remove Gucharmap*Chapters, and just use the model directly.


Removed:
   trunk/gucharmap/gucharmap-block-chapters.c
   trunk/gucharmap/gucharmap-block-chapters.h
   trunk/gucharmap/gucharmap-chapters.c
   trunk/gucharmap/gucharmap-chapters.h
   trunk/gucharmap/gucharmap-script-chapters.c
   trunk/gucharmap/gucharmap-script-chapters.h
Modified:
   trunk/gucharmap/Makefile.am
   trunk/gucharmap/gucharmap-block-chapters-model.h
   trunk/gucharmap/gucharmap-chapters-model.c
   trunk/gucharmap/gucharmap-chapters-model.h
   trunk/gucharmap/gucharmap-chapters-view.c
   trunk/gucharmap/gucharmap-chapters-view.h
   trunk/gucharmap/gucharmap-charmap.c
   trunk/gucharmap/gucharmap-charmap.h
   trunk/gucharmap/gucharmap-script-chapters-model.c
   trunk/gucharmap/gucharmap-script-chapters-model.h
   trunk/gucharmap/gucharmap-search-dialog.c
   trunk/gucharmap/gucharmap-settings.c
   trunk/gucharmap/gucharmap-window.c
   trunk/gucharmap/gucharmap-window.h
   trunk/gucharmap/gucharmap.h

Modified: trunk/gucharmap/Makefile.am
==============================================================================
--- trunk/gucharmap/Makefile.am	(original)
+++ trunk/gucharmap/Makefile.am	Fri Mar 21 10:46:53 2008
@@ -25,9 +25,7 @@
 lib_LTLIBRARIES = libgucharmap.la
 
 libgucharmap_la_SOURCES = \
-	gucharmap-block-chapters.c gucharmap-block-chapters.h \
 	gucharmap-block-chapters-model.c gucharmap-block-chapters-model.h \
-	gucharmap-chapters.c gucharmap-chapters.h \
 	gucharmap-chapters-model.c gucharmap-chapters-model.h \
 	gucharmap-chapters-view.c gucharmap-chapters-view.h \
 	gucharmap-charmap.c gucharmap-charmap.h \
@@ -38,7 +36,6 @@
 	gucharmap-intl.c gucharmap-intl.h \
 	gucharmap-marshal.c gucharmap-marshal.h \
 	gucharmap-mini-fontsel.c gucharmap-mini-fontsel.h \
-	gucharmap-script-chapters.c gucharmap-script-chapters.h \
 	gucharmap-script-chapters-model.c gucharmap-script-chapters-model.h \
 	gucharmap-script-codepoint-list.c gucharmap-script-codepoint-list.h \
 	gucharmap-search-dialog.h gucharmap-search-dialog.c \
@@ -76,16 +73,13 @@
 
 libgucharmapincludedir = $(includedir)/gucharmap
 libgucharmapinclude_HEADERS = \
-	gucharmap-block-chapters.h \
 	gucharmap-block-chapters-model.h \
-	gucharmap-chapters.h \
 	gucharmap-chapters-model.h \
 	gucharmap-chapters-view.h \
 	gucharmap-charmap.h \
 	gucharmap-codepoint-list.h \
 	gucharmap.h \
 	gucharmap-mini-fontsel.h \
-	gucharmap-script-chapters.h \
 	gucharmap-script-chapters-model.h \
 	gucharmap-script-codepoint-list.h \
 	gucharmap-search-dialog.h \

Modified: trunk/gucharmap/gucharmap-block-chapters-model.h
==============================================================================
--- trunk/gucharmap/gucharmap-block-chapters-model.h	(original)
+++ trunk/gucharmap/gucharmap-block-chapters-model.h	Fri Mar 21 10:46:53 2008
@@ -23,7 +23,7 @@
 #ifndef GUCHARMAP_BLOCK_CHAPTERS_MODEL_H
 #define GUCHARMAP_BLOCK_CHAPTERS_MODEL_H
 
-#include <gucharmap/gucharmap-chapters.h>
+#include <gucharmap/gucharmap-chapters-model.h>
 
 G_BEGIN_DECLS
 

Modified: trunk/gucharmap/gucharmap-chapters-model.c
==============================================================================
--- trunk/gucharmap/gucharmap-chapters-model.c	(original)
+++ trunk/gucharmap/gucharmap-chapters-model.c	Fri Mar 21 10:46:53 2008
@@ -19,7 +19,7 @@
  */
 
 #include "config.h"
-#include "gucharmap-chapters.h"
+#include "gucharmap-chapters-model.h"
 #include "gucharmap-marshal.h"
 #include <string.h>
 

Modified: trunk/gucharmap/gucharmap-chapters-model.h
==============================================================================
--- trunk/gucharmap/gucharmap-chapters-model.h	(original)
+++ trunk/gucharmap/gucharmap-chapters-model.h	Fri Mar 21 10:46:53 2008
@@ -1,4 +1,3 @@
-/* $Id: gucharmap-chapters.h 1376 2007-12-03 21:42:48Z chpe $ */
 /*
  * Copyright (c) 2004 Noah Levitt
  * Copyright (C) 2007 Christian Persch

Modified: trunk/gucharmap/gucharmap-chapters-view.c
==============================================================================
--- trunk/gucharmap/gucharmap-chapters-view.c	(original)
+++ trunk/gucharmap/gucharmap-chapters-view.c	Fri Mar 21 10:46:53 2008
@@ -1,4 +1,3 @@
-/* $Id: gucharmap-block-chapters.c 1376 2007-12-03 21:42:48Z chpe $ */
 /*
  * Copyright (c) 2004 Noah Levitt
  *
@@ -73,6 +72,12 @@
   return g_object_new (gucharmap_chapters_view_get_type (), NULL);
 }
 
+GucharmapChaptersModel *
+gucharmap_chapters_view_get_model (GucharmapChaptersView *view)
+{
+  return view->model;
+}
+
 void
 gucharmap_chapters_view_set_model (GucharmapChaptersView *view,
                                    GucharmapChaptersModel *model)

Modified: trunk/gucharmap/gucharmap-chapters-view.h
==============================================================================
--- trunk/gucharmap/gucharmap-chapters-view.h	(original)
+++ trunk/gucharmap/gucharmap-chapters-view.h	Fri Mar 21 10:46:53 2008
@@ -1,4 +1,3 @@
-/* $Id: gucharmap-block-chapters.h 919 2005-09-08 13:35:59Z behdad $ */
 /*
  * Copyright (c) 2004 Noah Levitt
  *

Modified: trunk/gucharmap/gucharmap-charmap.c
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.c	(original)
+++ trunk/gucharmap/gucharmap-charmap.c	Fri Mar 21 10:46:53 2008
@@ -25,7 +25,6 @@
 
 #include "gucharmap-charmap.h"
 #include "gucharmap-unicode-info.h"
-#include "gucharmap-script-chapters.h"
 #include "gucharmap-intl.h"
 #include "gucharmap-marshal.h"
 #include "gucharmap-settings.h"
@@ -34,16 +33,16 @@
 {
   GtkHPaned parent;
 
+  GucharmapChaptersView *chapters_view;
   GucharmapTable *chartable;
 
-  gint _unused_1;
-  gboolean showing_details_page;
-
   GtkWidget *details;  /* GtkTextView * */
 
   GdkCursor *hand_cursor;
   GdkCursor *regular_cursor;
   gboolean hovering_over_link;
+  gboolean showing_details_page;
+  gboolean last_character_set;
 };
 
 
@@ -57,16 +56,26 @@
                          gunichar new_character);
 };
 
-gboolean _gucharmap_unicode_has_nameslist_entry (gunichar uc);
-
-enum 
+enum
 {
-  STATUS_MESSAGE = 0,
+  STATUS_MESSAGE,
   LINK_CLICKED,
   NUM_SIGNALS
 };
 
-static guint gucharmap_charmap_signals[NUM_SIGNALS] = { 0, 0 };
+enum {
+  PROP_0,
+  PROP_CHAPTERS_MODEL
+};
+
+static guint gucharmap_charmap_signals[NUM_SIGNALS];
+
+gboolean _gucharmap_unicode_has_nameslist_entry (gunichar uc);
+
+static void gucharmap_charmap_class_init (GucharmapCharmapClass *klass);
+static void gucharmap_charmap_init       (GucharmapCharmap *charmap);
+
+G_DEFINE_TYPE (GucharmapCharmap, gucharmap_charmap, GTK_TYPE_HPANED)
 
 static void
 status_message (GucharmapCharmap *charmap, const gchar *message)
@@ -76,36 +85,65 @@
 }
 
 static void 
-charmap_finalize (GObject *object)
+gucharmap_charmap_finalize (GObject *object)
 {
   GucharmapCharmap *charmap = GUCHARMAP_CHARMAP (object);
 
   gdk_cursor_unref (charmap->hand_cursor);
   gdk_cursor_unref (charmap->regular_cursor);
+
+  G_OBJECT_CLASS (gucharmap_charmap_parent_class)->finalize (object);
+}
+
+static void
+gucharmap_charmap_set_property (GObject *object,
+                                guint prop_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+  GucharmapCharmap *charmap = GUCHARMAP_CHARMAP (object);
+
+  switch (prop_id) {
+    case PROP_CHAPTERS_MODEL:
+      gucharmap_charmap_set_chapters_model (charmap, g_value_get_object (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
 }
 
 static void
 gucharmap_charmap_class_init (GucharmapCharmapClass *clazz)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (clazz);
+
+  _gucharmap_intl_ensure_initialized ();
+
+  object_class->set_property = gucharmap_charmap_set_property;
+  object_class->finalize = gucharmap_charmap_finalize;
+
   clazz->status_message = NULL;
 
   gucharmap_charmap_signals[STATUS_MESSAGE] =
-      g_signal_new ("status-message", gucharmap_charmap_get_type (), 
+      g_signal_new (I_("status-message"), gucharmap_charmap_get_type (),
                     G_SIGNAL_RUN_FIRST,
                     G_STRUCT_OFFSET (GucharmapCharmapClass, status_message),
                     NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE,
                     1, G_TYPE_STRING);
 
   gucharmap_charmap_signals[LINK_CLICKED] =
-      g_signal_new ("link-clicked", gucharmap_charmap_get_type (), 
+      g_signal_new (I_("link-clicked"), gucharmap_charmap_get_type (),
                     G_SIGNAL_RUN_FIRST,
                     G_STRUCT_OFFSET (GucharmapCharmapClass, link_clicked),
                     NULL, NULL, _gucharmap_marshal_VOID__UINT_UINT, G_TYPE_NONE, 
                     2, G_TYPE_UINT, G_TYPE_UINT);
 
-  G_OBJECT_CLASS (clazz)->finalize = charmap_finalize;
-
-  _gucharmap_intl_ensure_initialized ();
+  g_object_class_install_property (object_class,
+                                   PROP_CHAPTERS_MODEL,
+                                   g_param_spec_object ("chapters-model", NULL, NULL,
+                                                        GUCHARMAP_TYPE_CHAPTERS_MODEL,
+                                                        G_PARAM_WRITABLE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 }
 
 static void
@@ -839,44 +877,62 @@
 }
 
 static void
-chapter_changed (GucharmapChapters *chapters,
-                 GucharmapCharmap  *charmap)
+chapters_view_selection_changed_cb (GtkTreeSelection *selection,
+                                    GucharmapCharmap *charmap)
 {
-  gucharmap_table_set_codepoint_list (charmap->chartable, gucharmap_chapters_get_codepoint_list (chapters));
+  GucharmapCodepointList *codepoint_list;
+  GtkTreeIter iter;
+
+  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+    return;
+
+  codepoint_list = gucharmap_chapters_view_get_codepoint_list (charmap->chapters_view);
+  gucharmap_table_set_codepoint_list (charmap->chartable, codepoint_list);
+  // FIXME unref
 }
 
 static void
 gucharmap_charmap_init (GucharmapCharmap *charmap)
 {
-}
-
-GtkWidget *
-gucharmap_charmap_new (GucharmapChapters *chapters)
-{
-  GucharmapCharmap *charmap = g_object_new (gucharmap_charmap_get_type (), NULL);
+  GtkWidget *scrolled_window, *view;
+  GtkTreeSelection *selection;
   GtkWidget *pane2;
 
+  /* FIXME: move this to realize */
   charmap->hand_cursor = gdk_cursor_new (GDK_HAND2);
   charmap->regular_cursor = gdk_cursor_new (GDK_XTERM);
   charmap->hovering_over_link = FALSE;
-  gtk_widget_show (GTK_WIDGET (chapters));
 
-  g_signal_connect (G_OBJECT (chapters), "changed", G_CALLBACK (chapter_changed), charmap);
+  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+                                       GTK_SHADOW_ETCHED_IN);
+
+  view = gucharmap_chapters_view_new ();
+  charmap->chapters_view = GUCHARMAP_CHAPTERS_VIEW (view);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+  g_signal_connect (selection, "changed",
+                    G_CALLBACK (chapters_view_selection_changed_cb), charmap);
+
+  gtk_container_add (GTK_CONTAINER (scrolled_window), view);
+  gtk_widget_show (view);
+  gtk_paned_pack1 (GTK_PANED (charmap), scrolled_window, FALSE, TRUE);
+  gtk_widget_show (scrolled_window);
 
   pane2 = make_chartable_pane (charmap);
-  gtk_paned_pack1 (GTK_PANED (charmap), GTK_WIDGET (chapters), FALSE, TRUE);
   gtk_paned_pack2 (GTK_PANED (charmap), pane2, TRUE, TRUE);
   g_signal_connect (pane2, "switch-page",
                     G_CALLBACK (notebook_switch_page), charmap);
-
-  gucharmap_charmap_go_to_character (charmap, gucharmap_settings_get_last_char ());
-
-  return GTK_WIDGET (charmap);
 }
 
-G_DEFINE_TYPE (GucharmapCharmap, gucharmap_charmap, GTK_TYPE_HPANED)
+GtkWidget *
+gucharmap_charmap_new (void)
+{
+  return g_object_new (gucharmap_charmap_get_type (), NULL);
+}
 
-void 
+void
 gucharmap_charmap_set_font (GucharmapCharmap *charmap, 
                             const gchar *font_name)
 {
@@ -887,12 +943,13 @@
 gucharmap_charmap_go_to_character (GucharmapCharmap *charmap, 
                                    gunichar          wc)
 {
-  GucharmapChapters *chapters = gucharmap_charmap_get_chapters (charmap);
   gboolean status;
 
-  status = gucharmap_chapters_go_to_character (chapters, wc);
+  /* FIXME: move wc validation up here? */
+
+  status = gucharmap_chapters_view_select_character (charmap->chapters_view, wc);
   if (!status)
-    g_warning ("gucharmap_chapters_go_to_character failed (%04X)\n", wc);
+    g_warning ("gucharmap_chapters_view_select_character failed (U+%04X)\n", wc);
 
   if (wc <= UNICHAR_MAX)
     gucharmap_table_set_active_character (charmap->chartable, wc);
@@ -911,20 +968,41 @@
 }
 
 void
-gucharmap_charmap_set_chapters (GucharmapCharmap  *charmap,
-                                GucharmapChapters *chapters)
+gucharmap_charmap_set_chapters_model (GucharmapCharmap  *charmap,
+                                      GucharmapChaptersModel *model)
 {
-  gtk_container_remove (GTK_CONTAINER (charmap), GTK_PANED (charmap)->child1);
-  gtk_paned_pack1 (GTK_PANED (charmap), GTK_WIDGET (chapters), FALSE, TRUE);
-  g_signal_connect (G_OBJECT (chapters), "changed", G_CALLBACK (chapter_changed), charmap);
-  gtk_widget_show (GTK_WIDGET (chapters));
+  gunichar wc;
+
+  gucharmap_chapters_view_set_model (charmap->chapters_view, model);
+  if (!model)
+    return;
 
-  /* Keep the same character selected as before */
-  gucharmap_charmap_go_to_character (charmap, gucharmap_table_get_active_character (charmap->chartable));
+  if (charmap->last_character_set)
+    wc = gucharmap_table_get_active_character (charmap->chartable);
+  else
+    wc = gucharmap_settings_get_last_char ();
+
+  gucharmap_charmap_go_to_character (charmap, wc);
+  charmap->last_character_set = TRUE;
 }
 
-GucharmapChapters *
-gucharmap_charmap_get_chapters (GucharmapCharmap  *charmap)
+GucharmapChaptersModel *
+gucharmap_charmap_get_chapters_model (GucharmapCharmap *charmap)
 {
-  return GUCHARMAP_CHAPTERS (GTK_PANED (charmap)->child1);
+  return gucharmap_chapters_view_get_model (charmap->chapters_view);
 }
+
+GucharmapChaptersView *
+gucharmap_charmap_get_chapters_view  (GucharmapCharmap *charmap)
+{
+  return charmap->chapters_view;
+}
+
+GucharmapCodepointList *
+gucharmap_charmap_get_book_codepoint_list (GucharmapCharmap *charmap)
+{
+  GucharmapCodepointList *codepoint_list;
+  codepoint_list = (GucharmapCodepointList *) gucharmap_chapters_view_get_book_codepoint_list (charmap->chapters_view);
+  return g_object_ref (codepoint_list);
+}
+

Modified: trunk/gucharmap/gucharmap-charmap.h
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.h	(original)
+++ trunk/gucharmap/gucharmap-charmap.h	Fri Mar 21 10:46:53 2008
@@ -21,7 +21,8 @@
 
 #include <gtk/gtk.h>
 #include <gucharmap/gucharmap-table.h>
-#include <gucharmap/gucharmap-chapters.h>
+#include <gucharmap/gucharmap-chapters-model.h>
+#include <gucharmap/gucharmap-chapters-view.h>
 
 G_BEGIN_DECLS
 
@@ -41,19 +42,23 @@
 typedef struct _GucharmapCharmapClass GucharmapCharmapClass;
 
 GType                 gucharmap_charmap_get_type           (void);
-GtkWidget *           gucharmap_charmap_new                (GucharmapChapters *chapters);
+
+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);
 GucharmapTable *      gucharmap_charmap_get_chartable      (GucharmapCharmap  *charmap);
-void                  gucharmap_charmap_set_chapters       (GucharmapCharmap  *charmap,
-                                                            GucharmapChapters *chapters);
-GucharmapChapters *   gucharmap_charmap_get_chapters       (GucharmapCharmap  *charmap);
 
+GucharmapChaptersView *  gucharmap_charmap_get_chapters_view  (GucharmapCharmap       *charmap);
+
+void                     gucharmap_charmap_set_chapters_model (GucharmapCharmap       *charmap,
+                                                               GucharmapChaptersModel *model);
 
+GucharmapChaptersModel * gucharmap_charmap_get_chapters_model (GucharmapCharmap       *charmap);
 
-GucharmapTable *gucharmap_charmap_get_chartable (GucharmapCharmap *charmap);
+GucharmapCodepointList * gucharmap_charmap_get_book_codepoint_list (GucharmapCharmap *charmap);
 
 G_END_DECLS
 

Modified: trunk/gucharmap/gucharmap-script-chapters-model.c
==============================================================================
--- trunk/gucharmap/gucharmap-script-chapters-model.c	(original)
+++ trunk/gucharmap/gucharmap-script-chapters-model.c	Fri Mar 21 10:46:53 2008
@@ -26,7 +26,6 @@
 #include "gucharmap-unicode-info.h"
 #include "gucharmap-script-chapters-model.h"
 #include "gucharmap-script-codepoint-list.h"
-#include "gucharmap-chapters.h"
 #include "gucharmap-settings.h"
 
 static void

Modified: trunk/gucharmap/gucharmap-script-chapters-model.h
==============================================================================
--- trunk/gucharmap/gucharmap-script-chapters-model.h	(original)
+++ trunk/gucharmap/gucharmap-script-chapters-model.h	Fri Mar 21 10:46:53 2008
@@ -21,7 +21,7 @@
 #ifndef GUCHARMAP_SCRIPT_CHAPTERS_MODEL_H
 #define GUCHARMAP_SCRIPT_CHAPTERS_MODEL_H
 
-#include <gucharmap/gucharmap-chapters.h>
+#include <gucharmap/gucharmap-chapters-model.h>
 
 G_BEGIN_DECLS
 

Modified: trunk/gucharmap/gucharmap-search-dialog.c
==============================================================================
--- trunk/gucharmap/gucharmap-search-dialog.c	(original)
+++ trunk/gucharmap/gucharmap-search-dialog.c	Fri Mar 21 10:46:53 2008
@@ -630,7 +630,7 @@
   gdk_cursor_unref (cursor);
 
 
-  list = (GucharmapCodepointList *) gucharmap_chapters_get_book_codepoint_list (gucharmap_charmap_get_chapters (priv->guw->charmap));
+  list = gucharmap_charmap_get_book_codepoint_list (priv->guw->charmap);
 
   if (priv->search_state == NULL
       || list != priv->search_state->list
@@ -664,6 +664,8 @@
 
   g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) idle_search, search_dialog, (GDestroyNotify) search_completed);
   g_signal_emit (search_dialog, gucharmap_search_dialog_signals[SEARCH_START], 0);
+
+  g_object_unref (list);
 }
 
 void

Modified: trunk/gucharmap/gucharmap-settings.c
==============================================================================
--- trunk/gucharmap/gucharmap-settings.c	(original)
+++ trunk/gucharmap/gucharmap-settings.c	Fri Mar 21 10:46:53 2008
@@ -23,7 +23,7 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
-#include "gucharmap-chapters.h"
+#include "gucharmap-chapters-model.h"
 #include "gucharmap-settings.h"
 #include "gucharmap-intl.h"
 #if HAVE_GCONF

Modified: trunk/gucharmap/gucharmap-window.c
==============================================================================
--- trunk/gucharmap/gucharmap-window.c	(original)
+++ trunk/gucharmap/gucharmap-window.c	Fri Mar 21 10:46:53 2008
@@ -25,8 +25,8 @@
 #include "gucharmap-window.h"
 #include "gucharmap-mini-fontsel.h"
 #include "gucharmap-unicode-info.h"
-#include "gucharmap-script-chapters.h"
-#include "gucharmap-block-chapters.h"
+#include "gucharmap-script-chapters-model.h"
+#include "gucharmap-block-chapters-model.h"
 #include "gucharmap-intl.h"
 #include "gucharmap-search-dialog.h"
 #include "gucharmap-settings.h"
@@ -481,16 +481,14 @@
 next_chapter (GtkAction       *action,
               GucharmapWindow *guw)
 {
-  GucharmapChapters *chapters = gucharmap_charmap_get_chapters (guw->charmap);
-  gucharmap_chapters_next (chapters);
+  gucharmap_chapters_view_next (gucharmap_charmap_get_chapters_view (guw->charmap));
 }
 
 static void
 prev_chapter (GtkAction       *action,
               GucharmapWindow *guw)
 {
-  GucharmapChapters *chapters = gucharmap_charmap_get_chapters (guw->charmap);
-  gucharmap_chapters_previous (chapters);
+  gucharmap_chapters_view_previous (gucharmap_charmap_get_chapters_view (guw->charmap));
 }
 
 static void
@@ -513,6 +511,32 @@
 };
 
 static void
+set_chapters_model (GucharmapWindow *guw,
+                    ChaptersMode mode)
+{
+  GucharmapChaptersModel *model = NULL;
+
+  switch (mode)
+    {
+      case CHAPTERS_SCRIPT:
+      	model = gucharmap_script_chapters_model_new ();
+	chapters_set_labels (_("Next Script"), _("Previous Script"), guw);
+	break;
+      
+      case CHAPTERS_BLOCK:
+      	model = gucharmap_block_chapters_model_new ();
+	chapters_set_labels (_("Next Block"), _("Previous Block"), guw);
+	break;
+      
+      default:
+        g_assert_not_reached ();
+    }
+
+  gucharmap_charmap_set_chapters_model (guw->charmap, model);
+  g_object_unref (model);
+}
+
+static void
 view_by (GtkAction        *action,
 	 GtkRadioAction   *radioaction,
          GucharmapWindow  *guw)
@@ -522,14 +546,10 @@
   switch (gtk_radio_action_get_current_value (radioaction))
     {
       case VIEW_BY_SCRIPT:
-      	gucharmap_charmap_set_chapters (guw->charmap, GUCHARMAP_CHAPTERS (gucharmap_script_chapters_new ()));
-	chapters_set_labels (_("Next Script"), _("Previous Script"), guw);
         mode = CHAPTERS_SCRIPT;
 	break;
       
       case VIEW_BY_BLOCK:
-        gucharmap_charmap_set_chapters (guw->charmap, GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()));
-	chapters_set_labels (_("Next Block"), _("Previous Block"), guw);
         mode = CHAPTERS_BLOCK;
 	break;
       
@@ -537,6 +557,7 @@
         g_assert_not_reached ();
     }
 
+  set_chapters_model (guw, mode);
   gucharmap_settings_set_chapters_mode (mode);
 }
 
@@ -854,25 +875,11 @@
 pack_stuff_in_window (GucharmapWindow *guw)
 {
   GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-  GtkWidget *chapters;
   GtkWidget *big_vbox;
   GtkWidget *hbox;
   GucharmapTable *chartable;
 
-  switch (priv->chapters_mode)
-    {
-      case CHAPTERS_SCRIPT:
-        chapters = gucharmap_script_chapters_new ();
-        break;
-
-      case CHAPTERS_BLOCK:
-        chapters = gucharmap_block_chapters_new ();
-        break;
-
-      default:
-        g_assert_not_reached ();
-    }
-  guw->charmap = GUCHARMAP_CHARMAP (gucharmap_charmap_new (GUCHARMAP_CHAPTERS (chapters)));
+  guw->charmap = GUCHARMAP_CHARMAP (gucharmap_charmap_new ());
 
   big_vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (guw), big_vbox);
@@ -920,6 +927,8 @@
   g_signal_connect (guw->charmap, "status-message", G_CALLBACK (status_message), guw);
 
   gtk_widget_show (big_vbox);
+
+  set_chapters_model (guw, priv->chapters_mode);
 }
 
 static void

Modified: trunk/gucharmap/gucharmap-window.h
==============================================================================
--- trunk/gucharmap/gucharmap-window.h	(original)
+++ trunk/gucharmap/gucharmap-window.h	Fri Mar 21 10:46:53 2008
@@ -1,4 +1,3 @@
-/* $Id$ */
 /*
  * Copyright (c) 2004 Noah Levitt
  *
@@ -17,7 +16,6 @@
  * 59 Temple Place, Suite 330, Boston, MA 02110-1301  USA
  */
 
-
 #ifndef GUCHARMAP_WINDOW_H
 #define GUCHARMAP_WINDOW_H
 

Modified: trunk/gucharmap/gucharmap.h
==============================================================================
--- trunk/gucharmap/gucharmap.h	(original)
+++ trunk/gucharmap/gucharmap.h	Fri Mar 21 10:46:53 2008
@@ -27,9 +27,9 @@
 #include <gucharmap/gucharmap-mini-fontsel.h>
 #include <gucharmap/gucharmap-codepoint-list.h>
 #include <gucharmap/gucharmap-script-codepoint-list.h>
-#include <gucharmap/gucharmap-chapters.h>
-#include <gucharmap/gucharmap-block-chapters.h>
-#include <gucharmap/gucharmap-script-chapters.h>
+#include <gucharmap/gucharmap-chapters-model.h>
+#include <gucharmap/gucharmap-block-chapters-model.h>
+#include <gucharmap/gucharmap-script-chapters-model.h>
 #include <gucharmap/gucharmap-search-dialog.h>
 
 #endif /* #ifndef GUCHARMAP_H */



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