[gtk+/gtk-3-14] Add a way to avoid menu on color swatches
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] Add a way to avoid menu on color swatches
- Date: Tue, 7 Jul 2015 17:45:44 +0000 (UTC)
commit 01fec30f5afaaa1966f94ab54c1e1c3e3d38b898
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 13 21:56:41 2015 -0400
Add a way to avoid menu on color swatches
gtk/gtkcolorswatch.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index 05b6c81..b67f80c 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -43,6 +43,7 @@ struct _GtkColorSwatchPrivate
guint contains_pointer : 1;
guint use_alpha : 1;
guint selectable : 1;
+ guint has_menu : 1;
GdkWindow *event_window;
@@ -54,7 +55,8 @@ enum
{
PROP_ZERO,
PROP_RGBA,
- PROP_SELECTABLE
+ PROP_SELECTABLE,
+ PROP_HAS_MENU
};
enum
@@ -84,6 +86,7 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
swatch->priv = gtk_color_swatch_get_instance_private (swatch);
swatch->priv->use_alpha = TRUE;
swatch->priv->selectable = TRUE;
+ swatch->priv->has_menu = TRUE;
gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE);
gtk_widget_set_has_window (GTK_WIDGET (swatch), FALSE);
@@ -387,7 +390,7 @@ swatch_key_press (GtkWidget *widget,
event->keyval == GDK_KEY_KP_Enter ||
event->keyval == GDK_KEY_KP_Space)
{
- if (swatch->priv->has_color &&
+ if (swatch->priv->has_color &&
swatch->priv->selectable &&
(gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) == 0)
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
@@ -551,7 +554,7 @@ tap_action (GtkGestureMultiPress *gesture,
}
else if (button == GDK_BUTTON_SECONDARY)
{
- if (swatch->priv->has_color)
+ if (swatch->priv->has_color && swatch->priv->has_menu)
do_popup (GTK_WIDGET (swatch), button, gtk_get_current_event_time ());
}
}
@@ -609,7 +612,7 @@ swatch_realize (GtkWidget *widget)
gtk_widget_set_window (widget, window);
g_object_ref (window);
- swatch->priv->event_window =
+ swatch->priv->event_window =
gdk_window_new (window,
&attributes, attributes_mask);
gtk_widget_register_window (widget, swatch->priv->event_window);
@@ -675,6 +678,9 @@ swatch_get_property (GObject *object,
case PROP_SELECTABLE:
g_value_set_boolean (value, gtk_color_swatch_get_selectable (swatch));
break;
+ case PROP_HAS_MENU:
+ g_value_set_boolean (value, swatch->priv->has_menu);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -697,6 +703,9 @@ swatch_set_property (GObject *object,
case PROP_SELECTABLE:
gtk_color_swatch_set_selectable (swatch, g_value_get_boolean (value));
break;
+ case PROP_HAS_MENU:
+ swatch->priv->has_menu = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -762,10 +771,14 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
g_object_class_install_property (object_class, PROP_SELECTABLE,
g_param_spec_boolean ("selectable", P_("Selectable"), P_("Whether the swatch is selectable"),
TRUE, GTK_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_HAS_MENU,
+ g_param_spec_boolean ("has-menu", P_("Has Menu"), P_("Whether the swatch should offer customization"),
+ TRUE, GTK_PARAM_READWRITE));
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COLOR_SWATCH_ACCESSIBLE);
}
+
/* Public API {{{1 */
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]