Beispiel #1
0
    def assemble_actionbar(self, bar):

        bar.install = bar.add(text=_("Mark for _Installation"),
                              tooltip=_("Mark selected packages for installation"),
                              pixbuf=red_pixbuf.get_pixbuf("to-be-installed"),
                              sensitive_fn=self.install_sensitive_cb,
                              callback=lambda x:self.set_package_action_cb(red_pendingops.TO_BE_INSTALLED))

        bar.remove = bar.add(text=_("Mark for _Removal"),
                             tooltip=_("Mark selected packages for removal"),
                             pixbuf=red_pixbuf.get_pixbuf("to-be-removed"),
                             sensitive_fn=self.remove_sensitive_cb,
                             callback=lambda x:self.set_package_action_cb(red_pendingops.TO_BE_REMOVED))

        bar.cancel = bar.add(text=_("_Cancel"),
                             tooltip=_("Cancel marked package actions"),
                             stock=gtk.STOCK_CANCEL,
                             sensitive_fn=self.cancel_sensitive_cb,
                             callback=lambda x:self.set_package_action_cb(red_pendingops.NO_ACTION))

        bar.info = bar.add(text=_("I_nformation"),
                           tooltip=_("Package information"),
                           pixbuf=red_pixbuf.get_pixbuf("info"),
                           sensitive_fn=self.info_sensitive_cb,
                           callback=lambda x:self.package_info_cb())
Beispiel #2
0
    def assemble_actionbar(self, bar):

        bar.install = bar.add(
            text=_("Mark for _Installation"),
            tooltip=_("Mark selected packages for installation"),
            pixbuf=red_pixbuf.get_pixbuf("to-be-installed"),
            sensitive_fn=self.install_sensitive_cb,
            callback=lambda x: self.set_package_action_cb(red_pendingops.
                                                          TO_BE_INSTALLED))

        bar.remove = bar.add(text=_("Mark for _Removal"),
                             tooltip=_("Mark selected packages for removal"),
                             pixbuf=red_pixbuf.get_pixbuf("to-be-removed"),
                             sensitive_fn=self.remove_sensitive_cb,
                             callback=lambda x: self.set_package_action_cb(
                                 red_pendingops.TO_BE_REMOVED))

        bar.cancel = bar.add(text=_("_Cancel"),
                             tooltip=_("Cancel marked package actions"),
                             stock=gtk.STOCK_CANCEL,
                             sensitive_fn=self.cancel_sensitive_cb,
                             callback=lambda x: self.set_package_action_cb(
                                 red_pendingops.NO_ACTION))

        bar.info = bar.add(text=_("I_nformation"),
                           tooltip=_("Package information"),
                           pixbuf=red_pixbuf.get_pixbuf("info"),
                           sensitive_fn=self.info_sensitive_cb,
                           callback=lambda x: self.package_info_cb())
Beispiel #3
0
    def assemble_toolbar(self, bar):

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)

        bar.run = bar.add(text=_("Run Now"),
                          tooltip=_("Perform installations and removals"),
                          sensitive_fn=self.sensitize_run_button,
                          stock=gtk.STOCK_EXECUTE,
                          callback=lambda x:run_transaction_cb(self))

        bar.append_space()

        bar.subs = bar.add(text=_("Catalogs"),
                           tooltip=_("Change your catalog subscriptions"),
                           pixbuf=red_pixbuf.get_pixbuf("channels-24"),
                           callback=lambda x:self.open_or_raise_window(red_subscriptions.SubscriptionsWindow))

        def verify_and_refresh_sensitive_cb():
            comp=self.componentbook.get_visible_component()
            return comp.run_sensitized()

        bar.refresh = bar.add(text=_("Refresh"),
                              tooltip=_("Refresh catalog data"),
                              stock = gtk.STOCK_REFRESH,
                              sensitive_fn=verify_and_refresh_sensitive_cb,
                              callback=lambda x:rcd_util.refresh(self))
Beispiel #4
0
    def assemble_toolbar(self, bar):

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)

        bar.run = bar.add(text=_("Run Now"),
                          tooltip=_("Perform installations and removals"),
                          sensitive_fn=self.sensitize_run_button,
                          stock=gtk.STOCK_EXECUTE,
                          callback=lambda x: run_transaction_cb(self))

        bar.append_space()

        bar.subs = bar.add(text=_("Catalogs"),
                           tooltip=_("Change your catalog subscriptions"),
                           pixbuf=red_pixbuf.get_pixbuf("channels-24"),
                           callback=lambda x: self.open_or_raise_window(
                               red_subscriptions.SubscriptionsWindow))

        def verify_and_refresh_sensitive_cb():
            comp = self.componentbook.get_visible_component()
            return comp.run_sensitized()

        bar.refresh = bar.add(text=_("Refresh"),
                              tooltip=_("Refresh catalog data"),
                              stock=gtk.STOCK_REFRESH,
                              sensitive_fn=verify_and_refresh_sensitive_cb,
                              callback=lambda x: rcd_util.refresh(self))
Beispiel #5
0
    def add_row(self, icon, name, new_version, old_version, size):

        if icon is None:
            icon = red_pixbuf.get_pixbuf("empty")

        iter = self.store.append()
        self.store.set(iter, 0, icon, 1, name, 2, old_version, 3, new_version, 4, size)
        self.row += 1
