svnno****@sourc*****
svnno****@sourc*****
Wed Mar 28 12:53:51 JST 2007
Revision: 3081 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3081 Author: kous Date: 2007-03-28 12:53:51 +0900 (Wed, 28 Mar 2007) Log Message: ----------- * src/main.c: used relative path for gettext on Windows. * src/utils/utils.[ch]: added kz_win32_base_path(). * src/widget/kz-thumbnail.c: used KZ_GET_SYSTEM_KZ_DATA_DIR instead of KZ_GET_SYSTEM_DATA_DIR. * src/kz-autoscroller.c, src/dialogs/kz-about-dialog.c, src/bookmarks/kz-bookmark-editor.c, src/kz-icons.c, src/kz-window.c: used KZ_GET_XXX. * src/kz-app.[ch], src/kazehakase.h: added system_kz_data_dir, system_icons_dir and system_pixmaps_dir. * src/kz-app.c: moved kz_icons_init() to kz_app_init_dependencies(). Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/src/bookmarks/kz-bookmark-editor.c kazehakase/trunk/src/dialogs/kz-about-dialog.c kazehakase/trunk/src/kazehakase.h kazehakase/trunk/src/kz-app.c kazehakase/trunk/src/kz-app.h kazehakase/trunk/src/kz-autoscroller.c kazehakase/trunk/src/kz-icons.c kazehakase/trunk/src/kz-window.c kazehakase/trunk/src/main.c kazehakase/trunk/src/utils/utils.c kazehakase/trunk/src/utils/utils.h kazehakase/trunk/src/widget/kz-thumbnail.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/ChangeLog 2007-03-28 03:53:51 UTC (rev 3081) @@ -1,3 +1,22 @@ +2007-03-28 Kouhei Sutou <kou****@cozmi*****> + + * src/main.c: used relative path for gettext on Windows. + + * src/utils/utils.[ch]: added kz_win32_base_path(). + + * src/widget/kz-thumbnail.c: used KZ_GET_SYSTEM_KZ_DATA_DIR + instead of KZ_GET_SYSTEM_DATA_DIR. + + * src/kz-autoscroller.c, src/dialogs/kz-about-dialog.c, + src/bookmarks/kz-bookmark-editor.c, src/kz-icons.c, + src/kz-window.c: used KZ_GET_XXX. + + * src/kz-app.[ch], src/kazehakase.h: added system_kz_data_dir, + system_icons_dir and system_pixmaps_dir. + + * src/kz-app.c: moved kz_icons_init() to + kz_app_init_dependencies(). + 2007-03-28 Hiroyuki Ikezoe <poinc****@ikezo*****> * src/kz-notebook.[ch]: New APIs. Modified: kazehakase/trunk/src/bookmarks/kz-bookmark-editor.c =================================================================== --- kazehakase/trunk/src/bookmarks/kz-bookmark-editor.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/bookmarks/kz-bookmark-editor.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -123,6 +123,7 @@ GtkAccelGroup *accel_group; GtkUIManager *menu_merge; GError *err = NULL; + gchar *ui_file_name; g_object_set(G_OBJECT(editor), "allow-shrink", TRUE, NULL); @@ -145,9 +146,10 @@ gtk_ui_manager_insert_action_group(menu_merge, actions, 0); g_signal_connect(menu_merge, "add_widget", G_CALLBACK(cb_menu_merge_add_widget), main_vbox); - gtk_ui_manager_add_ui_from_file(menu_merge, - KZ_SYSCONFDIR"/kz-ui-bookmarks.xml", - &err); + ui_file_name = g_build_filename(KZ_GET_SYSTEM_CONFIG_DIR, + "kz-ui-bookmarks.xml", NULL); + gtk_ui_manager_add_ui_from_file(menu_merge, ui_file_name, &err); + g_free(ui_file_name); if (err) { g_warning("%s", err->message); Modified: kazehakase/trunk/src/dialogs/kz-about-dialog.c =================================================================== --- kazehakase/trunk/src/dialogs/kz-about-dialog.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/dialogs/kz-about-dialog.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -157,7 +157,7 @@ GTK_STOCK_OK, GTK_RESPONSE_NONE, NULL); - + gtk_window_set_type_hint (GTK_WINDOW (about_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_wmclass (GTK_WINDOW (about_dialog), @@ -165,14 +165,16 @@ gtk_window_set_position (GTK_WINDOW (about_dialog), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (about_dialog), FALSE); - pixmap_name = g_build_filename(KZ_DATADIR, "icons", "kz-logo-bg.png", NULL); + pixmap_name = g_build_filename(KZ_GET_SYSTEM_ICONS_DIR, + "kz-logo-bg.png", NULL); bg_pixmap = gtk_image_new_from_file(pixmap_name); image = gtk_image_get_pixbuf(GTK_IMAGE(bg_pixmap)); bg_width = gdk_pixbuf_get_width(image); bg_height = gdk_pixbuf_get_height(image); g_free(pixmap_name); - logo_name = g_build_filename(KZ_DATADIR, "icons", "kz-logo.png", NULL); + logo_name = g_build_filename(KZ_GET_SYSTEM_ICONS_DIR, + "kz-logo.png", NULL); logo_pixmap = gtk_image_new_from_file(logo_name); logo = gtk_image_get_pixbuf(GTK_IMAGE(logo_pixmap)); logo_width = gdk_pixbuf_get_width(logo); Modified: kazehakase/trunk/src/kazehakase.h =================================================================== --- kazehakase/trunk/src/kazehakase.h 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/kazehakase.h 2007-03-28 03:53:51 UTC (rev 3081) @@ -78,8 +78,11 @@ #define KZ_GET_CLIPS_DIR kz_app_get_clips_dir(kz_app) #define KZ_GET_THUMBNAILS_DIR kz_app_get_thumbnails_dir(kz_app) #define KZ_GET_SYSTEM_DATA_DIR kz_app_get_system_data_dir(kz_app) +#define KZ_GET_SYSTEM_KZ_DATA_DIR kz_app_get_system_kz_data_dir(kz_app) #define KZ_GET_SYSTEM_RUBY_EXT_DIR kz_app_get_system_ruby_ext_dir(kz_app) #define KZ_GET_SYSTEM_CONFIG_DIR kz_app_get_system_config_dir(kz_app) +#define KZ_GET_SYSTEM_ICONS_DIR kz_app_get_system_icons_dir(kz_app) +#define KZ_GET_SYSTEM_PIXMAPS_DIR kz_app_get_system_pixmaps_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-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/kz-app.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -26,7 +26,7 @@ #include <stdlib.h> #ifdef USE_SSL #include <gcrypt.h> -#include <gnutls/gnutls.h> +#include <gnutls/gnutls.h> #include <errno.h> #include <pthread.h> GCRY_THREAD_OPTION_PTHREAD_IMPL; @@ -92,8 +92,11 @@ gchar *clips_dir; gchar *thumbnails_dir; gchar *system_data_dir; + gchar *system_kz_data_dir; gchar *system_ruby_ext_dir; gchar *system_config_dir; + gchar *system_icons_dir; + gchar *system_pixmaps_dir; }; #define KZ_APP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_APP, KzAppPrivate)) @@ -244,9 +247,13 @@ { KzAppPrivate *priv = KZ_APP_GET_PRIVATE(app); - priv->user_dir = g_build_filename(g_get_home_dir(), - "."PACKAGE, - NULL); +#ifdef G_OS_WIN32 + priv->user_dir = g_build_filename(g_get_user_config_dir(), + PACKAGE, NULL); + g_printf("user_dir: %s\n", priv->user_dir); +#else + priv->user_dir = g_build_filename(g_get_home_dir(), "."PACKAGE, NULL); +#endif priv->history_dir = g_build_filename(priv->user_dir, "history", NULL); @@ -264,10 +271,27 @@ ".thumbnails", NULL); - priv->system_data_dir = g_strdup(KZ_DATADIR); +#ifdef G_OS_WIN32 + priv->system_data_dir = g_build_filename(kz_win32_base_path(), + "share", NULL); + priv->system_kz_data_dir = g_build_filename(priv->system_data_dir, + PACKAGE, NULL); + priv->system_ruby_ext_dir = g_build_filename(priv->system_kz_data_dir, + "ext", "ruby", NULL); + priv->system_config_dir = g_build_filename(kz_win32_base_path(), + "etc", PACKAGE, NULL); +#else + priv->system_data_dir = g_strdup(DATADIR); + priv->system_kz_data_dir = g_strdup(KZ_DATADIR); priv->system_ruby_ext_dir = g_strdup(KZ_RUBY_EXTDIR); priv->system_config_dir = g_strdup(KZ_SYSCONFDIR); +#endif + priv->system_icons_dir = g_build_filename(priv->system_kz_data_dir, + "icons", NULL); + priv->system_pixmaps_dir = g_build_filename(priv->system_data_dir, + "pixmaps", NULL); + ensure_directories(app); } @@ -286,8 +310,11 @@ g_free(priv->clips_dir); g_free(priv->thumbnails_dir); g_free(priv->system_data_dir); + g_free(priv->system_kz_data_dir); g_free(priv->system_ruby_ext_dir); g_free(priv->system_config_dir); + g_free(priv->system_icons_dir); + g_free(priv->system_pixmaps_dir); priv->user_dir = NULL; priv->history_dir = NULL; @@ -299,8 +326,11 @@ priv->clips_dir = NULL; priv->thumbnails_dir = NULL; priv->system_data_dir = NULL; + priv->system_kz_data_dir = NULL; priv->system_ruby_ext_dir = NULL; priv->system_config_dir = NULL; + priv->system_icons_dir = NULL; + priv->system_pixmaps_dir = NULL; } #define DEFINE_PATH_GETTER(name) \ @@ -322,8 +352,11 @@ DEFINE_PATH_GETTER(clips_dir) DEFINE_PATH_GETTER(thumbnails_dir) DEFINE_PATH_GETTER(system_data_dir) +DEFINE_PATH_GETTER(system_kz_data_dir) DEFINE_PATH_GETTER(system_ruby_ext_dir) DEFINE_PATH_GETTER(system_config_dir) +DEFINE_PATH_GETTER(system_icons_dir) +DEFINE_PATH_GETTER(system_pixmaps_dir) static void @@ -402,8 +435,6 @@ proxy_file = g_build_filename(priv->user_dir, "proxyrc", NULL); priv->proxy = kz_profile_open(proxy_file, sysproxy_file); - kz_icons_init(); - #ifdef USE_SSL /* initialize gnutls. this function should be called once. */ gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); @@ -527,6 +558,8 @@ g_return_if_fail(KZ_IS_APP(app)); + kz_icons_init(); + if (!kz_history_time_stamp_exists()) kz_history_make_time_stamp(); @@ -550,7 +583,6 @@ g_return_if_fail(KZ_IS_APP(app)); - priv = KZ_APP_GET_PRIVATE(app); kz_ext_exit(); Modified: kazehakase/trunk/src/kz-app.h =================================================================== --- kazehakase/trunk/src/kz-app.h 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/kz-app.h 2007-03-28 03:53:51 UTC (rev 3081) @@ -65,8 +65,11 @@ const gchar *kz_app_get_clips_dir (KzApp *app); const gchar *kz_app_get_thumbnails_dir (KzApp *app); const gchar *kz_app_get_system_data_dir (KzApp *app); +const gchar *kz_app_get_system_kz_data_dir (KzApp *app); const gchar *kz_app_get_system_ruby_ext_dir (KzApp *app); const gchar *kz_app_get_system_config_dir (KzApp *app); +const gchar *kz_app_get_system_icons_dir (KzApp *app); +const gchar *kz_app_get_system_pixmaps_dir (KzApp *app); GtkWidget *kz_app_create_new_window (KzApp *app, const gchar *uri); Modified: kazehakase/trunk/src/kz-autoscroller.c =================================================================== --- kazehakase/trunk/src/kz-autoscroller.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/kz-autoscroller.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -79,6 +79,7 @@ GdkPixmap *icon_pixmap = NULL; GdkBitmap *icon_bitmap = NULL; GtkWidget *icon_img; + gchar *icon_name; object_class = (GObjectClass *) klass; @@ -86,7 +87,10 @@ /* initialize the autoscroll icon */ - icon_pixbuf = gdk_pixbuf_new_from_file (KZ_DATADIR "/icons/autoscroll.xpm", NULL); + icon_name = g_build_filename(KZ_GET_SYSTEM_ICONS_DIR, + "autoscroll.xpm", NULL); + icon_pixbuf = gdk_pixbuf_new_from_file(icon_name, NULL); + g_free(icon_name); if(icon_pixbuf) { gdk_pixbuf_render_pixmap_and_mask (icon_pixbuf, &icon_pixmap, Modified: kazehakase/trunk/src/kz-icons.c =================================================================== --- kazehakase/trunk/src/kz-icons.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/kz-icons.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + /* * Copyright (C) 2003 Takuro Ashie * @@ -18,6 +20,7 @@ * $Id$ */ +#include "kazehakase.h" #include "kz-icons.h" #include <gtk/gtk.h> @@ -34,21 +37,18 @@ kz_icons_init (void) { GtkIconFactory *factory; - static gchar *dirname = NULL; GDir *dir; GError *error = NULL; const gchar *entry; + gchar *kz_icon_file_name; - if (!dirname) - dirname = g_build_filename(KZ_DATADIR, "icons", NULL); - - dir = g_dir_open(dirname, 0, &error); + dir = g_dir_open(KZ_GET_SYSTEM_ICONS_DIR, 0, &error); if (error) { - g_warning("%s", error->message); + g_warning("can't open icon directory: %s", error->message); g_error_free(error); + return; } - if (!dir) return; factory = gtk_icon_factory_new(); gtk_icon_factory_add_default(factory); @@ -81,7 +81,8 @@ icon_name[namelen] = '\0'; /* load icon file */ - filename = g_build_filename(dirname, entry, NULL); + filename = g_build_filename(KZ_GET_SYSTEM_ICONS_DIR, entry, + NULL); pixbuf = gdk_pixbuf_new_from_file(filename, NULL); g_free (filename); @@ -101,8 +102,10 @@ /* * regist kazehakase icon */ - kz_icon = gdk_pixbuf_new_from_file - (DATADIR "/pixmaps/kazehakase-icon.png", NULL); + kz_icon_file_name = g_build_filename(KZ_GET_SYSTEM_PIXMAPS_DIR, + "kazehakase-icon.png", NULL); + kz_icon = gdk_pixbuf_new_from_file(kz_icon_file_name, NULL); + g_free(kz_icon_file_name); if (kz_icon) { GtkIconSet *icon_set; Modified: kazehakase/trunk/src/kz-window.c =================================================================== --- kazehakase/trunk/src/kz-window.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/kz-window.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -638,23 +638,25 @@ { case KZ_UI_LEVEL_CUSTOM: action_str = "UILevelCustom"; - ui_file = g_build_filename(g_get_home_dir(), - "."PACKAGE, + ui_file = g_build_filename(KZ_GET_USER_DIR, "kz-ui.xml", NULL); break; case KZ_UI_LEVEL_EXPERT: action_str = "UILevelExpert"; - ui_file = g_strdup(KZ_SYSCONFDIR"/kz-ui-expert.xml"); + ui_file = g_build_filename(KZ_GET_SYSTEM_CONFIG_DIR, + "kz-ui-expert.xml", NULL); break; case KZ_UI_LEVEL_MEDIUM: action_str = "UILevelMedium"; - ui_file = g_strdup(KZ_SYSCONFDIR"/kz-ui-medium.xml"); + ui_file = g_build_filename(KZ_GET_SYSTEM_CONFIG_DIR, + "kz-ui-medium.xml", NULL); break; case KZ_UI_LEVEL_BEGINNER: default: action_str = "UILevelBeginner"; - ui_file = g_strdup(KZ_SYSCONFDIR"/kz-ui-beginner.xml"); + ui_file = g_build_filename(KZ_GET_SYSTEM_CONFIG_DIR, + "kz-ui-beginner.xml", NULL); break; } @@ -686,7 +688,7 @@ gtk_ui_manager_ensure_update(kz->menu_merge); /* update bookmarks */ - widget = gtk_ui_manager_get_widget(kz->menu_merge, + widget = gtk_ui_manager_get_widget(kz->menu_merge, "/menubar/BookmarksMenu"); if (GTK_IS_MENU_ITEM(widget)) widget = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget)); Modified: kazehakase/trunk/src/main.c =================================================================== --- kazehakase/trunk/src/main.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/main.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -427,7 +427,17 @@ gboolean restore = FALSE; /* initialize */ +#ifdef G_OS_WIN32 + { + gchar *locale_dir; + locale_dir = g_build_filename(kz_win32_base_path(), + "share", "locale", NULL); + bindtextdomain(PACKAGE, locale_dir); + g_free(locale_dir); + } +#else bindtextdomain(PACKAGE, LOCALEDIR); +#endif bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); Modified: kazehakase/trunk/src/utils/utils.c =================================================================== --- kazehakase/trunk/src/utils/utils.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/utils/utils.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -1060,3 +1060,18 @@ return last_component_encoded_uri; } + +#ifdef G_OS_WIN32 +static gchar *win32_base_path = NULL; + +const gchar * +kz_win32_base_path (void) +{ + if (win32_base_path) + return win32_base_path; + + win32_base_path = g_win32_get_package_installation_directory(PACKAGE, + NULL); + return win32_base_path; +} +#endif Modified: kazehakase/trunk/src/utils/utils.h =================================================================== --- kazehakase/trunk/src/utils/utils.h 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/utils/utils.h 2007-03-28 03:53:51 UTC (rev 3081) @@ -82,6 +82,10 @@ gchar *kz_uri_encode_last_component (const gchar *uri); +#ifdef G_OS_WIN32 +const gchar *kz_win32_base_path (void); +#endif + G_END_DECLS #endif /* __UTILS_H__ */ Modified: kazehakase/trunk/src/widget/kz-thumbnail.c =================================================================== --- kazehakase/trunk/src/widget/kz-thumbnail.c 2007-03-28 03:13:30 UTC (rev 3080) +++ kazehakase/trunk/src/widget/kz-thumbnail.c 2007-03-28 03:53:51 UTC (rev 3081) @@ -86,7 +86,7 @@ gchar *dummy_file_name; GdkPixbuf *dummy; - dummy_file_name = g_build_filename(KZ_GET_SYSTEM_DATA_DIR, + dummy_file_name = g_build_filename(KZ_GET_SYSTEM_KZ_DATA_DIR, "kz-no-thumbnail.png", NULL); dummy = gdk_pixbuf_new_from_file(dummy_file_name, NULL);