Python gi.repository.Gtk 模块,SeparatorMenuItem() 实例源码

我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用gi.repository.Gtk.SeparatorMenuItem()

项目:surface-orientation    作者:virtualguywithabowtie    | 项目源码 | 文件源码
def setup_menu(self,indicator):
        def add_item(item):
            item.show()
            menu.append(item)
            return item
        menu = gtk.Menu()
        toggle_button = add_item(gtk.CheckMenuItem("Lock Orentation"))
        toggle_button.connect("toggled", self.toggle, indicator)
        indicator.set_secondary_activate_target(toggle_button)
        add_item(gtk.SeparatorMenuItem())
        palm_toggle_button = add_item(gtk.CheckMenuItem("Palm Rejection"))
        palm_toggle_button.connect('toggled', self.palm_toggle, indicator)
        palm_toggle_button.set_active(True)

        add_item(gtk.MenuItem('About')).connect("activate", self.open_about_page)
        add_item(gtk.MenuItem("Exit")).connect("activate", self.quit)
        return menu
项目:YubiGuard    作者:pykong    | 项目源码 | 文件源码
def build_menu(self):
        menu = Gtk.Menu()

        item_unlock = Gtk.MenuItem('Unlock')
        item_unlock.connect('activate', self.unlock)
        menu.append(item_unlock)
        self.item_unlock = item_unlock
        self.item_unlock.set_sensitive(False)  # default state

        item_help = Gtk.MenuItem('Help')
        item_help.connect('activate', self.open_help)
        menu.append(item_help)

        separator = Gtk.SeparatorMenuItem()
        menu.append(separator)

        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect('activate', self.quit)
        menu.append(item_quit)

        menu.show_all()
        return menu
项目:pomodoro-indicator    作者:atareao    | 项目源码 | 文件源码
def add2menu(menu, text=None, icon=None, conector_event=None,
             conector_action=None):
    if text is not None:
        menu_item = Gtk.ImageMenuItem.new_with_label(text)
        if icon:
            image = Gtk.Image.new_from_file(icon)
            menu_item.set_image(image)
            menu_item.set_always_show_image(True)
    else:
        if icon is None:
            menu_item = Gtk.SeparatorMenuItem()
        else:
            menu_item = Gtk.ImageMenuItem.new_from_file(icon)
            menu_item.set_always_show_image(True)
    if conector_event is not None and conector_action is not None:
        menu_item.connect(conector_event, conector_action)
    menu_item.show()
    menu.append(menu_item)
    return menu_item
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def build_login_menu(self):

        def open_login(context):
            webbrowser.open(self.cfg_cls.LOGIN_URI, new=1, autoraise=True)

        login_menu = Gtk.Menu()
        item_login = Gtk.MenuItem('Login')
        item_separator = Gtk.SeparatorMenuItem()
        item_quit = Gtk.MenuItem('Quit')

        item_login.connect('activate', open_login)
        item_quit.connect('activate', self.quit)

        login_menu.append(item_login)
        login_menu.append(item_separator)
        login_menu.append(item_quit)
        login_menu.show_all()

        self.INDICATOR.set_menu(login_menu)
项目:backlight-indicator    作者:atareao    | 项目源码 | 文件源码
def add2menu(menu, text=None, icon=None, conector_event=None,
             conector_action=None):
    if text is not None:
        menu_item = Gtk.ImageMenuItem.new_with_label(text)
        if icon:
            image = Gtk.Image.new_from_file(icon)
            menu_item.set_image(image)
            menu_item.set_always_show_image(True)
    else:
        if icon is None:
            menu_item = Gtk.SeparatorMenuItem()
        else:
            menu_item = Gtk.ImageMenuItem.new_from_file(icon)
            menu_item.set_always_show_image(True)
    if conector_event is not None and conector_action is not None:
        menu_item.connect(conector_event, conector_action)
    menu_item.show()
    menu.append(menu_item)
    return menu_item
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def add2menu(menu, text = None, icon = None, conector_event = None, conector_action = None, note = None):
    if note != None:
        menu_item = MenuNote(note)
    else:
        if text != None:
            if icon == None:
                menu_item = Gtk.MenuItem.new_with_label(text)
            else:
                menu_item = Gtk.ImageMenuItem.new_with_label(text)
                image = Gtk.Image.new_from_stock(icon, Gtk.IconSize.MENU)
                menu_item.set_image(image)
                menu_item.set_always_show_image(True)
        else:
            if icon == None:
                menu_item = Gtk.SeparatorMenuItem()
            else:
                menu_item = Gtk.ImageMenuItem.new_from_stock(icon, None)
                menu_item.set_always_show_image(True)
    if conector_event != None and conector_action != None:              
        menu_item.connect(conector_event,conector_action)
    menu_item.show()
    menu.append(menu_item)
    return menu_item
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def add2menu(menu, text = None, icon = None, conector_event = None, conector_action = None, note = None):
    if note != None:
        menu_item = MenuNote(note)
    else:
        if text != None:
            menu_item = Gtk.ImageMenuItem.new_with_label(text)
            if icon:
                image = Gtk.Image.new_from_stock(icon, Gtk.IconSize.MENU)
                menu_item.set_image(image)
                menu_item.set_always_show_image(True)
        else:
            if icon == None:
                menu_item = Gtk.SeparatorMenuItem()
            else:
                menu_item = Gtk.ImageMenuItem.new_from_stock(icon, None)
                menu_item.set_always_show_image(True)
    if conector_event != None and conector_action != None:              
        menu_item.connect(conector_event,conector_action)
    menu_item.show()
    menu.append(menu_item)
    return menu_item
