Example #1
0
    def __clicked(self, button):
        if self.__window.get_property('visible'): return
        self.__window.child.show_all()
        self.__window.size_request()
        x, y = self.child.window.get_origin()
        w, h = self.child.window.get_size()        
        ww, wh = self.__window.child.parent.get_size()
        sx, sy = self._move_to(x, y, w, h, ww, wh, pad=3)
        self.__window.set_transient_for(get_top_parent(self))
        self.__window.move(sx, sy)
        self.__window.show()
        self.__window.grab_focus()
        self.__window.grab_add()
        pointer = gtk.gdk.pointer_grab(
            self.__window.window, True,
            gtk.gdk.BUTTON_PRESS_MASK |
            gtk.gdk.BUTTON_RELEASE_MASK |
            gtk.gdk.BUTTON_MOTION_MASK |
            gtk.gdk.POINTER_MOTION_MASK |
            gtk.gdk.SCROLL_MASK, None, None, gtk.get_current_event_time())
        keyboard = gtk.gdk.keyboard_grab(
            self.__window.window, True, gtk.get_current_event_time())

        if pointer != gtk.gdk.GRAB_SUCCESS or keyboard != gtk.gdk.GRAB_SUCCESS:
            self.__window.grab_remove()
            self.__window.hide()

            if pointer == gtk.gdk.GRAB_SUCCESS:
                gtk.gdk.pointer_ungrab(gtk.get_current_event_time())
            if keyboard == gtk.gdk.GRAB_SUCCESS:
                gtk.gdk.keyboard_ungrab(gtk.get_current_event_time())
Example #2
0
    def do_open(self):
        screen = wnck.screen_get(0)
        opened_one = False

        app_wins = self.app_group.get_windows()
        active_ws = screen.get_active_workspace()

        # Sorted by stacking order
        visible_wins = [
            win for win in screen.get_windows_stacked()
            if win in app_wins and win.is_on_workspace(active_ws)
        ]
        if not visible_wins and self.item:
            self.item.open()
            return

        if screen.get_active_window() in visible_wins:
            # Already active
            if len(visible_wins) > 1:
                # This group has the active win, so cycle the topmost active window down
                print " *** Raising window: ", visible_wins[0].get_name()
                visible_wins[0].activate(gtk.get_current_event_time())
            return
        else:
            # Not currently active, so raise them all
            for win in visible_wins:
                win.activate(gtk.get_current_event_time())
            return

        raise Exception(
            "No application windows on this desktop, and no Item to launch")
    def __init_ui(self):
        self.menu = gtk.Menu()

        self.database_item = gtk.MenuItem(_('Database'))
        self.database_item.show()
        self.database_item.set_sensitive(False)

        self.unlock_item = gtk.MenuItem(_('Unlock File'))
        self.unlock_item.show()
        self.unlock_item.connect(
            'activate',
            lambda w, d=None: self.file_open(self.config.get("file"))
        )

        self.lock_item = gtk.MenuItem(_('Lock File'))
        self.lock_item.connect(
            'activate',
            lambda w, d=None: self.file_close()
        )

        self.prefs_item = gtk.MenuItem(_('Preferences'))
        self.prefs_item.show()
        self.prefs_item.connect(
            'activate',
            lambda w, d=None: self.prefs()
        )

        self.about_item = gtk.MenuItem(_('About'))
        self.about_item.show()
        self.about_item.connect('activate', self.__cb_about)

        self.quit_item = gtk.MenuItem('Quit')
        self.quit_item.show()
        self.quit_item.connect('activate', gtk.main_quit)

        self.menu.append(self.database_item)
        self.menu.append(gtk.SeparatorMenuItem())
        self.menu.append(self.unlock_item)
        self.menu.append(self.lock_item)
        self.menu.append(gtk.SeparatorMenuItem())
        self.menu.append(self.prefs_item)
        self.menu.append(self.about_item)
        self.menu.append(self.quit_item)

        self.ind.set_menu(self.menu)
        #self.menu.show_all()

        gtk.about_dialog_set_url_hook(
            lambda d, l: gtk.show_uri(None, l, gtk.get_current_event_time())
        )

        gtk.about_dialog_set_email_hook(
            lambda d, l: gtk.show_uri(None, "mailto:" + l, gtk.get_current_event_time())
        )

        ## set up various ui element holders
        self.popup_entryview = None
        self.popup_entrylist = None
Example #4
0
    def popdown (self):
        if not (self.flags()&gtk.MAPPED):
            return
        
        self.ignore_enter = False

        gtk.Window.hide (self) # Bypass the warning we issue on hide()

        gtk.gdk.keyboard_ungrab(gtk.get_current_event_time())

        # Ungrab pointer
        gtk.gdk.pointer_ungrab(gtk.get_current_event_time())
        self.grab_remove()
Example #5
0
    def popdown(self):
        if not (self.flags() & gtk.MAPPED):
            return

        self.ignore_enter = False

        gtk.Window.hide(self)  # Bypass the warning we issue on hide()

        gtk.gdk.keyboard_ungrab(gtk.get_current_event_time())

        # Ungrab pointer
        gtk.gdk.pointer_ungrab(gtk.get_current_event_time())
        self.grab_remove()
