Skip to content

Commit

Permalink
release v0.1.2 - window resize improvements
Browse files Browse the repository at this point in the history
- fix resizing limitation by graph bug
- reload graph on window resize (still not perfect...)
- add GtkNotebook for comfort editor (placeholder for now)
  • Loading branch information
Yann Büchau committed Jan 9, 2017
1 parent 3e071a8 commit edd269e
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 104 deletions.
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
simbuto (0.1.2) unstable; urgency=medium

* implement comfort budget editor
* fix window shrink limitation to image size bug
* automatic graph reloading on window resize (still not perfect...)

-- Yann Büchau <[email protected]> Mon, 09 Jan 2017 19:50:44 +0100

simbuto (0.1.1) unstable; urgency=medium

* add command-line options (help, verbose, debug)
Expand Down
2 changes: 1 addition & 1 deletion usr/lib/simbuto/python/simbuto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Internal modules

# the version
VERSION = "0.1.1"
VERSION = "0.1.2"

__version__ = VERSION

Expand Down
76 changes: 69 additions & 7 deletions usr/lib/simbuto/python/simbuto/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datetime
import hashlib
import contextlib
import time

# external modules
import gi
Expand All @@ -24,7 +25,11 @@


class SimbutoGui(object):
""" class for the gui
"""
def __init__(self):
""" class constructor
"""
# initially set an empty configuration
self.set_config(configparser.ConfigParser())
# set up the quit signals
Expand Down Expand Up @@ -113,7 +118,7 @@ def budget_needs_saving(self):

@property
def current_editor_content(self):
textview = self("editor_textview")
textview = self("texteditor_textview")
tb = textview.get_buffer() # get the underlying buffer
start, end = tb.get_bounds()
content = tb.get_text(start, end, True)
Expand Down Expand Up @@ -178,6 +183,21 @@ def calendar_setting_in_progress(self):
def calendar_setting_in_progress(self, value):
self._calendar_setting_in_progress = bool(value)

@property
def last_window_size_allocate(self):
try:
return self._last_window_size_allocate
except AttributeError:
return 0

@last_window_size_allocate.setter
def last_window_size_allocate(self, value):
self._last_window_size_allocate = float(value)

@property
def window_resize_is_long_ago(self):
return self.last_window_size_allocate + 0.1 < time.time()

########################
### Context managers ###
########################
Expand Down Expand Up @@ -253,6 +273,7 @@ def setup_gui(self):
"UpdateGraphFromEditor": self.update_graph_from_editor,
"RegionDaySelected": self.region_day_selected,
"ResetDate": self.reset_dateregion,
"WindowResize": self.window_resize,
}
self.builder.connect_signals(self.handlers)

Expand Down Expand Up @@ -328,10 +349,17 @@ def setup_gui(self):
# editor
editorheading = self("editor_heading_label")
editorheading.set_text(_("Budget editor"))
editor_textview = self("editor_textview") # the tv
editor_textview = self("texteditor_textview") # the tv
monofont = Pango.FontDescription("monospace") # a monospace font
editor_textview.modify_font(monofont) # set the editor to monospace

# the notebook
self("comforteditor_placeholder_label").set_text(_("Comfort editor "
"coming soon!"))
self("editor_notebook_comforteditor_label").set_text(_("Comfort"))
self("editor_notebook_texteditor_label").set_text(_("Text"))
self("editor_notebook").next_page() # switch to "Text page"

# graph
plotheading = self("plot_heading_label")
plotheading.set_text(_("Budget graph"))
Expand All @@ -340,15 +368,17 @@ def setup_gui(self):
self.reset_statusbar() # initially reset statusbar

# calendar
# translate

# pretend the start date was selected and let automatic range selection
# do the rest
self("dateregion_expander_label").set_text(_("Date range"))
self("dateregion_start_calendar_label").set_text(_("start date"))
self("dateregion_end_calendar_label").set_text(_("end date"))
self.reset_dateregion() # reset dateregion

# the notebook
self("comforteditor_placeholder_label").set_text(_("Comfort editor "
"coming soon!"))

window.show_all()