项目:shadowsocks-eos    作者:Simpleyyt    | 项目源码 | 文件源码
def load_servers(self):
        for child in self.server_submenu.get_children():
            self.server_submenu.remove(child)
        servers = self.config.get('configs', '[]')
        index = self.config.get('index', 0)
        group = []
        i = 0
        for server in servers:
            name = server['remarks'] + '(' + server['server'] + ':' + str(server['port']) + ')'
            item = Gtk.RadioMenuItem.new_with_label(group, name)
            item.connect('activate', self.server_activate, server, i)
            self.server_submenu.append(item)
            group = item.get_group()
            if i == index:
                item.set_active(True)
                self.server_activate(item, server, i)
            i = i + 1

        self.server_submenu.append(Gtk.SeparatorMenuItem())

        self.open_server_item = Gtk.MenuItem('???????...')
        self.open_server_item.connect('activate', self.show_server_setting)
        self.server_submenu.append(self.open_server_item)
        self.server_submenu.show_all()
项目:SafeEyes    作者:slgobinath    | 项目源码 | 文件源码
def create_gtk_builder(glade_file):
    """
    Create a Gtk builder and load the glade file.
    """
    builder = Gtk.Builder()
    builder.set_translation_domain('safeeyes')
    builder.add_from_file(glade_file)
    # Tranlslate all sub components
    for obj in builder.get_objects():
        if (not isinstance(obj, Gtk.SeparatorMenuItem)) and hasattr(obj, "get_label"):
            label = obj.get_label()
            if label is not None:
                obj.set_label(_(label))
        elif hasattr(obj, "get_title"):
            title = obj.get_title()
            if title is not None:
                obj.set_title(_(title))
    return builder
项目:pomodoro-indicator    作者:atareao    | 项目源码 | 文件源码
def get_menu(self):
        """Create and populate the menu."""
        menu = Gtk.Menu()

        self.pomodoro_start = Gtk.MenuItem.new_with_label(_('Start'))
        self.pomodoro_start.connect('activate', self.on_pomodoro_start)
        self.pomodoro_start.show()
        menu.append(self.pomodoro_start)

        self.pomodoro_restart = Gtk.MenuItem.new_with_label(_('Re-start'))
        self.pomodoro_restart.connect('activate', self.on_pomodoro_restart)
        self.pomodoro_restart.show()
        menu.append(self.pomodoro_restart)

        separator1 = Gtk.SeparatorMenuItem()
        separator1.show()
        menu.append(separator1)
        #
        menu_preferences = Gtk.MenuItem.new_with_label(_('Preferences'))
        menu_preferences.connect('activate', self.on_preferences_item)
        menu_preferences.show()
        menu.append(menu_preferences)

        menu_help = Gtk.MenuItem.new_with_label(_('Help'))
        menu_help.set_submenu(self.get_help_menu())
        menu_help.show()
        menu.append(menu_help)
        #
        separator2 = Gtk.SeparatorMenuItem()
        separator2.show()
        menu.append(separator2)
        #
        menu_exit = Gtk.MenuItem.new_with_label(_('Exit'))
        menu_exit.connect('activate', self.on_quit_item)
        menu_exit.show()
        menu.append(menu_exit)
        #
        menu.show()
        return(menu)
