Commit 3fbc68b4 authored by Sergio Costas's avatar Sergio Costas

Used Uncrustify to beutify the code

parent 2f12fa30
......@@ -2,7 +2,6 @@ using Gtk;
using Gdk;
namespace Terminus {
/**
* This is a Gtk.Paned that can be set to a percentage value, instead of
* having to use absolute values (which depends on the current size of
......@@ -10,7 +9,6 @@ namespace Terminus {
*/
public class PanedPercentage : Gtk.Paned {
private int current_paned_position;
private int current_paned_size;
private double desired_paned_percentage;
......@@ -18,10 +16,9 @@ namespace Terminus {
private bool horizontal;
public PanedPercentage(Gtk.Orientation orientation, double percentage) {
this.current_paned_position = -1;
this.current_paned_size = -1;
this.changed_paned_size = false;
this.current_paned_size = -1;
this.changed_paned_size = false;
this.orientation = orientation;
if (orientation == Gtk.Orientation.VERTICAL) {
......@@ -37,30 +34,28 @@ namespace Terminus {
*/
this.size_allocate.connect_after((allocation) => {
if (this.horizontal) {
if (this.current_paned_size != allocation.height) {
this.current_paned_size = allocation.height;
this.changed_paned_size = true;
if (this.current_paned_size != allocation.height) {
this.current_paned_size = allocation.height;
this.changed_paned_size = true;
}
} else {
if (this.current_paned_size != allocation.width) {
this.current_paned_size = allocation.width;
this.changed_paned_size = true;
if (this.current_paned_size != allocation.width) {
this.current_paned_size = allocation.width;
this.changed_paned_size = true;
}
}
});
this.draw.connect((cr) => {
if (changed_paned_size) {
this.current_paned_position=(int)(this.current_paned_size * this.desired_paned_percentage);
this.set_position(this.current_paned_position);
this.changed_paned_size = false;
this.current_paned_position = (int) (this.current_paned_size * this.desired_paned_percentage);
this.set_position(this.current_paned_position);
this.changed_paned_size = false;
} else {
if (this.position != this.current_paned_position) {
this.current_paned_position = this.position;
this.desired_paned_percentage = ((double)this.current_paned_position)/((double)this.current_paned_size);
if (this.position != this.current_paned_position) {
this.current_paned_position = this.position;
this.desired_paned_percentage = ((double) this.current_paned_position) / ((double) this.current_paned_size);
}
}
return false;
......
/*
Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
This file is part of Terminus
Terminus is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Terminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
* Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
*
* This file is part of Terminus
*
* Terminus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Terminus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
using Vte;
using Gtk;
namespace Terminus {
/**
* This is the main class, that contains everything. This class must be
* enclosed in a window.
*/
class Base : Gtk.Notebook {
public signal void ended();
public signal void new_window();
public Base() {
this.page_added.connect(this.check_pages);
this.page_removed.connect(this.check_pages);
this.new_terminal_tab();
}
public void new_terminal_tab() {
var term = new Terminus.Container(this,null);
term.ended.connect( (w) => {
var term = new Terminus.Container(this, null);
term.ended.connect((w) => {
this.delete_page(term);
});
term.show_all();
var page = this.append_page(term,term.notetab);
var page = this.append_page(term, term.notetab);
this.set_current_page(page);
}
......@@ -61,7 +57,6 @@ namespace Terminus {
}
public void check_pages(Gtk.Widget child, uint page_num) {
var npages = this.get_n_pages();
if (npages == 0) {
this.ended();
......@@ -74,7 +69,6 @@ namespace Terminus {
}
public void next_tab() {
var p = this.get_n_pages();
if (this.page + 1 == p) {
this.set_current_page(0);
......@@ -84,7 +78,6 @@ namespace Terminus {
}
public void prev_tab() {
if (this.page == 0) {
var p = this.get_n_pages();
this.set_current_page(p - 1);
......@@ -92,6 +85,5 @@ namespace Terminus {
this.prev_page();
}
}
}
}
/*
Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
This file is part of Terminus
Terminus is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Terminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
using Gtk,Gdk,Keybinder;
* Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
*
* This file is part of Terminus
*
* Terminus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Terminus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
using Gtk, Gdk, Keybinder;
namespace Terminus {
// This class is the one that manages the global keybind
public void keybind_cb(string key, void *udata) {
Bindkey obj = (Bindkey)udata;
Bindkey obj = (Bindkey) udata;
obj.show_guake();
}
class Bindkey : Object {
private string? key;
private string ? key;
private bool use_bindkey;
public signal void show_guake();
public Bindkey(bool use_bindkey) {
this.use_bindkey = use_bindkey;
if (this.use_bindkey) {
Keybinder.init();
......@@ -45,7 +41,6 @@ namespace Terminus {
}
public bool set_bindkey(string key) {
bool retval;
if (this.use_bindkey) {
......@@ -55,7 +50,7 @@ namespace Terminus {
}
this.key = key;
if (this.use_bindkey) {
retval = Keybinder.bind(key,Terminus.keybind_cb,this);
retval = Keybinder.bind(key, Terminus.keybind_cb, this);
if (retval == false) {
print("Failed to set the guake_mode bind key\n");
}
......@@ -70,7 +65,7 @@ namespace Terminus {
if (this.key == null) {
return;
}
Keybinder.unbind(this.key,Terminus.keybind_cb);
Keybinder.unbind(this.key, Terminus.keybind_cb);
this.key = null;
}
}
......
/*
Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
This file is part of Terminus
Terminus is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Terminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
* Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
*
* This file is part of Terminus
*
* Terminus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Terminus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
using Vte;
using Gtk;
using GLib;
namespace Terminus {
/**
* This is the terminal container. It can contain one terminal, or a Paned with
* two containers. It can be splited in two elements and reagruped in a single
......@@ -29,31 +28,29 @@ namespace Terminus {
*/
class Container : Gtk.Bin {
public Terminus.Container ? container1;
public Terminus.Container ? container2;
public Terminus.Notetab ? notetab;
public Terminus.Container? container1;
public Terminus.Container? container2;
public Terminus.Notetab? notetab;
private Terminus.Terminal? terminal;
private Terminus.PanedPercentage? paned;
private Terminus.Terminal ? terminal;
private Terminus.PanedPercentage ? paned;
private Terminus.Container top_container;
private Terminus.Base main_container;
public signal void ended(Terminus.Container who);
public Container(Terminus.Base main_container, Terminus.Terminal? terminal, Terminus.Container? top_container = null) {
public Container(Terminus.Base main_container, Terminus.Terminal ? terminal, Terminus.Container ? top_container = null) {
this.main_container = main_container;
if (top_container == null) {
this.top_container = this;
this.notetab = new Terminus.Notetab(this.main_container,this);
this.notetab = new Terminus.Notetab(this.main_container, this);
} else {
this.top_container = top_container;
this.notetab = null;
this.notetab = null;
}
if (terminal == null) {
this.terminal = new Terminus.Terminal(this.main_container,this.top_container);
this.terminal = new Terminus.Terminal(this.main_container, this.top_container);
} else {
this.terminal = terminal;
}
......@@ -62,7 +59,6 @@ namespace Terminus {
}
public void set_tab_title(string title) {
if (this.notetab != null) {
this.notetab.change_title(title);
}
......@@ -75,13 +71,12 @@ namespace Terminus {
this.terminal.split_horizontal.connect(this.split_horizontal_cb);
this.terminal.split_vertical.connect(this.split_vertical_cb);
this.paned = null;
this.paned = null;
this.container1 = null;
this.container2 = null;
}
public Gtk.Widget? get_current_child() {
public Gtk.Widget ? get_current_child() {
if (this.terminal != null) {
this.terminal.split_horizontal.disconnect(this.split_horizontal_cb);
this.terminal.split_vertical.disconnect(this.split_vertical_cb);
......@@ -114,9 +109,9 @@ namespace Terminus {
this.terminal.split_vertical.disconnect(this.split_vertical_cb);
this.terminal.ended.disconnect(this.ended_cb);
this.paned = new Terminus.PanedPercentage( horizontal ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL, 0.5);
this.container1 = new Terminus.Container(this.main_container,this.terminal, this.top_container);
this.container2 = new Terminus.Container(this.main_container,null, this.top_container);
this.paned = new Terminus.PanedPercentage(horizontal ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL, 0.5);
this.container1 = new Terminus.Container(this.main_container, this.terminal, this.top_container);
this.container2 = new Terminus.Container(this.main_container, null, this.top_container);
this.container1.ended.connect(this.ended_child);
this.container2.ended.connect(this.ended_child);
this.paned.add1(this.container1);
......@@ -135,7 +130,6 @@ namespace Terminus {
}
public void ended_child(Terminus.Container child) {
Terminus.Container old_container;
if (child == this.container1) {
......@@ -154,7 +148,7 @@ namespace Terminus {
this.set_terminal_child();
this.terminal.do_grab_focus();
} else {
this.paned = new_child as Terminus.PanedPercentage;
this.paned = new_child as Terminus.PanedPercentage;
this.container1 = old_container.container1;
this.container2 = old_container.container2;
this.container1.ended.connect(this.ended_child);
......
/*
Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
This file is part of Terminus
Terminus is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Terminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
* Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
*
* This file is part of Terminus
*
* Terminus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Terminus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
using Vte;
using Gtk;
namespace Terminus {
/**
* This is the widget put in each tab
*/
class Notetab : Gtk.Box {
private Terminus.Container top_container;
private Gtk.Label title;
private Terminus.Base main_container;
public Notetab(Terminus.Base main_container, Terminus.Container top_container) {
this.main_container = main_container;
this.top_container = top_container;
this.orientation = Gtk.Orientation.HORIZONTAL;
this.title = new Gtk.Label("");
this.main_container = main_container;
this.top_container = top_container;
this.orientation = Gtk.Orientation.HORIZONTAL;
this.title = new Gtk.Label("");
this.title.margin_end = 3;
var close_button = new Gtk.Button.from_icon_name("window-close");
this.pack_start(this.title,true,true);
this.pack_start(close_button,false,true);
this.pack_start(this.title, true, true);
this.pack_start(close_button, false, true);
this.show_all();
close_button.clicked.connect( () => {
close_button.clicked.connect(() => {
this.main_container.delete_page(this.top_container);
});
}
public void change_title(string new_title) {
this.title.label = new_title;
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
This file is part of Terminus
Terminus is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Terminus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
* Copyright 2016 (C) Raster Software Vigo (Sergio Costas)
*
* This file is part of Terminus
*
* Terminus is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Terminus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
using Gtk;
namespace Terminus {
class Fixed : Gtk.Fixed {
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) {
base.get_preferred_width(out minimum_width, out natural_width);
minimum_width = 1;
natural_width = 1;
}
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) {
base.get_preferred_height(out minimum_height, out natural_height);
minimum_height = 1;
natural_height = 1;
......@@ -36,7 +34,6 @@ namespace Terminus {
}
class Window : Gtk.Window {
public signal void ended(Terminus.Window window);
public signal void new_window();
......@@ -65,15 +62,14 @@ namespace Terminus {
#endif
}
public Window(bool guake_mode, Terminus.Base? terminal = null) {
this.is_guake = guake_mode;
public Window(bool guake_mode, Terminus.Base ? terminal = null) {
this.is_guake = guake_mode;
this.initialized = 0;
this.type_hint = Gdk.WindowTypeHint.NORMAL;
this.type_hint = Gdk.WindowTypeHint.NORMAL;
this.focus_on_map = true;
this.destroy.connect( (w) => {
this.destroy.connect((w) => {
this.ended(this);
});
......@@ -84,11 +80,11 @@ namespace Terminus {
}
this.terminal.ended.connect(this.ended_cb);
this.terminal.new_window.connect( () => {
this.terminal.new_window.connect(() => {
this.new_window();
});
this.show.connect_after( () => {
this.show.connect_after(() => {
GLib.Timeout.add(500, () => {
this.present();
return false;
......@@ -105,19 +101,19 @@ namespace Terminus {
}
this.map.connect(this.mapped);
this.realize.connect_after( () => {
this.realize.connect_after(() => {
this.set_size();
});
this.window_state_event.connect( (event) => {
this.window_state_event.connect((event) => {
if ((event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0) {
this.unmaximize();
this.set_size();
this.unmaximize();
this.set_size();
}
return false;
});
this.paned = new Gtk.Paned(Gtk.Orientation.VERTICAL);
this.paned = new Gtk.Paned(Gtk.Orientation.VERTICAL);
this.paned.wide_handle = true;
this.paned.events = Gdk.EventMask.BUTTON_PRESS_MASK|Gdk.EventMask.BUTTON_RELEASE_MASK|Gdk.EventMask.POINTER_MOTION_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK;
this.paned.events = Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK;
this.add(this.paned);
this.paned.add1(this.terminal);
this.fixed = new Terminus.Fixed();
......@@ -125,40 +121,40 @@ namespace Terminus {
this.paned.add2(fixed);
this.mouseY = -1;
this.paned.motion_notify_event.connect( (widget,event) => {
this.paned.motion_notify_event.connect((widget, event) => {
if (this.mouseY < 0) {
return false;
return false;
}
if ((event.state & Gdk.ModifierType.BUTTON1_MASK) == 0) {
this.mouseY = -1;
Terminus.settings.set_int("guake-height", this.current_size);
return false;
this.mouseY = -1;
Terminus.settings.set_int("guake-height", this.current_size);
return false;
}
int y;
y = (int)(event.y_root);
y = (int) (event.y_root);
int newval = y - this.mouseY;
this.current_size += newval;
this.mouseY = y;
this.resize(this.get_monitor_width(),this.current_size);
this.mouseY = y;
this.resize(this.get_monitor_width(), this.current_size);
this.paned.set_position(this.current_size);
return true;
});
this.paned.button_press_event.connect( (widget, event) => {
this.paned.button_press_event.connect((widget, event) => {
if (event.button != 1) {
return false;
return false;
}
int y;
y = (int)(event.y_root);
y = (int) (event.y_root);
this.mouseY = y;
return true;
});
this.paned.button_release_event.connect( (widget,event) => {
this.paned.button_release_event.connect((widget, event) => {
if (event.button != 1) {
return false;
return false;
}
this.mouseY = -1;
Terminus.settings.set_int("guake-height", this.current_size);
......@@ -174,7 +170,6 @@ namespace Terminus {
}
public void ended_cb() {
this.terminal.ended.disconnect(this.ended_cb);
this.destroy();
}
......@@ -185,7 +180,7 @@ namespace Terminus {
this.set_size();
}
private void set_properties(){
private void set_properties() {
this.stick();
this.set_keep_above(true);
this.set_skip_taskbar_hint(true);
......@@ -194,9 +189,9 @@ namespace Terminus {
}
private void set_size() {
this.move(0,0);
this.move(0, 0);
this.paned.set_position(this.current_size);
this.resize(this.get_monitor_width(),this.current_size);
this.resize(this.get_monitor_width(), this.current_size);
}
}
}
#
# My favorite format
#
newlines = LF # AUTO (default), CRLF, CR, or LF
indent_with_tabs = 1 # 1=indent to level only, 2=indent with tabs
input_tab_size = 8 # original tab size
output_tab_size = 4 # new tab size
indent_columns = output_tab_size
# indent_label = 0 # pos: absolute col, neg: relative column
indent_align_string = False # align broken strings
indent_brace = 0
indent_class = true
nl_start_of_file = remove
# nl_start_of_file_min = 0
nl_end_of_file = force
nl_end_of_file_min = 1
nl_max = 4
nl_before_block_comment = 2
nl_after_func_body = 2
nl_after_func_proto_group = 2
nl_assign_brace = remove # "= {" vs "= \n {"
nl_enum_brace = remove # "enum {" vs "enum \n {"
nl_union_brace = remove # "union {" vs "union \n {"
nl_struct_brace = remove # "struct {" vs "struct \n {"
nl_do_brace = remove # "do {" vs "do \n {"
nl_if_brace = remove # "if () {" vs "if () \n {"
nl_for_brace = remove # "for () {" vs "for () \n {"
nl_else_brace = remove # "else {" vs "else \n {"
nl_while_brace = remove # "while () {" vs "while () \n {"
nl_switch_brace = remove # "switch () {" vs "switch () \n {"
nl_func_var_def_blk = 0
nl_before_case = 1
nl_fcall_brace = remove # "foo() {" vs "foo()\n{"
nl_fdef_brace = remove # "int foo() {" vs "int foo()\n{"
nl_after_return = TRUE
nl_brace_while = remove
nl_brace_else = remove
nl_squeeze_ifdef = TRUE
pos_bool = trail # BOOL ops on trailing end
eat_blanks_before_close_brace = TRUE
eat_blanks_after_open_brace = TRUE
mod_paren_on_return = ignore # "return 1;" vs "return (1);"
mod_full_brace_if = force # "if (a) a--;" vs "if (a) { a--; }"
mod_full_brace_for = force # "for () a--;" vs "for () { a--; }"
mod_full_brace_do = force # "do a--; while ();" vs "do { a--; } while ();"
mod_full_brace_while = force # "while (a) a--;" vs "while (a) { a--; }"
sp_before_byref = remove
sp_before_semi = remove
sp_paren_paren = remove # space between (( and ))
sp_return_paren = force # "return (1);" vs "return(1);"
sp_sizeof_paren = remove # "sizeof (int)" vs "sizeof(int)"
sp_before_sparen = force # "if (" vs "if("
sp_after_sparen = force # "if () {" vs "if (){"
sp_after_cast = force # "(int) a" vs "(int)a"
sp_inside_braces = force # "{ 1 }" vs "{1}"
sp_inside_braces_struct = force # "{ 1 }" vs "{1}"
sp_inside_braces_enum = force # "{ 1 }" vs "{1}"
sp_inside_paren = remove