A simple program !!!!!!!!!!!!1
- From: nalin4linux77 linux <nalin4linux77 gmail com>
- To: gtkmm-list gnome org
- Subject: A simple program !!!!!!!!!!!!1
- Date: Sat, 14 Apr 2012 10:24:46 +0530
Friends I am Nalin X Linux (Rocking)
Today i am presenting a small class program which use Gtkmm and Glade. And the cause of why i post this software is that thees days i was serching for a sampile (easy) program for gtkmm and i never get any easy program for beginners!!!!!!!
Finally i made a sample program. and now i am dedicating this program for beginners of gtkmm with glade. because i have a condition no one else struggle like me !!!!!!
What ever else the program is given below
#include <iostream>
using namespace std;
//including the rocking hederfile gtkmm
#include <gtkmm.h>
class rock
{
Gtk::Window* window;
Gtk::Label* label;
Gtk::Button* button;
//Functions must be public
public:
void rock_me()
{
label->set_label("Yes I am rocking");
window->maximize();
//flush must be used for giving output instantly
cout<<"Nalin X Linux is now rocking"<<flush;
}
//Constructer which will involk automatically when object is created
rock()
{
//Creating builder and giving file called rock.glade which is in same directory
Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file("rock.glade");
//Getting widget from glade file
builder->get_widget("window",window);
builder->get_widget("button",button);
builder->get_widget("label", label);
// "*this" is a pointer which point to itself
button->signal_clicked().connect(sigc::mem_fun(*this, &rock::rock_me));
//Final running
Gtk::Main::run(*window);
}
};
int main(int argc,char *argv[])
{
Gtk::Main kit(argc,argv);
//creating the object called ob for the class rock
rock ob;
}
//Program finished hear
Download the atached file called "rock.glade" and copy it to the same directory where you saved the "rock_gtkmm.cpp"
Open the Terminal <<<<<
Now compile it with : g++ -Wall -o "rock_gtkmm" "rock_gtkmm.cpp" `pkg-config gtkmm-3.0 --cflags --libs`
Run it with : ./rock_gtkmm
Have a nice day <<<<<<<<<<< Thanks for reading
by your friend Nalin X Linux
--
Mob : +91 8281029215
FREE SOFTWARE FREE SOCIETY
Attachment:
rock.glade
Description: application/glade
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]