def __init__(self, gconf_client, gconf_key, screen, backend, buddy_menu, plugin): g15theme.G15Page.__init__(self, _("Settings"), screen, priority=g15screen.PRI_HIGH, theme=g15theme.G15Theme( os.path.join(g15globals.themes_dir, "default"), "menu-screen"), originating_plugin=plugin) me = backend.get_me() self.theme_properties = { "title": _("Settings"), "icon": backend.get_icon() if me.avatar is None else me.avatar, "alt_title": me.nickname } self.menu = g15theme.Menu("menu") self.get_screen().add_page(self) self.add_child(self.menu) self.menu.add_child( SelectChannelMenuItem(gconf_client, gconf_key, backend, plugin)) self.menu.add_child( g15theme.MenuItem('audio-status', True, _('Audio'), activatable=False)) self.menu.add_child(AudioInputMenuItem(backend)) self.menu.add_child(AudioOutputMenuItem(backend)) self.menu.add_child( g15theme.MenuItem('select-status', True, _('Select Status'), activatable=False)) self.menu.add_child(OnLineStatusMenuItem(backend)) self.menu.add_child(AwayStatusMenuItem(backend)) self.menu.add_child( g15theme.MenuItem('select-mode', True, _('Select Buddy List Mode'), activatable=False)) for i in MODE_LIST: self.menu.add_child( SelectModeMenuItem(gconf_client, gconf_key, i, MODES[i][1], backend, buddy_menu)) self.menu.add_child(ReturnMenuItem()) self.add_child(g15theme.MenuScrollbar("viewScrollbar", self.menu))
def load_menu_items(self): items = [] display = "Default" i = 0 status, output = self._get_status_output("xrandr") if status == 0: old_active = self._current_active new_active = [] for line in output.split('\n'): arr = re.findall(r'\S+', line) if line.startswith(" "): size = self._parse_size(arr[0]) for a in range(1, len(arr)): word = arr[a] refresh_string = ''.join(c for c in word if c not in '*+') if len(refresh_string) > 0: refresh_rate = float(refresh_string) i += 1 item = ResolutionMenuItem( i, size, refresh_rate, self, "profile-%d-%s" % (i, refresh_rate), display) item.current = "*" in word items.append(item) if item.current: new_active.append(item) elif "connected" in line: i += 1 display = arr[0] item = g15theme.MenuItem( "display-%s" % i, True, arr[0], activatable=False, icon=g15icontools.get_icon_path(ICONS)) items.append(item) if len( items ) != self._last_items or old_active is None or self._differs( new_active, old_active): self.menu.set_children(items) self._last_items = len(items) if new_active is not None: self.menu.set_selected_item(new_active[0]) self._current_active = new_active self._schedule_check() else: raise Exception( "Failed to query XRandR. Is the xrandr command installed, and do you have the XRandR extension enabled in your X configuration?" )
def load_menu_items(self): items = [] self.volume_monitor_signals = [] # Webcams etc video_devices = [] for i in os.listdir("/dev"): if i.startswith("video"): video_devices.append(i) if len(video_devices) > 0: items.append( g15theme.MenuItem("video-devices", True, _("Video Devices"), icon=g15icontools.get_icon_path( ["camera-web", "camera-video"]), activatable=False)) for i in video_devices: items.append(G15VideoDeviceMenuItem(self, i)) # Video File def activate_video_file(): GObject.idle_add(self._open_video_file) items.append( g15theme.MenuItem("video-file", True, _("Open Audio/Video File"), activate=activate_video_file, icon=g15icontools.get_icon_path("folder"))) # DVD / Mounts self.volume_monitor = Gio.VolumeMonitor.get() self.volume_monitor_signals.append( self.volume_monitor.connect("mount_added", self._on_mount_added)) self.volume_monitor_signals.append( self.volume_monitor.connect("mount_removed", self._on_mount_removed)) removable_media_items = [] for i, mount in enumerate(self.volume_monitor.get_mounts()): drive = mount.get_drive() if not mount.is_shadowed( ) and drive is not None and drive.is_media_removable(): removable_media_items.append( MountMenuItem('mount-%d' % i, mount, self)) if len(removable_media_items): items.append( g15theme.MenuItem("removable-devices", True, _("Removable Devices"), icon=g15icontools.get_icon_path([ "driver-removable-media", "gnome-dev-removable" ]), activatable=False)) items += removable_media_items # Pulse status, output = g15os.get_command_output("pacmd list-sources") if status == 0 and len(output) > 0: i = 0 pulse_items = [] for line in output.split("\n"): line = line.strip() if line.startswith("name: "): name = line[7:-1] elif line.startswith("device.description = "): pulse_items.append( PulseSourceMenuItem(name, line[22:-1], self)) if len(pulse_items) > 0: items.append( g15theme.MenuItem("pulse-sources", True, _("PulseAudio Source"), icon=g15icontools.get_icon_path([ "audio-card", "audio-speakers", "audio-volume-high", "audio-x-generic" ]), activatable=False)) items += pulse_items # Visualisations - TODO - there must be a better way to list them items.append( g15theme.MenuItem("visualisation-mode", True, _("Visualisation Mode"), icon=g15icontools.get_icon_path([ "preferences-color", "gtk-select-color", "preferences-desktop-screensaver", "kscreensaver", "xscreensaver" ]), activatable=False)) for c in [ "goom", \ "libvisual_bumpscope", \ "libvisual_corona", \ "libvisual_infinite", \ "libvisual_jakdaw", \ "libvisual_jess", \ "libvisual_lv_analyzer", \ "libvisual_lv_scope", \ "libvisual_lv_oinksie", \ "synaesthesia", \ "spacescope", \ "spectrascope", \ "synaescope", \ "wavescope", \ "monoscope"]: try: Gst.ElementFactory.make(c, None) items.append(G15VisualisationMenuItem(c, self)) except Exception as e: logger.debug("Error creating visualizations", exc_info=e) pass self.menu.set_children(items) if len(items) > 0: self.menu.selected = items[0] else: self.menu.selected = None