Re: [gtk-list] question about resizing & combos
- From: Gustavo Joćo Alves Marques Carneiro <ee96090 fe up pt>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] question about resizing & combos
- Date: Tue, 26 Oct 1999 22:27:32 +0100 (WET)
On Tue, 26 Oct 1999, Giaslas Georgios wrote:
> Hi all,
> i have the following two problems
> i've sent this mail again but none replied to me =:-(
>
> 1) if i have a menubar and a clist (or anything else)
> inside a container and i resize the window (make it bigger)
> both of the above widgets are resized too, but i want
> only the clist to be resized.
> how can i do that?
> only the clist to be resized.
> how can i do that?
Assuming you're using a vertical box to contain these widgets, you
should pack the the menu bar with
gtk_box_pack_start(GTK_BOX(vbox),menubar,FALSE,FALSE,padding), that is
'expand' and 'fill' arguments set to FALSE.
When packing the clist, do
gtk_box_pack_start(GTK_BOX(vbox),clist,TRUE,TRUE,padding);
>
> 2) i have a combo box and when the user selects
> a string i want all the strings before this to be removed.
> i've done it and when i change the comboentry using
> arrow keys it's ok. but when it's changed using the
> mouse i get a segmentation fault.
> Is it a bug or it's my fault?
> please try the following little program to see what
> i mean exactly.
>
> (I use gtk+ version 1.2.6)
>
> Please reply this time...
>
> Thank you all
>
> -----------------------------
> #include <gtk/gtk.h>
>
> GList *glist=NULL;
> gint active=0;
> GtkWidget *combo;
> GtkWidget *window;
>
> static gint delete_callback(GtkWidget *widget, gpointer data)
> {
> gtk_main_quit();
> return(FALSE);
> }
>
> void callback(GtkEntry *comboentry, gpointer data)
> {
> GList *l;
> gint cnt=0;
> if (active)
> {
> l=g_list_first(glist);
> while (g_strcasecmp(l->data, gtk_entry_get_text(comboentry)))
> {
> g_print("data %s deleted\n", (gchar *) l->data);
> glist=g_list_remove(glist, l->data);
> g_free(l->data);
g_free(l->data) should come before g_list_remove because it is
not guaranteed that the location pointed by 'l' is valid after you remove
it from the list.
> cnt++;
> l=g_list_first(glist);
> }
Also, you should take care that this previous 'while' doesn't ever
result in an endless loop.
> gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
> }
> }
>
> int main (int argc, char *argv[])
> {
> gtk_init(&argc, &argv);
> window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
> gtk_signal_connect(GTK_OBJECT(window), "delete_event",
> GTK_SIGNAL_FUNC(delete_callback), NULL);
> combo=gtk_combo_new();
> glist = g_list_append(glist, "String 1");
> glist = g_list_append(glist, "String 2");
> glist = g_list_append(glist, "String 3");
> glist = g_list_append(glist, "String 4");
> gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",
> GTK_SIGNAL_FUNC(callback), NULL);
>
> gtk_combo_set_popdown_strings( GTK_COMBO(combo), glist);
> gtk_container_add(GTK_CONTAINER(window), combo);
> gtk_widget_show_all(window);
> active=1;
> gtk_main();
> return 0;
> }
> --------------------------
>
>
--
Gustavo J.A.M. Carneiro
World::Portugal::FEUP::DEEC::LEEC::TEC
[reinolinux.fe.up.pt/~ee96090]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]