[pan: 11/15] Get hold of the correct scorefile name
- From: Dominique Dumont <ddumont src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan: 11/15] Get hold of the correct scorefile name
- Date: Sun, 12 Jun 2022 09:12:12 +0000 (UTC)
commit 8440cf64412e2c510983d361c47c9ccc24aa5e4b
Author: Thomas Tanner <thosrtanner googlemail com>
Date: Sun Jun 5 12:18:20 2022 +0100
Get hold of the correct scorefile name
pan/data-impl/data-impl.cc | 6 ++++++
pan/data-impl/data-impl.h | 2 ++
pan/data/data.h | 8 ++++++++
pan/gui/gui.cc | 9 +++------
4 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/pan/data-impl/data-impl.cc b/pan/data-impl/data-impl.cc
index 50cf6ac..ca7c9be 100644
--- a/pan/data-impl/data-impl.cc
+++ b/pan/data-impl/data-impl.cc
@@ -135,6 +135,12 @@ DataImpl :: save_state ()
}
}
+std::string
+DataImpl :: get_scorefile_name() const
+{
+ return _data_io->get_scorefile_name();
+}
+
#ifdef HAVE_GKR
#if GTK_CHECK_VERSION(3,0,0)
gboolean
diff --git a/pan/data-impl/data-impl.h b/pan/data-impl/data-impl.h
index 689844e..9389a5b 100644
--- a/pan/data-impl/data-impl.h
+++ b/pan/data-impl/data-impl.h
@@ -577,6 +577,8 @@ namespace pan
virtual void rescore ();
+ virtual std::string get_scorefile_name() const;
+
private:
Scorefile _scorefile;
diff --git a/pan/data/data.h b/pan/data/data.h
index e54f223..d39a842 100644
--- a/pan/data/data.h
+++ b/pan/data/data.h
@@ -607,6 +607,14 @@ namespace pan
virtual void rescore () = 0;
+ /* Get the scorefile name.
+ *
+ * This is a little bit unclean but it allows people to find and edit
+ * the scorefile until such point as a proper editor is written for
+ * it
+ */
+ virtual std::string get_scorefile_name() const = 0;
+
/*****************************************************************
***
*** HEADERS - XOVER
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 85c77ee..47e4260 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -2380,13 +2380,12 @@ GUI :: do_edit_scores (GtkAction *act)
return;
}
- //FIXME This is wrong because this might not be the filename
- char *filename = g_build_filename(file::get_pan_home().c_str(), "Score", NULL);
+ //This isn't lovely. But I know I don't free filename in the callback
+ char *filename = const_cast<char *>(_data.get_scorefile_name().c_str());
if (not file::file_exists(filename)) {
FILE *f = fopen(filename, "a+");
if (f == nullptr) {
Log::add_err_va("Error creating file '%s'", filename);
- g_free(filename);
return;
}
fclose(f);
@@ -2404,15 +2403,13 @@ GUI :: do_edit_scores (GtkAction *act)
catch (EditorSpawnerError const &)
{
//There should be a big red exclamation on the status line
- g_free(filename);
}
}
void
GUI :: edit_scores_cleanup(int status, char *filename, GtkAction *act)
{
- //FIXME rescore articles
- g_free(filename);
+ _data.rescore();
gtk_action_set_sensitive(act, true);
_spawner.reset();
gtk_window_present(get_window(_root));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]