Permalink
Browse files

Follow mouse preference. WIP

Change-Id: I4d0a63fdeea4d1fa1fac5b1b85a668d5362c20d4
  • Loading branch information...
1 parent 0dc7fb4 commit 93c7335c969b70ac706f201d4a044269429d8a3c @tomasz-wiszkowski committed Jan 10, 2013
Showing with 47 additions and 5 deletions.
  1. +15 −2 src/elements/xfcon_settings.py
  2. +9 −1 src/elements/xfcon_window.py
  3. +23 −2 src/plugins/preferences/view.py
@@ -100,18 +100,31 @@ class XfConSettings(gobject.GObject):
_("Percentage of screen occupied by window."),
10, 100, 80,
gobject.PARAM_READWRITE),
+
+ '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),
}
__properties__ = {}
def __init__(self):
super(XfConSettings, self).__init__()
- for prop in gobject.list_properties(XfConSettings):
- self.__properties__[prop.name] = prop.default_value
+ if (self.__properties__ == {}):
+ for prop in gobject.list_properties(XfConSettings):
+ self.__properties__[prop.name] = prop.default_value
def do_get_property(self, name):
return self.__properties__[name.name]
def do_set_property(self, name, value):
self.__properties__[name.name] = value
+ def set_window_follows_mouse(self, status):
+ self.set_property("window-follows-mouse", status)
+
+ def get_window_follows_mouse(self):
+ return self.get_property("window-follows-mouse")
+
@@ -18,6 +18,8 @@
import pygtk
import pynotify
+from Xlib import display
+
from elements.xfcon_dialogs import XfConDialog
from elements.xfcon_globals import PLUGINS_DIR, APPNAME
from elements.xfcon_notebook import XfConNotebook
@@ -178,7 +180,13 @@ def __on_menu_hide(self, *args):
def __calculate_window_size(self):
screen = self.get_screen()
height = self.settings.get_property('window-height')
- rect = screen.get_monitor_geometry(screen.get_primary_monitor())
+ if self.settings.get_window_follows_mouse():
+ root = display.Display().screen().root.query_pointer()._data
+ root_x = root['root_x']
+ root_y = root['root_y']
+ rect = screen.get_monitor_geometry(screen.get_monitor_at_point(root_x, root_y))
+ else:
+ rect = screen.get_monitor_geometry(screen.get_primary_monitor())
rect.height = rect.height * height / 100
return rect
@@ -1,4 +1,3 @@
-#
# Copyright 2012 Tomasz Wiszkowski
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,37 @@
import gobject
import gtk
from elements.xfcon_object import XfConObject
+from elements.xfcon_settings import XfConSettings
class PreferencesView(gtk.HBox, XfConObject):
__signals__ = XfConObject.XfConSignals()
def __init__(self):
super(PreferencesView, self).__init__(True, True)
+ self.settings = XfConSettings()
+
+ self.screen_group = self.__create_screen_settings()
+ self.pack_start(self.screen_group)
self.label = gtk.Label()
- self.label.set_label("Settings");
+ self.label.set_label("Settings")
self.pack_start(self.label)
self.label.show()
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()
+ 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)
+ return frame
+
+ def __change_follow_mouse(self, box, *args):
+ self.settings.set_window_follows_mouse(box.get_active())
+

0 comments on commit 93c7335

Please sign in to comment.