Commit 2ec1d188 authored by Gaute Hope's avatar Gaute Hope

Only add button and relevant fields visible when adding a new template in

* Only add button and relevant fields visible when adding a new template in the template manager.
* mainWindow.py: Using gtk.gdk.window.get_origin () to calculate calendar window position.

svn path=/trunk/; revision=1044
parent 10c27137
2007-12-26 Gaute Hope <eg@gaute.vetsj.com>
* Only add button and relevant fields visible when adding a new template in the template manager.
* mainWindow.py: Using gtk.gdk.window.get_origin () to calculate calendar window position.
2007-12-24 Gaute Hope <eg@gaute.vetsj.com>
* Don't show again is now translatable
......
......@@ -28,6 +28,8 @@ class AddWindow:
self.widget = self.xml.get_widget ("addWindow")
self.widget.connect("delete-event", self.widget.hide_on_delete)
self.mode = 0
self.cancel_button = self.xml.get_widget ("select_cancel_button")
self.ok_button = self.xml.get_widget ("select_ok_button")
......@@ -81,11 +83,17 @@ class AddWindow:
self.button_template.show_all ()
def ShowAddWindow (self, transient):
# mode: 0 = normal add, 1 = new template
def ShowAddWindow (self, transient, mode = 0):
self.mode = mode
self.transient = transient
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show_all()
if (mode == 1):
self.button_template.hide ()
elif (mode == 0):
self.button_template.show_all ()
def on_cancel_button_clicked (self, *args):
......@@ -98,10 +106,16 @@ class AddWindow:
def on_button_crontab_clicked (self, *args):
self.widget.hide ()
self.ParentClass.editor = self.ParentClass.crontab_editor
self.ParentClass.editor.showadd (self.transient)
if (self.mode == 1):
self.ParentClass.editor.shownew_template (self.transient)
elif (self.mode == 0):
self.ParentClass.editor.showadd (self.transient)
def on_button_at_clicked (self, *args):
self.widget.hide ()
self.ParentClass.editor = self.ParentClass.at_editor
self.ParentClass.editor.showadd (self.transient)
if (self.mode == 1):
self.ParentClass.editor.shownew_template (self.transient)
elif (self.mode == 0):
self.ParentClass.editor.showadd (self.transient)
......@@ -166,6 +166,27 @@ class AtEditor:
self.button_add_template.hide ()
self.__update_textboxes__()
def shownew_template (self, transient):
self.button_save.set_label (gtk.STOCK_ADD)
self.__reset__ ()
self.tid = 0
self.mode = 2 # edit template
self.widget.set_title(_("New template"))
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.__setup_calendar__ ()
self.widget.show_all ()
# hide time settings
self.at_vbox_time.hide ()
# save and cancel buttons
self.button_save.set_label (gtk.STOCK_ADD)
self.button_add_template.hide ()
self.__update_textboxes__()
def showedit (self, transient, record, job_id, iter):
self.button_save.set_label (gtk.STOCK_APPLY)
......@@ -249,10 +270,7 @@ class AtEditor:
self.__hide_calendar__ ()
def __show_calendar__ (self):
x, y = self.widget.get_position ()
xoff, yoff, i, j, k = self.widget.window.get_geometry ()
x = x + xoff
y = y + yoff
x, y = self.widget.window.get_origin ()
button_rect = self.cal_button.get_allocation ()
x = x + button_rect.x
y = y + button_rect.y + button_rect.height
......
......@@ -219,6 +219,23 @@ class CrontabEditor:
else:
self.cb_nooutput.set_active (False)
def shownew_template (self, transient):
self.button_apply.set_label (gtk.STOCK_ADD)
self.mode = 2
self.tid = 0
self.__reset__ ()
self.widget.set_title(_("New template"))
self.__update_textboxes__ ()
self.widget.set_transient_for(transient)
self.widget.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.widget.show ()
self.button_template.hide ()
def showedit (self, transient, record, job_id, linenumber, iter):
self.button_apply.set_label (gtk.STOCK_APPLY)
......
......@@ -129,7 +129,7 @@ class TemplateManager:
self.reload_tv ()
def on_new_clicked (self, *args):
self.parent.addWindow.ShowAddWindow (self.widget)
self.parent.addWindow.ShowAddWindow (self.widget, 1)
def on_delete_clicked (self, *args):
store, iter = self.treeview.get_selection().get_selected()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment