widget-factory: Make sure we close popover on page 3

We don't want the popover to stay open when we open
an about dialog or shortcuts window. Since cascade-popdown
would also affect e.g. the context menu of the text widgets,
do this explicitly.
This commit is contained in:
Matthias Clasen 2020-11-03 12:09:43 -05:00
parent dab11ea841
commit 7624f66fec
2 changed files with 23 additions and 1 deletions

View File

@ -260,6 +260,8 @@ activate_about (GSimpleAction *action,
gpointer user_data)
{
GtkApplication *app = user_data;
GtkWindow *window;
GtkWidget *button;
const char *authors[] = {
"Andrea Cimitan",
"Cosimo Cecchi",
@ -277,6 +279,10 @@ activate_about (GSimpleAction *action,
s = g_string_new ("");
window = gtk_application_get_active_window (app);
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
if (os_name && os_version)
@ -326,6 +332,21 @@ activate_about (GSimpleAction *action,
g_free (os_version);
}
static void
activate_shortcuts_window (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
GtkWindow *window;
GtkWidget *button;
window = gtk_application_get_active_window (app);
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
gtk_widget_activate_action (GTK_WIDGET (window), "win.show-help-overlay", NULL);
}
static void
activate_quit (GSimpleAction *action,
GVariant *parameter,
@ -2371,6 +2392,7 @@ main (int argc, char *argv[])
GAction *action;
static GActionEntry app_entries[] = {
{ "about", activate_about, NULL, NULL, NULL },
{ "shortcuts", activate_shortcuts_window, NULL, NULL, NULL },
{ "quit", activate_quit, NULL, NULL, NULL },
{ "inspector", activate_inspector, NULL, NULL, NULL },
{ "main", NULL, "s", "'steak'", NULL },

View File

@ -51,7 +51,7 @@
</item>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About Widget Factory</attribute>