项目:fux-terminal    作者:fuxprojesi    | 项目源码 | 文件源码
def on_button_press_event(wid, event):
        """
        on_button_press_event: Sa? tu?a t?kland???nda yap?lacak i?lem

        Fare'nin sa? tu?una t?kland???nda bu fonksiyon tetiklenir. Fonksiyon içinde
        T?klanan tu?un sa? tu? olup olmad??? sorgulan?r. E?er do?ru ise aç?l?r menü
        Olu?turulur. Olu?turulam menü argümanlar?na sinyaller atan?r ve gösterilir.
        """
        if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
           menu = Gtk.Menu()

           term = Gtk.ImageMenuItem("Terminal Aç")
           term_img = Gtk.Image()
           term_img.set_from_icon_name("utilities-terminal", Gtk.IconSize.MENU)
           term.set_image(term_img)
           term.set_always_show_image(True)

           copy = Gtk.ImageMenuItem("Kopyala")
           copy_img = Gtk.Image()
           copy_img.set_from_icon_name("edit-copy", Gtk.IconSize.MENU)
           copy.set_image(copy_img)
           copy.set_always_show_image(True)

           paste = Gtk.ImageMenuItem("Yap??t?r")
           paste_img = Gtk.Image()
           paste_img.set_from_icon_name("edit-paste", Gtk.IconSize.MENU)
           paste.set_image(paste_img)
           paste.set_always_show_image(True)

           menu.append(term)
           menu.append(Gtk.SeparatorMenuItem())
           menu.append(copy)
           menu.append(paste)

           term.connect("activate", RightClick.open_terminal)
           copy.connect("activate", RightClick.copy_text)
           paste.connect("activate", RightClick.paste_text)

           menu.show_all()
           menu.popup(None, None, None, None, event.button, event.time)
           return True
项目:budgie-extras    作者:UbuntuBudgie    | 项目源码 | 文件源码
def change_onthefly(self):
        modesep = Gtk.SeparatorMenuItem()
        self.menu.add(modesep)
        mode_mention = Gtk.MenuItem("Mode")
        applet_modes = Gtk.Menu()
        active = modes.index(self.mode)
        self.mode_index = active
        self.menulist = ["      " + m for m in modes]
        self.menulist[active] = "? " + str(modes[active]) + ""
        for item in self.menulist:
            md = Gtk.MenuItem(item)
            md.connect('activate', self.set_mode, item)
            applet_modes.append(md)
        mode_mention.set_submenu(applet_modes)
        self.menu.add(mode_mention)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def popup_folder_menu(self, event):
        # create folder; upload files; reload; share; properties
        menu = Gtk.Menu()
        self.menu = menu

        new_folder_item = Gtk.MenuItem.new_with_label(_('New Folder'))
        new_folder_item.connect('activate', self.on_new_folder_activated)
        menu.append(new_folder_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)
        upload_files_item = Gtk.MenuItem.new_with_label(_('Upload Files...'))
        upload_files_item.connect('activate', self.on_upload_files_activated)
        menu.append(upload_files_item)
        upload_folders_item = Gtk.MenuItem.new_with_label(
                _('Upload Folders...'))
        upload_folders_item.connect('activate',
                                    self.on_upload_folders_activated)
        menu.append(upload_folders_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)
        reload_item = Gtk.MenuItem.new_with_label(_('Reload (F5)'))
        reload_item.connect('activate', self.on_reload_activated)
        menu.append(reload_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)
        props_item = Gtk.MenuItem.new_with_label(_('Properties'))
        props_item.connect('activate', self.on_props_activated)
        menu.append(props_item)

        menu.show_all()
        menu.popup(None, None, None, None, event.button, event.time)
