Example #1
0
        ///<summary>Handle edit->undo command from menu</summary>
        public void OnContentsActivated(object o, EventArgs args)
        {
#if ENABLE_UNIX_SPECIFIC
            string helpScript = FileResourcePath.GetDataPath("help_script.sh");
            System.Diagnostics.Process.Start(helpScript);
#endif
        }
Example #2
0
        public SelectRangeWidget(DataBook db)
        {
            dataBook = db;

            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "SelectRangePlugin.ui"));
            builder.Autoconnect(this);

            // set up entry completions
            FromEntry.Completion            = new EntryCompletion();
            FromEntry.Completion.Model      = new ListStore(typeof(string));
            FromEntry.Completion.TextColumn = 0;

            ToEntry.Completion            = new EntryCompletion();
            ToEntry.Completion.Model      = new ListStore(typeof(string));
            ToEntry.Completion.TextColumn = 0;

            // set button sensitivity
            OnEntryChanged(null, null);

            this.Shown += OnWidgetShown;

            this.Add(SelectRangeHBox);
            this.ShowAll();
        }
Example #3
0
        public FindReplaceWidget(DataBook db, IFinder iFinder)
        {
            finder   = iFinder;
            dataBook = db;

            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "FindReplaceTable", "bless");
            gxml.Autoconnect(this);

            this.Shown += OnWidgetShown;
            SearchPatternEntry.Activated  += OnSearchPatternEntryActivated;
            ReplacePatternEntry.Activated += OnReplacePatternEntryActivated;

            SearchPatternEntry.FocusGrabbed  += OnFocusGrabbed;
            ReplacePatternEntry.FocusGrabbed += OnFocusGrabbed;

            SearchAsComboBox.Active  = 0;
            ReplaceAsComboBox.Active = 0;

            SearchPatternEntry.Completion            = new EntryCompletion();
            SearchPatternEntry.Completion.Model      = new ListStore(typeof(string));
            SearchPatternEntry.Completion.TextColumn = 0;

            ReplacePatternEntry.Completion            = new EntryCompletion();
            ReplacePatternEntry.Completion.Model      = new ListStore(typeof(string));
            ReplacePatternEntry.Completion.TextColumn = 0;

            // initialize replace pattern
            replacePattern = new byte[0];

            this.Add(FindReplaceTable);
            this.ShowAll();
        }
Example #4
0
        public FindReplaceWidget(DataBook db, IFinder iFinder)
        {
            finder   = iFinder;
            dataBook = db;

            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "FindReplacePlugin.ui"));
            builder.Autoconnect(this);

            this.Shown += OnWidgetShown;
            SearchPatternEntry.Activated  += OnSearchPatternEntryActivated;
            ReplacePatternEntry.Activated += OnReplacePatternEntryActivated;

            SearchPatternEntry.FocusGrabbed  += OnFocusGrabbed;
            ReplacePatternEntry.FocusGrabbed += OnFocusGrabbed;

            SearchAsComboBox.Active  = 0;
            ReplaceAsComboBox.Active = 0;

            SearchPatternEntry.Completion            = new EntryCompletion();
            SearchPatternEntry.Completion.Model      = new ListStore(typeof(string));
            SearchPatternEntry.Completion.TextColumn = 0;

            ReplacePatternEntry.Completion            = new EntryCompletion();
            ReplacePatternEntry.Completion.Model      = new ListStore(typeof(string));
            ReplacePatternEntry.Completion.TextColumn = 0;

            // initialize replace pattern
            replacePattern = new byte[0];

            this.Add(FindReplaceTable);
            this.ShowAll();
        }
        public LayoutSelectionDialog(DataBook db)
            : base(Catalog.GetString("Select Layout"), null, 0)
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "LayoutSelectionPaned", "bless");
            gxml.Autoconnect(this);

            dataBook = db;

            // create the preview area
            dataPreview = new DataView();
            ByteBuffer bb = new ByteBuffer();

            bb.Append(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, 0, 16);
            bb.Append(new byte[] { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, 0, 16);
            dataPreview.Buffer = bb;

            PreviewFrame.Add(dataPreview.Display);
            PreviewFrame.ShowAll();

            layoutDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "bless");
            layoutDir = System.IO.Path.Combine(layoutDir, "layouts");

            // Initialize list
            PopulateLayoutList();

            this.DefaultWidth  = 600;
            this.DefaultHeight = 300;
            this.Modal         = false;
            this.BorderWidth   = 6;
            this.HasSeparator  = false;
            this.AddButton(Gtk.Stock.Close, ResponseType.Close);
            this.AddButton(Gtk.Stock.Ok, ResponseType.Ok);
            this.Response += new ResponseHandler(OnDialogResponse);
            this.VBox.Add(LayoutSelectionPaned);
        }
