Example #1
0
		internal GuiBuilderWindow (GuiBuilderProject fproject, Stetic.Project gproject, Stetic.WidgetInfo rootWidget)
		{
			this.fproject = fproject;
			this.rootWidget = rootWidget;
			this.gproject = gproject;
			name = rootWidget.Name;
			gproject.ProjectReloaded += OnProjectReloaded;
			rootWidget.Changed += OnChanged;
		}
		void Load ()
		{
			if (gproject != null || disposed || fileName == null)
				return;
			
			gproject = GuiBuilderService.SteticApp.CreateProject ();
			formInfos = new List<GuiBuilderWindow> ();
			
			if (!System.IO.File.Exists (fileName)) {
				// Regenerate the gtk-gui folder if the stetic project
				// doesn't exist.
				GtkDesignInfo.FromProject (project).UpdateGtkFolder ();
			}

			try {
				gproject.Load (fileName);
			} catch (Exception ex) {
				MessageService.ShowException (ex, GettextCatalog.GetString ("The GUI designer project file '{0}' could not be loaded.", fileName));
				hasError = true;
			}

			Counters.SteticProjectsLoaded++;
			gproject.ResourceProvider = GtkDesignInfo.FromProject (project).ResourceProvider;
			gproject.WidgetAdded += OnAddWidget;
			gproject.WidgetRemoved += OnRemoveWidget;
			gproject.ActionGroupsChanged += OnGroupsChanged;
			project.FileAddedToProject += OnFileAdded;
			project.FileRemovedFromProject += OnFileRemoved;
			project.ReferenceAddedToProject += OnReferenceAdded;
			project.ReferenceRemovedFromProject += OnReferenceRemoved;
			
			foreach (Stetic.WidgetInfo ob in gproject.Widgets)
				RegisterWindow (ob, false);
				
			// Monitor changes in the file
			lastSaveTime = System.IO.File.GetLastWriteTime (fileName);
			watcher = new FileSystemWatcher ();
			if (System.IO.File.Exists (fileName)) {
				watcher.Path = Path.GetDirectoryName (fileName);
				watcher.Filter = Path.GetFileName (fileName);
				watcher.Changed += (FileSystemEventHandler) DispatchService.GuiDispatch (new FileSystemEventHandler (OnSteticFileChanged));
				watcher.EnableRaisingEvents = true;
			}
		}	
		void Unload ()
		{
			if (gproject == null)
				return;

			Counters.SteticProjectsLoaded--;
			
			if (Unloaded != null)
				Unloaded (this, EventArgs.Empty);
			if (formInfos != null) {
				foreach (GuiBuilderWindow win in formInfos)
					win.Dispose ();
				formInfos = null;
			}
			if (gproject != null) {
				gproject.WidgetAdded -= OnAddWidget;
				gproject.WidgetRemoved -= OnRemoveWidget;
				gproject.ActionGroupsChanged -= OnGroupsChanged;
				gproject.Dispose ();
				gproject = null;
			}
			if (project != null) {
				project.FileAddedToProject -= OnFileAdded;
				project.FileRemovedFromProject -= OnFileRemoved;
				project.ReferenceAddedToProject -= OnReferenceAdded;
				project.ReferenceRemovedFromProject -= OnReferenceRemoved;
			}
			needsUpdate = true;
			hasError = false;
			librariesUpdated = false;
			if (watcher != null) {
				watcher.Dispose ();
				watcher = null;
			}
			NotifyChanged ();
		}
Example #4
0
		public Stetic.CodeGenerationResult GenerateCode (ArrayList projectFiles, bool useGettext, string gettextClass, bool usePartialClasses)
		{
			Gtk.Application.Init ();
			
			Stetic.Application app = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None);
			
			Stetic.Project[] projects = new Stetic.Project [projectFiles.Count];
			for (int n=0; n < projectFiles.Count; n++) {
				projects [n] = app.CreateProject ();
				projects [n].Load ((string) projectFiles [n]);
			}
			
			Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
			options.UseGettext = useGettext;
			options.GettextClass = gettextClass;
			options.UsePartialClasses = usePartialClasses;
			options.GenerateSingleFile = false;
			
			return app.GenerateProjectCode (options, projects);
		}
