Exemple #1
0
    def _addMenuItems(self, uiman):
        view_menu_item = uiman.get_widget('/MainMenuBar/View')
        view_menu = view_menu_item.get_submenu()
        seperator = gtk.SeparatorMenuItem()
        self.treeview_menuitem = gtk.RadioMenuItem(
            None, _("Show Video Effects as a List"))
        self.iconview_menuitem = gtk.RadioMenuItem(
            self.treeview_menuitem, _("Show Video Effects as Icons"))

        if self.settings.lastEffectView == SHOW_TREEVIEW:
            self.treeview_menuitem.set_active(True)
            self.iconview_menuitem.set_active(False)
        else:
            self.treeview_menuitem.set_active(False)
            self.iconview_menuitem.set_active(True)

        self.treeview_menuitem.connect("toggled",
                                       self._treeViewMenuItemToggledCb)
        view_menu.append(seperator)
        view_menu.append(self.treeview_menuitem)
        view_menu.append(self.iconview_menuitem)
        self.treeview_menuitem.show()
        self.iconview_menuitem.show()
        seperator.show()

        self.effect_view = self.settings.lastEffectView
Exemple #2
0
    def _append_column(self, column):
        column.set_widget(column.label)
        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        if column.key in ['*', '№', 'Time']:
            column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
        else:
            column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        if FC().columns[column.key][2] > 0:
            column.set_fixed_width(FC().columns[column.key][2])

        self.append_column(column)
        column.button = column.label.get_parent().get_parent().get_parent()
        column.button.connect("button-press-event", self.on_click_header)
        if column.key == '№':
            self.trkn_col.button.menu = Popup()
            self.num_order = gtk.RadioMenuItem(None, _("Numbering by order"))
            self.num_order.connect("button-press-event", self.on_toggled_num)
            self.num_tags = gtk.RadioMenuItem(self.num_order,
                                              _("Numbering by tags"))
            self.num_tags.connect("button-press-event", self.on_toggled_num)

            self.trkn_col.button.menu.append(self.num_order)
            self.trkn_col.button.menu.append(self.num_tags)
            if FC().numbering_by_order:
                self.num_order.set_active(True)
            else:
                self.num_tags.set_active(True)
def _build_option(option):
    '''build an option object, return a list of gtk.RadioMenuItems'''
    option_list = []
    gtk_option = gtk.RadioMenuItem(None, option[0].text)

    if option.selected_index <= 0 or option.selected_index >= len(option):
        gtk_option.set_active(True)

    gtk_option.connect('activate', _option_cb, option[0], option)
    option_list.append(gtk_option)

    for (count, opt) in enumerate(option[1:]):
        gtk_opt = gtk.RadioMenuItem(gtk_option, opt.text)
        option.signal_connect("enabled", _set_sensitive, gtk_opt, True)
        option.signal_connect("disabled", _set_sensitive, gtk_opt, False)

        if option.selected_index == count + 1:
            gtk_opt.set_active(True)

        gtk_opt.connect('activate', _option_cb, opt, option)
        option_list.append(gtk_opt)
    
    option.signal_connect("enabled", _set_sensitive, gtk_option, True)
    option.signal_connect("disabled", _set_sensitive, gtk_option, False)

    return option_list
