Copywrite protection and source-code distribution

2018-08-01 Thread Roger Matthews via gtk-app-devel-list
I have developed an application using GTK+3.10. What copy-write protection can 
you (GTK+) provide for me. I have been told that copywrite is free and 
automatic and that to protect the software from piracy I need sufficient money 
to prove prior usage in a court of law.  I don't see how the requirement of 
including my source code in the package will allow for successful 
commercialisation when someone can just simply copy the source-code.  I have no 
problems about acknowledging GTK+ for providing the GUI development platform 
and for helping with problems in coding, etcetera. Without adequate protection 
this requirement (including the source-code) renders GTK+ useless as far as any 
kind of commercialisation is concerned, please enlighten me on this matter.

Roger Matthews


[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-green-avg-v1.png]<http://www.avg.com/email-signature?utm_medium=email_source=link_campaign=sig-email_content=webmail>
 Virus-free. 
www.avg.com<http://www.avg.com/email-signature?utm_medium=email_source=link_campaign=sig-email_content=webmail>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Updating displayed spinbutton value from a text file

2018-07-05 Thread Roger Matthews via gtk-app-devel-list
 I'm using gtk+3.10 on Ubuntu 14.04 and am writing an application in C, 
with the user interface constructed with a builder.ui file. I am using 
spinbuttons to create and change Cairo drawings of some mathematical functions. 
The spinbuttons’ adjustment value is initialised from the builder.ui file and 
can then can be changed with the spinbutton, I also read values from a text 
file to create and change the drawings, which after being read from the file 
(containing many drawing parameters) these parameters are then written to 
seperate files for each parameter which are then read into the drawing function 
in drawing.c, which is compiled together with mymain.c.
 This works ok (the drawings change), except that when reading the values 
from the file I would also like to update the values displayed in the 
spinbuttons so that they match those in the file and with the correctly updated 
drawings.
 I have tried using the following, taken from Foundations of GTK+ 
Development, by Andrew Krause (gtk+2):

gtk_spin_button_set_value (GtkSpinButton *spin_drawingparameter1, int 
drawingparameter1);

in the callback for the spinbutton *spin_readfile (which makes the choice 
between reading/not reading the file).

When attempting to compile I receive this error message:

mymain.c: In function ‘callback_readfile’:
mymain.c:1124:28: error: expected expression before ‘GtkSpinButton’
 gtk_spin_button_set_value (GtkSpinButton *spin_drawingparameter1, int 
drawingparameter1);
^
mymain.c:1124:28: error: too few arguments to function 
‘gtk_spin_button_set_value’
In file included from /usr/include/gtk-3.0/gtk/gtk.h:176:0,
 from mymain.c:9:
/usr/include/gtk-3.0/gtk/gtkspinbutton.h:197:7: note: declared here
 void  gtk_spin_button_set_value(GtkSpinButton  *spin_button,
   ^
make: *** [mymain] Error 1

The first error I don't know what I need to do at all, while the second error 
may be related to the gtk+ version, or it might not
Can this be done in my builder.ui file, perhaps with “change-value”?

Any help would be greatly appreciated,
Thanks,
Roger Matthews

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Re: LuckyB.C.'s reply to GtkDrawingArea "width" and "height"

2018-03-13 Thread Roger Matthews
Big thanks to Eric Cashon and LuckyB.C.,

the 
"width" and "height"  problem is certainly solved, I have also 
copied, changed and adapted the code from the link in the email by LuckyBC, 
included bits of Eric's code, as well as much of my own code, this works very 
nicely, having just worked out how to connect and pass data from newly-added 
spinbuttons to the change_drawing and drawing functions, then produce my own 
drawings.

.and yes, I will make the appropriate acknowledgments as set out in the 
open source legal framework.

Thanks again,

Roger Matthews.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Lucky B.C.'s reply to GtkDrawingArea "width" and "height"

2018-03-06 Thread Roger Matthews
Thanks Lucky B. C. for replying to my email, I have already tried

  4000

  1000

without success (see code below).

 I am attempting to draw a Cairo line from two points entered with spin 
buttons that is built with builder.ui, using C language on Ubuntu 14.04, with 
Gtk+ 3.0. I have already built a gui coded in C without using a builder.ui file 
and am now attempting to reproduce this with a builder.ui to make the 
application. The interface opens, the 'hello' and 'quit' buttons work, the 
spinbuttons are (now) working correctly, but I am encountering two or three 
problems with drawing that may or may not be connected:

1) I cannot work out how to set the size of the GtkDrawingArea in the 
builder.ui file, which is a simple thing to do in the program using, for 
example:



  darea = gtk_drawing_area_new();

  gtk_widget_set_size_request (darea, 800, 500);

  gtk_fixed_put (GTK_FIXED (fixed), darea, 0, 0);

  g_signal_connect(G_OBJECT(darea), "draw", G_CALLBACK(on_draw_event), NULL);