Example #6
0
def main():
    parser = OptionParser()
    parser.add_option(
        "-m",
        "--move-away",
        action="store_true",
        default=False,
        dest="clear_workspace",
        help="iconify to other workspace to avoid crowding panel",
    )
    (options, args) = parser.parse_args()

    screen = wnck.screen_get_default()
    while gtk.events_pending():
        gtk.main_iteration()

    recollMain = ""
    recollwins = []
    for window in screen.get_windows():
        if window.get_class_group().get_name() == "Recoll":
            if window.get_name() == "Recoll":
                recollMain = window
            recollwins.append(window)

    if not recollMain:
        os.system("recoll&")
        sys.exit(0)

    # Check the main window state, and either activate or minimize all
    # recoll windows.
    workspace = screen.get_active_workspace()
    if not recollMain.is_visible_on_workspace(workspace):
        for win in recollwins:
            win.move_to_workspace(workspace)
            if win != recollMain:
                win.unminimize(gtk.get_current_event_time())
        recollMain.activate(gtk.get_current_event_time())
    else:
        otherworkspace = None
        if options.clear_workspace:
            # We try to minimize to another workspace
            wkspcs = screen.get_workspaces()
            for wkspc in wkspcs:
                if wkspc.get_number() != workspace.get_number():
                    otherworkspace = wkspc
                    break
        for win in recollwins:
            if otherworkspace:
                win.move_to_workspace(otherworkspace)
            win.minimize()
Example #7
0
 def openRightClickMenu(self, path, etime=None):
     menu = self.genRightClickMenu(path)
     if not menu:
         return
     if etime is None:
         etime = gtk.get_current_event_time()
     menu.popup(None, None, None, 3, etime)
Example #8
0
 def _load_editor(self, filename):
     if filename.endswith(".rws") or filename.endswith(".RWS"):
         editor = WorksheetEditor(self.notebook)
     elif filename.endswith(".py") or filename.endswith(".PY"):
         editor = LibraryEditor(self.notebook)
     else:
         gfile = gio.File(filename)
         context = gtk.gdk.AppLaunchContext()
         context.set_screen(self.window.get_screen())
         context.set_timestamp(gtk.get_current_event_time())
         try:
             handler = gfile.query_default_handler()
         except gio.Error, e:
             dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK,
                                        type=gtk.MESSAGE_ERROR)
             dialog.set_markup(format_escaped("<big><b>Don't know how to open '%s'</b></big>", os.path.basename(filename)))
             dialog.format_secondary_text(str(e))
             dialog.run()
             dialog.destroy()
             return None
         try:
             handler.launch([gfile], context)
         except glib.GError, e:
             dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK,
                                        type=gtk.MESSAGE_ERROR)
             dialog.set_markup(format_escaped("<big><b>Failed to open '%s'</b></big>", os.path.basename(filename)))
             dialog.format_secondary_text(str(e))
             dialog.run()
             dialog.destroy()
Example #9
0
def spawn(command, system=False, sn=None, reap=True, *args, **kwargs):
    def child_closed(pid, cond):
        dprint(command, "closed")
        if sn:
            sn.complete()

    if not system:
        if type(command) == list:
            command[0] = os.path.join(BIN_DIR, command[0])
        else:
            command = os.path.join(BIN_DIR, command)
    else:
        if type(command) == list:
            command[0] = os.path.expanduser(command[0])
        else:
            command = os.path.expanduser(command)

    env = os.environ

    if sn:
        id = sn.get_startup_id()
        env["DESKTOP_STARTUP_ID"] = id

    env["BLUEMAN_EVENT_TIME"] = str(gtk.get_current_event_time())

    p = Popen(command, env=env, *args, **kwargs)
    if reap:
        gobject.child_watch_add(p.pid, child_closed)
    return p
Example #10
0
    def drag_data_received_cb(self, widget, context, x, y, selection,
                              targetType, time):
        logging.debug('ClipboardTray: got data for target %r',
                      selection.target)

        object_id = self._context_map.get_object_id(context)
        try:
            if selection is None:
                logging.warn('ClipboardTray: empty selection for target %s',
                             selection.target)
            elif selection.target == 'XdndDirectSave0':
                if selection.data == 'S':
                    window = context.source_window

                    prop_type, format_, dest = window.property_get(
                        'XdndDirectSave0', 'text/plain')

                    clipboardservice = clipboard.get_instance()
                    clipboardservice.add_object_format(object_id,
                                                       'XdndDirectSave0',
                                                       dest,
                                                       on_disk=True)
            else:
                self._add_selection(object_id, selection)

        finally:
            # If it's the last target to be processed, finish
            # the dnd transaction
            if not self._context_map.has_context(context):
                context.drop_finish(True, gtk.get_current_event_time())
Example #11
0
 def run(self):
     screen = wnck.screen_get_default()
     screen.force_update()
     active = screen.get_active_window()
     if active.get_name() == "ducklauncher!!!":
         active = screen.get_previously_active_window()
     w = wnck.window_get(self.win_info['id'])
     try:
         if w.is_minimized():
             w.activate(gtk.get_current_event_time())
         elif w.get_xid() == active.get_xid():
             w.minimize()
         else:
             w.activate(gtk.get_current_event_time())
     except AttributeError:
         w.activate(gtk.get_current_event_time())
Example #12
0
 def on_right_click(self, button, time, data):
     quit_menu = gtk.Menu()
     quit_menu_item = gtk.MenuItem("Quit")
     quit_menu_item.connect("activate", self.on_quit, self.statusIcon)
     quit_menu.append(quit_menu_item)
     quit_menu.show_all()
     quit_menu.popup(None, None, gtk.status_icon_position_menu, 1, gtk.get_current_event_time(), self.statusIcon)
Example #13
0
 def activate_xid(self, xid):
     """ use the shell model to look up the window from xid, activat window"""
     window = self.get_wnck_window_from_xid(xid)
     if window:
         window.activate(gtk.get_current_event_time())
     else:
         _logger.debug('failed to get window from xid:%s' % (xid, ))
