Author: post
Date: 2010-12-05 17:21:12 +0100 (Sun, 05 Dec 2010)
New Revision: 3663

Modified:
   trunk/src/application.c
   trunk/src/application.h
   trunk/src/rs-actions.c
   trunk/src/ui.xml
Log:
Add "Copy Image to clipboard".

Modified: trunk/src/application.c
===================================================================
--- trunk/src/application.c     2010-12-05 14:55:42 UTC (rev 3662)
+++ trunk/src/application.c     2010-12-05 16:21:12 UTC (rev 3663)
@@ -210,6 +210,59 @@
        return exported;
 }
 
+gboolean
+rs_photo_copy_to_clipboard(RS_PHOTO *photo, RSFilter *prior_to_resample, gint 
width, gint height, gboolean keep_aspect, gdouble scale, gint snapshot)
+{
+       gfloat actual_scale;
+
+       g_assert(RS_IS_PHOTO(photo));
+       g_assert(RS_IS_FILTER(prior_to_resample));
+
+       RSFilter *fresample= rs_filter_new("RSResample", prior_to_resample);
+       RSFilter *ftransform_input = rs_filter_new("RSColorspaceTransform", 
fresample);
+       RSFilter *fdcp = rs_filter_new("RSDcp", ftransform_input);
+       RSFilter *fdenoise= rs_filter_new("RSDenoise", fdcp);
+       RSFilter *ftransform_display = rs_filter_new("RSColorspaceTransform", 
fdenoise);
+       RSFilter *fend = ftransform_display;
+
+       gint input_width;
+       rs_filter_get_size_simple(prior_to_resample, RS_FILTER_REQUEST_QUICK, 
&input_width, NULL);
+       actual_scale = ((gdouble) width / (gdouble) input_width);
+       if (0 < width && 0 < height) /* We only wan't to set width and height 
if they are not -1 */
+               rs_filter_set_recursive(fend, "width", width, "height", height, 
NULL);
+
+       /* Set dcp profile */
+       RSDcpFile *dcp_profile  = rs_photo_get_dcp_profile(photo);
+       if (dcp_profile != NULL)
+               g_object_set(fdcp, "profile", dcp_profile, "use-profile", TRUE, 
NULL);
+       else
+               g_object_set(fdcp, "use-profile", FALSE, NULL);
+
+       /* Set image settings */
+       rs_filter_set_recursive(fend, "settings", photo->settings[snapshot], 
NULL);
+
+       RSFilterResponse *response;
+       RSFilterRequest *request = rs_filter_request_new();
+       rs_filter_request_set_quick(RS_FILTER_REQUEST(request), FALSE);
+       rs_filter_param_set_object(RS_FILTER_PARAM(request), "colorspace", 
rs_color_space_new_singleton("RSSrgb"));
+
+       response = rs_filter_get_image8(fend, request);
+       GdkPixbuf *pixbuf = rs_filter_response_get_image8(response);
+       GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+       gtk_clipboard_set_image(clipboard, pixbuf);
+
+       g_object_unref(request);
+       g_object_unref(response);
+       g_object_unref(pixbuf);
+       g_object_unref(ftransform_input);
+       g_object_unref(ftransform_display);
+       g_object_unref(fresample);
+       g_object_unref(fdenoise);
+       g_object_unref(fdcp);
+
+       return TRUE;
+}
+
 RS_BLOB *
 rs_new(void)
 {

Modified: trunk/src/application.h
===================================================================
--- trunk/src/application.h     2010-12-05 14:55:42 UTC (rev 3662)
+++ trunk/src/application.h     2010-12-05 16:21:12 UTC (rev 3663)
@@ -86,6 +86,7 @@
 
 gboolean rs_photo_save(RS_PHOTO *photo, RSFilter *prior_to_resample, RSOutput 
*output,
        gint width, gint height, gboolean keep_aspect, gdouble scale, gint 
snapshot);
+gboolean rs_photo_copy_to_clipboard(RS_PHOTO *photo, RSFilter 
*prior_to_resample, gint width, gint height, gboolean keep_aspect, gdouble 
scale, gint snapshot);
 RS_BLOB *rs_new();
 void rs_free(RS_BLOB *rs);
 void rs_set_photo(RS_BLOB *rs, RS_PHOTO *photo);

Modified: trunk/src/rs-actions.c
===================================================================
--- trunk/src/rs-actions.c      2010-12-05 14:55:42 UTC (rev 3662)
+++ trunk/src/rs-actions.c      2010-12-05 16:21:12 UTC (rev 3663)
@@ -79,7 +79,7 @@
 {
        rs_core_action_group_set_sensivity("RevertSettings", 
RS_IS_PHOTO(rs->photo));
        rs_core_action_group_set_sensivity("CopySettings", 
RS_IS_PHOTO(rs->photo));
-       rs_core_action_group_set_sensivity("PasteSettings", 
!!(rs->settings_buffer));
+       rs_core_action_group_set_sensivity("CopyImage", 
RS_IS_PHOTO(rs->photo));        
rs_core_action_group_set_sensivity("PasteSettings", !!(rs->settings_buffer));
        rs_core_action_group_set_sensivity("SaveDefaultSettings", 
RS_IS_PHOTO(rs->photo));
 }
 
@@ -374,6 +374,17 @@
        gtk_main_quit();
 }
 
+
+ACTION(copy_image)
+{
+       if (!rs->photo)
+               return;
+       if (rs_photo_copy_to_clipboard(rs->photo, rs->filter_end, -1, -1, 
FALSE, 1.0, rs->current_setting))
+               gui_status_notify(_("Image copied to clipboard"));
+       else
+               gui_status_notify(_("ERROR: Could not copy image to 
clipboard"));
+}
+
 ACTION(revert_settings)
 {
        if (RS_IS_PHOTO(rs->photo))
@@ -1211,6 +1222,7 @@
        { "QuickExport", GTK_STOCK_SAVE, _("_Quick Export"), "<control>S", 
NULL, ACTION_CB(quick_export) },
        { "ExportAs", GTK_STOCK_SAVE_AS, _("_Export As"), "<control><shift>S", 
NULL, ACTION_CB(export_as) },
        { "ExportToGimp", GTK_STOCK_EXECUTE, _("_Export to Gimp"), 
"<control>G", NULL, ACTION_CB(export_to_gimp) },
+       { "CopyImage", GTK_STOCK_COPY, _("_Copy Image to Clipboard"), 
"<control><shift>C", NULL, ACTION_CB(copy_image) },
        { "Reload", GTK_STOCK_REFRESH, _("_Reload directory"), "<control>R", 
NULL, ACTION_CB(reload) },
        { "DeleteFlagged", GTK_STOCK_DELETE, _("_Delete flagged photos"), 
"<control><shift>D", NULL, ACTION_CB(delete_flagged) },
        { "Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", NULL, 
ACTION_CB(quit) },

Modified: trunk/src/ui.xml
===================================================================
--- trunk/src/ui.xml    2010-12-05 14:55:42 UTC (rev 3662)
+++ trunk/src/ui.xml    2010-12-05 16:21:12 UTC (rev 3663)
@@ -12,6 +12,7 @@
   <menu action="EditMenu">
    <menuitem action="RevertSettings" />
    <menuitem action="CopySettings" />
+        <menuitem action="CopyImage" />
    <menuitem action="PasteSettings" />
    <menuitem action="ResetSettings" />
    <menuitem action="SaveDefaultSettings" />


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to