Re: Many questions

2011-03-05 Thread Alexander Nagel
Am Sat, 05 Mar 2011 01:58:06 -0500
schrieb Jacques Pelletier jpellet...@ieee.org:

 Hi everybody,
good morning,
 
 I have several questions:
 
 1) How do we use the GThreadedSocketService and how do we specify the
 function to run when the connection is established?
 
 I'm using these function in a GUI application (see protocoltool on 
 sourceforge); when the connection is made/closed, the GUI's controls
 are enabled/disabled.
 
 2) Can an application load a linux kernel module? For example, my
 application may need i2c drivers. Does glib/gtk/gnome have anything
 to load kernel modules? How can it be done?
yes they can. The program modprobe does this. I just did a strace of
modprobe when it load a module and discovered init_module
manpage: http://linux.die.net/man/2/init_module
Perhaps you read the source code of modprobe for more details.

 
 3) Now, for unrelated questions, what are the hook functions used
 for? They look interesting, but being an amateur programmer, I have
 no idea of the context where they may be used. Are they useful in an
 user application?
They are a sort of callback functions. A nice example are 
gtk_about_dialog_set_email_hook
gtk_about_dialog_set_url_hook

The hook functions get called called when the user press the email or
url link in the about dialog. Then in the hook function you can open
another program e.g. browser or emailclient.

hth
Alex
 
 4) How do we properly use the g_cancellable functions and when are
 these used? Are they useful in an user application?
 
 Thanks!
 
 JP
 
 Note: please reply to this mailing list for convenience of other
 users. 
 
 
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 

Alexander Nagel
E-mail: alexan...@acwn.de
Homepage: 
http://www.acwn.de/
http://www.standspur-kadaver.de/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Many questions

2011-03-04 Thread Jacques Pelletier
Hi everybody,

I have several questions:

1) How do we use the GThreadedSocketService and how do we specify the function 
to run when the connection is established?

I'm using these function in a GUI application (see protocoltool on 
sourceforge); when the connection is made/closed, the GUI's controls are 
enabled/disabled.

2) Can an application load a linux kernel module? For example, my application 
may need i2c drivers. Does glib/gtk/gnome have anything to load kernel 
modules? How can it be done?

3) Now, for unrelated questions, what are the hook functions used for? They 
look interesting, but being an amateur programmer, I have no idea of the 
context where they may be used. Are they useful in an user application?

4) How do we properly use the g_cancellable functions and when are these used?
Are they useful in an user application?

Thanks!

JP

Note: please reply to this mailing list for convenience of other users. 


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


Many questions when I drew a line

2008-08-14 Thread Lazy Fox
/***
I'm new to GTK+, please help me with following simple questions.
Thanks for your patience.

I wrote a simple programme to draw a line, the whole file is below
these questions:
1. I use gtk_widget_set_size_request() to resize the drawing_area,
   but it's useless. The size of the drawing_area will resize to it's
   parent's size automatically.How to make it's size fixed?
2. The bg_color I set in redraw() is useless too. Each time I run the
application,
   the background color is different. Looks like random color.
3. Where can find introduction of GrStyle? It's too simple in GTK+ Manual Page.
4. How to set the line color and line width?
5. How to use color? The common RGB color is like (255, 255, 255),
   but in GTK+ this can be (0x, 0x, 0x).
   I was confused, how to set a right RGB color? Is there a bunch of build in
   color I can use?
 ***/
#include gtk/gtk.h

gboolean redraw(GtkWidget *widget, GdkEvent *event, gpointer data)
{
GdkGC *gc = gdk_gc_new(widget-window);
GdkColor bg_color;

// Draw background
bg_color.red = 0x;
bg_color.green = 0;
bg_color.blue = 0;
gdk_gc_set_foreground(gc, bg_color);
gdk_draw_rectangle(widget-window, gc, TRUE,
0, 0, widget-allocation.width, 
widget-allocation.height);
gdk_draw_line(widget-window, 
widget-style-fg_gc[GTK_WIDGET_STATE(widget)],
0, 0, 120, 100);

return TRUE;
}

int main(int argc, char *argv[])
{
GtkWidget *w;
GtkWidget *drawing_area;

gtk_init(argc, argv);

w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(w), 300, 200);
g_signal_connect(GTK_OBJECT(w), destroy, G_CALLBACK(gtk_main_quit), 
NULL);

drawing_area = gtk_drawing_area_new();
gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 100, 100);
g_signal_connect(G_OBJECT(drawing_area), expose-event,
G_CALLBACK(redraw), NULL);
gtk_container_add(GTK_CONTAINER(w), drawing_area);

gtk_widget_show_all(w);
gtk_main();
return 0;
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list