Example #14
0
    def do_url(self, about, url, data):
        try:
            gtk.show_uri(None, url, gtk.get_current_event_time())

        #For GTK < 2.14
        except:
            os.system('xdg-open %s &' % url)
 def _onPopup(self, w, event=None):
   '''
   Callback for popup button or right mouse button. Brings up a context
   menu.
   '''
   if event:
     if event.button != 3:
       return False
     path = self.get_path_at_pos(int(event.x), int(event.y))[0]
     selection = self.get_selection()
     selection.set_mode(gtk.SELECTION_NONE)
     self.set_cursor(path)
     selection.set_mode(gtk.SELECTION_SINGLE)      
     time = event.time
     button = event.button
     func = None
     extra_data = None
   else:
     path, col= self.get_cursor()
     time = gtk.get_current_event_time()
     button = 0
     extra_data = getTreePathBoundingBox(self, path, col)
     func = lambda m, b: (b.x, b.y + (b.height/2), True)
     
   menu = ui_manager.uimanager.get_widget(ui_manager.POPUP_MENU_PATH)
   menu.popup(None, None, func, button, time, extra_data)
   return True
Example #16
0
	def run(self):
		screen = wnck.screen_get_default()
		screen.force_update()
		active= screen.get_active_window()
		if active.get_name()=="ducklauncher!!!":
			active= screen.get_previously_active_window()
		w=wnck.window_get(self.win_info ['id'])
		try:
			if w.is_minimized():
				w.activate(gtk.get_current_event_time())
			elif w.get_xid()==active.get_xid():
				w.minimize()
			else:
				w.activate(gtk.get_current_event_time())
		except AttributeError:
			w.activate(gtk.get_current_event_time())
Example #17
0
    def set_zoom_level(self, new_level, x_event_time=0):
        old_level = self.zoom_level
        if old_level == new_level:
            return

        if old_level != self.ZOOM_ACTIVITY:
            screen = gtk.gdk.screen_get_default()
            active_window_type = screen.get_active_window().get_type_hint()
            if active_window_type != gtk.gdk.WINDOW_TYPE_HINT_DESKTOP:
                return

        self._zoom_level = new_level
        if new_level is not self.ZOOM_ACTIVITY:
            self._desktop_level = new_level

        self.zoom_level_changed.send(self, old_level=old_level,
                                     new_level=new_level)

        show_desktop = new_level is not self.ZOOM_ACTIVITY
        self._screen.toggle_showing_desktop(show_desktop)

        if new_level is self.ZOOM_ACTIVITY:
            # activate the window, in case it was iconified
            # (e.g. during sugar launch, the Journal starts in this state)
            window = self._active_activity.get_window()
            if window:
                window.activate(x_event_time or gtk.get_current_event_time())
Example #18
0
def spawn(command, system=False, sn=None, reap=True, *args, **kwargs):
    def child_closed(pid, cond):
        dprint(command, "closed")
        if sn:
            sn.complete()

    if not system:
        if type(command) == list:
            command[0] = os.path.join(BIN_DIR, command[0])
        else:
            command = os.path.join(BIN_DIR, command)
    else:
        if type(command) == list:
            command[0] = os.path.expanduser(command[0])
        else:
            command = os.path.expanduser(command)

    env = os.environ

    if sn:
        id = sn.get_startup_id()
        env["DESKTOP_STARTUP_ID"] = id

    env["BLUEMAN_EVENT_TIME"] = str(gtk.get_current_event_time())

    p = Popen(command, env=env, *args, **kwargs)
    if reap:
        gobject.child_watch_add(p.pid, child_closed)
    return p
Example #19
0
 def on_left_click(self, icon):
     if self.registry.Network.is_connected():
         popuplist = [("This is a blip", self.newWaveViewer, None, self.draw_unread_count(1))]
         # [('No updates',self.blank,None)]
     else:
         popuplist = [("You're not logged in.", self.blank, None)]
     self.popupMenu(1, gtk.get_current_event_time(), popuplist)
Example #20
0
    def make_popup(self):
        menu = gtk.Menu()
        no_music = 'no-music'
        names = self.config.keys()
        for name in [no_music] + sorted(names):
            real_name = 'None'
            if name in self.config:
                real_name = self.config[name]['name']
            if name == self.playlist or (name == no_music
                                         and self.playlist == None):
                item = gtk.CheckMenuItem(real_name)
                item.set_active(True)
            else:
                item = gtk.MenuItem(real_name)

            def make_click(name):
                def click(object):
                    if name == no_music:
                        self.stop_music()
                    else:
                        self.play_music(name)

                return click

            item.connect('activate', make_click(name))
            item.show()
            menu.append(item)

        menu.popup(None, None, None, 0, gtk.get_current_event_time())
Example #21
0
 def _get_startup_env(self):
     env = dict(os.environ)
     env['DESKTOP_STARTUP_ID'] = 'hotwire%d_TIME%d' % (
         os.getpid(),
         gtk.get_current_event_time(),
     )
     return env
Example #22
0
def show_section(section, screen=None):
    if library.uninstalled:
        root = library.get_root()
        uri = os.path.join(root, 'docs', 'manual', 'pt_BR')
        if section != '':
            uri += '/' + section + '.page'
    else:
        if library.get_resource_exists('stoq', 'docs', 'manual', 'pt_BR'):
            manual_dir = library.get_resource_filename('stoq', 'docs',
                                                       'manual', 'pt_BR')
            if section:
                uri = os.path.join(manual_dir, section + '.page')
            else:
                uri = manual_dir
        else:
            uri = 'stoq'
            if section:
                uri += '?' + section

    if not screen:
        toplevel = get_current_toplevel()
        if toplevel:
            screen = toplevel.get_screen()

    try:
        gtk.show_uri(screen, 'ghelp:' + uri, gtk.get_current_event_time())
    except glib.GError:
        open_browser(
            'http://doc.stoq.com.br/manual/%s/%s.html' % (
                stoq.short_version,
                section or 'index',
            ), screen)
