How to change background color of GtkTextView? - gtk

How to change background color of GtkTextView? I tried with normal widget set bg functionality but gtk is just changing border color of GtkText View.
Plus can some some please explain me with simple example, that how to change Text Color/Font/Text Size in GtkTextView (Whole text in GtkTextView)?
I fond some examples but they are not working..
Thnaks,
PP.

gtk_widget_override_background_color()
This the GTK 3.x+ way (until GTK 3.16). From
https://developer.gnome.org/gtk3/unstable/GtkWidget.html#gtk-widget-modify-base
"gtk_widget_modify_base has been deprecated since version 3.0 and should not be used in newly-written code. Use gtk_widget_override_background_color() instead"
UPDATE: thegtknerd notes that this method too is now deprecated and it has been since 3.16.

gtk_widget_modify_base()
http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-modify-base

As of gtk3, I believe the proper way to do that is through CSS. Register a gtk style sheet though GtkCssProvider, then you can write this CSS:
textview text {
background-color: #theme_bg_color;
}
We can see the relevant CSS nodes in the documentation for GtkTextView. In this case I put #theme_bg_color which is an adwaita CSS variable, but you can as well put anything that goes in a usual CSS file, like red or #ff0000.

Related

Why is the textfield label purple in smui?

I installed the svelte material ui component library in my svelte project. Unfortunately
the floating label is colored purple by the following css rule provided by the smui-package. How can I fix this?
css in dev tools
.mdc-text-field--focused:not(.mdc-text-field--disabled) .mdc-floating-label {
color:rgba(98, 0, 238, 0.87) //purple
}
smui textfield
<Textfield bind:value={valueA} label="Label">
<HelperText slot="helper">Helper Text</HelperText>
</Textfield>
I am guessing you are using the default bare.css stylesheet, probably as a CDN package. While it is possible to override some of that base theming using CSS variables, Textfield labels cannot be overridden that way. (If you're interested, see this REPL verifying that, in fact, labels are not impacted by changing CSS variables).
For that, you will have to put together your own theme, meaning defining your own primary, secondary, etc. theme colors, spacing, etc. (note: you won't have to override everything, only these values you want to change from the default behavior ; for instance, in your case, you can focus on colors and leave spacing etc. untouched).
Once your theme has been compiled into a stylesheet, use it as a replacement for the bare.css file (or CDN package) you were using until then. You can also dive into the details of the compiled stylesheet and manually change any of the rules you want.
My advice: experiment and tinker until you get the result you were looking for. You'll learn a lot in doing so. Good luck !

VSCode "View Problem" Dialog Background Property

I searched through the VSCode Docs, but was unable to locate any useful documentation that explained what the properties that highlight the background colors for the widget demonstrated in the image below.
What VSCode Theme property modifies the "View Problem" dialogue's background color?
After two hours of isolating individual properties and trying to diagnose the issue, I can confirm that the property that controls the background color of VSCode's "View Problem" dialog is called: 'editorMarkerNavigation.background'.
I hope this helps others in the future.
So this isn't a problems widget, its a navigation widget, and it helps to communicate important statuses in the current script you have loaded into the editor. It attempts to help you find and locate issues. I find that it is most useful when used inside of a very large code base. It doesn't just relay what problems exist, it can show errors, info, & warnings too.
So the property you suggested colors the majority of the background, but part of the widget is a header, and to change the background color of the header you will also need to use "editorMarkerNavigationError.headerBackground".
This is the full property list for "Marker Navigation Widget".
// #file "./themes/your-vscode-theme.json"
{
"editorMarkerNavigationInfo.headerBackground": #000000,
"editorMarkerNavigation.background": #000000,
"editorMarkerNavigationError.background": #000000,
"editorMarkerNavigationInfo.background": #000000,
"editorMarkerNavigationWarning.background": #000000,
"editorMarkerNavigationWarning.headerBackground": #000000
}

Adding icons to an button in gwt

i have button and want to set an icon to it along with the text inside it. their is no property to add icon to button like in smartGwt .. any idea how to achieve it please help.
There are many ways of achieving this.
Way 1 : Easy way
Just set the background image via code.
myButton.getElement().getStyle().setBackgroundImage("path");
Way 2: Another easy way
Set your own html
myButton.setHtml("Pass the html string");
Way 3: Easy but gives more control
myButton.addStylename("buttonStyle")
Use css to style this
.buttonStyle{
color : red;
}
Way 4: Best way according to me
Create your own split button wrapping it around a flowpanel or horizontalPanel, with image as your first widget and button as your another widget. This gives you additional control on image and as well as button. You can have your click handler on image as well as button and you can style each one of them individually.
This is how I achieved setting an icon in my get:button.
Add an extra style class hook, mine below is btn-fa-group to your gwt button. If you use the attribute 'addStyleNames' you can define them in your stylesheet and have multiple classes.
<g:Button text=" Post Your Answer" enabled="false" ui:field="showPostButton" addStyleNames="btn btn-default btn-fa-group" />
Now in your CSS define the following declaration:
btn-fa-group:before {
color: #333333;
content: "\f0c0";
display: inline-block;
font-family: "fontawesome";
}
Some important things to note; don't forget the before selector, make sure the unicode starts with a slash and have fontAwesome installed. Alternatively you can use another glyph icon if you have the font installed.
You can set innerhtml with image in button i.e.
Button button=new Button("<image src='abc.jpg' width='200px' height='300px' />Ok");
Button bt = new Button();
bt.getElement().getStyle().setBackgroundImage("url('path/to/ur/image/imagename.extention')");
also set size of background image wrt to the size of button
bt.getElement().getStyle().setProperty("backgroundSize","30px");
Add a Css Class to your Button is probalby the best solution.
button.addStyleName("ButtonIcon");
How to define the CSS and HTML you can read here.
Yes ,you can .Gwt have a SmartGwt type button called push buttopn
com.google.gwt.user.client.ui.PushButton
You can pass Image object to it as below
Image image = new Image(GWT.getModuleBaseURL() + "/images/search-arrow.png");
RootPanel.get().add(new PushButton(image));

Twitter Widget ignoring font-size css on iPhone

My website uses the Twitter widget to grab tweet and uses the "twtr-tweet-text" class to change the font family and size.
Unfortunately, on my iPhone (not on iPad) it seems to ignore the font size completely which causes it to overlap my footer. Looking closer it seems that the font-size is right for the 'reply retweet favourite' section but not for the actual tweet.
http://jshjohnson.com
How would I go about stopping this happening?
Thanks
The twitter widget has code that is setting the font-size in the linked widgit.css. I don't know if you have access to change to CSS within that file, but you can get more specific than the widget.css by targeting the div with your own style. You may have an ugly css rule but it's a quick and dirty fix.
If you can target this more specifically than the widget.css the rule should be applied. The following might work, if I'm targeting the text you had in mind.
div.twtr-tweet-wrap p {
font-size: .75em; /* set whatever font size you want */
...
}
Anyway you have the idea, just find the div you want and get specific. You could check to see what the twitter css is doing here. If you really wanted you could try and match the rule and set the font-size to inherit, so only one font-size rule would have the specific size, to ease future adjustments.

Gtk Spinner Not Appearing

I'm trying to get a Gtk::Spinner object to display while calculations are in progress but nothing appears to be happening. The snippet of code looks like...
{
Gtk::Spinner spinner;
spinner.start ();
// do some work...
spinner.stop ();
}
I'd have thought the spinner needed to know which dialogue it appears over but I can't see any way of feeding that into the object. Does anyone know where I could find a worked example? I can find the Gtk documentation in many places, but that isn't helping much.
In short, here is a quick checklist if Gtk::Spinner is not appearing on screen:
Make sure librsvg is installed.
Check if your currently active Gtk theme has an image file with base name "process-working-symbolic" (e.g. /path/to/your/theme/icons/scalable-up-to-32/status/process-working-symbolic.svg).
In your app code: Make sure you added the spinner object to some parent widget / container: vbox.pack_start(spinner, Gtk::PACK_SHRINK);
In your app code: Ensure all widgets are actually made visible: show_all_children();
In your app code: Finally you need to call spinner.start() for the widget to actually appear and spin on screen.
In detail:
The actual Gtk spinner widget code (see function gtk_spinner_class_init() in gtkspinner.c) is not doing any drawing on its own. In fact its code is very little. All it does is adding CSS code to the gtk widget:
it assigns the CSS class "spinner" to the widget
and it automatically adds and removes the CSS pseudo-class "checked" whenever the widget's boolean gtk property "active" changes.
So the actual look (icon) and the animation is defined by your current theme's CSS file. E.g. in Gtk's default theme's gtk-contained.css file you find the following:
spinner {
background: none;
opacity: 0;
-gtk-icon-source: -gtk-icontheme("process-working-symbolic");
};
Which means it will automatically search for an appropriate image file with base name "process-working-symbolic" in the theme's "icons" directory tree. And the actual spinning animation is defined in the same CSS file by this:
spinner:checked {
opacity: 1;
animation: spin 1s linear infinite;
};
In most other themes these CSS code portions for the spinner widget are pretty much identical.
Now here is a common problem with this: in most themes the spinner image is an SVG file (e.g. typically "process-working-symbolic.svg"), but the stock Gdk pixbuf loaders do not support the SVG format at all. They support a variety of other image file formats, but for actually allowing Gdk/Gtk to load .svg files you need to install a third-party pixbuf loader capable to do so like librsvg.
Alternative:
In case you cannot or don't want to bother to install an SVG capable Gdk pixbuf loader like librsvg, then you can also simply add image file(s) with the same base name, but in another file format like "process-working-symbolic.png" to your theme's icons directory tree. So either draw or download some spinner picture then scale it and place them several times to the resolutions listed in your theme's "icons" directory, e.g.:
/THEMEDIR/icons/8x8/status/process-working-symbolic.png
/THEMEDIR/icons/16x16/status/process-working-symbolic.png
/THEMEDIR/icons/22x22/status/process-working-symbolic.png
/THEMEDIR/icons/24x24/status/process-working-symbolic.png
/THEMEDIR/icons/32x32/status/process-working-symbolic.png
/THEMEDIR/icons/64x64/status/process-working-symbolic.png
/THEMEDIR/icons/256x256/status/process-working-symbolic.png
/THEMEDIR/icons/512x512/status/process-working-symbolic.png
Also you should know: Whenever you do spinner.start() the spinner icon immediately appears on screen, but even on a decent machine it typically takes almost a second before the spinner starts its animation.
Did you call
spinner.show ();
and add it to some window?
Moreover, your calculations may block the UI, so it is not updated. Call
while (Gtk::Main::events_pending ())
Gtk::Main::iteration ();
once in a while.
To change the mouse cursor to "busy" you can do the following:
Glib::RefPtr<Gdk::Window> window = dialog.get_window();
if(window) {
window->set_cursor(Gdk::Cursor(Gdk::WATCH));
Gdk::flush();
}
To change it back, do
window->set_cursor();
instead.
Disclaimer: I usually work with GTK in C, and have translated this on the fly...