I'm using Vala with GTK+ and now I'm trying to add custom CSS to specified widget.
I can add fe. backgroudn to GtkWidget but not for #sidebar
#sidebar { //It doesn't work
color: white;
}
GtkWindow { // It works
background-color: red;
}
I'm adding class to widget like that:
sidebar = new Gtk.Label("Hello");
sidebar.set_name("sidebar");
And it's changes color to GtkWindow, but not for this label.
Any ideas?
I haven't programmed in Vala, but you should add class to StyleContext.
This is in C
sidebar = gtk_label_new ("Hello');
gtk_style_context_add_class ( gtk_widget_get_style_context ("mysidebar"), sidebar);
Also, style "sidebar", is already defined in GtkStyle. You should change the "sidebar" in CSS into something else (sidebar is used by views, toolbar etc)
But if you persist, the syntax should be:
.mysidebar {
#anything
}
Related
I tried following CSS if there is effect of color but I could not change the default white color of the Part.
.MPartStack {
swt-maximize-visible: false;
swt-minimize-visible: false;
swt-mru-visible: true;
swt-tab-outline: false;
}
.MPart {
background-color: black;
border-color: black;
swt-corner-radius: 0;
}
Only Part Stack works and I am unable to see any change reflected from .MPart.
If you create a Composite in the code for your part to need to set it to inherit the background using
composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
otherwise the part Composite will not pick up the MPart style.
An alternative is to set a CSS class for the controls that you create, like this:
WidgetElement.setCSSClass(control, "your-class-name");
I am trying to change my celltable alternate rows background colors.
by default they have white and lite blue color .. is there a possibility i can change these colors to lets say white and red..
attached is the screenshot .. you can see a white and blue color rows .. if there is a solution to change these colors.
I am aboe to change color , but it looks like it is changin each cell color and not the complete background , see the attached image , any way i can avoid these white spaces.
this is my css
.cellTableEvenRow {
}
.cellTableOddRow {
background: powderblue !important;
}
.cellTableEvenRowCell {
}
.cellTableOddRowCell {
}
thanks
You have to provide a custom CellTable.Resources instance.
To do that you have to create sub-interfaces of CellTable.Resources and CellTable.Style. In the your custom CellTable.Resources you can add your own CSS file in addition to the default style:
public interface CustomResources extends CellTable.Resources {
#Source({Style.DEFAULT_CSS, "CustomCellTable.css"})
Style cellTableStyle();
}
public interface CustomStyle extends CellTable.Style {
}
Now you can specify your custom style in the CustomCellTable.css:
.cellTableEvenRow {
background: white;
}
.cellTableOddRow {
background: red;
}
To create an instance of your custom CellTable.Resources simply call:
CellTable.Resources res = GWT.create(CustomResources.class)
Now you can give that instance to the CellTable instance using its constructor:
CellTable cellTable=new CellTable(15, res);
15 is the default page but can be changed. CellTable has no constructor with only the resources as parameter. At least the page size has to be specified.
I'm trying to style a GtkNotebook using a GtkCssProvider. I can control most things using a GtkNotebook or GtkNotebook tab selector, but I can't figure out how to style the scroll arrows on the side:
If I apply a style that changes every element, e.g.:
* {
color: #f00;
}
it changes the arrows (and everything else), so it appears they do support theming:
What is the actual selector that matches those arrows, so I can apply a style to just them?
Looking at the source code, arrows in GtkNotebook are not full fledged widgets; they are just rendered with gtk_render_arrow().
The code of gtk_render_arrow shows the CSS class arrow is applied before the rendering. This means you can customize the position within the notebook class and the rendering in the arrow subclass, e.g.:
.notebook {
-GtkNotebook-initial-gap: 20;
-GtkNotebook-arrow-spacing: 20;
}
.notebook.arrow {
color: black;
}
.notebook.arrow:prelight {
color: white
}
.notebook.arrow:insensitive {
color: gray
}
Different theme engines can provide additional customizations.
is there a way to change global the selection color of gwt datagrid?
I added following css-format in the main-app-css file:
.dataGridSelectedRow {
background: #1EDA17;
color: white;
height: auto;
overflow: auto;
}
I have seen also following link:
http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideUiCss.html
Sadly my change had no effect.
Do I miss any setStyleName() call?
There is also another way of setting custom css formatting for selected row in DataGrid. You need to create your custom interface that extends DataGrid.Resources. In this interface you should ovveride method dataGridStyle() and in #Source annotaion put path to your custom css file.
For example:
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.DataGrid.Resources;
public interface CustomDataGridResources extends Resources {
public interface CustomDataGridResources extends Resources {
#Source({DataGrid.Style.DEFAULT_CSS, "resources/CustomDataGridStyles.css"})
CustomStyle dataGridStyle();
interface CustomStyle extends DataGrid.Style {
}
}
If you want just to change style for selected row then your css file will contain only:
.dataGridSelectedRow {
background: #1EDA17;
color: white;
height: auto;
overflow: auto;
}
But I also prefer to change cursor for howered row:
.dataGridHoveredRow {
cursor: pointer;
cursor: hand;
}
Look also at similar discussion.
For applying custom style to your DataGrid you can use grid's constructor
public DataGrid(int pageSize, Resources resources, ProvidesKey<T> keyProvider)
where Resource is an instance that implements your custom interface (in my case CustomDataGridResources).
DataGrid.Resources customDataGridResources = GWT.create(CustomDataGridResources.class)
The custom css will not work since GWT overrides it with clean.css. If you use FIREBUG or any other tool you might recognize it. The solution is simple. Add !important to each line which has not affected with your custom css
.dataGridSelectedRow {
background: #1EDA17 !important;
color: white !important;
height: auto !important;
overflow: auto !important;
}
I'm creating a MenuBar, and I want to have it display a little icon when there are sub-elements to be displayed. I thought I could achieve this like so:
interface ActionHeroResources extends ClientBundle, MenuBar.Resources
{
#Source("actionhero.css")
public ActionHeroCSS css();
#Override
#Source("agw-dropdown.png")
ImageResource menuBarSubMenuIcon();
}
private static final ActionHeroResources RESOURCES = GWT.create(ActionHeroResources.class);
MenuBar actionMenu = new MenuBar(true, RESOURCES);
public ActionHero()
{
actionMenu.addItem("Select", aSelectMenuFullOfOptions);
}
But the menu appears with the word "Select" an no icon! I'm positive my ImageResource is working correctly because I use menuBarSubMenuIcon().getURL() from the same resource later, and my image shows up just as you'd expect. In the HTML generated by GWT, there is absolutely no distinction between the items with MenuBars as children and the items with Commands. My CSS is working fine.
Any thoughts?
Try overriding the CSS style for .gwt-MenuBar-vertical .subMenuIcon-selected, like this:
.gwt-MenuBar-vertical .subMenuIcon-selected {
background: none;
}
I use this for my own selected items and it works great:
.gwt-MenuBar-vertical .subMenuIcon-selected {
background: url(images/hand_pointer.png) no-repeat 0px 0px;
}
The problem was ultimately that the popup panels that form the submenus take their stylename from the parent, but append a dependent stylename. I don't know of a way to predict what that dependent stylename will be, since the original stylename is obfuscated. I worked around this problem by using the more generic .gwt-MenuBar popup stylename. This only works because I only have one style of popup menu in my program - I'm not sure what I would do if I wanted two popups to look different!
Hopefully, in later gwt releases, the MenuBar styles will come more closely from the resources passed to the menubar and make less use of dependent style names.
You can simply set a css rule for the that appears in the sub menu like this:
.subMenuIcon > img {
/* override gwt sub menu icon */
width: 6px !important;
height: 11px !important;
background: url('your-image-relative-path.png') no-repeat 0px 0px !important;
}