Ejemplo n.º 1
0
    def __init__(self, applet):

        self.client = awn.config_get_default_for_applet(applet)
        self._values = {}  #{key:value,key:value,etc:etc}
        self._registered = {}  #{key:type,key:type,etc:etc}
        self._connects = {
        }  #{key:[[func,arg],[func,arg]],key:[[func,arg],[func,arg]]}
Ejemplo n.º 2
0
    def __init__(self, uid, panel_id):
        super(Calendar, self).__init__('calendar', uid, panel_id)

        self.set_tooltip_text(self.title_text)

        # Workaround taken from digital-clock.vala: AwnIcon does not like
        # not having icon set, so we give it 1x1 transparent pixbuf
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 1, 1)
        pixbuf.fill(0)
        self.set_icon_pixbuf(pixbuf)

        self.connect('size-changed', self.on_size_changed)

        self.connect("button-press-event", self.button_press_callback)
        gobject.timeout_add(100, self.first_paint)
        self.timer = gobject.timeout_add(1000, self.timer_callback)
        #self.timer = gobject.timeout_add(1000, self.subsequent_paint)
        self.build_popup_menu()
        self.build_login_window()
        # Get config params
        self.client = awn.config_get_default_for_applet(self)
        for i in ["clock_border", "clock_foreground", "graphic", "integration", "password", "url", "username", "twelve_hour_clock", "blinking_colon", "clock_plain", "cal_appearance_index", "clock_appearance_index"]:
            self.client.notify_add(config.GROUP_DEFAULT, i, self.config_event_callback)
        self.get_config()
        if self.password is None and self.integration is not None and \
           self.integration.requires_login:
            self.login()
        try:
            self.locale_lang = locale.getdefaultlocale()[0][0:2]
        except:
            pass
            #print "locale not set"
        self.connect("destroy", self.quit_callback)
        gtk.gdk.threads_init()
Ejemplo n.º 3
0
    def __init__(self, canonical, uid, panel_id):
        super(Dialect, self).__init__(canonical, uid, panel_id)

        # BEGIN initialisation
        self.init = True

        # GLOBAL methods
        self.effects = self.get_effects()
        self.config = awn.config_get_default_for_applet(self)
        self.path = os.path.dirname(__file__)
        self.theme = gtk.icon_theme_get_default()

        # DEFAULT icon and tooltip
        self.image = self.set_icon_name(self.theme_icon)
        self.flag = awn.OverlayPixbufFile(None)
        self.overlays = False
        self.set_tooltip_text(self.app_name)
        self.get_icon().get_tooltip().props.toggle_on_click = False

        # Initialise XKLAVIER
        self.xklavier_init()

        # Load GTK widgets
        self.gtk_init()

        # Create CONTEXT menu
        self.context_init()

        # Generate LAYOUT and KEY TOGGLE lists
        self.layout_init()

        # Load PREFERENCES
        self.prefs_init()

        # Set User MENU items
        self.set_umenu()

        # Set GTK widgets
        self.gtk_status()

        # Set Default LAYOUT
        self.set_layout(0)

        # Connect applet SIGNALS
        self.connect('clicked', self.on_click)
        self.connect('middle-clicked', self.on_click)
        self.connect('context-menu-popup', self.on_click)
        self.connect('scroll-event', self.on_scroll)

        # COMPLETE initialisation
        self.init = False

        # Set timer to monitor HOTKEY changes
        gobject.timeout_add(500, self.external_config)
Ejemplo n.º 4
0
    def show_prefs(self, widget):
        wTree = gtk.Builder()
        wTree.add_from_file(self.ui_path)

        window = wTree.get_object("dialog1")
        window.set_icon(self.get_icon().get_icon_at_size(48))

        client = awn.config_get_default_for_applet(self)

        combo = wTree.get_object("tooltip_format_combo")
        formats = gtk.ListStore(str)
        for item in [_("Title - Artist"), _("Artist - Title")]:
            formats.append([item])
        combo.set_model(formats)
        ren = gtk.CellRendererText()
        combo.pack_start(ren)
        combo.add_attribute(ren, "text", 0)

        docklet_check = wTree.get_object("docklet_checkbox")
        docklet_mouseout = wTree.get_object("docklet_mouseout_checkbox")
        album_art_check = wTree.get_object("album_art_checkbox")
        size_spin = wTree.get_object("album_art_size_spin")

        client.bind(GROUP_DEFAULT, "tooltip_format", combo, "active", False,
                    BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "use_docklet", docklet_check, "active",
                    False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "docklet_mouseout_close", docklet_mouseout,
                    "active", False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "show_album_art", album_art_check, "active",
                    False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "album_art_size", size_spin, "value", False,
                    BIND_METHOD_FALLBACK)

        close_button = wTree.get_object("close_button")
        close_button.connect("clicked", lambda x: window.destroy())

        def unbind_all():
            client.unbind_all_for_object(combo)
            client.unbind_all_for_object(docklet_check)
            client.unbind_all_for_object(docklet_mouseout)
            client.unbind_all_for_object(album_art_check)
            client.unbind_all_for_object(size_spin)

        window.connect("destroy", lambda x: unbind_all())
        window.show()
Ejemplo n.º 5
0
    def show_prefs(self, widget):
        wTree = gtk.Builder()
        wTree.add_from_file(self.ui_path)

        window = wTree.get_object("dialog1")
        window.set_icon(self.get_icon().get_icon_at_size(48))

        client = awn.config_get_default_for_applet(self)

        combo = wTree.get_object("tooltip_format_combo")
        formats = gtk.ListStore(str)
        for item in [_("Title - Artist"), _("Artist - Title")]:
            formats.append([item])
        combo.set_model(formats)
        ren = gtk.CellRendererText()
        combo.pack_start(ren)
        combo.add_attribute(ren, "text", 0)

        docklet_check = wTree.get_object("docklet_checkbox")
        docklet_mouseout = wTree.get_object("docklet_mouseout_checkbox")
        album_art_check = wTree.get_object("album_art_checkbox")
        size_spin = wTree.get_object("album_art_size_spin")

        client.bind(GROUP_DEFAULT, "tooltip_format",
                    combo, "active", False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "use_docklet",
                    docklet_check, "active", False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "docklet_mouseout_close",
                    docklet_mouseout, "active", False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "show_album_art",
                    album_art_check, "active", False, BIND_METHOD_FALLBACK)
        client.bind(GROUP_DEFAULT, "album_art_size",
                    size_spin, "value", False, BIND_METHOD_FALLBACK)

        close_button = wTree.get_object("close_button")
        close_button.connect("clicked", lambda x: window.destroy())

        def unbind_all():
            client.unbind_all_for_object(combo)
            client.unbind_all_for_object(docklet_check)
            client.unbind_all_for_object(docklet_mouseout)
            client.unbind_all_for_object(album_art_check)
            client.unbind_all_for_object(size_spin)
        window.connect("destroy", lambda x: unbind_all())
        window.show()
Ejemplo n.º 6
0
    def __init__(self, uid, panel_id, feeds):
        super(awn.AppletSimple, self).__init__(APPLET_NAME, uid, panel_id)

        self.feeds = feeds
        self.configuration = awn.config_get_default_for_applet(self)

        self.set_icon_name('comics-icon')
        # Initialise notifications
        notify_init(applet_display_name)
        self.dialog = awn.Dialog(self)
        self.dialog.connect('button-release-event',
                            self.on_dialog_button_press)

        hbox = gtk.HBox(False)
        self.message_icon = gtk.Image()
        self.message_label = gtk.Label()
        hbox.pack_start(self.message_icon, expand=False, fill=False)
        hbox.pack_end(self.message_label)
        hbox.show_all()
        self.dialog.add(hbox)

        self.connect('destroy', self.on_destroy)
        self.connect('button-press-event', self.on_button_press)
        self.connect('scroll-event', self.on_scroll)

        self.visible = False
        self.windows = []
        self.window_iterator = BidirectionalIterator(self.windows)
        self.current_window = None
        self.manager = None
        self.adder = None
        self.about = None

        try:
            for filename in (f for f in os.listdir(STRIPS_DIR)
                             if f.endswith('.strip')):
                strip = self.create_window(os.path.join(STRIPS_DIR, filename))
        except OSError:
            return

        self.feeds.update()
Ejemplo n.º 7
0
    def __init__ (self, uid, panel_id):
        self.awn = awn
        awn.AppletSimple.__init__(self, "stacks", uid, panel_id)

        gobject.signal_new("stacks-gui-hide", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, ())
        gobject.signal_new("stacks-gui-show", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, ())
        gobject.signal_new("stacks-gui-toggle", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, ())
        gobject.signal_new("stacks-gui-destroy", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, ())
        gobject.signal_new("stacks-gui-config", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, ())
        gobject.signal_new("stacks-config-changed", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
        gobject.signal_new("stacks-item-removed", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, (gtk.ListStore, gtk.TreeIter,))
        gobject.signal_new("stacks-item-created", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, (gtk.ListStore, gtk.TreeIter,))
        gobject.signal_new("stacks-gui-request-hide", StacksApplet, gobject.SIGNAL_RUN_LAST,
                gobject.TYPE_NONE, ())


        # initalize variables
        self.effects = self.get_effects()

        # connect to events
        self.connect("button-release-event", self.applet_button_cb)
        self.connect("enter-notify-event", self.applet_enter_cb)
        self.connect("drag-data-received", self.applet_drop_cb)
        self.connect("drag-motion", self.applet_drag_motion_cb)
        self.connect("drag-leave", self.applet_drag_leave_cb)
        self.connect("size-changed", self.applet_size_changed_cb)

        # read configuration
        #self.gconf_client.notify_add(self.gconf_path, self.backend_gconf_cb)
        self.client = awn.config_get_default_for_applet(self)
        self.config = get_config_dict(self.client, self.get_uid())

        self.set_gui(self.config['gui_type'])
Ejemplo n.º 8
0
    def __init__(self, uid, panel_id, feeds):
        super(awn.AppletSimple, self).__init__(APPLET_NAME, uid, panel_id)

        self.feeds = feeds
        self.configuration = awn.config_get_default_for_applet(self)

        self.set_icon_name('comics-icon')
        # Initialise notifications
        notify_init(applet_display_name)
        self.dialog = awn.Dialog(self)
        self.dialog.connect('button-release-event',
                            self.on_dialog_button_press)

        hbox = gtk.HBox(False)
        self.message_icon = gtk.Image()
        self.message_label = gtk.Label()
        hbox.pack_start(self.message_icon, expand=False, fill=False)
        hbox.pack_end(self.message_label)
        hbox.show_all()
        self.dialog.add(hbox)

        self.connect('destroy', self.on_destroy)
        self.connect('button-press-event', self.on_button_press)
        self.connect('scroll-event', self.on_scroll)

        self.visible = False
        self.windows = []
        self.window_iterator = BidirectionalIterator(self.windows)
        self.current_window = None
        self.manager = None
        self.adder = None
        self.about = None

        try:
            for filename in (f for f in os.listdir(STRIPS_DIR)
                             if f.endswith('.strip')):
                strip = self.create_window(os.path.join(STRIPS_DIR, filename))
        except OSError:
            return

        self.feeds.update()
Ejemplo n.º 9
0
    def __init__(self, uid, panel_id):
        super(Calendar, self).__init__('calendar', uid, panel_id)

        self.set_tooltip_text(self.title_text)

        # Workaround taken from digital-clock.vala: AwnIcon does not like
        # not having icon set, so we give it 1x1 transparent pixbuf
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 1, 1)
        pixbuf.fill(0)
        self.set_icon_pixbuf(pixbuf)

        self.connect('size-changed', self.on_size_changed)

        self.connect("button-press-event", self.button_press_callback)
        gobject.timeout_add(100, self.first_paint)
        self.timer = gobject.timeout_add(1000, self.timer_callback)
        #self.timer = gobject.timeout_add(1000, self.subsequent_paint)
        self.build_popup_menu()
        self.build_login_window()
        # Get config params
        self.client = awn.config_get_default_for_applet(self)
        for i in [
                "clock_border", "clock_foreground", "graphic", "integration",
                "password", "url", "username", "twelve_hour_clock",
                "blinking_colon", "clock_plain", "cal_appearance_index",
                "clock_appearance_index"
        ]:
            self.client.notify_add(config.GROUP_DEFAULT, i,
                                   self.config_event_callback)
        self.get_config()
        if self.password is None and self.integration is not None and \
           self.integration.requires_login:
            self.login()
        try:
            self.locale_lang = locale.getdefaultlocale()[0][0:2]
        except:
            pass
            #print "locale not set"
        self.connect("destroy", self.quit_callback)
        gtk.gdk.threads_init()
