~ubuntu-branches/ubuntu/precise/glom/precise

« back to all changes in this revision

Viewing changes to glom/mode_data/db_adddel/db_adddel_withbuttons.cc

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Murray Cumming
  • Date: 2012-02-28 20:30:15 UTC
  • mfrom: (1.1.47)
  • Revision ID: package-import@ubuntu.com-20120228203015-pycwl994nb3avhhy
Tags: 1.20.9-0ubuntu1
* Upload the new serie to precise (lp: #871276)
* debian/glom-utils.install:
  - install extra binary which was not installed before

[ Murray Cumming ]
* New upstream release.
* Use postgresql-9.1 instead of postgresql-8.4 (lp: #873289)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Glom
 
2
 *
 
3
 * Copyright (C) 2001-2004 Murray Cumming
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 */
 
20
 
 
21
#include "db_adddel_withbuttons.h"
 
22
#include <glom/utils_ui.h>
 
23
#include <gtkmm/buttonbox.h>
 
24
#include <gtkmm/stock.h>
 
25
 
 
26
namespace Glom
 
27
{
 
28
 
 
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)
 
34
{
 
35
  m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
 
36
  m_ButtonBox.set_spacing(Utils::DEFAULT_SPACING_SMALL);
 
37
 
 
38
  setup_buttons();
 
39
  pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
 
40
 
 
41
  //Link buttons to handlers:
 
42
 
 
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);
 
45
 
 
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));
 
48
 
 
49
  m_ButtonBox.pack_end(m_Button_Del, Gtk::PACK_SHRINK);
 
50
  m_ButtonBox.pack_end(m_Button_Edit, Gtk::PACK_SHRINK);
 
51
 
 
52
  setup_buttons();
 
53
}
 
54
 
 
55
DbAddDel_WithButtons::~DbAddDel_WithButtons()
 
56
{
 
57
}
 
58
 
 
59
void DbAddDel_WithButtons::on_button_add()
 
60
{
 
61
  on_MenuPopup_activate_Add();
 
62
}
 
63
 
 
64
void DbAddDel_WithButtons::on_button_del()
 
65
{
 
66
  on_MenuPopup_activate_Delete();
 
67
}
 
68
 
 
69
void DbAddDel_WithButtons::on_button_edit()
 
70
{
 
71
  do_user_requested_edit();
 
72
}
 
73
 
 
74
void DbAddDel_WithButtons::set_allow_add(bool val)
 
75
{
 
76
  DbAddDel::set_allow_add(val);
 
77
 
 
78
  setup_buttons();
 
79
}
 
80
 
 
81
void DbAddDel_WithButtons::set_allow_delete(bool val)
 
82
{
 
83
  DbAddDel::set_allow_delete(val);
 
84
 
 
85
  setup_buttons();
 
86
}
 
87
 
 
88
void DbAddDel_WithButtons::set_allow_user_actions(bool bVal)
 
89
{
 
90
  DbAddDel::set_allow_user_actions(bVal);
 
91
 
 
92
  setup_buttons();
 
93
 
 
94
  //Recreate popup menu with correct items:
 
95
  setup_menu();
 
96
}
 
97
 
 
98
void DbAddDel_WithButtons::setup_buttons()
 
99
{
 
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;
 
103
 
 
104
  m_Button_Add.show();
 
105
  m_Button_Add.set_property("visible", allow_add);
 
106
 
 
107
  m_Button_Edit.show();
 
108
  m_Button_Edit.set_property("visible", allow_edit);
 
109
 
 
110
  if(!m_open_button_title.empty())
 
111
    m_Button_Edit.set_label(m_open_button_title);
 
112
 
 
113
  m_Button_Del.show();
 
114
  m_Button_Del.set_property("visible", allow_del);
 
115
 
 
116
  m_ButtonBox.show();
 
117
}
 
118
 
 
119
void DbAddDel_WithButtons::show_all_vfunc()
 
120
{
 
121
  //Call the base class:
 
122
  Gtk::Box::show_all_vfunc();
 
123
 
 
124
  //Hide some stuff:
 
125
  setup_buttons();
 
126
}
 
127
 
 
128
void DbAddDel_WithButtons::set_allow_view_details(bool val)
 
129
{
 
130
  DbAddDel::set_allow_view_details(val);
 
131
 
 
132
  setup_buttons();
 
133
}
 
134
 
 
135
void DbAddDel_WithButtons::on_selection_changed(bool selection)
 
136
{
 
137
  m_Button_Edit.set_sensitive(selection);
 
138
  m_Button_Del.set_sensitive(selection);
 
139
}
 
140
 
 
141
} //namespace Glom