def _row_click(self, widget, event):
        '''
        event called when clicking on a row
        '''
        print('_row_click')

        try:
            treepath, treecolumn, cellx, celly = self.get_path_at_pos(event.x, event.y)
        except:
            return

        active_object = self.artist_manager.model.get_from_path(treepath)

        if not isinstance(active_object, Album):
            self.source.artist_info.emit('selected', active_object.name, None)
            if self.icon_automatic:
                # reset counter so that we get correct double click action for albums
                self.source.click_count = 0

            if treecolumn != self.get_expander_column():
                if self.row_expanded(treepath) and event.button == 1 and self._last_row_was_artist:
                    self.collapse_row(treepath)
                else:
                    self.expand_row(treepath, False)

                self._last_row_was_artist = True

                if event.button == 3:
                    # on right click
                    # display popup

                    self.artist_popup_menu.popup(self.source, 'popup_menu', 3,
                                                 Gtk.get_current_event_time())
            print('_row click artist exit')
            return

        if event.button == 1:
            # on click
            # to expand the entry view
            ctrl = event.state & Gdk.ModifierType.CONTROL_MASK
            shift = event.state & Gdk.ModifierType.SHIFT_MASK

            if self.icon_automatic and not self._last_row_was_artist:
                self.source.click_count += 1 if not ctrl and not shift else 0

            if self.source.click_count == 1:
                Gdk.threads_add_timeout(GLib.PRIORITY_DEFAULT_IDLE, 250,
                                        self.source.show_hide_pane, active_object)

        elif event.button == 3:
            # on right click
            # display popup

            self.popup.popup(self.source, 'popup_menu', 3,
                             Gtk.get_current_event_time())

        self._last_row_was_artist = False

        print('_row_click album exit')
        return
Beispiel #2
0
	def keyEvent(self, key, val):
		tp = Gdk.EventType.BUTTON_PRESS if val else Gdk.EventType.BUTTON_RELEASE
		event = Gdk.Event.new(tp)
		event.button = int(key) - Keys.BTN_LEFT + 1
		window, event.x, event.y = Gdk.Window.at_pointer()
		screen, x, y, mask = Gdk.Display.get_default().get_pointer()
		event.x_root, event.y_root = x, y
		
		gtk_window = None
		for w in Gtk.Window.list_toplevels():
			if w.get_window():
				if window.get_toplevel().get_xid() == w.get_window().get_xid():
					gtk_window = w
					break
		if gtk_window:
			if gtk_window.get_type_hint() == Gdk.WindowTypeHint.COMBO:
				# Special case, clicking on combo does nothing, so
				# pressing "space" is emulated instead.
				if not val:
					return
				event = Gdk.Event.new(Gdk.EventType.KEY_PRESS)
				event.time = Gtk.get_current_event_time()
				event.hardware_keycode = 65
				event.keyval = Gdk.KEY_space
				event.window = self.mapper.target_window
		event.time = Gtk.get_current_event_time()
		event.window = window
		event.set_device(self.device)
		Gtk.main_do_event(event)
Beispiel #3
0
    def on_treeview_extension_show_context_menu(self, treeview, event=None):
        selection = treeview.get_selection()
        model, paths = selection.get_selected_rows()
        container = model.get_value(model.get_iter(paths[0]), self.C_EXTENSION)

        if not container:
            return

        menu = Gtk.Menu()

        if container.metadata.doc:
            menu_item = Gtk.MenuItem(_('Documentation'))
            menu_item.connect('activate', self.open_weblink,
                container.metadata.doc)
            menu.append(menu_item)

        menu_item = Gtk.MenuItem(_('Extension info'))
        menu_item.connect('activate', self.show_extension_info, model, container)
        menu.append(menu_item)

        if container.metadata.payment:
            menu_item = Gtk.MenuItem(_('Support the author'))
            menu_item.connect('activate', self.open_weblink, container.metadata.payment)
            menu.append(menu_item)

        menu.show_all()
        if event is None:
            func = TreeViewHelper.make_popup_position_func(treeview)
            menu.popup(None, None, func, None, 3, Gtk.get_current_event_time())
        else:
            menu.popup(None, None, None, None, 3, Gtk.get_current_event_time())

        return True
Beispiel #4
0
 def bench_func(n):
     times = []
     for i in xrange(n):
         t = time.time()
         Gtk.get_current_event_time()
         Gtk.rc_get_theme_dir()[:]
         t = time.time() - t
         times.append(t)
     return times
    def show_popup(self, align=True):
        """
        show the current popup menu
        """

        if align:
            self._popup_menu.popup(None, None, self._popup_callback, self, 0, Gtk.get_current_event_time())
        else:
            self._popup_menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
Beispiel #6
0
    def __popup_menu(self, view, library):
        model, itr = view.get_selection().get_selected()
        if itr is None:
            return
        songs = list(model[itr][0])
        songs = filter(lambda s: isinstance(s, AudioFile), songs)
        menu = SongsMenu(library, songs, playlists=False, remove=False, ratings=False)
        menu.preseparate()

        def _remove(model, itr):
            playlist = model[itr][0]
            dialog = ConfirmRemovePlaylistDialog(self, playlist)
            if dialog.run() == Gtk.ResponseType.YES:
                playlist.delete()
                model.get_model().remove(model.convert_iter_to_child_iter(itr))

        rem = MenuItem(_("_Delete"), Icons.EDIT_DELETE)
        connect_obj(rem, "activate", _remove, model, itr)
        menu.prepend(rem)

        def _rename(path):
            self.__render.set_property("editable", True)
            view.set_cursor(path, view.get_columns()[0], start_editing=True)

        ren = qltk.MenuItem(_("_Rename"), Icons.EDIT)
        qltk.add_fake_accel(ren, "F2")
        connect_obj(ren, "activate", _rename, model.get_path(itr))
        menu.prepend(ren)

        playlist = model[itr][0]
        PLAYLIST_HANDLER.populate_menu(menu, library, self, [playlist])
        menu.show_all()
        return view.popup_menu(menu, 0, Gtk.get_current_event_time())
Beispiel #7
0
 def __view_source__cb(self, menu_item):
     setup_view_source(self._home_activity)
     shell_model = shell.get_model()
     if self._home_activity is not shell_model.get_active_activity():
         self._home_activity.get_window().activate(
             Gtk.get_current_event_time())
     self.emit('done')
Beispiel #8
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
Beispiel #9
0
 def help_callback(self, action, parameter):
     if meld.conf.UNINSTALLED:
         uri = "http://meldmerge.org/help/"
     else:
         uri = "help:meld"
     Gtk.show_uri(Gdk.Screen.get_default(), uri,
                  Gtk.get_current_event_time())
Beispiel #10
0
    def showGUI(self):
        """Show the Orca Find dialog. This assumes that the GUI has
        already been created.
        """

        findDialog = self.get_widget("findDialog")
        ts = orca_state.lastInputEvent.timestamp
        if ts == 0:
            ts = Gtk.get_current_event_time()
        findDialog.present_with_time(ts)

        # Populate the dialog box from the previous searchQuery, should
        # one exist.  Note:  This is necessary because we are destroying
        # the dialog (rather than merely hiding it) before performing the
        # search.

        try:
            searchForEntry = self.get_widget("searchForEntry")
            searchForEntry.set_text(orca_state.searchQuery.searchString)
            searchForEntry.select_region(0, len(searchForEntry.get_text()))
            if orca_state.searchQuery.startAtTop:
                self.get_widget("topRadioButton").set_active(True)
            self.get_widget("matchCaseCheckbox").set_active(\
                orca_state.searchQuery.caseSensitive)
            self.get_widget("matchEntireWordCheckbox").set_active(\
                orca_state.searchQuery.matchEntireWord)
            self.get_widget("wrapAroundCheckbox").set_active(\
                orca_state.searchQuery.windowWrap)
            self.get_widget("searchBackwardsCheckbox").set_active(\
                orca_state.searchQuery.searchBackwards)
        except:
            pass
 def listbox_row_activated(self, listbox, listboxrow):
     """ docker container has been selected so open terminal """
     self.current_container_id = listboxrow.get_name()
     self.current_container_info = get_container_info(self.current_container_id)
     
     self.menu.show_all()
     self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
Beispiel #12
0
    def __popup_menu(self, view, fs):
        # get all songs for the selection
        filenames = [normalize_path(f, canonicalise=True)
                     for f in fs.get_selected_paths()]
        maybe_songs = [self.__library.get(f) for f in filenames]
        songs = [s for s in maybe_songs if s]

        if songs:
            menu = self.pm.Menu(self.__library, songs)
            if menu is None:
                menu = Gtk.Menu()
            else:
                menu.prepend(SeparatorMenuItem())
        else:
            menu = Gtk.Menu()

        b = TrashMenuItem()
        b.connect('activate', self.__delete, filenames, fs)
        menu.prepend(b)

        def selection_done_cb(menu):
            menu.destroy()

        menu.connect('selection-done', selection_done_cb)
        menu.show_all()
        return view.popup_menu(menu, 0, Gtk.get_current_event_time())
