Re: Help replacing GtkDrawingArea with GtkLayout



On Tue, 2014-03-11 at 21:43 +0100, Joël Krähemann wrote:
[...]
Please consider the documentation of gtk_widget_set_app_paintable()
don't believe GtkLayout can do your job. You could try id with a
GtkDrawingArea with a cairo surface. I do some drawing in C take a look
at http://sourceforge.net/p/ags/code/HEAD/tree/src/ags/X/ags_editor.c

regards Joël



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Finally got it you can't read GdkWindow before you didn't show the assigned widget.

I am unsure what you mean by "read GdkWindow", as you can see from the
console output when running the minimal example the GdkWindow attached
to the GtkLayout does exist and does get its flags set. Those g_print()
statements are there to confirm that fact.


#include <gtk/gtk.h>

gboolean
configure_event (GtkWidget *widget,
                 GdkEventConfigure *configure,
                 gpointer data)
{
  fprintf (stderr, "configure-event\n");
  gtk_main_quit ();
  return FALSE;
}
int main(int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *layout;
  GtkWidget *label1;
  GdkWindow *win;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  layout = gtk_layout_new (NULL, NULL);
  g_object_set(G_OBJECT(layout),
               "app-paintable", TRUE,
               NULL);

  gtk_widget_add_events (layout, GDK_ALL_EVENTS_MASK);
  gtk_container_add (GTK_CONTAINER (window), layout);

  label1 = gtk_label_new ("label 1");

  gtk_layout_put (GTK_LAYOUT (layout), label1, 10, 50);


  gtk_widget_show_all (window);

  win = gtk_layout_get_bin_window (GTK_LAYOUT(layout));
  g_print("win is %p initial mask 0x%x\n", win, gdk_window_get_events
          (win));
  gdk_window_set_events (win, gdk_window_get_events (win) |
                         GDK_STRUCTURE_MASK);
  g_print("After adding GDK_STRUCTURE_MASK mask 0x%x\n",
          gdk_window_get_events (win));

  g_signal_connect (layout, "configure-event",
                    G_CALLBACK (configure_event), NULL);

  gtk_main ();

  return 0;
}


When I compile the version you have given the code behaves as before,
the window pops up (because the configure-event signal has not been
received, whose callback would cause an exit).
Are you saying it does something different for you?

Richard




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