Merge pull request #103 from gergelypolonkai/refine-ui

Add a selection menu to the header bar’s selection mode
This commit is contained in:
Gergely Polonkai 2014-10-19 02:19:10 +02:00
commit 82a22241c9
5 changed files with 40 additions and 26 deletions

View File

@ -6,8 +6,9 @@ src/ag-chart.c
src/ag-db.c src/ag-db.c
src/ag-display-theme.c src/ag-display-theme.c
src/ag-window.c src/ag-window.c
src/ag-header-bar.c
src/astrognome.c src/astrognome.c
[type: gettext/glade]src/resources/ui/astrognome.ui [type: gettext/glade]src/resources/gtk/menus.ui
[type: gettext/glade]src/resources/ui/ag-window.ui [type: gettext/glade]src/resources/ui/ag-window.ui
[type: gettext/glade]src/resources/ui/ag-preferences.ui [type: gettext/glade]src/resources/ui/ag-preferences.ui
[type: gettext/glade]src/resources/ui/ag-chart-edit.ui [type: gettext/glade]src/resources/ui/ag-chart-edit.ui

View File

@ -361,6 +361,7 @@ const gchar *action_accels[] = {
"win.change-tab::points", "F7", NULL, "win.change-tab::points", "F7", NULL,
"win.change-tab::edit", "F4", NULL, "win.change-tab::edit", "F4", NULL,
"win.back", "<Alt>Left", "Back", NULL, "win.back", "<Alt>Left", "Back", NULL,
"win.select-all", "<Primary>A", NULL,
NULL NULL
}; };
@ -378,29 +379,6 @@ setup_accelerators(AgApp *app)
} }
} }
static void
setup_menu(AgApp *app)
{
GtkBuilder *builder;
GMenuModel *model;
GError *err = NULL;
builder = gtk_builder_new();
if (!gtk_builder_add_from_resource(
builder,
"/eu/polonkai/gergely/Astrognome/ui/astrognome.ui",
&err
)) {
g_error("%s", (err) ? err->message : "unknown error");
}
model = G_MENU_MODEL(gtk_builder_get_object(builder, "app-menu"));
gtk_application_set_app_menu(GTK_APPLICATION(app), model);
g_object_unref(builder);
}
static void static void
startup(GApplication *gapp) startup(GApplication *gapp)
{ {
@ -409,7 +387,6 @@ startup(GApplication *gapp)
G_APPLICATION_CLASS(ag_app_parent_class)->startup(gapp); G_APPLICATION_CLASS(ag_app_parent_class)->startup(gapp);
setup_actions(app); setup_actions(app);
setup_menu(app);
setup_accelerators(app); setup_accelerators(app);
} }

View File

@ -1645,6 +1645,26 @@ ag_window_connection_action(GSimpleAction *action,
} }
} }
static void
ag_window_select_all_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GET_PRIV(AG_WINDOW(user_data));
ag_icon_view_select_all(priv->chart_list);
}
static void
ag_window_select_none_action(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GET_PRIV(AG_WINDOW(user_data));
ag_icon_view_unselect_all(priv->chart_list);
}
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 },
@ -1658,6 +1678,8 @@ static GActionEntry win_entries[] = {
{ "refresh", ag_window_refresh_action, NULL, NULL, NULL }, { "refresh", ag_window_refresh_action, NULL, NULL, 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 }, { "connection", ag_window_connection_action, "s", "'aspects'", NULL },
{ "select-all", ag_window_select_all_action, NULL, NULL, NULL },
{ "select-none", ag_window_select_none_action, NULL, NULL, NULL },
}; };
static void static void

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<gresources> <gresources>
<gresource prefix="/eu/polonkai/gergely/Astrognome"> <gresource prefix="/eu/polonkai/gergely/Astrognome">
<file>ui/astrognome.ui</file> <file>gtk/menus.ui</file>
<file>ui/ag-window.ui</file> <file>ui/ag-window.ui</file>
<file>ui/ag-preferences.ui</file> <file>ui/ag-preferences.ui</file>
<file>ui/ag-chart-edit.ui</file> <file>ui/ag-chart-edit.ui</file>

View File

@ -39,4 +39,17 @@
</item> </item>
</section> </section>
</menu> </menu>
<menu id="selection-menu">
<section>
<item>
<attribute name="label" translatable="yes">Select All</attribute>
<attribute name="action">win.select-all</attribute>
<attribute name="accel">&lt;Primary&gt;a</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Select None</attribute>
<attribute name="action">win.select-none</attribute>
</item>
</section>
</menu>
</interface> </interface>