Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to swap pane position (put edit pane above output) #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions dreampielib/data/dreampie.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,21 @@ You can also set the __expects_str__ attribute of a function to True to achieve
<property name="position">5</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="swap_panes_chk">
<property name="label" translatable="yes">Swap panes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5.5</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="leave_code_chk">
<property name="label" translatable="yes">Leave code in the code box after execution</property>
Expand Down Expand Up @@ -1967,6 +1982,17 @@ You can also set the __expects_str__ attribute of a function to True to achieve
<accelerator key="F6" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem_unclog">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Try to unclog a stuck subprocess. Use with care!</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Unclog subprocess</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_unclog_subprocess"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem_clear_reshist">
<property name="visible">True</property>
Expand Down
50 changes: 42 additions & 8 deletions dreampielib/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ def __init__(self, pyexec, runfile):
# A tuple (page_num, text) of the recently closed tab
self.reopen_tab_data = None

# last (font, vertical_layout) configured. If they are changed,
# configure() will resize the window and place the paned.
self.last_configured_layout = (None, None)
self.configure()

self.output = Output(self.textview)

self.folding = Folding(self.textbuffer, LINE_LEN)
Expand Down Expand Up @@ -213,6 +208,14 @@ def __init__(self, pyexec, runfile):
self.complete_dict_keys,
INDENT_WIDTH)

# had to move this down below autocomplete in order to allow configuration of autocomplete popup direction

# last (font, vertical_layout) configured. If they are changed,
# configure() will resize the window and place the paned.
self.last_configured_layout = (None, None)
self.configure()


# Hack: we connect this signal here, so that it will have lower
# priority than the key-press event of autocomplete, when active.
self.sourceview_keypress_handler = self.sourceview.connect(
Expand Down Expand Up @@ -961,6 +964,16 @@ def on_interrupt(self, _widget):
_("A command isn't being executed currently"))
beep()

def on_unclog_subprocess(self, _widget):
# It seems that sometimes DreamPie thinks there is an unclaimed
# result when there really isn't. Here we try to clear the clog by
# decrementing the unclaimed result counter. This could blow up
# badly if used at the wrong time, so should only be used when it
# really seems like DreamPie thinks the subprocess is busy but it
# really isn't.
self._n_unclaimed_results -= 1


# History persistence

def on_save_history(self, _widget):
Expand Down Expand Up @@ -1266,9 +1279,13 @@ def configure(self):
tags.apply_theme_source(sv.get_buffer(), theme)

vertical_layout = self.config.get_bool('vertical-layout')
swap_panes = self.config.get_bool('swap-panes')
if vertical_layout:
pane = self.vpaned_main; other_pane = self.hpaned_main
self.notebook.props.tab_pos = gtk.POS_BOTTOM
if swap_panes:
self.notebook.props.tab_pos = gtk.POS_TOP
else:
self.notebook.props.tab_pos = gtk.POS_BOTTOM
else:
pane = self.hpaned_main; other_pane = self.vpaned_main
self.notebook.props.tab_pos = gtk.POS_TOP
Expand All @@ -1277,9 +1294,26 @@ def configure(self):
if pane.get_child1() is None:
child1 = other_pane.get_child1(); other_pane.remove(child1)
child2 = other_pane.get_child2(); other_pane.remove(child2)
pane.pack1(child1, resize=True, shrink=False)
pane.pack2(child2, resize=not vertical_layout, shrink=False)
else:
child1 = pane.get_child1(); pane.remove(child1)
child2 = pane.get_child2(); pane.remove(child2)

if child1.get_name() == 'scrolledwindow_textview':
editPane, outputPane = child1, child2
else:
editPane, outputPane = child2, child1

if swap_panes:
pane.pack1(outputPane, resize=not vertical_layout, shrink=False)
pane.pack2(editPane, resize=True, shrink=False)
else:
pane.pack1(editPane, resize=True, shrink=False)
pane.pack2(outputPane, resize=not vertical_layout, shrink=False)

# if panes are swapped, the autocomplete window should pop up BELOW cursor
# (otherwise it will extend up off the screen)
self.autocomplete.window.align = "top" if swap_panes else "bottom"

# If the fonts were changed, we might need to enlarge the window
last_font, last_vertical = self.last_configured_layout
if last_font != font or last_vertical != vertical_layout:
Expand Down
9 changes: 8 additions & 1 deletion dreampielib/gui/autocomplete_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,14 @@ def place_window(self):
self.window.show_all()
self.window_height = self.window.get_size()[1]
self.window.hide()
self.window.move(x, y-self.window_height)
#self.window.move(x, y-self.window_height)
# If panes are swapped, the TOP of the autocomplete will align with cursor; if not, the BOTTOM will align
# This prevents the window from extending off the screen.
if self.align == "bottom":
offset = -self.window_height
else:
offset = sv.get_line_yrange(it)[1]
self.window.move(x, y+offset)

def on_mark_set(self, sb, it, mark):
if mark is sb.get_insert():
Expand Down
1 change: 1 addition & 0 deletions dreampielib/gui/call_tip_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, sourceview, sv_changed):

# Widgets
self.textview = tv = gtk.TextView()
tv.set_wrap_mode(gtk.WRAP_WORD)
self.hscrollbar = hs = gtk.HScrollbar()
self.vscrollbar = vs = gtk.VScrollbar()
self.resizegrip = rg = gtk.EventBox()
Expand Down
1 change: 1 addition & 0 deletions dreampielib/gui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
recall-1-char-commands = False
hide-defs = False
leave-code = False
swap-panes = False

[Dark theme]
is-active = True
Expand Down
4 changes: 4 additions & 0 deletions dreampielib/gui/config_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def __init__(self, config, gladefile, parent):
self.horizontal_layout_rad.props.active = not config.get_bool('vertical-layout')

self.leave_code_chk.props.active = config.get_bool('leave-code')

self.swap_panes_chk.props.active = config.get_bool('swap-panes')

self.hide_defs_chk.props.active = config.get_bool('hide-defs')

Expand Down Expand Up @@ -156,6 +158,8 @@ def run(self):

config.set_bool('leave-code', self.leave_code_chk.props.active)

config.set_bool('swap-panes', self.swap_panes_chk.props.active)

config.set_bool('hide-defs', self.hide_defs_chk.props.active)

if self.matplotlib_ia_switch_rad.props.active:
Expand Down