need help with some queries
- From: Syed Irfan <crazycrusoe yahoo com>
- To: gtk-list gnome org
- Subject: need help with some queries
- Date: Thu, 14 Feb 2002 14:02:23 -0800 (PST)
hi
i need some help understanding some things, i am
through to chapter 6 in the gtk tutorial :-)
/* my program 5, button.button */
#include <gtk/gtk.h>
//#define INFO
/usr/share/doc/gtk+-devel-1.2.10/examples/buttons/info.xpm
why cant i define the above and use INFO in the
program ? instead of giving the whole path to the file
?
gint my_delete_cb(GtkWidget *widget, GdkEvent *event,
gpointer data)
{
g_print("\nyou pressed the %s \n", (char*) data);
gtk_main_quit();
return (TRUE);
}
gint my_clicked_button_cb(GtkWidget *widget, gpointer
data)
{
g_print("\n pressed the %s\n", (char *) data);
return (FALSE);
}
//gint my_leave_button_cb(GtkWidget *widget, GdkEvent
*event, gpointer data)
//gives output " uhooo this ones good; Ã) "
//i mean the strange character "Ã" instead of "pointer
moved away from button" ?
//bugger, but removing GdkEvent *event from the
function declaration
//does da trick, dunno why ? any explanation here ?
gint my_leave_button_cb(GtkWidget *widget, gpointer
data)
{
g_print("\nuhooo this ones good; %s\n",(char*) data);
return (TRUE);
}
GtkWidget *my_xpm_label_box(GtkWidget *parent, gchar
*xpm_filename, gchar *label_text)
{
GtkWidget *box_1;
GtkWidget *label;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
//create box for xpm and label
box_1=gtk_hbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(box_1),
2);
//setting style of the button
style = gtk_widget_get_style(parent);
//the display of the pixmap
pixmap = gdk_pixmap_create_from_xpm(parent->window,
&mask, &style->bg[GTK_STATE_NORMAL], xpm_filename);
pixmapwid = gtk_pixmap_new(pixmap, mask);
//create label for the button
label = gtk_label_new(label_text);
//packing the pixmap into box
gtk_box_pack_start(GTK_BOX(box_1), pixmapwid, FALSE,
FALSE, 3);
//packing the label into the box
gtk_box_pack_start(GTK_BOX(box_1), label, FALSE,
FALSE, 3);
gtk_widget_show(pixmapwid);
gtk_widget_show(label);
return (box_1);
}
int main(int argc, char *argv[])
{
//gtk widgets first
GtkWidget *window;
GtkWidget *button;
GtkWidget *box_1;
//dont forget to initialize
gtk_init(&argc, &argv);
//create the window
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//connect the x with close
gtk_signal_connect(GTK_OBJECT(window),
"delete_event", GTK_SIGNAL_FUNC(my_delete_cb),
(gpointer) "x button on the top right corner");
gtk_container_set_border_width(GTK_CONTAINER(window),
20);
//what the heck is that realize thingy ? below
//whats the diff between gtk_widget_show() and
//gtk_widget_realize() ??
gtk_widget_realize(window);
// gtk_widget_show(window);
// now creating the button
button = gtk_button_new();
//connecting the button to an event, basically the
button callback
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(my_clicked_button_cb), (gpointer)
"cool button");
gtk_signal_connect(GTK_OBJECT(button), "leave",
GTK_SIGNAL_FUNC(my_leave_button_cb), (gpointer)
"pointer moved away from button");
//the strange thing about, when the mouse
pointer clicks the //button, this is the output i get
uhooo this ones good; pointer moved away from button
pressed the cool button
but shouldnt i get only "pressed the cool button"
why am i getting the uhooo this ones good as well ?
box_1 = my_xpm_label_box(window,
"/usr/lib/kde1-compat/share/icons/large/info.xpm",
"cool button");
gtk_widget_show(box_1);
gtk_container_add(GTK_CONTAINER(button), box_1);
gtk_widget_show(button);
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show(window);
gtk_main();
return(0);
}
thankyou verymuch guys
=====
=====================================
CrazyCrusoe
Hackerd00d
http://members.linuxstart.com/openweb
=====================================
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]