[california/wip/727001-remove] UI in place



commit a923c5d4f6bc7cbb811983ea8baee654a2d1e7a3
Author: Jim Nelson <jim yorba org>
Date:   Thu Sep 11 16:19:23 2014 -0700

    UI in place

 po/POTFILES.in                                   |    3 +
 po/POTFILES.skip                                 |    1 +
 src/Makefile.am                                  |    2 +
 src/backing/backing-source.vala                  |    5 +
 src/backing/eds/backing-eds-calendar-source.vala |    1 +
 src/california-resources.xml                     |    3 +
 src/manager/manager-calendar-list.vala           |    8 +-
 src/manager/manager-remove-calendar.vala         |   51 +++++++++
 src/manager/manager-window.vala                  |    2 +-
 src/rc/calendar-manager-list.ui                  |   11 +--
 src/rc/remove-calendar.ui                        |  118 ++++++++++++++++++++++
 11 files changed, 191 insertions(+), 14 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0cb24e1..59e4bc7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,6 +20,8 @@ src/host/host-import-calendar.vala
 src/host/host-main-window.vala
 src/host/host-quick-create-event.vala
 src/host/host-show-event.vala
+src/manager/manager-calendar-list-item.vala
+src/manager/manager-remove-calendar.vala
 src/view/month/month-controller.vala
 src/view/week/week-controller.vala
 [type: gettext/glade]src/rc/activator-list.ui
@@ -37,5 +39,6 @@ src/view/week/week-controller.vala
 [type: gettext/glade]src/rc/google-login.ui
 [type: gettext/glade]src/rc/main-window-title.ui
 [type: gettext/glade]src/rc/quick-create-event.ui
+[type: gettext/glade]src/rc/remove-calendar.ui
 [type: gettext/glade]src/rc/show-event.ui
 [type: gettext/glade]src/rc/window-menu.interface
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 00e9fcb..1c3ae7c 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -18,6 +18,7 @@ src/host/host-main-window.c
 src/host/host-quick-create-event.c
 src/host/host-show-event.c
 src/manager/manager-calendar-list-item.c
+src/manager/manager-remove-calendar.c
 src/view/month/month-controller.c
 src/view/week/week-controller.c
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 11179c6..ea6468a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -113,6 +113,7 @@ california_VALASOURCES = \
        manager/manager.vala \
        manager/manager-calendar-list.vala \
        manager/manager-calendar-list-item.vala \
+       manager/manager-remove-calendar.vala \
        manager/manager-window.vala \
        \
        tests/tests.vala \
@@ -205,6 +206,7 @@ california_RC = \
        rc/google-login.ui \
        rc/main-window-title.ui \
        rc/quick-create-event.ui \
+       rc/remove-calendar.ui \
        rc/show-event.ui \
        rc/window-menu.interface \
        $(NULL)
