Add connection view changer buttons (aspects/antiscia)
This commit is contained in:
parent
6070dc9cc0
commit
59ac56ba8f
@ -1264,6 +1264,69 @@ ag_window_delete_action(GSimpleAction *action,
|
||||
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[] = {
|
||||
{ "close", ag_window_close_action, NULL, NULL, NULL },
|
||||
{ "save", ag_window_save_action, NULL, NULL, NULL },
|
||||
@ -1277,6 +1340,7 @@ static GActionEntry win_entries[] = {
|
||||
{ "refresh", ag_window_refresh_action, NULL, NULL, NULL },
|
||||
{ "selection", ag_window_selection_mode_action, NULL, "false", NULL },
|
||||
{ "delete", ag_window_delete_action, NULL, NULL, NULL },
|
||||
{ "connection", ag_window_connection_action, "s", "'aspects'", NULL },
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -765,6 +765,27 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user