Commit 46516f8e authored by sumpfralle's avatar sumpfralle

open the log window when clicking at the status bar

fixed multiline output in status bar


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@929 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 35b8f97e
...@@ -4457,11 +4457,17 @@ Usually you will want to use the cutter radius here to cut around the outline.</ ...@@ -4457,11 +4457,17 @@ Usually you will want to use the cutter radius here to cut around the outline.</
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkEventBox" id="StatusBarEventBox">
<property name="visible">True</property>
<child> <child>
<object class="GtkStatusbar" id="StatusBar"> <object class="GtkStatusbar" id="StatusBar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Click to open the log window.</property>
<property name="spacing">2</property> <property name="spacing">2</property>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">3</property> <property name="position">3</property>
......
...@@ -357,6 +357,7 @@ class ProjectGui: ...@@ -357,6 +357,7 @@ class ProjectGui:
self.preferences_window.connect("delete-event", self.toggle_preferences_window, False) self.preferences_window.connect("delete-event", self.toggle_preferences_window, False)
self._preferences_window_position = None self._preferences_window_position = None
self._preferences_window_visible = False self._preferences_window_visible = False
self._log_window_position = None
# "about" window # "about" window
self.about_window = self.gui.get_object("AboutWindow") self.about_window = self.gui.get_object("AboutWindow")
self.about_window.set_version(VERSION) self.about_window.set_version(VERSION)
...@@ -956,6 +957,8 @@ class ProjectGui: ...@@ -956,6 +957,8 @@ class ProjectGui:
self.gui.get_object("AvailableCores").set_label(str(cpu_cores)) self.gui.get_object("AvailableCores").set_label(str(cpu_cores))
# status bar # status bar
self.status_bar = self.gui.get_object("StatusBar") self.status_bar = self.gui.get_object("StatusBar")
self.gui.get_object("StatusBarEventBox").connect("button-press-event",
self.toggle_log_window)
# menu bar # menu bar
uimanager = gtk.UIManager() uimanager = gtk.UIManager()
self._accel_group = uimanager.get_accel_group() self._accel_group = uimanager.get_accel_group()
...@@ -1926,14 +1929,20 @@ class ProjectGui: ...@@ -1926,14 +1929,20 @@ class ProjectGui:
def add_log_message(self, title, message, record=None): def add_log_message(self, title, message, record=None):
timestamp = datetime.datetime.fromtimestamp( timestamp = datetime.datetime.fromtimestamp(
record.created).strftime("%H:%M") record.created).strftime("%H:%M")
# avoid the ugly character for a linefeed
message = " ".join(message.splitlines())
try: try:
message = message.encode("utf-8") message = message.encode("utf-8")
except UnicodeDecodeError: except UnicodeDecodeError:
# remove all non-ascii characters # remove all non-ascii characters
message = "".join([char for char in message if ord(char) < 128]) clean_char = lambda c: (32 <= ord(c) < 128) and c or " "
message = "".join(map(clean_char, message))
self.log_model.append((timestamp, title, message)) self.log_model.append((timestamp, title, message))
# update the status bar (if the GTK interface is still active) # update the status bar (if the GTK interface is still active)
if not self.status_bar.window is None: if not self.status_bar.window is None:
# remove the last message from the stack (probably not necessary)
self.status_bar.pop(0)
# push the new message
try: try:
self.status_bar.push(0, message) self.status_bar.push(0, message)
except TypeError: except TypeError:
...@@ -1962,14 +1971,20 @@ class ProjectGui: ...@@ -1962,14 +1971,20 @@ class ProjectGui:
checkbox_state = toggle_log_checkbox.get_active() checkbox_state = toggle_log_checkbox.get_active()
if value is None: if value is None:
new_state = checkbox_state new_state = checkbox_state
elif isinstance(value, gtk.gdk.Event):
# someone clicked at the status bar -> toggle the window state
new_state = not checkbox_state
else: else:
if action is None: if action is None:
new_state = value new_state = value
else: else:
new_state = action new_state = action
if new_state: if new_state:
if self._log_window_position:
self.log_window.move(*self._log_window_position)
self.log_window.show() self.log_window.show()
else: else:
self._log_window_position = self.log_window.get_position()
self.log_window.hide() self.log_window.hide()
toggle_log_checkbox.set_active(new_state) toggle_log_checkbox.set_active(new_state)
# don't destroy the window with a "destroy" event # don't destroy the window with a "destroy" event
......
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