[gtranslator] Fix pixmaps paths



commit 823319ade0fd38561286d2d00b7a795cbbfaed9b
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Jan 27 23:27:47 2010 +0100

    Fix pixmaps paths

 data/desktop/Makefile.am                  |    2 +-
 data/pixmaps/Makefile.am                  |    2 +-
 src/Makefile.am                           |    2 +
 src/actions-file.c                        |    5 +-
 src/application.c                         |   56 +++++---
 src/dialogs/Makefile.am                   |    3 +-
 src/dialogs/comment-dialog.c              |    3 +-
 src/dialogs/header-dialog.c               |    4 +-
 src/dialogs/jump-dialog.c                 |   23 ++--
 src/dialogs/preferences-dialog.c          |    9 +-
 src/dialogs/profile-dialog.c              |   41 +++---
 src/dialogs/search-dialog.c               |   27 ++--
 src/dirs.c                                |  208 +++++++++++++++++++++++++++++
 src/dirs.h                                |   56 ++++++++
 src/main.c                                |   49 +++----
 src/prefs-manager-app.c                   |    5 +-
 src/translation-memory/berkeley/db-base.c |   17 ++-
 src/utils.c                               |  121 +----------------
 src/view.c                                |   24 ++--
 src/window.c                              |   22 ++-
 20 files changed, 429 insertions(+), 250 deletions(-)
---
diff --git a/data/desktop/Makefile.am b/data/desktop/Makefile.am
index 4a1b7f5..33e6e11 100644
--- a/data/desktop/Makefile.am
+++ b/data/desktop/Makefile.am
@@ -4,7 +4,7 @@
 ## the dirs where all the DATA should go ..
 ##
 Applicationdir = $(datadir)/applications
-Applicationicondir = $(datadir)/pixmaps
+Applicationicondir = $(datadir)/gtranslator/pixmaps
 
 ##
 ## and the DATA
diff --git a/data/pixmaps/Makefile.am b/data/pixmaps/Makefile.am
index 6957132..5f2d20c 100644
--- a/data/pixmaps/Makefile.am
+++ b/data/pixmaps/Makefile.am
@@ -1,4 +1,4 @@
-icondir = $(datadir)/pixmaps/gtranslator
+icondir = $(datadir)/gtranslator/pixmaps
 icon_DATA =	\
 	gtranslator-plugin.png \
 	gtranslator-fuzzy-next.png \
diff --git a/src/Makefile.am b/src/Makefile.am
index 213971a..668ded6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -89,6 +89,8 @@ header_DATA = \
 libgtranslator_la_SOURCES = \
 	$(BUILT_SOURCES) \
 	application.c \
+	dirs.h \
+	dirs.c \
 	message-table.c \
 	message-table-model.c \
 	message-table-model.h \
diff --git a/src/actions-file.c b/src/actions-file.c
index edf91ed..81f1f02 100644
--- a/src/actions-file.c
+++ b/src/actions-file.c
@@ -763,8 +763,9 @@ gtranslator_file_quit (GtkAction * action, GtranslatorWindow * window)
   GFile *file, *file_temp;
   gint r;
 
-  config_folder = gtranslator_utils_get_user_config_dir ();
+  config_folder = gtranslator_dirs_get_user_config_dir ();
   filename = g_build_filename (config_folder, "profiles.xml", NULL);
+  g_free (config_folder);
   filename_temp = g_build_filename (g_get_tmp_dir (), "profiles.xml", NULL);
 
   file = g_file_new_for_path (filename);
@@ -772,7 +773,6 @@ gtranslator_file_quit (GtkAction * action, GtranslatorWindow * window)
 
   profiles_list = gtranslator_application_get_profiles (GTR_APP);
 
-
   if (profiles_list != NULL)
     {
       if (g_file_query_exists (file_temp, NULL))
@@ -797,7 +797,6 @@ gtranslator_file_quit (GtkAction * action, GtranslatorWindow * window)
 	}
     }
 
-  g_free (config_folder);
   g_object_unref (file_temp);
   g_object_unref (file);
 
diff --git a/src/application.c b/src/application.c
index b24d223..f9800f7 100644
--- a/src/application.c
+++ b/src/application.c
@@ -25,6 +25,7 @@
 #endif
 
 #include "application.h"
+#include "dirs.h"
 #include "utils.h"
 #include "window.h"
 #include "egg-toolbars-model.h"
@@ -32,8 +33,6 @@
 #include "./translation-memory/translation-memory.h"
 #include "./translation-memory/berkeley/berkeley.h"
 
-
-
 #include <glib.h>
 #include <glib-object.h>
 #include <gio/gio.h>
@@ -46,31 +45,33 @@
 					 GtranslatorApplicationPrivate))
 
 G_DEFINE_TYPE (GtranslatorApplication, gtranslator_application, G_TYPE_OBJECT)
