Resizing/Repainting of container when child-button is resized ...



Hi there,

sorry for flooding this list with questions, please bear with me.
I'm trying to learn this stuff....

I have this HBox with a width of three and in it a Menu, a
button with a text label and a toolbar of buttons with icons
only.

Depending on user input the text displayed in the button may
change and the width needs to be adjusted.

Now, when I resize the button it
(a) doesn't get resized correctly immediately. The window resizes OK
(if the button got wider), text label gets blank, and only when I click
on the button will the button resize and the toolbar be shifted (let's
say to the right).

(b) If the original window was (let's say) 500 pixels wide, even after
I click on the button and everything gets resized OK, the window
will still only paint in an area 500 pixels wide, i.e. the window will
get wider, the WM decorations will be resized accordingly, the toolbar
shifted to the right, but then the parts of the toolbar outside the
original window size will not be painted, though they remain
sensitive (even tooltips work).

I have the feeling like the two issues are separate things ... have
tried various things to force the GUI to resize as you can see from
the code snippets below (widget_send_expose, emit expose events
directly, invalidate_rect, queue_draw, process_updates), to no avail.

What am I missing?
TIA,

Karl.


some code snippets:

 window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title (GTK_WINDOW (window1), _("XVidcap"));
 gtk_window_set_resizable (GTK_WINDOW (window1), FALSE);
 hbox1 = gtk_hbox_new (FALSE, 0);
 gtk_widget_show (hbox1);
 gtk_container_add (GTK_CONTAINER (window1), hbox1);
 menubar1 = gtk_menu_bar_new ();
 gtk_widget_show (menubar1);
 gtk_box_pack_start (GTK_BOX (hbox1), menubar1, FALSE, FALSE, 0);
...
 filename = gtk_button_new_with_label(_("filename"));
 gtk_widget_show (filename);
 gtk_box_pack_start (GTK_BOX (hbox1), filename, TRUE, TRUE, 0);
// at this point I don't know the text I need to put here, yet .....
 gtk_widget_set_size_request (filename, 130, -1);
//  gtk_widget_set_size_request (filename, -1, -1);
// gtk_container_set_resize_mode (GTK_CONTAINER (filename), GTK_RESIZE_IMMEDIATE);

---

/*
* change value of frame/filename display
*/
void
GtkChangeLabel (int pic_no)
{
       PangoLayout *layout;
       gint width, height, old_handlebox_width, old_filename_width;
       static char file[PATH_MAX+1];
       static int blub;
       gboolean ignore = TRUE;
       GdkRectangle r;
       GdkEvent eev;
printf("run %i times\n", ++blub);
//      old_handlebox_width = GTK_WIDGET( handlebox1 )->allocation.width;
// layout = gtk_widget_create_pango_layout (filename, gtk_button_get_label(GTK_BUTTON (filename)));
//      pango_layout_get_pixel_size (layout, &old_filename_width, &height);
       if (jobp->flags & FLG_MULTI_IMAGE) {
               sprintf (file, "%s[%04d]", jobp->file, pic_no);
       } else {
               sprintf (file, jobp->file, pic_no);
       }
       gtk_button_set_label(GTK_BUTTON (filename), file);
       layout = gtk_widget_create_pango_layout (filename, file);
       pango_layout_get_pixel_size (layout, &width, &height);
       g_object_unref (layout);
gtk_widget_set_size_request(GTK_WIDGET (filename), (width + 30), -1);
       gtk_widget_set_size_request(GTK_WIDGET (hbox1), -1, -1);
gtk_widget_set_size_request(GTK_WIDGET (filename), (width + 30), -1);
       gtk_widget_set_size_request(GTK_WIDGET (hbox1), -1, -1);
// g_signal_emit_by_name((GtkObject*) window1, "expose-event", &ignore);
       r.x = 0;
       r.y = 0;
       r.width = GTK_WIDGET(window1)->allocation.width;
       r.height = GTK_WIDGET(window1)->allocation.height;
       gdk_window_invalidate_rect(window1->window, &r, TRUE);
/*      gdk_window_process_updates(window1->window, TRUE);
       eev.type = GDK_EXPOSE;
       gtk_widget_send_expose(GTK_WIDGET(window1), &eev);
       gtk_widget_send_expose(GTK_WIDGET(hbox1), &eev);
       gtk_widget_send_expose(GTK_WIDGET(filename), &eev);
       gtk_widget_send_expose(GTK_WIDGET(toolbar3), &eev);
*/
//      gtk_button_enter(GTK_BUTTON(filename));
       gtk_widget_queue_draw(GTK_WIDGET(filename));
       gtk_widget_queue_draw(GTK_WIDGET(toolbar3));
       gtk_widget_queue_draw(GTK_WIDGET(hbox1));
       gtk_widget_queue_draw(GTK_WIDGET(window1));
       gdk_window_process_updates(window1->window, TRUE);
}













[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]