2) Despite the warnings the Cairo drawing is drawn when I click on tab2, 
although ultimately I would like to use a GtkLayout to contain spinbuttons and 
the drawing within the same notebook page, and to have the drawing updated as 
the spinbutton values are changed, so far with no success, but for now let's 
deal with the sizing of the GtkDrawingArea, so that my pre-existing gui program 
can be converted into an application.



Any help with these problems would be greatly appreciated, sorry about the 
length of this email, if the code below is copied to your computer it should 
run, thanks, Roger.



With the drawing area “width” and “height”  commented-out in 
builder.ui these are the commands, errors and warnings:



$ gedit darea_widthheight.c

$ make

gcc -mcmodel=large `pkg-config --cflags gtk+-3.0` -o darea_widthheight 
darea_widthheight.c `pkg-config --libs gtk+-3.0` -lm

$ ./darea_widthheight

(darea_widthheight:2787): Gtk-CRITICAL **: gtk_buildable_add_child: assertion 
'iface->add_child != NULL' failed

(darea_widthheight:2787): Gtk-CRITICAL **: gtk_buildable_add_child: assertion 
'iface->add_child != NULL' failed

(darea_widthheight:2787): GLib-GObject-WARNING **: invalid unclassed pointer in 
cast to 'GtkWindow'

(darea_widthheight:2787): Gtk-CRITICAL **: gtk_window_get_size: assertion 
'GTK_IS_WINDOW (window)' failed

winwidth_draw1 = 1734702190, winheight_draw1 = 741438053

Hello World

$



Then when the drawing area “width” and “height”  are uncommented in 
builder.ui, note that “width” and “height”  are not recognised.



$ ./darea_widthheight

(darea_widthheight:2928): Gtk-CRITICAL **: gtk_buildable_add_child: assertion 
'iface->add_child != NULL' failed

(darea_widthheight:2928): Gtk-CRITICAL **: gtk_buildable_add_child: assertion 
'iface->add_child != NULL' failed

(darea_widthheight:2928): Gtk-WARNING **: Unknown property: GtkDrawingArea.width

(darea_widthheight:2928): Gtk-WARNING **: Unknown property: 
GtkDrawingArea.height

(darea_widthheight:2928): GLib-GObject-WARNING **: invalid unclassed pointer in 
cast to 'GtkWindow'

(darea_widthheight:2928): Gtk-CRITICAL **: gtk_window_get_size: assertion 
'GTK_IS_WINDOW (window)' failed

winwidth_draw1 = 1734702190, winheight_draw1 = 741438053

Hello World

$



darea_widthheight.c:

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 

#include 



float float1 = 53.1;

int integer1 = 53;



static void

print_hello (GtkWidget *widget, gpointer   data)

{

  g_print ("Hello World\n");

}



static void get_new_number_float_float1(GtkWidget *widget, gpointer data)

{

float1 = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));

write_file2();

}



static void get_new_number_int_integer1(GtkWidget *widget, gpointer data)

{

integer1 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));

write_file2();

}



static void do_drawing1(cairo_t *, GtkWidget *);



static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,

gpointer user_data)

{

do_drawing1(cr, widget);

return FALSE;

}



static void do_drawing1(cairo_t *cr, GtkWidget *widget)

