linvinus / AltYo

AltYo - drop-down terminal emulator, written in vala, depends only on libvte and gtk3.
GNU General Public License v3.0
106 stars 27 forks source link

'Tabs on top' again and 'How to hide tab bar' again #32

Open suedi opened 8 years ago

suedi commented 8 years ago

revisiting #10 and #11

When using altyo in standalone mode like I do, tab bar at bottom is a bit annoying even more so when you fill the terminal with text and you are used to look at the bottom text line in a terminal. It gets kind of cluttery.

Since you added a config option: Tab bar mode I'm thinking it would be trivial to add a hot-key accel for hiding and unhiding tab bar, am I right?

I really would like tab bar on top but realize that would be a bigger code change and possibly would produce space between tab bar and window (uggly?) so would settle on a hot-key for hiding and unhiding tab bar, toggling that is.

If you do not like it could you please give some pointers how I would go about adding it meself?

So I guess my questions are

  1. Would it be trivial to add
  2. Do you like the idea
  3. Pointers to where in code one could add it if you aint got time

EDIT 1

I did a really ugly proof of concept hack in altyo_window.vala

added an hotkey accel to "About", Ctrl+k, via settings menu ( right click and settings )

hijacked that accel in code this.add_window_accel("altyo_about" ... at line 2408

changed code to

this.add_window_accel("altyo_about", _("About"), _("About"), Gtk.Stock.ABOUT,"",()=>{
            this.hvbox_display_mode=1;
            this.conf.set_integer("window_hvbox_display_mode", 1);
            this.save_configuration();
            this.reconfigure();
            this.search_update();
            // this.ShowAbout(); 
        });

If I have a altyo --standalone running with several tabs visible ( window_hvbox_display_mode=0 ) and hit Ctrl+k tabs bar is hidden ( window_hvbox_display_mode=1 )

Uggly - yes, Hacky - very much so, but proves it could be done!

EDIT 2 then I tried

this.add_window_accel("altyo_about", _("About"), _("About"), Gtk.Stock.ABOUT,"",()=>{
    if(this.hvbox_display_mode==1) {
        this.hvbox_display_mode=0;
    }
    else  {
        this.hvbox_display_mode=1;
    }
    this.search_update();
    // this.ShowAbout(); 
});

Now I can toggle between visible and hidden tab bar. :-)

linvinus commented 8 years ago

Hi! i'm glad that source code quite understandable. I think this is possible to implement for standalone mode.

suedi commented 8 years ago

Is it something you are willing todo?

linvinus commented 8 years ago

Yes. for standalone mode only.

suedi commented 8 years ago

That sounds great man!

Since I work in standalone I am happy.

But I am curious why you don't want it in drop-down mode. Is it a technical reason or more of design/beauty reason?

linvinus commented 8 years ago

I really would like tab bar on top but realize that would be a bigger code change and possibly would produce space between tab bar and window (uggly?)

For testing purpose you can make trivial change

In file altyo_window.vala find this lines

    this.main_vbox.pack_start(this.tasks_notebook,true,true,0);//maximum size
    //this.main_vbox.pack_start(notebook,true,true,0);//maximum size
    this.main_vbox.pack_start(this.quick_options_notebook,false,false,0);//minimum size
    this.main_vbox.pack_start(hvbox,false,false,0);//minimum size

and change order like this

    this.main_vbox.pack_start(hvbox,false,false,0);//minimum size
    this.main_vbox.pack_start(this.tasks_notebook,true,true,0);//maximum size
    //this.main_vbox.pack_start(notebook,true,true,0);//maximum size
    this.main_vbox.pack_start(this.quick_options_notebook,false,false,0);//minimum size

you should get something like this

tabsontop_altyo

linvinus commented 8 years ago

let me know is it useful for you or not?

suedi commented 8 years ago

I have not compiled yet but can already say it looks very useful indeed. Still I would like the hotkey for hiding tab bar though

It was not so big code change, huh?

I saw you could edit the value for tab header in settings i.e settings--> advanced --> Tab --> Tab Format --> Terminal header

Maybe it would be possible to set it to something a bit shorter like getting rid off denis@tentorium part or setting path part to only the working directory. I mean not vala/altyo/Altyo but then it would be just "Altyo"

I tried in Tab Format .--> Terminal header

<span foreground='tab-index-color'>_INDEX_</span>/_PATH_   ...

But it didn't work, Am I doing something wrong?

Would be nice if this was a little more fine grained.

The idea is here to get Terminal headers to be a bit shorter and therefore not wrap several lines so often.

Will recompile and get back to you

linvinus commented 8 years ago

I have not compiled yet but can already say it looks very useful indeed.

please use it for a while, and then say is it useful or not. also, how many tabs usually you are opening in altyo?

terminal header is standard function of xterm for example, if you run following command

echo -ne "\033]0;asdasd\007" ; cat

terminal title must change

more info http://askubuntu.com/questions/22413/how-to-change-gnome-terminal-title http://tldp.org/HOWTO/Xterm-Title.html

So if you wish another title format you should change it in your .bashrc file

in altyo you may CUT some parts of title, and highlight some parts with color see example under settings--> advanced --> Tab --> Pattern

linvinus commented 8 years ago

Some problems of designing GUI described there http://guijournal.com/2011/07/gui-design-too-many-tabs/

and there http://hallofshame.gp.co.at/tabs.htm

but in altyo i can't remove tabs to fit in single line =)

as for me, in some cases (as on screenshot above ), tabs on top looks ugly

