[california/wip/725763-manager] Final touches.
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725763-manager] Final touches.
- Date: Sat, 15 Mar 2014 00:11:42 +0000 (UTC)
commit f682ee5db45c84e68f900de9ecc74f10edc26f63
Author: Jim Nelson <jim yorba org>
Date: Fri Mar 14 17:11:24 2014 -0700
Final touches.
src/Makefile.am | 3 +-
src/application/california-application.vala | 11 +----
src/host/host-main-window.vala | 24 ++++------
src/host/host-modal-window.vala | 49 +++++++++++++++++++-
src/host/host-stack-window.vala | 40 ----------------
.../{manager-dialog.vala => manager-window.vala} | 20 ++++----
src/rc/app-menu.interface | 4 --
7 files changed, 69 insertions(+), 82 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 89a22f1..054184e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,12 +68,11 @@ california_VALASOURCES = \
host/host-modal-window.vala \
host/host-popup.vala \
host/host-show-event.vala \
- host/host-stack-window.vala \
\
manager/manager.vala \
manager/manager-calendar-list.vala \
manager/manager-calendar-list-item.vala \
- manager/manager-dialog.vala \
+ manager/manager-window.vala \
\
util/util-memory.vala \
util/util-string.vala \
diff --git a/src/application/california-application.vala b/src/application/california-application.vala
index d42d122..f656b13 100644
--- a/src/application/california-application.vala
+++ b/src/application/california-application.vala
@@ -35,7 +35,6 @@ public class Application : Gtk.Application {
public const string ACTION_QUIT = "app.quit";
private static const ActionEntry[] action_entries = {
- { "add-calendar", on_add_calendar },
{ "calendar-manager", on_calendar_manager },
{ "about", on_about },
{ "quit", on_quit }
@@ -122,16 +121,8 @@ public class Application : Gtk.Application {
dialog.destroy();
}
- private void on_add_calendar() {
- show_calendar_manager(true);
- }
-
private void on_calendar_manager() {
- show_calendar_manager(false);
- }
-
- private void show_calendar_manager(bool show_add_calendar) {
- Manager.Dialog.display(main_window, show_add_calendar);
+ Manager.Window.display(main_window);
}
private void on_about() {
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 66644d3..7e1d263 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -86,25 +86,18 @@ public class MainWindow : Gtk.ApplicationWindow {
add(layout);
}
- private Gtk.Widget show_interaction(Gtk.Widget relative_to, Gdk.Point? for_location,
+ private void show_interaction(Gtk.Widget relative_to, Gdk.Point? for_location,
Interaction child) {
- ModalWindow modal_window = new ModalWindow(this, null);
+ ModalWindow modal_window = new ModalWindow(this);
modal_window.content_area.add(child);
// when the dialog closes, reset View.Controllable state (selection is maintained while
// use is viewing/editing Interaction) and destroy widgets
- child.dismissed.connect(() => {
- current_view.unselect_all();
- modal_window.destroy();
- });
+ child.dismissed.connect(() => current_view.unselect_all());
modal_window.show_all();
-
- // the default widget is lost in the shuffle, reestablish its primacy
- if (child.default_widget != null)
- child.default_widget.grab_default();
-
- return modal_window;
+ modal_window.run();
+ modal_window.destroy();
}
private void on_new_event() {
@@ -137,8 +130,6 @@ public class MainWindow : Gtk.ApplicationWindow {
else
create_update_event = new CreateUpdateEvent.update(existing);
- show_interaction(relative_to, for_location, create_update_event);
-
create_update_event.create_event.connect((event) => {
create_event_async.begin(event, null);
});
@@ -147,6 +138,8 @@ public class MainWindow : Gtk.ApplicationWindow {
// TODO: Delete from original source if not the same as the new source
update_event_async.begin(event, null);
});
+
+ show_interaction(relative_to, for_location, create_update_event);
}
private async void create_event_async(Component.Event event, Cancellable? cancellable) {
@@ -174,7 +167,6 @@ public class MainWindow : Gtk.ApplicationWindow {
private void on_request_display_event(Component.Event event, Gtk.Widget relative_to,
Gdk.Point? for_location) {
ShowEvent show_event = new ShowEvent(event);
- show_interaction(relative_to, for_location, show_event);
show_event.remove_event.connect(() => {
remove_event_async.begin(event, null);
@@ -183,6 +175,8 @@ public class MainWindow : Gtk.ApplicationWindow {
show_event.update_event.connect(() => {
create_event(null, null, event, relative_to, for_location);
});
+
+ show_interaction(relative_to, for_location, show_event);
}
private async void remove_event_async(Component.Event event, Cancellable? cancellable) {
diff --git a/src/host/host-modal-window.vala b/src/host/host-modal-window.vala
index 775f667..45992d5 100644
--- a/src/host/host-modal-window.vala
+++ b/src/host/host-modal-window.vala
@@ -6,21 +6,66 @@
namespace California.Host {
+/**
+ * A GtkDialog with no visible action area.
+ *
+ * This is designed for UI panes that want to control their own interaction with the user (in
+ * particular, button placement) but need all the benefits interaction-wise of GtkDialog.
+ *
+ * It's expected this will go away when we move to GTK+ 3.12 and can use GtkPopovers for these
+ * interactions.
+ */
+
public class ModalWindow : Gtk.Dialog {
public Gtk.Box content_area { get; private set; }
- public ModalWindow(Gtk.Window? parent, string? title) {
+ private Interaction? primary = null;
+
+ public ModalWindow(Gtk.Window? parent) {
transient_for = parent;
- this.title = title;
modal = true;
resizable = false;
content_area = (Gtk.Box) get_content_area();
content_area.margin = 8;
+ content_area.add.connect(on_content_added);
+ content_area.remove.connect(on_content_removed);
get_action_area().visible = false;
get_action_area().no_show_all = true;
}
+
+ private void on_content_added(Gtk.Widget widget) {
+ Interaction? interaction = widget as Interaction;
+ if (interaction != null) {
+ if (primary == null)
+ primary = interaction;
+
+ interaction.dismissed.connect(on_interaction_dismissed);
+ }
+ }
+
+ private void on_content_removed(Gtk.Widget widget) {
+ Interaction? interaction = widget as Interaction;
+ if (interaction != null) {
+ if (primary == interaction)
+ primary = null;
+
+ interaction.dismissed.disconnect(on_interaction_dismissed);
+ }
+ }
+
+ private void on_interaction_dismissed() {
+ response(Gtk.ResponseType.CLOSE);
+ }
+
+ public override void show() {
+ base.show();
+
+ // the default widget is lost in the shuffle, reestablish its primacy
+ if (primary != null && primary.default_widget != null)
+ primary.default_widget.grab_default();
+ }
}
}
diff --git a/src/manager/manager-dialog.vala b/src/manager/manager-window.vala
similarity index 55%
rename from src/manager/manager-dialog.vala
rename to src/manager/manager-window.vala
index ceebc6e..a910c6f 100644
--- a/src/manager/manager-dialog.vala
+++ b/src/manager/manager-window.vala
@@ -6,18 +6,20 @@
namespace California.Manager {
-public class Dialog : Host.StackWindow {
- private static Manager.Dialog? instance = null;
-
- private CalendarList calendar_list = new CalendarList();
+/**
+ * The Calendar Manager main window.
+ */
+
+public class Window : Host.ModalWindow {
+ private static Manager.Window? instance = null;
- private Dialog(Gtk.Window? parent, bool show_add_calendar) {
- base (parent, _("Calendar Manager"));
+ private Window(Gtk.Window? parent) {
+ base (parent);
- add_card(calendar_list);
+ content_area.add(new CalendarList());
}
- public static void display(Gtk.Window? parent, bool show_add_calendar) {
+ public static void display(Gtk.Window? parent) {
// only allow one instance at a time
if (instance != null) {
instance.present_with_time(Gdk.CURRENT_TIME);
@@ -25,7 +27,7 @@ public class Dialog : Host.StackWindow {
return;
}
- instance = new Manager.Dialog(parent, show_add_calendar);
+ instance = new Manager.Window(parent);
instance.show_all();
instance.run();
instance.destroy();
diff --git a/src/rc/app-menu.interface b/src/rc/app-menu.interface
index e73539a..564080b 100644
--- a/src/rc/app-menu.interface
+++ b/src/rc/app-menu.interface
@@ -3,10 +3,6 @@
<menu id="app-menu">
<section>
<item>
- <attribute name="label" translatable="yes">A_dd or create calendar...</attribute>
- <attribute name="action">app.add-calendar</attribute>
- </item>
- <item>
<attribute name="label" translatable="yes">_Calendars</attribute>
<attribute name="action">app.calendar-manager</attribute>
<attribute name="accel"><Primary>l</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]