From c7d3cb0ca81c473c3e025bc4b81170f9de8e1813 Mon Sep 17 00:00:00 2001 From: Olaf Schulz Date: Tue, 12 Nov 2019 16:10:04 +0100 Subject: [PATCH] Normalize code syntax --- src/app.vala | 16 +++---- src/config-manager.vala | 26 +++++------ src/key-overlay.vala | 56 ++++++++++++------------ src/keybinding-manager.vala | 4 +- src/main.vala | 20 ++++----- src/neo-window.vala | 86 +++++++++++++++++++------------------ src/scaling-image.vala | 6 +-- 7 files changed, 108 insertions(+), 106 deletions(-) diff --git a/src/app.vala b/src/app.vala index a53a0cb..bcd3002 100644 --- a/src/app.vala +++ b/src/app.vala @@ -31,7 +31,7 @@ namespace NeoLayoutViewer{ } protected override void activate () { - if (this.neo_win == null ) { + if (this.neo_win == null) { // Create the window of this application and show it this.neo_win = new NeoWindow (this); @@ -48,32 +48,32 @@ namespace NeoLayoutViewer{ #endif this.add_window(this.neo_win); - }else{ + } else { // reached if app.activate() called by remote instance this.neo_win.toggle(); } } - private void bind_shortcuts(){ + private void bind_shortcuts() { manager = new KeybindingManager(this.neo_win); var show_shortcut = configm.getConfig().get("show_shortcut").strip(); var move_shortcut = configm.getConfig().get("move_shortcut").strip(); var monitor_shortcut = configm.getConfig().get("monitor_shortcut").strip(); - if (move_shortcut.length > 0){ + if (move_shortcut.length > 0) { manager.bind(move_shortcut, ()=>{this.neo_win.numkeypad_move(0);}); } - if (show_shortcut == monitor_shortcut){ + if (show_shortcut == monitor_shortcut) { // combination of show + monitor move debug("Use combined shortcut for window showing and monitor switching."); manager.bind(monitor_shortcut, ()=>{this.neo_win.monitor_move(-1, true);}); - }else{ - if (monitor_shortcut.length > 0){ + } else { + if (monitor_shortcut.length > 0) { manager.bind(monitor_shortcut, ()=>{this.neo_win.monitor_move();}); } - if (show_shortcut.length > 0){ + if (show_shortcut.length > 0) { manager.bind(show_shortcut, ()=>{this.neo_win.toggle();}); } } diff --git a/src/config-manager.vala b/src/config-manager.vala index 4ce82f1..a01390b 100644 --- a/src/config-manager.vala +++ b/src/config-manager.vala @@ -20,10 +20,10 @@ namespace NeoLayoutViewer { string conffile2 = null; //1. Try to read conf file - foreach( var path in paths ){ + foreach (var path in paths) { string testfile = @"$(path)/$(conffile)"; debug(@"Search $(testfile)\n"); - if( search_config_file(testfile) ){ + if (search_config_file(testfile)) { conffile2 = testfile; debug(@"Found $(testfile)\n"); break; @@ -31,11 +31,11 @@ namespace NeoLayoutViewer { } //2. Try deprecated name with leading dot - if( conffile2 == null ){ - foreach( var path in paths ){ + if (conffile2 == null) { + foreach (var path in paths) { string testfile = @"$(path)/.$(conffile)"; debug(@"Search $(testfile)\n"); - if( search_config_file(testfile) ){ + if (search_config_file(testfile)) { conffile2 = testfile; debug(@"Found $(testfile)\n"); break; @@ -44,10 +44,10 @@ namespace NeoLayoutViewer { } //3. Try to write new conf file if read had failed - if( conffile2 == null ){ - foreach( var path in paths ){ + if (conffile2 == null) { + foreach (var path in paths) { string testfile = @"$(path)/$(conffile)"; - if( create_conf_file(testfile) > -1){ + if (create_conf_file(testfile) > -1) { debug(@"Create $(testfile)\n"); conffile2 = testfile; break; @@ -57,7 +57,7 @@ namespace NeoLayoutViewer { debug(@"Config file: $(conffile2)"); - if(search_config_file(conffile2)) + if (search_config_file(conffile2)) load_config_file(conffile2); add_intern_values(); @@ -80,7 +80,7 @@ namespace NeoLayoutViewer { Standard values. This vaules will be written in the config file if it was not found. */ - public void add_defaults(){ + public void add_defaults() { //config.set("show_shortcut", "n", "Toggle the visibility of the window."); addSetting("show_shortcut", "q", "Toggle the visibility of the window."); addSetting("on_top", "1", "Show window on top."); @@ -161,8 +161,8 @@ namespace NeoLayoutViewer { data_stream.put_string(e.key + " = " + e.value + "\n"); } } // Streams - catch ( GLib.IOError e){ return -1; } - catch ( GLib.Error e){ return -1; } + catch ( GLib.IOError e) { return -1; } + catch ( GLib.Error e) { return -1; } return 0; } @@ -187,7 +187,7 @@ namespace NeoLayoutViewer { if (comment.match(line)) continue; split = regex.split(line); - if(split.length>1){ + if (split.length>1) { this.config.set(split[0].strip(), split[1].strip()); } } diff --git a/src/key-overlay.vala b/src/key-overlay.vala index 0149bbc..d6deaf3 100644 --- a/src/key-overlay.vala +++ b/src/key-overlay.vala @@ -45,7 +45,7 @@ namespace NeoLayoutViewer { this.winMain.check_resize.connect(main_resized); } - private void main_resized(){ + private void main_resized() { int width; int height; @@ -53,13 +53,13 @@ namespace NeoLayoutViewer { //height = this.winMain.get_allocated_height(); this.winMain.get_size(out width, out height); - if( this._width == width && this._height == height ){ + if (this._width == width && this._height == height) { return; // to avoid infinite resize live lock... } debug(@"Window resize signal. New width/height: $(width)/$(height)"); - if( width == 1 && height == 1){ - return; // (1,1) send if user show/hides window very fast. + if (width == 1 && height == 1) { + return; // (1, 1) send if user show/hides window very fast. } this._width = width; @@ -132,7 +132,7 @@ namespace NeoLayoutViewer { gridCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, 96, false, 0); //free space gridCell(22.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, -1, false, -1); - // print,scroll,break + // print, scroll, break gridCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, 107, false, 0); gridCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, 78, false, 0); gridCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, 127, true, 0); @@ -367,7 +367,7 @@ namespace NeoLayoutViewer { int y = 0; // detach cells from grid - /*foreach (KeyEventCell w in this.eventCells.values){ + /*foreach (KeyEventCell w in this.eventCells.values) { this.remove(w); }*/ // Reset id. Number will increased in ever moveCell call @@ -407,7 +407,7 @@ namespace NeoLayoutViewer { moveCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, false); //free space moveCell(22.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, false); - // print,scroll,break + // print, scroll, break moveCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, false); moveCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, false); moveCell(44.0, 30.0, ref x_unscaled, ref y_unscaled, ref x, ref y, scaleX, scaleY, true); @@ -645,19 +645,19 @@ namespace NeoLayoutViewer { int width; int height; - if( x_unscaled + width_unscaled > win_width_unscaled){ + if (x_unscaled + width_unscaled > win_width_unscaled) { debug(@"AAAA cell too wide! Change from $(width_unscaled) to $(win_width_unscaled-x_unscaled)"); width_unscaled = win_width_unscaled - x_unscaled; width = win_width - x; - }else{ + } else { width = (int)GLib.Math.floor((x_unscaled + width_unscaled) * scaleX - x ); } - if( y_unscaled + height_unscaled > win_height_unscaled){ + if (y_unscaled + height_unscaled > win_height_unscaled) { debug(@"AAAA cell too tall! Change from $(height_unscaled) to $(win_height_unscaled-y_unscaled)"); height_unscaled = win_height_unscaled - y_unscaled; height = win_height - y; - }else{ + } else { height = (int)GLib.Math.floor((y_unscaled + height_unscaled) * scaleY - y ); } */ @@ -675,7 +675,7 @@ namespace NeoLayoutViewer { // Modifier, die andere Buchstabenebenen aktivieren. Zusätzlich Ebenen-Bild einblenden. cell = new KeyEventCell.modifier(winMain, width, height, width, height, keycode /*=modifier array index*/ ); break; - //Andere Modifier (CTRL, Alt,... ) + //Andere Modifier (CTRL, Alt, ... ) case 2: //left ctrl //cell = new KeyEventCell.modifier(winMain, width, height, width, height, keycode ); cell = new KeyEventCell.modifier2(winMain, width, height, width, height, keycode /*modifier array index */, "tastatur_ctrl_left_2.png" ); @@ -724,7 +724,7 @@ namespace NeoLayoutViewer { } // TODO - if (this.color_event_boxes && cell.get_children().length() == 0){ + if (this.color_event_boxes && cell.get_children().length() == 0) { Label l = new Label(""); // do not use non-empty string l.show(); @@ -760,19 +760,19 @@ namespace NeoLayoutViewer { int width; int height; - if( x_unscaled + width_unscaled > win_width_unscaled){ + if (x_unscaled + width_unscaled > win_width_unscaled) { debug(@"AAAA cell too wide! Change from $(width_unscaled) to $(win_width_unscaled-x_unscaled)"); width_unscaled = win_width_unscaled - x_unscaled; width = win_width - x; - }else{ + } else { width = (int)GLib.Math.floor((x_unscaled + width_unscaled) * scaleX - x ); } - if( y_unscaled + height_unscaled > win_height_unscaled){ + if (y_unscaled + height_unscaled > win_height_unscaled) { debug(@"AAAA cell too tall! Change from $(height_unscaled) to $(win_height_unscaled-y_unscaled)"); height_unscaled = win_height_unscaled - y_unscaled; height = win_height - y; - }else{ + } else { height = (int)GLib.Math.floor((y_unscaled + height_unscaled) * scaleY - y ); } */ @@ -822,7 +822,7 @@ namespace NeoLayoutViewer { Achtung, mittlerweile ist es die Identitätsabbildung, da die zwei redundanten Layer, die durch Caps-Lock entstehen, entfernt wurden. */ - private const short[] layer_permutation = {0,1,2,3,5,4,6}; + private const short[] layer_permutation = {0, 1, 2, 3, 5, 4, 6}; private KeyEventCell.all(NeoWindow winMain, double unscaled_width, double unscaled_height, int width, int height) { this.winMain = winMain; @@ -844,21 +844,21 @@ namespace NeoLayoutViewer { this.keysym = keysym; this.button_press_event.connect ((event) => { - if (event.button != 1){ + if (event.button != 1) { return false; } uint ks = this.keysym[NeoLayoutViewer.KeyEventCell.layer_permutation[winMain.layer] - 1]; - int modi = winMain.getActiveModifierMask({4,5}); //ctrl+alt mask + int modi = winMain.getActiveModifierMask({4, 5}); //ctrl+alt mask if (ks < 1) return false; #if _NO_WIN if (modi == 0 || true) { // Alt-Mask do not work :-( - keysend(ks,modi); + keysend(ks, modi); } else { //debug("Variante mit zweitem Modifier."); - keysend2(ks,modi & Gdk.ModifierType.CONTROL_MASK, modi & Gdk.ModifierType.MOD1_MASK); + keysend2(ks, modi & Gdk.ModifierType.CONTROL_MASK, modi & Gdk.ModifierType.MOD1_MASK); } #endif //GLib.stdout.printf(@"Key: $(ks)\n"); GLib.stdout.flush(); @@ -885,7 +885,7 @@ namespace NeoLayoutViewer { }); } - public KeyEventCell.modifier2(NeoWindow winMain, double unscaled_width, double unscaled_height, int width, int height, int modifier_index, string pressed_key_image ){ + public KeyEventCell.modifier2(NeoWindow winMain, double unscaled_width, double unscaled_height, int width, int height, int modifier_index, string pressed_key_image) { this.all(winMain, unscaled_width, unscaled_height, width, height); this.modifier_index = modifier_index; this.image_source_id = @"modifier_$(pressed_key_image)"; @@ -902,7 +902,7 @@ namespace NeoLayoutViewer { // store unscaled variant (TODO: redundant) winMain.image_buffer.set(this.image_source_id, modifier_pixbufs[0]); - }else{ + } else { modifier_pixbufs = { winMain.image_buffer.get(this.image_source_id) }; @@ -952,11 +952,11 @@ namespace NeoLayoutViewer { * that Gtk+ will actually give this size to the widget. */ - public override void get_preferred_width(out int minimum_width, out int natural_width){ + public override void get_preferred_width(out int minimum_width, out int natural_width) { minimum_width = width; natural_width = width; } - public override void get_preferred_height(out int minimum_height, out int natural_height){ + public override void get_preferred_height(out int minimum_height, out int natural_height) { minimum_height = height; natural_height = height; } @@ -966,12 +966,12 @@ namespace NeoLayoutViewer { // Wrapper to store array into hash map?! public class KeycodeArray { public uint[] val; - public KeycodeArray(uint[] val){ + public KeycodeArray(uint[] val) { this.val = val; } } - public Gee.HashMap generateKeysyms(){ + public Gee.HashMap generateKeysyms() { Gee.HashMap keysyms = new Gee.HashMap(); /* Define keyboard layout. this object maps the keycodes to the list of keycodes of each keyboard layer. */ diff --git a/src/keybinding-manager.vala b/src/keybinding-manager.vala index 9e15f99..26e67c6 100644 --- a/src/keybinding-manager.vala +++ b/src/keybinding-manager.vala @@ -177,7 +177,7 @@ namespace NeoLayoutViewer { if (xevent->type == X.EventType.KeyPress) { - foreach(Keybinding binding in bindings) { + foreach (Keybinding binding in bindings) { // remove NumLock, CapsLock and ScrollLock from key state uint event_mods = xevent.xkey.state & ~ (lock_modifiers[7]); @@ -194,7 +194,7 @@ namespace NeoLayoutViewer { /* Checks periodically which modifier are pressed. */ - private bool modifier_timer(){ + private bool modifier_timer() { unowned X.Display display = Gdk.X11.get_default_xdisplay(); checkModifier(display, &modifier_keycodes[0], modifier_keycodes.length, &modifier_pressed[0]); diff --git a/src/main.vala b/src/main.vala index 4adc508..52d75da 100644 --- a/src/main.vala +++ b/src/main.vala @@ -20,7 +20,7 @@ namespace NeoLayoutViewer{ // Try to find asset folder (images) string asset_folder = search_asset_folder( configm.getConfig().get("asset_folder") ); - if( asset_folder == null ){ + if (asset_folder == null) { stdout.printf(@"Application start failed because asset folder was not found.\nTry to set path manually in the config file '$(configm.used_config_path)'\n"); stdout.flush(); return 0; @@ -42,7 +42,7 @@ namespace NeoLayoutViewer{ if (app.is_remote) { print(@"Application is already running.\n"); app.activate(); - }else{ + } else { return app.run(args); } @@ -62,9 +62,9 @@ namespace NeoLayoutViewer{ var monitor_shortcut = configm.getConfig().get("monitor_shortcut").strip(); string tmp = ""; - if (show_shortcut == monitor_shortcut && false){ + if (show_shortcut == monitor_shortcut && false) { tmp = "Monitor wechseln/Ausblenden - %s".printf(show_shortcut); - }else{ + } else { tmp = """Ein-/Ausblenden - %s Monitor wechseln - %s""".printf(show_shortcut, monitor_shortcut); @@ -100,7 +100,7 @@ namespace NeoLayoutViewer{ } - private void center_window(Gtk.Window win){ + private void center_window(Gtk.Window win) { int screen_width = app.neo_win.get_screen_width(); int screen_height = app.neo_win.get_screen_height(); int x, y, w, h; @@ -114,7 +114,7 @@ namespace NeoLayoutViewer{ The folder will be assumed as right one if one required file was found. @return: assed folder or null. */ - private static string? search_asset_folder(string path){ + private static string? search_asset_folder(string path) { /*const*/ string filename = "/icons/Neo-Icon.png"; string[] paths = { @@ -124,17 +124,17 @@ namespace NeoLayoutViewer{ SHARED_ASSETS_PATH, // path given by Makefile }; - foreach( var p in paths ){ + foreach (var p in paths) { debug(@"Search assets in $(p)\n"); var file = File.new_for_path (p+filename); - if( file.query_exists(null)) return p; + if (file.query_exists(null)) return p; } - foreach( var s in GLib.Environment.get_system_data_dirs()){ + foreach (var s in GLib.Environment.get_system_data_dirs()) { var env_path = @"$(s)/NeoLayoutViewer/assets"; debug(@"Search assets in $(env_path)\n"); var file2 = File.new_for_path (env_path+filename); - if( file2.query_exists(null)) return env_path; + if (file2.query_exists(null)) return env_path; } return null; diff --git a/src/neo-window.vala b/src/neo-window.vala index 2b0e461..ac61a8e 100644 --- a/src/neo-window.vala +++ b/src/neo-window.vala @@ -29,7 +29,7 @@ namespace NeoLayoutViewer { this.active = new_state; if (this.active == 0) { modKeyImage.hide(); - }else{ + } else { modKeyImage.show(); } } @@ -55,7 +55,7 @@ namespace NeoLayoutViewer { private int _layer = 1; public int layer { get { return _layer; } - set { if (value < 1 || value > 6) { _layer = 1; }else{ _layer = value; } } + set { if (value < 1 || value > 6) { _layer = 1; } else { _layer = value; } } } public int[] active_modifier_by_keyboard; public int[] active_modifier_by_mouse; @@ -190,7 +190,7 @@ namespace NeoLayoutViewer { // Valid range: [1, 10*number_of_monitors - 1] position_cycle[j] = int.max(int.min(int.parse(split[i]), position_cycle.length-1), 1); - if ( position_cycle[j] == 0 ){ + if (position_cycle[j] == 0) { // Invalid number parsed (or parsing failed). Print error message and use predefined array GLib.stdout.printf("Position cycle reading failed. Problematic value: $(split[i])\n"); throw new PositionArrayParsingError.CODE_1A("Unexpected Integer"); @@ -198,18 +198,20 @@ namespace NeoLayoutViewer { GLib.assert( position_cycle[j] > 0 ); j++; - if (j%10 == 0){ j++; } + if (j%10 == 0) { j++; } } } catch (PositionArrayParsingError e) { fill_position_cycle_default(ref position_cycle); } catch (RegexError e) { fill_position_cycle_default(ref position_cycle); } + + debug("Position cycle map:"); for (int i = 0;i < position_cycle.length; i++) { - GLib.stdout.printf(@"$(i)=> $(position_cycle[i])\n"); + debug(@"$(i)=> $(position_cycle[i])"); } - if (app.start_layer > 0 ){ + if (app.start_layer > 0) { this.fix_layer = true; this.layer = app.start_layer; this.active_modifier_by_mouse[1] = this.LAYER_TO_MODIFIERS[this.layer-1, 0]; @@ -229,7 +231,7 @@ namespace NeoLayoutViewer { this.screen_dim[0] = int.max(1, int.parse(this.config.get("screen_width"))); } - if(screen_dim_auto[1]) { + if (screen_dim_auto[1]) { this.screen_dim[1] = this.get_screen_height(); this.screen_dim_auto[1] = false; // Disables further re-evaluations } else { @@ -296,12 +298,12 @@ namespace NeoLayoutViewer { //Nicht selektierbar (für virtuelle Tastatur) this.set_accept_focus((this.config.get("window_selectable") != "0")); - if( this.config.get("show_on_startup") != "0" ){ + if (this.config.get("show_on_startup") != "0") { //Move ist erst nach show() erfolgreich //this.numkeypad_move(int.parse(this.config.get("position"))); this.numkeypad_move(this.position_num); this.show(); - }else{ + } else { this.hide(); //this.numkeypad_move(int.parse(this.config.get("position"))); this.numkeypad_move(this.position_num); @@ -328,7 +330,7 @@ namespace NeoLayoutViewer { } } - public override void hide(){ + public override void hide() { //store current coordinates int tmpx; int tmpy; @@ -341,13 +343,13 @@ namespace NeoLayoutViewer { base.hide(); } - public bool toggle(){ - if(this.minimized) show(); + public bool toggle() { + if (this.minimized) show(); else hide(); return this.minimized; } - public void numkeypad_move(int pos){ + public void numkeypad_move(int pos) { var display = Gdk.Display.get_default(); //var screen = Gdk.Screen.get_default(); @@ -366,7 +368,7 @@ namespace NeoLayoutViewer { GLib.assert(n_monitors > 0); // Automatic set of next position - if( (pos%10) == 0 ){ + if ((pos%10) == 0) { /* Resolve next position */ pos = this.position_cycle[this.position_num]; } @@ -374,11 +376,11 @@ namespace NeoLayoutViewer { // Validate input for manual set of position. // Note that 'extra monitors', which are not respected in position_cycle, will be ignored. - if ( pos >= this.position_cycle.length ){ + if (pos >= this.position_cycle.length) { pos %= 10; // go back to first monitor } - if ( pos < 1 ){ + if (pos < 1) { GLib.stdout.printf(@"Positioning error! Can not handle $(pos). Fall back on pos=5.\n"); pos = 5; } @@ -395,7 +397,7 @@ namespace NeoLayoutViewer { // Get monitor for this position int monitor_index = pos/10; GLib.assert(monitor_index >= 0); - if (monitor_index >= n_monitors){ + if (monitor_index >= n_monitors) { monitor_index %= n_monitors; } @@ -416,11 +418,11 @@ namespace NeoLayoutViewer { Size user_size = this.size_for_monitor[this.monitor_id]; if (user_size != null && monitor_rect_dest.width == user_size.monitor_width /* catch resolution changes */ - ){ + ) { // Use stored values width = user_size.width; height = user_size.height; - }else{ + } else { // Default values width = get_image_width_for_monitor(monitor_rect_dest.width); height = get_unscaled_height() * width / get_unscaled_width(); @@ -438,7 +440,7 @@ namespace NeoLayoutViewer { this.get_size(out w, out h); // wrong if resolution changed?! TODO: Edit comment //this.get_size2(out w, out h); // this reflect resolution changes - if (w != width || h != height){ + if (w != width || h != height) { // Window should move on monitor where the window needs an other width. this.resize(width, height); this.set_default_size(width, height); @@ -501,24 +503,24 @@ namespace NeoLayoutViewer { this.move(x, y); } - public void monitor_move(int i_monitor=-1, bool hide_after_latest=false){ + public void monitor_move(int i_monitor=-1, bool hide_after_latest=false) { - if (hide_after_latest ){ - if (this.minimized ){ + if (hide_after_latest) { + if (this.minimized) { debug(@"Show minimized window again. $(this.position_num)"); show(); return; } } - if ( i_monitor < 0 ){ + if (i_monitor < 0) { numkeypad_move(this.position_num + 10); - }else{ + } else { numkeypad_move( 10 * i_monitor + (this.position_num % 10)); } debug(@"New position: $(this.position_num)"); - if( hide_after_latest && this.position_num < 10 && this.already_shown_on_monitor1 ){ + if (hide_after_latest && this.position_num < 10 && this.already_shown_on_monitor1) { // First monitor reached again debug(@"Hide window. $(this.position_num)"); @@ -531,7 +533,7 @@ namespace NeoLayoutViewer { this.position_on_hide_x = tmpx; this.position_on_hide_y = tmpy; } - if ( this.position_num < 10 ){ + if (this.position_num < 10) { this.already_shown_on_monitor1 = true; } } @@ -686,7 +688,7 @@ namespace NeoLayoutViewer { this.active_modifier_by_mouse[3] //neo-mod4 ] + 1; - }else{ + } else { this.layer = this.MODIFIER_MAP2[ this.active_modifier_by_keyboard[1] | this.active_modifier_by_mouse[1], //shift this.active_modifier_by_keyboard[2] | this.active_modifier_by_mouse[2], //neo-mod3 @@ -743,10 +745,10 @@ namespace NeoLayoutViewer { this.check_modifier(iet1); } - public int get_screen_width(){ + public int get_screen_width() { // Return value derived from config.get("screen_width")) or Gdk.Screen.width() - if( this.screen_dim_auto[0] ){ + if (this.screen_dim_auto[0]) { //Re-evaluate #if GTK_MINOR_VERSION == 18 || GTK_MINOR_VERSION == 19 || GTK_MINOR_VERSION == 20 || GTK_MINOR_VERSION == 21 @@ -760,7 +762,7 @@ namespace NeoLayoutViewer { var screen = this.get_screen(); var monitor = display.get_monitor_at_window(screen.get_active_window()); //Note that type of this is Gtk.Window, but get_active_window() return Gdk.Window - if( monitor == null){ + if (monitor == null) { monitor = display.get_primary_monitor(); } Gdk.Rectangle geometry = monitor.get_geometry(); @@ -786,10 +788,10 @@ namespace NeoLayoutViewer { return backgroundW_unscaled; } - public int get_screen_height(){ + public int get_screen_height() { // Return value derived from config.get("screen_height")) or Gdk.Screen.height() - if( this.screen_dim_auto[1] ){ + if (this.screen_dim_auto[1]) { //Re-evaluate #if GTK_MINOR_VERSION == 18 || GTK_MINOR_VERSION == 19 || GTK_MINOR_VERSION == 20 || GTK_MINOR_VERSION == 21 @@ -803,7 +805,7 @@ namespace NeoLayoutViewer { var screen = this.get_screen(); var monitor = display.get_monitor_at_window(screen.get_active_window()); //Note that type of this is Gtk.Window, but get_active_window() return Gdk.Window - if( monitor == null){ + if (monitor == null) { monitor = display.get_primary_monitor(); } Gdk.Rectangle geometry = monitor.get_geometry(); @@ -813,14 +815,14 @@ namespace NeoLayoutViewer { return screen_dim[1]; } - private void fill_position_cycle_default(ref int[] positions){ + private void fill_position_cycle_default(ref int[] positions) { /* Position Next position o ← o ← o 9 8 9 4 7 8 ↓ ↑ 6 5 6 ====> 1 3 9 o o o 3 2 3 2 3 6 ↓ ↘ ↑ o → o → o - Values for monitor 4 are 11,…,19 and so on. + Values for monitor 4 are 11, …, 19 and so on. Example output: positions = { @@ -833,7 +835,7 @@ namespace NeoLayoutViewer { GLib.assert( positions.length%10 == 0 && positions.length > 0); int n_monitors = positions.length/10; - for(int i_monitor=0; i_monitor < n_monitors; i_monitor++){ + for (int i_monitor=0; i_monitor < n_monitors; i_monitor++) { int s = i_monitor*10; positions[s] = -1; positions[s+1] = s + 2; @@ -848,7 +850,7 @@ namespace NeoLayoutViewer { } } - private void main_resized(){ + private void main_resized() { // Overwrite stored size for current monitor int width; @@ -857,7 +859,7 @@ namespace NeoLayoutViewer { Size user_size = this.size_for_monitor[this.monitor_id]; GLib.assert (user_size != null); - if (user_size != null ){ + if (user_size != null) { user_size.width = width; user_size.height = height; } @@ -871,15 +873,15 @@ namespace NeoLayoutViewer { private int _monitor_width; public int width { get { return _width; } - set { if (value < 1 ) { _width = 1; }else{ _width = value; } } + set { if (value < 1) { _width = 1; } else { _width = value; } } } public int height { get { return _height; } - set { if (value < 1 ) { _height = 1; }else{ _height = value; } } + set { if (value < 1) { _height = 1; } else { _height = value; } } } public int monitor_width { get { return _monitor_width; } - set { if (value < 1 ) { _monitor_width = 1; }else{ _monitor_width = value; } } + set { if (value < 1) { _monitor_width = 1; } else { _monitor_width = value; } } } } } diff --git a/src/scaling-image.vala b/src/scaling-image.vala index 1af0093..4e3c0eb 100644 --- a/src/scaling-image.vala +++ b/src/scaling-image.vala @@ -55,7 +55,7 @@ namespace NeoLayoutViewer { this.winMain.check_resize.connect(main_resized); } - private void main_resized(){ + private void main_resized() { // Get new window size int win_width2; @@ -71,8 +71,8 @@ namespace NeoLayoutViewer { debug(@"Window resize signal. New width/height: $(width)/$(height)\n"); - if( win_width2 == 1 && win_height2 == 1){ - return; // (1,1) send if user show/hides window very fast. + if (win_width2 == 1 && win_height2 == 1) { + return; // (1, 1) send if user show/hides window very fast. } // Eval new image size