Beispiel #6
0
    def add_row(self, icon, name, new_version, old_version, size):

        if icon is None:
            icon = red_pixbuf.get_pixbuf("empty")

        iter = self.store.append()
        self.store.set(iter, 0, icon, 1, name, 2, old_version, 3, new_version,
                       4, size)
        self.row += 1
Beispiel #7
0
    def __init__(self):
        red_tray.TrayIcon.__init__(self, "Red Carpet Notification Icon")

        self.thread = None

        self.high_priority_icon = red_pixbuf.get_pixbuf('importance-necessary')
        self.low_priority_icon = red_pixbuf.get_pixbuf('importance-urgent')

        self.image = gtk.Image()
        self.box = gtk.EventBox()
        self.box.connect('button_press_event', self.image_press_cb, self)
        self.box.add(self.image)
        self.add(self.box)

        self.tooltips = gtk.Tooltips()

        self.check_updates(None)
        gtk.timeout_add(POLL_INTERVAL, self.check_updates, self)
Beispiel #8
0
def get_package_channel_icon(pkg, width=0, height=0):
    if pkg.has_key("channel") and pkg["channel"]:
        return get_channel_icon(pkg["channel"], width, height)
    elif pkg.has_key("channel_guess"):
        return get_channel_icon(pkg["channel_guess"], width, height)
    else:
        # Don't return None here, because we want an empty image to be
        # scaled to the correct height.
        return red_pixbuf.get_pixbuf("empty", width=width, height=height)
Beispiel #9
0
def get_package_channel_icon(pkg, width=0, height=0):
    if pkg.has_key("channel") and pkg["channel"]:
        return get_channel_icon(pkg["channel"], width, height)
    elif pkg.has_key("channel_guess"):
        return get_channel_icon(pkg["channel_guess"], width, height)
    else:
        # Don't return None here, because we want an empty image to be
        # scaled to the correct height.
        return red_pixbuf.get_pixbuf("empty", width=width, height=height)
Beispiel #10
0
    def __init__(self):
        red_tray.TrayIcon.__init__(self, "Red Carpet Notification Icon")

        self.thread = None

        self.high_priority_icon = red_pixbuf.get_pixbuf('importance-necessary')
        self.low_priority_icon = red_pixbuf.get_pixbuf('importance-urgent')
            
        self.image = gtk.Image()
        self.box = gtk.EventBox()
        self.box.connect('button_press_event',
                         self.image_press_cb, self)
        self.box.add(self.image)
        self.add(self.box)

        self.tooltips = gtk.Tooltips()
        
        self.check_updates(None)
        gtk.timeout_add(POLL_INTERVAL, self.check_updates, self)
Beispiel #11
0
    def __init__(self):
        gtk.Dialog.__init__(self, red_main.get_title())

        self.set_icon(red_pixbuf.get_pixbuf("red-carpet"))

        self.local = 1

        self.data = red_settings.DaemonData()
        self.build()
        self.populate()
Beispiel #12
0
    def add(self,
            text,
            tooltip,
            stock=None,
            pixbuf=None,
            pixbuf_name=None,
            sensitive_fn=None,
            callback=None):

        if pixbuf_name:
            assert not pixbuf
            pixbuf = red_pixbuf.get_pixbuf(pixbuf_name)

        if stock or pixbuf:
            image = gtk.Image()

            if stock:
                assert not pixbuf
                image.set_from_stock(stock, gtk.ICON_SIZE_LARGE_TOOLBAR)

            if pixbuf:
                assert not stock
                image.set_from_pixbuf(pixbuf)
        else:
            image = None

        w = self.append_item(text, tooltip, None, image, lambda x: callback(self.user_data))
        w.set_sensitive(0)

        item = {"text":text,
                "tooltip":tooltip,
                "stock":stock,
                "pixbuf":pixbuf,
                "sensitive_fn":sensitive_fn,
                "callback":callback,
                "widget":w
                }

        self.items.append(item)

        return w
Beispiel #13
0
    def set_icons(self, icons, interval=300):
        if self.icon_timeout:
            gtk.timeout_remove(self.icon_timeout)
            self.icon_timeout = 0

        self.icons = []
        for x in icons:
            pixbuf = red_pixbuf.get_pixbuf(x)
            if pixbuf:
                self.icons.append(pixbuf)
        if self.icons:
            self.image.set_from_pixbuf(self.icons[0])

        if len(self.icons) > 1:

            def icon_cb(pv):
                pv.curr_icon += 1
                if pv.curr_icon >= len(pv.icons):
                    pv.curr_icon = 0
                pv.image.set_from_pixbuf(pv.icons[pv.curr_icon])
                return 1

            self.icon_timeout = gtk.timeout_add(interval, icon_cb, self)
Beispiel #14
0
    def set_icons(self, icons, interval=300):
        if self.icon_timeout:
            gtk.timeout_remove(self.icon_timeout)
            self.icon_timeout = 0
            
        self.icons = []
        for x in icons:
            pixbuf = red_pixbuf.get_pixbuf(x)
            if pixbuf:
                self.icons.append(pixbuf)
        if self.icons:
            self.image.set_from_pixbuf(self.icons[0])

        if len(self.icons) > 1:
            def icon_cb(pv):
                pv.curr_icon += 1
                if pv.curr_icon >= len(pv.icons):
                    pv.curr_icon = 0
                pv.image.set_from_pixbuf(pv.icons[pv.curr_icon])
                return 1

            self.icon_timeout = gtk.timeout_add(interval,
                                                icon_cb,
                                                self)
