From 343426ddc3998dc46ca92d433c2ac842169331b1 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 16 Apr 2015 14:50:21 -0400 Subject: [PATCH] gui: Tab labels should inherit from common type This allows me to pass a pointer to the generic type to be used by other classes. Signed-off-by: Anna Schumaker --- gui/queue/label.cpp | 37 +++++++++++++++++-------------------- include/gui/queue/label.h | 30 ++++++++++++------------------ 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/gui/queue/label.cpp b/gui/queue/label.cpp index d37409c0..c6f420fc 100644 --- a/gui/queue/label.cpp +++ b/gui/queue/label.cpp @@ -4,39 +4,40 @@ #include -CollectionLabel :: CollectionLabel(BaseObjectType *cobject, - const Glib::RefPtr builder) + +QueueLabel :: QueueLabel(BaseObjectType *cobject, + const Glib::RefPtr builder) : Gtk::HBox(cobject), _builder(builder) { - _builder->get_widget("collection_size", collection_size); } -CollectionLabel :: ~CollectionLabel() +QueueLabel :: ~QueueLabel() { } +CollectionLabel :: CollectionLabel(BaseObjectType *cobject, + const Glib::RefPtr builder) + : QueueLabel(cobject, builder) +{ + _builder->get_widget("collection_size", collection_size); +} + + + HistoryLabel :: HistoryLabel(BaseObjectType *cobject, const Glib::RefPtr builder) - : Gtk::HBox(cobject), _builder(builder) + : QueueLabel(cobject, builder) { _builder->get_widget("history_size", history_size); } -HistoryLabel :: ~HistoryLabel() -{ -} - PlaylistLabel :: PlaylistLabel(BaseObjectType *cobject, - const Glib::RefPtr builder) - : Gtk::HBox(cobject), _builder(builder) -{ -} - -PlaylistLabel :: ~PlaylistLabel() + const Glib::RefPtr builder) + : QueueLabel(cobject, builder) { } @@ -44,13 +45,9 @@ PlaylistLabel :: ~PlaylistLabel() TempLabel :: TempLabel(BaseObjectType *cobject, const Glib::RefPtr builder) - : Gtk::HBox(cobject), _builder(builder) + : QueueLabel(cobject, builder) { _builder->get_widget("temp_number", temp_number); _builder->get_widget("temp_size", temp_size); _builder->get_widget("temp_close", temp_close); } - -TempLabel :: ~TempLabel() -{ -} diff --git a/include/gui/queue/label.h b/include/gui/queue/label.h index 33fb023a..d5cee273 100644 --- a/include/gui/queue/label.h +++ b/include/gui/queue/label.h @@ -7,54 +7,48 @@ #include -class CollectionLabel : public Gtk::HBox { -private: +class QueueLabel : public Gtk::HBox { +protected: Glib::RefPtr _builder; +public: + QueueLabel(BaseObjectType *, const Glib::RefPtr); + ~QueueLabel(); +}; + + +class CollectionLabel : public QueueLabel { public: Gtk::Label *collection_size; CollectionLabel(BaseObjectType *, const Glib::RefPtr); - ~CollectionLabel(); }; -class HistoryLabel : public Gtk::HBox { -private: - Glib::RefPtr _builder; - +class HistoryLabel : public QueueLabel { public: Gtk::Label *history_size; HistoryLabel(BaseObjectType *, const Glib::RefPtr); - ~HistoryLabel(); }; -class PlaylistLabel : public Gtk::HBox { -private: - Glib::RefPtr _builder; - +class PlaylistLabel : public QueueLabel { public: PlaylistLabel(BaseObjectType *, const Glib::RefPtr); - ~PlaylistLabel(); }; -class TempLabel : public Gtk::HBox { -private: - Glib::RefPtr _builder; - +class TempLabel : public QueueLabel { public: Gtk::Label *temp_number; Gtk::Label *temp_size; Gtk::Button *temp_close; TempLabel(BaseObjectType *, const Glib::RefPtr); - ~TempLabel(); }; #endif /* OCARINA_GUI_QUEUE_LABEL_H */