Exemple #4
0
    def __init__(self):
        self.ind = appindicator.Indicator(
            "switch_screens_indicator", "gsd-xrandr.svg",
            appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status(appindicator.STATUS_ACTIVE)
        self.ind.set_icon(
            "/usr/share/icons/ubuntu-mono-dark/apps/22/gsd-xrandr.svg")

        self.menu = gtk.Menu()

        dual_screen_radio = gtk.RadioMenuItem(None, "Dual Screen")
        dual_screen_radio.show()
        self.menu.append(dual_screen_radio)

        single_screen_radio = gtk.RadioMenuItem(dual_screen_radio,
                                                "Single Screen")
        single_screen_radio.show()
        self.menu.append(single_screen_radio)

        dual_screen_radio.connect("activate", self.dual_screen)
        single_screen_radio.connect("activate", self.single_screen)

        self.menu.show()

        self.ind.set_menu(self.menu)
Exemple #5
0
    def __init__(self, callback, active_item):
        gtk.Menu.__init__(self)
        # append two MenuItem's to this menu and set callbacks
        self.oneCharMenuItem = gtk.RadioMenuItem(None,
                                                 _('Block one char emoticons'))
        self.oneCharMenuItem.set_name('one')
        if active_item == 'one':
            self.oneCharMenuItem.set_active(True)
        self.append(self.oneCharMenuItem)

        self.anyCharMenuItem = gtk.RadioMenuItem(self.oneCharMenuItem,
                                                 _('Block any emoticon'))
        self.anyCharMenuItem.set_name('any')
        if active_item == 'any':
            self.anyCharMenuItem.set_active(True)
        self.append(self.anyCharMenuItem)

        self.disabledItem = gtk.RadioMenuItem(self.oneCharMenuItem,
                                              _('Show all emoticons'))
        self.disabledItem.set_name('no')
        if active_item == 'no':
            self.disabledItem.set_active(True)
        self.append(self.disabledItem)

        self.oneCharCallback = self.oneCharMenuItem.connect(
            'activate', callback)
        self.anyCharCallback = self.anyCharMenuItem.connect(
            'activate', callback)
        self.disabledCallback = self.disabledItem.connect('activate', callback)

        self.show_all()
    def menu_setup(self):
        self.menu = gtk.Menu()
        self.BTCtickers = None

        self.bitstampBTC = gtk.RadioMenuItem(self.BTCtickers, "BitStamp")
        self.bitstampBTC.connect("activate",
                                 lambda x: self.toggleBTCdisplay("bitstamp"))
        self.bitstampBTC.show()
        self.BTCtickers = self.bitstampBTC

        self.bitfinexBTC = gtk.RadioMenuItem(self.BTCtickers, "Bitfinex")
        self.bitfinexBTC.connect("activate",
                                 lambda x: self.toggleBTCdisplay("bitfinex"))
        self.bitfinexBTC.show()
        self.BTCtickers = self.bitfinexBTC

        self.defSet = gtk.MenuItem("Choose exchange : ")
        self.defSet.show()
        self.menu.append(self.defSet)
        self.menu.append(self.bitstampBTC)
        self.menu.append(self.bitfinexBTC)

        self.setRefreshMenu(self.menu)

        self.getNewPricesBTC()

        self.about = gtk.MenuItem("About")
        self.about.connect("activate", self.menu_about_response)
        self.about.show()
        self.menu.append(self.about)
        self.quit_item = gtk.MenuItem("Quit Indicator")
        self.quit_item.connect("activate", self.quit)
        self.quit_item.show()
        self.menu.append(self.quit_item)
Exemple #7
0
    def _on_known_accounts(self, known_accounts):
        known_accounts_to_log = []
        for account in known_accounts:
            account_to_log = {}
            for key, value in account.copy().iteritems():
                if key == 'password':
                    value = '*' * len(value)
                account_to_log[key] = value
            known_accounts_to_log.append(account_to_log)
        log.debug("_on_known_accounts: %s", known_accounts_to_log)
        if len(known_accounts) <= 1:
            return

        self.builder.get_object("menuitem_change_owner").set_visible(True)

        self.change_owner_submenu = gtk.Menu()
        self.change_owner_submenu_items = {}
        maingroup = gtk.RadioMenuItem(None, None)

        self.change_owner_submenu_items[None] = gtk.RadioMenuItem(maingroup)

        for account in known_accounts:
            username = account["username"]
            item = gtk.RadioMenuItem(maingroup, username)
            self.change_owner_submenu_items[username] = item
            self.change_owner_submenu.append(item)
            item.connect("toggled", self._on_change_owner_toggled, username)

        self.change_owner_submenu.show_all()
        self.change_owner_submenu_items[None].set_active(True)
        self.change_owner_submenu_items[None].hide()
        self.builder.get_object("menuitem_change_owner").connect(
            "activate", self._on_change_owner_submenu_active)
        self.builder.get_object("menuitem_change_owner").set_submenu(
            self.change_owner_submenu)
    def menu_setup(self):
        self.menu = gtk.Menu()
        self.BTCtickers = None
        self.btceBTC = gtk.RadioMenuItem(self.BTCtickers, "BTC-E")
        self.btceBTC.connect("activate",
                             lambda x: self.toggleBTCdisplay("btce"))
        self.btceBTC.show()
        self.BTCtickers = self.btceBTC
        self.mtgoxBTC = gtk.RadioMenuItem(self.BTCtickers, "MtGox")
        self.mtgoxBTC.connect("activate",
                              lambda x: self.toggleBTCdisplay("mtgox"))
        self.mtgoxBTC.show()
        self.BTCtickers = self.mtgoxBTC
        self.bitstampBTC = gtk.RadioMenuItem(self.BTCtickers, "BitStamp")
        self.bitstampBTC.connect("activate",
                                 lambda x: self.toggleBTCdisplay("bitstamp"))
        self.bitstampBTC.show()
        self.BTCtickers = self.bitstampBTC
        self.blockchainBTC = gtk.RadioMenuItem(self.BTCtickers, "BlockChain")
        self.blockchainBTC.connect(
            "activate", lambda x: self.toggleBTCdisplay("blockchain"))
        self.blockchainBTC.show()
        self.BTCtickers = self.blockchainBTC

        self.defSet = gtk.MenuItem("Choose exchange : ")
        self.defSet.show()
        self.menu.append(self.defSet)
        self.menu.append(self.mtgoxBTC)
        self.menu.append(self.btceBTC)
        self.menu.append(self.bitstampBTC)
        self.menu.append(self.blockchainBTC)

        self.setRefreshMenu(self.menu)

        self.ltcAdd = gtk.CheckMenuItem("LTC Price")
        self.ltcAdd.connect("activate", self.initLTCAddOn)
        if self.LTCMODE:
            self.ltcAdd.activate()
        self.ltcAdd.show()
        self.menu.append(self.ltcAdd)

        self.nmcAdd = gtk.CheckMenuItem("NMC Price")
        self.nmcAdd.connect("activate", self.initNMCAddOn)
        if self.NMCMODE:
            self.nmcAdd.activate()
        self.nmcAdd.show()
        self.menu.append(self.nmcAdd)

        self.getNewPricesBTC()

        self.about = gtk.MenuItem("About")
        self.about.connect("activate", self.menu_about_response)
        self.about.show()
        self.menu.append(self.about)
        self.quit_item = gtk.MenuItem("Quit Indicator")
        self.quit_item.connect("activate", self.quit)
        self.quit_item.show()
        self.menu.append(self.quit_item)
Exemple #9
0
    def __init__(self):

        super(PyApp, self).__init__()
        self.set_title("Menu Demo")
        self.set_default_size(500, 450)
        self.set_position(gtk.WIN_POS_CENTER)

        mb = gtk.MenuBar()

        menu1 = gtk.Menu()
        file = gtk.MenuItem("_File")
        file.set_submenu(menu1)
        acgroup = gtk.AccelGroup()
        self.add_accel_group(acgroup)
        new = gtk.ImageMenuItem(gtk.STOCK_NEW, acgroup)
        new.add_accelerator("activate", acgroup, ord('N'),
                            gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)

        menu1.append(new)
        open = gtk.ImageMenuItem(gtk.STOCK_OPEN)

        menu1.append(open)
        chk = gtk.CheckMenuItem("Checkable")

        menu1.append(chk)
        radio1 = gtk.RadioMenuItem(None, "Radio1")
        radio2 = gtk.RadioMenuItem(radio1, "Radio2")

        menu1.append(radio1)
        menu1.append(radio2)
        sep = gtk.SeparatorMenuItem()

        menu1.append(sep)
        exit = gtk.ImageMenuItem(gtk.STOCK_QUIT)

        menu1.append(exit)
        menu2 = gtk.Menu()
        edit = gtk.MenuItem("_Edit")
        edit.set_submenu(menu2)
        copy = gtk.ImageMenuItem(gtk.STOCK_COPY)

        menu2.append(copy)
        cut = gtk.ImageMenuItem(gtk.STOCK_CUT)

        menu2.append(cut)
        paste = gtk.ImageMenuItem(gtk.STOCK_PASTE)

        menu2.append(paste)
        mb.append(file)
        mb.append(edit)
        vbox = gtk.VBox(False, 2)
        vbox.pack_start(mb, False, False, 0)

        self.add(vbox)
        self.connect("destroy", gtk.main_quit)
        self.show_all()
Exemple #10
0
  def button_press(self, widget, event):
    menu = gtk.Menu()

    # Pause item menu
    if (self.paused):
      rmItem = gtk.ImageMenuItem(gtk.STOCK_EXECUTE)
    else:
      rmItem = gtk.ImageMenuItem(gtk.STOCK_MEDIA_STOP)
      
    rmItem.connect('activate', self.onPause)
    rmItem.show()
    menu.append(rmItem)
    
    # Preference item menu
    rmItem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
    rmItem.show()
    # Creating and linking langues submenu
    menulngs = gtk.Menu()
    rmItem.set_submenu(menulngs)
    
    # Creating languages items in submenu
    # one empty item to initiate radioitem group
    smItem = gtk.RadioMenuItem(None, None)
    for i in self.supported_langs:
      # Creating new item
      smItem = gtk.RadioMenuItem(smItem, i, True)
      # ... adding item in submenu
      menulngs.append(smItem)
      # linking it with onLang fonction
      smItem.connect("toggled", self.onLang, i)
      # i is defaut language activating radio button
      if i == self.lang :
        smItem.set_active(True)
      # show item
      smItem.show()
    
    menu.append(rmItem)
    
    about = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
    about.connect("activate", self.show_about_dialog)
    about.show()
    
    quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
    quit.connect("activate", self.quit)
    quit.show()
    
    menu.append(about)
    menu.append(quit)
    menu.show_all()
    
    menu.popup(None, None, gtk.status_icon_position_menu, event.button, event.time, self.statusicon)
 def populate_popup_cb(self, webview, menu):
     item = gtk.MenuItem(label="Source Edition")
     menu.append(item)
     submenu = gtk.Menu()
     menuitem = gtk.MenuItem(label="Loaded Source or File Source")
     menuitem.connect('activate', self.edit_source_activated_cb)
     submenu.append(menuitem)
     menuitem = gtk.MenuItem(label="Interpreted Source (JS useful)")
     menuitem.connect('activate', self.edit_loaded_activated_cb)
     submenu.append(menuitem)
     item.set_submenu(submenu)
     # -------------------------------
     menu.append(gtk.SeparatorMenuItem())
     # -------------------------------
     item = gtk.ImageMenuItem(stock_id=gtk.STOCK_HOME)
     item.connect('activate', self.go_home_activated_cb)
     item.set_property('label', 'Starting Page')
     menu.append(item)
     # -------------------------------
     menu.append(gtk.SeparatorMenuItem())
     # -------------------------------
     self.append_plugins_submenu(menu)
     item = gtk.MenuItem(label="Server Config")
     menu.append(item)
     submenu = gtk.Menu()
     menuitem = gtk.CheckMenuItem(label="Enable Server")
     menuitem.connect('toggled', self.toggle_serveur_activated_cb)
     menuitem.set_property('active', self.flag_serveur)
     submenu.append(menuitem)
     menuitem = gtk.RadioMenuItem(None, "Localhost Acces Only")
     menuitem.connect('toggled', self.toggle_local_acces_activated_cb)
     menuitem.set_property('active', self.flag_local_acces)
     menuitem.set_property('sensitive', self.flag_serveur)
     submenu.append(menuitem)
     menuitem = gtk.RadioMenuItem(menuitem, "Global Acces")
     menuitem.connect('toggled', self.toggle_general_acces_activated_cb)
     menuitem.set_property('active', not self.flag_local_acces)
     menuitem.set_property('sensitive', self.flag_serveur)
     submenu.append(menuitem)
     item.set_submenu(submenu)
     # -------------------------------
     menu.append(gtk.SeparatorMenuItem())
     # -------------------------------
     item = gtk.CheckMenuItem(label="Auto Refresh")
     item.connect('toggled', self.toggle_auto_refresh_cb)
     item.set_property('active', self.auto_refresh)
     menu.append(item)
     item = gtk.MenuItem(label="Panel location")
     item.connect('activate', self.toggle_view_activated_cb)
     menu.append(item)
     menu.show_all()
Exemple #12
0
 def _build_languages_menu(self):
     menu = gtk.Menu()
     group = gtk.RadioMenuItem()  #group = [] # PyGObject
     for code, name in SpellChecker.languages:
         item = gtk.RadioMenuItem(
             group=group, label=name
         )  #item = gtk.RadioMenuItem.new_with_label(group, name) # PyGObject
         item.connect('activate', self._language_change_callback, code)
         if code == self.language:
             item.set_active(True)
         #group.append(item) # PyGObject
         menu.append(item)
     menu.show_all()
     return menu
Exemple #13
0
    def popupMenu(self, event, iter, right=True):
        menu = gtk.Menu()
        if self.treemodel.get_value(iter, 4) == 'server':
            menuitems = {"Restart Server": self.restartServer}
            iters = [iter]
        else:
            if right:
                selection = self.treeview.get_selection().get_selected_rows()
                iters = [
                    self.treemodel.get_iter(path)
                    for path in selection[1] if self.treemodel.get_value(
                        self.treemodel.get_iter(path), 4) != 'server'
                ]
            else:
                iters = [iter]

            outputMenu = gtk.Menu()

            menu_item = gtk.RadioMenuItem(None, 'Null Output')
            menu_item.connect('toggled', self.on_output_menu_toggled, iters)
            menu_item.show()
            outputMenu.append(menu_item)

            menu_item1 = gtk.RadioMenuItem(menu_item, 'Vlc Output')
            menu_item1.connect('toggled', self.on_output_menu_toggled, iters)
            menu_item1.show()
            outputMenu.append(menu_item1)

            menu_item2 = gtk.RadioMenuItem(menu_item, 'Flv Output')
            menu_item2.connect('toggled', self.on_output_menu_toggled, iters)
            menu_item2.show()
            outputMenu.append(menu_item2)

            outputsItem = gtk.MenuItem('Select Output')
            outputsItem.set_submenu(outputMenu)
            menu.append(outputsItem)

            menuitems = {
                "Set UploadBW": self._setUploadBW,
                "Get Statistics": self._getStatistics
            }

        for i in menuitems.keys():
            menu_item = gtk.MenuItem(i)
            menu_item.connect("activate", menuitems[i], iters)
            menu.append(menu_item)
        menu.show_all()
        return menu
Exemple #14
0
    def handle_subtitles(self, widget):
        tracks = []
        menu = gtk.Menu()

        tracks = app.video_renderer.get_subtitle_tracks()

        if len(tracks) == 0:
            child = gtk.MenuItem(_("None Available"))
            child.set_sensitive(False)
            child.show()
            menu.append(child)
        else:
            enabled_track = app.video_renderer.get_enabled_subtitle_track()

            first_child = None
            for i, lang in tracks:
                child = gtk.RadioMenuItem(first_child, lang)
                if enabled_track == i:
                    child.set_active(True)
                child.connect('activate', self.handle_subtitle_change, i)
                child.show()
                menu.append(child)
                if first_child == None:
                    first_child = child

            sep = gtk.SeparatorMenuItem()
            sep.show()
            menu.append(sep)

            child = gtk.RadioMenuItem(first_child, _("Disable Subtitles"))
            if enabled_track == -1:
                child.set_active(True)
            child.connect('activate', self.handle_disable_subtitles)
            child.show()
            menu.append(child)

        sep = gtk.SeparatorMenuItem()
        sep.show()
        menu.append(sep)

        child = gtk.MenuItem(_("Select a Subtitles file..."))
        sensitive = 'PlayingLocalVideo' in app.menu_manager.enabled_groups
        child.set_sensitive(sensitive)
        child.connect('activate', self.handle_select_subtitle_file)
        child.show()
        menu.append(child)

        menu.popup(None, None, None, 1, gtk.get_current_event_time())
    def __init__(self, dict):
        self.dict = dict
        self.statusicon = gtk.StatusIcon()
        self.statusicon.set_from_file(linconf.LOGO)
        self.statusicon.connect("popup-menu", self.right_click_event)
        #self.statusicon.connect("activate", self.right_click_event)
        self.statusicon.set_tooltip("translate")
        self.does_trans = True
        # 这里可以放一个配置界面
        #window = gtk.Window()
        #window.connect("destroy", lambda w: gtk.main_quit())
        #window.show_all()
        self.menu = gtk.Menu()

        itemlist = [(u'About', self.show_about_dialog),
                    (u'Quit', gtk.main_quit)]

        self.EnableTransMenu = gtk.CheckMenuItem("划句")
        self.EnableTransMenu.set_active(self.does_trans)
        self.EnableTransMenu.connect('toggled', self.trans_or_not_menu_view)
        self.menu.append(self.EnableTransMenu)

        engine_menu = gtk.Menu()
        google_item = gtk.RadioMenuItem(None, "google")
        youdao_item = gtk.RadioMenuItem(google_item, "有道")
        baidu_item = gtk.RadioMenuItem(google_item, "百度")
        google_item.connect('activate', self._engine_select, "google")
        youdao_item.connect('activate', self._engine_select, "youdao")
        baidu_item.connect('activate', self._engine_select, "baidu")
        youdao_item.set_active(linconf.translate_engine == "youdao")
        google_item.set_active(linconf.translate_engine == "google")
        baidu_item.set_active(linconf.translate_engine == "baidu")

        engine_menu.add(google_item)
        engine_menu.add(youdao_item)
        engine_menu.add(baidu_item)

        engine_menu_item = gtk.MenuItem("搜索引擎")
        engine_menu_item.set_submenu(engine_menu)
        self.menu.add(engine_menu_item)

        for text, callback in itemlist:
            item = gtk.MenuItem(text)
            item.connect('activate', callback)
            item.show()
            self.menu.append(item)

        self.menu.show_all()
Exemple #16
0
 def _languages_menu(self):
     def _set_language(item, code):
         self.language = code
         self._cherrytree_instance.spell_check_notify_new_lang(code)
     menu = gtk.Menu()
     group = gtk.RadioMenuItem()
     connect = []
     for code, name in self.languages:
         item = gtk.RadioMenuItem(group, name)
         if code == self.language:
             item.set_active(True)
         connect.append((item, code))
         menu.append(item)
     for item, code in connect:
         item.connect('activate', _set_language, code)
     return menu
Exemple #17
0
    def __init__(self):
        gtk.HBox.__init__(self)

        self.entry=gtk.Entry()
        self.entry.set_size_request(80,-1)
        self.entry.connect("focus-in-event",self.entry_focus_in)
        self.entry.connect("focus-out-event",self.entry_focus_out)

        bar=gtk.MenuBar()
        self.search=gtk.MenuItem("search")
        button=gtk.Button("",gtk.STOCK_FIND)
        
        menu=gtk.Menu()
        item=None
        for name in ("Subject","From","Body"):
            item=gtk.RadioMenuItem(item,name)
            item.connect("toggled",self.change_search_type,name)
            menu.append(item)
            if name=="Subject": item.set_active(True)

        self.search.set_submenu(menu)

        bar.append(self.search)
        
        #self.pack_start(gtk.VSeparator(),False,False,2)
        self.pack_start(bar,False,False,0)
        self.pack_start(self.entry,False,False,0)
        self.pack_start(button,False,False,0)
        #self.pack_start(gtk.VSeparator(),False,False,2)


        button.connect("clicked",self.on_search_clicked)

        self.search_type="Subject"
Exemple #18
0
    def __init__(self):
        self.ind = appindicator.Indicator(
            "example-simple-client", "indicator-messages",
            appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_status(appindicator.STATUS_ACTIVE)
        self.ind.set_attention_icon("indicator-messages-new")
        self.ind.set_icon("distributor-logo")

        # create a menu
        self.menu = gtk.Menu()

        # create items for the menu - labels, checkboxes, radio buttons and images are supported:

        item = gtk.MenuItem("Regular Menu Item")
        self.menu.append(item)

        check = gtk.CheckMenuItem("Check Menu Item")
        self.menu.append(check)

        radio = gtk.RadioMenuItem(None, "Radio Menu Item")
        self.menu.append(radio)

        image = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        image.connect("activate", self.quit)
        self.menu.append(image)

        self.menu.show()

        self.ind.set_menu(self.menu)
    def menu_setupLTC(self):
        self.menuLTC = gtk.Menu()
        self.LTCtickers = None

        self.bitfinexLTC = gtk.RadioMenuItem(self.LTCtickers, "Bitfinex")
        self.bitfinexLTC.connect("activate",
                                 lambda x: self.toggleLTCdisplay("bitfinex"))
        self.bitfinexLTC.show()
        self.LTCtickers = self.bitfinexLTC

        defSetLTC = gtk.MenuItem("Choose exchange : ")
        defSetLTC.show()
        self.menuLTC.append(defSetLTC)
        self.menuLTC.append(self.bitfinexLTC)
        self.setRefreshMenu(self.menuLTC)

        self.getNewPricesLTC()

        self.kill_LTC = gtk.MenuItem("LTC Off")
        self.kill_LTC.connect("activate", self.noLTC)
        self.kill_LTC.show()
        self.menuLTC.append(self.kill_LTC)
        self.quit_item = gtk.MenuItem("Quit Indicator")
        self.quit_item.connect("activate", self.quit)
        self.quit_item.show()
        self.menuLTC.append(self.quit_item)
        self.LTCInit = True
Exemple #20
0
    def _update_menu(self):
        """Update main window session menu"""
        for item in self._session_menu.get_children():
            self._session_menu.remove(item)

        # get current session index
        current_session = self._options.section('sessions').get('current')

        # iterate over saved sessions and create menu item for each
        group = None
        for index, session in enumerate(
                self._options.section('sessions').get('list')):
            menu_item = gtk.RadioMenuItem(group, session.get('name'))
            menu_item.set_active(index == current_session)
            menu_item.connect('activate', self._switch_session, index)
            menu_item.show()

            # append menu item to menu
            self._session_menu.append(menu_item)

            # store current item to be used for grouping with others
            group = menu_item

        # add options
        separator = gtk.SeparatorMenuItem()
        separator.show()

        self._session_menu.append(separator)
        self._session_menu.append(self._manage_sessions_menu_item)
Exemple #21
0
def create_menu_items_from_view(menu, items):
    # TODO: images & radio groups, for now only basic representation
    for item in items:
        if item.type is MenuItemView.COMMAND:
            it = gtk.MenuItem(item.label)
            it.connect("activate", lambda i, item: item.command(), item )
            it.show()
            menu.append(it)
        elif item.type is MenuItemView.CASCADE_MENU:
            men = gtk.Menu()
            it = gtk.MenuItem(item.label)
            create_menu_items_from_view(men, item.items)
            it.set_submenu(men)
            it.show()
            menu.append(it)
        elif item.type is MenuItemView.SEPARATOR:
            it = gtk.SeperatorMenuItem()
            it.show()
            menu.append(it)
        elif item.type is MenuItemView.CHECKBUTTON:
            it = gtk.CheckMenuItem(item.label)
            if item.checkbox:
                it.set_active()
            it.show()
            menu.append(it)
        elif item.type is MenuItemView.RADIOBUTTON:
            it = gtk.RadioMenuItem(item.label)
            it.show()
            menu.append(it)
        elif item.type is MenuItemView.RADIOBUTTONGROUP:
            pass
    def menu_setupNMC(self):
        self.menuNMC = gtk.Menu()
        self.NMCtickers = None
        self.btceNMC = gtk.RadioMenuItem(self.NMCtickers, "BTC-E")
        self.btceNMC.connect("activate",
                             lambda x: self.toggleNMCdisplay("btce"))
        self.btceNMC.show()
        self.NMCtickers = self.btceNMC
        #self.mtgoxLTC = gtk.RadioMenuItem(self.LTCtickers,"MtGox"); self.mtgoxLTC.connect("activate", lambda x: self.toggleLTCdisplay("mtgox")); self.mtgoxLTC.show()
        #self.BTCtickers = self.mtgoxBTC

        defSetNMC = gtk.MenuItem("Choose exchange : ")
        defSetNMC.show()
        self.menuNMC.append(defSetNMC)
        self.menuNMC.append(self.btceNMC)
        #self.menuLTC.append(self.mtgoxLTC);
        self.setRefreshMenu(self.menuNMC)

        self.getNewPricesNMC()

        self.kill_NMC = gtk.MenuItem("NMC Off")
        self.kill_NMC.connect("activate", self.noNMC)
        self.kill_NMC.show()
        self.menuNMC.append(self.kill_NMC)
        self.quit_item = gtk.MenuItem("Quit Indicator")
        self.quit_item.connect("activate", self.quit)
        self.quit_item.show()
        self.menuNMC.append(self.quit_item)
        self.NMCInit = True
Exemple #23
0
 def get_item(self):
     try:
         return self.__item
     except:
         self.__item = gtk.RadioMenuItem(None, self._get_menu_label())
         self.__item.connect("activate", self._on_select)
         self.__item.show()
         return self.__item
Exemple #24
0
    def menu_exchange_create(self, menuIn):
        """Create the menu for controlling what exchange mechanism to use."""
        exchangeMenu = gtk.Menu()
        exMenu = gtk.MenuItem("Set exchange:")
        exMenu.set_submenu(exchangeMenu)

        self.ETHtickers = None
        menuCADETH = gtk.RadioMenuItem(self.ETHtickers, "CAD / ETH")
        menuCADETH.connect("activate",
                           lambda x: self.menu_exchange_response("ethcad"))
        menuCADETH.show()
        if (self.exchange == "ethcad"):
            menuCADETH.set_active(True)
        self.ETHtickers = menuCADETH
        menuBTCETH = gtk.RadioMenuItem(self.ETHtickers, "BTC / ETH")
        menuBTCETH.connect("activate",
                           lambda x: self.menu_exchange_response("btceth"))
        menuBTCETH.show()
        if (self.exchange == "btceth"):
            menuBTCETH.set_active(True)
        self.ETHtickers = menuBTCETH
        menuETHUSD = gtk.RadioMenuItem(self.ETHtickers, "ETH / USD")
        menuETHUSD.connect("activate",
                           lambda x: self.menu_exchange_response("ethusd"))
        menuETHUSD.show()
        if (self.exchange == "ethusd"):
            menuETHUSD.set_active(True)
        self.ETHtickers = menuETHUSD
        menuETHBTC = gtk.RadioMenuItem(self.ETHtickers, "ETH / BTC")
        menuETHBTC.connect("activate",
                           lambda x: self.menu_exchange_response("ethbtc"))
        menuETHBTC.show()
        if (self.exchange == "ethbtc"):
            menuETHBTC.set_active(True)
        self.ETHtickers = menuETHBTC

        exchangeMenu.append(menuCADETH)
        # exchangeMenu.append(menuBTCETH)
        # exchangeMenu.append(menuETHUSD)
        # exchangeMenu.append(menuETHBTC)
        exMenu.show()
        exchangeMenu.show()
        menuIn.append(exMenu)
Exemple #25
0
    def menu_refresh_create(self, menuIn):
        """Create the menu for controlling how often the data is refreshed."""
        refreshmenu = gtk.Menu()
        refMenu = gtk.MenuItem("Set refresh rate:")
        refMenu.set_submenu(refreshmenu)

        self.refreshRates = None
        menuRefresh1 = gtk.RadioMenuItem(self.refreshRates, "30s")
        menuRefresh1.connect("activate",
                             lambda x: self.menu_refresh_response(30))
        menuRefresh1.show()
        if (self.refresh_frequency == 30):
            menuRefresh1.set_active(True)
        self.refreshRates = menuRefresh1
        menuRefresh2 = gtk.RadioMenuItem(self.refreshRates, "1m")
        menuRefresh2.connect("activate",
                             lambda x: self.menu_refresh_response(60))
        menuRefresh2.show()
        if (self.refresh_frequency == 60):
            menuRefresh2.set_active(True)
        self.refreshRates = menuRefresh2
        menuRefresh3 = gtk.RadioMenuItem(self.refreshRates, "5m")
        menuRefresh3.connect("activate",
                             lambda x: self.menu_refresh_response(300))
        menuRefresh3.show()
        if (self.refresh_frequency == 300):
            menuRefresh3.set_active(True)
        self.refreshRates = menuRefresh3
        menuRefresh4 = gtk.RadioMenuItem(self.refreshRates, "10m")
        menuRefresh4.connect("activate",
                             lambda x: self.menu_refresh_response(600))
        menuRefresh4.show()
        if (self.refresh_frequency == 600):
            menuRefresh4.set_active(True)
        self.refreshRates = menuRefresh4

        refreshmenu.append(menuRefresh1)
        refreshmenu.append(menuRefresh2)
        refreshmenu.append(menuRefresh3)
        refreshmenu.append(menuRefresh4)
        refMenu.show()
        refreshmenu.show()
        menuIn.append(refMenu)
Exemple #26
0
def create_menu(window):
    main_menu = gtk.Menu()
    window.set_menu(main_menu)

    menu_others = gtk.Menu()
    item_others = gtk.MenuItem("Others")
    item_radio1 = gtk.RadioMenuItem(None, "Radio1")
    item_radio2 = gtk.RadioMenuItem(item_radio1, "Radio2")
    item_check = gtk.CheckMenuItem("Check")
    item_close = gtk.MenuItem("Close")
    item_separator = gtk.SeparatorMenuItem()
    main_menu.append(item_others)
    menu_others.append(item_radio1)
    menu_others.append(item_radio2)
    menu_others.append(item_separator)
    menu_others.append(item_check)
    menu_others.append(item_close)
    item_others.set_submenu(menu_others)
    item_close.connect('activate', gtk.main_quit)
    main_menu.show_all()
Exemple #27
0
	def init(self, context):
		BaseOutlineView.init(self, context)
		
		self._grouping = GROUP_NONE
		
		# add grouping controls to toolbar
		
		self._item_none = gtk.RadioMenuItem(None, "No Grouping")
		self._item_type = gtk.RadioMenuItem(self._item_none, "Group by Type")
		self._item_author = gtk.RadioMenuItem(self._item_none, "Group by Author")
		self._item_year = gtk.RadioMenuItem(self._item_none, "Group by Year")
		
		self._preferences = Preferences()
		
		grouping = self._preferences.get("BibtexOutlineGrouping", GROUP_NONE)
		if grouping == GROUP_NONE:
			self._item_none.set_active(True)
		elif grouping == GROUP_TYPE:
			self._item_type.set_active(True)
		elif grouping == GROUP_AUTHOR:
			self._item_author.set_active(True)
		elif grouping == GROUP_YEAR:
			self._item_year.set_active(True)
		
		self._handlers[self._item_none] = self._item_none.connect("toggled", self._on_grouping_toggled)
		self._handlers[self._item_type] = self._item_type.connect("toggled", self._on_grouping_toggled)
		self._handlers[self._item_author] = self._item_author.connect("toggled", self._on_grouping_toggled)
		self._handlers[self._item_year] = self._item_year.connect("toggled", self._on_grouping_toggled)

		menu = gtk.Menu()
		menu.add(self._item_none)
		menu.add(self._item_type)
		menu.add(self._item_author)
		menu.add(self._item_year)
		menu.show_all()

		tool_button = gtk.MenuToolButton(gtk.STOCK_SORT_DESCENDING)
		tool_button.set_menu(menu)
		tool_button.show()
		
		self._toolbar.insert(tool_button, -1)
Exemple #28
0
 def generate_iface_submenu(self):
     if hasattr(self, 'iface_submenu'):
         self.iface_submenu.foreach(lambda x: self.iface_submenu.remove(x))
         iface_submenu = self.iface_submenu
     else:
         iface_submenu = gtk.Menu()
     iface_item1 = None
     devices = self.netstats.ifaces.keys()
     devices.sort()
     for device in devices:
         if not iface_item1:
             iface_item1 = gtk.RadioMenuItem(label=device)
             iface_item = iface_item1
         else:
             iface_item = gtk.RadioMenuItem(iface_item1, label=device)
         iface_item.connect('toggled', self.change_iface, device)
         if device == self.iface:
             iface_item.set_active(True)
         iface_submenu.add(iface_item)
     iface_submenu.show_all()
     return iface_submenu
	def build_menu(self,args=None):
		# create a menu
		self.menu = gtk.Menu()
		self.wifi_submenu = gtk.Menu()
		self.devices_submenu=gtk.Menu()

		self.devices_menu=gtk.MenuItem("Device (%s)"%self.active_interface)
		self.devices_menu.set_submenu(self.devices_submenu)
		self.menu.add(self.devices_menu)
	
		self.menu_item_all=gtk.RadioMenuItem(None, "All")
		self.menu_item_all.connect("toggled", self.on_button_toggled, 'All')
		self.menu_item_all.set_active(True)
		self.devices_submenu.append(self.menu_item_all)
		self.menu.append(gtk.SeparatorMenuItem())
		for iface in self.get_interfaces():
			if iface !='All':
				menu_iface=gtk.RadioMenuItem(self.menu_item_all, iface)
				menu_iface.connect("toggled", self.on_button_toggled, iface)
				self.devices_submenu.append(menu_iface)
				menu_iface.show()
		#nethogsmonitor menus
		self.nethogs_menu=gtk.CheckMenuItem("Enable Monitor")
		self.nethogs_menu.set_active(self.bandwidthPerProcess_active)
		self.menu.add(self.nethogs_menu)
		self.nethogs_menu.connect("activate",self.on_nethogs_menu_click);

		for i in range(15):
			self.menu_process.append(gtk.MenuItem(""))
			self.menu.add(self.menu_process[i])
			self.menu_process[i].set_visible(False)
		#seperator
		self.menu.append(gtk.SeparatorMenuItem())
		#Quit button
		exit_menu = gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT)
		exit_menu.connect('activate', self.on_exit)
		self.menu.add(exit_menu)
		self.menu.show_all()
		self.ind.set_menu(self.menu)
		self.update_process_menu() #After you build the menu, update it, to clear any empty menu items
Exemple #30
0
    def generate_adapter_menu(self):
        menu = gtk.Menu()

        sep = gtk.SeparatorMenuItem()
        sep.show()
        menu.append(sep)

        settings = gtk.ImageMenuItem("gtk-preferences")
        settings.connect("activate",
                         lambda x: self.blueman.adapter_properties())
        settings.show()
        menu.append(settings)

        group = None
        for adapter in self.adapters:
            props = adapter.GetProperties()
            item = gtk.RadioMenuItem(group, props["Name"])
            if group == None:
                group = item

            item.connect("activate", self.on_adapter_selected,
                         adapter.GetObjectPath())
            if adapter.GetObjectPath(
            ) == self.blueman.List.Adapter.GetObjectPath():
                item.props.active = True

            item.show()
            menu.prepend(item)

        sep = gtk.SeparatorMenuItem()
        sep.show()
        menu.prepend(sep)

        item = create_menuitem(_("_Search"), get_icon("gtk-find", 16))
        item.connect("activate", lambda x: self.blueman.inquiry())
        item.show()
        menu.prepend(item)
        self.Search = item

        m = self.item_adapter.get_submenu()
        if m != None:
            m.deactivate()
        self.item_adapter.set_submenu(menu)

        sep = gtk.SeparatorMenuItem()
        sep.show()
        menu.append(sep)

        item = gtk.ImageMenuItem("gtk-quit")
        item.connect("activate", lambda x: gtk.main_quit())
        item.show()
        menu.append(item)