Initial commit...
This commit is contained in:
parent
f22acb1d82
commit
2a93b0e404
10
README.md
10
README.md
@ -1,2 +1,12 @@
|
||||
# Cornea
|
||||
Cornea is a Python + Gtk application to take screenshots.
|
||||
|
||||
# Notes
|
||||
* Need python 2+
|
||||
* ```sudo apt-get install python3```
|
||||
|
||||
# Images
|
||||
![1 Cornera interface. ](images/pic1.png)
|
||||
|
||||
# TODO
|
||||
* Create OCR feature...
|
||||
|
11
cornea.desktop
Executable file
11
cornea.desktop
Executable file
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Name=Cornea
|
||||
GenericName=A python screenshot application.
|
||||
Comment=Take screenshots of your desktop.
|
||||
Exec=<your_path>/screenshot
|
||||
Icon=<your_path>/resources/cornea.png
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
Categories=Utility;
|
||||
MimeType=text/plain;
|
||||
Terminal=false
|
BIN
images/pic1.png
Normal file
BIN
images/pic1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
6
requirements.txt
Normal file
6
requirements.txt
Normal file
@ -0,0 +1,6 @@
|
||||
EasyProcess==0.2.7
|
||||
Pillow==6.1.0
|
||||
pycairo==1.18.1
|
||||
PyGObject==3.34.0
|
||||
pyscreenshot==0.5.1
|
||||
setproctitle==1.1.10
|
53
src/__main__.py
Executable file
53
src/__main__.py
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Gtk imports
|
||||
import gi, faulthandler, signal
|
||||
gi.require_version('Gtk', '3.0')
|
||||
|
||||
from gi.repository import Gtk as gtk
|
||||
from gi.repository import Gdk as gdk
|
||||
from gi.repository import GLib
|
||||
|
||||
# Python imports
|
||||
import inspect
|
||||
|
||||
from setproctitle import setproctitle
|
||||
|
||||
# Application imports
|
||||
from utils import Settings, CrossClassSignals
|
||||
from signal_classes import MainWindow, DrawingArea, MainMenuPopup
|
||||
|
||||
|
||||
class Main:
|
||||
def __init__(self):
|
||||
setproctitle('Cornea')
|
||||
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit)
|
||||
faulthandler.enable() # For better debug info
|
||||
|
||||
settings = Settings()
|
||||
builder = settings.returnBuilder()
|
||||
|
||||
# Gets the methods from the classes and sets to handler.
|
||||
# Then, builder connects to any signals it needs.
|
||||
utilsClass = CrossClassSignals(settings)
|
||||
classes = [MainWindow(settings, utilsClass),
|
||||
DrawingArea(settings, utilsClass),
|
||||
MainMenuPopup(settings, utilsClass)]
|
||||
|
||||
handlers = {}
|
||||
for c in classes:
|
||||
methods = inspect.getmembers(c, predicate=inspect.ismethod)
|
||||
handlers.update(methods)
|
||||
|
||||
builder.connect_signals(handlers)
|
||||
window = settings.createWindow()
|
||||
window.show()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main = Main()
|
||||
gtk.main()
|
||||
except Exception as e:
|
||||
print( repr(e) )
|
544
src/resources/Main_Window.glade
Normal file
544
src/resources/Main_Window.glade
Normal file
@ -0,0 +1,544 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkWindow" id="Region_Window">
|
||||
<property name="can_focus">False</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>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="selectionArea">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<style>
|
||||
<class name="regionWindow"/>
|
||||
</style>
|
||||
</object>
|
||||
<object class="GtkListStore" id="fileStore">
|
||||
<columns>
|
||||
<!-- column-name Images -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkImage" id="grabRegionImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-copy</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="regionMenu">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<property name="window_position">mouse</property>
|
||||
<property name="type_hint">menu</property>
|
||||
<property name="decorated">False</property>
|
||||
<property name="gravity">north-east</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Grab Region</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">grabRegionImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="grabRegion" 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-close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="returnToMainWindow" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</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="GtkLabel" id="messageLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="monitorStore">
|
||||
<columns>
|
||||
<!-- column-name Monitors -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkImage" id="picImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-cancel</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="renameImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-edit</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="revertImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-undo</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="timeoutAdjustment">
|
||||
<property name="upper">60</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="Main_Window">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Cornea</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">500</property>
|
||||
<property name="default_height">310</property>
|
||||
<property name="icon">pyCornea.png</property>
|
||||
<property name="gravity">center</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<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="GtkRadioButton" id="entireScrnToggle">
|
||||
<property name="label" translatable="yes">Entire screen</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Take a screenshot of the entire screen.</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="toggleRadioBttn" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="windowToggle">
|
||||
<property name="label" translatable="yes">Active window</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Take a screenshot of the active window.</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">entireScrnToggle</property>
|
||||
<signal name="toggled" handler="toggleRadioBttn" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="regionToggle">
|
||||
<property name="label" translatable="yes">Select a region</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Select a region to be captured by clicking a point of the screen without releasing the mouse, dragging you mouse to the other corner of the region, and releasing the mouse button.</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">entireScrnToggle</property>
|
||||
<signal name="toggled" handler="toggleRadioBttn" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="monitorToggle">
|
||||
<property name="label" translatable="yes">Select a monitor</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Take a screenshot of the selected monitor.</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">entireScrnToggle</property>
|
||||
<signal name="toggled" handler="toggleRadioBttn" 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">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Timeout</property>
|
||||
<property name="justify">right</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="delayAmount">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Delay in seconds before the screenshot is taken.</property>
|
||||
<property name="input_purpose">number</property>
|
||||
<property name="adjustment">timeoutAdjustment</property>
|
||||
<property name="snap_to_ticks">True</property>
|
||||
<property name="numeric">True</property>
|
||||
</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">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAspectFrame" id="previewPane">
|
||||
<property name="width_request">312</property>
|
||||
<property name="height_request">312</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="imageView">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</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>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="snapshotBttn">
|
||||
<property name="label" translatable="yes">Take Snapshot</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">picImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="take_screenshot" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="monitorsView">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">monitorStore</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Monitors</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="width_request">200</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_top">15</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">fileStore</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<signal name="button-press-event" handler="showMainMenu" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection">
|
||||
<signal name="changed" handler="setImage" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Images</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_order">descending</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="close" 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>
|
||||
<object class="GtkPopover" id="mainMenu">
|
||||
<property name="width_request">320</property>
|
||||
<property name="height_request">150</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="relative_to">delayAmount</property>
|
||||
<signal name="grab-focus" handler="setBackupVar" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<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="GtkEntry" id="fileNameEntry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="has_focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Revert</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">revertImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="resetName" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</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="GtkButton">
|
||||
<property name="label" translatable="yes">Rename</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">renameImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="renameFile" 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">
|
||||
<property name="label">gtk-open</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="openFile" 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-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="deleteFile" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
BIN
src/resources/cornea.png
Normal file
BIN
src/resources/cornea.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
3
src/resources/stylesheet.css
Normal file
3
src/resources/stylesheet.css
Normal file
@ -0,0 +1,3 @@
|
||||
.regionWindow {
|
||||
background-color: rgba(0, 0, 0, 0.0);
|
||||
}
|
14
src/screenshot
Executable file
14
src/screenshot
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set -o xtrace ## To debug scripts
|
||||
# set -o errexit ## To exit on error
|
||||
# set -o errunset ## To exit if a variable is referenced but not set
|
||||
|
||||
|
||||
function main() {
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
cd "${SCRIPTPATH}"
|
||||
source "../venv/bin/activate"
|
||||
python .
|
||||
}
|
||||
main $@;
|
180
src/signal_classes/DrawingArea.py
Normal file
180
src/signal_classes/DrawingArea.py
Normal file
@ -0,0 +1,180 @@
|
||||
# Gtk imports
|
||||
import gi, cairo
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
||||
from gi.repository import Gtk as gtk
|
||||
from gi.repository import Gdk as gdk
|
||||
from gi.repository import GLib as glib
|
||||
|
||||
|
||||
# Python imports
|
||||
import threading, html
|
||||
|
||||
import pyscreenshot as capture
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
|
||||
return wrapper
|
||||
|
||||
class MouseButtons:
|
||||
LEFT_BUTTON = 1
|
||||
RIGHT_BUTTON = 3
|
||||
|
||||
|
||||
class DrawingArea:
|
||||
def __init__(self, settings, utilsClass):
|
||||
self.settings = settings
|
||||
self.utilsClass = utilsClass
|
||||
self.builder = self.settings.returnBuilder()
|
||||
|
||||
self.mainWindow = self.builder.get_object('Main_Window')
|
||||
self.regionWindow = self.builder.get_object('Region_Window')
|
||||
self.regionMenu = self.builder.get_object('regionMenu')
|
||||
self.messageLabel = self.builder.get_object('messageLabel')
|
||||
MONITOR = self.settings.getMonitorData()
|
||||
|
||||
self.settings.setWindowData(self.regionWindow)
|
||||
self.regionWindow.set_default_size(MONITOR[0].width, MONITOR[0].height)
|
||||
self.regionWindow.set_size_request(MONITOR[0].width, MONITOR[0].height)
|
||||
self.regionWindow.set_keep_above(True)
|
||||
|
||||
self.DRAW_AREA = self.builder.get_object("selectionArea")
|
||||
self.DRAW_AREA.add_events(gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
self.DRAW_AREA.add_events(gdk.EventMask.BUTTON_RELEASE_MASK)
|
||||
self.DRAW_AREA.add_events(gdk.EventMask.BUTTON1_MOTION_MASK)
|
||||
self.DRAW_AREA.connect("button-press-event", self.on_button_press)
|
||||
self.DRAW_AREA.connect("button-release-event", self.on_button_release)
|
||||
self.DRAW_AREA.connect("motion-notify-event", self.on_mouse_move)
|
||||
self.DRAW_AREA.connect("draw", self.on_draw)
|
||||
|
||||
area = self.settings.getMonitorData()[0]
|
||||
self.SCREENSHOTS_DIR = self.settings.returnScreenshotsDir()
|
||||
self.WIN_REC = [area.x, area.y, area.width, area.height]
|
||||
self.coords = [[0.0, 0.0], [0.0, 0.0]] # point1 and point2
|
||||
self.BORDER_COLOR = [255, 0, 0, 0.84]
|
||||
self.TRANS_COLOR = [0, 0, 0, 0.0]
|
||||
self.BG_COLOR = [0, 0, 0, 0.4]
|
||||
self.success = "#88cc27"
|
||||
self.warning = "#ffa800"
|
||||
self.error = "#ff0000"
|
||||
self.rec = None
|
||||
self.cr = None
|
||||
|
||||
self.regionWindow.set_default_size(area.width, area.height)
|
||||
self.regionWindow.set_size_request(area.width, area.height)
|
||||
self.regionWindow.move(area.x, area.y)
|
||||
self.regionWindow.set_resizable(False)
|
||||
self.regionWindow.set_keep_above(True)
|
||||
|
||||
|
||||
|
||||
def on_button_press(self, w, e):
|
||||
self.messageLabel.set_markup("")
|
||||
if e.type == gdk.EventType.BUTTON_PRESS and e.button == MouseButtons.LEFT_BUTTON:
|
||||
self.coords[0] = [e.x, e.y]
|
||||
self.regionMenu.hide()
|
||||
|
||||
# This will reset draw area initially. No further use
|
||||
if self.cr:
|
||||
self.draw(self.cr, self.WIN_REC, self.BG_COLOR)
|
||||
self.DRAW_AREA.queue_draw()
|
||||
if e.type == gdk.EventType.BUTTON_PRESS and e.button == MouseButtons.RIGHT_BUTTON:
|
||||
self.regionMenu.show()
|
||||
|
||||
# Update second set of coords.
|
||||
def on_mouse_move(self, w, e):
|
||||
self.coords[1] = [e.x, e.y]
|
||||
self.DRAW_AREA.queue_draw()
|
||||
|
||||
@threaded
|
||||
def on_button_release(self, w, e):
|
||||
if e.type == gdk.EventType.BUTTON_RELEASE and e.button == MouseButtons.LEFT_BUTTON:
|
||||
glib.idle_add(self.regionMenu.show)
|
||||
|
||||
|
||||
@threaded
|
||||
def grabRegion(self, widget):
|
||||
glib.idle_add(self.regionMenu.hide)
|
||||
glib.idle_add(self.mainWindow.hide)
|
||||
self.boundingBoxGrab(self.rec[0], self.rec[1], self.rec[2], self.rec[3])
|
||||
glib.idle_add(self.regionMenu.show)
|
||||
glib.idle_add(self.mainWindow.show)
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
|
||||
@threaded
|
||||
def returnToMainWindow(self, widget):
|
||||
glib.idle_add(self.regionWindow.hide)
|
||||
glib.idle_add(self.regionMenu.hide)
|
||||
glib.idle_add(self.mainWindow.show)
|
||||
|
||||
|
||||
def on_draw(self, wid, cr):
|
||||
if not self.cr: self.cr = cr
|
||||
# Reset the screen with transparent view
|
||||
self.draw(cr, self.WIN_REC, self.BG_COLOR)
|
||||
|
||||
point1 = self.coords[0]
|
||||
point2 = self.coords[1]
|
||||
x1 = point1[0]
|
||||
y1 = point1[1]
|
||||
x2 = point2[0]
|
||||
y2 = point2[1]
|
||||
w = x2 - x1
|
||||
h = y2 - y1
|
||||
|
||||
# Rectangle information for region and screen grab
|
||||
self.rec = [int(x1), int(y1), int(x2), int(y2)]
|
||||
# Draw the new selection region
|
||||
self.selectionDraw(cr, [x1, y1, w, h], self.BORDER_COLOR, self.TRANS_COLOR)
|
||||
|
||||
|
||||
def draw(self, cr, x1y1wh, rgba):
|
||||
cr.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3])
|
||||
cr.rectangle(x1y1wh[0], x1y1wh[1], x1y1wh[2], x1y1wh[3])
|
||||
cr.set_operator(1);
|
||||
cr.fill()
|
||||
|
||||
def selectionDraw(self, cr, x1y1wh, brdrcol, transclr):
|
||||
# Clear the region
|
||||
cr.set_source_rgba(transclr[0], transclr[1], transclr[2], transclr[3])
|
||||
cr.rectangle(x1y1wh[0], x1y1wh[1], x1y1wh[2], x1y1wh[3])
|
||||
cr.set_operator(0);
|
||||
cr.fill()
|
||||
|
||||
# Draw a border
|
||||
cr.set_source_rgba(brdrcol[0], brdrcol[1], brdrcol[2], brdrcol[3])
|
||||
cr.rectangle(x1y1wh[0] - 2, x1y1wh[1] - 2, x1y1wh[2] + 4, x1y1wh[3] + 4)
|
||||
cr.set_operator(1);
|
||||
cr.stroke()
|
||||
|
||||
# Actual region grab
|
||||
def boundingBoxGrab(self, x1, y1, x2, y2):
|
||||
self.utilsClass.sleep(0.4)
|
||||
try:
|
||||
temp = 0;
|
||||
if x2 < x1:
|
||||
temp = x1
|
||||
x1 = x2
|
||||
x2 = temp
|
||||
|
||||
if y2 < y1:
|
||||
temp = y1
|
||||
y1 = y2
|
||||
y2 = temp
|
||||
|
||||
|
||||
self.utilsClass.boundingBoxGrab(x1, y1, x2, y2)
|
||||
markup = "<span foreground='" + self.success + "'>Grabbed region successfully...</span>"
|
||||
glib.idle_add(self.messageLabel.set_markup, markup)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
markup = "<span foreground='" + self.warning + "' >Oops...</span>" + \
|
||||
"\n<span foreground='" + self.error + "'>" + html.escape( str(e) ) + "</span>"
|
||||
glib.idle_add(self.messageLabel.set_markup, markup)
|
51
src/signal_classes/MainMenuPopup.py
Normal file
51
src/signal_classes/MainMenuPopup.py
Normal file
@ -0,0 +1,51 @@
|
||||
# Gtk imports
|
||||
|
||||
# Python imports
|
||||
import os, subprocess
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
class MainMenuPopup:
|
||||
def __init__(self, settings, utilsClass):
|
||||
self.settings = settings
|
||||
self.utilsClass = utilsClass
|
||||
|
||||
self.builder = self.settings.returnBuilder()
|
||||
self.fileNameEntry = self.builder.get_object("fileNameEntry")
|
||||
self.SCREENSHOTS_DIR = self.settings.returnScreenshotsDir()
|
||||
self.backupName = None
|
||||
|
||||
|
||||
def renameFile(self, widget, data=None):
|
||||
newName = self.fileNameEntry.get_text().strip()
|
||||
oldFilePath = self.SCREENSHOTS_DIR + '/' + self.backupName
|
||||
newFilePath = self.SCREENSHOTS_DIR + '/' + newName
|
||||
try:
|
||||
if os.path.isfile(oldFilePath) and newName:
|
||||
os.rename(oldFilePath, newFilePath)
|
||||
self.backupName = newName
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
def openFile(self, widget, data=None):
|
||||
filePath = self.SCREENSHOTS_DIR + '/' + self.backupName
|
||||
subprocess.Popen(['xdg-open', filePath], stdout=subprocess.PIPE)
|
||||
|
||||
def deleteFile(self, widget, data=None):
|
||||
try:
|
||||
filePath = self.SCREENSHOTS_DIR + '/' + self.backupName
|
||||
if os.path.isfile(filePath):
|
||||
os.remove(filePath)
|
||||
self.builder.get_object("mainMenu").popdown()
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
|
||||
def resetName(self, widget, data=None):
|
||||
self.fileNameEntry.set_text(self.backupName)
|
||||
|
||||
def setBackupVar(self, widget):
|
||||
self.backupName = self.fileNameEntry.get_text()
|
153
src/signal_classes/MainWindow.py
Normal file
153
src/signal_classes/MainWindow.py
Normal file
@ -0,0 +1,153 @@
|
||||
# Gtk imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
||||
from gi.repository import Gtk as gtk
|
||||
from gi.repository import Gdk as gdk
|
||||
from gi.repository import GLib as glib
|
||||
|
||||
# Python imports
|
||||
import threading, subprocess, os
|
||||
import pyscreenshot as capture
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
|
||||
return wrapper
|
||||
|
||||
class MouseButtons:
|
||||
LEFT_BUTTON = 1
|
||||
RIGHT_BUTTON = 3
|
||||
|
||||
|
||||
class MainWindow:
|
||||
def __init__(self, settings, utilsClass):
|
||||
self.settings = settings
|
||||
self.utilsClass = utilsClass
|
||||
self.builder = self.settings.returnBuilder()
|
||||
|
||||
self.mainWindow = self.builder.get_object('Main_Window')
|
||||
self.regionWindow = self.builder.get_object('Region_Window')
|
||||
self.monitorStore = self.builder.get_object("monitorStore")
|
||||
self.MONITORS = self.settings.getMonitorData()
|
||||
|
||||
# Not adding the reference monitor
|
||||
i = 0
|
||||
for monitor in self.MONITORS:
|
||||
if i > 0:
|
||||
mon = str(monitor.width) + "x" + str(monitor.height) + "+" + str(monitor.x) + "+" + str(monitor.y)
|
||||
self.monitorStore.append([mon])
|
||||
i += 1
|
||||
|
||||
monitorsView = self.builder.get_object("monitorsView")
|
||||
monitorsView.set_cursor(1)
|
||||
|
||||
self.SCREENSHOTS_DIR = self.settings.returnScreenshotsDir()
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
|
||||
|
||||
|
||||
def take_screenshot(self, widget):
|
||||
active_radio = self.getActiveRadio()
|
||||
active = active_radio.get_children()[0].get_text()
|
||||
|
||||
if "Entire screen" in active:
|
||||
self.getEntireScreen()
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
if "Active window" in active:
|
||||
self.getActiveWindow()
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
if "Select a region" in active:
|
||||
self.regionWindow.show_all()
|
||||
if "Select a monitor" in active:
|
||||
self.snapshotMonitor()
|
||||
self.utilsClass.refereshDirectoryList()
|
||||
|
||||
|
||||
def getEntireScreen(self):
|
||||
self.utilsClass.sleep()
|
||||
# childprocess=False needed to not crash program
|
||||
im = capture.grab(childprocess=False)
|
||||
im.save(self.utilsClass.generateScreenshotName())
|
||||
|
||||
def getActiveWindow(self):
|
||||
self.utilsClass.sleep()
|
||||
|
||||
screen = gdk.get_default_root_window().get_screen()
|
||||
w = screen.get_active_window()
|
||||
pb = gdk.pixbuf_get_from_window(w, *w.get_geometry())
|
||||
pb.savev(self.utilsClass.generateScreenshotName(), "png", (), ())
|
||||
|
||||
def snapshotMonitor(self):
|
||||
monitorsView = self.builder.get_object("monitorsView")
|
||||
iterator = monitorsView.get_selection().get_selected()[1]
|
||||
path = self.monitorStore.get_path(iterator)
|
||||
# Slot 0 is ref monitor. Need to add 1 to get proper slot
|
||||
monitor = self.MONITORS[int(str(path)) + 1]
|
||||
|
||||
self.utilsClass.sleep()
|
||||
|
||||
x2 = monitor.x + monitor.width
|
||||
y2 = monitor.y + monitor.height
|
||||
self.utilsClass.boundingBoxGrab(monitor.x, monitor.y, x2, y2)
|
||||
|
||||
def toggleRadioBttn(self, widget):
|
||||
monitorsView = self.builder.get_object('monitorsView')
|
||||
delayAmount = self.builder.get_object('delayAmount')
|
||||
snapshotBttn = self.builder.get_object('snapshotBttn')
|
||||
active = self.getActiveRadio().get_children()[0].get_text()
|
||||
|
||||
self.regionWindow.hide()
|
||||
monitorsView.set_sensitive(False)
|
||||
delayAmount.set_sensitive(True)
|
||||
snapshotBttn.set_sensitive(True)
|
||||
delayAmount.set_value(0)
|
||||
|
||||
if "Active window" in active:
|
||||
delayAmount.set_value(4)
|
||||
if "Select a region" in active:
|
||||
delayAmount.set_sensitive(False)
|
||||
if "Select a monitor" in active:
|
||||
monitorsView.set_sensitive(True)
|
||||
|
||||
def setImage(self, user_data):
|
||||
# We need the refresh state for the files list b/c GtkTreeSelection
|
||||
# is calling this method b/c caling this too quickly causes issues...
|
||||
if self.utilsClass.returnRefreshingState() == False:
|
||||
selected = user_data.get_selected()[1]
|
||||
if selected:
|
||||
fileNameEntry = self.builder.get_object("fileNameEntry")
|
||||
imageView = self.builder.get_object("imageView")
|
||||
file = self.builder.get_object("fileStore").get_value(selected, 0)
|
||||
fullPath = self.SCREENSHOTS_DIR + "/" + file
|
||||
|
||||
try:
|
||||
if os.path.isfile(fullPath):
|
||||
fileNameEntry.set_text(file)
|
||||
pixbuf = gtk.Image.new_from_file(fullPath).get_pixbuf()
|
||||
scaledPixBuf = pixbuf.scale_simple(480, 320, 2) # 2 = BILINEAR and is best by default
|
||||
imageView.set_from_pixbuf(scaledPixBuf)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
|
||||
def getActiveRadio(self):
|
||||
master_radio = self.builder.get_object('entireScrnToggle')
|
||||
active_radio = next((
|
||||
radio for radio in master_radio.get_group()
|
||||
if radio.get_active()
|
||||
))
|
||||
return active_radio
|
||||
|
||||
def showMainMenu(self, w, e):
|
||||
if e.type == gdk.EventType.BUTTON_PRESS and e.button == MouseButtons.RIGHT_BUTTON:
|
||||
self.builder.get_object("mainMenu").popup()
|
||||
|
||||
def close(self, widget):
|
||||
gtk.main_quit()
|
3
src/signal_classes/__init__.py
Normal file
3
src/signal_classes/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .MainWindow import MainWindow
|
||||
from .DrawingArea import DrawingArea
|
||||
from .MainMenuPopup import MainMenuPopup
|
96
src/utils/CrossClassSignals.py
Normal file
96
src/utils/CrossClassSignals.py
Normal file
@ -0,0 +1,96 @@
|
||||
# Gtk imports
|
||||
from gi.repository import GLib as glib
|
||||
|
||||
# Python imports
|
||||
import os, threading, time, datetime
|
||||
|
||||
import pyscreenshot as capture
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||
|
||||
return wrapper
|
||||
|
||||
class CrossClassSignals:
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.builder = self.settings.returnBuilder()
|
||||
self.SCREENSHOTS_DIR = self.settings.returnScreenshotsDir()
|
||||
self.fileStore = self.builder.get_object("fileStore")
|
||||
self.refreshingState = False
|
||||
|
||||
|
||||
def returnRefreshingState(self):
|
||||
return self.refreshingState
|
||||
|
||||
def setRefreshingState(self, state):
|
||||
self.refreshingState = state
|
||||
|
||||
|
||||
@threaded
|
||||
def refereshDirectoryList(self):
|
||||
self.refreshingState = True
|
||||
images = self.returnDirectoryList()
|
||||
images.sort()
|
||||
if len(images) != len(self.fileStore):
|
||||
self.fileStore.clear()
|
||||
for image in images:
|
||||
glib.idle_add(self.addToStore, (image))
|
||||
|
||||
# self.fileStore.sort()
|
||||
self.refreshingState = False
|
||||
|
||||
|
||||
@threaded
|
||||
def addToStore(self, image):
|
||||
self.fileStore.append([image])
|
||||
|
||||
def returnDirectoryList(self):
|
||||
files = []
|
||||
|
||||
for file in os.listdir(self.SCREENSHOTS_DIR):
|
||||
if os.path.isfile(os.path.join(self.SCREENSHOTS_DIR, file)):
|
||||
files.append(file)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def boundingBoxGrab(self, x1, y1, x2, y2):
|
||||
# childprocess=False needed to not crash program
|
||||
im = capture.grab(bbox=(x1, y1, x2, y2), childprocess=False)
|
||||
im.save(self.generateScreenshotName())
|
||||
|
||||
def generateScreenshotName(self):
|
||||
return self.SCREENSHOTS_DIR + '/scrshot_' + self.getTime() + '.png'
|
||||
|
||||
def getTime(self):
|
||||
now = datetime.datetime.now()
|
||||
return now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
def sleep(self, wait=None):
|
||||
delayAmount = self.builder.get_object("delayAmount")
|
||||
if not wait:
|
||||
wait = delayAmount.get_value_as_int()
|
||||
|
||||
time.sleep(wait)
|
||||
|
||||
|
||||
def getClipboardData(self):
|
||||
proc = subprocess.Popen(['xclip','-selection', 'clipboard', '-o'], stdout=subprocess.PIPE)
|
||||
retcode = proc.wait()
|
||||
data = proc.stdout.read()
|
||||
return data.decode("utf-8").strip()
|
||||
|
||||
def setClipboardData(self, data):
|
||||
proc = subprocess.Popen(['xclip','-selection','clipboard'], stdin=subprocess.PIPE)
|
||||
proc.stdin.write(data)
|
||||
proc.stdin.close()
|
||||
retcode = proc.wait()
|
||||
|
||||
def close(self, widget):
|
||||
gtk.main_quit()
|
71
src/utils/Settings.py
Normal file
71
src/utils/Settings.py
Normal file
@ -0,0 +1,71 @@
|
||||
# Gtk imports
|
||||
import gi, cairo
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
||||
from gi.repository import Gtk as gtk
|
||||
from gi.repository import Gdk as gdk
|
||||
|
||||
# Python imports
|
||||
import os
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self):
|
||||
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__)) + "/"
|
||||
self.builder = gtk.Builder()
|
||||
self.builder.add_from_file(self.SCRIPT_PTH + "../resources/Main_Window.glade")
|
||||
|
||||
# 'Filters'
|
||||
self.images = ('.png', '.jpg', '.jpeg', '.gif')
|
||||
HOME_PATH = os.path.expanduser('~')
|
||||
self.SCREENSHOTS_DIR = HOME_PATH + "/" + ".screenshots"
|
||||
|
||||
if not os.path.isdir(self.SCREENSHOTS_DIR):
|
||||
os.mkdir(self.SCREENSHOTS_DIR)
|
||||
|
||||
|
||||
def createWindow(self):
|
||||
# Get window and connect signals
|
||||
window = self.builder.get_object("Main_Window")
|
||||
window.connect("delete-event", gtk.main_quit)
|
||||
self.setWindowData(window)
|
||||
return window
|
||||
|
||||
def setWindowData(self, window):
|
||||
screen = window.get_screen()
|
||||
visual = screen.get_rgba_visual()
|
||||
|
||||
if visual != None and screen.is_composited():
|
||||
window.set_visual(visual)
|
||||
|
||||
# bind css file
|
||||
cssProvider = gtk.CssProvider()
|
||||
cssProvider.load_from_path(self.SCRIPT_PTH + '../resources/stylesheet.css')
|
||||
screen = gdk.Screen.get_default()
|
||||
styleContext = gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
def getMonitorData(self):
|
||||
screen = self.builder.get_object("Main_Window").get_screen()
|
||||
wdth = screen.get_width()
|
||||
hght = screen.get_height()
|
||||
mon0 = gdk.Rectangle()
|
||||
mon0.width = wdth
|
||||
mon0.height = hght
|
||||
monitors = []
|
||||
|
||||
monitors.append(mon0)
|
||||
for m in range(screen.get_n_monitors()):
|
||||
monitors.append(screen.get_monitor_geometry(m))
|
||||
|
||||
return monitors
|
||||
|
||||
|
||||
def returnBuilder(self): return self.builder
|
||||
def returnScreenshotsDir(self): return self.SCREENSHOTS_DIR
|
||||
|
||||
# Filter returns
|
||||
def returnImagesFilter(self): return self.images
|
2
src/utils/__init__.py
Normal file
2
src/utils/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .Settings import Settings
|
||||
from .CrossClassSignals import CrossClassSignals
|
Loading…
Reference in New Issue
Block a user