Blame plugins/gtk+/glade-recent-chooser-editor.c

Packit 1e8aac
/*
Packit 1e8aac
 * Copyright (C) 2013 Tristan Van Berkom.
Packit 1e8aac
 *
Packit 1e8aac
 * This library is free software; you can redistribute it and/or modify it
Packit 1e8aac
 * under the terms of the GNU Lesser General Public License as
Packit 1e8aac
 * published by the Free Software Foundation; either version 2.1 of
Packit 1e8aac
 * the License, or (at your option) any later version.
Packit 1e8aac
 *
Packit 1e8aac
 * This library is distributed in the hope that it will be useful, but
Packit 1e8aac
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1e8aac
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 1e8aac
 * Lesser General Public License for more details.
Packit 1e8aac
 *
Packit 1e8aac
 * You should have received a copy of the GNU Lesser General Public 
Packit 1e8aac
 * License along with this program; if not, write to the Free Software
Packit 1e8aac
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 1e8aac
 *
Packit 1e8aac
 * Authors:
Packit 1e8aac
 *   Tristan Van Berkom <tvb@gnome.org>
Packit 1e8aac
 */
Packit 1e8aac
Packit 1e8aac
#include <config.h>
Packit 1e8aac
#include <gladeui/glade.h>
Packit 1e8aac
#include <glib/gi18n-lib.h>
Packit 1e8aac
Packit 1e8aac
#include "glade-recent-chooser-editor.h"
Packit 1e8aac
Packit 1e8aac
static void glade_recent_chooser_editor_editable_init (GladeEditableIface * iface);
Packit 1e8aac
Packit 1e8aac
struct _GladeRecentChooserEditorPrivate {
Packit 1e8aac
  GtkWidget *select_multiple_editor;
Packit 1e8aac
  GtkWidget *show_numbers_editor;
Packit 1e8aac
};
Packit 1e8aac
Packit 1e8aac
static GladeEditableIface *parent_editable_iface;
Packit 1e8aac
Packit 1e8aac
G_DEFINE_TYPE_WITH_CODE (GladeRecentChooserEditor, glade_recent_chooser_editor, GLADE_TYPE_EDITOR_SKELETON,
Packit 1e8aac
                         G_ADD_PRIVATE (GladeRecentChooserEditor)
Packit 1e8aac
                         G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
Packit 1e8aac
                                                glade_recent_chooser_editor_editable_init));
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_recent_chooser_editor_class_init (GladeRecentChooserEditorClass * klass)
Packit 1e8aac
{
Packit 1e8aac
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
Packit 1e8aac
Packit 1e8aac
  gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-recent-chooser-editor.ui");
Packit 1e8aac
Packit 1e8aac
  gtk_widget_class_bind_template_child_private (widget_class, GladeRecentChooserEditor, select_multiple_editor);
Packit 1e8aac
  gtk_widget_class_bind_template_child_private (widget_class, GladeRecentChooserEditor, show_numbers_editor);
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_recent_chooser_editor_init (GladeRecentChooserEditor * self)
Packit 1e8aac
{
Packit 1e8aac
  self->priv = glade_recent_chooser_editor_get_instance_private (self);
Packit 1e8aac
Packit 1e8aac
  gtk_widget_init_template (GTK_WIDGET (self));
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_recent_chooser_editor_load (GladeEditable *editable,
Packit 1e8aac
				  GladeWidget   *gwidget)
Packit 1e8aac
{
Packit 1e8aac
  GladeRecentChooserEditor *recent_editor = GLADE_RECENT_CHOOSER_EDITOR (editable);
Packit 1e8aac
  GladeRecentChooserEditorPrivate *priv = recent_editor->priv;
Packit 1e8aac
Packit 1e8aac
  /* Chain up to default implementation */
Packit 1e8aac
  parent_editable_iface->load (editable, gwidget);
Packit 1e8aac
Packit 1e8aac
  if (gwidget)
Packit 1e8aac
    {
Packit 1e8aac
      GObject *object = glade_widget_get_object (gwidget);
Packit 1e8aac
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 1e8aac
      gboolean has_show_numbers = (GTK_IS_RECENT_ACTION (object) || GTK_IS_RECENT_CHOOSER_MENU (object));
Packit 1e8aac
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 1e8aac
Packit 1e8aac
      /* Update subclass specific editor visibility */
Packit 1e8aac
      gtk_widget_set_visible (priv->select_multiple_editor, !has_show_numbers);
Packit 1e8aac
      gtk_widget_set_visible (priv->show_numbers_editor, has_show_numbers);
Packit 1e8aac
    }
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
static void
Packit 1e8aac
glade_recent_chooser_editor_editable_init (GladeEditableIface * iface)
Packit 1e8aac
{
Packit 1e8aac
  parent_editable_iface = g_type_interface_peek_parent (iface);
Packit 1e8aac
Packit 1e8aac
  iface->load = glade_recent_chooser_editor_load;
Packit 1e8aac
}
Packit 1e8aac
Packit 1e8aac
Packit 1e8aac
GtkWidget *
Packit 1e8aac
glade_recent_chooser_editor_new (void)
Packit 1e8aac
{
Packit 1e8aac
  return g_object_new (GLADE_TYPE_RECENT_CHOOSER_EDITOR, NULL);
Packit 1e8aac
}