def get_current_editor_content(self):
Expand All @@ -371,7 +401,7 @@ def update_window_title_filename(self):
def empty_editor(self):
self.logger.debug(_("emptying editor"))
# get the textview
textview = self("editor_textview")
textview = self("texteditor_textview")
textbuffer = textview.get_buffer() # get the underlying buffer
textbuffer.set_text("") # empty the text
self.currently_edited_file = None # no file edited currently
Expand All @@ -397,7 +427,8 @@ def update_statusbar(self, text = None):
statuslabel.set_text(newtext)

def update_graph_from_editor(self, *args):
rect = self("plot_image").get_allocation()
# rect = self("plot_image").get_allocation()
rect = self("plot_scrolledwindow").get_allocation()
width = rect.width
height = rect.height
try:
Expand Down Expand Up @@ -467,6 +498,12 @@ def region_day_selected(self,calendar):
# update the graph
self.update_graph_from_editor()

def window_resize(self,*args):
if self.window_resize_is_long_ago:
self.update_graph_from_editor()
self.last_window_size_allocate = time.time()


###############
### Dialogs ###
###############
Expand Down Expand Up @@ -600,7 +637,7 @@ def fill_editor_from_file(self, filename):
text = res[0]
if text is not None:
# get the textview
textview = self("editor_textview")
textview = self("texteditor_textview")
textbuffer = textview.get_buffer() # get the underlying buffer
textbuffer.set_text(text) # empty the text
self.logger.debug(_("editor was filled with contents of file '{}'"
Expand Down Expand Up @@ -635,3 +672,28 @@ def quit(self, *args):
self.wanttosave_dialog()
self.mainloop.quit()


class BudgetFactEditor(Gtk.Box):
""" The budget facts editor
"""
def __init__(self):
# run the Gtk.Box constructor
super().__init__(
orientation = Gtk.Orientation.HORIZONTAL, # orientation
spacing = 5, # spacing
)

##################
### Properties ###
##################


class SingleBudgetFactEditor(Gtk.Box):
""" the editor for a single budget fact
"""
def __init__(self):
# run the Gtk.Box constructor
super().__init__(
orientation = Gtk.Orientation.HORIZONTAL, # orientation
spacing = 5, # spacing
)
95 changes: 78 additions & 17 deletions usr/share/simbuto/gui/simbuto.glade
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<accel-groups>
<group name="window_accelgroup"/>
</accel-groups>
<signal name="configure-event" handler="WindowResize" swapped="no"/>
<signal name="delete-event" handler="CloseWindow" swapped="no"/>
<child>
<object class="GtkBox" id="main_vbox">
Expand Down Expand Up @@ -298,26 +299,71 @@
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="editor_scrolledwindow">
<property name="width_request">400</property>
<property name="height_request">300</property>
<object class="GtkNotebook" id="editor_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">external</property>
<property name="shadow_type">in</property>
<property name="min_content_width">500</property>
<property name="min_content_height">300</property>
<property name="show_border">False</property>
<child>
<object class="GtkTextView" id="editor_textview">
<object class="GtkLabel" id="comforteditor_placeholder_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="tab_expand">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="editor_notebook_comforteditor_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Comfort</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="texteditor_scrolledwindow">
<property name="width_request">350</property>
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="pixels_above_lines">5</property>
<property name="pixels_below_lines">5</property>
<property name="wrap_mode">word-char</property>
<property name="left_margin">3</property>
<property name="right_margin">5</property>
<property name="accepts_tab">False</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="hscrollbar_policy">external</property>
<property name="shadow_type">in</property>
<property name="min_content_width">500</property>
<property name="min_content_height">300</property>
<child>
<object class="GtkTextView" id="texteditor_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="pixels_above_lines">5</property>
<property name="pixels_below_lines">5</property>
<property name="wrap_mode">word-char</property>
<property name="left_margin">3</property>
<property name="right_margin">5</property>
<property name="accepts_tab">False</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
<property name="tab_expand">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="editor_notebook_texteditor_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Text</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
Expand Down Expand Up @@ -496,12 +542,27 @@
</packing>
</child>
<child>
<object class="GtkImage" id="plot_image">
<object class="GtkScrolledWindow" id="plot_scrolledwindow">
<property name="width_request">300</property>
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">external</property>
<property name="vscrollbar_policy">external</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport" id="plot_viewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="plot_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
Expand Down
Loading

0 comments on commit edd269e

Please sign in to comment.