Ejemplo n.º 10
0
    def bind_keys(self):
        """
        Loads all the config variables
        """
        self.client = awn.config_get_default_for_applet(self)

        config_map = {
            'audiosink': 'audio_sink',
            'videosink': 'video_sink',
            'video_width': 'video_width',
            'video_height': 'video_height',
        }

        for key, prop_name in config_map.iteritems():
            self.client.bind(config.GROUP_DEFAULT, key, self, prop_name, False,
                             config.BIND_METHOD_FALLBACK)

        self.recentItems = self.client.get_list(config.GROUP_DEFAULT,
                                                "recent_items")

        self.connect("notify::video-width", self.resize_video_widget)
        self.connect("notify::video-height", self.resize_video_widget)
Ejemplo n.º 11
0
    def __init__(self, applet):
        #Get an AwnConfigClient
        self.config = awn.config_get_default_for_applet(applet)

        #Get a dictionary
        self.dict = {}
        self.__getitem__ = self.dict.__getitem__

        #List of strings to get
        list_of_strings = ['icon_border', 'normal_border', 'active_border', \
            'window_main', 'window_border', 'shine_top', 'shine_bottom', \
            'shine_hover_top', 'shine_hover_bottom', 'text_color', 'shadow_color', \
            'custom_back', 'custom_border', 'background_mode', 'background_file']

        #List of integers to get
        list_of_integers = ['width', 'height']

        #List of booleans to get
        list_of_booleans = ['use_custom', 'use_custom_text']

        #Get all the values
        #Strings
        for string in list_of_strings:
            self[string] = self.config.get_value(GROUP_DEFAULT, string)
        #Integers
        for integer in list_of_integers:
            self[integer] = self.config.get_value(GROUP_DEFAULT, integer)
            if integer == 'width' and self[integer] < 24:
                self[integer] = 160
            elif integer == 'height' and self[integer] < 24:
                self[integer] = 110
        #Booleans
        for boolean in list_of_booleans:
            self[boolean] = self.config.get_value(GROUP_DEFAULT, boolean)

        #Connect to changes to all the values
        for value in list_of_strings + list_of_integers + list_of_booleans:
            self.config.notify_add(GROUP_DEFAULT, value, self.value_changed)
Ejemplo n.º 12
0
    def __init__(self, uid, panel_id):
        """Creating the applets core"""
        awn.AppletSimple.__init__(self, "media-control", uid, panel_id)
        self.set_tooltip_text(MediaControlApplet.APPLET_NAME)
        self.set_icon_info(['main-icon', 'play', 'pause', 'prev', 'next'], [
            'media-control', 'media-playback-start', 'media-playback-pause',
            'media-skip-backward', 'media-skip-forward'
        ])
        self.set_icon_state('main-icon')

        self.ui_path = os.path.join(os.path.dirname(__file__),
                                    "media-control.ui")
        # get the missing album art pixbuf
        try:
            file_name = __file__[0:__file__.rfind('/')]
            file_name += "/icons/missing-artwork.svg"
            self.no_album_art_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                file_name, 128, 128)
        except:
            self.no_album_art_pixbuf = None
        self.album_art_pixbuf = None

        self.timer_running = False
        self.playing_changed_id = 0
        self.dbus_names = {}
        self.MediaPlayer = None
        self.is_playing = False

        # Player selection frame
        self.players_frame = gtk.Frame()
        self.controls = gtk.VBox()
        self.controls.set_spacing(5)
        self.label = gtk.Label()
        self.label.set_ellipsize(pango.ELLIPSIZE_END)
        self.label.set_max_width_chars(30)
        self.label.set_padding(4, 0)
        self.label.set_markup(MediaControlApplet.APPLET_NAME_MARKUP)

        # album overlay
        self.album_overlay = awn.OverlayPixbuf()
        self.album_overlay.props.gravity = gtk.gdk.GRAVITY_SOUTH_EAST
        self.album_overlay.props.alpha = 0.85
        self.album_overlay.props.active = False
        self.add_overlay(self.album_overlay)

        # Dialog
        self.dialog = awn.Dialog(self)

        # Docklet related stuff
        self.docklet = None
        self.docklet_visible = False
        self.docklet_image = None
        self.docklet_label = None
        self.docklet_play_pause = None

        #Popup menu
        self.about = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
        self.about.connect("activate", self.show_about)
        self.prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        self.prefs.connect("activate", self.show_prefs)

        self.popup_menu = self.create_default_menu()
        self.popup_menu.append(self.prefs)
        self.popup_menu.append(gtk.SeparatorMenuItem())
        self.popup_menu.append(self.about)
        self.popup_menu.show_all()

        self.ensure_player()

        # Defining Widgets
        vbox = gtk.VBox()
        self.players_frame.add(vbox)
        for player in self.get_supported_player_names():
            button = gtk.Button(player)
            button.connect("clicked", self.start_player_pressed, player)
            vbox.add(button)

        # dialog widgets
        button_previous = gtk.ToolButton("gtk-media-previous")
        button_play = gtk.ToolButton("gtk-media-play")
        button_pause = gtk.ToolButton("gtk-media-pause")
        button_next = gtk.ToolButton("gtk-media-next")
        self.image = gtk.Image()
        # Packing Widgets
        hbox = gtk.HBox()
        hbox.pack_start(button_previous)
        hbox.add(button_play)
        hbox.add(button_next)
        self.controls.pack_start(self.image)
        self.controls.add(hbox)
        vbox = gtk.VBox()
        vbox.set_spacing(5)
        vbox.pack_start(self.label)
        vbox.add(self.players_frame)
        vbox.add(self.controls)
        self.dialog.add(vbox)
        hbox.show_all()
        vbox.show_all()
        # Button Connects
        button_previous.connect("clicked", self.button_previous_press)
        button_play.connect("clicked", self.button_pp_press)
        button_next.connect("clicked", self.button_next_press)

        # Standard AWN Connects
        self.connect("scroll-event", self.wheel_turn)
        self.connect("clicked", self.icon_clicked)
        self.connect("middle-clicked", self.button_pp_press)
        self.connect("context-menu-popup", self.menu_popup)
        self.connect("enter-notify-event", self.enter_notify)
        self.dialog.props.hide_on_unfocus = True
        # Drag&drop support
        self.get_icon().connect("drag-data-received", self.applet_drop_cb)
        self.get_icon().connect("drag-motion", self.applet_drag_motion_cb)
        self.get_icon().connect("drag-leave", self.applet_drag_leave_cb)

        self.get_icon().drag_dest_set(
            gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
            [("text/uri-list", 0, 0),
             ("text/plain", 0, 1)], gtk.gdk.ACTION_COPY)

        self.client = awn.config_get_default_for_applet(self)

        self.client.bind(GROUP_DEFAULT, "use_docklet", self, "use-docklet",
                         True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "docklet_mouseout_close", self,
                         "docklet-close", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "show_album_art", self,
                         "album-art-enabled", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "album_art_size", self,
                         "album-art-size", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "tooltip_format", self,
                         "tooltip-order", True, BIND_METHOD_FALLBACK)

        try:
            if self.MediaPlayer: self.update_song_info()
        except:
            pass

        proxy = dbus.SessionBus().get_object('org.freedesktop.DBus',
                                             '/org/freedesktop/DBus')
        proxy.connect_to_signal('NameOwnerChanged', self.name_owner_changed_cb)