Example #6
0
	public ExportDialog(DataBook db, Gtk.Window mw)
			: base(Catalog.GetString("Export Bytes"), null, 0)
	{
		Glade.XML gxml = new Glade.XML (FileResourcePath.GetDataPath("bless.glade"), "ExportDialogVBox", "bless");
		gxml.Autoconnect (this);

		dataBook = db;
		mainWindow = mw;
		pluginManager = PluginManager.GetForType(typeof(ExportPlugin));
		
		// initialize plugins if we have to
		if (pluginManager == null) {
			PluginManager.AddForType(typeof(ExportPlugin), new object[0]);
			pluginManager = PluginManager.GetForType(typeof(ExportPlugin));
		}
		
		exportFinishedEvent = new AutoResetEvent(false);

		SetupExportPlugins();

		ExportPatternComboEntry.Model = new ListStore (typeof (string));
		ExportPatternComboEntry.TextColumn = 0;
		LoadFromPatternFile((ListStore)ExportPatternComboEntry.Model);

		ProgressHBox.Visible = false;
		cancelClicked = false;

		this.Modal = false;
		this.BorderWidth = 6;
		this.HasSeparator = false;
		CloseButton = (Gtk.Button)this.AddButton(Gtk.Stock.Close, ResponseType.Close);
		ExportButton = (Gtk.Button)this.AddButton(Catalog.GetString("Export"), ResponseType.Ok);
		this.Response += new ResponseHandler(OnDialogResponse);
		this.VBox.Add(ExportDialogVBox);
	}
        public ProgressDisplayBar()
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "ProgressBarHBox", "bless");
            gxml.Autoconnect(this);

            this.Add(ProgressBarHBox);
            this.Hide();
        }
Example #8
0
        public ProgressDisplayBar()
        {
            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "ProgressDisplayPlugin.ui"));
            builder.Autoconnect(this);

            this.Add(ProgressBarHBox);
            this.Hide();
        }
Example #9
0
        void InitWidget()
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "SessionPreferencesVBox", "bless");
            gxml.Autoconnect(this);

            LoadPreviousSessionCheckButton.Toggled     += OnLoadPreviousSessionToggled;
            AskBeforeLoadingSessionCheckButton.Toggled += AskBeforeLoadingSessionToggled;
            RememberCursorPositionCheckButton.Toggled  += RememberCursorPositionToggled;
            RememberWindowGeometryCheckButton.Toggled  += RememberWindowGeometryToggled;
        }
Example #10
0
 public AboutDialog()
 {
     Artists     = new string[] { "Michael Iatrou" };
     Authors     = new string[] { "Alexandros Frantzis" };
     Copyright   = Catalog.GetString("Copyright 2004 - 2008 Alexandros Frantzis");
     ProgramName = "Bless";
     Version     = ConfigureDefines.VERSION;
     Comments    = Catalog.GetString("Bless is a Hex Editor for Gtk#");
     Website     = "http://home.gna.org/bless";
     Logo        = new Gdk.Pixbuf(FileResourcePath.GetDataPath("bless-about.png"));
 }
