Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

MainWindow.cpp
Saturday, March 29th, 2008 at 11:41:30am MDT 

  1. #include "MainWindow.h"
  2.  
  3. MainWindow::MainWindow()
  4. {
  5.         // Initialise members
  6.         preferences_window = NULL;
  7.        
  8.         // Load the data for this window and it's widgets.
  9.     refXml = Gnome::Glade::Xml::create("simpleapp.glade", "main_window");
  10.    
  11.     // The window
  12.     refXml->get_widget("main_window", window);
  13.         window->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::on_delete_event));
  14.  
  15.     // Widgets
  16.     refXml->connect_clicked("preferences_button", sigc::mem_fun(*this, &MainWindow::on_preferences_open));
  17.    
  18.     // Show everything.
  19.     window->show_all_children(true);
  20. }
  21.  
  22. MainWindow::~MainWindow()
  23. {
  24.         delete window; // Frees all the children for the window, too.
  25. }
  26.  
  27. bool MainWindow::on_delete_event(GdkEventAny *e)
  28. {
  29.         if (preferences_window != NULL)
  30.                 return true;
  31.        
  32.         return false;
  33. }
  34.  
  35. void MainWindow::on_preferences_open()
  36. {
  37.         if (preferences_window == NULL)
  38.                 preferences_window = new PreferencesWindow;
  39.        
  40.         preferences_window->window->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::on_preferences_close));
  41.         preferences_window->window->signal_hide().connect(sigc::mem_fun(*this, &MainWindow::on_preferences_hide));
  42.  
  43. }
  44.  
  45. void MainWindow::on_preferences_hide()
  46. {
  47.         std::cout << "MainWindow::on_preferences_hide() called" << std::endl;
  48.        
  49.         delete preferences_window;
  50.         preferences_window = NULL;
  51.        
  52.         std::cout << "MainWindow::on_preferences_hide() finished" << std::endl;
  53. }
  54.  
  55. bool MainWindow::on_preferences_close(GdkEventAny *e)
  56. {
  57.         on_preferences_hide();
  58.         return false;
  59. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right