Fix dialog parents & Shortcuts

This commit is contained in:
Crom (Thibaut CHARLES) 2015-03-13 15:38:41 +01:00
parent dacb8310e9
commit 063856457d

View File

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