Example #11
0
        void InitWidget()
        {
            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "PreferencesDialog.ui"));
            builder.Autoconnect(this);

            LoadPreviousSessionCheckButton.Toggled     += OnLoadPreviousSessionToggled;
            AskBeforeLoadingSessionCheckButton.Toggled += AskBeforeLoadingSessionToggled;
            RememberCursorPositionCheckButton.Toggled  += RememberCursorPositionToggled;
            RememberWindowGeometryCheckButton.Toggled  += RememberWindowGeometryToggled;
        }
Example #12
0
        ///<summary>Handle edit->undo command from menu</summary>
        public void OnContentsActivated(object o, EventArgs args)
        {
            OperatingSystem os  = Environment.OSVersion;
            PlatformID      pid = os.Platform;

            if (pid == PlatformID.Unix)
            {
                string helpScript = FileResourcePath.GetDataPath("help_script.sh");
                System.Diagnostics.Process.Start(helpScript);
            }
        }
Example #13
0
        void InitWidget()
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "UndoPreferencesVBox", "bless");
            gxml.Autoconnect(this);

            UndoLimitedRadioButton.Toggled     += OnUndoLimitedToggled;
            UndoActionsSpinButton.ValueChanged += OnUndoActionsValueChanged;

            KeepUndoAlwaysRadioButton.Toggled += OnKeepUndoAlwaysToggled;
            KeepUndoMemoryRadioButton.Toggled += OnKeepUndoMemoryToggled;
            KeepUndoNeverRadioButton.Toggled  += OnKeepUndoNeverToggled;
        }
Example #14
0
        void InitWidget()
        {
            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "PreferencesDialog.ui"));
            builder.Autoconnect(this);

            UndoLimitedRadioButton.Toggled     += OnUndoLimitedToggled;
            UndoActionsSpinButton.ValueChanged += OnUndoActionsValueChanged;

            KeepUndoAlwaysRadioButton.Toggled += OnKeepUndoAlwaysToggled;
            KeepUndoMemoryRadioButton.Toggled += OnKeepUndoMemoryToggled;
            KeepUndoNeverRadioButton.Toggled  += OnKeepUndoNeverToggled;
        }
Example #15
0
        void InitWidget()
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "GeneralPreferencesVBox", "bless");
            gxml.Autoconnect(this);

            SelectTempDirButton.Clicked += OnSelectTempDirButtonClicked;
            SelectLayoutButton.Clicked  += OnSelectLayoutClicked;

            LayoutFileEntry.Changed             += OnLayoutFileChanged;
            UseCurrentLayoutCheckButton.Toggled += OnUseCurrentLayoutToggled;
            DefaultEditModeComboBox.Changed     += OnDefaultEditModeChanged;
            TempDirEntry.FocusOutEvent          += OnTempDirFocusOutEvent;
        }
Example #16
0
        void InitWidget()
        {
            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "PreferencesDialog.ui"));
            builder.Autoconnect(this);

            SelectTempDirButton.Clicked += OnSelectTempDirButtonClicked;
            SelectLayoutButton.Clicked  += OnSelectLayoutClicked;

            LayoutFileEntry.Changed             += OnLayoutFileChanged;
            UseCurrentLayoutCheckButton.Toggled += OnUseCurrentLayoutToggled;
            DefaultEditModeComboBox.Changed     += OnDefaultEditModeChanged;
            TempDirEntry.FocusOutEvent          += OnTempDirFocusOutEvent;
        }
Example #17
0
        public ProgressDialog(string primary, Gtk.Window main) : base(primary)
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "ProgressVBox", "bless");
            gxml.Autoconnect(this);

            // setup window
            this.SkipTaskbarHint = false;
            this.TypeHint        = Gdk.WindowTypeHint.Dialog;
            this.TransientFor    = main;
            this.BorderWidth     = 6;

            MessageLabel.Markup = "<span weight=\"bold\" size=\"larger\">" + primary + "</span>";

            this.Add(ProgressVBox);
            this.Hide();
        }
