Pass by reference...(easy question)

2007-05-03 Thread beginner.c

Hi,

I know how to pass by reference in C normally. But how do I pass by ref a
GTK Widget to a function?
-- 
View this message in context: 
http://www.nabble.com/Pass-by-reference...%28easy-question%29-tf3688934.html#a10313107
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


GtkImage problem

2007-05-04 Thread beginner.c

I have the following code, which comiles and displays the image yet I get the
following errors



Compile error
passing argument 1 of 'gtk_image_set_from_file' from incompatible pointer
type

Runtime errors
(process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:12275): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:12275): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed

(testreference:12275): Gtk-CRITICAL **: gtk_widget_show: assertion
`GTK_IS_WIDGET (widget)' failed




#include 
#include 
#include 
#include 
#include 

#include 

#include 
#include 



/*
 * Standard gettext macros.
 */
#ifdef ENABLE_NLS
#  include 
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#define N_(String) gettext_noop (String)
#  else
#define N_(String) (String)
#  endif
#else
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif



#include "callbacks.h"

/* For testing propose use the local (not installed) glade file */
/* #define GLADE_FILE
PACKAGE_DATA_DIR"/testreference/glade/testreference.glade" */
#define GLADE_FILE "testreference.glade"


void create_window (GtkWidget *window, GtkWidget *image)
{

GladeXML *gxml;

gxml = glade_xml_new (GLADE_FILE, NULL, NULL);


glade_xml_signal_autoconnect (gxml);
window = glade_xml_get_widget (gxml, "window");
image = glade_xml_get_widget (gxml, "image1");
}

void funcImage (GtkWidget *image)
{
gtk_image_set_from_file (image, "/home/s/Pictures/space-05.jpg");
}

int
main (int argc, char *argv[])
{
GtkWidget *window = NULL;
GtkWidget *image = gtk_image_new();
 

#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif


gtk_set_locale ();
gtk_init (&argc, &argv);

create_window (window,image);
gtk_widget_show (window);
funcImage(image);
gtk_main ();

return 0;
}
-- 
View this message in context: 
http://www.nabble.com/GtkImage-problem-tf3694858.html#a10332372
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: GtkImage problem

2007-05-05 Thread beginner.c

As suggested I've done: gtk_image_set_from_file (GTK_IMAGE(image),
"/home/s/Pictures/space-05.jpg");

However, the image is no longer displayed and I get these errors




(process:7344): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:7344): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:7344): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:7344): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:7344): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:7344): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:7344): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:7344): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed

(testreference:7344): Gtk-CRITICAL **: gtk_widget_show: assertion
`GTK_IS_WIDGET (widget)' failed

(testreference:7344): GLib-GObject-CRITICAL **: g_type_instance_get_private:
assertion `instance != NULL && instance->g_class != NULL' failed

(testreference:7344): Gtk-CRITICAL **: gtk_image_set_from_file: assertion
`GTK_IS_IMAGE (image)' failed 