项目:indicator-keyboard-led    作者:adrianiainlam    | 项目源码 | 文件源码
def create_menu(self, xdotool, order):
        menu = Gtk.Menu()
        xdotool = xdotool or shutil.which('xdotool')
        if xdotool and os.access(xdotool, os.X_OK) and os.path.isfile(xdotool):
            def send_keypress(menuitem, keystroke):
                subprocess.call([xdotool, 'key', keystroke])
            def new_menu_item(itemtype):
                if itemtype == 'N':
                    item = Gtk.MenuItem.new_with_label(_('Num Lock'))
                    item.connect('activate', send_keypress, 'Num_Lock')
                elif itemtype == 'C':
                    item = Gtk.MenuItem.new_with_label(_('Caps Lock'))
                    item.connect('activate', send_keypress, 'Caps_Lock')
                elif itemtype == 'S':
                    item = Gtk.MenuItem.new_with_label(_('Scroll Lock'))
                    item.connect('activate', send_keypress, 'Scroll_Lock')
                else:
                    raise ValueError('Invalid itemtype')
                return item

            for i in order:
                menu.append(new_menu_item(i))
            menu.append(Gtk.SeparatorMenuItem())

        quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
        menu.append(quit_item)
        quit_item.connect('activate', Gtk.main_quit)

        self.indicator.set_menu(menu)
        menu.show_all()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def _populate_popup(self, textview, menu):
        '''Populates the menu with the Find item.'''
        menu.append(Gtk.SeparatorMenuItem())
        opc = Gtk.ImageMenuItem((Gtk.STOCK_FIND))
        opc.get_children()[0].set_label('Find...')
        menu.append(opc)
        opc.connect("activate", self.show_search)
        menu.show_all()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def _populate_menu(self, textview, menu):
        opc = Gtk.ImageMenuItem((Gtk.STOCK_CLEAR))
        opc.get_children()[0].set_label('Clear text')
        menu.prepend(Gtk.SeparatorMenuItem())
        menu.prepend(opc)
        opc.connect("activate", self._clear, iter)
        menu.show_all()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def hex_view_populate_popup(self, textview, popup):
        disassemble_item = Gtk.MenuItem('Disassemble')
        disassemble_item.connect('activate', self.disassemble_item_activate)
        separator = Gtk.SeparatorMenuItem()
        popup.prepend(separator)
        popup.prepend(disassemble_item)
        separator.show()
        disassemble_item.show()
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def init_main_menu(self):
        main_menu = Gtk.Menu()

        self.new_button = Gtk.MenuItem.new_with_label('New')
        self.open_button = Gtk.MenuItem.new_with_label('Open')

        self.open_stock_button = Gtk.MenuItem.new_with_label('Import Stock')

        view_button = Gtk.MenuItem.new_with_label('View')

        self.view_menu = Gtk.Menu()
        self.viewer_button = Gtk.MenuItem.new_with_label('Viewer')
        self.builder_button = Gtk.MenuItem.new_with_label('Builder')
        self.view_menu.append(self.viewer_button)
        self.view_menu.append(self.builder_button)
        self.view_menu.show_all() 

        view_button.set_submenu(self.view_menu)

        self.save_button = Gtk.MenuItem.new_with_label('Save')
        self.save_as_button = Gtk.MenuItem.new_with_label('Save As...')
        self.quit_button = Gtk.MenuItem.new_with_label('Quit')

        main_menu.append(self.new_button)
        main_menu.append(self.open_button)
        main_menu.append(self.open_stock_button) 
        main_menu.append(Gtk.SeparatorMenuItem())
        main_menu.append(view_button)
        main_menu.append(Gtk.SeparatorMenuItem())
        main_menu.append(self.save_button)
        main_menu.append(self.save_as_button)
        main_menu.append(Gtk.SeparatorMenuItem())
        main_menu.append(self.quit_button)
        main_menu.show_all()

        return main_menu
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Menu.__init__(self)

        self.edit_button = Gtk.MenuItem.new_with_label('Edit')
        self.copy_button = Gtk.MenuItem.new_with_label('Copy')
        self.delete_button = Gtk.MenuItem.new_with_label('Delete')

        self.append(self.edit_button)
        self.append(self.copy_button)
        self.append(Gtk.SeparatorMenuItem())
        self.append(self.delete_button)

        self.show_all()
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Menu.__init__(self)

        self.add_button = Gtk.MenuItem.new_with_label('Add')
        self.paste_button = Gtk.MenuItem.new_with_label('Paste')

        self.append(self.add_button)
        self.append(Gtk.SeparatorMenuItem())
        self.append(self.paste_button)

        self.show_all()
项目:CowNewsReader    作者:blediboss    | 项目源码 | 文件源码
def build_menu(self):
        self.menu = gtk.Menu()
        self.item_main_window = gtk.MenuItem('Open Main Window')
        self.item_main_window.connect('activate', self.main_window)
        self.menu.append(self.item_main_window)
        self.menu.append(gtk.SeparatorMenuItem().new())
        self.item_quit = gtk.MenuItem('Quit')
        self.item_quit.connect('activate', self.quit)
        self.menu.append(self.item_quit)
        self.menu.show_all()
项目:ScreenRotator    作者:frecel    | 项目源码 | 文件源码
def build_menu():
    menu = Gtk.Menu()
    #brightness
    item_brightness_up = Gtk.MenuItem('Increase Brightness')
    item_brightness_up.connect('activate', increase_brightness)
    menu.append(item_brightness_up)
    item_brightness_down = Gtk.MenuItem("Decrease Brightness")
    item_brightness_down.connect('activate', decrease_brightness)
    menu.append(item_brightness_down)
    #rotate
    item_rotate = Gtk.MenuItem('Rotate')
    item_rotate.connect('activate', rotate_screen)
    menu.append(item_rotate)
    #flip
    item_flip = Gtk.MenuItem('Flip')
    item_flip.connect('activate', flip_screen)
    menu.append(item_flip)
    #seperator
    seperator = Gtk.SeparatorMenuItem()
    menu.append(seperator)
    #quit
    item_quit = Gtk.MenuItem('Quit')
    item_quit.connect('activate', quit)
    menu.append(item_quit)
    menu.show_all()
    return menu