diff --git a/src/backing/backing-source.vala b/src/backing/backing-source.vala
index c2a0dbc..23b8537 100644
--- a/src/backing/backing-source.vala
+++ b/src/backing/backing-source.vala
@@ -68,6 +68,11 @@ public abstract class Source : BaseObject, Gee.Comparable<Source> {
     public bool read_only { get; protected set; }
     
     /**
+     * Whether the { link Source} is local-only or has network backing.
+     */
+    public bool is_local { get; protected set; }
+    
+    /**
      * The suggested color to use when displaying the { link Source} or information about or from
      * it.
      */
diff --git a/src/backing/eds/backing-eds-calendar-source.vala 
b/src/backing/eds/backing-eds-calendar-source.vala
index ad587a1..1a38348 100644
--- a/src/backing/eds/backing-eds-calendar-source.vala
+++ b/src/backing/eds/backing-eds-calendar-source.vala
@@ -41,6 +41,7 @@ internal class EdsCalendarSource : CalendarSource {
         title = eds_source.display_name;
         visible = eds_calendar.selected;
         color = eds_calendar.color;
+        is_local = eds_calendar.backend_name == "local";
         
         // when changed within the app, need to write it back out
         notify[PROP_TITLE].connect(on_title_changed);
diff --git a/src/california-resources.xml b/src/california-resources.xml
index 0be1eb7..c09f7c7 100644
--- a/src/california-resources.xml
+++ b/src/california-resources.xml
@@ -49,6 +49,9 @@
         <file compressed="true">rc/quick-create-event.ui</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
+        <file compressed="true">rc/remove-calendar.ui</file>
+    </gresource>
+    <gresource prefix="/org/yorba/california">
         <file compressed="false">rc/show-event.ui</file>
     </gresource>
     <gresource prefix="/org/yorba/california">
diff --git a/src/manager/manager-calendar-list.vala b/src/manager/manager-calendar-list.vala
index b64763f..d27d4e0 100644
--- a/src/manager/manager-calendar-list.vala
+++ b/src/manager/manager-calendar-list.vala
@@ -55,10 +55,6 @@ internal class CalendarList : Gtk.Grid, Toolkit.Card {
             BindingFlags.SYNC_CREATE, transform_selected_to_sensitive);
         model.bind_property(Toolkit.ListBoxModel.PROP_SELECTED, remove_button, "sensitive",
             BindingFlags.SYNC_CREATE, transform_selected_to_sensitive);
-        
-        // TODO: Remove this when deleting a calendar is implemented
-        remove_button.visible = false;
-        remove_button.no_show_all = true;
     }
     
     ~CalendarList() {
@@ -69,7 +65,7 @@ internal class CalendarList : Gtk.Grid, Toolkit.Card {
     }
     
     private bool transform_selected_to_sensitive(Binding binding, Value source_value, ref Value 
target_value) {
-        target_value = model.selected != null;
+        target_value = model.selected != null && !model.selected.read_only;
         
         return true;
     }
@@ -140,6 +136,8 @@ internal class CalendarList : Gtk.Grid, Toolkit.Card {
     
     [GtkCallback]
     private void on_remove_button_clicked() {
+        if (model.selected != null)
+            jump_to_card_by_name(RemoveCalendar.ID, model.selected);
     }
     
     [GtkCallback]
diff --git a/src/manager/manager-remove-calendar.vala b/src/manager/manager-remove-calendar.vala
new file mode 100644
index 0000000..c4ec626
--- /dev/null
+++ b/src/manager/manager-remove-calendar.vala
@@ -0,0 +1,51 @@
+/* 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.Manager {
+
+[GtkTemplate (ui = "/org/yorba/california/rc/remove-calendar.ui")]
+private class RemoveCalendar : Gtk.Grid, Toolkit.Card {
+    public const string ID = "RemoveCalendar";
+    
+    public string card_id { get { return ID; } }
+    
+    public string? title { get { return null; } }
+    
+    public Gtk.Widget? default_widget { get { return null; } }
+    
+    public Gtk.Widget? initial_focus { get { return null; } }
+    
+    [GtkChild]
+    private Gtk.Label explanation_label;
+    
+    public RemoveCalendar() {
+    }
+    
+    public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
+        Backing.CalendarSource source = message as Backing.CalendarSource;
+        
+        string fmt;
+        if (source.is_local)
+            fmt = _("This will remove the %s local calendar from your computer.  All associated information 
will be deleted permanently.");
+        else
+            fmt = _("This will remove the %s network calendar from your computer.  This will not affect the 
information stored on the server.");
+        
+        explanation_label.label = fmt.printf("<b>" + GLib.Markup.escape_text(source.title) + "</b>");
+    }
+    
+    [GtkCallback]
+    private void on_cancel_button_clicked() {
+        jump_back();
+    }
+    
+    [GtkCallback]
+    private void on_remove_button_clicked() {
+        jump_back();
+    }
+}
+
+}
+
diff --git a/src/manager/manager-window.vala b/src/manager/manager-window.vala
index 08e3546..597761d 100644
--- a/src/manager/manager-window.vala
+++ b/src/manager/manager-window.vala
@@ -16,7 +16,7 @@ public class Window : Toolkit.DeckWindow {
     private Window(Gtk.Window? window) {
         base (window, null);
         
-        deck.add_cards(iterate<Toolkit.Card>(calendar_list).to_array_list());
+        deck.add_cards(iterate<Toolkit.Card>(calendar_list, new RemoveCalendar()).to_array_list());
         Activator.prepare_deck(deck, null);
     }
     
diff --git a/src/rc/calendar-manager-list.ui b/src/rc/calendar-manager-list.ui
index 3f76e72..ae6e15f 100644
--- a/src/rc/calendar-manager-list.ui
+++ b/src/rc/calendar-manager-list.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.18.3 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <template class="CaliforniaManagerCalendarList" parent="GtkGrid">
@@ -22,7 +22,8 @@
             <child>
               <object class="GtkListBox" id="calendar_list_box">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can_focus">True</property>
+                <property name="has_focus">True</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
                 <property name="activate_on_single_click">False</property>
@@ -36,8 +37,6 @@
       <packing>
         <property name="left_attach">0</property>
         <property name="top_attach">0</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -70,8 +69,6 @@
       <packing>
         <property name="left_attach">0</property>
         <property name="top_attach">2</property>
-        <property name="width">1</property>
-        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -140,8 +137,6 @@
       <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>
diff --git a/src/rc/remove-calendar.ui b/src/rc/remove-calendar.ui
new file mode 100644
index 0000000..8f74249
--- /dev/null
+++ b/src/rc/remove-calendar.ui
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <template class="CaliforniaManagerRemoveCalendar" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="row_spacing">8</property>
+    <child>
+      <object class="GtkButtonBox" id="buttonbox1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">end</property>
+        <property name="margin_top">8</property>
+        <property name="spacing">8</property>
+        <property name="homogeneous">True</property>
+        <property name="layout_style">start</property>
+        <child>
+          <object class="GtkButton" id="cancel_button">
+            <property name="label" translatable="yes">_Cancel</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_underline">True</property>
+            <signal name="clicked" handler="on_cancel_button_clicked" 
object="CaliforniaManagerRemoveCalendar" swapped="no"/>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="remove_button">
+            <property name="label" translatable="yes">_Remove</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_underline">True</property>
+            <signal name="clicked" handler="on_remove_button_clicked" 
object="CaliforniaManagerRemoveCalendar" swapped="no"/>
+            <style>
+              <class name="destructive-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">2</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="explanation_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="margin_left">16</property>
+        <property name="margin_right">8</property>
+        <property name="vexpand">True</property>
+        <property name="xalign">0</property>
+        <property name="yalign">0</property>
+        <property name="label">(empty)</property>
+        <property name="use_markup">True</property>
+        <property name="wrap">True</property>
+        <property name="width_chars">32</property>
+        <property name="max_width_chars">32</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">8</property>
+        <child>
+          <object class="GtkImage" id="image1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="pixel_size">60</property>
+            <property name="icon_name">dialog-warning-symbolic</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="title_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Are you sure you want to remove this 
calendar?</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+      </packing>
+    </child>
+  </template>
+</interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]