Beispiel #13
0
    def _on_tools_clicked(self, button=None):
        if not self._tools_menu:
            self._tools_menu = Gtk.Menu()
            self._tools_menu.attach_to_widget(self._tools)

            unused_item = Gtk.CheckMenuItem(C_('option-entry|indicators', 'Show unused items'))
            unused_item.connect('toggled', self._tools_show_unused_toggled)
            self._tools_menu.append(unused_item)

            header_item = Gtk.MenuItem(C_('option-entry|indicators', 'Predefined templates:'))
            header_item.props.sensitive = False
            self._tools_menu.append(Gtk.SeparatorMenuItem())
            self._tools_menu.append(header_item)

            templates = (
                ('host ~ clock, language, session, power',
                 '~host;~spacer;~language;~session;~power'),
                ('host ~ clock ~ language, session, a11y, power',
                 '~host;~spacer;~clock;~spacer;~language;~session;~a11y;~power'),
                ('host, layout, clock ~ language, session, power',
                 '~host;~layout;~clock;~spacer;~language;~session;~power'))

            for title, value in templates:
                item = Gtk.MenuItem(title)
                item.connect('activate', self._on_tools_template_clicked, value)
                self._tools_menu.append(item)

            self._tools_menu.show_all()
        self._tools_menu.popup(None, None, None, None, 0,
                               Gtk.get_current_event_time())
Beispiel #14
0
def launch(cmd, paths=None, system=False, icon_name=None, sn=True, name="blueman"):
    '''Launch a gui app with starup notification'''
    display = Gdk.Display.get_default()
    timestamp = Gtk.get_current_event_time()
    context = display.get_app_launch_context()
    context.set_timestamp(timestamp)
    if sn: flags = Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION
    else: flags = Gio.AppInfoCreateFlags.NONE

    env = os.environ
    env["BLUEMAN_EVENT_TIME"] = str(timestamp)

    if not system:
        cmd = os.path.join(BIN_DIR, cmd)
    else:
        cmd = os.path.expanduser(cmd)

    if paths:
        files = [Gio.File.new_for_commandline_arg(p) for p in paths]
    else:
        files = None

    if icon_name:
        icon = Gio.Icon.new_for_string(icon_name)
        context.set_icon(icon)

    appinfo = Gio.AppInfo.create_from_commandline(cmd, name, flags)
    launched = appinfo.launch(files, context)

    if not launched:
        dprint("Command: %s failed" % cmd)

    return launched
Beispiel #15
0
 def on_button_add_clicked(self, button):
     songs = [song_row_to_dict(s) for s in self.liststore if s[0]]
     self.menu = self.app.playlist.new_playlist_menu()
     self.menu.show_all()
     self.menu.songs = songs
     self.menu.popup(None, None, None, None, 1,
                     Gtk.get_current_event_time())
Beispiel #16
0
 def do_show_entry_view_popup(self, view, over_entry):
         if view == self.__sidebar:
                 menu = Gtk.Menu.new_from_model(self.__sidebar_menu)
         else:
                 menu = Gtk.Menu.new_from_model(self.__source_menu)
         menu.attach_to_widget(self, None)
         menu.popup(None, None, None, None, 3, Gtk.get_current_event_time())
Beispiel #17
0
    def search(self,button):
        print 'search clicked'
        self.popup_menu=Gtk.Menu()
        s=self.search_field.get_text()
        if s:
            #thread.start_new_thread(scrape_test.main,(s,))
            pool = ThreadPool(processes=1)
            async_result = pool.apply_async(scrape_test.main, (s,)) # tuple of args for foo
            self.href, title, size, seeders, leechers= async_result.get() 
            self.popup_menu.set_title("Torrents")
            print self.popup_menu.get_title()
            for i in range(len(self.href)):
                #print str(i+1)+'. '+title[i]+' '+size[i]+' '+seeders[i]+' '+leechers[i]
                menu_item = Gtk.MenuItem(str(i+1)+'. '+title[i]+'     '+size[i]+' '+seeders[i]+'-SEEDERS '+leechers[i]+'-LEECHERS')
                menu_item.connect("activate",self.item_activated,i)
                self.popup_menu.append(menu_item)
            self.popup_menu.show_all()
            self.popup_menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())

        else:
            print 'EMPTY'
            self.label.set_text("Search field is empty")
            #self.dialog=self.builder.get_object('dialog1')
            v=self.dialog.run()
            if v==1:
                self.dialog.hide()
