Merge branch 'master' into city-chooser
Conflicts: src/ag-db.c src/ag-window.c
This commit is contained in:
commit
1a8c778d31
@ -35,7 +35,7 @@ PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
|
|||||||
PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.12])
|
PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.12])
|
||||||
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
|
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
|
||||||
PKG_CHECK_MODULES([LIBXSLT], [libexslt])
|
PKG_CHECK_MODULES([LIBXSLT], [libexslt])
|
||||||
PKG_CHECK_MODULES([WEBKIT], [webkit2gtk-3.0])
|
PKG_CHECK_MODULES([WEBKIT], [webkit2gtk-4.0])
|
||||||
PKG_CHECK_MODULES([GDA], [libgda-5.0 libgda-sqlite-5.0])
|
PKG_CHECK_MODULES([GDA], [libgda-5.0 libgda-sqlite-5.0])
|
||||||
PKG_CHECK_MODULES([SWE_GLIB], [swe-glib >= 2.1.0])
|
PKG_CHECK_MODULES([SWE_GLIB], [swe-glib >= 2.1.0])
|
||||||
|
|
||||||
|
19
src/ag-app.c
19
src/ag-app.c
@ -9,7 +9,7 @@
|
|||||||
#include "astrognome.h"
|
#include "astrognome.h"
|
||||||
|
|
||||||
typedef struct _AgAppPrivate {
|
typedef struct _AgAppPrivate {
|
||||||
WebKitWebViewGroup *web_view_group;
|
WebKitUserContentManager *manager;
|
||||||
} AgAppPrivate;
|
} AgAppPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(AgApp, ag_app, GTK_TYPE_APPLICATION);
|
G_DEFINE_TYPE_WITH_PRIVATE(AgApp, ag_app, GTK_TYPE_APPLICATION);
|
||||||
@ -58,7 +58,7 @@ ag_app_create_window(AgApp *app)
|
|||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
AgAppPrivate *priv = ag_app_get_instance_private(app);
|
AgAppPrivate *priv = ag_app_get_instance_private(app);
|
||||||
|
|
||||||
window = ag_window_new(app, priv->web_view_group);
|
window = ag_window_new(app, priv->manager);
|
||||||
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(window));
|
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(window));
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all(window);
|
||||||
|
|
||||||
@ -428,9 +428,10 @@ ag_app_init(AgApp *app)
|
|||||||
GBytes *css_data;
|
GBytes *css_data;
|
||||||
const gchar *css_source;
|
const gchar *css_source;
|
||||||
gsize css_length;
|
gsize css_length;
|
||||||
|
WebKitUserStyleSheet *stylesheet;
|
||||||
|
|
||||||
priv = ag_app_get_instance_private(app);
|
priv = ag_app_get_instance_private(app);
|
||||||
priv->web_view_group = webkit_web_view_group_new(NULL);
|
priv->manager = webkit_user_content_manager_new();
|
||||||
|
|
||||||
css_data = g_resources_lookup_data(
|
css_data = g_resources_lookup_data(
|
||||||
"/eu/polonkai/gergely/Astrognome/ui/chart-default.css",
|
"/eu/polonkai/gergely/Astrognome/ui/chart-default.css",
|
||||||
@ -439,14 +440,14 @@ ag_app_init(AgApp *app)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ((css_source = g_bytes_get_data(css_data, &css_length)) != NULL) {
|
if ((css_source = g_bytes_get_data(css_data, &css_length)) != NULL) {
|
||||||
webkit_web_view_group_add_user_style_sheet(
|
stylesheet = webkit_user_style_sheet_new(
|
||||||
priv->web_view_group,
|
|
||||||
css_source,
|
css_source,
|
||||||
NULL,
|
WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
|
||||||
NULL,
|
WEBKIT_USER_STYLE_LEVEL_USER,
|
||||||
NULL,
|
NULL, NULL
|
||||||
WEBKIT_INJECTED_CONTENT_FRAMES_TOP_ONLY
|
|
||||||
);
|
);
|
||||||
|
webkit_user_content_manager_add_style_sheet(priv->manager, stylesheet);
|
||||||
|
webkit_user_style_sheet_unref(stylesheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_bytes_unref(css_data);
|
g_bytes_unref(css_data);
|
||||||
|
@ -397,9 +397,14 @@ ag_window_redraw_aspect_table(AgWindow *window)
|
|||||||
void
|
void
|
||||||
ag_window_redraw_chart(AgWindow *window)
|
ag_window_redraw_chart(AgWindow *window)
|
||||||
{
|
{
|
||||||
|
gsize length;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
||||||
gchar *svg_content = ag_chart_create_svg(priv->chart, NULL, &err);
|
gchar *svg_content = ag_chart_create_svg(
|
||||||
|
priv->chart,
|
||||||
|
&length,
|
||||||
|
&err
|
||||||
|
);
|
||||||
|
|
||||||
if (svg_content == NULL) {
|
if (svg_content == NULL) {
|
||||||
ag_app_message_dialog(
|
ag_app_message_dialog(
|
||||||
@ -409,11 +414,16 @@ ag_window_redraw_chart(AgWindow *window)
|
|||||||
err->message
|
err->message
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
webkit_web_view_load_html(
|
GBytes *content;
|
||||||
|
|
||||||
|
content = g_bytes_new_take(svg_content, length);
|
||||||
|
|
||||||
|
webkit_web_view_load_bytes(
|
||||||
WEBKIT_WEB_VIEW(priv->chart_web_view),
|
WEBKIT_WEB_VIEW(priv->chart_web_view),
|
||||||
svg_content, NULL
|
content, "image/svg+xml",
|
||||||
|
"UTF-8", NULL
|
||||||
);
|
);
|
||||||
g_free(svg_content);
|
g_bytes_unref(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
ag_window_redraw_aspect_table(window);
|
ag_window_redraw_aspect_table(window);
|
||||||
@ -1263,6 +1273,69 @@ ag_window_delete_action(GSimpleAction *action,
|
|||||||
g_action_group_activate_action(G_ACTION_GROUP(window), "refresh", NULL);
|
g_action_group_activate_action(G_ACTION_GROUP(window), "refresh", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ag_window_js_callback(GObject *object, GAsyncResult *res, gpointer user_data)
|
||||||
|
{
|
||||||
|
WebKitJavascriptResult *js_result;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
|
if ((js_result = webkit_web_view_run_javascript_finish(
|
||||||
|
WEBKIT_WEB_VIEW(object),
|
||||||
|
res,
|
||||||
|
&err
|
||||||
|
)) != NULL) {
|
||||||
|
webkit_javascript_result_unref(js_result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ag_window_connection_action(GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GVariant *current_state;
|
||||||
|
const gchar *state;
|
||||||
|
gchar *js_code = NULL;
|
||||||
|
AgWindowPrivate *priv = ag_window_get_instance_private(
|
||||||
|
AG_WINDOW(user_data)
|
||||||
|
);
|
||||||
|
static gchar *js = "aspects = document.getElementById('aspects');\n" \
|
||||||
|
"antiscia = document.getElementById('antiscia');\n" \
|
||||||
|
"aspects.setAttribute('visibility', '%s');\n" \
|
||||||
|
"antiscia.setAttribute('visibility', '%s');\n";
|
||||||
|
|
||||||
|
current_state = g_action_get_state(G_ACTION(action));
|
||||||
|
|
||||||
|
if (g_variant_equal(current_state, parameter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_action_change_state(G_ACTION(action), parameter);
|
||||||
|
|
||||||
|
state = g_variant_get_string(parameter, NULL);
|
||||||
|
|
||||||
|
if (strcmp("aspects", state) == 0) {
|
||||||
|
g_debug("Switching to aspects");
|
||||||
|
js_code = g_strdup_printf(js, "visible", "hidden");
|
||||||
|
} else if (strcmp("antiscia", state) == 0) {
|
||||||
|
g_debug("Switching to antiscia");
|
||||||
|
js_code = g_strdup_printf(js, "hidden", "visible");
|
||||||
|
} else {
|
||||||
|
g_warning("Connection type '%s' is invalid", state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (js_code) {
|
||||||
|
webkit_web_view_run_javascript(
|
||||||
|
WEBKIT_WEB_VIEW(priv->chart_web_view),
|
||||||
|
js_code,
|
||||||
|
NULL,
|
||||||
|
ag_window_js_callback,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
g_free(js_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GActionEntry win_entries[] = {
|
static GActionEntry win_entries[] = {
|
||||||
{ "close", ag_window_close_action, NULL, NULL, NULL },
|
{ "close", ag_window_close_action, NULL, NULL, NULL },
|
||||||
{ "save", ag_window_save_action, NULL, NULL, NULL },
|
{ "save", ag_window_save_action, NULL, NULL, NULL },
|
||||||
@ -1276,6 +1349,7 @@ static GActionEntry win_entries[] = {
|
|||||||
{ "refresh", ag_window_refresh_action, NULL, NULL, NULL },
|
{ "refresh", ag_window_refresh_action, NULL, NULL, NULL },
|
||||||
{ "selection", ag_window_selection_mode_action, NULL, "false", NULL },
|
{ "selection", ag_window_selection_mode_action, NULL, "false", NULL },
|
||||||
{ "delete", ag_window_delete_action, NULL, NULL, NULL },
|
{ "delete", ag_window_delete_action, NULL, NULL, NULL },
|
||||||
|
{ "connection", ag_window_connection_action, "s", "'aspects'", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1736,13 +1810,19 @@ ag_window_configure_event_cb(GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group)
|
ag_window_new(AgApp *app, WebKitUserContentManager *manager)
|
||||||
{
|
{
|
||||||
AgWindow *window = g_object_new(AG_TYPE_WINDOW, NULL);
|
AgWindow *window = g_object_new(AG_TYPE_WINDOW, NULL);
|
||||||
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
AgWindowPrivate *priv = ag_window_get_instance_private(window);
|
||||||
|
|
||||||
priv->chart_web_view = webkit_web_view_new_with_group(web_view_group);
|
priv->chart_web_view = webkit_web_view_new_with_user_content_manager(
|
||||||
gtk_container_add(GTK_CONTAINER(priv->tab_chart), priv->chart_web_view);
|
manager
|
||||||
|
);
|
||||||
|
gtk_box_pack_end(
|
||||||
|
GTK_BOX(priv->tab_chart),
|
||||||
|
priv->chart_web_view,
|
||||||
|
TRUE, TRUE, 0
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: translate this error message!
|
// TODO: translate this error message!
|
||||||
webkit_web_view_load_html(
|
webkit_web_view_load_html(
|
||||||
|
@ -41,7 +41,7 @@ struct _AgWindowClass {
|
|||||||
|
|
||||||
GType ag_window_get_type(void) G_GNUC_CONST;
|
GType ag_window_get_type(void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget *ag_window_new(AgApp *app, WebKitWebViewGroup *web_view_group);
|
GtkWidget *ag_window_new(AgApp *app, WebKitUserContentManager *manager);
|
||||||
|
|
||||||
void ag_window_set_chart(AgWindow *window,
|
void ag_window_set_chart(AgWindow *window,
|
||||||
AgChart *chart);
|
AgChart *chart);
|
||||||
|
@ -764,9 +764,40 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkAlignment" id="tab_chart">
|
<object class="GtkBox" id="tab_chart">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton" id="toolbar_aspect">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Aspects</property>
|
||||||
|
<property name="draw_indicator">False</property>
|
||||||
|
<property name="action_name">win.connection</property>
|
||||||
|
<property name="action_target">'aspects'</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkRadioButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Antiscia</property>
|
||||||
|
<property name="draw_indicator">False</property>
|
||||||
|
<property name="group">toolbar_aspect</property>
|
||||||
|
<property name="action_name">win.connection</property>
|
||||||
|
<property name="action_target">'antiscia'</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">start</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="name">chart</property>
|
<property name="name">chart</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user