2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-03-03 17:19:30 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2004-08-26 14:20:30 +00:00
|
|
|
* gimpviewrendererlayer.c
|
2003-03-03 17:19:30 +00:00
|
|
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-03-03 17:19:30 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-03-03 17:19:30 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-03-03 17:19:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2003-03-03 17:19:30 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2003-09-06 22:02:12 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2003-03-03 17:19:30 +00:00
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2009-08-27 22:24:53 +02:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
|
2003-09-06 22:02:12 +00:00
|
|
|
#include "text/gimptextlayer.h"
|
2003-03-03 17:19:30 +00:00
|
|
|
|
2004-08-26 14:20:30 +00:00
|
|
|
#include "gimpviewrendererlayer.h"
|
2003-03-03 17:19:30 +00:00
|
|
|
|
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static void gimp_view_renderer_layer_render (GimpViewRenderer *renderer,
|
|
|
|
GtkWidget *widget);
|
2003-03-03 17:19:30 +00:00
|
|
|
|
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
G_DEFINE_TYPE (GimpViewRendererLayer, gimp_view_renderer_layer,
|
2006-05-15 09:46:31 +00:00
|
|
|
GIMP_TYPE_VIEW_RENDERER_DRAWABLE)
|
2003-03-03 17:19:30 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
#define parent_class gimp_view_renderer_layer_parent_class
|
2003-03-03 17:19:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-08-26 14:20:30 +00:00
|
|
|
gimp_view_renderer_layer_class_init (GimpViewRendererLayerClass *klass)
|
2003-03-03 17:19:30 +00:00
|
|
|
{
|
2004-09-09 11:58:49 +00:00
|
|
|
GimpViewRendererClass *renderer_class = GIMP_VIEW_RENDERER_CLASS (klass);
|
2003-03-03 17:19:30 +00:00
|
|
|
|
2004-08-26 14:20:30 +00:00
|
|
|
renderer_class->render = gimp_view_renderer_layer_render;
|
2003-03-03 17:19:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static void
|
|
|
|
gimp_view_renderer_layer_init (GimpViewRendererLayer *renderer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-03-03 17:19:30 +00:00
|
|
|
static void
|
2004-08-26 14:20:30 +00:00
|
|
|
gimp_view_renderer_layer_render (GimpViewRenderer *renderer,
|
|
|
|
GtkWidget *widget)
|
2003-03-03 17:19:30 +00:00
|
|
|
{
|
2014-05-07 01:01:56 +02:00
|
|
|
const gchar *icon_name = NULL;
|
2003-03-03 17:19:30 +00:00
|
|
|
|
2003-09-06 22:02:12 +00:00
|
|
|
if (gimp_layer_is_floating_sel (GIMP_LAYER (renderer->viewable)))
|
|
|
|
{
|
2014-05-07 01:01:56 +02:00
|
|
|
icon_name = GIMP_STOCK_FLOATING_SELECTION;
|
2003-09-06 22:02:12 +00:00
|
|
|
}
|
2010-10-05 07:39:00 +02:00
|
|
|
else if (gimp_item_is_text_layer (GIMP_ITEM (renderer->viewable)))
|
2003-09-06 22:02:12 +00:00
|
|
|
{
|
2014-05-07 01:01:56 +02:00
|
|
|
icon_name = gimp_viewable_get_icon_name (renderer->viewable);
|
2003-09-06 22:02:12 +00:00
|
|
|
}
|
2009-08-27 22:24:53 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpContainer *children = gimp_viewable_get_children (renderer->viewable);
|
|
|
|
|
|
|
|
if (children && gimp_container_get_n_children (children) == 0)
|
2014-05-11 22:49:22 +02:00
|
|
|
icon_name = "folder";
|
2009-08-27 22:24:53 +02:00
|
|
|
}
|
2003-03-03 17:19:30 +00:00
|
|
|
|
2014-05-07 01:01:56 +02:00
|
|
|
if (icon_name)
|
|
|
|
gimp_view_renderer_render_icon (renderer, widget, icon_name);
|
2003-09-06 22:02:12 +00:00
|
|
|
else
|
2004-08-25 22:31:44 +00:00
|
|
|
GIMP_VIEW_RENDERER_CLASS (parent_class)->render (renderer, widget);
|
2003-03-03 17:19:30 +00:00
|
|
|
}
|