Re: Converting stuff from Gtk to Gtkmm



On 8/15/06, razors <abra185 yahoo com> wrote:
Hi, im trying to port a widget from Gtk+ to Gtkmm ( or am i wrong and there
is a way to use a GtkWidget on Gtkmm? Like attach a Gtk Widget to a Gtkmm
Panel?) and my problem is, i have the following code:

GdkWindow* parent = gtk_widget_get_parent_window(widget);
GdkDisplay* display =
gdk_drawable_get_display(GDK_DRAWABLE(parent));
GdkScreen* screen =
gdk_drawable_get_screen(GDK_DRAWABLE(parent));

Display* xdisplay = GDK_DISPLAY_XDISPLAY(display);
Screen* xscreen = GDK_SCREEN_XSCREEN(screen);
int screen_number = XScreenNumberOfScreen(xscreen);
XID xid_parent = GDK_WINDOW_XWINDOW(parent);

I cant port some of those functions(or find how) to gtkmm....
GDK_WINDOW_XWINDOW, GDK_DISPLAY_XDISPLAY( cant find xdisplay or something on
Gtk::Display) and XID isnt defined. What should i do? Thanks in advance

Regards,
Romulo.

You can mix and match GTK+ and gtkmm as much as you like.  Most (all?)
gtkmm widgets have a gobj() method that returns a pointer to the
underlying GTK+ widget which you can then use with plain GTK+
functions.  So for example, if you wanted to add a GTK+ widget to a
gtkmm container, you could do something like:
gtk_container_add(gtkmmwidget.gobj(), gtkwidget);

In a similar way, you could use gtkmm for everything, and then when
you need the X display, you can revert to plain GTK+ objects:
// dpy is of type Gdk::Display
xdisplay = GDK_DISPLAY_XDISPLAY(dpy.gobj());

Alternately, you can 'wrap' the plain GTK+ widget in a gtkmm wrapper as in:
Gtk::Widget* wrapped_widget = Glib::wrap(gtkwidget);
and then use wrapped_widget as a normal Gtk::Widget

Hope that helps

--
jonner



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