beginner.c wrote:
> 
> I have the following code, which comiles and displays the image yet I get
> the following errors
> 
> 
> 
> Compile error
> passing argument 1 of 'gtk_image_set_from_file' from incompatible pointer
> type
> 
> Runtime errors
> (process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:12275): GLib-GObject-CRITICAL **: g_type_add_interface_static:
> assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
> 
> (process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:12275): GLib-GObject-CRITICAL **: gtype.c:2242: initialization
> assertion failed, use IA__g_type_init() prior to this function
> 
> (process:12275): GLib-GObject-CRITICAL **: g_object_new: assertion
> `G_TYPE_IS_OBJECT (object_type)' failed
> 
> (testreference:12275): Gtk-CRITICAL **: gtk_widget_show: assertion
> `GTK_IS_WIDGET (widget)' failed
> 
> 
> 
> 
> #include 
> #include 
> #include 
> #include 
> #include 
> 
> #include 
> 
> #include 
> #include 
> 
> 
> 
> /*
>  * Standard gettext macros.
>  */
> #ifdef ENABLE_NLS
> #  include 
> #  undef _
> #  define _(String) dgettext (PACKAGE, String)
> #  ifdef gettext_noop
> #define N_(String) gettext_noop (String)
> #  else
> #define N_(String) (String)
> #  endif
> #else
> #  define textdomain(String) (String)
> #  define gettext(String) (String)
> #  define dgettext(Domain,Message) (Message)
> #  define dcgettext(Domain,Message,Type) (Message)
> #  define bindtextdomain(Domain,Directory) (Domain)
> #  define _(String) (String)
> #  define N_(String) (String)
> #endif
> 
> 
> 
> #include "callbacks.h"
> 
> /* For testing propose use the local (not installed) glade file */
> /* #define GLADE_FILE
> PACKAGE_DATA_DIR"/testreference/glade/testreference.glade" */
> #define GLADE_FILE "testreference.glade"
>   
> 
> void create_window (GtkWidget *window, GtkWidget *image)
> {
>   
>   GladeXML *gxml;
>   
>   gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
>   
> 
>   glade_xml_signal_autoconnect (gxml);
>   window = glade_xml_get_widget (gxml, "window");
>   image = glade_xml_get_widget (gxml, "image1");
> }
> 
> void funcImage (GtkWidget *image)
> {
>   gtk_image_set_from_file (image, "/home/s/Pictures/space-05.jpg");
> }
> 
> int
> main (int argc, char *argv[])
> {
>   GtkWidget *window = NULL;
>   GtkWidget *image 

Re: GtkImage problem

2007-05-06 Thread beginner.c

Thanks for the response but as you can see from my original post I am in fact
calling gtk_init() prior to any of these functions.



David Nečas (Yeti)-2 wrote:
> 
> On Sat, May 05, 2007 at 04:27:14PM -0700, beginner.c wrote:
>> 
>> As suggested I've done: gtk_image_set_from_file (GTK_IMAGE(image),
>> "/home/s/Pictures/space-05.jpg");
> 
> Please see my answer
> 
>   http://mail.gnome.org/archives/gtk-list/2007-May/msg00039.html
> 
> unfortunately sent to the wrong mailing list thanks to
> the bloody unset Reply-To headers.
> 
> Yeti
> 
> --
> http://gwyddion.net/
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/GtkImage-problem-tf3694858.html#a10344471
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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

Re: GtkImage problem

2007-05-06 Thread beginner.c

You are right. Thanks for that. Everything executes without error...except,
no image is displayed. 


void create_window (GtkWidget *window, GtkWidget *image)
{

GladeXML *gxml;

gxml = glade_xml_new (GLADE_FILE, NULL, NULL);

/* This is important */
glade_xml_signal_autoconnect (gxml);
window = glade_xml_get_widget (gxml, "window");
image = glade_xml_get_widget (gxml, "image1");
}

void funcImage (GtkWidget *image)
{
image = gtk_image_new();
gtk_image_clear(GTK_IMAGE(image));
gtk_image_set_from_file (GTK_IMAGE(image),
"/home/s/Pictures/space-05.jpg");
gtk_widget_show(image);
}

int
main (int argc, char *argv[])
{
GtkWidget *window = NULL;
GtkWidget *image = NULL;
 

#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif


gtk_set_locale ();
gtk_init (&argc, &argv);

create_window (window,image);

funcImage(image);
//gtk_widget_show_all (window);
gtk_main ();

return 0;
}











David Nečas (Yeti)-2 wrote:
> 
> On Sun, May 06, 2007 at 04:06:11AM -0700, beginner.c wrote:
>> 
>> I am in fact
>> calling gtk_init() prior to any of these functions.
> 
> No, you don't, the call to gtk_image_new() to initialize
> image
> 
>   GtkWidget *image = gtk_image_new();
> 
> is performed before any code in main().
> 
> Yeti
> 
> --
> http://gwyddion.net/
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/GtkImage-problem-tf3694858.html#a10350080
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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

Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

2007-05-14 Thread beginner.c

Hi,

