[Kazehakase-cvs] kazehakase-svn [3040] * ext/ruby/kz-rb-ext.[ch], ext/ruby/Makefile.am: used KZ_GET_XXX

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Tue Mar 27 11:41:35 JST 2007


Revision: 3040
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3040
Author:   kous
Date:     2007-03-27 11:41:35 +0900 (Tue, 27 Mar 2007)

Log Message:
-----------
* ext/ruby/kz-rb-ext.[ch], ext/ruby/Makefile.am: used KZ_GET_XXX
macros instead of KZ_XXX macros.

* src/kz-app.[ch], src/kazehakase.h, src/Makefile.am: added
user_dir, system_data_dir, system_ruby_ext_dir.

* data/ext/ruby/kz/ruby-dialog.rb (Kz::RubyDialog): followed the
above changes.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/data/ext/ruby/kz/ruby-dialog.rb
    kazehakase/trunk/ext/ruby/Makefile.am
    kazehakase/trunk/ext/ruby/kz-rb-ext.c
    kazehakase/trunk/ext/ruby/kz-rb-ext.h
    kazehakase/trunk/src/Makefile.am
    kazehakase/trunk/src/kazehakase.h
    kazehakase/trunk/src/kz-app.c
    kazehakase/trunk/src/kz-app.h

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/ChangeLog	2007-03-27 02:41:35 UTC (rev 3040)
@@ -1,3 +1,14 @@
+2007-03-27  Kouhei Sutou  <kou****@cozmi*****>
+
+	* ext/ruby/kz-rb-ext.[ch], ext/ruby/Makefile.am: used KZ_GET_XXX
+	macros instead of KZ_XXX macros.
+
+	* src/kz-app.[ch], src/kazehakase.h, src/Makefile.am: added
+	user_dir, system_data_dir, system_ruby_ext_dir.
+
+	* data/ext/ruby/kz/ruby-dialog.rb (Kz::RubyDialog): followed the
+	above changes.
+
 2007-03-27  Hiroyuki Ikezoe  <poinc****@ikezo*****>
 
 	* module/embed/gecko/kz-mozutils.cpp: Set printer list correctly.

Modified: kazehakase/trunk/data/ext/ruby/kz/ruby-dialog.rb
===================================================================
--- kazehakase/trunk/data/ext/ruby/kz/ruby-dialog.rb	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/data/ext/ruby/kz/ruby-dialog.rb	2007-03-27 02:41:35 UTC (rev 3040)
@@ -37,7 +37,7 @@
   end
 
   class RubyDialog
-    HISTORY_PATH = File.join(Kz::CONFIG_DIR, "ruby-command-history")
+    HISTORY_PATH = File.join(Kz::USER_DIR, "ruby-command-history")
     @@history ||= nil
     @@history_spins ||= []
 

Modified: kazehakase/trunk/ext/ruby/Makefile.am
===================================================================
--- kazehakase/trunk/ext/ruby/Makefile.am	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/ext/ruby/Makefile.am	2007-03-27 02:41:35 UTC (rev 3040)
@@ -3,13 +3,6 @@
 ext_LTLIBRARIES = ruby.la
 
 AM_CPPFLAGS =						\
-	-DLOCALEDIR=\""$(localedir)"\"			\
-	-DSYSCONFDIR=\""$(sysconfdir)"\"		\
-	-DDATADIR=\""$(datadir)"\"			\
-	-DEXTDIR=\""$(extdir)"\"			\
-	-DKZ_SYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\"	\
-	-DKZ_DATADIR=\""$(datadir)/$(PACKAGE)"\"	\
-	-DKZ_RUBY_EXTDIR=\""$(extrubydir)"\"		\
 	-DGTK_DISABLE_DEPRECATED=1			\
 	-DGDK_DISABLE_DEPRECATED=1			\
 	-DG_DISABLE_DEPRECATED=1

Modified: kazehakase/trunk/ext/ruby/kz-rb-ext.c
===================================================================
--- kazehakase/trunk/ext/ruby/kz-rb-ext.c	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/ext/ruby/kz-rb-ext.c	2007-03-27 02:41:35 UTC (rev 3040)
@@ -69,7 +69,8 @@
 static void
 Init_kz (void)
 {
-    gchar *config_dir, *actions_dir, *sidebars_dir;
+    const gchar *user_dir;
+    gchar *actions_dir, *sidebars_dir;
 
     mKz = rb_define_module("Kz");
 
@@ -77,13 +78,12 @@
     rb_define_const(mKz, "URI", rb_str_new2(KAZEHAKASE_URI));
     rb_define_const(mKz, "PACKAGE", rb_str_new2(PACKAGE));
 
-    config_dir = g_build_filename(g_get_home_dir(), "."PACKAGE, NULL);
-    actions_dir = g_build_filename(config_dir, "actions", NULL);
-    sidebars_dir = g_build_filename(config_dir, "sidebars", NULL);
-    rb_define_const(mKz, "CONFIG_DIR", rb_str_new2(config_dir));
+    user_dir = KZ_GET_USER_DIR;
+    actions_dir = g_build_filename(user_dir, "actions", NULL);
+    sidebars_dir = g_build_filename(user_dir, "sidebars", NULL);
+    rb_define_const(mKz, "USER_DIR", rb_str_new2(user_dir));
     rb_define_const(mKz, "ACTIONS_DIR", rb_str_new2(actions_dir));
     rb_define_const(mKz, "SIDEBARS_DIR", rb_str_new2(sidebars_dir));
-    g_free(config_dir);
     g_free(actions_dir);
     g_free(sidebars_dir);
 
@@ -161,11 +161,11 @@
         _kz_rb_ext_version = g_strdup(StringValueCStr(version));
     }
 
-    dirname = g_build_filename(KZ_DATADIR, "ext", "ruby", NULL);
+    dirname = g_build_filename(KZ_GET_SYSTEM_DATA_DIR, "ext", "ruby", NULL);
     rb_ary_unshift(rb_load_path, rb_str_new2(dirname));
     g_free(dirname);
 
-    rb_ary_unshift(rb_load_path, rb_str_new2(KZ_RUBY_EXTDIR));
+    rb_ary_unshift(rb_load_path, rb_str_new2(KZ_GET_SYSTEM_RUBY_EXT_DIR));
 
     Init_kz();
 

Modified: kazehakase/trunk/ext/ruby/kz-rb-ext.h
===================================================================
--- kazehakase/trunk/ext/ruby/kz-rb-ext.h	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/ext/ruby/kz-rb-ext.h	2007-03-27 02:41:35 UTC (rev 3040)
@@ -10,6 +10,7 @@
 #undef PACKAGE_STRING
 #undef PACKAGE_VERSION
 
+#include "kazehakase.h"
 #include "kz-app.h"
 #include "kz-window.h"
 #include "kz-notebook.h"

Modified: kazehakase/trunk/src/Makefile.am
===================================================================
--- kazehakase/trunk/src/Makefile.am	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/src/Makefile.am	2007-03-27 02:41:35 UTC (rev 3040)
@@ -7,18 +7,19 @@
 libkazehakasedir = $(libdir)/$(PACKAGE)
 libkazehakase_LTLIBRARIES = libkazehakase.la
 
-AM_CPPFLAGS = \
-	-DLOCALEDIR=\""$(localedir)"\" \
-	-DSYSCONFDIR=\""$(sysconfdir)"\" \
-	-DDATADIR=\""$(datadir)"\" \
-	-DKZ_EXTDIR=\""$(extdir)"\" \
-	-DKZ_SYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \
-	-DKZ_DATADIR=\""$(datadir)/$(PACKAGE)"\" \
-	-DKZ_SEARCH_MODULEDIR=\""$(searchdir)"\" \
-	-DKZ_EMBED_MODULEDIR=\""$(embeddir)"\" \
-	-DGTK_DISABLE_DEPRECATED=1 \
-	-DGDK_DISABLE_DEPRECATED=1 \
-	-DG_LOG_DOMAIN=\"Kazehakase\" \
+AM_CPPFLAGS =						\
+	-DLOCALEDIR=\""$(localedir)"\"			\
+	-DSYSCONFDIR=\""$(sysconfdir)"\"		\
+	-DDATADIR=\""$(datadir)"\"			\
+	-DKZ_EXTDIR=\""$(extdir)"\"			\
+	-DKZ_RUBY_EXTDIR=\""$(extrubydir)"\"		\
+	-DKZ_SYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\"	\
+	-DKZ_DATADIR=\""$(datadir)/$(PACKAGE)"\"	\
+	-DKZ_SEARCH_MODULEDIR=\""$(searchdir)"\"	\
+	-DKZ_EMBED_MODULEDIR=\""$(embeddir)"\"		\
+	-DGTK_DISABLE_DEPRECATED=1			\
+	-DGDK_DISABLE_DEPRECATED=1			\
+	-DG_LOG_DOMAIN=\"Kazehakase\"			\
 	-DG_DISABLE_DEPRECATED=1
 
 INCLUDES = \