Beispiel #18
0
    def on_button_clicked(self, widget):
        screen = widget.get_screen()
        self.time = Gtk.get_current_event_time()
        self.device = Gtk.get_current_event_device()

        self.grab_widget = Gtk.Window(Gtk.WindowType.POPUP)
        self.grab_widget.set_screen(screen)
        self.grab_widget.resize(1, 1)
        self.grab_widget.move(-100, -100)
        self.grab_widget.show()

        self.grab_widget.add_events(Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK)
        toplevel = widget.get_toplevel()

        if isinstance(toplevel, Gtk.Window):
            if toplevel.has_group():
                toplevel.add_window(grab_widget)

        window = self.grab_widget.get_window()

        picker_cursor = Gdk.Cursor(screen.get_display(), Gdk.CursorType.CROSSHAIR);

        grab_status = self.device.grab(window, Gdk.GrabOwnership.APPLICATION, False,
                                       Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK,
                                       picker_cursor, self.time)

        if grab_status != Gdk.GrabStatus.SUCCESS:
            return

        Gtk.device_grab_add(self.grab_widget, self.device, True)

        self.bp_handler = self.grab_widget.connect("button-press-event", self.mouse_press)
        self.kp_handler = self.grab_widget.connect("key-press-event", self.key_press)
 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())
Beispiel #20
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
Beispiel #21
0
def show_url(url):
    """Open any @url with default viewer"""
    try:
        pretty.print_debug(__name__, "show_url", url)
        return Gtk.show_uri(Gdk.Screen.get_default(), url, Gtk.get_current_event_time())
    except GLib.GError as exc:
        pretty.print_error(__name__, "Gtk.show_uri:", exc)
Beispiel #22
0
 def leftclick(self, status_icon):
     if not self.thr.is_alive():
         self.thr.start()
     button = 1
     time = Gtk.get_current_event_time()
     position = Gtk.StatusIcon.position_menu
     self.nm_menu().popup(None, None, position, status_icon, button, time)
 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.SelectionMode.NONE)
     self.set_cursor(path, None, False)
     selection.set_mode(gtk.SelectionMode.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, extra_data, button, time)
   return True
Beispiel #24
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)
Beispiel #25
0
    def on_toolbar1_popup_context_menu(self, toolbar, x, y, button):
        menu = self.toolbar1_popup

        def _posfunc(*a):
            return x, y, True
        time = Gtk.get_current_event_time()
        menu.popup(None, None, _posfunc, None, button, time)
Beispiel #26
0
 def on_button_press(self, widget, event):
     if event.button == 3:
         self.popup.show_all()
         self.popup.popup(None, None, None, None, 3,
                          Gtk.get_current_event_time())
     elif event.button == 1 and event.get_click_count()[1] == 2:
         self.ok_index()
Beispiel #27
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 = Gdk.Screen.get_default()
            active_window_type = screen.get_active_window().get_type_hint()
            if active_window_type != Gdk.WindowTypeHint.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())
Beispiel #28
0
    def popup_playlist_menu(self, button, songs):
        menu = self.playlist_menu
        while len(menu.get_children()) > 0:
            menu.remove(menu.get_children()[0])

        for item in self.liststore_left:
            if item[1] in ('Cached', 'Caching'):
                continue
            menu_item = Gtk.MenuItem(item[0])
            menu_item.list_name = item[1]
            menu_item.connect('activate', self.on_menu_item_activated)
            menu.append(menu_item)

        if self.playlist_advice_disname:
            sep_item = Gtk.SeparatorMenuItem()
            menu.append(sep_item)
            advice_item = Gtk.MenuItem('+ ' + self.playlist_advice_disname)
            advice_item.connect('activate',
                    self.on_advice_menu_item_activated)
            advice_item.set_tooltip_text(
                    _('Create this playlist and add songs into it'))
            menu.append(advice_item)

        menu.songs = songs
        menu.show_all()
        menu.popup(None, None, None, None, 1, 
                Gtk.get_current_event_time())
Beispiel #29
0
    def showGUI(self):
        self._gui.show_all()

        ts = orca_state.lastInputEventTimestamp
        if ts == 0:
            ts = Gtk.get_current_event_time()
        self._gui.present_with_time(ts)