Example #23
0
def spawn_app(app_info,
              argv,
              filelist,
              workdir=None,
              startup_notify=True,
              timestamp=None,
              launch_cb=None,
              screen=None):
    """
	Spawn app.

	@argv: argument list including files
	@workdir: where to set workdir if not cwd
	@app_info: Used for startup notification, if @startup_notify is True
	@filelist: Used for startup notification
	@startup_notify: Use startup notification
	@timestamp: Event timestamp
	@launch_cb: Called if successful with
	            (argv, pid, notify_id, filelist, timestamp)
	@screen: GdkScreen on which to put the application

	return pid if successful
	raise SpawnError on error
	"""
    notify_id = None
    if startup_notify:
        ctx = gtk.gdk.AppLaunchContext()
        ctx.set_timestamp(timestamp or gtk.get_current_event_time())
        if screen:
            ctx.set_screen(screen)
        # This not only returns the string ID but
        # it actually starts the startup notification!
        notify_id = ctx.get_startup_notify_id(app_info, filelist)
        child_env_add = {STARTUP_ENV: notify_id}
    else:
        child_env_add = {}
    if screen:
        child_env_add["DISPLAY"] = screen.make_display_name()

    if not workdir or not os.path.exists(workdir):
        workdir = "."

    argv = list(locale_encode_argv(argv))

    try:
        (pid, _ig1, _ig2,
         _ig3) = glib.spawn_async(argv,
                                  working_directory=workdir,
                                  flags=glib.SPAWN_SEARCH_PATH,
                                  child_setup=child_setup,
                                  user_data=child_env_add)
        debug_log("Launched", argv, notify_id, "pid:", pid)
    except glib.GError as exc:
        error_log("Error Launching ", argv, unicode(exc))
        if notify_id:
            gtk.gdk.notify_startup_complete_with_id(notify_id)
        raise SpawnError(unicode(exc))
    if launch_cb:
        launch_cb(argv, pid, notify_id, filelist, timestamp)
    return pid
Example #24
0
 def _on_help_clicked(self, widget):
     """Gtk+ callback"""
     try:
         gtk.show_uri(self.mainWindow.get_screen(), "ghelp:glchess", gtk.get_current_event_time())
     except gobject.GError, e:
         # TODO: This should be a pop-up dialog
         print _('Unable to display help: %s') % str(e)
Example #25
0
    def attach_view(self, menuitem, window):
        def relocate_view(item, v, d):
            # Reference the widget so that it is not destroyed
            if hasattr(v, "reparent_prepare"):
                v.reparent_prepare()
            wid = v.widget
            wid.hide()
            wid.get_parent().remove(wid)
            if d in ("south", "east", "west", "fareast"):
                v._destination = d
                self.controller.gui.viewbook[d].add_view(v, name=v._label)
                window.disconnect(window.cleanup_id)
                window.destroy()
            wid.show()
            if hasattr(v, "reparent_done"):
                v.reparent_done()
            return True

        menu = gtk.Menu()
        for (label, destination) in (
            (_("...embedded east of the video"), "east"),
            (_("...embedded west of the video"), "west"),
            (_("...embedded south of the video"), "south"),
            (_("...embedded at the right of the window"), "fareast"),
        ):
            item = gtk.MenuItem(label, use_underline=False)
            item.connect("activate", relocate_view, self, destination)
            menu.append(item)

        menu.show_all()
        menu.popup(None, None, None, 0, gtk.get_current_event_time())
        return True
    def drag_data_received_cb(self, widget, context, x, y, selection,
                              targetType, time):
        logging.debug('ClipboardTray: got data for target %r',
            selection.target)

        object_id = self._context_map.get_object_id(context)
        try:
            if selection is None:
                logging.warn('ClipboardTray: empty selection for target %s',
                    selection.target)
            elif selection.target == 'XdndDirectSave0':
                if selection.data == 'S':
                    window = context.source_window

                    prop_type, format_, dest = window.property_get(
                        'XdndDirectSave0', 'text/plain')

                    clipboardservice = clipboard.get_instance()
                    clipboardservice.add_object_format(object_id,
                                                       'XdndDirectSave0',
                                                       dest, on_disk=True)
            else:
                self._add_selection(object_id, selection)

        finally:
            # If it's the last target to be processed, finish
            # the dnd transaction
            if not self._context_map.has_context(context):
                context.drop_finish(True, gtk.get_current_event_time())
Example #27
0
 def on_left_click(self, event):
     with open(os.path.expanduser("~/.wbar"), "r") as wbarconfigfile:
         lines = wbarconfigfile.readlines()
     wbarconfigfile.close()
     i = 0
     self.names = []
     self.commands = {}
     for wbarconfigline in lines:
         wbarconfigline = wbarconfigline.strip()
         if wbarconfigline[:3] == "i: ":
             i += 1
             do_include = False
         if wbarconfigline[:3] == "c: " and wbarconfigline[3:7] != "wbar":
             self.commands[i] = wbarconfigline[3:]
             do_include = True
         if wbarconfigline[:3] == "t: " and do_include:
             self.names.append((wbarconfigline[3:], i))
     main_menu = gtk.Menu()
     for wbar_entry in self.names:
         main_menu_item = gtk.MenuItem(wbar_entry[0])
         main_menu_item.connect("activate", self.on_execute,
                                self.status_icon, wbar_entry[1])
         main_menu.append(main_menu_item)
     main_menu.show_all()
     main_menu.popup(None, None, gtk.status_icon_position_menu, 1,
                     gtk.get_current_event_time(), self.status_icon)
