[gtk/present-toplevel-2: 32/70] toplevel: Add title, startup-id, transient-for, icon-list
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/present-toplevel-2: 32/70] toplevel: Add title, startup-id, transient-for, icon-list
- Date: Wed, 4 Mar 2020 00:08:10 +0000 (UTC)
commit e13f07d5f33b78317f7b4147e612a6311b6675e9
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 1 12:12:59 2020 -0500
toplevel: Add title, startup-id, transient-for, icon-list
Move misc. toplevel-only things to be GdkToplevel properties.
gdk/gdktoplevel.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdktoplevel.h | 16 +++++++
gdk/gdktoplevelprivate.h | 4 ++
3 files changed, 129 insertions(+)
---
diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c
index d284994028..d74520b0f6 100644
--- a/gdk/gdktoplevel.c
+++ b/gdk/gdktoplevel.c
@@ -57,6 +57,29 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
P_("State"),
GDK_TYPE_SURFACE_STATE, GDK_SURFACE_STATE_WITHDRAWN,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("title",
+ "Title",
+ "The title of the surface",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("startup-id",
+ "Startup ID",
+ "The startup ID of the surface",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("transient-for",
+ "Transient For",
+ "The transient parent of the surface",
+ GDK_TYPE_SURFACE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
+ g_object_interface_install_property (iface,
+ g_param_spec_pointer ("icon-list",
+ "Icon List",
+ "The list of icon textures",
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
}
guint
@@ -64,6 +87,10 @@ gdk_toplevel_install_properties (GObjectClass *object_class,
guint first_prop)
{
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STATE, "state");
+ g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_TITLE, "title");
+ g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STARTUP_ID, "startup-id");
+ g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_TRANSIENT_FOR,
"transient-for");
+ g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_ICON_LIST, "icon-list");
return GDK_TOPLEVEL_NUM_PROPERTIES;
}
@@ -117,3 +144,85 @@ gdk_toplevel_get_state (GdkToplevel *toplevel)
return state;
}
+
+/**
+ * gdk_toplevel_set_title:
+ * @toplevel: a #GdkToplevel
+ * @title: title of @surface
+ *
+ * Sets the title of a toplevel surface, to be displayed in the titlebar,
+ * in lists of windows, etc.
+ */
+void
+gdk_toplevel_set_title (GdkToplevel *toplevel,
+ const char *title)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ g_object_set (toplevel, "title", title, NULL);
+}
+
+/**
+ * gdk_toplevel_set_startup_id:
+ * @toplevel: a #GdkToplevel
+ * @startup_id: a string with startup-notification identifier
+ *
+ * When using GTK, typically you should use gtk_window_set_startup_id()
+ * instead of this low-level function.
+ */
+void
+gdk_toplevel_set_startup_id (GdkToplevel *toplevel,
+ const char *startup_id)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ g_object_set (toplevel, "startup-id", startup_id, NULL);
+}
+
+/**
+ * gdk_toplevel_set_transient_for:
+ * @toplevel: a #GdkToplevel
+ * @parent: another toplevel #GdkSurface
+ *
+ * Indicates to the window manager that @surface is a transient dialog
+ * associated with the application surface @parent. This allows the
+ * window manager to do things like center @surface on @parent and
+ * keep @surface above @parent.
+ *
+ * See gtk_window_set_transient_for() if you’re using #GtkWindow or
+ * #GtkDialog.
+ */
+void
+gdk_toplevel_set_transient_for (GdkToplevel *toplevel,
+ GdkSurface *parent)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ g_object_set (toplevel, "transient-for", parent, NULL);
+}
+
+
+/**
+ * gdk_toplevel_set_icon_list:
+ * @toplevel: a #GdkToplevel
+ * @surfaces: (transfer none) (element-type GdkTexture):
+ * A list of textures to use as icon, of different sizes
+ *
+ * Sets a list of icons for the surface.
+ *
+ * One of these will be used to represent the surface in iconic form.
+ * The icon may be shown in window lists or task bars. Which icon
+ * size is shown depends on the window manager. The window manager
+ * can scale the icon but setting several size icons can give better
+ * image quality.
+ *
+ * Note that some platforms don't support surface icons.
+ */
+void
+gdk_toplevel_set_icon_list (GdkToplevel *toplevel,
+ GList *surfaces)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ g_object_set (toplevel, "icon-list", surfaces, NULL);
+}
diff --git a/gdk/gdktoplevel.h b/gdk/gdktoplevel.h
index 6a10c4af22..90d5e41a7f 100644
--- a/gdk/gdktoplevel.h
+++ b/gdk/gdktoplevel.h
@@ -43,6 +43,22 @@ gboolean gdk_toplevel_present (GdkToplevel *toplevel,
GDK_AVAILABLE_IN_ALL
GdkSurfaceState gdk_toplevel_get_state (GdkToplevel *toplevel);
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_set_title (GdkToplevel *toplevel,
+ const char *title);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_set_startup_id (GdkToplevel *toplevel,
+ const char *startup_id);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_set_transient_for (GdkToplevel *toplevel,
+ GdkSurface *parent);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_set_icon_list (GdkToplevel *toplevel,
+ GList *surfaces);
+
G_END_DECLS
#endif /* __GDK_TOPLEVEL_H__ */
diff --git a/gdk/gdktoplevelprivate.h b/gdk/gdktoplevelprivate.h
index fbf751e3fa..6190a5d6d1 100644
--- a/gdk/gdktoplevelprivate.h
+++ b/gdk/gdktoplevelprivate.h
@@ -18,6 +18,10 @@ struct _GdkToplevelInterface
typedef enum {
GDK_TOPLEVEL_PROP_STATE,
+ GDK_TOPLEVEL_PROP_TITLE,
+ GDK_TOPLEVEL_PROP_STARTUP_ID,
+ GDK_TOPLEVEL_PROP_TRANSIENT_FOR,
+ GDK_TOPLEVEL_PROP_ICON_LIST,
GDK_TOPLEVEL_NUM_PROPERTIES
} GdkToplevelProperties;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]