[california] Allow for non-date-specified Quick Add: Bug #735939



commit 9e5222e46de4ab6603f80491dd7530129723d62f
Author: Jim Nelson <jim yorba org>
Date:   Wed Sep 3 16:54:24 2014 -0700

    Allow for non-date-specified Quick Add: Bug #735939
    
    Unity/Ambience theming bug led us not to show any GtkPopovers that
    are attached to the GtkHeaderBar, instead using the current day for
    Ctrl+N (or the Quick Add button).  That regressed functionality by
    not allowing for users to enter a Quick Add event devoid of a
    starting date.  This restores that functionality, using a DeckWindow
    instead of a DeckPopover on Unity/Ambiance.

 src/host/host-main-window.vala        |   28 +++++++++++----------
 src/host/host-quick-create-event.vala |   15 +++++++++++-
 src/rc/quick-create-event.ui          |   42 ++++++++++++++++++++++++++++++--
 src/toolkit/toolkit-deck-window.vala  |    1 +
 4 files changed, 69 insertions(+), 17 deletions(-)
---
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index 6924978..de664d3 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -368,16 +368,13 @@ public class MainWindow : Gtk.ApplicationWindow {
     }
     
     private void on_quick_create_event() {
-        // 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);
+#if ENABLE_UNITY
+        // Unity/Ambiance has display problems with GtkPopovers attached to GtkHeaderBars, so use
+        // a DeckWindow
+        quick_create_event(null, null, null);
+#else
+        quick_create_event(null, quick_add_button, null);
+#endif
     }
     
     private void on_jump_to_today() {
@@ -447,8 +444,10 @@ public class MainWindow : Gtk.ApplicationWindow {
         quick_create_event(event, relative_to, for_location);
     }
     
-    private void quick_create_event(Component.Event? initial, Gtk.Widget relative_to, Gdk.Point? 
for_location) {
-        QuickCreateEvent quick_create = new QuickCreateEvent();
+    private void quick_create_event(Component.Event? initial, Gtk.Widget? relative_to, Gdk.Point? 
for_location) {
+        bool use_deck_window = relative_to == null && for_location == null;
+        
+        QuickCreateEvent quick_create = new QuickCreateEvent(use_deck_window);
         
         Toolkit.Deck deck = new Toolkit.Deck();
         deck.add_cards(iterate<Toolkit.Card>(quick_create).to_array_list());
@@ -460,7 +459,10 @@ public class MainWindow : Gtk.ApplicationWindow {
                 edit_event(quick_create.event);
         });
         
-        show_deck_popover(relative_to, for_location, deck);
+        if (use_deck_window)
+            show_deck_window(deck);
+        else
+            show_deck_popover(relative_to, for_location, deck);
     }
     
     private void on_request_display_event(Component.Event event, Gtk.Widget relative_to,
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index 8913969..5b887c9 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -40,15 +40,23 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
     [GtkChild]
     private Gtk.Button create_button;
     
+    [GtkChild]
+    private Gtk.Button cancel_button;
+    
     private Toolkit.ComboBoxTextModel<Backing.CalendarSource> model;
     private Toolkit.EntryClearTextConnector clear_text_connector = new Toolkit.EntryClearTextConnector();
     
-    public QuickCreateEvent() {
+    public QuickCreateEvent(bool in_deck_window) {
         model = build_calendar_source_combo_model(calendar_combo_box);
         
         clear_text_connector.connect_to(details_entry);
         details_entry.bind_property("text", create_button, "sensitive", BindingFlags.SYNC_CREATE,
             transform_text_to_sensitivity);
+        
+        // Only show Cancel button if in a DeckWindow; if in popover, dismissal is easy and doesn't
+        // require one
+        cancel_button.visible = in_deck_window;
+        cancel_button.no_show_all = !in_deck_window;
     }
     
     private bool transform_text_to_sensitivity(Binding binding, Value source_value, ref Value target_value) {
@@ -124,6 +132,11 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
         edit_event();
     }
     
+    [GtkCallback]
+    private void on_cancel_button_clicked() {
+        notify_user_closed();
+    }
+    
     private void edit_event() {
         // Must pass some kind of event to create/update, so use blank if required
         if (event == null)
diff --git a/src/rc/quick-create-event.ui b/src/rc/quick-create-event.ui
index e86fab3..b27b3a5 100644
--- a/src/rc/quick-create-event.ui
+++ b/src/rc/quick-create-event.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.16.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <template class="CaliforniaHostQuickCreateEvent" parent="GtkGrid">
@@ -23,6 +23,7 @@
         <property name="left_attach">0</property>
         <property name="top_attach">0</property>
         <property name="width">2</property>
+        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -36,6 +37,8 @@
       <packing>
         <property name="left_attach">1</property>
         <property name="top_attach">1</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -52,6 +55,8 @@
       <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>
     <child>
@@ -95,6 +100,8 @@
       <packing>
         <property name="left_attach">1</property>
         <property name="top_attach">2</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -112,6 +119,8 @@
       <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>
@@ -123,6 +132,8 @@
       <packing>
         <property name="left_attach">1</property>
         <property name="top_attach">3</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -139,6 +150,8 @@
       <packing>
         <property name="left_attach">0</property>
         <property name="top_attach">3</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
       </packing>
     </child>
     <child>
@@ -181,6 +194,28 @@
             <property name="can_focus">False</property>
             <property name="spacing">2</property>
             <child>
+              <object class="GtkButton" id="cancel_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="tooltip_text" translatable="yes">Cancel</property>
+                <property name="relief">none</property>
+                <signal name="clicked" handler="on_cancel_button_clicked" 
object="CaliforniaHostQuickCreateEvent" swapped="no"/>
+                <child>
+                  <object class="GtkImage" id="image4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">cancel</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkButton" id="edit_button">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -203,7 +238,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">0</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
@@ -231,7 +266,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -247,6 +282,7 @@
         <property name="left_attach">0</property>
         <property name="top_attach">4</property>
         <property name="width">2</property>
+        <property name="height">1</property>
       </packing>
     </child>
   </template>
diff --git a/src/toolkit/toolkit-deck-window.vala b/src/toolkit/toolkit-deck-window.vala
index 08c4331..fa81775 100644
--- a/src/toolkit/toolkit-deck-window.vala
+++ b/src/toolkit/toolkit-deck-window.vala
@@ -23,6 +23,7 @@ public class DeckWindow : Gtk.Dialog {
         transient_for = parent;
         modal = true;
         resizable = false;
+        decorated = false;
         
         deck.dismiss.connect(on_deck_dismissed);
         deck.success.connect(on_deck_success);


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