{

  GtkWidget *win = gtk_widget_get_toplevel(widget);



char paramname1, paramname2;

 FILE* infile_file2 = fopen("file2", "r");

 fscanf(infile_file2,"%s %f\n%s %d\n", , , , 
);

 fclose(infile_file2);



  int winwidth_draw1, winheight_draw1;

  gtk_window_get_size(GTK_WINDOW(win), _draw1, _draw1);

printf("winwidth_draw1 = %d, winheight_draw1 = %d\n", winwidth_draw1, 
winheight_draw1);

  cairo_set_source_rgb(cr, 0.6, 0.0, 0.0);

  cairo_set_line_width(cr, 1.0);

  cairo_move_to(cr, float1, float1);

  cairo_line_to(cr, integer1, integer1);

  cairo_stroke(cr);

}



static void activate (GtkApplication *app, gpointer user_data)

{

int   argc;

char **argv;



  GtkBuilder *builder1;

  GObject *window, *notebook;

  GObject *label1, *spin_float1, 

builder.ui and GtkDrawingArea size

2018-02-27 Thread Roger Matthews
How do I set the size, or what are the x and y size  of a 
GtkDrawingArea in builder.ui, I can't find these in the documentation anywhere, 
thanks,

Roger Matthews
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


re: builder.ui and spinbutton adjustment

2018-02-26 Thread Roger Matthews
I have the first version of Gtk+ 3, I believe it is Gtk+ 3.19.4. Being the 
first of the Gtk+ 3 it may contain bugs that I am not aware of that have since 
been fixed in later versions. The fact that the "upper", "lower", 
"step-increment", "page-increment" and "page-size" properties are all read from 
the builder.ui correctly but the "value" property is not leads me to believe 
that it may be a bug. I can see no differences between each  
statement of the adjustment in the builder.ui, it may also be that I am missing 
some code or that I have made some other mistake, any help would be greatly 
appreciated as it might stop be banging my head against the desk, thanks,

Roger Matthews
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


builder.ui and spinbutton adjustment

2018-02-25 Thread Roger Matthews
Problem: spinbutton adjustment “value” not displayed on otherwise functional 
floating-point and integer spinbuttons, built from builder.ui, using C language 
on Ubuntu 14.04, with Gtk+ 3.0. I have already built a gui coded in C without 
using a builder.ui file and am now attempting to reproduce this with a 
builder.ui to make the application. The interface opens, the 'hello' and 'quit' 
buttons work, the spinbuttons are active, can be changed and printed to the 
terminal via the callback functions, but the initial “value” is either 0.0 or 0 
for float and integer respectively, and not the intended initial value. The two 
run-time messages shown immediately below obviously refer to the two spinbutton 
adjustments. Sorry about the length of this email, if the code below is copied 
to your computer it should run, thanks,
Roger Matthews.

Written at terminal:---

/Roger_app2$ gedit spin_app.c
/Roger_app2$ make
/Roger_app2$ ./spin_app
(spin_app:3326): Gtk-CRITICAL **: gtk_buildable_add_child: assertion 
'iface->add_child != NULL' failed
(spin_app:3326): Gtk-CRITICAL **: gtk_buildable_add_child: assertion 
'iface->add_child != NULL' failed
float1 = 0.1
float1 = 0.2
float1 = 0.3
integer1 = 1
integer1 = 2
integer1 = 3
integer1 = 4
Hello World
/Roger_app2$

spin_app.c -
compiled with:
gcc `pkg-config --cflags gtk+-3.0` -o spin_app spin_app.c `pkg-config --libs 
gtk+-3.0`

#include 
#include 

float float1 = 53.1;
int integer1 = 53;

static void
print_hello (GtkWidget *widget,
 gpointer   data)
{
  g_print ("Hello World\n");
}

static void get_new_number_float_float1(GtkWidget *widget, gpointer data)
{
float1 = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
printf("float1 = %.1f\n", float1);
}

static void get_new_number_int_integer1(GtkWidget *widget, gpointer data)
{
integer1 = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
printf("integer1 = %d\n", integer1);
}

static void do_drawing(cairo_t *, GtkWidget *);

static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
gpointer user_data)
{
  do_drawing(cr, widget);
  return FALSE;
}

