3
* Copyright (C) 2001-2004 Murray Cumming
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation; either version 2 of the
8
* License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
21
#include "db_adddel_withbuttons.h"
22
#include <glom/utils_ui.h>
23
#include <gtkmm/buttonbox.h>
24
#include <gtkmm/stock.h>
29
DbAddDel_WithButtons::DbAddDel_WithButtons()
30
: m_ButtonBox(Gtk::ORIENTATION_HORIZONTAL),
31
m_Button_Del(Gtk::Stock::DELETE),
32
m_Button_Edit(Gtk::Stock::OPEN),
33
m_Button_Add(Gtk::Stock::ADD)
35
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
36
m_ButtonBox.set_spacing(Utils::DEFAULT_SPACING_SMALL);
39
pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
41
//Link buttons to handlers:
43
m_Button_Add.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_add));
44
m_ButtonBox.pack_end(m_Button_Add, Gtk::PACK_SHRINK);
46
m_Button_Del.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_del));
47
m_Button_Edit.signal_clicked().connect(sigc::mem_fun(*this, &DbAddDel_WithButtons::on_button_edit));
49
m_ButtonBox.pack_end(m_Button_Del, Gtk::PACK_SHRINK);
50
m_ButtonBox.pack_end(m_Button_Edit, Gtk::PACK_SHRINK);
55
DbAddDel_WithButtons::~DbAddDel_WithButtons()
59
void DbAddDel_WithButtons::on_button_add()
61
on_MenuPopup_activate_Add();
64
void DbAddDel_WithButtons::on_button_del()
66
on_MenuPopup_activate_Delete();
69
void DbAddDel_WithButtons::on_button_edit()
71
do_user_requested_edit();
74
void DbAddDel_WithButtons::set_allow_add(bool val)
76
DbAddDel::set_allow_add(val);
81
void DbAddDel_WithButtons::set_allow_delete(bool val)
83
DbAddDel::set_allow_delete(val);
88
void DbAddDel_WithButtons::set_allow_user_actions(bool bVal)
90
DbAddDel::set_allow_user_actions(bVal);
94
//Recreate popup menu with correct items:
98
void DbAddDel_WithButtons::setup_buttons()
100
const bool allow_edit = get_allow_user_actions() && get_allow_view_details();
101
const bool allow_del = get_allow_user_actions() && m_allow_delete;
102
const bool allow_add = get_allow_user_actions() && m_allow_add;
105
m_Button_Add.set_property("visible", allow_add);
107
m_Button_Edit.show();
108
m_Button_Edit.set_property("visible", allow_edit);
110
if(!m_open_button_title.empty())
111
m_Button_Edit.set_label(m_open_button_title);
114
m_Button_Del.set_property("visible", allow_del);
119
void DbAddDel_WithButtons::show_all_vfunc()
121
//Call the base class:
122
Gtk::Box::show_all_vfunc();
128
void DbAddDel_WithButtons::set_allow_view_details(bool val)
130
DbAddDel::set_allow_view_details(val);
135
void DbAddDel_WithButtons::on_selection_changed(bool selection)
137
m_Button_Edit.set_sensitive(selection);
138
m_Button_Del.set_sensitive(selection);