You are not logged in.

#1 2010-01-13 00:33:11

Vamp898
Member
From: 東京
Registered: 2009-01-03
Posts: 909
Website

GTKmm Problem

I just did this:

Started Anjuta --> Created an GTKmm Project

and i got this main.cc:

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * main.cc
 * Copyright (C) test 2010 <vamp898@>
 * 
 * test is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * test is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm.h>
#include <iostream>



/* For testing propose use the local (not installed) ui file */
/* #define UI_FILE PACKAGE_DATA_DIR"/test/ui/test.ui" */
#define UI_FILE "src/test.ui"
   
int
main (int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    
    //Load the Glade file and instiate its widgets:
    Glib::RefPtr<Gtk::Builder> builder;
    try
    {
        builder = Gtk::Builder::create_from_file(UI_FILE);
    }
    catch (const Glib::FileError & ex)
    {
        std::cerr << ex.what() << std::endl;
        return 1;
    }
    Gtk::Window* main_win = 0;
    builder->get_widget("main_window", main_win);
    if (main_win)
    {
        kit.run(*main_win);
    }
    return 0;
}

Did i understand anything wrong or what? There is a main (no Class or something else, just a function) and in this the Window gets created. How should i interact with the Window? i cant acces the window outside the main() isnt it?

Offline

#2 2010-01-13 01:00:47

Vamp898
Member
From: 東京
Registered: 2009-01-03
Posts: 909
Website

Re: GTKmm Problem

ok nevermind, i throw Anjuta away from my computer

Sometimes he translates C++ stuff like public on

class Window : public Gtk::Window

into the german word "öffentlich"

class Window : öffentlich Gtk::Window

-.-

Offline

#3 2010-01-13 10:45:25

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: GTKmm Problem

you don't have to use that template file smile

anyway for GTK development I'd recommend vala over C++, since even though i think C++ is the better language, vala better integrates with GLib/GObject etc.


"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page

Offline

#4 2010-01-13 13:39:30

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: GTKmm Problem

For Gtk development I'd recommend PyGtk, at least for most inexperienced users.  It's a lot easier to see and understand the class hierarchy and relationships between objects in Python.

Offline

#5 2010-01-13 17:32:43

Vamp898
Member
From: 東京
Registered: 2009-01-03
Posts: 909
Website

Re: GTKmm Problem

im using Eclipse for C++ from now on and it just works fine. It works awesome^^

i had to set up some include paths but then it works awesome smile

But now i have a problem

I have a file called UI.glade and in this File i have an window1 (created with Glade for sure).

When im doing this

Window *w;
Builder b;
b.create_from_file( "UI.glade" );
b.get_widget( "window1", w );

im getting this error

(Main:24635): gtkmm-CRITICAL **: gtkmm: object `window1' not found in GtkBuilder file.

(Main:24635): gtkmm-CRITICAL **: gtkmm: Gtk::Buidler: widget `window1' was not found in the GtkBuilder file, or the specified part of it.

that gives no sense hmm

Offline

#6 2010-01-13 17:40:19

Vamp898
Member
From: 東京
Registered: 2009-01-03
Posts: 909
Website

Re: GTKmm Problem

Ah ok i got it xD it was an typing error -.-

Offline

Board footer

Powered by FluxBB