[niepce: 1/4] * Tweak UI files. Don't hardcode the list of them
- From: Hubert Figuiere <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce: 1/4] * Tweak UI files. Don't hardcode the list of them
- Date: Mon, 9 Mar 2009 02:47:15 -0400 (EDT)
commit 90d3199f593024fbfa61ac27b20d848b0299ec8a
Author: Hubert Figuiere <hub figuiere net>
Date: Sat Mar 7 14:25:01 2009 -0500
* Tweak UI files. Don't hardcode the list of themes
available in the application.
* More Gtk utilities for ComboBox and TreeModel.
* Update POTFILES lists.
---
ChangeLog | 7 ++
po/POTFILES.in | 3 +-
po/POTFILES.skip | 3 +-
src/fwk/toolkit/application.hpp | 2 +-
src/fwk/toolkit/gtkutils.cpp | 19 +++++-
src/fwk/toolkit/gtkutils.hpp | 24 ++++++++-
src/niepce/ui/dialogs/importdialog.cpp | 10 +--
src/niepce/ui/dialogs/importdialog.hpp | 3 +-
src/niepce/ui/dialogs/importdialog.ui | 47 +++++++++++-----
src/niepce/ui/dialogs/preferences.ui | 82 +++++++++++---------------
src/niepce/ui/dialogs/preferencesdialog.cpp | 39 ++++++-------
src/niepce/ui/dialogs/preferencesdialog.hpp | 2 +
12 files changed, 143 insertions(+), 98 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2dd5728..a2360dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-03-07 Hubert Figuiere <hub figuiere net>
+
+ * Tweak UI files. Don't hardcode the list of themes
+ available in the application.
+ * More Gtk utilities for ComboBox and TreeModel.
+ * Update POTFILES lists.
+
2009-03-06 Hubert Figuiere <hub figuiere net>
* Dialog framework. Move the dialogs in their subdir
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 742d872..6a8f731 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,11 +2,12 @@ src/fwk/toolkit/metadatawidget.cpp
src/fwk/toolkit/application.cpp
src/niepce/ui/dialogs/importdialog.cpp
src/niepce/ui/dialogs/importdialog.ui
+src/niepce/ui/dialogs/preferences.ui
+src/niepce/ui/dialogs/preferencesdialog.cpp
src/niepce/ui/librarymainviewcontroller.cpp
src/niepce/ui/metadatapanecontroller.cpp
src/niepce/ui/niepceapplication.cpp
src/niepce/ui/niepcewindow.cpp
-src/niepce/ui/preferences.ui
src/niepce/ui/selectioncontroller.cpp
src/niepce/ui/workspacecontroller.cpp
src/niepce/ui/thumb-view/eog-thumb-view.cpp
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 921a659..dc8ee27 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,3 +1,2 @@
src/niepce/ui/dialogs/importdialog.glade
-src/niepce/ui/preferences.glade
-
+src/niepce/ui/dialogs/preferences.glade
diff --git a/src/fwk/toolkit/application.hpp b/src/fwk/toolkit/application.hpp
index aa69b7b..69f4e6e 100644
--- a/src/fwk/toolkit/application.hpp
+++ b/src/fwk/toolkit/application.hpp
@@ -39,7 +39,7 @@ class Application
{
public:
typedef boost::shared_ptr<Application> Ptr;
- typedef std::pair<Glib::ustring, std::string> ThemeDesc;
+ typedef std::pair<std::string, std::string> ThemeDesc;
virtual ~Application();
diff --git a/src/fwk/toolkit/gtkutils.cpp b/src/fwk/toolkit/gtkutils.cpp
index cdf543a..3e0adb5 100644
--- a/src/fwk/toolkit/gtkutils.cpp
+++ b/src/fwk/toolkit/gtkutils.cpp
@@ -23,13 +23,26 @@
namespace fwk {
-void TextTreeviewModel::inject(Gtk::TreeView & treeview)
+Glib::RefPtr<Gtk::ListStore>
+TextTreeviewModel::inject(Gtk::TreeView & treeview)
{
- treeview.set_model(Gtk::ListStore::create(*this));
- treeview.append_column("", m_col1);
+ Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*this);
+ treeview.set_model(model);
+ treeview.append_column("text", m_col1);
+ return model;
}
+Glib::RefPtr<Gtk::ListStore>
+TextPairTreeviewModel::inject(Gtk::ComboBox & combo)
+{
+ Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*this);
+ combo.set_model(model);
+ static_cast<Gtk::CellLayout&>(combo).clear();
+ combo.pack_start(m_col1);
+ return model;
+}
+
}
/*
Local Variables:
diff --git a/src/fwk/toolkit/gtkutils.hpp b/src/fwk/toolkit/gtkutils.hpp
index f6af9b4..c1f10be 100644
--- a/src/fwk/toolkit/gtkutils.hpp
+++ b/src/fwk/toolkit/gtkutils.hpp
@@ -23,6 +23,7 @@
#include <string>
#include <gtkmm/treeview.h>
+#include <gtkmm/combobox.h>
namespace fwk {
@@ -35,11 +36,32 @@ public:
{ add(m_col1); }
/** "inject" the model to the TreeView */
- void inject(Gtk::TreeView & treeview);
+ Glib::RefPtr<Gtk::ListStore> inject(Gtk::TreeView & treeview);
+ /** "inject" the model to the ComboBox */
+ Glib::RefPtr<Gtk::ListStore> inject(Gtk::ComboBox & combox);
Gtk::TreeModelColumn<std::string> m_col1;
};
+class TextPairTreeviewModel
+ : public Gtk::TreeModelColumnRecord
+{
+public:
+ TextPairTreeviewModel()
+ {
+ add(m_col1);
+ add(m_col2);
+ }
+
+ /** "inject" the model to the TreeView */
+ Glib::RefPtr<Gtk::ListStore> inject(Gtk::TreeView & treeview);
+ /** "inject" the model to the ComboBox */
+ Glib::RefPtr<Gtk::ListStore> inject(Gtk::ComboBox & combox);
+
+ Gtk::TreeModelColumn<std::string> m_col1;
+ Gtk::TreeModelColumn<std::string> m_col2;
+};
+
}
diff --git a/src/niepce/ui/dialogs/importdialog.cpp b/src/niepce/ui/dialogs/importdialog.cpp
index 7d213b7..2ef1844 100644
--- a/src/niepce/ui/dialogs/importdialog.cpp
+++ b/src/niepce/ui/dialogs/importdialog.cpp
@@ -64,7 +64,7 @@ void ImportDialog::setup_widget()
_builder->get_widget("rawstudio_import_check", m_rawstudio_import_check);
_builder->get_widget("directory_name", m_directory_name);
_builder->get_widget("folderList", m_folderList);
- m_folderListModel.inject(*m_folderList);
+ m_folderListModel = m_folderListModelRecord.inject(*m_folderList);
m_is_setup = true;
}
@@ -100,14 +100,12 @@ void ImportDialog::do_select_directories()
void ImportDialog::set_to_import(const Glib::SListHandle<Glib::ustring> & l)
{
m_list_to_import = l;
- Glib::RefPtr<Gtk::ListStore> store
- = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(m_folderList->get_model());
- store->clear();
+ m_folderListModel->clear();
for(std::list<std::string>::const_iterator i = m_list_to_import.begin();
i != m_list_to_import.end(); ++i) {
DBG_OUT("selected %s", i->c_str());
- Gtk::TreeIter iter = store->append();
- iter->set_value(m_folderListModel.m_col1, *i);
+ Gtk::TreeIter iter = m_folderListModel->append();
+ iter->set_value(m_folderListModelRecord.m_col1, *i);
}
}
diff --git a/src/niepce/ui/dialogs/importdialog.hpp b/src/niepce/ui/dialogs/importdialog.hpp
index 9210d35..c7da239 100644
--- a/src/niepce/ui/dialogs/importdialog.hpp
+++ b/src/niepce/ui/dialogs/importdialog.hpp
@@ -68,7 +68,8 @@ private:
Gtk::CheckButton *m_rawstudio_import_check;
Gtk::Label *m_directory_name;
Gtk::TreeView *m_folderList;
- fwk::TextTreeviewModel m_folderListModel;
+ fwk::TextTreeviewModel m_folderListModelRecord;
+ Glib::RefPtr<Gtk::ListStore> m_folderListModel;
};
}
diff --git a/src/niepce/ui/dialogs/importdialog.ui b/src/niepce/ui/dialogs/importdialog.ui
index c8a099f..63089a6 100644
--- a/src/niepce/ui/dialogs/importdialog.ui
+++ b/src/niepce/ui/dialogs/importdialog.ui
@@ -1,7 +1,10 @@
<?xml version="1.0"?>
<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkListStore" id="model1">
<columns>
+ <!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
@@ -17,8 +20,10 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Import</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="default_width">300</property>
+ <property name="default_height">300</property>
+ <property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox2">
@@ -42,6 +47,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -56,10 +62,11 @@
</child>
<child>
<object class="GtkButton" id="select_directories">
+ <property name="label" translatable="yes">...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="receives_default">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">...</property>
</object>
<packing>
<property name="expand">False</property>
@@ -69,6 +76,7 @@
</object>
<packing>
<property name="expand">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -89,8 +97,8 @@
<object class="GtkScrolledWindow" id="scroller1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="folderList">
<property name="visible">True</property>
@@ -113,23 +121,26 @@
<property name="visible">True</property>
<child>
<object class="GtkCheckButton" id="ufraw_import_check">
+ <property name="label" translatable="yes">Import _UFRaw</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Import _UFRaw</property>
+ <property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="rawstudio_import_check">
+ <property name="label" translatable="yes">Import Raw_Studio</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Import Raw_Studio</property>
+ <property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@@ -143,7 +154,7 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="shadow_type">in</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
@@ -153,8 +164,8 @@
<object class="GtkComboBox" id="date_tz_combo">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="active">0</property>
<property name="model">model1</property>
+ <property name="active">0</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
@@ -162,6 +173,9 @@
</attributes>
</child>
</object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<object class="GtkLabel" id="label5">
@@ -215,24 +229,28 @@
<object class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button3">
+ <property name="label" translatable="yes">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<object class="GtkButton" id="button4">
+ <property name="label" translatable="yes">_Import</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="label" translatable="yes">_Import</property>
- <property name="use_underline">True</property>
<property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="position">1</property>
@@ -241,7 +259,8 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
diff --git a/src/niepce/ui/dialogs/preferences.ui b/src/niepce/ui/dialogs/preferences.ui
index da19af1..078c624 100644
--- a/src/niepce/ui/dialogs/preferences.ui
+++ b/src/niepce/ui/dialogs/preferences.ui
@@ -1,24 +1,14 @@
<?xml version="1.0"?>
-<!--*- mode: xml -*-->
<interface>
- <object class="GtkListStore" id="model1">
- <columns>
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0">System</col>
- </row>
- <row>
- <col id="0">Dark</col>
- </row>
- </data>
- </object>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="preferences">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="default_width">400</property>
+ <property name="default_height">300</property>
+ <property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
@@ -38,24 +28,25 @@
<property name="column_spacing">12</property>
<property name="row_spacing">12</property>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkCheckButton" id="reopen_checkbutton">
+ <property name="label" translatable="yes">_Reopen Library</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">_Reopen Library</property>
+ <property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="right_attach">2</property>
- <property name="y_options"/>
+ <property name="y_options"></property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
<child type="tab">
@@ -72,28 +63,10 @@
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="border_width">12</property>
- <property name="n_rows">1</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">12</property>
<child>
- <object class="GtkComboBox" id="theme_combo">
- <property name="visible">True</property>
- <property name="model">model1</property>
- <child>
- <object class="GtkCellRendererText" id="renderer1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
@@ -103,10 +76,24 @@
</object>
<packing>
<property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="theme_combo">
+ <property name="visible">True</property>
+ <property name="active">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label2">
@@ -128,16 +115,17 @@
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="button1">
+ <property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="label">gtk-close</property>
+ <property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -147,13 +135,13 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
- <action-widget response="0">reopen_checkbutton</action-widget>
<action-widget response="0">button1</action-widget>
</action-widgets>
</object>
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
index ae91bfd..fa29517 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.cpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -19,11 +19,14 @@
#include <boost/bind.hpp>
+#include <glibmm/i18n.h>
#include <gtkmm/combobox.h>
+#include <gtkmm/liststore.h>
#include <gtkmm/checkbutton.h>
#include "fwk/toolkit/configdatabinder.hpp"
#include "fwk/toolkit/application.hpp"
+#include "fwk/toolkit/gtkutils.hpp"
#include "preferencesdialog.hpp"
@@ -45,32 +48,24 @@ void PreferencesDialog::setup_widget()
builder()->get_widget("theme_combo", theme_combo);
-// Why are ComboBox so complicated to use?
-// class Columns :
-// public Gtk::TreeModel::ColumnRecord
-// {
-// public:
-// Gtk::TreeModelColumn<Glib::ustring> label;
-// Columns() { add(label); }
-// };
-
-// Columns columns;
-// Glib::RefPtr<Gtk::ListStore> model(Gtk::ListStore::create(columns));
+ Glib::RefPtr<Gtk::ListStore> model = m_theme_combo_model.inject(*theme_combo);
+
+ const std::vector<fwk::Application::ThemeDesc> & themes
+ = fwk::Application::app()->get_available_themes();
+ std::vector<fwk::Application::ThemeDesc>::const_iterator i;
+ for(i = themes.begin(); i != themes.end(); ++i) {
+ DBG_OUT("adding %s", i->first.c_str());
+ Gtk::TreeIter iter = model->append();
+ iter->set_value(m_theme_combo_model.m_col1, i->first);
+ iter->set_value(m_theme_combo_model.m_col2, i->second);
+ }
-// theme_combo->set_model(model);
-// const std::vector<fwk::Application::ThemeDesc> & themes = fwk::Application::app()->get_available_themes();
-// std::vector<fwk::Application::ThemeDesc>::const_iterator i;
-// for(i = themes.begin(); i != themes.end(); ++i) {
-// DBG_OUT("adding %s", i->first.c_str());
-// Gtk::TreeIter iter = model->append();
-// (*iter).set_value(columns.label, i->first);
-// }
theme_combo->set_active(fwk::Application::app()
->get_use_custom_theme());
theme_combo->signal_changed().connect(
- boost::bind(&fwk::Application::set_use_custom_theme,
- fwk::Application::app(),
- theme_combo->property_active()));
+ boost::bind(&fwk::Application::set_use_custom_theme,
+ fwk::Application::app(),
+ theme_combo->property_active()));
builder()->get_widget("reopen_checkbutton", reopen_checkbutton);
binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
diff --git a/src/niepce/ui/dialogs/preferencesdialog.hpp b/src/niepce/ui/dialogs/preferencesdialog.hpp
index ae48900..41f3488 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.hpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.hpp
@@ -34,6 +34,8 @@ public:
}
virtual void setup_widget();
+private:
+ fwk::TextPairTreeviewModel m_theme_combo_model;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]