项目:gracer    作者:isamert    | 项目源码 | 文件源码
def on_view_populate_popup(self, view, menu):
        menu_find_definition = Gtk.ImageMenuItem(_("Find Definition"))
        menu_find_definition.connect('activate', self.on_find_definition_active)
        #menu_find_definition.set_image(gtk.image_new_from_stock(gtk.STOCK_COMMENT, gtk.ICON_SIZE_MENU))
        menu_find_definition.show()

        separator = Gtk.SeparatorMenuItem()
        separator.show()

        menu.prepend(separator)
        menu.prepend(menu_find_definition)
项目:king-phisher-plugins    作者:securestate    | 项目源码 | 文件源码
def _get_popup_menu(self):
        self._menu_items_req_selection = []
        self.popup_menu = Gtk.Menu.new()

        self.menu_item_transfer = Gtk.MenuItem.new_with_label(self.transfer_direction.title())
        self.popup_menu.append(self.menu_item_transfer)

        self.menu_item_edit = Gtk.MenuItem.new_with_label('Edit')
        self.popup_menu.append(self.menu_item_edit)

        menu_item = Gtk.MenuItem.new_with_label('Collapse All')
        menu_item.connect('activate', self.signal_menu_activate_collapse_all)
        self.popup_menu.append(menu_item)

        menu_item = Gtk.MenuItem.new_with_label('Set Working Directory')
        menu_item.connect('activate', self.signal_menu_activate_set_working_directory)
        self.popup_menu.append(menu_item)
        self._menu_items_req_selection.append(menu_item)

        menu_item = Gtk.MenuItem.new_with_label('Create Folder')
        menu_item.connect('activate', self.signal_menu_activate_create_folder)
        self.popup_menu.append(menu_item)

        menu_item = Gtk.MenuItem.new_with_label('Rename')
        menu_item.connect('activate', self.signal_menu_activate_rename)
        self.popup_menu.append(menu_item)
        self._menu_items_req_selection.append(menu_item)

        menu_item = Gtk.SeparatorMenuItem()
        self.popup_menu.append(menu_item)

        menu_item = Gtk.MenuItem.new_with_label('Delete')
        menu_item.connect('activate', self.signal_menu_activate_delete_prompt)
        self.popup_menu.append(menu_item)
        self._menu_items_req_selection.append(menu_item)

        self.popup_menu.show_all()
项目:hubangl    作者:soonum    | 项目源码 | 文件源码
def _build_separatormenuitem(self, menu):
        _separator = Gtk.SeparatorMenuItem()
        menu.append(_separator)
项目:sleep-inhibit    作者:mssever    | 项目源码 | 文件源码
def _build_indicator_menu(self, indicator):
        '''Build the indicator menu'''
        menu = Gtk.Menu()

        self.inhibit_menu_item = Gtk.MenuItem("Inhibit Sleep")
        menu.append(self.inhibit_menu_item)
        self.inhibit_menu_item.connect("activate", self.on_toggle)
        self.inhibit_menu_item.show()

        menu_item = Gtk.SeparatorMenuItem()
        menu.append(menu_item)
        menu_item.show()

        menu_item = Gtk.MenuItem('Preferences')
        menu.append(menu_item)
        menu_item.connect('activate', self.on_settings)
        menu_item.show()

        menu_item = Gtk.MenuItem('About')
        menu.append(menu_item)
        menu_item.connect('activate', self.on_about)
        menu_item.show()

        menu_item = Gtk.MenuItem("Quit")
        menu.append(menu_item)
        menu_item.connect("activate", self.on_quit)
        menu_item.show()

        indicator.set_menu(menu)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def init_status_icon(self):
        def on_status_icon_popup_menu(status_icon, event_button, event_time):
            menu.popup(None, None,
                    lambda a,b: Gtk.StatusIcon.position_menu(menu, status_icon),
                    None, event_button, event_time)

        def on_status_icon_activate(status_icon):
            if self.window.props.visible:
                self.window.hide()
            else:
                self.window.present()

        if not self.profile or not self.profile['use-status-icon']:
            self.status_icon = None
            return

        menu = Gtk.Menu()
        show_item = Gtk.MenuItem.new_with_label(_('Show App'))
        show_item.connect('activate', lambda item: self.window.present())
        menu.append(show_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)

        pause_upload_item = Gtk.MenuItem.new_with_label(
                _('Pause Upload Tasks'))
        pause_upload_item.connect('activate',
                lambda item: self.upload_page.pause_tasks())
        menu.append(pause_upload_item)

        pause_download_item = Gtk.MenuItem.new_with_label(
                _('Pause Download Tasks'))
        pause_download_item.connect('activate',
                lambda item: self.download_page.pause_tasks())
        menu.append(pause_download_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)

        quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
        quit_item.connect('activate', lambda item: self.quit())
        menu.append(quit_item)

        menu.show_all()
        self.status_menu = menu

        if 'AppIndicator' in globals():
            self.status_icon = AppIndicator.Indicator.new(Config.NAME,
                    Config.NAME,
                    AppIndicator.IndicatorCategory.APPLICATION_STATUS)
            self.status_icon.set_menu(menu)
            self.status_icon.set_status(AppIndicator.IndicatorStatus.ACTIVE)
        else:
            self.status_icon = Gtk.StatusIcon()
            self.status_icon.set_from_icon_name(Config.NAME)
            # left click
            self.status_icon.connect('activate', on_status_icon_activate)
            # right click
            self.status_icon.connect('popup_menu', on_status_icon_popup_menu)

    # Open API
