[hamster-applet] hooray for some more deleted code - switched to our new completion
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] hooray for some more deleted code - switched to our new completion
- Date: Thu, 19 Nov 2009 22:05:16 +0000 (UTC)
commit 002db0d709c66fcdf2bfb2841960630d5b893b9f
Author: Toms Bauģis <toms baugis gmail com>
Date: Thu Nov 19 22:03:26 2009 +0000
hooray for some more deleted code - switched to our new completion
data/edit_activity.ui | 8 ++-
hamster/edit_activity.py | 122 ++++++----------------------------------------
2 files changed, 20 insertions(+), 110 deletions(-)
---
diff --git a/data/edit_activity.ui b/data/edit_activity.ui
index 9ef499a..a8df34a 100644
--- a/data/edit_activity.ui
+++ b/data/edit_activity.ui
@@ -204,13 +204,15 @@
<property name="xalign">0</property>
<property name="label" translatable="yes">Activity:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">activity_combo</property>
</object>
</child>
<child>
- <object class="GtkComboBoxEntry" id="activity_combo">
+ <object class="GtkAlignment" id="activity_box">
+ <property name="width_request">300</property>
<property name="visible">True</property>
- <signal name="changed" handler="on_activity_combo_changed"/>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/hamster/edit_activity.py b/hamster/edit_activity.py
index f6ddc71..d81b17b 100644
--- a/hamster/edit_activity.py
+++ b/hamster/edit_activity.py
@@ -17,47 +17,39 @@
# You should have received a copy of the GNU General Public License
# along with Project Hamster. If not, see <http://www.gnu.org/licenses/>.
-
-import pygtk
-pygtk.require('2.0')
-
-import os
import gtk
-import gobject
-
-import stuff
-
-import widgets
-
-import eds
-from configuration import runtime
-
import time
import datetime as dt
-import colorsys
-import cairo, pango
+import stuff, widgets
+from configuration import runtime
+
""" TODO:
* hook into notifications and refresh our days if some evil neighbour edit
fact window has dared to edit facts
"""
-
class CustomFactController:
def __init__(self, parent = None, fact_date = None, fact_id = None):
self._gui = stuff.load_ui_file("edit_activity.ui")
self.window = self.get_widget('custom_fact_window')
self.parent, self.fact_id = parent, fact_id
-
start_date, end_date = None, None
+
+ #TODO - should somehow hint that time is not welcome here
+ self.new_name = widgets.ActivityEntry()
+ self.new_name.connect("changed", self.on_new_name_changed)
+ self.get_widget("activity_box").add(self.new_name)
+
if fact_id:
fact = runtime.storage.get_fact(fact_id)
label = fact['name']
if fact['category'] != _("Unsorted"):
label += "@%s" % fact['category']
- self.get_widget('activity_combo').child.set_text(label)
+
+ self.new_name.set_text(label)
start_date = fact["start_time"]
end_date = fact["end_time"]
@@ -113,9 +105,6 @@ class CustomFactController:
self.set_end_date_label(end_date)
- self.set_dropdown()
- self.refresh_menu()
-
self.dayline = widgets.DayLine()
self.dayline.on_time_changed = self.update_time
self.dayline.on_more_data = runtime.storage.get_facts
@@ -134,87 +123,6 @@ class CustomFactController:
def draw_preview(self, date, highlight = None):
day_facts = runtime.storage.get_facts(date)
self.dayline.draw(day_facts, highlight)
-
-
-
- def set_dropdown(self):
- # set up drop down menu
- self.activity_list = self._gui.get_object('activity_combo')
- self.activity_list.set_model(gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING))
-
-
- self.activity_list.set_property("text-column", 2)
- self.activity_list.clear()
- activity_cell = gtk.CellRendererText()
- self.activity_list.pack_start(activity_cell, True)
- self.activity_list.add_attribute(activity_cell, 'text', 0)
- category_cell = stuff.CategoryCell()
- self.activity_list.pack_start(category_cell, False)
- self.activity_list.add_attribute(category_cell, 'text', 1)
-
- self.activity_list.child.connect('key-press-event', self.on_activity_list_key_pressed)
-
-
- # set up autocompletition
- self.activities = gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING)
- completion = gtk.EntryCompletion()
- completion.set_model(self.activities)
-
- activity_cell = gtk.CellRendererText()
- completion.pack_start(activity_cell, True)
- completion.add_attribute(activity_cell, 'text', 0)
- completion.set_property("text-column", 2)
-
- category_cell = stuff.CategoryCell()
- completion.pack_start(category_cell, False)
- completion.add_attribute(category_cell, 'text', 1)
-
- completion.set_minimum_key_length(1)
- completion.set_inline_completion(True)
-
- self.activity_list.child.set_completion(completion)
-
-
- def refresh_menu(self):
- #first populate the autocomplete - contains all entries in lowercase
- self.activities.clear()
- all_activities = runtime.storage.get_autocomplete_activities()
- for activity in all_activities:
- activity_category = activity['name']
- if activity['category']:
- activity_category += "@%s" % activity['category']
- self.activities.append([activity['name'],
- activity['category'],
- activity_category])
-
-
- #now populate the menu - contains only categorized entries
- store = self.activity_list.get_model()
- store.clear()
-
- #populate fresh list from DB
- categorized_activities = runtime.storage.get_sorted_activities()
-
- for activity in categorized_activities:
- activity_category = activity['name']
- if activity['category']:
- activity_category += "@%s" % activity['category']
- item = store.append([activity['name'],
- activity['category'],
- activity_category])
-
- # finally add TODO tasks from evolution to both lists
- tasks = eds.get_eds_tasks()
- for activity in tasks:
- activity_category = "%s %s" % (activity['name'], activity['category'])
- self.activities.append([activity['name'],activity['category'],activity_category])
- store.append([activity['name'], activity['category'], activity_category])
-
- return True
def get_widget(self, name):
""" skip one variable (huh) """
@@ -245,7 +153,7 @@ class CustomFactController:
return None
def figure_description(self):
- activity = self.get_widget("activity_combo").child.get_text().decode("utf-8")
+ activity = self.new_name.get_text().decode("utf-8")
# juggle with description - break into parts and then put together
buf = self.get_widget('description').get_buffer()
@@ -264,7 +172,7 @@ class CustomFactController:
return description or inline_description
def on_save_button_clicked(self, button):
- activity = self.get_widget("activity_combo").child.get_text().decode("utf-8")
+ activity = self.new_name.get_text().decode("utf-8")
if not activity:
return False
@@ -312,7 +220,7 @@ class CustomFactController:
def on_cancel_clicked(self, button):
self.close_window()
- def on_activity_combo_changed(self, combo):
+ def on_new_name_changed(self, combo):
self.validate_fields()
def on_start_date_entered(self, widget):
@@ -336,7 +244,7 @@ class CustomFactController:
self.get_widget("end_date_label").set_text(some_date.strftime("%x"))
def validate_fields(self, widget = None):
- activity_text = self.get_widget("activity_combo").child.get_text()
+ activity_text = self.new_name.get_text()
start_time = self._get_datetime("start")
end_time = self._get_datetime("end")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]