Ejemplo n.º 13
0
    def __init__(self, applet):
        self.applet = applet

        #Initiate what is needed
        self.window = gtk.Window()
        self.window.set_title(_("File Browser Launcher Preferences"))
        self.nbook = gtk.Notebook()
        self.theme = gtk.icon_theme_get_default()
        self.initializing = True

        #AwnConfigClient instance
        self.client = awn.config_get_default_for_applet(applet)

        #File browser
        self.fb = self.client.get_string(group, 'fb')

        #Left mouse button action
        self.lmb = self.client.get_int(group, 'lmb')

        #Left mouse button path
        self.lmb_path = self.client.get_string(group, 'lmb_path')

        #Middle mouse button action
        self.mmb = self.client.get_int(group, 'mmb')

        #Middle mouse button path
        self.mmb_path = self.client.get_string(group, 'mmb_path')

        #Places...
        self.places = {}
        if applet.nautilus_computer:
            self.places['computer'] = self.client.get_bool(
                group, 'show_computer')
        self.places['home'] = self.client.get_int(group, 'show_home')
        self.places['filesystem'] = self.client.get_int(
            group, 'show_filesystem')
        self.places['local'] = self.client.get_int(group, 'show_local')
        self.places['network'] = self.client.get_int(group, 'show_network')
        if applet.nautilus_connect_server:
            self.places['connect'] = self.client.get_int(group, 'show_connect')
        self.places['bookmarks'] = self.client.get_int(group, 'show_bookmarks')
        self.places['trash'] = self.client.get_bool(group, 'show_trash')

        self.places_ordered = ('computer', 'home', 'filesystem', 'local',
                               'network', 'connect', 'bookmarks', 'trash')

        #Open the places item when clicked
        self.places_open = self.client.get_int(group, 'places_open')

        #Focus the location entry widget
        self.focus_entry = self.client.get_int(group, 'focus_entry')

        #Set the icon appropriately
        try:
            self.window.set_icon(self.theme.load_icon('folder', 48, 0))
        except:
            pass

        #Make the General tab
        general_vbox = gtk.VBox(False, 12)
        general_vbox.set_border_width(12)

        #First section: File Browser
        fb_vbox = gtk.VBox()
        general_vbox.pack_start(fb_vbox, False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _("File Browser"))
        label.set_alignment(0.0, 0.5)

        vbox = gtk.VBox()

        align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        align.set_padding(0, 0, 6, 0)
        align.add(vbox)

        #xdg-open (aka system default)
        default_radio = gtk.RadioButton(None, _("System Default"))
        default_radio.identifier = 'general.fb.default'
        default_radio.connect('toggled', self.radio_toggled)
        vbox.pack_start(default_radio, False)

        #Go through short list of common file managers
        fb_list = {
            'nautilus': "Nautilus",
            'thunar': "Thunar",
            'konqueror': "Konqueror",
            'dolphin': "Dolphin"
        }

        keys = fb_list.keys()
        keys.sort()

        for name in keys:
            if os.path.exists('/usr/bin/' +
                              name) or os.path.exists('/usr/local/bin/' +
                                                      name):
                radio = gtk.RadioButton(default_radio, fb_list[name])
                radio.identifier = 'general.fb.' + name
                radio.connect('toggled', self.radio_toggled)
                vbox.pack_start(radio, False)
                if self.fb == name:
                    radio.set_active(True)

        #Last option: custom with an entry for the app name
        radio = gtk.RadioButton(default_radio, _("Other"))
        radio.identifier = 'general.fb.custom'

        self.custom_entry = gtk.Entry()
        if self.fb in fb_list.keys() + ['xdg-open']:
            self.custom_entry.set_sensitive(False)

        else:
            radio.set_active(True)

        radio.connect('toggled', self.radio_toggled)

        self.custom_entry.set_text(self.fb)
        self.custom_entry.connect('focus-out-event', \
          lambda w, e:self.client.set_string(group, 'fb', w.get_text()))

        vbox.pack_start(radio, False)
        vbox.pack_start(self.custom_entry, False)

        fb_vbox.pack_start(label, False)
        fb_vbox.pack_start(align, False)

        #Second section: Behavior
        behavior_vbox = gtk.VBox()
        general_vbox.pack_start(behavior_vbox, False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _("Behavior"))
        label.set_alignment(0.0, 0.5)

        vbox = gtk.VBox()

        align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        align.set_padding(0, 0, 6, 0)
        align.add(vbox)

        dialog_radio = gtk.RadioButton(None, _("One icon with dialog"))
        dialog_radio.identifier = 'general.dialog'
        dialog_radio.connect('toggled', self.radio_toggled)
        vbox.pack_start(dialog_radio, False)

        docklet_radio = gtk.RadioButton(dialog_radio,
                                        _("One icon with docklet"))
        docklet_radio.identifier = 'general.docklet'
        if self.client.get_int(group, 'mode') == 1:
            docklet_radio.set_active(True)
        docklet_radio.connect('toggled', self.radio_toggled)
        vbox.pack_start(docklet_radio, False)

        persist_radio = gtk.RadioButton(dialog_radio, _("Multiple icons"))
        persist_radio.identifier = 'general.persist'
        if self.client.get_int(group, 'mode') == 2:
            persist_radio.set_active(True)
        persist_radio.connect('toggled', self.radio_toggled)
        vbox.pack_start(persist_radio, False)

        self.focus_check = gtk.CheckButton(_("Focus text entry"))
        self.focus_check.identifier = 'general.focus'
        if self.focus_entry == 2:
            self.focus_check.set_active(True)
        self.focus_check.connect('toggled', self.check_toggled)
        vbox.pack_start(self.focus_check, False)
        if self.client.get_int(group, 'mode') != 0:
            self.focus_check.set_sensitive(False)

        self.open_check = gtk.CheckButton(_("Open place when clicked"))
        self.open_check.identifier = 'general.open'
        if self.places_open:
            self.open_check.set_active(True)
        self.open_check.connect('toggled', self.check_toggled)
        vbox.pack_start(self.open_check, False)
        if self.client.get_int(group, 'mode') != 0:
            self.open_check.set_sensitive(False)

        behavior_vbox.pack_start(label, False)
        behavior_vbox.pack_start(align, False)

        #Put the general tab together
        self.nbook.append_page(general_vbox, gtk.Label(_("General")))

        #Places tab
        places_vbox = gtk.VBox()
        places_vbox.set_border_width(12)

        #Show all places
        self.places_all = gtk.CheckButton(_("Show all places"))
        self.places_all.identifier = 'places.all'
        self.places_all.set_active(True)

        for place in self.places_ordered:
            if place in self.places:
                val = self.places[place]
                if not ((type(val) == bool and val == True) or
                        (type(val) == int and val == 2)):
                    self.places_all.set_active(False)
                    break

        self.places_all.connect('toggled', self.check_toggled)
        places_vbox.pack_start(self.places_all, False)

        self.places_checks = {}
        strings = {
            'computer': _("Computer"),
            'home': _("Home folder"),
            'filesystem': _("Filesystem"),
            'local': _("Mounted local drives"),
            'network': _("Mounted network drives"),
            'connect': _("Connect to server"),
            'bookmarks': _("Bookmarks"),
            'trash': _("Trash")
        }

        for place in self.places_ordered:
            if place in self.places:
                check = gtk.CheckButton(strings[place])
                check.identifier = 'places.' + place
                val = self.places[place]
                if (type(val) == bool and val == True) or (type(val) == int
                                                           and val == 2):
                    check.set_active(True)
                check.connect('toggled', self.check_toggled)
                self.places_checks[place] = check
                places_vbox.pack_start(check, False)

        self.nbook.append_page(places_vbox, gtk.Label(_("Places")))

        #Left click
        left_vbox = gtk.VBox(False, 12)
        left_vbox.set_border_width(12)

        action_vbox = gtk.VBox()
        left_vbox.pack_start(action_vbox, False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _("Action"))
        label.set_alignment(0.0, 0.5)
        action_vbox.pack_start(label, False)

        vbox = gtk.VBox()

        align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        align.set_padding(0, 0, 6, 0)
        align.add(vbox)
        action_vbox.pack_start(align, False)

        keys = {
            'display': _("Display dialog/docklet"),
            'open': _("Open the folder"),
            'nothing': _("Nothing")
        }
        radios = []

        for key in ('display', 'open', 'nothing'):
            radio = gtk.RadioButton(None, keys[key])
            radios.append(radio)
            radio.identifier = 'lmb.' + key
            vbox.pack_start(radio)

            if key == 'open':
                radio.set_group(radios[0])
                radio.set_active(self.lmb == 2)

            elif key == 'nothing':
                radio.set_group(radios[0])
                radio.set_active(self.lmb == 3)

            radio.connect('toggled', self.radio_toggled)

        #Folder
        folder_vbox = gtk.VBox()
        left_vbox.pack_start(folder_vbox, False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _("Folder"))
        label.set_alignment(0.0, 0.5)
        folder_vbox.pack_start(label, False)

        vbox = gtk.VBox()

        align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        align.set_padding(0, 0, 6, 0)
        align.add(vbox)
        folder_vbox.pack_start(align, False)

        self.lmb_entry = gtk.Entry()
        self.lmb_entry.connect('focus-out-event', self.entry_focus_out,
                               'lmb_path')

        if self.lmb_path is None or self.lmb_path.strip(
        ) == '' or not os.path.exists(self.lmb_path):
            self.lmb_entry.set_text(os.environ['HOME'] + '/')

        else:
            self.lmb_entry.set_text(self.lmb_path.rstrip('/') + '/')

        button = gtk.Button(stock=gtk.STOCK_OPEN)
        button.connect('clicked', self.browse_folder, True)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(self.lmb_entry, True)
        hbox.pack_start(button, False)

        vbox.pack_start(hbox, False)

        self.nbook.append_page(left_vbox, gtk.Label(_("Left Click")))

        #Middle click
        mid_vbox = gtk.VBox(False, 12)
        mid_vbox.set_border_width(12)

        action_vbox = gtk.VBox()
        mid_vbox.pack_start(action_vbox, False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _("Action"))
        label.set_alignment(0.0, 0.5)
        action_vbox.pack_start(label, False)

        vbox = gtk.VBox()

        align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        align.set_padding(0, 0, 6, 0)
        align.add(vbox)
        action_vbox.pack_start(align, False)

        keys = {
            'display': _("Display dialog/docklet"),
            'open': _("Open the folder"),
            'nothing': _("Nothing")
        }
        radios = []

        for key in ('display', 'open', 'nothing'):
            radio = gtk.RadioButton(None, keys[key])
            radios.append(radio)
            radio.identifier = 'mmb.' + key
            vbox.pack_start(radio)

            if key == 'open':
                radio.set_group(radios[0])
                radio.set_active(self.mmb == 2)

            elif key == 'nothing':
                radio.set_group(radios[0])
                radio.set_active(self.mmb == 3)

            radio.connect('toggled', self.radio_toggled)

        #Folder
        folder_vbox = gtk.VBox()
        mid_vbox.pack_start(folder_vbox, False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _("Folder"))
        label.set_alignment(0.0, 0.5)
        folder_vbox.pack_start(label, False)

        vbox = gtk.VBox()

        align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        align.set_padding(0, 0, 6, 0)
        align.add(vbox)
        folder_vbox.pack_start(align, False)

        self.mmb_entry = gtk.Entry()
        self.mmb_entry.connect('focus-out-event', self.entry_focus_out,
                               'mmb_path')

        if self.mmb_path is None or self.mmb_path.strip(
        ) == '' or not os.path.exists(self.mmb_path):
            self.mmb_entry.set_text(os.environ['HOME'] + '/')

        else:
            self.mmb_entry.set_text(self.mmb_path.rstrip('/') + '/')

        button = gtk.Button(stock=gtk.STOCK_OPEN)
        button.connect('clicked', self.browse_folder, False)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(self.mmb_entry, True)
        hbox.pack_start(button, False)

        vbox.pack_start(hbox, False)

        self.nbook.append_page(mid_vbox, gtk.Label(_("Middle Click")))

        #Close button
        close_button = gtk.Button(stock=gtk.STOCK_CLOSE)
        close_button.connect('clicked', lambda a: self.window.destroy())

        #HButtonBox
        hbbox = gtk.HButtonBox()
        hbbox.set_layout(gtk.BUTTONBOX_END)
        hbbox.pack_end(close_button, False, False, 5)

        #Now for a main table
        main_vbox = gtk.VBox(False, 12)
        main_vbox.pack_start(self.nbook, True, True)
        main_vbox.pack_start(hbbox, False, False)

        #Put it all together
        self.window.add(main_vbox)
        self.window.set_border_width(12)
        self.window.show_all()
        self.initializing = False
Ejemplo n.º 14
0
    def __init__(self, applet):
        self.applet = applet

        #Get AwnConfigClient
        self.config = awn.config_get_default_for_applet(applet)

        #Make the main window
        self.win = gtk.Window()
        self.win.set_title(_("SlickSwitcher Preferences"))
        self.win.set_border_width(6)

        #Get the default icon theme
        self.icon_theme = gtk.icon_theme_get_default()

        #Get the window's icon
        image_path = '/'.join(__file__.split('/')[:-1]) + '/icons/'
        icon = gtk.gdk.pixbuf_new_from_file(image_path + 'done.png')
        self.win.set_icon(icon)

        #Main Widgets
        main_vbox = gtk.VBox(False, 6)
        colors_vbox = gtk.VBox(False, 6)
        other_colors_vbox = gtk.VBox(False, 6)
        advanced_vbox = gtk.VBox(False, 6)
        notebook = gtk.Notebook()

        colors_vbox.set_border_width(6)
        other_colors_vbox.set_border_width(6)
        advanced_vbox.set_border_width(6)

        #Colors: Borders, Windows, and Dialog

        #Border Colors
        label_border_colors = gtk.Label(_("Border Colors"))
        label_border_colors.set_alignment(0.0, 0.5)
        boldify(label_border_colors)
        image_border_colors = gtk.image_new_from_file(image_path + 'border.png')

        #Icon Border
        icon_border = self.make_hbox(_("Icon border:"), 'icon_border')

        #Normal Border
        normal_border = self.make_hbox(_("Normal border:"), 'normal_border')

        #Hovered Border
        active_border = self.make_hbox(_("Hovered border:"), 'active_border')

        #Window Colors
        label_window_colors = gtk.Label(_("Window Colors"))
        label_window_colors.set_alignment(0.0, 0.5)
        boldify(label_window_colors)
        image_window_colors = gtk.image_new_from_file(image_path + 'windows.png')

        #Main Color
        window_main = self.make_hbox(_("Main color:"), 'window_main')

        #Border Color
        window_border = self.make_hbox(_("Border color:"), 'window_border')

        #Dialog Colors
        label_dialog_colors = gtk.Label(_("Dialog colors"))
        label_dialog_colors.set_alignment(0.0, 0.5)
        boldify(label_dialog_colors)
        image_dialog_colors = gtk.image_new_from_file(image_path + 'dialog.png')

        #Use custom colors (CheckButton)
        check_dialog_colors = gtk.CheckButton(_("Use custom colors"))
        check_dialog_colors.key = 'use_custom'
        if self.config.get_value(GROUP_DEFAULT, 'use_custom') == True:
            check_dialog_colors.set_active(True)
        check_dialog_colors.connect('toggled', self.check_toggled)

        #Background Color
        dialog_back = self.make_hbox(_("Background color:"), 'custom_back')

        #Border Color
        dialog_border = self.make_hbox(_("Border color:"), 'custom_border')

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(icon_border)
        vbox.pack_start(normal_border)
        vbox.pack_start(active_border)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_border_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_border_colors, False)
        vbox.pack_start(hbox, False)

        colors_vbox.pack_start(vbox, False)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(window_main)
        vbox.pack_start(window_border)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_window_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_window_colors, False)
        vbox.pack_start(hbox, False)

        colors_vbox.pack_start(vbox, False)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(dialog_back, False)
        vbox.pack_start(dialog_border, False)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_dialog_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_dialog_colors, False)
        vbox.pack_start(check_dialog_colors, False)
        vbox.pack_start(hbox, False)

        colors_vbox.pack_start(vbox, False)

        notebook.append_page(colors_vbox, gtk.Label(_("Colors")))

        #Other colors: text and shine
        #Number Colors
        label_number_colors = gtk.Label(_("Number Colors"))
        label_number_colors.set_alignment(0.0, 0.5)
        boldify(label_number_colors)
        image_number_colors = gtk.image_new_from_file(image_path + 'number.png')

        #Use custom colors (CheckButton)
        check_text_colors = gtk.CheckButton(_("Use custom colors"))
        check_text_colors.key = 'use_custom_text'
        if self.config.get_value(GROUP_DEFAULT, 'use_custom_text') == True:
            check_text_colors.set_active(True)
        check_text_colors.connect('toggled', self.check_toggled)

        #Main Color
        text_color = self.make_hbox(_("Main color:"), 'text_color')

        #Drop-Shadow Color
        shadow_color = self.make_hbox(_("Drop-shadow color:"), 'shadow_color')

        #Shine Colors
        label_shine_colors = gtk.Label(_("Shine Colors"))
        label_shine_colors.set_alignment(0.0, 0.5)
        boldify(label_shine_colors)
        image_shine_colors = gtk.image_new_from_file(image_path + 'shine.png')

        #Top Color
        shine_top = self.make_hbox(_("Top color:"), 'shine_top')

        #Bottom Color
        shine_bottom = self.make_hbox(_("Bottom color:"), 'shine_bottom')

        #Hover Top Color
        shine_hover_top = self.make_hbox(_("Hover top color:"), 'shine_hover_top')

        #Hover Bottom Color
        shine_hover_bottom = self.make_hbox(_("Hover bottom color:"), 'shine_hover_bottom')

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(text_color)
        vbox.pack_start(shadow_color)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_number_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_number_colors, False)
        vbox.pack_start(check_text_colors, False)
        vbox.pack_start(hbox, False)

        other_colors_vbox.pack_start(vbox, False)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(shine_top)
        vbox.pack_start(shine_bottom)
        vbox.pack_start(shine_hover_top)
        vbox.pack_start(shine_hover_bottom)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_shine_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_shine_colors, False)
        vbox.pack_start(hbox, False)

        other_colors_vbox.pack_start(vbox, False)

        notebook.append_page(other_colors_vbox, gtk.Label(_("Other colors")))

        #Advanced: Workspace width & height, Background mode/file

        #Workspace Size...
        vbox = gtk.VBox(False, 3)

        #Width
        label_width = gtk.Label(_("Width:"))
        label_width.set_alignment(0.0, 0.5)
        width = self.config.get_value(GROUP_DEFAULT, 'width')
        if width < 24 or width > 400:
            width = 160
        width_adj = gtk.Adjustment(float(width), 24, 400, 5, 10, 0)
        width = gtk.SpinButton(width_adj, 1, 0)
        width.key = 'width'
        width.connect('focus-out-event', self.spinbutton_focusout)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(label_width, False)
        hbox.pack_end(width, False)

        vbox.pack_start(hbox, False)

        #Height
        label_height = gtk.Label(_("Height:"))
        label_height.set_alignment(0.0, 0.5)
        height = self.config.get_value(GROUP_DEFAULT, 'height')
        if height < 24 or height > 400:
            height = 110
        height_adj = gtk.Adjustment(float(height), 24, 400, 5, 10, 0)
        height = gtk.SpinButton(height_adj, 1, 0)
        height.key = 'height'
        height.connect('focus-out-event', self.spinbutton_focusout)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(label_height, False)
        hbox.pack_end(height, False)

        vbox.pack_start(hbox, False)

        align = gtk.Alignment(xscale=1.0)
        align.set_padding(0, 0, 12, 0)
        align.add(vbox)

        label_workspace_size = gtk.Label(_("Workspace Size"))
        label_workspace_size.set_alignment(0.0, 0.5)
        boldify(label_workspace_size)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_workspace_size, False)
        vbox.pack_start(align, False)

        advanced_vbox.pack_start(vbox, False)

        #Background...
        vbox = gtk.VBox(False, 3)

        size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        #Mode
        label_mode = gtk.Label(_("Mode:"))

        self.combo_mode = gtk.combo_box_new_text()
        self.combo_mode.append_text(_("GNOME"))
        self.combo_mode.append_text(_("Compiz Wallpaper Plugin"))
        self.combo_mode.append_text(_("File"))

        size_group.add_widget(self.combo_mode)

        mode = self.config.get_value(GROUP_DEFAULT, 'background_mode')
        if mode == 'compiz':
            self.combo_mode.set_active(1)
        elif mode == 'file':
            self.combo_mode.set_active(2)
        else:
            self.combo_mode.set_active(0)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(label_mode, False)
        hbox.pack_end(self.combo_mode, False)

        vbox.pack_start(hbox, False)

        #File
        label_file = gtk.Label(_("File:"))

        file_chooser = gtk.FileChooserButton(_("Choose a Background Image"))
        file_chooser.connect('file-set', self.file_chooser_set)

        path = self.config.get_value(GROUP_DEFAULT, 'background_file')
        if path in (None, '', os.environ['HOME'], os.environ['HOME'] + '/', '/dev/null', '/'):
            file_chooser.set_filename(os.environ['HOME'] + '/' + \
                gettext.dgettext('xdg-user-dirs', 'Pictures'))

        else:
            file_chooser.set_filename(path)

        size_group.add_widget(file_chooser)

        self.file_hbox = gtk.HBox(False, 6)
        self.file_hbox.pack_start(label_file, False)
        self.file_hbox.pack_end(file_chooser, False)

        if mode != 'file':
            self.file_hbox.set_sensitive(False)

        vbox.pack_start(self.file_hbox, False)

        align = gtk.Alignment(xscale=1.0)
        align.set_padding(0, 0, 12, 0)
        align.add(vbox)

        label_background = gtk.Label(_("Background"))
        label_background.set_alignment(0.0, 0.5)
        boldify(label_background)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_background, False)
        vbox.pack_start(align, False)

        advanced_vbox.pack_start(vbox, False)

        self.combo_mode.connect('changed', self.combo_mode_changed)

        notebook.append_page(advanced_vbox, gtk.Label(_("Advanced")))

        #Close button in an HButtonBox
        close_button = gtk.Button(stock=gtk.STOCK_CLOSE)
        close_button.connect('clicked', self.close)
        hbox = gtk.HBox()
        hbox.pack_end(close_button, False)

        #Put it all together
        main_vbox.pack_start(notebook)
        main_vbox.pack_start(hbox, False)
        self.win.add(main_vbox)
        self.win.show_all()
