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 + diff --git a/src/ag-chart.c b/src/ag-chart.c index 0b62486..1639f35 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) { @@ -854,6 +848,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, @@ -918,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"); @@ -1015,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, diff --git a/src/ag-window.c b/src/ag-window.c index 2604acb..406b96f 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 ); @@ -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(