Merge pull request #21 from gergelypolonkai/remove-stack-switcher
Move view changing functionality from GtkStackSwitcher into a view menu
This commit is contained in:
commit
cddfae951d
@ -126,7 +126,7 @@ ag_app_open_chart(AgApp *app, GFile *file)
|
|||||||
uri = g_file_get_uri(file);
|
uri = g_file_get_uri(file);
|
||||||
ag_window_set_uri(AG_WINDOW(window), uri);
|
ag_window_set_uri(AG_WINDOW(window), uri);
|
||||||
g_free(uri);
|
g_free(uri);
|
||||||
ag_window_open_chart_tab(AG_WINDOW(window));
|
ag_window_change_tab(AG_WINDOW(window), "chart");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -65,6 +65,17 @@ ag_window_gear_menu_action(GSimpleAction *action, GVariant *parameter, gpointer
|
|||||||
g_variant_unref(state);
|
g_variant_unref(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ag_window_view_menu_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
|
{
|
||||||
|
GVariant *state;
|
||||||
|
|
||||||
|
state = g_action_get_state(G_ACTION(action));
|
||||||
|
g_action_change_state(G_ACTION(action), g_variant_new_boolean(!g_variant_get_boolean(state)));
|
||||||
|
|
||||||
|
g_variant_unref(state);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ag_window_close_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
ag_window_close_action(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -475,6 +486,7 @@ static GActionEntry win_entries[] = {
|
|||||||
{ "save", ag_window_save_action, NULL, NULL, NULL },
|
{ "save", ag_window_save_action, NULL, NULL, NULL },
|
||||||
{ "save-as", ag_window_save_as_action, NULL, NULL, NULL },
|
{ "save-as", ag_window_save_as_action, NULL, NULL, NULL },
|
||||||
{ "export-svg", ag_window_export_svg_action, NULL, NULL, NULL },
|
{ "export-svg", ag_window_export_svg_action, NULL, NULL, NULL },
|
||||||
|
{ "view-menu", ag_window_view_menu_action, NULL, "false", NULL },
|
||||||
{ "gear-menu", ag_window_gear_menu_action, NULL, "false", NULL },
|
{ "gear-menu", ag_window_gear_menu_action, NULL, "false", NULL },
|
||||||
{ "change-tab", ag_window_change_tab_action, "s", "'edit'", NULL },
|
{ "change-tab", ag_window_change_tab_action, "s", "'edit'", NULL },
|
||||||
};
|
};
|
||||||
@ -677,7 +689,11 @@ ag_window_settings_save(GtkWindow *window, GSettings *settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ag_window_open_chart_tab(AgWindow *window)
|
ag_window_change_tab(AgWindow *window, const gchar *tab_name)
|
||||||
{
|
{
|
||||||
gtk_stack_set_visible_child_name(GTK_STACK(window->priv->stack), "chart");
|
gtk_stack_set_visible_child_name(GTK_STACK(window->priv->stack), tab_name);
|
||||||
|
g_action_change_state(
|
||||||
|
g_action_map_lookup_action(G_ACTION_MAP(window), "change-tab"),
|
||||||
|
g_variant_new_string(tab_name)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void ag_window_settings_restore(GtkWindow *window,
|
|||||||
GSettings *settings);
|
GSettings *settings);
|
||||||
void ag_window_settings_save(GtkWindow *window,
|
void ag_window_settings_save(GtkWindow *window,
|
||||||
GSettings *settings);
|
GSettings *settings);
|
||||||
void ag_window_open_chart_tab(AgWindow *window);
|
void ag_window_change_tab(AgWindow *window, const gchar *tab_name);
|
||||||
|
|
||||||
#define AG_WINDOW_ERROR (ag_window_error_quark())
|
#define AG_WINDOW_ERROR (ag_window_error_quark())
|
||||||
GQuark ag_window_error_quark(void);
|
GQuark ag_window_error_quark(void);
|
||||||
|
@ -2,6 +2,34 @@
|
|||||||
<!-- Generated with glade 3.18.3 -->
|
<!-- Generated with glade 3.18.3 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.12"/>
|
<requires lib="gtk+" version="3.12"/>
|
||||||
|
<menu id="view_menu">
|
||||||
|
<section>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Edit</attribute>
|
||||||
|
<attribute name="action">win.change-tab</attribute>
|
||||||
|
<attribute name="accel"><F3></attribute>
|
||||||
|
<attribute name="target">edit</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Chart</attribute>
|
||||||
|
<attribute name="action">win.change-tab</attribute>
|
||||||
|
<attribute name="accel"><F5></attribute>
|
||||||
|
<attribute name="target">chart</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Aspects</attribute>
|
||||||
|
<attribute name="action">win.change-tab</attribute>
|
||||||
|
<attribute name="accel"><F6></attribute>
|
||||||
|
<attribute name="target">aspects</attribute>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">Points</attribute>
|
||||||
|
<attribute name="action">win.change-tab</attribute>
|
||||||
|
<attribute name="accel"><F7></attribute>
|
||||||
|
<attribute name="target">points</attribute>
|
||||||
|
</item>
|
||||||
|
</section>
|
||||||
|
</menu>
|
||||||
<menu id="gear_menu">
|
<menu id="gear_menu">
|
||||||
<section>
|
<section>
|
||||||
<item>
|
<item>
|
||||||
@ -87,7 +115,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="vexpand">False</property>
|
<property name="vexpand">False</property>
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="show_close_button">True</property>
|
<property name="show_close_button">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box">
|
<object class="GtkBox" id="box">
|
||||||
@ -97,37 +124,53 @@
|
|||||||
<style>
|
<style>
|
||||||
<class name="linked"/>
|
<class name="linked"/>
|
||||||
</style>
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="action_name">win.gear-menu</property>
|
||||||
|
<property name="menu_model">gear_menu</property>
|
||||||
|
<property name="use_popover">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkStackSwitcher">
|
<object class="GtkImage" id="gear_image">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="icon_size">1</property>
|
||||||
<property name="stack">stack</property>
|
<property name="icon_name">emblem-system-symbolic</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkMenuButton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="valign">center</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="action_name">win.gear-menu</property>
|
|
||||||
<property name="menu_model">gear_menu</property>
|
|
||||||
<property name="use_popover">True</property>
|
|
||||||
<style>
|
|
||||||
<class name="image-button"/>
|
|
||||||
</style>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="gear_image">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="icon_size">1</property>
|
|
||||||
<property name="icon_name">emblem-system-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="action_name">win.view-menu</property>
|
||||||
|
<property name="menu_model">view_menu</property>
|
||||||
|
<property name="use_popover">True</property>
|
||||||
|
<style>
|
||||||
|
<class name="image-button"/>
|
||||||
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="view_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
<property name="icon_name">document-properties-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
Loading…
Reference in New Issue
Block a user