Modified: kazehakase/trunk/src/kazehakase.h
===================================================================
--- kazehakase/trunk/src/kazehakase.h	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/src/kazehakase.h	2007-03-27 02:41:35 UTC (rev 3040)
@@ -69,9 +69,12 @@
 #define KZ_GET_WINDOW_LIST     kz_app_get_window_list(kz_app)
 #define KZ_GET_MIGEMO          kz_app_get_migemo(kz_app)
 
+#define KZ_GET_USER_DIR		kz_app_get_user_dir(kz_app)
 #define KZ_GET_HISTORY_DIR	kz_app_get_history_dir(kz_app)
 #define KZ_GET_HISTORY_TIME_STAMP	kz_app_get_history_time_stamp(kz_app)
 #define KZ_GET_POPUP_DIR	kz_app_get_popup_dir(kz_app)
+#define KZ_GET_SYSTEM_DATA_DIR	kz_app_get_system_data_dir(kz_app)
+#define KZ_GET_SYSTEM_RUBY_EXT_DIR	kz_app_get_system_ruby_ext_dir(kz_app)
 
 
 #define KZ_SET_SEARCH(engine_name)	kz_app_set_search(kz_app, engine_name)

Modified: kazehakase/trunk/src/kz-app.c
===================================================================
--- kazehakase/trunk/src/kz-app.c	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/src/kz-app.c	2007-03-27 02:41:35 UTC (rev 3040)
@@ -80,9 +80,13 @@
 	gchar          *session_id;
 #endif /* HAVE_LIBSM */
 
+	/* paths */
+	gchar		*user_dir;
 	gchar		*history_dir;
 	gchar		*history_time_stamp;
 	gchar		*popup_dir;
+	gchar		*system_data_dir;
+	gchar		*system_ruby_ext_dir;
 };
 
 #define KZ_APP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_APP, KzAppPrivate))
@@ -235,6 +239,60 @@
 }
 
 static void
