Back to index

unity  6.0.0
FilterAllButton.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright 2011 Canonical Ltd.
00004  *
00005  * This program is free software: you can redistribute it and/or modify it
00006  * under the terms of the GNU Lesser General Public License version 3, as
00007  * published by the  Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License version 3 along with this program.  If not, see
00017  * <http://www.gnu.org/licenses/>
00018  *
00019  * Authored by: Andrea Azzarone <azzaronea@gmail.com>
00020  *
00021  */
00022 
00023 
00024 #include <glib.h>
00025 #include <glib/gi18n-lib.h>
00026 
00027 #include "FilterAllButton.h"
00028 
00029 namespace unity
00030 {
00031 namespace dash
00032 {
00033 
00034 FilterAllButton::FilterAllButton(NUX_FILE_LINE_DECL)
00035  : FilterBasicButton(_("All"), NUX_FILE_LINE_PARAM)
00036 {
00037   SetActive(true);
00038   SetInputEventSensitivity(false);
00039 
00040   state_change.connect(sigc::mem_fun(this, &FilterAllButton::OnStateChanged));
00041 }
00042 
00043 FilterAllButton::~FilterAllButton()
00044 {
00045 }
00046 
00047 void FilterAllButton::SetFilter(Filter::Ptr const& filter)
00048 {
00049   if (filtering_connection_.connected())
00050     filtering_connection_.disconnect();
00051 
00052   filter_ = filter;
00053   OnFilteringChanged(filter_->filtering); // Evil hack ;)
00054 
00055   filtering_connection_ = filter_->filtering.changed.connect(sigc::mem_fun(this, &FilterAllButton::OnFilteringChanged));
00056 }
00057 
00058 void FilterAllButton::OnStateChanged(nux::View* view)
00059 {
00060   if (filter_ and Active())
00061     filter_->Clear();
00062   QueueDraw();
00063 }
00064 
00065 void FilterAllButton::OnFilteringChanged(bool filtering)
00066 {
00067   SetActive(!filtering);
00068   SetInputEventSensitivity(filtering);
00069 }
00070 
00071 } // namespace dash
00072 } // namespace unity