Ejemplo n.º 15
0
  def __init__(self, uid, panel_id):
    #AWN Applet Configuration
    awn.Applet.__init__(self, 'file-browser-launcher', uid, panel_id)

    self.icon_box = awn.IconBox(self)
    self.add(self.icon_box)
    self.icon = awn.ThemedIcon()
    self.icon.set_tooltip_text(_("File Browser Launcher"))
    self.icon.set_size(self.get_size())
    self.dialog = awn.Dialog(self.icon, self)

    #AwnConfigClient instance
    self.client = awn.config_get_default_for_applet(self)

    #Get the default icon theme
    self.theme = gtk.icon_theme_get_default()
    self.icons[24] = {}
    try:
      self.icons[24]['folder'] = self.theme.load_icon('folder', 24, 0)
    except:
      self.icons[24]['folder'] = None

    #Docklet...
    self.mode = self.client.get_int(group, 'mode')
    self.client.notify_add(group, 'mode', self.update_mode)

    if self.mode == 2:
      self.docklet_visible = True
      self.update_docklet(False)

    else:
      self.icon_box.add(self.icon)

    #Set the icon
    self.icon.set_info_simple('file-browser-launcher', uid, 'folder')

    if gio:
      #This part (and other progress overlay code) adapted from
      #mhr3's 'Dropper' applet
      #Set the progress overlay
      self.timer_overlay = awn.OverlayProgressCircle()
      self.timer_overlay.props.active = False
      self.timer_overlay.props.apply_effects = False
      self.icon.add_overlay(self.timer_overlay)
    else:
      #Read fstab for mounting info
      #(It it assumed that fstab won't change after the applet is started)
      self.fstab2 = open('/etc/fstab', 'r')
      self.fstab = self.fstab2.read().split('\n')
      self.fstab2.close()

    #Check if nautilus-connect-server is installed
    if os.path.exists('/usr/bin/nautilus-connect-server') or os.path.exists \
      ('/usr/local/bin/nautilus-connect-server'):
      self.nautilus_connect_server = True
    else:
      self.nautilus_connect_server = False

    if os.path.exists('/usr/share/applications/nautilus-computer.desktop') or \
      os.path.exists('/usr/local/share/applications/nautilus-computer.desktop'):
      self.nautilus_computer = True
    else:
      self.nautilus_computer = False

    def trash_count_cb(*args):
      if self.show_trash:
        if gio:
          self.do_gio_places()
        else:
          self.add_places()

    self.trash = vfs.Trash.get_default()
    self.trash.connect('file-count-changed', trash_count_cb)

    #Make the dialog, will only be shown when approiate
    #Make all the things needed for a treeview for the homefolder, root dir, bookmarks, and mounted drives
    self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, str, int)

    #Renderers
    renderer0 = gtk.CellRendererPixbuf()
    renderer1 = gtk.CellRendererText()
    self.eject_render = gtk.CellRendererPixbuf()
    self.eject_render.set_property("mode", gtk.CELL_RENDERER_MODE_ACTIVATABLE)

    #Add renderers to column
    column = gtk.TreeViewColumn('0')
    column.pack_start(renderer0, False)
    column.add_attribute(renderer0, 'pixbuf', 0)
    column.pack_start(renderer1, True)
    column.add_attribute(renderer1, 'markup', 1)
    column.pack_start(self.eject_render, False)
    column.add_attribute(self.eject_render, 'pixbuf', 2)

    #TreeView
    self.treeview = gtk.TreeView(self.liststore)
    self.treeview.set_hover_selection(True)
    self.treeview.set_headers_visible(False)
    self.treeview.append_column(column)
    self.treeview.set_no_show_all(True)
    self.treeview.connect('button-press-event', self.treeview_clicked)

    self.vbox = gtk.VBox()
    self.vbox.pack_start(self.treeview)

    if gio:
      self.monitor = gio.volume_monitor_get()
      for signal in ('volume-added', 'volume-changed', 'volume-removed', 'mount-added',
        'mount-changed', 'mount-removed'):
        self.monitor.connect(signal, self.do_gio_places)

      for key in ('show_computer', 'show_home', 'show_filesystem', 'show_local', 'show_network',
        'show_connect', 'show_trash', 'show_bookmarks'):
        self.client.notify_add(group, key, self.do_gio_places)

      self.do_gio_places()

      #(From YAMA by Onox)
      #Monitor bookmarks file for changes
      bookmarks_file = os.path.expanduser("~/.gtk-bookmarks")

      #keep a reference to avoid getting it garbage collected
      self.__bookmarks_monitor = gio.File(bookmarks_file).monitor_file()

      def bookmarks_changed_cb(monitor, file, other_file, event):
        if event in (gio.FILE_MONITOR_EVENT_CHANGES_DONE_HINT, gio.FILE_MONITOR_EVENT_CREATED,
          gio.FILE_MONITOR_EVENT_DELETED):
          #Refresh menu to re-initialize the widget
          self.do_gio_places()

      self.__bookmarks_monitor.connect("changed", bookmarks_changed_cb)

    #Entry widget for displaying the path to open
    self.entry = gtk.Entry()
    self.entry.set_text(os.environ['HOME'])
    self.entry.connect('key-release-event', self.detect_enter)
    self.entry.show()

    #Open button to run the file browser
    self.enter = gtk.Button(stock=gtk.STOCK_OPEN)
    self.enter.connect('clicked', self.launch_fb)
    self.enter.show()

    #HBox to put the two together
    entry_hbox = gtk.HBox()
    entry_hbox.pack_start(self.entry)
    entry_hbox.pack_start(self.enter, False)

    #And add the HBox to the vbox and add the vbox to the dialog
    self.vbox.pack_end(entry_hbox)
    self.dialog.add(self.vbox)

    #Connect to signals
    self.icon.connect('clicked', self.icon_clicked)
    self.icon.connect('middle-clicked', self.icon_clicked)
    self.icon.connect('context-menu-popup', self.show_context_menu)
    self.connect('size-changed', self.size_changed)
    self.dialog.connect('focus-out-event', self.dialog_focus_out)
    self.theme.connect('changed', self.icon_theme_changed)

    if gio:
      #Allow the user to drag&drop a file/folder onto the applet. After
      #a short delay, show the dialog, and allow the file/folder to be dropped
      #on any place in the TreeView (other than root, Connect to Server..., and
      #maybe unmounted places). The move the file/folder and (if successful)
      #open the place in the file browser
      #The Applet icon - just open the dialog after a short delay
      self.icon.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, \
        [("text/uri-list", 0, 0)], \
        gtk.gdk.ACTION_COPY)
      self.icon.connect('drag-data-received', self.applet_drag_data_received)
      self.icon.connect('drag-motion', self.applet_drag_motion)
      self.icon.connect('drag-leave', self.applet_drag_leave)

      #The TreeView - drop the file to move it to the folder
      self.treeview.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, \
        [("text/uri-list", 0, 0)], \
        gtk.gdk.ACTION_MOVE)
      self.treeview.connect('drag-data-received', self.treeview_drag_data_received)
      self.treeview.connect('drag-motion', self.treeview_drag_motion)
      self.treeview.connect('drag-leave', self.treeview_drag_leave)

    elif self.mode == 2:
      self.add_places()
Ejemplo n.º 16
0
    def __init__(self, uid, panel_id):
        self.network_handler = self.NetworkHandler()
        self.tokens = classes.Tokens()
        self.favicons = classes.Tokens(cache_index)

        #AWN Applet Configuration
        awn.AppletSimple.__init__(self, 'feeds', uid, panel_id)
        self.set_tooltip_text(_("Loading feeds..."))
        self.dialog = awn.Dialog(self)

        self.main_vbox = gtk.VBox(False, False)
        self.dialog.add(self.main_vbox)
        self.main_vbox.show()

        #Need icon theme
        self.icon_theme = gtk.icon_theme_get_default()
        self.icon_theme.connect('changed', self.icon_theme_changed)

        #Get a 16x16 icon representing the Internet/web
        self.web_image = self.icon_theme.load_icon('applications-internet', 16, 0)

        #Force a size of 16x16
        if self.web_image.get_width() != 16 or self.web_image.get_height() != 16:
            self.web_image = self.web_image.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)

        #Throbber overlay
        self.throbber = awn.OverlayThrobber()
        self.throbber.props.gravity = gtk.gdk.GRAVITY_SOUTH_WEST

        #Error icon overlay
        self.error_icon = awn.OverlayThemedIcon("gtk-dialog-error")
        self.error_icon.props.gravity = gtk.gdk.GRAVITY_SOUTH_WEST

        #First updated feed favicon (bottom right)
        self.favicon1 = awn.OverlayPixbuf(self.web_image)
        self.favicon1.props.gravity = gtk.gdk.GRAVITY_SOUTH_EAST

        #Second updated feed favicon (bottom)
        self.favicon2 = awn.OverlayPixbuf(self.web_image)
        self.favicon2.props.gravity = gtk.gdk.GRAVITY_SOUTH

        #Third updated feed favicon (right)
        self.favicon3 = awn.OverlayPixbuf(self.web_image)
        self.favicon3.props.gravity = gtk.gdk.GRAVITY_EAST

        for overlay in (self.throbber, self.error_icon, self.favicon1, self.favicon2, self.favicon3):
            if self.get_size() > 48:
                overlay.props.scale = 16.0 / self.get_size()
            else:
                overlay.props.scale = 0.33
            overlay.props.apply_effects = True
            overlay.props.active = False
            self.add_overlay(overlay)

        #Magic at work. Position the 2nd and 3rd favicons adjacent to the icon
        if self.get_size() > 48:
            self.favicon2.props.x_adj = 0.5 - 24.0 / self.get_size()
            self.favicon3.props.y_adj = 0.5 - 24.0 / self.get_size()

        else:
            self.favicon2.props.x_adj = 0.0
            self.favicon3.props.y_adj = 0.0

        #"Loading feeds..." label
        self.loading_feeds = gtk.Label(_("Loading feeds..."))
        self.loading_feeds.modify_font(pango.FontDescription('bold'))
        self.main_vbox.pack_start(self.loading_feeds, False, False, 3)
        self.loading_feeds.show()
        self.loading_feeds.set_no_show_all(True)

        #No feeds label
        self.no_feeds = gtk.Label(_("You don't have any feeds."))
        self.main_vbox.pack_start(self.no_feeds)
        self.no_feeds.set_no_show_all(True)

        #AwnConfigClient instance
        self.client = awn.config_get_default_for_applet(self)

        #Connect to signals
        self.connect('button-press-event', self.button_press)
        self.dialog.props.hide_on_unfocus = True

        self.get_urls()

        #TODO: put this and the similar code in add_feed() into a single, better place
        for url in self.urls:
            _base_url = '-'.join(url.split('-')[:-1])
            username = url.split('-')[-1]

            if _base_url == 'google-reader':
                self.feeds[url] = classes.GoogleReader(self, username)

            elif _base_url == 'google-wave':
                self.feeds[url] = classes.GoogleWave(self, username)

            elif _base_url == 'reddit':
                self.feeds[url] = classes.Reddit(self, username)

            elif _base_url in ('twitter-timeline', 'twitter-both', 'twitter-replies'):
                self.feeds[url] = classes.Twitter(self, username, None, base_url=_base_url)

            else:
                self.feeds[url] = classes.WebFeed(self, url)

        #Set the icon
        only_greader = bool(len(self.urls))
        for feed in self.feeds.values():
            if not isinstance(feed, classes.GoogleReader):
                only_greader = False
                break

        self.set_icon_name(['awn-feeds', 'awn-feeds-greader'][only_greader])

        self.setup_dialog()

        #Allow user to drag and drop feed URLs onto the applet icon
        #E.g. In a browser, user drags and drops a link to an Atom feed onto the applet
        self.get_icon().drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, \
          [("STRING", 0, 0), ("text/plain", 0, 0), ("text/uri-list", 0, 0)], \
          gtk.gdk.ACTION_COPY)
        self.get_icon().connect('drag_data_received', self.applet_drag_data_received)
        self.get_icon().connect('drag-motion', self.applet_drag_motion)
        self.get_icon().connect('drag-leave', self.applet_drag_leave)
        self.dialog.connect('scroll-event', self.scroll)
        self.connect('size-changed', self.size_changed)

        #Set up the D-Bus service
        self.service = classes.DBusService(self)

        self.update_feeds()
