static void finish_prepare_screenshot (GdkRectangle *rectangle) { GdkRectangle rect; GdkWindow *window; window = find_current_window (); screenshot = screenshot_get_pixbuf (window, rectangle); if (screenshot_config->take_window_shot) { switch (screenshot_config->border_effect[0]) { case 's': /* shadow */ screenshot_add_shadow (&screenshot); break; case 'b': /* border */ screenshot_add_border (&screenshot); break; case 'n': /* none */ default: break; } } /* release now the lock, it was acquired when we were finding the window */ screenshot_release_lock (); if (screenshot == NULL) { screenshot_show_error_dialog (NULL, _("Unable to take a screenshot of the current window"), NULL); exit (1); } flash = cheese_flash_new (); if (rectangle != NULL) rect = *rectangle; else screenshot_get_window_rect (window, &rect); cheese_flash_fire (flash, &rect); play_sound_effect (window); g_object_unref (flash); if (screenshot_config->copy_to_clipboard) { screenshot_save_to_clipboard (); gtk_main_quit (); return; } screenshot_ensure_icc_profile (window); screenshot_build_filename_async (screenshot_config->last_save_dir, build_filename_ready_cb, screenshot); }
static void finish_prepare_screenshot (char *initial_uri, GdkWindow *window, GdkRectangle *rectangle) { ScreenshotDialog *dialog; gboolean include_mask = (!take_window_shot && !take_area_shot); /* always disable window border for full-desktop or selected-area screenshots */ if (!take_window_shot) screenshot = screenshot_get_pixbuf (window, rectangle, include_pointer, FALSE, include_mask); else { screenshot = screenshot_get_pixbuf (window, rectangle, include_pointer, include_border, include_mask); switch (border_effect[0]) { case 's': /* shadow */ screenshot_add_shadow (&screenshot); break; case 'b': /* border */ screenshot_add_border (&screenshot); break; case 'n': /* none */ default: break; } } /* release now the lock, it was acquired when we were finding the window */ screenshot_release_lock (); if (screenshot == NULL) { screenshot_show_error_dialog (NULL, _("Unable to take a screenshot of the current window"), NULL); exit (1); } play_sound_effect (window); dialog = screenshot_dialog_new (screenshot, initial_uri, take_window_shot); g_free (initial_uri); screenshot_save_start (screenshot, save_done_notification, dialog); run_dialog (dialog); }
void screenshot (const char *filename) { GtkWidget *filechooser; GdkPixbuf *pixbuf; int response; /* Get the screenshot */ pixbuf = screenshot_get_pixbuf (GDK_ROOT_WINDOW()); if (!pixbuf) { screenshot_show_error_dialog (NULL, "Could not capture a screenshot.", NULL); return; } /* If we were passed a filename, save it now */ if (filename) { save (NULL, pixbuf, filename); return; } /* Otherwise, open a file chooser to get a filename */ filechooser = gtk_file_chooser_dialog_new ("Save Screenshot", NULL, GTK_FILE_CHOOSER_ACTION_SAVE, "Cancel", GTK_RESPONSE_REJECT, "Save", GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response (GTK_DIALOG (filechooser), GTK_RESPONSE_ACCEPT); #if GTK_CHECK_VERSION(2,7,3) gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (filechooser), TRUE); #endif gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), "Screenshot.png"); gtk_widget_show (filechooser); /* TODO: add extra widget showing thumbnail */ /* TODO: add combo for available file types -- see gdk_pixbuf_save docs */ /* TODO: add magic options to upload to scap/flickr/etc? */ response = gtk_dialog_run (GTK_DIALOG (filechooser)); if (response == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser)); save (GTK_WINDOW (filechooser), pixbuf, filename); } gtk_widget_destroy (filechooser); return; }
static void finish_prepare_screenshot (ScreenshotApplication *self, GdkRectangle *rectangle) { GdkPixbuf *screenshot; screenshot = screenshot_get_pixbuf (rectangle); if (screenshot == NULL) { g_critical ("Unable to capture a screenshot of any window"); if (screenshot_config->interactive) screenshot_show_dialog (NULL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Unable to capture a screenshot"), _("All possible methods failed")); else screenshot_play_sound_effect ("dialog-error", _("Unable to capture a screenshot")); g_application_release (G_APPLICATION (self)); if (screenshot_config->file != NULL) exit (EXIT_FAILURE); return; } if (screenshot_config->take_window_shot) { switch (screenshot_config->border_effect[0]) { case 's': /* shadow */ screenshot_add_shadow (&screenshot); break; case 'b': /* border */ screenshot_add_border (&screenshot); break; case 'n': /* none */ default: break; } } self->priv->screenshot = screenshot; if (screenshot_config->copy_to_clipboard) { screenshot_save_to_clipboard (self); screenshot_play_sound_effect ("screen-capture", _("Screenshot taken")); g_application_release (G_APPLICATION (self)); return; } /* FIXME: apply the ICC profile according to the preferences. * org.gnome.ColorManager.GetProfileForWindow() does not exist anymore, * so we probably need to fetch the color profile of the screen where * the area/window was. * * screenshot_ensure_icc_profile (window); */ if (screenshot_config->file != NULL) { self->priv->save_uri = g_file_get_uri (screenshot_config->file); self->priv->should_overwrite = TRUE; screenshot_save_to_file (self); } else screenshot_build_filename_async (screenshot_config->save_dir, NULL, build_filename_ready_cb, self); }