Setting Cursor-Color in GTK+ 3 - gtk

I'm looking to set a GtkTextView cursor-color. I know I can do it through the gtk_rc_parse command or something similar, but the documentation says that those commands are depreciated, and I don't think GtkCssProvider supports cursor-color. Is it possible to set it some other way?

This can be done in gtk3 with CSS. GtkTextView itself doesn't have a "cursor-color" property. You must go up in hierarchy to GtkWidget which does have that property and since GtkTextView is a type of GtkWidget you can style the GtkTextView through GtkWidget. So you use: -GtkWidget-cursor-color
This is true for other properties as well. For instance, "focus-line-width". This property is shared by several widgets including GtkButton and the rows of a GtkTreeView.
The style property listed for a specific widget in the documentation must be preceded by: -widgetname-
For instance, the only style property listed for GtkTextView is "error-underline-color" So in the CSS you would use: -GtkTextView-error-underline-color
Here's an example of changing "cursor-color" and other properties in a GtkTextView:
http://www.gtkforums.com/viewtopic.php?f=988&p=195276=Styling+a+GtkTextView+with+Gtk3+and+Css%3A#p195276

This is probably what you are looking for: http://developer.gnome.org/gtk3/3.0/GtkWidget.html#gtk-widget-override-cursor

Actually, there seem to be cursor-color style property:
http://developer.gnome.org/gtk3/3.0/GtkWidget.html#GtkWidget--s-cursor-color

Related

Where can vscode view the default colors for parts that you don't define

I sometimes wonder what vscode's default widget color is. For example: when I use a github theme, I find that it only defines one part of the color internally, so where is the other part defined, and how do I view it.
For example, when I look at the color scheme of the topic by Developer : generator color theme... command, the undefined part is always shown in the form of comments(e.g "activityBar.activeBackground": null,). How can I see the color of this annotated section?

Text-align and GTK CSS

This is interesting, according to the docs there isn't a text-align and trying it gives
gi.repository.GLib.Error: gtk-css-provider-error-quark: <data>:3:14'text-align' is not a valid property name (3)
Is there an alternative to text-align: left/right/etc for buttons or other widgets with GTK CSS?
You might try the "gtk_widget_set_halign" function. Following is an example.
gtk_widget_set_halign(GTK_WIDGET(button), GTK_ALIGN_CENTER);
The first parameter is the widget that you want to affect (e.g. a button). The second parameter is the type of alignment that you want to perform within the widget. The second parameter has five pre-defined constants:
GTK_ALIGN_BASELINE
GTK_ALIGN_CENTER
GTK_ALIGN_END
GTK_ALIGN_FILL
GTK_ALIGN_START
I hope that is clear.
Regards.
I should have updated with answer -
self.builder.get_object("button1").set_alignment(0,0);

smartGWT override widget style

I want to override the background color of the TreeGrid object (and other default styles). But it doesn't let me change the default css.
TreeGrid grid = new TreeGrid();
grid.removeStyleName("listGrid");
OR
TreeGrid grid = new TreeGrid();
grid.removeStyleName(grid.getStyleName());
This code doesnt seem to work. The stylename remains the same.
I think I'm missing something but I cant seem to figure it out. Also if I set another stylename for the widget it keeps the default stylename.
Thanks in advance!
I found the answer myself.
Looks like there are various solutions. But this one was the easiest for me.
There are different methods for setting different parts of the style for this component. To set the body style name I simply used the following code and it worked. No need to create a new css rule here.
treeGrid.setBodyStyleName("#E0E0E0");

How can I set a custom size for the RichTextArea.Formatter.setFontSize() in GWT?

Using the RichTextArea in GWT, It looks like I can only change the font size to one of the values: LARGE, MEDIUM, SMALL, etc (RichTextArea.FontSize), but I want to be able to setFontSize of the RichTextArea.Formatter to a specific size in pt or in px.
How can I achieve that?
I've been digging a bit on this, and it would seem that it is unfortunately not possible, because browsers are limited in their handling of font sizes in the rich text editors. In particular, Firefox generates the (deprecated) <font size="x"></font> element when the font size is changed, and the value of x can be only in the 1-7 range.
If you have a look at the setFontSize method in RichTextAreaImplStandard (GWT source code), you'll see that it ends up calling the execCommand javascript function, which in the case of FontSize only accepts values in 1-7:
http://msdn.microsoft.com/en-us/library/ms536991%28VS.85%29.aspx
You can actually achieve that using string manipulation of the HTML code.
So if you are not using the background color property of the RichTextArea then what you have to do is to replace the "background-color=RED" to "font-size=12px". And then set it back to the RichTextArea object as setHTML().
This works fine as I've implemented this functionality in one of our production application..
Thanks,
Pratik.

How to set "toggle-spacing" style property to GtkMenuItem in gtk+?

How can I set "toggle-spacing" style property to GtkMenuItem in gtk+?
I have added five GtkImageMenuItem(gtk_image_menu_item_new_with_label) to GtkMenu. Now I want to provide spacing between Image and label of this GtkImageMenuItem.
There is a style property (toggle-spacing) in GtkMenuItem to provide spacing between image and label.
How can I use this property?
I want to give alternate colors to each GtkMenuItem. How it is possible?
Kinda menu I want to create is shown in this image.
(source: flickr.com)
Thanks,
KBalar
Setting Properties.
To make the row colors alternate use gtk_tree_view_set_rules_hint.