Commit 6aa8c95
Update windows file dialog
Changed files (6)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/Argument.valamodifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/FileDialogTab.valamodifiedlibbirdfont/MainWindow.valamodifiedlibbirdfont/TabContent.vala
Diff
@@ -427,12 +427,16 @@ public class GtkWindow : Gtk.Window, NativeWindow { public void file_chooser (string title, FileChooser fc, uint flags) { string? fn = null; - if ((flags & FileChooser.LOAD) > 0) {- fn = show_file_chooser (title, FileChooserAction.OPEN, Stock.OPEN);- } else if ((flags & FileChooser.SAVE) > 0) {- fn = show_file_chooser (title, FileChooserAction.SAVE, Stock.SAVE);- } else {- warning ("Unknown type");+ if (BirdFont.get_arguments () .has_argument ("--windows")) {+ MenuTab.show_file_dialog_tab (title, fc);+ } else { + if ((flags & FileChooser.LOAD) > 0) {+ fn = show_file_chooser (title, FileChooserAction.OPEN, Stock.OPEN);+ } else if ((flags & FileChooser.SAVE) > 0) {+ fn = show_file_chooser (title, FileChooserAction.SAVE, Stock.SAVE);+ } else {+ warning ("Unknown type");+ } } fc.selected (fn);@@ -71,7 +71,8 @@ public class Argument : GLib.Object { a == "--mac" || a == "--android" || a == "--log" ||- a == "--no-ucd") {+ a == "--no-ucd" ||+ a == "--windows") { prev = a; i++; continue;@@ -209,6 +210,8 @@ public class Argument : GLib.Object { return "--android"; case 'l': return "--log";+ case 'w': + return "--windows"; } return "";@@ -252,6 +255,7 @@ public class Argument : GLib.Object { print_padded ("-h, --help", t_("show this message")); print_padded ("-l, --log", t_("write a log file")); print_padded ("-m, --mac", t_("enable Machintosh customizations"));+ print_padded ("-w, --windows", t_("enable Windows customizations")); print_padded ("-n, --no-translation", t_("don't translate")); print_padded ("-s, --slow", t_("sleep between each command in test suite")); print_padded ("-t --test [TEST]", t_("run test case"));@@ -442,7 +442,9 @@ public class BirdFont { experimental = args.has_argument ("--test"); show_coordinates = args.has_argument ("--show-coordinates") || experimental; fatal_wanings = args.has_argument ("--fatal-warning");- win32 = (arg[0].index_of (".exe") > -1) || arg[0] == "wine";+ win32 = (arg[0].index_of (".exe") > -1) + || arg[0] == "wine"+ || args.has_argument ("--windows"); #if MAC mac = true;@@ -495,6 +497,10 @@ public class BirdFont { } } + public static Argument get_arguments () {+ return args;+ }+ void save_default_colors () { Theme.save_color ("Background 1", 1, 1, 1, 1); Theme.save_color ("Background 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);@@ -503,7 +509,7 @@ public class BirdFont { Theme.save_color ("Background 5", 0.3, 0.3, 0.3, 1); Theme.save_color ("Background 6", 224/255.0, 224/255.0, 224/255.0, 1); Theme.save_color ("Background 7", 56 / 255.0, 59 / 255.0, 65 / 255.0, 1);- Theme.save_color ("Background 7", 55/255.0, 55/255.0, 55/255.0, 1);+ Theme.save_color ("Background 8", 55/255.0, 55/255.0, 55/255.0, 1); Theme.save_color ("Background 9", 72/255.0, 72/255.0, 72/255.0, 1); Theme.save_color ("Foreground 1", 0, 0, 0, 1);@@ -1,5 +1,5 @@ /*- Copyright (C) 2014 Johan Mattsson+ Copyright (C) 2014 2015 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -141,7 +141,7 @@ public class FileDialogTab : FontDisplay { } public override void draw (WidgetAllocation allocation, Context cr) {- double y = 20 * MainWindow.units;+ double y = 75 * MainWindow.units; int s = 0; bool color = (scroll % 2) == 0; @@ -202,9 +202,16 @@ public class FileDialogTab : FontDisplay { cr.rectangle (0, y - 14 * MainWindow.units, allocation.width, 18 * MainWindow.units); cr.fill (); cr.restore ();+ } else {+ cr.save ();+ Theme.color (cr, "Background 1");+ cr.rectangle (0, y - 14 * MainWindow.units, allocation.width, 18 * MainWindow.units);+ cr.fill ();+ cr.restore (); } } + // text cr.save (); if (dark) { Theme.color (cr, "Background 1");@@ -218,7 +225,7 @@ public class FileDialogTab : FontDisplay { public override void button_release (int button, double ex, double ey) { int s = 0;- double y = 0;+ double y = 75 * MainWindow.units - 20 * MainWindow.units; string selected; bool dir = false; File f;@@ -248,6 +255,7 @@ public class FileDialogTab : FontDisplay { if (button == 1) { if (!dir) {+ selected_filename = selected; show_text_area (selected); } else { if (selected == "..") {@@ -268,6 +276,22 @@ public class FileDialogTab : FontDisplay { redraw_area (0, 0, allocation.width, allocation.height); } + public override void double_click (uint button, double ex, double ey) { + File f;++ button_release ((int) button, ex, ey);++ if (is_null (selected_filename)) {+ warning ("No file.");+ return;+ }+ + if (selected_filename != "") {+ f = get_child (current_dir, selected_filename);+ action.file_selected ((!)f.get_path ());+ }+ }+ public override string get_label () { return title; }@@ -281,14 +305,14 @@ public class FileDialogTab : FontDisplay { } public override void scroll_wheel_down (double x, double y) {- int nfiles = files.size + directories.size;+ double rows = 4.16 + files.size + directories.size; scroll += 3; - if (scroll > nfiles - visible_rows) {- scroll = (int) (nfiles - visible_rows);+ if (scroll > rows - visible_rows) {+ scroll = (int) (rows - visible_rows); } - if (visible_rows > nfiles) {+ if (visible_rows > rows) { scroll = 0; } @@ -308,19 +332,19 @@ public class FileDialogTab : FontDisplay { } public override void update_scrollbar () {- uint rows = files.size + directories.size;+ double rows = 4.16 + files.size + directories.size; // 4.16 rows under the text input if (rows == 0 || visible_rows == 0) { MainWindow.set_scrollbar_size (0); MainWindow.set_scrollbar_position (0); } else {- MainWindow.set_scrollbar_size ((double) visible_rows / rows);- MainWindow.set_scrollbar_position ((double) scroll / rows);+ MainWindow.set_scrollbar_size (visible_rows / rows);+ MainWindow.set_scrollbar_position (scroll / rows); } } public override void scroll_to (double percent) {- uint rows = files.size + directories.size;+ double rows = 4.16 + files.size + directories.size; scroll = (int) (percent * rows); if (scroll > rows - visible_rows) {@@ -214,7 +214,7 @@ public class MainWindow : GLib.Object { return singleton; } - public static void file_chooser (string title, FileChooser fc, uint flags) { + public static void file_chooser (string title, FileChooser fc, uint flags) { MainWindow.native_window.file_chooser (title, fc, flags); } @@ -1,5 +1,5 @@ /*- Copyright (C) 2014 Johan Mattsson+ Copyright (C) 2014 2015 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -284,11 +284,11 @@ public class TabContent : GLib.Object { Theme.text_color (text_input_label, "Background 1"); - text_input_label.allocation = allocation; text_input_label.widget_x = 10; text_input_label.widget_y = 17; text_input.allocation = allocation;+ text_input.layout (); text_input.widget_x = text_input_label.get_extent () + 20; text_input.widget_y = 10; text_input.width = allocation.width