diff options
author | Daniel_Burrows@alumni.brown.edu <Daniel_Burrows@alumni.brown.edu> | 2010-07-03 23:48:07 -0700 |
---|---|---|
committer | Daniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu> | 2010-07-03 23:49:22 -0700 |
commit | c286cba98a4c9c81c8b983d4593b6bfe5738c76b (patch) | |
tree | cab3bf9881a565d2eeb93340fa49c637c5b226fe /src | |
parent | b2aa333c7b9af41a0aa0122d9d976a4dee2be6ba (diff) | |
download | aptitude-c286cba98a4c9c81c8b983d4593b6bfe5738c76b.tar.gz |
Move the search input controller and view classes over to generic/.
As a side effect, this creates a "controllers" directory in the generic tree,
and removes the now-empty GTK+-specific controller and view directories.
The README files are moved over to the generic locations and tweaked to be
correct for their new home.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/generic/Makefile.am | 2 | ||||
-rw-r--r-- | src/generic/SConscript | 1 | ||||
-rw-r--r-- | src/generic/controllers/Makefile.am (renamed from src/gtk/controllers/Makefile.am) | 4 | ||||
-rw-r--r-- | src/generic/controllers/README (renamed from src/gtk/controllers/README) | 7 | ||||
-rw-r--r-- | src/generic/controllers/SConscript (renamed from src/gtk/controllers/SConscript) | 0 | ||||
-rw-r--r-- | src/generic/controllers/search_input.cc (renamed from src/gtk/controllers/search_input.cc) | 38 | ||||
-rw-r--r-- | src/generic/controllers/search_input.h (renamed from src/gtk/controllers/search_input.h) | 17 | ||||
-rw-r--r-- | src/generic/views/Makefile.am | 4 | ||||
-rw-r--r-- | src/generic/views/README (renamed from src/gtk/views/README) | 0 | ||||
-rw-r--r-- | src/generic/views/SConscript | 2 | ||||
-rw-r--r-- | src/generic/views/mocks/search_input.h (renamed from src/gtk/views/mocks/search_input.h) | 19 | ||||
-rw-r--r-- | src/generic/views/search_input.cc (renamed from src/gtk/views/search_input.cc) | 2 | ||||
-rw-r--r-- | src/generic/views/search_input.h (renamed from src/gtk/views/search_input.h) | 18 | ||||
-rw-r--r-- | src/gtk/Makefile.am | 2 | ||||
-rw-r--r-- | src/gtk/SConscript | 2 | ||||
-rw-r--r-- | src/gtk/view-impls/README | 4 | ||||
-rw-r--r-- | src/gtk/view-impls/search_input_entry.cc | 28 | ||||
-rw-r--r-- | src/gtk/view-impls/search_input_entry.h | 7 | ||||
-rw-r--r-- | src/gtk/views/Makefile.am | 10 | ||||
-rw-r--r-- | src/gtk/views/SConscript | 10 | ||||
-rw-r--r-- | src/gtk/views/mocks/Makefile.am | 1 |
22 files changed, 90 insertions, 89 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bfec1786..8ec45e17 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ bin_PROGRAMS=aptitude LDADD=@LIBINTL@ $(MAYBE_LIBGTK) cmdline/libcmdline.a mine/libcmine.a \ generic/apt/libgeneric-apt.a generic/util/libgeneric-util.a \ generic/apt/matching/libgeneric-matching.a \ + generic/controllers/libgeneric-controllers.a \ generic/problemresolver/libgeneric-problemresolver.a \ generic/views/libgeneric-views.a diff --git a/src/generic/Makefile.am b/src/generic/Makefile.am index 7a5aec65..d741746f 100644 --- a/src/generic/Makefile.am +++ b/src/generic/Makefile.am @@ -1,3 +1,3 @@ MAINTAINERCLEANFILES=Makefile.in -SUBDIRS = util problemresolver apt views +SUBDIRS = apt controllers problemresolver util views diff --git a/src/generic/SConscript b/src/generic/SConscript index 9b19cf60..e434e8fa 100644 --- a/src/generic/SConscript +++ b/src/generic/SConscript @@ -3,6 +3,7 @@ programs_env.Dist('Makefile.am', 'SConscript') sub_srcs = SConscript(dirs = [ 'apt', + 'controllers', 'problemresolver', 'util', 'views', diff --git a/src/gtk/controllers/Makefile.am b/src/generic/controllers/Makefile.am index 9cbb48b4..36c3308d 100644 --- a/src/gtk/controllers/Makefile.am +++ b/src/generic/controllers/Makefile.am @@ -1,8 +1,8 @@ INCLUDES=-I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/intl -noinst_LIBRARIES = libgtk-controllers.a +noinst_LIBRARIES = libgeneric-controllers.a -libgtk_controllers_a_SOURCES = \ +libgeneric_controllers_a_SOURCES = \ search_input.cc \ search_input.h diff --git a/src/gtk/controllers/README b/src/generic/controllers/README index 959e3f24..9853700f 100644 --- a/src/gtk/controllers/README +++ b/src/generic/controllers/README @@ -20,12 +20,17 @@ creating new widget types has several benefits: GUI via an abstract interface, and the unit test could provide an implementation of this interface that is entirely non-interactive. +This directory, being in the generic section of the aptitude source +code, should not contain references to any UI-level objects. + For at least some of aptitude's code, 4) will require refactoring, which should be done opportunistically as usual. Controllers might provide an interface to the outside world; if so, they should declare that interface as an abstract class in their -header file, deriving from sigc::trackable. +header file, deriving from sigc::trackable. This reduces compile-time +build dependencies and allows the controller to be mocked out for +testing. Unlike views, controllers are implemented in this directory. This is because controllers are less likely to have multiple implementations, diff --git a/src/gtk/controllers/SConscript b/src/generic/controllers/SConscript index a428eab3..a428eab3 100644 --- a/src/gtk/controllers/SConscript +++ b/src/generic/controllers/SConscript diff --git a/src/gtk/controllers/search_input.cc b/src/generic/controllers/search_input.cc index dfd583bf..11c7bd06 100644 --- a/src/gtk/controllers/search_input.cc +++ b/src/generic/controllers/search_input.cc @@ -18,6 +18,7 @@ // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. +// Local includes: #include "search_input.h" #include <aptitude.h> @@ -25,12 +26,19 @@ #include <generic/apt/matching/parse.h> #include <generic/apt/matching/pattern.h> -#include <gtk/views/search_input.h> +#include <generic/views/search_input.h> +// System includes: #include <boost/format.hpp> #include <boost/make_shared.hpp> -namespace gui +#include <cwidget/generic/util/transcode.h> + +using cwidget::util::transcode; + +namespace views = aptitude::views; + +namespace aptitude { namespace controllers { @@ -48,7 +56,7 @@ namespace gui void search_input_changed(); /** \brief A signal emitted when the user searches for a package. */ - sigc::signal<void, Glib::ustring, cwidget::util::ref_ptr<aptitude::matching::pattern> > signal_activated; + sigc::signal<void, std::wstring, cwidget::util::ref_ptr<aptitude::matching::pattern> > signal_activated; public: // Only public for make_shared. @@ -64,15 +72,15 @@ namespace gui static boost::shared_ptr<search_input_impl> create(const boost::shared_ptr<views::search_input> &view); - Glib::ustring get_text() const; + std::wstring get_text() const; /** \brief Set the text of the view and emit a search * immediately. */ - void enter_text(const Glib::ustring &text); + void enter_text(const std::wstring &text); sigc::connection - connect_activated(const sigc::slot<void, Glib::ustring, cwidget::util::ref_ptr<aptitude::matching::pattern> > &slot); + connect_activated(const sigc::slot<void, std::wstring, cwidget::util::ref_ptr<aptitude::matching::pattern> > &slot); }; search_input_impl::search_input_impl(const boost::shared_ptr<views::search_input> &_view) @@ -89,8 +97,8 @@ namespace gui void search_input_impl::do_search() { - Glib::ustring search_term_u(view->get_search_text()); - std::string search_term(search_term_u); + const std::wstring search_term_w(view->get_search_text()); + const std::string search_term(transcode(search_term_w)); cwidget::util::ref_ptr<aptitude::matching::pattern> p; try { @@ -101,21 +109,21 @@ namespace gui std::string msg = (boost::format("%s: %s") % _("Parse error") % ex.errmsg()).str(); - view->set_error_message(msg); + view->set_error_message(transcode(msg)); return; } - view->set_error_message(""); - signal_activated(search_term_u, p); + view->set_error_message(std::wstring()); + signal_activated(search_term_w, p); } void search_input_impl::search_input_changed() { - const Glib::ustring limit(view->get_search_text()); + const std::wstring limit(view->get_search_text()); bool valid; try { - aptitude::matching::parse_with_errors(limit); + aptitude::matching::parse_with_errors(transcode(limit)); valid = true; } catch(aptitude::matching::MatchingException &) @@ -126,14 +134,14 @@ namespace gui view->set_input_validity(valid); } - void search_input_impl::enter_text(const Glib::ustring &text) + void search_input_impl::enter_text(const std::wstring &text) { view->set_search_text(text); do_search(); } sigc::connection - search_input_impl::connect_activated(const sigc::slot<void, Glib::ustring, cwidget::util::ref_ptr<aptitude::matching::pattern> > &slot) + search_input_impl::connect_activated(const sigc::slot<void, std::wstring, cwidget::util::ref_ptr<aptitude::matching::pattern> > &slot) { return signal_activated.connect(slot); } diff --git a/src/gtk/controllers/search_input.h b/src/generic/controllers/search_input.h index dddedb91..5e3d0591 100644 --- a/src/gtk/controllers/search_input.h +++ b/src/generic/controllers/search_input.h @@ -18,15 +18,13 @@ // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -#ifndef APTITUDE_GTK_CONTROLLERS_SEARCH_INPUT_H -#define APTITUDE_GTK_CONTROLLERS_SEARCH_INPUT_H +#ifndef APTITUDE_CONTROLLERS_SEARCH_INPUT_H +#define APTITUDE_CONTROLLERS_SEARCH_INPUT_H #include <boost/shared_ptr.hpp> #include <cwidget/generic/util/ref_ptr.h> -#include <glibmm/ustring.h> - #include <sigc++/connection.h> #include <sigc++/slot.h> #include <sigc++/trackable.h> @@ -37,10 +35,7 @@ namespace aptitude { class pattern; } -} -namespace gui -{ namespace views { class search_input; @@ -66,7 +61,7 @@ namespace gui * tabs. It might be better to incorporate it into * create_search_input(). */ - virtual void enter_text(const Glib::ustring &text) = 0; + virtual void enter_text(const std::wstring &text) = 0; /** \brief Register a slot to be invoked when a search should be * performed. @@ -75,7 +70,7 @@ namespace gui * user and a search pattern parsed from that text. */ virtual sigc::connection - connect_activated(const sigc::slot<void, Glib::ustring, cwidget::util::ref_ptr<aptitude::matching::pattern> > & + connect_activated(const sigc::slot<void, std::wstring, cwidget::util::ref_ptr<aptitude::matching::pattern> > & slot) = 0; }; @@ -88,8 +83,8 @@ namespace gui * \return A search input controller attached to the given view. */ boost::shared_ptr<search_input> - create_search_input(const boost::shared_ptr<views::search_input> &view); + create_search_input(const boost::shared_ptr<aptitude::views::search_input> &view); } } -#endif // APTITUDE_GTK_SEARCH_INPUT_H +#endif // APTITUDE_CONTROLLERS_SEARCH_INPUT_H diff --git a/src/generic/views/Makefile.am b/src/generic/views/Makefile.am index 02c15271..9891ce75 100644 --- a/src/generic/views/Makefile.am +++ b/src/generic/views/Makefile.am @@ -5,4 +5,6 @@ libgeneric_views_a_SOURCES = \ download_progress.cc \ download_progress.h \ progress.cc \ - progress.h + progress.h \ + search_input.cc \ + search_input.h diff --git a/src/gtk/views/README b/src/generic/views/README index bccf1fc1..bccf1fc1 100644 --- a/src/gtk/views/README +++ b/src/generic/views/README diff --git a/src/generic/views/SConscript b/src/generic/views/SConscript index efefe65b..8c5a3a7b 100644 --- a/src/generic/views/SConscript +++ b/src/generic/views/SConscript @@ -5,6 +5,8 @@ srcs = map(File, [ 'download_progress.h', 'progress.cc', 'progress.h', + 'search_input.cc', + 'search_input.h' ]) programs_env.Dist('Makefile.am', 'README', 'SConscript') diff --git a/src/gtk/views/mocks/search_input.h b/src/generic/views/mocks/search_input.h index f70a0b5e..4e0fa59f 100644 --- a/src/gtk/views/mocks/search_input.h +++ b/src/generic/views/mocks/search_input.h @@ -17,13 +17,16 @@ // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -#ifndef APTITUDE_GTK_VIEWS_MOCKS_SEARCH_INPUT_H -#define APTITUDE_GTK_VIEWS_MOCKS_SEARCH_INPUT_H +#ifndef APTITUDE_VIEWS_MOCKS_SEARCH_INPUT_H +#define APTITUDE_VIEWS_MOCKS_SEARCH_INPUT_H +// Local includes: +#include <generic/views/search_input.h> + +// System includes: #include <gmock/gmock.h> -#include <gtk/views/search_input.h> -namespace gui +namespace aptitude { namespace views { @@ -38,9 +41,9 @@ namespace gui class search_input : public views::search_input { public: - MOCK_METHOD0(get_search_text, Glib::ustring()); - MOCK_METHOD1(set_search_text, void(const Glib::ustring &)); - MOCK_METHOD1(set_error_message, void(const Glib::ustring &)); + MOCK_METHOD0(get_search_text, std::wstring()); + MOCK_METHOD1(set_search_text, void(const std::wstring &)); + MOCK_METHOD1(set_error_message, void(const std::wstring &)); MOCK_METHOD1(set_input_validity, void(bool)); MOCK_METHOD1(set_find_sensitivity, void(bool)); MOCK_METHOD1(connect_search_text_changed, sigc::connection(const sigc::slot<void> &)); @@ -67,4 +70,4 @@ namespace gui } } -#endif // APTITUDE_GTK_VIEWS_MOCKS_SEARCH_INPUT_H +#endif // APTITUDE_VIEWS_MOCKS_SEARCH_INPUT_H diff --git a/src/gtk/views/search_input.cc b/src/generic/views/search_input.cc index 931d27cf..a9ae7de2 100644 --- a/src/gtk/views/search_input.cc +++ b/src/generic/views/search_input.cc @@ -20,7 +20,7 @@ #include "search_input.h" -namespace gui +namespace aptitude { namespace views { diff --git a/src/gtk/views/search_input.h b/src/generic/views/search_input.h index 9e0b0a5d..736080b4 100644 --- a/src/gtk/views/search_input.h +++ b/src/generic/views/search_input.h @@ -17,16 +17,16 @@ // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -#ifndef APTITUDE_GTK_VIEWS_SEARCH_INPUT_H -#define APTITUDE_GTK_VIEWS_SEARCH_INPUT_H - -#include <glibmm/ustring.h> +#ifndef APTITUDE_GENERIC_VIEWS_SEARCH_INPUT_H +#define APTITUDE_GENERIC_VIEWS_SEARCH_INPUT_H #include <sigc++/connection.h> #include <sigc++/slot.h> #include <sigc++/trackable.h> -namespace gui +#include <string> + +namespace aptitude { namespace views { @@ -36,7 +36,7 @@ namespace gui virtual ~search_input(); /** \brief Retrieve the input. */ - virtual Glib::ustring get_search_text() = 0; + virtual std::wstring get_search_text() = 0; /** \brief Set the input. * @@ -45,13 +45,13 @@ namespace gui * * Should trigger the text_changed signal as a side-effect. */ - virtual void set_search_text(const Glib::ustring &text) = 0; + virtual void set_search_text(const std::wstring &text) = 0; /** \brief Set the currently displayed error message. * * \param msg The new message (blank to display no message). */ - virtual void set_error_message(const Glib::ustring &msg) = 0; + virtual void set_error_message(const std::wstring &msg) = 0; /** \brief Indicate visually whether the current text is valid, * without necessarily displaying an error message. @@ -86,4 +86,4 @@ namespace gui } } -#endif // APTITUDE_GTK_VIEWS_SEARCH_INPUT_H +#endif // APTITUDE_GENERIC_VIEWS_SEARCH_INPUT_H diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am index 3943f62c..61a06a5a 100644 --- a/src/gtk/Makefile.am +++ b/src/gtk/Makefile.am @@ -1,10 +1,8 @@ INCLUDES=-I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/intl SUBDIRS = \ - controllers \ toplevel \ util \ - views \ view-impls noinst_LIBRARIES=libgtk.a diff --git a/src/gtk/SConscript b/src/gtk/SConscript index eba5f795..23e456e6 100644 --- a/src/gtk/SConscript +++ b/src/gtk/SConscript @@ -61,11 +61,9 @@ toplevel_srcs = map(File, [ ]) sub_srcs = SConscript(dirs = [ - 'controllers', 'toplevel', 'util', 'view-impls', - 'views', ]) srcs = (toplevel_srcs, sub_srcs) diff --git a/src/gtk/view-impls/README b/src/gtk/view-impls/README index 5a991189..3abe1a72 100644 --- a/src/gtk/view-impls/README +++ b/src/gtk/view-impls/README @@ -1,2 +1,2 @@ -This directory contains concrete implementations of the view -interfaces defined in <gtk/view>.
\ No newline at end of file +This directory contains concrete implementations of the view interfaces +defined in <generic/view> that are used by the GTK+ frontend. diff --git a/src/gtk/view-impls/search_input_entry.cc b/src/gtk/view-impls/search_input_entry.cc index cf610cb5..9cbcbeb0 100644 --- a/src/gtk/view-impls/search_input_entry.cc +++ b/src/gtk/view-impls/search_input_entry.cc @@ -18,19 +18,25 @@ // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. +// Local includes: #include "search_input_entry.h" -#include <gtk/views/search_input.h> +#include <generic/views/search_input.h> +// System includes: #include <boost/make_shared.hpp> +#include <cwidget/generic/util/transcode.h> + +using cwidget::util::transcode; + namespace gui { namespace view_impls { namespace { - class search_input_entry_impl : public views::search_input + class search_input_entry_impl : public aptitude::views::search_input { Gtk::Entry *search_entry; Gtk::Label *error_label; @@ -58,11 +64,11 @@ namespace gui Gtk::Label *error_label, Gtk::Button *find_button); - Glib::ustring get_search_text(); + std::wstring get_search_text(); - void set_search_text(const Glib::ustring &text); + void set_search_text(const std::wstring &text); - void set_error_message(const Glib::ustring &msg); + void set_error_message(const std::wstring &msg); void set_input_validity(bool valid); @@ -93,23 +99,23 @@ namespace gui find_button); } - Glib::ustring search_input_entry_impl::get_search_text() + std::wstring search_input_entry_impl::get_search_text() { - return search_entry->get_text(); + return transcode(std::string(search_entry->get_text()), "UTF-8"); } - void search_input_entry_impl::set_search_text(const Glib::ustring &text) + void search_input_entry_impl::set_search_text(const std::wstring &text) { - search_entry->set_text(text); + search_entry->set_text(transcode(text, "UTF-8")); } - void search_input_entry_impl::set_error_message(const Glib::ustring &msg) + void search_input_entry_impl::set_error_message(const std::wstring &msg) { if(!msg.empty()) { Glib::ustring markup = Glib::ustring::compose("<span size=\"smaller\" color=\"red\">%1</span>", - Glib::Markup::escape_text(msg)); + Glib::Markup::escape_text(transcode(msg, "UTF-8"))); error_label->set_markup(markup); error_label->show(); diff --git a/src/gtk/view-impls/search_input_entry.h b/src/gtk/view-impls/search_input_entry.h index 8eeb3058..bc80fc84 100644 --- a/src/gtk/view-impls/search_input_entry.h +++ b/src/gtk/view-impls/search_input_entry.h @@ -26,13 +26,16 @@ #include <gtkmm/entry.h> #include <gtkmm/label.h> -namespace gui +namespace aptitude { namespace views { class search_input; } +} +namespace gui +{ namespace view_impls { /** \brief Create a search input view based on a text entry @@ -42,7 +45,7 @@ namespace gui * \param error_label The label in which to display error messages. * \param find_button A button that the user can use to perform a search. */ - boost::shared_ptr<views::search_input> + boost::shared_ptr<aptitude::views::search_input> create_search_input_entry(Gtk::Entry *search_entry, Gtk::Label *error_label, Gtk::Button *find_button); diff --git a/src/gtk/views/Makefile.am b/src/gtk/views/Makefile.am deleted file mode 100644 index 4192a2ad..00000000 --- a/src/gtk/views/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -INCLUDES=-I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src -I$(top_srcdir)/intl -SUBDIRS = mocks - -noinst_LIBRARIES = libgtk-views.a - -libgtk_views_a_SOURCES = \ - search_input.cc \ - search_input.h - -EXTRA_DIST = README SConscript
\ No newline at end of file diff --git a/src/gtk/views/SConscript b/src/gtk/views/SConscript deleted file mode 100644 index a428eab3..00000000 --- a/src/gtk/views/SConscript +++ /dev/null @@ -1,10 +0,0 @@ -Import('programs_env') - -srcs = map(File, [ - 'search_input.cc', - 'search_input.h', - ]) - -programs_env.Dist('Makefile.am', 'README', 'SConscript') - -Return('srcs') diff --git a/src/gtk/views/mocks/Makefile.am b/src/gtk/views/mocks/Makefile.am deleted file mode 100644 index b693a5de..00000000 --- a/src/gtk/views/mocks/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = search_input.h |