in drop-down mode, tabs on top will cause vertically jumping of terminal, when you add or close tabs or when you change directory in mc (midnight commander), this is really annoying

this is fundamental GUI design issue, which i don't know how to resolve

suedi commented 8 years ago

please use it for a while, and then say is it useful or not.

Sry, got a little carried away there, Will of course use it and evaluate

also, how many tabs usually you are opening in altyo?

Yeah for me that can be many, probably more than most but thats productive for me

Thank you for the education -- now I have tab headings that I like Very good support in Altyo for this when you understand how it is supposed to be used with regexp and all. :+1:

Also I discovered the "Max Tab width" feature and will experiment with that :+1:

Also found the feature "Revert" - revert to original settings very useful when I got lost and deleted to much :+1:

Thank you for clarifying your design descisions. I guess the lesson for me is that what works in standalone may not be good for Drop-down

Will report back

suedi commented 8 years ago

Added to main.vala during testing a new command line option --ontop witch if issued will have tab bar on top.

This is so I can in a quick manor compare tabs on top and on bottom to see what I like

65    struct Globals{
66        static bool on_top = false;
...
88  public static const OptionEntry[] options = {
89      /*allow show help from remote call*/
 90           { "ontop", 'o', 0, OptionArg.NONE, ref Globals.on_top,N_("Tab bar ontop"), null },

and in altyo_window.vala line 1441

            if ( Globals.on_top ) {
            this.main_vbox.pack_start(hvbox,false,false,0);//minimum size
        }
        this.main_vbox.pack_start(this.tasks_notebook,true,true,0);//maximum size
        //this.main_vbox.pack_start(notebook,true,true,0);//maximum size
        this.main_vbox.pack_start(this.quick_options_notebook,false,false,0);//minimum size
        if ( ! Globals.on_top ) {
            this.main_vbox.pack_start(hvbox,false,false,0);//minimum size
        }

Is it possible to move tab bar dynamically after the program has started i.e reorder the visual elements of the this.main_vbox.pack_start statements ????

EDIT

Okay found a hackish way

this.add_window_accel("altyo_about", _("About"), _("About"), Gtk.Stock.ABOUT,"",()=>{
            if ( Globals.on_top ) {
                this.main_vbox.reorder_child( this.hvbox,-1);
                Globals.on_top=false;
            }
            else {
                this.main_vbox.reorder_child( this.hvbox,0);
                Globals.on_top=true;
            }  
    // this.ShowAbout(); 
});

This will alternate top and botton locations of tab bar with hotkey accel for "About"

I don't know how to query a widgets location inside Gtk.box. Perhaps that would be better than using Globals.on_top for tracking tab bar location????

Don't know if this was a good idea maybe it is better on the commandline. Also, as usual, I only regarded standalone mode

suedi commented 8 years ago

I did a test where I hijacked About for hiding/unhiding and hijacked terminal_sort_by_hostname for moving tab bar top/bottom

What I really like is the ability to move the tab bar around as I desire. To be able to hide it on a whim. And both from keyboard hotkeys, no mouse.

Now I can choose from what type of job I am doing.

Am I doing a longer job in the current tab I can hide tab bar and get a clean interface with no disturbances.

Am I doing some job that involves a lot of switching of tabs I just unhide it and it is very clear to follow what tab is active. Should I feel that it gets cluttered at the bottom with command line and tab bar flowing together I can move tab bar to the top.

Also if is a concern that it would confuse newbies this feature could be Disabled in default config file like "Follow mouse cursor" and "Sort by hostname"

could the reliance on Globals.on_top be removed in favor of query a widgets location inside Gtk.box I would really really like this

And I think you should leave it in for dropdown as well, let the user decide

EDIT Made a quick test with this and dropdown mode

Although hotkey accels for hijacked "About" and "Sort Tabs on Host name" did not work the context menu's for them did ( yeah doesn't work since you are using a different conf file for dropdown, if set there they work)

I get no flickering for adding/deleting tabs or dir change in mc with tab bar on top

If you have a lot of tabs open I think it looks better with them on top

suedi commented 8 years ago

would it because possible to detect when tab bar wraps to second line?

My line of thoughts go to dynamically use "max tab width" so to shrink space of each tab when tab bar is about to overflow to a second line.

I mean to prevent second line instead shrink each tab.

It was just a thought, lets see what you think about it

linvinus commented 8 years ago

as i understand, for tabs you prefer to use single line mode. this mode used in many other applications, like guake and tilda altyo don't use such approach by design.

But, if you really want to implement this strategy for widget size calculation you should check following functions get_preferred_width() get_preferred_height_for_width() in https://github.com/linvinus/AltYo/blob/master/hvbox.vala

more info about size calculation in GTK3 available there https://developer.gnome.org/gtk3/stable/GtkWidget.html#geometry-management

also you may check realization of similar functions in https://git.gnome.org/browse/gtk+/tree/gtk/gtknotebook.c

but in my opinion, this is bad idea, this problem is one of major problems that i was want to resolve in tilda, but because there was many others i decide to write my own application.

if you want single-line mode only for standalone window, then you, probably, should open new window instead of new tab when there is not enough space for new tab in first line.

suedi commented 8 years ago

It was just a thought with dynamic I think I will settle for a fixed "max tab width"

What did you think about the hiding and moving of tab bar?

suedi commented 8 years ago

yeah I like it.

Allthough I got used to be able to move tab bar from bottom to top with a short cut key.

I am not sure if you want that but I would probably carry a patch for it otherwise