Example #5
0
        static int RunApp(string[] args, int n)
        {
            Project = SteticApp.CreateProject ();

            Project.WidgetAdded += OnWidgetAdded;
            Project.WidgetRemoved += OnWidgetRemoved;
            Project.ModifiedChanged += OnProjectModified;
            Project.ProjectReloaded += OnProjectReloaded;

            Palette = SteticApp.PaletteWidget;
            widgetTree = SteticApp.WidgetTreeWidget;
            Signals = SteticApp.SignalsWidget;
            propertyTree = SteticApp.PropertiesWidget;
            ProjectView = new WindowListWidget ();

            UIManager = new Stetic.UIManager (Project);

            Glade.XML.CustomHandler = CustomWidgetHandler;
            Glade.XML glade = new Glade.XML ("stetic.glade", "MainWindow");
            glade.Autoconnect (typeof (SteticMain));

            if (ProjectView.Parent is Gtk.Viewport &&
                ProjectView.Parent.Parent is Gtk.ScrolledWindow) {
                Gtk.Viewport viewport = (Gtk.Viewport)ProjectView.Parent;
                Gtk.ScrolledWindow scrolled = (Gtk.ScrolledWindow)viewport.Parent;
                viewport.Remove (ProjectView);
                scrolled.Remove (viewport);
                scrolled.AddWithViewport (ProjectView);
            }

            foreach (Gtk.Widget w in glade.GetWidgetPrefix ("")) {
                Gtk.Window win = w as Gtk.Window;
                if (win != null) {
                    win.AddAccelGroup (UIManager.AccelGroup);
                    win.ShowAll ();
                }
            }
            MainWindow = (Gtk.Window)Palette.Toplevel;
            WidgetNotebook = (Gtk.Notebook) glade ["notebook"];
            WidgetNotebook.SwitchPage += OnPageChanged;
            ProjectView.ComponentActivated += OnWidgetActivated;
            widgetTree.SelectionChanged += OnSelectionChanged;

            #if GTK_SHARP_2_6
            // This is needed for both our own About dialog and for ones
            // the user constructs
            Gtk.AboutDialog.SetUrlHook (ActivateUrl);
            #endif

            if (n < args.Length) {
                LoadProject (args [n]);
            }

            ReadConfiguration ();

            foreach (string s in Configuration.WidgetLibraries) {
                SteticApp.AddWidgetLibrary (s);
            }
            SteticApp.UpdateWidgetLibraries (false);

            ProjectView.Fill (Project);

            Program.Run ();
            return 0;
        }
Example #6
0
		void Load ()
		{
			if (gproject != null || disposed || folderName == null)
				return;
			
			GtkDesignInfo info = GtkDesignInfo.FromProject (project); 
			gproject = GuiBuilderService.SteticApp.CreateProject (info);
			formInfos = new List<GuiBuilderWindow> ();
			
//			TODO : when expanding project, UpdateGtkFolder causes in throwing exception by gtk
//			info.UpdateGtkFolder ();

			try {
				gproject.Load (folderName);
			} catch (Exception ex) {
				MessageService.ShowException (ex, GettextCatalog.GetString ("The GUI designer project folder '{0}' could not be loaded.", folderName));
				hasError = true;
			}

			Counters.SteticProjectsLoaded++;
			gproject.ResourceProvider = GtkDesignInfo.FromProject (project).ResourceProvider;
//			gproject.DesignInfo = info;
			gproject.WidgetAdded += OnAddWidget;
			gproject.WidgetRemoved += OnRemoveWidget;
			gproject.ActionGroupsChanged += OnGroupsChanged;
			project.FileAddedToProject += OnFileAdded;
			project.FileRemovedFromProject += OnFileRemoved;
			project.ReferenceAddedToProject += OnReferenceAdded;
			project.ReferenceRemovedFromProject += OnReferenceRemoved;
			
			foreach (Stetic.WidgetInfo ob in gproject.Widgets)
				RegisterWindow (ob, false);
		}