I'm doing the following and get the above error (of course with the funny
characters). What am I doing wrong?

int a = 0;
char *x;
char Text[500];

sprintf (Text,"Blah %i",a);
x = Text;

gtk_label_set_text (GTK_LABEL(label1),x);
-- 
View this message in context: 
http://www.nabble.com/Pango-WARNING-**%3A-Invalid-UTF-8-string-passed-to-pango_layout_set_text%28%29-tf3751858.html#a10602235
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: Alternative GTK widgets

2007-05-14 Thread beginner.c

I've noticed libegg gets used a lot. Does it have a web page? It seems the
most obvious thing for widgets but are there some screen shots somewhere
showing off the widgets?



jcupitt wrote:
> 
> On 5/12/07, Shoq <[EMAIL PROTECTED]> wrote:
>> Pardon my noobness, but I am new to GTK.  I had assumed there would be a
>> wealth of open source widgets that descend from the toolkit. I am
>> starting
>> to think this was a very poor assumption on my part.  I've not be able to
>> find anything but a few aborted attempts at variations by other parties.
>> Am
>> I missing something? Is there are directory of other efforts to add value
>> to
>> the base classes?
> 
> There are a few I know of:
> 
>libegg
> 
> This is part of gnome, but you can use it separately (I think). It's a
> set of gtk widgets that people have written that seem useful but which
> haven't settled enough to go into the main gtk distribution yet. I
> think the name is supposed to suggest incubation: if a libegg widget
> becomes popular and useful enough, it will eventually get into gtk.
> For example, the recent files stuff started out in libegg, I think.
> 
>   libsexy
> 
> A library of extra widgets, seems nice, widely used.
> 
>   gtk-extra
> 
> Sheet, plot and other widgets. This is now becoming a little
> old-fashioned (in my opinion), most of their widgets now have
> equivalents in the main gtk tree.
> 
> In addition, most gtk applications include a set of their own widgets
> which you can usually just cut out and keep (license permitting).
> 
> John
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Alternative-GTK-widgets-tf3730474.html#a10602860
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: Alternative GTK widgets

2007-05-15 Thread beginner.c

Perhaps we should all put in some links - this would be beneficial for
everybody I think (not all are still active/useful):

http://dev.investorsidekick.com/begtkextra/
http://libbit.sf.net/
http://www.curlyankles.com/
http://kornelix.squarespace.com/utilities/
http://sourceforge.net/projects/enlightenment/ - gevas
http://gtkadi.sourceforge.net/
http://www.eudoxos.de/gtk/gtkdatabox/index.html
http://sourceforge.net/projects/gtkcombogrid
http://gtkdateentry.sourceforge.net/
http://gtkmaskedentry.sourceforge.net/
http://helm.cs.unibo.it/mml-widget/
http://view.sourceforge.net/


-- 
View this message in context: 
http://www.nabble.com/Alternative-GTK-widgets-tf3730474.html#a10632692
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


beginner question about extern

2007-06-17 Thread beginner.c

Hi,

I'm having a problem with multiple files and using extern
In main.c I'm declaring

GtkWidget *a;
(...do a bunch of stuff successfully to a)

In another file:
extern GtkWidget *a;
(..do a bunch of stuff with error)

gtk_toggle_button_set_active: assertion failed ...blah blah failed.
I'm am typecasting in my second file as I am in the first file, it works in
the first file
-- 
View this message in context: 
http://www.nabble.com/beginner-question-about-extern-tf3935358.html#a11161340
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


GTK Theme engines

2007-07-01 Thread beginner.c

Is is possible to write a theming engine that can detect the widgets that are
being used in an application and adjust the theme that would be applied to
it.

eg if the window is not decorated do this
if the window has a menubar but no icon bar do this

Any ideas?
-- 
View this message in context: 
http://www.nabble.com/GTK-Theme-engines-tf4010268.html#a11388725
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Dealing with workspaces

2007-07-02 Thread beginner.c

