[california/wip/725763-manager] Cleanup, thinking about how GtkStack is going to work
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725763-manager] Cleanup, thinking about how GtkStack is going to work
- Date: Sat, 15 Mar 2014 00:11:32 +0000 (UTC)
commit 716a6194a4a7d012a8eab4ca6e56e682873d629c
Author: Jim Nelson <jim yorba org>
Date: Fri Mar 14 15:45:35 2014 -0700
Cleanup, thinking about how GtkStack is going to work
src/Makefile.am | 2 +-
src/host/host-interaction.vala | 10 ++++----
src/host/host-main-window.vala | 12 ++++-----
src/host/host-modal-window.vala | 3 +-
src/host/host-stack-window.vala | 40 ++++++++++++++++++++++++++++++++
src/manager/manager-calendar-list.vala | 9 ++++++-
src/manager/manager-controller.vala | 20 ----------------
src/manager/manager-dialog.vala | 7 ++---
src/rc/calendar-manager-list.ui | 34 +++++++++++++++++++++++++++
9 files changed, 98 insertions(+), 39 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 805c404..89a22f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -68,11 +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-controller.vala \
manager/manager-dialog.vala \
\
util/util-memory.vala \
diff --git a/src/host/host-interaction.vala b/src/host/host-interaction.vala
index cf31c88..afebc36 100644
--- a/src/host/host-interaction.vala
+++ b/src/host/host-interaction.vala
@@ -22,17 +22,17 @@ namespace California.Host {
public interface Interaction : Gtk.Widget {
/**
+ * The default widget for the { link Interaction}.
+ */
+ public abstract Gtk.Widget? default_widget { get; }
+
+ /**
* Fired when the user has cancelled, closed, or dismissed the { link Interaction}.
*
* This should be called by implementing classes even if other signals suggest or imply that
* the Interaction is dismissed, so a single signal handler can deal with cleanup.
*/
public signal void dismissed();
-
- /**
- * The default widget for the { link Interaction}.
- */
- public abstract Gtk.Widget? default_widget { get; }
}
}
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 25d427e..66644d3 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -88,25 +88,23 @@ public class MainWindow : Gtk.ApplicationWindow {
private Gtk.Widget show_interaction(Gtk.Widget relative_to, Gdk.Point? for_location,
Interaction child) {
- Gtk.Dialog dialog = new Gtk.Dialog();
- dialog.transient_for = this;
- dialog.modal = true;
- ((Gtk.Box) dialog.get_content_area()).pack_start(child, true, true, 0);
+ ModalWindow modal_window = new ModalWindow(this, null);
+ 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();
- dialog.destroy();
+ modal_window.destroy();
});
- dialog.show_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 dialog;
+ return modal_window;
}
private void on_new_event() {
diff --git a/src/host/host-modal-window.vala b/src/host/host-modal-window.vala
index 6596feb..775f667 100644
--- a/src/host/host-modal-window.vala
+++ b/src/host/host-modal-window.vala
@@ -13,9 +13,10 @@ public class ModalWindow : Gtk.Dialog {
transient_for = parent;
this.title = title;
modal = true;
+ resizable = false;
content_area = (Gtk.Box) get_content_area();
- content_area.margin = 4;
+ content_area.margin = 8;
get_action_area().visible = false;
get_action_area().no_show_all = true;
diff --git a/src/host/host-stack-window.vala b/src/host/host-stack-window.vala
new file mode 100644
index 0000000..6c28af5
--- /dev/null
+++ b/src/host/host-stack-window.vala
@@ -0,0 +1,40 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+namespace California.Host {
+
+public class StackWindow : ModalWindow {
+ private Gtk.Stack stack = new Gtk.Stack();
+
+ public StackWindow(Gtk.Window? parent, string? title) {
+ base (parent, title);
+
+ content_area.add(stack);
+ }
+
+ /**
+ * Adds the GtkWidget to the internal GtkStack, not the ModalWindow itself.
+ */
+ public void add_card(Host.Interaction interaction) {
+ stack.add(interaction);
+ interaction.dismissed.connect(on_interaction_dismissed);
+ }
+
+ /**
+ * Removes the GtkWidget from the internal GtkStack, not the ModalWindow itself.
+ */
+ public void remove_card(Host.Interaction interaction) {
+ stack.remove(interaction);
+ interaction.dismissed.disconnect(on_interaction_dismissed);
+ }
+
+ private void on_interaction_dismissed() {
+ response(Gtk.ResponseType.CLOSE);
+ }
+}
+
+}
+
diff --git a/src/manager/manager-calendar-list.vala b/src/manager/manager-calendar-list.vala
index ba8309c..dccbbe0 100644
--- a/src/manager/manager-calendar-list.vala
+++ b/src/manager/manager-calendar-list.vala
@@ -7,7 +7,9 @@
namespace California.Manager {
[GtkTemplate (ui = "/org/yorba/california/rc/calendar-manager-list.ui")]
-public class CalendarList : Gtk.Grid {
+public class CalendarList : Gtk.Grid, Host.Interaction {
+ public Gtk.Widget? default_widget { get { return null; } }
+
[GtkChild]
private Gtk.ListBox calendar_list_box;
@@ -47,6 +49,11 @@ public class CalendarList : Gtk.Grid {
debug("activated %s", item.source.to_string());
item = null;
}
+
+ [GtkCallback]
+ private void on_close_button_clicked() {
+ dismissed();
+ }
}
}
diff --git a/src/manager/manager-dialog.vala b/src/manager/manager-dialog.vala
index 9c6e3d6..ceebc6e 100644
--- a/src/manager/manager-dialog.vala
+++ b/src/manager/manager-dialog.vala
@@ -6,16 +6,15 @@
namespace California.Manager {
-public class Dialog : Host.ModalWindow {
+public class Dialog : Host.StackWindow {
private static Manager.Dialog? instance = null;
- private Manager.Controller controller;
+ private CalendarList calendar_list = new CalendarList();
private Dialog(Gtk.Window? parent, bool show_add_calendar) {
base (parent, _("Calendar Manager"));
- controller = new Controller(show_add_calendar);
- content_area.add(controller);
+ add_card(calendar_list);
}
public static void display(Gtk.Window? parent, bool show_add_calendar) {
diff --git a/src/rc/calendar-manager-list.ui b/src/rc/calendar-manager-list.ui
index 62dbe1b..787736c 100644
--- a/src/rc/calendar-manager-list.ui
+++ b/src/rc/calendar-manager-list.ui
@@ -20,5 +20,39 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkButtonBox" id="calendar_list_button_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">end</property>
+ <property name="margin_top">8</property>
+ <property name="baseline_position">bottom</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label" translatable="yes">_Close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="valign">end</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="on_close_button_clicked" object="CaliforniaManagerCalendarList"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]