Example #18
0
        public ProgressDialog(string primary, Gtk.Window main) : base(primary)
        {
            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "ProgressDialog.ui"));
            builder.Autoconnect(this);

            // setup window
            this.SkipTaskbarHint = false;
            this.TypeHint        = Gdk.WindowTypeHint.Dialog;
            this.TransientFor    = main;
            this.BorderWidth     = 6;

            MessageLabel.Markup = "<span weight=\"bold\" size=\"larger\">" + primary + "</span>";

            this.Add(ProgressVBox);
            this.Hide();
        }
Example #19
0
        public GotoOffsetWidget(DataBook db)
        {
            dataBook = db;

            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "GotoOffsetHBox", "bless");
            gxml.Autoconnect(this);

            OffsetEntry.Completion            = new EntryCompletion();
            OffsetEntry.Completion.Model      = new ListStore(typeof(string));
            OffsetEntry.Completion.TextColumn = 0;

            // set button sensitivity
            OnOffsetEntryChanged(null, null);

            this.Shown += OnWidgetShown;

            this.Add(GotoOffsetHBox);
            this.ShowAll();
        }
        public BitwiseOperationsWidget(DataBook db, Gtk.Action action)
        {
            dataBook      = db;
            performAction = action;

            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "BitwiseOperationsHBox", "bless");
            gxml.Autoconnect(this);

            OperationComboBox.Active = 0;
            OperandAsComboBox.Active = 0;
            numberBase = 16;

            // set button sensitivity
            OnOperandEntryChanged(null, null);

            this.Shown += OnWidgetShown;

            this.Add(BitwiseOperationsHBox);
            this.ShowAll();
        }
Example #21
0
        public BitwiseOperationsWidget(DataBook db, Gtk.Action action)
        {
            dataBook      = db;
            performAction = action;

            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "BitwiseOperationsPlugin.ui"));
            builder.Autoconnect(this);

            OperationComboBox.Active = 0;
            OperandAsComboBox.Active = 0;
            numberBase = 16;

            // set button sensitivity
            OnOperandEntryChanged(null, null);

            this.Shown += OnWidgetShown;

            this.Add(BitwiseOperationsHBox);
            this.ShowAll();
        }
Example #22
0
        public PreferencesDialog(Window parent)
            : base(Catalog.GetString("Bless Preferences"), parent, DialogFlags.DestroyWithParent)
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "PreferencesPaned", "bless");
            gxml.Autoconnect(this);

            mainWindow = parent;

            generalPreferences = new GeneralPreferences(mainWindow);
            sessionPreferences = new SessionPreferences(mainWindow);
            undoPreferences    = new UndoPreferences(mainWindow);
            LoadPreferencesTreeView();

            this.Modal        = false;
            this.TransientFor = parent;
            this.BorderWidth  = 6;
            this.AddButton("Close", ResponseType.Close);
            this.Response += new ResponseHandler(OnDialogResponse);
            this.VBox.Add(PreferencesPaned);
            this.VBox.ShowAll();
        }
Example #23
0
        public PreferencesDialog(Window parent)
            : base(Catalog.GetString("Bless Preferences"), parent, DialogFlags.DestroyWithParent)
        {
            Gtk.Builder builder = new Gtk.Builder();
            builder.AddFromFile(FileResourcePath.GetDataPath("ui", "PreferencesDialog.ui"));
            builder.Autoconnect(this);

            mainWindow = parent;

            generalPreferences = new GeneralPreferences(mainWindow);
            sessionPreferences = new SessionPreferences(mainWindow);
            undoPreferences    = new UndoPreferences(mainWindow);
            LoadPreferencesTreeView();

            this.Modal        = false;
            this.TransientFor = parent;
            this.BorderWidth  = 6;
            this.AddButton(Gtk.Stock.Close, ResponseType.Close);
            this.Response += new ResponseHandler(OnDialogResponse);
            this.VBox.Add(PreferencesPaned);
            this.VBox.ShowAll();
        }
