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(); }
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 ProgressDisplayBar() { Gtk.Builder builder = new Gtk.Builder(); builder.AddFromFile(FileResourcePath.GetDataPath("ui", "ProgressDisplayPlugin.ui")); builder.Autoconnect(this); this.Add(ProgressBarHBox); this.Hide(); }
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; }
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; }
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; }
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(); }
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(); }
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(); }
public ExportDialog(DataBook db, Gtk.Window mw) : base(Catalog.GetString("Export Bytes"), null, 0) { Gtk.Builder builder = new Gtk.Builder(); builder.AddFromFile(FileResourcePath.GetDataPath("ui", "ExportDialog.ui")); builder.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 LayoutSelectionDialog(DataBook db) : base(Catalog.GetString("Select Layout"), null, 0) { Gtk.Builder builder = new Gtk.Builder(); builder.AddFromFile(FileResourcePath.GetDataPath("ui", "LayoutSelectionDialog.ui")); builder.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); }
public ConversionTable(DataBook db) { Gtk.Builder builder = new Gtk.Builder(); builder.AddFromFile(FileResourcePath.GetDataPath("ui", "ConversionTablePlugin.ui")); builder.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(); }
public BlessMain(string[] args) { Application.Init(); // Catalog.Init(ConfigureDefines.GETTEXT_PACKAGE, ConfigureDefines.LOCALE_DIR); try { Portable.AddLocalFontFile(FileResourcePath.GetDataPath("bless-courier.ttf")); } catch (Exception) { System.Console.WriteLine("Warning: Could not add built-in Courier font, will fall back to system Courier font as needed."); } // load main window from GtkBuilder XML Gtk.Builder builder = new Gtk.Builder(); builder.AddFromFile(FileResourcePath.GetDataPath("ui", "MainWindow.ui")); builder.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)); 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(); }