Themeing GtkNotebook (tab panels) - gtk

I'm trying to customize a theme - I want to remove the rounded corners for a theme I'm using in xfce.
In the gtkrc
style "clearlooks-notebook-bg"
{
bg[NORMAL] = #bg_color
}
style "clearlooks-notebook" = "clearlooks-notebook-bg"
{
xthickness = 5
ythickness = 0
}
Those aren't the properties I'm looking for..so I browse over to http://developer.gnome.org/gtk/stable/GtkNotebook.html#GtkNotebook.style-properties and there really isn't anything I am seeing that points me to the panels.
I see /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so but I don't know where the theme files are located (xubuntu) so that I can see how clearlooks is handling the style of the tabs.
Pointers please

Theme resource file i.e. gtkrc is generally located under /usr/share/themes/<theme-name>/gtk-2.0/. For Clearlooks on Fedora 15, I can see gtkrc under /usr/share/themes/Clearlooks/gtk-2.0/.
What you are looking for cannot be achieved simple change in the gtkrc file. You have to understand that Clearlooks provides a Gtk Engine (/usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so is loadable module with the implementation of Gtk Engine for Clearlooks theme) along with theme resource file. Gtk Engine is responsible for implementation of drawing functions. These drawing functions override the ones provided by gtk+ library (GtkStyle, GtkRCStyle source files in Gtk) Thus you need to update the source of Clearlooks for changing the appearance. Source code is not very large (about ~10 files or so)! To get the source code of Clearlooks Gtk Engine on your system, check the package name for clearlooks (dpkg -S /usr/lib/gtk-2.0/2.10.0/engines/libclearlooks.so) & get the source for the package (apt-get source <clearlooks-package-name>). Modify the source code (look for draw_*/clearlooks_draw_* functions, clearlooks has code for drawing rounded rectangle thus draw_*/clearlooks_draw_* functions draw rounded rectangle as needed so change it to draw normal rectangle instead), build, install & have fun with new sharp unrounded tab corners!
Hope this helps!

Related

VSCode API: Access the minimap