项目:backlight-indicator    作者:atareao    | 项目源码 | 文件源码
def get_menu(self):
        """Create and populate the menu."""
        menu = Gtk.Menu()

        self.working_menu_item = Gtk.MenuItem().new_with_label(_('Start'))
        self.working_menu_item.connect('activate', self.on_working_menu_item)
        self.working_menu_item.show()
        menu.append(self.working_menu_item)
        if self.wid > 0:
            self.working_menu_item.set_label(_('Stop'))
        else:
            self.working_menu_item.set_label(_('Start'))
        menu.append(self.working_menu_item)
        #
        capture_backlight_menu = Gtk.MenuItem().new_with_label(_('Capture \
backlight'))
        capture_backlight_menu.connect('activate',
                                       self.on_capture_backlight_menu)
        capture_backlight_menu.show()
        menu.append(capture_backlight_menu)
        #
        set_backlight_menu = Gtk.MenuItem().new_with_label(_('Set \
backlight manually'))
        set_backlight_menu.connect('activate', self.on_set_backlight_menu)
        set_backlight_menu.show()
        menu.append(set_backlight_menu)
        #
        separator1 = Gtk.SeparatorMenuItem()
        separator1.show()
        menu.append(separator1)
        #
        menu_preferences = Gtk.MenuItem.new_with_label(_('Preferences'))
        menu_preferences.connect('activate', self.on_preferences_item)
        menu_preferences.show()
        menu.append(menu_preferences)

        menu_help = Gtk.MenuItem.new_with_label(_('Help'))
        menu_help.set_submenu(self.get_help_menu())
        menu_help.show()
        menu.append(menu_help)
        #
        separator2 = Gtk.SeparatorMenuItem()
        separator2.show()
        menu.append(separator2)
        #
        menu_exit = Gtk.MenuItem.new_with_label(_('Exit'))
        menu_exit.connect('activate', self.on_quit_item)
        menu_exit.show()
        menu.append(menu_exit)
        #
        menu.show()
        return(menu)
项目:testindicator    作者:logileifs    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Indicator, self).__init__()
        self.indicator = appindicator.Indicator.new(
            'testindicator',
            YELLOW,
            IndicatorCategory.APPLICATION_STATUS
        )
        self.status = None
        self.on_quit = kwargs.get('quit')
        self.on_run = kwargs.get('run', None)
        self.on_stop = kwargs.get('stop', None)
        self.indicator.set_status(IndicatorStatus.ACTIVE)
        self.menu = gtk.Menu()

        self.project_name = gtk.MenuItem(cfg.project_name)
        self.project_name.set_sensitive(False)
        self.project_name.show()
        self.menu.append(self.project_name)

        separator_item = gtk.SeparatorMenuItem()
        separator_item.show()
        self.menu.append(separator_item)

        self.show_item = gtk.CheckMenuItem("Notifications")
        self.show_item.set_active(cfg.notifications)
        self.show_item.connect('toggled', self.on_notifications_toggle)
        self.show_item.show()
        self.menu.append(self.show_item)

        self.run_now_item = gtk.MenuItem('Run tests (CTRL+SUPER+T)')
        self.run_now_item.connect('activate', self.run_or_stop)
        self.run_now_item.set_sensitive(True)
        self.run_now_item.show()
        self.menu.append(self.run_now_item)

        separator_item = gtk.SeparatorMenuItem()
        separator_item.show()
        self.menu.append(separator_item)

        self.item_quit = gtk.MenuItem('Exit (CTRL+SUPER+E)')
        self.item_quit.connect('activate', self.on_quit)
        self.menu.append(self.item_quit)
        self.menu.show_all()
        self.indicator.set_menu(self.menu)
