From 74e8373dadad4ec73ac340519cd0773d818453ef Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 18 Jul 2014 18:30:11 +0200 Subject: [PATCH 1/6] Add missing g_free() call for house_system_enum_name in chart loading --- src/ag-chart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ag-chart.c b/src/ag-chart.c index 0b62486..6f241fc 100644 --- a/src/ag-chart.c +++ b/src/ag-chart.c @@ -854,6 +854,7 @@ ag_chart_load_from_file(GFile *file, GError **err) g_variant_unref(city); ag_g_variant_unref(note); g_type_class_unref(house_system_class); + g_free(house_system_enum_name); g_set_error(err, AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE, From 427f915f62209670f46b1b4b24d2ba4a6c696bf8 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 18 Jul 2014 18:31:56 +0200 Subject: [PATCH 2/6] Use enum nick instead of name in house system saving This is easier to do, and the save file has that value already --- src/ag-chart.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ag-chart.c b/src/ag-chart.c index 6f241fc..6f51cde 100644 --- a/src/ag-chart.c +++ b/src/ag-chart.c @@ -833,16 +833,10 @@ ag_chart_load_from_file(GFile *file, GError **err) g_variant_get(house_system, "ms", &house_system_name); g_variant_unref(house_system); - house_system_enum_name = g_utf8_strup(house_system_name, -1); - g_free(house_system_name); - house_system_name = house_system_enum_name; - house_system_enum_name = g_strdup_printf( - "GSWE_HOUSE_SYSTEM_%s", - house_system_name - ); + house_system_enum_name = g_utf8_strdown(house_system_name, -1); g_free(house_system_name); house_system_class = g_type_class_ref(GSWE_TYPE_HOUSE_SYSTEM); - if ((enum_value = g_enum_get_value_by_name( + if ((enum_value = g_enum_get_value_by_nick( G_ENUM_CLASS(house_system_class), house_system_enum_name )) == NULL) { From bd277de1bc329b4ef58ae2df372ff7f2e6ebd9d4 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 18 Jul 2014 18:32:53 +0200 Subject: [PATCH 3/6] Add house system save functionality This was missing from #37 --- src/ag-chart.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ag-chart.c b/src/ag-chart.c index 6f51cde..1639f35 100644 --- a/src/ag-chart.c +++ b/src/ag-chart.c @@ -913,6 +913,8 @@ create_save_doc(AgChart *chart) gchar *value; GsweCoordinates *coordinates; GsweTimestamp *timestamp; + GEnumClass *house_system_class; + GEnumValue *enum_value; doc = xmlNewDoc(BAD_CAST "1.0"); root_node = xmlNewNode(NULL, BAD_CAST "chartinfo"); @@ -1010,6 +1012,19 @@ create_save_doc(AgChart *chart) xmlNewChild(time_node, NULL, BAD_CAST "timezone", BAD_CAST value); g_free(value); + house_system_class = g_type_class_ref(GSWE_TYPE_HOUSE_SYSTEM); + enum_value = g_enum_get_value( + house_system_class, + gswe_moment_get_house_system(GSWE_MOMENT(chart)) + ); + xmlNewChild( + data_node, + NULL, + BAD_CAST "housesystem", + BAD_CAST enum_value->value_nick + ); + g_type_class_unref(house_system_class); + if (ag_chart_get_note(chart)) { xmlNewChild( root_node, From de4e2f54eff0ac6784cae490a681b49ebb6c7767 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 18 Jul 2014 18:35:39 +0200 Subject: [PATCH 4/6] Add default house system to settings schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is taken from an enum list, which is hand made. There must be a way to generate it programatically at compile time… --- data/eu.polonkai.gergely.astrognome.gschema.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/data/eu.polonkai.gergely.astrognome.gschema.xml b/data/eu.polonkai.gergely.astrognome.gschema.xml index 2d03e80..b2b17a7 100644 --- a/data/eu.polonkai.gergely.astrognome.gschema.xml +++ b/data/eu.polonkai.gergely.astrognome.gschema.xml @@ -1,4 +1,10 @@ + + + + + + @@ -11,6 +17,11 @@ Display aspect symbols as UTF-8 characters Whether to show aspect symbols as their UTF-8 representation. Uses less memory, but not all system fonts have them defined. If an aspect don’t have a character representation, an image fallback will be used. + + 'placidus' + The default house system + The house system to use by default in new charts + From 0ead40813bb3f095bc1b1c346b34f66f337c5a9a Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 18 Jul 2014 20:49:02 +0200 Subject: [PATCH 5/6] Rename ag_window_find_house_system() to ag_window_set_house_system() --- src/ag-window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ag-window.c b/src/ag-window.c index 2604acb..dcb78f2 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -636,7 +636,7 @@ ag_window_redraw_chart(AgWindow *window) } static gboolean -ag_window_find_house_system(GtkTreeModel *model, +ag_window_set_house_system(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, AgWindow *window) @@ -721,7 +721,7 @@ ag_window_update_from_chart(AgWindow *window) gtk_tree_model_foreach( GTK_TREE_MODEL(priv->house_system_model), - (GtkTreeModelForeachFunc)ag_window_find_house_system, + (GtkTreeModelForeachFunc)ag_window_set_house_system, window ); From 69bc58495cfc9651edb7f73c491d82ca8540eea9 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 18 Jul 2014 20:49:35 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Set=20Edit=20tab=E2=80=99s=20house=20system?= =?UTF-8?q?=20to=20the=20default=20on=20startup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ag-window.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/ag-window.c b/src/ag-window.c index dcb78f2..406b96f 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -947,6 +947,39 @@ ag_window_add_house_system(GsweHouseSystemInfo *house_system_info, ); } +static gboolean +ag_window_set_default_house_system(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + AgWindow *window) +{ + GsweHouseSystem row_house_system; + AgWindowPrivate *priv = ag_window_get_instance_private(window); + AgSettings *settings = ag_settings_get(); + GSettings *main_settings = ag_settings_peek_main_settings(settings); + GsweHouseSystem house_system = g_settings_get_enum( + main_settings, + "default-house-system" + ); + + g_object_unref(settings); + + gtk_tree_model_get( + GTK_TREE_MODEL(priv->house_system_model), + iter, + 0, &row_house_system, + -1 + ); + + if (house_system == row_house_system) { + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(priv->house_system), iter); + + return TRUE; + } + + return FALSE; +} + static void ag_window_init(AgWindow *window) { @@ -977,6 +1010,11 @@ ag_window_init(AgWindow *window) house_system_list = gswe_all_house_systems(); g_list_foreach(house_system_list, (GFunc)ag_window_add_house_system, priv); g_list_free(house_system_list); + gtk_tree_model_foreach( + GTK_TREE_MODEL(priv->house_system_model), + (GtkTreeModelForeachFunc)ag_window_set_default_house_system, + window + ); house_system_renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(