Beispiel #30
0
    def copy_dom0_clipboard(self, *_args, **_kwargs):
        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
        text = clipboard.wait_for_text()

        if not text:
            self.notify("dom0 clipboard is empty!")
            return

        try:
            fd = os.open(APPVIEWER_LOCK, os.O_RDWR | os.O_CREAT, 0o0666)
        except Exception:  # pylint: disable=broad-except
            self.notify("Error while accessing Qubes clipboard!")
        else:
            try:
                fcntl.flock(fd, fcntl.LOCK_EX)
            except Exception:  # pylint: disable=broad-except
                self.notify("Error while locking Qubes clipboard!")
                os.close(fd)
            else:
                try:
                    with open(DATA, "w") as contents:
                        contents.write(text)
                    with open(FROM, "w") as source:
                        source.write("dom0")
                    with open(XEVENT, "w") as timestamp:
                        timestamp.write(str(Gtk.get_current_event_time()))
                except Exception as ex:  # pylint: disable=broad-except
                    self.notify("Error while writing to "
                                "Qubes clipboard!\n{0}".format(str(ex)))
                fcntl.flock(fd, fcntl.LOCK_UN)
                os.close(fd)
Beispiel #31
0
def show_uri(parent, link):
    screen = parent.get_screen()
    Gtk.show_uri(screen, link, Gtk.get_current_event_time())
Beispiel #32
0
def _get_startup_id():
    from quodlibet import app
    app_name = type(app.window).__name__
    return "%s_TIME%d" % (app_name, Gtk.get_current_event_time())
Beispiel #33
0
    def editor_drag_received(self, widget, context, x, y, selection,
                             targetType, time):
        """Handle the drop from an annotation to the editor.
        """
        # FIXME: Upon DND, TextView receives the event twice. Some
        # posts from 2004 signal the same problem, some hacks can be
        # found in existing code :
        #   widget.emit_stop_by_name ("drag-data-received")
        #   context.finish(False, False, time)
        #   widget.stop_emission("drag-data-received")
        # but none of them seems to work here. Just use a basic approach,
        # imagining that nobody is fast enough to really do two DNDs
        # at the same time.
        # But on win32, timestamp is always 0. So we must use x and y information as well.
        if time == self.last_dndtime and x == self.last_x and y == self.last_y:
            return True
        self.last_dndtime = time
        self.last_x = x
        self.last_y = y

        x, y = self.editor.window_to_buffer_coords(Gtk.TextWindowType.TEXT,
                                                   *widget.get_pointer())
        it = self.editor.get_iter_at_location(x, y)
        self.editor.get_buffer().place_cursor(it.iter)

        if targetType == config.data.target_type['annotation']:
            for uri in str(selection.get_data(), 'utf8').split('\n'):
                source = self.controller.package.annotations.get(uri)
                if source is None:
                    return True
                m = Gtk.Menu()
                for (title, choice) in (
                    (_("Snapshot only"), [
                        'link',
                        'snapshot',
                    ]),
                    (_("Overlayed snapshot only"), [
                        'link',
                        'overlay',
                    ]),
                    (_("Timestamp only"), [
                        'link',
                        'timestamp',
                    ]),
                    (_("Snapshot+timestamp"),
                     ['link', 'snapshot', 'timestamp']),
                    (_("Annotation content"), ['link', 'content']),
                ):
                    i = Gtk.MenuItem(title)
                    i.connect(
                        'activate',
                        (lambda it, ann, data: self.insert_annotation_content(
                            data, ann, focus=True)), source, choice)
                    m.append(i)
                m.show_all()
                m.popup(None, None, None, 0, Gtk.get_current_event_time())
            return True
        elif targetType == config.data.target_type['annotation-type']:
            for uri in str(selection.get_data(), 'utf8').split('\n'):
                source = self.controller.package.annotationTypes.get(uri)
                if source is None:
                    return True
                m = Gtk.Menu()
                for (title, choice) in (
                    (_("as a list"), ['list']),
                    (_("as a grid"), ['grid']),
                    (_("as a table"), ['table']),
                    (_("as a transcription"), ['transcription']),
                ):
                    i = Gtk.MenuItem(title)
                    i.connect(
                        'activate',
                        (lambda it, at, data: self.
                         insert_annotationtype_content(data, at, focus=True)),
                        source, choice)
                    m.append(i)
                m.show_all()
                m.popup(None, None, None, 0, Gtk.get_current_event_time())
            return True
        elif targetType == config.data.target_type['timestamp']:
            data = decode_drop_parameters(selection.get_data())
            t = int(data['timestamp'])
            # FIXME: propose various choices (insert timestamp, insert snapshot, etc)
            self.editor.get_buffer().insert_at_cursor(helper.format_time(t))
            return True
        else:
            logger.warn("Unknown target type for drop: %d" % targetType)
        return False