Beispiel #15
0
            else:
                raise

        if icon_data:
            loader = gtk.gdk.gdk_pixbuf_loader_new()

            try:
                loader.write(icon_data.data, len(icon_data.data))
                loader.close()
            except gobject.GError, e:
                pass
            else:
                pixbuf = loader.get_pixbuf()

    if pixbuf is None:
        pixbuf = red_pixbuf.get_pixbuf("default-channel", width, height)

    cached_channel_icons[key] = pixbuf
    return pixbuf


def get_channel_image(id, width=0, height=0):
    pixbuf = get_channel_icon(id, width, height)
    if not pixbuf:
        return None
    img = gtk.Image()
    img.set_from_pixbuf(pixbuf)
    return img

def get_package_channel_name(pkg):
    if pkg.has_key("channel") and pkg["channel"]:
Beispiel #16
0
def bundle_installed(bundle):
    return bundle["is_installed"]


def bundle_type(bundle):
    return bundle["type"]


def bundle_status(bundle):
    if bundle_installed(bundle):
        return _("installed")
    else:
        return _("not installed")


__installed_icon = red_pixbuf.get_pixbuf("status-installed")
__uninstalled_icon = red_pixbuf.get_pixbuf("status-not-installed")


def bundle_status_icon(bundle):
    if bundle_installed(bundle):
        return __installed_icon
    else:
        return __uninstalled_icon


def bundle_action(bundle):
    pass


def bundle_action_icon(bundle):
Beispiel #17
0
            else:
                raise

        if icon_data:
            loader = gtk.gdk.gdk_pixbuf_loader_new()

            try:
                loader.write(icon_data.data, len(icon_data.data))
                loader.close()
            except gobject.GError, e:
                pass
            else:
                pixbuf = loader.get_pixbuf()

    if pixbuf is None:
        pixbuf = red_pixbuf.get_pixbuf("default-channel", width, height)

    cached_channel_icons[key] = pixbuf
    return pixbuf


def get_channel_image(id, width=0, height=0):
    pixbuf = get_channel_icon(id, width, height)
    if not pixbuf:
        return None
    img = gtk.Image()
    img.set_from_pixbuf(pixbuf)
    return img


def get_package_channel_name(pkg):
Beispiel #18
0
def pkg_sec_icon(pkg):
    pixbuf_name = "section-" + pkg["section_str"]
    return red_pixbuf.get_pixbuf(pixbuf_name, width=16, height=16)
Beispiel #19
0
	return bundle["version"]

def bundle_installed(bundle):
	return bundle["is_installed"]

def bundle_type(bundle):
	return bundle["type"]

def bundle_status(bundle):
	if bundle_installed(bundle):
		return _("installed")
	else:
		return _("not installed")


__installed_icon   = red_pixbuf.get_pixbuf("status-installed")
__uninstalled_icon = red_pixbuf.get_pixbuf("status-not-installed")

def bundle_status_icon(bundle):
	if bundle_installed(bundle):
		return __installed_icon
	else:
		return __uninstalled_icon

def bundle_action(bundle):
	pass

def bundle_action_icon(bundle):
	pass

Beispiel #20
0
    def assemble_menubar(self, bar):

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_BUTTON)

        file_str = _("_File")
        edit_str = _("_Edit")
        view_str = _("_View")
        actions_str = _("_Actions")
        help_str = _("_Help")

        bar.add("/" + file_str)
        bar.add("/" + edit_str)
        bar.add("/" + view_str)
        bar.add("/" + actions_str)
        bar.add("/" + help_str)

        bar.add("/%s/%s" % (file_str, _("Connect to daemon...")),
                description=_("Connect to a remote daemon"),
                callback=lambda x: self.connect_to_daemon(),
                pixbuf_name="connect",
                accelerator="<Control>O")

        bar.add("/%s/sep" % file_str, is_separator=1)

        def install_file_sensitive_fn():
            return rcd_util.check_server_permission("install")

        bar.add("/%s/%s" % (file_str, _("Install from _File...")),
                description=_("Install a package from a local file"),
                pixbuf=red_pixbuf.get_pixbuf("install-from-file"),
                sensitive_fn=install_file_sensitive_fn,
                callback=lambda x: red_installfiles.install_local(self))

        def install_url_sensitive_fn():
            return rcd_util.check_server_permission("install") and \
                   red_installfiles.can_install_remote()

        bar.add("/%s/%s" % (file_str, _("Install from _URL...")),
                description=_("Install a package from a remote URL"),
                pixbuf=red_pixbuf.get_pixbuf("install-from-url"),
                sensitive_fn=install_url_sensitive_fn,
                callback=lambda x: red_installfiles.install_remote(self))

        bar.add("/%s/sep2" % file_str, is_separator=1)

        ##
        ## Mount command
        ##

        def mount_callback(app):
            app.open_or_raise_window(red_mount.MountWindow)

        def mount_sensitive_fn():
            return rcd_util.check_server_permission("superuser")

        bar.add("/%s/%s" % (file_str, _("_Mount Directory...")),
                description=_("Mount a directory as a catalog"),
                callback=mount_callback,
                sensitive_fn=mount_sensitive_fn,
                accelerator="<Control>M")

        ##
        ## Unmount command
        ##

        def unmount_callback(app):
            app.open_or_raise_window(red_mount.UnmountWindow)

        def unmount_sensitive_fn():
            return rcd_util.check_server_permission("superuser") and \
                   red_mount.has_mounted_channels()

        bar.add("/%s/%s" % (file_str, _("U_nmount Directory...")),
                description=_("Unmount a directory"),
                callback=unmount_callback,
                sensitive_fn=unmount_sensitive_fn,
                accelerator="<Control>N")

        bar.add("/%s/sep3" % file_str, is_separator=1)

        ##
        ## Activate
        ##

        def activate_sensitive_fn():
            return rcd_util.check_server_permission("superuser") \
                   and rcd_util.get_all_services()

        bar.add("/%s/%s" % (file_str, _("_Register...")),
                description=_("Register daemon"),
                callback=lambda x: self.open_or_raise_window(red_activation.
                                                             ActivationWindow),
                sensitive_fn=activate_sensitive_fn)

        bar.add("/%s/sep4" % file_str, is_separator=1)

        bar.add("/%s/%s" % (file_str, _("Quit")),
                description=_("Quit Red Carpet"),
                stock=gtk.STOCK_QUIT,
                callback=lambda x: self.shutdown())

        ##
        ## Select all/none
        ##

        def select_all_sensitive_cb():
            comp = self.componentbook.get_visible_component()
            if not comp:
                return 0
            return comp.select_all_sensitive()

        bar.add("/%s/%s" % (edit_str, _("Select _All")),
                description=_("Select all items"),
                callback=lambda x: self.select_all_cb(1),
                accelerator="<Control>a",
                sensitive_fn=select_all_sensitive_cb)

        bar.add("/%s/%s" % (edit_str, _("Select _None")),
                description=_("Deselect all items"),
                callback=lambda x: self.select_all_cb(0),
                sensitive_fn=select_all_sensitive_cb,
                accelerator="<Shift><Control>A")

        bar.add("/%s/sep" % edit_str, is_separator=1)

        bar.add("/%s/%s" % (edit_str, _("Services...")),
                description=_("Edit services"),
                callback=lambda x: self.open_or_raise_window(red_services.
                                                             ServicesWindow),
                accelerator="<Control>E")

        bar.add("/%s/%s" % (edit_str, _("Catalog _Subscriptions...")),
                description=_("Edit your catalog subscriptions"),
                callback=lambda x: self.open_or_raise_window(
                    red_subscriptions.SubscriptionsWindow),
                pixbuf=red_pixbuf.get_pixbuf("channels-16"),
                accelerator="<Control>B")

        bar.add("/%s/%s" % (edit_str, _("_Preferences...")),
                description=_("Edit your Red Carpet preferences"),
                stock=gtk.STOCK_PREFERENCES,
                callback=lambda x: self.open_or_raise_window(red_prefs.
                                                             PrefsWindow))

        bar.add("/%s/%s" % (edit_str, _("_Users...")),
                description=_("Edit user permissions for this daemon"),
                pixbuf=red_pixbuf.get_pixbuf("users"),
                callback=lambda x: self.open_or_raise_window(red_users.
                                                             UsersWindow))

        ##
        ## Sidebar
        ##

        def checked_get_cb():
            return self.sidebar.get_property("visible")

        def checked_set_cb(flag):
            self.sidebar.change_visibility()

        bar.add("/%s/%s" % (view_str, _("_Sidebar")),
                description=_("Hide or show the Pending Actions sidebar"),
                checked_get=checked_get_cb,
                checked_set=checked_set_cb)

        bar.add("/%s/%s" % (view_str, _("_Advanced Search Options")),
                description=_("Hide or show advanced search options"),
                checked_get=red_searchbox.show_advanced_get,
                checked_set=red_searchbox.show_advanced_set)

        bar.add("/%s/%s" % (view_str, _("_Catalog Names")),
                description=_("Hide or show catalog names in package lists"),
                checked_get=red_packageview.show_channel_names_get,
                checked_set=red_packageview.show_channel_names_set)

        bar.add("/%s/sep" % view_str, is_separator=1)

        bar.add("/%s/%s" % (view_str, _("Package _Information...")),
                description=_(
                    "View information about currently selected packages"),
                pixbuf_name="info",
                callback=lambda x: self.package_info_cb(),
                sensitive_fn=self.info_sensitive_cb,
                accelerator="<Control>I")

        bar.add("/%s/sep1" % view_str, is_separator=1)

        bar.add("/%s/%s" % (view_str, _("_Daemon Information...")),
                description=_("View information about this daemon"),
                callback=red_serverinfo.view_server_info_cb)

        bar.add("/%s/sep2" % view_str, is_separator=1)

        ##
        ## Run Transaction
        ##

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (actions_str, _("Run _Now")),
                description=_("Run the current transaction"),
                image=image,
                callback=run_transaction_cb,
                sensitive_fn=self.sensitize_run_button,
                accelerator="<Control>X")

        ##
        ## Verify System Dependencies
        ##

        def verify_and_refresh_sensitive_cb():
            comp = self.componentbook.get_visible_component()
            return comp.run_sensitized()

        bar.add("/%s/%s" % (actions_str, _("_Verify System Dependencies")),
                description=_("Verify that all system dependencies are met"),
                callback=verify_deps_cb,
                sensitive_fn=verify_and_refresh_sensitive_cb,
                accelerator="<Control>D")

        bar.add("/%s/sep1" % actions_str, is_separator=1)

        ##
        ## Install Package
        ##

        bar.add("/%s/%s" % (actions_str, _("Mark for I_nstallation")),
                description=_("Mark this package for installation"),
                pixbuf_name="to-be-installed",
                callback=lambda x: self.set_package_action_cb(red_pendingops.
                                                              TO_BE_INSTALLED),
                sensitive_fn=self.install_sensitive_cb)

        ##
        ## Remove Package
        ##

        bar.add("/%s/%s" % (actions_str, _("Mark for _Removal")),
                description=_("Mark this package for removal"),
                pixbuf_name="to-be-removed",
                callback=lambda x: self.set_package_action_cb(red_pendingops.
                                                              TO_BE_REMOVED),
                sensitive_fn=self.remove_sensitive_cb)

        ##
        ## Cancel Action
        ##

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (actions_str, _("_Cancel")),
                description=_("Cancel installation or removal mark"),
                image=image,
                callback=lambda x: self.set_package_action_cb(red_pendingops.
                                                              NO_ACTION),
                sensitive_fn=self.cancel_sensitive_cb)

        bar.add("/%s/sep2" % actions_str, is_separator=1)

        ##
        ## Refresh Channel Data
        ##

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (actions_str, _("Re_fresh Catalog Data")),
                description=_("Download latest catalog data"),
                image=image,
                callback=rcd_util.refresh,
                sensitive_fn=verify_and_refresh_sensitive_cb,
                accelerator="<Control>R")

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_HELP, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (help_str, _("_Contents")),
                description=_("View Red Carpet help"),
                image=image,
                callback=help_cb,
                accelerator="F1")

        bar.add("/%s/%s" % (help_str, _("_About...")),
                description=_("About Red Carpet"),
                pixbuf_name="menu-about",
                callback=lambda x: self.open_or_raise_window(red_about.About))
Beispiel #21
0
    def __init__(self, server):

        gtk.Window.__init__(self)
        red_component.ComponentListener.__init__(self)
        red_pendingops.PendingOpsListener.__init__(self)

        self.server = server
        self.__title = None
        self.component_stack = []

        self.busy_count = 0
        self.busy_handler = 0

        self.vbox = gtk.VBox(0, 0)
        self.add(self.vbox)
        self.vbox.show()

        self.components = []

        self.accel_group = gtk.AccelGroup()
        self.add_accel_group(self.accel_group)

        self.set_icon(red_pixbuf.get_pixbuf("red-carpet"))

        # Menubar
        self.menubar = red_menubar.MenuBar(self.accel_group)
        self.menubar.set_user_data(self)
        self.assemble_menubar(self.menubar)
        self.vbox.pack_start(self.menubar, expand=0, fill=1)
        self.menubar.show()

        ## Toolbar
        self.toolbar = red_toolbar.Toolbar()
        self.assemble_toolbar(self.toolbar)
        self.vbox.pack_start(self.toolbar, expand=0, fill=1)
        self.toolbar.show_all()

        ## GtkSettings
        settings = gtk.settings_get_default()
        self.toolbar.set_style(settings.get_property("gtk-toolbar-style"))
        self.toolbar.set_icon_size(
            settings.get_property("gtk-toolbar-icon-size"))

        def settings_notify_toolbar_style_cb(set, pspec, app):
            app.toolbar.set_style(set.get_property("gtk-toolbar-style"))

        def settings_notify_toolbar_icon_size_cb(set, pspec, app):
            app.toolbar.set_icon_size(
                settings.get_property("gtk-toolbar-icon-size"))

        settings.connect("notify::gtk-toolbar-style",
                         settings_notify_toolbar_style_cb, self)
        settings.connect("notify::gtk-toolbar-icon-size",
                         settings_notify_toolbar_icon_size_cb, self)

        self.transient_windows = {}

        self.hpaned = gtk.HPaned()
        self.vbox.pack_start(self.hpaned, expand=1, fill=1)

        self.sidebar = red_sidebar.SideBar()
        # Ensure a sane width for the sidebar if visible
        if self.sidebar.get_property("visible"):
            w, h = self.sidebar.size_request()
            self.sidebar.set_size_request(int(w * 1.5), -1)

        self.hpaned.pack1(self.sidebar, resize=0, shrink=0)

        main_box = gtk.VBox(0, 6)
        main_box.set_border_width(6)
        self.hpaned.pack2(main_box, resize=1, shrink=1)

        ## Actionbar
        self.actionbar = red_actionbar.Actionbar()
        self.assemble_actionbar(self.actionbar)
        main_box.pack_end(self.actionbar, expand=0, fill=0)

        # Componentbook
        self.componentbook = red_componentbook.ComponentBook()

        def componentbook_switched_cb(cbook, comp):
            old_comp = self.get_component()
            if id(old_comp) == id(comp):
                return
            self.set_component(comp)

            if comp.is_busy():
                self.busy_start()
            if old_comp and old_comp.is_busy():
                self.busy_stop()

            # Clear the status bar, update the toolbar
            self.statusbar.pop(0)
            self.toolbar.sensitize_toolbar_items()
            self.actionbar.sensitize_actionbar_items()

            # Show the new component, hide the old one
            comp.visible(1)
            comp.set_parent(self)
            comp.activated()
            if not comp.show_actionbar():
                self.actionbar.hide()
            else:
                self.actionbar.show()

            if old_comp:
                old_comp.visible(0)
                old_comp.deactivated()
                old_comp.set_parent(None)

            self.set_title(comp.name())

        self.componentbook.connect("switched", componentbook_switched_cb)

        main_box.pack_start(self.componentbook, expand=1, fill=1)
        main_box.show_all()
        self.hpaned.show()

        ## Statusbar
        self.statusbar = red_statusbar.Statusbar()
        self.statusbar.show()
        self.vbox.pack_start(self.statusbar, expand=0, fill=1)
        notifier = red_connection.get_notifier()
        notifier.connect("connected", lambda x, y, z: z.set_connected(y),
                         self.statusbar)
        self.statusbar.connect("connect", lambda x: self.connect_to_daemon())
        notifier.notify()

        self.menubar.set_statusbar(self.statusbar)

        self.connect("delete_event", lambda x, y: self.shutdown())

        ## Geometry handling
        self.load_geometry()

        self.save_geometry_id = 0

        def size_allocate_cb(win, alloc):
            def save_geometry_cb(win):
                win.save_geometry()
                win.save_geometry_id = 0

                return 0

            if not self.save_geometry_id:
                self.save_geometry_id = gtk.idle_add(save_geometry_cb, win)

        self.connect("size_allocate", size_allocate_cb)
Beispiel #22
0
    def assemble_menubar(self, bar):

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_BUTTON)

        file_str = _("_File")
        edit_str = _("_Edit")
        view_str = _("_View")
        actions_str = _("_Actions")
        help_str = _("_Help")

        bar.add("/" + file_str)
        bar.add("/" + edit_str)
        bar.add("/" + view_str)
        bar.add("/" + actions_str)
        bar.add("/" + help_str)

        bar.add("/%s/%s" % (file_str, _("Connect to daemon...")),
                description=_("Connect to a remote daemon"),
                callback=lambda x:self.connect_to_daemon(),
                pixbuf_name="connect",
                accelerator="<Control>O")

        bar.add("/%s/sep" % file_str, is_separator=1)

        def install_file_sensitive_fn():
            return rcd_util.check_server_permission("install")

        bar.add("/%s/%s" % (file_str, _("Install from _File...")),
                description=_("Install a package from a local file"),
                pixbuf=red_pixbuf.get_pixbuf("install-from-file"),
                sensitive_fn=install_file_sensitive_fn,
                callback=lambda x:red_installfiles.install_local(self))

        def install_url_sensitive_fn():
            return rcd_util.check_server_permission("install") and \
                   red_installfiles.can_install_remote()

        bar.add("/%s/%s" % (file_str, _("Install from _URL...")),
                description=_("Install a package from a remote URL"),
                pixbuf=red_pixbuf.get_pixbuf("install-from-url"),
                sensitive_fn=install_url_sensitive_fn,
                callback=lambda x:red_installfiles.install_remote(self))

        bar.add("/%s/sep2" % file_str, is_separator=1)

        ##
        ## Mount command
        ##

        def mount_callback(app):
            app.open_or_raise_window(red_mount.MountWindow)

        def mount_sensitive_fn():
            return rcd_util.check_server_permission("superuser")

        bar.add("/%s/%s" % (file_str, _("_Mount Directory...")),
                description=_("Mount a directory as a catalog"),
                callback=mount_callback,
                sensitive_fn=mount_sensitive_fn,
                accelerator="<Control>M")

        ##
        ## Unmount command
        ##

        def unmount_callback(app):
            app.open_or_raise_window(red_mount.UnmountWindow)

        def unmount_sensitive_fn():
            return rcd_util.check_server_permission("superuser") and \
                   red_mount.has_mounted_channels()

        bar.add("/%s/%s" % (file_str, _("U_nmount Directory...")),
                description=_("Unmount a directory"),
                callback=unmount_callback,
                sensitive_fn=unmount_sensitive_fn,
                accelerator="<Control>N")
        

        bar.add("/%s/sep3" % file_str, is_separator=1)

        ##
        ## Activate
        ##

        def activate_sensitive_fn():
            return rcd_util.check_server_permission("superuser") \
                   and rcd_util.get_all_services()
        
        bar.add("/%s/%s" % (file_str, _("_Register...")),
                description=_("Register daemon"),
                callback=lambda x:self.open_or_raise_window(red_activation.ActivationWindow),
                sensitive_fn=activate_sensitive_fn)

        bar.add("/%s/sep4" % file_str, is_separator=1)
        
        bar.add("/%s/%s" % (file_str, _("Quit")),
                description=_("Quit Red Carpet"),
                stock=gtk.STOCK_QUIT,
                callback=lambda x:self.shutdown())


        ##
        ## Select all/none
        ##

        def select_all_sensitive_cb():
            comp = self.componentbook.get_visible_component()
            if not comp:
                return 0
            return comp.select_all_sensitive()

        bar.add("/%s/%s" % (edit_str, _("Select _All")),
                description=_("Select all items"),
                callback=lambda x:self.select_all_cb(1),
                accelerator="<Control>a",
                sensitive_fn=select_all_sensitive_cb)

        bar.add("/%s/%s" % (edit_str, _("Select _None")),
                description=_("Deselect all items"),
                callback=lambda x:self.select_all_cb(0),
                sensitive_fn=select_all_sensitive_cb,
                accelerator="<Shift><Control>A")

        bar.add("/%s/sep" % edit_str, is_separator=1)

        bar.add("/%s/%s" % (edit_str, _("Services...")),
                description=_("Edit services"),
                callback=lambda x:self.open_or_raise_window(red_services.ServicesWindow),
                accelerator="<Control>E")

        bar.add("/%s/%s" % (edit_str, _("Catalog _Subscriptions...")),
                description=_("Edit your catalog subscriptions"),
                callback=lambda x:self.open_or_raise_window(red_subscriptions.SubscriptionsWindow),
                pixbuf=red_pixbuf.get_pixbuf("channels-16"),
                accelerator="<Control>B")

        bar.add("/%s/%s" % (edit_str, _("_Preferences...")),
                description=_("Edit your Red Carpet preferences"),
                stock=gtk.STOCK_PREFERENCES,
                callback=lambda x:self.open_or_raise_window(red_prefs.PrefsWindow))

        bar.add("/%s/%s" % (edit_str, _("_Users...")),
                description=_("Edit user permissions for this daemon"),
                pixbuf=red_pixbuf.get_pixbuf("users"),
                callback=lambda x:self.open_or_raise_window(red_users.UsersWindow))

        ##
        ## Sidebar
        ##

        def checked_get_cb():
            return self.sidebar.get_property("visible")
        def checked_set_cb(flag):
            self.sidebar.change_visibility()

        bar.add("/%s/%s" % (view_str, _("_Sidebar")),
                description=_("Hide or show the Pending Actions sidebar"),
                checked_get=checked_get_cb,
                checked_set=checked_set_cb)

        bar.add("/%s/%s" % (view_str, _("_Advanced Search Options")),
                description=_("Hide or show advanced search options"),
                checked_get=red_searchbox.show_advanced_get,
                checked_set=red_searchbox.show_advanced_set)

        bar.add("/%s/%s" % (view_str, _("_Catalog Names")),
                description=_("Hide or show catalog names in package lists"),
                checked_get=red_packageview.show_channel_names_get,
                checked_set=red_packageview.show_channel_names_set)

        bar.add("/%s/sep" % view_str, is_separator=1)

        bar.add("/%s/%s" % (view_str, _("Package _Information...")),
                description=_("View information about currently selected packages"),
                pixbuf_name="info",
                callback=lambda x:self.package_info_cb(),
                sensitive_fn=self.info_sensitive_cb,
                accelerator="<Control>I")

        bar.add("/%s/sep1" % view_str, is_separator=1)

        bar.add("/%s/%s" % (view_str, _("_Daemon Information...")),
                description=_("View information about this daemon"),
                callback=red_serverinfo.view_server_info_cb)

        bar.add("/%s/sep2" % view_str, is_separator=1)

        ##
        ## Run Transaction
        ##

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (actions_str, _("Run _Now")),
                description=_("Run the current transaction"),
                image=image,
                callback=run_transaction_cb,
                sensitive_fn=self.sensitize_run_button,
                accelerator="<Control>X")

        ##
        ## Verify System Dependencies
        ##

        def verify_and_refresh_sensitive_cb():
            comp = self.componentbook.get_visible_component()
            return comp.run_sensitized()
                
        bar.add("/%s/%s" % (actions_str, _("_Verify System Dependencies")),
                description=_("Verify that all system dependencies are met"),
                callback=verify_deps_cb,
                sensitive_fn=verify_and_refresh_sensitive_cb,
                accelerator="<Control>D")

        bar.add("/%s/sep1" % actions_str, is_separator=1)

        ##
        ## Install Package
        ##

        bar.add("/%s/%s" % (actions_str, _("Mark for I_nstallation")),
                description=_("Mark this package for installation"),
                pixbuf_name="to-be-installed",
                callback=lambda x:self.set_package_action_cb(red_pendingops.TO_BE_INSTALLED),
                sensitive_fn=self.install_sensitive_cb)

        ##
        ## Remove Package
        ##

        bar.add("/%s/%s" % (actions_str, _("Mark for _Removal")),
                description=_("Mark this package for removal"),
                pixbuf_name="to-be-removed",
                callback=lambda x:self.set_package_action_cb(red_pendingops.TO_BE_REMOVED),
                sensitive_fn=self.remove_sensitive_cb)

        ##
        ## Cancel Action
        ##

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (actions_str, _("_Cancel")),
                description=_("Cancel installation or removal mark"),
                image=image,
                callback=lambda x:self.set_package_action_cb(red_pendingops.NO_ACTION),
                sensitive_fn=self.cancel_sensitive_cb)

        bar.add("/%s/sep2" % actions_str, is_separator=1)

        ##
        ## Refresh Channel Data
        ##

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (actions_str, _("Re_fresh Catalog Data")),
                description=_("Download latest catalog data"),
                image=image,
                callback=rcd_util.refresh,
                sensitive_fn=verify_and_refresh_sensitive_cb,
                accelerator="<Control>R")

        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_HELP, gtk.ICON_SIZE_MENU)

        bar.add("/%s/%s" % (help_str, _("_Contents")),
                description=_("View Red Carpet help"),
                image=image,
                callback=help_cb,
                accelerator="F1")

        bar.add("/%s/%s" % (help_str, _("_About...")),
                description=_("About Red Carpet"),
                pixbuf_name="menu-about",
                callback=lambda x:self.open_or_raise_window(red_about.About))
