# generic_view.py
#
# Copyright (C) 2017 Sascha Manns <saigkill@opensuse.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from gi.repository import Gtk, GObject, GLib, Gdk, Gio
from gettext import gettext as _
from gnomepublisher import log
import logging
logger = logging.getLogger(__name__)

class GenericView(Gtk.Stack):

    # __gsignals__ = {
    #     'open-article': (GObject.SignalFlags.RUN_FIRST, None, (GObject.GObject,)),
    # }

    @log
    def __init__(self, name, title=None):
        Gtk.Stack.__init__(self,
                           transition_type=Gtk.StackTransitionType.CROSSFADE)
        self.name = name
        self.title = title

        self._ui = Gtk.Builder()
        self._ui.add_from_resource('/org/gnome/Publisher/ui/empty-view.ui')

        # Setup the layout
        self.setup_layout()

        # Setup the Empty state view
        self._empty_view = self._ui.get_object('empty-view')
        self.add_named(self._empty_view, 'empty')

        #self.tracker = tracker
        self.show_all()

    @log
    def show_empty_view(self, show):
        if show:
            self.set_visible_child_name('empty')
        else:
            self.set_visible_child_name('view')

    @log
    def setup_layout(self):
        scrolledWindow = Gtk.ScrolledWindow()

        self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self._box.pack_end(self.flowbox, True, True, 0)
        scrolledWindow.add(self._box)

        self.add_named(scrolledWindow, 'view')

    @log
    def update(self):
        pass