Example #28
0
    def popup(self, items = None):
        menu = _gtk.Menu()
        index = 0

        if _util.humanbool(self.options.get('show-current-selection', 'yes')) and len(self.history):
            item = _gtk.MenuItem("")
            item.get_children()[0].set_markup(
                "<b>%s</b>" % (self._printable(self.history.top, True),),
            )
            menu.append(item)
            menu.append(_gtk.SeparatorMenuItem())
            index += 1

        self._build_menu(menu, items or self.items())

        menu.show_all()
        menu.popup(
            None,
            None,
            None,
            1,
            _gtk.get_current_event_time(),
        )
        menu.set_active(index)
        return True
Example #29
0
 def __menu(self, view, library):
     path, col = view.get_cursor()
     header = col.header_name
     menu = view.Menu(header, self.browser, library)
     if menu is not None:
         view.popup_menu(menu, 0, gtk.get_current_event_time())
     return True
Example #30
0
    def do_url(self, about, url, data):
        try:
            gtk.show_uri(None, url, gtk.get_current_event_time())

        #For GTK < 2.14
        except:
            os.system('xdg-open %s &' % url)
Example #31
0
    def bpe(self, widget, event):
        '''called on button press event'''
        if (self.window == None):
            return
        if (event.button == 3 and self.menu != None):
            self._priox = event.x
            self._prioy = event.y
            self.menu.popup(None,
                            None,
                            None,
                            event.button,
                            gtk.get_current_event_time())

        #set button in true
        #clear the current selection and set this square as selected
        if(event.button == 1):
            self.button1_in = True
            index = self.getIndex(event.x, event.y)
            if ((event.state & gtk.gdk.SHIFT_MASK) and (self.last_selected != -1)):
                index += 1
                end = min(index,self.numSquares)
                for i in range(self.last_selected,end):
                    self.selected[i] = True
            else:
                if not(event.state & gtk.gdk.CONTROL_MASK):
                    self.resetSelected()
                if index < self.numSquares:
                    self.selected[index] = True
                    self.last_selected = index
            self.queue_draw()
        return False
Example #32
0
    def bpe(self, widget, event):
        '''called on button press event'''
        if (self.window == None):
            return
        if (event.button == 3 and self.menu != None):
            self._priox = event.x
            self._prioy = event.y
            self.menu.popup(None,
                            None,
                            None,
                            event.button,
                            gtk.get_current_event_time())

        #set button in true
        #clear the current selection and set this square as selected
        if(event.button == 1):
            self.button1_in = True
            index = self.getIndex(event.x, event.y)
            if ((event.state & gtk.gdk.SHIFT_MASK) and (self.last_selected != -1)):
                index += 1
                end = min(index,self.numSquares)
                for i in range(self.last_selected,end):
                    self.selected[i] = True
            else:
                if not(event.state & gtk.gdk.CONTROL_MASK):
                    self.resetSelected()
                if index < self.numSquares:
                    self.selected[index] = True
                    self.last_selected = index
            self.queue_draw()
        return False
Example #33
0
    def on_left_click(self):
        win = gajim.interface.roster.window
        if len(gajim.events.get_systray_events()) == 0:
            # No pending events, so toggle visible/hidden for roster window
            if win.get_property('visible') and (win.get_property(
            'has-toplevel-focus') or os.name == 'nt'):
                # visible in ANY virtual desktop?

                # we could be in another VD right now. eg vd2
                # and we want to show it in vd2
                if not gtkgui_helpers.possibly_move_window_in_current_desktop(
                win) and gajim.config.get('save-roster-position'):
                    x, y = win.get_position()
                    gajim.config.set('roster_x-position', x)
                    gajim.config.set('roster_y-position', y)
                win.hide() # else we hide it from VD that was visible in
            else:
                if not win.get_property('visible'):
                    win.show_all()
                    if gajim.config.get('save-roster-position'):
                        gtkgui_helpers.move_window(win,
                            gajim.config.get('roster_x-position'),
                            gajim.config.get('roster_y-position'))
                if not gajim.config.get('roster_window_skip_taskbar'):
                    win.set_property('skip-taskbar-hint', False)
                win.present_with_time(gtk.get_current_event_time())
        else:
            self.handle_first_event()
Example #34
0
 def __songs_popup_menu(self, songlist):
     path, col = songlist.get_cursor()
     header = col.header_name
     menu = self.songlist.Menu(header, self.browser, self.__library)
     if menu is not None:
         return self.songlist.popup_menu(menu, 0,
                 gtk.get_current_event_time())
Example #35
0
def show_section(section, screen=None):
    if library.uninstalled:
        root = library.get_root()
        uri = os.path.join(root, 'docs', 'manual', 'pt_BR')
        if section != '':
            uri += '/' + section + '.page'
    else:
        if library.get_resource_exists('stoq', 'docs', 'manual', 'pt_BR'):
            manual_dir = library.get_resource_filename(
                'stoq', 'docs', 'manual', 'pt_BR')
            if section:
                uri = os.path.join(manual_dir, section + '.page')
            else:
                uri = manual_dir
        else:
            uri = 'stoq'
            if section:
                uri += '?' + section

    if not screen:
        toplevel = get_current_toplevel()
        if toplevel:
            screen = toplevel.get_screen()

    try:
        gtk.show_uri(screen, 'ghelp:' + uri, gtk.get_current_event_time())
    except glib.GError:
        open_browser('http://doc.stoq.com.br/manual/%s/%s.html' % (
            stoq.short_version,
            section or 'index', ), screen)
Example #36
0
 def make_startup_id(self, key, ev_time = None):
     if not ev_time:
         ev_time = gtk.get_current_event_time()
     if not key:
         return "zeitgeist_TIME%d" % ev_time
     else:
         return "zeitgeist:%s_TIME%d" % (key, ev_time)