static void do_drawing(cairo_t *cr, GtkWidget *widget)
{
  GtkWidget *win = gtk_widget_get_toplevel(widget);

  int winwidth_draw1, winheight_draw1;
  gtk_window_get_size(GTK_WINDOW(win), _draw1, _draw1);
  cairo_set_source_rgb(cr, 0.6, 0.0, 0.0);
  cairo_set_line_width(cr, 1.0);
  cairo_move_to(cr, 20, 20);
  cairo_line_to(cr, 70, 135);
  cairo_stroke(cr);
}

int
main (int   argc,
  char *argv[])
{
  GtkBuilder *builder;
  GObject *window;
  GObject *notebook;
  GObject *label1;
  GObject *spin_float1;
  GObject *label2;
  GObject *spin_int1;
  GObject *notebook_tab1;
  GObject *button_hello;
  GObject *notebook_tab2;
  GObject *button_quit;
  GObject *notebook_tab3;
  GObject *adjustment1;
  GObject *adjustment2;

  gtk_init (, );

  /* Construct a GtkBuilder instance and load our UI description */
  builder = gtk_builder_new ();
  gtk_builder_add_from_file (builder, "builder.ui", NULL);

  /* Connect signal handlers to the constructed widgets. */
  window = gtk_builder_get_object (builder, "window");
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  spin_float1 = gtk_builder_get_object (builder, "button1");
  g_signal_connect (spin_float1, "value-changed",
G_CALLBACK (get_new_number_float_float1), NULL);

  spin_int1 = gtk_builder_get_object (builder, "button2");
  g_signal_connect (spin_int1, "value-changed",
G_CALLBACK (get_new_number_int_integer1), NULL);

  button_hello = gtk_builder_get_object (builder, "button_hello");
  g_signal_connect (button_hello, "clicked", G_CALLBACK (print_hello), NULL);

  button_quit = gtk_builder_get_object (builder, "quit");
  g_signal_connect (button_quit, "clicked", G_CALLBACK (gtk_main_quit), NULL);

  gtk_main ();

  return 0;
}

builder.ui 




  
True
Roger's App
10
600
400

  
True
True


  
True
1200
1200
  

  Label1
  True

  
  1
  1
  
  
  

  True
  True
  True
  
  1
  1
  adjustment1
  

  53.1
 

Spinbutton Adjustment in builder.ui

2018-02-24 Thread Roger Matthews
I need help with Spinbutton Adjustment in builder.ui, please see the attached 
file,

thanks,

Roger Matthews
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Filechooserbuttons and gtk_widget_set_sensitive

2015-10-07 Thread Roger Matthews
To someone willing to help,
 
 1) Following the example Listing 4.10 of the GTK+ Development book 
filechooserbuttons.c I have created a filechooser button and label, which are 
attached to a grid rather than a box. When clicked a "dialogue" appears, I can 
then navigate directories to the filtered files, highlight the selected files, 
but when double-clicked or press 'open', nothing happens. That is, the 
path/filename is displayed in the label and the selected filename is displayed 
in the button but the file is not opened. How do I open the file?
 
2) I would like to activate/de-activate spinbuttons depending on whether 
certain other selections have been made (with other integer spinbuttons). I 
have tried using gtk_widget_set_sensitive ( GtkWidget *widget, gboolean 
sensitive) but get compilation warning: unknown type name 'gtk_widget_set'. I'm 
using GTK3. Any clues? 
 
3) I've built a GUI coded in C without using a builder.ui file and would like 
to make it into a stand-alone application, preferably all 'hand' coded, how do 
I do this? I'm having difficulty following the example in the documentation 
because it uses a buider.ui file, I am unsure of the form of the main() format, 
and I can't locate 
https://git.gnome.org/browse/gtk+/tree/examples/application2/exampleappwin.c 
 
Thanks,
Roger Matthews
  
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Non-editable output label

2015-09-13 Thread Roger Matthews
 To Chris Moller and others interested,
 thanks for 
taking the time to respond, or if you're thinking of responding to my query, 
don't worry about responding because I have figured it out. Stupid me didn't 
realise that I would need a callback function for this also,
Thanks,
Roger Matthews
  
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Non-editable float output widget

2015-09-10 Thread Roger Matthews
 To An Interested and Helpfull Person,
I would 
like to show some floating point and integer numbers which are the results of 
various calculations on the top-level window alongside other widgets. These 
resultant numbers must be non-editable. I've tried this by first converting the 
numbers to strings:
 
