[gtk+/wip/gbsneto/other-locations: 12/13] placesview: initial support for opening flags
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/gbsneto/other-locations: 12/13] placesview: initial support for opening flags
- Date: Wed, 24 Jun 2015 13:52:08 +0000 (UTC)
commit 5065166d29754568b6937a03a20daf36dce72206
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Jun 22 03:17:12 2015 -0300
placesview: initial support for opening flags
gtk/gtkplacesview.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++-
gtk/gtkplacesview.h | 6 ++++
2 files changed, 73 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index b7d2e9c..13fb91b 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -70,6 +70,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkPlacesView, gtk_places_view, GTK_TYPE_BOX)
enum {
PROP_0,
PROP_LOCAL_ONLY,
+ PROP_OPEN_FLAGS,
LAST_PROP
};
@@ -918,6 +919,14 @@ gtk_places_view_class_init (GtkPlacesViewClass *klass)
FALSE,
G_PARAM_READWRITE);
+ properties[PROP_OPEN_FLAGS] =
+ g_param_spec_flags ("open-flags",
+ P_("Open Flags"),
+ P_("Modes in which the calling application can open locations selected in the
sidebar"),
+ GTK_TYPE_PLACES_OPEN_FLAGS,
+ GTK_PLACES_OPEN_NORMAL,
+ G_PARAM_READWRITE);
+
g_object_class_install_properties (object_class, LAST_PROP, properties);
/* Bind class to template */
@@ -941,6 +950,7 @@ gtk_places_view_init (GtkPlacesView *self)
{
self->priv = gtk_places_view_get_instance_private (self);
self->priv->volume_monitor = g_volume_monitor_get ();
+ self->priv->open_flags = GTK_PLACES_OPEN_NORMAL;
gtk_widget_init_template (GTK_WIDGET (self));
}
@@ -951,8 +961,8 @@ gtk_places_view_init (GtkPlacesView *self)
* Creates a new #GtkPlacesView widget.
*
* The application should connect to at least the
- * #GtkPlacesSidebar::open-location signal to be notified
- * when the user makes a selection in the sidebar.
+ * #GtkPlacesView::open-location signal to be notified
+ * when the user makes a selection in the view.
*
* Returns: a newly created #GtkPlacesView
*
@@ -965,6 +975,61 @@ gtk_places_view_new (void)
}
/**
+ * gtk_places_view_set_open_flags:
+ * @view: a #GtkPlacesView
+ * @flags: Bitmask of modes in which the calling application can open locations
+ *
+ * Sets the way in which the calling application can open new locations from
+ * the places view. For example, some applications only open locations
+ * “directly” into their main view, while others may support opening locations
+ * in a new notebook tab or a new window.
+ *
+ * This function is used to tell the places @view about the ways in which the
+ * application can open new locations, so that the view can display (or not)
+ * the “Open in new tab” and “Open in new window” menu items as appropriate.
+ *
+ * When the #GtkPlacesView::open-location signal is emitted, its flags
+ * argument will be set to one of the @flags that was passed in
+ * gtk_places_view_set_open_flags().
+ *
+ * Passing 0 for @flags will cause #GTK_PLACES_OPEN_NORMAL to always be sent
+ * to callbacks for the “open-location” signal.
+ *
+ * Since: 3.18
+ */
+void
+gtk_places_view_set_open_flags (GtkPlacesView *view,
+ GtkPlacesOpenFlags flags)
+{
+ g_return_if_fail (GTK_IS_PLACES_VIEW (view));
+
+ if (view->priv->open_flags != flags)
+ {
+ view->priv->open_flags = flags;
+ g_object_notify_by_pspec (G_OBJECT (view), properties[PROP_OPEN_FLAGS]);
+ }
+}
+
+/**
+ * gtk_places_view_get_open_flags:
+ * @view: a #GtkPlacesSidebar
+ *
+ * Gets the open flags.
+ *
+ * Returns: the #GtkPlacesOpenFlags of @view
+ *
+ * Since: 3.18
+ */
+GtkPlacesOpenFlags
+gtk_places_view_get_open_flags (GtkPlacesView *view)
+{
+ g_return_val_if_fail (GTK_IS_PLACES_SIDEBAR (view), 0);
+
+ return view->priv->open_flags;
+}
+
+
+/**
* gtk_places_view_get_local_only:
* @view: a #GtkPlacesView
*
diff --git a/gtk/gtkplacesview.h b/gtk/gtkplacesview.h
index 7670338..2db6b2d 100644
--- a/gtk/gtkplacesview.h
+++ b/gtk/gtkplacesview.h
@@ -70,6 +70,12 @@ GDK_AVAILABLE_IN_3_18
GType gtk_places_view_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_18
+GtkPlacesOpenFlags gtk_places_view_get_open_flags (GtkPlacesView *view);
+GDK_AVAILABLE_IN_3_18
+void gtk_places_view_set_open_flags (GtkPlacesView *view,
+ GtkPlacesOpenFlags flags);
+
+GDK_AVAILABLE_IN_3_18
gboolean gtk_places_view_get_local_only (GtkPlacesView *view);
GDK_AVAILABLE_IN_3_18
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]