Fix dialog parents & Shortcuts

master
Crom (Thibaut CHARLES) 8 years ago
parent dacb8310e9
commit 063856457d
  1. 29
      source/window.d

@ -23,6 +23,7 @@ import gtk.Button;
import gtk.ScrolledWindow;
import gtk.AccelGroup;
import gtk.HBox;
import gdk.Keysyms;
import twoda;
@ -47,6 +48,7 @@ class Window : MainWindow{
auto buttonDelete = new Button("user-trash-symbolic", GtkIconSize.SMALL_TOOLBAR);
auto buttonRenumber = new Button("view-list-symbolic", GtkIconSize.SMALL_TOOLBAR);
auto buttonNewCol = new Button("tab-new-symbolic", GtkIconSize.SMALL_TOOLBAR);
auto buttonLocale = new Button("accessories-dictionary-symbolic", GtkIconSize.SMALL_TOOLBAR);
buttonSave.setTooltipText("Save");
buttonSaveAs.setTooltipText("Save as");
@ -55,10 +57,11 @@ class Window : MainWindow{
buttonDelete.setTooltipText("Delete row");
buttonRenumber.setTooltipText("Renumber all rows");
buttonNewCol.setTooltipText("Add new column");
buttonLocale.setTooltipText("Set locale table suffix");
enum GDK_KEY_S = 0x053;
buttonSave.addAccelerator("clicked", accel, GDK_KEY_S, GdkModifierType.CONTROL_MASK, GtkAccelFlags.VISIBLE);
buttonSaveAs.addAccelerator("clicked", accel, GDK_KEY_S, GdkModifierType.CONTROL_MASK|GdkModifierType.SHIFT_MASK, GtkAccelFlags.VISIBLE);
buttonOpen.addAccelerator("clicked", accel, GdkKeysyms.GDK_O, GdkModifierType.CONTROL_MASK, GtkAccelFlags.VISIBLE);
buttonSave.addAccelerator("clicked", accel, GdkKeysyms.GDK_S, GdkModifierType.CONTROL_MASK, GtkAccelFlags.VISIBLE);
buttonSaveAs.addAccelerator("clicked", accel, GdkKeysyms.GDK_S, GdkModifierType.CONTROL_MASK|GdkModifierType.SHIFT_MASK, GtkAccelFlags.VISIBLE);
//Header bar
import gtk.HeaderBar;
@ -69,6 +72,7 @@ class Window : MainWindow{
header.setProperty("show-close-button", true);
header.packStart(buttonOpen);
header.packStart(buttonLocale);
header.packEnd(buttonSaveAs);
header.packEnd(buttonSave);
@ -117,7 +121,7 @@ class Window : MainWindow{
buttonSaveAs.addOnClicked((Button){
import gtk.FileChooserDialog;
auto fc = new FileChooserDialog("Save 2DA as", window, FileChooserAction.SAVE);
auto fc = new FileChooserDialog("Save 2DA as", this, FileChooserAction.SAVE);
fc.setDoOverwriteConfirmation(true);
fc.setCreateFolders(true);
fc.setCurrentFolder(openedFile!=""? dirName(openedFile) : getcwd());
@ -132,7 +136,7 @@ class Window : MainWindow{
buttonOpen.addOnClicked((Button){
import gtk.FileChooserDialog;
auto fc = new FileChooserDialog("Open 2DA", window, FileChooserAction.OPEN);
auto fc = new FileChooserDialog("Open 2DA", this, FileChooserAction.OPEN);
fc.setSelectMultiple(false);
fc.setCurrentFolder(openedFile!=""? dirName(openedFile) : getcwd());
auto res = fc.run();
@ -233,12 +237,16 @@ class Window : MainWindow{
//setup cols
foreach(i ; 0..newColIndex+1){
tree.appendColumn(SetupColumn(tree, titles[i], i));
tree.appendColumn(setupColumn(tree, titles[i], i));
}
oldstore.destroy();
});
buttonLocale.addOnClicked((Button){
displayMessage("Not implemented");
});
//Open if exists
@ -383,7 +391,7 @@ class Window : MainWindow{
//Setup TreeView columns
foreach(index, s ; twoda.header){
auto col = SetupColumn(tree, s, index);
auto col = setupColumn(tree, s, index);
tree.appendColumn(col);
}
@ -415,7 +423,6 @@ class Window : MainWindow{
private:
MainWindow window;
HBox statusbar;
HeaderBar header;
@ -435,13 +442,13 @@ private:
return -1;
}
auto ref SetupColumn(TreeView tree, string sName, size_t index){
auto ref setupColumn(TreeView tree, string sName, size_t index){
auto store = cast(ListStore)tree.getModel();
CellRendererText cr = new CellRendererText();
cr.setProperty("editable", true);
if(index==0){
cr.setProperty("background-rgba", cast(ulong)(new GdkRGBA(0.36, 0.13, 0.4, 0.5)));
cr.setProperty("background-rgba", cast(ulong)(new GdkRGBA(0.5, 0.7, 1, 1)));
cr.setProperty("background-set", true);
cr.addOnEdited((string path, string newval, CellRendererText crt){
@ -478,7 +485,7 @@ private:
col.setReorderable(true);
col.addOnClicked((TreeViewColumn col){
import gtk.Dialog;
auto dlg = new Dialog("Column options", window, GtkDialogFlags.MODAL, ["Close"], [ResponseType.CANCEL]);
auto dlg = new Dialog("Column options", this, GtkDialogFlags.MODAL, ["Close"], [ResponseType.CANCEL]);
//Rename
dlg.getContentArea.packStart(new Label("Rename:"), false, false, 0);

Loading…
Cancel
Save