[california/wip/734698-agenda] Mouse hover and click events
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/734698-agenda] Mouse hover and click events
- Date: Wed, 3 Dec 2014 04:51:37 +0000 (UTC)
commit ec82b322484dfafc287b9c446bd4ab83aaaf902b
Author: Jim Nelson <jim yorba org>
Date: Tue Dec 2 20:51:24 2014 -0800
Mouse hover and click events
src/rc/view-agenda-date-row.ui | 2 +-
src/rc/view-agenda-event-row.ui | 35 +++++++++++++++------
src/view/agenda/agenda-controller.vala | 2 +-
src/view/agenda/agenda-date-row.vala | 6 ++-
src/view/agenda/agenda-event-row.vala | 51 +++++++++++++++++++++++++++++--
5 files changed, 78 insertions(+), 18 deletions(-)
---
diff --git a/src/rc/view-agenda-date-row.ui b/src/rc/view-agenda-date-row.ui
index 6dcfa8c..88fee77 100644
--- a/src/rc/view-agenda-date-row.ui
+++ b/src/rc/view-agenda-date-row.ui
@@ -9,7 +9,7 @@
<object class="GtkLabel" id="date_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_right">6</property>
+ <property name="margin_right">8</property>
<property name="margin_top">3</property>
<property name="xalign">1</property>
<property name="yalign">0</property>
diff --git a/src/rc/view-agenda-event-row.ui b/src/rc/view-agenda-event-row.ui
index efd29a8..a80fc07 100644
--- a/src/rc/view-agenda-event-row.ui
+++ b/src/rc/view-agenda-event-row.ui
@@ -6,14 +6,21 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="time_label">
+ <object class="GtkEventBox" id="time_eventbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_right">12</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label">(time)</property>
- <property name="use_markup">True</property>
+ <property name="visible_window">False</property>
+ <child>
+ <object class="GtkLabel" id="time_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_right">8</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label">(time)</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -22,12 +29,20 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="summary_label">
+ <object class="GtkEventBox" id="summary_eventbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label">(summary)</property>
+ <property name="visible_window">False</property>
+ <child>
+ <object class="GtkLabel" id="summary_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label">(summary)</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">True</property>
diff --git a/src/view/agenda/agenda-controller.vala b/src/view/agenda/agenda-controller.vala
index 2e80b48..94166c0 100644
--- a/src/view/agenda/agenda-controller.vala
+++ b/src/view/agenda/agenda-controller.vala
@@ -119,7 +119,7 @@ public class Controller : BaseObject, View.Controllable {
}
private Gtk.Widget model_presentation(Calendar.Date date) {
- return new DateRow(date);
+ return new DateRow(this, date);
}
private void update_subscriptions() {
diff --git a/src/view/agenda/agenda-date-row.vala b/src/view/agenda/agenda-date-row.vala
index 2b3acdb..7d8ad5a 100644
--- a/src/view/agenda/agenda-date-row.vala
+++ b/src/view/agenda/agenda-date-row.vala
@@ -21,9 +21,11 @@ private class DateRow : Gtk.Box {
[GtkChild]
private Gtk.ListBox event_listbox;
+ private unowned Controller owner;
private Toolkit.ListBoxModel<Component.Event> listbox_model;
- public DateRow(Calendar.Date date) {
+ public DateRow(Controller owner, Calendar.Date date) {
+ this.owner = owner;
this.date = date;
listbox_model = new Toolkit.ListBoxModel<Component.Event>(event_listbox, model_presentation);
@@ -52,7 +54,7 @@ private class DateRow : Gtk.Box {
}
private Gtk.Widget model_presentation(Component.Event event) {
- return new EventRow(event);
+ return new EventRow(owner, event);
}
}
diff --git a/src/view/agenda/agenda-event-row.vala b/src/view/agenda/agenda-event-row.vala
index df43465..2dc33ca 100644
--- a/src/view/agenda/agenda-event-row.vala
+++ b/src/view/agenda/agenda-event-row.vala
@@ -10,22 +10,46 @@ namespace California.View.Agenda {
private class EventRow : Gtk.Box {
private const Calendar.WallTime.PrettyFlag TIME_PRETTY_FLAGS = Calendar.WallTime.PrettyFlag.NONE;
+ private const string COLOR_PRINTF = "<span color=\"%s\">%s</span>";
+
private static Gtk.SizeGroup time_label_size_group;
public new Component.Event event { get; private set; }
[GtkChild]
+ private Gtk.EventBox time_eventbox;
+
+ [GtkChild]
private Gtk.Label time_label;
[GtkChild]
+ private Gtk.EventBox summary_eventbox;
+
+ [GtkChild]
private Gtk.Label summary_label;
- public EventRow(Component.Event event) {
+ private Controller owner;
+ private Toolkit.ButtonConnector button_connector = new Toolkit.ButtonConnector();
+ private Toolkit.MotionConnector motion_connector = new Toolkit.MotionConnector();
+
+ public EventRow(Controller owner, Component.Event event) {
+ this.owner = owner;
this.event = event;
// all time labels are the same width
time_label_size_group.add_widget(time_label);
+ // capture motion and mouse clicks for both labels
+ button_connector.connect_to(time_eventbox);
+ button_connector.connect_to(summary_eventbox);
+ motion_connector.connect_to(time_eventbox);
+ motion_connector.connect_to(summary_eventbox);
+
+ button_connector.clicked.connect(on_event_clicked);
+ motion_connector.entered.connect(on_event_entered_exited);
+ motion_connector.exited.connect(on_event_entered_exited);
+ motion_connector.motion.connect(on_event_motion);
+
update_ui();
}
@@ -38,17 +62,36 @@ private class EventRow : Gtk.Box {
}
private void update_ui() {
- summary_label.label = event.summary;
+ summary_label.label = COLOR_PRINTF.printf(event.calendar_source.color, event.summary);
+ string label;
if (event.is_all_day) {
- time_label.label = _("All day");
+ label = _("All day");
} else {
// hex value is an endash
- time_label.label = "%s – %s".printf(
+ label = "%s – %s".printf(
event.exact_time_span.start_exact_time.to_wall_time().to_pretty_string(TIME_PRETTY_FLAGS),
event.exact_time_span.end_exact_time.to_wall_time().to_pretty_string(TIME_PRETTY_FLAGS)
);
}
+
+ time_label.label = COLOR_PRINTF.printf(event.calendar_source.color, label);
+ }
+
+ private bool on_event_clicked(Toolkit.ButtonEvent details) {
+ owner.request_display_event(event, details.widget, details.press_point);
+
+ return Toolkit.PROPAGATE;
+ }
+
+ private void on_event_entered_exited(Toolkit.MotionEvent details) {
+ // when entering or leaving cell, reset the cursor
+ Toolkit.set_toplevel_cursor(details.widget, null);
+ }
+
+ private void on_event_motion(Toolkit.MotionEvent details) {
+ // if hovering over an event, show the "hyperlink" cursor
+ Toolkit.set_toplevel_cursor(details.widget, Gdk.CursorType.HAND1);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]