+kz_app_init_path (KzApp *app)
+{
+	KzAppPrivate *priv = KZ_APP_GET_PRIVATE(app);
+
+	priv->user_dir = g_strdup(g_get_home_dir());
+	priv->history_dir = g_build_filename(priv->user_dir, HISTORY_DIR,
+					     NULL);
+	priv->history_time_stamp = g_build_filename(priv->history_dir,
+						    "time-stamp",
+						    NULL);
+	priv->popup_dir = g_build_filename(priv->user_dir, IMAGE_DIR, NULL);
+
+	priv->system_data_dir = g_strdup(KZ_DATADIR);
+	priv->system_ruby_ext_dir = g_strdup(KZ_RUBY_EXTDIR);
+}
+
+static void
+kz_app_dispose_path (GObject *app)
+{
+	KzAppPrivate *priv = KZ_APP_GET_PRIVATE(app);
+
+	g_free(priv->user_dir);
+	g_free(priv->history_dir);
+	g_free(priv->history_time_stamp);
+	g_free(priv->popup_dir);
+	g_free(priv->system_data_dir);
+	g_free(priv->system_ruby_ext_dir);
+
+	priv->user_dir = NULL;
+	priv->history_dir = NULL;
+	priv->history_time_stamp = NULL;
+	priv->popup_dir = NULL;
+	priv->system_data_dir = NULL;
+	priv->system_ruby_ext_dir = NULL;
+}
+
+#define DEFINE_PATH_GETTER(name)			\
+const gchar *						\
+kz_app_get_ ## name (KzApp *app)			\
+{							\
+	g_return_val_if_fail(KZ_IS_APP(app), NULL);	\
+							\
+	return KZ_APP_GET_PRIVATE(app)->name;		\
+}
+
+DEFINE_PATH_GETTER(user_dir)
+DEFINE_PATH_GETTER(history_dir)
+DEFINE_PATH_GETTER(history_time_stamp)
+DEFINE_PATH_GETTER(popup_dir)
+DEFINE_PATH_GETTER(system_data_dir)
+DEFINE_PATH_GETTER(system_ruby_ext_dir)
+
+
+static void
 kz_app_init (KzApp *app)
 {
 	gchar *sysconf_file, *conf_file;
@@ -246,12 +304,7 @@
 	gchar *proxy_file, *sysproxy_file;
 	KzAppPrivate *priv = KZ_APP_GET_PRIVATE(app);
 
-	priv->history_dir = g_build_filename(g_get_home_dir(), HISTORY_DIR,
-					     NULL);
-	priv->history_time_stamp = g_build_filename(priv->history_dir,
-						    "time-stamp",
-						    NULL);
-	priv->popup_dir = g_build_filename(g_get_home_dir(), IMAGE_DIR, NULL);
+	kz_app_init_path(app);
 
 	priv->window_list = NULL;
 	priv->favicon = kz_favicon_get_instance();
@@ -420,20 +473,14 @@
 		SmcCloseConnection ((SmcConn) priv->smc_conn, 0, NULL);
 #endif /* HAVE_LIBSM */
 
-	g_free(priv->history_dir);
-	g_free(priv->history_time_stamp);
-	g_free(priv->popup_dir);
-
-	priv->history_dir = NULL;
-	priv->history_time_stamp = NULL;
-	priv->popup_dir = NULL;
-
 	priv->profile   = NULL;
 	priv->proxy     = NULL;
 	priv->bookmarks = NULL;
 	priv->favicon   = NULL;
 	priv->argv	= NULL;
 
+	kz_app_dispose_path(object);
+
 	if (G_OBJECT_CLASS (kz_app_parent_class)->dispose)
 		G_OBJECT_CLASS (kz_app_parent_class)->dispose(object);
 }
@@ -1019,28 +1066,3 @@
 	}
 }
 #endif /* HAVE_LIBSM */
-
-const gchar *
-kz_app_get_history_dir (KzApp *app)
-{
-	g_return_val_if_fail(KZ_IS_APP(app), NULL);
-
-	return KZ_APP_GET_PRIVATE(app)->history_dir;
-}
-
-const gchar *
-kz_app_get_history_time_stamp (KzApp *app)
-{
-	g_return_val_if_fail(KZ_IS_APP(app), NULL);
-
-	return KZ_APP_GET_PRIVATE(app)->history_time_stamp;
-}
-
-const gchar *
-kz_app_get_popup_dir (KzApp *app)
-{
-	g_return_val_if_fail(KZ_IS_APP(app), NULL);
-
-	return KZ_APP_GET_PRIVATE(app)->popup_dir;
-}
-

Modified: kazehakase/trunk/src/kz-app.h
===================================================================
--- kazehakase/trunk/src/kz-app.h	2007-03-27 01:57:37 UTC (rev 3039)
+++ kazehakase/trunk/src/kz-app.h	2007-03-27 02:41:35 UTC (rev 3040)
@@ -55,6 +55,13 @@
 
 KzApp     *kz_app_new           (gint argc, gchar **argv);
 
+const gchar	*kz_app_get_user_dir		(KzApp *app);
+const gchar	*kz_app_get_history_dir		(KzApp *app);
+const gchar	*kz_app_get_history_time_stamp	(KzApp *app);
+const gchar	*kz_app_get_popup_dir		(KzApp *app);
+const gchar	*kz_app_get_system_data_dir	(KzApp *app);
+const gchar	*kz_app_get_system_ruby_ext_dir	(KzApp *app);
+
 GtkWidget *kz_app_create_new_window (KzApp *app, const gchar *uri);
 
 GtkWidget *kz_app_restore_session   (KzApp *app);
@@ -85,10 +92,6 @@
 KzMigemo       *kz_app_get_migemo          (KzApp *app);
 #endif
 
-const gchar	*kz_app_get_history_dir		(KzApp *app);
-const gchar	*kz_app_get_history_time_stamp	(KzApp *app);
-const gchar	*kz_app_get_popup_dir		(KzApp *app);
-
 G_END_DECLS
 
 #endif /* __KZ_APP_H__ */




More information about the Kazehakase-cvs mailing list
Back to archive index