root/trunk/umit/gui/SchedulerEdit.py @ 4789

Revision 4789, 25.1 kB (checked in by luis, 4 years ago)

Fixed #317. Now to show help documentation, it use a function from umit.gui.Help -> show_help. All calls outside wizard getting same error was fixed.

Line 
1# Copyright (C) 2007 Adriano Monteiro Marques
2#
3# Author: Guilherme Polo <ggpolo@gmail.com>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19import os
20import gtk
21from ConfigParser import ConfigParser
22
23from umit.core.Paths import Path
24from umit.core.I18N import _
25from umit.core.UmitConf import CommandProfile
26from umit.core.CronParser import CronParser
27from umit.core.Utils import open_url_as
28
29from higwidgets.higwindows import HIGWindow
30from higwidgets.higboxes import HIGVBox, HIGHBox, hig_box_space_holder
31from higwidgets.higlabels import HIGEntryLabel
32from higwidgets.higframe import HIGFrame
33from higwidgets.higbuttons import HIGButton
34from higwidgets.higtables import HIGTable
35from higwidgets.higdialogs import HIGAlertDialog
36
37from umit.gui.ProfileCombo import ProfileCombo
38from umit.gui.FileChoosers import DirectoryChooserDialog
39from umit.gui.Help import show_help
40
41pixmaps_dir = Path.pixmaps_dir
42   
43if pixmaps_dir:
44    logo = os.path.join(pixmaps_dir, 'wizard_logo.png')
45else:
46    logo = None
47
48class SchedSchemaEditor(HIGWindow):
49    """
50    Scheduler Schemas Editor
51    """
52   
53    def __init__(self, daddy=None):
54        HIGWindow.__init__(self)
55
56        self.daddy = daddy
57        self.wtitle = _("Scan Scheduler Editor")
58       
59        # header
60        self.title_markup = "<span size='16500' weight='heavy'>%s</span>"
61        self.ttitle = HIGEntryLabel("")
62        self.ttitle.set_line_wrap(False)
63        self.ttitle.set_markup(self.title_markup % self.wtitle)
64        self.umit_logo = gtk.Image()
65        self.umit_logo.set_from_file(logo)
66        # schemas name
67        self.schema_name_lbl = HIGEntryLabel(_("Schema Name"))
68        self.schema_name = gtk.combo_box_entry_new_text()
69        self.schema_name.connect('changed', self._check_schema)
70        # target and scan profiles
71        #self.target_lbl = HIGEntryLabel(_("Target"))
72        #self.target = gtk.Entry()
73        self.scan_name_lbl = HIGEntryLabel(_("Scan Profile"))
74        self.scan_name = ProfileCombo()
75        self.scan_name.update()
76        self.scan_name.set_active(0)
77        self.scan_name.connect('changed', self._set_scan_command)
78        # scan command
79        self.scan_command_lbl = HIGEntryLabel(_("Command"))
80        self.scan_command = gtk.Entry()
81        # scheduling profile
82        self.sched_name_lbl = HIGEntryLabel(_("Scheduling Profile"))
83        self.sched_name = gtk.combo_box_new_text()
84        self.sched_name_edit = gtk.Button(stock=gtk.STOCK_EDIT)
85        blbl = self.sched_name_edit.get_children()[0].get_children()[0].get_children()[1]
86        blbl.set_text(_("Edit Profiles"))
87        self.sched_name_edit.connect('clicked', self._edit_schedprofiles)
88        # schema settings
89        self.schema_sett_frame = HIGFrame()
90        self.setting_saveto = gtk.CheckButton(_("Save outputs to"))
91        self.setting_saveto_entry = gtk.Entry()
92        self.setting_saveto_browse = gtk.Button(_("..."))
93        self.setting_saveto_browse.connect('clicked', self._select_saveto)
94        self.setting_mailto = gtk.CheckButton(_("Send output to email"))
95        self.setting_mailto_entry = gtk.Entry()
96        self.setting_smtp_lbl = HIGEntryLabel(_("SMTP Schema"))
97        self.setting_smtp = gtk.combo_box_new_text()
98        self.setting_addtoinv = gtk.CheckButton(_("Add to the Inventory"))
99        self.setting_enabled = gtk.CheckButton(_("Enabled"))
100        # bottom buttons
101        self.help = HIGButton(stock=gtk.STOCK_HELP)
102        self.help.connect('clicked', self._show_help)
103        self.apply = HIGButton(stock=gtk.STOCK_APPLY)
104        self.apply.connect('clicked', self._save_schema)
105        self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
106        self.cancel.connect('clicked', self._exit)
107        self.ok = HIGButton(stock=gtk.STOCK_OK)
108        self.ok.connect('clicked', self._save_schema_and_leave)
109       
110        self.load_smtp_schemas()
111        self._set_scan_command(None)
112        self.profile_running = None # no SchedProfileEditor instance is running.
113        self._load_pscheds()
114        self.load_schemas()
115       
116        self.__set_props()
117        self.__do_layout()
118
119        self.connect('destroy', self._exit)
120       
121    def load_smtp_schemas(self):
122        """
123        Load smtp profiles.
124        """
125        schemas = ConfigParser()
126        schemas.read(Path.smtp_schemas)
127       
128        self.smtp_sections = [ ]
129        self.setting_smtp.get_model().clear()
130        for section in schemas.sections():
131            self.smtp_sections.append(section)
132            self.setting_smtp.append_text(section)
133           
134        self.setting_smtp.set_active(0)
135       
136
137    def load_schemas(self):
138        """
139        Load schemas profiles.
140        """
141        schemas = ConfigParser()
142        schemas.read(Path.sched_schemas)
143       
144        self.sections = [ ]
145        self.schema_name.get_model().clear()
146        for section in schemas.sections():
147            self.sections.append(section)
148            self.schema_name.append_text(section)
149           
150        self.schema_name.set_active(0)
151        self._check_schema(None)
152
153   
154    def _load_schema(self):
155        """
156        Load current set schedule schema.
157        """
158        schema = ConfigParser()
159        schema.read(Path.sched_schemas)
160       
161        values = {'command':self.scan_command.set_text,
162                  'saveto':self.setting_saveto_entry.set_text,
163                  'mailto':self.setting_mailto_entry.set_text}
164        enable = {'saveto':self.setting_saveto.set_active,
165                  'mailto':self.setting_mailto.set_active}
166       
167        for item in schema.items(self.schema_name.get_active_text()):
168            if item[0] == 'addtoinv':
169                self.setting_addtoinv.set_active(int(item[1]))
170                if item[1] == '2':
171                    self.apply.set_sensitive(False)
172                    self.ok.set_sensitive(False)
173                else:
174                    self.apply.set_sensitive(True)
175                    self.ok.set_sensitive(True)                   
176            elif item[0] == 'enabled':
177                self.setting_enabled.set_active(int(item[1]))
178            elif item[0] == 'profile':
179                pindx = self.profiles.index(item[1])
180                self.sched_name.set_active(pindx)
181            elif item[0] == 'smtp':
182                if item[1]:
183                    pindx = self.smtp_sections.index(item[1])
184                    self.setting_smtp.set_active(pindx)
185            else:
186                values[item[0]](item[1])
187                if item[0] in ('saveto', 'mailto'):
188                    if len(item[1]):
189                        enable[item[0]](True)
190                    else:
191                        enable[item[0]](False)
192           
193           
194    def _check_schema(self, event):
195        """
196        Check if current text in schema_name combobox is a schema name.
197        """
198        if self.schema_name.get_active_text() in self.sections: 
199            # load schema
200            self._load_schema()
201        else:
202            # reset to default values
203            self.apply.set_sensitive(True)
204            self.ok.set_sensitive(True)
205            self.setting_addtoinv.set_active(False)
206            self.setting_enabled.set_active(False)
207            self.setting_mailto.set_active(False)
208            self.setting_mailto_entry.set_text('')
209            self.setting_saveto.set_active(False)
210            self.setting_saveto_entry.set_text('')
211       
212        self.schema_sett_frame._set_label(self.schema_name.get_active_text() \
213+ " - Settings")
214           
215
216    def _set_scan_command(self, event):
217        """
218        Set scan command based on chosen profile.
219        """
220        profile = self.scan_name.get_selected_profile()
221        cmd_profile = CommandProfile()
222        command = cmd_profile.get_command(profile)
223        self.scan_command.set_text(command % '<target>')
224       
225   
226    def _load_pscheds(self):
227        """
228        Load scheduling profiles.
229        """
230        pscheds = ConfigParser()
231        pscheds.read(Path.sched_profiles)
232       
233        self.profiles = [ ]
234        self.sched_name.get_model().clear()
235        for section in pscheds.sections():
236            self.sched_name.append_text(section)
237            self.profiles.append(section)
238           
239        self.sched_name.set_active(0)
240   
241   
242    def _edit_schedprofiles(self, event):
243        """
244        Open Scheduling Profiles Editor.
245        """
246        if self.profile_running:
247            return
248       
249        win = SchedProfileEditor(self, self.sched_name.get_active_text())
250        win.show_all()
251        self.profile_running = win
252   
253   
254    def _select_saveto(self, event):
255        """
256        Select directory to save file.
257        """
258        dir_chooser = DirectoryChooserDialog(_("Select a directory"))
259       
260        dir_chooser.run()
261        dir_chosen = dir_chooser.get_filename()
262        dir_chooser.destroy()
263        self.setting_saveto_entry.set_text(dir_chosen)
264       
265   
266    def _save_schema(self, event):
267        """
268        Save current schema.
269        """
270        schema = self.schema_name.get_active_text()
271        command = self.scan_command.get_text()
272        schedule = self.sched_name.get_active_text()
273        mailto = self.setting_mailto.get_active()
274       
275        if not schema or not schedule or not command or '<target>' in command:
276            dlg = HIGAlertDialog(self, 
277                                 message_format=_('Scheduling Schema - Error\
278 while saving.'),
279                                 secondary_text=_("There is some error in at \
280least one of the following fields: \"Schema name\", \"Command\" or \"Scheduling\
281 Profile\"\n\nCheck if \"Schema name\" is not empty.\nCheck if \"Command\" does\
282 contain \"<target>\" on it.\nCheck if there is some \"Scheduling Profile\" \
283selected."))
284           
285            dlg.run()
286            dlg.destroy()
287            return
288       
289        if mailto and not self.setting_smtp.get_active_text():
290            dlg = HIGAlertDialog(self, 
291                                 message_format=_('Scheduling Schema - Error\
292 while saving.'),
293                                 secondary_text=_("You need to create a \
294a SMTP Schema for sending email."))
295           
296            dlg.run()
297            dlg.destroy()
298            return
299       
300        # check for output existance
301        if self.setting_saveto.get_active() and \
302           not os.path.isdir(self.setting_saveto_entry.get_text()):
303           
304            dlg = HIGAlertDialog(self, 
305                                 message_format=_('Scheduling Schema - Error\
306 while saving.'),
307                                 secondary_text=_("You especified an invalid \
308directory to save scans output."))
309           
310            dlg.run()
311            dlg.destroy()
312            return 
313   
314        # write schema to file
315        s_cfg = ConfigParser()
316        s_cfg.read(Path.sched_schemas)
317       
318        if not s_cfg.has_section(schema):
319            new_sec = True
320            s_cfg.add_section(schema)
321        else:
322            new_sec = False
323           
324        s_cfg.set(schema, 'profile', schedule)
325        s_cfg.set(schema, 'command', command)
326        if self.setting_enabled.get_active():
327            s_cfg.set(schema, 'enabled', '1')
328        else:
329            s_cfg.set(schema, 'enabled', '0')
330        if self.setting_addtoinv.get_active():
331            s_cfg.set(schema, 'addtoinv', '1')
332        else:
333            s_cfg.set(schema, 'addtoinv', '0')
334        if self.setting_saveto.get_active():
335            s_cfg.set(schema, 'saveto', self.setting_saveto_entry.get_text())
336        else:
337            s_cfg.set(schema, 'saveto', '')
338        if mailto:
339            s_cfg.set(schema, 'mailto', self.setting_mailto_entry.get_text())
340            s_cfg.set(schema, 'smtp', self.setting_smtp.get_active_text())
341        else:
342            s_cfg.set(schema, 'mailto', '')
343            s_cfg.set(schema, 'smtp', '')
344           
345        s_cfg.write(open(Path.sched_schemas, 'w'))
346       
347        if new_sec:
348            self.load_schemas()
349           
350        if self.daddy:
351            self.daddy.load_schemas()
352       
353
354    def _save_schema_and_leave(self, event):
355        """
356        Save current schema and close editor.
357        """
358        self._save_schema(None)
359        self._exit(None)
360
361
362    def _show_help(self, event):
363        """
364        Show help for Scan Scheduler Editor.
365        """
366        show_help(self, "scheduler.html#setting-up-a-schedule")
367
368    def __set_props(self):
369        """
370        Set window properties.
371        """
372        self.set_title(self.wtitle)
373        self.set_default_size(440, -1)
374
375    def __do_layout(self):
376        """
377        Layout widgets in window.
378        """
379        main_vbox = HIGVBox()
380        main_vbox.set_border_width(5)
381        main_vbox.set_spacing(12)
382        header_hbox = HIGHBox()
383        schema_table = HIGTable()
384        schedsn_hbox = HIGHBox()
385        sett_table = HIGTable()
386        btns_hbox = HIGHBox()
387
388        header_hbox._pack_expand_fill(self.ttitle)
389        header_hbox._pack_noexpand_nofill(self.umit_logo)
390       
391        # schema name
392        schema_table.attach_label(self.schema_name_lbl, 0, 1, 0, 1)
393        schema_table.attach_entry(self.schema_name, 1, 2, 0, 1)
394       
395        # target and scan profile
396        schema_table.attach_label(self.scan_name_lbl, 0, 1, 1, 2)
397        schema_table.attach_entry(self.scan_name, 1, 2, 1, 2)
398       
399        # scan command
400        schema_table.attach_label(self.scan_command_lbl, 0, 1, 2, 3)
401        schema_table.attach_label(self.scan_command, 1, 2, 2, 3)
402       
403        # scheduling profile
404        schedsn_hbox._pack_expand_fill(self.sched_name)
405        schedsn_hbox._pack_noexpand_nofill(self.sched_name_edit)
406
407        schema_table.attach_label(self.sched_name_lbl, 0, 1, 3, 4)
408        schema_table.attach_entry(schedsn_hbox, 1, 2, 3, 4)
409
410        # settings frame
411        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
412        settings_align.set_padding(6, 0, 12, 0)
413        schemasett_hbox = HIGVBox()
414       
415        # saveto
416        sett_hbox = HIGHBox()
417        sett_hbox._pack_expand_fill(self.setting_saveto_entry)
418        sett_hbox._pack_noexpand_nofill(self.setting_saveto_browse)
419        sett_table.attach_label(self.setting_saveto, 0, 1, 0, 1)
420        sett_table.attach_entry(sett_hbox, 1, 2, 0, 1)
421
422        # mailto, smtp
423        sett_hbox = HIGHBox()
424        sett_hbox._pack_expand_fill(self.setting_mailto_entry)
425        sett_hbox._pack_noexpand_nofill(self.setting_smtp_lbl)
426        sett_hbox._pack_expand_fill(self.setting_smtp)
427        sett_table.attach_label(self.setting_mailto, 0, 1, 1, 2)
428        sett_table.attach_entry(sett_hbox, 1, 2, 1, 2)
429        schemasett_hbox._pack_noexpand_nofill(sett_table)
430
431        # add to inventory
432        sett_hbox = HIGHBox()
433        sett_hbox._pack_noexpand_nofill(self.setting_addtoinv)
434        schemasett_hbox._pack_noexpand_nofill(sett_hbox)
435
436        # enabled/disabled
437        sett_hbox = HIGHBox()
438        sett_hbox._pack_noexpand_nofill(self.setting_enabled)
439        schemasett_hbox._pack_noexpand_nofill(sett_hbox) 
440        settings_align.add(schemasett_hbox)
441
442        self.schema_sett_frame.add(settings_align)
443       
444        # bottom buttons
445        btns_hbox.set_homogeneous(True)
446        btns_hbox._pack_expand_fill(self.help)
447        btns_hbox._pack_expand_fill(hig_box_space_holder())
448        btns_hbox._pack_expand_fill(self.apply)
449        btns_hbox._pack_expand_fill(self.cancel)
450        btns_hbox._pack_expand_fill(self.ok)
451       
452       
453        main_vbox._pack_noexpand_nofill(header_hbox)
454        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
455        main_vbox._pack_noexpand_nofill(schema_table)
456        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
457        main_vbox._pack_noexpand_nofill(self.schema_sett_frame)
458        main_vbox.pack_end(btns_hbox, False, False, 0)
459       
460        self.add(main_vbox)
461
462
463    def _exit(self, event):
464        """
465        Close current and window and profile editor if it is running.
466        """
467        if self.profile_running:
468            self.profile_running._exit(None)
469       
470        if self.daddy:
471            self.daddy.schemawin = None
472           
473        self.destroy()
474       
475
476    def _get_profile_running(self):
477        """
478        Get profile editor running instance.
479        """
480        return self.__profilerunning
481   
482   
483    def _set_profile_running(self, running):
484        """
485        Set profile editor instance.
486        """
487        self.__profilerunning = running
488
489
490    # Properties
491    profile_running = property(_get_profile_running, _set_profile_running)
492
493
494class SchedProfileEditor(HIGWindow):
495    """
496    Scheduling Profiles Editor
497    """
498   
499    def __init__(self, daddy, profile=None):
500        HIGWindow.__init__(self)
501        self.daddy = daddy
502       
503        self.wtitle = _("Scheduling Profiles Editor")
504        self.start_profile = profile
505       
506        # header
507        self.title_markup = "<span size='16500' weight='heavy'>%s</span>"
508        self.ttitle = HIGEntryLabel("")
509        self.ttitle.set_line_wrap(False)
510        self.ttitle.set_markup(self.title_markup % self.wtitle)
511        self.umit_logo = gtk.Image()
512        self.umit_logo.set_from_file(logo)
513        # profiles name
514        self.schedp_name_lbl = HIGEntryLabel(_("Scheduling Profile"))
515        self.schedp_name = gtk.combo_box_entry_new_text()
516        self.schedp_name.connect('changed', self._check_profile)
517        # cron format
518        self.cron_frame = HIGFrame(_("Schedule"))
519        self.cron_minute_lbl = HIGEntryLabel(_("Minute"))
520        self.cron_minute = gtk.Entry()
521        self.cron_hour_lbl = HIGEntryLabel(_("Hour"))
522        self.cron_hour = gtk.Entry()
523        self.cron_day_lbl = HIGEntryLabel(_("Day of month"))
524        self.cron_day = gtk.Entry()
525        self.cron_month_lbl = HIGEntryLabel(_("Month"))
526        self.cron_month = gtk.Entry()
527        self.cron_weekday_lbl = HIGEntryLabel(_("Weekday"))
528        self.cron_weekday = gtk.Entry()
529        # bottom buttons
530        self.help = HIGButton(stock=gtk.STOCK_HELP)
531        self.help.connect('clicked', self._show_help)
532        self.apply = HIGButton(stock=gtk.STOCK_APPLY)
533        self.apply.connect('clicked', self._save_profile)
534        self.cancel = HIGButton(stock=gtk.STOCK_CANCEL)
535        self.cancel.connect('clicked', self._exit)
536        self.ok = HIGButton(stock=gtk.STOCK_OK)
537        self.ok.connect('clicked', self._save_profile_and_leave)
538
539        self.load_profiles()
540        self.__set_props()
541        self.__do_layout()
542       
543        self.connect('destroy', self._exit)
544
545
546    def load_profiles(self):
547        """
548        Load scheduling profiles.
549        """
550        profiles = ConfigParser()
551        profiles.read(Path.sched_profiles)
552       
553        self.sections = [ ]
554        ind = 0
555        for indx, section in enumerate(profiles.sections()):
556            self.sections.append(section)
557            self.schedp_name.append_text(section)
558            if section == self.start_profile:
559                ind = indx
560           
561        self.schedp_name.set_active(ind)
562
563        self._check_profile(None)
564
565    def _load_profile(self):
566        """
567        Load current set schedule profile.
568        """
569        profile = ConfigParser()
570        profile.read(Path.sched_profiles)
571       
572        values = {'minute':self.cron_minute.set_text,
573                  'hour':self.cron_hour.set_text,
574                  'day':self.cron_day.set_text,
575                  'month':self.cron_month.set_text,
576                  'weekday':self.cron_weekday.set_text}
577       
578        for item in profile.items(self.schedp_name.get_active_text()):
579            values[item[0]](item[1])
580       
581
582    def _check_profile(self, event):
583        """
584        Check if current text in schedp_name combobox is a profile name.
585        """
586        if self.schedp_name.get_active_text() in self.sections:
587            self._load_profile()
588        else:
589            self.cron_minute.set_text('')
590            self.cron_hour.set_text('')
591            self.cron_day.set_text('')
592            self.cron_month.set_text('')
593            self.cron_weekday.set_text('')
594       
595
596    def _save_profile(self, event):
597        """
598        Save scheduling profile.
599        """
600        pname = self.schedp_name.get_active_text()
601        if not len(pname):
602            dlg = HIGAlertDialog(self, 
603                                 message_format=_('Scheduling Profile - Error \
604while saving'),
605                                 secondary_text=_("You need to specify a name \
606for Profile."))
607            dlg.run()
608            dlg.destroy()
609            return
610       
611        parser = CronParser()
612        minute = self.cron_minute.get_text()
613        hour = self.cron_hour.get_text()
614        day = self.cron_day.get_text()
615        month = self.cron_month.get_text()
616        weekday = self.cron_weekday.get_text()
617        try:
618            parser.parse_minute(minute)
619            parser.parse_hour(hour)
620            parser.parse_day(day)
621            parser.parse_month(month)
622            parser.parse_weekday(weekday)
623        except Exception, e:
624            dlg = HIGAlertDialog(self, 
625                                 message_format=_('Scheduling Profile - Error \
626while saving'),
627                                 secondary_text=_("Check your cron syntax and \
628try to save again."))
629            dlg.run()
630            dlg.destroy()
631            return
632       
633        # write profile to file
634        p_cfg = ConfigParser()
635        p_cfg.read(Path.sched_profiles)
636       
637       
638        if not p_cfg.has_section(pname):
639            new_sec = True
640            p_cfg.add_section(pname)
641        else:
642            new_sec = False
643           
644        p_cfg.set(pname, 'minute', minute)
645        p_cfg.set(pname, 'hour', hour)
646        p_cfg.set(pname, 'day', day)
647        p_cfg.set(pname, 'month', month)
648        p_cfg.set(pname, 'weekday', weekday)
649           
650        p_cfg.write(open(Path.sched_profiles, 'w'))
651       
652        if new_sec: # update daddy scheduling profiles list
653            self.daddy._load_pscheds()
654
655
656    def _save_profile_and_leave(self, event):
657        """
658        Save scheduling profile and leave.
659        """
660        self._save_profile(None)
661        self._exit(None)
662
663
664    def _show_help(self, event):
665        """
666        Show help for Scheduling Profiles.
667        """
668        show_help(self,"scheduler.html#creating-a-new-scheduling-profile")
669
670
671    def __set_props(self):
672        """
673        Set window properties
674        """
675        self.set_title(self.wtitle)
676
677
678    def __do_layout(self):
679        """
680        Layout window widgets.
681        """
682        main_vbox = HIGVBox()
683        main_vbox.set_border_width(5)
684        main_vbox.set_spacing(12)
685        header_hbox = HIGHBox()
686        schedp_hbox = HIGHBox()
687        cron_box = HIGVBox()
688        cron_table = HIGTable(5, 2)
689        btns_hbox = HIGHBox()
690       
691        header_hbox._pack_expand_fill(self.ttitle)
692        header_hbox._pack_noexpand_nofill(self.umit_logo)
693       
694        schedp_hbox._pack_noexpand_nofill(self.schedp_name_lbl)
695        schedp_hbox._pack_expand_fill(self.schedp_name)
696               
697        # cron format
698        settings_align = gtk.Alignment(0.5, 0.5, 1, 1)
699        settings_align.set_padding(6, 0, 12, 0)
700       
701        cron_table.attach(self.cron_minute_lbl, 0, 1, 0, 1)
702        cron_table.attach(self.cron_minute, 1, 2, 0, 1)
703        cron_table.attach(self.cron_hour_lbl, 0, 1, 1, 2)
704        cron_table.attach(self.cron_hour, 1, 2, 1, 2)
705        cron_table.attach(self.cron_day_lbl, 0, 1, 2, 3)
706        cron_table.attach(self.cron_day, 1, 2, 2, 3)
707        cron_table.attach(self.cron_month_lbl, 0, 1, 3, 4)
708        cron_table.attach(self.cron_month, 1, 2, 3, 4)
709        cron_table.attach(self.cron_weekday_lbl, 0, 1, 4, 5)
710        cron_table.attach(self.cron_weekday, 1, 2, 4, 5)
711
712        cron_box._pack_noexpand_nofill(cron_table)
713        settings_align.add(cron_box)
714        self.cron_frame.add(settings_align)
715       
716        # bottom buttons
717        btns_hbox.set_homogeneous(True)
718        btns_hbox._pack_expand_fill(self.help)
719        btns_hbox._pack_expand_fill(hig_box_space_holder())
720        btns_hbox._pack_expand_fill(self.apply)
721        btns_hbox._pack_expand_fill(self.cancel)
722        btns_hbox._pack_expand_fill(self.ok)
723       
724        main_vbox._pack_noexpand_nofill(header_hbox)
725        main_vbox._pack_noexpand_nofill(gtk.HSeparator())
726        main_vbox._pack_noexpand_nofill(schedp_hbox)
727        main_vbox._pack_noexpand_nofill(self.cron_frame)
728        main_vbox.pack_end(btns_hbox, False, False, 0)
729        self.add(main_vbox)
730       
731       
732    def _exit(self, event):
733        """
734        Close window and change profile editor instance on daddy.
735        """
736        self.daddy.profile_running = None
737        self.destroy()
738       
739
740if __name__ == "__main__":
741    w = SchedSchemaEditor()
742    w.show_all()
743    w.connect('destroy', gtk.main_quit)
744    gtk.main()
745   
Note: See TracBrowser for help on using the browser.