Example #37
0
    def activate(self, text=None):
        if self._window.is_active():
            return

        try:
            time = gtk.get_current_event().time
        except:
            LOGGER.warning("Using bogus timestamp.")
            time = gtk.get_current_event_time()

        workspace = self._window.get_workspace()
        if workspace != None and workspace.is_virtual():
            if not self._window.is_in_viewport(workspace):
                pos_x = workspace.get_viewport_x() + self._window.get_geometry(
                )[0]
                pos_y = workspace.get_viewport_y() + self._window.get_geometry(
                )[1]
                self._window.get_screen().move_viewport(pos_x, pos_y)

        if hasattr(self._window.get_workspace(),
                   'activate') and self._window.get_workspace(
                   ) != self._window.get_screen().get_active_workspace():
            self._window.get_workspace().activate(time)

        self._window.activate(time)
Example #38
0
 def make_startup_id(self, key, ev_time = None):
     if not ev_time:
         ev_time = gtk.get_current_event_time()
     if not key:
         return "GIMMIE_TIME%d" % ev_time
     else:
         return "GIMMIE:%s_TIME%d" % (key, ev_time)
Example #39
0
 def __toggled_cb(self, widget):
     menu = self.__menu
     if widget.get_active() and menu:
         time = gtk.get_current_event_time()
         qltk.popup_menu_under_widget(menu, widget, 0, time)
     elif menu:
         menu.popdown()
 def _item_popup_cb(self, self_, brush):
     time = gtk.get_current_event_time()
     self.menu = BrushPopupMenu(self, brush)
     self.menu.show_all()
     self.menu.popup(
         parent_menu_shell=None, parent_menu_item=None, func=None, button=3, activate_time=time, data=None
     )
Example #41
0
 def __popup(self, safter, widget, button=3, time=None):
     time = time or gtk.get_current_event_time()
     if widget:
         return qltk.popup_menu_under_widget(safter, widget, button, time)
     else:
         safter.popup(None, None, None, button, time)
     return True
Example #42
0
    def attach_view(self, menuitem, window):
        def relocate_view(item, v, d):
            # Reference the widget so that it is not destroyed
            if hasattr(v, 'reparent_prepare'):
                v.reparent_prepare()
            wid = v.widget
            wid.hide()
            wid.get_parent().remove(wid)
            if d in ('south', 'east', 'west', 'fareast'):
                v._destination = d
                self.controller.gui.viewbook[d].add_view(v, name=v._label)
                window.disconnect(window.cleanup_id)
                window.destroy()
            wid.show()
            if hasattr(v, 'reparent_done'):
                v.reparent_done()
            return True

        menu = gtk.Menu()
        for (label,
             destination) in ((_("...embedded east of the video"), 'east'),
                              (_("...embedded west of the video"), 'west'),
                              (_("...embedded south of the video"), 'south'),
                              (_("...embedded at the right of the window"),
                               'fareast')):
            item = gtk.MenuItem(label, use_underline=False)
            item.connect('activate', relocate_view, self, destination)
            menu.append(item)

        menu.show_all()
        menu.popup(None, None, None, 0, gtk.get_current_event_time())
        return True
 def action_select_or_minimize_window(self, widget=None,
                                      event=None, minimize=True):
     # The window is activated, unless it is already
     # activated, then it's minimized. Minimized
     # windows are unminimized. The workspace
     # is switched if the window is on another
     # workspace.
     if event:
         t = event.time
     else:
         t = gtk.get_current_event_time()
     if self.window.get_workspace() is not None \
     and self.screen.get_active_workspace() != self.window.get_workspace():
         self.window.get_workspace().activate(t)
     if not self.window.is_in_viewport(self.screen.get_active_workspace()):
         win_x,win_y,win_w,win_h = self.window.get_geometry()
         self.screen.move_viewport(win_x-(win_x%self.screen.get_width()),
                                   win_y-(win_y%self.screen.get_height()))
         # Hide popup since mouse movment won't
         # be tracked during compiz move effect
         # which means popup list can be left open.
         self.emit('popup-hide', 'viewport-change')
     if self.window.is_minimized():
         self.window.unminimize(t)
     elif self.window.is_active() and minimize:
         self.window.minimize()
     else:
         self.window.activate(t)
Example #44
0
    def popup (self, time=None):
        if not (self.widgetToAlignWith.flags() & gtk.REALIZED):
            return
        if (self.flags()&gtk.MAPPED):
            return
        if not (self.widgetToAlignWith.flags()&gtk.MAPPED):
            return
        if len(self.view.get_model()) <= 0:
            return
        
        self.ignore_enter = True
        
        if not self.window_group :
            target_toplevel = self.widgetToAlignWith.get_toplevel()
            if target_toplevel != None and target_toplevel.group != None:
                target_toplevel.group.add_window (self)
                self.target_group = target_toplevel.group
            elif target_toplevel is not None:
                self.window_group = gtk.WindowGroup ()
                self.window_group.add_window (target_toplevel)
                self.window_group.add_window (self)
            else:
                LOGGER.warning("CuemiacEntryPopup : No toplevel window for widgetToAlignWith!")
                return
                    
        self.update_position()
        gtk.Window.show_all (self) # We issue warnings on the native methods, so bypass that

        # For grabbing to work we need the view realized
        if not (self.flags() & gtk.REALIZED):
            self.realize ()

        # Grab pointer
        self.grab_add()
        gtk.gdk.pointer_grab(
            self.window, True,
            gtk.gdk.BUTTON_PRESS_MASK|
                gtk.gdk.BUTTON_RELEASE_MASK|
                gtk.gdk.POINTER_MOTION_MASK,
            None, None, gtk.get_current_event_time())
        
        gtk.gdk.keyboard_grab(self.window, True,
                              gtk.get_current_event_time())
        
        first = self.view.get_model().get_iter_first()
        if first != None:
            self.view.get_selection().select_iter(first)