Beispiel #34
0
def show_uri(parent, link):
    from gi.repository import Gtk  # pylint: disable=E0611

    screen = parent.get_screen()
    Gtk.show_uri(screen, link, Gtk.get_current_event_time())
Beispiel #35
0
 def __popup(self, view, library):
     songs = self.__get_selected_songs(view.get_selection())
     menu = SongsMenu(library, songs)
     menu.show_all()
     return view.popup_menu(menu, 0, Gtk.get_current_event_time())
Beispiel #36
0
 def __open_activate_cb(self, menu_item):
     self._home_activity.get_window().activate(Gtk.get_current_event_time())
Beispiel #37
0
 def __resume_activate_cb(self, menu_item):
     self._home_activity.get_window().activate(Gtk.get_current_event_time())
     self.emit('done')
Beispiel #38
0
def show_uri(parent, link):
    """Open a web browser to the specified link."""
    from gi.repository import Gtk  # pylint: disable=E0611
    screen = parent.get_screen()
    Gtk.show_uri(screen, link, Gtk.get_current_event_time())
Beispiel #39
0
 def on_toggled(self, button):
     """
         Pops out the menu upon button toggle
     """
     self.menu.popup(None, None, self.get_menu_position, None, 0,
                     Gtk.get_current_event_time())
Beispiel #40
0
 def popup_menu(self, *args):
     self.popup.popup(None, None, None, None, 0,
                      Gtk.get_current_event_time())
Beispiel #41
0
 def on_main_menu_button_clicked(self, button, main_menu):
     main_menu.popup(None, None, None, None, 1,
                     Gtk.get_current_event_time())
Beispiel #42
0
 def on_help_button_clicked(self, *_args):
     Gtk.show_uri(Gdk.Screen.get_default(),
                  "help:mate-user-guide/menu-editor",
                  Gtk.get_current_event_time())
Beispiel #43
0
 def __popup(self, widget, menu):
     time = Gtk.get_current_event_time()
     button = 3
     qltk.popup_menu_under_widget(menu, widget, button, time)
     return True
Beispiel #44
0
 def on_button_release_event(self, event):
     if self._sel_ignore_next:
         self._sel_ignore_time = Gtk.get_current_event_time()
     self._sel_ignore_next = False
Beispiel #45
0
 def button_press(self, widget, event):
     if event.button == 3:
         #make widget popup
         widget.popup(None, None, None, None, 0,
                      gtk.get_current_event_time())
         pass
Beispiel #46
0
 def __activate_cb(self, icon):
     window = self._home_model.get_active_activity().get_window()
     window.activate(Gtk.get_current_event_time())
Beispiel #47
0
 def __songs_popup_menu(self, songlist):
     path, col = songlist.get_cursor()
     menu = songlist.Menu(app.library)
     if menu is not None:
         return songlist.popup_menu(menu, 0, Gtk.get_current_event_time())
Beispiel #48
0
 def on_selection_changed(selection):
     if self._sel_ignore_time != Gtk.get_current_event_time():
         self.emit("selection-changed", selection)
     self._sel_ignore_time = -1
Beispiel #49
0
 def cb(button):
     allocation = button.get_allocation()
     x, y = button.get_window().get_origin()[1:]
     x += allocation.x
     y += allocation.y + allocation.height
     menu.popup(None, None, (lambda *ignore: (x, y, True)), None, 1, Gtk.get_current_event_time())
Beispiel #50
0
    def do_activate(self):
        if not self.window:
            self.window = Gtk.ApplicationWindow(application=self,
                                                title=_("Local Services"),
                                                icon_name="blueman",
                                                border_width=5)

            grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL,
                            visible=True,
                            row_spacing=10)
            self.window.add(grid)

            self.box = Gtk.Box(Gtk.Orientation.HORIZONTAL,
                               vexpand=True,
                               visible=True)
            grid.add(self.box)

            button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                 halign=Gtk.Align.END,
                                 visible=True)
            grid.add(button_box)

            self.b_apply = Gtk.Button(label="_Apply",
                                      receives_default=True,
                                      use_underline=True,
                                      sensitive=False,
                                      visible=True,
                                      width_request=80)
            button_box.add(self.b_apply)

            self.viewport = Gtk.Viewport(visible=True, width_request=120)

            self.box.add(self.viewport)

            self.Config = Config("org.blueman.general")

            data = [
                {
                    "id": "icon_name",
                    "type": str,
                    "renderer":
                    Gtk.CellRendererPixbuf(stock_size=Gtk.IconSize.DND),
                    "render_attrs": {
                        "icon_name": 0
                    }
                },
                {
                    "id": "caption",
                    "type": str,
                    "renderer": Gtk.CellRendererText(),
                    "render_attrs": {
                        "markup": 1
                    },
                    "view_props": {
                        "expand": True
                    }
                },
                {
                    "id": "id",
                    "type": str
                },
            ]

            self.List = ls = GenericList(data,
                                         headers_visible=False,
                                         visible=True)

            ls.selection.connect("changed", self.on_selection_changed)

            self.viewport.add(ls)

            self.load_plugins()

            ls.selection.select_path(self.Config["services-last-item"])

            self.b_apply.connect("clicked", self.on_apply_clicked)

        self.window.present_with_time(Gtk.get_current_event_time())
