From fee1adf08f7aa59abc0d97ef7043e4ca82dfa1bb Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 2 Sep 2014 10:09:32 +0200 Subject: [PATCH 01/10] Add point table to the UI definition --- src/resources/ui/ag-window.ui | 125 +++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 3 deletions(-) diff --git a/src/resources/ui/ag-window.ui b/src/resources/ui/ag-window.ui index 568ab04..e376939 100644 --- a/src/resources/ui/ag-window.ui +++ b/src/resources/ui/ag-window.ui @@ -820,11 +820,130 @@ - + True - none - + + True + False + 0 + in + + + True + False + True + 5 + True + 5 + + + True + False + Fire + + + 0 + 1 + + + + + True + False + Earth + + + 0 + 2 + + + + + True + False + Air + + + 0 + 3 + + + + + True + False + Water + + + 0 + 4 + + + + + True + False + Points + + + 0 + 5 + + + + + True + False + Cardinal + + + 1 + 0 + + + + + True + False + Fixed + + + 2 + 0 + + + + + True + False + Mutable + + + 3 + 0 + + + + + True + False + Points + + + 4 + 0 + + + + + + + True + False + Elements and Qualities + + From b9791f1436a2622553c7747e64ca2fc97f7ff09a Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 2 Sep 2014 10:16:30 +0200 Subject: [PATCH 02/10] Unify accels for the view changer menu --- src/ag-app.c | 3 ++- src/resources/ui/ag-window.ui | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ag-app.c b/src/ag-app.c index 6203674..29324f2 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -313,7 +313,8 @@ const gchar *action_accels[] = { "win.gear-menu", "F10", NULL, "app.help", "F1", NULL, "win.change-tab::chart", "F5", NULL, - "win.change-tab::aspects", "F9", NULL, + "win.change-tab::aspects", "F6", NULL, + "win.change-tab::points", "F7", NULL, "win.change-tab::edit", "F4", NULL, NULL }; diff --git a/src/resources/ui/ag-window.ui b/src/resources/ui/ag-window.ui index e376939..dfedb9a 100644 --- a/src/resources/ui/ag-window.ui +++ b/src/resources/ui/ag-window.ui @@ -7,7 +7,7 @@ Edit win.change-tab - <F3> + <F4> edit From 5f95ffd16ed92f2090e78c57926f903cd70c0d3f Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 2 Sep 2014 16:24:37 +0200 Subject: [PATCH 03/10] Fill up points table --- src/ag-window.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/ag-window.c b/src/ag-window.c index 67f227a..d4df720 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -48,6 +48,7 @@ struct _AgWindowPrivate { GtkWidget *aspect_table; GtkWidget *chart_web_view; + GtkWidget *points_eq; GtkAdjustment *year_adjust; AgSettings *settings; @@ -402,6 +403,79 @@ ag_window_redraw_aspect_table(AgWindow *window) gtk_widget_show_all(priv->aspect_table); } +static void +ag_window_set_element_point(AgWindow *window, + GsweElement element, + guint left, + guint top) +{ + guint points; + GtkWidget *label; + gchar *points_string; + AgWindowPrivate *priv = ag_window_get_instance_private(window); + + points = gswe_moment_get_element_points( + GSWE_MOMENT(priv->chart), + element + ); + + if ((label = gtk_grid_get_child_at( + GTK_GRID(priv->points_eq), + left, top + )) == NULL) { + label = gtk_label_new(""); + gtk_grid_attach(GTK_GRID(priv->points_eq), label, left, top, 1, 1); + gtk_widget_show(label); + } + + points_string = g_strdup_printf("%d", points); + gtk_label_set_text(GTK_LABEL(label), points_string); + g_free(points_string); +} + +static void +ag_window_set_quality_point(AgWindow *window, + GsweQuality quality, + guint left, + guint top) +{ + guint points; + GtkWidget *label; + gchar *points_string; + AgWindowPrivate *priv = ag_window_get_instance_private(window); + + points = gswe_moment_get_quality_points( + GSWE_MOMENT(priv->chart), + quality + ); + + if ((label = gtk_grid_get_child_at( + GTK_GRID(priv->points_eq), + left, top + )) == NULL) { + label = gtk_label_new(""); + gtk_grid_attach(GTK_GRID(priv->points_eq), label, left, top, 1, 1); + gtk_widget_show(label); + } + + points_string = g_strdup_printf("%d", points); + gtk_label_set_text(GTK_LABEL(label), points_string); + g_free(points_string); +} + +static void +ag_window_redraw_points_table(AgWindow *window) +{ + ag_window_set_element_point(window, GSWE_ELEMENT_FIRE, 4, 1); + ag_window_set_element_point(window, GSWE_ELEMENT_EARTH, 4, 2); + ag_window_set_element_point(window, GSWE_ELEMENT_AIR, 4, 3); + ag_window_set_element_point(window, GSWE_ELEMENT_WATER, 4, 4); + + ag_window_set_quality_point(window, GSWE_QUALITY_CARDINAL, 1, 5); + ag_window_set_quality_point(window, GSWE_QUALITY_FIX, 2, 5); + ag_window_set_quality_point(window, GSWE_QUALITY_MUTABLE, 3, 5); +} + /** * ag_window_redraw_chart: * @window: the #AgWindow to operate on @@ -441,6 +515,7 @@ ag_window_redraw_chart(AgWindow *window) } ag_window_redraw_aspect_table(window); + ag_window_redraw_points_table(window); } static gboolean @@ -1387,6 +1462,7 @@ ag_window_display_changed(GSettings *settings, gchar *key, AgWindow *window) } ag_window_redraw_aspect_table(window); + ag_window_redraw_points_table(window); } static void @@ -1991,6 +2067,11 @@ ag_window_class_init(AgWindowClass *klass) AgWindow, selection_toolbar ); + gtk_widget_class_bind_template_child_private( + widget_class, + AgWindow, + points_eq + ); gtk_widget_class_bind_template_callback( widget_class, From 0cf6f171a6618f4d403b7726786ab93bb7654e26 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 2 Sep 2014 21:37:07 +0200 Subject: [PATCH 04/10] Move data directory creation/query code to ag_get_user_data_dir() --- src/ag-db.c | 17 ++--------------- src/astrognome.c | 34 ++++++++++++++++++++++++++++++++++ src/astrognome.h | 2 ++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/ag-db.c b/src/ag-db.c index 60aee74..fb32e92 100644 --- a/src/ag-db.c +++ b/src/ag-db.c @@ -456,30 +456,17 @@ static void ag_db_init(AgDb *db) { GdaSqlParser *parser; - GFile *user_data_dir = g_file_new_for_path(g_get_user_data_dir()), - *ag_data_dir = g_file_get_child(user_data_dir, "astrognome"); + GFile *ag_data_dir = ag_get_user_data_dir(); AgDbPrivate *priv = ag_db_get_instance_private(db); gchar *path = g_file_get_path(ag_data_dir); GError *err = NULL; gda_init(); - if (!g_file_query_exists(ag_data_dir, NULL)) { - gchar *path = g_file_get_path(ag_data_dir); - - if (g_mkdir_with_parents(path, 0700) != 0) { - g_error( - "Data directory %s does not exist and can not be created.", - path - ); - } - } - priv->dsn = g_strdup_printf("SQLite://DB_DIR=%s;DB_NAME=charts", path); g_free(path); - g_object_unref(user_data_dir); - g_object_unref(ag_data_dir); + g_clear_object(&ag_data_dir); priv->conn = gda_connection_open_from_string( NULL, diff --git a/src/astrognome.c b/src/astrognome.c index b7bb512..bd2fe06 100644 --- a/src/astrognome.c +++ b/src/astrognome.c @@ -188,6 +188,40 @@ ag_house_system_nick_to_id(const gchar *nick) return GSWE_HOUSE_SYSTEM_NONE; } +/** + * ag_get_user_data_dir: + * + * Creates the astrognome data directory (~/.local/share/astrognome on XDG + * compatible systems) if necessary, and returns a GFile handle to it. + * + * Returns: (transfer full): a #GFile handle to the application data directory + * that must be freed with g_object_unref(). + */ +GFile * +ag_get_user_data_dir(void) +{ + GFile *user_data_dir = g_file_new_for_path(g_get_user_data_dir()), + *ag_data_dir = g_file_get_child(user_data_dir, "astrognome"); + + g_clear_object(&user_data_dir); + g_assert(ag_data_dir); + + if (!g_file_query_exists(ag_data_dir, NULL)) { + gchar *path = g_file_get_path(ag_data_dir); + + if (g_mkdir_with_parents(path, 0700) != 0) { + g_error( + "Data directory ā€˜%sā€™ does not exist and cannot be created.", + path + ); + } + + g_free(path); + } + + return ag_data_dir; +} + int main(int argc, char *argv[]) { diff --git a/src/astrognome.h b/src/astrognome.h index 80a1eeb..efcc1c4 100644 --- a/src/astrognome.h +++ b/src/astrognome.h @@ -1,6 +1,7 @@ #ifndef __ASTROGNOME_H__ #define __ASTROGNOME_H__ +#include #include typedef struct { @@ -34,6 +35,7 @@ enum { const gchar *ag_house_system_id_to_nick(GsweHouseSystem house_system); GsweHouseSystem ag_house_system_nick_to_id(const gchar *nick); +GFile *ag_get_user_data_dir(void); #ifndef GDOUBLE_FROM_LE inline static gdouble From 7f844264cc933a9979d9fbf26bdef68d9adc3ce9 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 3 Sep 2014 09:54:57 +0200 Subject: [PATCH 05/10] Add house numbers to the default chart template Fixes #54 --- src/resources/ui/chart-default.xsl | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/resources/ui/chart-default.xsl b/src/resources/ui/chart-default.xsl index b1170d3..29bad68 100644 --- a/src/resources/ui/chart-default.xsl +++ b/src/resources/ui/chart-default.xsl @@ -504,6 +504,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rotate(-,0,0) translate(,0) rotate(90,0,0) + + + From 760f0e86636f2b512fee2f05536cd3b0e5000600 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Thu, 4 Sep 2014 15:25:05 +0200 Subject: [PATCH 06/10] Add Alt-Left and Back accels for the back button --- src/ag-app.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ag-app.c b/src/ag-app.c index 29324f2..d545664 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -316,6 +316,7 @@ const gchar *action_accels[] = { "win.change-tab::aspects", "F6", NULL, "win.change-tab::points", "F7", NULL, "win.change-tab::edit", "F4", NULL, + "win.back", "Left", "Back", NULL, NULL }; From 4be6bb46271e4c55f18175bd0643cab832319ee3 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 6 Sep 2014 10:02:47 +0200 Subject: [PATCH 07/10] Add icon for Pholus --- images/comet_pholus.svg | 74 +++++++++++++++++++ src/ag.gresource.xml | 1 + src/resources/default-icons/planet-pholus.xml | 4 + src/resources/ui/chart-default.xsl | 1 + 4 files changed, 80 insertions(+) create mode 100644 images/comet_pholus.svg create mode 100644 src/resources/default-icons/planet-pholus.xml diff --git a/images/comet_pholus.svg b/images/comet_pholus.svg new file mode 100644 index 0000000..aad1ce1 --- /dev/null +++ b/images/comet_pholus.svg @@ -0,0 +1,74 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/ag.gresource.xml b/src/ag.gresource.xml index 0f4bf0c..ac2a03f 100644 --- a/src/ag.gresource.xml +++ b/src/ag.gresource.xml @@ -32,6 +32,7 @@ default-icons/planet-neptune.xml default-icons/planet-pluto.xml default-icons/planet-chiron.xml + default-icons/planet-pholus.xml default-icons/planet-ceres.xml default-icons/planet-pallas.xml default-icons/planet-juno.xml diff --git a/src/resources/default-icons/planet-pholus.xml b/src/resources/default-icons/planet-pholus.xml new file mode 100644 index 0000000..9410ac1 --- /dev/null +++ b/src/resources/default-icons/planet-pholus.xml @@ -0,0 +1,4 @@ + diff --git a/src/resources/ui/chart-default.xsl b/src/resources/ui/chart-default.xsl index 29bad68..ecf45bb 100644 --- a/src/resources/ui/chart-default.xsl +++ b/src/resources/ui/chart-default.xsl @@ -56,6 +56,7 @@ + From e18a58802662579ae4ef76ba5a3e92ec9b4ad297 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 6 Sep 2014 10:11:47 +0200 Subject: [PATCH 08/10] Add icon for Nessus --- images/comet_nessus.svg | 75 +++++++++++++++++++ src/ag.gresource.xml | 1 + src/resources/default-icons/planet-nessus.xml | 4 + src/resources/ui/chart-default.xsl | 1 + 4 files changed, 81 insertions(+) create mode 100644 images/comet_nessus.svg create mode 100644 src/resources/default-icons/planet-nessus.xml diff --git a/images/comet_nessus.svg b/images/comet_nessus.svg new file mode 100644 index 0000000..ece9c28 --- /dev/null +++ b/images/comet_nessus.svg @@ -0,0 +1,75 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/ag.gresource.xml b/src/ag.gresource.xml index ac2a03f..d73c94f 100644 --- a/src/ag.gresource.xml +++ b/src/ag.gresource.xml @@ -33,6 +33,7 @@ default-icons/planet-pluto.xml default-icons/planet-chiron.xml default-icons/planet-pholus.xml + default-icons/planet-nessus.xml default-icons/planet-ceres.xml default-icons/planet-pallas.xml default-icons/planet-juno.xml diff --git a/src/resources/default-icons/planet-nessus.xml b/src/resources/default-icons/planet-nessus.xml new file mode 100644 index 0000000..05606d5 --- /dev/null +++ b/src/resources/default-icons/planet-nessus.xml @@ -0,0 +1,4 @@ + diff --git a/src/resources/ui/chart-default.xsl b/src/resources/ui/chart-default.xsl index ecf45bb..74a9957 100644 --- a/src/resources/ui/chart-default.xsl +++ b/src/resources/ui/chart-default.xsl @@ -57,6 +57,7 @@ + From acd4a8e078028ba90b214d25612af4c0219ff5fc Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 6 Sep 2014 10:19:19 +0200 Subject: [PATCH 09/10] Add icon for Chariklo --- images/comet_chariklo.svg | 75 +++++++++++++++++++ src/ag.gresource.xml | 1 + .../default-icons/planet-chariklo.xml | 4 + src/resources/ui/chart-default.xsl | 1 + 4 files changed, 81 insertions(+) create mode 100644 images/comet_chariklo.svg create mode 100644 src/resources/default-icons/planet-chariklo.xml diff --git a/images/comet_chariklo.svg b/images/comet_chariklo.svg new file mode 100644 index 0000000..50e16f4 --- /dev/null +++ b/images/comet_chariklo.svg @@ -0,0 +1,75 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/ag.gresource.xml b/src/ag.gresource.xml index d73c94f..c0fa6b2 100644 --- a/src/ag.gresource.xml +++ b/src/ag.gresource.xml @@ -38,6 +38,7 @@ default-icons/planet-pallas.xml default-icons/planet-juno.xml default-icons/planet-vesta.xml + default-icons/planet-chariklo.xml default-icons/planet-moon-node.xml default-icons/planet-moon-apogee.xml default-icons/point-vertex.xml diff --git a/src/resources/default-icons/planet-chariklo.xml b/src/resources/default-icons/planet-chariklo.xml new file mode 100644 index 0000000..064de15 --- /dev/null +++ b/src/resources/default-icons/planet-chariklo.xml @@ -0,0 +1,4 @@ + diff --git a/src/resources/ui/chart-default.xsl b/src/resources/ui/chart-default.xsl index 74a9957..e73f857 100644 --- a/src/resources/ui/chart-default.xsl +++ b/src/resources/ui/chart-default.xsl @@ -62,6 +62,7 @@ + From 6078a6e7b206d682fe568822744288245399f036 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 6 Sep 2014 11:01:46 +0200 Subject: [PATCH 10/10] Add correct parent for ag_app_buttoned_dialog() It was still using @parent, which was explicitly set to NULL Fixes #51 --- src/ag-app.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ag-app.c b/src/ag-app.c index d545664..3ae09f9 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -481,12 +481,11 @@ ag_app_buttoned_dialog(GtkWindow *window, const gchar *button_text; gint response_id; GtkWidget *dialog; - GtkWindow *parent = NULL; g_return_val_if_fail(GTK_IS_WINDOW(window), GTK_RESPONSE_NONE); dialog = gtk_message_dialog_new( - parent, + window, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, message_type, GTK_BUTTONS_NONE,