Problems using gtk on object-oriented attempt - Linux
This is a discussion on Problems using gtk on object-oriented attempt - Linux ; Hello,
Since lately, I am trying to write every code only more in C++ instead of
C.
Unfortunately I have problems handling gtk signals while using the
object-oriented attempt of C++.
I could write something like this...
#include
#include
using ...
-
Problems using gtk on object-oriented attempt
Hello,
Since lately, I am trying to write every code only more in C++ instead of
C.
Unfortunately I have problems handling gtk signals while using the
object-oriented attempt of C++.
I could write something like this...
#include
#include
using namespace std;
static void destroyWindow(GtkWidget *widget, gpointer data) {
gtk_main_quit();
}
class EmptyWindow {
private:
GtkWidget *window;
public:
void paintWindow(int argc, char **argv);
};
void EmptyWindow:
aintWindow(int argc, char **argv) {
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroyWindow), NULL);
gtk_widget_show(window);
gtk_main();
}
int main(int argc, char **argv) {
EmptyWindow *emptywindow = new EmptyWindow();
emptywindow->paintWindow(argc, argv);
return 0;
}
It actually works, but this signal function on top hurts the
object-oriented attempt, so how can I use signals with real methods, in
this case methods of "EmptyWindow"?
When i define a real method, I don't know how to access it with
g_signal_connect, due to its parameter.
Markus
-
Re: Problems using gtk on object-oriented attempt
On Wed, 25 Oct 2006 21:38:18 +0200, Markus Pitha wrote:
> It actually works, but this signal function on top hurts the
> object-oriented attempt, so how can I use signals with real methods, in
> this case methods of "EmptyWindow"?
> When i define a real method, I don't know how to access it with
> g_signal_connect, due to its parameter.
>
Why not switch to use gtkmm - an object oriented layer on-top of gtk?
http://gtkmm.sourceforge.net/gtkmm2/docs/index.html
--
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/p...rch=0xE3E80917
-
Re: Problems using gtk on object-oriented attempt
Hello,
On Wed, 25 Oct 2006 19:59:11 +0000 Michael Rasmussen wrote:
> Why not switch to use gtkmm - an object oriented layer on-top of gtk?
> http://gtkmm.sourceforge.net/gtkmm2/docs/index.html
When I use these libraries, does that mean that people have to download
these libraries first to be able to compile the program (e.g. with a
make file to this program) or does it run anyhow with the usual gtk? I
guess a compiled program runs over gtk, but if someone wants to compile
it with a make file, he needs to download the three needed libraries
first. At the moment I am downloading it and see that I need libsigc and
glibmm for using gtkmm and I read that I naturally have to bind in other
header files than gtk/gtk.h. When someone wants to use my program, which
should be built with a makefile, he has to download these libraries too,
which is associated with work and the next problem is the compatibility to
Windows. At the moment I don't write anything for Windows and it's
possible to use the standard gtk on Windows too, so it wouldn't be a
problem to port programs to Windows. I found information about a gtkmm
runtime environment but who knows if this is as stable as the usual gtk
library.
Markus
-
Re: Problems using gtk on object-oriented attempt
Markus Pitha writes:
> Hello,
>
> On Wed, 25 Oct 2006 19:59:11 +0000 Michael Rasmussen wrote:
> > Why not switch to use gtkmm - an object oriented layer on-top of gtk?
> > http://gtkmm.sourceforge.net/gtkmm2/docs/index.html
>
> When I use these libraries, does that mean that people have to download
> these libraries first to be able to compile the program (e.g. with a
> make file to this program) or does it run anyhow with the usual gtk? I
> guess a compiled program runs over gtk, but if someone wants to compile
> it with a make file, he needs to download the three needed libraries
> first. At the moment I am downloading it and see that I need libsigc and
> glibmm for using gtkmm and I read that I naturally have to bind in other
> header files than gtk/gtk.h. When someone wants to use my program, which
> should be built with a makefile, he has to download these libraries
> too,
Right -- if they're going to use the code, they have to have the
libraries. If they've got a reasonable distribution, though, getting
them is easy enough not to be a problem.
> which is associated with work and the next problem is the compatibility to
> Windows. At the moment I don't write anything for Windows and it's
> possible to use the standard gtk on Windows too, so it wouldn't be a
> problem to port programs to Windows. I found information about a gtkmm
> runtime environment but who knows if this is as stable as the usual gtk
> library.
--
Joseph J. Pfeiffer, Jr., Ph.D. Phone -- (505) 646-1605
Department of Computer Science FAX -- (505) 646-1002
New Mexico State University http://www.cs.nmsu.edu/~pfeiffer
-
Re: Problems using gtk on object-oriented attempt
On Wed, 25 Oct 2006 17:19:09 -0600 Joe Pfeiffer wrote:
> Right -- if they're going to use the code, they have to have the
> libraries. If they've got a reasonable distribution, though, getting
> them is easy enough not to be a problem.
Actually you are right and if someone want's to get a program, it's
probably the least he can do to use it.
Regards
Markus