#   Programmer:  Antonio Barbosa
#   E-mail:      ab@jn.pt
#   Note:        Initial Release 22 Fev 2006
#

#Plugin
#RunTab1

import wx
import drScrolledMessageDialog
from drSourceBrowser import drSourceBrowserPanel

def OnAbout(DrFrame):
  Version = "0.0.1"
  NameAndVersion = "Runs first page: " + Version + "\n"
  AboutString = NameAndVersion + "By Antonio Barbosa"
  drScrolledMessageDialog.ShowMessage(DrFrame, AboutString, "About")

def OnHelp(DrFrame):
  HelpString = "Runs allways the first script.\n It is suposed to be the main one...\n"
  HelpString += "\n\nWhat does this plugin:\n"
  HelpString += "\t Saves Actual Document\n"
  HelpString += "\t Selects First Page\n"
  HelpString += "\t Runs First Page script\n"
  HelpString += "\t And finally, restores the previous working page\n"

  drScrolledMessageDialog.ShowMessage(DrFrame, HelpString, "Help")

def OnPreferences(DrFrame):
  DrFrame.ShowMessage("Nothing to configure ... ;)", "PREFS")

def Plugin(DrFrame):

  def OnRunTab1 (event):
    # First Save Actual Document
    DrFrame.OnSave(None)
    # Keep actual page
    _actualpage=DrFrame.documentnotebook.GetSelection ()
    # Select First Page
    DrFrame.documentnotebook.SetSelection (0)
    DrFrame.documentnotebook.SetTab()
    # Run First Page script
    DrFrame.OnRun(None)
    # And finally, restore previous page
    DrFrame.documentnotebook.SetSelection (_actualpage)
    DrFrame.documentnotebook.SetTab()

  DrFrame.AddPluginFunction("RunTab1", "Run Tab1", OnRunTab1)