项目:shadowsocks-eos    作者:Simpleyyt    | 项目源码 | 文件源码
def build_menu(self):
        self.menu = Gtk.Menu()

        self.status_item = Gtk.MenuItem('Shadowsocks???')
        self.status_item.set_sensitive(False)
        self.menu.append(self.status_item)

        self.switch_item = Gtk.MenuItem('?? Shadowsocks')
        self.switch_item.connect('activate', self.switch)
        self.menu.append(self.switch_item)

        self.update_status()

        self.menu.append(Gtk.SeparatorMenuItem())

        group = []
        self.autoproxy_item = Gtk.RadioMenuItem.new_with_label(group, '??????')
        self.menu.append(self.autoproxy_item)
        self.autoproxy_item.connect('activate', self.proxy_active)

        group = self.autoproxy_item.get_group()
        self.wholeproxy_item = Gtk.RadioMenuItem.new_with_label(group, '????')
        self.menu.append(self.wholeproxy_item)
        self.wholeproxy_item.connect('activate', self.proxy_active)

        gb = self.config.get('global', False)


        self.autoproxy_item.set_active(not gb)
        self.wholeproxy_item.set_active(gb)


        self.menu.append(Gtk.SeparatorMenuItem())

        self.server_item = Gtk.MenuItem('???')
        self.menu.append(self.server_item)
        self.server_submenu = Gtk.Menu()
        self.server_item.set_submenu(self.server_submenu)

        self.menu.append(Gtk.SeparatorMenuItem())

        self.editpac_item = Gtk.MenuItem('??????? PAC...')
        self.editpac_item.connect('activate', self.open_pac_folder)
        self.menu.append(self.editpac_item)

        self.updatepac_item = Gtk.MenuItem('? GFWList ?? PAC')
        self.updatepac_item.connect('activate', self.update_pac)
        self.menu.append(self.updatepac_item)

        self.editrule_item = Gtk.MenuItem('?? GFWList ?????...')
        self.editrule_item.connect('activate', self.open_pac_folder)
        self.menu.append(self.editrule_item)

        self.menu.append(Gtk.SeparatorMenuItem())

        self.exit_item = Gtk.MenuItem('??')
        self.menu.append(self.exit_item)
        self.exit_item.connect('activate', self.exit)
项目:king-phisher-plugins    作者:securestate    | 项目源码 | 文件源码
def __init__(self, queue):
        self.queue = queue
        self.scroll = sftp_utilities.get_object('SFTPClient.notebook.page_stfp.scrolledwindow_transfer_statuses')
        self.treeview_transfer = sftp_utilities.get_object('SFTPClient.notebook.page_stfp.treeview_transfer_statuses')
        self._tv_lock = threading.RLock()

        col_text = Gtk.CellRendererText()
        col_img = Gtk.CellRendererPixbuf()
        col = Gtk.TreeViewColumn('')
        col.pack_start(col_img, False)
        col.add_attribute(col_img, 'pixbuf', 0)
        self.treeview_transfer.append_column(col)

        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Local File', col_text, 1, m_col_sort=1, resizable=True))
        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Remote File', col_text, 2, m_col_sort=2, resizable=True))
        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Status', col_text, 3, m_col_sort=3, resizable=True))

        col_bar = Gtk.TreeViewColumn('Progress')
        progress = Gtk.CellRendererProgress()
        col_bar.pack_start(progress, True)
        col_bar.add_attribute(progress, 'value', 4)
        col_bar.set_property('resizable', True)
        col_bar.set_min_width(125)
        self.treeview_transfer.append_column(col_bar)

        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Size', col_text, 5, m_col_sort=3, resizable=True))
        self._tv_model = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, str, str, int, str, object)
        self.treeview_transfer.connect('size-allocate', self.signal_tv_size_allocate)
        self.treeview_transfer.connect('button_press_event', self.signal_tv_button_pressed)

        self.treeview_transfer.set_model(self._tv_model)
        self.treeview_transfer.show_all()

        self.popup_menu = Gtk.Menu.new()

        self.menu_item_paused = Gtk.CheckMenuItem.new_with_label('Paused')
        menu_item = self.menu_item_paused
        menu_item.connect('toggled', self.signal_menu_toggled_paused)
        self.popup_menu.append(menu_item)

        self.menu_item_cancel = Gtk.MenuItem.new_with_label('Cancel')
        menu_item = self.menu_item_cancel
        menu_item.connect('activate', self.signal_menu_activate_cancel)
        self.popup_menu.append(menu_item)

        menu_item = Gtk.SeparatorMenuItem()
        self.popup_menu.append(menu_item)

        menu_item = Gtk.MenuItem.new_with_label('Clear')
        menu_item.connect('activate', self.signal_menu_activate_clear)
        self.popup_menu.append(menu_item)
        self.popup_menu.show_all()
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def menuPopup( self, widget, event ):
        if event.button == 3:
            mTree = Gtk.Menu()
            #i18n
            desktopMenuItem = Gtk.MenuItem(label=_("Add to desktop"))
            panelMenuItem = Gtk.MenuItem(label=_("Add to panel"))
            separator1 = Gtk.SeparatorMenuItem()
            favoriteMenuItem = Gtk.CheckMenuItem(label=_("Show in my favorites"))
            launchMenuItem = Gtk.MenuItem(label=_("Launch"))
            deleteMenuItem = Gtk.MenuItem(label=_("Delete from menu"))
            separator2 = Gtk.SeparatorMenuItem()
            propsMenuItem = Gtk.MenuItem(label=_("Edit properties"))

            mTree.append(desktopMenuItem)
            mTree.append(panelMenuItem)
            mTree.append(separator1)

            mTree.append(favoriteMenuItem)

            mTree.append(launchMenuItem)
            if os.environ["HOME"] in widget.desktopFile:
                mTree.append(deleteMenuItem)
                deleteMenuItem.connect("activate", self.delete_from_menu, widget)

            mTree.append(separator2)

            mTree.append(propsMenuItem)

            mTree.show_all()

            desktopMenuItem.connect("activate", self.add_to_desktop, widget)
            panelMenuItem.connect("activate", self.add_to_panel, widget)

            launchMenuItem.connect( "activate", self.onLaunchApp, widget )
            propsMenuItem.connect( "activate", self.onPropsApp, widget)

            if self.isLocationInFavorites( widget.desktopFile ):
                favoriteMenuItem.set_active( True )
                favoriteMenuItem.connect( "toggled", self.onRemoveFromFavorites, widget )
            else:
                favoriteMenuItem.set_active( False )
                favoriteMenuItem.connect( "toggled", self.onAddToFavorites, widget )

            self.mateMenuWin.stopHiding()
            mTree.attach_to_widget(widget, None)
            if (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION) >= (3, 22):
                mTree.popup_at_pointer(event)
            else:
                mTree.popup(None, None, None, None, event.button, event.time)
