Ejemplo n.º 1
0
def capture_screen():
    if lookitconfig.LookitConfig().getint('General', 'delay') == 0:
        time.sleep(1)
    root = gtk.gdk.get_default_root_window()
    size = root.get_geometry()
    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, size[2], size[3])
    pixbuf.get_from_drawable(root, root.get_colormap(), 0, 0, 0, 0, size[2],
                             size[3])
    return pixbuf
Ejemplo n.º 2
0
def capture_active_window():
    if lookitconfig.LookitConfig().getint('General', 'delay') == 0:
        time.sleep(1)
    root = gtk.gdk.get_default_root_window()
    window = gtk.gdk.screen_get_default().get_active_window()
    size = window.get_geometry()
    origin = window.get_root_origin()
    # Calculating window decorations offset
    delta_x = window.get_origin()[0] - window.get_root_origin()[0]
    delta_y = window.get_origin()[1] - window.get_root_origin()[1]
    size_x = size[2] + delta_x
    size_y = size[3] + delta_y
    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, size_x, size_y)
    pixbuf.get_from_drawable(root, root.get_colormap(), origin[0], origin[1],
                             0, 0, size_x, size_y)
    return pixbuf
Ejemplo n.º 3
0
def upload_file(image, existing_file=False):
    config = lookitconfig.LookitConfig()

    proto = config.get('Upload', 'type')
    # Temporary disable upload
    if not config.getboolean('Upload', 'enableupload'):
        proto = 'None'

    if proto == 'None':
        success = True
        data = False
    elif proto == 'SSH':
        success, data = upload_file_sftp(
            image,
            config.get('Upload', 'hostname'),
            int(config.get('Upload', 'port')),
            config.get('Upload', 'username'),
            config.get('Upload', 'password'),
            config.get('Upload', 'ssh_key_file'),
            config.get('Upload', 'directory'),
            config.get('Upload', 'url'),
        )
    elif proto == 'HTTP':
        success, data = upload_file_http(image, config.get('Upload', 'URL'))
    elif proto == 'FTP':
        success, data = upload_file_ftp(
            image,
            config.get('Upload', 'hostname'),
            int(config.get('Upload', 'port')),
            config.get('Upload', 'username'),
            config.get('Upload', 'password'),
            config.get('Upload', 'directory'),
            config.get('Upload', 'url'),
        )
    elif proto == 'Omploader':
        success, data = upload_file_omploader(image)
        try:
            f = open(liblookit.LOG_FILE, 'ab')
            f.write(time.ctime() + ' Uploaded screenshot to Omploader: ' +
                    data['original_image'] + '\n')
        except IOError, e:
            pass
        finally:
Ejemplo n.º 4
0
    def __init__(self):
        self.indicator = appindicator.Indicator(
            "Lookit", "lookit-panel", appindicator.CATEGORY_APPLICATION_STATUS)
        self.indicator.set_status(appindicator.STATUS_ACTIVE)

        self.menu = gtk.Menu()
        self.add_menu_item('Capture Area', cmd.CAPTURE_AREA)
        self.add_menu_item('Capture Entire Screen', cmd.CAPTURE_SCREEN)
        self.add_menu_item('Capture Active Window', cmd.CAPTURE_ACTIVE_WINDOW)

        self.add_menu_separator()

        delaymenu = gtk.Menu()
        self.add_menu_item('0 seconds', cmd.DELAY_0, delaymenu)
        self.add_menu_item('3 seconds', cmd.DELAY_3, delaymenu)
        self.add_menu_item('5 seconds', cmd.DELAY_5, delaymenu)
        self.add_menu_item('10 seconds', cmd.DELAY_10, delaymenu)
        sub = gtk.MenuItem('Set Delay:')
        sub.set_submenu(delaymenu)
        self.menu.append(sub)

        config = lookitconfig.LookitConfig()
        enableupload = config.getboolean('Upload', 'enableupload')
        self.add_check_menu_item('Upload to server',
                                 cmd.TOGGLE_UPLOAD,
                                 value=enableupload)

        self.add_menu_separator()
        self.add_menu_item('Preferences', cmd.SHOW_PREFERENCES)
        self.add_menu_item('About', cmd.SHOW_ABOUT)

        self.image_position = len(self.menu)
        self.image_list = []

        self.add_menu_separator()
        self.add_menu_item('Exit', cmd.EXIT)

        self.menu.show_all()
        self.indicator.set_menu(self.menu)
Ejemplo n.º 5
0
    def __init__(self):
        try:
            self.builder = gtk.Builder()
            datadir = liblookit.get_data_dir()
            xmlfile = os.path.join(datadir, 'preferences.xml')
            self.builder.add_from_file(xmlfile)
        except Exception as e:
            print e
            sys.exit(1)

        connections = gtk.ListStore(str)
        for connection in CONNECTION_TYPES:
            connections.append([connection])
        cell = gtk.CellRendererText()
        combobox = self.builder.get_object('combobox')
        combobox.set_model(connections)
        combobox.pack_start(cell)
        combobox.add_attribute(cell, 'text', 0)
        combobox.set_active(0)

        self.config = lookitconfig.LookitConfig()
        self.builder.connect_signals(self)
Ejemplo n.º 6
0
def handle_delay():
    delay_value = lookitconfig.LookitConfig().getint('General', 'delay')
    time.sleep(delay_value)
Ejemplo n.º 7
0
 def set_upload(self, value):
     config = lookitconfig.LookitConfig()
     config.set('Upload', 'enableupload', value)
     config.save()
Ejemplo n.º 8
0
 def set_delay(self, value):
     config = lookitconfig.LookitConfig()
     config.set('General', 'delay', value)
     config.save()