[california/wip/725767-week] Add accelerators, switch order of views when app loads
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725767-week] Add accelerators, switch order of views when app loads
- Date: Tue, 20 May 2014 00:40:51 +0000 (UTC)
commit aee42a59e5c4ac4b3f17dc75de9bd021c2d77036
Author: Jim Nelson <jim yorba org>
Date: Mon May 19 17:40:24 2014 -0700
Add accelerators, switch order of views when app loads
src/host/host-main-window.vala | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index f629565..5c42d69 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -25,11 +25,19 @@ public class MainWindow : Gtk.ApplicationWindow {
private const string ACTION_PREVIOUS = "win.previous";
private const string ACCEL_PREVIOUS = "<Alt>Left";
+ private const string ACTION_MONTH = "win.view-month";
+ private const string ACCEL_MONTH = "<Ctrl>M";
+
+ private const string ACTION_WEEK = "win.view-week";
+ private const string ACCEL_WEEK = "<Ctrl>W";
+
private static const ActionEntry[] action_entries = {
{ "quick-create-event", on_quick_create_event },
{ "jump-to-today", on_jump_to_today },
{ "next", on_next },
- { "previous", on_previous }
+ { "previous", on_previous },
+ { "view-month", on_view_month },
+ { "view-week", on_view_week }
};
// Set as a property so it can be bound to the current View.Controllable
@@ -59,6 +67,8 @@ public class MainWindow : Gtk.ApplicationWindow {
Application.instance.add_accelerator(ACCEL_JUMP_TO_TODAY, ACTION_JUMP_TO_TODAY, null);
Application.instance.add_accelerator(rtl ? ACCEL_PREVIOUS : ACCEL_NEXT, ACTION_NEXT, null);
Application.instance.add_accelerator(rtl ? ACCEL_NEXT : ACCEL_PREVIOUS, ACTION_PREVIOUS, null);
+ Application.instance.add_accelerator(ACCEL_MONTH, ACTION_MONTH, null);
+ Application.instance.add_accelerator(ACCEL_WEEK, ACTION_WEEK, null);
// view stack settings
view_stack.homogeneous = true;
@@ -69,9 +79,8 @@ public class MainWindow : Gtk.ApplicationWindow {
view_stack.notify["visible-child"].connect(on_view_changed);
// add views to view stack, first added is first shown
- // TODO: Switch back to month_view first
- add_controller(week_view);
add_controller(month_view);
+ add_controller(week_view);
// if not on Unity, use headerbar as the titlebar (removes window chrome) and provide close
// button for users who might have trouble finding it otherwise
@@ -102,6 +111,10 @@ public class MainWindow : Gtk.ApplicationWindow {
nav_buttons.pack_start(prev);
nav_buttons.pack_end(next);
+ // TODO:
+ // Remove Gtk.StackSwitcher for a few reasons: (a) the buttons are kinda wide and
+ // would like to conserve header bar space; (b) want to add tooltips to buttons; and (c)
+ // want to move to icons at some point
Gtk.StackSwitcher view_switcher = new Gtk.StackSwitcher();
view_switcher.stack = view_stack;
view_switcher.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED);
@@ -239,6 +252,14 @@ public class MainWindow : Gtk.ApplicationWindow {
current_controller.previous();
}
+ private void on_view_month() {
+ view_stack.set_visible_child(month_view.get_container());
+ }
+
+ private void on_view_week() {
+ view_stack.set_visible_child(week_view.get_container());
+ }
+
private void on_request_create_timed_event(Calendar.ExactTimeSpan initial, Gtk.Widget relative_to,
Gdk.Point? for_location) {
Component.Event event = new Component.Event.blank();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]