Commit b3bf2964 authored by Daniel Garcia Moreno's avatar Daniel Garcia Moreno

Show comments in activity and current edit popup

parent d94cd97a
......@@ -27,6 +27,10 @@
<object class="GtkBox" id="edit-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
......@@ -41,39 +45,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkTextView" id="comments">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Comments about this activity</property>
<property name="left_margin">5</property>
<property name="right_margin">5</property>
<property name="top_margin">5</property>
<property name="bottom_margin">5</property>
<property name="input_hints">GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE</property>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Comments</property>
<property name="xalign">0</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
......@@ -190,5 +161,50 @@
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<style>
<class name="comments-frame"/>
</style>
<child>
<object class="GtkTextView" id="comments">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Comments about this activity</property>
<property name="left_margin">5</property>
<property name="right_margin">5</property>
<property name="top_margin">5</property>
<property name="bottom_margin">5</property>
<property name="input_hints">GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE</property>
<style>
<class name="comments"/>
</style>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Comments</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
</object>
</interface>
......@@ -541,6 +541,54 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<style>
<class name="comments-frame"/>
</style>
<child>
<object class="GtkTextView" id="current-comments">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Comments about this activity</property>
<property name="left_margin">5</property>
<property name="right_margin">5</property>
<property name="top_margin">5</property>
<property name="bottom_margin">5</property>
<property name="input_hints">GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE</property>
<style>
<class name="comments"/>
</style>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Comments</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="current-timer">
<property name="visible">True</property>
......@@ -553,7 +601,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
......
......@@ -18,3 +18,12 @@ list {
list row {
border-bottom: solid 1px alpha(currentColor,0.1);
}
.comments-frame {
border: 1px solid @borders;
}
.activity-comment {
padding: 6px;
font-size: small;
}
......@@ -52,6 +52,7 @@ class Activity(GObject.Object):
start: datetime = datetime.now()
stop: Optional[datetime] = None
id: Optional[int] = None
comments: Optional[str] = None
def __init__(self, name="activity", start=datetime.now(),
stop=None, id=None, comments=None):
......@@ -85,6 +86,7 @@ class ActivityWidget(Gtk.Box):
label = NotImplemented
time_label = NotImplemented
start_label = NotImplemented
comments = NotImplemented
activity = NotImplemented
activity_id = None
......@@ -115,8 +117,16 @@ class ActivityWidget(Gtk.Box):
box2.pack_start(self.start_label, True, True, 6)
self.comments = Gtk.Label(label=act.comments)
self.comments.set_xalign(0.0)
self.comments.set_line_wrap(True)
context = self.comments.get_style_context()
context.add_class("dim-label")
context.add_class("activity-comment")
self.pack_start(box2, False, False, 6)
self.add(box1)
self.add(self.comments)
self.show_all()
......
......@@ -130,6 +130,7 @@ class MainWindow(Gtk.ApplicationWindow):
self.current_minute = self.builder.get_object('current-minute')
self.current_day = self.builder.get_object('current-day')
self.current_timer = self.builder.get_object('current-timer')
self.current_comments = self.builder.get_object('current-comments')
self.current_name.bind_property('text', self.activity_label, 'label')
self.timer.bind_property('label', self.current_timer, 'label')
......@@ -138,6 +139,7 @@ class MainWindow(Gtk.ApplicationWindow):
self.current_hour.connect('changed', self.change_current)
self.current_minute.connect('changed', self.change_current)
self.current_day.connect('day-selected', self.change_current)
self.current_comments.get_buffer().connect('changed', self.change_current)
def create_report(self):
self.report_stack = self.builder.get_object('report-stack')
......@@ -550,9 +552,11 @@ class MainWindow(Gtk.ApplicationWindow):
self.current_name.set_text(activity.name)
self.current_hour.set_value(activity.start.hour)
self.current_minute.set_value(activity.start.minute)
self.current_day.year = activity.start.year
self.current_day.month = activity.start.month - 1
self.current_day.day = activity.start.day
self.current_day.select_month(activity.start.month - 1,
activity.start.year)
self.current_day.select_day(activity.start.day)
self.current_comments.get_buffer().set_text(activity.comments)
def change_current(self, *args, **kwargs):
if not self.activity_id or not self.start_date:
......@@ -561,6 +565,11 @@ class MainWindow(Gtk.ApplicationWindow):
new_date = self.current_day.get_date()
name = self.current_name.get_text()
comments_buf = self.current_comments.get_buffer()
comments_start = comments_buf.get_start_iter()
comments_end = comments_buf.get_end_iter()
comments = comments_buf.get_text(comments_start, comments_end, False)
self.start_date = datetime(new_date.year,
new_date.month + 1,
new_date.day,
......@@ -569,5 +578,7 @@ class MainWindow(Gtk.ApplicationWindow):
activity = Activity(id=self.activity_id,
name=name,
start=self.start_date, stop=None)
start=self.start_date,
stop=None,
comments=comments)
self.application.db.update(activity)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment