def create_button_chooser(self, settings, key, path_prefix, path_suffix, button_picture_size, menu_pictures_size, num_cols): if self is None: return chooser = PictureChooserButton(num_cols=num_cols, button_picture_size=button_picture_size, menu_pictures_size=menu_pictures_size, \ has_button_label=True) theme = settings.get_string(key) chooser.set_button_label(theme) chooser.set_tooltip_text(theme) if path_suffix == "cinnamon" and theme == "cinnamon": chooser.set_picture_from_file("/usr/share/cinnamon/theme/thumbnail.png") elif path_suffix == "icons": current_theme = IconTheme.get_default() folder = current_theme.lookup_icon("folder", button_picture_size, 0) if folder is not None: path = folder.get_filename() chooser.set_picture_from_file(path) else: try: for path in ["/usr/share/%s/%s/%s/thumbnail.png" % (path_prefix, theme, path_suffix), os.path.expanduser("~/.%s/%s/%s/thumbnail.png" % (path_prefix, theme, path_suffix)), "/usr/share/cinnamon/thumbnails/%s/%s.png" % (path_suffix, theme), "/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix]: if os.path.exists(path): chooser.set_picture_from_file(path) break except Exception: chooser.set_picture_from_file("/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix) return chooser
def __init__(self, *args, entities=[], quit_cb=None, max_pages=10, **kwargs): """Editor class Args: entities (list): of dict having keys"Label", "URI", "Description"; max_pages (int): maximum number of pages kept in RAM """ ApplicationWindow.__init__(self, *args, **kwargs) self.quit_cb = quit_cb self.open_dialogs = [] # Set window icon icon = lambda x: IconTheme.get_default().load_icon((name), x, 0) icons = [icon(size) for size in [32, 48, 64, 96]]; self.set_icon_list(icons); # Set shortcuts accelerators = AccelGroup() self.add_accel_group(accelerators) add_accelerator(accelerators, self.entity_open, "<Control>o", signal="clicked") add_accelerator(accelerators, self.entity_search, "<Control>f", signal="clicked") add_accelerator(accelerators, self.entity_discussion_open_external, "<Control>d", signal="clicked") add_accelerator(accelerators, self.entity_history_open_external, "<Control>h", signal="clicked") add_accelerator(accelerators, self.entities_select, "<Control>s", signal="clicked") add_accelerator(accelerators, self.cancel_entities_selection, "<Control><Shift>s", signal="clicked") add_accelerator(accelerators, self.entities_search, "<Control><Shift>f", signal="activate") # Init sidebar self.sidebar_list = SidebarList() self.sidebar_list.connect("entity-selected", self.sidebar_row_selected_cb) self.sidebar_viewport.add(self.sidebar_list) # Init pages loading = LoadingPage() self.pages.add_titled(loading, "loading", "Loading") # Parse args self.max_pages = max_pages if entities: self.load(entities) else: entities_open_dialog = Open(quit_cb=self.quit_cb, new_session=True) entities_open_dialog.connect("new-window-clicked", self.new_window_clicked_cb) entities_open_dialog.connect("window-new", self.open_window_new_clicked_cb) self.open_dialogs.append(entities_open_dialog) entities_open_dialog.get_focus()
def get_deluge_icon(): """The deluge icon for use in dialogs. It will first attempt to get the icon from the theme and will fallback to using an image that is distributed with the package. Returns: Pixbuf: the deluge icon """ if windows_check(): return get_logo(32) else: try: icon_theme = IconTheme.get_default() return icon_theme.load_icon('deluge', 64, 0) except GError: return get_logo(64)
def __init__(self, languages, *args, **kwargs): Window.__init__(self, *args, **kwargs) icon = lambda x: IconTheme.get_default().load_icon((name), x, 0) icons = [icon(size) for size in [32, 48, 64, 96]] self.set_icon_list(icons) self.languages.set_header_func(self.update_header) for language in languages: row = ListBoxRow() label = Label() label.set_text(language['itemLabel']['value']) label.code = language['c']['value'] row.child = label row.add(label) self.languages.add(row) self.languages.show_all()
def __init__(self, *args, new_session=True, quit_cb=None, verbose=False): Window.__init__(self, *args) # Set window icon icon = lambda x: IconTheme.get_default().load_icon((name), x, 0) icons = [icon(size) for size in [32, 48, 64, 96]]; self.set_icon_list(icons); self.verbose = verbose self.new_session = new_session self.results_listbox.selected = EntitySet() self.filtered_results = EntitySet() self.entities = self.results_listbox.selected self.variables = EntitySet(triplet=False) self.hb_title = self.header_bar.get_title() self.hb_subtitle = self.header_bar.get_subtitle() self.search_entry_connection = self.search_entry.connect("search-changed", self.search_entry_search_changed_cb) self.filters_listbox = FiltersList() self.filters_viewport.add(self.filters_listbox) if quit_cb: self.quit_cb = quit_cb self.connect("delete-event", self.on_quit) self.show() if new_session: self.header_bar.set_show_close_button(True) else: self.header_bar.set_show_close_button(False) self.back.set_visible(True) self.open_button.connect('clicked', self.open_button_clicked_cb) text = """<b>Search for an <a href="url">entity</a> in the database</b>""" if system() == 'Linux': url = "help:daty/daty-entities" if system() == 'Windows': url = "http://daty.prevete.ml/daty-entities.html" text = sub('url', url, text) set_text(self.subtitle, text, url, markup=True)
def __init__(self, *args, **kwargs): Window.__init__(self, *args, **kwargs) icon = lambda x: IconTheme.get_default().load_icon((name), x, 0) icons = [icon(size) for size in [32, 48, 64, 96]] self.set_icon_list(icons) self.credentials.set_header_func(self.update_header) self.languages.set_header_func(self.update_header) for key in self.config.data['credentials']: row = ListBoxRow() grid = Grid() grid.props.column_homogeneous = True label = Label() label.set_text(key) label.props.halign = Align(1) context = label.get_style_context() resource = "/ml/prevete/Daty/gtk/value.css" set_style(context, resource, "dim-label", True) entry = Entry() entry.set_text(self.config.data['credentials'][key]) context = entry.get_style_context() set_style(context, resource, "flat", True) grid.attach(label, 0, 0, 1, 1) grid.attach(entry, 1, 0, 2, 1) row.add(grid) self.credentials.add(row) self.credentials.show_all() query = """SELECT ?item ?itemLabel ?c { ?item wdt:P424 ?c . MINUS{?item wdt:P31/wdt:P279* wd:Q14827288} #exclude Wikimedia projects MINUS{?item wdt:P31/wdt:P279* wd:Q17442446} #exclude Wikimedia internal stuff SERVICE wikibase:label { bd:serviceParam wikibase:language "your_first_language". } } """ query = sub("your_first_language", self.config.data['languages'][0], query) self.retrieve(query, self.languages_callback)
def __init__(self, config, *args, **kwargs): Assistant.__init__(self) icon = lambda x: IconTheme.get_default().load_icon((name), x, 0) icons = [icon(size) for size in [32, 48, 64, 96]]; self.set_icon_list(icons); self.config = config self.credentials.set_header_func(self.update_header) elements = [("user", self.username_label, self.username), ("bot_user", self.bot_username_label, self.bot_username), ("bot_password", self.bot_password_label, self.bot_password)] for key, label, entry in elements: row = ListBoxRow() grid = Grid() grid.props.column_homogeneous = True label.props.halign = Align(1) grid.attach(label, 0, 0, 1, 1) grid.attach(entry, 1, 0, 2, 1) row.add(grid) self.credentials.add(row) self.credentials.show_all() lc, encoding = getdefaultlocale() if (lc): language = lc.split("_")[0] else: language = environ.get("LANGUAGE", None) if language: language = language.split(":")[0] self.config.data['languages'] = [language] self.connect('destroy', main_quit) self.show_all()
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_("Adjust System Date & Time")) # FIXME self.set_keep_above(True) try: self.set_icon(IconTheme.get_default().load_icon( icon_name = "preferences-system-time", size = 32, flags = 0, )) except Exception: pass # render_icon: Deprecated since version 3.0: Use Gtk.Widget.render_icon_pixbuf() instead. # render_icon_pixbuf: Deprecated since version 3.10: Use Gtk.IconTheme.load_icon() instead. ######### self.buttonCancel = self.add_button(gtk.STOCK_CANCEL, 0) #self.buttonCancel.connect("clicked", lambda w: sys.exit(0)) self.buttonSet = self.add_button(_("Set System Time"), 1) #self.buttonSet.connect("clicked", self.setSysTimeClicked) ######### hbox = gtk.HBox() self.label_cur = gtk.Label(label=_("Current:")) pack(hbox, self.label_cur) pack(self.vbox, hbox) ######### hbox = gtk.HBox() self.radioMan = gtk.RadioButton.new_with_mnemonic( group=None, label=_("Set _Manully:"), ) self.radioMan.connect("clicked", self.radioManClicked) pack(hbox, self.radioMan) pack(self.vbox, hbox) ###### vb = gtk.VBox() sg = gtk.SizeGroup(mode=gtk.SizeGroupMode.HORIZONTAL) ### hbox = gtk.HBox() ## l = gtk.Label() l.set_property("width-request", self.xpad) pack(hbox, l) ## self.ckeckbEditTime = gtk.CheckButton.new_with_mnemonic(_("Edit _Time")) self.editTime = False self.ckeckbEditTime.connect("clicked", self.ckeckbEditTimeClicked) pack(hbox, self.ckeckbEditTime) sg.add_widget(self.ckeckbEditTime) self.timeInput = TimeButton() ## ??????? options pack(hbox, self.timeInput) pack(vb, hbox) ### hbox = gtk.HBox() ## l = gtk.Label() l.set_property("width-request", self.xpad) pack(hbox, l) ## self.ckeckbEditDate = gtk.CheckButton.new_with_mnemonic(_("Edit _Date")) self.editDate = False self.ckeckbEditDate.connect("clicked", self.ckeckbEditDateClicked) pack(hbox, self.ckeckbEditDate) sg.add_widget(self.ckeckbEditDate) self.dateInput = DateButton() ## ??????? options pack(hbox, self.dateInput) pack(vb, hbox) ### pack(self.vbox, vb, 0, 0, 10)#????? self.vboxMan = vb ###### hbox = gtk.HBox() self.radioNtp = gtk.RadioButton.new_with_mnemonic_from_widget( radio_group_member=self.radioMan, label=_("Set from _NTP:"), ) self.radioNtp.connect("clicked", self.radioNtpClicked) pack(hbox, self.radioNtp) pack(self.vbox, hbox) ### hbox = gtk.HBox() ## l = gtk.Label() l.set_property("width-request", self.xpad) pack(hbox, l) ## pack(hbox, gtk.Label(label=_("Server:") + " ")) combo = gtk.ComboBoxText.new_with_entry() combo.get_child().connect("changed", self.updateSetButtonSensitive) pack(hbox, combo, 1, 1) self.ntpServerEntry = combo.get_child() for s in ui.ntpServers: combo.append_text(s) combo.set_active(0) self.hboxNtp = hbox pack(self.vbox, hbox) ###### self.radioManClicked() #self.radioNtpClicked() self.ckeckbEditTimeClicked() self.ckeckbEditDateClicked() ###### self.updateTimes() self.vbox.show_all()
# this work to /opt /usr /usr/local prefixes if exists(join(bin_path, share_path)): return join(bin_path, share_path) if exists(join(bin_path, icons_path)): return join(bin_path, icons_path) bin_path = split(bin_path)[0] ICON_PATH = get_path() if ICON_PATH: icon_16 = Pixbuf.new_from_file_at_scale(ICON_PATH, 16, 16, True) icon_32 = Pixbuf.new_from_file_at_scale(ICON_PATH, 32, 32, True) icon_48 = Pixbuf.new_from_file_at_scale(ICON_PATH, 48, 48, True) icon_64 = Pixbuf.new_from_file_at_scale(ICON_PATH, 64, 64, True) icon_128 = Pixbuf.new_from_file_at_scale(ICON_PATH, 128, 128, True) else: from gi.repository.Gtk import IconTheme from gi.repository.GLib import log_default_handler, LogLevelFlags log_default_handler(None, LogLevelFlags.LEVEL_FATAL, "Formiko icon not found", 0) icon_theme = IconTheme.get_default() icon_16 = icon_theme.load_icon("text-editor-symbolic", 16, 0) icon_32 = icon_theme.load_icon("text-editor-symbolic", 32, 0) icon_48 = icon_theme.load_icon("text-editor-symbolic", 48, 0) icon_64 = icon_theme.load_icon("text-editor-symbolic", 64, 0) icon_128 = icon_theme.load_icon("text-editor-symbolic", 128, 0) icon_list = [icon_16, icon_32, icon_48, icon_64, icon_128]
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_("Adjust System Date & Time")) # FIXME self.set_keep_above(True) self.set_icon(IconTheme.get_default().load_icon( icon_name = "preferences-system-time", size = 32, flags = 0, )) # render_icon: Deprecated since version 3.0: Use Gtk.Widget.render_icon_pixbuf() instead. # render_icon_pixbuf: Deprecated since version 3.10: Use Gtk.IconTheme.load_icon() instead. ######### self.buttonCancel = self.add_button(gtk.STOCK_CANCEL, 0) #self.buttonCancel.connect("clicked", lambda w: sys.exit(0)) self.buttonSet = self.add_button(_("Set System Time"), 1) #self.buttonSet.connect("clicked", self.setSysTimeClicked) ######### hbox = gtk.HBox() self.label_cur = gtk.Label(label=_("Current:")) pack(hbox, self.label_cur) pack(self.vbox, hbox) ######### hbox = gtk.HBox() self.radioMan = gtk.RadioButton.new_with_mnemonic( group=None, label=_("Set _Manully:"), ) self.radioMan.connect("clicked", self.radioManClicked) pack(hbox, self.radioMan) pack(self.vbox, hbox) ###### vb = gtk.VBox() sg = gtk.SizeGroup(mode=gtk.SizeGroupMode.HORIZONTAL) ### hbox = gtk.HBox() ## l = gtk.Label() l.set_property("width-request", self.xpad) pack(hbox, l) ## self.ckeckbEditTime = gtk.CheckButton.new_with_mnemonic(_("Edit _Time")) self.editTime = False self.ckeckbEditTime.connect("clicked", self.ckeckbEditTimeClicked) pack(hbox, self.ckeckbEditTime) sg.add_widget(self.ckeckbEditTime) self.timeInput = TimeButton() ## ??????? options pack(hbox, self.timeInput) pack(vb, hbox) ### hbox = gtk.HBox() ## l = gtk.Label() l.set_property("width-request", self.xpad) pack(hbox, l) ## self.ckeckbEditDate = gtk.CheckButton.new_with_mnemonic(_("Edit _Date")) self.editDate = False self.ckeckbEditDate.connect("clicked", self.ckeckbEditDateClicked) pack(hbox, self.ckeckbEditDate) sg.add_widget(self.ckeckbEditDate) self.dateInput = DateButton() ## ??????? options pack(hbox, self.dateInput) pack(vb, hbox) ### pack(self.vbox, vb, 0, 0, 10)#????? self.vboxMan = vb ###### hbox = gtk.HBox() self.radioNtp = gtk.RadioButton.new_with_mnemonic_from_widget( radio_group_member=self.radioMan, label=_("Set from _NTP:"), ) self.radioNtp.connect("clicked", self.radioNtpClicked) pack(hbox, self.radioNtp) pack(self.vbox, hbox) ### hbox = gtk.HBox() ## l = gtk.Label() l.set_property("width-request", self.xpad) pack(hbox, l) ## pack(hbox, gtk.Label(label=_("Server:") + " ")) combo = gtk.ComboBoxText.new_with_entry() combo.get_child().connect("changed", self.updateSetButtonSensitive) pack(hbox, combo, 1, 1) self.ntpServerEntry = combo.get_child() for s in ui.ntpServers: combo.append_text(s) combo.set_active(0) self.hboxNtp = hbox pack(self.vbox, hbox) ###### self.radioManClicked() #self.radioNtpClicked() self.ckeckbEditTimeClicked() self.ckeckbEditDateClicked() ###### self.updateTimes() self.vbox.show_all()
# this work to /opt /usr /usr/local prefixes if exists(join(bin_path, share_path)): return join(bin_path, share_path) if exists(join(bin_path, icons_path)): return join(bin_path, icons_path) bin_path = split(bin_path)[0] ICON_PATH = get_path() if ICON_PATH: icon_16 = Pixbuf.new_from_file_at_scale(ICON_PATH, 16, 16, True) icon_32 = Pixbuf.new_from_file_at_scale(ICON_PATH, 32, 32, True) icon_48 = Pixbuf.new_from_file_at_scale(ICON_PATH, 48, 48, True) icon_64 = Pixbuf.new_from_file_at_scale(ICON_PATH, 64, 64, True) icon_128 = Pixbuf.new_from_file_at_scale(ICON_PATH, 128, 128, True) else: from gi.repository.Gtk import IconTheme from gi.repository.GLib import log_default_handler, LogLevelFlags log_default_handler("Application", LogLevelFlags.LEVEL_ERROR, "Formiko icon not found", 0) icon_theme = IconTheme.get_default() icon_16 = icon_theme.load_icon("text-editor-symbolic", 16, 0) icon_32 = icon_theme.load_icon("text-editor-symbolic", 32, 0) icon_48 = icon_theme.load_icon("text-editor-symbolic", 48, 0) icon_64 = icon_theme.load_icon("text-editor-symbolic", 64, 0) icon_128 = icon_theme.load_icon("text-editor-symbolic", 128, 0) icon_list = [icon_16, icon_32, icon_48, icon_64, icon_128]