Back to index

unity  6.0.0
FilterGenreButton.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Gordon Allott <gord.allott@canonical.com>
00019  *
00020  */
00021 
00022 #include "FilterGenreButton.h"
00023 
00024 namespace unity
00025 {
00026 namespace dash
00027 {
00028 
00029 FilterGenreButton::FilterGenreButton(std::string const& label, NUX_FILE_LINE_DECL)
00030   : FilterBasicButton(label, NUX_FILE_LINE_PARAM)
00031 {
00032   InitTheme();
00033 
00034   state_change.connect([&](nux::Button* button)
00035   {
00036     if (filter_)
00037       filter_->active = Active();
00038   });
00039 }
00040 
00041 FilterGenreButton::FilterGenreButton(NUX_FILE_LINE_DECL)
00042   : FilterBasicButton(NUX_FILE_LINE_PARAM)
00043 {
00044   InitTheme();
00045 
00046   state_change.connect([&](nux::Button* button)
00047   {
00048     if (filter_)
00049       filter_->active = Active();
00050   });
00051 }
00052 
00053 
00054 void FilterGenreButton::SetFilter(FilterOption::Ptr const& filter)
00055 {
00056   filter_ = filter;
00057 
00058   SetActive(filter_->active);
00059 
00060   filter_->active.changed.connect([&](bool is_active)
00061   {
00062     SetActive(is_active);
00063   });
00064 }
00065 
00066 FilterOption::Ptr FilterGenreButton::GetFilter()
00067 {
00068   return filter_;
00069 }
00070 
00071 } // namespace dash
00072 } // namespace unity