Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GtkTextView top/bottom margin?

I would like to know the correct and generally accepted way of adding a top and bottom margin to a GtkTextView that is inside of a GtkScrolledWindow. There are functions to set the left and right margin, which I am using:

gtk_text_view_set_left_margin(GTK_TEXT_VIEW(editor_text_view), 2);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(editor_text_view), 2);

But I can't seem to find any documentation on top and bottom. I've tried changing the border width of the GtkTextView with gtk_container_set_border_width but the border is not painted with the background color of the GtkTextView.

Basically - what I have is on the left and what I want is on the right.

Screenshot of what I haveScreenshot of what I want

like image 687
Sean Bright Avatar asked Dec 14 '11 21:12

Sean Bright


3 Answers

You should use CSS for this things in GTK+ 3:

http://developer.gnome.org/gtk3/3.3/GtkCssProvider.html

Maybe you can use the view class:

.view {
    padding: 3px;
}

Or only apply the style to the GtkTextView:

GtkTextView {
    padding: 3px;
}
like image 87
manuq Avatar answered Nov 14 '22 22:11

manuq


I'm using Ubuntu Natty with gtk+-3.2.3. and those CSS properties don't have any affect for some reason.

But you can use: gtk_text_view_set_border_window_size( )

Along with: GTK_TEXT_WINDOW_TOP and GTK_TEXT_WINDOW_BOTTOM

And the border color will match the background of the GtkTextView.

http://developer.gnome.org/gtk3/3.4/GtkTextView.html#gtk-text-view-set-border-window-size

like image 27
mike Avatar answered Nov 14 '22 23:11

mike


I just had to solve similar issue and I nested the text view in GtkAlignment - that gave me an option to set padding for all sides.

like image 1
Ladislav Mrnka Avatar answered Nov 14 '22 23:11

Ladislav Mrnka