Beispiel #51
0
 def Raise(self):
     self.app.window.present_with_time(Gtk.get_current_event_time())
Beispiel #52
0
 def Raise(self):
     self.__app.window.setup_window()
     self.__app.window.present_with_time(Gtk.get_current_event_time())
Beispiel #53
0
	def host_click(self, tv, event):
		""" right click on a host event """
		
		# grab the right click
		if event.button == 3:

			try:
				self.rightclickmenu.destroy()
			except: pass

			self.rightclickmenu = Gtk.Menu()

			# get selected host
			try:
				targets = []
				if self.on_services_view:
					(model, pathlist) = self.services_list.servicestree.get_selection().get_selected_rows()
				else:
					(model, pathlist) = self.host_list.hosttree.get_selection().get_selected_rows()
				
				if len(pathlist) < 1:
					# right click on nothing
					return False 

				for path in pathlist :
					tree_iter = model.get_iter(path)

					if self.on_services_view:

						service = self._filter_service(model.get_value(tree_iter,0)) # selected service

						for port in self.database.get_ports_by_service(service):
							targets.append(port)

					else:
						#print("provone")
						address = model.get_value(tree_iter,1) # selected host address
						domain = model.get_value(tree_iter,2) # selected host address
						host_id = model.get_value(tree_iter,4)

						targets.append(self.database.get_host(host_id))

						self._selected_opt["host"] = address
						self._selected_opt["domain"] = domain
						self._selected_opt["port"] = 0

				if self.on_services_view:
					extra_name = service

				else:
					i4 = Gtk.MenuItem("Delete")
					i4.show()

					self.rightclickmenu.append(i4)
					i4.connect("activate", self._delete_host)

					extra_name = "hostlist"

				extra = self.extensions.get_extra(extra_name)


				for c_ext in extra:
					tabs = {}

					try:
						for extension in extra[c_ext].submenu(extra_name):

							# remove _ and show spaces
							extension = extension.replace("_"," ")

							if len(extension.split(" ")) > 1:
								if not extension.split(" ")[0] in tabs:

									i3 = Gtk.MenuItem(extension.split(" ")[0])
									i3.show()

									tabs[extension.split(" ")[0]] = []
									tabs[extension.split(" ")[0]].append(Gtk.Menu())
									tabs[extension.split(" ")[0]].append(i3)

									self.rightclickmenu.append(i3)
								
								item = Gtk.MenuItem(extension)
								tabs[extension.split(" ")[0]][0].append(item)

							else:

								item = Gtk.MenuItem(extension)
								item.show()
								self.rightclickmenu.append(item)

							item.connect("activate", self.run_multi_extra, targets, extra[c_ext], extra_name)
					
				
						# show all
						for menu in tabs:
							tabs[menu][0].hide()
							tabs[menu][1].set_submenu(tabs[menu][0])

					except : 
						if self.on_services_view:
							item = Gtk.MenuItem(c_ext)
							item.show()
							self.rightclickmenu.append(item)

							item.connect("activate", self.run_multi_extra, targets, extra[c_ext], service)


				self.rightclickmenu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
				self.rightclickmenu.show_all()

				return True

			except Exception as e: print(e)
Beispiel #54
0
 def __on_properties_clicked(self, button):
     self.__menu.popup(None, button, None, button, 0,
                       Gtk.get_current_event_time())
     pass
Beispiel #55
0
 def __button_release_event_cb(self, icon, event):
     window = self._home_model.get_active_activity().get_window()
     window.activate(Gtk.get_current_event_time())