-     struct _GtranslatorApplicationPrivate
-     {
-       GList *windows;
-       GtranslatorWindow *active_window;
 
-       GList *profiles;
-       GtranslatorProfile *active_profile;
+struct _GtranslatorApplicationPrivate
+{
+  GList *windows;
+  GtranslatorWindow *active_window;
 
-       gchar *toolbars_file;
-       EggToolbarsModel *toolbars_model;
+  GList *profiles;
+  GtranslatorProfile *active_profile;
 
-       GtkIconFactory *icon_factory;
+  gchar *toolbars_file;
+  EggToolbarsModel *toolbars_model;
 
-       gchar *last_dir;
+  GtkIconFactory *icon_factory;
 
-       GtranslatorTranslationMemory *tm;
+  gchar *last_dir;
 
-       gboolean first_run;
-     };
+  GtranslatorTranslationMemory *tm;
 
-     static gchar *get_accel_file (void)
+  gboolean first_run;
+};
+
+static gchar *
+get_accel_file (void)
 {
   gchar *config;
 
-  config = gtranslator_utils_get_user_config_dir ();
+  config = gtranslator_dirs_get_user_config_dir ();
 
   if (config != NULL)
     {
@@ -130,6 +131,7 @@ gtranslator_application_init (GtranslatorApplication * application)
   gchar *gtranslator_folder;
   gchar *path_default_gtr_toolbar;
   gchar *profiles_file;
+  gchar *dir;
 
   GtranslatorApplicationPrivate *priv;
 
@@ -144,7 +146,7 @@ gtranslator_application_init (GtranslatorApplication * application)
   /*
    * Creating config folder
    */
-  gtranslator_folder = gtranslator_utils_get_user_config_dir ();
+  gtranslator_folder = gtranslator_dirs_get_user_config_dir ();
 
   if (!g_file_test (gtranslator_folder, G_FILE_TEST_IS_DIR))
     {
@@ -194,11 +196,15 @@ gtranslator_application_init (GtranslatorApplication * application)
 
   priv->toolbars_file = g_build_filename (gtranslator_folder,
 					  "gtr-toolbar.xml", NULL);
-  path_default_gtr_toolbar =
-    gtranslator_utils_get_file_from_pkgdatadir ("gtr-toolbar.xml");
 
   g_free (gtranslator_folder);
 
+  dir = gtranslator_dirs_get_gtranslator_data_dir ();
+  path_default_gtr_toolbar = g_build_filename (dir,
+                                               "gtr-toolbar.xml",
+                                               NULL);
+  g_free (dir);
+
   egg_toolbars_model_load_names (priv->toolbars_model,
 				 path_default_gtr_toolbar);
 
@@ -511,11 +517,17 @@ gtranslator_application_register_icon (GtranslatorApplication * app,
 {
   GtkIconSet *icon_set;
   GtkIconSource *icon_source = gtk_icon_source_new ();
+  gchar *pixmaps_dir;
   gchar *path;
+  GdkPixbuf *pixbuf;
 
-  path = gtranslator_utils_get_file_from_pixmapsdir (icon);
+  pixmaps_dir = gtranslator_dirs_get_pixmaps_dir ();
+  path = g_build_filename (pixmaps_dir,
+                           icon,
+                           NULL);
+  g_free (pixmaps_dir);
 
-  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+  pixbuf = gdk_pixbuf_new_from_file (path, NULL);
   if (pixbuf)
     {
       icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index bd61b1e..3e39132 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -33,8 +33,7 @@ libdialogs_la_SOURCES = \
 	jump-dialog.c \
 	jump-dialog.h
 
-uidir = $(pkgdatadir)
-
+uidir = $(pkgdatadir)/ui
 ui_DATA =  \
 		preferences-dialog.ui \
 		search-dialog.ui \
diff --git a/src/dialogs/comment-dialog.c b/src/dialogs/comment-dialog.c
index e82eda6..74c54fc 100644
--- a/src/dialogs/comment-dialog.c
+++ b/src/dialogs/comment-dialog.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #endif
 
+#include "dirs.h"
 #include "po.h"
 #include "comment-dialog.h"
 #include "tab.h"
@@ -109,7 +110,7 @@ gtranslator_comment_dialog_init (GtranslatorCommentDialog * dlg)
 		    "response", G_CALLBACK (dialog_response_handler), NULL);
 
   /*Glade */
-  path = gtranslator_utils_get_file_from_pkgdatadir ("comment-dialog.ui");
+  path = gtranslator_dirs_get_ui_file ("comment-dialog.ui");
   ret = gtranslator_utils_get_ui_objects (path,
 					  root_objects,
 					  &error_widget,
diff --git a/src/dialogs/header-dialog.c b/src/dialogs/header-dialog.c
index 52b93c9..98ecb78 100644
--- a/src/dialogs/header-dialog.c
+++ b/src/dialogs/header-dialog.c
@@ -28,6 +28,7 @@
 #include <string.h>
 
 #include "application.h"
+#include "dirs.h"
 #include "header-dialog.h"
 #include "utils.h"
 #include "prefs-manager.h"
@@ -269,8 +270,7 @@ gtranslator_header_dialog_init (GtranslatorHeaderDialog * dlg)
 
   g_signal_connect (dlg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
 
-  path = gtranslator_utils_get_file_from_pkgdatadir ("header-dialog.ui");
-
+  path = gtranslator_dirs_get_ui_file ("header-dialog.ui");
   ret = gtranslator_utils_get_ui_objects (path,
 					  root_objects,
 					  &error_widget,
diff --git a/src/dialogs/jump-dialog.c b/src/dialogs/jump-dialog.c
index da777f8..d6307e4 100644
--- a/src/dialogs/jump-dialog.c
+++ b/src/dialogs/jump-dialog.c
@@ -20,6 +20,7 @@
 #include <config.h>
 #endif
 
+#include "dirs.h"
 #include "jump-dialog.h"
 #include "tab.h"
 #include "utils.h"
@@ -39,15 +40,17 @@
 
 G_DEFINE_TYPE (GtranslatorJumpDialog, gtranslator_jump_dialog,
 	       GTK_TYPE_DIALOG)
-     struct _GtranslatorJumpDialogPrivate
-     {
-       GtkWidget *main_box;
-       GtkWidget *jump;
 
-       GtranslatorWindow *window;
-     };
+struct _GtranslatorJumpDialogPrivate
+{
+  GtkWidget *main_box;
+  GtkWidget *jump;
+
+  GtranslatorWindow *window;
+};
 
-     static void dialog_response_handler (GtkDialog * dlg, gint res_id)
+static void
+dialog_response_handler (GtkDialog * dlg, gint res_id)
 {
   GtranslatorJumpDialog *dialog = GTR_JUMP_DIALOG (dlg);
   GtranslatorTab *tab;
@@ -74,12 +77,12 @@ gtranslator_jump_dialog_init (GtranslatorJumpDialog * dlg)
 {
   gboolean ret;
   GtkWidget *error_widget;
+  gchar *path;
   gchar *root_objects[] = {
     "adjustment1",
     "main_box",
     NULL
   };
-  gchar *path;
 
   dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
 
@@ -107,7 +110,7 @@ gtranslator_jump_dialog_init (GtranslatorJumpDialog * dlg)
 		    "response", G_CALLBACK (dialog_response_handler), NULL);
 
   /*Glade */
-  path = gtranslator_utils_get_file_from_pkgdatadir ("jump-dialog.ui");
+  path = gtranslator_dirs_get_ui_file ("jump-dialog.ui");
   ret = gtranslator_utils_get_ui_objects (path,
 					  root_objects,
 					  &error_widget,
@@ -128,8 +131,6 @@ gtranslator_jump_dialog_init (GtranslatorJumpDialog * dlg)
 		      dlg->priv->main_box, TRUE, TRUE, 0);
 
   gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
-
-
 }
 
 static void
diff --git a/src/dialogs/preferences-dialog.c b/src/dialogs/preferences-dialog.c
index f203b4d..5464031 100644
--- a/src/dialogs/preferences-dialog.c
+++ b/src/dialogs/preferences-dialog.c
@@ -26,6 +26,7 @@
 #endif
 
 #include "application.h"
+#include "dirs.h"
 #include "preferences-dialog.h"
 #include "prefs-manager.h"
 #include "profile.h"
@@ -437,9 +438,12 @@ active_toggled_cb (GtkCellRendererToggle * cell_renderer,
   GFile *file;
 
 
-  config_folder = gtranslator_utils_get_user_config_dir ();
+  config_folder = gtranslator_dirs_get_user_config_dir ();
   filename = g_build_filename (config_folder, "profiles.xml", NULL);
+  g_free (config_folder);
+
   file = g_file_new_for_path (filename);
+  g_free (filename);
 
   path = gtk_tree_path_new_from_string (path_str);
 
@@ -473,6 +477,7 @@ active_toggled_cb (GtkCellRendererToggle * cell_renderer,
 	    }
 	}
     }
+
   gtk_list_store_clear (GTK_LIST_STORE (model));
   gtranslator_preferences_fill_profile_treeview (dlg, model);
   gtk_tree_path_free (path);
@@ -1195,7 +1200,7 @@ gtranslator_preferences_dialog_init (GtranslatorPreferencesDialog * dlg)
 
   /*Glade */
 
-  path = gtranslator_utils_get_file_from_pkgdatadir ("preferences-dialog.ui");
+  path = gtranslator_dirs_get_ui_file ("preferences-dialog.ui");
   ret = gtranslator_utils_get_ui_objects (path,
 					  root_objects,
 					  &error_widget,
diff --git a/src/dialogs/profile-dialog.c b/src/dialogs/profile-dialog.c
index c205c23..29e36cd 100644
--- a/src/dialogs/profile-dialog.c
+++ b/src/dialogs/profile-dialog.c
@@ -24,6 +24,7 @@
 #endif
 
 #include "application.h"
+#include "dirs.h"
 #include "profile-dialog.h"
 #include "preferences-dialog.h"
 #include "profile.h"
@@ -44,29 +45,31 @@
 
 G_DEFINE_TYPE (GtranslatorProfileDialog, gtranslator_profile_dialog,
 	       GTK_TYPE_DIALOG)
-     struct _GtranslatorProfileDialogPrivate
-     {
-       GtkWidget *main_box;
 
-       GtkWidget *profile_name_entry;
+struct _GtranslatorProfileDialogPrivate
+{
+  GtkWidget *main_box;
+
+  GtkWidget *profile_name_entry;
 
-       GtkWidget *author_name_entry;
-       GtkWidget *author_email_entry;
+  GtkWidget *author_name_entry;
+  GtkWidget *author_email_entry;
 
-       GtkWidget *language_name_entry;
-       GtkWidget *language_code_entry;
-       GtkWidget *charset_entry;
-       GtkWidget *encoding_entry;
-       GtkWidget *language_email_entry;
-       GtkWidget *plurals_forms_entry;
+  GtkWidget *language_name_entry;
+  GtkWidget *language_code_entry;
+  GtkWidget *charset_entry;
+  GtkWidget *encoding_entry;
+  GtkWidget *language_email_entry;
+  GtkWidget *plurals_forms_entry;
 
-       GtranslatorPreferencesDialog *prefs_dlg;
+  GtranslatorPreferencesDialog *prefs_dlg;
 
-       GtranslatorProfile *new_profile;
-       GtranslatorProfile *old_profile;
-     };
+  GtranslatorProfile *new_profile;
+  GtranslatorProfile *old_profile;
+};
 
-     static void gtranslator_profile_dialog_finalize (GObject * object)
+static void
+gtranslator_profile_dialog_finalize (GObject * object)
 {
   G_OBJECT_CLASS (gtranslator_profile_dialog_parent_class)->finalize (object);
 }
@@ -364,11 +367,11 @@ gtranslator_profile_dialog_init (GtranslatorProfileDialog * dlg)
 {
   gboolean ret;
   GtkWidget *error_widget;
+  gchar *path;
   gchar *root_objects[] = {
     "profiles_dialog",
     NULL
   };
-  gchar *path;
 
   dlg->priv = GTR_PROFILE_DIALOG_GET_PRIVATE (dlg);
 
@@ -380,7 +383,7 @@ gtranslator_profile_dialog_init (GtranslatorProfileDialog * dlg)
   gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
   gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2);
 
-  path = gtranslator_utils_get_file_from_pkgdatadir ("profile-dialog.ui");
+  path = gtranslator_dirs_get_ui_file ("profile-dialog.ui");
   ret = gtranslator_utils_get_ui_objects (path,
 					  root_objects,
 					  &error_widget,
diff --git a/src/dialogs/search-dialog.c b/src/dialogs/search-dialog.c
index e93df57..fecaf4a 100644
--- a/src/dialogs/search-dialog.c
+++ b/src/dialogs/search-dialog.c
@@ -37,6 +37,7 @@
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 
+#include "dirs.h"
 #include "search-dialog.h"
 #include "history-entry.h"
 #include "utils.h"
@@ -82,17 +83,17 @@ struct _GtranslatorSearchDialogPrivate
 
 G_DEFINE_TYPE (GtranslatorSearchDialog, gtranslator_search_dialog,
 	       GTK_TYPE_DIALOG)
-     enum
-     {
-       PROP_0,
-       PROP_SHOW_REPLACE
-     };
-
-     static void
-       gtranslator_search_dialog_set_property (GObject * object,
-					       guint prop_id,
-					       const GValue * value,
-					       GParamSpec * pspec)
+enum
+{
+  PROP_0,
+  PROP_SHOW_REPLACE
+};
+
+static void
+gtranslator_search_dialog_set_property (GObject * object,
+					guint prop_id,
+					const GValue * value,
+					GParamSpec * pspec)
 {
   GtranslatorSearchDialog *dlg = GTR_SEARCH_DIALOG (object);
 
@@ -365,11 +366,11 @@ gtranslator_search_dialog_init (GtranslatorSearchDialog * dlg)
   GtkWidget *content;
   GtkWidget *error_widget;
   gboolean ret;
+  gchar *path;
   gchar *root_objects[] = {
     "search_dialog_content",
     NULL
   };
-  gchar *path;
 
   dlg->priv = GTR_SEARCH_DIALOG_GET_PRIVATE (dlg);
 
@@ -387,7 +388,7 @@ gtranslator_search_dialog_init (GtranslatorSearchDialog * dlg)
 				  (GTK_DIALOG (dlg)->action_area), 5);
   gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 6);
 
-  path = gtranslator_utils_get_file_from_pkgdatadir ("search-dialog.ui");
+  path = gtranslator_dirs_get_ui_file ("search-dialog.ui");
   ret = gtranslator_utils_get_ui_objects (path,
 					  root_objects,
 					  &error_widget,
diff --git a/src/dirs.c b/src/dirs.c
new file mode 100644
index 0000000..e107a13
--- /dev/null
+++ b/src/dirs.c
@@ -0,0 +1,208 @@
+/*
+ * gtranslator-dirs.c
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2008 Ignacio Casal Quinteiro
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, 
+ * Boston, MA 02111-1307, USA. 
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "dirs.h"
+
+gchar *
+gtranslator_dirs_get_user_config_dir (void)
+{
+	gchar *config_dir = NULL;
+
+	config_dir = g_build_filename (g_get_user_config_dir (),
+				       "gtranslator",
+				       NULL);
+
+	return config_dir;
+}
+
+gchar *
+gtranslator_dirs_get_user_cache_dir (void)
+{
+	const gchar *cache_dir;
+
+	cache_dir = g_get_user_cache_dir ();
+
+	return g_build_filename (cache_dir,
+				 "gtranslator",
+				 NULL);
+}
+
+gchar *
+gtranslator_dirs_get_user_plugins_dir (void)
+{
+	gchar *config_dir;
+	gchar *plugin_dir;
+
+	config_dir = gtranslator_dirs_get_user_config_dir ();
+
+	plugin_dir = g_build_filename (config_dir,
+				       "plugins",
+				       NULL);
+	g_free (config_dir);
+	
+	return plugin_dir;
+}
+
+gchar *
+gtranslator_dirs_get_user_accels_file (void)
+{
+	gchar *accels = NULL;
+	gchar *config_dir = NULL;
+
+	config_dir = gtranslator_dirs_get_user_config_dir ();
+	accels = g_build_filename (config_dir,
+				   "accels",
+				   "gtranslator",
+				   NULL);
+
+	g_free (config_dir);
+
+	return accels;
+}
+
+gchar *
+gtranslator_dirs_get_gtranslator_data_dir (void)
+{
+	gchar *data_dir;
+
+#ifdef G_OS_WIN32
+	gchar *win32_dir;
+	
+	win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+
+	data_dir = g_build_filename (win32_dir,
+				     "share",
+				     "gtranslator",
+				     NULL);
+	
+	g_free (win32_dir);
+#else
+	data_dir = g_build_filename (DATADIR,
+	                             "gtranslator",
+	                             NULL);
+#endif
+
+	return data_dir;
+}
+
+gchar *
+gtranslator_dirs_get_gtranslator_locale_dir (void)
+{
+	gchar *locale_dir;
+
+#ifdef G_OS_WIN32
+	gchar *win32_dir;
+	
+	win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+
+	locale_dir = g_build_filename (win32_dir,
+				       "share",
+				       "locale",
+				       NULL);
+	
+	g_free (win32_dir);
+#else
+	locale_dir = g_build_filename (DATADIR,
+				       "locale",
+				       NULL);
+#endif
+
+	return locale_dir;
+}
+
+gchar *
+gtranslator_dirs_get_gtranslator_lib_dir (void)
+{
+	gchar *lib_dir;
+
+#ifdef G_OS_WIN32
+	gchar *win32_dir;
+	
+	win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+
+	lib_dir = g_build_filename (win32_dir,
+				    "lib",
+				    "gtranslator",
+				    NULL);
+	
+	g_free (win32_dir);
+#else
+	lib_dir = g_build_filename (LIBDIR,
+				    "gtranslator",
+				    NULL);
+#endif
+
+	return lib_dir;
+}
+
+gchar *
+gtranslator_dirs_get_gtranslator_plugins_dir (void)
+{
+	gchar *lib_dir;
+	gchar *plugin_dir;
+	
+	lib_dir = gtranslator_dirs_get_gtranslator_lib_dir ();
+	
+	plugin_dir = g_build_filename (lib_dir,
+				       "plugins",
+				       NULL);
+	g_free (lib_dir);
+	
+	return plugin_dir;
+}
+
+gchar *
+gtranslator_dirs_get_ui_file (const gchar *file)
+{
+	gchar *datadir;
+	gchar *ui_file;
+
+	g_return_val_if_fail (file != NULL, NULL);
+	
+	datadir = gtranslator_dirs_get_gtranslator_data_dir ();
+	ui_file = g_build_filename (datadir,
+				    "ui",
+				    file,
+				    NULL);
+	g_free (datadir);
+	
+	return ui_file;
+}
+
+gchar *
+gtranslator_dirs_get_pixmaps_dir (void)
+{
+	gchar *datadir;
+	gchar *pixmapsdir;
+	
+	datadir = gtranslator_dirs_get_gtranslator_data_dir ();
+	pixmapsdir = g_build_filename (datadir,
+				       "pixmaps",
+				       NULL);
+	g_free (datadir);
+	
+	return pixmapsdir;
+}
diff --git a/src/dirs.h b/src/dirs.h
new file mode 100644
index 0000000..e926249
--- /dev/null
+++ b/src/dirs.h
@@ -0,0 +1,56 @@
+/*
+ * gtranslator-dirs.h
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2008 Ignacio Casal Quinteiro
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, 
+ * Boston, MA 02111-1307, USA. 
+ */
+
+
+#ifndef __GEDIT_DIRS_H__
+#define __GEDIT_DIRS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gchar		*gtranslator_dirs_get_user_config_dir		(void);
+
+gchar		*gtranslator_dirs_get_user_cache_dir		(void);
+
+gchar		*gtranslator_dirs_get_user_plugins_dir		(void);
+
+gchar		*gtranslator_dirs_get_user_accels_file		(void);
+
+gchar		*gtranslator_dirs_get_gtranslator_data_dir	(void);
+
+gchar		*gtranslator_dirs_get_gtranslator_locale_dir	(void);
+
+gchar		*gtranslator_dirs_get_gtranslator_lib_dir	(void);
+
+gchar		*gtranslator_dirs_get_gtranslator_plugins_dir	(void);
+
+gchar		*gtranslator_dirs_get_gtranslator_plugin_loaders_dir
+								(void);
+
+gchar		*gtranslator_dirs_get_ui_file			(const gchar *file);
+
+gchar           *gtranslator_dirs_get_pixmaps_dir               (void);
+
+G_END_DECLS
+
+#endif /* __GEDIT_DIRS_H__ */
diff --git a/src/main.c b/src/main.c
index 15f7e9c..9f9c401 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,7 @@
 #include "prefs-manager-app.h"
 #include "plugins-engine.h"
 #include "utils.h"
+#include "dirs.h"
 
 #include <locale.h>
 #include <glib.h>
@@ -87,37 +88,35 @@ get_command_line_data ()
   return file_list;
 }
 
-
 /* This method is from the file gedit.c which is part of gedit */
 #ifdef G_OS_WIN32
 static void
 setup_path (void)
 {
-  /* Set PATH to include the gedit executable's folder */
-  wchar_t exe_filename[MAX_PATH];
-  wchar_t *p;
-  gchar *exe_folder_utf8;
   gchar *path;
+  gchar *installdir;
+  gchar *bin;
 
-  GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));
+  installdir = g_win32_get_package_installation_directory_of_module (NULL);
 
-  p = wcsrchr (exe_filename, L'\\');
-  g_assert (p != NULL);
+  bin = g_build_filename (installdir,
+                          "bin", NULL);
+  g_free (installdir);
 
-  *p = L'\0';
-  exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
+  /* Set PATH to include the gedit executable's folder */
+  path = g_build_path (";",
+                       bin,
+                       g_getenv ("PATH"),
+                       NULL);
+  g_free (bin);
 
-  path = g_build_path (";", exe_folder_utf8, g_getenv ("PATH"), NULL);
   if (!g_setenv ("PATH", path, TRUE))
-    g_warning ("Could not set PATH for gtranslator");
+    g_warning ("Could not set PATH for gedit");
 
-  g_free (exe_folder_utf8);
   g_free (path);
 }
 #endif
 
-
-
 /*
  * The ubiquitous main function...
  */
@@ -133,7 +132,7 @@ main (gint argc, gchar * argv[])
   gchar *config_folder;
   GList *profiles_list = NULL;
   GFile *file;
-  gchar *pixmapsdir;
+  gchar *pixmaps_dir;
   gchar *window_icon;
 
   /*
@@ -178,8 +177,10 @@ main (gint argc, gchar * argv[])
   /*
    * Show the application window with icon.
    */
-  window_icon =
-    gtranslator_utils_get_file_from_pixmapsdir ("gtranslator.png");
+  pixmaps_dir = gtranslator_dirs_get_pixmaps_dir ();
+  window_icon = g_build_filename (pixmaps_dir,
+  				  "gtranslator.png",
+  				  NULL);
   gtk_window_set_default_icon_from_file (window_icon, &error);
   g_free (window_icon);
   if (error)
@@ -189,14 +190,10 @@ main (gint argc, gchar * argv[])
       g_clear_error (&error);
     }
 
-  /*
-   * We set the default icon dir
-   */
-
-  pixmapsdir = gtranslator_utils_get_file_from_pixmapsdir (NULL);
+  /* We set the default icon dir */
   gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-				     pixmapsdir);
-  g_free (pixmapsdir);
+                                     pixmaps_dir);
+  g_free (pixmaps_dir);
 
   /*
    * Init preferences manager
@@ -215,7 +212,7 @@ main (gint argc, gchar * argv[])
   /*
    * Load profiles list
    */
-  config_folder = gtranslator_utils_get_user_config_dir ();
+  config_folder = gtranslator_dirs_get_user_config_dir ();
   filename = g_build_filename (config_folder, "profiles.xml", NULL);
   file = g_file_new_for_path (filename);
 
diff --git a/src/prefs-manager-app.c b/src/prefs-manager-app.c
index 7baa3a1..88af9d7 100644
--- a/src/prefs-manager-app.c
+++ b/src/prefs-manager-app.c
@@ -34,6 +34,7 @@
 #include <gdl/gdl.h>
 #endif
 
+#include "dirs.h"
 #include "prefs-manager.h"
 #include "prefs-manager-private.h"
 #include "prefs-manager-app.h"
@@ -123,7 +124,7 @@ get_gtranslator_state_file ()
 
       state_file = g_key_file_new ();
 
-      config_folder = gtranslator_utils_get_user_config_dir ();
+      config_folder = gtranslator_dirs_get_user_config_dir ();
       path = g_build_filename (config_folder, GTR_STATE_FILE_NAME, NULL);
       g_free (config_folder);
 
@@ -199,7 +200,7 @@ gtranslator_state_file_sync ()
   state_file = get_gtranslator_state_file ();
   g_return_val_if_fail (state_file != NULL, FALSE);
 
-  config_folder = gtranslator_utils_get_user_config_dir ();
+  config_folder = gtranslator_dirs_get_user_config_dir ();
   path = g_build_filename (config_folder, GTR_STATE_FILE_NAME, NULL);
   g_free (config_folder);
 
diff --git a/src/translation-memory/berkeley/db-base.c b/src/translation-memory/berkeley/db-base.c
index 69cac21..4f664b7 100644
--- a/src/translation-memory/berkeley/db-base.c
+++ b/src/translation-memory/berkeley/db-base.c
@@ -22,6 +22,7 @@
 #include <config.h>
 #endif
 
+#include "dirs.h"
 #include "utils.h"
 #include "db-base.h"
 #include DB_HEADER
@@ -38,18 +39,20 @@
 						 GtranslatorDbBasePrivate))
 
 G_DEFINE_TYPE (GtranslatorDbBase, gtranslator_db_base, G_TYPE_OBJECT)
-     struct _GtranslatorDbBasePrivate
-     {
-       DB *db;
-       gchar *path;
-     };
 
-     static gchar *get_db_base_directory ()
+struct _GtranslatorDbBasePrivate
+{
+  DB *db;
+  gchar *path;
+};
+
+static gchar *
+get_db_base_directory ()
 {
   gchar *config;
   gchar *db_dir;
 
-  config = gtranslator_utils_get_user_config_dir ();
+  config = gtranslator_dirs_get_user_config_dir ();
 
   db_dir = g_build_filename (config, "berkeley", NULL);
   g_free (config);
diff --git a/src/utils.c b/src/utils.c
index 335d868..dea574d 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -788,8 +788,8 @@ gtranslator_utils_help_display (GtkWindow * parent,
       if (strchr (lang, '.'))
 	continue;
 
-      path = gtranslator_utils_get_datadir ();
-      uri = g_build_filename (path, "/gnome/help/", doc_id,
+      path = gtranslator_dirs_get_gtranslator_data_dir ();
+      uri = g_build_filename (path, "gnome", "help", doc_id,
 			      lang, file_name, NULL);
       g_free (path);
 
@@ -835,19 +835,6 @@ gtranslator_utils_help_display (GtkWindow * parent,
   g_free (command);
 }
 
-/**
- * gtranslator_utils_get_user_config_dir:
- * 
- * Returns the default config dir for gtranslator.
- * 
- * Returns: the config dir for gtranslator.
- */
-gchar *
-gtranslator_utils_get_user_config_dir (void)
-{
-  return g_build_filename (g_get_user_config_dir (), "gtranslator", NULL);
-}
-
 gchar *
 gtranslator_utils_get_current_date (void)
 {
@@ -1016,107 +1003,3 @@ gtranslator_utils_escape_underscores (const gchar * text, gssize length)
 
   return g_string_free (str, FALSE);
 }
-
-/**
- * gtranslator_utils_get_file_from_pixmapsdir:
- * @filename: name of the file
- *
- * Returns the absolute path of a file that is located on the folder that contains 
- * the pixmaps. If filename is NULL returns the path to the folder PIXMAPSDIR
- */
-gchar *
-gtranslator_utils_get_file_from_pixmapsdir (const gchar * filename)
-{
-  gchar *path;
-
-#ifndef G_OS_WIN32
-  path = g_build_filename (WINDOW_ICON, NULL, NULL);
-#else
-  gchar *win32_dir;
-
-  win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
-  path = g_build_filename (win32_dir, "share", "pixmaps", filename, NULL);
-  g_free (win32_dir);
-#endif
-
-  return path;
-}
-
-
-/**
- * gtranslator_utils_get_file_from_pkgdatadir:
- * @filename: name of the file
- *
- * Returns the absolute path of a file that is located on the folder that contains 
- * the data of the package. If filename is NULL returns the path to the folder
- * that contains the data of the package.
- */
-gchar *
-gtranslator_utils_get_file_from_pkgdatadir (const gchar * filename)
-{
-  gchar *path;
-
-#ifndef G_OS_WIN32
-  path = g_build_filename (PKGDATADIR, filename, NULL);
-#else
-  gchar *win32_dir;
-
-  win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
-  path = g_build_filename (win32_dir, "share", "gtranslator", filename, NULL);
-  g_free (win32_dir);
-#endif
-
-  return path;
-}
-
-
-/**
- * gtranslator_utils_get_datadir:
- *
- * Returns the path to the DATADIR folder
- */
-
-gchar *
-gtranslator_utils_get_datadir (void)
-{
-  gchar *path;
-
-#ifndef G_OS_WIN32
-  path = g_build_filename (DATADIR, NULL);
-#else
-  gchar *win32_dir;
-
-  win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
-
-  path = g_build_filename (win32_dir, "share", NULL);
-
-  g_free (win32_dir);
-#endif
-
-  return path;
-}
-
-/**
- * gtranslator_utils_get_win32_plugindir:
- *
- * Returns the path to the GTR_PLUGINDIR folder on windows
- */
-gchar *
-gtranslator_utils_get_win32_plugindir (void)
-{
-  gchar *path;
-
-#ifndef G_OS_WIN32
-  path = NULL;
-#else
-  gchar *win32_dir;
-
-  win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
-
-  path = g_build_filename (win32_dir, "lib", "gtranslator", "plugins", NULL);
-
-  g_free (win32_dir);
-#endif
-
-  return path;
-}
diff --git a/src/view.c b/src/view.c
index 3dde15d..0e0c725 100644
--- a/src/view.c
+++ b/src/view.c
@@ -27,6 +27,7 @@
 
 #include <string.h>
 
+#include "dirs.h"
 #include "prefs-manager.h"
 #include "utils.h"
 #include "view.h"
@@ -51,18 +52,18 @@
 						 	GtranslatorViewPrivate))
 
 G_DEFINE_TYPE (GtranslatorView, gtranslator_view, GTK_TYPE_SOURCE_VIEW)
-     struct _GtranslatorViewPrivate
-     {
-       GtkSourceBuffer *buffer;
 
-       guint search_flags;
-       gchar *search_text;
+struct _GtranslatorViewPrivate
+{
+  GtkSourceBuffer *buffer;
+
+  guint search_flags;
+  gchar *search_text;
 
 #ifdef HAVE_GTKSPELL
-       GtkSpell *spell;
+  GtkSpell *spell;
 #endif
-     };
-
+};
 
 #ifdef HAVE_GTKSPELL
      static void gtranslator_attach_gtkspell (GtranslatorView * view)
@@ -97,7 +98,7 @@ gtranslator_view_init (GtranslatorView * view)
   gchar **langs;
   const gchar *const *temp;
   gint i;
-  gchar *pkgdatadir;
+  gchar *datadir;
 
   view->priv = GTR_VIEW_GET_PRIVATE (view);
 
@@ -110,13 +111,12 @@ gtranslator_view_init (GtranslatorView * view)
        temp != NULL && *temp != NULL; ++temp)
     g_ptr_array_add (dirs, g_strdup (*temp));
 
-  pkgdatadir = gtranslator_utils_get_file_from_pkgdatadir (NULL);
+  datadir = gtranslator_dirs_get_gtranslator_data_dir ();
   /* FIXME: Where pkgdatadir must be free */
-  g_ptr_array_add (dirs, pkgdatadir);
+  g_ptr_array_add (dirs, datadir);
   g_ptr_array_add (dirs, NULL);
   langs = (gchar **) g_ptr_array_free (dirs, FALSE);
 
-
   gtk_source_language_manager_set_search_path (lm, langs);
   lang = gtk_source_language_manager_get_language (lm, "gtranslator");
   g_strfreev (langs);
diff --git a/src/window.c b/src/window.c
index 750e16c..9b3f830 100644
--- a/src/window.c
+++ b/src/window.c
@@ -26,6 +26,7 @@
 
 #include "actions.h"
 #include "application.h"
+#include "dirs.h"
 #include "header.h"
 #include "msg.h"
 #include "notebook.h"
@@ -378,9 +379,12 @@ gtranslator_window_layout_load (GtranslatorWindow * window,
 				       layout_filename))
     {
       gchar *path;
+      gchar *datadir;
 
+      datadir = gtranslator_dirs_get_gtranslator_data_dir ();
+      path = g_build_filename (datadir, "layout.xml", NULL);
+      g_free (datadir);
 
-      path = gtranslator_utils_get_file_from_pkgdatadir ("layout.xml");
       //DEBUG_PRINT ("Layout = %s", path);
       if (!gdl_dock_layout_load_from_file (window->priv->layout_manager,
 					   path))
@@ -1487,6 +1491,7 @@ gtranslator_window_draw (GtranslatorWindow * window)
   GtkWidget *hbox_dock;
   GtkWidget *tm_widget;
   GtkActionGroup *action_group;
+  gchar *datadir;
   gchar *path;
 
   GtranslatorWindowPrivate *priv = window->priv;
@@ -1535,7 +1540,10 @@ gtranslator_window_draw (GtranslatorWindow * window)
   gtk_ui_manager_insert_action_group (priv->ui_manager, action_group, 0);
   g_object_unref (action_group);
 
-  path = gtranslator_utils_get_file_from_pkgdatadir ("gtranslator-ui.xml");
+  datadir = gtranslator_dirs_get_gtranslator_data_dir ();
+  path = g_build_filename (datadir, "gtranslator-ui.xml", NULL);
+  g_free (datadir);
+
   if (!gtk_ui_manager_add_ui_from_file (priv->ui_manager, path, &error))
     {
       g_warning ("building menus failed: %s", error->message);
@@ -1713,12 +1721,12 @@ gtranslator_window_init (GtranslatorWindow * window)
   /*
    * Loading dock layout
    */
-  config_folder = gtranslator_utils_get_user_config_dir ();
+  config_folder = gtranslator_dirs_get_user_config_dir ();
   filename = g_build_filename (config_folder, "gtranslator-layout.xml", NULL);
+  g_free (config_folder);
 
   gtranslator_window_layout_load (window, filename, NULL);
   g_free (filename);
-  g_free (config_folder);
 }
 
 static void
@@ -1760,12 +1768,12 @@ save_panes_state (GtranslatorWindow * window)
   if (gtranslator_prefs_manager_window_state_can_set ())
     gtranslator_prefs_manager_set_window_state (window->priv->window_state);
 
-  config_folder = gtranslator_utils_get_user_config_dir ();
+  config_folder = gtranslator_dirs_get_user_config_dir ();
   filename = g_build_filename (config_folder, "gtranslator-layout.xml", NULL);
-  gtranslator_window_layout_save (window, filename, NULL);
+  g_free (config_folder);
 
+  gtranslator_window_layout_save (window, filename, NULL);
   g_free (filename);
-  g_free (config_folder);
 }
 
 static void



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