bhattigurjot

gtkmm

Jul 1st, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. //including the rocking hederfile gtkmm
  4. #include <gtkmm.h>
  5. class rock
  6. {
  7. Gtk::Window* window;
  8. Gtk::Label* label;
  9. Gtk::Button* button;
  10. //Functions must be public
  11. public:
  12.  
  13. void rock_me()
  14. {
  15. label->set_label("Yes I am rocking");
  16. window->maximize();
  17. //flush must be used for giving output instantly
  18. cout<<"Nalin X Linux is now rocking"<<flush;
  19. }
  20. //Constructer which will involk automatically when object is created
  21. rock()
  22. {
  23. //Creating builder and giving file called rock.glade which is in same directory
  24. Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file("rock.glade");
  25. //Getting widget from glade file
  26. builder->get_widget("window",window);
  27. builder->get_widget("button",button);
  28. builder->get_widget("label", label);
  29. // "*this" is a pointer which point to itself
  30. button->signal_clicked().connect(sigc::mem_fun(*this, &rock::rock_me));
  31. //Final running
  32. app->run(*window);
  33. }
  34. };
  35. int main(int argc,char *argv[])
  36. {
  37. Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv);
  38. //creating the object called ob for the class rock
  39. rock ob;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment