[gnome-todo] task-row: show pointer cursor when hovering the row
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] task-row: show pointer cursor when hovering the row
- Date: Fri, 22 Sep 2017 01:55:01 +0000 (UTC)
commit 43095ba0f05755c6f44742594257bb94d79b660d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Sep 21 22:53:34 2017 -0300
task-row: show pointer cursor when hovering the row
So we give the proper visual feedback to the user that the
row is actually clickable.
data/ui/task-row.ui | 139 +++++++++++++++++++++++++++------------------------
src/gtd-task-row.c | 76 ++++++++++++++--------------
2 files changed, 112 insertions(+), 103 deletions(-)
---
diff --git a/data/ui/task-row.ui b/data/ui/task-row.ui
index 76b10ef..256c2f5 100644
--- a/data/ui/task-row.ui
+++ b/data/ui/task-row.ui
@@ -28,86 +28,93 @@
<!-- Main page, visible when the task row is unfocused -->
<child>
- <object class="GtkBox">
+ <object class="GtkEventBox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
-
- <!-- Box with DnD margin -->
+ <signal name="enter-notify-event" handler="mouse_over_event_cb" object="GtdTaskRow"
swapped="no" />
+ <signal name="leave-notify-event" handler="mouse_out_event_cb" object="GtdTaskRow"
swapped="no" />
<child>
- <object class="GtkBox" id="dnd_box">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- </object>
- </child>
+ <property name="spacing">6</property>
- <child>
- <object class="GtkEventBox" id="dnd_event_box">
- <property name="visible">True</property>
- <signal name="button-press-event" handler="button_press_event" object="GtdTaskRow"
swapped="no" />
- <signal name="drag-begin" handler="drag_begin_cb" object="GtdTaskRow" swapped="no" />
- <signal name="drag-failed" handler="drag_failed_cb" object="GtdTaskRow" swapped="no" />
- <signal name="enter-notify-event" handler="mouse_over_event" object="GtdTaskRow"
swapped="no" />
- <signal name="leave-notify-event" handler="mouse_out_event" object="GtdTaskRow"
swapped="no" />
+ <!-- Box with DnD margin -->
<child>
- <object class="GtkImage" id="dnd_icon">
+ <object class="GtkBox" id="dnd_box">
<property name="visible">True</property>
- <property name="icon-name">open-menu-symbolic</property>
- <property name="pixel-size">12</property>
- <style>
- <class name="dim-label" />
- </style>
+ <property name="can_focus">False</property>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkCheckButton" id="done_check">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="vexpand">True</property>
- <property name="draw_indicator">True</property>
- <property name="margin-start">6</property>
- <signal name="toggled" handler="complete_check_toggled_cb" object="GtdTaskRow"
swapped="no" />
- </object>
- </child>
+ <child>
+ <object class="GtkEventBox" id="dnd_event_box">
+ <property name="visible">True</property>
+ <signal name="button-press-event" handler="button_press_event" object="GtdTaskRow"
swapped="no" />
+ <signal name="drag-begin" handler="drag_begin_cb" object="GtdTaskRow" swapped="no" />
+ <signal name="drag-failed" handler="drag_failed_cb" object="GtdTaskRow" swapped="no"
/>
+ <signal name="enter-notify-event" handler="mouse_over_dnd_event_cb"
object="GtdTaskRow" swapped="no" />
+ <signal name="leave-notify-event" handler="mouse_out_dnd_event_cb"
object="GtdTaskRow" swapped="no" />
+ <child>
+ <object class="GtkImage" id="dnd_icon">
+ <property name="visible">True</property>
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="pixel-size">12</property>
+ <style>
+ <class name="dim-label" />
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
- <child>
- <object class="GtkLabel" id="title_label">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="xalign">0.0</property>
- </object>
- </child>
+ <child>
+ <object class="GtkCheckButton" id="done_check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="margin-start">6</property>
+ <signal name="toggled" handler="complete_check_toggled_cb" object="GtdTaskRow"
swapped="no" />
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="task_date_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="task_list_label">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="max_width_chars">18</property>
+ <property name="ellipsize">middle</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
- <child>
- <object class="GtkLabel" id="task_date_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="task_list_label">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="max_width_chars">18</property>
- <property name="ellipsize">middle</property>
- <style>
- <class name="dim-label"/>
- </style>
</object>
</child>
-
</object>
<packing>
<property name="name">unfocused</property>
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index a99fd20..d7dca22 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -80,13 +80,6 @@ enum
LAST_PROP
};
-typedef enum
-{
- CURSOR_NONE,
- CURSOR_GRAB,
- CURSOR_GRABBING
-} CursorType;
-
static guint signals[NUM_SIGNALS] = { 0, };
@@ -95,8 +88,8 @@ static guint signals[NUM_SIGNALS] = { 0, };
*/
static void
-set_dnd_cursor (GtkWidget *widget,
- CursorType type)
+set_cursor (GtkWidget *widget,
+ const gchar *cursor_name)
{
GdkDisplay *display;
GdkCursor *cursor;
@@ -104,25 +97,11 @@ set_dnd_cursor (GtkWidget *widget,
if (!gtk_widget_get_realized (widget))
return;
+ cursor = NULL;
display = gtk_widget_get_display (widget);
- switch (type)
- {
- case CURSOR_NONE:
- cursor = NULL;
- break;
-
- case CURSOR_GRAB:
- cursor = gdk_cursor_new_from_name (display, "grab");
- break;
-
- case CURSOR_GRABBING:
- cursor = gdk_cursor_new_from_name (display, "grabbing");
- break;
-
- default:
- cursor = NULL;
- }
+ if (cursor_name)
+ cursor = gdk_cursor_new_from_name (display, cursor_name);
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_display_flush (display);
@@ -185,21 +164,42 @@ remove_task_cb (GtdEditPane *edit_panel,
}
static gboolean
-mouse_out_event (GtkWidget *widget,
- GdkEvent *event,
- GtdTaskRow *self)
+mouse_out_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ GtdTaskRow *self)
+{
+ set_cursor (widget, NULL);
+
+ return GDK_EVENT_STOP;
+}
+
+static gboolean
+mouse_over_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ GtdTaskRow *self)
+{
+ set_cursor (widget, "pointer");
+
+ return GDK_EVENT_STOP;
+}
+
+
+static gboolean
+mouse_out_dnd_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ GtdTaskRow *self)
{
- set_dnd_cursor (widget, CURSOR_NONE);
+ set_cursor (widget, NULL);
return GDK_EVENT_STOP;
}
static gboolean
-mouse_over_event (GtkWidget *widget,
- GdkEvent *event,
- GtdTaskRow *self)
+mouse_over_dnd_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ GtdTaskRow *self)
{
- set_dnd_cursor (widget, CURSOR_GRAB);
+ set_cursor (widget, "grab");
return GDK_EVENT_STOP;
}
@@ -224,7 +224,7 @@ drag_begin_cb (GtkWidget *widget,
surface = get_dnd_icon (self);
- set_dnd_cursor (widget, CURSOR_GRABBING);
+ set_cursor (widget, "grabbing");
gtk_drag_set_icon_surface (context, surface);
@@ -631,8 +631,10 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, drag_begin_cb);
gtk_widget_class_bind_template_callback (widget_class, drag_failed_cb);
gtk_widget_class_bind_template_callback (widget_class, edit_finished_cb);
- gtk_widget_class_bind_template_callback (widget_class, mouse_out_event);
- gtk_widget_class_bind_template_callback (widget_class, mouse_over_event);
+ gtk_widget_class_bind_template_callback (widget_class, mouse_out_event_cb);
+ gtk_widget_class_bind_template_callback (widget_class, mouse_out_dnd_event_cb);
+ gtk_widget_class_bind_template_callback (widget_class, mouse_over_event_cb);
+ gtk_widget_class_bind_template_callback (widget_class, mouse_over_dnd_event_cb);
gtk_widget_class_bind_template_callback (widget_class, remove_task_cb);
gtk_widget_class_set_css_name (widget_class, "taskrow");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]