Is there any way to access the "minimap" that optionally appears next to the scroll bar on the right hand side of the editor?
Preferably I would like to access that panel's width in pixels.
The best I could do to get the values I want is to read the current editor configuration (also settable from the vscode settings UI/JSON).
const editorConfig = vscode.workspace.getConfiguration('editor');
const minimapOn = editorConfig.get("minimap.enabled");
const minimapWidth = editorConfig.get("minimap.maxColumn");
But this only lists the maximum width, not the current one.
Configuring the Width of the Editor's Minimap
The Minimaps with is configurable, not by pixels, but by characters.
The reason it is configurable by characters is because it gives developers a way of setting the minimap's width to the exact width that there longest lines of code are. This is beneficial, as it makes the minimap as wide as needed, without taking up any unnecessary space.
Below is the setting that changes the width of the editor's minimap.
// #file Globally Scoped "settings.json" file
{
"editor.minimap.maxColumn": 75
}
75 can be set to any amount of characters you choose.
Now the part about the API
Anytime you have a setting that does what you want, you can use the API to apply it to your extension. I don't want to continue explaining anything byond the scope of this question, so I will provide a link to the documentation that covers the method used to change a setting using the VS Code API, and a snippet showing you how to use the method to change the minimap's columns width.
Below shows the code an extension might include to change the size of the minimap.
await vscode.workspace
.getConfiguration()
.update(
'editor.minimap.maxColumn',
100,
vscode.ConfigurationTarget.Global
);
NOTE: I wrote the example above off the top of my head. I know that the semantics are all correct, but you will probably have to play with it to get it to do exactly what it is your going for.
Here are a couple links to help you understand what your doing.
"vscode.workspace.getConfiguration()" This is can be interpreted as the base of program-interface that changes settings. From this part of the API, a few methods, objects, constants, and events extend, all of which are used to set, get, and mutate configurations within VS Code.
"The Configuration target" sets the settings.json file you are targeting. Global is a good bet, I prefer "workspace" (which is not the same as "workspace folder".

Material-UI Sizing Confusion

In the sizing documentation, it says "Easily make an element as wide or as tall (relative to its parent) with the width and height utilities.".
What I realize is that almost all the examples in system section of documentation, examples mostly related to Box component. I tried some of the tricks from there on Button element. And expectedly nothing changed.
Well for those who is new on material (actually UI) this is a bit tricky. first, they use Box because as per box documentation they said box generated using material styled (not the styled-components) "The Box component packages all the style functions that are exposed in #material-ui/system. It's created using the styled() function of #material-ui/core/styles."
So, I went to the github and material core repository to understand how to do that.
export const styleFunction = css(
compose(
borders,
display,
flexbox,
grid,
positions,
palette,
shadows,
sizing,
spacing,
typography,
),
);
css and compose are also exported from #material-ui/system
then at the end of the file;
const Box = styled(BoxRoot, { shouldForwardProp }, { muiName: 'MuiBox' })(styleFunction);
export default Box;
The styled used here is from an experimentalStyled package (an internal package) but that does not matter. Cuz, Material guys exporting a styled function/hook for our use.
import { styled } from "#material-ui/core/styles";
I tried this styled function for Button component.
const CustomButton = styled(Button)(sizing);
adn yes it worked. I am now able to apply magical styling skills defined in the system section of material UI.
For those who wants to use this instead of other methods. I pushed an npm package too.
material-ui-styled-hook

Ubuntu + Eclipse 4.2 - Dark theme - How to darken sidebar backgrounds?

Due to spending 24/7 programming in front of a computer screen (job, thesis), it's beneficial to view dark colours as much as possible.
Ubuntu's Ambiance theme can be neatly enhanced using Solancer's customisations, and Eclipse Juno looks mostly consistent after applying Roger Dudler's dark Juno theme.
However, there is a problem with using a dark Juno theme like Dudler's. The background colour of (in)active elements within Package Explorer, Project Explorer and other Eclipse views displays white/grey colours that are not only inconsistent, but actually obscures important display components like expansion arrows.
After much googling, it seems such colours are inherited from the OS, and therefore cannot be changed from within Eclipse Preferences. I'd hoped that the dark GTK 3 / Unity theme (Solancer's Ambiance) would supply the necessary dark colours, but this is not the case.
I've used sed to replace all predefined colours in all the .css files under /opt/eclipse/plugins/org.eclipse.platform_4.2.0.v*/css with #FF0000 to establish whether any colours defined there affect the white/grey problem colours; sadly they do not.
Having seen mention of a ~/.e4css folder online which may contain overriding CSS definitions for such properties, I sought the folder on my local machine, only to find it does not exist.
Similar questions to this exist on SO, yet none explicitly specify how to "fix" these colours.
My question is simple: is there a GTK+ 3.0 CSS property (group) that can be defined to specify these colours for Eclipse 4.x, and where should it be configured?
Finally found the solution through searching GTK configuration files manually myself.
It turns out Eclipse uses GTK+ 2.0 .
If you install a custom GTK theme in Ubuntu (all are compatible with Unity too) you'll extract the theme folder into ~/.themes.
GTK+ 3.0 is configured via css, e.g. ~/.themes/YourTheme/gtk-3.0/gtk.css
GTK+ 2.0 is configured via an rc file, e.g. ~/.themes/YourTheme/gtk-2.0/gtkrc
Most GTK+ 3.0 themes contain both of these configuration folders due to many applications being GTK+ 2.0 specific.
The leading line in the GTK+ 2.0 gtkrc file contains fundamental foreground and background colours; these are what must be changed.
To modify the selected, active element bg colour in Eclipse views you must change colour base_color. To modify the unselected element bg colour, you must change selected_bg_color. Font colour is changed with the equivalent fg_color properties (in the case of base_color this is simply 'fg_color').
Bear in mind this will affect all GTK applications, so you may need to tweak according to personal taste. Also note that you must reload the active GTK theme and restart Eclipse to see changes in effect. The quickest way to do this is to sudo apt-get install myunity, launch and leave it open while you restart Eclipse during colour changes, and select another theme followed by your desired theme each time you wish to load your gtkrc changes.
The original gtkrc leading line in my active GTK theme read:
gtk-color-scheme = "base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#000000\nlink_color:#DD4814"
After much experimentation I settled on this replacement configuration:
gtk-color-scheme = "base_color:#555555\nfg_color:#000000\ntooltip_fg_color:#999999\nselected_bg_color:#666666\nselected_fg_color:#ffffff\ntext_color:#000000\nbg_color:#333333\ntooltip_bg_color:#000000\nlink_color:#DD4814"
The change across the entire OS is very pleasing! Here's how Eclipse looks now, no obscuring this time:
Hope you like the new look :)
P.S. As you'd predict, the process for Netbeans is equivalent.
UPDATE
This is supplementary info, the above process is still correct when using a custom theme such as Dudler's.
After further experimentation it's now clear why editing /opt/eclipse/plugins/org.eclipse.platform_4.2.0.v*/css/*.css didn't have any effect:
Let's say you're editing e4_default_gtk.css in that location - the effects of changed styles in that file will only apply when you select GTK in Window -> Preferences -> Appearance -> [Theme].
You can relate the themes listed in this dropdown, along with your Operating System, to the names of the .css files in the aforementioned filesystem location.
If you don't want to change the look of the entire desktop you can launch a separate GTK+ theme for Eclipse by setting GTK2_RC_FILES flag in the command to start Eclipse.
Example:
GTK2_RC_FILES=/path/to/gtk/theme/gtkrc /opt/eclipse/eclipse
That means that you can create a copy of your GTK+ theme and tweak it for Eclipse without effecting any other part of your desktop.
You finally don't need to change your GTK theme to have a dark Package Explorer or Project Explorer etc. windows. Try the solution posted here, for me it works well both on Ubuntu and Windows without changing system theme.
Even in 2013, some items still can not be 'themed', and not only in Eclipse IDE. Only way to fight with color hardcoders (people who define item color via constant, not via theme parameter) is Compiz Color Filter. I develop such filter which preserve colours while inverting. So no problem with any software anymore.
Unfortunately, color filtering will not work on latest Ubuntu's as i know.
Please read more here http://ubuntuforums.org/showthread.php?t=1419702&page=3
!!ARBfp1.0
TEMP temp, neg, YPbPr;
TEX temp, fragment.texcoord[0], texture[0], RECT;
RCP neg.a, temp.a;
MAD temp.rgb, -neg.a, temp, 1.0;
MUL temp.rgb, temp.a, temp;
MUL temp, fragment.color, temp;
DP3 YPbPr.x, temp, {0.333, 0.333, 0.333, 1};
SUB YPbPr.y, YPbPr.x, temp.b;
SUB YPbPr.z, YPbPr.x, temp.r;
ADD temp.r, YPbPr.x, YPbPr.z;
ADD temp.b, YPbPr.x, YPbPr.y;
SUB temp.g, YPbPr.x, YPbPr.z;
SUB temp.g, temp.g, YPbPr.y;
MOV result.color, temp;
END
# DO NOT MOVE LINE #2 (TEMP...) below, i.e. do not insert comments before it!
# do not insert comments before 'END' token: SOMETIMES not work!
# replace file /usr/share/compiz/filters/negative with this file.
# Color filter: negative, but preserve colours. Tested on Ubuntu LTS 10.04.
# compiled from [1], [2] by jopka#kvidex.ru, www.bdyssh.ru
# [1] http://hronir.blogspot.com/2008/09/compiz-fusion-color-filter-for-hue.html
# [2] http://ubuntuforums.org/showthread.php?t=1419702
# add to line 15: MUL temp.b, 0.5, temp.b; - for warm/melatonine colors, or
# MUL temp.g, 0.5, temp.g; - for cold colors.
For Eclipse 4.5:
1. Create a file like the inserted snippet
2. Save it as "/usr/share/themes/..used theme../gtk-3.0/apps/eclipse.css"
3. Include it "/usr/share/themes/..used theme../gtk-3.0/gtk-main.css"
#define-color ecl_scrollbutton_color #7C7C7C;
#define-color ecl_scrollbutton_color_hover #FB7A00;
.scrollbar,
.scrollbar.vertical {
-GtkScrollbar-has-backward-stepper: 0;
-GtkScrollbar-has-forward-stepper: 0;
-GtkRange-slider-width: 14;
border-radius: 20px;
border-image: none;
}
/*.scrollbar.trough,
.scrollbar.trough.vertical {
}
*/
.scrollbar.slider,
.scrollbar.slider.horizontal,
.scrollbar.slider.vertical,
.scrollbar.button,
.scrollbar.button.horizontal,
.scrollbar.button.vertical {
border-width: 0.5px;
border-style: solid;
border-color: shade (#ecl_scrollbutton_color, 0.66);
background-image: -gtk-gradient (linear, left top, right top,
from (shade (#ecl_scrollbutton_color, 1)),
color-stop (0.5, #ecl_scrollbutton_color),
to (shade (#ecl_scrollbutton_color, 1)));
box-shadow: inset 1px 0 shade (#bg_color, 1.1),
inset -1px 0 shade (#bg_color, 1.01),
inset 0 1px shade (#bg_color, 1.1),
inset 0 -1px shade (#bg_color, 1.1);
}
.scrollbar.slider:hover,
.scrollbar.slider.vertical:hover,
.scrollbar.slider.horizontal:hover {
background-image: -gtk-gradient (linear, left top, left bottom,
from (shade (#ecl_scrollbutton_color_hover, 1)),
color-stop (0.5, #ecl_scrollbutton_color_hover),
to (shade (#ecl_scrollbutton_color_hover, 1)));
box-shadow: inset 1px 0 shade (#bg_color, 1.1),
inset -1px 0 shade (#bg_color, 1.1),
inset 0 1px shade (#bg_color, 1.1),
inset 0 -1px shade (#bg_colo

Mac style joined buttons (segmented control) with Gtk

I've seen it done in the ubuntu software center, and with a few gnome apps.
Where two buttons look like a single rectangle with a line through it, how is this being done?
In GTK 3.0 and later, use the INLINE_TOOLBAR style class or LINKED style class.
#!/usr/bin/env python
from gi.repository import Gtk
button_names = [
Gtk.STOCK_ABOUT,
Gtk.STOCK_ADD,
Gtk.STOCK_REMOVE,
Gtk.STOCK_QUIT]
buttons = [Gtk.ToolButton.new_from_stock(name) for name in button_names]
toolbar = Gtk.Toolbar()
for button in buttons:
toolbar.insert(button, -1)
style_context = toolbar.get_style_context()
style_context.add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR)
window = Gtk.Window()
window.set_size_request(200, 50)
window.add(toolbar)
window.connect('delete-event', Gtk.main_quit)
window.show_all()
Gtk.main()
Fwiw, since I recently had the same question, here's another answer with an up-to-date citation and using C instead of some wrapper. (I use GTKmm, but I feel we should refer to the native C API unless a wrapper is explicitly stated.)
I wanted to achieve the same thing and eventually stumbled upon the answer, at the official page HowDoI: Buttons. This effect is achieved by putting the targeted Buttons in a Container and giving the latter the CSS class linked. (That page says using a Box is normal, but asBox will probably be deprecated soon and Grid is superior anyway... use a Grid.)
So:
GtkWidget *const grid = gtk_grid_new ();
GtkStyleContext *const context = gtk_widget_get_style_context (grid);
gtk_style_context_add_class (context, "linked");
/* Add your Buttons to the Grid */
That link also discusses some other handy embellishments we can make to GtkButtons, including the classes suggested-action and destructive-action.
For similar questions, it's very illustrative to browse the source of (A) an application that does what you want to replicate and (B) the Adwaita theme CSS.

programmatically change the background color in eclipse

I have a question related to eclipse plugin development. Is there any means
by which I can programmatically change the background color in eclipse.
I am able to change the text foreground color by calling
setTextColor(color, offset, length, controlRedraw) in ITextViewer
but I don't find any function by which I can change the background
color of the text.
If anyone has been through this kindly share your thoughts.
Thanks
arav
I am not sure this can be done easily, short of extending your own version of a Text Editor, here you provide a Configuration Class which inturn accepts a PresentationReconciler Class which is like a Rule Class that tells you if you need to put a Foreground or a Background Color
See this document
PresentationReconciler
IPresentationDamager: define dirty region given a text change
IPresentationRepairer: recreate presentation for dirty region
DefaultDamagerRepairer does both, based on a token scanner
ITokenScanner: parse text into a token stream
RuleBasedScanner uses simple rules
Extract from the presentation
From Text Editor Recipes, Season’s recipes for your text editor
Tom Eicher, IBM Eclipse Team
Here, the null background color means, takes the default system background for that widget. (so here: white).
But you could specify whatever color you want, based on the partitioning of your document and on the rules that would apply.
I know this was asked a while ago, but in case anyone is looking for another solution, I thought I would post the following:
Since you are able to use the setTextColor method, then you should be able to use the changeTextPresentation method as well.
In the case of my plug-in, I have a TextListener that calls the TextChanged method I overwrote. I did the following to add background color using the changeTextPresentation method. In doing so, I was able to get a Green background with Black foreground. Not that I would want this, of course, but just for testing purposes.
public void TextChanged(TextEvent event){
...
TextPresentation presentation = new TextPresentation();
TextAttribute attr = new TextAttribute(new ColorManager().getColor(MyConstants.BLACK),
new ColorManager().getColor(MyConstants.GREEN), style);
presentation.addStyleRange(new StyleRange(startOffset, tokLength, attr.getForeground(),
attr.getBackground());
sourceViewer.changeTextPresentation(presentation, true); //sourceViewer is a global variable passed to my TextListener class constructor.
}