def set_icon(self, kind, filename): if kind == "icon": self.icon_entry.set_text(filename) else: self.icon_open_entry.set_text(filename) if filename == "": filenames = get_node_icon_filenames(self.node) filename = filenames[{"icon": 0, "icon_open": 1}[kind]] self.set_preview(kind, filename) # try to auto-set open icon filename if kind == "icon": if self.icon_open_entry.get_text().strip() == "": open_filename = guess_open_icon_filename(filename) if os.path.isabs(open_filename) and \ os.path.exists(open_filename): # do a full set self.set_icon("icon_open", open_filename) else: # just do preview if lookup_icon_filename(self.main_window.get_notebook(), open_filename): self.set_preview("icon_open", open_filename) else: self.set_preview("icon_open", filename)
def populate_iconlist(self, list, icons): for iconfile in icons: filename = lookup_icon_filename(self.main_window.get_notebook(), iconfile) if filename: try: pixbuf = keepnote.gui.get_pixbuf(filename) except GError: continue list.append((pixbuf, iconfile))
def populate_iconlist(self, list, icons): for iconfile in icons: filename = lookup_icon_filename(self.main_window.get_notebook(), iconfile) if filename: try: pixbuf = keepnote.gui.get_pixbuf(filename) except gobject.GError: continue list.append((pixbuf, iconfile))
def add_icon(self, iconfile): child = gtk.MenuItem("") child.remove(child.child) img = gtk.Image() iconfile2 = lookup_icon_filename(self._notebook, iconfile) img.set_from_file(iconfile2) child.add(img) child.child.show() child.show() child.connect("activate", lambda w: self.emit("set-icon", iconfile)) self.append_grid(child)
def set_preview(self, kind, filename): if os.path.isabs(filename): filename2 = filename else: filename2 = lookup_icon_filename(self.main_window.get_notebook(), filename) if kind == "icon": self.icon_image.set_from_file(filename2) else: self.icon_open_image.set_from_file(filename2)
def _get_actions(self): """Returns actions for view's UI""" return map(lambda x: Action(*x), [ ("treeview_popup", None, "", "", None, lambda w: None), ("listview_popup", None, "", "", None, lambda w: None), ("Copy Tree", gtk.STOCK_COPY, _("Copy _Tree"), "<control><shift>C", _("Copy entire tree"), lambda w: self.on_copy_tree()), ("New Page", gtk.STOCK_NEW, _("New _Page"), "<control>N", _("Create a new page"), lambda w: self.on_new_page(), "note-new.png"), ("New Child Page", gtk.STOCK_NEW, _("New _Child Page"), "<control><shift>N", _("Create a new child page"), lambda w: self.on_new_child_page(), "note-new.png"), ("New Folder", gtk.STOCK_DIRECTORY, _("New _Folder"), "<control><shift>M", _("Create a new folder"), lambda w: self.on_new_dir(), "folder-new.png"), ("Attach File", gtk.STOCK_ADD, _("_Attach File..."), "", _("Attach a file to the notebook"), lambda w: self._on_attach_file_menu()), ("Back", gtk.STOCK_GO_BACK, _("_Back"), "", None, lambda w: self.visit_history(-1)), ("Forward", gtk.STOCK_GO_FORWARD, _("_Forward"), "", None, lambda w: self.visit_history(1)), ("Go to Note", gtk.STOCK_JUMP_TO, _("Go to _Note"), "", None, lambda w: self.on_goto_node(None, None)), ("Go to Parent Note", gtk.STOCK_GO_BACK, _("Go to _Parent Note"), "<shift><alt>Left", None, lambda w: self.on_goto_parent_node()), ("Go to Next Note", gtk.STOCK_GO_DOWN, _("Go to Next N_ote"), "<alt>Down", None, lambda w: self.goto_next_node()), ("Go to Previous Note", gtk.STOCK_GO_UP, _("Go to _Previous Note"), "<alt>Up", None, lambda w: self.goto_prev_node()), ("Expand Note", gtk.STOCK_ADD, _("E_xpand Note"), "<alt>Right", None, lambda w: self.expand_node()), ("Collapse Note", gtk.STOCK_REMOVE, _("_Collapse Note"), "<alt>Left", None, lambda w: self.collapse_node()), ("Expand All Child Notes", gtk.STOCK_ADD, _("Expand _All Child Notes"), "<shift><alt>Right", None, lambda w: self.expand_node(True)), ("Collapse All Child Notes", gtk.STOCK_REMOVE, _("Collapse A_ll Child Notes"), "<shift><alt>Left", None, lambda w: self.collapse_node(True)), ("Go to Tree View", None, _("Go to _Tree View"), "<control>T", None, lambda w: self.goto_treeview()), ("Go to List View", None, _("Go to _List View"), "<control>Y", None, lambda w: self.goto_listview()), ("Go to Editor", None, _("Go to _Editor"), "<control>D", None, lambda w: self.goto_editor()), ("Delete Note", gtk.STOCK_DELETE, _("_Delete"), "", None, self.on_delete_node), ("Rename Note", gtk.STOCK_EDIT, _("_Rename"), "", None, lambda w: self._on_rename_node()), ("Change Note Icon", None, _("_Change Note Icon"), "", None, lambda w: None, lookup_icon_filename(None, u"folder-red.png")), ("Change Fg Color", None, _("Change _Fg Color")), ("Change Bg Color", None, _("Change _Bg Color")), ])