What is the best method of dealing with workspaces? I need my app to start up
on a specific workspace. Im aware of gdk_window_stick which should place the
window on ALL workspaces - just not quite what I need.

Any information greatly appreciated.
-- 
View this message in context: 
http://www.nabble.com/Dealing-with-workspaces-tf4016299.html#a11406331
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


gdk_window_set_keep_below

2007-07-03 Thread beginner.c

How can I ensure one window is above another when both are using

gdk_window_set_keep_below

Is it first in best dressed?
-- 
View this message in context: 
http://www.nabble.com/gdk_window_set_keep_below-tf4021764.html#a11423048
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Passing Struct to g_signal_connect

2008-10-19 Thread beginner.c

I need to pass a struct using g_signal_connect, but the issue I'm having is
that I can't alter the elements of the struct within the called function
e.g.

void on_button2_clicked (struct allStructs *by_ptr)

{
gtk_label_set_text ((GtkLabel*)by_ptr->widgets.label, "whatever");
}

main
{
blah blah
struct allStructs baseStruct;

g_signal_connect (G_OBJECT(baseStruct.widgets.nextButton), "clicked",
G_CALLBACK (on_button2_clicked), &baseStruct);
}

Any idea's? If I pass this struct to any other function I have no problem
performing functions like in the callback. For some reason, I can't in the
callback.

-- 
View this message in context: 
http://www.nabble.com/Passing-Struct-to-g_signal_connect-tp20055372p20055372.html
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: Passing Struct to g_signal_connect

2008-10-19 Thread beginner.c

Thank you. However, now I'm getting a segfault when trying to access any of
the elements of the passed struct. Does it matter that the button to which
the signal is attached is actually in the struct I'm passing to the
callback? This is what GDB gives me

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb72fa940 (LWP 14464)]
0x08049f16 in on_button2_clicked (button=0x807f418, by_ptr=0x0)
at callbacks.h:56
56  printf("Qs: %i\n", by_ptr->globals.Qs);

Thanks for your help


Till Harbaum / Lists wrote:
> 
> Hi,
> 
> you have to make sure that the parameters of your callback function
> exactly match what's been described for this particular event. In your
> case your have to check the "clicked" event for a GtkButton which gives
> us:
> 
> void user_function(GtkButton *button, gpointer   user_data)  
> 
> So this is how your callback function should look like:
> void on_button2_clicked(GtkButton *button, struct allStructs *by_ptr)
> 
> Your struct should be the _second_ parameter and not the first (any only)
> one your made it. What you did is: You got a pointer to the GtkButton
> structure 
> of your button and used _that_ as a pointer to your own struct. You
> are likely messing up the Button structure ...
> 
> This is one ugly thing with the C bindings and the fact that everything
> is just casted by this G_CALLBACK() macro. That way the compiler isn't
> able to check these things and errors like yours happen. And these can
> be very nasty bugs since they cause people to write to memory they
> are not supposed to write to. A classic door for hackers ...
> 
> Till
> 
> Am Sonntag 19 Oktober 2008 schrieb beginner.c:
>> 
>> I need to pass a struct using g_signal_connect, but the issue I'm having
>> is
>> that I can't alter the elements of the struct within the called function
>> e.g.
>> 
>> void on_button2_clicked (struct allStructs *by_ptr)
>> 
>> {
>>  gtk_label_set_text ((GtkLabel*)by_ptr->widgets.label, "whatever");
>> }
>> 
>> main
>> {
>> blah blah
>> struct allStructs baseStruct;
>> 
>> g_signal_connect (G_OBJECT(baseStruct.widgets.nextButton), "clicked",
>> G_CALLBACK (on_button2_clicked), &baseStruct);
>> }
>> 
>> Any idea's? If I pass this struct to any other function I have no problem
>> performing functions like in the callback. For some reason, I can't in
>> the
>> callback.
>> 
> 
> 
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Passing-Struct-to-g_signal_connect-tp20055372p20062941.html
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


g_signal_connect, structs and my sanity

2008-11-03 Thread beginner.c