Beispiel #23
0
    return rcd_util.get_package_channel_icon(pkg, width=24, height=24)

def pkg_sec_name(pkg):
    return pkg["section_user_str"]

def pkg_sec_icon(pkg):
    pixbuf_name = "section-" + pkg["section_str"]
    return red_pixbuf.get_pixbuf(pixbuf_name, width=16, height=16)

def pkg_importance(pkg):
    return pkg.get("importance_str", "")

def pkg_locked(pkg):
    return pkg["locked"]

__locked_icon = red_pixbuf.get_pixbuf("lock")

def pkg_locked_icon(pkg):
    if pkg["locked"]:
        return __locked_icon
    else:
        return None

def pkg_is_installed(pkg):
    return pkg["installed"]

def pkg_is_name_installed(pkg):
    return pkg["name_installed"] != 0

def pkg_is_upgrade(pkg):
    return pkg["name_installed"] > 0
Beispiel #24
0
    def __init__(self, server):

        gtk.Window.__init__(self)
        red_component.ComponentListener.__init__(self)
        red_pendingops.PendingOpsListener.__init__(self)

        self.server = server
        self.__title = None
        self.component_stack = []

        self.busy_count = 0
        self.busy_handler = 0

        self.vbox = gtk.VBox(0, 0)
        self.add(self.vbox)
        self.vbox.show()

        self.components = []

        self.accel_group = gtk.AccelGroup()
        self.add_accel_group(self.accel_group)

        self.set_icon(red_pixbuf.get_pixbuf("red-carpet"))

        # Menubar
        self.menubar = red_menubar.MenuBar(self.accel_group)
        self.menubar.set_user_data(self)
        self.assemble_menubar(self.menubar)
        self.vbox.pack_start(self.menubar, expand=0, fill=1)
        self.menubar.show()

        ## Toolbar
        self.toolbar = red_toolbar.Toolbar()
        self.assemble_toolbar(self.toolbar)
        self.vbox.pack_start(self.toolbar, expand=0, fill=1)
        self.toolbar.show_all()

        ## GtkSettings
        settings = gtk.settings_get_default()
        self.toolbar.set_style(settings.get_property("gtk-toolbar-style"))
        self.toolbar.set_icon_size(settings.get_property("gtk-toolbar-icon-size"))

        def settings_notify_toolbar_style_cb(set, pspec, app):
            app.toolbar.set_style(set.get_property("gtk-toolbar-style"))

        def settings_notify_toolbar_icon_size_cb(set, pspec, app):
            app.toolbar.set_icon_size(settings.get_property("gtk-toolbar-icon-size"))
        
        settings.connect("notify::gtk-toolbar-style",
                         settings_notify_toolbar_style_cb, self)
        settings.connect("notify::gtk-toolbar-icon-size",
                         settings_notify_toolbar_icon_size_cb, self)

        self.transient_windows = {}

        self.hpaned = gtk.HPaned()
        self.vbox.pack_start(self.hpaned, expand=1, fill=1)

        self.sidebar = red_sidebar.SideBar()
        # Ensure a sane width for the sidebar if visible
        if self.sidebar.get_property("visible"):
            w, h = self.sidebar.size_request()
            self.sidebar.set_size_request(int(w * 1.5), -1)

        self.hpaned.pack1(self.sidebar, resize=0, shrink=0)

        main_box = gtk.VBox(0, 6)
        main_box.set_border_width(6)
        self.hpaned.pack2(main_box, resize=1, shrink=1)

        ## Actionbar
        self.actionbar = red_actionbar.Actionbar()
        self.assemble_actionbar(self.actionbar)
        main_box.pack_end(self.actionbar, expand=0, fill=0)

        # Componentbook
        self.componentbook = red_componentbook.ComponentBook()

        def componentbook_switched_cb(cbook, comp):
            old_comp = self.get_component()
            if id(old_comp) == id(comp):
                return
            self.set_component(comp)
            
            if comp.is_busy():
                self.busy_start()
            if old_comp and old_comp.is_busy():
                self.busy_stop()

            # Clear the status bar, update the toolbar
            self.statusbar.pop(0)
            self.toolbar.sensitize_toolbar_items()
            self.actionbar.sensitize_actionbar_items()

            # Show the new component, hide the old one
            comp.visible(1)
            comp.set_parent(self)
            comp.activated()
            if not comp.show_actionbar():
                self.actionbar.hide()
            else:
                self.actionbar.show()

            if old_comp:
                old_comp.visible(0)
                old_comp.deactivated()
                old_comp.set_parent(None)
                
            self.set_title(comp.name())
            
        self.componentbook.connect("switched", componentbook_switched_cb)

        main_box.pack_start(self.componentbook, expand=1, fill=1)
        main_box.show_all()
        self.hpaned.show()

        ## Statusbar
        self.statusbar = red_statusbar.Statusbar()
        self.statusbar.show()
        self.vbox.pack_start(self.statusbar, expand=0, fill=1)
        notifier = red_connection.get_notifier()
        notifier.connect("connected",
                         lambda x,y,z:z.set_connected(y), self.statusbar)
        self.statusbar.connect("connect", lambda x:self.connect_to_daemon())
        notifier.notify()

        self.menubar.set_statusbar(self.statusbar)

        self.connect("delete_event", lambda x, y:self.shutdown())

        ## Geometry handling
        self.load_geometry()

        self.save_geometry_id = 0

        def size_allocate_cb(win, alloc):

            def save_geometry_cb(win):
                win.save_geometry()
                win.save_geometry_id = 0

                return 0
            
            if not self.save_geometry_id:
                self.save_geometry_id = gtk.idle_add(save_geometry_cb, win)

        self.connect("size_allocate", size_allocate_cb)