Add a way to avoid menu on color swatches

This commit is contained in:
Matthias Clasen 2015-06-13 21:56:41 -04:00
parent 1bba3b0a38
commit 98a3fac6ab

View File

@ -41,6 +41,7 @@ struct _GtkColorSwatchPrivate
guint has_color : 1;
guint use_alpha : 1;
guint selectable : 1;
guint has_menu : 1;
GdkWindow *event_window;
@ -52,7 +53,8 @@ enum
{
PROP_ZERO,
PROP_RGBA,
PROP_SELECTABLE
PROP_SELECTABLE,
PROP_HAS_MENU
};
enum
@ -82,6 +84,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);
@ -517,7 +520,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 ());
}
}
@ -641,6 +644,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;
@ -663,6 +669,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;
@ -728,10 +737,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 *