Example #45
0
    def popup(self, time=None):
        if not (self.widgetToAlignWith.flags() & gtk.REALIZED):
            return
        if (self.flags() & gtk.MAPPED):
            return
        if not (self.widgetToAlignWith.flags() & gtk.MAPPED):
            return
        if len(self.view.get_model()) <= 0:
            return

        self.ignore_enter = True

        if not self.window_group:
            target_toplevel = self.widgetToAlignWith.get_toplevel()
            if target_toplevel != None and target_toplevel.group != None:
                target_toplevel.group.add_window(self)
                self.target_group = target_toplevel.group
            elif target_toplevel is not None:
                self.window_group = gtk.WindowGroup()
                self.window_group.add_window(target_toplevel)
                self.window_group.add_window(self)
            else:
                LOGGER.warning(
                    "CuemiacEntryPopup : No toplevel window for widgetToAlignWith!"
                )
                return

        self.update_position()
        gtk.Window.show_all(
            self)  # We issue warnings on the native methods, so bypass that

        # For grabbing to work we need the view realized
        if not (self.flags() & gtk.REALIZED):
            self.realize()

        # Grab pointer
        self.grab_add()
        gtk.gdk.pointer_grab(
            self.window, True, gtk.gdk.BUTTON_PRESS_MASK
            | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK, None,
            None, gtk.get_current_event_time())

        gtk.gdk.keyboard_grab(self.window, True, gtk.get_current_event_time())

        first = self.view.get_model().get_iter_first()
        if first != None:
            self.view.get_selection().select_iter(first)
Example #46
0
    def __popup_menu(self, view, parent):
        menu = gtk.Menu()

        view.ensure_popup_selection()
        model, rows = view.get_selection().get_selected_rows()
        can_change = min([model[path][CANEDIT] for path in rows])

        items = [
            SplitDisc,
            SplitTitle,
            SplitPerformer,
            SplitArranger,
            SplitValues,
            SplitPerformerFromTitle,
            SplitOriginalArtistFromTitle,
        ]
        items.extend(self.handler.plugins)
        items.sort(key=lambda item: (item._order, item.__name__))

        if len(rows) == 1:
            row = model[rows[0]]

            value = row[VALUE].decode("utf-8")
            text = util.unescape(value)
            multi = value.split("<")[0] != value

            for Item in items:
                if Item.tags and row[TAG] not in Item.tags:
                    continue

                try:
                    b = Item(row[TAG], text)
                except:
                    util.print_exc()
                else:
                    b.connect("activate", self.__menu_activate, view)

                    if not min(map(self.__songinfo.can_change, b.needs) + [1]) or multi:
                        b.set_sensitive(False)

                    menu.append(b)

            if menu.get_children():
                menu.append(gtk.SeparatorMenuItem())

        b = gtk.ImageMenuItem(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU)
        b.connect("activate", self.__remove_tag, view)
        keyval, mod = gtk.accelerator_parse("Delete")
        menu.__accels = gtk.AccelGroup()
        b.add_accelerator("activate", menu.__accels, keyval, mod, gtk.ACCEL_VISIBLE)
        menu.append(b)

        menu.show_all()
        # Setting the menu itself to be insensitive causes it to not
        # be dismissed; see #473.
        for c in menu.get_children():
            c.set_sensitive(can_change and c.get_property("sensitive"))
        menu.connect("selection-done", lambda m: m.destroy())
        return view.popup_menu(menu, 3, gtk.get_current_event_time())
Example #47
0
    def open_chat(self, jid, account, message):
        """
        Shows the tabbed window for new message to 'jid', using account (optional)
        'account'
        """
        if not jid:
            raise dbus_support.MissingArgument()
        jid = self._get_real_jid(jid, account)
        try:
            jid = helpers.parse_jid(jid)
        except Exception:
            # Jid is not conform, ignore it
            return DBUS_BOOLEAN(False)

        minimized_control = None
        if account:
            accounts = [account]
        else:
            accounts = gajim.connections.keys()
            if len(accounts) == 1:
                account = accounts[0]
        connected_account = None
        first_connected_acct = None
        for acct in accounts:
            if gajim.connections[acct].connected > 1: # account is  online
                contact = gajim.contacts.get_first_contact_from_jid(acct, jid)
                if gajim.interface.msg_win_mgr.has_window(jid, acct):
                    connected_account = acct
                    break
                # jid is in roster
                elif contact:
                    minimized_control = \
                        jid in gajim.interface.minimized_controls[acct]
                    connected_account = acct
                    break
                # we send the message to jid not in roster, because account is
                # specified, or there is only one account
                elif account:
                    connected_account = acct
                elif first_connected_acct is None:
                    first_connected_acct = acct

        # if jid is not a conntact, open-chat with first connected account
        if connected_account is None and first_connected_acct:
            connected_account = first_connected_acct

        if minimized_control:
            gajim.interface.roster.on_groupchat_maximized(None, jid,
                connected_account)

        if connected_account:
            gajim.interface.new_chat_from_jid(connected_account, jid, message)
            # preserve the 'steal focus preservation'
            win = gajim.interface.msg_win_mgr.get_window(jid,
                    connected_account).window
            if win.get_property('visible'):
                win.window.focus(gtk.get_current_event_time())
            return DBUS_BOOLEAN(True)
        return DBUS_BOOLEAN(False)
Example #48
0
 def _on_help_clicked(self, widget):
     """Gtk+ callback"""
     try:
         gtk.show_uri(self.mainWindow.get_screen(), "ghelp:glchess",
                      gtk.get_current_event_time())
     except gobject.GError, e:
         # TODO: This should be a pop-up dialog
         print _('Unable to display help: %s') % str(e)
