Re: Addind 2 Widget in 1 Container....
- From: Thibault Duponchelle <t duponchelle gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Addind 2 Widget in 1 Container....
- Date: Wed, 16 Dec 2009 01:03:32 +0100
Hi !
GtkWindow is a container that can contain exactly one other widget.
Other containers, e.g. Gtk[HV]Box, GtkTable, GtkLayout, ..., can contain
more widgets organized in different ways. So put on of them to the
window and pack the widgets to it.
[...]
Yeti
Thank you Yeti and Lars Wirzenius for your help.
I studied GtkLayout with the Gnome tutoriel and I found the solution.
I post it if it could help someone.
GtkWidget* draw_screen(GLOBAL_SKIN_INFOS *gsi) {
SKIN_INFOS *si;
si=malloc(sizeof(SKIN_INFOS));
gsi->si=(SKIN_INFOS*)si;
skin_load(gsi->si,gsi->SkinFileName);
/* Create the window */
GtkWidget *pImage;
GtkWidget *pWindow;
GtkWidget *pLayout;
GtkWidget *gtk_window_new(GtkWindowType type);
pWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(pWindow),"tilem");// define title of
the window
gtk_window_set_position(GTK_WINDOW(pWindow),GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(pWindow),gsi->si->width,gsi->si->height);
pImage=gtk_image_new_from_pixbuf(gsi->si->image);
gsi->pImage=pImage;
GtkWidget *pAf;
int screenwidth=gsi->si->lcd_pos.right-gsi->si->lcd_pos.left;
int screenheight=gsi->si->lcd_pos.bottom-gsi->si->lcd_pos.top;
pAf = gtk_aspect_frame_new(NULL, 0.5, 0.5, 1.0, TRUE);
gtk_frame_set_shadow_type(GTK_FRAME(pAf),
GTK_SHADOW_NONE);
{
gsi->emu->lcdwin = gtk_drawing_area_new();
gtk_widget_set_name(gsi->emu->lcdwin,
"tilem-lcd");
gtk_widget_set_size_request(gsi->emu->lcdwin,
screenwidth,
screenheight);
gtk_container_add(GTK_CONTAINER(pAf),
gsi->emu->lcdwin);
gtk_widget_show(gsi->emu->lcdwin);
}
/* ###SOLUTION### */
pLayout=gtk_layout_new(NULL,NULL);
gtk_widget_show(pAf);
/* Into GtkLayout : I put the GtkImage (x=0, y=0) and the drawarea (on
the GtkImage) :D */
gtk_layout_put(GTK_LAYOUT(pLayout),pImage,0,0);
gtk_layout_put(GTK_LAYOUT(pLayout),pAf,gsi->si->lcd_pos.left,gsi->si->lcd_pos.top);
/* Now I add the GtkLayout to the pWindow */
gtk_container_add(GTK_CONTAINER(pWindow),pLayout);
/* ###END### */
g_signal_connect(G_OBJECT(pWindow),"destroy",G_CALLBACK(OnDestroy),NULL);
/* Connection signal keyboard key press */
gtk_widget_add_events(pWindow, GDK_KEY_RELEASE_MASK);
gtk_signal_connect(GTK_OBJECT(pWindow), "key_press_event",
G_CALLBACK(keyboard_event), NULL);
gtk_widget_add_events(pWindow, GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
gtk_signal_connect(GTK_OBJECT(pWindow), "button_press_event",
G_CALLBACK(mouse_event),(gpointer)gsi);
gtk_widget_show_all(pWindow);
return pWindow;
}
One more times thank you.
Best regards.
Thibault Duponchelle
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]