Help spinbuttons

2015-03-16 Thread Roger Matthews

/* I want a window containing many spinbuttons for both
integers and floating-point numbers, these may then be either 1) left
unchanged, or 2) changed to a new value. Then, whether changed or unchanged,
use the integers and floats as input parameters into various calculations. As
it is the printf() statements only show the unchanged values. */


/*The example below is taken from page 90 of
Foundations of GTK+ Development by Andrew Krause*/


#include stdio.h

#include gtk/gtk.h


int main(int argc, char *argv[])


GtkWidget *window, *spin_int, *spin_float;

GtkAdjustment *integer, *float_pt;


gint number_int;

gdouble number_double;


gtk_init (argc, argv);


window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_window_set_title (GTK_WINDOW (window), Spin Buttons);

gtk_container_set_border_width (GTK_CONTAINER(window), 10);

gtk_widget_set_size_request (window, 150, 100);


integer = GTK_ADJUSTMENT (gtk_adjustment_new (5.0, 0.0,
10.0, 1.0, 2.0, 2.0));

float_pt = GTK_ADJUSTMENT (gtk_adjustment_new (0.5, 0.0, 1.0,
0.1, 0.5, 0.5));


spin_int = gtk_spin_button_new (integer, 1.0, 0);

spin_float = gtk_spin_button_new (float_pt, 0.1, 1);


gtk_container_add (GTK_CONTAINER (window), spin_int);

gtk_container_add (GTK_CONTAINER (window), spin_float);


gtk_widget_show_all (window);





(integer, change-value, G_CALLBACK (spin_int), number_int);


  g_print (Hello

(g_print Before gtk_main, integer %d\n, number_int);

Before gtk_main, integer %d\n, number_int);

Before gtk_main, double %f\n, number_double);


gtk_main ();



gtk_main %d\n, number_int);


return 0;



/*Below are the commands to edit, compile and execute the
program, and the warnings, messages and output to the terminal. At this stage
the warnings are unimportant, I merely want to be able to read or save both the
unchanged and changed values displayed in the spinbutton(s).*/



$ gedit page90.c


$ gcc `pkg-config --cflags gtk+-3.0` -o page90.exe page90.c
`pkg-config --libs gtk+-3.0`


$ ./page90.exe


(page90.exe:2614): Gtk-WARNING **: Attempting to add a
widget with type GtkSpinButton to a GtkWindow, but as a GtkBin subclass a
GtkWindow can only contain one widget at a time; it already contains a widget
of type GtkSpinButton


(page90.exe:2614): GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.38.1/./gobject/gsignal.c:2475: signal 'change-value' is
invalid for instance '0xee5350' of type 'GtkAdjustment'

Hello World

g_print Before gtk_main, integer 5

printf Before gtk_main, integer 5

printf Before gtk_main, double 0.50*/


gtk-app-devel-list mailing list

Re: borderless MacOS menus (was 'Gtk3 MacOS (OSX) context menu issues')

2015-03-16 Thread Jim Charlton

On 15-03-15 08:24 PM, Jim Charlton wrote:

On 15-03-15 01:49 PM, Roger Davis wrote:

Thanks for the suggestion, Jim, but no luck so far in getting any 
change to my menu borders via

.window-frame, .window-frame:backdrop {
  box-shadow: 6px 6px;
  margin: 6px;

which I added to a new $XDG_CONFIG_HOME/gtk-3.0/gtk.css file. This 
file is definitely being parsed at app startup time, because if I change

.window-frame, .window-frame:backdrop {

to instead read

* {

I get the most hideous GUI imaginable, i.e., big ugly shadow borders 
around almost everything *except* my menus, which are still 
completely borderless! It just seems like my system is flat-out never 
drawing any menu borders no matter what.


On Sun, 15 Mar 2015, Jim Charlton wrote:

My experience has been that I can set the XDG_CONFIG_HOME 
environment variable to the path to the gtk-3.0 directory (eg. 
/opt/local/share/themes/Default) and then put both the gtk.css and 
the settings.ini file in the 
/opt/local/share/themes/Default/gtk-3.0/ directory. When a gtk3 
application is run, both files will be processed.  You can put css 
into the gtk.css file and it seems to override the in-line 
(compiled?) theme data.  If you do figure out how to put shadowed 
margins on the menus, let us know if it brings back the item 
selection problem.

If you just want to put a border on the menubar you can try adding

.menubar {
  border-width: 6px;
  background-color: red;
  border-color: black;
  border-style: solid;

to the gtk.css file.  This will give a red background and a wide, 
black border to the menubar.  Or apply the same configuration to 
.menuitem to give background color and borders to all menu items in 
the menubar and in the dropdown menu boxes.

I am not quite sure how you could make it shadowed.

jim...  Jim Charlton
gtk-app-devel-list mailing list

Ahhh...  you can get shadowed borders by adding something like

.menubar {
  border-width: 1px;
  box-shadow:  inset 0 0 10px #00;|
border-style: solid;

You can experiment with various box-shadow parameters.


gtk-app-devel-list mailing list

Re: borderless MacOS menus (was 'Gtk3 MacOS (OSX) context menu issues')

2015-03-16 Thread Roger Davis

On Mon, 16 Mar 2016, Jim Charlton wrote:

.menubar {
 border-width: 6px;
 background-color: red;
 border-color: black;
 border-style: solid;

Thanks Jim, that tip led to this good-enough-for-now solution:

GtkMenu {
  border-width: 1px;
  border-color: #cc;
  border-style: solid;
  box-shadow: inset -1px -1px 2px #77;

GtkMenu is equivalent to .menu as far as I can tell, and both worked for 
me -- can anyone comment? The .menubar style class does not work as these 
are popup menus, not menubars. (Curiously, .popup does not work, which 
would seem to apply according to the GtkStyleContext man page.)

My earlier attempt with

* {

did not work because I wasn't specifying the correct property entries. 
(border-width and border-style are key, I was incorrectly using margin 

Box shadows seem totally unattainable on my MacOS system if I do not use 
the optional (!?!) 'inset' specifier. I actually do not want an inset 
shadow (I want outset?) but the above specification creates a shadow 
that's subtle enough that you can't easily tell the difference.

Many minor gtk3 style inconsistencies remain between my MacOS and CentOS 7 
boxes, but I think for now I've whacked all that exceed my personal 
hideousity threshold.


gtk-app-devel-list mailing list