[gnome-calendar] event-widget: use single click activation
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] event-widget: use single click activation
- Date: Thu, 4 Dec 2014 22:31:55 +0000 (UTC)
commit f37e2f641644a27a7a55790cfd1d714cd16f7c52
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Fri Sep 26 00:37:45 2014 -0400
event-widget: use single click activation
Use pointer cursor
src/gcal-event-widget.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index d90c5a5..e23db78 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -32,6 +32,7 @@ typedef struct
gboolean has_reminders;
GdkWindow *event_window;
+ gboolean button_pressed;
} GcalEventWidgetPrivate;
enum
@@ -91,6 +92,9 @@ static gboolean gcal_event_widget_draw (GtkWidget *widget,
static gboolean gcal_event_widget_button_press_event (GtkWidget *widget,
GdkEventButton *event);
+static gboolean gcal_event_widget_button_release_event (GtkWidget *widget,
+ GdkEventButton *event);
+
G_DEFINE_TYPE_WITH_PRIVATE (GcalEventWidget, gcal_event_widget, GTK_TYPE_WIDGET)
static void
@@ -114,6 +118,7 @@ gcal_event_widget_class_init(GcalEventWidgetClass *klass)
widget_class->size_allocate = gcal_event_widget_size_allocate;
widget_class->draw = gcal_event_widget_draw;
widget_class->button_press_event = gcal_event_widget_button_press_event;
+ widget_class->button_release_event = gcal_event_widget_button_release_event;
g_object_class_install_property (object_class,
PROP_UUID,
@@ -192,6 +197,11 @@ gcal_event_widget_class_init(GcalEventWidgetClass *klass)
static void
gcal_event_widget_init(GcalEventWidget *self)
{
+ GcalEventWidgetPrivate *priv;
+
+ priv = gcal_event_widget_get_instance_private (self);
+ priv->button_pressed = FALSE;
+
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
@@ -373,6 +383,8 @@ gcal_event_widget_realize (GtkWidget *widget)
gint attributes_mask;
GtkAllocation allocation;
+ GdkCursor* pointer_cursor;
+
priv = gcal_event_widget_get_instance_private (GCAL_EVENT_WIDGET (widget));
gtk_widget_set_realized (widget, TRUE);
@@ -403,6 +415,10 @@ gcal_event_widget_realize (GtkWidget *widget)
attributes_mask);
gdk_window_set_user_data (priv->event_window, widget);
gdk_window_show (priv->event_window);
+
+ pointer_cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
+ GDK_HAND1);
+ gdk_window_set_cursor (priv->event_window, pointer_cursor);
}
static void
@@ -568,12 +584,32 @@ static gboolean
gcal_event_widget_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
- if (event->type == GDK_2BUTTON_PRESS)
- g_signal_emit (widget, signals[ACTIVATE], 0);
+ GcalEventWidgetPrivate *priv;
+
+ priv = gcal_event_widget_get_instance_private (GCAL_EVENT_WIDGET (widget));
+ priv->button_pressed = TRUE;
return TRUE;
}
+static gboolean
+gcal_event_widget_button_release_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GcalEventWidgetPrivate *priv;
+
+ priv = gcal_event_widget_get_instance_private (GCAL_EVENT_WIDGET (widget));
+
+ if (priv->button_pressed)
+ {
+ priv->button_pressed = FALSE;
+ g_signal_emit (widget, signals[ACTIVATE], 0);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
GtkWidget*
gcal_event_widget_new (gchar *uuid)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]