Fix runtime error
[geeqie.git] / src / renderer-clutter.c
index c0f3b10..3937275 100644 (file)
@@ -1,14 +1,22 @@
 /*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
- * Author: Vladimir Nadvornik
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * 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 2 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <stdio.h>
@@ -107,6 +115,8 @@ struct _RendererClutter
 
        gboolean clut_updated;
        gint64 last_pixbuf_change;
+
+       GdkPixbuf *display_pixbuf;
 };
 
 typedef struct _RendererClutterAreaParam RendererClutterAreaParam;
@@ -118,154 +128,6 @@ struct _RendererClutterAreaParam {
        gint h;
 };
 
-typedef struct _RendererClutterShaderInfo RendererClutterShaderInfo;
-struct _RendererClutterShaderInfo {
-       float checkersize;
-       float checkercolor0[3];
-       float checkercolor1[3];
-};
-
-#define CLUT_SIZE      32
-
-static void rc_set_shader(CoglHandle material, const RendererClutterShaderInfo *shaderInfo)
-{
-       CoglHandle shader;
-       CoglHandle program;
-       gint uniform_no;
-
-       shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
-       cogl_shader_source (shader,
-       "vec3 checker(vec2 texc, vec3 color0, vec3 color1)                                              \n"
-       "{                                                                                                                                              \n"
-       "  if (mod(floor(texc.x) + floor(texc.y), 2.0) == 0.0)                                  \n"
-       "    return color0;                                                                                                             \n"
-       "  else                                                                                                                                 \n"
-       "    return color1;                                                                                                             \n"
-       "}                                                                                                                                              \n"
-       "                                                                                                                                               \n"
-       "uniform sampler2D tex;                                                                                                 \n"
-       "uniform sampler3D clut;                                                                                                \n"
-       "uniform float scale;                                                                                                   \n"
-       "uniform float offset;                                                                                                  \n"
-       "uniform float checkersize;                                                                                             \n"
-       "uniform vec3 color0;                                                                                                   \n"
-       "uniform vec3 color1;                                                                                                   \n"
-       "                                                                                                                                               \n"
-       "void main(void)                                                                                                                \n"
-       "{                                                                                                                                              \n"
-       "    vec3 bg = checker(gl_FragCoord.xy / checkersize, color0, color1);  \n"
-       "    vec4 img4 = texture2D(tex, gl_TexCoord[0].xy);                                             \n"
-       "    vec3 img3 = img4.bgr;                                                                                              \n"
-       "    img3 = img3 * scale + offset;                                                                              \n"
-       "    img3 = texture3D(clut, img3).rgb;                                                                  \n"
-       "                                                                                                                                               \n"
-       "    gl_FragColor = vec4(img3 * img4.a + bg * (1.0 - img4.a), 1.0);             \n"
-       "}                                                                                                                                              \n"
-       );
-       cogl_shader_compile(shader);
-       gchar *err = cogl_shader_get_info_log(shader);
-       DEBUG_0("%s\n",err);
-       g_free(err);
-
-       program = cogl_create_program ();
-       cogl_program_attach_shader (program, shader);
-       cogl_handle_unref (shader);
-       cogl_program_link (program);
-
-       uniform_no = cogl_program_get_uniform_location (program, "tex");
-       cogl_program_set_uniform_1i (program, uniform_no, 0);
-
-       uniform_no = cogl_program_get_uniform_location (program, "clut");
-       cogl_program_set_uniform_1i (program, uniform_no, 1);
-
-       uniform_no = cogl_program_get_uniform_location (program, "scale");
-       cogl_program_set_uniform_1f (program, uniform_no, (double) (CLUT_SIZE - 1) / CLUT_SIZE);
-
-       uniform_no = cogl_program_get_uniform_location (program, "offset");
-       cogl_program_set_uniform_1f (program, uniform_no, 1.0 / (2 * CLUT_SIZE));
-
-       uniform_no = cogl_program_get_uniform_location (program, "checkersize");
-       cogl_program_set_uniform_1f (program, uniform_no, shaderInfo->checkersize);
-
-       uniform_no = cogl_program_get_uniform_location (program, "color0");
-       cogl_program_set_uniform_float (program, uniform_no, 3, 1, shaderInfo->checkercolor0);
-
-       uniform_no = cogl_program_get_uniform_location (program, "color1");
-       cogl_program_set_uniform_float (program, uniform_no, 3, 1, shaderInfo->checkercolor1);
-
-       cogl_material_set_user_program (material, program);
-       cogl_handle_unref (program);
-}
-
-
-static void rc_prepare_post_process_lut(RendererClutter *rc)
-{
-       PixbufRenderer *pr = rc->pr;
-       static guchar clut[CLUT_SIZE * CLUT_SIZE * CLUT_SIZE * 3];
-       guint r, g, b;
-       GdkPixbuf *tmp_pixbuf;
-       CoglHandle material;
-       CoglHandle tex3d;
-
-       DEBUG_0("%s clut start", get_exec_time());
-
-       for (r = 0; r < CLUT_SIZE; r++)
-               {
-               for (g = 0; g < CLUT_SIZE; g++)
-                       {
-                       for (b = 0; b < CLUT_SIZE; b++)
-                               {
-                               guchar *ptr = clut + ((b * CLUT_SIZE + g) * CLUT_SIZE + r) * 3;
-                               ptr[0] = floor ((double) r / (CLUT_SIZE - 1) * 255.0 + 0.5);
-                               ptr[1] = floor ((double) g / (CLUT_SIZE - 1) * 255.0 + 0.5);
-                               ptr[2] = floor ((double) b / (CLUT_SIZE - 1) * 255.0 + 0.5);
-                               }
-                       }
-               }
-       tmp_pixbuf = gdk_pixbuf_new_from_data(clut, GDK_COLORSPACE_RGB, FALSE, 8,
-                                             CLUT_SIZE * CLUT_SIZE,
-                                             CLUT_SIZE,
-                                             CLUT_SIZE * CLUT_SIZE * 3,
-                                             NULL, NULL);
-       if (pr->func_post_process)
-               {
-               pr->func_post_process(pr, &tmp_pixbuf, 0, 0, CLUT_SIZE * CLUT_SIZE, CLUT_SIZE, pr->post_process_user_data);
-               }
-       g_object_unref(tmp_pixbuf);
-
-       DEBUG_0("%s clut upload start", get_exec_time());
-#if CLUTTER_CHECK_VERSION(1,10,0)
-       {
-       CoglContext *ctx = clutter_backend_get_cogl_context(clutter_get_default_backend ());
-
-       tex3d = cogl_texture_3d_new_from_data(ctx,
-                                             CLUT_SIZE, CLUT_SIZE, CLUT_SIZE,
-                                             COGL_PIXEL_FORMAT_RGB_888,
-                                             COGL_PIXEL_FORMAT_RGB_888,
-                                             CLUT_SIZE * 3,
-                                             CLUT_SIZE * CLUT_SIZE * 3,
-                                             clut,
-                                             NULL);
-       }
-#else
-       tex3d = cogl_texture_3d_new_from_data(CLUT_SIZE, CLUT_SIZE, CLUT_SIZE,
-                                             COGL_TEXTURE_NONE,
-                                             COGL_PIXEL_FORMAT_RGB_888,
-                                             COGL_PIXEL_FORMAT_RGB_888,
-                                             CLUT_SIZE * 3,
-                                             CLUT_SIZE * CLUT_SIZE * 3,
-                                             clut,
-                                             NULL);
-#endif
-       material = clutter_texture_get_cogl_material(CLUTTER_TEXTURE(rc->texture));
-       cogl_material_set_layer(material, 1, tex3d);
-       cogl_handle_unref(tex3d);
-       DEBUG_0("%s clut end", get_exec_time());
-       rc->clut_updated = TRUE;
-}
-
-
-
 static void rc_sync_actor(RendererClutter *rc)
 {
        PixbufRenderer *pr = rc->pr;
@@ -276,8 +138,8 @@ static void rc_sync_actor(RendererClutter *rc)
 
        clutter_actor_set_anchor_point(CLUTTER_ACTOR(rc->texture), 0, 0);
 
-       DEBUG_0("scale %d %d", rc->pr->width, rc->pr->height);
-       DEBUG_0("pos   %d %d", rc->pr->x_offset, rc->pr->y_offset);
+       DEBUG_3("scale %d %d", rc->pr->width, rc->pr->height);
+       DEBUG_3("pos   %d %d", rc->pr->x_offset, rc->pr->y_offset);
 
        clutter_actor_set_scale(CLUTTER_ACTOR(rc->texture),
                                (gfloat)pr->width / pr->image_width,
@@ -380,18 +242,20 @@ static void rc_schedule_texture_upload(RendererClutter *rc)
                {
                /* delay clutter redraw until the texture has some data
                   set priority between gtk redraw and clutter redraw */
-               DEBUG_0("%s tex upload high prio", get_exec_time());
+               DEBUG_3("%s tex upload high prio", get_exec_time());
                rc->idle_update = g_idle_add_full(CLUTTER_PRIORITY_REDRAW - 10, rc_area_changed_cb, rc, NULL);
                }
        else
                {
                /* higher prio than histogram */
-               DEBUG_0("%s tex upload low prio", get_exec_time());
+               DEBUG_3("%s tex upload low prio", get_exec_time());
 
                rc->idle_update = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE - 5, rc_area_changed_cb, rc, NULL);
                }
 }
 
+static void update_display_pixbuf(RendererClutter *rc);
+
 static gboolean rc_area_changed_cb(gpointer data)
 {
        RendererClutter *rc = (RendererClutter *)data;
@@ -403,8 +267,6 @@ static gboolean rc_area_changed_cb(gpointer data)
        if (h == 0) h = 1;
        if (h > par->h) h = par->h;
 
-
-       DEBUG_0("%s upload start", get_exec_time());
        if (pr->pixbuf)
                {
                CoglHandle texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(rc->texture));
@@ -418,11 +280,10 @@ static gboolean rc_area_changed_cb(gpointer data)
                                        h,
                                        par->w,
                                        h,
-                                       gdk_pixbuf_get_has_alpha(pr->pixbuf) ? COGL_PIXEL_FORMAT_BGRA_8888 : COGL_PIXEL_FORMAT_BGR_888,
+                                       gdk_pixbuf_get_has_alpha(pr->pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
                                        gdk_pixbuf_get_rowstride(pr->pixbuf),
                                        gdk_pixbuf_get_pixels(pr->pixbuf));
                }