Example #49
0
    def on_previews_box_popup_menu(self, menu):
        """
            Shows the cover menu upon keyboard interaction
        """
        paths = self.previews_box.get_selected_items()

        if paths:
            self.menu.popup(None, None, None, 0, gtk.get_current_event_time())
Example #50
0
def showPopupMenu(*_):
    menu = gtk.Menu()
    menu_item = gtk.MenuItem('Quit')
    menu_item.connect('activate', lambda *_, **__: gtk.main_quit())
    menu.append(menu_item)
    menu_item.show()
    menu.show()
    menu.popup(None, None, None, 1, gtk.get_current_event_time())
Example #51
0
 def on_status_icon_menu(self, statusicon, button, activate_time):
     popup_menu = gtk.Menu()
     quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
     quit_item.connect("activate", self.on_quit)
     popup_menu.append(quit_item)
     popup_menu.show_all()
     time = gtk.get_current_event_time()
     popup_menu.popup(None, None, None, 0, time)
Example #52
0
 def on_right_click(self, button, time, data):
     quit_menu = gtk.Menu()
     quit_menu_item = gtk.MenuItem("Quit")
     quit_menu_item.connect("activate", self.on_quit, self.status_icon)
     quit_menu.append(quit_menu_item)
     quit_menu.show_all()
     quit_menu.popup(None, None, gtk.status_icon_position_menu, 1,
                     gtk.get_current_event_time(), self.status_icon)
Example #53
0
 def leftclick(self, status_icon):
     if not self.thr.is_alive():
         self.thr.start()
     button = 1
     position = gtk.status_icon_position_menu
     time = gtk.get_current_event_time()
     # self.nm_menu().popup(None, None, position, button, time, status_icon)
     self.nmMenu.popup(None, None, position, button, time, status_icon)
Example #54
0
    def open_url(self, widget, url):
        if url.strip() != '':
            try:
                gtk.show_uri(None, url, gtk.get_current_event_time())

            #For GTK < 2.14
            except:
                os.system('xdg-open "%s" &' % url)
Example #55
0
 def show_uri(self, uri):
     if sys.platform == 'win32':
         os.startfile(uri)
     elif sys.platform == 'darwin':
         os.spawnl(os.P_NOWAIT, '/usr/bin/open', uri)
     else:
         gtk.show_uri(gtk.gdk.screen_get_default(), uri,
                      gtk.get_current_event_time())
Example #56
0
    def popup_menu(self, popup=True):
        """Display the popup menu.

        If self.extend_popup_menu is defined, it must be a method
        which will be called with the menu and the element as
        parameters, in order to extend the popup menu with contextual
        items.

        @param popup: should the menu be immediately displayed as a popup menu
        @type popup: boolean
        """
        p=self.controller.player

        menu = gtk.Menu()

        def goto(it, t):
            c=self.controller
            pos = c.create_position (value=t,
                                     key=c.player.MediaTime,
                                     origin=c.player.AbsolutePosition)
            c.update_status (status="set", position=pos)
            return True

        def save_as(it):
            self.controller.gui.save_snapshot_as(self.value)
            return True

        item = gtk.MenuItem(_("Play"))
        item.connect('activate', goto, self.value)
        menu.append(item)

        item = gtk.MenuItem(_("Refresh snapshot"))
        item.connect('activate', self.refresh_snapshot)
        menu.append(item)

        item = gtk.MenuItem(_("Save as..."))
        item.connect('activate', save_as)
        menu.append(item)

        if self.callback is not None:
            item = gtk.MenuItem(_("Use current player position"))
            item.connect('activate', lambda i: self.set_value(p.current_position_value))
            if p.status != p.PauseStatus and p.status != p.PlayingStatus:
                item.set_sensitive(False)
            menu.append(item)

            item = gtk.MenuItem(_("Adjust timestamp"))
            item.connect('activate', lambda i: self.set_value(self.controller.gui.adjust_timestamp(self.get_value())))
            menu.append(item)

        if self.extend_popup_menu is not None:
            self.extend_popup_menu(menu, self)

        menu.show_all()

        if popup:
            menu.popup(None, None, None, 0, gtk.get_current_event_time())
        return menu
Example #57
0
def main():
    parser = OptionParser()
    parser.add_option("-m", "--move-away", action="store_true", default=False,
                      dest="clear_workspace", 
                      help="iconify to other workspace to avoid crowding panel")
    (options, args) = parser.parse_args()

    screen = wnck.screen_get_default()
    while gtk.events_pending():
        gtk.main_iteration()

    recollMain = ""
    recollwins = [];
    for window in screen.get_windows():
        if window.get_class_group().get_name() == "Recoll":
            if window.get_name() == "Recoll":
                recollMain = window
            recollwins.append(window)

    if not recollMain:
        os.system("recoll&")
        sys.exit(0)

    # Check the main window state, and either activate or minimize all
    # recoll windows.
    workspace = screen.get_active_workspace()
    if not recollMain.is_visible_on_workspace(workspace):
        for win in recollwins:
            win.move_to_workspace(workspace)
            if win != recollMain:
                win.unminimize(gtk.get_current_event_time())
        recollMain.activate(gtk.get_current_event_time())
    else:
        otherworkspace = None
        if options.clear_workspace:
            # We try to minimize to another workspace
            wkspcs = screen.get_workspaces()
            for wkspc in wkspcs:
                if wkspc.get_number() != workspace.get_number():
                    otherworkspace = wkspc
                    break
        for win in recollwins:
            if otherworkspace:
                win.move_to_workspace(otherworkspace)
            win.minimize()
Example #58
0
    def roster_raise(self, widget, data=None):
        win = gajim.interface.roster.window
        if win.get_property("visible") and self.windowstate != 'iconified':
            gobject.idle_add(win.hide)
        else:
            win.present()
            self.windowstate = 'shown'

        win.window.focus(gtk.get_current_event_time())