def check_instance(directory, uri_list=[]): """ Check if gtg is already running. If so, open the tasks whose ids are in the uri_list """ pidfile = os.path.join(directory, "gtg.pid") if not os.path.exists(pidfile): open(pidfile, "w").close() os.chmod(pidfile, 0600) # see if gtg is already running pid = open(pidfile, "r").readline() if pid: p = os.system("/bin/ps %s >/dev/null" % pid) p_name = os.popen("/bin/ps -f %s" % pid).read() if p == 0 and "gtg" in p_name: print _("gtg is already running!") try: d = dbus.SessionBus().get_object(CoreConfig.BUSNAME, CoreConfig.BUSINTERFACE) d.ShowTaskBrowser() # if the user has specified a task to open, do that for uri in uri_list: if uri.startswith("gtg://"): d.OpenTaskEditor(uri[6:]) raise SystemExit except dbus.exceptions.DBusException: # If we cant't connect to the interface (e.g. changed interface # between GTG versions), we won't do anything more raise SystemExit # write the pid file with open(pidfile, "w") as f: f.write(repr(os.getpid()))
def on_export_start(self, saving): """ Start generating a document. If saving == True, ask user where to store the document. Otherwise, open it afterwards. """ model = self.combo.get_model() active = self.combo.get_active() self.template = Template(model[active][0]) tasks = self.get_selected_tasks() if len(tasks) == 0: self.show_error_dialog(_("No task matches your criteria. " "Empty report can't be generated.")) return self.filename = None if saving: self.filename = self.choose_file() if self.filename is None: return self.save_button.set_sensitive(False) self.open_button.set_sensitive(False) try: self.template.generate(tasks, self.plugin_api, self.on_export_finished) except Exception as err: self.show_error_dialog( _("GTG could not generate the document: %s") % err) raise
def activate(self, plugin_api): self.plugin_api = plugin_api self.hamster = dbus.SessionBus().get_object('org.gnome.Hamster', '/org/gnome/Hamster') # add menu item if plugin_api.is_browser(): self.menu_item = gtk.MenuItem(_("Start task in Hamster")) self.menu_item.show_all() self.menu_item.connect('activate', self.browser_cb, plugin_api) plugin_api.add_menu_item(self.menu_item) # and button self.button.set_label(_("Start task in Hamster")) start_icon_widget = self.get_icon_widget(self.IMG_START_PATH) self.button.set_icon_widget(start_icon_widget) self.button.set_tooltip_text(self.TOOLTIP_TEXT_START_ACTIVITY) self.button.set_sensitive(False) self.button.connect('clicked', self.browser_cb, plugin_api) self.button.show() plugin_api.add_toolbar_item(self.button) plugin_api.set_active_selection_changed_callback( self.selection_changed) plugin_api.get_view_manager().connect('tasks-deleted', self.tasks_deleted) plugin_api.get_view_manager().connect('task-status-changed', self.task_status_changed) # set up preferences self.preference_dialog_init() self.preferences_load()
def on_export_start(self, saving): """ Start generating a document. If saving == True, ask user where to store the document. Otherwise, open it afterwards. """ model = self.combo.get_model() active = self.combo.get_active() self.template = Template(model[active][0]) tasks = self.get_selected_tasks() if len(tasks) == 0: self.show_error_dialog( _("No task matches your criteria. " "Empty report can't be generated.")) return self.filename = None if saving: self.filename = self.choose_file() if self.filename is None: return self.save_button.set_sensitive(False) self.open_button.set_sensitive(False) try: self.template.generate(tasks, self.plugin_api, self.on_export_finished) except Exception as err: self.show_error_dialog( _("GTG could not generate the document: %s") % err) raise
def active_tasks_treeview(self, tree): # Build the title/label/tags columns desc = self.common_desc_for_tasks(tree, "Tasks") # "startdate" column col_name = 'startdate' col = {} col['title'] = _("Start date") col['expandable'] = False col['resizable'] = False col['value'] = [str, self.task_sdate_column] col['order'] = 3 col['sorting_func'] = self.start_date_sorting desc[col_name] = col # 'duedate' column col_name = 'duedate' col = {} col['title'] = _("Due") col['expandable'] = False col['resizable'] = False col['value'] = [str, self.task_duedate_column] col['order'] = 4 col['sorting_func'] = self.due_date_sorting desc[col_name] = col # Returning the treeview treeview = self.build_task_treeview(tree, desc) treeview.set_sort_column('duedate') return treeview
def __set_default_values(self): """Configure the widget components with their initial default values""" # Disable some handlers while setting up the widget to avoid # interferences self.tn_cb.handler_block(self.tn_cb_clicked_hid) self.tn_entry.handler_block(self.tn_entry_clicked_hid) self.tag_icon_selector.handler_block(self.tis_selection_changed_hid) # Default icon markup = "<span size='small'>%s</span>" % _("Click To\nSet Icon") self.ti_bt_label.set_justify(gtk.JUSTIFY_CENTER) self.ti_bt_label.set_markup(markup) self.ti_bt_label.show() self.__set_icon(None) # Unselect any previously selected icon self.tag_icon_selector.unselect_icon() # Show in WV self.tn_cb.set_active(True) # Name entry self.tn_entry.set_text(_("Enter tag name here")) self.tn_entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, None) # Color selection self.tc_cc_colsel.unselect_color() # Custom colors self.custom_colors = self.config.get('custom_colors') if len(self.custom_colors) > 0: self.tc_cc_colsel.set_custom_colors(self.custom_colors) # Focus self.tn_entry.grab_focus() # Re-enable checkbutton handler_block self.tn_cb.handler_unblock(self.tn_cb_clicked_hid) self.tn_entry.handler_unblock(self.tn_entry_clicked_hid) self.tag_icon_selector.handler_unblock(self.tis_selection_changed_hid)
class Backend(GenericTomboy): ''' A simple class that adds some description to the GenericTomboy class. It's done this way since Tomboy and Gnote backends have different descriptions and Dbus addresses but the same backend behind them. ''' _general_description = { GenericBackend.BACKEND_NAME: "backend_gnote", GenericBackend.BACKEND_HUMAN_NAME: _("Gnote"), GenericBackend.BACKEND_AUTHORS: ["Luca Invernizzi"], GenericBackend.BACKEND_TYPE: GenericBackend.TYPE_READWRITE, GenericBackend.BACKEND_DESCRIPTION: _("This service can synchronize all or part of your Gnote" " notes in GTG. If you decide it would be handy to" " have one of your notes in your TODO list, just tag it " "with the tag you have chosen (you'll configure it later" "), and it will appear in GTG."), } _static_parameters = { GenericBackend.KEY_ATTACHED_TAGS: { GenericBackend.PARAM_TYPE: GenericBackend.TYPE_LIST_OF_STRINGS, GenericBackend.PARAM_DEFAULT_VALUE: ["@GTG-Gnote"] }, } _BUS_ADDRESS = ("org.gnome.Gnote", "/org/gnome/Gnote/RemoteControl", "org.gnome.Gnote.RemoteControl")
def test_parse_fuzzy_dates_str(self): """ Print fuzzy dates in localized version """ self.assertEqual(str(Date.parse("now")), _("now")) self.assertEqual(str(Date.parse("soon")), _("soon")) self.assertEqual(str(Date.parse("later")), _("someday")) self.assertEqual(str(Date.parse("someday")), _("someday")) self.assertEqual(str(Date.parse("")), "")
def set_error_code(self, error_code): ''' Sets this infobar to show an error to the user @param error_code: the code of the error to show. Error codes are listed in BackendSignals ''' self._populate() self.connect("response", self._on_error_response) backend_name = self.backend.get_human_name() if error_code == BackendSignals.ERRNO_AUTHENTICATION: self.set_message_type(gtk.MESSAGE_ERROR) self.label.set_markup(self.AUTHENTICATION_MESSAGE % backend_name) self.add_button(_('Configure synchronization service'), gtk.RESPONSE_ACCEPT) self.add_button(_('Ignore'), gtk.RESPONSE_CLOSE) elif error_code == BackendSignals.ERRNO_NETWORK: if not is_connection_up(): return self.set_message_type(gtk.MESSAGE_WARNING) self.label.set_markup(self.NETWORK_MESSAGE % backend_name) # FIXME: use gtk stock button instead self.add_button(_('Ok'), gtk.RESPONSE_CLOSE) elif error_code == BackendSignals.ERRNO_DBUS: self.set_message_type(gtk.MESSAGE_WARNING) self.label.set_markup(self.DBUS_MESSAGE % backend_name) self.add_button(_('Ok'), gtk.RESPONSE_CLOSE) self.show_all()
def noteChosen(self, widget=None, data=None): tomboy = self.getTomboyObject() if tomboy is None: return supposed_title = self.combobox_entry.get_text() if filter(lambda x: tomboy.GetNoteTitle(x) == supposed_title, tomboy.ListAllNotes()) == []: self.label_caption.set_text(_("That note does not exist!")) dialog = gtk.MessageDialog(parent=self.dialog, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format=_("That note does not \ exist. Do you want to create a new one?")) response = dialog.run() dialog.destroy() if response == gtk.RESPONSE_YES: tomboy.CreateNamedNote(supposed_title) else: return # note insertion mark_start = self.textview.buff.get_insert() iter_start = self.textview.buff.get_iter_at_mark(mark_start) tomboy_widget = self.widgetCreate(supposed_title) anchor = self.textviewInsertWidget(tomboy_widget, iter_start) self.anchors.append(anchor) self.dialog.destroy()
def __init_gtk(self): menu = Gtk.Menu() # add "new task" # FIXME test this label... is it needed? play with it a little menuItem = Gtk.MenuItem(label=_('Add New Task')) menuItem.connect('activate', self.__open_task) menu.append(menuItem) # Show Main Window show_browser = Gtk.MenuItem(label=_('Show Main Window')) show_browser.connect('activate', self.__show_browser) menu.append(show_browser) # separator (it's intended to be after show_all) # separator should be shown only when having tasks self.__task_separator = Gtk.SeparatorMenuItem() menu.append(self.__task_separator) menu_top_length = len(menu) menu.append(Gtk.SeparatorMenuItem()) # quit item menuItem = Gtk.MenuItem(label=_('Quit')) menuItem.connect('activate', self.__view_manager.close_browser) menu.append(menuItem) menu.show_all() self.__task_separator.hide() self.__tasks_menu = SortedLimitedMenu(self.MAX_ITEMS, menu, menu_top_length) self._indicator.activate(self.__show_browser, menu)
def __build_menu(self): """Build up the widget""" # Reset the widget for i in self: self.remove(i) if i not in self.custom_menuitems: i.destroy() if self.tag is not None: # Color chooser FIXME: SHOULD BECOME A COLOR PICKER self.mi_cc = Gtk.MenuItem() self.mi_cc.set_label(_("Edit Tag...")) self.mi_ctag = Gtk.MenuItem() self.mi_ctag.set_label(_("Generate Color")) self.append(self.mi_cc) self.append(self.mi_ctag) self.mi_cc.connect('activate', self.on_mi_cc_activate) self.mi_ctag.connect('activate', self.on_mi_ctag_activate) for custom_mi in self.custom_menuitems: self.append(custom_mi) if self.tag.is_search_tag(): self.mi_del = Gtk.MenuItem() self.mi_del.set_label(_("Delete")) self.append(self.mi_del) self.mi_del.connect('activate', self.on_mi_del_activate) # Make it visible self.show_all()
def strtodate(stri) : if stri == _("now") or stri == "now": return NOW elif stri == _("soon") or stri == "soon": return SOON elif stri == _("later") or stri == "later": return LATER toreturn = None zedate = [] if stri : if '-' in stri : zedate = stri.split('-') elif '/' in stri : zedate = stri.split('/') if len(zedate) == 3 : y = zedate[0] m = zedate[1] d = zedate[2] if y.isdigit() and m.isdigit() and d.isdigit() : yy = int(y) mm = int(m) dd = int(d) # we catch exceptions here try : toreturn = date(yy,mm,dd) except ValueError: toreturn = None if not toreturn: return no_date else: return RealDate(toreturn)
def noteChosen(self, widget=None, data=None): tomboy = self.getTomboyObject() if tomboy is None: return supposed_title = self.combobox_entry.get_text() if not self._node_exist(tomboy, supposed_title): self.label_caption.set_text(_("That note does not exist!")) DIALOG_DESTROY_WITH_PARENT = Gtk.DialogFlags.DESTROY_WITH_PARENT message = _( "That note does not exist. Do you want to create a new one?") dialog = Gtk.MessageDialog( parent=self.dialog, flags=DIALOG_DESTROY_WITH_PARENT, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO, message_format=message, ) response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.YES: tomboy.CreateNamedNote(supposed_title) else: return # note insertion mark_start = self.textview.buff.get_insert() iter_start = self.textview.buff.get_iter_at_mark(mark_start) tomboy_widget = self.widgetCreate(supposed_title) anchor = self.textviewInsertWidget(tomboy_widget, iter_start) self.anchors.append(anchor) self.dialog.destroy()
def active_tasks_treeview(self, tree): # Build the title/label/tags columns desc = self.common_desc_for_tasks(tree) # "startdate" column col_name = 'startdate' col = {} col['title'] = _("Start date") col['expandable'] = False col['resizable'] = False col['value'] = [str, self.task_sdate_column] col['order'] = 3 col['sorting_func'] = self.start_date_sorting desc[col_name] = col # 'duedate' column col_name = 'duedate' col = {} col['title'] = _("Due") col['expandable'] = False col['resizable'] = False col['value'] = [str, self.task_duedate_column] col['order'] = 4 col['sorting_func'] = self.due_date_sorting desc[col_name] = col # Returning the treeview treeview = self.build_task_treeview(tree, desc) treeview.set_sort_column('duedate') return treeview
def test_parse_local_fuzzy_dates(self): """ Parse fuzzy dates in their localized version """ self.assertEqual(Date.parse(_("now")), Date.now()) self.assertEqual(Date.parse(_("soon")), Date.soon()) self.assertEqual(Date.parse(_("later")), Date.someday()) self.assertEqual(Date.parse(_("someday")), Date.someday()) self.assertEqual(Date.parse(""), Date.no_date())
def __init_gtk(self): menu = gtk.Menu() # add "new task" menuItem = gtk.MenuItem(_('Add _New Task')) menuItem.connect('activate', self.__open_task) menu.append(menuItem) # Show Main Window show_browser = gtk.MenuItem(_('_Show Main Window')) show_browser.connect('activate', self.__show_browser) menu.append(show_browser) # separator (it's intended to be after show_all) # separator should be shown only when having tasks self.__task_separator = gtk.SeparatorMenuItem() menu.append(self.__task_separator) menu_top_length = len(menu) menu.append(gtk.SeparatorMenuItem()) # quit item menuItem = gtk.MenuItem(_('_Quit')) menuItem.connect('activate', self.__view_manager.close_browser) menu.append(menuItem) menu.show_all() self.__task_separator.hide() self.__tasks_menu = SortedLimitedMenu(self.MAX_ITEMS, menu, menu_top_length) self._indicator.activate(self.__show_browser, menu)
def check_instance(directory, uri_list = []): """ Check if gtg is already running. If so, open the tasks whose ids are in the uri_list """ pidfile = os.path.join(directory, "gtg.pid") if not os.path.exists(pidfile): open(pidfile, "w").close() os.chmod(pidfile, 0600) #see if gtg is already running pid = open(pidfile, "r").readline() if pid: p = os.system("/bin/ps %s >/dev/null" % pid) p_name = os.popen("/bin/ps -f %s" % pid).read() if p == 0 and "gtg" in p_name: print _("gtg is already running!") d=dbus.SessionBus().get_object(CoreConfig.BUSNAME,\ CoreConfig.BUSINTERFACE) d.show_task_browser() #if the user has specified a task to open, do that for uri in uri_list: if uri.startswith("gtg://"): d.open_task_editor(uri[6:]) raise SystemExit #write the pid file with open(pidfile, "w") as f: f.write(`os.getpid()`)
def activate(self, plugin_api): self.plugin_api = plugin_api self.hamster = dbus.SessionBus().get_object('org.gnome.Hamster', '/org/gnome/Hamster') # add menu item if plugin_api.is_browser(): self.menu_item = Gtk.MenuItem(_("Start task in Hamster")) self.menu_item.show_all() self.menu_item.connect('activate', self.browser_cb, plugin_api) plugin_api.add_menu_item(self.menu_item) # and button self.button.set_label(_("Start task in Hamster")) start_icon_widget = self.get_icon_widget(self.IMG_START_PATH) self.button.set_icon_widget(start_icon_widget) self.button.set_tooltip_text(self.TOOLTIP_TEXT_START_ACTIVITY) self.button.set_sensitive(False) self.button.connect('clicked', self.browser_cb, plugin_api) self.button.show() plugin_api.add_toolbar_item(self.button) plugin_api.set_active_selection_changed_callback( self.selection_changed) plugin_api.get_view_manager().connect('tasks-deleted', self.tasks_deleted) plugin_api.get_view_manager().connect('task-status-changed', self.task_status_changed) # set up preferences self.preference_dialog_init() self.preferences_load()
def __build_window(self): """Build up the widget""" # toplevel widget self.top_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.top_vbox) # header line: icon, grid with name and "hide in wv" #FIXME self.hdr_align = Gtk.Alignment() self.top_vbox.pack_start(self.hdr_align, True, True, 0) self.hdr_align.set_padding(0, 25, 0, 0) self.hdr_box = Gtk.Box() self.hdr_align.add(self.hdr_box) self.hdr_box.set_spacing(10) # Button to tag icon selector self.ti_bt = Gtk.Button() self.ti_bt_label = Gtk.Label() self.ti_bt.add(self.ti_bt_label) self.hdr_box.pack_start(self.ti_bt, True, True, 0) self.ti_bt.set_size_request(64, 64) self.ti_bt.set_relief(Gtk.ReliefStyle.HALF) # vbox for tag name and hid in WV self.tp_grid = Gtk.Grid() self.hdr_box.pack_start(self.tp_grid, True, True, 0) self.tp_grid.set_column_spacing(5) self.tn_entry_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0) self.tp_grid.add(self.tn_entry_lbl_align) self.tn_entry_lbl = Gtk.Label() self.tn_entry_lbl.set_markup("<span weight='bold'>%s</span>" % _("Name : ")) self.tn_entry_lbl_align.add(self.tn_entry_lbl) self.tn_entry = Gtk.Entry() self.tn_entry.set_width_chars(20) self.tp_grid.attach(self.tn_entry, 1, 0, 1, 1) self.tn_cb_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0) self.tp_grid.attach(self.tn_cb_lbl_align, 0, 1, 1, 1) self.tn_cb_lbl = Gtk.Label(label=_("Show Tag in Work View :")) self.tn_cb_lbl_align.add(self.tn_cb_lbl) self.tn_cb = Gtk.CheckButton() self.tp_grid.attach(self.tn_cb, 1, 1, 1, 1) # Tag color self.tc_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.top_vbox.pack_start(self.tc_vbox, True, True, 0) self.tc_label_align = Gtk.Alignment() self.tc_vbox.pack_start(self.tc_label_align, True, True, 0) self.tc_label_align.set_padding(0, 0, 0, 0) self.tc_label = Gtk.Label() self.tc_label_align.add(self.tc_label) self.tc_label.set_markup("<span weight='bold'>%s</span>" % _("Select Tag Color:")) self.tc_label.set_alignment(0, 0.5) # Tag color chooser self.tc_cc_align = Gtk.Alignment.new(0.5, 0.5, 0, 0) self.tc_vbox.pack_start(self.tc_cc_align, True, True, 0) self.tc_cc_align.set_padding(15, 15, 10, 10) self.tc_cc_colsel = SimpleColorSelector() #self.tc_cc_colsel = Gtk.ColorChooserWidget() self.tc_cc_align.add(self.tc_cc_colsel) # Icon selector self.tag_icon_selector = TagIconSelector()
def __build_window(self): """Build up the widget""" # toplevel widget self.top_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.top_vbox) # header line: icon, grid with name and "hide in wv" #FIXME self.hdr_align = Gtk.Alignment() self.top_vbox.pack_start(self.hdr_align, True, True, 0) self.hdr_align.set_padding(0, 25, 0, 0) self.hdr_box = Gtk.Box() self.hdr_align.add(self.hdr_box) self.hdr_box.set_spacing(10) # Button to tag icon selector self.ti_bt = Gtk.Button() self.ti_bt_label = Gtk.Label() self.ti_bt.add(self.ti_bt_label) self.hdr_box.pack_start(self.ti_bt, True, True, 0) self.ti_bt.set_size_request(64, 64) self.ti_bt.set_relief(Gtk.ReliefStyle.HALF) # vbox for tag name and hid in WV self.tp_grid = Gtk.Grid() self.hdr_box.pack_start(self.tp_grid, True, True, 0) self.tp_grid.set_column_spacing(5) self.tn_entry_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0) self.tp_grid.add(self.tn_entry_lbl_align) self.tn_entry_lbl = Gtk.Label() self.tn_entry_lbl.set_markup("<span weight='bold'>%s</span>" % _("Name : ")) self.tn_entry_lbl_align.add(self.tn_entry_lbl) self.tn_entry = Gtk.Entry() self.tn_entry.set_width_chars(20) self.tp_grid.attach(self.tn_entry, 1, 0, 1, 1) self.tn_cb_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0) self.tp_grid.attach(self.tn_cb_lbl_align, 0, 1, 1, 1) self.tn_cb_lbl = Gtk.Label(label=_("Show Tag in Work View :")) self.tn_cb_lbl_align.add(self.tn_cb_lbl) self.tn_cb = Gtk.CheckButton() self.tp_grid.attach(self.tn_cb, 1, 1, 1, 1) # Tag color self.tc_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.top_vbox.pack_start(self.tc_vbox, True, True, 0) self.tc_label_align = Gtk.Alignment() self.tc_vbox.pack_start(self.tc_label_align, True, True, 0) self.tc_label_align.set_padding(0, 0, 0, 0) self.tc_label = Gtk.Label() self.tc_label_align.add(self.tc_label) self.tc_label.set_markup( "<span weight='bold'>%s</span>" % _("Select Tag Color:")) self.tc_label.set_alignment(0, 0.5) # Tag color chooser self.tc_cc_align = Gtk.Alignment.new(0.5, 0.5, 0, 0) self.tc_vbox.pack_start(self.tc_cc_align, True, True, 0) self.tc_cc_align.set_padding(15, 15, 10, 10) #self.tc_cc_colsel = SimpleColorSelector() self.tc_cc_colsel = Gtk.ColorChooserWidget() self.tc_cc_align.add(self.tc_cc_colsel) # Icon selector self.tag_icon_selector = TagIconSelector()
def test_get_canonical_date(self): ''' Tests for "get_canonical_date" ''' known_values = (("1985-03-29", "1985-03-29"), ("now", _("now")), ("soon", _("soon")), ("later", _("later")), ("", "")) for value, result in known_values: date = get_canonical_date(value) self.assertEqual(date.__str__(), result)
def __build_window(self): """Build up the widget""" # toplevel widget self.top_vbox = gtk.VBox() self.add(self.top_vbox) # header line: icon, table with name and "hide in wv" self.hdr_align = gtk.Alignment() self.top_vbox.pack_start(self.hdr_align) self.hdr_align.set_padding(0, 25, 0, 0) self.hdr_hbox = gtk.HBox() self.hdr_align.add(self.hdr_hbox) self.hdr_hbox.set_spacing(10) # Button to tag icon selector self.ti_bt = gtk.Button() self.ti_bt_label = gtk.Label() self.ti_bt.add(self.ti_bt_label) self.hdr_hbox.pack_start(self.ti_bt) self.ti_bt.set_size_request(64, 64) self.ti_bt.set_relief(gtk.RELIEF_HALF) # vbox for tag name and hid in WV self.tp_table = gtk.Table(2, 2) self.hdr_hbox.pack_start(self.tp_table) self.tp_table.set_col_spacing(0, 5) self.tn_entry_lbl_align = gtk.Alignment(0, 0.5) self.tp_table.attach(self.tn_entry_lbl_align, 0, 1, 0, 1) self.tn_entry_lbl = gtk.Label() self.tn_entry_lbl.set_markup("<span weight='bold'>%s</span>" % _("Name : ")) self.tn_entry_lbl_align.add(self.tn_entry_lbl) self.tn_entry = gtk.Entry() self.tp_table.attach(self.tn_entry, 1, 2, 0, 1) self.tn_entry.set_width_chars(20) self.tn_cb_lbl_align = gtk.Alignment(0, 0.5) self.tp_table.attach(self.tn_cb_lbl_align, 0, 1, 1, 2) self.tn_cb_lbl = gtk.Label(_("Show Tag in Work View :")) self.tn_cb_lbl_align.add(self.tn_cb_lbl) self.tn_cb = gtk.CheckButton() self.tp_table.attach(self.tn_cb, 1, 2, 1, 2) # Tag color self.tc_vbox = gtk.VBox() self.top_vbox.pack_start(self.tc_vbox) self.tc_label_align = gtk.Alignment() self.tc_vbox.pack_start(self.tc_label_align) self.tc_label_align.set_padding(0, 0, 0, 0) self.tc_label = gtk.Label() self.tc_label_align.add(self.tc_label) self.tc_label.set_markup( "<span weight='bold'>%s</span>" % _("Select Tag Color:")) self.tc_label.set_alignment(0, 0.5) # Tag color chooser self.tc_cc_align = gtk.Alignment(0.5, 0.5, 0, 0) self.tc_vbox.pack_start(self.tc_cc_align) self.tc_cc_align.set_padding(15, 15, 10, 10) self.tc_cc_colsel = SimpleColorSelector() self.tc_cc_align.add(self.tc_cc_colsel) # Icon selector self.tag_icon_selector = TagIconSelector()
def __build_window(self): """Build up the widget""" # toplevel widget self.top_vbox = gtk.VBox() self.add(self.top_vbox) # header line: icon, table with name and "hide in wv" self.hdr_align = gtk.Alignment() self.top_vbox.pack_start(self.hdr_align) self.hdr_align.set_padding(0, 25, 0, 0) self.hdr_hbox = gtk.HBox() self.hdr_align.add(self.hdr_hbox) self.hdr_hbox.set_spacing(10) # Button to tag icon selector self.ti_bt = gtk.Button() self.ti_bt_label = gtk.Label() self.ti_bt.add(self.ti_bt_label) self.hdr_hbox.pack_start(self.ti_bt) self.ti_bt.set_size_request(64, 64) self.ti_bt.set_relief(gtk.RELIEF_HALF) # vbox for tag name and hid in WV self.tp_table = gtk.Table(2, 2) self.hdr_hbox.pack_start(self.tp_table) self.tp_table.set_col_spacing(0, 5) self.tn_entry_lbl_align = gtk.Alignment(0, 0.5) self.tp_table.attach(self.tn_entry_lbl_align, 0, 1, 0, 1) self.tn_entry_lbl = gtk.Label() self.tn_entry_lbl.set_markup("<span weight='bold'>%s</span>" % _("Name : ")) self.tn_entry_lbl_align.add(self.tn_entry_lbl) self.tn_entry = gtk.Entry() self.tp_table.attach(self.tn_entry, 1, 2, 0, 1) self.tn_entry.set_width_chars(20) self.tn_cb_lbl_align = gtk.Alignment(0, 0.5) self.tp_table.attach(self.tn_cb_lbl_align, 0, 1, 1, 2) self.tn_cb_lbl = gtk.Label(_("Show Tag in Work View :")) self.tn_cb_lbl_align.add(self.tn_cb_lbl) self.tn_cb = gtk.CheckButton() self.tp_table.attach(self.tn_cb, 1, 2, 1, 2) # Tag color self.tc_vbox = gtk.VBox() self.top_vbox.pack_start(self.tc_vbox) self.tc_label_align = gtk.Alignment() self.tc_vbox.pack_start(self.tc_label_align) self.tc_label_align.set_padding(0, 0, 0, 0) self.tc_label = gtk.Label() self.tc_label_align.add(self.tc_label) self.tc_label.set_markup("<span weight='bold'>%s</span>" % _("Select Tag Color:")) self.tc_label.set_alignment(0, 0.5) # Tag color chooser self.tc_cc_align = gtk.Alignment(0.5, 0.5, 0, 0) self.tc_vbox.pack_start(self.tc_cc_align) self.tc_cc_align.set_padding(15, 15, 10, 10) self.tc_cc_colsel = SimpleColorSelector() self.tc_cc_align.add(self.tc_cc_colsel) # Icon selector self.tag_icon_selector = TagIconSelector()
def get_tags_tree(self, req): """This create a liblarch tree suitable for tags, including the all_tags_tag and notag_tag. """ tagtree = Tree() ### building the initial tags # Build the "all tasks tag" alltag = Tag(CoreConfig.ALLTASKS_TAG, req=req) alltag.set_attribute("special", "all") alltag.set_attribute("label", "<span weight='bold'>%s</span>" % _("All tasks")) alltag.set_attribute("icon", "gtg-tags-all") alltag.set_attribute("order", 0) tagtree.add_node(alltag) p = {} self.tasktree.add_filter(CoreConfig.ALLTASKS_TAG, self.alltag, parameters=p) # Build the "without tag tag" notag_tag = Tag(CoreConfig.NOTAG_TAG, req=req) notag_tag.set_attribute("special", "notag") notag_tag.set_attribute("label", "<span weight='bold'>%s</span>" % _("Tasks with no tags")) notag_tag.set_attribute("icon", "gtg-tags-none") notag_tag.set_attribute("order", 2) tagtree.add_node(notag_tag) p = {} self.tasktree.add_filter(CoreConfig.NOTAG_TAG, self.notag, parameters=p) # Build the search tag search_tag = Tag(CoreConfig.SEARCH_TAG, req=req) search_tag.set_attribute("special", "search") search_tag.set_attribute("label", "<span weight='bold'>%s</span>" % _("Search")) search_tag.set_attribute("icon", "search") search_tag.set_attribute("order", 1) tagtree.add_node(search_tag) p = {} self.tasktree.add_filter(CoreConfig.SEARCH_TAG, search_filter, parameters=p) # Build the separator sep_tag = Tag(CoreConfig.SEP_TAG, req=req) sep_tag.set_attribute("special", "sep") sep_tag.set_attribute("order", 3) tagtree.add_node(sep_tag) #### Filters tagtree.add_filter("activetag", self.actively_used_tag) tagtree.add_filter("usedtag", self.used_tag) activeview = tagtree.get_viewtree(name="activetags", refresh=False) activeview.apply_filter("activetag") # This view doesn't seem to be used. So it's not useful to build it now # usedview = tagtree.get_viewtree(name='usedtags',refresh=False) # usedview.apply_filter('usedtag') self.tagtree = tagtree self.tagtree_loaded = True return tagtree
def export_execute_with_ui(self, document_ready): if not self.load_template(): self.show_error_dialog(_("Template not found")) return False # REMOVE ME try: self.export_generate(document_ready) except Exception, e: self.show_error_dialog(_("Could not generate the document: %s") % e) return False
def _build_issue_text(self, issue_dic): ''' Creates the text that describes a issue ''' text = _("Reported by: ") + issue_dic["reporter"] + '\n' text += _("Link to issue: ") + \ self._parameters['service-url'] + '/view.php?id=%s' % \ (issue_dic["number"]) + '\n' text += '\n' + issue_dic["text"] return text
def refresh_sync_button(self): ''' Refreshes the state of the button that enables the backend ''' self.sync_button.set_sensitive(not self.backend.is_default()) if self.backend.is_enabled(): label = _("Disable syncing") else: label = _("Enable syncing") self.sync_button.set_label(label)
def refresh_sync_status_label(self): ''' Refreshes the Gtk.Label that shows the current state of this backend ''' if self.backend.is_default(): label = _("This is the default synchronization service") else: if self.backend.is_enabled(): label = _("Syncing is enabled.") else: label = _('Syncing is <span color="red">disabled</span>.') self.sync_status_label.set_markup(label)
def set_complex_title(self,text,tags=[]): if tags: assert(isinstance(tags[0], str)) due_date = no_date defer_date = no_date if text: # Get tags in the title #NOTE: the ?: tells regexp that the first one is # a non-capturing group, so it must not be returned # to findall. http://www.amk.ca/python/howto/regex/regex.html # ~~~~Invernizzi for match in re.findall(r'(?:^|[\s])(@\w+)', text): tags.append(match) # Remove the @ #text =text.replace(match,match[1:],1) # Get attributes regexp = r'([\s]*)([\w-]+):([^\s]+)' for spaces, attribute, args in re.findall(regexp, text): valid_attribute = True if attribute.lower() in ["tags", "tag"] or \ attribute.lower() in [_("tags"), _("tag")]: for tag in args.split(","): if not tag.startswith("@") : tag = "@"+tag tags.append(tag) elif attribute.lower() == "defer" or \ attribute.lower() == _("defer"): defer_date = get_canonical_date(args) if not defer_date: valid_attribute = False elif attribute.lower() == "due" or \ attribute.lower() == _("due"): due_date = get_canonical_date(args) if not due_date: valid_attribute = False else: # attribute is unknown valid_attribute = False if valid_attribute: # if the command is valid we have to remove it # from the task title text = \ text.replace("%s%s:%s" % (spaces, attribute, args), "") # # Create the new task # task = self.req.new_task(tags=[t.get_name() for t in tags], newtask=True) for t in tags: self.add_tag(t) if text != "": self.set_title(text.strip()) self.set_to_keep() self.set_due_date(due_date) self.set_start_date(defer_date)
def set_complex_title(self, text, tags=[]): if tags: assert (isinstance(tags[0], str)) due_date = Date.no_date() defer_date = Date.no_date() if text: # Get tags in the title for match in extract_tags_from_text(text): tags.append(match) # Get attributes regexp = r'([\s]*)([\w-]+):\s*([^\s]+)' matches = re.findall(regexp, text, re.UNICODE) for spaces, attribute, args in matches: valid_attribute = True if attribute.lower() in ["tags", _("tags"), "tag", _("tag")]: for tag in args.split(","): if not tag.strip() == "@" and not tag.strip() == "": if not tag.startswith("@"): tag = "@" + tag tags.append(tag) elif attribute.lower() in [ "defer", _("defer"), "start", _("start") ]: try: defer_date = Date.parse(args) except ValueError: valid_attribute = False elif attribute.lower() == "due" or \ attribute.lower() == _("due"): try: due_date = Date.parse(args) except: valid_attribute = False else: # attribute is unknown valid_attribute = False if valid_attribute: # remove valid attribute from the task title text = \ text.replace("%s%s:%s" % (spaces, attribute, args), "") for t in tags: self.add_tag(t) if text != "": self.set_title(text.strip()) self.set_to_keep() self.set_due_date(due_date) self.set_start_date(defer_date)
def _build_bug_text(self, bug_dic): ''' Creates the text that describes a bug ''' text = _("Reported by: ") + '%s(karma: %s)' % \ (bug_dic["owner"], bug_dic["owner_karma"]) + '\n' # one link is enough, since they're all alias bug_project = bug_dic['projects'][0]['project_short'] text += _("Link to bug: ") + \ "https://bugs.edge.launchpad.net/%s/+bug/%s" % \ (bug_project, bug_dic["number"]) + '\n' text += '\n' + bug_dic["text"] return text
def set_complex_title(self, text, tags=[]): if tags: assert(isinstance(tags[0], str)) due_date = Date.no_date() defer_date = Date.no_date() if text: # Get tags in the title for match in extract_tags_from_text(text): tags.append(match) # Get attributes regexp = r'([\s]*)([\w-]+):\s*([^\s]+)' matches = re.findall(regexp, text, re.UNICODE) for spaces, attribute, args in matches: valid_attribute = True if attribute.lower() in ["tags", _("tags"), "tag", _("tag")]: for tag in args.split(","): if not tag.strip() == "@" and not tag.strip() == "": if not tag.startswith("@"): tag = "@" + tag tags.append(tag) elif attribute.lower() in ["defer", _("defer"), "start", _("start")]: try: defer_date = Date.parse(args) except ValueError: valid_attribute = False elif attribute.lower() == "due" or \ attribute.lower() == _("due"): try: due_date = Date.parse(args) except: valid_attribute = False else: # attribute is unknown valid_attribute = False if valid_attribute: # remove valid attribute from the task title text = \ text.replace("%s%s:%s" % (spaces, attribute, args), "") for t in tags: self.add_tag(t) if text != "": self.set_title(text.strip()) self.set_to_keep() self.set_due_date(due_date) self.set_start_date(defer_date)
def __build_custom_palette(self): """Draws the palette of custom colors""" self.__reset_custom_palette() # (re-)create the palette widget self.custom_palette = Gtk.Alignment.new(0, 0, 1, 0) self.custom_palette.set_padding(10, 0, 0, 0) self.pack_start(self.custom_palette, True, True, 0) # Draw the previous color palette: only one line cc_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.custom_palette.add(cc_vbox) cc_vbox.set_spacing(4) cc_box = Gtk.Box() cc_vbox.pack_start(cc_box, True, True, 0) for i in range(len(self.custom_colors)): # add the color box img = SimpleColorSelectorPaletteItem() img.set_size_request( BUTTON_WIDTH, BUTTON_HEIGHT) img.connect("button-press-event", self.on_color_clicked) if i < len(self.custom_colors): img.set_color(self.custom_colors[i]) self.buttons_lookup[self.custom_colors[i]] = img cc_box.pack_start(img, False, False, 0) cc_box.set_spacing(4) self.cc_buttons.append(img) # Draw the add button buttons_hbox = Gtk.Box() cc_vbox.pack_start(buttons_hbox, True, True, 0) img = Gtk.Image() img.set_from_stock(Gtk.STOCK_ADD, Gtk.IconSize.BUTTON) self.add_button = Gtk.Button() self.add_button.set_image(img) self.add_button.set_label(_("Add custom color")) buttons_hbox.pack_start(self.add_button, True, False, 0) self.add_button.connect("clicked", self.on_color_add) # Draw the clear selected color button img = Gtk.Image() img.set_from_stock(Gtk.STOCK_REMOVE, Gtk.IconSize.BUTTON) self.clear_button = Gtk.Button() self.clear_button.set_image(img) self.clear_button.set_label(_("Clear selected color")) buttons_hbox.pack_start(self.clear_button, True, False, 0) self.clear_button.connect("clicked", self.on_color_clear) self.clear_button.set_sensitive(False) # hide the custom palette if no custom color is defined if len(self.custom_colors) == 0: self.custom_palette.hide() else: self.custom_palette.show_all()
def __build_custom_palette(self): """Draws the palette of custom colors""" self.__reset_custom_palette() # (re-)create the palette widget self.custom_palette = Gtk.Alignment.new(0, 0, 1, 0) self.custom_palette.set_padding(10, 0, 0, 0) self.pack_start(self.custom_palette, True, True, 0) # Draw the previous color palette: only one line cc_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.custom_palette.add(cc_vbox) cc_vbox.set_spacing(4) cc_box = Gtk.Box() cc_vbox.pack_start(cc_box, True, True, 0) for i in range(len(self.custom_colors)): # add the color box img = SimpleColorSelectorPaletteItem() img.set_size_request( BUTTON_WIDTH, BUTTON_HEIGHT) img.connect("button-press-event", self.on_color_clicked) if i < len(self.custom_colors): img.set_color(self.custom_colors[i]) self.buttons_lookup[self.custom_colors[i]] = img cc_box.pack_start(img, False, False, 0) cc_box.set_spacing(4) self.cc_buttons.append(img) # Draw the add button buttons_hbox = Gtk.Box() cc_vbox.pack_start(buttons_hbox) img = Gtk.Image() img.set_from_stock(Gtk.STOCK_ADD, Gtk.ICON_SIZE_BUTTON) self.add_button = Gtk.Button() self.add_button.set_image(img) self.add_button.set_label(_("Add custom color")) buttons_hbox.pack_start(self.add_button, expand=True, fill=False) self.add_button.connect("clicked", self.on_color_add) # Draw the clear selected color button img = gtk.Image() img.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON) self.clear_button = gtk.Button() self.clear_button.set_image(img) self.clear_button.set_label(_("Clear selected color")) buttons_hbox.pack_start(self.clear_button, expand=True, fill=False) self.clear_button.connect("clicked", self.on_color_clear) self.clear_button.set_sensitive(False) # hide the custom palette if no custom color is defined if len(self.custom_colors) == 0: self.custom_palette.hide() else: self.custom_palette.show_all()
class GnomeConfig: CANLOAD = _("Everything necessary to run this plugin is available.") CANNOTLOAD = _("The plugin can not be loaded") miss1 = _("Some python modules are missing") miss2 = _("Please install the following python modules:") MODULEMISSING = "%s \n%s" % (miss1, miss2) dmiss1 = _("Some remote dbus objects are missing.") dmiss2 = _("Please start the following applications:") DBUSMISSING = "%s \n%s" % (dmiss1, dmiss2) bmiss1 = _("Some modules and remote dbus objects are missing.") bmiss2 = _("Please install or start the following components:") MODULANDDBUS = "%s \n%s" % (bmiss1, bmiss2) umiss1 = _("Unknown error while loading the plugin.") umiss2 = _("Very helpful message, isn't it? Please report a bug.") UNKNOWN = "%s \n%s" % (umiss1, umiss2)
def _populate_gtk(self, width): '''Creates the gtk widgets @param width: the width of the gtk.Label object ''' period_label = gtk.Label(_("Check for new tasks every")) period_label.set_alignment(xalign=0, yalign=0.5) period_label.set_line_wrap(True) period_label.set_size_request(width=width, height=-1) self.pack_start(period_label, False) align = gtk.Alignment(xalign=0, yalign=0.5, xscale=1) align.set_padding(0, 0, 10, 0) self.pack_start(align, False) period = self.backend.get_parameters()['period'] self.adjustment = gtk.Adjustment(value=period, lower=1, upper=120, step_incr=1, page_incr=0, page_size=0) self.period_spin = gtk.SpinButton(adjustment=self.adjustment, climb_rate=0.3, digits=0) self.minutes_label = gtk.Label() self.update_minutes_label() self.minutes_label.set_alignment(xalign=0, yalign=0.5) self.pack_start(self.minutes_label, False) align.add(self.period_spin) self.show_all()
def __build_window(self): """Build up the widget""" self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_POPUP_MENU) vbox = gtk.VBox() self.add(vbox) # icon list scld_win = gtk.ScrolledWindow() scld_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) scld_win.set_shadow_type(gtk.SHADOW_ETCHED_IN) vbox.pack_start(scld_win, expand=True, fill=True) self.symbol_iv = gtk.IconView() self.symbol_iv.set_pixbuf_column(0) self.symbol_iv.set_property("columns", 7) self.symbol_iv.set_property("item-width", 32) # IconView size: # -------------- # it seems that with the above parameters, a row width is about: # item_count * (32px (item) + 6px (dflt padding) + 2px (spacing?)) \ # + 2*6px (dflt widget margin) # The same goes for row height, but being right for this value is less # important due to the vertical scrollbar. # The IcVw size should fit the width of 7 cols and height of ~4 lines. self.symbol_iv.set_size_request(40 * 7 + 12, 38 * 4) scld_win.add(self.symbol_iv) # icon remove button img = gtk.Image() img.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON) self.remove_bt = gtk.Button() self.remove_bt.set_image(img) self.remove_bt.set_label(_("Remove selected icon")) vbox.pack_start(self.remove_bt, fill=False, expand=False) # set the callbacks self.symbol_iv.connect("selection-changed", self.on_selection_changed) self.remove_bt.connect("clicked", self.on_remove_bt_clicked)
def __init__(self, ze_id, requester, newtask=False): TreeNode.__init__(self, ze_id) # the id of this task in the project should be set # tid is a string ! (we have to choose a type and stick to it) assert(isinstance(ze_id, str) or isinstance(ze_id, str)) self.tid = str(ze_id) self.set_uuid(uuid.uuid4()) self.remote_ids = {} self.content = "" self.title = _("My new task") # available status are: Active - Done - Dismiss - Note self.status = self.STA_ACTIVE self.closed_date = Date.no_date() self.due_date = Date.no_date() self.start_date = Date.no_date() self.can_be_deleted = newtask # tags self.tags = [] self.req = requester self.__main_treeview = requester.get_main_view() # If we don't have a newtask, we will have to load it. self.loaded = newtask # Should not be necessary with the new backends # if self.loaded: # self.req._task_loaded(self.tid) self.attributes = {} self._modified_update()
def __init__(self, ze_id, requester, newtask=False): TreeNode.__init__(self, ze_id) # the id of this task in the project should be set # tid is a string ! (we have to choose a type and stick to it) assert(isinstance(ze_id, str) or isinstance(ze_id, unicode)) self.tid = str(ze_id) self.set_uuid(uuid.uuid4()) self.remote_ids = {} self.content = "" self.title = _("My new task") # available status are: Active - Done - Dismiss - Note self.status = self.STA_ACTIVE self.closed_date = Date.no_date() self.due_date = Date.no_date() self.start_date = Date.no_date() self.can_be_deleted = newtask # tags self.tags = [] self.req = requester self.__main_treeview = requester.get_main_view() # If we don't have a newtask, we will have to load it. self.loaded = newtask # Should not be necessary with the new backends # if self.loaded: # self.req._task_loaded(self.tid) self.attributes = {} self._modified_update()
def _populate_task(self, task, bug_dic): ''' Fills a GTG task with the data from a launchpad bug. @param task: a Task @param bug: a launchpad bug dictionary, generated with _prefetch_bug_data ''' # set task status if bug_dic["completed"]: task.set_status(Task.STA_DONE) else: task.set_status(Task.STA_ACTIVE) if task.get_title() != bug_dic['title']: task.set_title(_("Bug") + " %s: " % bug_dic["number"] + bug_dic['title']) text = self._build_bug_text(bug_dic) if task.get_excerpt() != text: task.set_text(text) new_tags_sources = [] if self._parameters["import-bug-tags"]: new_tags_sources += bug_dic['tags'] if self._parameters["tag-with-project-name"]: new_tags_sources += [dic['project_short'] for dic in bug_dic['projects']] new_tags = set(['@' + str(tag) for tag in new_tags_sources]) current_tags = set(task.get_tags_name()) # remove the lost tags for tag in current_tags.difference(new_tags): task.remove_tag(tag) # add the new ones for tag in new_tags.difference(current_tags): task.add_tag(tag) task.add_remote_id(self.get_id(), bug_dic['self_link'])
def _populate_task(self, task, issue_dic): ''' Fills a GTG task with the data from a mantis issue. @param task: a Task @param issue_dic: a mantis issue ''' # set task status if issue_dic["completed"]: task.set_status(Task.STA_DONE) else: task.set_status(Task.STA_ACTIVE) if task.get_title() != issue_dic['title']: task.set_title(_("Iss.") + " %s: " % issue_dic["number"] + issue_dic['title']) text = self._build_issue_text(issue_dic) if task.get_excerpt() != text: task.set_text(text) new_tags = set([]) if self._parameters["tag-with-project-name"]: new_tags = set(['@' + issue_dic['project']]) current_tags = set(task.get_tags_name()) # add the new ones for tag in new_tags.difference(current_tags): task.add_tag(tag) task.add_remote_id(self.get_id(), issue_dic['number'])
def to_readable_string(self): """ Return nice representation of date. Fuzzy dates => localized version Close dates => Today, Tomorrow, In X days Other => with locale dateformat, stripping year for this year """ if self._fuzzy is not None: return STRINGS[self._fuzzy] days_left = self.days_left() if days_left == 0: return _('Today') elif days_left < 0: abs_days = abs(days_left) return ngettext('Yesterday', '%(days)d days ago', abs_days) % \ {'days': abs_days} elif days_left > 0 and days_left <= 15: return ngettext('Tomorrow', 'In %(days)d days', days_left) % \ {'days': days_left} else: locale_format = locale.nl_langinfo(locale.D_FMT) if calendar.isleap(datetime.date.today().year): year_len = 366 else: year_len = 365 if float(days_left) / year_len < 1.0: # if it's in less than a year, don't show the year field locale_format = locale_format.replace('/%Y', '') locale_format = locale_format.replace('.%Y', '.') return self._real_date.strftime(locale_format)
def _show_gsettings_install_label(self): vbox = self.builder.get_object("prefs-vbox7") label = Gtk.Label() label.set_markup( _("<small>Please install <i><b>gsettings</b></i> " "to enable New task shortcut</small>")) vbox.add(label)
def to_readable_string(self): """ Return nice representation of date. Fuzzy dates => localized version Close dates => Today, Tomorrow, In X days Other => with locale dateformat, stripping year for this year """ if self._fuzzy is not None: return STRINGS[self._fuzzy] days_left = self.days_left() if days_left == 0: return _('Today') elif days_left < 0: abs_days = abs(days_left) relative_threshold = 3 * 7 if abs_days > relative_threshold: return self._real_date.isoformat() if abs_days > 365: return ngettext('1 year ago', '%(years)d years ago', abs_days/365) % \ {'years': abs_days/365} if abs_days > 60: return ngettext('1 month ago', '%(months)d months ago', abs_days/30.5) % \ {'months': abs_days/30.5} if abs_days > 14: return ngettext('1 week ago', '%(weeks)d weeks ago', abs_days/7) % \ {'weeks': abs_days/7} return ngettext('Yesterday', '%(days)d days ago', abs_days) % \ {'days': abs_days} elif days_left > 0 and days_left <= 15: return ngettext('Tomorrow', 'In %(days)d days', days_left) % \ {'days': days_left} else: return self._real_date.isoformat() """