-       DEBUG_0("%s upload end", get_exec_time());
        rc_area_clip_add(rc, par->x, par->y, par->w, h);
 
 
@@ -439,8 +300,31 @@ static gboolean rc_area_changed_cb(gpointer data)
                clutter_actor_queue_redraw(CLUTTER_ACTOR(rc->texture));
                rc->idle_update = 0;
 
-               /* FIXME: find a better place for this */
-               if (!rc->clut_updated) rc_prepare_post_process_lut(rc);
+               update_display_pixbuf(rc);
+
+               if (pr->func_post_process && pr->pixbuf)
+                       {
+                       pr->func_post_process(pr, &rc->display_pixbuf, 0, 0, gdk_pixbuf_get_width(pr->pixbuf), gdk_pixbuf_get_height(pr->pixbuf), pr->post_process_user_data);
+                       }
+
+               if (pr->pixbuf)
+                       {
+                       CoglHandle texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(rc->texture));
+
+                       cogl_texture_set_region(texture,
+                                               0 + GET_RIGHT_PIXBUF_OFFSET(rc),
+                                               0,
+                                               0,
+                                               0,
+                                               gdk_pixbuf_get_width(pr->pixbuf),
+                                               gdk_pixbuf_get_height(pr->pixbuf),
+                                               gdk_pixbuf_get_width(pr->pixbuf),
+                                               gdk_pixbuf_get_height(pr->pixbuf),
+                                               gdk_pixbuf_get_has_alpha(pr->pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
+                                               gdk_pixbuf_get_rowstride(pr->pixbuf),
+                                               gdk_pixbuf_get_pixels(rc->display_pixbuf));
+                       DEBUG_3("%s upload end", get_exec_time());
+                       }
 
                return FALSE;
                }
@@ -494,57 +378,114 @@ static void rc_remove_pending_updates(RendererClutter *rc)
                }
 }
 
+static void update_display_pixbuf(RendererClutter *rc)
+{
+       PixbufRenderer *pr = rc->pr;
+       GdkPixbuf* tmppixbuf = NULL;
+
+       if (pr->pixbuf)
+               {
+               if (rc->display_pixbuf)
+                       {
+                       g_object_unref(rc->display_pixbuf);
+                       }
+
+               if (!gdk_pixbuf_get_has_alpha(pr->pixbuf))
+                       {
+                       rc->display_pixbuf = gdk_pixbuf_copy(pr->pixbuf);
+                       }
+               else
+                       {
+                       if (pr->ignore_alpha)
+                               {
+                               tmppixbuf = gdk_pixbuf_add_alpha(pr->pixbuf, FALSE, 0, 0, 0);
+
+                               pixbuf_ignore_alpha_rect(tmppixbuf, 0, 0, gdk_pixbuf_get_width(pr->pixbuf), gdk_pixbuf_get_height(pr->pixbuf));
+
+                               rc->display_pixbuf = gdk_pixbuf_composite_color_simple (tmppixbuf,
+                                               gdk_pixbuf_get_width(pr->pixbuf),
+                                               gdk_pixbuf_get_height(pr->pixbuf),
+                                               GDK_INTERP_BILINEAR,
+                                               255,
+                                               PR_ALPHA_CHECK_SIZE,
+                                               ((options->image.alpha_color_1.red << 8 & 0x00FF0000) +
+                                               (options->image.alpha_color_1.green & 0x00FF00) +
+                                               (options->image.alpha_color_1.blue >> 8 & 0x00FF)),
+                                               ((options->image.alpha_color_2.red << 8 & 0x00FF0000) +
+                                               (options->image.alpha_color_2.green & 0x00FF00) +
+                                               (options->image.alpha_color_2.blue >> 8 & 0x00FF)));
+                               g_object_unref(tmppixbuf);
+                               }
+                       else
+                               {
+                               rc->display_pixbuf = gdk_pixbuf_composite_color_simple (pr->pixbuf,
+                                               gdk_pixbuf_get_width(pr->pixbuf),
+                                               gdk_pixbuf_get_height(pr->pixbuf),
+                                               GDK_INTERP_BILINEAR,
+                                               255,
+                                               PR_ALPHA_CHECK_SIZE,
+                                               ((options->image.alpha_color_1.red << 8 & 0x00FF0000) +
+                                               (options->image.alpha_color_1.green & 0x00FF00) +
+                                               (options->image.alpha_color_1.blue >> 8 & 0x00FF)),
+                                               ((options->image.alpha_color_2.red << 8 & 0x00FF0000) +
+                                               (options->image.alpha_color_2.green & 0x00FF00) +
+                                               (options->image.alpha_color_2.blue >> 8 & 0x00FF)));
+                               }
+                       }
+               }
+}
+
 static void rc_update_pixbuf(void *renderer, gboolean lazy)
 {
        RendererClutter *rc = (RendererClutter *)renderer;
        PixbufRenderer *pr = rc->pr;
 
-       DEBUG_0("rc_update_pixbuf");
+       DEBUG_3("rc_update_pixbuf");
 
        rc_remove_pending_updates(rc);
 
        rc->last_pixbuf_change = g_get_monotonic_time();
-       DEBUG_0("%s change time reset", get_exec_time());
+       DEBUG_3("%s change time reset", get_exec_time());
 
        if (pr->pixbuf)
                {
-               gint width = gdk_pixbuf_get_width(pr->pixbuf);
-               gint height = gdk_pixbuf_get_height(pr->pixbuf);
+                       gint width = gdk_pixbuf_get_width(pr->pixbuf);
+                       gint height = gdk_pixbuf_get_height(pr->pixbuf);
 
-               DEBUG_0("pixbuf size %d x %d (%d)", width, height, gdk_pixbuf_get_has_alpha(pr->pixbuf) ? 32 : 24);
+                       DEBUG_3("pixbuf size %d x %d (%d)", width, height, gdk_pixbuf_get_has_alpha(pr->pixbuf) ? 32 : 24);
 
-               gint prev_width, prev_height;
+                       gint prev_width, prev_height;
 
-               if (pr->stereo_data == STEREO_PIXBUF_SBS || pr->stereo_data == STEREO_PIXBUF_CROSS)
-                       {
-                       width /= 2;
-                       }
+                       if (pr->stereo_data == STEREO_PIXBUF_SBS || pr->stereo_data == STEREO_PIXBUF_CROSS)
+                               {
+                               width /= 2;
+                               }
 
 
-               clutter_texture_get_base_size(CLUTTER_TEXTURE(rc->texture), &prev_width, &prev_height);
+                       clutter_texture_get_base_size(CLUTTER_TEXTURE(rc->texture), &prev_width, &prev_height);
 
-               if (width != prev_width || height != prev_height)
-                       {
-                       /* FIXME use CoglMaterial with multiple textures for background, color management, anaglyph, ... */
-                       CoglHandle texture = cogl_texture_new_with_size(width,
-                                                                       height,
-                                                                       COGL_TEXTURE_NO_AUTO_MIPMAP | COGL_TEXTURE_NO_SLICING,
-                                                                       gdk_pixbuf_get_has_alpha(pr->pixbuf) ? COGL_PIXEL_FORMAT_BGRA_8888 : COGL_PIXEL_FORMAT_BGR_888);
-
-                       if (texture != COGL_INVALID_HANDLE)
+                       if (width != prev_width || height != prev_height)
                                {
-                               clutter_texture_set_cogl_texture(CLUTTER_TEXTURE(rc->texture), texture);
-                               cogl_handle_unref(texture);
+                               /** @FIXME use CoglMaterial with multiple textures for background, color management, anaglyph, ... */
+                               CoglHandle texture = cogl_texture_new_with_size(width,
+                                                                               height,
+                                                                               COGL_TEXTURE_NO_AUTO_MIPMAP,
+                                                                               gdk_pixbuf_get_has_alpha(pr->pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888);
+
+                               if (texture != COGL_INVALID_HANDLE)
+                                       {
+                                       clutter_texture_set_cogl_texture(CLUTTER_TEXTURE(rc->texture), texture);
+                                       cogl_handle_unref(texture);
+                                       }
+                               }
+                       clutter_actor_set_clip(rc->texture, 0, 0, 0, 0); /* visible area is extended as area_changed events arrive */
+                       if (!lazy)
+                               {
+                               rc_area_changed(renderer, GET_RIGHT_PIXBUF_OFFSET(rc), 0, width, height);
                                }
-                       }
-               clutter_actor_set_clip(rc->texture, 0, 0, 0, 0); /* visible area is extended as area_changed events arrive */
-               if (!lazy)
-                       {
-                       rc_area_changed(renderer, GET_RIGHT_PIXBUF_OFFSET(rc), 0, width, height);
-                       }
-               }
 
-       rc->clut_updated = FALSE;
+               rc->clut_updated = FALSE;
+               }
 }
 
 
@@ -553,7 +494,7 @@ static void rc_update_zoom(void *renderer, gboolean lazy)
 {
        RendererClutter *rc = (RendererClutter *)renderer;
 
-       DEBUG_0("rc_update_zoom");
+       DEBUG_3("rc_update_zoom");
        rc_sync_actor(rc);
 }
 
@@ -722,7 +663,7 @@ static gboolean rc_overlay_get(void *renderer, gint id, GdkPixbuf **pixbuf, gint
 static void rc_update_viewport(void *renderer)
 {
        RendererClutter *rc = (RendererClutter *)renderer;
-       ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
+       ClutterColor stage_color = { rc->pr->color.red / 256, rc->pr->color.green / 256, rc->pr->color.blue / 256, 0xff };
 
        rc->stereo_off_x = 0;
        rc->stereo_off_y = 0;
@@ -751,7 +692,7 @@ static void rc_update_viewport(void *renderer)
                        rc->stereo_off_y = rc->pr->stereo_fixed_y_left;
                        }
                }
-       DEBUG_0("rc_update_viewport  scale %d %d", rc->pr->width, rc->pr->height);
+       DEBUG_3("rc_update_viewport  scale %d %d", rc->pr->width, rc->pr->height);
 
        clutter_stage_set_color(CLUTTER_STAGE(rc->stage), &stage_color);
 
