def __init__(self, event):## FIXME common.WidgetClass.__init__(self, event) ###### sizeGroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL) ###### try: seperated = event.parent.showSeperatedYmdInputs except AttributeError: seperated = False if seperated: self.startDateInput = YearMonthDayBox() self.endDateInput = YearMonthDayBox() else: self.startDateInput = DateButton() self.endDateInput = DateButton() ###### hbox = gtk.HBox() label = gtk.Label(_("Start") + ": ") label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) pack(hbox, self.startDateInput) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_("End") + ": ") label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) pack(hbox, self.endDateInput) pack(self, hbox)
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Select Date...')) #self.set_has_separator(False) #self.set_skip_taskbar_hint(True) self.connect('delete-event', self.hideMe) self.mode = calTypes.primary ###### Reciving dropped day! self.drag_dest_set( gtk.DestDefaults.ALL, (), gdk.DragAction.COPY, ) self.drag_dest_add_text_targets() self.connect('drag-data-received', self.dragRec) ###### hb0 = gtk.HBox(spacing=4) pack(hb0, gtk.Label(_('Date Mode'))) combo = CalTypeCombo() combo.set_active(self.mode) pack(hb0, combo) pack(self.vbox, hb0) ####################### hbox = gtk.HBox(spacing=5) rb1 = gtk.RadioButton.new_with_label(None, '') rb1.num = 1 pack(hbox, rb1) self.ymdBox = YearMonthDayBox() pack(hbox, self.ymdBox) pack(self.vbox, hbox) ######## hb2 = gtk.HBox(spacing=4) pack(hb2, gtk.Label('yyyy/mm/dd')) dateInput = DateButtonOption(hist_size=16) pack(hb2, dateInput) rb2 = gtk.RadioButton.new_with_label_from_widget(rb1, '') rb2.num = 2 #rb2.set_group([rb1]) hb2i = gtk.HBox(spacing=5) pack(hb2i, rb2) pack(hb2i, hb2) pack(self.vbox, hb2i) ####### dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 2, self.hideMe) dialog_add_button(self, gtk.STOCK_OK, _('_OK'), 1, self.ok) ####### self.comboMode = combo self.dateInput = dateInput self.radio1 = rb1 self.radio2 = rb2 self.hbox2 = hb2 ####### combo.connect ('changed', self.comboModeChanged) rb1.connect_after('clicked', self.radioChanged) rb2.connect_after('clicked', self.radioChanged) dateInput.connect('activate', self.ok) self.radioChanged() ####### self.vbox.show_all() self.resize(1, 1)
def optionsWidgetCreate(self): from scal3.ui_gtk.pref_utils import LiveLabelSpinPrefItem, SpinPrefItem, \ LiveCheckColorPrefItem, CheckPrefItem, ColorPrefItem if self.optionsWidget: return ColumnBase.optionsWidgetCreate(self) ##### prefItem = LiveLabelSpinPrefItem( _("Height"), SpinPrefItem(ui, "wcalHeight", 1, 9999, digits=0), self.heightUpdate, ) pack(self.optionsWidget, prefItem.getWidget()) ### prefItem = LiveLabelSpinPrefItem( _("Text Size Scale"), SpinPrefItem(ui, "wcalTextSizeScale", 0.01, 1, digits=2), self.queue_draw, ) pack(self.optionsWidget, prefItem.getWidget()) ######## prefItem = LiveCheckColorPrefItem( CheckPrefItem(ui, "wcalGrid", _("Grid")), ColorPrefItem(ui, "wcalGridColor", True), self.queue_draw, ) pack(self.optionsWidget, prefItem.getWidget()) ### self.optionsWidget.show_all()
def aboutShow(self, obj=None, data=None): if not self.aboutDialog: from scal3.ui_gtk.about import AboutDialog with open( join(rootDir, "authors-dialog"), encoding="utf-8", ) as authorsFile: authors = authorsFile.read().splitlines() dialog = AboutDialog( name=core.APP_DESC, version=core.VERSION, title=_("About ") + core.APP_DESC, authors=[ _(author) for author in authors ], comments=core.aboutText, license=core.licenseText, website=core.homePage, parent=self, ) # add Donate button, FIXME dialog.connect("delete-event", self.aboutHide) dialog.connect("response", self.aboutHide) #dialog.set_logo(GdkPixbuf.Pixbuf.new_from_file(ui.logo)) #dialog.set_skip_taskbar_hint(True) self.aboutDialog = dialog openWindow(self.aboutDialog)
def menuMainCreate(self): if self.menuMain: return menu = gtk.Menu() #### item = ImageMenuItem(_('Resize')) item.set_image(imageFromFile('resize.png')) item.connect('button-press-event', self.startResize) menu.add(item) ####### menu.add(self.checkAbove) menu.add(self.checkSticky) ####### menu.add(labelStockMenuItem('Select _Today', gtk.STOCK_HOME, self.goToday)) menu.add(labelStockMenuItem('Select _Date...', gtk.STOCK_INDEX, self.selectDateShow)) menu.add(labelStockMenuItem('Day Info', gtk.STOCK_INFO, self.dayInfoShow)) menu.add(labelStockMenuItem('_Customize', gtk.STOCK_EDIT, self.customizeShow)) menu.add(labelStockMenuItem('_Preferences', gtk.STOCK_PREFERENCES, self.prefShow)) #menu.add(labelStockMenuItem('_Add Event', gtk.STOCK_ADD, ui.addCustomEvent)) menu.add(labelStockMenuItem('_Event Manager', gtk.STOCK_ADD, self.eventManShow)) menu.add(labelImageMenuItem('Time Line', 'timeline-18.png', self.timeLineShow)) #menu.add(labelImageMenuItem('Week Calendar', 'weekcal-18.png', self.weekCalShow)) menu.add(labelStockMenuItem(_('Export to %s')%'HTML', gtk.STOCK_CONVERT, self.exportClicked)) menu.add(labelStockMenuItem('_About', gtk.STOCK_ABOUT, self.aboutShow)) if self.statusIconMode!=1: menu.add(labelStockMenuItem('_Quit', gtk.STOCK_QUIT, self.quit)) menu.show_all() self.menuMain = menu
def __init__(self, wcal, index, mode, params, sgroupLabel, sgroupFont): from scal3.ui_gtk.mywidgets import MyFontButton gtk.HBox.__init__(self) self.wcal = wcal self._parent = wcal self.index = index self.mode = mode ###### module, ok = calTypes[mode] if not ok: raise RuntimeError("cal type %r not found" % mode) label = gtk.Label(_(module.desc) + " ") label.set_alignment(0, 0.5) pack(self, label) sgroupLabel.add_widget(label) ### self.fontCheck = gtk.CheckButton(_("Font")) pack(self, gtk.Label(""), 1, 1) pack(self, self.fontCheck) ### self.fontb = MyFontButton(wcal) pack(self, self.fontb) sgroupFont.add_widget(self.fontb) #### self.set(params) #### self.fontCheck.connect("clicked", self.onChange) self.fontb.connect("font-set", self.onChange)
def __init__(self, group): NormalWidgetClass.__init__(self, group) ##### totalFrame = gtk.Frame() totalFrame.set_label(group.desc) totalVbox = gtk.VBox() ### expandHbox = gtk.HBox()## for courseList and classTimeBounds ## frame = gtk.Frame() frame.set_label(_('Course List')) self.courseListEditor = CourseListEditor(self.group) self.courseListEditor.set_size_request(100, 150) frame.add(self.courseListEditor) pack(expandHbox, frame, 1, 1) ## frame = gtk.Frame()## FIXME frame.set_label(_('Class Time Bounds')) self.classTimeBoundsEditor = ClassTimeBoundsEditor(self.group) self.classTimeBoundsEditor.set_size_request(50, 150) frame.add(self.classTimeBoundsEditor) pack(expandHbox, frame) ## pack(totalVbox, expandHbox, 1, 1) ##### totalFrame.add(totalVbox) pack(self, totalFrame, 1, 1)## expand? FIXME
def popupPopulate(self, label, menu): itemCopyAll = ImageMenuItem(_("Copy _All")) itemCopyAll.set_image(gtk.Image.new_from_stock( gtk.STOCK_COPY, gtk.IconSize.MENU), ) itemCopyAll.connect("activate", self.copyAll) ## itemCopy = ImageMenuItem(_("_Copy")) itemCopy.set_image(gtk.Image.new_from_stock( gtk.STOCK_COPY, gtk.IconSize.MENU, )) itemCopy.connect("activate", self.copy) itemCopy.set_sensitive( self.get_property("cursor-position") > self.get_property("selection-bound") ) # FIXME ## for item in menu.get_children(): menu.remove(item) ## menu.add(itemCopyAll) menu.add(itemCopy) menu.show_all() ## ui.updateFocusTime()
def run(self, format, fpath): self.redirectStdOutErr() try: if format=='json': try: text = open(fpath, 'r', encoding='utf-8').read() except Exception as e: sys.stderr.write(_('Error in reading file')+'\n%s\n'%e) else: try: data = jsonToData(text) except Exception as e: sys.stderr.write(_('Error in loading JSON data')+'\n%s\n'%e) else: try: newGroups = ui.eventGroups.importData(data) except Exception as e: sys.stderr.write(_('Error in importing events')+'\n%s\n'%e) else: for group in newGroups: self.win.manager.appendGroupTree(group) print(_('%s groups imported successfully')%_(len(newGroups))) else: raise ValueError('invalid format %r'%format) finally: self.restoreStdOutErr()
def __init__(self, term, **kwargs): self.term = term gtk.Dialog.__init__(self, **kwargs) self.resize(800, 500) self.set_title(_('View Weekly Schedule')) self.connect('delete-event', self.onDeleteEvent) ##### hbox = gtk.HBox() self.currentWOnlyCheck = gtk.CheckButton(_('Current Week Only')) self.currentWOnlyCheck.connect('clicked', lambda obj: self.updateWidget()) pack(hbox, self.currentWOnlyCheck) ## pack(hbox, gtk.Label(''), 1, 1) ## button = gtk.Button(_('Export to ')+'SVG') button.connect('clicked', self.exportToSvgClicked) pack(hbox, button) ## pack(self.vbox, hbox) ##### self._widget = WeeklyScheduleWidget(term) pack(self.vbox, self._widget, 1, 1) ##### self.vbox.show_all() self.updateWidget()
def __init__(self, module, opt): t = opt[1] self.opt = opt ## needed?? self.module = module self.type = t self.var_name = opt[0] hbox = gtk.HBox() if t==bool: w = gtk.CheckButton(_(opt[2])) self.get_value = w.get_active self.set_value = w.set_active elif t==list: pack(hbox, gtk.Label(_(opt[2]))) w = gtk.ComboBoxText() ### or RadioButton for s in opt[3]: w.append_text(_(s)) self.get_value = w.get_active self.set_value = w.set_active elif t==int: pack(hbox, gtk.Label(_(opt[2]))) w = IntSpinButton(opt[3], opt[4]) self.get_value = w.get_value self.set_value = w.set_value elif t==float: pack(hbox, gtk.Label(_(opt[2]))) w = FloatSpinButton(opt[3], opt[4], opt[5]) self.get_value = w.get_value self.set_value = w.set_value else: raise RuntimeError('bad option type "%s"'%t) pack(hbox, w) self._widget = hbox #### self.updateVar = lambda: setattr(self.module, self.var_name, self.get_value()) self.updateWidget = lambda: self.set_value(getattr(self.module, self.var_name))
def __init__(self, group, **kwargs): from scal3.ui_gtk.mywidgets.cal_type_combo import CalTypeCombo self._group = group gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Convert Calendar Type')) #### dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.ResponseType.CANCEL) dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.ResponseType.OK) ## self.connect('response', lambda w, e: self.hide()) #### hbox = gtk.HBox() label = gtk.Label(_('This is going to convert calendar types of all events inside group \"%s\" to a specific type. This operation does not work for Yearly events and also some of Custom events. You have to edit those events manually to change calendar type.')%group.title) label.set_line_wrap(True) pack(hbox, label) pack(hbox, gtk.Label(''), 1, 1) pack(self.vbox, hbox) ### hbox = gtk.HBox() pack(hbox, gtk.Label(_('Calendar Type')+':')) combo = CalTypeCombo() combo.set_active(group.mode) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) self.modeCombo = combo pack(self.vbox, hbox) #### self.vbox.show_all() window_set_size_aspect(self, 1.6)
def __init__(self, group): BaseWidgetClass.__init__(self, group) ###### sizeGroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL) ###### hbox = gtk.HBox() label = gtk.Label(_('Scale')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.scaleCombo = common.Scale10PowerComboBox() pack(hbox, self.scaleCombo) pack(self, hbox) #### hbox = gtk.HBox() label = gtk.Label(_('Start')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.startSpin = IntSpinButton(-maxStartEnd, maxStartEnd) pack(hbox, self.startSpin) pack(self, hbox) #### hbox = gtk.HBox() label = gtk.Label(_('End')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.endSpin = IntSpinButton(-maxStartEnd, maxStartEnd) pack(hbox, self.endSpin) pack(self, hbox)
def __init__(self, name, stockName, method, desc='', shortDesc='', enableTooltip=True): #print('ToolbarItem', name, stockName, method, desc, text) self.method = method ###### if not desc: desc = name.capitalize() ## if not shortDesc: shortDesc = desc ## desc = _(desc) shortDesc = _(shortDesc) ###### gtk.ToolButton.__init__(self) self.set_icon_widget( gtk.Image.new_from_stock( getattr(gtk, 'STOCK_%s'%(stockName.upper())), gtk.IconSize.DIALOG, ) if stockName else None, #shortDesc, ) self.set_label(shortDesc) self._name = name self.desc = desc #self.shortDesc = shortDesc## FIXME self.initVars() if enableTooltip: set_tooltip(self, desc)## FIXME self.set_is_important(True)## FIXME
def getStatusIconTooltip(self): ##tt = core.weekDayName[core.getWeekDay(*ddate)] tt = core.weekDayName[core.jwday(ui.todayCell.jd)] #if ui.pluginsTextStatusIcon:##????????? # sep = _(",")+" " #else: sep = "\n" for mode in calTypes.active: y, m, d = ui.todayCell.dates[mode] tt += "%s%s %s %s" % ( sep, _(d), locale_man.getMonthName(mode, m, y), _(y), ) if ui.pluginsTextStatusIcon: text = ui.todayCell.pluginsText if text != "": tt += "\n\n%s" % text # .replace("\t", "\n") ## FIXME for item in ui.todayCell.eventsData: if not item["showInStatusIcon"]: continue itemS = "" if item["time"]: itemS += item["time"] + " - " itemS += item["text"][0] tt += "\n\n%s" % itemS return tt
def getText(self, year, month, day): yearlyData = self.yearlyData if not yearlyData: return "" mode = self.mode #if mode!=calTypes.primary: # year, month, day = convert(year, month, day, calTypes.primary, mode) text = "" item = yearlyData[month - 1] if len(item) > day - 1: text = item[day - 1] if self.show_date and text: text = "%s %s: %s" % ( _(day), getMonthName(mode, month), text, ) if len(yearlyData) > 12: text2 = yearlyData[12].get((year, month, day), "") if text2: if text: text += "\n" if self.show_date: text2 = "%s %s %s: %s" % ( _(day), getMonthName(mode, month, year), _(year), text2, ) text += text2 return text
def save(self, widget=None): self.get_window().set_cursor(gdk.Cursor.new(gdk.CursorType.WATCH)) while gtk.events_pending(): gtk.main_iteration_do(False) path = self.fcw.get_filename() if path in (None, ''): return print('Exporting to html file "%s"'%path) i = self.combo.get_active() months = [] module = calTypes.primaryModule() if i==0: s = getCurrentMonthStatus() months = [s] title = '%s %s'%(locale_man.getMonthName(calTypes.primary, s.month, s.year), _(s.year)) elif i==1: for i in range(1, 13): months.append(getMonthStatus(ui.cell.year, i)) title = '%s %s'%(_('Calendar'), _(ui.cell.year)) elif i==2: y0, m0 = self.ymBox0.get_value() y1, m1 = self.ymBox1.get_value() for ym in range(y0*12+m0-1, y1*12+m1): y, m = divmod(ym, 12) m += 1 months.append(getMonthStatus(y, m)) title = _('Calendar') exportToHtml(path, months, title) self.get_window().set_cursor(gdk.Cursor.new(gdk.CursorType.LEFT_PTR)) self.hide()
def setData(self, data): if "enable" not in data: data["enable"] = data.get("default_enable", self.default_enable) ### if "show_date" not in data: data["show_date"] = data.get("default_show_date", self.default_show_date) ### title = data.get("title") if title: data["title"] = _(title) ### about = data.get("about") if about: data["about"] = _(about) ### authors = data.get("authors") if authors: data["authors"] = [_(author) for author in authors] ##### if "calType" in data: calType = data["calType"] try: self.mode = calTypes.names.index(calType) except ValueError: #raise ValueError("Invalid calType: %r"%calType) log.error( "Plugin \"%s\" needs calendar module " % _file + "\"%s\" that is not loaded!\n" % mode ) self.mode = None del data["calType"] ##### JsonSObj.setData(self, data)
def __init__(self, event): gtk.Expander.__init__(self) self.set_label(_('Notification')) self.event = event self.hboxDict = {} totalVbox = gtk.VBox() ### hbox = gtk.HBox() pack(hbox, gtk.Label(_('Notify')+' ')) self.notifyBeforeInput = DurationInputBox() pack(hbox, self.notifyBeforeInput, 0, 0) pack(hbox, gtk.Label(' '+_('before event'))) pack(hbox, gtk.Label(), 1, 1) pack(totalVbox, hbox) ### for cls in event_lib.classes.notifier: notifier = cls(self.event) inputWidget = makeWidget(notifier) if not inputWidget: printError('notifier %s, inputWidget = %r'%(cls.name, inputWidget)) continue hbox = gtk.HBox() cb = gtk.CheckButton(notifier.desc) cb.inputWidget = inputWidget cb.connect('clicked', lambda check: check.inputWidget.set_sensitive(check.get_active())) cb.set_active(False) pack(hbox, cb) hbox.cb = cb #pack(hbox, gtk.Label(''), 1, 1) pack(hbox, inputWidget, 1, 1) hbox.inputWidget = inputWidget self.hboxDict[notifier.name] = hbox pack(totalVbox, hbox) self.add(totalVbox)
def __init__(self, account=None, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Edit Account') if account else _('Add New Account')) ### dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.ResponseType.CANCEL) dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.ResponseType.OK) ## self.connect('response', lambda w, e: self.hide()) ####### self.account = account self.activeWidget = None ####### hbox = gtk.HBox() combo = gtk.ComboBoxText() for cls in event_lib.classes.account: combo.append_text(cls.desc) pack(hbox, gtk.Label(_('Account Type'))) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) pack(self.vbox, hbox) #### if self.account: self.isNew = False combo.set_active(event_lib.classes.account.names.index(self.account.name)) else: self.isNew = True defaultAccountTypeIndex = 0 combo.set_active(defaultAccountTypeIndex) self.account = event_lib.classes.account[defaultAccountTypeIndex]() self.activeWidget = None combo.connect('changed', self.typeChanged) self.comboType = combo self.vbox.show_all() self.typeChanged()
def __init__(self, abrivateWeekDays=False): self.abrivateWeekDays = abrivateWeekDays self.absWeekNumber = core.getAbsWeekNumberFromJd(ui.cell.jd)## FIXME gtk.TreeView.__init__(self) self.set_headers_visible(False) self.ls = gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str)## icon, weekDay, time, text self.set_model(self.ls) ### cell = gtk.CellRendererPixbuf() col = gtk.TreeViewColumn(_('Icon'), cell) col.add_attribute(cell, 'pixbuf', 0) self.append_column(col) ### cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_('Week Day'), cell) col.add_attribute(cell, 'text', 1) col.set_resizable(True) self.append_column(col) ### cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_('Time'), cell) col.add_attribute(cell, 'text', 2) col.set_resizable(True)## FIXME self.append_column(col) ### cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_('Description'), cell) col.add_attribute(cell, 'text', 3) col.set_resizable(True) self.append_column(col)
def __init__(self, event):## FIXME common.WidgetClass.__init__(self, event) ################ hbox = gtk.HBox() pack(hbox, gtk.Label(_('Month'))) self.monthCombo = MonthComboBox() self.monthCombo.build(event.mode) pack(hbox, self.monthCombo) pack(hbox, gtk.Label(''), 1, 1) #pack(self, hbox) ### #hbox = gtk.HBox() pack(hbox, gtk.Label(_('Day'))) self.daySpin = DaySpinButton() pack(hbox, self.daySpin) pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ### hbox = gtk.HBox() self.startYearCheck = gtk.CheckButton(_('Start Year')) pack(hbox, self.startYearCheck) self.startYearSpin = YearSpinButton() pack(hbox, self.startYearSpin) pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) self.startYearCheck.connect('clicked', self.startYearCheckClicked) #### self.notificationBox = common.NotificationBox(event) pack(self, self.notificationBox)
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.initVars() ud.windowList.appendItem(self) ### self.set_title(_('Day Info')) self.connect('delete-event', self.onClose) self.vbox.set_spacing(15) ### dialog_add_button(self, gtk.STOCK_CLOSE, _('Close'), 0, self.onClose) dialog_add_button(self, '', _('Previous'), 1, self.goBack) dialog_add_button(self, '', _('Today'), 2, self.goToday) dialog_add_button(self, '', _('Next'), 3, self.goNext) ### self.allDateLabels = AllDateLabelsVBox() self.pluginsTextView = PluginsTextView() self.eventsView = DayOccurrenceView() ### for item in (self.allDateLabels, self.pluginsTextView, self.eventsView): self.appendItem(item) ### exp = gtk.Expander() exp.set_label(item.desc) exp.add(item) exp.set_expanded(True) pack(self.vbox, exp) self.vbox.show_all()
def __init__(self, abrivateWeekDays=False): self.abrivateWeekDays = abrivateWeekDays self.absWeekNumber = core.getAbsWeekNumberFromJd(ui.cell.jd)## FIXME gtk.TreeView.__init__(self) self.set_headers_visible(False) self.ls = gtk.ListStore( GdkPixbuf.Pixbuf, # icon str, # weekDay str, # time str, # text ) self.set_model(self.ls) ### cell = gtk.CellRendererPixbuf() col = gtk.TreeViewColumn(_("Icon"), cell) col.add_attribute(cell, "pixbuf", 0) self.append_column(col) ### cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_("Week Day"), cell) col.add_attribute(cell, "text", 1) col.set_resizable(True) self.append_column(col) ### cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_("Time"), cell) col.add_attribute(cell, "text", 2) col.set_resizable(True)## FIXME self.append_column(col) ### cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_("Description"), cell) col.add_attribute(cell, "text", 3) col.set_resizable(True) self.append_column(col)
def readLocationData(): lines = open(dataDir+'/locations.txt').read().split('\n') cityData = [] country = '' for l in lines: p = l.split('\t') if len(p)<2: #print(p) continue if p[0]=='': if p[1]=='': city, lat, lng = p[2:5] #if country=='Iran': # print(city) if len(p)>4: cityData.append(( country + '/' + city, _(country) + '/' + _(city), float(lat), float(lng) )) else: print(country, p) else: country = p[1] return cityData
def optionsWidgetCreate(self): from scal3.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton if self.optionsWidget: return self.optionsWidget = gtk.VBox() #### if self.customizeWidth: value = self.getWidthValue() ### hbox = gtk.HBox() pack(hbox, gtk.Label(_('Width'))) spin = IntSpinButton(0, 999) pack(hbox, spin) spin.set_value(value) spin.connect('changed', self.widthSpinChanged) pack(self.optionsWidget, hbox) #### if self.customizeFont: hbox = gtk.HBox() pack(hbox, gtk.Label(_('Font Family'))) combo = FontFamilyCombo(hasAuto=True) combo.set_value(self.getFontValue()) pack(hbox, combo) combo.connect('changed', self.fontFamilyComboChanged) pack(self.optionsWidget, hbox) #### self.optionsWidget.show_all()
def __init__(self, event, typeChangable=True, isNew=False, useSelectedDate=False, **kwargs): checkEventsReadOnly() gtk.Dialog.__init__(self, **kwargs) #self.set_transient_for(None) #self.set_type_hint(gdk.WindowTypeHint.NORMAL) self.isNew = isNew #self.connect('delete-event', lambda obj, e: self.destroy()) #self.resize(800, 600) ### dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.ResponseType.CANCEL) dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.ResponseType.OK) ### self.connect('response', lambda w, e: self.hide()) ### self.activeWidget = None self._group = event.parent self.eventTypeOptions = list(self._group.acceptsEventTypes) #### if not event.name in self.eventTypeOptions: self.eventTypeOptions.append(event.name) eventTypeIndex = self.eventTypeOptions.index(event.name) #### self.event = event ####### if isNew and not event.timeZone: event.timeZone = str(core.localTz)## why? FIXME ####### hbox = gtk.HBox() pack(hbox, gtk.Label( _('Group') + ': ' + self._group.title )) hbox.show_all() pack(self.vbox, hbox) ####### hbox = gtk.HBox() pack(hbox, gtk.Label(_('Event Type'))) if typeChangable: combo = gtk.ComboBoxText() for tmpEventType in self.eventTypeOptions: combo.append_text(event_lib.classes.event.byName[tmpEventType].desc) pack(hbox, combo) #### combo.set_active(eventTypeIndex) #### #self.activeWidget = makeWidget(event) combo.connect('changed', self.typeChanged) self.comboEventType = combo else: pack(hbox, gtk.Label(': '+event.desc)) pack(hbox, gtk.Label(''), 1, 1) hbox.show_all() pack(self.vbox, hbox) ##### if useSelectedDate: self.event.setJd(ui.cell.jd) self.activeWidget = makeWidget(event) if self.isNew: self.activeWidget.focusSummary() pack(self.vbox, self.activeWidget, 1, 1) self.vbox.show()
def __init__(self): gtk.HBox.__init__(self, spacing=4) self.mode = calTypes.primary #### pack(self, gtk.Label(_("Year"))) self.spinY = YearSpinButton() pack(self, self.spinY) #### pack(self, gtk.Label(_("Month"))) comboMonth = gtk.ComboBoxText() module, ok = calTypes[self.mode] if not ok: raise RuntimeError("cal type %r not found" % self.mode) for i in range(12): comboMonth.append_text(_(module.getMonthName( i + 1, None, # year=None means all months ))) comboMonth.set_active(0) pack(self, comboMonth) self.comboMonth = comboMonth #### pack(self, gtk.Label(_("Day"))) self.spinD = DaySpinButton() pack(self, self.spinD) self.comboMonthConn = comboMonth.connect( "changed", self.comboMonthChanged, ) self.spinY.connect("changed", self.comboMonthChanged)
def _save(self, path): comboItem = self.combo.get_active() months = [] module = calTypes.primaryModule() if comboItem == 0: s = getCurrentMonthStatus() months = [s] title = "%s %s" % ( locale_man.getMonthName( calTypes.primary, s.month, s.year, ), _(s.year), ) elif comboItem == 1: for i in range(1, 13): months.append(getMonthStatus(ui.cell.year, i)) title = "%s %s" % (_("Calendar"), _(ui.cell.year)) elif comboItem == 2: y0, m0 = self.ymBox0.get_value() y1, m1 = self.ymBox1.get_value() for ym in range(y0 * 12 + m0 - 1, y1 * 12 + m1): y, m = divmod(ym, 12) m += 1 months.append(getMonthStatus(y, m)) title = _("Calendar") exportToHtml(path, months, title) self.hide()
def updateWidget(self): #for index, module in calTypes.iterIndexModule(): # if module.name != 'hijri': for mode in calTypes.active: modeDesc = calTypes[mode].desc if not 'hijri' in modeDesc.lower(): self.altMode = mode self.altModeDesc = modeDesc break self.topLabel.set_label(_('Start')+': '+dateLocale(*monthDb.startDate)+' '+_('Equals to')+' %s'%_(self.altModeDesc)) self.startDateInput.set_value(jd_to(monthDb.startJd, self.altMode)) ########### selectYm = getCurrentYm() - 1 ## previous month selectIndex = None self.trees.clear() for index, ym, mLen in monthDb.getMonthLenList(): if ym == selectYm: selectIndex = index year, month0 = divmod(ym, 12) self.trees.append([ ym, _(year), _(monthName[month0]), mLen, '', ]) self.updateEndDates() ######## if selectIndex is not None: self.treev.scroll_to_cell(str(selectIndex)) self.treev.set_cursor(str(selectIndex))
def onExposeEvent(self, widget=None, event=None): cr = self.getContext() self.drawBg(cr) try: font = ui.wcalTypeParams[self.index]["font"] except: font = None self.drawTextList( cr, [[( _(self.wcal.status[i].dates[self.mode][2], self.mode), "", )] for i in range(7)], font=font, ) self.drawCursorFg(cr)
class PluginsTextView(gtk.TextView, ud.BaseCalObj): _name = 'pluginsText' desc = _('Plugins Text') def __init__(self): gtk.TextView.__init__(self) self.initVars() ### self.set_wrap_mode(gtk.WrapMode.WORD) self.set_editable(False) self.set_cursor_visible(False) self.set_justification(gtk.Justification.CENTER) def onDateChange(self, *a, **ka): ud.BaseCalObj.onDateChange(self, *a, **ka) self.get_buffer().set_text(ui.cell.pluginsText)
def __init__(self, group, **kwargs): self._group = group gtk.Dialog.__init__(self, **kwargs) self.set_title(_("Export Group")) #### dialog_add_button( self, gtk.STOCK_CANCEL, _("_Cancel"), gtk.ResponseType.CANCEL, ) dialog_add_button( self, gtk.STOCK_OK, _("_OK"), gtk.ResponseType.OK, ) self.connect("response", lambda w, e: self.hide()) #### hbox = gtk.HBox() frame = gtk.Frame() frame.set_label(_("Format")) radioBox = gtk.VBox() ## self.radioIcs = gtk.RadioButton(label="iCalendar") self.radioJsonCompact = gtk.RadioButton( label=_("Compact JSON (StarCalendar)"), group=self.radioIcs, ) self.radioJsonPretty = gtk.RadioButton( label=_("Pretty JSON (StarCalendar)"), group=self.radioIcs, ) ## pack(radioBox, self.radioJsonCompact) pack(radioBox, self.radioJsonPretty) pack(radioBox, self.radioIcs) ## self.radioJsonCompact.set_active(True) self.radioIcs.connect("clicked", self.formatRadioChanged) self.radioJsonCompact.connect("clicked", self.formatRadioChanged) self.radioJsonPretty.connect("clicked", self.formatRadioChanged) ## frame.add(radioBox) pack(hbox, frame) pack(hbox, gtk.Label(""), 1, 1) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) self.fcw.set_current_folder(deskDir) pack(self.vbox, self.fcw, 1, 1) #### self.vbox.show_all() self.formatRadioChanged()
def __init__(self): gtk.Window.__init__(self) self.initVars() ud.windowList.appendItem(self) ### self.resize(ud.screenW, 150) self.move(0, 0) self.set_title(_('Time Line')) self.set_decorated(False) self.connect('delete-event', self.closeClicked) self.connect('button-press-event', self.buttonPress) ### self.tline = TimeLine(self.closeClicked) self.connect('key-press-event', self.tline.keyPress) self.add(self.tline) self.tline.show() self.appendItem(self.tline)
def optionsChanged(self, widget=None, tags=[]): if not tags: tags = self.getData() tagObjList = ui.eventTags if self.eventType: if self.relatedCheck.get_active(): tagObjList = [ t for t in tagObjList if self.eventType in t.eventTypes ] self.treestore.clear() for t in tagObjList: self.treestore.append(( t.name, t.name in tags, ## True or False t.desc, t.usage, _(t.usage)))
def numPlus(self, plus): pos = self.get_position() text = toStr(self.get_text()) n = len(text) commaI = text.rfind(',', 0, pos) if commaI == -1: startI = 0 else: if text[commaI + 1] == ' ': startI = commaI + 2 else: startI = commaI + 1 nextCommaI = text.find(',', pos) if nextCommaI == -1: endI = n else: endI = nextCommaI dashI = text.find('-', startI, endI) if dashI != -1: #print('dashI=%r'%dashI) if pos < dashI: endI = dashI else: startI = dashI + 1 thisNumStr = text[startI:endI] #print(startI, endI, thisNumStr) if thisNumStr: thisNum = numDecode(thisNumStr) newNum = thisNum + plus if not self._min <= newNum <= self._max: return else: if plus > 0: newNum = self._max else: newNum = self._min newNumStr = _(newNum) newText = text[:startI] + newNumStr + text[endI:] self.set_text(newText) #print('new end index', endI - len(thisNumStr) + len(newNumStr)) self.set_position(pos) self.select_region( startI, endI - len(thisNumStr) + len(newNumStr), )
class YearWheelWindow(gtk.Window, ud.BaseCalObj): _name = "yearWheelWin" desc = _("Year Wheel") def __init__(self): gtk.Window.__init__(self) self.initVars() ud.windowList.appendItem(self) ### size = min(ud.screenW, ud.screenH) * 0.9 self.resize(size, size) self.move( (ud.screenW - size) / 2, (ud.screenH - size) / 2, ) self.set_title(self.desc) self.set_decorated(False) self.connect("delete-event", self.closeClicked) self.connect("button-press-event", self.onButtonPress) ### self._widget = YearWheel(self.closeClicked) self.connect("key-press-event", self._widget.keyPress) self.add(self._widget) self._widget.show() self.appendItem(self._widget) def closeClicked(self, arg=None, event=None): if ui.mainWin: self.hide() else: self.destroy() core.stopRunningThreads() gtk.main_quit() return True def onButtonPress(self, obj, gevent): if gevent.button == 1: self.begin_move_drag( gevent.button, int(gevent.x_root), int(gevent.y_root), gevent.time, ) return True return False
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Export')) self.vbox.set_spacing(10) #### dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.ResponseType.CANCEL) dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.ResponseType.OK) #### hbox = gtk.HBox() frame = gtk.Frame() frame.set_label(_('Format')) radioBox = gtk.VBox() ## self.radioIcs = gtk.RadioButton(label='iCalendar') self.radioJsonCompact = gtk.RadioButton(label=_('Compact JSON (StarCalendar)'), group=self.radioIcs) self.radioJsonPretty = gtk.RadioButton(label=_('Pretty JSON (StarCalendar)'), group=self.radioIcs) ## pack(radioBox, self.radioJsonCompact) pack(radioBox, self.radioJsonPretty) pack(radioBox, self.radioIcs) ## self.radioJsonCompact.set_active(True) self.radioIcs.connect('clicked', self.formatRadioChanged) self.radioJsonCompact.connect('clicked', self.formatRadioChanged) self.radioJsonPretty.connect('clicked', self.formatRadioChanged) ## frame.add(radioBox) pack(hbox, frame) pack(hbox, gtk.Label(''), 1, 1) pack(self.vbox, hbox) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('File')+':')) self.fpathEntry = gtk.Entry() self.fpathEntry.set_text(join(deskDir, 'events-%.4d-%.2d-%.2d'%core.getSysDate(DATE_GREG))) pack(hbox, self.fpathEntry, 1, 1) pack(self.vbox, hbox) #### self.groupSelect = GroupsTreeCheckList() swin = gtk.ScrolledWindow() swin.add(self.groupSelect) swin.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC) pack(self.vbox, swin, 1, 1) #### self.vbox.show_all() self.formatRadioChanged() self.resize(600, 600)
class PluginsTextColumn(Column): _name = 'pluginsText' desc = _('Plugins Text') expand = True customizeFont = True truncateText = False def __init__(self, wcal): Column.__init__(self, wcal) self.connect('draw', self.onExposeEvent) def onExposeEvent(self, widget=None, event=None): cr = self.getContext() self.drawBg(cr) self.drawTextList( cr, [[(line, '') for line in self.wcal.status[i].pluginsText.split('\n')] for i in range(7)])
def editGroupByPath(self, path): from scal3.ui_gtk.event.group.editor import GroupEditorDialog checkEventsReadOnly() # FIXME group, = self.getObjsByPath(path) if group.name == "trash": self.editTrash() elif group.isReadOnly(): showError(_( "Event group \"%s\" is synchronizing and read-only" ) % group.title, parent=self) else: group = GroupEditorDialog(group, parent=self).run() if group is None: return groupIter = self.trees.get_iter(path) for i, value in enumerate(self.getGroupRow(group)): self.trees.set_value(groupIter, i, value) self.onGroupModify(group)
def __init__(self, event): ## FIXME common.WidgetClass.__init__(self, event) ###### sizeGroup = gtk.SizeGroup(gtk.SizeGroupMode.HORIZONTAL) ###### hbox = gtk.HBox() label = gtk.Label(_('Start')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.startDateInput = DateButton() pack(hbox, self.startDateInput) ### pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_('Repeat Every ')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.weeksSpin = IntSpinButton(1, 99999) pack(hbox, self.weeksSpin) pack(hbox, gtk.Label(' ' + _(' Weeks'))) ### pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ###### hbox = gtk.HBox() label = gtk.Label(_('End')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) self.endDateInput = DateButton() pack(hbox, self.endDateInput) ### pack(hbox, gtk.Label(''), 1, 1) pack(self, hbox) ######### hbox = gtk.HBox() label = gtk.Label(_('Time')) label.set_alignment(0, 0.5) sizeGroup.add_widget(label) pack(hbox, label) ## self.dayTimeStartInput = HourMinuteButton() self.dayTimeEndInput = HourMinuteButton() ## pack(hbox, self.dayTimeStartInput) pack(hbox, gtk.Label(' ' + _('to') + ' ')) pack(hbox, self.dayTimeEndInput) pack(self, hbox)
def __init__(self, rule): self.rule = rule gtk.HBox.__init__(self) ### self.countLabel = gtk.Label("") pack(self, self.countLabel) ### self.trees = gtk.ListStore(str) self.dialog = None ### self.editButton = gtk.Button(_("Edit")) self.editButton.set_image( gtk.Image.new_from_stock( gtk.STOCK_EDIT, gtk.IconSize.BUTTON, )) self.editButton.connect("clicked", self.showDialog) pack(self, self.editButton)
def __init__(self, event): gtk.VBox.__init__(self) self.event = event self.vbox = gtk.VBox() pack(self, self.vbox) hbox = gtk.HBox() pack(hbox, gtk.Label(""), 1, 1) addButton = gtk.Button() addButton.set_label(_("_Add File")) addButton.set_image( gtk.Image.new_from_stock( gtk.STOCK_ADD, gtk.IconSize.BUTTON, )) addButton.connect("clicked", self.addClicked) pack(hbox, addButton) pack(self, hbox) self.show_all() self.newFiles = []
class CalObj(MyProgressBar, CustomizableCalObj): _name = "seasonPBar" desc = _("Season Progress Bar") def __init__(self): MyProgressBar.__init__(self) self.initVars() def onConfigChange(self, *a, **kw): self.update_font() def onDateChange(self, *a, **kw): from scal3.season import getSeasonNamePercentFromJd CustomizableCalObj.onDateChange(self, *a, **kw) name, frac = getSeasonNamePercentFromJd( ui.cell.jd, ui.seasonPBar_southernHemisphere) if rtl: percent = "%d%%" % (frac * 100) else: percent = "%%%d" % (frac * 100) self.set_text( _(name) + " - " + textNumEncode( percent, changeDot=True, )) self.set_fraction(frac) def optionsWidgetCreate(self): from scal3.ui_gtk.pref_utils import LiveCheckPrefItem if self.optionsWidget: return #### self.optionsWidget = gtk.HBox() prefItem = LiveCheckPrefItem( ui, "seasonPBar_southernHemisphere", label=_("Southern Hemisphere"), onChangeFunc=self.onDateChange, ) pack(self.optionsWidget, prefItem.getWidget()) #### self.optionsWidget.show_all()
def optionsWidgetCreate(self): from os.path import isabs from scal3.ui_gtk.mywidgets.icon import IconSelectButton if self.optionsWidget: return self.optionsWidget = gtk.VBox() ### iconPath = ui.wcal_toolbar_mainMenu_icon if not isabs(iconPath): iconPath = join(pixDir, iconPath) ### hbox = gtk.HBox() pack(hbox, gtk.Label(_("Icon") + " ")) self.iconSelect = IconSelectButton() self.iconSelect.set_filename(iconPath) self.iconSelect.connect("changed", self.onIconChanged) pack(hbox, self.iconSelect) pack(hbox, gtk.Label(""), 1, 1) pack(self.optionsWidget, hbox) self.optionsWidget.show_all()
def __init__(self, accountCombo=None): gtk.HBox.__init__(self) self.combo = AccountGroupCombo() pack(self, self.combo) ## button = gtk.Button( #stock=gtk.STOCK_CONNECT, ) button.set_label(_("Fetch")) button.connect("clicked", self.fetchClicked) pack(self, button) self.fetchButton = button ## label = gtk.Label() label.set_alignment(0.1, 0.5) pack(self, label, 1, 1) self.msgLabel = label ### if accountCombo: accountCombo.connect("changed", self.accountComboChanged)
def __init__(self, **kwargs): from scal3.ui_gtk.mywidgets.tz_combo import TimeZoneComboBoxEntry gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Time Zone')) #### dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), gtk.ResponseType.CANCEL) dialog_add_button(self, gtk.STOCK_OK, _('_OK'), gtk.ResponseType.OK) ### self.connect('response', self.onResponse) #### label = gtk.Label() label.set_markup(''.join([ _('"Time Zone" property is newly added to events') + '\n', _('But this property needs to be saved for current events') + '\n', _('Select the time zone for your current location') + '\n\n', '<small>', _('If you have been in a different time zone while adding some of your event, you need to edit those events manually and change the time zone' ) + '\n', _('Time zone for All-Day events will be disabled by default'), '</small>', ])) label.set_line_wrap(True) pack(self.vbox, label, 1, 1) #### hbox = gtk.HBox() self.timeZoneInput = TimeZoneComboBoxEntry() pack(hbox, gtk.Label(''), 1, 1) pack(hbox, self.timeZoneInput) pack(hbox, gtk.Label(''), 1, 1) hbox.set_border_width(20) pack(self.vbox, hbox, 1, 1) #### self.errorLabel = gtk.Label() pack(self.vbox, self.errorLabel, 1, 1) #### pack(self.vbox, gtk.Label(''), 1, 1) #### self.vbox.show_all()
def __init__(self, vertical, module, varName, texts, label=None): self.num = len(texts) self.module = module self.varName = varName if vertical: box = gtk.VBox() else: box = gtk.HBox() self._widget = box self.radios = [gtk.RadioButton(label=_(s)) for s in texts] first = self.radios[0] if label != None: pack(box, gtk.Label(label)) pack(box, gtk.Label(''), 1, 1) pack(box, first) for r in self.radios[1:]: pack(box, gtk.Label(''), 1, 1) pack(box, r) r.set_group(first) pack(box, gtk.Label(''), 1, 1) ## FIXME
class CalObj(gtk.HBox, CustomizableCalBox): _name = 'winContronller' desc = _('Window Controller') buttonClassList = (WinConButtonMin, WinConButtonMax, WinConButtonClose, WinConButtonSep) buttonClassDict = dict([(cls._name, cls) for cls in buttonClassList]) def __init__(self): gtk.HBox.__init__(self, spacing=ui.winControllerSpacing) self.set_property('height-request', 15) self.set_direction(gtk.TextDirection.LTR) ## FIXME self.initVars() ########### for bname, enable in ui.winControllerButtons: button = self.buttonClassDict[bname](self) button.enable = enable self.appendItem(button) self.set_property('can-focus', True) ################## self.gWin = ui.mainWin if self.gWin: self.gWin.winCon = self ## dirty FIXME ##gWin.connect('focus-in-event', self.windowFocusIn) ##gWin.connect('focus-out-event', self.windowFocusOut) self.winFocused = True def windowFocusIn(self, widget=None, event=None): for b in self.items: b.setFocus(False) self.winFocused = True return False def windowFocusOut(self, widget=None, event=None): for b in self.items: b.setInactive() self.winFocused = False return False def updateVars(self): CustomizableCalBox.updateVars(self) ui.winControllerButtons = self.getItemsData()
def __init__(self): self.module = locale_man self.varName = 'lang' ### ls = gtk.ListStore(GdkPixbuf.Pixbuf, str) combo = gtk.ComboBox() combo.set_model(ls) ### cell = gtk.CellRendererPixbuf() pack(combo, cell, False) combo.add_attribute(cell, 'pixbuf', 0) ### cell = gtk.CellRendererText() pack(combo, cell, True) combo.add_attribute(cell, 'text', 1) ### self._widget = combo self.ls = ls self.append(join(pixDir, 'computer.png'), _('System Setting')) for (key, data) in langDict.items(): self.append(data.flag, data.name)
def __init__(self, rule): self.rule = rule ##### gtk.HBox.__init__(self) ### combo = gtk.ComboBoxText() for item in rule.wmIndexNames: combo.append_text(item) pack(self, combo) self.nthCombo = combo ### combo = WeekDayComboBox() pack(self, combo) self.weekDayCombo = combo ### pack(self, gtk.Label(_(" of "))) ### combo = MonthComboBox(True) combo.build(rule.getMode()) pack(self, combo) self.monthCombo = combo
def updateVars(self): ## FIXME courseIndex = self.courseCombo.get_active() if courseIndex is None: showError(_('No course is selected'), ui.eventManDialog) raise RuntimeError('No courses is selected') else: self.event.courseId = self.courseIds[courseIndex] ## self.event.setDate(*tuple(self.dateInput.get_value())) ## self.event['dayTimeRange'].setRange( self.dayTimeStartCombo.get_value(), self.dayTimeEndCombo.get_value(), ) #### #self.event.summary = self.summaryEntry.get_text() self.event.description = self.descriptionInput.get_text() self.event.icon = self.iconSelect.get_filename() #### self.notificationBox.updateVars() self.event.updateSummary()
def __init__(self, **kwargs): gtk.Dialog.__init__(self, **kwargs) self.set_title(_('Export to %s') % 'HTML') ## parent=None FIXME #self.set_has_separator(False) ######## hbox = gtk.HBox(spacing=2) pack(hbox, gtk.Label(_('Month Range'))) combo = gtk.ComboBoxText() for t in ('Current Month', 'Whole Current Year', 'Custom'): combo.append_text(_(t)) pack(hbox, combo) pack(hbox, gtk.Label(''), 1, 1) self.combo = combo ### hbox2 = gtk.HBox(spacing=2) pack(hbox2, gtk.Label(_('from month'))) self.ymBox0 = YearMonthButton() pack(hbox2, self.ymBox0) pack(hbox2, gtk.Label(''), 1, 1) pack(hbox2, gtk.Label(_('to month'))) self.ymBox1 = YearMonthButton() pack(hbox2, self.ymBox1) pack(hbox, hbox2, 1, 1) self.hbox2 = hbox2 combo.set_active(0) pack(self.vbox, hbox) ######## self.fcw = gtk.FileChooserWidget(action=gtk.FileChooserAction.SAVE) pack(self.vbox, self.fcw, 1, 1) self.vbox.set_focus_child(self.fcw) ## FIXME self.vbox.show_all() combo.connect('changed', self.comboChanged) ## dialog_add_button(self, gtk.STOCK_CANCEL, _('_Cancel'), 1, self.onDelete) dialog_add_button(self, gtk.STOCK_SAVE, _('_Save'), 2, self.save) ## self.connect('delete-event', self.onDelete) try: self.fcw.set_current_folder(core.deskDir) except AttributeError: ## PyGTK < 2.4 pass
class EventsCountColumn(Column): _name = "eventsCount" desc = _("Events Count") customizeWidth = True customizeExpand = True def __init__(self, wcal): Column.__init__(self, wcal) ## self.connect("draw", self.onExposeEvent) def optionsWidgetCreate(self): if self.optionsWidget: return Column.optionsWidgetCreate(self) ### self.optionsWidget.show_all() def getDayTextData(self, i): n = len(self.wcal.status[i].eventsData) ## item["show"][1] FIXME if n > 0: line = _("%s events") % _(n) else: line = "" return [ (line, None), ] def onExposeEvent(self, widget=None, event=None): cr = self.getContext() self.drawBg(cr) ### w = self.get_allocation().width h = self.get_allocation().height ### self.drawTextList( cr, [self.getDayTextData(i) for i in range(7)], )
def plugTreevButtonPress(self, widget, gevent): b = gevent.button if b == 3: cur = self.plugTreeview.get_cursor()[0] if cur: i = cur[0] j = self.plugTreestore[i][0] plug = core.allPlugList[j] menu = gtk.Menu() ## item = labelStockMenuItem( "_About", gtk.STOCK_ABOUT, self.plugAboutClicked, ) item.set_sensitive(bool(plug.about)) menu.add(item) ## item = labelStockMenuItem( "_Configure", gtk.STOCK_PREFERENCES, self.plugConfClicked, ) item.set_sensitive(plug.hasConfig) menu.add(item) ## menu.add( labelImageMenuItem( _("Export to %s") % "iCalendar", "ical-32.png", self.plugExportToIcsClicked, plug, )) ## menu.show_all() self.tmpMenu = menu menu.popup(None, None, None, None, 3, gevent.time) return True return False
def __init__(self): from natz.tree import getZoneInfoTree gtk.HBox.__init__(self) model = gtk.TreeStore(str, bool) self.c = gtk.ComboBoxText.new_with_entry() pack(self, self.c, 1, 1) #gtk.ComboBoxText.__init__(self) self.c.set_model(model) self.c.set_entry_text_column(0) first_cell = self.c.get_cells()[0] # self.c.add_attribute(first_cell, "text", 0) # above line causes this warning: # Cannot connect attribute 'text' for cell renderer class # 'GtkCellRendererText' since 'text' is already attributed to column 0 self.c.add_attribute(first_cell, "sensitive", 1) self.c.connect("changed", self.onChanged) child = self.c.get_child() child.set_text(str(core.localTz)) #self.set_text(str(core.localTz)) ## FIXME ### self.get_text = child.get_text #self.get_text = self.c.get_active_text ## FIXME self.set_text = child.set_text ##### recentIter = model.append(None, [ _("Recent..."), False, ]) for tz_name in ui.localTzHist: model.append(recentIter, [tz_name, True]) ### self.appendOrderedDict( None, getZoneInfoTree(), )
def onResponse(self, dialog, responseId): if responseId == gtk.ResponseType.OK: timeZone = self.timeZoneInput.get_text() try: natz.gettz(timeZone) except Exception as e: self.errorLabel.set_text( _("Time zone is invalid") + "\n" + str(e)) else: try: for event in ui.iterAllEvents(): event.timeZone = timeZone event.afterModify() event.save() except Exception as e: self.errorLabel.set_text(str(e)) else: self.hide() else: self.hide() while gtk.events_pending(): gtk.main_iteration_do(False)
class WeekDaysColumn(Column): _name = 'weekDays' desc = _('Week Days') colorizeHolidayText = True showCursor = True customizeWidth = True customizeFont = True def __init__(self, wcal): Column.__init__(self, wcal) self.connect('draw', self.onExposeEvent) def onExposeEvent(self, widget=None, event=None): cr = self.getContext() self.drawBg(cr) self.drawTextList( cr, [[ (core.getWeekDayN(i), ''), ] for i in range(7)], ) self.drawCursorFg(cr)
class CalObj(gtk.ProgressBar, CustomizableCalObj): _name = 'seasonPBar' desc = _('Season Progress Bar') def __init__(self): gtk.ProgressBar.__init__(self) self.initVars() def onDateChange(self, *a, **kw): from scal3.season import getSeasonNamePercentFromJd CustomizableCalObj.onDateChange(self, *a, **kw) name, frac = getSeasonNamePercentFromJd(ui.cell.jd) if rtl: percent = '%d%%' % (frac * 100) else: percent = '%%%d' % (frac * 100) self.set_text( _(name) + ' - ' + textNumEncode( percent, changeDot=True, )) self.set_fraction(frac)
def getMoveToGroupSubMenu(self, path, group, event): ## returns a MenuItem instance item = labelStockMenuItem( _("Move to %s") % "...", None, ## FIXME ) subMenu = gtk.Menu() ### for new_group in ui.eventGroups: if new_group.id == group.id: continue #if not new_group.enable:## FIXME # continue if event.name in new_group.acceptsEventTypes: new_groupItem = ImageMenuItem() new_groupItem.set_label(new_group.title) ## image = gtk.Image() image.set_from_pixbuf( newColorCheckPixbuf( new_group.color, 20, True, )) new_groupItem.set_image(image) ## new_groupItem.connect( "activate", self.moveEventToGroupFromMenu, path, event, group, new_group, ) ## subMenu.add(new_groupItem) ## item.set_submenu(subMenu) return item