Example #24
0
        ///<summary>Create a DataViewDisplay</summary>
        public DataViewDisplay(DataView dv)
        {
            dataView = dv;

            // load the default layout from the data directory
            layout = new Layout(FileResourcePath.GetDataPath("bless-default.layout"));

            // initialize scrollbar
            Gtk.Adjustment
                adj = new Gtk.Adjustment(0.0, 0.0, 1.0, 1.0, 10.0, 0.0);
            vscroll = new Gtk.VScrollbar(adj);

            adj.ValueChanged += OnScrolled;

            // initialize drawing area
            drawingArea                 = new Gtk.DrawingArea();
            drawingArea.Realized       += OnRealized;
            drawingArea.ExposeEvent    += OnExposed;
            drawingArea.ConfigureEvent += OnConfigured;
            drawingArea.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xff));

            // add events that we want to handle
            drawingArea.AddEvents((int)Gdk.EventMask.ButtonPressMask);
            drawingArea.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
            drawingArea.AddEvents((int)Gdk.EventMask.PointerMotionMask);
            drawingArea.AddEvents((int)Gdk.EventMask.PointerMotionHintMask);
            drawingArea.AddEvents((int)Gdk.EventMask.KeyPressMask);
            drawingArea.AddEvents((int)Gdk.EventMask.KeyReleaseMask);

            drawingArea.CanFocus = true;     // needed to catch key events

            hbox = new Gtk.HBox();

            hbox.PackStart(drawingArea, true, true, 0);
            hbox.PackStart(vscroll, false, false, 0);

            this.PackStart(hbox);
        }
        public ConversionTable(DataBook db)
        {
            Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "ConversionTableWidget", "bless");
            gxml.Autoconnect(this);

            littleEndian  = true;
            unsignedAsHex = false;
            dataBook      = db;

            foreach (DataViewDisplay dvd in dataBook.Children)
            {
                OnDataViewAdded(dvd.View);
            }

            dataBook.PageAdded  += new DataView.DataViewEventHandler(OnDataViewAdded);
            dataBook.Removed    += new RemovedHandler(OnDataViewRemoved);
            dataBook.SwitchPage += new SwitchPageHandler(OnSwitchPage);

            Preferences.Proxy.Subscribe("Tools.ConversionTable.Show", "ct2", new PreferencesChangedHandler(OnPreferencesChanged));

            this.Add(ConversionTableWidget);
            this.ShowAll();
        }
Example #26
0
        ///<summary>Populate the layout list</summary>
        void PopulateLayoutList()
        {
            // specify the column types
            TreeStore ts = new TreeStore(typeof(string), typeof(string));

            TreeIter ti = ts.AppendValues(Catalog.GetString("System-wide Layouts"), string.Empty);

            // fill list from bless data dir
            string dataDir = FileResourcePath.GetDataPath("data");

            if (Directory.Exists(dataDir))
            {
                string[] files = Directory.GetFiles(dataDir, "*.layout");
                foreach (string s in files)
                {
                    ts.AppendValues(ti, System.IO.Path.GetFileName(s), s);
                }
            }

            ti = ts.AppendValues(Catalog.GetString("User Layouts"), string.Empty);

            // fill list from user layout dir
            if (Directory.Exists(layoutDir))
            {
                string[] files = Directory.GetFiles(layoutDir, "*.layout");
                foreach (string s in files)
                {
                    ts.AppendValues(ti, System.IO.Path.GetFileName(s), s);
                }
            }

            // Create the treeview
            LayoutList.Model = ts;
            LayoutList.AppendColumn("Layout", new CellRendererText(), "text", (int)LayoutColumn.Filename);
            LayoutList.ExpandAll();
            LayoutList.Selection.Changed += OnLayoutListSelectionChanged;
        }