Ejemplo n.º 17
0
    def __init__(self, applet):

        self.client = awn.config_get_default_for_applet(applet)
        self._values = {} #{key:value,key:value,etc:etc}
        self._registered = {} #{key:type,key:type,etc:etc}
        self._connects = {} #{key:[[func,arg],[func,arg]],key:[[func,arg],[func,arg]]}
Ejemplo n.º 18
0
  def __init__(self, applet):
    self.applet = applet

    #Initiate what is needed
    self.window = gtk.Window()
    self.window.set_title(_("File Browser Launcher Preferences"))
    self.nbook = gtk.Notebook()
    self.theme = gtk.icon_theme_get_default()
    self.initializing = True

    #AwnConfigClient instance
    self.client = awn.config_get_default_for_applet(applet)

    #File browser
    self.fb = self.client.get_string(group, 'fb')

    #Left mouse button action
    self.lmb = self.client.get_int(group, 'lmb')

    #Left mouse button path
    self.lmb_path = self.client.get_string(group, 'lmb_path')

    #Middle mouse button action
    self.mmb = self.client.get_int(group, 'mmb')

    #Middle mouse button path
    self.mmb_path = self.client.get_string(group, 'mmb_path')

    #Places...
    self.places = {}
    if applet.nautilus_computer:
      self.places['computer'] = self.client.get_bool(group, 'show_computer')
    self.places['home'] = self.client.get_int(group, 'show_home')
    self.places['filesystem'] = self.client.get_int(group, 'show_filesystem')
    self.places['local'] = self.client.get_int(group, 'show_local')
    self.places['network'] = self.client.get_int(group, 'show_network')
    if applet.nautilus_connect_server:
      self.places['connect'] = self.client.get_int(group, 'show_connect')
    self.places['bookmarks'] = self.client.get_int(group, 'show_bookmarks')
    self.places['trash'] = self.client.get_bool(group, 'show_trash')

    self.places_ordered = ('computer', 'home', 'filesystem', 'local', 'network', 'connect',
      'bookmarks', 'trash')

    #Open the places item when clicked
    self.places_open = self.client.get_int(group, 'places_open')

    #Focus the location entry widget
    self.focus_entry = self.client.get_int(group, 'focus_entry')

    #Set the icon appropriately
    try:
      self.window.set_icon(self.theme.load_icon('folder', 48, 0))
    except:
      pass

    #Make the General tab
    general_vbox = gtk.VBox(False, 12)
    general_vbox.set_border_width(12)

    #First section: File Browser
    fb_vbox = gtk.VBox()
    general_vbox.pack_start(fb_vbox, False)

    label = gtk.Label()
    label.set_markup('<b>%s</b>' % _("File Browser"))
    label.set_alignment(0.0, 0.5)

    vbox = gtk.VBox()

    align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
    align.set_padding(0, 0, 6, 0)
    align.add(vbox)

    #xdg-open (aka system default)
    default_radio = gtk.RadioButton(None, _("System Default"))
    default_radio.identifier = 'general.fb.default'
    default_radio.connect('toggled', self.radio_toggled)
    vbox.pack_start(default_radio, False)

    #Go through short list of common file managers
    fb_list = {'nautilus': "Nautilus",
      'thunar': "Thunar",
      'konqueror': "Konqueror",
      'dolphin': "Dolphin"}

    keys = fb_list.keys()
    keys.sort()

    for name in keys:
      if os.path.exists('/usr/bin/' + name) or os.path.exists('/usr/local/bin/' + name):
        radio = gtk.RadioButton(default_radio, fb_list[name])
        radio.identifier = 'general.fb.' + name
        radio.connect('toggled', self.radio_toggled)
        vbox.pack_start(radio, False)
        if self.fb == name:
          radio.set_active(True)

    #Last option: custom with an entry for the app name
    radio = gtk.RadioButton(default_radio, _("Other"))
    radio.identifier = 'general.fb.custom'

    self.custom_entry = gtk.Entry()
    if self.fb in fb_list.keys() + ['xdg-open']:
      self.custom_entry.set_sensitive(False)

    else:
      radio.set_active(True)

    radio.connect('toggled', self.radio_toggled)

    self.custom_entry.set_text(self.fb)
    self.custom_entry.connect('focus-out-event', \
      lambda w, e:self.client.set_string(group, 'fb', w.get_text()))

    vbox.pack_start(radio, False)
    vbox.pack_start(self.custom_entry, False)

    fb_vbox.pack_start(label, False)
    fb_vbox.pack_start(align, False)

    #Second section: Behavior
    behavior_vbox = gtk.VBox()
    general_vbox.pack_start(behavior_vbox, False)

    label = gtk.Label()
    label.set_markup('<b>%s</b>' % _("Behavior"))
    label.set_alignment(0.0, 0.5)

    vbox = gtk.VBox()

    align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
    align.set_padding(0, 0, 6, 0)
    align.add(vbox)

    dialog_radio = gtk.RadioButton(None, _("One icon with dialog"))
    dialog_radio.identifier = 'general.dialog'
    dialog_radio.connect('toggled', self.radio_toggled)
    vbox.pack_start(dialog_radio, False)

    docklet_radio = gtk.RadioButton(dialog_radio, _("One icon with docklet"))
    docklet_radio.identifier = 'general.docklet'
    if self.client.get_int(group, 'mode') == 1:
      docklet_radio.set_active(True)
    docklet_radio.connect('toggled', self.radio_toggled)
    vbox.pack_start(docklet_radio, False)

    persist_radio = gtk.RadioButton(dialog_radio, _("Multiple icons"))
    persist_radio.identifier = 'general.persist'
    if self.client.get_int(group, 'mode') == 2:
      persist_radio.set_active(True)
    persist_radio.connect('toggled', self.radio_toggled)
    vbox.pack_start(persist_radio, False)

    self.focus_check = gtk.CheckButton(_("Focus text entry"))
    self.focus_check.identifier = 'general.focus'
    if self.focus_entry == 2:
      self.focus_check.set_active(True)
    self.focus_check.connect('toggled', self.check_toggled)
    vbox.pack_start(self.focus_check, False)
    if self.client.get_int(group, 'mode') != 0:
      self.focus_check.set_sensitive(False)

    self.open_check = gtk.CheckButton(_("Open place when clicked"))
    self.open_check.identifier = 'general.open'
    if self.places_open:
      self.open_check.set_active(True)
    self.open_check.connect('toggled', self.check_toggled)
    vbox.pack_start(self.open_check, False)
    if self.client.get_int(group, 'mode') != 0:
      self.open_check.set_sensitive(False)

    behavior_vbox.pack_start(label, False)
    behavior_vbox.pack_start(align, False)

    #Put the general tab together
    self.nbook.append_page(general_vbox, gtk.Label(_("General")))

    #Places tab
    places_vbox = gtk.VBox()
    places_vbox.set_border_width(12)

    #Show all places
    self.places_all = gtk.CheckButton(_("Show all places"))
    self.places_all.identifier = 'places.all'
    self.places_all.set_active(True)

    for place in self.places_ordered:
      if place in self.places:
        val = self.places[place]
        if not ((type(val) == bool and val == True) or (type(val) == int and val == 2)):
          self.places_all.set_active(False)
          break

    self.places_all.connect('toggled', self.check_toggled)
    places_vbox.pack_start(self.places_all, False)

    self.places_checks = {}
    strings = {'computer': _("Computer"), 'home': _("Home folder"), 'filesystem': _("Filesystem"),
      'local': _("Mounted local drives"), 'network': _("Mounted network drives"),
      'connect': _("Connect to server"), 'bookmarks': _("Bookmarks"), 'trash': _("Trash")}

    for place in self.places_ordered:
      if place in self.places:
        check = gtk.CheckButton(strings[place])
        check.identifier = 'places.' + place
        val = self.places[place]
        if (type(val) == bool and val == True) or (type(val) == int and val == 2):
          check.set_active(True)
        check.connect('toggled', self.check_toggled)
        self.places_checks[place] = check
        places_vbox.pack_start(check, False)

    self.nbook.append_page(places_vbox, gtk.Label(_("Places")))

    #Left click
    left_vbox = gtk.VBox(False, 12)
    left_vbox.set_border_width(12)

    action_vbox = gtk.VBox()
    left_vbox.pack_start(action_vbox, False)

    label = gtk.Label()
    label.set_markup('<b>%s</b>' % _("Action"))
    label.set_alignment(0.0, 0.5)
    action_vbox.pack_start(label, False)

    vbox = gtk.VBox()

    align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
    align.set_padding(0, 0, 6, 0)
    align.add(vbox)
    action_vbox.pack_start(align, False)

    keys = {'display': _("Display dialog/docklet"), 'open': _("Open the folder"),
      'nothing': _("Nothing")}
    radios = []

    for key in ('display', 'open', 'nothing'):
      radio = gtk.RadioButton(None, keys[key])
      radios.append(radio)
      radio.identifier = 'lmb.' + key
      vbox.pack_start(radio)

      if key == 'open':
        radio.set_group(radios[0])
        radio.set_active(self.lmb == 2)

      elif key == 'nothing':
        radio.set_group(radios[0])
        radio.set_active(self.lmb == 3)

      radio.connect('toggled', self.radio_toggled)

    #Folder
    folder_vbox = gtk.VBox()
    left_vbox.pack_start(folder_vbox, False)

    label = gtk.Label()
    label.set_markup('<b>%s</b>' % _("Folder"))
    label.set_alignment(0.0, 0.5)
    folder_vbox.pack_start(label, False)

    vbox = gtk.VBox()

    align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
    align.set_padding(0, 0, 6, 0)
    align.add(vbox)
    folder_vbox.pack_start(align, False)

    self.lmb_entry = gtk.Entry()
    self.lmb_entry.connect('focus-out-event', self.entry_focus_out, 'lmb_path')

    if self.lmb_path is None or self.lmb_path.strip() == '' or not os.path.exists(self.lmb_path):
      self.lmb_entry.set_text(os.environ['HOME'] + '/')

    else:
      self.lmb_entry.set_text(self.lmb_path.rstrip('/') + '/')

    button = gtk.Button(stock=gtk.STOCK_OPEN)
    button.connect('clicked', self.browse_folder, True)

    hbox = gtk.HBox(False, 6)
    hbox.pack_start(self.lmb_entry, True)
    hbox.pack_start(button, False)
    
    vbox.pack_start(hbox, False)

    self.nbook.append_page(left_vbox, gtk.Label(_("Left Click")))

    #Middle click
    mid_vbox = gtk.VBox(False, 12)
    mid_vbox.set_border_width(12)

    action_vbox = gtk.VBox()
    mid_vbox.pack_start(action_vbox, False)

    label = gtk.Label()
    label.set_markup('<b>%s</b>' % _("Action"))
    label.set_alignment(0.0, 0.5)
    action_vbox.pack_start(label, False)

    vbox = gtk.VBox()

    align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
    align.set_padding(0, 0, 6, 0)
    align.add(vbox)
    action_vbox.pack_start(align, False)

    keys = {'display': _("Display dialog/docklet"), 'open': _("Open the folder"),
      'nothing': _("Nothing")}
    radios = []

    for key in ('display', 'open', 'nothing'):
      radio = gtk.RadioButton(None, keys[key])
      radios.append(radio)
      radio.identifier = 'mmb.' + key
      vbox.pack_start(radio)

      if key == 'open':
        radio.set_group(radios[0])
        radio.set_active(self.mmb == 2)

      elif key == 'nothing':
        radio.set_group(radios[0])
        radio.set_active(self.mmb == 3)

      radio.connect('toggled', self.radio_toggled)

    #Folder
    folder_vbox = gtk.VBox()
    mid_vbox.pack_start(folder_vbox, False)

    label = gtk.Label()
    label.set_markup('<b>%s</b>' % _("Folder"))
    label.set_alignment(0.0, 0.5)
    folder_vbox.pack_start(label, False)

    vbox = gtk.VBox()

    align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
    align.set_padding(0, 0, 6, 0)
    align.add(vbox)
    folder_vbox.pack_start(align, False)

    self.mmb_entry = gtk.Entry()
    self.mmb_entry.connect('focus-out-event', self.entry_focus_out, 'mmb_path')

    if self.mmb_path is None or self.mmb_path.strip() == '' or not os.path.exists(self.mmb_path):
      self.mmb_entry.set_text(os.environ['HOME'] + '/')

    else:
      self.mmb_entry.set_text(self.mmb_path.rstrip('/') + '/')

    button = gtk.Button(stock=gtk.STOCK_OPEN)
    button.connect('clicked', self.browse_folder, False)

    hbox = gtk.HBox(False, 6)
    hbox.pack_start(self.mmb_entry, True)
    hbox.pack_start(button, False)
    
    vbox.pack_start(hbox, False)

    self.nbook.append_page(mid_vbox, gtk.Label(_("Middle Click")))

    #Close button
    close_button = gtk.Button(stock=gtk.STOCK_CLOSE)
    close_button.connect('clicked',lambda a:self.window.destroy())

    #HButtonBox
    hbbox = gtk.HButtonBox()
    hbbox.set_layout(gtk.BUTTONBOX_END)
    hbbox.pack_end(close_button, False, False, 5)

    #Now for a main table
    main_vbox = gtk.VBox(False, 12)
    main_vbox.pack_start(self.nbook, True, True)
    main_vbox.pack_start(hbbox, False, False)

    #Put it all together
    self.window.add(main_vbox)
    self.window.set_border_width(12)
    self.window.show_all()
    self.initializing = False
Ejemplo n.º 19
0
    def __init__(self, uid, panel_id):
        """Creating the applets core"""
        awn.AppletSimple.__init__(self, "media-control", uid, panel_id)
        self.set_tooltip_text(MediaControlApplet.APPLET_NAME)
        self.set_icon_info(
            ['main-icon', 'play', 'pause', 'prev', 'next'],
            ['media-control', 'media-playback-start', 'media-playback-pause',
             'media-skip-backward', 'media-skip-forward']
        )
        self.set_icon_state('main-icon')

        self.ui_path = os.path.join(os.path.dirname(__file__), "media-control.ui")
        # get the missing album art pixbuf
        try:
            file_name = __file__[0:__file__.rfind('/')]
            file_name += "/icons/missing-artwork.svg"
            self.no_album_art_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                file_name, 128, 128)
        except:
            self.no_album_art_pixbuf = None
        self.album_art_pixbuf = None

        self.timer_running = False
        self.playing_changed_id = 0
        self.dbus_names = {}
        self.MediaPlayer = None
        self.is_playing = False

        # Player selection frame
        self.players_frame = gtk.Frame()
        self.controls = gtk.VBox()
        self.controls.set_spacing(5)
        self.label = gtk.Label()
        self.label.set_ellipsize(pango.ELLIPSIZE_END)
        self.label.set_max_width_chars(30)
        self.label.set_padding(4, 0)
        self.label.set_markup(MediaControlApplet.APPLET_NAME_MARKUP)

        # album overlay
        self.album_overlay = awn.OverlayPixbuf()
        self.album_overlay.props.gravity = gtk.gdk.GRAVITY_SOUTH_EAST
        self.album_overlay.props.alpha = 0.85
        self.album_overlay.props.active = False
        self.add_overlay(self.album_overlay)

        # Dialog
        self.dialog = awn.Dialog (self)

        # Docklet related stuff
        self.docklet = None
        self.docklet_visible = False
        self.docklet_image = None
        self.docklet_label = None
        self.docklet_play_pause = None

        #Popup menu
        self.about = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
        self.about.connect("activate", self.show_about)
        self.prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        self.prefs.connect("activate", self.show_prefs)

        self.popup_menu = self.create_default_menu()
        self.popup_menu.append(self.prefs)
        self.popup_menu.append(gtk.SeparatorMenuItem())
        self.popup_menu.append(self.about)
        self.popup_menu.show_all()

        self.ensure_player()

        # Defining Widgets
        vbox = gtk.VBox()
        self.players_frame.add(vbox)
        for player in self.get_supported_player_names():
          button = gtk.Button(player)
          button.connect("clicked", self.start_player_pressed, player)
          vbox.add(button)

        # dialog widgets
        button_previous = gtk.ToolButton ("gtk-media-previous")
        button_play = gtk.ToolButton ("gtk-media-play")
        button_pause = gtk.ToolButton ("gtk-media-pause")
        button_next = gtk.ToolButton ("gtk-media-next")
        self.image = gtk.Image()
        # Packing Widgets
        hbox = gtk.HBox()
        hbox.pack_start(button_previous)
        hbox.add(button_play)
        hbox.add(button_next)
        self.controls.pack_start(self.image)
        self.controls.add(hbox)
        vbox = gtk.VBox()
        vbox.set_spacing(5)
        vbox.pack_start(self.label)
        vbox.add(self.players_frame)
        vbox.add(self.controls)
        self.dialog.add(vbox)
        hbox.show_all()
        vbox.show_all()
        # Button Connects
        button_previous.connect("clicked", self.button_previous_press)
        button_play.connect("clicked", self.button_pp_press)
        button_next.connect("clicked", self.button_next_press)

        # Standard AWN Connects
        self.connect("scroll-event", self.wheel_turn)
        self.connect("clicked", self.icon_clicked)
        self.connect("middle-clicked", self.button_pp_press)
        self.connect("context-menu-popup", self.menu_popup)
        self.connect("enter-notify-event", self.enter_notify)
        self.dialog.props.hide_on_unfocus = True
        # Drag&drop support
        self.get_icon().connect("drag-data-received", self.applet_drop_cb)
        self.get_icon().connect("drag-motion", self.applet_drag_motion_cb)
        self.get_icon().connect("drag-leave", self.applet_drag_leave_cb)

        self.get_icon().drag_dest_set(
                           gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
                           [("text/uri-list", 0, 0), ("text/plain", 0, 1)],
                           gtk.gdk.ACTION_COPY)
        
        self.client = awn.config_get_default_for_applet(self)

        self.client.bind(GROUP_DEFAULT, "use_docklet",
                         self, "use-docklet", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "docklet_mouseout_close",
                         self, "docklet-close", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "show_album_art",
                         self, "album-art-enabled", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "album_art_size",
                         self, "album-art-size", True, BIND_METHOD_FALLBACK)
        self.client.bind(GROUP_DEFAULT, "tooltip_format",
                         self, "tooltip-order", True, BIND_METHOD_FALLBACK)

        try:
            if self.MediaPlayer: self.update_song_info()
        except:
            pass

        proxy = dbus.SessionBus().get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
        proxy.connect_to_signal('NameOwnerChanged', self.name_owner_changed_cb)
