[geany/geany-plugins] 157ce2: pohelper: Fix references to installation paths on Windows

Enrico Tröger git-noreply at xxxxx
Sun Mar 13 00:12:11 UTC 2016


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 13 Mar 2016 00:12:11 UTC
Commit:      157ce2610b2f28c56cda97750b5f94a223c3dcbb
             https://github.com/geany/geany-plugins/commit/157ce2610b2f28c56cda97750b5f94a223c3dcbb

Log Message:
-----------
pohelper: Fix references to installation paths on Windows


Modified Paths:
--------------
    pohelper/src/gph-plugin.c

Modified: pohelper/src/gph-plugin.c
27 lines changed, 23 insertions(+), 4 deletions(-)
===================================================================
@@ -1358,6 +1358,22 @@ on_color_button_color_notify (GtkWidget  *widget,
   gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), user_data);
 }
 
+static gchar *
+get_data_dir_path (const gchar *filename)
+{
+#ifdef G_OS_WIN32
+  gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL);
+#else
+  gchar *prefix = NULL;
+#endif
+  gchar *path   = g_build_filename (prefix ? prefix : "", PLUGINDATADIR,
+                                    filename, NULL);
+  
+  g_free (prefix);
+  
+  return path;
+}
+
 static void
 show_stats_dialog (guint  all,
                    guint  translated,
@@ -1365,11 +1381,11 @@ show_stats_dialog (guint  all,
                    guint  untranslated)
 {
   GError     *error = NULL;
+  gchar      *ui_filename = get_data_dir_path ("stats.ui");;
   GtkBuilder *builder = gtk_builder_new ();
   
   gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
-  if (! gtk_builder_add_from_file (builder, PKGDATADIR"/pohelper/stats.ui",
-                                   &error)) {
+  if (! gtk_builder_add_from_file (builder, ui_filename, &error)) {
     g_critical (_("Failed to load UI definition, please check your "
                   "installation. The error was: %s"), error->message);
     g_error_free (error);
@@ -1449,6 +1465,7 @@ show_stats_dialog (guint  all,
     gtk_dialog_run (GTK_DIALOG (dialog));
     gtk_widget_destroy (GTK_WIDGET (dialog));
   }
+  g_free (ui_filename);
   g_object_unref (builder);
 }
 
@@ -1695,14 +1712,15 @@ plugin_init (GeanyData *data)
 {
   GtkBuilder *builder;
   GError *error = NULL;
+  gchar *ui_filename;
   guint i;
   
   load_config ();
   
+  ui_filename = get_data_dir_path ("menus.ui");
   builder = gtk_builder_new ();
   gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
-  if (! gtk_builder_add_from_file (builder, PKGDATADIR"/pohelper/menus.ui",
-                                   &error)) {
+  if (! gtk_builder_add_from_file (builder, ui_filename, &error)) {
     g_critical (_("Failed to load UI definition, please check your "
                   "installation. The error was: %s"), error->message);
     g_error_free (error);
@@ -1722,6 +1740,7 @@ plugin_init (GeanyData *data)
     g_signal_connect (obj, "toggled",
                       G_CALLBACK (on_update_headers_upon_save_toggled), NULL);
   }
+  g_free (ui_filename);
   
   /* signal handlers */
   plugin_signal_connect (geany_plugin, NULL, "document-activate", TRUE,



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list