Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More settings

Change-Id: I5fcf99840d34077a6cd6b2731c62f1a5b0c6f3fa
  • Loading branch information...
commit fb59e8423cae6090d0cdd849b554915051e7bc37 1 parent 93c7335
@tomasz-wiszkowski authored
View
2  src/elements/xfcon_notebook.py
@@ -46,7 +46,7 @@ def __xfcon_page_signals(self):
def __init__(self):
super(self.__class__, self).__init__()
- self.settings = XfConSettings()
+ self.settings = XfConSettings.Instance()
self.add_tab_image = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_SMALL_TOOLBAR)
self.add_tab_page = gtk.Label("*")
self.add_tab_page.show()
View
43 src/elements/xfcon_settings.py
@@ -95,27 +95,44 @@ class XfConSettings(gobject.GObject):
"<Control><Shift>v",
gobject.PARAM_READWRITE),
- 'window-height': (gobject.TYPE_UINT,
- _("Window height."),
- _("Percentage of screen occupied by window."),
- 10, 100, 80,
- gobject.PARAM_READWRITE),
-
+ # Resolved
'window-follows-mouse': (gobject.TYPE_BOOLEAN,
_("Define if window should be open on same monitor as mouse."),
_("True, if window should be opened on same monitor as mouse."),
False,
gobject.PARAM_READWRITE),
+
+ 'window-width': (gobject.TYPE_UINT,
+ _("Window width."),
+ _("Percentage of screen occupied by window."),
+ 20, 100, 100,
+ gobject.PARAM_READWRITE),
+
+ 'window-height': (gobject.TYPE_UINT,
+ _("Window height."),
+ _("Percentage of screen occupied by window."),
+ 20, 100, 80,
+ gobject.PARAM_READWRITE),
}
__properties__ = {}
+ __instance__ = None
def __init__(self):
super(XfConSettings, self).__init__()
+ if (XfConSettings.__instance__):
+ raise RuntimeError("Settings already instantiated")
+ XfConSettings.__instance__ = self
if (self.__properties__ == {}):
for prop in gobject.list_properties(XfConSettings):
self.__properties__[prop.name] = prop.default_value
+ @classmethod
+ def Instance(cls):
+ if not XfConSettings.__instance__:
+ XfConSettings()
+ return XfConSettings.__instance__
+
def do_get_property(self, name):
return self.__properties__[name.name]
@@ -128,3 +145,17 @@ def set_window_follows_mouse(self, status):
def get_window_follows_mouse(self):
return self.get_property("window-follows-mouse")
+ def set_window_width(self, value):
+ self.set_property("window-width", int(value))
+
+ def get_window_width(self):
+ return self.get_property("window-width")
+
+ def set_window_height(self, value):
+ self.set_property("window-height", int(value))
+
+ def get_window_height(self):
+ return self.get_property("window-height")
+
+gobject.type_register(XfConSettings)
+
View
25 src/elements/xfcon_window.py
@@ -34,7 +34,7 @@ def __init__(self):
XfConDialog.init(self)
- self.settings = XfConSettings()
+ self.settings = XfConSettings.Instance()
self.activate()
self.set_decorated(False)
@@ -98,7 +98,8 @@ def __import_plugins(self):
self.default_plugin = plugin
def __bind_config(self):
- self.settings.connect('notify::window-height', self.__config_set_window_height)
+ self.settings.connect('notify::window-height', self.__config_set_window_size)
+ self.settings.connect('notify::window-width', self.__config_set_window_size)
self.notebook.connect(XfConNotebook.XFCON_SIGNAL_BUILD_DEFAULT_VIEW, self.__on_tab_add)
def __bind_keys(self):
@@ -114,12 +115,15 @@ def __bind_keys(self):
self.__on_accel_show_hide) ])
def __apply_config(self):
- self.__config_set_window_height()
+ self.__config_set_window_size()
- def __config_set_window_height(self, *ignore):
+ def __config_set_window_size(self, *ignore):
rect = self.__calculate_window_size()
self.move(rect.x, rect.y)
- self.resize(rect.width, rect.height)
+ self.set_geometry_hints(self,
+ min_width = rect.width, min_height = rect.height,
+ max_width = rect.width, max_height = rect.height,
+ base_width = rect.width, base_height = rect.height)
def __on_tab_add(self, *ignore):
return self.__do_create_default_view()
@@ -180,6 +184,7 @@ def __on_menu_hide(self, *args):
def __calculate_window_size(self):
screen = self.get_screen()
height = self.settings.get_property('window-height')
+ width = self.settings.get_property('window-width')
if self.settings.get_window_follows_mouse():
root = display.Display().screen().root.query_pointer()._data
root_x = root['root_x']
@@ -188,6 +193,9 @@ def __calculate_window_size(self):
else:
rect = screen.get_monitor_geometry(screen.get_primary_monitor())
rect.height = rect.height * height / 100
+ width = rect.width * width / 100
+ rect.x = (rect.width - width) / 2
+ rect.width = width
return rect
def __on_accel_show_hide(self, *args):
@@ -249,13 +257,8 @@ def show(self):
# to respect panels position once shown. we don't want this, although it would
# be nice to expose panels later
# http://stackoverflow.com/questions/502282
- rect = self.__calculate_window_size()
+ self.__config_set_window_size()
self.show_all()
- self.move(rect.x, rect.y)
- self.set_geometry_hints(self,
- min_width = rect.width, min_height = rect.height,
- max_width = rect.width, max_height = rect.height,
- base_width = rect.width, base_height = rect.height)
self.restore_focus()
def hide(self):
View
78 src/plugins/preferences/view.py
@@ -17,35 +17,81 @@
from elements.xfcon_object import XfConObject
from elements.xfcon_settings import XfConSettings
-class PreferencesView(gtk.HBox, XfConObject):
+class PreferencesView(gtk.Frame, XfConObject):
__signals__ = XfConObject.XfConSignals()
def __init__(self):
- super(PreferencesView, self).__init__(True, True)
- self.settings = XfConSettings()
+ super(PreferencesView, self).__init__(_("Preferences"))
+ self.settings = XfConSettings.Instance()
self.screen_group = self.__create_screen_settings()
- self.pack_start(self.screen_group)
- self.label = gtk.Label()
- self.label.set_label("Settings")
- self.pack_start(self.label)
- self.label.show()
+ self.main_box = gtk.Alignment(0.5, 0.5)
+ self.main_box.add(self.screen_group)
+ self.main_box.show()
+ self.add(self.main_box)
self.show()
def __create_screen_settings(self):
- frame = gtk.Frame("Screen / Monitor settings")
- frame.show()
- container = gtk.VBox(True, True)
- container.show()
- frame.add(container)
- follow_mouse = gtk.CheckButton("Follow Mouse", False)
- follow_mouse.show()
+ # Where to open view
+ follow_mouse = gtk.CheckButton()
follow_mouse.set_active(self.settings.get_window_follows_mouse())
follow_mouse.connect("toggled", self.__change_follow_mouse)
- container.pack_start(follow_mouse, False, False)
+ follow_mouse.show()
+ follow_mouse_label = gtk.Label(_("Open on same monitor as mouse"))
+ follow_mouse_label.set_alignment(0.0, 0.5)
+ follow_mouse_label.show()
+
+ # Width of the window
+ window_width = gtk.SpinButton()
+ window_width.set_range(20, 100)
+ window_width.set_increments(5, 20)
+ window_width.set_value(self.settings.get_window_width())
+ window_width.connect("value-changed", self.__change_window_width)
+ window_width.show()
+ window_width_label = gtk.Label(_("Window Width (% of monitor width)"))
+ window_width_label.set_alignment(0.0, 0.5)
+ window_width_label.show()
+
+ # Height of the window
+ window_height = gtk.SpinButton()
+ window_height.set_range(20, 100)
+ window_height.set_increments(5, 20)
+ window_height.set_value(self.settings.get_window_height())
+ window_height.connect("value-changed", self.__change_window_height)
+ window_height.show()
+ window_height_label = gtk.Label(_("Window Height (% of monitor height)"))
+ window_height_label.set_alignment(0.0, 0.5)
+ window_height_label.show()
+
+ # Put it together
+ container = gtk.Table(1, 2)
+ container.set_row_spacings(20)
+ container.set_col_spacings(20)
+ container.set_border_width(20)
+ row = 0
+ container.attach(follow_mouse, 0, 1, row, row + 1, 0, 0)
+ container.attach(follow_mouse_label, 1, 2, row, row + 1)
+ row += 1
+ container.attach(window_width, 0, 1, row, row + 1, 0, 0)
+ container.attach(window_width_label, 1, 2, row, row + 1)
+ row += 1
+ container.attach(window_height, 0, 1, row, row + 1, 0, 0)
+ container.attach(window_height_label, 1, 2, row, row + 1)
+ row += 1
+ container.show()
+
+ frame = gtk.Frame(_("Screen"))
+ frame.show()
+ frame.add(container)
return frame
def __change_follow_mouse(self, box, *args):
self.settings.set_window_follows_mouse(box.get_active())
+ def __change_window_width(self, spinner, *args):
+ self.settings.set_window_width(spinner.get_value())
+
+ def __change_window_height(self, spinner, *args):
+ self.settings.set_window_height(spinner.get_value())
+
View
3  src/plugins/terminal/settings.py
@@ -18,7 +18,7 @@
import vte
from elements.xfcon_settings import XfConSettings
-class XfTermSettings(XfConSettings):
+class XfTermSettings(gobject.GObject):
__gproperties__ = {
'term-show-scrollbar': (gobject.TYPE_BOOLEAN,
_("Sets visibility of scroll bar."),
@@ -113,3 +113,4 @@ def do_set_property(self, name, value):
else:
super(XfTermSettings, self).do_set_property(name, value)
+gobject.type_register(XfTermSettings)
View
37 src/plugins/terminal/xfcon_terminal.py
@@ -38,7 +38,8 @@ class XfConTerminal(gtk.HBox, XfConObject):
def __init__(self, directory=None, command=None):
super(XfConTerminal, self).__init__()
- self.settings = XfTermSettings()
+ self.term_settings = XfTermSettings()
+ self.settings = XfConSettings.Instance()
self.match_valid = False
self.match_pair = None
@@ -65,17 +66,17 @@ def __init__(self, directory=None, command=None):
self.show()
def __bind_config(self):
- self.settings.connect('notify::term-scroll-on-output',
+ self.term_settings.connect('notify::term-scroll-on-output',
self.__config_set_scroll)
- self.settings.connect('notify::term-scroll-on-keypress',
+ self.term_settings.connect('notify::term-scroll-on-keypress',
self.__config_set_scroll)
- self.settings.connect('notify::term-scroll-history-size',
+ self.term_settings.connect('notify::term-scroll-history-size',
self.__config_set_scroll)
- self.settings.connect('notify::term-scroll-visible',
+ self.term_settings.connect('notify::term-scroll-visible',
self.__config_set_scroll)
- self.settings.connect('notify::term-emulator-font',
+ self.term_settings.connect('notify::term-emulator-font',
self.__config_set_font_style)
- self.settings.connect('notify::term-emulator-opacity',
+ self.term_settings.connect('notify::term-emulator-opacity',
self.__config_set_background_transparency)
def __bind_signals(self):
@@ -118,22 +119,22 @@ def __apply_config(self, *ignore):
def __config_set_font_style(self, *ignore):
font = FontDescription(
- self.settings.get_property('term-emulator-font'))
+ self.term_settings.get_property('term-emulator-font'))
self.terminal.set_font(font)
def __config_set_background_transparency(self, *ignore):
- transparency = self.settings.get_property('term-emulator-opacity')
+ transparency = self.term_settings.get_property('term-emulator-opacity')
self.terminal.set_opacity(int(transparency * 65535))
def __config_set_scroll(self, *ignore):
self.terminal.set_scroll_on_output(
- self.settings.get_property('term-scroll-on-output'))
+ self.term_settings.get_property('term-scroll-on-output'))
self.terminal.set_scroll_on_keystroke(
- self.settings.get_property('term-scroll-on-keypress'))
+ self.term_settings.get_property('term-scroll-on-keypress'))
self.terminal.set_scrollback_lines(
- self.settings.get_property('term-scroll-history-size'))
+ self.term_settings.get_property('term-scroll-history-size'))
self.scrollbar.set_visible(
- self.settings.get_property('term-scroll-visible'))
+ self.term_settings.get_property('term-scroll-visible'))
def __config_set_keybindings(self, *ignore):
self.terminal.set_backspace_binding(vte.ERASE_AUTO)
@@ -229,12 +230,12 @@ def grab_focus(self):
def __get_fork_params(self, params=None):
if params['command'] is None:
params['command'] = os.environ['SHELL']
- if self.settings.get_property('term-shell-login'):
+ if self.term_settings.get_property('term-shell-login'):
params['loglastlog'] = True
params['argv'] = ['-xv']
if params['directory'] is None:
- if self.settings.get_property('term-share-cwd'):
+ if self.term_settings.get_property('term-share-cwd'):
params['directory'] = XfConTerminal.class_last_path
else:
params['directory'] = "~"
@@ -254,11 +255,11 @@ def __delete_shell(self, pid):
def __configure_terminal(self):
self.terminal.set_word_chars(
- self.settings.get_property('term-emulator-word-chars'))
+ self.term_settings.get_property('term-emulator-word-chars'))
self.terminal.set_audible_bell(
- self.settings.get_property('term-emulator-bell-audible'))
+ self.term_settings.get_property('term-emulator-bell-audible'))
self.terminal.set_visible_bell(
- self.settings.get_property('term-emulator-bell-visual'))
+ self.term_settings.get_property('term-emulator-bell-visual'))
self.terminal.set_sensitive(True)
self.terminal.set_flags(gtk.CAN_DEFAULT)
self.terminal.set_flags(gtk.CAN_FOCUS)
Please sign in to comment.
Something went wrong with that request. Please try again.