char string_anumber[20]; /* As a global variable */
sprintf (string_anumber, "%f", anumber);
 
subsequent printf() statements show that this converts the number to a string 
successfully.
Then I try to show the string as a gtk_label (for want of an approprtiate 
method):
 
label_string_anumber = gtk_label_new (string_anumber);
gtk_grid_attach (GTK_GRID (grid), label_string_anumber, 0, 0, 1, 1);
 
This compiles but simply shows nothing at the given grid location. I've also 
tried:
 
label_string_anumber = g_print ("%s", string_anumber);
gtk_grid_attach (GTK_GRID (grid), label_string_anumber, 0, 0, 1, 1);
 
and:
 
gtk_grid_attach (GTK_GRID (grid), g_print ("%s", string_anumber), 0, 0, 1, 1);
 
Thanks for reading, considering and responding to this enquiry,
Roger Matthews.
  
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


RE: Scrolling a Cairo drawing-area or Gtk layout

2015-07-27 Thread Roger Matthews



Hi Damien Caliste, Jim Charlton, and Pramithesh,   that has 
worked and here is the code I used:window2 = 
gtk_window_new(GTK_WINDOW_TOPLEVEL);gtk_window_set_default_size(GTK_WINDOW(window2),
 1000, 800);grid2 = gtk_grid_new();darea = 
gtk_drawing_area_new();gtk_widget_set_size_request(darea, 3000, 
2000);gtk_grid_attach(GTK_GRID (grid2), darea, 0, 0, 1, 
1);g_signal_connect(G_OBJECT(darea), draw, G_CALLBACK(on_draw_event), 
NULL);g_signal_connect(G_OBJECT(darea), destroy, 
G_CALLBACK(gtk_widget_destroy), NULL);swin2 = gtk_scrolled_window_new(NULL, 
NULL);gtk_container_set_border_width(GTK_CONTAINER (swin2), 
5);gtk_container_add(GTK_CONTAINER (swin2), grid2);box2 = gtk_box_new (TRUE, 
5);gtk_box_pack_start (GTK_BOX (box2), swin2, TRUE, TRUE, 5);gtk_container_add 
(GTK_CONTAINER (window2), box2);gtk_widget_show_all (window2);



 Date: Mon, 27 Jul 2015 10:10:27 +0200
 From: damien.cali...@cea.fr
 To: gtk-app-devel-list@gnome.org
 Subject: Re: Scrolling a Cairo drawing-area or Gtk layout
 
 Hello,
 
 Le 21/07/2015, Roger Matthews roger.matth...@hotmail.com a écrit :
  which results from a simple straight line equation, and*/ /* that
  extends beyond the bounds of the window.
 Reading your code quickly, it seems to me that, you're drawing indeed
 the line outside the drawing area, *but* the drawing area has the size
 of your window, so GTK is not displaying any scrollbars.
 
 In my opinion, you should :
 - in main, declare your drawing area to a fixed size (let say
   1200×1200) and declare your window size at 600×400 as you're doing ;
 - in the drawing method (do_drawing()), don't use the window size, but
   the drawing size as bounds from your drwaing commands. It's useless
   to draw lines or whatever outside the cairo drawing area, they will
   be cropped anyway. So don't reach for the top level there, use the
   size of the widget itself.
 
 As a schemme :
 - your implementation : |#|
 - the way to do it : |##|
   - # means GTK scrollview, - means drawing area
   - call cairo drawing primitives in the coordinates of the drawing area
 (-), but not outside.
 
 Damien.
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

  
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Scrolling a Cairo drawing-area or Gtk layout

2015-07-25 Thread Roger Matthews
 /*Hello, if there is anybody willing to help with this problem I would be very 
appreciative and thanks in advance. Here is some code and my problem is this: */
/*I create two windows, one with spinbuttons for parameter entry, and the other 
shows a cairo line which results from a simple straight line equation, and*/
/* that extends beyond the bounds of the window. The first window is scrollable 
and I would like to be able to scroll to the end of the line in the second 
window*/
/*but don't seem to be able to work out how. I've tried putting the darea into 
the scrolled-window as per window1, it compiles and runs but has no 
scrollbars.*/
/*I've also tried gtk_container_add (darea, swin, layout, and many combination 
thereof) to window2.*/

