[Goodies-commits] r7352 - in xfce4-screenshooter/trunk: . lib panel-plugin src
Jerome Guelfucci
jeromeg at xfce.org
Sat May 16 23:47:19 CEST 2009
Author: jeromeg
Date: 2009-05-16 21:47:18 +0000 (Sat, 16 May 2009)
New Revision: 7352
Modified:
xfce4-screenshooter/trunk/ChangeLog
xfce4-screenshooter/trunk/TODO
xfce4-screenshooter/trunk/lib/exo-job.c
xfce4-screenshooter/trunk/lib/exo-job.h
xfce4-screenshooter/trunk/lib/exo-simple-job.c
xfce4-screenshooter/trunk/lib/exo-simple-job.h
xfce4-screenshooter/trunk/lib/libscreenshooter.h
xfce4-screenshooter/trunk/lib/screenshooter-actions.c
xfce4-screenshooter/trunk/lib/screenshooter-capture.c
xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c
xfce4-screenshooter/trunk/lib/screenshooter-dialogs.h
xfce4-screenshooter/trunk/lib/screenshooter-job.c
xfce4-screenshooter/trunk/lib/screenshooter-job.h
xfce4-screenshooter/trunk/lib/screenshooter-simple-job.c
xfce4-screenshooter/trunk/lib/screenshooter-simple-job.h
xfce4-screenshooter/trunk/lib/screenshooter-utils.c
xfce4-screenshooter/trunk/lib/screenshooter-utils.h
xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c
xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c
xfce4-screenshooter/trunk/src/main.c
Log:
* src/screenshooter-utils.{c,h}: add (screenshooter_error) which shows
an error using a GtkMessageDialog.
* lib/*, panel-plugin/screenshooter-plugin.c, src/main.c:
- use (screenshooter_error) instead of (xfce_err).
- remove some trailing white spaces.
* lib/screenshooter-job.c (screenshooter_job_ask_info): add a missing return,
when the job has been cancelled.
* TODO: updated.
Modified: xfce4-screenshooter/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter/trunk/ChangeLog 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/ChangeLog 2009-05-16 21:47:18 UTC (rev 7352)
@@ -1,3 +1,14 @@
+2009-05-16 jeromeg
+
+ * src/screenshooter-utils.{c,h}: add (screenshooter_error) which shows
+ an error using a GtkMessageDialog.
+ * lib/*, panel-plugin/screenshooter-plugin.c, src/main.c:
+ - use (screenshooter_error) instead of (xfce_err).
+ - remove some trailing white spaces.
+ * lib/screenshooter-job.c (screenshooter_job_ask_info): add a missing return,
+ when the job has been cancelled.
+ * TODO: updated.
+
2009-05-15 jeromeg
* src/main.c:
Modified: xfce4-screenshooter/trunk/TODO
===================================================================
--- xfce4-screenshooter/trunk/TODO 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/TODO 2009-05-16 21:47:18 UTC (rev 7352)
@@ -2,7 +2,6 @@
as in thunar and xfdesktop.
* Check for leaks using valgrind.
* Use Xshape to have a transparent background in the generated screenshots.
-* Remove every call to xfce_err with a gtk_message_dialog.
* the Zimagez code needs a lot of error checking.
Low priority:
Modified: xfce4-screenshooter/trunk/lib/exo-job.c
===================================================================
--- xfce4-screenshooter/trunk/lib/exo-job.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/exo-job.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -90,7 +90,7 @@
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
- type = g_type_register_static_simple (G_TYPE_OBJECT,
+ type = g_type_register_static_simple (G_TYPE_OBJECT,
"ExoJob",
sizeof (ExoJobClass),
(GClassInitFunc) exo_job_class_init,
@@ -115,7 +115,7 @@
exo_job_parent_class = g_type_class_peek_parent (klass);
gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = exo_job_finalize;
+ gobject_class->finalize = exo_job_finalize;
klass->execute = NULL;
klass->error = NULL;
@@ -133,8 +133,8 @@
job_signals[ERROR] =
g_signal_new ("error",
G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET (ExoJobClass, error),
+ G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (ExoJobClass, error),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
@@ -143,15 +143,15 @@
* ExoJob::finished:
* @job : an #ExoJob.
*
- * This signal will be automatically emitted once the @job finishes
- * its execution, no matter whether @job completed successfully or
+ * This signal will be automatically emitted once the @job finishes
+ * its execution, no matter whether @job completed successfully or
* was cancelled by the user.
**/
job_signals[FINISHED] =
g_signal_new ("finished",
G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET (ExoJobClass, finished),
+ G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (ExoJobClass, finished),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -164,14 +164,14 @@
* This signal is emitted to display information about the * @job.
* Examples of messages are "Preparing..." or "Cleaning up...".
*
- * The @message is garanteed to contain valid UTF-8, so it can be
+ * The @message is garanteed to contain valid UTF-8, so it can be
* displayed by #GtkWidget<!---->s out of the box.
**/
job_signals[INFO_MESSAGE] =
g_signal_new ("info-message",
G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET (ExoJobClass, info_message),
+ G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (ExoJobClass, info_message),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
@@ -181,15 +181,15 @@
* @job : an #ExoJob.
* @percent : the percentage of completeness.
*
- * This signal is emitted to present the state of the overall
- * progress. The @percent value is garantied to be in the range 0.0
+ * This signal is emitted to present the state of the overall
+ * progress. The @percent value is garantied to be in the range 0.0
* to 100.0.
**/
job_signals[PERCENT] =
g_signal_new ("percent",
G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET (ExoJobClass, percent),
+ G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (ExoJobClass, percent),
NULL, NULL,
g_cclosure_marshal_VOID__DOUBLE,
G_TYPE_NONE, 1, G_TYPE_DOUBLE);
@@ -252,7 +252,7 @@
* @object : an #ExoJob.
* @result : the #GAsyncResult of the job.
*
- * This function is called by the #GIOScheduler at the end of the
+ * This function is called by the #GIOScheduler at the end of the
* operation. It checks if there were errors during the operation
* and emits "error" and "finished" signals.
**/
@@ -289,7 +289,7 @@
* @user_data : a #GSimpleAsyncResult.
*
* This function is called by the #GIOScheduler to execute the
- * operation associated with the job. It basically calls the
+ * operation associated with the job. It basically calls the
* ExoJobClass#execute function.
*
* Return value: %FALSE, to stop the thread at the end of the
@@ -311,7 +311,7 @@
success = (*EXO_JOB_GET_CLASS (job)->execute) (job, &error);
/* TODO why was this necessary again? */
- g_io_scheduler_job_send_to_mainloop (scheduler_job, (GSourceFunc) gtk_false,
+ g_io_scheduler_job_send_to_mainloop (scheduler_job, (GSourceFunc) gtk_false,
NULL, NULL);
if (!success)
@@ -342,7 +342,7 @@
{
ExoJobSignalData *data = user_data;
- g_signal_emit_valist (data->instance, data->signal_id, data->signal_detail,
+ g_signal_emit_valist (data->instance, data->signal_id, data->signal_detail,
data->var_args);
return FALSE;
@@ -359,8 +359,8 @@
* return type of the signal is G_TYPE_NONE, the return
* value location can be omitted.
*
- * Send a the signal with the given @signal_id and @signal_detail to the
- * main loop of the application and waits for the listeners to handle
+ * Send a the signal with the given @signal_id and @signal_detail to the
+ * main loop of the application and waits for the listeners to handle
* it.
**/
static void
@@ -377,7 +377,7 @@
data.instance = job;
data.signal_id = signal_id;
data.signal_detail = signal_detail;
-
+
/* copy the variable argument list */
G_VA_COPY (data.var_args, var_args);
@@ -417,7 +417,7 @@
* @job : an #ExoJob.
*
* Emits the "finished" signal to notify listeners of the end of the
- * operation.
+ * operation.
*
* This function should never be called from outside the application's
* main loop.
@@ -474,9 +474,9 @@
* exo_job_cancel:
* @job : a #ExoJob.
*
- * Attempts to cancel the operation currently performed by @job. Even
+ * Attempts to cancel the operation currently performed by @job. Even
* after the cancellation of @job, it may still emit signals, so you
- * must take care of disconnecting all handlers appropriately if you
+ * must take care of disconnecting all handlers appropriately if you
* cannot handle signals after cancellation.
**/
void
@@ -530,7 +530,7 @@
* @error : error to be set if the @job was cancelled.
*
* Sets the @error if the @job was cancelled. This is a convenience
- * function that is equivalent to
+ * function that is equivalent to
* <informalexample><programlisting>
* GCancellable *cancellable;
* cancellable = exo_job_get_cancllable (job);
Modified: xfce4-screenshooter/trunk/lib/exo-job.h
===================================================================
--- xfce4-screenshooter/trunk/lib/exo-job.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/exo-job.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -42,7 +42,7 @@
/* virtual methods */
gboolean (*execute) (ExoJob *job,
- GError **error);
+ GError **error);
/* signals */
void (*error) (ExoJob *job,
Modified: xfce4-screenshooter/trunk/lib/exo-simple-job.c
===================================================================
--- xfce4-screenshooter/trunk/lib/exo-simple-job.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/exo-simple-job.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -72,12 +72,12 @@
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
- type = g_type_register_static_simple (EXO_TYPE_JOB,
+ type = g_type_register_static_simple (EXO_TYPE_JOB,
"ExoSimpleJob",
sizeof (ExoSimpleJobClass),
(GClassInitFunc) exo_simple_job_class_init,
sizeof (ExoSimpleJob),
- NULL,
+ NULL,
0);
}
@@ -135,7 +135,7 @@
{
g_assert (err != NULL || exo_job_is_cancelled (job));
- /* set error if the job was cancelled. otherwise just propagate
+ /* set error if the job was cancelled. otherwise just propagate
* the results of the processing function */
if (exo_job_set_error_if_cancelled (job, error))
{
@@ -162,8 +162,8 @@
* @... : a list of #GType and parameter pairs (exactly
* @n_param_values pairs) that are passed to @func.
*
- * Allocates a new #ExoJob which executes the specified @func with
- * the specified parameters.
+ * Allocates a new #ExoJob which executes the specified @func with
+ * the specified parameters.
*
* An example could be:
*
Modified: xfce4-screenshooter/trunk/lib/exo-simple-job.h
===================================================================
--- xfce4-screenshooter/trunk/lib/exo-simple-job.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/exo-simple-job.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -28,7 +28,7 @@
/**
* ExoSimpleJobFunc:
* @job : an #ExoJob.
- * @param_values : a #GValueArray of the #GValue<!---->s passed to
+ * @param_values : a #GValueArray of the #GValue<!---->s passed to
* exo_simple_job_launch().
* @error : return location for errors.
*
Modified: xfce4-screenshooter/trunk/lib/libscreenshooter.h
===================================================================
--- xfce4-screenshooter/trunk/lib/libscreenshooter.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/libscreenshooter.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
+
#ifndef HAVE_SCREENSHOOTER_H
#define HAVE_SCREENSHOOTER_H
Modified: xfce4-screenshooter/trunk/lib/screenshooter-actions.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-actions.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-actions.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -25,7 +25,7 @@
screenshooter_take_screenshot (sd->region, sd->delay, sd->show_mouse);
g_return_if_fail (screenshot != NULL);
-
+
if (sd->action == SAVE)
{
if (sd->screenshot_dir == NULL)
Modified: xfce4-screenshooter/trunk/lib/screenshooter-capture.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-capture.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-capture.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -35,16 +35,16 @@
-static GdkWindow
+static GdkWindow
*get_active_window (GdkScreen *screen, gboolean *needs_unref)
{
GdkWindow *window, *window2;
TRACE ("Get the active window");
-
+
window = gdk_screen_get_active_window (screen);
-
- /* If there is no active window, we fallback to the whole screen. */
+
+ /* If there is no active window, we fallback to the whole screen. */
if (G_UNLIKELY (window == NULL))
{
TRACE ("No active window, fallback to the root window");
@@ -58,7 +58,7 @@
TRACE ("The active window is the desktop, fallback to the root window");
g_object_unref (window);
-
+
window = gdk_get_default_root_window ();
*needs_unref = FALSE;
}
@@ -68,9 +68,9 @@
TRACE ("Active window is a normal window, grab the toplevel window");
window2 = gdk_window_get_toplevel (window);
-
+
g_object_unref (window);
-
+
window = window2;
}
@@ -84,25 +84,25 @@
{
gint x_orig, y_orig;
gint width, height;
-
+
GdkPixbuf *screenshot;
GdkWindow *root;
-
+
GdkRectangle *rectangle = g_new0 (GdkRectangle, 1);
-
+
/* Get the root window */
TRACE ("Get the root window");
-
+
root = gdk_get_default_root_window ();
TRACE ("Get the frame extents");
-
+
gdk_window_get_frame_extents (window, rectangle);
-
+
/* Don't grab thing offscreen. */
TRACE ("Make sure we don't grab things offscreen");
-
+
x_orig = rectangle->x;
y_orig = rectangle->y;
width = rectangle->width;
@@ -125,14 +125,14 @@
if (y_orig + height > gdk_screen_height ())
height = gdk_screen_height () - y_orig;
-
+
g_free (rectangle);
-
+
/* Take the screenshot from the root GdkWindow, to grab things such as
* menus. */
TRACE ("Grab the screenshot");
-
+
screenshot = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
x_orig, y_orig, 0, 0,
width, height);
@@ -155,26 +155,26 @@
gint cursorx, cursory, xhot, yhot;
TRACE ("Get the coordinates of the cursor");
-
+
gdk_window_get_pointer (root, &cursorx, &cursory, NULL);
TRACE ("Get the cursor hotspot");
sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "x_hot"), "%d", &xhot);
sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "y_hot"), "%d", &yhot);
-
+
/* rectangle_window stores the window coordinates */
rectangle_window.x = x_orig;
rectangle_window.y = y_orig;
rectangle_window.width = width;
rectangle_window.height = height;
-
+
/* rectangle_cursor stores the cursor coordinates */
rectangle_cursor.x = cursorx;
rectangle_cursor.y = cursory;
rectangle_cursor.width = gdk_pixbuf_get_width (cursor_pixbuf);
rectangle_cursor.height = gdk_pixbuf_get_height (cursor_pixbuf);
-
+
/* see if the pointer is inside the window */
if (gdk_rectangle_intersect (&rectangle_window,
&rectangle_cursor,
@@ -190,14 +190,14 @@
GDK_INTERP_BILINEAR,
255);
}
-
+
g_object_unref (cursor_pixbuf);
}
gdk_cursor_unref (cursor);
}
- return screenshot;
+ return screenshot;
}
@@ -206,27 +206,27 @@
*get_rectangle_screenshot (void)
{
GdkPixbuf *screenshot = NULL;
-
+
/* Get root window */
TRACE ("Get the root window");
-
+
GdkWindow *root_window = gdk_get_default_root_window ();
-
+
GdkGCValues gc_values;
GdkGC *gc;
GdkGrabStatus grabstatus_mouse, grabstatus_keyboard;
-
+
GdkGCValuesMask values_mask =
- GDK_GC_FUNCTION | GDK_GC_FILL | GDK_GC_CLIP_MASK |
- GDK_GC_SUBWINDOW | GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN |
- GDK_GC_EXPOSURES | GDK_GC_LINE_WIDTH | GDK_GC_LINE_STYLE |
+ GDK_GC_FUNCTION | GDK_GC_FILL | GDK_GC_CLIP_MASK |
+ GDK_GC_SUBWINDOW | GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN |
+ GDK_GC_EXPOSURES | GDK_GC_LINE_WIDTH | GDK_GC_LINE_STYLE |
GDK_GC_CAP_STYLE | GDK_GC_JOIN_STYLE;
-
+
GdkColor gc_white = {0, 65535, 65535, 65535};
GdkColor gc_black = {0, 0, 0, 0};
-
- GdkEventMask mask =
- GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
+
+ GdkEventMask mask =
+ GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK;
GdkCursor *xhair_cursor = gdk_cursor_new (GDK_CROSSHAIR);
@@ -234,11 +234,11 @@
gboolean done = FALSE;
gboolean cancelled = FALSE;
gint x, y, w, h;
-
- /*Set up graphics context for a XOR rectangle that will be drawn as
+
+ /*Set up graphics context for a XOR rectangle that will be drawn as
* the user drags the mouse */
TRACE ("Initialize the graphics context");
-
+
gc_values.function = GDK_XOR;
gc_values.line_width = 2;
gc_values.line_style = GDK_LINE_ON_OFF_DASH;
@@ -250,44 +250,44 @@
gc_values.clip_y_origin = 0;
gc_values.clip_mask = None;
gc_values.subwindow_mode = GDK_INCLUDE_INFERIORS;
-
+
gc = gdk_gc_new_with_values (root_window, &gc_values, values_mask);
gdk_gc_set_rgb_fg_color (gc, &gc_white);
gdk_gc_set_rgb_bg_color (gc, &gc_black);
-
+
/* Change cursor to cross-hair */
TRACE ("Set the cursor");
-
+
grabstatus_mouse =
gdk_pointer_grab (root_window, FALSE, mask, NULL, xhair_cursor, GDK_CURRENT_TIME);
grabstatus_keyboard = gdk_keyboard_grab (root_window, FALSE, GDK_CURRENT_TIME);
-
+
while (!done && grabstatus_mouse == GDK_GRAB_SUCCESS
&& grabstatus_keyboard == GDK_GRAB_SUCCESS)
{
gint x1, y1, x2, y2;
GdkEvent *event;
-
+
event = gdk_event_get ();
-
- if (event == NULL)
+
+ if (event == NULL)
continue;
-
+
switch (event->type)
{
/* Start dragging the rectangle out */
-
+
case GDK_BUTTON_PRESS:
TRACE ("Start dragging the rectangle");
-
+
x = x2 = x1 = event->button.x;
y = y2 = y1 = event->button.y;
w = 0; h = 0;
pressed = TRUE;
break;
-
+
/* Finish dragging the rectangle out */
case GDK_BUTTON_RELEASE:
if (pressed)
@@ -297,24 +297,24 @@
/* Remove the rectangle drawn previously */
TRACE ("Remove the rectangle drawn previously");
-
- gdk_draw_rectangle (root_window,
- gc,
- FALSE,
+
+ gdk_draw_rectangle (root_window,
+ gc,
+ FALSE,
x, y, w, h);
done = TRUE;
- }
- else
+ }
+ else
{
/* The user has not dragged the mouse, start again */
TRACE ("Mouse was not dragged, start again");
-
+
pressed = FALSE;
}
}
break;
-
+
/* The user is moving the mouse */
case GDK_MOTION_NOTIFY:
if (pressed)
@@ -326,10 +326,10 @@
/* Remove the rectangle drawn previously */
TRACE ("Remove the rectangle drawn previously");
-
- gdk_draw_rectangle (root_window,
- gc,
- FALSE,
+
+ gdk_draw_rectangle (root_window,
+ gc,
+ FALSE,
x, y, w, h);
}
@@ -344,13 +344,13 @@
/* Draw the rectangle as the user drags the mouse */
TRACE ("Draw the new rectangle");
-
+
if (w > 0 && h > 0)
- gdk_draw_rectangle (root_window,
- gc,
- FALSE,
+ gdk_draw_rectangle (root_window,
+ gc,
+ FALSE,
x, y, w, h);
-
+
}
break;
@@ -366,10 +366,10 @@
/* Remove the rectangle drawn previously */
TRACE ("Remove the rectangle drawn previously");
-
- gdk_draw_rectangle (root_window,
- gc,
- FALSE,
+
+ gdk_draw_rectangle (root_window,
+ gc,
+ FALSE,
x, y, w, h);
}
}
@@ -378,16 +378,16 @@
cancelled = TRUE;
}
- break;
-
- default:
break;
+
+ default:
+ break;
}
-
+
gdk_event_free (event);
}
-
- if (grabstatus_mouse == GDK_GRAB_SUCCESS)
+
+ if (grabstatus_mouse == GDK_GRAB_SUCCESS)
{
TRACE ("Ungrab the pointer");
@@ -400,22 +400,22 @@
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
}
-
+
/* Get the screenshot's pixbuf */
if (G_LIKELY (!cancelled))
{
TRACE ("Get the pixbuf for the screenshot");
-
+
screenshot =
gdk_pixbuf_get_from_drawable (NULL, root_window, NULL, x, y, 0, 0, w, h);
}
if (G_LIKELY (gc != NULL))
g_object_unref (gc);
-
+
gdk_cursor_unref (xhair_cursor);
-
+
return screenshot;
}
@@ -447,40 +447,40 @@
GdkPixbuf *screenshot = NULL;
GdkWindow *window = NULL;
GdkScreen *screen;
-
- /* gdk_get_default_root_window () does not need to be unrefed,
- * needs_unref enables us to unref *window only if a non default
+
+ /* gdk_get_default_root_window () does not need to be unrefed,
+ * needs_unref enables us to unref *window only if a non default
* window has been grabbed. */
gboolean needs_unref = TRUE;
-
+
/* Get the screen on which the screenshot should be taken */
screen = gdk_screen_get_default ();
-
- /* wait for n=delay seconds */
+
+ /* wait for n=delay seconds */
if (region != SELECT)
sleep (delay);
-
- /* Get the window/desktop we want to screenshot*/
+
+ /* Get the window/desktop we want to screenshot*/
if (region == FULLSCREEN)
{
TRACE ("We grab the entire screen");
window = gdk_get_default_root_window ();
needs_unref = FALSE;
- }
+ }
else if (region == ACTIVE_WINDOW)
{
TRACE ("We grab the active window");
- window = get_active_window (screen, &needs_unref);
+ window = get_active_window (screen, &needs_unref);
}
-
+
if (region == FULLSCREEN || region == ACTIVE_WINDOW)
{
TRACE ("Get the screenshot of the given window");
screenshot = get_window_screenshot (window, show_mouse);
-
+
if (needs_unref)
g_object_unref (window);
}
@@ -491,6 +491,6 @@
screenshot = get_rectangle_screenshot ();
}
-
+
return screenshot;
}
Modified: xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -21,59 +21,59 @@
#define ICON_SIZE 16
-/* Prototypes */
+/* Prototypes */
-static void
+static void
cb_fullscreen_screen_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
-static void
+static void
cb_active_window_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
-static void
+static void
cb_rectangle_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
static void
cb_show_mouse_toggled (GtkToggleButton *tb,
- ScreenshotData *sd);
-static void
+ ScreenshotData *sd);
+static void
cb_save_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
-static void
-cb_toggle_set_sensi (GtkToggleButton *tb,
+static void
+cb_toggle_set_sensi (GtkToggleButton *tb,
GtkWidget *widget);
-static void
-cb_toggle_set_insensi (GtkToggleButton *tb,
+static void
+cb_toggle_set_insensi (GtkToggleButton *tb,
GtkWidget *widget);
-static void
+static void
cb_open_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
-static void
+static void
cb_clipboard_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
-static void
+static void
cb_show_save_dialog_toggled (GtkToggleButton *tb,
ScreenshotData *sd);
-static void
+static void
cb_close_toggled (GtkToggleButton *tb,
- ScreenshotData *sd);
-static void
-cb_default_folder (GtkWidget *chooser,
- ScreenshotData *sd);
-static void
-cb_delay_spinner_changed (GtkWidget *spinner,
ScreenshotData *sd);
-static gchar
+static void
+cb_default_folder (GtkWidget *chooser,
+ ScreenshotData *sd);
+static void
+cb_delay_spinner_changed (GtkWidget *spinner,
+ ScreenshotData *sd);
+static gchar
*generate_filename_for_uri (const gchar *uri);
-static void
-cb_combo_active_item_changed (GtkWidget *box,
+static void
+cb_combo_active_item_changed (GtkWidget *box,
ScreenshotData *sd);
-static void
-add_item (GAppInfo *app_info,
+static void
+add_item (GAppInfo *app_info,
GtkWidget *liststore);
-static void
+static void
populate_liststore (GtkListStore *liststore);
-static void
-set_default_item (GtkWidget *combobox,
+static void
+set_default_item (GtkWidget *combobox,
ScreenshotData *sd);
static void
cb_progress_upload (goffset current_num_bytes,
@@ -95,7 +95,7 @@
GFile *save_file);
static gchar
*save_screenshot_to (GdkPixbuf *screenshot,
- gchar *save_uri);
+ gchar *save_uri);
@@ -163,7 +163,7 @@
/* Set the widget active if the toggle button is active */
-static void
+static void
cb_toggle_set_sensi (GtkToggleButton *tb, GtkWidget *widget)
{
gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (tb));
@@ -172,7 +172,7 @@
/* Set the widget active if the toggle button is inactive */
-static void
+static void
cb_toggle_set_insensi (GtkToggleButton *tb, GtkWidget *widget)
{
gtk_widget_set_sensitive (widget, !gtk_toggle_button_get_active (tb));
@@ -192,7 +192,7 @@
/* Set the action when the button is toggled */
-static void cb_clipboard_toggled (GtkToggleButton *tb,
+static void cb_clipboard_toggled (GtkToggleButton *tb,
ScreenshotData *sd)
{
if (gtk_toggle_button_get_active (tb))
@@ -216,7 +216,7 @@
{
gtk_toggle_button_get_active (tb) ? (sd->close = 1) : (sd->close = 0);
-}
+}
@@ -224,12 +224,12 @@
static void cb_default_folder (GtkWidget *chooser, ScreenshotData *sd)
{
g_free (sd->screenshot_dir);
-
+
sd->screenshot_dir = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
}
-
+
/* Set the delay according to the spinner */
static void cb_delay_spinner_changed (GtkWidget *spinner, ScreenshotData *sd)
{
@@ -238,9 +238,9 @@
-/* Generates filename Screenshot-n.png (where n is the first integer
+/* Generates filename Screenshot-n.png (where n is the first integer
* greater than 0) so that Screenshot-n.jpg does not exist in the folder
- * whose URI is *uri.
+ * whose URI is *uri.
* @uri: uri of the folder for which the filename should be generated.
* returns: the filename or NULL if *uri == NULL.
*/
@@ -271,7 +271,7 @@
{
g_object_unref (file);
g_object_unref (directory);
-
+
return basename;
}
@@ -283,7 +283,7 @@
basename = g_strdup_printf (_("Screenshot-%d.png"), i);
file = g_file_get_child (directory, basename);
-
+
if (!g_file_query_exists (file, NULL))
exists = FALSE;
@@ -294,7 +294,7 @@
}
g_object_unref (directory);
-
+
return basename;
}
@@ -306,19 +306,19 @@
GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (box));
GtkTreeIter iter;
gchar *active_command = NULL;
-
+
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (box), &iter);
-
+
gtk_tree_model_get (model, &iter, 2, &active_command, -1);
-
+
g_free (sd->app);
sd->app = active_command;
}
-/* Extract the informations from app_info and add them to the
- * liststore.
+/* Extract the informations from app_info and add them to the
+ * liststore.
* */
static void add_item (GAppInfo *app_info, GtkWidget *liststore)
{
@@ -328,58 +328,58 @@
GIcon *icon = g_app_info_get_icon (app_info);
GdkPixbuf *pixbuf = NULL;
GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
-
+
/* Get the icon */
if (G_IS_LOADABLE_ICON (icon))
{
GFile *file = g_file_icon_get_file (G_FILE_ICON (icon));
gchar *path = g_file_get_path (file);
-
- pixbuf =
- gdk_pixbuf_new_from_file_at_size (path, ICON_SIZE,
+
+ pixbuf =
+ gdk_pixbuf_new_from_file_at_size (path, ICON_SIZE,
ICON_SIZE, NULL);
-
+
g_free (path);
g_object_unref (file);
}
else
{
gchar **names = NULL;
-
+
g_object_get (G_OBJECT (icon), "names", &names, NULL);
-
+
if (G_LIKELY (names != NULL))
{
if (names[0] != NULL)
{
- pixbuf = gtk_icon_theme_load_icon (icon_theme,
- names[0],
+ pixbuf = gtk_icon_theme_load_icon (icon_theme,
+ names[0],
ICON_SIZE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
NULL);
- }
-
- g_strfreev (names);
+ }
+
+ g_strfreev (names);
}
}
-
+
if (G_UNLIKELY (pixbuf == NULL))
{
pixbuf = gtk_icon_theme_load_icon (icon_theme, "exec", ICON_SIZE,
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
NULL);
}
-
+
/* Add to the liststore */
gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
-
+
gtk_list_store_set (GTK_LIST_STORE (liststore), &iter,
0, pixbuf,
1, name,
2, command,
-1);
-
- /* Free the stuff */
+
+ /* Free the stuff */
g_free (command);
g_free (name);
g_object_unref (pixbuf);
@@ -393,17 +393,17 @@
{
const gchar *content_type;
GList *list_app;
-
+
content_type = "image/png";
-
+
/* Get all applications for image/png.*/
list_app = g_app_info_get_all_for_type (content_type);
-
+
/* Add them to the liststore */
if (G_LIKELY (list_app != NULL))
{
g_list_foreach (list_app, (GFunc) add_item, liststore);
-
+
g_list_free (list_app);
}
}
@@ -414,12 +414,12 @@
static void set_default_item (GtkWidget *combobox, ScreenshotData *sd)
{
GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
-
- GtkTreeIter iter;
-
+
+ GtkTreeIter iter;
+
/* Get the first iter */
if (G_LIKELY (gtk_tree_model_get_iter_first (model , &iter)))
- {
+ {
gchar *command = NULL;
gboolean found = FALSE;
@@ -427,30 +427,30 @@
do
{
gtk_tree_model_get (model, &iter, 2, &command, -1);
-
+
if (g_str_equal (command, sd->app))
{
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox),
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox),
&iter);
-
+
found = TRUE;
}
-
- g_free (command);
+
+ g_free (command);
}
while (gtk_tree_model_iter_next (model, &iter));
-
+
/* If no suitable item was found, set the first item as active and
* set sd->app accordingly. */
if (G_UNLIKELY (!found))
{
gtk_tree_model_get_iter_first (model , &iter);
gtk_tree_model_get (model, &iter, 2, &command, -1);
-
+
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
-
+
g_free (sd->app);
-
+
sd->app = command;
}
}
@@ -500,7 +500,7 @@
{
TRACE ("An error occurred");
- xfce_err (error->message);
+ screenshooter_error ("%s", error->message);
g_error_free (error);
}
@@ -522,9 +522,9 @@
gtk_widget_destroy (dialog);
}
}
-
+
static gchar
*save_screenshot_to_local_path (GdkPixbuf *screenshot, GFile *save_file)
{
@@ -533,11 +533,11 @@
if (G_UNLIKELY (!gdk_pixbuf_save (screenshot, save_path, "png", &error, NULL)))
{
- xfce_err ("%s", error->message);
-
+ screenshooter_error ("%s", error->message);
+
g_error_free (error);
g_free (save_path);
-
+
return NULL;
}
else
@@ -556,7 +556,7 @@
GFile *save_parent = g_file_get_parent (save_file);
const gchar *parent_uri = g_file_get_uri (save_parent);
GCancellable *cancellable = g_cancellable_new ();
-
+
GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Transfer"),
NULL,
GTK_DIALOG_NO_SEPARATOR,
@@ -573,7 +573,7 @@
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
-
+
gtk_container_set_border_width (GTK_CONTAINER (dialog), 20);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "document-save");
@@ -625,7 +625,7 @@
gtk_dialog_run (GTK_DIALOG (dialog));
g_file_delete (save_file_temp, NULL, NULL);
-
+
g_object_unref (save_file_temp);
g_object_unref (save_parent);
g_object_unref (cancellable);
@@ -638,7 +638,7 @@
{
GFile *save_file = g_file_new_for_uri (save_uri);
gchar *result = NULL;
-
+
/* If the URI is a local one, we save directly */
if (!screenshooter_is_remote_uri (save_uri))
@@ -649,7 +649,7 @@
{
save_screenshot_to_remote_location (screenshot, save_file);
}
-
+
g_object_unref (save_file);
return result;
@@ -669,46 +669,46 @@
GtkWidget *dlg, *main_alignment;
GtkWidget *vbox;
- GtkWidget *capture_table, *actions_table;
-
+ GtkWidget *capture_table, *actions_table;
+
GtkWidget *area_main_box, *area_box, *area_label, *area_alignment;
- GtkWidget *active_window_button,
+ GtkWidget *active_window_button,
*fullscreen_button,
*rectangle_button;
GtkWidget *show_mouse_checkbox;
-
+
GtkWidget *delay_main_box, *delay_box, *delay_label, *delay_alignment;
GtkWidget *delay_spinner_box, *delay_spinner, *seconds_label;
GtkWidget *options_main_box, *options_label, *options_alignment, *options_box;
GtkWidget *save_checkbox;
-
+
GtkWidget *actions_main_box, *actions_label, *actions_alignment;
-
+
GtkWidget *save_radio_button, *dir_chooser;
-
+
GtkWidget *clipboard_radio_button;
-
+
GtkWidget *open_with_radio_button;
-
+
GtkListStore *liststore;
GtkWidget *combobox;
GtkCellRenderer *renderer, *renderer_pixbuf;
-
+
/* Create the dialog */
if (!plugin)
{
- dlg =
+ dlg =
xfce_titled_dialog_new_with_buttons (_("Screenshot"),
NULL,
GTK_DIALOG_DESTROY_WITH_PARENT|
GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
- GTK_STOCK_CANCEL,
+ GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
+ GTK_STOCK_OK,
GTK_RESPONSE_OK,
NULL);
@@ -722,17 +722,17 @@
GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_HELP,
GTK_RESPONSE_HELP,
- GTK_STOCK_CLOSE,
+ GTK_STOCK_CLOSE,
GTK_RESPONSE_OK,
NULL);
-
- xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dlg),
+
+ xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dlg),
_("Preferences"));
- }
+ }
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
-
+
gtk_container_set_border_width (GTK_CONTAINER (dlg), 0);
gtk_window_set_icon_name (GTK_WINDOW (dlg), "applets-screenshooter");
@@ -744,16 +744,16 @@
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_alignment, TRUE, TRUE, 0);
gtk_widget_show (main_alignment);
-
+
/* Create the main box for the dialog */
-
+
vbox = gtk_vbox_new (FALSE, 10);
-
+
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_container_add (GTK_CONTAINER (main_alignment), vbox);
gtk_widget_show (vbox);
-
+
/* Create the table to align the differents parts of the top of the UI */
capture_table = gtk_table_new (2, 2, FALSE);
@@ -764,112 +764,112 @@
gtk_widget_show (capture_table);
/* Create the main box for the regions */
-
+
area_main_box = gtk_vbox_new (FALSE, 6);
gtk_widget_show (area_main_box);
gtk_table_attach_defaults (GTK_TABLE (capture_table), area_main_box, 0, 1, 0, 2);
-
+
/* Create area label */
-
+
area_label = gtk_label_new ("");
-
+
gtk_label_set_markup (GTK_LABEL (area_label),
_("<span weight=\"bold\" stretch=\"semiexpanded\">"
"Region to capture</span>"));
-
+
gtk_misc_set_alignment (GTK_MISC (area_label), 0, 0);
gtk_widget_show (area_label);
gtk_container_add (GTK_CONTAINER (area_main_box), area_label);
-
+
/* Create area alignment */
-
+
area_alignment = gtk_alignment_new (0, 0, 1, 1);
-
+
gtk_container_add (GTK_CONTAINER (area_main_box), area_alignment);
-
+
gtk_alignment_set_padding (GTK_ALIGNMENT (area_alignment), 0, 6, 12, 0);
-
+
gtk_widget_show (area_alignment);
-
- /* Create area box */
+
+ /* Create area box */
area_box = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (area_alignment), area_box);
gtk_container_set_border_width (GTK_CONTAINER (area_box), 0);
gtk_widget_show (area_box);
-
+
/* Create radio buttons for areas to screenshot */
-
+
/* Fullscreen */
-
- fullscreen_button =
- gtk_radio_button_new_with_mnemonic (NULL,
+
+ fullscreen_button =
+ gtk_radio_button_new_with_mnemonic (NULL,
_("Entire screen"));
-
- gtk_box_pack_start (GTK_BOX (area_box),
- fullscreen_button, FALSE,
+
+ gtk_box_pack_start (GTK_BOX (area_box),
+ fullscreen_button, FALSE,
FALSE, 0);
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fullscreen_button),
(sd->region == FULLSCREEN));
-
+
gtk_widget_set_tooltip_text (fullscreen_button,
_("Take a screenshot of the entire screen"));
-
- g_signal_connect (G_OBJECT (fullscreen_button), "toggled",
+
+ g_signal_connect (G_OBJECT (fullscreen_button), "toggled",
G_CALLBACK (cb_fullscreen_screen_toggled),
sd);
-
+
gtk_widget_show (fullscreen_button);
-
+
/* Active window */
-
+
active_window_button =
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (fullscreen_button),
_("Active window"));
-
- gtk_box_pack_start (GTK_BOX (area_box),
- active_window_button, FALSE,
+
+ gtk_box_pack_start (GTK_BOX (area_box),
+ active_window_button, FALSE,
FALSE, 0);
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_window_button),
(sd->region == ACTIVE_WINDOW));
-
+
gtk_widget_set_tooltip_text (active_window_button,
_("Take a screenshot of the active window"));
-
- g_signal_connect (G_OBJECT (active_window_button), "toggled",
+
+ g_signal_connect (G_OBJECT (active_window_button), "toggled",
G_CALLBACK (cb_active_window_toggled),
sd);
-
+
gtk_widget_show (active_window_button);
-
+
/* Rectangle */
-
- rectangle_button =
+
+ rectangle_button =
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (fullscreen_button),
_("Select a region"));
- gtk_box_pack_start (GTK_BOX (area_box),
- rectangle_button, FALSE,
+ gtk_box_pack_start (GTK_BOX (area_box),
+ rectangle_button, FALSE,
FALSE, 0);
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rectangle_button),
(sd->region == SELECT));
-
+
gtk_widget_set_tooltip_text (rectangle_button,
_("Select a region to be captured by clicking a point of "
"the screen without releasing the mouse button, "
"dragging your mouse to the other corner of the region, "
"and releasing the mouse button."));
-
+
g_signal_connect (G_OBJECT (rectangle_button), "toggled",
G_CALLBACK (cb_rectangle_toggled), sd);
-
+
gtk_widget_show (rectangle_button);
/* Create show mouse checkbox */
- show_mouse_checkbox =
+ show_mouse_checkbox =
gtk_check_button_new_with_label (_("Capture the mouse pointer"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_mouse_checkbox),
@@ -880,87 +880,87 @@
gtk_widget_set_tooltip_text (show_mouse_checkbox,
_("Display the mouse pointer on the screenshot"));
- gtk_box_pack_start (GTK_BOX (area_box),
- show_mouse_checkbox, FALSE,
+ gtk_box_pack_start (GTK_BOX (area_box),
+ show_mouse_checkbox, FALSE,
FALSE, 5);
gtk_widget_show (show_mouse_checkbox);
-
- g_signal_connect (G_OBJECT (show_mouse_checkbox), "toggled",
+
+ g_signal_connect (G_OBJECT (show_mouse_checkbox), "toggled",
G_CALLBACK (cb_show_mouse_toggled), sd);
g_signal_connect (G_OBJECT (rectangle_button), "toggled",
G_CALLBACK (cb_toggle_set_insensi), show_mouse_checkbox);
/* Create the main box for the delay stuff */
-
+
delay_main_box = gtk_vbox_new (FALSE, 6);
-
+
gtk_widget_show (delay_main_box);
gtk_table_attach_defaults (GTK_TABLE (capture_table), delay_main_box, 1, 2, 0, 1);
-
+
/* Create delay label */
-
+
delay_label = gtk_label_new ("");
-
+
gtk_label_set_markup (GTK_LABEL(delay_label),
_("<span weight=\"bold\" stretch=\"semiexpanded\">"
"Delay before capturing</span>"));
-
+
gtk_misc_set_alignment(GTK_MISC (delay_label), 0, 0);
gtk_box_pack_start (GTK_BOX (delay_main_box), delay_label, FALSE, FALSE, 0);
-
+
gtk_widget_show (delay_label);
-
+
/* Create delay alignment */
-
+
delay_alignment = gtk_alignment_new (0, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (delay_main_box), delay_alignment, FALSE, FALSE, 0);
-
+
gtk_alignment_set_padding (GTK_ALIGNMENT (delay_alignment), 0, 6, 12, 0);
-
+
gtk_widget_show (delay_alignment);
-
+
/* Create delay box */
-
+
delay_box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (delay_alignment), delay_box);
gtk_container_set_border_width (GTK_CONTAINER (delay_box), 0);
gtk_widget_show (delay_box);
-
+
/* Create delay spinner */
-
+
delay_spinner_box = gtk_hbox_new (FALSE, 4);
gtk_widget_show (delay_spinner_box);
-
+
gtk_box_pack_start (GTK_BOX (delay_box), delay_spinner_box, FALSE, FALSE, 0);
delay_spinner = gtk_spin_button_new_with_range(0.0, 60.0, 1.0);
-
+
gtk_spin_button_set_value (GTK_SPIN_BUTTON (delay_spinner), sd->delay);
-
+
gtk_widget_set_tooltip_text (delay_spinner,
- _("Delay in seconds before the screenshot is taken"));
-
+ _("Delay in seconds before the screenshot is taken"));
+
gtk_widget_show (delay_spinner);
-
+
gtk_box_pack_start (GTK_BOX (delay_spinner_box), delay_spinner, FALSE, FALSE, 0);
seconds_label = gtk_label_new (_("seconds"));
gtk_widget_show (seconds_label);
-
+
gtk_box_pack_start (GTK_BOX (delay_spinner_box), seconds_label, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (delay_spinner), "value-changed",
G_CALLBACK (cb_delay_spinner_changed), sd);
-
- /* Set the delay box as inactive when we capture rectangles */
+
+ /* Set the delay box as inactive when we capture rectangles */
g_signal_connect (G_OBJECT (rectangle_button), "toggled",
G_CALLBACK (cb_toggle_set_insensi), delay_box);
-
+
/* Set the default state */
cb_toggle_set_insensi (GTK_TOGGLE_BUTTON (rectangle_button), delay_box);
@@ -979,19 +979,19 @@
gtk_label_set_markup (GTK_LABEL(options_label),
_("<span weight=\"bold\" stretch=\"semiexpanded\">After "
"capturing</span>"));
-
- gtk_misc_set_alignment(GTK_MISC (options_label), 0, 0);
+
+ gtk_misc_set_alignment(GTK_MISC (options_label), 0, 0);
gtk_widget_show (options_label);
gtk_box_pack_start (GTK_BOX (options_main_box), options_label, FALSE, FALSE, 0);
/* Create options alignment */
-
+
options_alignment = gtk_alignment_new (0, 0, 1, 1);
gtk_container_add (GTK_CONTAINER (options_main_box), options_alignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (options_alignment), 0, 6, 12, 0);
-
+
gtk_widget_show (options_alignment);
/* Create the options box to be stored in the options alignment*/
@@ -1001,8 +1001,8 @@
gtk_container_set_border_width (GTK_CONTAINER (options_box), 0);
gtk_widget_show (options_box);
- /* Display the save dialog checkbox */
-
+ /* Display the save dialog checkbox */
+
save_checkbox = gtk_check_button_new_with_label (_("Show the save dialog"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (save_checkbox),
@@ -1013,16 +1013,16 @@
"and the save location"));
gtk_box_pack_start (GTK_BOX (options_box), save_checkbox, FALSE, FALSE, 0);
-
+
gtk_widget_show (save_checkbox);
-
- g_signal_connect (G_OBJECT (save_checkbox), "toggled",
+
+ g_signal_connect (G_OBJECT (save_checkbox), "toggled",
G_CALLBACK (cb_show_save_dialog_toggled), sd);
/* Create the 'close the user interface after taking the screenshot' checkbox */
if (!plugin)
{
- GtkWidget *close_checkbox =
+ GtkWidget *close_checkbox =
gtk_check_button_new_with_label (_("Close the application"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (close_checkbox),
@@ -1037,7 +1037,7 @@
gtk_widget_show (close_checkbox);
- g_signal_connect (G_OBJECT (close_checkbox), "toggled",
+ g_signal_connect (G_OBJECT (close_checkbox), "toggled",
G_CALLBACK (cb_close_toggled), sd);
}
@@ -1049,13 +1049,13 @@
gtk_widget_show (actions_main_box);
/* Create actions label */
-
+
actions_label = gtk_label_new ("");
-
+
gtk_label_set_markup (GTK_LABEL (actions_label),
_("<span weight=\"bold\" stretch=\"semiexpanded\">Action"
"</span>"));
-
+
gtk_misc_set_alignment (GTK_MISC (actions_label), 0, 0);
gtk_widget_show (actions_label);
gtk_box_pack_start (GTK_BOX (actions_main_box), actions_label, FALSE, FALSE, 0);
@@ -1078,19 +1078,19 @@
gtk_container_add (GTK_CONTAINER (actions_alignment), actions_table);
gtk_widget_show (actions_table);
-
+
/* Save option radio button */
-
+
save_radio_button = gtk_radio_button_new_with_mnemonic (NULL, _("Save in:"));
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (save_radio_button),
(sd->action == SAVE));
-
- g_signal_connect (G_OBJECT (save_radio_button), "toggled",
+
+ g_signal_connect (G_OBJECT (save_radio_button), "toggled",
G_CALLBACK (cb_save_toggled), sd);
-
+
gtk_widget_set_tooltip_text (save_radio_button, _("Save the screenshot to a PNG file"));
-
+
gtk_widget_show (save_radio_button);
gtk_table_attach_defaults (GTK_TABLE (actions_table), save_radio_button, 0, 1, 0, 1);
@@ -1105,118 +1105,118 @@
/* Directory chooser */
- dir_chooser =
+ dir_chooser =
gtk_file_chooser_button_new (_("Default save location"),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
-
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dir_chooser),
+
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dir_chooser),
sd->screenshot_dir);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dir_chooser), FALSE);
-
+
gtk_widget_show (dir_chooser);
-
+
gtk_widget_set_tooltip_text (dir_chooser, _("Set the default save location"));
- g_signal_connect (G_OBJECT (dir_chooser), "selection-changed",
+ g_signal_connect (G_OBJECT (dir_chooser), "selection-changed",
G_CALLBACK (cb_default_folder), sd);
-
+
g_signal_connect (G_OBJECT (save_radio_button), "toggled",
G_CALLBACK (cb_toggle_set_sensi), dir_chooser);
gtk_table_attach_defaults (GTK_TABLE (actions_table), dir_chooser, 1, 2, 0, 1);
/* Copy to clipboard radio button */
-
- clipboard_radio_button =
+
+ clipboard_radio_button =
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (save_radio_button),
_("Copy to the clipboard"));
-
+
gtk_widget_show (clipboard_radio_button);
-
+
gtk_widget_set_tooltip_text (clipboard_radio_button,
_("Copy the screenshot to the clipboard so that it can be "
"pasted later"));
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (clipboard_radio_button),
(sd->action == CLIPBOARD));
-
- g_signal_connect (G_OBJECT (clipboard_radio_button), "toggled",
+
+ g_signal_connect (G_OBJECT (clipboard_radio_button), "toggled",
G_CALLBACK (cb_clipboard_toggled), sd);
gtk_table_attach_defaults (GTK_TABLE (actions_table), clipboard_radio_button,
0, 1, 1, 2);
/* Open with radio button */
-
- open_with_radio_button =
+
+ open_with_radio_button =
gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (save_radio_button),
_("Open with:"));
-
+
gtk_widget_show (open_with_radio_button);
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (open_with_radio_button),
(sd->action == OPEN));
-
- g_signal_connect (G_OBJECT (open_with_radio_button), "toggled",
+
+ g_signal_connect (G_OBJECT (open_with_radio_button), "toggled",
G_CALLBACK (cb_open_toggled), sd);
-
+
gtk_widget_set_tooltip_text (open_with_radio_button,
_("Open the screenshot with the chosen application"));
gtk_table_attach_defaults (GTK_TABLE (actions_table), open_with_radio_button,
0, 1, 2, 3);
-
+
/* Open with combobox */
-
+
liststore = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
-
+
combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (liststore));
-
+
renderer = gtk_cell_renderer_text_new ();
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
-
+
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer_pixbuf, FALSE);
-
+
gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
-
+
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 1, NULL);
-
+
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer_pixbuf,
- "pixbuf", 0, NULL);
-
+ "pixbuf", 0, NULL);
+
populate_liststore (liststore);
-
+
set_default_item (combobox, sd);
-
+
gtk_table_attach_defaults (GTK_TABLE (actions_table), combobox, 1, 2, 2, 3);
-
- g_signal_connect (G_OBJECT (combobox), "changed",
+
+ g_signal_connect (G_OBJECT (combobox), "changed",
G_CALLBACK (cb_combo_active_item_changed), sd);
-
- gtk_widget_show_all (combobox);
-
+
+ gtk_widget_show_all (combobox);
+
gtk_widget_set_tooltip_text (combobox, _("Application to open the screenshot"));
g_signal_connect (G_OBJECT (open_with_radio_button), "toggled",
G_CALLBACK (cb_toggle_set_sensi), combobox);
-
+
/* Run the callback functions to grey/ungrey the correct widgets */
-
+
cb_toggle_set_sensi (GTK_TOGGLE_BUTTON (open_with_radio_button), combobox);
-
- return dlg;
+
+ return dlg;
}
-/* Saves the screenshot according to the options in sd.
+/* Saves the screenshot according to the options in sd.
* @screenshot: a GdkPixbuf containing our screenshot
* show_save_dialog: whether the save dialog should be shown.
* @default_dir: the default save location.
*/
-gchar
-*screenshooter_save_screenshot (GdkPixbuf *screenshot,
+gchar
+*screenshooter_save_screenshot (GdkPixbuf *screenshot,
gboolean show_save_dialog,
const gchar *default_dir)
{
@@ -1232,26 +1232,26 @@
gchar *save_uri = NULL;
gint dialog_response;
- /* If the user wants a save dialog, we run it, and grab the
+ /* If the user wants a save dialog, we run it, and grab the
* filename the user has chosen. */
-
+
/* Create the dialog and set its default properties */
- chooser =
+ chooser =
gtk_file_chooser_dialog_new (_("Save screenshot as..."),
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL,
+ GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE,
+ GTK_STOCK_SAVE,
GTK_RESPONSE_ACCEPT,
NULL);
-
+
gtk_window_set_icon_name (GTK_WINDOW (chooser), "applets-screenshooter");
-
+
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (chooser), TRUE);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
-
+
gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (chooser), default_dir);
@@ -1259,29 +1259,29 @@
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), filename);
/* Create the preview and the thumbnail */
-
+
preview = gtk_image_new ();
-
+
gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (chooser), preview);
-
- thumbnail =
- gdk_pixbuf_scale_simple (screenshot,
- gdk_pixbuf_get_width(screenshot)/5,
- gdk_pixbuf_get_height(screenshot)/5,
+
+ thumbnail =
+ gdk_pixbuf_scale_simple (screenshot,
+ gdk_pixbuf_get_width(screenshot)/5,
+ gdk_pixbuf_get_height(screenshot)/5,
GDK_INTERP_BILINEAR);
-
+
gtk_image_set_from_pixbuf (GTK_IMAGE (preview), thumbnail);
-
+
g_object_unref (thumbnail);
-
+
dialog_response = gtk_dialog_run (GTK_DIALOG (chooser));
-
+
/* The user pressed the save button */
if (G_LIKELY (dialog_response == GTK_RESPONSE_ACCEPT))
{
save_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
}
-
+
gtk_widget_destroy (chooser);
if (G_LIKELY (save_uri != NULL))
@@ -1290,12 +1290,12 @@
g_free (save_uri);
}
- }
+ }
else
- {
+ {
/* Else, we just save the file in the default folder */
gchar *save_uri = g_build_filename (default_dir, filename, NULL);
-
+
savename = save_screenshot_to (screenshot, save_uri);
g_free (save_uri);
@@ -1304,6 +1304,6 @@
TRACE ("Free the gchars and unref the GFiles");
g_free (filename);
-
+
return savename;
}
Modified: xfce4-screenshooter/trunk/lib/screenshooter-dialogs.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-dialogs.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-dialogs.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -19,7 +19,7 @@
#ifndef __HAVE_DIALOGS_H__
#define __HAVE_DIALOGS_H__
-
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -37,11 +37,9 @@
-GtkWidget
-*screenshooter_dialog_new (ScreenshotData *sd,
- gboolean plugin);
-gchar
-*screenshooter_save_screenshot (GdkPixbuf *screenshot,
- gboolean show_save_dialog,
- const gchar *default_dir);
-#endif
+GtkWidget *screenshooter_dialog_new (ScreenshotData *sd,
+ gboolean plugin);
+gchar *screenshooter_save_screenshot (GdkPixbuf *screenshot,
+ gboolean show_save_dialog,
+ const gchar *default_dir);
+#endif
Modified: xfce4-screenshooter/trunk/lib/screenshooter-job.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-job.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-job.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -173,7 +173,8 @@
g_return_if_fail (format != NULL);
if (G_UNLIKELY (exo_job_is_cancelled (EXO_JOB (job))))
-
+ return;
+
va_start (va_args, format);
message = g_strdup_vprintf (format, va_args);
va_end (va_args);
Modified: xfce4-screenshooter/trunk/lib/screenshooter-job.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-job.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-job.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -66,8 +66,8 @@
GtkListStore *info,
const gchar *format,
...);
-
+
void screenshooter_job_image_uploaded (ScreenshooterJob *job,
const gchar *file_name);
Modified: xfce4-screenshooter/trunk/lib/screenshooter-simple-job.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-simple-job.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-simple-job.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -51,12 +51,12 @@
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
- type = g_type_register_static_simple (SCREENSHOOTER_TYPE_JOB,
+ type = g_type_register_static_simple (SCREENSHOOTER_TYPE_JOB,
"ScreenshooterSimpleJob",
sizeof (ScreenshooterSimpleJobClass),
(GClassInitFunc) screenshooter_simple_job_class_init,
sizeof (ScreenshooterSimpleJob),
- NULL,
+ NULL,
0);
}
@@ -114,7 +114,7 @@
{
g_assert (err != NULL || exo_job_is_cancelled (job));
- /* set error if the job was cancelled. otherwise just propagate
+ /* set error if the job was cancelled. otherwise just propagate
* the results of the processing function */
if (exo_job_set_error_if_cancelled (job, error))
{
Modified: xfce4-screenshooter/trunk/lib/screenshooter-simple-job.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-simple-job.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-simple-job.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -34,7 +34,7 @@
/**
* ScreenshooterSimpleJobFunc:
* @job : a #ScreenshooterJob.
- * @param_values : a #GValueArray of the #GValue<!---->s passed to
+ * @param_values : a #GValueArray of the #GValue<!---->s passed to
* screenshooter_simple_job_launch().
* @error : return location for errors.
*
Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -30,7 +30,7 @@
* @screenshot: the screenshot
*/
void
-screenshooter_copy_to_clipboard (GdkPixbuf *screenshot)
+screenshooter_copy_to_clipboard (GdkPixbuf *screenshot)
{
GtkClipboard *clipboard;
@@ -65,7 +65,7 @@
gint close_app = 1;
gchar *screenshot_dir = g_strdup (home_uri);
gchar *app = g_strdup ("none");
-
+
if (G_LIKELY (file != NULL))
{
TRACE ("Open the rc file");
@@ -82,23 +82,23 @@
show_save_dialog = xfce_rc_read_int_entry (rc, "show_save_dialog", 1);
show_mouse = xfce_rc_read_int_entry (rc, "show_mouse", 1);
close_app = xfce_rc_read_int_entry (rc, "close", 1);
-
+
g_free (app);
app = g_strdup (xfce_rc_read_entry (rc, "app", "none"));
-
+
g_free (screenshot_dir);
screenshot_dir =
g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", home_uri));
}
TRACE ("Close the rc file");
-
+
xfce_rc_close (rc);
}
-
+
/* And set the sd values */
TRACE ("Set the values of the struct");
-
+
sd->delay = delay;
sd->region = region;
sd->action = action;
@@ -119,17 +119,17 @@
screenshooter_write_rc_file (gchar *file, ScreenshotData *sd)
{
XfceRc *rc;
-
+
g_return_if_fail (file != NULL);
TRACE ("Open the rc file");
rc = xfce_rc_simple_open (file, FALSE);
-
+
g_return_if_fail (rc != NULL);
TRACE ("Write the entries.");
-
+
xfce_rc_write_int_entry (rc, "delay", sd->delay);
xfce_rc_write_int_entry (rc, "region", sd->region);
xfce_rc_write_int_entry (rc, "action", sd->action);
@@ -142,7 +142,7 @@
TRACE ("Flush and close the rc file");
xfce_rc_flush (rc);
-
+
xfce_rc_close (rc);
}
@@ -159,7 +159,7 @@
GError *error = NULL;
g_return_if_fail (screenshot_path != NULL);
-
+
TRACE ("Path was != NULL");
g_return_if_fail (!g_str_equal (application, "none"));
@@ -169,17 +169,17 @@
command = g_strconcat (application, " ", screenshot_path, NULL);
TRACE ("Launch the command");
-
- /* Execute the command and show an error dialog if there was
+
+ /* Execute the command and show an error dialog if there was
* an error. */
if (!g_spawn_command_line_async (command, &error))
{
TRACE ("An error occured");
- xfce_err (error->message);
+ screenshooter_error ("%s", error->message);
g_error_free (error);
}
-
+
g_free (command);
}
@@ -217,7 +217,7 @@
gchar *rot13 (gchar *string)
{
gchar *result = string;
-
+
for (; *string; string++)
if (*string >= 'a' && *string <= 'z')
*string = (*string - 'a' + 13) % 26 + 'a';
@@ -227,3 +227,35 @@
return result;
}
+
+
+/**
+ * screenshooter_error:
+ * @format: printf()-style format string
+ * @...: arguments for @format
+ *
+ * Shows a modal error dialog with the given error text. Blocks until the user
+ * clicks the OK button.
+ **/
+void screenshooter_error (const gchar *format, ...)
+{
+ va_list va_args = NULL;
+ gchar *message = NULL;
+ GtkWidget *dialog;
+
+ g_return_if_fail (format != NULL);
+
+ va_start (va_args, format);
+ message = g_strdup_vprintf (format, va_args);
+ va_end (va_args);
+
+ dialog =
+ gtk_message_dialog_new (NULL, GTK_DIALOG_NO_SEPARATOR, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK, "%s", message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ g_free (message);
+}
+
Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.h 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.h 2009-05-16 21:47:18 UTC (rev 7352)
@@ -34,28 +34,17 @@
-void
-screenshooter_copy_to_clipboard (GdkPixbuf *screenshot) ;
+void screenshooter_copy_to_clipboard (GdkPixbuf *screenshot) ;
+void screenshooter_read_rc_file (gchar *file,
+ ScreenshotData *sd);
+void screenshooter_write_rc_file (gchar *file,
+ ScreenshotData *sd);
+void screenshooter_open_screenshot (const gchar *screenshot_path,
+ const gchar *application);
+gchar *screenshooter_get_home_uri ();
+gboolean screenshooter_is_remote_uri (const gchar *uri);
+gchar *rot13 (gchar *string);
+void screenshooter_error (const gchar *format,
+ ...);
-void
-screenshooter_read_rc_file (gchar *file,
- ScreenshotData *sd);
-
-void
-screenshooter_write_rc_file (gchar *file,
- ScreenshotData *sd);
-
-void
-screenshooter_open_screenshot (const gchar *screenshot_path,
- const gchar *application);
-
-gchar
-*screenshooter_get_home_uri ();
-
-gboolean
-screenshooter_is_remote_uri (const gchar *uri);
-
-gchar
-*rot13 (gchar *string);
-
-#endif
+#endif
Modified: xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -85,7 +85,7 @@
{
TRACE ("An error occured when opening the URL");
- xfce_err (error->message);
+ screenshooter_error ("%s", error->message);
g_error_free (error);
}
}
@@ -434,12 +434,12 @@
{
gchar *field_name = NULL;
gchar *field_value = NULL;
-
+
gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
0, &field_name,
1, &field_value,
-1);
-
+
if (g_str_equal (field_name, "user"))
{
user = g_strdup (field_value);
@@ -456,7 +456,7 @@
{
comment = g_strdup (field_value);
}
-
+
g_free (field_name);
g_free (field_value);
}
@@ -797,25 +797,25 @@
0, 0, NULL,
cb_image_uploaded,
NULL);
-
+
g_signal_handlers_disconnect_matched (job,
G_SIGNAL_MATCH_FUNC,
0, 0, NULL,
cb_error,
NULL);
-
+
g_signal_handlers_disconnect_matched (job,
G_SIGNAL_MATCH_FUNC,
0, 0, NULL,
cb_ask_for_information,
NULL);
-
+
g_signal_handlers_disconnect_matched (job,
G_SIGNAL_MATCH_FUNC,
0, 0, NULL,
cb_update_info,
NULL);
-
+
g_signal_handlers_disconnect_matched (job,
G_SIGNAL_MATCH_FUNC,
0, 0, NULL,
Modified: xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c
===================================================================
--- xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/panel-plugin/screenshooter-plugin.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -47,7 +47,7 @@
GtkWidget *button;
GtkWidget *image;
-
+
int style_id;
ScreenshotData *sd;
}
@@ -56,42 +56,42 @@
/* Protoypes */
-
-static void
+
+static void
screenshooter_plugin_construct (XfcePanelPlugin *plugin);
-static void
-screenshooter_plugin_read_rc_file (XfcePanelPlugin *plugin,
- PluginData *pd);
-
-static void
-screenshooter_plugin_write_rc_file (XfcePanelPlugin *plugin,
+static void
+screenshooter_plugin_read_rc_file (XfcePanelPlugin *plugin,
PluginData *pd);
-static gboolean
-cb_set_size (XfcePanelPlugin *plugin,
- int size,
+static void
+screenshooter_plugin_write_rc_file (XfcePanelPlugin *plugin,
PluginData *pd);
-
-static void
+
+static gboolean
+cb_set_size (XfcePanelPlugin *plugin,
+ int size,
+ PluginData *pd);
+
+static void
cb_properties_dialog (XfcePanelPlugin *plugin,
PluginData *pd);
-
+
static void
-cb_dialog_response (GtkWidget *dlg,
+cb_dialog_response (GtkWidget *dlg,
int response,
PluginData *pd);
-
-static void
-cb_free_data (XfcePanelPlugin *plugin,
+
+static void
+cb_free_data (XfcePanelPlugin *plugin,
PluginData *pd);
-
-static void
-cb_button_clicked (GtkWidget *button,
+
+static void
+cb_button_clicked (GtkWidget *button,
PluginData *pd);
static void
-cb_style_set (XfcePanelPlugin *plugin,
+cb_style_set (XfcePanelPlugin *plugin,
gpointer ignored,
PluginData *pd);
@@ -104,29 +104,29 @@
-/* Modify the size of the panel button
-Returns TRUE if succesful.
+/* Modify the size of the panel button
+Returns TRUE if succesful.
*/
static gboolean
cb_set_size (XfcePanelPlugin *plugin, int size, PluginData *pd)
{
GdkPixbuf *pb;
-
+
int width = size - 2 - 2 * MAX (pd->button->style->xthickness,
pd->button->style->ythickness);
TRACE ("Get the icon from the theme");
-
+
pb = xfce_themed_icon_load (SCREENSHOT_ICON_NAME, width);
TRACE ("Set the new icon");
-
+
gtk_image_set_from_pixbuf (GTK_IMAGE (pd->image), pb);
-
+
g_object_unref (pb);
TRACE ("Request size for the plugin");
-
+
gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size);
return TRUE;
@@ -136,7 +136,7 @@
/* Free the panel plugin data stored in pd
plugin: a XfcePanelPlugin (a screenshooter one).
-pd: the associated PluginData.
+pd: the associated PluginData.
*/
static void
cb_free_data (XfcePanelPlugin *plugin, PluginData *pd)
@@ -160,14 +160,14 @@
static void
cb_button_clicked (GtkWidget *button, PluginData *pd)
{
- /* Make the button unclickable so that the user does not press it while
+ /* Make the button unclickable so that the user does not press it while
another screenshot is in progress */
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
TRACE ("Start taking the screenshot");
-
+
screenshooter_take_and_output_screenshot (pd->sd);
-
+
/* Make the panel button clickable */
gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
}
@@ -194,9 +194,9 @@
screenshooter_plugin_read_rc_file (XfcePanelPlugin *plugin, PluginData *pd)
{
gchar *rc_file = xfce_panel_plugin_lookup_rc_file (plugin);
-
+
screenshooter_read_rc_file (rc_file, pd->sd);
-
+
g_free (rc_file);
}
@@ -210,9 +210,9 @@
screenshooter_plugin_write_rc_file (XfcePanelPlugin *plugin, PluginData *pd)
{
gchar * rc_file = xfce_panel_plugin_save_location (plugin, TRUE);
-
- screenshooter_write_rc_file (rc_file, pd->sd);
-
+
+ screenshooter_write_rc_file (rc_file, pd->sd);
+
g_free (rc_file);
}
@@ -230,24 +230,24 @@
g_object_set_data (G_OBJECT (pd->plugin), "dialog", NULL);
gtk_widget_destroy (dlg);
-
+
/* Update tooltips according to the chosen option */
set_panel_button_tooltip (pd);
-
+
/* Unblock the menu and save options */
xfce_panel_plugin_unblock_menu (pd->plugin);
screenshooter_plugin_write_rc_file (pd->plugin, pd);
}
-
+
if (response == GTK_RESPONSE_HELP)
{
GError *error_help = NULL;
-
- /* Execute the help and show an error dialog if there was
+
+ /* Execute the help and show an error dialog if there was
* an error. */
if (!g_spawn_command_line_async ("xfhelp4 xfce4-screenshooter.html", &error_help))
{
- xfce_err (error_help->message);
+ screenshooter_error ("%s", error_help->message);
g_error_free (error_help);
}
}
@@ -262,20 +262,20 @@
GtkWidget *dlg;
TRACE ("Create the dialog");
-
+
dlg = screenshooter_dialog_new (pd->sd, TRUE);
-
+
/* Block the menu to prevent the user from launching several dialogs at
the same time */
TRACE ("Block the menu");
-
+
xfce_panel_plugin_block_menu (plugin);
TRACE ("Run the dialog");
-
+
g_object_set_data (G_OBJECT (plugin), "dialog", dlg);
-
+
g_signal_connect (dlg, "response", G_CALLBACK (cb_dialog_response), pd);
gtk_widget_show (dlg);
@@ -321,7 +321,7 @@
pd->sd = sd;
TRACE ("Initialize the text domain");
-
+
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
pd->plugin = plugin;
@@ -330,33 +330,33 @@
TRACE ("Read the preferences file");
screenshooter_plugin_read_rc_file (plugin, pd);
-
+
/* Create the panel button */
TRACE ("Create the panel button");
-
+
pd->button = xfce_create_panel_button ();
pd->image = gtk_image_new ();
gtk_container_add (GTK_CONTAINER (pd->button), GTK_WIDGET (pd->image));
-
+
/* Set the tooltips if available */
TRACE ("Set the default tooltip");
-
+
set_panel_button_tooltip (pd);
TRACE ("Add the button to the panel");
-
+
gtk_widget_show_all (pd->button);
-
+
gtk_container_add (GTK_CONTAINER (plugin), pd->button);
xfce_panel_plugin_add_action_widget (plugin, pd->button);
-
+
/* Set the callbacks */
TRACE ("Set the clicked callback");
-
+
g_signal_connect (pd->button, "clicked", G_CALLBACK (cb_button_clicked), pd);
TRACE ("Set the free data callback");
@@ -374,7 +374,7 @@
TRACE ("Set the configuration menu");
xfce_panel_plugin_menu_show_configure (plugin);
-
+
g_signal_connect (plugin, "configure-plugin", G_CALLBACK (cb_properties_dialog), pd);
}
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (screenshooter_plugin_construct);
Modified: xfce4-screenshooter/trunk/src/main.c
===================================================================
--- xfce4-screenshooter/trunk/src/main.c 2009-05-16 17:40:30 UTC (rev 7351)
+++ xfce4-screenshooter/trunk/src/main.c 2009-05-16 21:47:18 UTC (rev 7352)
@@ -122,7 +122,7 @@
/* Launch the help page and show an error dialog if there was an error. */
if (!g_spawn_command_line_async ("xfhelp4 xfce4-screenshooter.html", &error_help))
{
- xfce_err (error_help->message);
+ screenshooter_error ("%s", error_help->message);
g_error_free (error_help);
}
}
@@ -310,8 +310,10 @@
}
else
{
- xfce_err (_("%s is not a valid directory, the default"
- " directory will be used."), screenshot_dir);
+ screenshooter_error ("%s",
+ _("%s is not a valid directory, the default"
+ " directory will be used."),
+ screenshot_dir);
}
g_object_unref (default_save_dir);
More information about the Goodies-commits
mailing list