Commit 8b4e5c77 authored by Sergio Costas's avatar Sergio Costas

Removed deprecated calls

Now ensures that the top bar shows if the terminal has the focus

Now tries to ensure that a terminal always have the focus
parent 7addc220
......@@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "terminus")
set (RELEASE_NAME "terminus")
set (CMAKE_C_FLAGS "")
set (PREFIX ${CMAKE_INSTALL_PREFIX})
set (VERSION "0.5.0")
set (VERSION "0.6.0")
set (TESTSRCDIR "${CMAKE_SOURCE_DIR}")
set (DOLLAR "$")
configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.cmake ${CMAKE_BINARY_DIR}/src/Config.vala)
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
set (VERSION "0.5.0")
set (VERSION "0.6.0")
add_definitions (${DEPS_CFLAGS})
link_libraries ( ${DEPS_LIBRARIES} )
link_directories ( ${DEPS_LIBRARY_DIRS} )
......
......@@ -54,7 +54,6 @@ namespace Terminus {
if (terminal == null) {
this.terminal = new Terminus.Terminal(this.main_container,this.top_container);
this.terminal.grab_focus();
} else {
this.terminal = terminal;
}
......
......@@ -60,6 +60,11 @@ namespace Terminus {
public Terminal(Terminus.Base main_container, Terminus.Container top_container) {
this.map.connect_after( () => {
// this ensures that the title is updated when the window is shown
GLib.Timeout.add(500,update_title_cb);
});
this.main_container = main_container;
this.top_container = top_container;
this.orientation = Gtk.Orientation.VERTICAL;
......@@ -73,21 +78,29 @@ namespace Terminus {
this.pack_start(newbox,true,true);
this.vte_terminal = new Vte.Terminal();
this.vte_terminal.set_encoding(null); // by default, UTF-8
this.vte_terminal.window_title_changed.connect( () => {
this.vte_terminal.window_title_changed.connect_after( () => {
this.update_title();
});
this.vte_terminal.focus_in_event.connect( () => {
this.vte_terminal.focus_in_event.connect_after( (event) => {
this.update_title();
return false;
});
this.vte_terminal.focus_out_event.connect( () => {
this.vte_terminal.focus_out_event.connect_after( (event) => {
this.update_title();
return false;
});
this.vte_terminal.resize_window.connect( (x,y) => {
this.vte_terminal.resize_window.connect_after( (x,y) => {
this.update_title();
});
this.vte_terminal.map.connect_after( (w) => {
GLib.Timeout.add(500, () => {
this.vte_terminal.grab_focus();
return false;
});
});
Terminus.settings.bind("scroll-on-output",this.vte_terminal,"scroll_on_output",GLib.SettingsBindFlags.DEFAULT);
Terminus.settings.bind("scroll-on-keystroke",this.vte_terminal,"scroll_on_keystroke",GLib.SettingsBindFlags.DEFAULT);
......@@ -178,9 +191,6 @@ namespace Terminus {
this.vte_terminal.button_press_event.connect(this.button_event);
this.vte_terminal.events = Gdk.EventMask.BUTTON_PRESS_MASK;
this.update_title();
this.show_all();
// Set all the properties
settings_changed("infinite-scroll");
......@@ -202,6 +212,13 @@ namespace Terminus {
Terminus.keybind_settings.changed.connect(this.keybind_settings_changed);
this.vte_terminal.key_press_event.connect(this.on_key_press);
this.show_all();
this.update_title();
}
public bool update_title_cb() {
this.update_title();
return false;
}
public void keybind_settings_changed(string key) {
......@@ -309,17 +326,18 @@ namespace Terminus {
private void update_title() {
string title = this.vte_terminal.get_window_title();
if (title == null) {
title = this.vte_terminal.get_current_file_uri();
string s_title = this.vte_terminal.get_window_title();
if (s_title == null) {
s_title = this.vte_terminal.get_current_file_uri();
}
if (title == null) {
title = this.vte_terminal.get_current_directory_uri();
if (s_title == null) {
s_title = this.vte_terminal.get_current_directory_uri();
}
if (title == null) {
title = "/bin/bash";
if (s_title == null) {
s_title = "/bin/bash";
}
this.top_container.set_tab_title(title);
this.top_container.set_tab_title(s_title);
var bgcolor = Gdk.RGBA();
string fg;
string bg;
......@@ -338,16 +356,16 @@ namespace Terminus {
fg = "#000000";
bg = "#AAAAAA";
}
this.title.label = "<span foreground=\"%s\" background=\"%s\" size=\"small\">%s %ldx%ld</span>".printf(fg,bg,title,this.vte_terminal.get_column_count(),this.vte_terminal.get_row_count());
this.titlebox.override_background_color(Gtk.StateFlags.NORMAL,bgcolor);
this.title.use_markup = true;
this.title.label = "<span foreground=\"%s\" background=\"%s\" size=\"small\">%s %ldx%ld</span>".printf(fg,bg,s_title,this.vte_terminal.get_column_count(),this.vte_terminal.get_row_count());
this.titlebox.override_background_color(Gtk.StateFlags.NORMAL,bgcolor);
}
public bool button_event(Gdk.EventButton event) {
if (event.button == 3) {
this.item_copy.sensitive = this.vte_terminal.get_has_selection();
this.menu.popup(null,null,null,3,Gtk.get_current_event_time());
this.menu.popup_at_pointer(event);
return true;
}
......@@ -355,5 +373,4 @@ namespace Terminus {
}
}
}
......@@ -19,7 +19,7 @@
using Gtk;
using Gee;
//project version = 0.5.0
//project version = 0.6.0
namespace Terminus {
......
......@@ -23,11 +23,13 @@ namespace Terminus {
class Fixed : Gtk.Fixed {
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) {
base.get_preferred_height(out minimum_height, out natural_height);
minimum_height = 1;
natural_height = 1;
}
......@@ -47,6 +49,14 @@ namespace Terminus {
private Terminus.Base terminal;
private int initialized;
private int get_monitor_width() {
return this.get_display().get_monitor_at_window(this.get_window().get_effective_toplevel()).get_geometry().width;
}
private int get_monitor_height() {
return this.get_display().get_monitor_at_window(this.get_window().get_effective_toplevel()).get_geometry().height;
}
public Window(bool guake_mode, Terminus.Base? terminal = null) {
this.is_guake = guake_mode;
......@@ -58,7 +68,7 @@ namespace Terminus {
this.destroy.connect( (w) => {
this.ended(this);
});
if (terminal == null) {
this.terminal = new Terminus.Base();
} else {
......@@ -69,17 +79,27 @@ namespace Terminus {
this.terminal.new_window.connect( () => {
this.new_window();
});
this.show.connect_after( () => {
GLib.Timeout.add(500, () => {
this.present();
return false;
});
});
if (guake_mode) {
var scr = this.get_screen();
this.set_properties();
this.current_size = Terminus.settings.get_int("guake-height");
if (this.current_size < 0) {
this.current_size = scr.get_height() * 3 / 7;
this.current_size = this.get_monitor_height() * 3 / 7;
Terminus.settings.set_int("guake-height", this.current_size);
}
this.move(0,0);
this.map.connect(this.mapped);
this.realize.connect_after( () => {
this.set_size();
});
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;
......@@ -106,7 +126,7 @@ namespace Terminus {
int newval = y - this.mouseY;
this.current_size += newval;
this.mouseY = y;
this.resize(this.get_screen().get_width(),this.current_size);
this.resize(this.get_monitor_width(),this.current_size);
this.paned.set_position(this.current_size);
return true;
});
......@@ -131,7 +151,6 @@ namespace Terminus {
});
this.paned.show_all();
this.mapped();
} else {
this.add(this.terminal);
this.terminal.show_all();
......@@ -139,31 +158,6 @@ namespace Terminus {
}
}
public override void get_preferred_width (out int minimum_width, out int natural_width) {
if ((this.is_guake) && (this.mouseY < 0)) {
var scr = this.get_screen();
minimum_width = scr.get_width();
natural_width = scr.get_width();
} else {
this.terminal.get_preferred_width(out minimum_width, out natural_width);
}
}
public override void get_preferred_height (out int minimum_height, out int natural_height) {
if ((this.is_guake) && (this.mouseY < 0)) {
var scr = this.get_screen();
this.current_size = Terminus.settings.get_int("guake-height");
if (this.current_size < 0) {
this.current_size = scr.get_height() * 3 / 7;
Terminus.settings.set_int("guake-height", this.current_size);
}
minimum_height = this.current_size;
natural_height = this.current_size;
} else {
this.terminal.get_preferred_height(out minimum_height, out natural_height);
}
}
public void ended_cb() {
this.terminal.ended.disconnect(this.ended_cb);
......@@ -171,18 +165,23 @@ namespace Terminus {
}
public void mapped() {
this.set_properties();
this.present();
this.set_size();
}
private void set_properties(){
this.stick();
this.set_keep_above(true);
this.set_skip_taskbar_hint(true);
this.set_skip_pager_hint(true);
this.set_decorated(false);
if (this.initialized == 0) {
this.paned.set_position(this.current_size);
} else if (this.initialized == 1) {
this.resize(this.get_screen().get_width(),this.current_size);
}
this.initialized++;
}
private void set_size() {
this.move(0,0);
this.paned.set_position(this.current_size);
this.resize(this.get_monitor_width(),this.current_size);
}
}
}
......@@ -8,7 +8,7 @@ vala_version: 0.30
*vapidir: src/vapidir
vala_binary: src/terminus
*version: 0.5.0
*version: 0.6.0
use_gresource: extras_gresource_xml
vala_vapi: checkwayland.vapi
*vala_package: posix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment