[genius] Wed Jun 03 11:36:01 2020 Jiri (George) Lebl <jirka 5z com>
- From: Jiri (George) Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Wed Jun 03 11:36:01 2020 Jiri (George) Lebl <jirka 5z com>
- Date: Wed, 3 Jun 2020 16:36:50 +0000 (UTC)
commit 42610e07d8da2807a5cda28570b28fea83949285
Author: Jiri (George) Lebl <jiri lebl gmail com>
Date: Wed Jun 3 11:36:04 2020 -0500
Wed Jun 03 11:36:01 2020 Jiri (George) Lebl <jirka 5z com>
* src/gnome-genius.c, src/genius.c: properly create the .genius
directory if missing, move gui settings to .genius/config-gui
and save config on OK in the setup dialog
ChangeLog | 6 ++++++
src/genius.c | 11 ++++++++++-
src/gnome-genius.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++---
src/plugin.c | 13 +++++++++----
4 files changed, 73 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 49462c4d..8fabc59d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Jun 03 11:36:01 2020 Jiri (George) Lebl <jirka 5z com>
+
+ * src/gnome-genius.c, src/genius.c: properly create the .genius
+ directory if missing, move gui settings to .genius/config-gui
+ and save config on OK in the setup dialog
+
Mon Jun 01 15:37:49 2020 Jiri (George) Lebl <jirka 5z com>
* src/gnome-genius.c: fix EOF quit
diff --git a/src/genius.c b/src/genius.c
index e76a4065..1a42f12a 100644
--- a/src/genius.c
+++ b/src/genius.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2017 Jiri (George) Lebl
+ * Copyright (C) 1997-2020 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -34,6 +34,8 @@
#include <fcntl.h>
#include <stdio.h>
#include <locale.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "calc.h"
#include "eval.h"
@@ -539,6 +541,13 @@ main(int argc, char *argv[])
exit (1);
}
+ /* ensure the directory, if it is a file, no worries not saving the properties is not fatal at all */
+ file = g_build_filename (g_get_home_dir (), ".genius", NULL);
+ if (access (file, F_OK) != 0) {
+ mkdir (file, 0755);
+ }
+ g_free (file);
+
gel_read_plugin_list();
if (do_compile || do_gettext)
diff --git a/src/gnome-genius.c b/src/gnome-genius.c
index 821978ea..57426f05 100644
--- a/src/gnome-genius.c
+++ b/src/gnome-genius.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2018 Jiri (George) Lebl
+ * Copyright (C) 1997-2020 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -1911,7 +1911,7 @@ set_properties (void)
/* FIXME: errors */
return;
- name = g_build_filename (home, ".gnome2", "genius", NULL);
+ name = g_build_filename (home, ".genius", "config-gui", NULL);
cfg = ve_config_new (name);
g_free (name);
@@ -2183,6 +2183,10 @@ setup_response (GtkWidget *widget, gint resp, gpointer data)
if (resp == GTK_RESPONSE_OK ||
resp == GTK_RESPONSE_CANCEL)
gtk_widget_destroy (widget);
+
+ /* save properties to file on OK */
+ if (resp == GTK_RESPONSE_OK)
+ set_properties ();
}
}
@@ -4271,12 +4275,22 @@ get_properties (void)
const char *home = g_get_home_dir ();
char *name;
VeConfig *cfg;
+ gboolean old_props = FALSE;
if (home == NULL)
/* FIXME: error? */
return;
- name = g_build_filename (home, ".gnome2", "genius", NULL);
+ name = g_build_filename (home, ".genius", "config-gui", NULL);
+ if (access (name, F_OK) != 0) {
+ g_free (name);
+ name = g_build_filename (home, ".gnome2", "genius", NULL);
+ if (access (name, F_OK) != 0) {
+ g_free (name);
+ return;
+ }
+ old_props = TRUE;
+ }
cfg = ve_config_new (name);
g_free (name);
@@ -4373,6 +4387,10 @@ get_properties (void)
genius_setup.precision_remember = ve_config_get_bool (cfg, buf);
ve_config_destroy (cfg);
+
+ if (old_props) {
+ set_properties ();
+ }
}
static void
@@ -4970,6 +4988,26 @@ activate (GApplication *app, gpointer data)
_("Cannot find the library file, genius installation may be
incorrect"));
}
+ /* ensure the directory, if it is a file, no worries not saving the properties is not fatal */
+ file = g_build_filename (g_get_home_dir (), ".genius", NULL);
+ if (access (file, F_OK) != 0) {
+ mkdir (file, 0755);
+ } else {
+ DIR *dir;
+
+ dir = opendir (file);
+ if (dir == NULL) {
+ genius_display_error (NULL /* parent */,
+ _("A file .genius in the home directory exists, "
+ "but it should be a directory. "
+ "Genius will not be able to save preferences."));
+ } else {
+ closedir (dir);
+ }
+ }
+ g_free (file);
+
+
/*read parameters */
get_properties ();
@@ -5349,6 +5387,7 @@ int
main (int argc, char *argv[])
{
int status;
+ char *name;
arg0 = g_strdup (argv[0]);
@@ -5389,5 +5428,11 @@ main (int argc, char *argv[])
unlink (fromrlfifo);
unlink (torlfifo);
+ /* remove old preferences to avoid confusion, by now things should be set in the new file */
+ name = g_build_filename (g_get_home_dir (), ".gnome2", "genius", NULL);
+ if (access (name, F_OK) == 0)
+ unlink (name);
+ g_free (name);
+
return status;
}
diff --git a/src/plugin.c b/src/plugin.c
index 64c3964e..3a32cfee 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -244,7 +244,7 @@ gel_save_plugins (void)
if (genius_is_gui)
path = g_build_filename (g_get_home_dir (),
- ".gnome2", "genius", NULL);
+ ".genius", "config-gui", NULL);
else
path = g_build_filename (g_get_home_dir (),
".genius", "config-cmdline", NULL);
@@ -295,10 +295,15 @@ gel_restore_plugins (void)
if (gel_plugin_list == NULL)
return;
- if (genius_is_gui)
+ if (genius_is_gui) {
path = g_build_filename (g_get_home_dir (),
- ".gnome2", "genius", NULL);
- else
+ ".genius", "config-gui", NULL);
+ if (access (path, F_OK) != 0) {
+ g_free (path);
+ path = g_build_filename (g_get_home_dir (),
+ ".gnome2", "genius", NULL);
+ }
+ } else
path = g_build_filename (g_get_home_dir (),
".genius", "config-cmdline", NULL);
cfg = ve_config_get (path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]