summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-18 12:08:11 +0100
committerinfirit <[email protected]>2014-12-18 12:08:11 +0100
commit6a0ed19ae7f1cf12b3e44c3d245c34a4fc9edf5d (patch)
treea06614fd5d6df1a24949e1e31821fd1061486e24 /src
parent3663ca884eb8c578ba372640cb5399a5419d48ca (diff)
downloadmate-system-monitor-6a0ed19ae7f1cf12b3e44c3d245c34a4fc9edf5d.tar.bz2
mate-system-monitor-6a0ed19ae7f1cf12b3e44c3d245c34a4fc9edf5d.tar.xz
Only display change color dialog on clicked instead of button-release
Taken from GSM commit: e2440e154dfdcf57364249c19c599bcfa5c177f2 From: Robert Roth <[email protected]> Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=517712
Diffstat (limited to 'src')
-rw-r--r--src/gsm_color_button.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/gsm_color_button.c b/src/gsm_color_button.c
index b22407c..f484406 100644
--- a/src/gsm_color_button.c
+++ b/src/gsm_color_button.c
@@ -48,6 +48,8 @@ struct _GSMColorButtonPrivate
guint type;
cairo_surface_t *image_buffer;
gdouble highlight;
+ gboolean button_down;
+ gboolean in_button;
};
/* Properties */
@@ -94,9 +96,11 @@ static void gsm_color_button_unrealize (GtkWidget * widget);
static void gsm_color_button_state_changed (GtkWidget * widget,
GtkStateType previous_state);
static void gsm_color_button_style_set (GtkWidget * widget,
- GtkStyle * previous_style);
-static gint gsm_color_button_clicked (GtkWidget * widget,
+ GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+ GdkEventButton * event);
static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
GdkEventCrossing * event);
static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
@@ -186,7 +190,8 @@ gsm_color_button_class_init (GSMColorButtonClass * klass)
widget_class->realize = gsm_color_button_realize;
widget_class->unrealize = gsm_color_button_unrealize;
widget_class->style_set = gsm_color_button_style_set;
- widget_class->button_release_event = gsm_color_button_clicked;
+ widget_class->button_release_event = gsm_color_button_released;
+ widget_class->button_press_event = gsm_color_button_pressed;
widget_class->enter_notify_event = gsm_color_button_enter_notify;
widget_class->leave_notify_event = gsm_color_button_leave_notify;
@@ -496,13 +501,10 @@ static void
gsm_color_button_size_allocate (GtkWidget * widget,
GtkAllocation * allocation)
{
- GSMColorButton *color_button;
-
g_return_if_fail (widget != NULL || allocation != NULL);
g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
gtk_widget_set_allocation (widget, allocation);
- color_button = GSM_COLOR_BUTTON (widget);
if (gtk_widget_get_realized (widget))
{
@@ -634,6 +636,8 @@ gsm_color_button_init (GSMColorButton * color_button)
color_button->priv->type = GSMCP_TYPE_CPU;
color_button->priv->image_buffer = NULL;
color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */
+ color_button->priv->in_button = FALSE;
+ color_button->priv->button_down = FALSE;
gtk_drag_dest_set (GTK_WIDGET (color_button),
GTK_DEST_DEFAULT_MOTION |
@@ -778,11 +782,34 @@ gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
return 0;
}
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+ if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+ {
+ GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+ color_button->priv->button_down = TRUE;
+ }
+ return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+ GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+ if (color_button->priv->button_down && color_button->priv->in_button)
+ gsm_color_button_clicked (widget, event);
+ color_button->priv->button_down = FALSE;
+ return 0;
+}
+
+
static gboolean
gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
{
GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
color_button->priv->highlight = 1.0;
+ color_button->priv->in_button = TRUE;
gtk_widget_queue_draw(widget);
return FALSE;
}
@@ -792,6 +819,7 @@ gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
{
GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
color_button->priv->highlight = 0;
+ color_button->priv->in_button = FALSE;
gtk_widget_queue_draw(widget);
return FALSE;
}