Clean up formatting. Remove extra whitespace, convert tabs to spaces, fix indentation

parent 39471e5e
......@@ -176,7 +176,7 @@ cheese_flash_start_fade (gpointer data)
return FALSE;
}
flash_priv->fade_timeout_tag =
flash_priv->fade_timeout_tag =
g_timeout_add_full (G_PRIORITY_DEFAULT,
1000.0 / FLASH_ANIMATION_RATE,
cheese_flash_opacity_fade,
......@@ -201,7 +201,7 @@ cheese_flash_fire (CheeseFlash *flash,
gtk_widget_set_opacity (GTK_WIDGET (flash_window), 0.99);
gtk_widget_show_all (GTK_WIDGET (flash_window));
flash_priv->flash_timeout_tag =
flash_priv->flash_timeout_tag =
g_timeout_add_full (G_PRIORITY_DEFAULT,
FLASH_DURATION,
cheese_flash_start_fade,
......
......@@ -35,7 +35,7 @@ Take the screenshot after the specified delay [in seconds].
.TP
\fB-e, --border-effect=\fIEFFECT\fB,\fR
Add an effect to the outside of the screenshot border.
\fIEFFECT\fR can be ``shadow''
\fIEFFECT\fR can be ``shadow''
(adding drop shadow), ``border'' (adding rectangular
space around the screenshot), ``vintage'' (desaturating
the screenshot slightly, tinting it and adding
......
......@@ -4,4 +4,4 @@ delay = /apps/gnome-screenshot/delay
last-save-directory = /apps/gnome-screenshot/last_save_directory
include-border = /apps/gnome-screenshot/include_border
include-pointer = /apps/gnome-screenshot/include_pointer
border-effect = /apps/gnome-screenshot/border_effect
\ No newline at end of file
border-effect = /apps/gnome-screenshot/border_effect
......@@ -89,7 +89,7 @@ set_recent_entry (ScreenshotApplication *self)
}
recent = gtk_recent_manager_get_default ();
exec_name = g_app_info_get_executable (app);
app_exec = g_strjoin (" ", exec_name, "%u", NULL);
......@@ -151,7 +151,7 @@ save_pixbuf_handle_error (ScreenshotApplication *self,
gchar *detail = g_strdup_printf (_("A file named “%s” already exists in “%s”"),
file_name, folder_name);
gint response;
response = screenshot_show_dialog (GTK_WINDOW (dialog->dialog),
GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO,
......@@ -215,7 +215,7 @@ save_pixbuf_ready_cb (GObject *source,
static void
find_out_writable_format_by_extension (gpointer data,
gpointer user_data)
gpointer user_data)
{
GdkPixbufFormat *format = (GdkPixbufFormat*) data;
gchar **name = (gchar **) user_data;
......@@ -229,7 +229,7 @@ find_out_writable_format_by_extension (gpointer data,
gdk_pixbuf_format_is_writable (format) == TRUE)
{
*name = gdk_pixbuf_format_get_name (format);
found = TRUE;
found = TRUE;
break;
}
ptr++;
......@@ -371,7 +371,7 @@ screenshot_save_to_file (ScreenshotApplication *self)
NULL, FALSE,
G_FILE_CREATE_NONE,
G_PRIORITY_DEFAULT,
NULL,
NULL,
save_file_create_ready_cb, self);
}
else
......@@ -614,7 +614,7 @@ screenshot_start (ScreenshotApplication *self)
delay = 0;
/* HACK: give time to the dialog to actually disappear.
* We don't have any way to tell when the compositor has finished
* We don't have any way to tell when the compositor has finished
* re-drawing.
*/
if (delay == 0 && screenshot_config->interactive)
......
......@@ -40,12 +40,12 @@
typedef struct _ScreenshotApplicationPriv ScreenshotApplicationPriv;
typedef struct {
GtkApplication parent;
ScreenshotApplicationPriv *priv;
GtkApplication parent;
ScreenshotApplicationPriv *priv;
} ScreenshotApplication;
typedef struct {
GtkApplicationClass parent_class;
GtkApplicationClass parent_class;
} ScreenshotApplicationClass;
GType screenshot_application_get_type (void);
......
......@@ -140,7 +140,7 @@ select_area_key_press (GtkWidget *window,
gtk_main_quit ();
}
return TRUE;
}
......@@ -197,7 +197,7 @@ create_select_window (void)
gtk_window_move (GTK_WINDOW (window), -100, -100);
gtk_window_resize (GTK_WINDOW (window), 10, 10);
gtk_widget_show (window);
return window;
}
......@@ -253,7 +253,7 @@ screenshot_select_area_x11_async (CallbackData *cb_data)
res = gdk_device_grab (pointer, gtk_widget_get_window (data.window),
GDK_OWNERSHIP_NONE, FALSE,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK,
cursor, GDK_CURRENT_TIME);
......
......@@ -50,18 +50,18 @@ typedef struct {
extern ScreenshotConfig *screenshot_config;
void screenshot_load_config (void);
void screenshot_save_config (void);
gboolean screenshot_config_parse_command_line (gboolean clipboard_arg,
gboolean window_arg,
gboolean area_arg,
gboolean include_border_arg,
gboolean disable_border_arg,
gboolean include_pointer_arg,
const gchar *border_effect_arg,
guint delay_arg,
gboolean interactive_arg,
const gchar *file_arg);
void screenshot_load_config (void);
void screenshot_save_config (void);
gboolean screenshot_config_parse_command_line (gboolean clipboard_arg,
gboolean window_arg,
gboolean area_arg,
gboolean include_border_arg,
gboolean disable_border_arg,
gboolean include_pointer_arg,
const gchar *border_effect_arg,
guint delay_arg,
gboolean interactive_arg,
const gchar *file_arg);
G_END_DECLS
......
......@@ -71,8 +71,8 @@ on_preview_draw (GtkWidget *drawing_area,
static gboolean
on_preview_button_press_event (GtkWidget *drawing_area,
GdkEventButton *event,
gpointer data)
GdkEventButton *event,
gpointer data)
{
ScreenshotDialog *dialog = data;
......@@ -84,8 +84,8 @@ on_preview_button_press_event (GtkWidget *drawing_area,
static gboolean
on_preview_button_release_event (GtkWidget *drawing_area,
GdkEventButton *event,
gpointer data)
GdkEventButton *event,
gpointer data)
{
ScreenshotDialog *dialog = data;
......@@ -97,11 +97,11 @@ on_preview_button_release_event (GtkWidget *drawing_area,
static void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
ScreenshotDialog *dialog)
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
ScreenshotDialog *dialog)
{
if (info == TYPE_IMAGE_PNG)
gtk_selection_data_set_pixbuf (selection_data, dialog->screenshot);
......@@ -111,11 +111,11 @@ drag_data_get (GtkWidget *widget,
static void
drag_begin (GtkWidget *widget,
GdkDragContext *context,
ScreenshotDialog *dialog)
GdkDragContext *context,
ScreenshotDialog *dialog)
{
gtk_drag_set_icon_pixbuf (context, dialog->preview_image,
dialog->drag_x, dialog->drag_y);
dialog->drag_x, dialog->drag_y);
}
static gboolean
......@@ -172,8 +172,8 @@ setup_drawing_area (ScreenshotDialog *dialog, GtkBuilder *ui)
gtk_widget_set_size_request (preview_darea, width, height);
gtk_aspect_frame_set (GTK_ASPECT_FRAME (aspect_frame), 0.0, 0.5,
(gfloat) width / (gfloat) height,
FALSE);
(gfloat) width / (gfloat) height,
FALSE);
if (screenshot_config->take_window_shot)
gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_NONE);
......@@ -186,21 +186,21 @@ setup_drawing_area (ScreenshotDialog *dialog, GtkBuilder *ui)
/* setup dnd */
gtk_drag_source_set (preview_darea,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
drag_types, G_N_ELEMENTS (drag_types),
GDK_ACTION_COPY);
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
drag_types, G_N_ELEMENTS (drag_types),
GDK_ACTION_COPY);
g_signal_connect (G_OBJECT (preview_darea), "drag_begin",
G_CALLBACK (drag_begin), dialog);
G_CALLBACK (drag_begin), dialog);
g_signal_connect (G_OBJECT (preview_darea), "drag_data_get",
G_CALLBACK (drag_data_get), dialog);
G_CALLBACK (drag_data_get), dialog);
}
ScreenshotDialog *
screenshot_dialog_new (GdkPixbuf *screenshot,
char *initial_uri,
SaveScreenshotCallback f,
gpointer user_data)
char *initial_uri,
SaveScreenshotCallback f,
gpointer user_data)
{
ScreenshotDialog *dialog;
GtkBuilder *ui;
......@@ -263,9 +263,9 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
gtk_widget_grab_focus (dialog->filename_entry);
gtk_editable_select_region (GTK_EDITABLE (dialog->filename_entry),
0,
pos);
0,
pos);
g_free (current_name);
g_free (current_folder);
g_object_unref (ui);
......@@ -324,7 +324,7 @@ screenshot_dialog_get_filename (ScreenshotDialog *dialog)
void
screenshot_dialog_set_busy (ScreenshotDialog *dialog,
gboolean busy)
gboolean busy)
{
GdkWindow *window;
......
......@@ -50,14 +50,14 @@ typedef struct {
} ScreenshotDialog;
ScreenshotDialog *screenshot_dialog_new (GdkPixbuf *screenshot,
char *initial_uri,
SaveScreenshotCallback f,
gpointer user_data);
char *initial_uri,
SaveScreenshotCallback f,
gpointer user_data);
char *screenshot_dialog_get_uri (ScreenshotDialog *dialog);
char *screenshot_dialog_get_folder (ScreenshotDialog *dialog);
char *screenshot_dialog_get_filename (ScreenshotDialog *dialog);
void screenshot_dialog_set_busy (ScreenshotDialog *dialog,
gboolean busy);
gboolean busy);
#endif /* __SCREENSHOT_DIALOG_H__ */
......@@ -36,7 +36,7 @@ typedef enum
NUM_TESTS
} TestType;
typedef struct
typedef struct
{
char *base_paths[NUM_TESTS];
char *screenshot_origin;
......@@ -54,7 +54,7 @@ expand_initial_tilde (const char *path)
if (path[1] == '/' || path[1] == '\0') {
return g_build_filename (g_get_home_dir (), &path[1], NULL);
}
slash_after_user_name = strchr (&path[1], '/');
if (slash_after_user_name == NULL) {
user_name = g_strdup (&path[1]);
......@@ -64,11 +64,11 @@ expand_initial_tilde (const char *path)
}
passwd_file_entry = getpwnam (user_name);
g_free (user_name);
if (passwd_file_entry == NULL || passwd_file_entry->pw_dir == NULL) {
return g_strdup (path);
}
return g_strconcat (passwd_file_entry->pw_dir,
slash_after_user_name,
NULL);
......@@ -217,7 +217,7 @@ retry:
file = g_file_new_for_path (path);
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE, cancellable, &error);
G_FILE_QUERY_INFO_NONE, cancellable, &error);
if (info != NULL)
{
/* file already exists, iterate again */
......@@ -302,7 +302,7 @@ out:
void
screenshot_build_filename_async (const char *save_dir,
const char *screenshot_origin,
const char *screenshot_origin,
GAsyncReadyCallback callback,
gpointer user_data)
{
......
......@@ -68,7 +68,7 @@ target_toggled_cb (GtkToggleButton *button,
{
take_window_shot = (target_toggle == TARGET_TOGGLE_WINDOW);
take_area_shot = (target_toggle == TARGET_TOGGLE_AREA);
gtk_widget_set_sensitive (border_check, take_window_shot);
gtk_widget_set_sensitive (effect_combo, take_window_shot);
gtk_widget_set_sensitive (effect_label, take_window_shot);
......@@ -122,10 +122,10 @@ effect_combo_changed_cb (GtkComboBox *combo,
}
}
static gint
interactive_dialog_key_press_cb (GtkWidget *widget,
static gint
interactive_dialog_key_press_cb (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
gpointer user_data)
{
if (event->keyval == GDK_KEY_F1)
{
......@@ -174,7 +174,7 @@ create_effects_combo (void)
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_UINT);
for (i = 0; i < n_effects; i++)
{
GtkTreeIter iter;
......@@ -213,7 +213,7 @@ create_effects_combo (void)
default:
break;
}
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (retval), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (retval), renderer,
......@@ -480,7 +480,7 @@ screenshot_interactive_dialog_new (CaptureClickedCallback f, gpointer user_data)
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
g_signal_connect (dialog, "key-press-event",
G_CALLBACK (interactive_dialog_key_press_cb),
G_CALLBACK (interactive_dialog_key_press_cb),
NULL);
button = gtk_button_new_with_mnemonic (_("_Cancel"));
......
......@@ -50,7 +50,7 @@ static double
gaussian (double x, double y, double r)
{
return ((1 / (2 * M_PI * r)) *
exp ((- (x * x + y * y)) / (2 * r * r)));
exp ((- (x * x + y * y)) / (2 * r * r)));
}
static ConvFilter *
......@@ -59,33 +59,32 @@ create_blur_filter (int radius)
ConvFilter *filter;
int x, y;
double sum;
filter = g_new0 (ConvFilter, 1);
filter->size = radius * 2 + 1;
filter->data = g_new (double, filter->size * filter->size);
sum = 0.0;
for (y = 0 ; y < filter->size; y++)
{
for (x = 0 ; x < filter->size; x++)
{
sum += filter->data[y * filter->size + x] = gaussian (x - (filter->size >> 1),
y - (filter->size >> 1),
radius);
}
{
sum += filter->data[y * filter->size + x] = gaussian (x - (filter->size >> 1),
y - (filter->size >> 1),
radius);
}
}
for (y = 0; y < filter->size; y++)
{
for (x = 0; x < filter->size; x++)
{
filter->data[y * filter->size + x] /= sum;
}
{
filter->data[y * filter->size + x] /= sum;
}
}
return filter;
}
static ConvFilter *
......@@ -93,7 +92,7 @@ create_outline_filter (int radius)
{
ConvFilter *filter;
double *iter;
filter = g_new0 (ConvFilter, 1);
filter->size = radius * 2 + 1;
filter->data = g_new (double, filter->size * filter->size);
......@@ -123,7 +122,7 @@ create_effect (GdkPixbuf *src,
int src_width, src_height;
int src_rowstride, dest_rowstride;
gboolean src_has_alpha;
guchar *src_pixels, *dest_pixels;
src_has_alpha = gdk_pixbuf_get_has_alpha (src);
......@@ -134,56 +133,56 @@ create_effect (GdkPixbuf *src,
dest_height = src_height + 2 * radius + offset;
dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
TRUE,
gdk_pixbuf_get_bits_per_sample (src),
dest_width, dest_height);
gdk_pixbuf_fill (dest, 0);
TRUE,
gdk_pixbuf_get_bits_per_sample (src),
dest_width, dest_height);
gdk_pixbuf_fill (dest, 0);
src_pixels = gdk_pixbuf_get_pixels (src);
src_rowstride = gdk_pixbuf_get_rowstride (src);
dest_pixels = gdk_pixbuf_get_pixels (dest);
dest_rowstride = gdk_pixbuf_get_rowstride (dest);
for (y = 0; y < dest_height; y++)
{
for (x = 0; x < dest_width; x++)
{
suma = 0;
src_x = x - radius;
src_y = y - radius;
/* We don't need to compute effect here, since this pixel will be
* discarded when compositing */
if (src_x >= 0 && src_x < src_width &&
src_y >= 0 && src_y < src_height &&
(!src_has_alpha ||
src_pixels [src_y * src_rowstride + src_x * 4 + 3] == 0xFF))
continue;
for (i = 0; i < filter->size; i++)
{
for (j = 0; j < filter->size; j++)
{
src_y = -(radius + offset) + y - (filter->size >> 1) + i;
src_x = -(radius + offset) + x - (filter->size >> 1) + j;
if (src_y < 0 || src_y >= src_height ||
src_x < 0 || src_x >= src_width)
continue;
suma += ( src_has_alpha ?
src_pixels [src_y * src_rowstride + src_x * 4 + 3] :
0xFF ) * filter->data [i * filter->size + j];
}
}
dest_pixels [y * dest_rowstride + x * 4 + 3] = CLAMP (suma * opacity, 0x00, 0xFF);
}
{
suma = 0;
src_x = x - radius;
src_y = y - radius;
/* We don't need to compute effect here, since this pixel will be
* discarded when compositing */
if (src_x >= 0 && src_x < src_width &&
src_y >= 0 && src_y < src_height &&
(!src_has_alpha ||
src_pixels [src_y * src_rowstride + src_x * 4 + 3] == 0xFF))
continue;
for (i = 0; i < filter->size; i++)
{
for (j = 0; j < filter->size; j++)
{
src_y = -(radius + offset) + y - (filter->size >> 1) + i;
src_x = -(radius + offset) + x - (filter->size >> 1) + j;
if (src_y < 0 || src_y >= src_height ||
src_x < 0 || src_x >= src_width)
continue;
suma += ( src_has_alpha ?
src_pixels [src_y * src_rowstride + src_x * 4 + 3] :
0xFF ) * filter->data [i * filter->size + j];
}
}
dest_pixels [y * dest_rowstride + x * 4 + 3] = CLAMP (suma * opacity, 0x00, 0xFF);
}
}
return dest;
}
......@@ -192,23 +191,23 @@ screenshot_add_shadow (GdkPixbuf **src)
{
GdkPixbuf *dest;
static ConvFilter *filter = NULL;
if (!filter)
filter = create_blur_filter (BLUR_RADIUS);
dest = create_effect (*src, filter,
BLUR_RADIUS,
dest = create_effect (*src, filter,
BLUR_RADIUS,
SHADOW_OFFSET, SHADOW_OPACITY);
if (dest == NULL)
return;
return;
gdk_pixbuf_composite (*src, dest,
BLUR_RADIUS, BLUR_RADIUS,
gdk_pixbuf_get_width (*src),
gdk_pixbuf_get_height (*src),
BLUR_RADIUS, BLUR_RADIUS, 1.0, 1.0,
GDK_INTERP_BILINEAR, 255);
BLUR_RADIUS, BLUR_RADIUS,
gdk_pixbuf_get_width (*src),
gdk_pixbuf_get_height (*src),
BLUR_RADIUS, BLUR_RADIUS, 1.0, 1.0,
GDK_INTERP_BILINEAR, 255);
g_object_unref (*src);
*src = dest;
}
......@@ -218,23 +217,23 @@ screenshot_add_border (GdkPixbuf **src)
{
GdkPixbuf *dest;
static ConvFilter *filter = NULL;
if (!filter)
filter = create_outline_filter (OUTLINE_RADIUS);
dest = create_effect (*src, filter,
OUTLINE_RADIUS,
dest = create_effect (*src, filter,
OUTLINE_RADIUS,
OUTLINE_OFFSET, OUTLINE_OPACITY);
if (dest == NULL)
return;
return;
gdk_pixbuf_composite (*src, dest,
OUTLINE_RADIUS, OUTLINE_RADIUS,
gdk_pixbuf_get_width (*src),
gdk_pixbuf_get_height (*src),
OUTLINE_RADIUS, OUTLINE_RADIUS, 1.0, 1.0,
GDK_INTERP_BILINEAR, 255);
OUTLINE_RADIUS, OUTLINE_RADIUS,
gdk_pixbuf_get_width (*src),
gdk_pixbuf_get_height (*src),
OUTLINE_RADIUS, OUTLINE_RADIUS, 1.0, 1.0,
GDK_INTERP_BILINEAR, 255);
g_object_unref (*src);
*src = dest;
}
......@@ -244,38 +243,38 @@ screenshot_add_vintage (GdkPixbuf **src)
{
GdkPixbuf *dest;
static ConvFilter *filter = NULL;
if (!filter)
filter = create_outline_filter (VINTAGE_OUTLINE_RADIUS);
dest = create_effect (*src, filter,
VINTAGE_OUTLINE_RADIUS,
dest = create_effect (*src, filter,
VINTAGE_OUTLINE_RADIUS,
OUTLINE_OFFSET, OUTLINE_OPACITY);
if (dest == NULL)
return;
return;
gdk_pixbuf_fill(dest, VINTAGE_OUTLINE_COLOR);
gdk_pixbuf_fill (dest, VINTAGE_OUTLINE_COLOR);
gdk_pixbuf_composite (*src, dest,
VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS,
gdk_pixbuf_get_width (*src),
gdk_pixbuf_get_height (*src),
VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS, 1.0, 1.0,
GDK_INTERP_HYPER, 255);
VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS,
gdk_pixbuf_get_width (*src),
gdk_pixbuf_get_height (*src),
VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS, 1.0, 1.0,
GDK_INTERP_HYPER, 255);
g_object_unref (*src);
*src = dest;
gdk_pixbuf_saturate_and_pixelate(*src, *src,
VINTAGE_SATURATION, FALSE);
dest = gdk_pixbuf_composite_color_simple(*src,
gdk_pixbuf_get_width(*src),
gdk_pixbuf_get_height(*src),
GDK_INTERP_BILINEAR,
VINTAGE_SOURCE_ALPHA, 64,
VINTAGE_OVERLAY_COLOR, VINTAGE_OVERLAY_COLOR);
gdk_pixbuf_saturate_and_pixelate (*src, *src,
VINTAGE_SATURATION, FALSE);
dest = gdk_pixbuf_composite_color_simple (*src,
gdk_pixbuf_get_width(*src),
gdk_pixbuf_get_height(*src),
GDK_INTERP_BILINEAR,
VINTAGE_SOURCE_ALPHA, 64,
VINTAGE_OVERLAY_COLOR, VINTAGE_OVERLAY_COLOR);
if (dest == NULL)
return;
return;
g_object_unref (*src);
*src = dest;
......
......@@ -63,7 +63,6 @@ screenshot_window_is_desktop (GdkWindow *window)
return TRUE;
return FALSE;
}
static Window
......@@ -81,13 +80,13 @@ find_wm_window (GdkWindow *window)
{
if (XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
xid, &root, &parent, &children, &nchildren) == 0)
{
g_warning ("Couldn't find window manager window");
return None;
}
{
g_warning ("Couldn't find window manager window");
return None;
}
if (root == parent)
return xid;
return xid;
xid = parent;
}
......@@ -128,7 +127,7 @@ blank_rectangle_in_pixbuf (GdkPixbuf *pixbuf, GdkRectangle *rect)
gboolean has_alpha;
g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
x2 = rect->x + rect->width;
y2 = rect->y + rect->height;
......@@ -145,14 +144,14 @@ blank_rectangle_in_pixbuf (GdkPixbuf *pixbuf, GdkRectangle *rect)
p = row + rect->x * n_channels;
for (x = rect->x; x < x2; x++)
{
*p++ = 0;
*p++ = 0;
*p++ = 0;
if (has_alpha)
*p++ = 255; /* opaque black */
}
{
*p++ = 0;
*p++ = 0;
*p++ = 0;