/*Having read that a gtk layout supports scrolling natively I assumed it would 
do this easily. If I declare the layout as GtkWidget then gtk_container_add 
accepts*/
/*the layout but produces no scrollbars and if I declare it as GtkLayout then 
gtk_container_add won't accept it, if I use gtk_layout_put there's problems 
too.*/
/*If an example of a gtk layout (on one, or more windows) with scrolling (on 
one, or more windows) could be provided I would be happy and could stop 
tearing*/
/*my hair out, thanks in advance, Roger Matthews.*/
#include stdio.h

#include math.h

#include gtk/gtk.h

#include cairo.h

 

/*Global Variables*/

 int i;

 double yvalue1[1001];

 int yvalue1_param1 = 1;

 float yvalue1_param2 =
3.0;

 float const_asp_ratio =
1.0;

/***GTK CALLBACK FUNCTIONS**/

static void get_new_number_integer_yvalue1_param1(GtkWidget
*widget, gpointer data)

{

 yvalue1_param1 =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));

 write_yvalue1params();

 printf(yvalue1_param1 = %d\n,
yvalue1_param1);

}

//

static void get_new_number_float_yvalue1_param2(GtkWidget
*widget, gpointer data)

{

 yvalue1_param2 =
gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));

 write_yvalue1params();

 printf(yvalue1_param2 = %f\n,
yvalue1_param2);

}

//

static void get_new_number_float_const_asp_ratio(GtkWidget
*widget, gpointer data)

{

 const_asp_ratio =
gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));

 write_yvalue1params();

 printf(const_asp_ratio = %f\n,
const_asp_ratio);

}

//

static void do_drawing(cairo_t *, GtkWidget *);

 

static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, 

gpointer user_data)

{  

  do_drawing(cr, widget);

  return FALSE;

}

 

static void do_drawing(cairo_t *cr, GtkWidget *widget)

