PDA

View Full Version : Newbie to Programming



royoni
15th August 2004, 09:50 AM
Hi,
I am new to Linux C++ programming and I use Anjuta + Glade on FC2.
I would like to make my first little programme which simply open an image then display it on the same window.

Please advise what is wrong on the screen shot and the error message, thank you very much!

window1_glade.hh
/ generated 2004/8/15 16:36:29 HKT by rolly@localhost.localdomain.(none)
// using glademm V2.5.0
//
// DO NOT EDIT THIS FILE ! It was created using
// glade-- /home/rolly/Projects/image2/image2.glade
// for gtk 2.4.0 and gtkmm 2.4.3
//
// Please modify the corresponding derived classes in ./src/window1.cc


#if defined __GNUC__ && __GNUC__ < 3
#error This program will crash if compiled with g++ 2.x
// see the dynamic_cast bug in the gtkmm FAQ
#endif //
#include "config.h"
/*
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (GETTEXT_PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
#include <gtkmmconfig.h>
#if GTKMM_MAJOR_VERSION==2 && GTKMM_MINOR_VERSION>2
#include <sigc++/compatibility.h>
#endif //gtkmm 2.3+
#include "window1_glade.hh"
#include <gdk/gdkkeysyms.h>
#include <gtkmm/accelgroup.h>
#include <gtk/gtkimagemenuitem.h>

window1_glade::window1_glade(
) : Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{ window1 = this;
gmm_data = new GlademmData(get_accel_group());
new1 = NULL;
open1 = NULL;
save1 = NULL;
save_as1 = NULL;
separatormenuitem1 = NULL;
quit1 = NULL;
menu7 = Gtk::manage(new class Gtk::Menu());
menuitem7 = NULL;
cut1 = NULL;
copy1 = NULL;
paste1 = NULL;
delete1 = NULL;
menu8 = Gtk::manage(new class Gtk::Menu());
menuitem8 = NULL;
menu9 = Gtk::manage(new class Gtk::Menu());
menuitem9 = NULL;
about1 = NULL;
menu10 = Gtk::manage(new class Gtk::Menu());
menuitem10 = NULL;
menubar1 = Gtk::manage(new class Gtk::MenuBar());

Glib::RefPtr<Gdk::PixbufLoader> _image1_loader=Gdk::PixbufLoader::create();
_image1_loader->write(_data, sizeof _data);
_image1_loader->close();
image1 = Gtk::manage(new class Gtk::Image(_image1_loader->get_pixbuf()));
vbox1 = Gtk::manage(new class Gtk::VBox(false, 0));


menu7->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-new")));
new1 = (Gtk::ImageMenuItem *)&menu7->items().back();

menu7->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-open")));
open1 = (Gtk::ImageMenuItem *)&menu7->items().back();

menu7->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-save")));
save1 = (Gtk::ImageMenuItem *)&menu7->items().back();

menu7->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-save-as")));
save_as1 = (Gtk::ImageMenuItem *)&menu7->items().back();

menu7->items().push_back(Gtk::Menu_Helpers::SeparatorElem ());
separatormenuitem1 = (Gtk::MenuItem *)&menu7->items().back();

menu7->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-quit")));
quit1 = (Gtk::ImageMenuItem *)&menu7->items().back();

menu8->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-cut")));
cut1 = (Gtk::ImageMenuItem *)&menu8->items().back();

menu8->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-copy")));
copy1 = (Gtk::ImageMenuItem *)&menu8->items().back();

menu8->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-paste")));
paste1 = (Gtk::ImageMenuItem *)&menu8->items().back();

menu8->items().push_back(Gtk::Menu_Helpers::StockMenuElem (Gtk::StockID("gtk-delete")));
delete1 = (Gtk::ImageMenuItem *)&menu8->items().back();

menu10->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_About")));
about1 = (Gtk::MenuItem *)&menu10->items().back();

menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"), *menu7));
menuitem7 = (Gtk::MenuItem *)&menubar1->items().back();

menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"), *menu8));
menuitem8 = (Gtk::MenuItem *)&menubar1->items().back();

menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_View"), *menu9));
menuitem9 = (Gtk::MenuItem *)&menubar1->items().back();

menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Help"), *menu10));
menuitem10 = (Gtk::MenuItem *)&menubar1->items().back();
image1->set_alignment(0.5,0.5);
image1->set_padding(0,0);
vbox1->pack_start(*menubar1, Gtk::PACK_SHRINK, 0);
vbox1->pack_start(*image1);
window1->set_title(_("window1"));
window1->set_default_size(500,400);
window1->set_modal(false);
window1->property_window_position().set_value(Gtk::WIN_POS_ NONE);
window1->set_resizable(true);
window1->property_destroy_with_parent().set_value(false);
window1->add(*vbox1);
new1->show();
open1->show();
save1->show();
save_as1->show();
separatormenuitem1->show();
quit1->show();
menuitem7->show();
cut1->show();
copy1->show();
paste1->show();
delete1->show();
menuitem8->show();
menuitem9->show();
about1->show();
menuitem10->show();
menubar1->show();
image1->show();
vbox1->show();
window1->show();
new1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_new1_activate));
open1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_open1_activate));
save1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_save1_activate));
save_as1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_save_as1_activate));
quit1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_quit1_activate));
cut1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_cut1_activate));
copy1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_copy1_activate));
paste1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_paste1_activate));
delete1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_delete1_activate));
about1->signal_activate().connect(SigC::slot(*this, &window1_glade::on_about1_activate));
}

window1_glade::~window1_glade()
{ delete gmm_data;
}


The following is the error message:
Building source directory of the Project: image2 ...
make
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/gtkmm-2.0 -I/usr/local/lib/gtkmm-2.0/include -I/usr/local/lib/sigc++-1.2/include -I/usr/local/include/sigc++-1.2 -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/atk-1.0 -Wall -g -MT window1_glade.o -MD -MP -MF ".deps/window1_glade.Tpo" -c -o window1_glade.o window1_glade.cc; \
then mv -f ".deps/window1_glade.Tpo" ".deps/window1_glade.Po"; else rm -f ".deps/window1_glade.Tpo"; exit 1; fi
window1_glade.cc: In constructor `window1_glade::window1_glade()':
window1_glade.cc:71: error: `PixbufLoader' undeclared in namespace `Gdk'
window1_glade.cc:71: error: template argument 1 is invalid
window1_glade.cc:71: error: ISO C++ forbids declaration of `_image1_loader'
with no type
window1_glade.cc:71: error: no class template named `PixbufLoader' in `Gdk'
window1_glade.cc:72: error: base operand of `->' is not a pointer
window1_glade.cc:72: error: `_data' undeclared (first use this function)
window1_glade.cc:72: error: (Each undeclared identifier is reported only once
for each function it appears in.)
window1_glade.cc:73: error: base operand of `->' is not a pointer
window1_glade.cc:74: error: base operand of `->' is not a pointer
make: *** [window1_glade.o] Error 1
Completed ... unsuccessful
Total time taken: 4 secs

royoni
15th August 2004, 03:17 PM
This is the screenshot!

crackers
15th August 2004, 05:15 PM
This is the screenshot!
I think you'll probably get better help in a more Glade-oriented forum than here, since these fora are more oriented to helping people with Fedora-specific issues.

royoni
16th August 2004, 06:42 AM
I think you'll probably get better help in a more Glade-oriented forum than here, since these fora are more oriented to helping people with Fedora-specific issues.

:) Thanks cracker,
but where can I find such kind of forum?
can you post a URL?

:)

imdeemvp
16th August 2004, 06:59 AM
did you do a google search? but if you did not here is the glade home page (http://glade.gnome.org/)

you may find your answer there.......... :eek:

tashirosgt
16th August 2004, 02:29 PM
How are you compiling this program, with a makefile? The problem seems to be that the header file that defines PixbufLoader is not included.

royoni
17th August 2004, 05:35 AM
How are you compiling this program, with a makefile? The problem seems to be that the header file that defines PixbufLoader is not included.

Thank you all! Is this the header file you mean? #include <gdk/gdkkeysyms.h>??
How can I search for the correct header file for Pixbufloader??

:confused:

PompeyBlue
17th August 2004, 09:52 AM
The joy of getting somebody else's code to compile on your machine. The way I find lost functions is to go the include directory for whatever I'm working on (XLIB or GLUT) and simply:

grep -I <symbol> *.h

This will search all header files for whatever symbol you are looking for. So in your cash I think you need to cd to the gdk header directory and then

grep -Ii Pixbufloader *.h

The -I mans all files, -i means ignore case.

It will either tell you which header file it's in or if it comes up blank it suggests that it's probably part of the application source that you are trying to compile.

PompeyBlue
17th August 2004, 09:53 AM
Oh yeah, it could also be a namespace problem, it could be compiled under std, not gdk and that's why it's not finding it ?

royoni
18th August 2004, 01:55 AM
The joy of getting somebody else's code to compile on your machine. The way I find lost functions is to go the include directory for whatever I'm working on (XLIB or GLUT) and simply:

grep -I <symbol> *.h

This will search all header files for whatever symbol you are looking for. So in your cash I think you need to cd to the gdk header directory and then

grep -Ii Pixbufloader *.h

The -I mans all files, -i means ignore case.

It will either tell you which header file it's in or if it comes up blank it suggests that it's probably part of the application source that you are trying to compile.

Thank you!
I did find the following pixbufloader.h files in my system, but I don't know how to configure Anjuta to look for the correct directory while compiling? (Since these files are in the gtkmm directories instead of gdk!)

Please advise, :D