Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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
- app->run(*window);
- }
- };
- int main(int argc,char *argv[])
- {
- Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv);
- //creating the object called ob for the class rock
- rock ob;
- }
Advertisement
Add Comment
Please, Sign In to add comment