@@ -775,7 +716,7 @@ static void rc_update_viewport(void *renderer)
 
 static void rc_scroll(void *renderer, gint x_off, gint y_off)
 {
-       DEBUG_0("rc_scroll");
+       DEBUG_3("rc_scroll");
        RendererClutter *rc = (RendererClutter *)renderer;
 
        rc_sync_actor(rc);
@@ -793,6 +734,11 @@ static void rc_free(void *renderer)
        RendererClutter *rc = (RendererClutter *)renderer;
        GtkWidget *widget = gtk_bin_get_child(GTK_BIN(rc->pr));
 
+       if (rc->display_pixbuf)
+               {
+               g_object_unref(rc->display_pixbuf);
+               }
+
        rc_remove_pending_updates(rc);
 
        rc_overlay_free_all(rc);
@@ -816,17 +762,6 @@ static void rc_free(void *renderer)
        g_free(rc);
 }
 
-/* initialize shader for transparency background checker */
-static void renderer_clutter_init_checker_shader(RendererClutter *rc)
-{
-       const RendererClutterShaderInfo info = {
-               16.0,                           /* checker size */
-               {0.6, 0.6, 0.6},        /* color 0 */
-               {0.4, 0.4, 0.4}         /* color 1 */
-       };
-       rc_set_shader(clutter_texture_get_cogl_material(CLUTTER_TEXTURE(rc->texture)), &info);
-}
-
 RendererFuncs *renderer_clutter_new(PixbufRenderer *pr)
 {
        RendererClutter *rc = g_new0(RendererClutter, 1);
@@ -856,6 +791,8 @@ RendererFuncs *renderer_clutter_new(PixbufRenderer *pr)
        rc->idle_update = 0;
        rc->pending_updates = NULL;
 
+       rc->display_pixbuf = NULL;
+
        rc->widget = gtk_bin_get_child(GTK_BIN(rc->pr));
 
        if (rc->widget)
@@ -863,7 +800,7 @@ RendererFuncs *renderer_clutter_new(PixbufRenderer *pr)
                if (!GTK_CLUTTER_IS_EMBED(rc->widget))
                        {
                        g_free(rc);
-                       DEBUG_0("pixbuf renderer has a child of other type than gtk_clutter_embed");
+                       DEBUG_3("pixbuf renderer has a child of other type than gtk_clutter_embed");
                        return NULL;
                        }
                }
@@ -883,7 +820,8 @@ RendererFuncs *renderer_clutter_new(PixbufRenderer *pr)
        rc->texture = clutter_texture_new ();
        clutter_container_add_actor(CLUTTER_CONTAINER(rc->group), rc->texture);
 
-       renderer_clutter_init_checker_shader(rc);
+       clutter_actor_set_content_scaling_filters(rc->texture, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_NEAREST);
+
        g_object_ref(G_OBJECT(rc->widget));
 
        gtk_widget_show(rc->widget);