Send gtk-list mailing list submissions to
gtk-list gnome org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.gnome.org/mailman/listinfo/gtk-list
or, via email, send a message with subject or body 'help' to
gtk-list-request gnome org
You can reach the person managing the list at
gtk-list-owner gnome org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of gtk-list digest..."
Today's Topics:
1. A problem about programming with Gtk+ ( ??? )
2. A problem about programming with Gtk+ (gordon)
3. Application development using GTK and GLADE3 (Harinandan S)
----------------------------------------------------------------------
Message: 1
Date: Sun, 14 Dec 2008 16:55:43 +0800
From: " ??? " <gordonszkuo gmail com>
Subject: A problem about programming with Gtk+
To: gtk-list gnome org
Message-ID:
<447e7b560812140055v5b754a87g1baa5d35f0c1e95e mail gmail com>
Content-Type: text/plain; charset="iso-8859-1"
Dear Gnome.
I got a prablem about programming in Gtk+. The following program
creat a 'Button'.But
there is a problem with the 'static void callback( GtkWidget *widget,
gpointer data )'.
In this part of the program ,i want to change the cursor before the program
executing the for-loop.
Here is the problem.In this program ,it always execute the for-loop first
and then change the
cursor.I do not understand what happen. Could you tell what's wrong with
my program and how to
fix it.Thanks.
Gordon
#include <unistd.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <pthread.h>
/* Create a new hbox with an image and a label packed into it
* and return the box. */
static GtkWidget *xpm_label_box( gchar *xpm_filename,
gchar *label_text )
{
GtkWidget *box;
GtkWidget *label;
GtkWidget *image;
/* Create box for image and label */
box = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 2);
/* Now on to the image stuff */
image = gtk_image_new_from_file (xpm_filename);
/* Create a label for the button */
label = gtk_label_new (label_text);
/* Pack the image and label into the box */
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);
gtk_widget_show (image);
gtk_widget_show (label);
return box;
}
static int cursor_change(gpointer data_pass)
{
GtkWidget *window = (GtkWidget *) data_pass;
gdk_threads_enter();
GThread *gthread;
g_thread_set_priority(gthread, G_THREAD_PRIORITY_URGENT);
g_thread_self();
{
//Set A Cursor
GdkCursor *new_cursor;
new_cursor=gdk_cursor_new(GDK_WATCH);
g_print ("I make it!");
gdk_window_set_cursor(window->window, new_cursor);
gdk_cursor_destroy(new_cursor);
}
gdk_threads_leave();
return 0;
}
/* Our usual callback function */
static void callback( GtkWidget *widget, gpointer data )
{
gint ptimer;
ptimer=g_timeout_add(1, (GtkFunction)cursor_change, data);
//ptimer=gdk_threads_add_timeout(100, (GtkFunction)cursor_change, data);
sleep(1);
int i,j;
for(i=0;i<100;i++)
{
g_print ("Hello again - %s was pressed %d\n", (char *) data,i);
}
/*
GdkCursor *renew_cursor;
renew_cursor=gdk_cursor_new(GDK_PENCIL);
gdk_window_set_cursor(window->window, renew_cursor);
gdk_cursor_destroy(renew_cursor);* */
}
int main( int argc, char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *button;
GtkWidget *box;
gtk_init (&argc, &argv);
/* // set foreground color is different from color key
{
GdkColor color;
GdkColormap *map;
memset(&color, 0, sizeof(color));
color.blue = 10000;
map = gdk_colormap_get_system();
gdk_color_alloc(map, &color);
gdk_gc_set_foreground(window->style->black_gc, &color);
}*/
gtk_rc_parse("/vpon/gui.rc");
/* Create a new window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!");
/* It's a good idea to do this for all windows. */
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
/* Sets the border width of the window. */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
/* Create a new button */
button = gtk_button_new ();
/* Connect the "clicked" signal of the button to our callback */
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (callback),
(gpointer) window);
/* This calls our box creating function */
box = xpm_label_box ("info.xpm", "cool button");
/* Pack and show all our widgets */
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (button), box);
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (window);
/* Rest in gtk_main and wait for the fun to begin! */
gtk_main ();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </archives/gtk-list/attachments/20081214/0ea09ed5/attachment.html>
------------------------------
Message: 2
Date: Mon, 15 Dec 2008 12:07:38 +0800
From: "gordon" <gordon formosa21 com>
Subject: A problem about programming with Gtk+
To: <gtk-list gnome org>
Message-ID: <5B2D10E518B94F1A86D865EC0F9E328D formosa700c7a8>
Content-Type: text/plain; charset="big5"
Dear Gnome.
I got a prablem about programming in Gtk+. The following program creat a 'Button'.But
there is a problem with the 'static void callback( GtkWidget *widget, gpointer data )'.
In this part of the program ,i want to change the cursor before the program executing the for-loop.
Here is the problem.In this program ,it always execute the for-loop first and then change the
cursor.I do not understand what happen. Could you tell what's wrong with my program and how to
fix it.Thanks.
Gordon
#include <unistd.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <pthread.h>
/* Create a new hbox with an image and a label packed into it
* and return the box. */
static GtkWidget *xpm_label_box( gchar *xpm_filename,
gchar *label_text )
{
GtkWidget *box;
GtkWidget *label;
GtkWidget *image;
/* Create box for image and label */
box = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 2);
/* Now on to the image stuff */
image = gtk_image_new_from_file (xpm_filename);
/* Create a label for the button */
label = gtk_label_new (label_text);
/* Pack the image and label into the box */
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);
gtk_widget_show (image);
gtk_widget_show (label);
return box;
}
static int cursor_change(gpointer data_pass)
{
GtkWidget *window = (GtkWidget *) data_pass;
gdk_threads_enter();
GThread *gthread;
g_thread_set_priority(gthread, G_THREAD_PRIORITY_URGENT);
g_thread_self();
{
//Set A Cursor
GdkCursor *new_cursor;
new_cursor=gdk_cursor_new(GDK_WATCH);
g_print ("I make it!");
gdk_window_set_cursor(window->window, new_cursor);
gdk_cursor_destroy(new_cursor);
}
gdk_threads_leave();
return 0;
}
/* Our usual callback function */
static void callback( GtkWidget *widget, gpointer data )
{
gint ptimer;
ptimer=g_timeout_add(1, (GtkFunction)cursor_change, data);
//ptimer=gdk_threads_add_timeout(100, (GtkFunction)cursor_change, data);
sleep(1);
int i,j;
for(i=0;i<100;i++)
{
g_print ("Hello again - %s was pressed %d\n", (char *) data,i);
}
/*
GdkCursor *renew_cursor;
renew_cursor=gdk_cursor_new(GDK_PENCIL);
gdk_window_set_cursor(window->window, renew_cursor);
gdk_cursor_destroy(renew_cursor);* */
}
int main( int argc, char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
GtkWidget *button;
GtkWidget *box;
gtk_init (&argc, &argv);
/* // set foreground color is different from color key
{
GdkColor color;
GdkColormap *map;
memset(&color, 0, sizeof(color));
color.blue = 10000;
map = gdk_colormap_get_system();
gdk_color_alloc(map, &color);
gdk_gc_set_foreground(window->style->black_gc, &color);
}*/
gtk_rc_parse("/vpon/gui.rc");
/* Create a new window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!");
/* It's a good idea to do this for all windows. */
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
/* Sets the border width of the window. */
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
/* Create a new button */
button = gtk_button_new ();
/* Connect the "clicked" signal of the button to our callback */
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (callback), (gpointer) window);
/* This calls our box creating function */
box = xpm_label_box ("info.xpm", "cool button");
/* Pack and show all our widgets */
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (button), box);
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (window);
/* Rest in gtk_main and wait for the fun to begin! */
gtk_main ();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </archives/gtk-list/attachments/20081215/e8979c2f/attachment.html>
------------------------------
Message: 3
Date: Tue, 16 Dec 2008 19:20:21 +0530
From: "Harinandan S" <harinandans gmail com>
Subject: Application development using GTK and GLADE3
To: gtk-list <gtk-list gnome org>
Message-ID:
<5a459d5e0812160550h6f8e14f7v54cfe9e0dcad1b76 mail gmail com>
Content-Type: text/plain; charset="iso-8859-1"
Hi All,
I am using Gtk+ 2.12.2 and Glade 3. I create windows using glade3 and use
GtkBuilder to create widgets. My application has many windows and each
window has a builder object associated with this. At some point of time I
have many windows open. I need to change some widgets in one window
depending on changes done to other widgets in another window. For example in
one window I show a label, the current file selected and if user changes the
file using another window which has a file chooser dialog I'll update the
label.
This requires pointer to the label. There are multiple dependencies like
this. Is there any way that I not maintain global variables and get the
pointer to other widgets? I have instances where there are more than two
windows open and multiple widget from other windows need to be accessed.
Also I cannot have all of them in one builder since I cannot afford to spend
memory to create all windows at a time.
How to manage this and access different pointers in different windows?
Regards,
Harinandan S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </archives/gtk-list/attachments/20081216/f08d878e/attachment.html>
------------------------------
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
End of gtk-list Digest, Vol 56, Issue 22
****************************************