Beispiel #56
0
	def mouse_click(self, tv, event):
		""" right click on a service event """
		
		if event.button == 3:

			try:
				self.rightclick_service_menu.destroy()
				self.rightclickmenu.destroy()
			except: pass

			# create the menu and submenu objects
			self.rightclick_service_menu = Gtk.Menu()
			self.rightclickmenu          = Gtk.Menu()

			targets = []
			generic = []

			# check
			if self.on_services_view:
				#try:
				(model, pathlist) = self.services_view.treeview.get_selection().get_selected_rows()
				
			else:
				(model, pathlist) = self.work.treeview.get_selection().get_selected_rows()

			if len(pathlist) < 1:
				# right click on nothing
				return False 

			# get selected port
			try:
				for path in pathlist :
					tree_iter = model.get_iter(path)

					# set selected port
					selected_port = model.get_value(tree_iter,1) 
					self._selected_opt["port"] = selected_port 


					if self.on_services_view:
						# set selected host if on service view
						self._selected_opt["host"] =  model.get_value(tree_iter,4) 
						targets.append(self.database.get_port(model.get_value(tree_iter,7) ))

					else:
						# set selected service if not on service view
						selected_service = model.get_value(tree_iter,4) # selected service
						targets.append(self.database.get_port(model.get_value(tree_iter,7)))
						self._selected_opt["service"] = selected_service 

			except:
				pass
				
			# fix some multiple names
			self._selected_opt["service"] = self._filter_service(self._selected_opt["service"])

			# get extra extensions
			extra = self.extensions.get_extra(self._selected_opt["service"])

			for extension in extra:
				if extension == "shell":
					# little trick for shell ext
					iE = Gtk.MenuItem(self._selected_opt["service"])
				else:
					iE = Gtk.MenuItem(extension)

				iE.show()
				self.rightclickmenu.append(iE)

				# check if there is a submenu for the current extension
				try:
					tabs = {}
					extension_ext_menu = Gtk.Menu()
					submenu = extra[extension].submenu(self._selected_opt["service"])

					for sub_item in submenu:
						if len(sub_item.split("_")) > 1:
							if not sub_item.split("_")[0] in tabs:
								t = Gtk.MenuItem(sub_item.split("_")[0])
								t.show()
								tabs[sub_item.split("_")[0]] = []
								tabs[sub_item.split("_")[0]].append(Gtk.Menu())
								tabs[sub_item.split("_")[0]].append(t)

					# remove _ and show spaces
					for tab in tabs:
						thetab = Gtk.MenuItem(tabs[tab][1].get_label())
						extension_ext_menu.append(thetab)
						thetab.show()
						thetab.set_submenu(tabs[tab][0])

					for sub_item in submenu:
						sub_item = sub_item.replace("_"," ")

						if len(sub_item.split(" ")) > 1:
							#print(sub_item)
							item = Gtk.MenuItem(sub_item)
								
							tabs[sub_item.split(" ")[0]][0].append(item)

						else:
							# extension in any sub-categories
							item = Gtk.MenuItem(sub_item)
							extension_ext_menu.append(item)
							
						# show and connect the extension
						item.show()
						item.connect('activate', self.run_multi_extra, targets, extra[extension], self._selected_opt["service"])
		
					iE.set_submenu(extension_ext_menu)

				except:
					iE.connect('activate', self.run_multi_extra, targets, extra[extension], self._selected_opt["service"])

				try:
					# try if there is generic for the current extension
					submenu = extra[extension].submenu("generic")

					for sub_item in submenu:
						# remove _ and show spaces
						generic.append(sub_item.replace("_"," "))
				except: pass

			gen_x = self.extensions.get_extra("generic")

			for gen in generic:

				i2 = Gtk.MenuItem(gen)
				i2.show()
				self.rightclickmenu.append(i2)

				i2.connect("activate", self.run_multi_extra, targets, gen_x["shell"], "generic")

			self.rightclickmenu.popup(None, None, None, None, 0, Gtk.get_current_event_time())

			return True
Beispiel #57
0
 def _activate(self, icon):
     """Handle a left click event (show the menu)."""
     self._popup_menu(icon,
                      button=0,
                      time=Gtk.get_current_event_time(),
                      extended=False)
Beispiel #58
0
 def on_import_clicked(self, w: Gtk.MenuToolButton):
     w.get_menu().popup(None, None, None, None, 0,
                        Gtk.get_current_event_time())
 def __popup(self, view, menu):
     return view.popup_menu(menu, 0, Gtk.get_current_event_time())
Beispiel #60
0
 def test_popup_menu(self):
     self.plugin.enabled()
     self.plugin._popup_menu(self.plugin._icon, Gdk.BUTTON_SECONDARY,
                             Gtk.get_current_event_time())
     self.plugin.disabled()