I'm getting a segfault on the gtkscale callback (when accessing printf("Qs:
%i\n", base->sTestOne.a);). Can somebody please tell me what I'm doing
wrong. Also, what would be the cleanest way to prototype my struct (struct
allStructs) outside of main?

Thanks






#include 
#include 
#include 
#include 
#include 

#include 

#include 

#include "struct.h"
#include "cb.h"

/*
 * Standard gettext macros.
 */
#ifdef ENABLE_NLS
#  include 
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#define N_(String) gettext_noop (String)
#  else
#define N_(String) (String)
#  endif
#else
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif



#include "callbacks.h"

/* For testing propose use the local (not installed) glade file */
/* #define GLADE_FILE
PACKAGE_DATA_DIR"/struct_callback/glade/struct_callback.glade" */
#define GLADE_FILE "struct_callback.glade"


void funcScale (GtkWidget *widget, struct allStructs *base)

{
gdouble value;
value = gtk_range_get_value (GTK_RANGE (widget));
printf("Qs: %i\n", value);
printf("Qs: %i\n", base->sTestOne.a);
}

void button_callback (GtkButton *button, struct allStructs *base)

{
//base->sTestOne.a = 99;
printf("Qs: %i\n", base->sTestOne.a);
}

void button_callback2 (GtkButton *button, struct allStructs *base)

{
printf("Qs: %i\n", base->sTestOne.a);
}

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

struct sOne
{
int a;
};

struct sTwo
{
int b;
};

struct widgets
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *hscale;
GladeXML *gxml;
};

struct allStructs
{
struct widgets sWidgets;
struct sOne sTestOne;
struct sTwo sTestTwo;
};



struct allStructs base;

base.sTestOne.a = 967;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif


gtk_set_locale ();
gtk_init (&argc, &argv);

base.sWidgets.gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
glade_xml_signal_autoconnect (base.sWidgets.gxml);
base.sWidgets.window = glade_xml_get_widget (base.sWidgets.gxml, 
"window");
base.sWidgets.button = glade_xml_get_widget (base.sWidgets.gxml,
"button1");
base.sWidgets.hscale = glade_xml_get_widget (base.sWidgets.gxml,
"hscale1");

g_signal_connect (base.sWidgets.button, "clicked", G_CALLBACK
(button_callback), &base);
g_signal_connect (base.sWidgets.button, "clicked", G_CALLBACK
(button_callback2), &base);
g_signal_connect (base.sWidgets.hscale, "change-value", G_CALLBACK
(funcScale), &base);
gtk_widget_show (base.sWidgets.window);

gtk_main ();
return 0;
}

-- 
View this message in context: 
http://www.nabble.com/g_signal_connect%2C-structs-and-my-sanity-tp20310462p20310462.html
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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


Re: g_signal_connect, structs and my sanity

2008-11-03 Thread beginner.c

Ahgreat thanks for pointing that out. Simple difference between
"change-value" and "value-changed".

Any feedback on prototyping my struct?

Thanks


David Munger wrote:
> 
> I guess you just have the wrong callback function signature for the
> "change-value" signal.
> 
> See http://library.gnome.org/devel/gtk/2.14/GtkRange.html
> 
> So:
> 
> void funcScale (GtkWidget *widget, struct allStructs *base)
> 
> should probably be:
> 
> void funcScale (GtkRange *range, GtkScrollType scroll, gdouble value,
> struct
> allStructs *base)
> 
> instead.
> 
> I hope that helps,
> 
> David
> 
> 
> void funcScale (GtkWidget *widget, struct allStructs *base)
>>
>> {
>>gdouble value;
>>value = gtk_range_get_value (GTK_RANGE (widget));
>>printf("Qs: %i\n", value);
>>printf("Qs: %i\n", base->sTestOne.a);
>> }
> 
> 
> [...]
> 
> 
>>g_signal_connect (base.sWidgets.hscale, "change-value", G_CALLBACK
>> (funcScale), &base);
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/g_signal_connect%2C-structs-and-my-sanity-tp20310462p20315985.html
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.

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