-
Notifications
You must be signed in to change notification settings - Fork 58
Implement configuration profiles #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
All instances of lxterminal invoked with the same --profile=NAME argument will share a config file (lxterminal-NAME.conf), and socket.
At a quick glance:
|
Thanks for your comments. Agreed on: lxterminal-PROFILE --> lxterminal-NAME. That was an oversight. [Having written the following description, it's clear to me that the global "profile" should definitely be renamed, perhaps to "profile_string", to make it explicit that it's different than what was passed to the command-line argument.] The default value of the profile global needs to be the empty string, i.e. "", not NULL. When set, it will contain the profile's name, plus an extra leading '-' character, due to the sprintf at lxterminal.c:1549. This makes the construction of the full config filename, and the full socket name, work easily with just a single sprintf -- e.g., the file name will be either "lxterminal.conf" or "lxterminal-myname.conf", without any extra logic. Using address->profile directly would involve extra conditionals to provide the '-' or not. Also, because the socket name and file name may be needed repeatedly over the life of the process, I don't think profile should ever be freed. I think the only leak that can occur is if the --profile argument is given more than once. And I believe this is the case for any of the string-valued argments. paul |
Renamed variable, and added comments, to make its role more obvious.
Of course, but you can't free it that way. Why not using You don't need to add comments to make its role more obvious. |
Why would I free it? Losing one byte of data because it's no longer pointed to is really not a big deal. But this isn't my codebase, so I'm more than happy to change it. :-) |
(and yes, I know that the static initializer can't be freed anyway) |
We may be talking at cross purposes.
Because you are allocating memory with g_strdup_printf(). Instead of |
Just because I'm allocating it with g_strdup_printf() doesn't mean it will be freed. As I said earlier, that memory must never be freed, because the string it contains might be needed at any time. (At least, that's how I currently understand the code. Perhaps I've missed something?) But perhaps your concern is that the code will change and someone will then want to free it? |
I think I will (after hearing from you) switch to using Is there anything else about the pull request that should change? Should I remove the change to lxterminal.1 ? I created it "by hand", so it may not match what the tools would produce, though I think it's syntactically correct. But I don't even know if that placeholder should be modified. Once you approve, I'd prefer to create a new pull request (or, modify this one?) to collapse my changes into one commit. But I'll defer to your opinion on whether I should or not. |
There is only a small diff to your lxterminal.1 after rebuilding from xml:
And yes, there should be a pre-generated man page. Apart from that, please wait until I find time to get back to lxterminal. |
Please take a look at this. I think that the profile belongs to the terminal window instead of a global variable, so I put it in the LXTerminal structure where it can be freed after the window is closed. (Unlike the global variable, which is allocated new memory each time it is used.) It also seems clearer to me to pass the profile as an argument to the setting functions and the socket creation function (even if it makes the commit a bit more complex). What do you think? |
ingo wrote:
Please take a look at [1]this.
It all seems fine.
I think that the profile belongs to the terminal window instead of a
global variable, so I put it in the LXTerminal structure where it can be
I'm a little confused by this: the profile is shared by all windows
that were started from the same process, correct? So it feels like
there's no reason for it to be copied into every window structure.
Not wrong, certainly, and I don't have a strong opinion about it.
Just curious.
freed after the window is closed. (Unlike the global variable, which is
allocated new memory each time it is used.)
It also seems clearer to me to pass the profile as an argument to the
setting functions and the socket creation function (even if it makes the
commit a bit more complex).
Agreed.
What do you think?
All looks good! Thanks!
paul
|
It seems to be the only way to get the profile in terminal_preferences_dialog() to save the settings. Or am I missing something? |
ingo wrote:
I'm a little confused by this: the profile is shared by all windows
that were started from the same process, correct? So it feels like
there's no reason for it to be copied into every window structure.
It seems to be the only way to get the profile in
terminal_preferences_dialog() to save the settings. Or am I missing
something?
Oh, of course. Thanks.
|
Although the implementation is a bit different now, thank you very much for your contribution. |
I really like the simplicity of lxterminal's text config file -- it makes it much easier to get going on a new machine if I can just copy the config into place, rather than having to configure multiple settings via menu or dconf. But I also have a need for several different configs (mostly font-size changes, and colors) for different styles of terminal. So this small patch implements terminal "profiles". It's very simple.
All instances of lxterminal invoked with the same "--profile=NAME" argument will share a config file (lxterminal-NAME.conf), and a socket (which is renamed in a similar way).
I'm happy to rework this, of course, if there are details that you'd prefer be changed.
Also, I included new versions of both lxterminal.xml and lxterminal.1, which I now realize was perhaps incorrect.