mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
clapper-app: Add "New Window" menu option
Allow creating new windows from within the app
This commit is contained in:
@@ -217,6 +217,21 @@ add_uri (GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||
clapper_app_uri_dialog_open_uri (gtk_app);
|
||||
}
|
||||
|
||||
static void
|
||||
new_window (GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||
{
|
||||
GtkApplication *gtk_app = GTK_APPLICATION (user_data);
|
||||
GtkWidget *stack = gtk_window_get_child (gtk_application_get_active_window (gtk_app));
|
||||
const gchar *child_name = gtk_stack_get_visible_child_name (GTK_STACK (stack));
|
||||
|
||||
/* Do not allow to open new windows during initial state,
|
||||
* there already is a free one to use */
|
||||
if (g_strcmp0 (child_name, "initial_state") != 0) {
|
||||
GtkWidget *window = clapper_app_window_new (gtk_app);
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
show_preferences (GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||
{
|
||||
@@ -648,6 +663,7 @@ clapper_app_application_constructed (GObject *object)
|
||||
static const GActionEntry app_actions[] = {
|
||||
{ "add-files", add_files, NULL, NULL, NULL },
|
||||
{ "add-uri", add_uri, NULL, NULL, NULL },
|
||||
{ "new-window", new_window, NULL, NULL, NULL },
|
||||
{ "info", show_info, NULL, NULL, NULL },
|
||||
{ "preferences", show_preferences, NULL, NULL, NULL },
|
||||
{ "about", show_about, NULL, NULL, NULL },
|
||||
|
@@ -178,6 +178,12 @@
|
||||
</child>
|
||||
</template>
|
||||
<menu id="app_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">New Window</attribute>
|
||||
<attribute name="action">app.new-window</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Preferences</attribute>
|
||||
|
Reference in New Issue
Block a user