summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-10-20 07:32:42 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-10-20 08:50:53 -0400
commitcf0c9eb15893b354e40e1e5f9cf31fb926e98b9b (patch)
treea6de0b2c2fd27de915a43a645809d19d64875078
parent23f6ff3cec19473146c2682bd0b358b2f340c7ff (diff)
downloadgtk+-cf0c9eb15893b354e40e1e5f9cf31fb926e98b9b.tar.gz
GtkPaned: Add a "wide-handle" property
This can be used by applications to indicate that a paned is expected to be actively used by the users for configuring the UI, and needs a prominent handle. https://bugzilla.gnome.org/show_bug.cgi?id=738860
-rw-r--r--docs/reference/gtk/gtk3-sections.txt3
-rw-r--r--gtk/gtkpaned.c82
-rw-r--r--gtk/gtkpaned.h6
-rw-r--r--gtk/gtkstylecontext.h10
4 files changed, 100 insertions, 1 deletions
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index db1b098544..5850e75563 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -2593,6 +2593,8 @@ gtk_paned_get_child2
gtk_paned_set_position
gtk_paned_get_position
gtk_paned_get_handle_window
+gtk_paned_set_wide_handle
+gtk_paned_get_wide_handle
<SUBSECTION Standard>
GTK_PANED
GTK_IS_PANED
@@ -6053,6 +6055,7 @@ GTK_STYLE_CLASS_TROUGH
GTK_STYLE_CLASS_VERTICAL
GTK_STYLE_CLASS_VIEW
GTK_STYLE_CLASS_WARNING
+GTK_STYLE_CLASS_WIDE
GTK_STYLE_REGION_COLUMN
GTK_STYLE_REGION_COLUMN_HEADER
GTK_STYLE_REGION_ROW
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 2855a29010..0790c0b666 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -138,7 +138,8 @@ enum {
PROP_POSITION,
PROP_POSITION_SET,
PROP_MIN_POSITION,
- PROP_MAX_POSITION
+ PROP_MAX_POSITION,
+ PROP_WIDE_HANDLE
};
enum {
@@ -380,6 +381,23 @@ gtk_paned_class_init (GtkPanedClass *class)
0, G_MAXINT, G_MAXINT,
GTK_PARAM_READABLE|G_PARAM_EXPLICIT_NOTIFY));
+ /**
+ * GtkPaned:wide-handle:
+ *
+ * Setting this property to %TRUE indicates that the paned needs
+ * to provide stronger visual separation (e.g. because it separates
+ * between two notebooks, whose tab rows would otherwise merge visually).
+ *
+ * Since: 3.16
+ */
+ g_object_class_install_property (object_class,
+ PROP_WIDE_HANDLE,
+ g_param_spec_boolean ("wide-handle",
+ P_("Wide Handle"),
+ P_("Whether the paned should have a prominent handle"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("handle-size",
P_("Handle Size"),
@@ -852,6 +870,9 @@ gtk_paned_set_property (GObject *object,
g_object_notify_by_pspec (object, pspec);
}
break;
+ case PROP_WIDE_HANDLE:
+ gtk_paned_set_wide_handle (paned, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -884,6 +905,9 @@ gtk_paned_get_property (GObject *object,
case PROP_MAX_POSITION:
g_value_set_int (value, priv->max_position);
break;
+ case PROP_WIDE_HANDLE:
+ g_value_set_boolean (value, gtk_paned_get_wide_handle (paned));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -2842,3 +2866,59 @@ gtk_paned_get_handle_window (GtkPaned *paned)
return paned->priv->handle;
}
+
+/**
+ * gtk_paned_set_wide_handle:
+ * @paned: a #GtkPaned
+ * @wide: the new value for the #GtkPaned:wide-handle property
+ *
+ * Sets the #GtkPaned:wide-handle property.
+ *
+ * Since: 3.16
+ */
+void
+gtk_paned_set_wide_handle (GtkPaned *paned,
+ gboolean wide)
+{
+ GtkStyleContext *context;
+ gboolean old_wide;
+
+ g_return_if_fail (GTK_IS_PANED (paned));
+
+ old_wide = gtk_paned_get_wide_handle (paned);
+ if (old_wide != wide)
+ {
+ context = gtk_widget_get_style_context (GTK_WIDGET (paned));
+ if (wide)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_WIDE);
+ else
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_WIDE);
+
+ gtk_widget_queue_resize (GTK_WIDGET (paned));
+ g_object_notify (G_OBJECT (paned), "wide-handle");
+ }
+}
+
+/**
+ * gtk_paned_get_wide_handle:
+ * @paned: a #GtkPaned
+ *
+ * Gets the #GtkPaned:wide-handle property.
+ *
+ * Returns: %TRUE if the paned should have a wide handle
+ *
+ * Since: 3.16
+ */
+gboolean
+gtk_paned_get_wide_handle (GtkPaned *paned)
+{
+ GtkStyleContext *context;
+
+ g_return_val_if_fail (GTK_IS_PANED (paned), FALSE);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (paned));
+ if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_WIDE))
+ return TRUE;
+ else
+ return FALSE;
+}
diff --git a/gtk/gtkpaned.h b/gtk/gtkpaned.h
index e2194880e3..fba38197ca 100644
--- a/gtk/gtkpaned.h
+++ b/gtk/gtkpaned.h
@@ -110,6 +110,12 @@ GtkWidget * gtk_paned_get_child2 (GtkPaned *paned);
GDK_AVAILABLE_IN_ALL
GdkWindow * gtk_paned_get_handle_window (GtkPaned *paned);
+GDK_AVAILABLE_IN_3_16
+void gtk_paned_set_wide_handle (GtkPaned *paned,
+ gboolean wide);
+GDK_AVAILABLE_IN_3_16
+gboolean gtk_paned_get_wide_handle (GtkPaned *paned);
+
G_END_DECLS
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 3af4d10947..8052a04dad 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -916,6 +916,16 @@ struct _GtkStyleContextClass
#define GTK_STYLE_CLASS_MONOSPACE "monospace"
/**
+ * GTK_STYLE_CLASS_WIDE:
+ *
+ * A CSS class to indicate that a UI element should be 'wide'.
+ * Used by #GtkPaned.
+ *
+ * Since: 3.16
+ */
+#define GTK_STYLE_CLASS_WIDE "wide"
+
+/**
* GTK_STYLE_REGION_ROW:
*
* A widget region name to define a treeview row.