forked from AuroraMiddleware/gtk
GtkApplication: add 'active-window' property
This commit is contained in:
parent
d1c458f9e1
commit
2e57819477
@ -246,6 +246,7 @@ gtk_application_window_get_type
|
||||
gtk_application_window_get_id
|
||||
gtk_application_window_new
|
||||
gtk_application_window_set_show_menubar
|
||||
gtk_application_get_active_window
|
||||
gtk_arrow_get_type
|
||||
gtk_arrow_new
|
||||
gtk_arrow_placement_get_type
|
||||
|
@ -132,7 +132,8 @@ enum {
|
||||
PROP_ZERO,
|
||||
PROP_REGISTER_SESSION,
|
||||
PROP_APP_MENU,
|
||||
PROP_MENUBAR
|
||||
PROP_MENUBAR,
|
||||
PROP_ACTIVE_WINDOW
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkApplication, gtk_application, G_TYPE_APPLICATION)
|
||||
@ -405,6 +406,8 @@ gtk_application_focus_in_event_cb (GtkWindow *window,
|
||||
priv->windows = g_list_concat (link, priv->windows);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (application), "active-window");
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
gtk_application_focus_changed (application, window);
|
||||
#endif
|
||||
@ -529,6 +532,8 @@ gtk_application_window_added (GtkApplication *application,
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
gtk_application_window_added_x11 (application, window);
|
||||
#endif
|
||||
|
||||
g_object_notify (G_OBJECT (application), "active-window");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -536,6 +541,9 @@ gtk_application_window_removed (GtkApplication *application,
|
||||
GtkWindow *window)
|
||||
{
|
||||
GtkApplicationPrivate *priv = application->priv;
|
||||
gpointer old_active;
|
||||
|
||||
old_active = priv->windows;
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
gtk_application_window_removed_x11 (application, window);
|
||||
@ -548,6 +556,9 @@ gtk_application_window_removed (GtkApplication *application,
|
||||
g_application_release (G_APPLICATION (application));
|
||||
priv->windows = g_list_remove (priv->windows, window);
|
||||
gtk_window_set_application (window, NULL);
|
||||
|
||||
if (priv->windows != old_active)
|
||||
g_object_notify (G_OBJECT (application), "active-window");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -755,6 +766,13 @@ gtk_application_class_init (GtkApplicationClass *class)
|
||||
P_("The GMenuModel for the menubar"),
|
||||
G_TYPE_MENU_MODEL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ACTIVE_WINDOW,
|
||||
g_param_spec_object ("active-window",
|
||||
P_("Active window"),
|
||||
P_("The window which most recently had focus"),
|
||||
GTK_TYPE_WINDOW,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -915,6 +933,29 @@ gtk_application_get_window_by_id (GtkApplication *application,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_get_active_window:
|
||||
* @application: a #GtkApplication
|
||||
*
|
||||
* Gets the "active" window for the application.
|
||||
*
|
||||
* The active window is the one that was most recently focused (within
|
||||
* the application). This window may not have the focus at the moment
|
||||
* if another application has it -- this is just the most
|
||||
* recently-focused window within this application.
|
||||
*
|
||||
* Returns: (transfer none): the active window
|
||||
*
|
||||
* Since: 3.6
|
||||
**/
|
||||
GtkWindow *
|
||||
gtk_application_get_active_window (GtkApplication *application)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
|
||||
|
||||
return application->priv->windows ? application->priv->windows->data : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_add_accelerator:
|
||||
* @application: a #GtkApplication
|
||||
|
@ -119,6 +119,9 @@ GDK_AVAILABLE_IN_3_6
|
||||
GtkWindow * gtk_application_get_window_by_id (GtkApplication *application,
|
||||
guint id);
|
||||
|
||||
GDK_AVAILABLE_IN_3_6
|
||||
GtkWindow * gtk_application_get_active_window (GtkApplication *application);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_APPLICATION_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user