Example #27
0
    public BlessMain(string[] args)
    {
        Application.Init();

        //
        Catalog.Init(ConfigureDefines.GETTEXT_PACKAGE, ConfigureDefines.LOCALE_DIR);

        // load main window from glade XML
        Glade.XML gxml = new Glade.XML(FileResourcePath.GetDataPath("bless.glade"), "MainWindow", "bless");
        gxml.Autoconnect(this);

        // set the application icon
        MainWindow.Icon = new Gdk.Pixbuf(FileResourcePath.GetDataPath("bless-48x48.png"));

        string blessConfDir = FileResourcePath.GetUserPath();

        // make sure local configuration directory exists
        try {
            if (!Directory.Exists(blessConfDir))
            {
                Directory.CreateDirectory(blessConfDir);
            }
        }
        catch (Exception ex) {
            ErrorAlert ea = new ErrorAlert(Catalog.GetString("Cannot create user configuration directory"), ex.Message + Catalog.GetString("\n\nSome features of Bless may not work properly."), MainWindow);
            ea.Run();
            ea.Destroy();
        }

        Preferences.Proxy.Enable = false;
        // load default preferences
        Preferences.Default.Load(FileResourcePath.GetDataPath("default-preferences.xml"));
        Preferences.Default["Default.Layout.File"] = FileResourcePath.GetDataPath("bless-default.layout");

        // load user preferences
        LoadPreferences(Path.Combine(blessConfDir, "preferences.xml"));
        Preferences.Instance.AutoSavePath = Path.Combine(blessConfDir, "preferences.xml");

        // add the (empty) Menubar and toolbar
        uiManager = new UIManager();
        MainWindow.AddAccelGroup(uiManager.AccelGroup);
        uiManager.AddUiFromString(uiXml);

        actionEntries = new ActionEntry[] {
            new ActionEntry("File", null, Catalog.GetString("_File"), null, null, null),
            new ActionEntry("Edit", null, Catalog.GetString("_Edit"), null, null, null),
            new ActionEntry("View", null, Catalog.GetString("_View"), null, null, null),
            new ActionEntry("Search", null, Catalog.GetString("_Search"), null, null, null),
            new ActionEntry("Tools", null, Catalog.GetString("_Tools"), null, null, null),
            new ActionEntry("Help", null, Catalog.GetString("_Help"), null, null, null)
        };

        ActionGroup group = new ActionGroup("MainMenuActions");

        group.Add(actionEntries);
        group.Add(new ToggleActionEntry[] {
            new ToggleActionEntry("ToolbarAction", null, Catalog.GetString("Toolbar"), null, null,
                                  new EventHandler(OnViewToolbarToggled), false)
        });

        uiManager.InsertActionGroup(group, 0);

        Widget mb = uiManager.GetWidget("/menubar");

        MainVBox.PackStart(mb, false, false, 0);
        MainVBox.ReorderChild(mb, 0);
        Widget tb = uiManager.GetWidget("/toolbar");

        tb.Visible = false;
        MainVBox.PackStart(tb, false, false, 0);
        MainVBox.ReorderChild(tb, 1);

        // create the DataBook
        dataBook             = new DataBook();
        dataBook.PageAdded  += new DataView.DataViewEventHandler(OnDataViewAdded);
        dataBook.Removed    += new RemovedHandler(OnDataViewRemoved);
        dataBook.SwitchPage += new SwitchPageHandler(OnSwitchPage);

        DataViewBox.PackStart(dataBook);


        // create the widget groups that hold utility widgets
        WidgetGroup widgetGroup0     = new WidgetGroup();
        WidgetGroup widgetGroup1     = new WidgetGroup();
        WidgetGroup sideWidgetGroup0 = new WidgetGroup();
        WidgetGroup sideWidgetGroup1 = new WidgetGroup();

        widgetGroup0.Show();
        widgetGroup1.Show();
        sideWidgetGroup0.Show();
        sideWidgetGroup1.Show();

        MainVBox.PackStart(widgetGroup0, false, false, 0);
        MainVBox.ReorderChild(widgetGroup0, 3);
        MainVBox.PackStart(widgetGroup1, false, false, 0);
        MainVBox.ReorderChild(widgetGroup1, 4);

        DataViewBox.PackStart(sideWidgetGroup0, false, false, 0);
        DataViewBox.ReorderChild(sideWidgetGroup0, 0);
        DataViewBox.PackEnd(sideWidgetGroup1, false, false, 0);
        //MainVBox.ReorderChild(widgetGroup1, 4);


        Services.File    = new FileService(dataBook, MainWindow);
        Services.Session = new SessionService(dataBook, MainWindow);
        Services.UI      = new UIService(uiManager);
        //Services.Info=new InfoService(infobar);

        // Add area plugins
        PluginManager.AddForType(typeof(AreaPlugin), new object[0]);
        PluginManager areaPlugins = PluginManager.GetForType(typeof(AreaPlugin));

        Area.InitiatePluginTable();
        foreach (AreaPlugin p in areaPlugins.Plugins)
        {
            Area.AddFactoryItem(p.Name, p.CreateArea);
        }

        // Load GUI plugins
        PluginManager.AddForType(typeof(GuiPlugin), new object[] { MainWindow, uiManager });
        PluginManager guiPlugins = PluginManager.GetForType(typeof(GuiPlugin));

        foreach (Plugin p in guiPlugins.Plugins)
        {
            guiPlugins.LoadPlugin(p);
        }

        // load recent file history
        try {
            History.Instance.Load(Path.Combine(blessConfDir, "history.xml"));
        }
        catch (Exception e) {
            System.Console.WriteLine(e.Message);
        }

        // if user specified files on the command line
        // try to load them
        if (args.Length > 0)
        {
            Services.File.LoadFiles(args);
        }
        else if (Preferences.Instance["Session.LoadPrevious"] == "True")
        {
            bool   loadIt          = true;
            string prevSessionFile = Path.Combine(blessConfDir, "last.session");

            if (Preferences.Instance["Session.AskBeforeLoading"] == "True" &&
                File.Exists(prevSessionFile))
            {
                MessageDialog md = new MessageDialog(MainWindow,
                                                     DialogFlags.DestroyWithParent,
                                                     MessageType.Question,
                                                     ButtonsType.YesNo, Catalog.GetString("Do you want to load your previous session?"));

                ResponseType result = (ResponseType)md.Run();
                md.Destroy();

                if (result == ResponseType.Yes)
                {
                    loadIt = true;
                }
                else
                {
                    loadIt = false;
                }
            }
            // try to load previous session
            if (loadIt)
            {
                Services.Session.Load(prevSessionFile);
            }
        }

        // if nothing has been loaded, create a new file
        if (dataBook.NPages == 0)
        {
            ByteBuffer bb = Services.File.NewFile();

            // create and setup a  DataView
            DataView dv = Services.File.CreateDataView(bb);

            // append the DataView to the DataBook
            dataBook.AppendView(dv, new CloseViewDelegate(Services.File.CloseFile), Path.GetFileName(bb.Filename));
        }

        PreferencesChangedHandler handler = new PreferencesChangedHandler(OnPreferencesChanged);

        Preferences.Proxy.Subscribe("View.Toolbar.Show", "mainwin", handler);


        // register drag and drop of files
        MainWindow.DragDataReceived += OnDragDataReceived;
        Gtk.Drag.DestSet(MainWindow, DestDefaults.Motion | DestDefaults.Drop, dropTargets, Gdk.DragAction.Copy | Gdk.DragAction.Move);

        DataViewBox.ShowAll();

        Preferences.Proxy.Enable = true;
        // fire the preferences changed event
        // so things are setup according to the preferences
        Preferences.Proxy.NotifyAll();

        Application.Run();
    }