{

 GtkWidget *win =
gtk_widget_get_toplevel(widget);

 int i;

 double yvalue1[1001];

 float const_asp_ratio;

 char yvalue1paramname1,
yvalue1paramname2, yvalue1paramname3;

 FILE*
infile_yvalue1params = fopen(InputParameters/yvalue1params,
r);

 fscanf(infile_yvalue1params,%s %d\n%s
%f\n%s %f\n, yvalue1paramname1, yvalue1_param1,
yvalue1paramname2, yvalue1_param2, yvalue1paramname3,
const_asp_ratio);

 fclose(infile_yvalue1params);

 

  /*Create 'yvalue1' */

  for(i = 0; i = 1000;
i++)

  {

  yvalue1[i] = (float)i;

  }

/*/

  int winwidth, winheight;

 
gtk_window_get_size(GTK_WINDOW(win), winwidth, winheight);

 

  cairo_set_source_rgb(cr,
0.6, 0.0, 0.0);

  cairo_set_line_width(cr,
1.0);

 

  cairo_move_to(cr,
winwidth/8, (float)yvalue1_param1*(winheight/8)+yvalue1_param2);

  for (i=0; i = 1000;
i++)

  {

  cairo_line_to(cr,
i+(winwidth/8), 
(float)yvalue1_param1*(winheight/8)+(yvalue1[i]*const_asp_ratio)+yvalue1_param2);

  }

  cairo_stroke(cr);

 

}/* End of do_drawing() */

//

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

{

GtkWidget *window, *swin, *grid, *box;

GtkAdjustment *horizontal, *vertical;

GtkWidget *quitbutton;

/*/

GtkWidget *label_yvalue1_param1;

GtkWidget *spin_int_yvalue1_param1;

GtkAdjustment *integer_yvalue1_param1;

/*/

GtkWidget *label_yvalue1_param2;

GtkWidget *spin_float_yvalue1_param2;

GtkAdjustment *float_yvalue1_param2;

/*/

GtkWidget *label_const_asp_ratio;

GtkWidget *spin_float_const_asp_ratio;

GtkAdjustment *float_const_asp_ratio;

/*/

GtkWidget *window2;

GtkWidget *darea;

GtkWidget *layout2;

GtkWidget *swin2;

GtkWidget *box2;

GtkWidget *scrollbar1;

//

gtk_init (argc, argv);

 

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_window_set_title (GTK_WINDOW (window), Scrolled
Window);

gtk_container_set_border_width (GTK_CONTAINER (window), 10);

gtk_widget_set_size_request (window, 200, 100);

g_signal_connect (G_OBJECT(window), destroy,
G_CALLBACK (gtk_main_quit), NULL);

 

grid = gtk_grid_new ();

/**/

label_yvalue1_param1

Re: Help spinbuttons, Paulo Silva

2015-04-09 Thread Roger Matthews

Hi Paulo, or anybody else interested in helping,
I've read chapter 2 of Foundations of GTK+ Development concerning signals and 
callback functions as suggested (see below) but am still getting this error:
 
(page90v2.exe:2289): Gtk-CRITICAL **: gtk_spin_button_get_value: assertion 
'GTK_IS_SPIN_BUTTON (spin_button)' failed
 
every time one of the up or down arrows in the spinbutton is pressed. Here is 
the code:
 
#include stdio.h
#include gtk/gtk.h
 
/*double number_double;*/
 
 static void get_new_number(GtkWidget *widget, gpointer spin_float)
{
/*number_double = */ gtk_spin_button_get_value(spin_float);
}
 
/*static void print_new_number(GtkWidget *widget, gpointer data)
{
  printf(print_new_number %f\n, number_double);
}*/
 
int main(int argc, char *argv[])
{
GtkWidget *window, *spin_float;
GtkAdjustment *float_pt;
 
/*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);
 
float_pt = GTK_ADJUSTMENT (gtk_adjustment_new (0.5, 0.0, 1.0, 0.1, 0.5, 0.5));
 
spin_float = gtk_spin_button_new (float_pt, 0.1, 1);
 
gtk_container_add (GTK_CONTAINER (window), spin_float);
gtk_widget_show_all (window);
 
  g_signal_connect (spin_float, value-changed, G_CALLBACK (get_new_number), 
NULL);
 /*g_signal_connect (window, value-changed, G_CALLBACK (print_new_number), 
NULL);*/
 
 printf(printf Before gtk_main, double %p\n, /*number_double*/spin_float);
 
gtk_main ();
 
  printf(After gtk_main, double %p\n, /*number_double*/spin_float);
 return 0;
}
//
/*
$ gedit page90v2.c
 
$ gcc `pkg-config --cflags gtk+-3.0` -o page90v2.exe page90v2.c `pkg-config 
--libs gtk+-3.0`
 
$ ./page90.exe
 (page90v2.exe:2289): Gtk-CRITICAL **: gtk_spin_button_get_value: assertion 
'GTK_IS_SPIN_BUTTON (spin_button)' failed
 
(page90v2.exe:2289): Gtk-CRITICAL **: gtk_spin_button_get_value: assertion 
'GTK_IS_SPIN_BUTTON (spin_button)' failed
^C
//
Paulo's reply:
 



Hello Roger.
I think you misunderstand the concept of callback functions. In your example 
there is no appropriated callback function to deal with the changes of spin 
button. And another thing, the 3rd parameters to register a callback function 
must be a pointer.
I suggest to take a look at chapter 2 under Signals and Callbacks section.
José Paulo
/**/
My original email:

2015-03-16 23:24 GMT-03:00 Roger Matthews roger.matth...@hotmail.com:




/* 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);

number_int=gtk_spin_button_get_value_as_int(spin_int);
number_double=gtk_spin_button_get_value(spin_float);

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

g_print (Hello World\n);
g_print(g_print Before gtk_main, integer %d\n, number_int);
printf(printf Before gtk_main, integer %d\n, number_int);
printf(printf Before gtk_main, double %f\n, number_double);

gtk_main ();

 printf(Hello World\n);

 printf(After 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

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);

 

number_int=gtk_spin_button_get_value_as_int(spin_int);

number_double=gtk_spin_button_get_value(spin_float);

 

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

 

  g_print (Hello
World\n);

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

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

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

 

gtk_main ();

 

  printf(Hello
World\n);

  printf(After
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
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list