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

« back to all changes in this revision

Viewing changes to glom/translation/combobox_locale.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 "combobox_locale.h"
22
 
#include <gtk/gtkcomboboxentry.h>
23
 
#include <glom/libglom/data_structure/iso_codes.h>
24
 
 
25
 
namespace Glom
26
 
{
27
 
 
28
 
ComboBox_Locale::ComboBox_Locale(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& /* refGlade */)
29
 
: Gtk::ComboBox(cobject)
30
 
{
31
 
  m_model = Gtk::ListStore::create(m_model_columns);
32
 
 
33
 
  //Fill the model:
34
 
  const IsoCodes::type_list_locales list_locales = IsoCodes::get_list_of_locales();
35
 
  for(IsoCodes::type_list_locales::const_iterator iter = list_locales.begin(); iter != list_locales.end(); ++iter)
36
 
  {
37
 
    Gtk::TreeModel::iterator tree_iter = m_model->append();
38
 
    Gtk::TreeModel::Row row = *tree_iter;
39
 
 
40
 
    const IsoCodes::Locale& the_locale = *iter;
41
 
    row[m_model_columns.m_identifier] = the_locale.m_identifier;
42
 
    row[m_model_columns.m_name] = the_locale.m_name;
43
 
  }
44
 
 
45
 
  m_model->set_sort_column(m_model_columns.m_name, Gtk::SORT_ASCENDING);
46
 
 
47
 
  set_model(m_model);
48
 
 
49
 
  //Do not show the non-human-readable ID: pack_start(m_model_columns.m_identifier);
50
 
 
51
 
  //Show this too.
52
 
  //Create the cell renderer manually, so we can specify the alignment:
53
 
  Gtk::CellRendererText* cell = Gtk::manage(new Gtk::CellRendererText());
54
 
  cell->property_xalign() = 0.0f;
55
 
  pack_start(*cell);
56
 
  add_attribute(cell->property_text(), m_model_columns.m_name);
57
 
}
58
 
 
59
 
 
60
 
ComboBox_Locale::~ComboBox_Locale()
61
 
{
62
 
 
63
 
}
64
 
 
65
 
Glib::ustring ComboBox_Locale::get_selected_locale() const
66
 
{
67
 
  Gtk::TreeModel::iterator iter = get_active();
68
 
  if(iter)
69
 
  {
70
 
    Gtk::TreeModel::Row row = *iter;
71
 
    return row[m_model_columns.m_identifier];
72
 
  }
73
 
  else
74
 
    return Glib::ustring();
75
 
}
76
 
 
77
 
void ComboBox_Locale::set_selected_locale(const Glib::ustring& locale)
78
 
{
79
 
  //Look for the row with this text, and activate it:
80
 
  Glib::RefPtr<Gtk::TreeModel> model = get_model();
81
 
  if(model)
82
 
  {
83
 
    for(Gtk::TreeModel::iterator iter = model->children().begin(); iter != model->children().end(); ++iter)
84
 
    {
85
 
      const Glib::ustring& this_text = (*iter)[m_model_columns.m_identifier];
86
 
 
87
 
      if(this_text == locale)
88
 
      {
89
 
        set_active(iter);
90
 
        return; //success
91
 
      }
92
 
    }
93
 
  }
94
 
 
95
 
  //Not found, so mark it as blank:
96
 
  std::cerr << "ComboBox_Locale::set_selected_locale(): locale not found in list: " << locale << std::endl;
97
 
  unset_active();
98
 
}
99
 
 
100
 
} //namespace Glom
101