← Back to team overview

gtg team mailing list archive

[Merge] lp:~scialexlight/gtg/gtg into lp:gtg

 

Alex Light has proposed merging lp:~scialexlight/gtg/gtg into lp:gtg.

Requested reviews:
  Gtg developers (gtg)
Related bugs:
  Bug #499320 in Getting Things GNOME!: "Option to show tags even if they are empty"
  https://bugs.launchpad.net/gtg/+bug/499320

For more details, see:
https://code.launchpad.net/~scialexlight/gtg/gtg/+merge/101054

This branch fixes Bug 499320 (https://bugs.launchpad.net/gtg/+bug/499320) and allows one to make a tag stay in the tag list no matter how few tasks have it. This new property is toggled using the left click context menu. 
-- 
https://code.launchpad.net/~scialexlight/gtg/gtg/+merge/101054
Your team Gtg developers is requested to review the proposed merge of lp:~scialexlight/gtg/gtg into lp:gtg.
=== modified file 'AUTHORS'
--- AUTHORS	2012-04-01 19:08:12 +0000
+++ AUTHORS	2012-04-06 01:46:18 +0000
@@ -104,3 +104,4 @@
 * Marta Maria Casetti <mmcasetti@xxxxxxxxx>
 * Song Yangyu <flyfy1@xxxxxxxxx>
 * Saurabh Anand <saurabhanandiit@xxxxxxxxx>
+* Alexander Light <scialexlight@xxxxxxxxx>

=== modified file 'CHANGELOG'
--- CHANGELOG	2012-04-02 18:06:56 +0000
+++ CHANGELOG	2012-04-06 01:46:18 +0000
@@ -13,6 +13,7 @@
       * added start: which has the same meaning as defer:
     * Automatic restore a backup XML file if the original XML file could not be loaded
     * Backends were renamed to Synchronization Services, by Anant Gupta
+    * Can set tags as permanent, making them stay in the list even if they are not mentioned in any events.
 
 2012-02-13 Getting Things GNOME! 0.2.9
     * Big refractorization of code, now using liblarch

=== modified file 'GTG/core/tag.py'
--- GTG/core/tag.py	2012-03-21 21:46:47 +0000
+++ GTG/core/tag.py	2012-04-06 01:46:18 +0000
@@ -174,6 +174,11 @@
     def is_removable(self):
         attr = self.get_all_attributes(butname=True, withparent=True)
         return (len(attr) <= 0 and not self.is_used())
+    
+    # This tag has been set as permanent by the user, it will
+    # be displayed even if no tasks currently have it.
+    def is_permanent(self):
+        return bool(self.get_attribute('is_permanent'))
 
     def is_special(self):
         return bool(self.get_attribute('special'))
@@ -185,7 +190,7 @@
         return self.get_total_tasks_count() > 0
 
     def is_actively_used(self):
-        return self.is_search_tag() or self.is_special() or self.get_active_tasks_count() > 0
+        return self.is_search_tag() or self.is_special() or self.is_permanent() or self.get_active_tasks_count() > 0
 
     def __str__(self):
         return "Tag: %s" % self.get_name()

=== modified file 'GTG/gtk/browser/__init__.py'
--- GTG/gtk/browser/__init__.py	2012-03-27 10:46:47 +0000
+++ GTG/gtk/browser/__init__.py	2012-04-06 01:46:18 +0000
@@ -49,3 +49,5 @@
     TAG_NOTIN_WORKVIEW_TOGG = _("Show this tag in the workview")
     QUICKADD_ENTRY_TOOLTIP  = _("You can create, open or filter your tasks here")
     QUICKADD_ICON_TOOLTIP   = _("Clear")
+    MAKE_TAG_PERMANENT      = _("Make Tag Permanent")
+    MAKE_TAG_NOT_PERMANENT  = _("Make Tag Not Permanent")

=== modified file 'GTG/gtk/browser/browser.py'
--- GTG/gtk/browser/browser.py	2012-04-03 06:01:15 +0000
+++ GTG/gtk/browser/browser.py	2012-04-06 01:46:18 +0000
@@ -128,7 +128,7 @@
 
         self.on_select_tag()
         self.browser_shown = False
-        
+
         #Update the title when a task change
         self.activetree.register_cllbck('node-added-inview', self._update_window_title)
         self.activetree.register_cllbck('node-deleted-inview', self._update_window_title)
@@ -154,6 +154,7 @@
         self.searchpopup          = self.builder.get_object("search_context_menu")
         self.nonworkviewtag_cb  = self.builder.get_object("nonworkviewtag_mi")
         self.nonworkviewtag_cb.set_label(GnomeConfig.TAG_IN_WORKVIEW_TOGG)
+        self.permanent_tag_cb   = self.builder.get_object("permanent_tag_mi")
         self.taskpopup          = self.builder.get_object("task_context_menu")
         self.defertopopup       = self.builder.get_object("defer_to_context_menu")
         self.ctaskpopup         = self.builder.get_object("closed_task_context_menu")
@@ -338,6 +339,8 @@
                 lambda w: openurl(info.REPORT_BUG_URL),
             "on_nonworkviewtag_toggled":
                 self.on_nonworkviewtag_toggled,
+            "on_permanent_tag_mi_toggled":
+                self.on_permanent_tag_mi_toggled,
             "on_preferences_activate":
                 self.open_preferences,
             "on_edit_backends_activate":
@@ -703,7 +706,7 @@
             t = self.req.get_tag(tname)
             t.del_attribute("color")
         self.reset_cursor()
-        
+       
     def on_tagcontext_deactivate(self, menushell):
         self.reset_cursor()
 
@@ -899,8 +902,15 @@
                     # the special 'All tags' or 'Tasks without tags'. We only
                     # want to popup the menu for normal tags.
 
-                    display_in_workview_item = self.tagpopup.get_children()[2]
+                    display_in_workview_item = self.tagpopup.get_children()[3]
                     selected_tag = self.req.get_tag(selected_tags[0])
+                    # Make sure that the permanent option is correct.
+                    if selected_tag.is_permanent():
+                        label = GnomeConfig.MAKE_TAG_NOT_PERMANENT
+                    else:
+                        label = GnomeConfig.MAKE_TAG_PERMANENT
+                    self.permanent_tag_cb.set_label(label)
+
                     nonworkview = selected_tag.get_attribute("nonworkview")
                     # We must invert because the tagstore has "True" for tasks
                     # that are *not* in workview, and the checkbox is set if
@@ -938,6 +948,27 @@
         self.nonworkviewtag_cb.set_label(label)
         if not self.dont_reset:
             self.reset_cursor()
+    
+    def on_permanent_tag_mi_toggled(self, widget):
+        """
+        Toggles a tags permanence, and removes a tag if it is
+        no longer active and its permanence is turned off.
+        """
+        self.set_target_cursor()
+        tag_id = self.get_selected_tags()[0]
+        tag = self.req.get_tag(tag_id)
+        toset = not tag.is_permanent() 
+        if toset:
+            tag.set_attribute('is_permanent','True')
+            label = GnomeConfig.MAKE_TAG_NOT_PERMANENT
+        else: 
+            tag.del_attribute('is_permanent')
+            label = GnomeConfig.MAKE_TAG_PERMANENT
+            # The tag might no longer need to be there so better check.
+            self.tagtree.refresh_all()
+        self.permanent_tag_cb.set_label(label)
+        if not self.dont_reset:
+            self.reset_cursor()
 
     def on_task_treeview_button_press_event(self, treeview, event):
         """Pop up context menu on right mouse click in the main task tree view"""

=== modified file 'GTG/gtk/browser/taskbrowser.glade'
--- GTG/gtk/browser/taskbrowser.glade	2012-04-02 18:06:56 +0000
+++ GTG/gtk/browser/taskbrowser.glade	2012-04-06 01:46:18 +0000
@@ -1170,6 +1170,15 @@
       </object>
     </child>
     <child>
+      <object class="GtkImageMenuItem" id="permanent_tag_mi">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="use_action_appearance">False</property>
+        <property name="use_underline">True</property>
+        <signal name="activate" handler="on_permanent_tag_mi_toggled" swapped="no"/> 
+      </object>
+    </child>
+    <child>
       <object class="GtkCheckMenuItem" id="nonworkviewtag_mi">
         <property name="visible">True</property>
         <property name="can_focus">False</property>