[recipes] Do the fullscreen keynav in a better way
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Do the fullscreen keynav in a better way
- Date: Sun, 12 Mar 2017 02:08:07 +0000 (UTC)
commit 68e50be814f8a212b2f83d0754b1268aaeeca27e
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Mar 11 21:05:10 2017 -0500
Do the fullscreen keynav in a better way
Instead of manually checking in the callback, enable and disable
the actions as appropriate.
src/gr-app.c | 21 +--------------------
src/gr-window.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 35aa895..1759637 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -98,8 +98,6 @@ chef_information_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_show_my_chef_information (GR_WINDOW (win));
}
@@ -112,8 +110,6 @@ about_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_show_about_dialog (GR_WINDOW (win));
}
@@ -126,8 +122,6 @@ report_issue_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_show_report_issue (GR_WINDOW (win));
}
@@ -140,8 +134,6 @@ news_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_show_news (GR_WINDOW (win));
}
@@ -154,8 +146,6 @@ quit_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gtk_window_close (win);
}
@@ -168,8 +158,6 @@ import_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_load_recipe (GR_WINDOW (win), NULL);
}
@@ -182,8 +170,6 @@ export_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_save_all (GR_WINDOW (win));
}
@@ -202,8 +188,6 @@ details_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
recipe = gr_recipe_store_get_recipe (gr_recipe_store_get (), id);
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
gr_window_show_recipe (GR_WINDOW (win), recipe);
}
@@ -220,10 +204,7 @@ search_activated (GSimpleAction *action,
gr_app_activate (G_APPLICATION (app));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
- if (gr_window_is_fullscreen (GR_WINDOW (win)))
- return;
- if (gr_window_can_search (GR_WINDOW (win)))
- gr_window_show_search (GR_WINDOW (win), search);
+ gr_window_show_search (GR_WINDOW (win), search);
}
#define DEFAULT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE)
diff --git a/src/gr-window.c b/src/gr-window.c
index c5988dc..ec413bb 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -320,9 +320,36 @@ static void
visible_page_changed (GrWindow *window)
{
const char *visible;
+ gboolean searchable;
+ gboolean fullscreen;
+ GAction *action;
+ const char *actions[] = {
+ "chef-information",
+ "about",
+ "news",
+ "import",
+ "export",
+ "details",
+ "quit",
+ "report-issue"
+ };
+ int i;
visible = gtk_stack_get_visible_child_name (GTK_STACK (window->main_stack));
+ searchable = strcmp (visible, "recipes") == 0 ||
+ strcmp (visible, "cuisines") == 0 ||
+ strcmp (visible, "search") == 0;
+ fullscreen = strcmp (visible, "image") == 0 ||
+ strcmp (visible, "cooking") == 0;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (g_application_get_default ()), "search");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), searchable);
+ for (i = 0; i < G_N_ELEMENTS (actions); i++) {
+ action = g_action_map_lookup_action (G_ACTION_MAP (g_application_get_default ()),
actions[i]);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !fullscreen);
+ }
+
if (strcmp (visible, "search") != 0) {
g_signal_handlers_block_by_func (window->search_bar, search_changed, window);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (window->search_button), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]