Ejemplo n.º 20
0
    def __init__(self, applet):
        self.applet = applet

        #Get AwnConfigClient
        self.config = awn.config_get_default_for_applet(applet)

        #Make the main window
        self.win = gtk.Window()
        self.win.set_title(_("SlickSwitcher Preferences"))
        self.win.set_border_width(6)

        #Get the default icon theme
        self.icon_theme = gtk.icon_theme_get_default()

        #Get the window's icon
        image_path = '/'.join(__file__.split('/')[:-1]) + '/icons/'
        icon = gtk.gdk.pixbuf_new_from_file(image_path + 'done.png')
        self.win.set_icon(icon)

        #Main Widgets
        main_vbox = gtk.VBox(False, 6)
        colors_vbox = gtk.VBox(False, 6)
        other_colors_vbox = gtk.VBox(False, 6)
        advanced_vbox = gtk.VBox(False, 6)
        notebook = gtk.Notebook()

        colors_vbox.set_border_width(6)
        other_colors_vbox.set_border_width(6)
        advanced_vbox.set_border_width(6)

        #Colors: Borders, Windows, and Dialog

        #Border Colors
        label_border_colors = gtk.Label(_("Border Colors"))
        label_border_colors.set_alignment(0.0, 0.5)
        boldify(label_border_colors)
        image_border_colors = gtk.image_new_from_file(image_path +
                                                      'border.png')

        #Icon Border
        icon_border = self.make_hbox(_("Icon border:"), 'icon_border')

        #Normal Border
        normal_border = self.make_hbox(_("Normal border:"), 'normal_border')

        #Hovered Border
        active_border = self.make_hbox(_("Hovered border:"), 'active_border')

        #Window Colors
        label_window_colors = gtk.Label(_("Window Colors"))
        label_window_colors.set_alignment(0.0, 0.5)
        boldify(label_window_colors)
        image_window_colors = gtk.image_new_from_file(image_path +
                                                      'windows.png')

        #Main Color
        window_main = self.make_hbox(_("Main color:"), 'window_main')

        #Border Color
        window_border = self.make_hbox(_("Border color:"), 'window_border')

        #Dialog Colors
        label_dialog_colors = gtk.Label(_("Dialog colors"))
        label_dialog_colors.set_alignment(0.0, 0.5)
        boldify(label_dialog_colors)
        image_dialog_colors = gtk.image_new_from_file(image_path +
                                                      'dialog.png')

        #Use custom colors (CheckButton)
        check_dialog_colors = gtk.CheckButton(_("Use custom colors"))
        check_dialog_colors.key = 'use_custom'
        if self.config.get_value(GROUP_DEFAULT, 'use_custom') == True:
            check_dialog_colors.set_active(True)
        check_dialog_colors.connect('toggled', self.check_toggled)

        #Background Color
        dialog_back = self.make_hbox(_("Background color:"), 'custom_back')

        #Border Color
        dialog_border = self.make_hbox(_("Border color:"), 'custom_border')

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(icon_border)
        vbox.pack_start(normal_border)
        vbox.pack_start(active_border)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_border_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_border_colors, False)
        vbox.pack_start(hbox, False)

        colors_vbox.pack_start(vbox, False)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(window_main)
        vbox.pack_start(window_border)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_window_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_window_colors, False)
        vbox.pack_start(hbox, False)

        colors_vbox.pack_start(vbox, False)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(dialog_back, False)
        vbox.pack_start(dialog_border, False)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_dialog_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_dialog_colors, False)
        vbox.pack_start(check_dialog_colors, False)
        vbox.pack_start(hbox, False)

        colors_vbox.pack_start(vbox, False)

        notebook.append_page(colors_vbox, gtk.Label(_("Colors")))

        #Other colors: text and shine
        #Number Colors
        label_number_colors = gtk.Label(_("Number Colors"))
        label_number_colors.set_alignment(0.0, 0.5)
        boldify(label_number_colors)
        image_number_colors = gtk.image_new_from_file(image_path +
                                                      'number.png')

        #Use custom colors (CheckButton)
        check_text_colors = gtk.CheckButton(_("Use custom colors"))
        check_text_colors.key = 'use_custom_text'
        if self.config.get_value(GROUP_DEFAULT, 'use_custom_text') == True:
            check_text_colors.set_active(True)
        check_text_colors.connect('toggled', self.check_toggled)

        #Main Color
        text_color = self.make_hbox(_("Main color:"), 'text_color')

        #Drop-Shadow Color
        shadow_color = self.make_hbox(_("Drop-shadow color:"), 'shadow_color')

        #Shine Colors
        label_shine_colors = gtk.Label(_("Shine Colors"))
        label_shine_colors.set_alignment(0.0, 0.5)
        boldify(label_shine_colors)
        image_shine_colors = gtk.image_new_from_file(image_path + 'shine.png')

        #Top Color
        shine_top = self.make_hbox(_("Top color:"), 'shine_top')

        #Bottom Color
        shine_bottom = self.make_hbox(_("Bottom color:"), 'shine_bottom')

        #Hover Top Color
        shine_hover_top = self.make_hbox(_("Hover top color:"),
                                         'shine_hover_top')

        #Hover Bottom Color
        shine_hover_bottom = self.make_hbox(_("Hover bottom color:"),
                                            'shine_hover_bottom')

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(text_color)
        vbox.pack_start(shadow_color)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_number_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_number_colors, False)
        vbox.pack_start(check_text_colors, False)
        vbox.pack_start(hbox, False)

        other_colors_vbox.pack_start(vbox, False)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(shine_top)
        vbox.pack_start(shine_bottom)
        vbox.pack_start(shine_hover_top)
        vbox.pack_start(shine_hover_bottom)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(image_shine_colors, False)
        hbox.pack_start(vbox, True)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_shine_colors, False)
        vbox.pack_start(hbox, False)

        other_colors_vbox.pack_start(vbox, False)

        notebook.append_page(other_colors_vbox, gtk.Label(_("Other colors")))

        #Advanced: Workspace width & height, Background mode/file

        #Workspace Size...
        vbox = gtk.VBox(False, 3)

        #Width
        label_width = gtk.Label(_("Width:"))
        label_width.set_alignment(0.0, 0.5)
        width = self.config.get_value(GROUP_DEFAULT, 'width')
        if width < 24 or width > 400:
            width = 160
        width_adj = gtk.Adjustment(float(width), 24, 400, 5, 10, 0)
        width = gtk.SpinButton(width_adj, 1, 0)
        width.key = 'width'
        width.connect('focus-out-event', self.spinbutton_focusout)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(label_width, False)
        hbox.pack_end(width, False)

        vbox.pack_start(hbox, False)

        #Height
        label_height = gtk.Label(_("Height:"))
        label_height.set_alignment(0.0, 0.5)
        height = self.config.get_value(GROUP_DEFAULT, 'height')
        if height < 24 or height > 400:
            height = 110
        height_adj = gtk.Adjustment(float(height), 24, 400, 5, 10, 0)
        height = gtk.SpinButton(height_adj, 1, 0)
        height.key = 'height'
        height.connect('focus-out-event', self.spinbutton_focusout)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(label_height, False)
        hbox.pack_end(height, False)

        vbox.pack_start(hbox, False)

        align = gtk.Alignment(xscale=1.0)
        align.set_padding(0, 0, 12, 0)
        align.add(vbox)

        label_workspace_size = gtk.Label(_("Workspace Size"))
        label_workspace_size.set_alignment(0.0, 0.5)
        boldify(label_workspace_size)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_workspace_size, False)
        vbox.pack_start(align, False)

        advanced_vbox.pack_start(vbox, False)

        #Background...
        vbox = gtk.VBox(False, 3)

        size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        #Mode
        label_mode = gtk.Label(_("Mode:"))

        self.combo_mode = gtk.combo_box_new_text()
        self.combo_mode.append_text(_("GNOME"))
        self.combo_mode.append_text(_("Compiz Wallpaper Plugin"))
        self.combo_mode.append_text(_("File"))

        size_group.add_widget(self.combo_mode)

        mode = self.config.get_value(GROUP_DEFAULT, 'background_mode')
        if mode == 'compiz':
            self.combo_mode.set_active(1)
        elif mode == 'file':
            self.combo_mode.set_active(2)
        else:
            self.combo_mode.set_active(0)

        hbox = gtk.HBox(False, 6)
        hbox.pack_start(label_mode, False)
        hbox.pack_end(self.combo_mode, False)

        vbox.pack_start(hbox, False)

        #File
        label_file = gtk.Label(_("File:"))

        file_chooser = gtk.FileChooserButton(_("Choose a Background Image"))
        file_chooser.connect('file-set', self.file_chooser_set)

        path = self.config.get_value(GROUP_DEFAULT, 'background_file')
        if path in (None, '', os.environ['HOME'], os.environ['HOME'] + '/',
                    '/dev/null', '/'):
            file_chooser.set_filename(os.environ['HOME'] + '/' + \
                gettext.dgettext('xdg-user-dirs', 'Pictures'))

        else:
            file_chooser.set_filename(path)

        size_group.add_widget(file_chooser)

        self.file_hbox = gtk.HBox(False, 6)
        self.file_hbox.pack_start(label_file, False)
        self.file_hbox.pack_end(file_chooser, False)

        if mode != 'file':
            self.file_hbox.set_sensitive(False)

        vbox.pack_start(self.file_hbox, False)

        align = gtk.Alignment(xscale=1.0)
        align.set_padding(0, 0, 12, 0)
        align.add(vbox)

        label_background = gtk.Label(_("Background"))
        label_background.set_alignment(0.0, 0.5)
        boldify(label_background)

        vbox = gtk.VBox(False, 3)
        vbox.pack_start(label_background, False)
        vbox.pack_start(align, False)

        advanced_vbox.pack_start(vbox, False)

        self.combo_mode.connect('changed', self.combo_mode_changed)

        notebook.append_page(advanced_vbox, gtk.Label(_("Advanced")))

        #Close button in an HButtonBox
        close_button = gtk.Button(stock=gtk.STOCK_CLOSE)
        close_button.connect('clicked', self.close)
        hbox = gtk.HBox()
        hbox.pack_end(close_button, False)

        #Put it all together
        main_vbox.pack_start(notebook)
        main_vbox.pack_start(hbox, False)
        self.win.add(main_vbox)
        self.win.show_all()