[california/wip/732029-gtk-312] Don't have *any* popovers attached to headerbar buttons
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/732029-gtk-312] Don't have *any* popovers attached to headerbar buttons
- Date: Fri, 15 Aug 2014 22:27:37 +0000 (UTC)
commit 2a11199416d819c18f23feb98aff47d8fb591c4e
Author: Jim Nelson <jim yorba org>
Date: Fri Aug 15 15:26:05 2014 -0700
Don't have *any* popovers attached to headerbar buttons
Due to Unity theming problem, fonts are blurred when popover is
attached to headerbar. Rather than fight it, change functionality
of the last remaining headerbar popover (Quick Add button) to jump
to today's date and add for that day. This can be reverted when the
Unity bug is fixed.
src/host/host-main-window.vala | 11 +++++++-
src/view/month/month-controller.vala | 16 ++++++++++++
src/view/view-controllable.vala | 45 ++++++++++++++++++++++++++++++++++
src/view/view.vala | 4 +++
src/view/week/week-controller.vala | 15 +++++++++++
5 files changed, 90 insertions(+), 1 deletions(-)
---
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 8f2ed22..d8643b5 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -358,7 +358,16 @@ public class MainWindow : Gtk.ApplicationWindow {
}
private void on_quick_create_event() {
- quick_create_event(null, quick_add_button, null);
+ // switch to Today and execute Quick Add when transition is complete
+ current_controller.today();
+ current_controller.execute_when_not_transitioning(do_quick_create_event);
+ }
+
+ private void do_quick_create_event(View.Controllable controller) {
+ Gtk.Widget? today_widget = controller.get_widget_for_date(Calendar.System.today);
+ assert(today_widget != null);
+
+ on_request_create_all_day_event(Calendar.System.today.to_date_span(), today_widget, null);
}
private void on_jump_to_today() {
diff --git a/src/view/month/month-controller.vala b/src/view/month/month-controller.vala
index 78a47cf..12463e9 100644
--- a/src/view/month/month-controller.vala
+++ b/src/view/month/month-controller.vala
@@ -66,6 +66,11 @@ public class Controller : BaseObject, View.Controllable {
public Calendar.Date default_date { get; protected set; }
/**
+ * @inheritDoc
+ */
+ public bool in_transition { get; protected set; }
+
+ /**
* { link View.Palette} for the entire view.
*/
public View.Palette palette { get; private set; }
@@ -92,6 +97,8 @@ public class Controller : BaseObject, View.Controllable {
Toolkit.StackModel.OrderedTransitionType.SLIDE_LEFT_RIGHT, model_presentation,
trim_presentation_from_cache, ensure_presentation_in_cache);
+ stack.bind_property("transition-running", this, PROP_IN_TRANSITION, BindingFlags.SYNC_CREATE);
+
// insert labels for days of the week across top of master grid
for (int col = 0; col < Grid.COLS; col++) {
Gtk.Label dow_label = new Gtk.Label(null);
@@ -189,6 +196,15 @@ public class Controller : BaseObject, View.Controllable {
/**
* @inheritDoc
*/
+ public Gtk.Widget? get_widget_for_date(Calendar.Date date) {
+ Grid? current_grid = get_current_month_grid();
+
+ return current_grid != null ? current_grid.get_cell_for_date(date) : null;
+ }
+
+ /**
+ * @inheritDoc
+ */
public View.Container get_container() {
return master_grid;
}
diff --git a/src/view/view-controllable.vala b/src/view/view-controllable.vala
index 0251c9c..299df7d 100644
--- a/src/view/view-controllable.vala
+++ b/src/view/view-controllable.vala
@@ -18,6 +18,12 @@ public interface Controllable : Object {
public const string PROP_CURRENT_LABEL = "current-label";
public const string PROP_IS_VIEWING_TODAY = "is-viewing-today";
public const string PROP_DEFAULT_DATE = "default-date";
+ public const string PROP_IN_TRANSITION = "in-transition";
+
+ /**
+ * For { link execute_when_not_in_transition}.
+ */
+ public delegate void Callback(View.Controllable controller);
/**
* A short string uniquely identifying this view.
@@ -46,6 +52,11 @@ public interface Controllable : Object {
public abstract bool is_viewing_today { get; protected set; }
/**
+ * Indicates when a transition is running (such as when moving between dates).
+ */
+ public abstract bool in_transition { get; protected set; }
+
+ /**
* Signal from the { link Controllable} that a DATE-TIME { link Component.Event} should be
* created with the specified initial parameters.
*/
@@ -96,6 +107,40 @@ public interface Controllable : Object {
* when creating or displaying events).
*/
public abstract void unselect_all();
+
+ /**
+ * Return the GtkWidget that represents the specified { link Calendar.Date}, if available.
+ */
+ public abstract Gtk.Widget? get_widget_for_date(Calendar.Date date);
+
+ /**
+ * Execute a { link Callback} only when the { link Controllable} is not performing a transition.
+ *
+ * If the Controllable is not in transition when called, the Callback is executed immediately.
+ * Otherwise, execution is delayed until the transition completes.
+ */
+ public void execute_when_not_transitioning(Callback callback) {
+ if (!in_transition) {
+ callback(this);
+
+ return;
+ }
+
+ ulong handler_id = 0;
+ handler_id = notify[PROP_IN_TRANSITION].connect(() => {
+ // watch for spurious notifications
+ if (in_transition)
+ return;
+
+ // disable this signal
+ if (handler_id > 0)
+ disconnect(handler_id);
+ else
+ debug("Unable to disconnect in-transition notify signal handler");
+
+ callback(this);
+ });
+ }
}
}
diff --git a/src/view/view.vala b/src/view/view.vala
index 57e3e19..584bfaa 100644
--- a/src/view/view.vala
+++ b/src/view/view.vala
@@ -18,6 +18,8 @@ public void init() throws Error {
if (!Unit.do_init(ref init_count))
return;
+ Calendar.init();
+
// subunit initialization
View.Common.init();
View.Month.init();
@@ -31,6 +33,8 @@ public void terminate() {
View.Week.terminate();
View.Month.terminate();
View.Common.terminate();
+
+ Calendar.terminate();
}
}
diff --git a/src/view/week/week-controller.vala b/src/view/week/week-controller.vala
index d3496d6..adbb00d 100644
--- a/src/view/week/week-controller.vala
+++ b/src/view/week/week-controller.vala
@@ -52,6 +52,11 @@ public class Controller : BaseObject, View.Controllable {
public bool is_viewing_today { get; protected set; }
/**
+ * @inheritDoc
+ */
+ public bool in_transition { get; protected set; }
+
+ /**
* { link View.Palette} for the entire hosted view.
*/
public View.Palette palette { get; private set; }
@@ -66,6 +71,7 @@ public class Controller : BaseObject, View.Controllable {
stack = new ViewContainer(this);
stack.homogeneous = true;
stack.transition_duration = Toolkit.SLOW_STACK_TRANSITION_DURATION_MSEC;
+ stack.bind_property("transition-running", this, PROP_IN_TRANSITION, BindingFlags.SYNC_CREATE);
stack_model = new Toolkit.StackModel<Calendar.Week>(stack,
Toolkit.StackModel.OrderedTransitionType.SLIDE_LEFT_RIGHT, model_presentation,
@@ -122,6 +128,15 @@ public class Controller : BaseObject, View.Controllable {
current.unselect_all();
}
+ /**
+ * @inheritDoc
+ */
+ public Gtk.Widget? get_widget_for_date(Calendar.Date date) {
+ Grid? current_grid = get_current_grid();
+
+ return current_grid != null ? current_grid.get_all_day_cell_for_date(date) : null;
+ }
+
private Grid? get_current_grid() {
return stack.get_visible_child() as Grid;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]