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