def __init__(self): self.__pending_messages = [] self.__pending_handler = 0 img = red_pixbuf.get_widget("console") box = gtk.HBox(0, 0) box.pack_start(img, expand=0, fill=0, padding=3) box.pack_start(gtk.VSeparator(), expand=0, fill=1, padding=3) self.textview = gtk.TextView() self.textview.set_editable(0) self.textview.set_cursor_visible(0) self.textview.set_size_request(300, 200) self.scrolled = gtk.ScrolledWindow() self.scrolled.add(self.textview) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) box.pack_start(self.scrolled, expand=1, fill=1) self.window = gtk.Dialog() self.window.set_title(_("ZENworks Error Console")) self.window.add_button(gtk.STOCK_OK, gtk.RESPONSE_CLOSE) self.window.vbox.add(box) self.window.connect("response", lambda d, x: d.hide())
def __init__(self): self.__pending_messages = [] self.__pending_handler = 0 img = red_pixbuf.get_widget("console") box = gtk.HBox(0, 0) box.pack_start(img, expand=0, fill=0, padding=3) box.pack_start(gtk.VSeparator(), expand=0, fill=1, padding=3) self.textview = gtk.TextView() self.textview.set_editable(0) self.textview.set_cursor_visible(0) self.textview.set_size_request(300, 200) self.scrolled = gtk.ScrolledWindow() self.scrolled.add(self.textview) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) box.pack_start(self.scrolled, expand=1, fill=1) self.window = gtk.Dialog() self.window.set_title(_("ZENworks Error Console")) self.window.add_button(gtk.STOCK_OK, gtk.RESPONSE_CLOSE) self.window.vbox.add(box) self.window.connect("response", lambda d, x: d.hide())
def pkg_section(pkg, pkg_info, key): box = gtk.HBox(0, 2) icon = pkg.get("section_str", "") if icon: icon = "section-%s" % icon box.pack_start(red_pixbuf.get_widget(icon, width=24, height=24), 0, 0) label = pkg.get("section_user_str") if label: box.pack_start(gtk.Label(label), 0, 0) return box
def append_locked_column(self): col = gtk.TreeViewColumn(None, gtk.CellRendererPixbuf(), pixbuf=red_packagearray.COLUMN_LOCKED_ICON) widget = red_pixbuf.get_widget("lock") widget.show() self.add_column(col, widget=widget, initially_visible=1, sort_id=red_packagearray.COLUMN_LOCKED ) return col
def __assemble_section_option(self): section_table = ( (_("All Sections"), None, -1), (_("Productivity"), "office", 0), (_("Imaging"), "imaging", 1), (_("Personal Info. Mgmt"), "pim", 2), (_("X Windows"), "xapp", 3), (_("Games"), "game", 4), (_("Multimedia"), "multimedia", 5), (_("Internet"), "internet", 6), (_("Utilities"), "util", 7), (_("System"), "system", 8), (_("Documentation"), "doc", 9), (_("Libraries"), "library", 10), (_("Development"), "devel", 11), (_("Development Tools"), "develutil", 12), (_("Miscellaneous"), "misc", 13), ) menu = gtk.Menu() width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) for name, icon, code in section_table: hbox = gtk.HBox(0, 0) if icon: icon = "section-" + icon img = red_pixbuf.get_widget(icon, width=width, height=height) hbox.pack_start(img, expand=0, fill=0, padding=0) label = gtk.Label(name) hbox.pack_start(label, expand=0, fill=0, padding=4) mi = gtk.MenuItem() def set_cb(x, sbox, code): sbox.__match_section = code self.__changed() mi.connect("activate", set_cb, self, code) mi.add(hbox) mi.show_all() menu.append(mi) opt = gtk.OptionMenu() opt.set_menu(menu) self.__match_section = -1 return opt
def __init__(self, image=None, pixbuf=None, pixbuf_name=None, text=None, formatted_text=None): gtk.EventBox.__init__(self) if pixbuf_name: assert not pixbuf and not image image = red_pixbuf.get_widget(pixbuf_name) if pixbuf: assert not pixbuf_name and not image image = gtk.Image() image.set_from_pixbuf(pixbuf) if text: assert not formatted_text formatted_text = "<span size=\"large\"><b>%s</b></span>" % text formatted_text = string.join( rcd_util.linebreak(formatted_text, width=70), "\n") box = gtk.HBox(0, 0) box.pack_start(gtk.Label(""), expand=1, fill=1) if image: box.pack_start(image, expand=0, fill=1, padding=4) label = gtk.Label("") if formatted_text: label.set_markup(formatted_text) box.pack_start(label, expand=0, fill=1, padding=4) box.pack_start(gtk.Label(""), expand=1, fill=1) frame = gtk.Frame(None) frame.add(box) self.add(frame) style = self.get_style().copy() color = self.get_colormap().alloc_color("white") style.bg[gtk.STATE_NORMAL] = color self.set_style(style) self.show_all() self.hide()
def build_verified_ok_page(self): page = self.page box = gtk.HBox(0, 0) box.pack_start(gtk.Label(""), expand=1, fill=1) img = red_pixbuf.get_widget("verify") box.pack_start(img, expand=0, fill=1, padding=4) msg1 = "<span size=\"large\"><b>%s</b></span>" \ % _("System Verified") msg2 = _("All package dependencies are satisfied, and no corrective actions are required.") msg = msg1+"\n"+string.join(rcd_util.linebreak(msg2, width=30), "\n") label = gtk.Label("") label.set_markup(msg) box.pack_start(label, expand=0, fill=1, padding=4) box.pack_start(gtk.Label(""), expand=1, fill=1) frame = gtk.Frame(None) frame.add(box) bg = gtk.EventBox() style = bg.get_style().copy() color = bg.get_colormap().alloc_color("white") style.bg[gtk.STATE_NORMAL] = color bg.set_style(style) bg.add(frame) page.pack_start(bg, expand=1, fill=1) buttons = gtk.HButtonBox() buttons.set_layout(gtk.BUTTONBOX_END) button = gtk.Button(gtk.STOCK_OK) button.set_use_stock(1) buttons.add(button) page.pack_end(buttons, 0, 0, 0) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.connect("clicked", lambda x:self.pop()) page.show_all()
def __assemble_section_option(self): section_table = ( (_("All Sections"), None, -1), (_("Productivity"), "office", 0), (_("Imaging"), "imaging", 1), (_("Personal Info. Mgmt"), "pim", 2), (_("X Windows"), "xapp", 3), (_("Games"), "game", 4), (_("Multimedia"), "multimedia", 5), (_("Internet"), "internet", 6), (_("Utilities"), "util", 7), (_("System"), "system", 8), (_("Documentation"), "doc", 9), (_("Libraries"), "library", 10), (_("Development"), "devel", 11), (_("Development Tools"), "develutil", 12), (_("Miscellaneous"), "misc", 13), ) menu = gtk.Menu() width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) for name, icon, code in section_table: hbox = gtk.HBox(0, 0) if icon: icon = "section-" + icon img = red_pixbuf.get_widget(icon, width=width, height=height) hbox.pack_start(img, expand=0, fill=0, padding=0) label = gtk.Label(name) hbox.pack_start(label, expand=0, fill=0, padding=4) mi = gtk.MenuItem() def set_cb(x, sbox, code): sbox.__match_section = code self.__changed() mi.connect("activate", set_cb, self, code) mi.add(hbox) mi.show_all() menu.append(mi) opt = gtk.OptionMenu() opt.set_menu(menu) self.__match_section = -1 return opt
def splash(time_in_seconds, thunk): win = gtk.Window() img = red_pixbuf.get_widget("gnoetry-splash") win.add(img) win.set_decorated(False) win.set_position(gtk.WIN_POS_CENTER) win.show_all() def do_thunk(): thunk() win.destroy() gtk.timeout_add(int(1000 * time_in_seconds), do_thunk)
def splash(time_in_seconds, thunk): win = gtk.Window() img = red_pixbuf.get_widget("gnoetry-splash") win.add(img) win.set_decorated(False) win.set_position(gtk.WIN_POS_CENTER) win.show_all() def do_thunk(): thunk() win.destroy() gtk.timeout_add(int(1000*time_in_seconds), do_thunk)
def __init__(self, image=None, pixbuf=None, pixbuf_name=None, text=None, formatted_text=None): gtk.EventBox.__init__(self) if pixbuf_name: assert not pixbuf and not image image = red_pixbuf.get_widget(pixbuf_name) if pixbuf: assert not pixbuf_name and not image image = gtk.Image() image.set_from_pixbuf(pixbuf) if text: assert not formatted_text formatted_text = '<span size="large"><b>%s</b></span>' % text formatted_text = string.join(rcd_util.linebreak(formatted_text, width=70), "\n") box = gtk.HBox(0, 0) box.pack_start(gtk.Label(""), expand=1, fill=1) if image: box.pack_start(image, expand=0, fill=1, padding=4) label = gtk.Label("") if formatted_text: label.set_markup(formatted_text) box.pack_start(label, expand=0, fill=1, padding=4) box.pack_start(gtk.Label(""), expand=1, fill=1) frame = gtk.Frame(None) frame.add(box) self.add(frame) style = self.get_style().copy() color = self.get_colormap().alloc_color("white") style.bg[gtk.STATE_NORMAL] = color self.set_style(style) self.show_all() self.hide()
def build(self): self.tooltips = gtk.Tooltips() self.connection = gtk.Button() align = gtk.Alignment(0.5, 0.5, 0, 0) self.connection.add(align) box = gtk.HBox(0, 2) align.add(box) image = red_pixbuf.get_widget("connect") box.pack_start(image, 0, 0) self.connection.show_all() self.pack_start(self.connection, 0, 0) self.connection.connect("clicked", lambda x: self.connect_clicked()) self.message = gtk.Statusbar() self.message.show() self.pack_start(self.message, expand=1, fill=1)
def build(self): self.tooltips = gtk.Tooltips() self.connection = gtk.Button() align = gtk.Alignment(0.5, 0.5, 0, 0) self.connection.add(align) box = gtk.HBox(0, 2) align.add(box) image = red_pixbuf.get_widget("connect") box.pack_start(image, 0, 0) self.connection.show_all() self.pack_start(self.connection, 0, 0) self.connection.connect("clicked", lambda x:self.connect_clicked()) self.message = gtk.Statusbar() self.message.show() self.pack_start(self.message, expand=1, fill=1)
def build_page_label(self): img = None if self.__component.stock(): img = gtk.Image() img.set_from_stock(self.__component.stock(), gtk.ICON_SIZE_SMALL_TOOLBAR) elif self.__component.pixbuf(): img = red_pixbuf.get_widget(self.__component.pixbuf(), width=16, height=16) label = gtk.Label(self.__component.name()) if img: box = gtk.HBox(0, 0) box.pack_start(img, expand=0, fill=0, padding=2) box.pack_start(label, expand=1, fill=1) return box return label
def build_page_label(self): img = None if self.__component.stock(): img = gtk.Image() img.set_from_stock(self.__component.stock(), gtk.ICON_SIZE_SMALL_TOOLBAR) elif self.__component.pixbuf(): img = red_pixbuf.get_widget(self.__component.pixbuf(), width=16, height=16) label = gtk.Label(self.__component.name()) if img: box = gtk.HBox(0, 0) box.pack_start(img, expand=0, fill=0, padding=2) box.pack_start(label, expand=1, fill=1) return box return label
def __assemble(self): self.item_id_list = [] menu = gtk.Menu() channels = rcd_util.get_all_channels() channels.sort(lambda x,y:cmp(string.lower(x["name"]), string.lower(y["name"]))) if self.__allow_any_channel: channels.insert(0, {"name": _("All Catalogs"), "id": MATCH_ANY_CHANNEL}) if self.__allow_any_subd_channel: channels.insert(0, {"name": _("All Subscribed Catalogs"), "id": MATCH_ANY_SUBD_CHANNEL, "subscribed": 1}) if self.__allow_no_channel: channels.append({"name": _("No Catalog/Unknown Catalog"), "id": MATCH_NO_CHANNEL}) width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) for c in channels: hbox = gtk.HBox(0, 0) if not is_channel_wildcard(c["id"]): pixbuf = rcd_util.get_channel_icon(c["id"], 24, 24) else: pixbuf = None img = gtk.Image() img.set_size_request(24, 24) if pixbuf: img.set_from_pixbuf(pixbuf) label = gtk.Label(c["name"]) hbox.pack_start(img, 0, 0, 0) hbox.pack_start(label, 0, 0, 4) if c.get("subscribed"): sub_img = red_pixbuf.get_widget("status-installed", width=width, height=height) hbox.pack_end(sub_img, expand=0, fill=0, padding=2) item = gtk.MenuItem() item.add(hbox) item.show_all() self.item_id_list.append(c["id"]) def activate_cb(item, id, opt): if id != self.__last_id: opt.__last_id = id opt.emit("selected", id) item.connect("activate", activate_cb, c["id"], self) menu.append(item) menu.show() self.set_menu(menu)
def __assemble(self): self.item_id_list = [] menu = gtk.Menu() channels = rcd_util.get_all_channels() channels.sort( lambda x, y: cmp(string.lower(x["name"]), string.lower(y["name"]))) if self.__allow_any_channel: channels.insert(0, { "name": _("All Catalogs"), "id": MATCH_ANY_CHANNEL }) if self.__allow_any_subd_channel: channels.insert( 0, { "name": _("All Subscribed Catalogs"), "id": MATCH_ANY_SUBD_CHANNEL, "subscribed": 1 }) if self.__allow_no_channel: channels.append({ "name": _("No Catalog/Unknown Catalog"), "id": MATCH_NO_CHANNEL }) width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) for c in channels: hbox = gtk.HBox(0, 0) if not is_channel_wildcard(c["id"]): pixbuf = rcd_util.get_channel_icon(c["id"], 24, 24) else: pixbuf = None img = gtk.Image() img.set_size_request(24, 24) if pixbuf: img.set_from_pixbuf(pixbuf) label = gtk.Label(c["name"]) hbox.pack_start(img, 0, 0, 0) hbox.pack_start(label, 0, 0, 4) if c.get("subscribed"): sub_img = red_pixbuf.get_widget("status-installed", width=width, height=height) hbox.pack_end(sub_img, expand=0, fill=0, padding=2) item = gtk.MenuItem() item.add(hbox) item.show_all() self.item_id_list.append(c["id"]) def activate_cb(item, id, opt): if id != self.__last_id: opt.__last_id = id opt.emit("selected", id) item.connect("activate", activate_cb, c["id"], self) menu.append(item) menu.show() self.set_menu(menu)
def add(self, path, description=None, callback=None, with_dropdown_arrow=0, is_separator=0, visible_fn=None, sensitive_fn=None, stock=None, image=None, pixbuf=None, pixbuf_name=None, checked_get=None, checked_set=None, radiogroup=None, radiotag=None, radio_get=None, radio_set=None, accelerator=None): if self.constructed: print "Can't add '%s' to an already-constructed menu bar." \ % path assert 0 prefix, name = os.path.split(path) path = string.replace(path, "_", "") if self.pending_items_hash.has_key(path): print "Collision: there is already a menu item with path '%s'" \ % path assert 0 if pixbuf_name: assert not pixbuf and not image image = red_pixbuf.get_widget(pixbuf_name) if pixbuf: assert not pixbuf_name and not image image = gtk.Image() image.set_from_pixbuf(pixbuf) item = {"path":path, "name":name, "description":description, "callback":callback, "with_dropdown_arrow":with_dropdown_arrow, "is_separator":is_separator, "visible_fn":visible_fn, "sensitive_fn":sensitive_fn, "stock":stock, "image":image, "checked_get":checked_get, "checked_set":checked_set, "radiogroup":radiogroup, "radiotag":radiotag, "radio_get":radio_get, "radio_set":radio_set, "accelerator":accelerator, } self.pending_items.append(item) self.pending_items_hash[path] = item
def add(self, path, description=None, callback=None, with_dropdown_arrow=0, is_separator=0, visible_fn=None, sensitive_fn=None, stock=None, image=None, pixbuf=None, pixbuf_name=None, checked_get=None, checked_set=None, radiogroup=None, radiotag=None, radio_get=None, radio_set=None, accelerator=None): if self.constructed: print "Can't add '%s' to an already-constructed menu bar." \ % path assert 0 prefix, name = os.path.split(path) path = string.replace(path, "_", "") if self.pending_items_hash.has_key(path): print "Collision: there is already a menu item with path '%s'" \ % path assert 0 if pixbuf_name: assert not pixbuf and not image image = red_pixbuf.get_widget(pixbuf_name) if pixbuf: assert not pixbuf_name and not image image = gtk.Image() image.set_from_pixbuf(pixbuf) item = {"path":path, "name":name, "description":description, "callback":callback, "with_dropdown_arrow":with_dropdown_arrow, "is_separator":is_separator, "visible_fn":visible_fn, "sensitive_fn":sensitive_fn, "stock":stock, "image":image, "checked_get":checked_get, "checked_set":checked_set, "radiogroup":radiogroup, "radiotag":radiotag, "radio_get":radio_get, "radio_set":radio_set, "accelerator":accelerator, } self.pending_items.append(item) self.pending_items_hash[path] = item
def do_popup(self, ev_button, ev_time, ev_x, ev_y): menu = gtk.Menu() menu.attach_to_widget(self, None) pkgs = self.get_selected_packages() if (ev_x, ev_y) != (-1, -1): path_info = self.get_path_at_pos(ev_x, ev_y) if path_info is None: return path, column, cell_x, cell_y = self.get_path_at_pos(ev_x, ev_y) model = self.get_model() clicked_pkg = model.get_list_item(path[0]) if not clicked_pkg in pkgs: pkgs = [clicked_pkg] self.set_cursor(path, column) def set_package_action(pkgs, action): for pkg in pkgs: if red_pendingops.can_perform_action_single(pkg, action): red_pendingops.set_action(pkg, action) # Install item = gtk.ImageMenuItem(_("Mark for _Installation")) image = red_pixbuf.get_widget("to-be-installed") item.set_image(image) if not red_pendingops.can_perform_action_multiple(pkgs, red_pendingops.TO_BE_INSTALLED): item.set_sensitive(0) item.show_all() menu.append(item) item.connect("activate", lambda x:set_package_action(pkgs, red_pendingops.TO_BE_INSTALLED)) # Remove item = gtk.ImageMenuItem(_("Mark for _Removal")) image = red_pixbuf.get_widget("to-be-removed") item.set_image(image) if not red_pendingops.can_perform_action_multiple(pkgs, red_pendingops.TO_BE_REMOVED): item.set_sensitive(0) item.show_all() menu.append(item) item.connect("activate", lambda x:set_package_action(pkgs, red_pendingops.TO_BE_REMOVED)) # Cancel item = gtk.ImageMenuItem(_("_Cancel")) image = gtk.Image() image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU) item.set_image(image) item.show_all() if not red_pendingops.can_perform_action_multiple(pkgs, red_pendingops.NO_ACTION): item.set_sensitive(0) menu.append(item) item.connect("activate", lambda x:set_package_action(pkgs, red_pendingops.NO_ACTION)) item = gtk.SeparatorMenuItem() item.show_all() menu.append(item) # Info item = gtk.ImageMenuItem(_("I_nformation")) image = red_pixbuf.get_widget("info") item.set_image(image) item.show_all() if len(pkgs) != 1: item.set_sensitive(0) menu.append(item) parent = self.get_toplevel() if not parent.flags() & gtk.TOPLEVEL: parent_window = None item.connect("activate", lambda x:red_packagebook.show_package_info(pkgs[0], parent=parent)) menu.popup(None, None, None, ev_button, ev_time)