[gnome-latex: 107/205] Delete latexila.prefs.file_chooser_dir_is_empty
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 107/205] Delete latexila.prefs.file_chooser_dir_is_empty
- Date: Fri, 14 Dec 2018 10:55:53 +0000 (UTC)
commit a1f3650592095a801c1909da82764ecc82507e4c
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sun Nov 8 00:26:22 2009 +0100
Delete latexila.prefs.file_chooser_dir_is_empty
It seems that I was (very) tired when I have coded this! To know if
latexila.prefs.file_chooser_dir is empty or not, we can just verify if
the value is NULL...
src/callbacks.c | 22 +++++-----------------
src/main.h | 1 -
src/prefs.c | 8 ++------
3 files changed, 7 insertions(+), 24 deletions(-)
---
diff --git a/src/callbacks.c b/src/callbacks.c
index 0c5d2d1..cea26cd 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -73,7 +73,7 @@ cb_open (void)
NULL
);
- if (! latexila.prefs.file_chooser_dir_is_empty)
+ if (latexila.prefs.file_chooser_dir != NULL)
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
latexila.prefs.file_chooser_dir);
@@ -91,15 +91,10 @@ cb_open (void)
}
/* save the current folder */
- if (! latexila.prefs.file_chooser_dir_is_empty)
- g_free (latexila.prefs.file_chooser_dir);
-
+ g_free (latexila.prefs.file_chooser_dir);
latexila.prefs.file_chooser_dir = gtk_file_chooser_get_current_folder_uri (
GTK_FILE_CHOOSER (dialog));
- if (latexila.prefs.file_chooser_dir != NULL)
- latexila.prefs.file_chooser_dir_is_empty = FALSE;
-
gtk_widget_destroy (dialog);
}
@@ -1020,7 +1015,7 @@ save_as_dialog (void)
NULL
);
- if (! latexila.prefs.file_chooser_dir_is_empty)
+ if (latexila.prefs.file_chooser_dir != NULL)
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
latexila.prefs.file_chooser_dir);
@@ -1075,15 +1070,10 @@ save_as_dialog (void)
}
/* save the current folder */
- if (! latexila.prefs.file_chooser_dir_is_empty)
- g_free (latexila.prefs.file_chooser_dir);
-
+ g_free (latexila.prefs.file_chooser_dir);
latexila.prefs.file_chooser_dir = gtk_file_chooser_get_current_folder_uri (
GTK_FILE_CHOOSER (dialog));
- if (latexila.prefs.file_chooser_dir != NULL)
- latexila.prefs.file_chooser_dir_is_empty = FALSE;
-
gtk_widget_destroy (dialog);
}
@@ -1319,9 +1309,7 @@ free_latexila (void)
g_free (latexila.prefs.command_pdflatex);
g_free (latexila.prefs.command_dvipdf);
g_free (latexila.prefs.command_dvips);
-
- if (! latexila.prefs.file_chooser_dir_is_empty)
- g_free (latexila.prefs.file_chooser_dir);
+ g_free (latexila.prefs.file_chooser_dir);
for (int i = 0 ; i < 7 ; i++)
g_object_unref (latexila.symbols.list_stores[i]);
diff --git a/src/main.h b/src/main.h
index df622eb..90bb804 100644
--- a/src/main.h
+++ b/src/main.h
@@ -90,7 +90,6 @@ typedef struct
gchar *command_pdflatex;
gchar *command_dvipdf;
gchar *command_dvips;
- gboolean file_chooser_dir_is_empty;
gchar *file_chooser_dir;
} preferences_t;
diff --git a/src/prefs.c b/src/prefs.c
index a0e7105..85d1e4e 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -46,7 +46,7 @@ static void cb_pref_command_dvipdf (GtkEditable *editable, gpointer user_data);
static void cb_pref_command_dvips (GtkEditable *editable, gpointer user_data);
/* default values */
-// there is an underscore in the end of each variable name
+// there is an underscore in the end for each variable name
static gboolean show_line_numbers_ = FALSE;
static gboolean show_side_pane_ = TRUE;
static gboolean show_edit_toolbar_ = TRUE;
@@ -255,13 +255,10 @@ load_preferences (preferences_t *prefs)
if (error != NULL)
{
print_warning ("%s", error->message);
- prefs->file_chooser_dir_is_empty = TRUE;
prefs->file_chooser_dir = NULL;
g_error_free (error);
error = NULL;
}
- else
- prefs->file_chooser_dir_is_empty = FALSE;
print_info ("load user preferences: OK");
g_key_file_free (key_file);
@@ -291,7 +288,7 @@ save_preferences (preferences_t *prefs)
g_key_file_set_string (key_file, PROGRAM_NAME, "command_dvips",
prefs->command_dvips);
- if (! prefs->file_chooser_dir_is_empty)
+ if (prefs->file_chooser_dir != NULL)
g_key_file_set_string (key_file, PROGRAM_NAME, "file_chooser_directory",
prefs->file_chooser_dir);
@@ -381,7 +378,6 @@ load_default_preferences (preferences_t *prefs)
prefs->command_pdflatex = g_strdup (command_pdflatex_);
prefs->command_dvipdf = g_strdup (command_dvipdf_);
prefs->command_dvips = g_strdup (command_dvips_);
- prefs->file_chooser_dir_is_empty = TRUE;
prefs->file_chooser_dir = NULL;
set_current_font_prefs (prefs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]