Re: Converting stuff from Gtk to Gtkmm



Thanks i appreciate your help, but i found a better way....since im not totally prepared to port all my app to gtkmm im using gtk+ for now...i havent found either a function on glademm to autoconnect signals wich piss me off ( i love that function ), i discovered that i can autoconnect C signals in a C++ application using glade just by passing the Linker flag -rdynamic to gcc/g++ and declaring the functions as extern "C" {} ..hope that helps for anyone that is googling that too, took me some time to figure out ;)
Anyway thanks for your help, i will be looking forward gtkmm and i will make a better use for it in my future applications. Thanks! =)

Jonathon Jongsma <jonathon jongsma gmail com> wrote:
On 8/15/06, razors 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


Get your email and more, right on the new Yahoo.com

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