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

« back to all changes in this revision

Viewing changes to glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-10-09 16:50:36 UTC
  • mfrom: (1.1.42 upstream)
  • Revision ID: james.westby@ubuntu.com-20091009165036-orinvwmohk838xxl
Tags: 1.12.2-0ubuntu1
* New upstream version:
  - FFE LP: #391664
* debian/control:
  - Bump python-gnome2-extras-dev build-dep to >= 2.25.3.
  - Bump libgdamm3.0-dev build-dep to libgdamm4.0-dev >= 3.99.14.
  - Change libgda3-dev build-dep to libgda-4.0-dev.
  - Change libgda3-postgres dependency to libgda-4.0-postgres.
  - Bump libgtkmm-2.4-dev build-dep to >= 2.14.
  - Add build-dep on libgconfmm-2.6-dev.
  - Bump libgoocanvasmm-dev build-dep to >= 0.14.0.
  - Remove build-dep on libbakery-2.6-dev.
  - Bump postgresql-8.3 dependency to postgresql-8.4.
  - Change scrollkeeper build-dep to rarian-compat.
  - Rename libglom{0,-dev} -> libglom-1.12-{0,dev}. Upstream include
    APIVER in the library name now.
* debian/rules:
  - Update --with-postgres-utils configure flag to point to the new
    path.
  - Drop deprecated --disable-scrollkeeper configure flag.
  - Update DEB_SHLIBDEPS_INCLUDE with new libglom-1.12-0 package name.
  - Don't include /usr/share/cdbs/1/rules/simple-patchsys.mk - there
    are currently no patches.
* debian/libglom-1.12-0.install:
  - Updated for new version.
* debian/libglom-1.12-dev.install:
  - Install pc and header files.
* debian/glom-doc.install:
  - Updated for new version.
* debian/glom.install:
  - Updated for new version.
