gucharmap r1673 - trunk/gucharmap
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gucharmap r1673 - trunk/gucharmap
- Date: Fri, 21 Mar 2008 10:54:10 +0000 (GMT)
Author: chpe
Date: Fri Mar 21 10:54:10 2008
New Revision: 1673
URL: http://svn.gnome.org/viewvc/gucharmap?rev=1673&view=rev
Log:
Split the window, mini-fontsel, search-dialog and settings out of the library. They aren't
generic enough, but currently only useful for gucharmap itself.
Also gets rid of the gconf dependency on libgucharmap.
Modified:
trunk/gucharmap/Makefile.am
trunk/gucharmap/gucharmap-block-chapters-model.c
trunk/gucharmap/gucharmap-chapters-view.c
trunk/gucharmap/gucharmap-charmap.c
trunk/gucharmap/gucharmap-charmap.h
trunk/gucharmap/gucharmap-init.c
trunk/gucharmap/gucharmap-mini-fontsel.c
trunk/gucharmap/gucharmap-mini-fontsel.h
trunk/gucharmap/gucharmap-private.h
trunk/gucharmap/gucharmap-script-chapters-model.c
trunk/gucharmap/gucharmap-search-dialog.c
trunk/gucharmap/gucharmap-search-dialog.h
trunk/gucharmap/gucharmap-settings.c
trunk/gucharmap/gucharmap-settings.h
trunk/gucharmap/gucharmap-types.h
trunk/gucharmap/gucharmap-unicode-info.c
trunk/gucharmap/gucharmap-unicode-info.h
trunk/gucharmap/gucharmap-window.c
trunk/gucharmap/gucharmap-window.h
trunk/gucharmap/gucharmap.h
trunk/gucharmap/main.c
Modified: trunk/gucharmap/Makefile.am
==============================================================================
--- trunk/gucharmap/Makefile.am (original)
+++ trunk/gucharmap/Makefile.am Fri Mar 21 10:54:10 2008
@@ -35,14 +35,10 @@
gucharmap-codepoint-list.c gucharmap-codepoint-list.h \
gucharmap-init.c gucharmap-init.h \
gucharmap-marshal.c gucharmap-marshal.h \
- gucharmap-mini-fontsel.c gucharmap-mini-fontsel.h \
- gucharmap-private.h \
+ gucharmap-private.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 \
- gucharmap-settings.h gucharmap-settings.c \
gucharmap-unicode-info.c gucharmap-unicode-info.h \
- gucharmap-window.c gucharmap-window.h \
unicode-blocks.h unicode-categories.h unicode-names.h \
unicode-nameslist.h unicode-scripts.h unicode-unihan.h \
$(NULL)
@@ -58,7 +54,6 @@
libgucharmap_la_CFLAGS = \
$(PANGO_CFLAGS) \
$(GTK_CFLAGS) \
- $(GCONF_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS)
@@ -69,7 +64,6 @@
libgucharmap_la_LIBADD = \
$(GTK_LIBS) \
- $(GCONF_LIBS) \
$(INTL_LIBS)
libgucharmapincludedir = $(includedir)/gucharmap-2/gucharmap
@@ -82,19 +76,25 @@
gucharmap-codepoint-list.h \
gucharmap.h \
gucharmap-init.h \
- gucharmap-mini-fontsel.h \
gucharmap-script-chapters-model.h \
gucharmap-script-codepoint-list.h \
- gucharmap-search-dialog.h \
- gucharmap-settings.h \
gucharmap-types.h \
gucharmap-unicode-info.h \
- gucharmap-window.h \
$(NULL)
bin_PROGRAMS = gucharmap
-gucharmap_SOURCES = main.c
+gucharmap_SOURCES = \
+ gucharmap-mini-fontsel.c \
+ gucharmap-mini-fontsel.h \
+ gucharmap-search-dialog.c \
+ gucharmap-search-dialog.h \
+ gucharmap-settings.c \
+ gucharmap-settings.h \
+ gucharmap-window.c \
+ gucharmap-window.h \
+ main.c \
+ $(NULL)
gucharmap_CPPFLAGS = \
-I$(top_srcdir) \
Modified: trunk/gucharmap/gucharmap-block-chapters-model.c
==============================================================================
--- trunk/gucharmap/gucharmap-block-chapters-model.c (original)
+++ trunk/gucharmap/gucharmap-block-chapters-model.c Fri Mar 21 10:54:10 2008
@@ -20,7 +20,6 @@
#include <config.h>
#include <glib/gi18n-lib.h>
#include "gucharmap-block-chapters-model.h"
-#include "gucharmap-settings.h"
#include "unicode-blocks.h"
#include "gucharmap-private.h"
Modified: trunk/gucharmap/gucharmap-chapters-view.c
==============================================================================
--- trunk/gucharmap/gucharmap-chapters-view.c (original)
+++ trunk/gucharmap/gucharmap-chapters-view.c Fri Mar 21 10:54:10 2008
@@ -19,7 +19,7 @@
#include <config.h>
#include <string.h>
#include <gtk/gtk.h>
-#include "gucharmap-settings.h"
+#include "gucharmap-unicode-info.h"
#include "gucharmap-chapters-view.h"
#include "gucharmap-private.h"
#include "unicode-blocks.h"
@@ -255,5 +255,5 @@
gucharmap_chapters_view_select_locale (GucharmapChaptersView *view)
{
return gucharmap_chapters_view_select_character (view,
- gucharmap_settings_get_locale_character ());
+ gucharmap_unicode_get_locale_character ());
}
Modified: trunk/gucharmap/gucharmap-charmap.c
==============================================================================
--- trunk/gucharmap/gucharmap-charmap.c (original)
+++ trunk/gucharmap/gucharmap-charmap.c Fri Mar 21 10:54:10 2008
@@ -27,7 +27,6 @@
#include "gucharmap-charmap.h"
#include "gucharmap-unicode-info.h"
#include "gucharmap-marshal.h"
-#include "gucharmap-settings.h"
#include "gucharmap-private.h"
enum
@@ -39,13 +38,13 @@
enum {
PROP_0,
- PROP_CHAPTERS_MODEL
+ PROP_CHAPTERS_MODEL,
+ PROP_ACTIVE_CHAPTER,
+ PROP_ACTIVE_CHARACTER,
};
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);
@@ -66,6 +65,30 @@
}
static void
+gucharmap_charmap_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GucharmapCharmap *charmap = GUCHARMAP_CHARMAP (object);
+
+ switch (prop_id) {
+ case PROP_CHAPTERS_MODEL:
+ g_value_set_object (value, gucharmap_charmap_get_chapters_model (charmap));
+ break;
+ case PROP_ACTIVE_CHAPTER:
+ g_value_take_string (value, gucharmap_chapters_view_get_selected (charmap->chapters_view));
+ break;
+ case PROP_ACTIVE_CHARACTER:
+ g_value_set_uint (value, gucharmap_charmap_get_active_character (charmap));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
gucharmap_charmap_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -77,6 +100,13 @@
case PROP_CHAPTERS_MODEL:
gucharmap_charmap_set_chapters_model (charmap, g_value_get_object (value));
break;
+ case PROP_ACTIVE_CHAPTER:
+ gucharmap_chapters_view_set_selected (charmap->chapters_view,
+ g_value_get_string (value));
+ break;
+ case PROP_ACTIVE_CHARACTER:
+ gucharmap_charmap_set_active_character (charmap, g_value_get_uint (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -88,6 +118,7 @@
{
GObjectClass *object_class = G_OBJECT_CLASS (clazz);
+ object_class->get_property = gucharmap_charmap_get_property;
object_class->set_property = gucharmap_charmap_set_property;
object_class->finalize = gucharmap_charmap_finalize;
@@ -105,11 +136,39 @@
NULL, NULL, _gucharmap_marshal_VOID__UINT_UINT, G_TYPE_NONE,
2, G_TYPE_UINT, G_TYPE_UINT);
- 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));
+ 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));
+
+ g_object_class_install_property
+ (object_class,
+ PROP_ACTIVE_CHAPTER,
+ g_param_spec_string ("active-chapter", NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property
+ (object_class,
+ PROP_ACTIVE_CHARACTER,
+ g_param_spec_uint ("active-character", NULL, NULL,
+ 0,
+ UNICHAR_MAX,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
}
static void
@@ -548,13 +607,6 @@
#endif /* #if ENABLE_UNIHAN */
}
-static gboolean
-gucharmap_active_char_save (gpointer last_char)
-{
- gucharmap_settings_set_last_char (GPOINTER_TO_UINT (last_char));
- return FALSE;
-}
-
static void
chartable_status_message (GucharmapCharmap *charmap,
const gchar *message)
@@ -576,11 +628,12 @@
wc = gucharmap_chartable_get_active_character (charmap->chartable);
+ /* Forward the notification */
+ g_object_notify (G_OBJECT (charmap), "active-character");
+
if (charmap->showing_details_page)
set_details (charmap, wc);
- g_idle_add (gucharmap_active_char_save, GUINT_TO_POINTER(wc));
-
gs = g_string_sized_new (256);
g_string_append_printf (gs, "U+%4.4X %s", wc,
gucharmap_get_unicode_name (wc));
@@ -634,7 +687,7 @@
g_signal_emit (charmap, gucharmap_charmap_signals[LINK_CLICKED], 0,
gucharmap_chartable_get_active_character (charmap->chartable),
uc);
- gucharmap_charmap_go_to_character (charmap, uc);
+ gucharmap_charmap_set_active_character (charmap, uc);
break;
}
}
@@ -825,6 +878,8 @@
codepoint_list = gucharmap_chapters_view_get_codepoint_list (charmap->chapters_view);
gucharmap_chartable_set_codepoint_list (charmap->chartable, codepoint_list);
g_object_unref (codepoint_list);
+
+ g_object_notify (G_OBJECT (charmap), "active-chapter");
}
static void
@@ -995,19 +1050,37 @@
}
void
-gucharmap_charmap_go_to_character (GucharmapCharmap *charmap,
- gunichar wc)
+gucharmap_charmap_set_active_character (GucharmapCharmap *charmap,
+ gunichar wc)
{
- gboolean status;
-
- /* FIXME: move wc validation up here? */
+ if (wc > UNICHAR_MAX)
+ return;
- status = gucharmap_chapters_view_select_character (charmap->chapters_view, wc);
- if (!status)
+ if (!gucharmap_chapters_view_select_character (charmap->chapters_view, wc)) {
g_warning ("gucharmap_chapters_view_select_character failed (U+%04X)\n", wc);
+ return;
+ }
+
+ gucharmap_chartable_set_active_character (charmap->chartable, wc);
+}
- if (wc <= UNICHAR_MAX)
- gucharmap_chartable_set_active_character (charmap->chartable, wc);
+gunichar
+gucharmap_charmap_get_active_character (GucharmapCharmap *charmap)
+{
+ return gucharmap_chartable_get_active_character (charmap->chartable);
+}
+
+void
+gucharmap_charmap_set_active_chapter (GucharmapCharmap *charmap,
+ const gchar *chapter)
+{
+ gucharmap_chapters_view_set_selected (charmap->chapters_view, chapter);
+}
+
+char *
+gucharmap_charmap_get_active_chapter (GucharmapCharmap *charmap)
+{
+ return gucharmap_chapters_view_get_selected (charmap->chapters_view);
}
/**
@@ -1026,19 +1099,27 @@
gucharmap_charmap_set_chapters_model (GucharmapCharmap *charmap,
GucharmapChaptersModel *model)
{
+ GObject *object = G_OBJECT (charmap);
gunichar wc;
+ g_object_freeze_notify (object);
+
+ g_object_notify (G_OBJECT (charmap), "chapters-model");
+
gucharmap_chapters_view_set_model (charmap->chapters_view, model);
- if (!model)
+ if (!model) {
+ g_object_thaw_notify (object);
return;
+ }
- if (charmap->last_character_set)
+ if (charmap->last_character_set) {
wc = gucharmap_chartable_get_active_character (charmap->chartable);
- else
- wc = gucharmap_settings_get_last_char ();
+ gucharmap_charmap_set_active_character (charmap, wc);
+ }
- gucharmap_charmap_go_to_character (charmap, wc);
charmap->last_character_set = TRUE;
+
+ g_object_thaw_notify (object);
}
GucharmapChaptersModel *
@@ -1060,4 +1141,3 @@
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:54:10 2008
@@ -46,8 +46,13 @@
GtkWidget * gucharmap_charmap_new (void);
-void gucharmap_charmap_go_to_character (GucharmapCharmap *charmap,
- gunichar uc);
+void gucharmap_charmap_set_active_character (GucharmapCharmap *charmap,
+ gunichar uc);
+gunichar gucharmap_charmap_get_active_character (GucharmapCharmap *charmap);
+
+void gucharmap_charmap_set_active_chapter (GucharmapCharmap *charmap,
+ const gchar *chapter);
+char * gucharmap_charmap_get_active_chapter (GucharmapCharmap *charmap);
void gucharmap_charmap_set_font (GucharmapCharmap *charmap,
const gchar *font_name);
Modified: trunk/gucharmap/gucharmap-init.c
==============================================================================
--- trunk/gucharmap/gucharmap-init.c (original)
+++ trunk/gucharmap/gucharmap-init.c Fri Mar 21 10:54:10 2008
@@ -21,7 +21,6 @@
#include <glib/gi18n-lib.h>
#include "gucharmap-init.h"
-#include "gucharmap-settings.h"
static guint initialization_count;
@@ -38,8 +37,6 @@
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
#endif /* #ifdef ENABLE_NLS */
-
- gucharmap_settings_initialize ();
}
void gucharmap_shutdown (void)
@@ -48,6 +45,4 @@
if (--initialization_count > 0)
return;
-
- gucharmap_settings_shutdown ();
}
Modified: trunk/gucharmap/gucharmap-mini-fontsel.c
==============================================================================
--- trunk/gucharmap/gucharmap-mini-fontsel.c (original)
+++ trunk/gucharmap/gucharmap-mini-fontsel.c Fri Mar 21 10:54:10 2008
@@ -23,8 +23,8 @@
#include <stdlib.h>
#include <string.h>
#include "gucharmap-mini-fontsel.h"
-#include "gucharmap-marshal.h"
-#include "gucharmap-private.h"
+
+#define I_(string) g_intern_static_string (string)
enum
{
Modified: trunk/gucharmap/gucharmap-mini-fontsel.h
==============================================================================
--- trunk/gucharmap/gucharmap-mini-fontsel.h (original)
+++ trunk/gucharmap/gucharmap-mini-fontsel.h Fri Mar 21 10:54:10 2008
@@ -16,15 +16,10 @@
* 59 Temple Place, Suite 330, Boston, MA 02110-1301 USA
*/
-#if !defined (__GUCHARMAP_GUCHARMAP_H_INSIDE__) && !defined (GUCHARMAP_COMPILATION)
-#error "Only <gucharmap/gucharmap.h> can be included directly."
-#endif
-
#ifndef GUCHARMAP_MINI_FONTSEL_H
#define GUCHARMAP_MINI_FONTSEL_H
#include <gtk/gtk.h>
-#include <gucharmap/gucharmap-types.h>
G_BEGIN_DECLS
@@ -39,6 +34,34 @@
#define GUCHARMAP_IS_MINI_FONT_SELECTION(obj) \
G_TYPE_CHECK_INSTANCE_TYPE ((obj), gucharmap_mini_font_selection_get_type ())
+typedef struct _GucharmapMiniFontSelection GucharmapMiniFontSelection;
+typedef struct _GucharmapMiniFontSelectionClass GucharmapMiniFontSelectionClass;
+
+struct _GucharmapMiniFontSelection
+{
+ GtkHBox parent;
+
+ GtkListStore *family_store;
+ GtkWidget *family; /* combo box */
+ GtkWidget *bold; /* toggle button*/
+ GtkWidget *italic; /* toggle button*/
+
+ GtkObject *size_adj;
+ GtkWidget *size; /* spin button */
+
+ PangoFontDescription *font_desc;
+
+ gint default_size;
+};
+
+struct _GucharmapMiniFontSelectionClass
+{
+ GtkHBoxClass parent_class;
+
+ void (* changed) (GucharmapMiniFontSelection *fontsel);
+};
+
+
GType gucharmap_mini_font_selection_get_type (void);
GtkWidget * gucharmap_mini_font_selection_new (void);
gboolean gucharmap_mini_font_selection_set_font_name (GucharmapMiniFontSelection *fontsel,
Modified: trunk/gucharmap/gucharmap-private.h
==============================================================================
--- trunk/gucharmap/gucharmap-private.h (original)
+++ trunk/gucharmap/gucharmap-private.h Fri Mar 21 10:54:10 2008
@@ -26,6 +26,8 @@
/* The last unicode character we support */
#define UNICHAR_MAX (0x0010FFFFUL)
+gboolean _gucharmap_unicode_has_nameslist_entry (gunichar uc);
+
struct _GucharmapChaptersModel
{
@@ -222,31 +224,6 @@
};
-struct _GucharmapMiniFontSelection
-{
- GtkHBox parent;
-
- GtkListStore *family_store;
- GtkWidget *family; /* combo box */
- GtkWidget *bold; /* toggle button*/
- GtkWidget *italic; /* toggle button*/
-
- GtkObject *size_adj;
- GtkWidget *size; /* spin button */
-
- PangoFontDescription *font_desc;
-
- gint default_size;
-};
-
-struct _GucharmapMiniFontSelectionClass
-{
- GtkHBoxClass parent_class;
-
- void (* changed) (GucharmapMiniFontSelection *fontsel);
-};
-
-
struct _GucharmapScriptChaptersModel
{
GucharmapChaptersModel parent;
@@ -269,31 +246,14 @@
};
-struct _GucharmapSearchDialog
+struct _GucharmapFontCodepointList
{
- GtkDialog parent;
-};
-
-struct _GucharmapSearchDialogClass
-{
- GtkDialogClass parent_class;
-
- /* signals */
- void (* search_start) (void);
- void (* search_finish) (gunichar found_char);
-};
-
-
-struct _GucharmapWindow
-{
- GtkWindow parent;
+ GucharmapCodepointList parent;
- GucharmapCharmap *charmap;
+ PangoCoverage *coverage;
};
-struct _GucharmapWindowClass
+struct _GucharmapFontCodepointListClass
{
- GtkWindowClass parent_class;
+ GucharmapCodepointListClass parent_class;
};
-
-GdkCursor * _gucharmap_window_progress_cursor (void);
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:54:10 2008
@@ -26,7 +26,6 @@
#include "gucharmap-unicode-info.h"
#include "gucharmap-script-chapters-model.h"
#include "gucharmap-script-codepoint-list.h"
-#include "gucharmap-settings.h"
#include "gucharmap-private.h"
static void
Modified: trunk/gucharmap/gucharmap-search-dialog.c
==============================================================================
--- trunk/gucharmap/gucharmap-search-dialog.c (original)
+++ trunk/gucharmap/gucharmap-search-dialog.c Fri Mar 21 10:54:10 2008
@@ -23,12 +23,11 @@
#include <string.h>
#include "gucharmap-search-dialog.h"
#include "gucharmap-window.h"
-#include "gucharmap-unicode-info.h"
-#include "gucharmap-marshal.h"
-#include "gucharmap-private.h"
#define GUCHARMAP_SEARCH_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), gucharmap_search_dialog_get_type (), GucharmapSearchDialogPrivate))
+#define I_(string) g_intern_static_string (string)
+
enum
{
SEARCH_START,
Modified: trunk/gucharmap/gucharmap-search-dialog.h
==============================================================================
--- trunk/gucharmap/gucharmap-search-dialog.h (original)
+++ trunk/gucharmap/gucharmap-search-dialog.h Fri Mar 21 10:54:10 2008
@@ -18,21 +18,34 @@
/* GucharmapSearchDialog handles all aspects of searching */
-#if !defined (__GUCHARMAP_GUCHARMAP_H_INSIDE__) && !defined (GUCHARMAP_COMPILATION)
-#error "Only <gucharmap/gucharmap.h> can be included directly."
-#endif
-
#ifndef GUCHARMAP_SEARCH_DIALOG_H
#define GUCHARMAP_SEARCH_DIALOG_H
#include <gtk/gtk.h>
-#include <gucharmap/gucharmap-types.h>
-#include <gucharmap/gucharmap-window.h>
+#include <gucharmap/gucharmap.h>
+#include "gucharmap-window.h"
G_BEGIN_DECLS
#define GUCHARMAP_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), gucharmap_search_dialog_get_type (), GucharmapSearchDialog))
+typedef struct _GucharmapSearchDialog GucharmapSearchDialog;
+typedef struct _GucharmapSearchDialogClass GucharmapSearchDialogClass;
+
+struct _GucharmapSearchDialog
+{
+ GtkDialog parent;
+};
+
+struct _GucharmapSearchDialogClass
+{
+ GtkDialogClass parent_class;
+
+ /* signals */
+ void (* search_start) (void);
+ void (* search_finish) (gunichar found_char);
+};
+
typedef enum
{
GUCHARMAP_DIRECTION_BACKWARD = -1,
Modified: trunk/gucharmap/gucharmap-settings.c
==============================================================================
--- trunk/gucharmap/gucharmap-settings.c (original)
+++ trunk/gucharmap/gucharmap-settings.c Fri Mar 21 10:54:10 2008
@@ -24,46 +24,22 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
-
-#include "gucharmap-chapters-model.h"
+#include <gucharmap/gucharmap.h>
#include "gucharmap-settings.h"
-#include "gucharmap-private.h"
#if HAVE_GCONF
#include <gconf/gconf-client.h>
static GConfClient *client;
#endif
+/* The last unicode character we support */
+/* keep in sync with gucharmap-private.h! */
+#define UNICHAR_MAX (0x0010FFFFUL)
+
#define WINDOW_STATE_TIMEOUT 1000 /* ms */
#define GCONF_PREFIX "/apps/gucharmap"
-static gunichar
-get_first_non_underscore_char (const char *str)
-{
- const char *p;
-
- if (!str)
- return 0;
-
- for (p = str; p && *p; p = g_utf8_find_next_char (p, NULL))
- {
- gunichar ch;
-
- ch = g_utf8_get_char (p);
- if (g_unichar_isalpha (ch))
- return ch;
- }
-
- return 0;
-}
-
-gunichar
-gucharmap_settings_get_locale_character (void)
-{
- return get_first_non_underscore_char (_("_File")); /* use a super-common string */
-}
-
static GucharmapChaptersMode
get_default_chapters_mode (void)
{
@@ -178,13 +154,13 @@
guint64 value;
if (!gucharmap_settings_initialized ()) {
- return gucharmap_settings_get_locale_character ();
+ return gucharmap_unicode_get_locale_character ();
}
str = gconf_client_get_string (client, GCONF_PREFIX"/last_char", NULL);
if (!str || !g_str_has_prefix (str, "U+")) {
g_free (str);
- return gucharmap_settings_get_locale_character ();
+ return gucharmap_unicode_get_locale_character ();
}
endptr = NULL;
@@ -192,7 +168,7 @@
value = g_ascii_strtoull (str + 2 /* skip the "U+" */, &endptr, 16);
if (errno || endptr == str || value > UNICHAR_MAX) {
g_free (str);
- return gucharmap_settings_get_locale_character ();
+ return gucharmap_unicode_get_locale_character ();
}
return (gunichar) value;
@@ -285,7 +261,7 @@
gunichar
gucharmap_settings_get_last_char (void)
{
- return gucharmap_settings_get_locale_character ();
+ return gucharmap_unicode_get_locale_character ();
}
void
Modified: trunk/gucharmap/gucharmap-settings.h
==============================================================================
--- trunk/gucharmap/gucharmap-settings.h (original)
+++ trunk/gucharmap/gucharmap-settings.h Fri Mar 21 10:54:10 2008
@@ -37,8 +37,6 @@
void gucharmap_settings_set_snap_pow2 (gboolean snap_pow2);
void gucharmap_settings_add_window (GtkWindow *window);
-gunichar gucharmap_settings_get_locale_character (void);
-
G_END_DECLS
#endif /* #ifndef GUCHARMAP_SETTINGS_H */
Modified: trunk/gucharmap/gucharmap-types.h
==============================================================================
--- trunk/gucharmap/gucharmap-types.h (original)
+++ trunk/gucharmap/gucharmap-types.h Fri Mar 21 10:54:10 2008
@@ -24,21 +24,12 @@
#ifndef GUCHARMAP_TYPES_H
#define GUCHARMAP_TYPES_H
-typedef struct _GucharmapWindow GucharmapWindow;
-typedef struct _GucharmapWindowClass GucharmapWindowClass;
-
-typedef struct _GucharmapSearchDialog GucharmapSearchDialog;
-typedef struct _GucharmapSearchDialogClass GucharmapSearchDialogClass;
-
typedef struct _GucharmapScriptCodepointList GucharmapScriptCodepointList;
typedef struct _GucharmapScriptCodepointListClass GucharmapScriptCodepointListClass;
typedef struct _GucharmapScriptChaptersModel GucharmapScriptChaptersModel;
typedef struct _GucharmapScriptChaptersModelClass GucharmapScriptChaptersModelClass;
-typedef struct _GucharmapMiniFontSelection GucharmapMiniFontSelection;
-typedef struct _GucharmapMiniFontSelectionClass GucharmapMiniFontSelectionClass;
-
typedef struct _GucharmapCodepointList GucharmapCodepointList;
typedef struct _GucharmapCodepointListClass GucharmapCodepointListClass;
Modified: trunk/gucharmap/gucharmap-unicode-info.c
==============================================================================
--- trunk/gucharmap/gucharmap-unicode-info.c (original)
+++ trunk/gucharmap/gucharmap-unicode-info.c Fri Mar 21 10:54:10 2008
@@ -313,8 +313,6 @@
return NULL;
}
-gboolean _gucharmap_unicode_has_nameslist_entry (gunichar uc);
-
gboolean
_gucharmap_unicode_has_nameslist_entry (gunichar uc)
{
@@ -582,3 +580,40 @@
&& t != G_UNICODE_SPACE_SEPARATOR);
}
+static gunichar
+get_first_non_underscore_char (const char *str)
+{
+ const char *p;
+
+ if (!str)
+ return 0;
+
+ for (p = str; p && *p; p = g_utf8_find_next_char (p, NULL))
+ {
+ gunichar ch;
+
+ ch = g_utf8_get_char (p);
+ if (g_unichar_isalpha (ch))
+ return ch;
+ }
+
+ return 0;
+}
+
+/**
+ * gucharmap_unicode_get_locale_character:
+ *
+ * Determines a character that's commonly used in the current
+ * locale's script.
+ *
+ * Returns: a unicode character
+ */
+gunichar
+gucharmap_unicode_get_locale_character (void)
+{
+ GtkStockItem item;
+ if (!gtk_stock_lookup (GTK_STOCK_FILE, &item))
+ return 0;
+
+ return get_first_non_underscore_char (item.label);
+}
Modified: trunk/gucharmap/gucharmap-unicode-info.h
==============================================================================
--- trunk/gucharmap/gucharmap-unicode-info.h (original)
+++ trunk/gucharmap/gucharmap-unicode-info.h Fri Mar 21 10:54:10 2008
@@ -58,6 +58,9 @@
G_CONST_RETURN gchar ** gucharmap_unicode_list_scripts (void);
G_CONST_RETURN gchar * gucharmap_unicode_get_script_for_char (gunichar wc);
+/* doesn't really belong here, but no better place was available */
+gunichar gucharmap_unicode_get_locale_character (void);
+
G_END_DECLS
#endif /* #ifndef GUCHARMAP_UNICODE_INFO_H */
Modified: trunk/gucharmap/gucharmap-window.c
==============================================================================
--- trunk/gucharmap/gucharmap-window.c (original)
+++ trunk/gucharmap/gucharmap-window.c Fri Mar 21 10:54:10 2008
@@ -24,45 +24,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "gucharmap-window.h"
-#include "gucharmap-mini-fontsel.h"
-#include "gucharmap-unicode-info.h"
-#include "gucharmap-script-chapters-model.h"
-#include "gucharmap-block-chapters-model.h"
#include "gucharmap-search-dialog.h"
#include "gucharmap-settings.h"
-#include "gucharmap-private.h"
-
-#ifndef ICON_PATH
-# define ICON_PATH ""
-#endif
-
-#define GUCHARMAP_WINDOW_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), gucharmap_window_get_type (), GucharmapWindowPrivate))
-
-typedef struct _GucharmapWindowPrivate GucharmapWindowPrivate;
-
-struct _GucharmapWindowPrivate
-{
- GtkWidget *status;
-
- GtkWidget *fontsel;
- GtkWidget *text_to_copy_container; /* the thing to show/hide */
- GtkWidget *text_to_copy_entry;
-
- GtkUIManager *uimanager;
-
- GtkActionGroup *action_group;
-
- GtkWidget *search_dialog; /* takes care of all aspects of searching */
-
- GtkWidget *progress;
-
- guint font_selection_visible : 1;
- guint text_to_copy_visible : 1;
- guint file_menu_visible : 1;
-
- GucharmapChaptersMode chapters_mode;
-};
static void gucharmap_window_class_init (GucharmapWindowClass *klass);
static void gucharmap_window_init (GucharmapWindow *window);
@@ -74,31 +37,28 @@
const gchar *message,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
- gtk_statusbar_pop (GTK_STATUSBAR (priv->status), 0);
+ gtk_statusbar_pop (GTK_STATUSBAR (guw->status), 0);
if (message)
- gtk_statusbar_push (GTK_STATUSBAR (priv->status), 0, message);
+ gtk_statusbar_push (GTK_STATUSBAR (guw->status), 0, message);
}
static gboolean
update_progress_bar (GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
gdouble fraction_completed;
- fraction_completed = gucharmap_search_dialog_get_completed (GUCHARMAP_SEARCH_DIALOG (priv->search_dialog));
+ fraction_completed = gucharmap_search_dialog_get_completed (GUCHARMAP_SEARCH_DIALOG (guw->search_dialog));
if (fraction_completed < 0 || fraction_completed > 1)
{
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), 0);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), NULL);
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (guw->progress), 0);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (guw->progress), NULL);
return FALSE;
}
else
{
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), fraction_completed);
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (guw->progress), fraction_completed);
return TRUE;
}
}
@@ -163,22 +123,19 @@
{
GdkCursor *cursor;
GtkAction *action;
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
- g_assert (GUCHARMAP_IS_WINDOW (guw));
cursor = _gucharmap_window_progress_cursor ();
gdk_window_set_cursor (GTK_WIDGET (guw)->window, cursor);
gdk_cursor_unref (cursor);
- action = gtk_action_group_get_action (priv->action_group, "Find");
+ action = gtk_action_group_get_action (guw->action_group, "Find");
gtk_action_set_sensitive (action, FALSE);
- action = gtk_action_group_get_action (priv->action_group, "FindNext");
+ action = gtk_action_group_get_action (guw->action_group, "FindNext");
gtk_action_set_sensitive (action, FALSE);
- action = gtk_action_group_get_action (priv->action_group, "FindPrevious");
+ action = gtk_action_group_get_action (guw->action_group, "FindPrevious");
gtk_action_set_sensitive (action, FALSE);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), _("Searching..."));
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (guw->progress), _("Searching..."));
g_timeout_add (100, (GSourceFunc) update_progress_bar, guw);
}
@@ -187,23 +144,22 @@
gunichar found_char,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
GtkAction *action;
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), 0);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), NULL);
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (guw->progress), 0);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (guw->progress), NULL);
if (found_char != (gunichar)(-1))
- gucharmap_charmap_go_to_character (guw->charmap, found_char);
+ gucharmap_charmap_set_active_character (guw->charmap, found_char);
/* not-found dialog handled by GucharmapSearchDialog */
gdk_window_set_cursor (GTK_WIDGET (guw)->window, NULL);
- action = gtk_action_group_get_action (priv->action_group, "Find");
+ action = gtk_action_group_get_action (guw->action_group, "Find");
gtk_action_set_sensitive (action, TRUE);
- action = gtk_action_group_get_action (priv->action_group, "FindNext");
+ action = gtk_action_group_get_action (guw->action_group, "FindNext");
gtk_action_set_sensitive (action, TRUE);
- action = gtk_action_group_get_action (priv->action_group, "FindPrevious");
+ action = gtk_action_group_get_action (guw->action_group, "FindPrevious");
gtk_action_set_sensitive (action, TRUE);
}
@@ -211,27 +167,24 @@
search_find (GtkAction *action,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
g_assert (GUCHARMAP_IS_WINDOW (guw));
- if (priv->search_dialog == NULL)
+ if (guw->search_dialog == NULL)
{
- priv->search_dialog = gucharmap_search_dialog_new (guw);
- g_signal_connect (priv->search_dialog, "search-start", G_CALLBACK (search_start), guw);
- g_signal_connect (priv->search_dialog, "search-finish", G_CALLBACK (search_finish), guw);
+ guw->search_dialog = gucharmap_search_dialog_new (guw);
+ g_signal_connect (guw->search_dialog, "search-start", G_CALLBACK (search_start), guw);
+ g_signal_connect (guw->search_dialog, "search-finish", G_CALLBACK (search_finish), guw);
}
- gtk_window_present (GTK_WINDOW (priv->search_dialog));
+ gtk_window_present (GTK_WINDOW (guw->search_dialog));
}
static void
search_find_next (GtkAction *action,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
- if (priv->search_dialog)
- gucharmap_search_dialog_start_search (GUCHARMAP_SEARCH_DIALOG (priv->search_dialog), GUCHARMAP_DIRECTION_FORWARD);
+ if (guw->search_dialog)
+ gucharmap_search_dialog_start_search (GUCHARMAP_SEARCH_DIALOG (guw->search_dialog), GUCHARMAP_DIRECTION_FORWARD);
else
search_find (action, guw);
}
@@ -240,10 +193,8 @@
search_find_prev (GtkAction *action,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
- if (priv->search_dialog)
- gucharmap_search_dialog_start_search (GUCHARMAP_SEARCH_DIALOG (priv->search_dialog), GUCHARMAP_DIRECTION_BACKWARD);
+ if (guw->search_dialog)
+ gucharmap_search_dialog_start_search (GUCHARMAP_SEARCH_DIALOG (guw->search_dialog), GUCHARMAP_DIRECTION_BACKWARD);
else
search_find (action, guw);
}
@@ -252,32 +203,29 @@
font_bigger (GtkAction *action,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
gint size, increment;
- size = gucharmap_mini_font_selection_get_font_size (GUCHARMAP_MINI_FONT_SELECTION (priv->fontsel));
+ size = gucharmap_mini_font_selection_get_font_size (GUCHARMAP_MINI_FONT_SELECTION (guw->fontsel));
increment = MAX (size / 5, 1);
- gucharmap_mini_font_selection_set_font_size (GUCHARMAP_MINI_FONT_SELECTION (priv->fontsel), size + increment);
+ gucharmap_mini_font_selection_set_font_size (GUCHARMAP_MINI_FONT_SELECTION (guw->fontsel), size + increment);
}
static void
font_smaller (GtkAction *action,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
gint size, increment;
- size = gucharmap_mini_font_selection_get_font_size (GUCHARMAP_MINI_FONT_SELECTION (priv->fontsel));
+ size = gucharmap_mini_font_selection_get_font_size (GUCHARMAP_MINI_FONT_SELECTION (guw->fontsel));
increment = MAX (size / 5, 1);
- gucharmap_mini_font_selection_set_font_size (GUCHARMAP_MINI_FONT_SELECTION (priv->fontsel), size - increment);
+ gucharmap_mini_font_selection_set_font_size (GUCHARMAP_MINI_FONT_SELECTION (guw->fontsel), size - increment);
}
static void
font_default (GtkAction *action,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
- gucharmap_mini_font_selection_reset_font_size (GUCHARMAP_MINI_FONT_SELECTION (priv->fontsel));
+ gucharmap_mini_font_selection_reset_font_size (GUCHARMAP_MINI_FONT_SELECTION (guw->fontsel));
}
static void
@@ -498,11 +446,10 @@
GucharmapWindow *guw)
{
GtkAction *action;
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
- action = gtk_action_group_get_action (priv->action_group, "NextChapter");
+ action = gtk_action_group_get_action (guw->action_group, "NextChapter");
g_object_set ( G_OBJECT (action), "label", labelnext, NULL);
- action = gtk_action_group_get_action (priv->action_group, "PreviousChapter");
+ action = gtk_action_group_get_action (guw->action_group, "PreviousChapter");
g_object_set ( G_OBJECT (action), "label", labelprev, NULL);
}
@@ -685,44 +632,43 @@
NULL,
G_CALLBACK (snap_cols_pow2), FALSE },
};
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
GtkWidget *menubar;
GtkAction *action;
- priv->uimanager = gtk_ui_manager_new();
+ guw->uimanager = gtk_ui_manager_new();
gtk_window_add_accel_group ( GTK_WINDOW (guw),
- gtk_ui_manager_get_accel_group (priv->uimanager) );
+ gtk_ui_manager_get_accel_group (guw->uimanager) );
- priv->action_group = gtk_action_group_new ("gucharmap_actions");
- gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE);
+ guw->action_group = gtk_action_group_new ("gucharmap_actions");
+ gtk_action_group_set_translation_domain (guw->action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (priv->action_group,
+ gtk_action_group_add_actions (guw->action_group,
menu_entries,
G_N_ELEMENTS (menu_entries),
guw);
- gtk_action_group_add_radio_actions (priv->action_group,
+ gtk_action_group_add_radio_actions (guw->action_group,
radio_menu_entries,
G_N_ELEMENTS (radio_menu_entries),
gucharmap_settings_get_chapters_mode(),
G_CALLBACK (view_by),
guw);
- gtk_action_group_add_toggle_actions (priv->action_group,
+ gtk_action_group_add_toggle_actions (guw->action_group,
toggle_menu_entries,
G_N_ELEMENTS (toggle_menu_entries),
guw);
- action = gtk_action_group_get_action (priv->action_group, "SnapColumns");
+ action = gtk_action_group_get_action (guw->action_group, "SnapColumns");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
gucharmap_settings_get_snap_pow2 ());
gucharmap_window_set_file_menu_visible (guw, TRUE);
- gtk_ui_manager_insert_action_group (priv->uimanager, priv->action_group, 0);
- g_object_unref (priv->action_group);
+ gtk_ui_manager_insert_action_group (guw->uimanager, guw->action_group, 0);
+ g_object_unref (guw->action_group);
- gtk_ui_manager_add_ui_from_string (priv->uimanager, ui_info, strlen (ui_info), NULL);
+ gtk_ui_manager_add_ui_from_string (guw->uimanager, ui_info, strlen (ui_info), NULL);
- menubar = gtk_ui_manager_get_widget (priv->uimanager, "/MenuBar");
+ menubar = gtk_ui_manager_get_widget (guw->uimanager, "/MenuBar");
return menubar;
}
@@ -743,7 +689,6 @@
insert_character_in_text_to_copy (GucharmapChartable *chartable,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
gchar ubuf[7];
gint pos;
gunichar wc;
@@ -754,27 +699,25 @@
return;
/* don't do anything if text_to_copy is not active */
- if (!priv->text_to_copy_visible)
+ if (!guw->text_to_copy_visible)
return;
ubuf[g_unichar_to_utf8 (wc, ubuf)] = '\0';
- gtk_editable_delete_selection (GTK_EDITABLE (priv->text_to_copy_entry));
- pos = gtk_editable_get_position (GTK_EDITABLE (priv->text_to_copy_entry));
- gtk_editable_insert_text (GTK_EDITABLE (priv->text_to_copy_entry), ubuf, -1, &pos);
- gtk_editable_set_position (GTK_EDITABLE (priv->text_to_copy_entry), pos);
+ gtk_editable_delete_selection (GTK_EDITABLE (guw->text_to_copy_entry));
+ pos = gtk_editable_get_position (GTK_EDITABLE (guw->text_to_copy_entry));
+ gtk_editable_insert_text (GTK_EDITABLE (guw->text_to_copy_entry), ubuf, -1, &pos);
+ gtk_editable_set_position (GTK_EDITABLE (guw->text_to_copy_entry), pos);
}
static void
edit_copy (GtkWidget *widget, GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
/* if nothing is selected, select the whole thing */
if (! gtk_editable_get_selection_bounds (
- GTK_EDITABLE (priv->text_to_copy_entry), NULL, NULL))
- gtk_editable_select_region (GTK_EDITABLE (priv->text_to_copy_entry), 0, -1);
+ GTK_EDITABLE (guw->text_to_copy_entry), NULL, NULL))
+ gtk_editable_select_region (GTK_EDITABLE (guw->text_to_copy_entry), 0, -1);
- gtk_editable_copy_clipboard (GTK_EDITABLE (priv->text_to_copy_entry));
+ gtk_editable_copy_clipboard (GTK_EDITABLE (guw->text_to_copy_entry));
}
static void
@@ -787,7 +730,6 @@
static GtkWidget *
make_text_to_copy (GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
GtkWidget *button;
GtkWidget *label;
GtkWidget *hbox;
@@ -798,11 +740,11 @@
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
- priv->text_to_copy_entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), priv->text_to_copy_entry, TRUE, TRUE, 0);
- gtk_widget_show (priv->text_to_copy_entry);
+ guw->text_to_copy_entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), guw->text_to_copy_entry, TRUE, TRUE, 0);
+ gtk_widget_show (guw->text_to_copy_entry);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->text_to_copy_entry);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), guw->text_to_copy_entry);
/* the copy button */
button = gtk_button_new_from_stock (GTK_STOCK_COPY);
@@ -812,7 +754,7 @@
G_CALLBACK (edit_copy), guw);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->text_to_copy_entry), "changed",
+ g_signal_connect (G_OBJECT (guw->text_to_copy_entry), "changed",
G_CALLBACK (entry_changed_sensitize_button), button);
gtk_widget_set_tooltip_text (button, _("Copy to the clipboard."));
@@ -824,22 +766,46 @@
status_realize (GtkWidget *status,
GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
/* FIXMEchpe ewww... */
/* increase the height a bit so it doesn't resize itself */
- gtk_widget_set_size_request (priv->status, -1, priv->status->allocation.height + 9);
+ gtk_widget_set_size_request (guw->status, -1, guw->status->allocation.height + 9);
+}
+
+
+static gboolean
+save_last_char_idle_cb (GucharmapWindow *guw)
+{
+ gunichar wc;
+
+ guw->save_last_char_idle_id = 0;
+
+ wc = gucharmap_charmap_get_active_character (guw->charmap);
+ gucharmap_settings_set_last_char (wc);
+
+ return FALSE;
+}
+
+static void
+charmap_sync_active_character (GtkWidget *widget,
+ GParamSpec *pspec,
+ GucharmapWindow *guw)
+{
+ if (guw->save_last_char_idle_id != 0)
+ return;
+
+ guw->save_last_char_idle_id = g_idle_add ((GSourceFunc) save_last_char_idle_cb, guw);
}
static void
pack_stuff_in_window (GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
GtkWidget *big_vbox;
GtkWidget *hbox;
GucharmapChartable *chartable;
guw->charmap = GUCHARMAP_CHARMAP (gucharmap_charmap_new ());
+ g_signal_connect (guw->charmap, "notify::active-character",
+ G_CALLBACK (charmap_sync_active_character), guw);
big_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (guw), big_vbox);
@@ -854,14 +820,14 @@
TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (guw->charmap));
- priv->fontsel = gucharmap_mini_font_selection_new ();
- g_signal_connect (priv->fontsel, "changed", G_CALLBACK (fontsel_changed), guw);
- gtk_box_pack_start (GTK_BOX (hbox), priv->fontsel, FALSE, FALSE, 0);
- gtk_widget_show (GTK_WIDGET (priv->fontsel));
-
- priv->text_to_copy_container = make_text_to_copy (guw);
- gtk_container_set_border_width (GTK_CONTAINER (priv->text_to_copy_container), 6);
- gtk_box_pack_start (GTK_BOX (big_vbox), priv->text_to_copy_container, FALSE, FALSE, 0);
+ guw->fontsel = gucharmap_mini_font_selection_new ();
+ g_signal_connect (guw->fontsel, "changed", G_CALLBACK (fontsel_changed), guw);
+ gtk_box_pack_start (GTK_BOX (hbox), guw->fontsel, FALSE, FALSE, 0);
+ gtk_widget_show (GTK_WIDGET (guw->fontsel));
+
+ guw->text_to_copy_container = make_text_to_copy (guw);
+ gtk_container_set_border_width (GTK_CONTAINER (guw->text_to_copy_container), 6);
+ gtk_box_pack_start (GTK_BOX (big_vbox), guw->text_to_copy_container, FALSE, FALSE, 0);
/* FIXMEchpe!! */
chartable =gucharmap_charmap_get_chartable (guw->charmap);
g_signal_connect (chartable, "activate", G_CALLBACK (insert_character_in_text_to_copy), guw);
@@ -870,14 +836,14 @@
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (big_vbox), hbox, FALSE, FALSE, 0);
- priv->status = gtk_statusbar_new ();
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (priv->status), FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), priv->status, TRUE, TRUE, 0);
- gtk_widget_show (priv->status);
- g_signal_connect (priv->status, "realize", G_CALLBACK (status_realize), guw);
+ guw->status = gtk_statusbar_new ();
+ gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (guw->status), FALSE);
+ gtk_box_pack_start (GTK_BOX (hbox), guw->status, TRUE, TRUE, 0);
+ gtk_widget_show (guw->status);
+ g_signal_connect (guw->status, "realize", G_CALLBACK (status_realize), guw);
- priv->progress = gtk_progress_bar_new ();
- gtk_box_pack_start (GTK_BOX (hbox), priv->progress, FALSE, FALSE, 0);
+ guw->progress = gtk_progress_bar_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), guw->progress, FALSE, FALSE, 0);
#if 0
grip = gtk_statusbar_new ();
@@ -890,22 +856,23 @@
gtk_widget_show (big_vbox);
- set_chapters_model (guw, priv->chapters_mode);
+ set_chapters_model (guw, guw->chapters_mode);
+
+ gucharmap_charmap_set_active_character (guw->charmap,
+ gucharmap_settings_get_last_char ());
}
static void
gucharmap_window_init (GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
gtk_window_set_title (GTK_WINDOW (guw), _("Character Map"));
- priv->font_selection_visible = FALSE;
- priv->text_to_copy_visible = FALSE;
- priv->file_menu_visible = FALSE;
- priv->chapters_mode = gucharmap_settings_get_chapters_mode ();
+ guw->font_selection_visible = FALSE;
+ guw->text_to_copy_visible = FALSE;
+ guw->file_menu_visible = FALSE;
+ guw->chapters_mode = gucharmap_settings_get_chapters_mode ();
- priv->search_dialog = NULL;
+ guw->search_dialog = NULL;
gtk_window_set_icon_name (GTK_WINDOW (guw), "gucharmap");
@@ -917,24 +884,20 @@
static void
window_finalize (GObject *object)
{
-#if 0
GucharmapWindow *guw = GUCHARMAP_WINDOW (object);
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
- /*
- if (priv->last_search)
- g_free (priv->last_search);
- */
-#endif
+ if (guw->save_last_char_idle_id != 0)
+ g_source_remove (guw->save_last_char_idle_id);
+
G_OBJECT_CLASS (gucharmap_window_parent_class)->finalize (object);
}
static void
-gucharmap_window_class_init (GucharmapWindowClass *clazz)
+gucharmap_window_class_init (GucharmapWindowClass *klass)
{
- G_OBJECT_CLASS (clazz)->finalize = window_finalize;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (clazz, sizeof (GucharmapWindowPrivate));
+ object_class->finalize = window_finalize;
}
GtkWidget *
@@ -947,42 +910,36 @@
gucharmap_window_set_font_selection_visible (GucharmapWindow *guw,
gboolean visible)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
+ guw->font_selection_visible = visible != FALSE;
- priv->font_selection_visible = visible != FALSE;
-
- g_object_set (priv->fontsel, "visible", visible, NULL);
+ g_object_set (guw->fontsel, "visible", visible, NULL);
}
void
gucharmap_window_set_text_to_copy_visible (GucharmapWindow *guw,
gboolean visible)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
-
- priv->text_to_copy_visible = visible != FALSE;
+ guw->text_to_copy_visible = visible != FALSE;
- g_object_set (priv->text_to_copy_container, "visible", visible, NULL);
+ g_object_set (guw->text_to_copy_container, "visible", visible, NULL);
}
void
gucharmap_window_set_file_menu_visible (GucharmapWindow *guw,
gboolean visible)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
GtkAction *action;
- priv->file_menu_visible = visible != FALSE;
+ guw->file_menu_visible = visible != FALSE;
- action = gtk_action_group_get_action (priv->action_group, "File");
+ action = gtk_action_group_get_action (guw->action_group, "File");
gtk_action_set_visible (action, visible);
- action = gtk_action_group_get_action (priv->action_group, "Quit");
+ action = gtk_action_group_get_action (guw->action_group, "Quit");
gtk_action_set_sensitive (action, visible);
}
GucharmapMiniFontSelection *
gucharmap_window_get_mini_font_selection (GucharmapWindow *guw)
{
- GucharmapWindowPrivate *priv = GUCHARMAP_WINDOW_GET_PRIVATE (guw);
- return GUCHARMAP_MINI_FONT_SELECTION (priv->fontsel);
+ return GUCHARMAP_MINI_FONT_SELECTION (guw->fontsel);
}
Modified: trunk/gucharmap/gucharmap-window.h
==============================================================================
--- trunk/gucharmap/gucharmap-window.h (original)
+++ trunk/gucharmap/gucharmap-window.h Fri Mar 21 10:54:10 2008
@@ -16,17 +16,12 @@
* 59 Temple Place, Suite 330, Boston, MA 02110-1301 USA
*/
-#if !defined (__GUCHARMAP_GUCHARMAP_H_INSIDE__) && !defined (GUCHARMAP_COMPILATION)
-#error "Only <gucharmap/gucharmap.h> can be included directly."
-#endif
-
#ifndef GUCHARMAP_WINDOW_H
#define GUCHARMAP_WINDOW_H
#include <gtk/gtk.h>
-#include <gucharmap/gucharmap-types.h>
-#include <gucharmap/gucharmap-charmap.h>
-#include <gucharmap/gucharmap-mini-fontsel.h>
+#include <gucharmap/gucharmap.h>
+#include "gucharmap-mini-fontsel.h"
G_BEGIN_DECLS
@@ -36,6 +31,42 @@
#define GUCHARMAP_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), gucharmap_window_get_type ()))
+typedef struct _GucharmapWindow GucharmapWindow;
+typedef struct _GucharmapWindowClass GucharmapWindowClass;
+
+struct _GucharmapWindow
+{
+ GtkWindow parent;
+
+ GucharmapCharmap *charmap;
+ GtkWidget *status;
+
+ GtkWidget *fontsel;
+ GtkWidget *text_to_copy_container; /* the thing to show/hide */
+ GtkWidget *text_to_copy_entry;
+
+ GtkUIManager *uimanager;
+
+ GtkActionGroup *action_group;
+
+ GtkWidget *search_dialog; /* takes care of all aspects of searching */
+
+ GtkWidget *progress;
+
+ guint save_last_char_idle_id;
+
+ guint font_selection_visible : 1;
+ guint text_to_copy_visible : 1;
+ guint file_menu_visible : 1;
+
+ GucharmapChaptersMode chapters_mode;
+};
+
+struct _GucharmapWindowClass
+{
+ GtkWindowClass parent_class;
+};
+
GType gucharmap_window_get_type (void);
GtkWidget * gucharmap_window_new (void);
void gucharmap_window_set_font_selection_visible (GucharmapWindow *guw,
@@ -46,8 +77,8 @@
gboolean visible);
GucharmapMiniFontSelection * gucharmap_window_get_mini_font_selection (GucharmapWindow *guw);
+GdkCursor * _gucharmap_window_progress_cursor (void);
+
G_END_DECLS
#endif /* #ifndef GUCHARMAP_WINDOW_H */
-
-
Modified: trunk/gucharmap/gucharmap.h
==============================================================================
--- trunk/gucharmap/gucharmap.h (original)
+++ trunk/gucharmap/gucharmap.h Fri Mar 21 10:54:10 2008
@@ -29,12 +29,9 @@
#include <gucharmap/gucharmap-chartable.h>
#include <gucharmap/gucharmap-codepoint-list.h>
#include <gucharmap/gucharmap-init.h>
-#include <gucharmap/gucharmap-mini-fontsel.h>
#include <gucharmap/gucharmap-script-chapters-model.h>
#include <gucharmap/gucharmap-script-codepoint-list.h>
-#include <gucharmap/gucharmap-search-dialog.h>
#include <gucharmap/gucharmap-unicode-info.h>
-#include <gucharmap/gucharmap-window.h>
#undef __GUCHARMAP_GUCHARMAP_H_INSIDE__
Modified: trunk/gucharmap/main.c
==============================================================================
--- trunk/gucharmap/main.c (original)
+++ trunk/gucharmap/main.c Fri Mar 21 10:54:10 2008
@@ -25,6 +25,7 @@
#include <gucharmap/gucharmap.h>
#include "gucharmap-settings.h"
+#include "gucharmap-window.h"
gint
main (gint argc, gchar **argv)
@@ -55,6 +56,8 @@
}
gucharmap_init ();
+ gucharmap_settings_initialize ();
+
g_set_application_name (_("Gucharmap"));
gtk_window_set_default_icon_name ("gucharmap");
@@ -101,6 +104,7 @@
gtk_main ();
+ gucharmap_settings_shutdown ();
gucharmap_shutdown ();
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]