[gtkmm] Newbie problem with Gtk::Notebook
- From: "Chun Wah, Leung (Ah Wah)" <egg_hk yahoo com>
- To: gtkmm-list gnome org
- Subject: [gtkmm] Newbie problem with Gtk::Notebook
- Date: Sun, 9 May 2004 16:09:33 -0700 (PDT)
I got a weird runtime error that I couldnt find out
why (Segementation fault). I tried to comment out some
of the lines in notebook section and the program works
again. Here is the code after commented out some lines
:
# myaccounts_mainwindow.h
#ifndef __MYACCOUNTS_MAINWINDOW_H__
#define __MYACCOUNTS_MAINWINDOW_H__
#include <gtkmm/window.h>
#include <gtkmm/box.h>
#include <gtkmm/menubar.h>
#include <gtkmm/menu.h>
#include <gtkmm/notebook.h>
class MainWindow: public Gtk::Window
{
public:
MainWindow();
virtual ~MainWindow();
protected:
// Child Widgets
Gtk::VBox m_VBox1; //main container
Gtk::MenuBar m_MenuBar;
Gtk::Menu m_Menu_Main, m_Menu_Module, m_Menu_Help;
Gtk::Notebook m_Notebook;
// Gtk::VBox m_NBVBox1, m_NBVBox2, m_NBVBox3,
m_NBVBox4, m_NBVBox5; // containers inside notebook
pages
// Signal handler
virtual void on_m_Menu_Main_Connect_activate();
virtual void on_m_Menu_Main_Disconnect_activate();
virtual void on_m_Menu_Main_Quit_activate();
virtual void on_m_Menu_others();
private:
void create_menuitems();
};
#endif // __MYACCOUNTS_MAINWINDOW_H__
# myaccounts_mainwindow.cpp
#include <gtkmm/stock.h>
#include "myaccounts_mainwindow.h"
MainWindow::MainWindow()
{
//Window's property
set_title("MyAccounts");
set_default_size(400, 200);
add(m_VBox1);
create_menuitems();
//Add the menus to the MenuBar:
m_MenuBar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Main",
m_Menu_Main));
m_MenuBar.items().push_back(Gtk::Menu_Helpers::MenuElem("M_odule",
m_Menu_Module));
m_MenuBar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Help",
m_Menu_Help));
//Add the MenuBar to the window:
m_VBox1.pack_start(m_MenuBar, Gtk::PACK_SHRINK);
//Notebook
m_Notebook.set_border_width(5);
// m_Notebook.append_page(m_NBVBox1, "Main");
// m_Notebook.append_page(m_NBVBox2, "General
Ledger");
/* m_Notebook.append_page(m_NBVBox3, "Sales Ledger");
m_Notebook.append_page(m_NBVBox4, "Purchases
Ledger");
m_Notebook.append_page(m_NBVBox5, "Inventories
Ledger");
*/
m_VBox1.pack_start(m_Notebook);
show_all_children();
}
MainWindow::~MainWindow()
{
}
void MainWindow::create_menuitems()
{
//Menus:
//Main menu:
{
Gtk::Menu::MenuList& menulist = m_Menu_Main.items();
menulist.push_back(Gtk::Menu_Helpers::MenuElem("_Connect",
Gtk::Menu::AccelKey("<control>c"),
SigC::slot(*this,
&MainWindow::on_m_Menu_Main_Connect_activate)));
menulist.push_back(Gtk::Menu_Helpers::MenuElem("_Disconnect",
Gtk::Menu::AccelKey("<control>d"),
SigC::slot(*this,
&MainWindow::on_m_Menu_Main_Disconnect_activate)));
menulist.push_back(Gtk::Menu_Helpers::SeparatorElem());
menulist.push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::QUIT,
SigC::slot(*this,
&MainWindow::on_m_Menu_Main_Quit_activate)));
}
//Module menu:
{
Gtk::Menu::MenuList& menulist =
m_Menu_Module.items();
menulist.push_back(Gtk::Menu_Helpers::MenuElem("General
Ledger",
SigC::slot(*this,
&MainWindow::on_m_Menu_others)));
menulist.push_back(Gtk::Menu_Helpers::MenuElem("Sales
Ledger",
SigC::slot(*this,
&MainWindow::on_m_Menu_others)));
menulist.push_back(Gtk::Menu_Helpers::MenuElem("Purchases
Ledger",
SigC::slot(*this,
&MainWindow::on_m_Menu_others)));
menulist.push_back(Gtk::Menu_Helpers::MenuElem("Inventories
Ledger",
SigC::slot(*this,
&MainWindow::on_m_Menu_others)));
}
//Help menu: (exercise stock items)
{
Gtk::Menu::MenuList& menulist = m_Menu_Help.items();
menulist.push_back(Gtk::Menu_Helpers::MenuElem("About...",
SigC::slot(*this,
&MainWindow::on_m_Menu_others)));
}
}
void MainWindow::on_m_Menu_Main_Connect_activate()
{
}
void MainWindow::on_m_Menu_Main_Disconnect_activate()
{
}
void MainWindow::on_m_Menu_Main_Quit_activate()
{
hide();
}
void MainWindow::on_m_Menu_others()
{
}
=====
Your capital > Assets - Liabilities
Chun Wah, Leung
(Ah Wah / AHua)
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]