* Fix debian/watch.
* Dropped obsolete 10-distro-install-postgres-change.patch.
* Built against latest libgoocanvasmm (LP: #428445).
* Also closes LP: #230007, LP: #393229, LP: #393231, LP: #394507,
  LP: #394887, LP: #394894, LP: #397409, LP: #381563.

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 "dialog_field_layout.h"
 
22
#include <libglom/data_structure/glomconversions.h>
 
23
#include <glom/glade_utils.h>
 
24
#include <glibmm/i18n.h>
 
25
 
 
26
namespace Glom
 
27
{
 
28
 
 
29
Dialog_FieldLayout::Dialog_FieldLayout(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder)
 
30
: Gtk::Dialog(cobject),
 
31
  m_label_field_name(0),
 
32
  m_checkbutton_editable(0),
 
33
  m_radiobutton_title_default(0),
 
34
  m_label_title_default(0),
 
35
  m_radiobutton_title_custom(0),
 
36
  m_entry_title_custom(0),
 
37
  m_box_formatting_placeholder(0),
 
38
  m_radiobutton_custom_formatting(0),
 
39
  m_box_formatting(0)
 
40
{
 
41
  builder->get_widget("label_field_name", m_label_field_name);
 
42
  builder->get_widget("checkbutton_editable", m_checkbutton_editable);
 
43
 
 
44
  builder->get_widget("radiobutton_use_title_default", m_radiobutton_title_default);
 
45
  builder->get_widget("label_title_default", m_label_title_default);
 
46
  builder->get_widget("radiobutton_use_title_custom", m_radiobutton_title_custom);
 
47
  builder->get_widget("entry_title_custom", m_entry_title_custom);
 
48
 
 
49
  //Get the place to put the Formatting stuff:
 
50
  builder->get_widget("radiobutton_use_custom", m_radiobutton_custom_formatting);
 
51
  builder->get_widget("box_formatting_placeholder", m_box_formatting_placeholder);
 
52
 
 
53
  //GtkBuilder can't find top-level objects (GtkAdjustments in this case),
 
54
  //that one top-level object references.
 
55
  //See http://bugzilla.gnome.org/show_bug.cgi?id=575714
 
56
  //so we need to this silliness. murrayc.
 
57
  std::list<Glib::ustring> builder_ids;
 
58
  builder_ids.push_back("box_formatting");
 
59
  builder_ids.push_back("adjustment2");
 
60
 
 
61
  //Get the formatting stuff:
 
62
  try
 
63
  {
 
64
    Glib::RefPtr<Gtk::Builder> refXmlFormatting = Gtk::Builder::create_from_file(Utils::get_glade_file_path("glom_developer.glade"), builder_ids);
 
65
    refXmlFormatting->get_widget_derived("box_formatting", m_box_formatting);
 
66
  }
 
67
  catch(const Gtk::BuilderError& ex)
 
68
  {
 
69
    std::cerr << ex.what() << std::endl;
 
70
  }
 
71
 
 
72
  m_box_formatting_placeholder->pack_start(*m_box_formatting);
 
73
  add_view(m_box_formatting);
 
74
 
 
75
  m_radiobutton_custom_formatting->signal_toggled().connect(sigc::mem_fun(*this, &Dialog_FieldLayout::on_radiobutton_custom_formatting));
 
76
 
 
77
  show_all_children();
 
78
}
 
79
 
 
80
Dialog_FieldLayout::~Dialog_FieldLayout()
 
81
{
 
82
  remove_view(m_box_formatting);
 
83
}
 
84
 
 
85
void Dialog_FieldLayout::set_field(const sharedptr<const LayoutItem_Field>& field, const Glib::ustring& table_name)
 
86
{
 
87
  m_layout_item = glom_sharedptr_clone(field);
 
88
 
 
89
  m_table_name = table_name;
 
90
 
 
91
  m_label_field_name->set_text( field->get_layout_display_name() );
 
92
 
 
93
  m_checkbutton_editable->set_active( field->get_editable() );
 
94
 
 
95
  //Calculated fields can never be edited:
 
96
  sharedptr<const Field> field_details = field->get_full_field_details();
 
97
  const bool editable_allowed = field_details && !field_details->get_has_calculation();
 
98
  m_checkbutton_editable->set_sensitive(editable_allowed);
 
99
 
 
100
  //Custom title:
 
101
  Glib::ustring title_custom;
 
102
  if(field->get_title_custom())
 
103
    title_custom = field->get_title_custom()->get_title();
 
104
 
 
105
  m_radiobutton_title_custom->set_active( field->get_title_custom() && field->get_title_custom()->get_use_custom_title() );
 
106
  m_entry_title_custom->set_text(title_custom);
 
107
  m_label_title_default->set_text(field->get_title_or_name_no_custom());
 
108
 
 
109
  //Formatting:
 
110
  m_radiobutton_custom_formatting->set_active( !field->get_formatting_use_default() );
 
111
  m_box_formatting->set_formatting(field->m_formatting, table_name, field->get_full_field_details());
 
112
 
 
113
  enforce_constraints();
 
114
}
 
115
 
 
116
sharedptr<LayoutItem_Field> Dialog_FieldLayout::get_field_chosen() const
 
117
{
 
118
    double x = 0;
 
119
    double y = 0;
 
120
    double width, height;
 
121
    m_layout_item->get_print_layout_position(x, y, width, height);
 
122
    std::cout << "DEBUGDialog_FieldLayout::get_field_chosen1(): m_layout_item: x=" << x << std::endl;
 
123
 
 
124
  m_layout_item->set_editable( m_checkbutton_editable->get_active() );
 
125
 
 
126
  m_layout_item->set_formatting_use_default( !m_radiobutton_custom_formatting->get_active() );
 
127
  m_box_formatting->get_formatting(m_layout_item->m_formatting);
 
128
 
 
129
  sharedptr<CustomTitle> title_custom = sharedptr<CustomTitle>::create();
 
130
  title_custom->set_use_custom_title(m_radiobutton_title_custom->get_active()); //For instance, tell it to really use a blank title.
 
131
  title_custom->set_title(m_entry_title_custom->get_text());
 
132
 
 
133
  m_layout_item->set_title_custom(title_custom);
 
134
 
 
135
  {
 
136
    double x = 0;
 
137
    double y = 0;
 
138
    double width, height;
 
139
    m_layout_item->get_print_layout_position(x, y, width, height);
 
140
    std::cout << "DEBUGDialog_FieldLayout::get_field_chosen2(): m_layout_item: x=" << x << std::endl;
 
141
  }
 
142
 
 
143
  return glom_sharedptr_clone(m_layout_item);
 
144
}
 
145
 
 
146
void Dialog_FieldLayout::on_radiobutton_custom_formatting()
 
147
{
 
148
  enforce_constraints();
 
149
}
 
150
 
 
151
void Dialog_FieldLayout::enforce_constraints()
 
152
{
 
153
  //Enable/Disable the custom formatting widgets:
 
154
  const bool custom = m_radiobutton_custom_formatting->get_active();
 
155
  m_box_formatting->set_sensitive(custom);
 
156
}
 
157
 
 
158
} //namespace Glom
 
159
 
 
160