[PATCH]: Improving gnome-panel-screenshot
- From: Fernando Herrera <fherrera onirica com>
- To: mark skynet ie
- Cc: desktop-devel-list gnome org
- Subject: [PATCH]: Improving gnome-panel-screenshot
- Date: Thu, 19 Jun 2003 19:14:31 +0200
Hi!
This patch comes after some GU4DEC discussion about
gnome-panel-screenshot.
Just now, our implementation takes a screenshot of
the whole Desktop, but if --window parameter is passed in
the command line or ALT or SHIFT is pressed with PrintScreen
key, the screenshot is only of the window the mover is over.
This is a really hidden feature and not very usable.
With this patch, both screenshots are taken, one from the whole
desktop and one from current window. Then the user can select
the one he really want. Also this is very useful, because until
you see the final screenshot you are not sure what do you want.
Here is the current one:
http://www.gnome.org/~fherrera/current-screenshot.png
and here the one with this patch applied:
http://www.gnome.org/~fherrera/improved-screenshot.png
The patch is a quick hack to show the feature, and maybe need
some more work (glade loving!!), but please, let me know what do you
think about this.
Salu2
--
Fernando Herrera de las Heras
Onírica: análisis, diseño e implantación de soluciones informáticas
http://www.onirica.com
Index: gnome-panel-screenshot.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/gnome-panel-screenshot.c,v
retrieving revision 1.55
diff -u -u -r1.55 gnome-panel-screenshot.c
--- gnome-panel-screenshot.c 26 May 2003 09:00:50 -0000 1.55
+++ gnome-panel-screenshot.c 19 Jun 2003 17:09:42 -0000
@@ -69,29 +69,46 @@
static GladeXML *xml = NULL;
static GtkWidget *toplevel = NULL;
-static GtkWidget *preview = NULL;
-static GdkPixbuf *screenshot = NULL;
-static GdkPixbuf *preview_image = NULL;
+static GtkWidget *desktop_preview = NULL;
+static GtkWidget *window_preview = NULL;
+static GdkPixbuf *desktop_screenshot = NULL;
+static GdkPixbuf *window_screenshot = NULL;
+static GdkPixbuf *desktop_preview_image = NULL;
+static GdkPixbuf *window_preview_image = NULL;
static char *web_dir;
static char *desktop_dir;
static const char *home_dir;
static char *class_name = NULL;
static pid_t temporary_pid = 0;
-static char *temporary_file = NULL;
+static char *temporary_desktop_file = NULL;
+static char *temporary_window_file = NULL;
static int status;
static GtkTargetEntry drag_types[] =
{ { "x-special/gnome-icon-list", 0, 0 },
{ "text/uri-list", 0, 0 } };
+enum {
+ DESKTOP_SCREENSHOT,
+ WINDOW_SCREENSHOT
+};
+
/* some prototypes for the glade autoconnecting sutff */
+void on_screenshot_type_changed (GtkWidget *widget,
+ gpointer data);
void on_save_rbutton_toggled (GtkWidget *toggle, gpointer data);
-void on_preview_expose_event (GtkWidget *drawing_area,
- GdkEventExpose *event,
- gpointer data);
-void on_preview_configure_event (GtkWidget *drawing_area,
- GdkEventConfigure *event,
- gpointer data);
+void on_desktop_preview_expose_event (GtkWidget *drawing_area,
+ GdkEventExpose *event,
+ gpointer data);
+void on_desktop_preview_configure_event (GtkWidget *drawing_area,
+ GdkEventConfigure *event,
+ gpointer data);
+void on_window_preview_expose_event (GtkWidget *drawing_area,
+ GdkEventExpose *event,
+ gpointer data);
+void on_window_preview_configure_event (GtkWidget *drawing_area,
+ GdkEventConfigure *event,
+ gpointer data);
void on_ok_button_clicked (GtkWidget *widget, gpointer data);
void on_cancel_button_clicked (GtkWidget *widget, gpointer data);
void on_help_button_clicked (GtkWidget *widget, gpointer data);
@@ -99,14 +116,15 @@
int on_toplevel_key_press_event (GtkWidget *widget, GdkEventKey *key);
/* some local prototypes */
-static gchar * add_file_to_path (const gchar *path);
+static gchar * add_file_to_path (const gchar *path, int type);
/* helper functions */
/* This code is copied from gdk-pixbuf-HEAD. It does no memory management and
* is very hard-coded. Please do not use it anywhere else. */
static gboolean
-save_to_file_internal (FILE *fp, const char *file, char **error)
+save_to_file_internal (FILE *fp, const char *file, int screenshot_type, char **error)
{
+ GdkPixbuf *screenshot = NULL;
png_structp png_ptr;
png_infop info_ptr;
guchar *ptr;
@@ -121,6 +139,12 @@
*error = NULL;
+ if (screenshot_type == DESKTOP_SCREENSHOT) {
+ screenshot = desktop_screenshot;
+ } else {
+ screenshot = window_screenshot;
+ }
+
bpc = gdk_pixbuf_get_bits_per_sample (screenshot);
w = gdk_pixbuf_get_width (screenshot);
h = gdk_pixbuf_get_height (screenshot);
@@ -253,7 +277,8 @@
}
static gboolean
-save_to_file (FILE *fp, const gchar *file, gboolean gui_errors)
+save_to_file (FILE *fp, const gchar *file, gboolean gui_errors,
+ int screenshot_type)
{
GtkWidget *dialog;
char *error = NULL;
@@ -262,7 +287,7 @@
fp = nibble_on_file (file);
}
- if ( ! save_to_file_internal (fp, file, &error)) {
+ if ( ! save_to_file_internal (fp, file, screenshot_type, &error)) {
if (gui_errors && error) {
dialog = gtk_message_dialog_new
(GTK_WINDOW (toplevel),
@@ -286,11 +311,14 @@
start_temporary (void)
{
char *dir;
- char *file = NULL;
+ char *desktop_file = NULL;
+ char *window_file = NULL;
mode_t old_mask;
- if (temporary_file != NULL) {
- if (access (temporary_file, F_OK) == 0)
+ if (temporary_desktop_file != NULL || temporary_window_file != NULL) {
+ if (access (temporary_desktop_file, F_OK) == 0)
+ return;
+ if (access (temporary_window_file, F_OK) == 0)
return;
/* Note: nautilus is a wanker and will happily do a move when
@@ -298,12 +326,18 @@
* this file is missing, we let nautilus have it and hope
* he chokes on it */
- dir = g_path_get_dirname (temporary_file);
+ if (temporary_desktop_file != NULL)
+ dir = g_path_get_dirname (temporary_desktop_file);
+ else
+ dir = g_path_get_dirname (temporary_window_file);
+
rmdir (dir);
g_free (dir);
- g_free (temporary_file = NULL);
- temporary_file = NULL;
+ g_free (temporary_desktop_file = NULL);
+ temporary_desktop_file = NULL;
+ g_free (temporary_window_file = NULL);
+ temporary_window_file = NULL;
/* just paranoia */
if (temporary_pid > 0)
@@ -319,42 +353,63 @@
rand ());
} while (mkdir (dir, 0700) < 0);
- file = add_file_to_path (dir);
-
- g_free (dir);
-
old_mask = umask(077);
+ /* Save both screenshots */
+ desktop_file = add_file_to_path (dir, DESKTOP_SCREENSHOT);
+ window_file = add_file_to_path (dir, WINDOW_SCREENSHOT);
+
temporary_pid = fork ();
if (temporary_pid == 0) {
- FILE *fp = fopen (file, "w");
+ FILE *fp = fopen (desktop_file, "w");
if (fp == NULL ||
- ! save_to_file (fp, file, FALSE)) {
+ ! save_to_file (fp, desktop_file, FALSE, DESKTOP_SCREENSHOT)) {
+ _exit (1);
+ }
+ fp = fopen (window_file, "w");
+ if (fp == NULL ||
+ ! save_to_file (fp, window_file, FALSE, WINDOW_SCREENSHOT)) {
_exit (1);
} else {
_exit (0);
}
+
}
/* can't fork? don't dispair, do synchroniously */
else if (temporary_pid < 0) {
- FILE *fp = fopen (file, "w");
+ FILE *fp = fopen (desktop_file, "w");
if (fp == NULL ||
- ! save_to_file (fp, file, TRUE)) {
- g_free (file);
+ ! save_to_file (fp, desktop_file, TRUE, DESKTOP_SCREENSHOT)) {
+ g_free (dir);
+ g_free (desktop_file);
temporary_pid = 0;
umask(old_mask);
return;
}
+ fp = fopen (window_file, "w");
+ if (fp == NULL ||
+ ! save_to_file (fp, window_file, TRUE, WINDOW_SCREENSHOT)) {
+ g_free (dir);
+ g_free (window_file);
+ temporary_pid = 0;
+
+ umask(old_mask);
+ return;
+ }
+
temporary_pid = 0;
} else if ( temporary_pid > 0)
while ((waitpid (temporary_pid, &status, 0) == -1) && errno == EINTR);
+ temporary_desktop_file = desktop_file;
+ temporary_window_file = window_file;
+
umask(old_mask);
- temporary_file = file;
+ g_free (dir);
}
static gboolean
@@ -363,7 +418,7 @@
start_temporary ();
- if (temporary_file == NULL)
+ if (temporary_desktop_file == NULL || temporary_window_file == NULL)
return FALSE;
if (temporary_pid == 0)
@@ -375,8 +430,10 @@
WEXITSTATUS (status) == 0) {
return TRUE;
} else {
- g_free (temporary_file);
- temporary_file = NULL;
+ g_free (temporary_desktop_file);
+ temporary_desktop_file = NULL;
+ g_free (temporary_window_file);
+ temporary_window_file = NULL;
temporary_pid = 0;
return FALSE;
}
@@ -385,10 +442,12 @@
static void
cleanup_temporary (void)
{
- char *file = temporary_file;
+ char *desktop_file = temporary_desktop_file;
+ char *window_file = temporary_window_file;
pid_t pid = temporary_pid;
- temporary_file = NULL;
+ temporary_desktop_file = NULL;
+ temporary_window_file = NULL;
temporary_pid = 0;
if (pid > 0) {
@@ -396,17 +455,24 @@
waitpid (pid, NULL, 0);
}
- if (file != NULL) {
+ if (desktop_file != NULL) {
+ unlink (desktop_file);
+ }
+
+ if (window_file != NULL) {
char *dir;
- unlink (file);
+ unlink (window_file);
- dir = g_path_get_dirname (file);
+ dir = g_path_get_dirname (window_file);
rmdir (dir);
g_free (dir);
}
- g_free (file);
+
+
+ g_free (desktop_file);
+ g_free (window_file);
}
#ifdef HAVE_GNOME_PRINT
@@ -577,13 +643,13 @@
#endif
static gchar *
-add_file_to_path (const gchar *path)
+add_file_to_path (const gchar *path, int type)
{
char *retval;
char *tmp;
int i = 1;
- if (class_name) {
+ if (type == WINDOW_SCREENSHOT && class_name) {
/* translators: this is the file that gets made up with the screenshot if a specific window is taken */
tmp = g_strdup_printf (_("%s%cScreenshot-%s.png"), path,
G_DIR_SEPARATOR, class_name);
@@ -607,7 +673,7 @@
g_free (retval);
- if (class_name) {
+ if (type == WINDOW_SCREENSHOT && class_name) {
/* translators: this is the file that gets made up with the screenshot if a specific window is taken */
tmp = g_strdup_printf (_("%s%cScreenshot-%s-%d.png"), path,
G_DIR_SEPARATOR, class_name, i);
@@ -639,13 +705,13 @@
}
void
-on_preview_expose_event (GtkWidget *drawing_area,
- GdkEventExpose *event,
- gpointer data)
+on_desktop_preview_expose_event (GtkWidget *drawing_area,
+ GdkEventExpose *event,
+ gpointer data)
{
gdk_draw_pixbuf (drawing_area->window,
drawing_area->style->white_gc,
- preview_image,
+ desktop_preview_image,
event->area.x,
event->area.y,
event->area.x,
@@ -657,19 +723,50 @@
}
void
-on_preview_configure_event (GtkWidget *drawing_area,
- GdkEventConfigure *event,
- gpointer data)
-{
- if (preview_image)
- g_object_unref (G_OBJECT (preview_image));
-
- preview_image = gdk_pixbuf_scale_simple (screenshot,
- event->width,
- event->height,
- GDK_INTERP_BILINEAR);
+on_desktop_preview_configure_event (GtkWidget *drawing_area,
+ GdkEventConfigure *event,
+ gpointer data)
+{
+ if (desktop_preview_image)
+ g_object_unref (G_OBJECT (desktop_preview_image));
+
+ desktop_preview_image = gdk_pixbuf_scale_simple (desktop_screenshot,
+ event->width,
+ event->height,
+ GDK_INTERP_BILINEAR);
}
+void
+on_window_preview_expose_event (GtkWidget *drawing_area,
+ GdkEventExpose *event,
+ gpointer data)
+{
+ gdk_draw_pixbuf (drawing_area->window,
+ drawing_area->style->white_gc,
+ window_preview_image,
+ event->area.x,
+ event->area.y,
+ event->area.x,
+ event->area.y,
+ event->area.width,
+ event->area.height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+}
+
+void
+on_window_preview_configure_event (GtkWidget *drawing_area,
+ GdkEventConfigure *event,
+ gpointer data)
+{
+ if (window_preview_image)
+ g_object_unref (G_OBJECT (window_preview_image));
+
+ window_preview_image = gdk_pixbuf_scale_simple (window_screenshot,
+ event->width,
+ event->height,
+ GDK_INTERP_BILINEAR);
+}
static void
setup_busy (gboolean busy)
{
@@ -687,16 +784,24 @@
/* block expose on the, since we don't want to redraw the preview
* in the draw. It'd make no sense and would just generate X traffic */
g_signal_handlers_block_by_func
- (G_OBJECT (preview),
- G_CALLBACK (on_preview_expose_event),
+ (G_OBJECT (desktop_preview),
+ G_CALLBACK (on_desktop_preview_expose_event),
+ NULL);
+ g_signal_handlers_block_by_func
+ (G_OBJECT (window_preview),
+ G_CALLBACK (on_window_preview_expose_event),
NULL);
gtk_widget_set_sensitive (toplevel, ! busy);
gtk_widget_queue_draw (toplevel);
g_signal_handlers_unblock_by_func
- (G_OBJECT (preview),
- G_CALLBACK (on_preview_expose_event),
+ (G_OBJECT (desktop_preview),
+ G_CALLBACK (on_desktop_preview_expose_event),
+ NULL);
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT (window_preview),
+ G_CALLBACK (on_window_preview_expose_event),
NULL);
gdk_flush ();
@@ -704,9 +809,15 @@
}
static gboolean
-gimme_file (const char *filename)
+gimme_file (const char *filename, int screenshot_type)
{
FILE *fp;
+ char *temporary_file;
+
+ if (screenshot_type == DESKTOP_SCREENSHOT)
+ temporary_file = temporary_desktop_file;
+ else
+ temporary_file = temporary_window_file;
fp = nibble_on_file (filename);
if (fp == NULL)
@@ -778,19 +889,49 @@
return TRUE;
} else {
- return save_to_file (fp, filename, TRUE);
+ return save_to_file (fp, filename, TRUE, screenshot_type);
}
}
void
+on_screenshot_type_changed (GtkWidget *widget,
+ gpointer data)
+{
+ char *file;
+ gchar *utf8_name;
+ GtkWidget *entry, *button;
+
+ entry = glade_xml_get_widget (xml, "save_entry");
+ button = glade_xml_get_widget (xml, "takedesktop_rbutton");
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
+ file = add_file_to_path (home_dir, DESKTOP_SCREENSHOT);
+ } else {
+ file = add_file_to_path (home_dir, WINDOW_SCREENSHOT);
+ }
+
+ utf8_name = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
+ gtk_entry_set_text (GTK_ENTRY (entry), utf8_name);
+
+}
+
+
+void
on_ok_button_clicked (GtkWidget *widget,
gpointer data)
{
GtkWidget *button;
gchar *file;
+ int screenshot_type;
setup_busy (TRUE);
+ button = glade_xml_get_widget (xml, "takedesktop_rbutton");
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
+ screenshot_type = DESKTOP_SCREENSHOT;
+ } else {
+ screenshot_type = WINDOW_SCREENSHOT;
+ }
+
button = glade_xml_get_widget (xml, "save_rbutton");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
GtkWidget *entry;
@@ -801,7 +942,7 @@
fileentry = glade_xml_get_widget (xml, "save_fileentry");
tmp = gtk_entry_get_text (GTK_ENTRY (entry));
file = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL);
- if (gimme_file (file)) {
+ if (gimme_file (file, screenshot_type)) {
gnome_entry_prepend_history (GNOME_ENTRY (gnome_file_entry_gnome_entry (GNOME_FILE_ENTRY (fileentry))),
TRUE, gtk_entry_get_text (GTK_ENTRY (entry)));
gtk_main_quit ();
@@ -814,8 +955,8 @@
button = glade_xml_get_widget (xml, "desktop_rbutton");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
- file = add_file_to_path (desktop_dir);
- if (gimme_file (file)) {
+ file = add_file_to_path (desktop_dir, screenshot_type);
+ if (gimme_file (file, screenshot_type)) {
gtk_main_quit ();
}
g_free (file);
@@ -833,8 +974,8 @@
}
#endif
- file = add_file_to_path (web_dir);
- if ( ! gimme_file (file)) {
+ file = add_file_to_path (web_dir, screenshot_type);
+ if ( ! gimme_file (file, screenshot_type)) {
g_free (file);
setup_busy (FALSE);
return;
@@ -1050,8 +1191,8 @@
rectangles = XShapeGetRectangles (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (window),
ShapeBounding, &rectangle_count, &rectangle_order);
if (rectangle_count > 0) {
- screenshot = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- gdk_pixbuf_fill (screenshot, 0);
+ window_screenshot = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+ gdk_pixbuf_fill (window_screenshot, 0);
for (i = 0; i < rectangle_count; i++) {
for (y = rectangles[i].y; y < rectangles[i].y + rectangles[i].height; y++) {
@@ -1060,8 +1201,8 @@
src_pixels = gdk_pixbuf_get_pixels (tmp) +
y * gdk_pixbuf_get_rowstride(tmp) +
rectangles[i].x * (gdk_pixbuf_get_has_alpha (tmp) ? 4 : 3);
- dest_pixels = gdk_pixbuf_get_pixels (screenshot) +
- y * gdk_pixbuf_get_rowstride (screenshot) +
+ dest_pixels = gdk_pixbuf_get_pixels (window_screenshot) +
+ y * gdk_pixbuf_get_rowstride (window_screenshot) +
rectangles[i].x * 4;
for (x = rectangles[i].x; x < rectangles[i].x + rectangles[i].width; x++) {
@@ -1075,10 +1216,10 @@
g_object_unref (tmp);
}
else {
- screenshot = tmp;
+ window_screenshot = tmp;
}
#else /* HAVE_X11_EXTENSIONS_SHAPE_H */
- screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
+ window_screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
x, y, 0, 0,
width, height);
#endif /* HAVE_X11_EXTENSIONS_SHAPE_H */
@@ -1096,18 +1237,18 @@
width = gdk_screen_width ();
height = gdk_screen_height ();
- screenshot = gdk_pixbuf_get_from_drawable (NULL, gdk_get_default_root_window (),
+ desktop_screenshot = gdk_pixbuf_get_from_drawable (NULL, gdk_get_default_root_window (),
NULL, 0, 0, 0, 0,
width, height);
}
static void
-drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- gpointer data)
+desktop_drag_data_get (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data)
{
char *string;
@@ -1116,7 +1257,29 @@
return;
}
- string = g_strdup_printf ("file:%s\r\n", temporary_file);
+ string = g_strdup_printf ("file:%s\r\n", temporary_desktop_file);
+ gtk_selection_data_set (selection_data,
+ selection_data->target,
+ 8, string, strlen (string)+1);
+ g_free (string);
+}
+
+static void
+window_drag_data_get (GtkWidget *widget,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ gpointer data)
+{
+ char *string;
+
+ if ( ! ensure_temporary ()) {
+ /*FIXME: cancel the drag*/
+ return;
+ }
+
+ string = g_strdup_printf ("file:%s\r\n", temporary_window_file);
gtk_selection_data_set (selection_data,
selection_data->target,
8, string, strlen (string)+1);
@@ -1134,13 +1297,29 @@
}
static void
-drag_begin (GtkWidget *widget, GdkDragContext *context)
+desktop_drag_begin (GtkWidget *widget, GdkDragContext *context)
{
static GdkPixmap *pixmap;
GdkBitmap *mask;
gdk_pixbuf_render_pixmap_and_mask
- (preview_image, &pixmap, &mask,
+ (desktop_preview_image, &pixmap, &mask,
+ 128);
+
+ gtk_drag_set_icon_pixmap
+ (context, gdk_rgb_get_colormap (), pixmap, mask, 0, 0);
+
+ start_temporary ();
+}
+
+static void
+window_drag_begin (GtkWidget *widget, GdkDragContext *context)
+{
+ static GdkPixmap *pixmap;
+ GdkBitmap *mask;
+
+ gdk_pixbuf_render_pixmap_and_mask
+ (window_preview_image, &pixmap, &mask,
128);
gtk_drag_set_icon_pixmap
@@ -1209,13 +1388,14 @@
main (int argc, char *argv[])
{
GtkWidget *save_entry;
- GtkWidget *frame;
+ GtkWidget *desktop_frame, *window_frame;
GConfClient *gconf_client;
GnomeClient *client;
struct stat s;
gchar *file, *window_icon;
gboolean window = FALSE;
- gint width, height;
+ gint desktop_width, desktop_height;
+ gint window_width, window_height;
guint delay = 0;
gboolean normal_web_dir = TRUE;
gchar *utf8_name;
@@ -1250,14 +1430,11 @@
exit (1);
}
- if (window) {
- if ( ! take_window_shot ()) {
- release_lock ();
- exit (1);
- }
- } else {
- take_screen_shot ();
+ if ( ! take_window_shot ()) {
+ release_lock ();
+ exit (1);
}
+ take_screen_shot ();
if (g_file_test ("gnome-panel-screenshot.glade", G_FILE_TEST_EXISTS)) {
xml = glade_xml_new ("gnome-panel-screenshot.glade", NULL, NULL);
@@ -1289,8 +1466,13 @@
gtk_widget_hide (button);
}
#endif
+ {
+ GtkWidget *button = glade_xml_get_widget (xml, "print_rbutton");
+ if (button != NULL)
+ gtk_widget_hide (button);
+ }
- if (screenshot == NULL) {
+ if (desktop_screenshot == NULL || window_screenshot == NULL) {
GtkWidget *dialog;
release_lock ();
dialog = gtk_message_dialog_new
@@ -1305,15 +1487,21 @@
exit (1);
}
- width = gdk_pixbuf_get_width (screenshot);
- height = gdk_pixbuf_get_height (screenshot);
-
- width /= 5;
- height /= 5;
+ desktop_width = gdk_pixbuf_get_width (desktop_screenshot);
+ desktop_height = gdk_pixbuf_get_height (desktop_screenshot);
+ window_width = gdk_pixbuf_get_width (window_screenshot);
+ window_height = gdk_pixbuf_get_height (window_screenshot);
+
+ desktop_width /= 5;
+ desktop_height /= 5;
+ window_width /= 5;
+ window_height /= 5;
toplevel = glade_xml_get_widget (xml, "toplevel");
- frame = glade_xml_get_widget (xml, "aspect_frame");
- preview = glade_xml_get_widget (xml, "preview");
+ desktop_frame = glade_xml_get_widget (xml, "desktop_aspect_frame");
+ window_frame = glade_xml_get_widget (xml, "window_aspect_frame");
+ desktop_preview = glade_xml_get_widget (xml, "desktop_preview");
+ window_preview = glade_xml_get_widget (xml, "window_preview");
save_entry = glade_xml_get_widget (xml, "save_entry");
window_icon = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP,
@@ -1324,14 +1512,18 @@
}
- gtk_window_set_default_size (GTK_WINDOW (toplevel), width * 2, -1);
- gtk_widget_set_size_request (preview, width, height);
- gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.0, 0.5,
- gdk_pixbuf_get_width (screenshot)/
- (gfloat) gdk_pixbuf_get_height (screenshot),
+ gtk_window_set_default_size (GTK_WINDOW (toplevel), desktop_width * 2, -1);
+ gtk_widget_set_size_request (desktop_preview, desktop_width, desktop_height);
+ gtk_aspect_frame_set (GTK_ASPECT_FRAME (desktop_frame), 0.0, 0.5,
+ gdk_pixbuf_get_width (desktop_screenshot)/
+ (gfloat) gdk_pixbuf_get_height (desktop_screenshot),
+ FALSE);
+ gtk_widget_set_size_request (window_preview, window_width, window_height);
+ gtk_aspect_frame_set (GTK_ASPECT_FRAME (window_frame), 0.0, 0.5,
+ gdk_pixbuf_get_width (window_screenshot)/
+ (gfloat) gdk_pixbuf_get_height (window_screenshot),
FALSE);
- if (window)
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_frame_set_shadow_type (GTK_FRAME (window_frame), GTK_SHADOW_NONE);
gconf_client = gconf_client_get_default ();
@@ -1350,7 +1542,7 @@
"Desktop", NULL);
g_object_unref (gconf_client);
- file = add_file_to_path (home_dir);
+ file = add_file_to_path (home_dir, DESKTOP_SCREENSHOT);
utf8_name = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
gtk_entry_set_text (GTK_ENTRY (save_entry), utf8_name);
g_free (file);
@@ -1372,14 +1564,24 @@
/* setup dnd */
/* just in case some wanker like nautilus took our image */
- g_signal_connect (G_OBJECT (preview), "drag_begin",
- G_CALLBACK (drag_begin), NULL);
- g_signal_connect (G_OBJECT (preview), "drag_data_get",
- G_CALLBACK (drag_data_get), NULL);
- gtk_drag_source_set (preview,
+ g_signal_connect (G_OBJECT (desktop_preview), "drag_begin",
+ G_CALLBACK (desktop_drag_begin), NULL);
+ g_signal_connect (G_OBJECT (desktop_preview), "drag_data_get",
+ G_CALLBACK (desktop_drag_data_get), NULL);
+ gtk_drag_source_set (desktop_preview,
GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
drag_types, 2,
GDK_ACTION_COPY);
+ g_signal_connect (G_OBJECT (window_preview), "drag_begin",
+ G_CALLBACK (window_drag_begin), NULL);
+ g_signal_connect (G_OBJECT (window_preview), "drag_data_get",
+ G_CALLBACK (window_drag_data_get), NULL);
+ gtk_drag_source_set (window_preview,
+ GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
+ drag_types, 2,
+ GDK_ACTION_COPY);
+
+
gtk_widget_grab_focus (save_entry);
gtk_editable_select_region (GTK_EDITABLE (save_entry), 0, -1);
Index: gnome-panel-screenshot.glade
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/gnome-panel-screenshot.glade,v
retrieving revision 1.12
diff -u -u -r1.12 gnome-panel-screenshot.glade
--- gnome-panel-screenshot.glade 18 Jun 2003 06:25:02 -0000 1.12
+++ gnome-panel-screenshot.glade 19 Jun 2003 17:09:44 -0000
@@ -135,7 +135,7 @@
</child>
<child>
- <widget class="GtkAspectFrame" id="aspect_frame">
+ <widget class="GtkAspectFrame" id="desktop_aspect_frame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
@@ -146,10 +146,10 @@
<property name="obey_child">True</property>
<child>
- <widget class="GtkDrawingArea" id="preview">
+ <widget class="GtkDrawingArea" id="desktop_preview">
<property name="visible">True</property>
- <signal name="expose_event" handler="on_preview_expose_event"/>
- <signal name="configure_event" handler="on_preview_configure_event"/>
+ <signal name="expose_event" handler="on_desktop_preview_expose_event" last_modification_time="Thu, 19 Jun 2003 14:25:42 GMT"/>
+ <signal name="configure_event" handler="on_desktop_preview_configure_event" last_modification_time="Thu, 19 Jun 2003 14:25:50 GMT"/>
</widget>
</child>
</widget>
@@ -159,6 +159,105 @@
<property name="fill">True</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkRadioButton" id="takedesktop_rbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">D_esktop screenshot</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_screenshot_type_changed" object="NULL" last_modification_time="Thu, 19 Jun 2003 15:35:15 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"> </property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAspectFrame" id="window_aspect_frame">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0.5</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="ratio">1</property>
+ <property name="obey_child">True</property>
+
+ <child>
+ <widget class="GtkDrawingArea" id="window_preview">
+ <property name="visible">True</property>
+ <signal name="expose_event" handler="on_window_preview_expose_event" last_modification_time="Thu, 19 Jun 2003 14:28:42 GMT"/>
+ <signal name="configure_event" handler="on_window_preview_configure_event" last_modification_time="Thu, 19 Jun 2003 14:28:37 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="takewindow_rbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Window screenshot</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">takedesktop_rbutton</property>
+ <signal name="clicked" handler="on_screenshot_type_changed" object="NULL" last_modification_time="Thu, 19 Jun 2003 15:35:09 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
@@ -375,7 +474,7 @@
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
</widget>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]