项目:mate-menu    作者:ubuntu-mate    | 项目源码 | 文件源码
def searchPopup( self, widget=None, event=None ):
        menu = Gtk.Menu()

        menuItem = Gtk.ImageMenuItem(label=_("Search DuckDuckGo"))
        img = Gtk.Image()
        img.set_from_file("/usr/share/mate-menu/icons/search_engines/ddg.png")
        menuItem.set_image(img)
        menuItem.connect("activate", self.search_ddg)
        menu.append(menuItem)

        menuItem = Gtk.ImageMenuItem(label=_("Search Google"))
        img = Gtk.Image()
        img.set_from_file("/usr/share/mate-menu/icons/search_engines/google.png")
        menuItem.set_image(img)
        menuItem.connect("activate", self.search_google)
        menu.append(menuItem)

        menuItem = Gtk.ImageMenuItem(label=_("Search Wikipedia"))
        img = Gtk.Image()
        img.set_from_file("/usr/share/mate-menu/icons/search_engines/wikipedia.png")
        menuItem.set_image(img)
        menuItem.connect("activate", self.search_wikipedia)
        menu.append(menuItem)

        menuItem = Gtk.SeparatorMenuItem()
        menu.append(menuItem)

        menuItem = Gtk.ImageMenuItem(label=_("Lookup Dictionary"))
        img = Gtk.Image()
        img.set_from_file('/usr/share/mate-menu/icons/dictionary.png')
        menuItem.set_image(img)
        menuItem.connect("activate", self.search_dictionary)
        menu.append(menuItem)

        menuItem = Gtk.ImageMenuItem(label=_("Search Computer"))
        img = Gtk.Image()
        img.set_from_icon_name("edit-find", Gtk.IconSize.INVALID)
        img.set_pixel_size( self.iconSize )
        menuItem.set_image(img)
        menuItem.connect("activate", self.Search)
        menu.append(menuItem)

        menu.show_all()

        self.mateMenuWin.stopHiding()
        menu.attach_to_widget(self.searchButton, None)
        if (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION) >= (3, 22):
            menu.popup_at_widget(widget, Gdk.Gravity.SOUTH_WEST, Gdk.Gravity.NORTH_WEST, event)
        else:
            menu.popup(None, None, None, None, event.button, event.time)

        #menu.reposition()
        #menu.reposition()
        #self.mateMenuWin.grab()
        self.focusSearchEntry(clear = False)
        return True