Merge pull request #39 from gergelypolonkai/configure-house-system
Save house system; Add default house system to the settings schema
This commit is contained in:
commit
0544932f14
@ -1,4 +1,10 @@
|
|||||||
<schemalist gettext-domain="astrognome">
|
<schemalist gettext-domain="astrognome">
|
||||||
|
<enum id="eu.polonkai.gergely.Astrognome.GsweHouseSystem">
|
||||||
|
<value nick="none" value="0"/>
|
||||||
|
<value nick="placidus" value="1"/>
|
||||||
|
<value nick="koch" value="2"/>
|
||||||
|
<value nick="equal" value="3"/>
|
||||||
|
</enum>
|
||||||
<schema id="eu.polonkai.gergely.Astrognome" path="/eu/polonkai/gergely/Astrognome/">
|
<schema id="eu.polonkai.gergely.Astrognome" path="/eu/polonkai/gergely/Astrognome/">
|
||||||
<child name="state" schema="eu.polonkai.gergely.Astrognome.state" />
|
<child name="state" schema="eu.polonkai.gergely.Astrognome.state" />
|
||||||
<key name="planets-char" type="b">
|
<key name="planets-char" type="b">
|
||||||
@ -11,6 +17,11 @@
|
|||||||
<summary>Display aspect symbols as UTF-8 characters</summary>
|
<summary>Display aspect symbols as UTF-8 characters</summary>
|
||||||
<description>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.</description>
|
<description>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.</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="default-house-system" enum="eu.polonkai.gergely.Astrognome.GsweHouseSystem">
|
||||||
|
<default>'placidus'</default>
|
||||||
|
<summary>The default house system</summary>
|
||||||
|
<description>The house system to use by default in new charts</description>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
<schema id="eu.polonkai.gergely.Astrognome.state" path="/eu/polonkai/gergely/Astrognome/state/">
|
<schema id="eu.polonkai.gergely.Astrognome.state" path="/eu/polonkai/gergely/Astrognome/state/">
|
||||||
<child name="window" schema="eu.polonkai.gergely.Astrognome.state.window" />
|
<child name="window" schema="eu.polonkai.gergely.Astrognome.state.window" />
|
||||||
|
@ -833,16 +833,10 @@ ag_chart_load_from_file(GFile *file, GError **err)
|
|||||||
|
|
||||||
g_variant_get(house_system, "ms", &house_system_name);
|
g_variant_get(house_system, "ms", &house_system_name);
|
||||||
g_variant_unref(house_system);
|
g_variant_unref(house_system);
|
||||||
house_system_enum_name = g_utf8_strup(house_system_name, -1);
|
house_system_enum_name = g_utf8_strdown(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
|
|
||||||
);
|
|
||||||
g_free(house_system_name);
|
g_free(house_system_name);
|
||||||
house_system_class = g_type_class_ref(GSWE_TYPE_HOUSE_SYSTEM);
|
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),
|
G_ENUM_CLASS(house_system_class),
|
||||||
house_system_enum_name
|
house_system_enum_name
|
||||||
)) == NULL) {
|
)) == NULL) {
|
||||||
@ -854,6 +848,7 @@ ag_chart_load_from_file(GFile *file, GError **err)
|
|||||||
g_variant_unref(city);
|
g_variant_unref(city);
|
||||||
ag_g_variant_unref(note);
|
ag_g_variant_unref(note);
|
||||||
g_type_class_unref(house_system_class);
|
g_type_class_unref(house_system_class);
|
||||||
|
g_free(house_system_enum_name);
|
||||||
|
|
||||||
g_set_error(err,
|
g_set_error(err,
|
||||||
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
|
AG_CHART_ERROR, AG_CHART_ERROR_CORRUPT_FILE,
|
||||||
@ -918,6 +913,8 @@ create_save_doc(AgChart *chart)
|
|||||||
gchar *value;
|
gchar *value;
|
||||||
GsweCoordinates *coordinates;
|
GsweCoordinates *coordinates;
|
||||||
GsweTimestamp *timestamp;
|
GsweTimestamp *timestamp;
|
||||||
|
GEnumClass *house_system_class;
|
||||||
|
GEnumValue *enum_value;
|
||||||
|
|
||||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||||
root_node = xmlNewNode(NULL, BAD_CAST "chartinfo");
|
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);
|
xmlNewChild(time_node, NULL, BAD_CAST "timezone", BAD_CAST value);
|
||||||
g_free(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)) {
|
if (ag_chart_get_note(chart)) {
|
||||||
xmlNewChild(
|
xmlNewChild(
|
||||||
root_node,
|
root_node,
|
||||||
|
@ -636,7 +636,7 @@ ag_window_redraw_chart(AgWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
ag_window_find_house_system(GtkTreeModel *model,
|
ag_window_set_house_system(GtkTreeModel *model,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
AgWindow *window)
|
AgWindow *window)
|
||||||
@ -721,7 +721,7 @@ ag_window_update_from_chart(AgWindow *window)
|
|||||||
|
|
||||||
gtk_tree_model_foreach(
|
gtk_tree_model_foreach(
|
||||||
GTK_TREE_MODEL(priv->house_system_model),
|
GTK_TREE_MODEL(priv->house_system_model),
|
||||||
(GtkTreeModelForeachFunc)ag_window_find_house_system,
|
(GtkTreeModelForeachFunc)ag_window_set_house_system,
|
||||||
window
|
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
|
static void
|
||||||
ag_window_init(AgWindow *window)
|
ag_window_init(AgWindow *window)
|
||||||
{
|
{
|
||||||
@ -977,6 +1010,11 @@ ag_window_init(AgWindow *window)
|
|||||||
house_system_list = gswe_all_house_systems();
|
house_system_list = gswe_all_house_systems();
|
||||||
g_list_foreach(house_system_list, (GFunc)ag_window_add_house_system, priv);
|
g_list_foreach(house_system_list, (GFunc)ag_window_add_house_system, priv);
|
||||||
g_list_free(house_system_list);
|
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();
|
house_system_renderer = gtk_cell_renderer_text_new();
|
||||||
gtk_cell_layout_pack_start(
|
gtk_cell_layout_pack_start(
|
||||||
|
Loading…
Reference in New Issue
Block a user