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
This commit is contained in:
Matthias Clasen 2014-10-20 07:32:42 -04:00
parent 23f6ff3cec
commit cf0c9eb158
4 changed files with 100 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -915,6 +915,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:
*