def GetTextCtrlMenu(self): from gui.uberwidgets.umenu import UMenu m, tc = UMenu(self), self.input_area.tc # spelling suggestions and options from gui.spellchecktextctrlmixin import add_spelling_suggestions if add_spelling_suggestions(tc, m): m.AddSep() m.AddItem( _('Copy'), id=wx.ID_COPY, callback=tc.Copy) # todo: disable if "not tc.CanCopy()" when shown. m.AddItem(_('Paste'), id=wx.ID_PASTE, callback=tc.Paste) m.AddSep() m.AddPrefCheck('messaging.show_actions_bar', _('Show &Actions Bar')) m.AddPrefCheck('messaging.show_formatting_bar', _('Show &Formatting Bar')) m.AddPrefCheck('messaging.show_send_button', _('Show Send Button')) m.AddSep() gui.toolbox.add_rtl_checkbox(tc, m) return m
def CreatePopupMenu(self): buddy_frame = wx.FindWindowByName('Buddy List') # TODO: fix skinned menus so that they don't need to be told they are in the system tray! umenu = UMenu(buddy_frame, onshow=None, windowless=True) add_hidden_convo_menu_items(umenu) statuscombo.add_global_to_menu(umenu, _('Set &Global Status...')) statmenu = UMenu( buddy_frame, onshow=None) #statuscombo.create_status_menu(add_custom = True) statuscombo.status_menu(statmenu, add_custom=True, add_promote=True) umenu.AddSubMenu(statmenu, _('Set IM &Status')) umenu.AddSep() show_hide = umenu.AddItem(_('Show &Buddy List'), id=actionIDs.ShowBuddyList) if buddy_frame: docker = getattr(buddy_frame, 'docker', None) if docker: disable_hide = docker.Enabled and docker.docked and docker.AutoHide show_hide.label = _( 'Hide &Buddy List') if buddy_frame.Shown else _( 'Show &Buddy List') show_hide.Enable(not disable_hide) # The menubar is the "app" menubar on Mac and thus cannot be hidden. if platformName != 'mac': umenu.AddPrefCheck('buddylist.show_menubar', _('Show Menu Bar')) umenu.AddItem(_('&Preferences...'), id=wx.ID_PREFERENCES) # Mac gets this menu item standard on the Dock, don't duplicate it. if platformName != 'mac': umenu.AddSep() umenu.AddItem(_('E&xit Digsby'), id=wx.ID_EXIT) # since status items are created dynamically, we must bind to them on the fly. self.SetupStatusHandlers() return umenu
def GetMenu(self): try: self._menu.Destroy() except AttributeError: pass from gui.uberwidgets.umenu import UMenu m = UMenu(self, onshow=self._onpopupshown) self._menu = m self._topid = id(self.Top) self.keep_on_top = m.AddCheckItem(_('&Keep on Top'), callback=self.Top.ToggleOnTop) self.view_past_chats_item = m.AddItem(_('&View Past Chats'), callback=self._on_view_past_chats) m.AddSep() add, addcheck, setmode = m.AddItem, m.AddCheckItem, self.set_mode c = self.capsbuttons = {} buddy = self.Buddy for bname, caption in buttons: if bname == 'files': c[bname] = add(caption, callback=lambda: self.Buddy.send_file()) else: if buddy is None or (bname == 'sms' and 'SMS' not in buddy.caps): continue c[bname] = addcheck( caption, callback=lambda b=bname: setmode(b, toggle_tofrom=b == 'im')) m.AddSep() self.edit_items = {} self.edit_items['Copy'] = add(_('Copy\tCtrl+C'), id=wx.ID_COPY) # add a "Copy Link" item if the mouse is hovering over a link message_area = getattr(self, 'message_area', None) if message_area is not None: # may not be created yet. ctrl = wx.FindWindowAtPointer() if ctrl is message_area: info = ctrl.HitTest(ctrl.ScreenToClient(wx.GetMousePosition())) if info.Link: add(_('Copy &Link'), callback=lambda: clipboard.copy(info.Link)) self.paste_item = self.edit_items['Paste'] = add(_('Paste\tCtrl+V'), id=wx.ID_PASTE) self.paste_index = len(self._menu) - 1 if pref('debug.message_area.show_edit_source', False): add(_('Edit Source'), callback=lambda: self.message_area.EditSource()) if pref('debug.message_area.show_jsconsole', False): from gui.browser import jsconsole add(_('&Javascript Console'), callback=lambda: jsconsole.show_console()) # text size menu if message_area is not None and message_area.IsShownOnScreen(): textsize_menu = UMenu(self) self.textbigger = textsize_menu.AddItem( _('&Increase Text Size\tCtrl+='), callback=message_area.IncreaseTextSize) self.textsmaller = textsize_menu.AddItem( _('&Decrease Text Size\tCtrl+-'), callback=message_area.DecreaseTextSize) textsize_menu.AddSep() textsize_menu.AddItem(_('&Reset Text Size\tCtrl+0'), callback=message_area.ResetTextSize) m.AddSubMenu(textsize_menu, _('&Text Size')) m.AddSep() # these checkboxes affect a global preference that immediately takes effect in # all open ImWins self.roomlist_item = m.AddCheckItem(_('Show &Room List'), callback=self.toggle_roomlist) self.actions_item = m.AddPrefCheck('messaging.show_actions_bar', _('Show &Actions Bar')) self.formatting_item = m.AddPrefCheck('messaging.show_formatting_bar', _('Show &Formatting Bar')) return self._menu
def create_main_menu(parent): 'Returns the main menu object.' menu = MenuBar(parent, skinkey='menubar') digsby = Menu(parent) view = Menu(parent) tools = Menu(parent) help = Menu(parent) def makeadd(m): return (lambda title, callback=None, id=-1: m.AddItem( title, callback=callback, id=id)) # # My Status # mystatus = Menu(parent, onshow=update_statuses) add = makeadd(mystatus) add(_('&New Status Message...'), new_status_message) add(_('&Edit Status Messages...'), lambda: prefsdialog_show('status')) mystatus.AddSep() from gui.protocols import add_group def add_chat(): import gui.chatgui gui.chatgui.join_chat() # # Digsby # digsby.AddSubMenu(mystatus, _('My Status')) add = makeadd(digsby) add(_('My &Accounts...'), lambda: prefsdialog_show('accounts')) digsby.AddSep() sendimitem = add(_('&New IM...\tCtrl+N'), ShowNewIMDialog) if pref('messaging.groupchat.enabled', False): groupchatitem = add(_('New Group C&hat...\tCtrl+Shift+N'), add_chat) else: groupchatitem = None digsby.AddSep() addcontactitem = add(_('Add &Contact...\tCtrl+A'), lambda: AddContactDialog.MakeOrShow()) addgroupitem = add(_('Add &Group...\tCtrl+Shift+A'), lambda: add_group()) renameitem = add(_('&Rename Selection'), lambda: parent.blist.rename_selected()) deleteitem = add( _('&Delete Selection...'), lambda: parent.blist.delete_blist_item(parent.blist.SelectedItem)) digsby.AddSep() add(_('Sign &Off Digsby (%s)') % profile.name, lambda: profile.signoff()) # wx.App handles this for proper shutdown. add(_('E&xit Digsby'), id=wx.ID_EXIT) def on_digsby_show(_m): b = parent.blist.SelectedItem allow_add = any(x.allow_contact_add for x in profile.account_manager.connected_accounts) for item in (sendimitem, groupchatitem, addcontactitem, addgroupitem): if item is not None: item.Enable(allow_add) if not allow_rename(b): renameitem.SetItemLabel(_('&Rename Selection')) deleteitem.SetItemLabel(_('&Delete Selection')) renameitem.Enable(False) deleteitem.Enable(False) else: renameitem.SetItemLabel( _('&Rename {name}').format(name=getattr(b, 'alias', b.name))) deleteitem.SetItemLabel( _('&Delete {name}').format(name=getattr(b, 'alias', b.name))) renameitem.Enable(True) deleteitem.Enable(True) # # View # add = makeadd(view) view.AddPrefCheck('buddylist.always_on_top', _('&Always On Top')) add(_('Skins...\tCtrl+S'), lambda: prefsdialog_show('appearance')) view.AddSep() view.AddPrefCheck('buddylist.show_menubar', _('&Menu Bar')) def on_menubar(val): if not val: wx.MessageBox( _('You can bring back the menubar by right clicking ' 'on the digsby icon in the task tray.'), _('Hide Menu Bar')) profile.prefs.link('buddylist.show_menubar', lambda val: wx.CallAfter(on_menubar, val), False, menu) view.AddPrefCheck('buddylist.show_status', _('Status Panel')) add(_('Arrange &Panels...'), callback=lambda *_a: edit_buddylist_order(parent)) view.AddSep() view.AddPrefCheck('buddylist.show_mobile', _('Show &Mobile Contacts\tCtrl+M')) view.AddPrefCheck('buddylist.show_offline', _('Show &Offline Contacts\tCtrl+O')) groupoffline = view.AddPrefCheck('buddylist.group_offline', _('&Group Offline Contacts\tCtrl+G')) hideoffline = view.AddPrefCheck('buddylist.hide_offline_groups', _('&Hide Offline Groups')) groupby = Menu(parent) add = makeadd(groupby) groupby.sorttypes = [] # sort by sortby = Menu(parent) add = makeadd(sortby) sortby.sorttypes = [] sort_models = profile.blist.sort_models group_by = sort_models[0] sort_by = sort_models[1] then_by = sort_models[2] def addsort(model, view, sortstr, title): def set(model=model, view=view, sortstr=sortstr): model.selection = [v[0] for v in model.values].index(sortstr) view[model.selection].Check(True) mi = view.AddCheckItem(title, set) view.sorttypes.append(sortstr) return mi sort_names = dict( (('none', _('&None')), ('status', _('&Status')), ('name', _('N&ame')), ('log', _('&Log Size')), ('service', _('Ser&vice')))) def addsorts(model, view, names): for name in names: addsort(model=model, view=view, sortstr=name, title=sort_names[name]) addsorts(model=group_by, view=groupby, names=[k for k, _v in GROUP_BY_CHOICES]) groupby.AddSep() groupby.AddItem(_('Advan&ced...'), callback=lambda: prefsdialog_show('contact_list')) addsorts(model=sort_by, view=sortby, names=[k for k, _v in SORT_BY_CHOICES]) sortby.AddSep() def sortby_adv_click(): sortby[-1].Check(then_by.selection > 0) prefsdialog_show('contact_list') sortby.AddCheckItem(_('Advan&ced...'), callback=sortby_adv_click) sortby_adv = sortby[-1] groupby.reset_watcher = reset_checks_SortOptionWatcher( model=group_by, view=groupby, names=GROUP_BY_CHOICES) sortby.reset_watcher = reset_checks_SortOptionWatcher( model=sort_by, view=sortby, names=SORT_BY_CHOICES) sortby.adv_watcher = reset_check_AdvWatcher(model=then_by, view=sortby_adv) view.AddSep() view.AddSubMenu(groupby, _('&Group By')) view.AddSubMenu(sortby, _('&Sort By')) # # Tools # add = makeadd(tools) add(_('&Preferences...\tCtrl+P'), id=wx.ID_PREFERENCES, callback=lambda: prefsdialog_show('accounts')) add(_('Buddy List &Search\tCtrl+F'), parent.start_search) add(_('&File Transfer History\tCtrl+J'), FileTransferDialog.Display) def pb_show(): from gui.pastbrowser import PastBrowser PastBrowser.MakeOrShow() add(_('&Chat History\tCtrl+H'), pb_show) # # Help # add = makeadd(help) add(_('&Documentation'), lambda: wx.LaunchDefaultBrowser('http://wiki.digsby.com')) add(_('Support &Forums'), lambda: wx.LaunchDefaultBrowser('http://forum.digsby.com')) help.AddSep() add(_('&Submit Bug Report'), do_diagnostic) add(_('Su&ggest a Feature'), send_features_email) help.AddSep() if getattr(sys, 'DEV', False) or pref('debug.console', False): add(_('Show Debug Console'), wx.GetApp().toggle_crust) help.AddSep() add(_('Su&pport Digsby'), lambda: support.SupportFrame.MakeOrShow(parent)) for hook in Hook("digsby.help.actions"): help_menu_items = hook() for item in help_menu_items: add(*item) def on_view_show(_m): sortstatus = pref('buddylist.sortby').startswith('*status') showoffline = pref('buddylist.show_offline') hidegroups = pref('buddylist.hide_offline_groups') groupoff = pref('buddylist.group_offline') groupoffline.Enable(not sortstatus and showoffline) groupoffline.Check(groupoff and (not sortstatus and showoffline)) hideoffline.Enable(not sortstatus) hideoffline.Check((sortstatus and not showoffline) or (not sortstatus and hidegroups)) digsbyMenuName = _('&Digsby') if config.platformName == "mac": digsbyMenuName = _("&File") menu.Append(digsby, digsbyMenuName, onshow=on_digsby_show) menu.Append(view, _('&View'), onshow=on_view_show) menu.Append(tools, _('&Tools'), onshow=lambda m: on_accounts_entries(parent, m)) menu.Append(help, _('&Help')) return menu