added preliminary multimonitor support

This commit is contained in:
Maxim Stewart 2020-03-29 21:03:17 -05:00
parent 3436dd09ee
commit e351d27ec5
5 changed files with 483 additions and 16 deletions

Binary file not shown.

View File

@ -27,7 +27,33 @@ class Main:
builder = gtk.Builder()
settings = Settings()
settings.attachBuilder(builder)
self.connectBuilder(settings, builder)
window = settings.createWindow()
window.fullscreen()
window.show()
monitors = settings.returnMonitorsInfo()
i = 1
if len(monitors) > 1:
for mon in monitors[1:]:
subBuilder = gtk.Builder()
subSettings = Settings(i)
subSettings.attachBuilder(subBuilder)
self.connectBuilder(subSettings, subBuilder)
win = subSettings.createWindow()
win.set_default_size(mon.width, mon.height)
win.set_size_request(mon.width, mon.height)
win.set_resizable(False)
win.move(mon.x, mon.y)
win.show()
i += 1
def connectBuilder(self, settings, builder):
# Gets the methods from the classes and sets to handler.
# Then, builder connects to any signals it needs.
classes = [CrossClassSignals(settings),
@ -40,9 +66,6 @@ class Main:
handlers.update(methods)
builder.connect_signals(handlers)
window = settings.createWindow()
window.fullscreen()
window.show_all()
if __name__ == "__main__":

View File

@ -0,0 +1,436 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkFileFilter" id="Folders">
<mime-types>
<mime-type>inode/directory</mime-type>
</mime-types>
</object>
<object class="GtkWindow" id="Window">
<property name="can_focus">False</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<property name="type_hint">desktop</property>
<property name="decorated">False</property>
<property name="gravity">center</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="width_request">256</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="center">
<object class="GtkFileChooserButton" id="selectDirDialog">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="action">select-folder</property>
<property name="filter">Folders</property>
<property name="title" translatable="yes">Directory Chooser</property>
<signal name="file-set" handler="setNewDirectory" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="taskBarWorkspacesVer">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkIconView" id="Desktop">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin">6</property>
<property name="selection_mode">multiple</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="width_request">180</property>
<property name="height_request">64</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="max_content_width">225</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="taskBarButtonsVer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkScrolledWindow">
<property name="height_request">64</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="taskBarButtonsHor">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="taskBarWorkspacesHor">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="createImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-new</property>
</object>
<object class="GtkImage" id="trashImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">icons/trash.png</property>
</object>
<object class="GtkWindow" id="iconControlsWindow">
<property name="can_focus">False</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">splashscreen</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="decorated">False</property>
<property name="deletable">False</property>
<property name="gravity">center</property>
<signal name="focus-out-event" handler="closePopup" swapped="no"/>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="width_request">500</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkEntry" id="filenameInput">
<property name="width_request">500</property>
<property name="height_request">26</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_stock">gtk-edit</property>
<signal name="key-release-event" handler="rename" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="iconsButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Copy...</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="copy" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Cut...</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="cut" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child type="center">
<object class="GtkButton">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Delete...</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="delete" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Trash</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Move to Trash...</property>
<property name="image">trashImage</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="trash" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="menuButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">15</property>
<property name="label" translatable="yes">Folder</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">15</property>
<property name="label" translatable="yes">File</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="createSwitch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">File/Folder</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Create</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Create File/Folder...</property>
<property name="image">createImage</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="create" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Paste...</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="paste" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -27,21 +27,24 @@ class TaskbarSignals:
def setPagerWidget(self):
pager = wnck.Pager()
pager.set_orientation(self.orientation)
if self.orientation == 0:
self.builder.get_object('taskBarWorkspacesHor').add(pager)
else:
self.builder.get_object('taskBarWorkspacesVer').add(pager)
pager.show()
def setTasklistWidget(self):
barBtns = wnck.Tasklist()
barBtns.set_scroll_enabled(False)
barBtns.set_button_relief(2) # 0 = normal relief, 2 = no relief
barBtns.set_grouping(1) # 0 = mever group, 1 auto group, 2 = always group
tasklist = wnck.Tasklist()
tasklist.set_scroll_enabled(False)
tasklist.set_button_relief(2) # 0 = normal relief, 2 = no relief
tasklist.set_grouping(1) # 0 = mever group, 1 auto group, 2 = always group
barBtns.set_orientation(self.orientation)
tasklist.set_orientation(self.orientation)
if self.orientation == 0:
self.builder.get_object('taskBarButtonsHor').add(barBtns)
self.builder.get_object('taskBarButtonsHor').add(tasklist)
else:
self.builder.get_object('taskBarButtonsVer').add(barBtns)
self.builder.get_object('taskBarButtonsVer').add(tasklist)
tasklist.show()

View File

@ -13,7 +13,7 @@ import os, json
class Settings:
def __init__(self):
def __init__(self, monIndex = 0):
self.builder = None
# 'Filters'
@ -33,6 +33,7 @@ class Settings:
self.iconContainerWxH = [128, 128]
self.systemIconImageWxH = [56, 56]
self.viIconWxH = [256, 128]
self.monitors = None
self.DEFAULTCOLOR = gdk.RGBA(0.0, 0.0, 0.0, 0.0) # ~#00000000
self.MOUSEOVERCOLOR = gdk.RGBA(0.0, 0.9, 1.0, 0.64) # ~#00e8ff
@ -53,7 +54,7 @@ class Settings:
self.GTK_ORIENTATION = 1 # HORIZONTAL (0) VERTICAL (1)
configFolder = os.path.expanduser('~') + "/.config/pytop/"
self.configFile = configFolder + "settings.ini"
self.configFile = configFolder + "mon_" + str(monIndex) + "_settings.ini"
if os.path.isdir(configFolder) == False:
os.mkdir(configFolder)
@ -98,8 +99,8 @@ class Settings:
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
window.set_app_paintable(True)
monitors = self.getMonitorData(screen)
window.resize(monitors[0].width, monitors[0].height)
self.monitors = self.getMonitorData(screen)
window.resize(self.monitors[0].width, self.monitors[0].height)
def getMonitorData(self, screen):
monitors = []
@ -107,7 +108,7 @@ class Settings:
monitors.append(screen.get_monitor_geometry(m))
for monitor in monitors:
print(str(monitor.width) + "x" + str(monitor.height) + "+" + str(monitor.x) + "+" + str(monitor.y))
print(str(monitor.width) + "+" + str(monitor.height) + "+" + str(monitor.x) + "+" + str(monitor.y))
return monitors
@ -124,6 +125,10 @@ class Settings:
json.dump(data, outfile)
def returnMonitorsInfo(self):
return self.monitors
def returnSettings(self):
returnData = []