[cheese] re-indent source code to match our style
- From: Daniel G. Siegel <dgsiegel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [cheese] re-indent source code to match our style
- Date: Wed, 23 Dec 2009 11:32:58 +0000 (UTC)
commit de1dd8931a01caa3e25de66f896eda06cb755daa
Author: daniel g. siegel <dgsiegel gnome org>
Date: Wed Dec 23 12:32:10 2009 +0100
re-indent source code to match our style
libcheese/cheese-avatar-chooser.c | 166 ++++++-----
libcheese/cheese-avatar-chooser.h | 8 +-
libcheese/cheese-camera-device-monitor.c | 148 ++++++-----
libcheese/cheese-camera-device-monitor.h | 9 +-
libcheese/cheese-camera-device.c | 168 ++++++-----
libcheese/cheese-camera-device.h | 31 ++-
libcheese/cheese-camera.c | 53 +++--
libcheese/cheese-camera.h | 40 ++--
libcheese/cheese-fileutil.c | 2 +-
libcheese/cheese-flash.c | 46 ++--
libcheese/cheese-gconf.c | 4 +-
libcheese/cheese-widget.c | 156 ++++++-----
libcheese/cheese-widget.h | 10 +-
src/cheese-prefs-balance-scale.c | 3 +-
src/cheese-prefs-camera-combo.c | 10 +-
src/cheese-prefs-dialog.c | 8 +-
src/cheese-prefs-resolution-combo.c | 18 +-
src/cheese-window.c | 107 ++++----
src/eog-thumb-nav.c | 236 ++++++++-------
src/eog-thumb-nav.h | 52 ++--
src/eog-thumbnail.c | 461 +++++++++++++++---------------
src/eog-thumbnail.h | 10 +-
tests/cheese-test-chooser.c | 54 ++--
tests/cheese-test-monitor.c | 38 ++--
tests/cheese-test-widget.c | 49 ++--
tests/test-webcam-button.c | 9 +-
26 files changed, 1009 insertions(+), 887 deletions(-)
---
diff --git a/libcheese/cheese-avatar-chooser.c b/libcheese/cheese-avatar-chooser.c
index 4f9114b..f208bfe 100644
--- a/libcheese/cheese-avatar-chooser.c
+++ b/libcheese/cheese-avatar-chooser.c
@@ -39,7 +39,8 @@ enum
PROP_PIXBUF
};
-enum {
+enum
+{
WIDGET_PAGE = 0,
IMAGE_PAGE = 1,
};
@@ -57,19 +58,19 @@ typedef struct
gulong photo_taken_id;
} CheeseAvatarChooserPrivate;
-#define CHEESE_AVATAR_CHOOSER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_AVATAR_CHOOSER,\
- CheeseAvatarChooserPrivate))
+#define CHEESE_AVATAR_CHOOSER_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_AVATAR_CHOOSER, \
+ CheeseAvatarChooserPrivate))
G_DEFINE_TYPE (CheeseAvatarChooser, cheese_avatar_chooser, GTK_TYPE_DIALOG);
static void
-cheese_widget_photo_taken_cb (CheeseCamera *camera,
- GdkPixbuf *pixbuf,
- CheeseAvatarChooser *chooser)
+cheese_widget_photo_taken_cb (CheeseCamera *camera,
+ GdkPixbuf *pixbuf,
+ CheeseAvatarChooser *chooser)
{
CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (chooser);
- GtkAllocation allocation;
+ GtkAllocation allocation;
gtk_widget_get_allocation (priv->camera, &allocation);
gtk_widget_set_size_request (priv->image, allocation.width, allocation.height);
@@ -79,8 +80,8 @@ cheese_widget_photo_taken_cb (CheeseCamera *camera,
priv->pixbuf = g_object_ref (pixbuf);
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), IMAGE_PAGE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),
- GTK_RESPONSE_ACCEPT,
- TRUE);
+ GTK_RESPONSE_ACCEPT,
+ TRUE);
g_object_notify (G_OBJECT (chooser), "pixbuf");
}
@@ -88,23 +89,27 @@ cheese_widget_photo_taken_cb (CheeseCamera *camera,
static void
picture_cb (gpointer data)
{
- CheeseAvatarChooser *chooser = CHEESE_AVATAR_CHOOSER (data);
- CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (data);
- GObject *camera;
+ CheeseAvatarChooser *chooser = CHEESE_AVATAR_CHOOSER (data);
+ CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (data);
+ GObject *camera;
camera = cheese_widget_get_camera (CHEESE_WIDGET (priv->camera));
- if (priv->photo_taken_id == 0) {
+ if (priv->photo_taken_id == 0)
+ {
priv->photo_taken_id = g_signal_connect (G_OBJECT (camera), "photo-taken",
- G_CALLBACK (cheese_widget_photo_taken_cb), chooser);
+ G_CALLBACK (cheese_widget_photo_taken_cb), chooser);
}
- if (cheese_camera_take_photo_pixbuf (CHEESE_CAMERA (camera))) {
+ if (cheese_camera_take_photo_pixbuf (CHEESE_CAMERA (camera)))
+ {
cheese_flash_fire (CHEESE_FLASH (priv->flash));
ca_gtk_play_for_widget (GTK_WIDGET (chooser), 0,
- CA_PROP_EVENT_ID, "camera-shutter",
- CA_PROP_MEDIA_ROLE, "event",
- CA_PROP_EVENT_DESCRIPTION, _("Shutter sound"),
- NULL);
- } else {
+ CA_PROP_EVENT_ID, "camera-shutter",
+ CA_PROP_MEDIA_ROLE, "event",
+ CA_PROP_EVENT_DESCRIPTION, _("Shutter sound"),
+ NULL);
+ }
+ else
+ {
g_assert_not_reached ();
}
}
@@ -119,32 +124,32 @@ hide_cb (gpointer data)
}
static void
-take_button_clicked_cb (GtkButton *button,
- CheeseAvatarChooser *chooser)
+take_button_clicked_cb (GtkButton *button,
+ CheeseAvatarChooser *chooser)
{
CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (chooser);
- GtkAllocation allocation;
+ GtkAllocation allocation;
gtk_widget_get_allocation (priv->take_button, &allocation);
gtk_widget_hide (priv->take_button);
gtk_widget_set_size_request (priv->countdown, -1, allocation.height);
gtk_widget_show (priv->countdown);
cheese_countdown_start (CHEESE_COUNTDOWN (priv->countdown),
- picture_cb,
- hide_cb,
- (gpointer) chooser);
+ picture_cb,
+ hide_cb,
+ (gpointer) chooser);
}
static void
-take_again_button_clicked_cb (GtkButton *button,
- CheeseAvatarChooser *chooser)
+take_again_button_clicked_cb (GtkButton *button,
+ CheeseAvatarChooser *chooser)
{
CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (chooser);
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), WIDGET_PAGE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),
- GTK_RESPONSE_ACCEPT,
- FALSE);
+ GTK_RESPONSE_ACCEPT,
+ FALSE);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), NULL);
g_object_unref (priv->pixbuf);
@@ -153,9 +158,9 @@ take_again_button_clicked_cb (GtkButton *button,
}
static void
-ready_cb (CheeseWidget *widget,
- gboolean is_ready,
- CheeseAvatarChooser *chooser)
+ready_cb (CheeseWidget *widget,
+ gboolean is_ready,
+ CheeseAvatarChooser *chooser)
{
CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (chooser);
@@ -165,34 +170,35 @@ ready_cb (CheeseWidget *widget,
static GtkWidget *
create_page (GtkWidget *child,
- GtkWidget *button,
- GtkWidget *extra)
+ GtkWidget *button,
+ GtkWidget *extra)
{
GtkWidget *vbox, *hbox;
vbox = gtk_vbox_new (FALSE, 8);
gtk_box_pack_start (GTK_BOX (vbox),
- child,
- TRUE,
- TRUE,
- 0);
+ child,
+ TRUE,
+ TRUE,
+ 0);
hbox = gtk_hbox_new (FALSE, 8);
gtk_box_pack_start (GTK_BOX (vbox),
- hbox,
- FALSE,
- TRUE,
- 0);
+ hbox,
+ FALSE,
+ TRUE,
+ 0);
gtk_box_pack_start (GTK_BOX (hbox),
- button,
- FALSE,
- TRUE,
- 0);
- if (extra != NULL) {
+ button,
+ FALSE,
+ TRUE,
+ 0);
+ if (extra != NULL)
+ {
gtk_box_pack_start (GTK_BOX (hbox),
- extra,
- TRUE,
- TRUE,
- 0);
+ extra,
+ TRUE,
+ TRUE,
+ 0);
}
return vbox;
@@ -206,49 +212,49 @@ cheese_avatar_chooser_init (CheeseAvatarChooser *chooser)
priv->flash = cheese_flash_new (GTK_WIDGET (chooser));
gtk_dialog_add_buttons (GTK_DIALOG (chooser),
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- "Select",
- GTK_RESPONSE_ACCEPT,
- NULL);
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ "Select",
+ GTK_RESPONSE_ACCEPT,
+ NULL);
gtk_window_set_title (GTK_WINDOW (chooser), _("Take a photo"));
gtk_dialog_set_has_separator (GTK_DIALOG (chooser), FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (chooser),
- GTK_RESPONSE_ACCEPT,
- FALSE);
+ GTK_RESPONSE_ACCEPT,
+ FALSE);
priv->notebook = gtk_notebook_new ();
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (chooser))),
- priv->notebook,
- TRUE, TRUE, 8);
+ priv->notebook,
+ TRUE, TRUE, 8);
/* Camera tab */
priv->camera = cheese_widget_new ();
g_signal_connect (G_OBJECT (priv->camera), "ready",
- G_CALLBACK (ready_cb), chooser);
+ G_CALLBACK (ready_cb), chooser);
priv->take_button = gtk_button_new_with_mnemonic (_("_Take a photo"));
g_signal_connect (G_OBJECT (priv->take_button), "clicked",
- G_CALLBACK (take_button_clicked_cb), chooser);
+ G_CALLBACK (take_button_clicked_cb), chooser);
gtk_widget_set_sensitive (priv->take_button, FALSE);
priv->countdown = cheese_countdown_new ();
gtk_widget_set_no_show_all (priv->countdown, TRUE);
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
- create_page (priv->camera, priv->take_button, priv->countdown),
- gtk_label_new ("webcam"));
+ create_page (priv->camera, priv->take_button, priv->countdown),
+ gtk_label_new ("webcam"));
/* Image tab */
- priv->image = gtk_image_new ();
+ priv->image = gtk_image_new ();
priv->take_again_button = gtk_button_new_with_mnemonic (_("_Discard photo"));
g_signal_connect (G_OBJECT (priv->take_again_button), "clicked",
- G_CALLBACK (take_again_button_clicked_cb), chooser);
+ G_CALLBACK (take_again_button_clicked_cb), chooser);
gtk_widget_set_sensitive (priv->take_again_button, FALSE);
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
- create_page (priv->image, priv->take_again_button, NULL),
- gtk_label_new ("image"));
+ create_page (priv->image, priv->take_again_button, NULL),
+ gtk_label_new ("image"));
gtk_window_set_default_size (GTK_WINDOW (chooser), 400, 300);
@@ -260,11 +266,13 @@ cheese_avatar_chooser_finalize (GObject *object)
{
CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (object);
- if (priv->flash != NULL) {
+ if (priv->flash != NULL)
+ {
g_object_unref (priv->flash);
priv->flash = NULL;
}
- if (priv->pixbuf != NULL) {
+ if (priv->pixbuf != NULL)
+ {
g_object_unref (priv->pixbuf);
priv->pixbuf = NULL;
}
@@ -282,7 +290,7 @@ cheese_avatar_chooser_response (GtkDialog *dialog, gint response_id)
static void
cheese_avatar_chooser_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+ GValue *value, GParamSpec *pspec)
{
CheeseAvatarChooserPrivate *priv = CHEESE_AVATAR_CHOOSER_GET_PRIVATE (object);
@@ -302,7 +310,7 @@ cheese_avatar_chooser_get_property (GObject *object, guint prop_id,
static void
cheese_avatar_chooser_class_init (CheeseAvatarChooserClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
object_class->finalize = cheese_avatar_chooser_finalize;
@@ -310,11 +318,11 @@ cheese_avatar_chooser_class_init (CheeseAvatarChooserClass *klass)
object_class->get_property = cheese_avatar_chooser_get_property;
g_object_class_install_property (object_class, PROP_PIXBUF,
- g_param_spec_object ("pixbuf",
- NULL,
- NULL,
- GDK_TYPE_PIXBUF,
- G_PARAM_READABLE));
+ g_param_spec_object ("pixbuf",
+ NULL,
+ NULL,
+ GDK_TYPE_PIXBUF,
+ G_PARAM_READABLE));
g_type_class_add_private (klass, sizeof (CheeseAvatarChooserPrivate));
}
diff --git a/libcheese/cheese-avatar-chooser.h b/libcheese/cheese-avatar-chooser.h
index f04d93c..369558a 100644
--- a/libcheese/cheese-avatar-chooser.h
+++ b/libcheese/cheese-avatar-chooser.h
@@ -25,15 +25,15 @@
G_BEGIN_DECLS
-#define CHEESE_TYPE_AVATAR_CHOOSER (cheese_avatar_chooser_get_type ())
+#define CHEESE_TYPE_AVATAR_CHOOSER (cheese_avatar_chooser_get_type ())
#define CHEESE_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_AVATAR_CHOOSER, \
- CheeseAvatarChooser))
+ CheeseAvatarChooser))
#define CHEESE_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_AVATAR_CHOOSER, \
- CheeseAvatarChooserClass))
+ CheeseAvatarChooserClass))
#define CHEESE_IS_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_AVATAR_CHOOSER))
#define CHEESE_IS_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_AVATAR_CHOOSER))
#define CHEESE_AVATAR_CHOOSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_AVATAR_CHOOSER, \
- CheeseAvatarChooserClass))
+ CheeseAvatarChooserClass))
typedef struct _CheeseAvatarChooserClass CheeseAvatarChooserClass;
typedef struct _CheeseAvatarChooser CheeseAvatarChooser;
diff --git a/libcheese/cheese-camera-device-monitor.c b/libcheese/cheese-camera-device-monitor.c
index f6e0b5b..027eca0 100644
--- a/libcheese/cheese-camera-device-monitor.c
+++ b/libcheese/cheese-camera-device-monitor.c
@@ -28,27 +28,28 @@
#include <string.h>
#ifdef HAVE_UDEV
-#define G_UDEV_API_IS_SUBJECT_TO_CHANGE 1
-#include <gudev/gudev.h>
+ #define G_UDEV_API_IS_SUBJECT_TO_CHANGE 1
+ #include <gudev/gudev.h>
#else
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#if USE_SYS_VIDEOIO_H > 0
-#include <sys/types.h>
-#include <sys/videoio.h>
-#elif defined(__sun)
-#include <sys/types.h>
-#include <sys/videodev2.h>
-#endif /* USE_SYS_VIDEOIO_H */
+ #include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/ioctl.h>
+ #if USE_SYS_VIDEOIO_H > 0
+ #include <sys/types.h>
+ #include <sys/videoio.h>
+ #elif defined (__sun)
+ #include <sys/types.h>
+ #include <sys/videodev2.h>
+ #endif /* USE_SYS_VIDEOIO_H */
#endif
#include "cheese-camera-device-monitor.h"
G_DEFINE_TYPE (CheeseCameraDeviceMonitor, cheese_camera_device_monitor, G_TYPE_OBJECT)
-#define CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- CHEESE_TYPE_CAMERA_DEVICE_MONITOR, CheeseCameraDeviceMonitorPrivate))
+#define CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ CHEESE_TYPE_CAMERA_DEVICE_MONITOR, \
+ CheeseCameraDeviceMonitorPrivate))
#define CHEESE_CAMERA_DEVICE_MONITOR_ERROR cheese_camera_device_monitor_error_quark ()
@@ -88,39 +89,46 @@ cheese_camera_device_monitor_error_quark (void)
#ifdef HAVE_UDEV
static void
cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
- GUdevDevice *udevice)
+ GUdevDevice *udevice)
{
- const char *device_file;
- const char *gstreamer_src, *product_name;
- const char *vendor;
- const char *product;
- const char *bus;
- gint vendor_id = 0;
- gint product_id = 0;
- gint v4l_version = 0;
- CheeseCameraDevice *device;
+ const char *device_file;
+ const char *gstreamer_src, *product_name;
+ const char *vendor;
+ const char *product;
+ const char *bus;
+ gint vendor_id = 0;
+ gint product_id = 0;
+ gint v4l_version = 0;
+ CheeseCameraDevice *device;
GST_INFO ("Checking udev device '%s'", g_udev_device_get_property (udevice, "DEVPATH"));
bus = g_udev_device_get_property (udevice, "ID_BUS");
- if (g_strcmp0 (bus, "usb") == 0) {
+ if (g_strcmp0 (bus, "usb") == 0)
+ {
vendor = g_udev_device_get_property (udevice, "ID_VENDOR_ID");
if (vendor != NULL)
vendor_id = g_ascii_strtoll (vendor, NULL, 16);
product = g_udev_device_get_property (udevice, "ID_MODEL_ID");
if (product != NULL)
product_id = g_ascii_strtoll (vendor, NULL, 16);
- if (vendor_id == 0 || product_id == 0) {
+ if (vendor_id == 0 || product_id == 0)
+ {
GST_WARNING ("Error getting vendor and product id");
- } else {
+ }
+ else
+ {
GST_INFO ("Found device %04x:%04x, getting capabilities...", vendor_id, product_id);
}
- } else {
+ }
+ else
+ {
GST_INFO ("Not an usb device, skipping vendor and model id retrieval");
}
device_file = g_udev_device_get_device_file (udevice);
- if (device_file == NULL) {
+ if (device_file == NULL)
+ {
GST_WARNING ("Error getting V4L device");
return;
}
@@ -134,7 +142,8 @@ cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
}
v4l_version = g_udev_device_get_property_as_int (udevice, "ID_V4L_VERSION");
- if (v4l_version == 2 || v4l_version == 1) {
+ if (v4l_version == 2 || v4l_version == 1)
+ {
const char *caps;
caps = g_udev_device_get_property (udevice, "ID_V4L_CAPABILITIES");
@@ -145,11 +154,15 @@ cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
return;
}
gstreamer_src = (v4l_version == 2) ? "v4l2src" : "v4lsrc";
- product_name = g_udev_device_get_property (udevice, "ID_V4L_PRODUCT");
- } else if (v4l_version == 0) {
+ product_name = g_udev_device_get_property (udevice, "ID_V4L_PRODUCT");
+ }
+ else if (v4l_version == 0)
+ {
GST_ERROR ("Fix your udev installation to include v4l_id, ignoring %s", device_file);
return;
- } else {
+ }
+ else
+ {
g_assert_not_reached ();
}
@@ -165,17 +178,17 @@ cheese_camera_device_monitor_added (CheeseCameraDeviceMonitor *monitor,
static void
cheese_camera_device_monitor_removed (CheeseCameraDeviceMonitor *monitor,
- GUdevDevice *udevice)
+ GUdevDevice *udevice)
{
g_signal_emit (monitor, monitor_signals[REMOVED], 0,
- g_udev_device_get_property (udevice, "DEVPATH"));
+ g_udev_device_get_property (udevice, "DEVPATH"));
}
static void
-cheese_camera_device_monitor_uevent_cb (GUdevClient *client,
- const gchar *action,
- GUdevDevice *udevice,
- CheeseCameraDeviceMonitor *monitor)
+cheese_camera_device_monitor_uevent_cb (GUdevClient *client,
+ const gchar *action,
+ GUdevDevice *udevice,
+ CheeseCameraDeviceMonitor *monitor)
{
if (g_str_equal (action, "remove"))
cheese_camera_device_monitor_removed (monitor, udevice);
@@ -187,8 +200,8 @@ void
cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
{
CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor);
- GList *devices, *l;
- gint i = 0;
+ GList *devices, *l;
+ gint i = 0;
if (priv->client == NULL)
return;
@@ -198,7 +211,8 @@ cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
devices = g_udev_client_query_by_subsystem (priv->client, "video4linux");
/* Initialize camera structures */
- for (l = devices; l != NULL; l = l->next) {
+ for (l = devices; l != NULL; l = l->next)
+ {
cheese_camera_device_monitor_added (monitor, l->data);
g_object_unref (l->data);
i++;
@@ -207,15 +221,16 @@ cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
if (i == 0) GST_WARNING ("No device found");
}
+
#else /* HAVE_UDEV */
void
cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
{
-#if 0
+ #if 0
CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor);
- struct v4l2_capability v2cap;
- struct video_capability v1cap;
- int fd, ok;
+ struct v4l2_capability v2cap;
+ struct video_capability v1cap;
+ int fd, ok;
if ((fd = open (device_path, O_RDONLY | O_NONBLOCK)) < 0)
{
@@ -229,7 +244,7 @@ cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
if (ok < 0)
{
g_warning ("Error while probing v4l capabilities for %s: %s",
- device_path, strerror (errno));
+ device_path, strerror (errno));
close (fd);
return;
}
@@ -249,7 +264,7 @@ cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
if (!(cap & V4L2_CAP_VIDEO_CAPTURE))
{
g_print ("Device %s seems to not have the capture capability, (radio tuner?)\n"
- "Removing it from device list.\n", device_path);
+ "Removing it from device list.\n", device_path);
close (fd);
return;
}
@@ -268,13 +283,15 @@ cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor)
devices = g_udev_client_query_by_subsystem (priv->client, "video4linux");
/* Initialize camera structures */
- for (l = devices; l != NULL; l = l->next) {
+ for (l = devices; l != NULL; l = l->next)
+ {
cheese_camera_device_monitor_added (monitor, l->data);
g_object_unref (l->data);
}
g_list_free (devices);
-#endif
+ #endif
}
+
#endif /* HAVE_UDEV */
static void
@@ -286,7 +303,8 @@ cheese_camera_device_monitor_finalize (GObject *object)
monitor = CHEESE_CAMERA_DEVICE_MONITOR (object);
CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor);
- if (priv->client != NULL) {
+ if (priv->client != NULL)
+ {
g_object_unref (priv->client);
priv->client = NULL;
}
@@ -299,21 +317,21 @@ cheese_camera_device_monitor_class_init (CheeseCameraDeviceMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = cheese_camera_device_monitor_finalize;
+ object_class->finalize = cheese_camera_device_monitor_finalize;
monitor_signals[ADDED] = g_signal_new ("added", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (CheeseCameraDeviceMonitorClass, added),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (CheeseCameraDeviceMonitorClass, added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
monitor_signals[REMOVED] = g_signal_new ("removed", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (CheeseCameraDeviceMonitorClass, removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (CheeseCameraDeviceMonitorClass, removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (CheeseCameraDeviceMonitorPrivate));
}
@@ -325,12 +343,12 @@ cheese_camera_device_monitor_init (CheeseCameraDeviceMonitor *monitor)
"cheese-device-monitor",
0, "Cheese Camera Device Monitor");
#ifdef HAVE_UDEV
- CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor);
- const gchar* const subsystems[] = { "video4linux", NULL };
+ CheeseCameraDeviceMonitorPrivate *priv = CHEESE_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor);
+ const gchar *const subsystems[] = {"video4linux", NULL};
priv->client = g_udev_client_new (subsystems);
g_signal_connect (G_OBJECT (priv->client), "uevent",
- G_CALLBACK (cheese_camera_device_monitor_uevent_cb), monitor);
+ G_CALLBACK (cheese_camera_device_monitor_uevent_cb), monitor);
#endif /* HAVE_UDEV */
}
diff --git a/libcheese/cheese-camera-device-monitor.h b/libcheese/cheese-camera-device-monitor.h
index 763b4f1..570e1c8 100644
--- a/libcheese/cheese-camera-device-monitor.h
+++ b/libcheese/cheese-camera-device-monitor.h
@@ -31,11 +31,14 @@
G_BEGIN_DECLS
#define CHEESE_TYPE_CAMERA_DEVICE_MONITOR (cheese_camera_device_monitor_get_type ())
-#define CHEESE_CAMERA_DEVICE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CHEESE_TYPE_CAMERA_DEVICE_MONITOR, CheeseCameraDeviceMonitor))
-#define CHEESE_CAMERA_DEVICE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CHEESE_TYPE_CAMERA_DEVICE_MONITOR, CheeseCameraDeviceMonitorClass))
+#define CHEESE_CAMERA_DEVICE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CHEESE_TYPE_CAMERA_DEVICE_MONITOR, \
+ CheeseCameraDeviceMonitor))
+#define CHEESE_CAMERA_DEVICE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CHEESE_TYPE_CAMERA_DEVICE_MONITOR, \
+ CheeseCameraDeviceMonitorClass))
#define CHEESE_IS_CAMERA_DEVICE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CHEESE_TYPE_CAMERA_DEVICE_MONITOR))
#define CHEESE_IS_CAMERA_DEVICE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CHEESE_TYPE_CAMERA_DEVICE_MONITOR))
-#define CHEESE_CAMERA_DEVICE_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_CAMERA_DEVICE_MONITOR, CheeseCameraDeviceMonitorClass))
+#define CHEESE_CAMERA_DEVICE_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_CAMERA_DEVICE_MONITOR, \
+ CheeseCameraDeviceMonitorClass))
typedef struct
{
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
index 94d1db3..9adf753 100644
--- a/libcheese/cheese-camera-device.c
+++ b/libcheese/cheese-camera-device.c
@@ -31,13 +31,13 @@
G_DEFINE_TYPE (CheeseCameraDevice, cheese_camera_device, G_TYPE_OBJECT)
-#define CHEESE_CAMERA_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_CAMERA_DEVICE, CheeseCameraDevicePrivate))
+#define CHEESE_CAMERA_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_CAMERA_DEVICE, \
+ CheeseCameraDevicePrivate))
GST_DEBUG_CATEGORY (cheese_camera_device);
#define GST_CAT_DEFAULT cheese_camera_device
-static gchar *supported_formats[] =
-{
+static gchar *supported_formats[] = {
"video/x-raw-rgb",
"video/x-raw-yuv",
NULL
@@ -67,7 +67,7 @@ typedef struct
/* CheeseVideoFormat */
-static CheeseVideoFormat*
+static CheeseVideoFormat *
cheese_video_format_copy (const CheeseVideoFormat *format)
{
return g_slice_dup (CheeseVideoFormat, format);
@@ -102,17 +102,18 @@ compare_formats (gconstpointer a, gconstpointer b)
const CheeseVideoFormat *d = b;
/* descending sort for rectangle area */
- return (d->width*d->height - c->width*c->height);
+ return (d->width * d->height - c->width * c->height);
}
static
-GstCaps *cheese_webcam_device_filter_caps (CheeseCameraDevice *device, const GstCaps *caps, GStrv formats)
+GstCaps *
+cheese_webcam_device_filter_caps (CheeseCameraDevice *device, const GstCaps *caps, GStrv formats)
{
/* CheeseCameraDevicePrivate *priv =
- CHEESE_CAMERA_DEVICE_GET_PRIVATE (device); */
- gchar *formats_string = g_strjoinv ("; ", formats);
- GstCaps *filter = gst_caps_from_string (formats_string);
- GstCaps *allowed = gst_caps_intersect (caps, filter);
+ * CHEESE_CAMERA_DEVICE_GET_PRIVATE (device); */
+ gchar *formats_string = g_strjoinv ("; ", formats);
+ GstCaps *filter = gst_caps_from_string (formats_string);
+ GstCaps *allowed = gst_caps_intersect (caps, filter);
GST_DEBUG ("Supported caps %" GST_PTR_FORMAT, caps);
GST_DEBUG ("Filter caps %" GST_PTR_FORMAT, filter);
@@ -130,6 +131,7 @@ cheese_camera_device_add_format (CheeseCameraDevice *device, CheeseVideoFormat *
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
GList *l;
+
for (l = priv->formats; l != NULL; l = l->next)
{
CheeseVideoFormat *item = l->data;
@@ -150,6 +152,7 @@ free_format_list (CheeseCameraDevice *device)
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
GList *l;
+
for (l = priv->formats; l != NULL; l = l->next)
g_free (l->data);
g_list_free (priv->formats);
@@ -209,7 +212,7 @@ cheese_webcam_device_update_format_table (CheeseCameraDevice *device)
{
CheeseVideoFormat *format = g_new0 (CheeseVideoFormat, 1);
- format->width = cur_width;
+ format->width = cur_width;
format->height = cur_height;
cheese_camera_device_add_format (device, format);
@@ -224,7 +227,7 @@ cheese_webcam_device_update_format_table (CheeseCameraDevice *device)
{
CheeseVideoFormat *format = g_new0 (CheeseVideoFormat, 1);
- format->width = cur_width;
+ format->width = cur_width;
format->height = cur_height;
cheese_camera_device_add_format (device, format);
@@ -276,8 +279,8 @@ cheese_camera_device_get_caps (CheeseCameraDevice *device)
src = gst_bin_get_by_name (GST_BIN (pipeline), "source");
GST_LOG ("Device: %s (%s)\n", priv->name, priv->device);
- pad = gst_element_get_pad (src, "src");
- caps = gst_pad_get_caps (pad);
+ pad = gst_element_get_pad (src, "src");
+ caps = gst_pad_get_caps (pad);
priv->caps = cheese_webcam_device_filter_caps (device, caps, supported_formats);
cheese_webcam_device_update_format_table (device);
@@ -309,68 +312,70 @@ cheese_camera_device_constructed (GObject *object)
static void
cheese_camera_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
- CheeseCameraDevicePrivate *priv =
+ CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
+ CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
- switch (prop_id) {
- case PROP_NAME:
- g_value_set_string (value, priv->name);
- break;
- case PROP_FILE:
- g_value_set_string (value, priv->device);
- break;
- case PROP_ID:
- g_value_set_string (value, priv->id);
- break;
- case PROP_SRC:
- g_value_set_string (value, priv->src);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+ case PROP_FILE:
+ g_value_set_string (value, priv->device);
+ break;
+ case PROP_ID:
+ g_value_set_string (value, priv->id);
+ break;
+ case PROP_SRC:
+ g_value_set_string (value, priv->src);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
cheese_camera_device_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
- CheeseCameraDevicePrivate *priv =
+ CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
+ CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
- switch (prop_id) {
- case PROP_NAME:
- if (priv->name)
- g_free (priv->name);
- priv->name = g_value_dup_string (value);
- break;
- case PROP_ID:
- if (priv->id)
- g_free (priv->id);
- priv->id = g_value_dup_string (value);
- break;
- case PROP_FILE:
- if (priv->device)
- g_free (priv->device);
- priv->device = g_value_dup_string (value);
- break;
- case PROP_SRC:
- if (priv->src)
- g_free (priv->src);
- priv->src = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ if (priv->name)
+ g_free (priv->name);
+ priv->name = g_value_dup_string (value);
+ break;
+ case PROP_ID:
+ if (priv->id)
+ g_free (priv->id);
+ priv->id = g_value_dup_string (value);
+ break;
+ case PROP_FILE:
+ if (priv->device)
+ g_free (priv->device);
+ priv->device = g_value_dup_string (value);
+ break;
+ case PROP_SRC:
+ if (priv->src)
+ g_free (priv->src);
+ priv->src = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
cheese_camera_device_finalize (GObject *object)
{
- CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
- CheeseCameraDevicePrivate *priv =
+ CheeseCameraDevice *device = CHEESE_CAMERA_DEVICE (object);
+ CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
g_free (priv->device);
@@ -426,23 +431,24 @@ cheese_camera_device_init (CheeseCameraDevice *device)
"cheese-camera-device",
0, "Cheese Camera Device");
priv->device = NULL;
- priv->id = NULL;
- priv->src = NULL;
- priv->name = g_strdup(_("Unknown device"));
- priv->caps = gst_caps_new_empty ();
+ priv->id = NULL;
+ priv->src = NULL;
+ priv->name = g_strdup (_("Unknown device"));
+ priv->caps = gst_caps_new_empty ();
priv->formats = NULL;
}
-CheeseCameraDevice *cheese_camera_device_new (void)
+CheeseCameraDevice *
+cheese_camera_device_new (void)
{
return g_object_new (CHEESE_TYPE_CAMERA_DEVICE, NULL);
}
-
/* public methods */
-GList *cheese_camera_device_get_format_list (CheeseCameraDevice *device)
+GList *
+cheese_camera_device_get_format_list (CheeseCameraDevice *device)
{
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
@@ -450,28 +456,35 @@ GList *cheese_camera_device_get_format_list (CheeseCameraDevice *device)
return g_list_sort (g_list_copy (priv->formats), compare_formats);
}
-const gchar *cheese_camera_device_get_name (CheeseCameraDevice *device)
+const gchar *
+cheese_camera_device_get_name (CheeseCameraDevice *device)
{
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
return priv->name;
}
-const gchar *cheese_camera_device_get_id (CheeseCameraDevice *device)
+
+const gchar *
+cheese_camera_device_get_id (CheeseCameraDevice *device)
{
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
return priv->id;
}
-const gchar *cheese_camera_device_get_src (CheeseCameraDevice *device)
+
+const gchar *
+cheese_camera_device_get_src (CheeseCameraDevice *device)
{
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
return priv->src;
}
-const gchar *cheese_camera_device_get_device_file (CheeseCameraDevice *device)
+
+const gchar *
+cheese_camera_device_get_device_file (CheeseCameraDevice *device)
{
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
@@ -479,7 +492,8 @@ const gchar *cheese_camera_device_get_device_file (CheeseCameraDevice *device)
return priv->device;
}
-CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *device)
+CheeseVideoFormat *
+cheese_camera_device_get_best_format (CheeseCameraDevice *device)
{
CheeseVideoFormat *format = g_boxed_copy (CHEESE_TYPE_VIDEO_FORMAT,
cheese_camera_device_get_format_list (device)->data);
@@ -488,13 +502,14 @@ CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *dev
return format;
}
-GstCaps *cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
- CheeseVideoFormat *format)
+GstCaps *
+cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
+ CheeseVideoFormat *format)
{
CheeseCameraDevicePrivate *priv =
CHEESE_CAMERA_DEVICE_GET_PRIVATE (device);
GstCaps *caps;
- gint i;
+ gint i;
GST_INFO ("Getting caps for %dx%d", format->width, format->height);
@@ -516,7 +531,8 @@ GstCaps *cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
NULL));
}
- if (!gst_caps_can_intersect (caps, priv->caps)) {
+ if (!gst_caps_can_intersect (caps, priv->caps))
+ {
gst_caps_unref (caps);
caps = gst_caps_new_empty ();
}
diff --git a/libcheese/cheese-camera-device.h b/libcheese/cheese-camera-device.h
index b84ec18..92250b3 100644
--- a/libcheese/cheese-camera-device.h
+++ b/libcheese/cheese-camera-device.h
@@ -30,11 +30,14 @@
G_BEGIN_DECLS
#define CHEESE_TYPE_CAMERA_DEVICE (cheese_camera_device_get_type ())
-#define CHEESE_CAMERA_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CHEESE_TYPE_CAMERA_DEVICE, CheeseCameraDevice))
-#define CHEESE_CAMERA_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CHEESE_TYPE_CAMERA_DEVICE, CheeseCameraDeviceClass))
+#define CHEESE_CAMERA_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CHEESE_TYPE_CAMERA_DEVICE, \
+ CheeseCameraDevice))
+#define CHEESE_CAMERA_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CHEESE_TYPE_CAMERA_DEVICE, \
+ CheeseCameraDeviceClass))
#define CHEESE_IS_CAMERA_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CHEESE_TYPE_CAMERA_DEVICE))
#define CHEESE_IS_CAMERA_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CHEESE_TYPE_CAMERA_DEVICE))
-#define CHEESE_CAMERA_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_CAMERA_DEVICE, CheeseCameraDeviceClass))
+#define CHEESE_CAMERA_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_CAMERA_DEVICE, \
+ CheeseCameraDeviceClass))
typedef struct
{
@@ -50,24 +53,24 @@ typedef struct
typedef struct
{
- int width;
- int height;
+ int width;
+ int height;
} CheeseVideoFormat;
GType cheese_video_format_get_type (void) G_GNUC_CONST;
GType cheese_camera_device_get_type (void) G_GNUC_CONST;
-CheeseCameraDevice *cheese_camera_device_new (void);
-GstCaps *cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
- CheeseVideoFormat *format);
-CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *device);
-GList *cheese_camera_device_get_format_list (CheeseCameraDevice *device);
+CheeseCameraDevice *cheese_camera_device_new (void);
+GstCaps * cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
+ CheeseVideoFormat *format);
+CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *device);
+GList * cheese_camera_device_get_format_list (CheeseCameraDevice *device);
-const gchar *cheese_camera_device_get_name (CheeseCameraDevice *device);
-const gchar *cheese_camera_device_get_src (CheeseCameraDevice *device);
-const gchar *cheese_camera_device_get_id (CheeseCameraDevice *device);
-const gchar *cheese_camera_device_get_device_file (CheeseCameraDevice *device);
+const gchar *cheese_camera_device_get_name (CheeseCameraDevice *device);
+const gchar *cheese_camera_device_get_src (CheeseCameraDevice *device);
+const gchar *cheese_camera_device_get_id (CheeseCameraDevice *device);
+const gchar *cheese_camera_device_get_device_file (CheeseCameraDevice *device);
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 9e4d9bf..d6d7794 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -74,6 +74,7 @@ typedef struct
int num_camera_devices;
char *device_name;
+
/* an array of CheeseCameraDevices */
GPtrArray *camera_devices;
int x_resolution;
@@ -234,10 +235,11 @@ cheese_camera_photo_data_cb (GstElement *element, GstBuffer *buffer,
NULL, NULL);
g_signal_handler_disconnect (G_OBJECT (priv->photo_sink),
- priv->photo_handler_signal_id);
+ priv->photo_handler_signal_id);
priv->photo_handler_signal_id = 0;
- if (priv->photo_filename != NULL) {
+ if (priv->photo_filename != NULL)
+ {
gdk_pixbuf_save (pixbuf, priv->photo_filename, "jpeg", NULL, NULL);
g_object_unref (G_OBJECT (pixbuf));
@@ -245,7 +247,9 @@ cheese_camera_photo_data_cb (GstElement *element, GstBuffer *buffer,
priv->photo_filename = NULL;
g_signal_emit (camera, camera_signals[PHOTO_SAVED], 0);
- } else {
+ }
+ else
+ {
g_signal_emit (camera, camera_signals[PHOTO_TAKEN], 0, pixbuf);
g_object_unref (pixbuf);
}
@@ -275,8 +279,8 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
static void
cheese_camera_add_device (CheeseCameraDeviceMonitor *monitor,
- CheeseCameraDevice *device,
- CheeseCamera *camera)
+ CheeseCameraDevice *device,
+ CheeseCamera *camera)
{
CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
@@ -287,15 +291,15 @@ cheese_camera_add_device (CheeseCameraDeviceMonitor *monitor,
static void
cheese_camera_detect_camera_devices (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
CheeseCameraDeviceMonitor *monitor;
priv->num_camera_devices = 0;
- priv->camera_devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
+ priv->camera_devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
monitor = cheese_camera_device_monitor_new ();
g_signal_connect (G_OBJECT (monitor), "added",
- G_CALLBACK (cheese_camera_add_device), camera);
+ G_CALLBACK (cheese_camera_add_device), camera);
cheese_camera_device_monitor_coldplug (monitor);
g_object_unref (monitor);
}
@@ -319,8 +323,9 @@ cheese_camera_create_camera_source_bin (CheeseCamera *camera)
{
CheeseCameraDevice *device = g_ptr_array_index (priv->camera_devices, i);
if (g_strcmp0 (cheese_camera_device_get_device_file (device),
- priv->device_name) == 0) {
- selected_camera = device;
+ priv->device_name) == 0)
+ {
+ selected_camera = device;
priv->selected_device = i;
break;
}
@@ -335,7 +340,8 @@ cheese_camera_create_camera_source_bin (CheeseCamera *camera)
TRUE, &err);
g_free (camera_input);
- if (priv->camera_source_bin == NULL) {
+ if (priv->camera_source_bin == NULL)
+ {
goto fallback;
}
@@ -637,9 +643,10 @@ CheeseCameraDevice *
cheese_camera_get_selected_device (CheeseCamera *camera)
{
CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+
if (cheese_camera_get_num_camera_devices (camera) > 0)
return CHEESE_CAMERA_DEVICE (
- g_ptr_array_index (priv->camera_devices, priv->selected_device));
+ g_ptr_array_index (priv->camera_devices, priv->selected_device));
else
return NULL;
}
@@ -705,9 +712,9 @@ cheese_camera_switch_camera_device (CheeseCamera *camera)
void
cheese_camera_play (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
CheeseCameraDevice *device = g_ptr_array_index (priv->camera_devices, priv->selected_device);
- GstCaps *caps;
+ GstCaps *caps;
caps = cheese_camera_device_get_caps_for_format (device, priv->current_format);
@@ -718,7 +725,8 @@ cheese_camera_play (CheeseCamera *camera)
priv->current_format = cheese_camera_device_get_best_format (device);
g_object_notify (G_OBJECT (camera), "format");
caps = cheese_camera_device_get_caps_for_format (device, priv->current_format);
- if (G_UNLIKELY (gst_caps_is_empty (caps))) {
+ if (G_UNLIKELY (gst_caps_is_empty (caps)))
+ {
gst_caps_unref (caps);
caps = gst_caps_new_any ();
}
@@ -1065,9 +1073,10 @@ CheeseCamera *
cheese_camera_new (GtkWidget *video_window, char *camera_device_name,
int x_resolution, int y_resolution)
{
- CheeseCamera *camera;
+ CheeseCamera *camera;
CheeseVideoFormat *format = g_slice_new (CheeseVideoFormat);
- format->width = x_resolution;
+
+ format->width = x_resolution;
format->height = y_resolution;
if (camera_device_name)
@@ -1095,7 +1104,8 @@ cheese_camera_setup (CheeseCamera *camera, char *id, GError **error)
cheese_camera_detect_camera_devices (camera);
- if (priv->num_camera_devices < 1) {
+ if (priv->num_camera_devices < 1)
+ {
g_set_error (error, CHEESE_CAMERA_ERROR, CHEESE_CAMERA_ERROR_NO_DEVICE, _("No device found"));
return;
}
@@ -1173,7 +1183,7 @@ cheese_camera_set_device_by_dev_udi (CheeseCamera *camera, char *udi)
GList *
cheese_camera_get_video_formats (CheeseCamera *camera)
{
- CheeseCameraDevice *device = cheese_camera_get_selected_device (camera);
+ CheeseCameraDevice *device = cheese_camera_get_selected_device (camera);
if (device)
return cheese_camera_device_get_format_list (device);
@@ -1185,6 +1195,7 @@ gboolean
cheese_camera_is_playing (CheeseCamera *camera)
{
CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+
return priv->pipeline_is_playing;
}
@@ -1192,11 +1203,13 @@ void
cheese_camera_set_video_format (CheeseCamera *camera, CheeseVideoFormat *format)
{
CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+
if (!(priv->current_format->width == format->width &&
priv->current_format->height == format->height))
{
g_object_set (G_OBJECT (camera), "format", format, NULL);
- if (cheese_camera_is_playing (camera)) {
+ if (cheese_camera_is_playing (camera))
+ {
cheese_camera_stop (camera);
cheese_camera_play (camera);
}
diff --git a/libcheese/cheese-camera.h b/libcheese/cheese-camera.h
index b956fb5..14c13b9 100644
--- a/libcheese/cheese-camera.h
+++ b/libcheese/cheese-camera.h
@@ -81,27 +81,27 @@ CheeseCamera *cheese_camera_new (GtkWidget *video_window,
int y_resolution);
const CheeseVideoFormat *cheese_camera_get_current_video_format (CheeseCamera *camera);
-void cheese_camera_setup (CheeseCamera *camera, char *udi, GError **error);
-void cheese_camera_play (CheeseCamera *camera);
-void cheese_camera_stop (CheeseCamera *camera);
-void cheese_camera_set_effect (CheeseCamera *camera, CheeseCameraEffect effect);
-void cheese_camera_start_video_recording (CheeseCamera *camera, char *filename);
-void cheese_camera_stop_video_recording (CheeseCamera *camera);
-gboolean cheese_camera_take_photo (CheeseCamera *camera, char *filename);
-gboolean cheese_camera_take_photo_pixbuf (CheeseCamera *camera);
-gboolean cheese_camera_has_camera (CheeseCamera *camera);
-int cheese_camera_get_num_camera_devices (CheeseCamera *camera);
-CheeseCameraDevice *cheese_camera_get_selected_device (CheeseCamera *camera);
-GPtrArray * cheese_camera_get_camera_devices (CheeseCamera *camera);
-void cheese_camera_set_device_by_dev_file (CheeseCamera *camera, char *file);
-void cheese_camera_set_device_by_dev_udi (CheeseCamera *camera, char *udi);
-gboolean cheese_camera_switch_camera_device (CheeseCamera *camera);
-GList * cheese_camera_get_video_formats (CheeseCamera *camera);
-void cheese_camera_set_video_format (CheeseCamera *camera,
- CheeseVideoFormat *format);
+void cheese_camera_setup (CheeseCamera *camera, char *udi, GError **error);
+void cheese_camera_play (CheeseCamera *camera);
+void cheese_camera_stop (CheeseCamera *camera);
+void cheese_camera_set_effect (CheeseCamera *camera, CheeseCameraEffect effect);
+void cheese_camera_start_video_recording (CheeseCamera *camera, char *filename);
+void cheese_camera_stop_video_recording (CheeseCamera *camera);
+gboolean cheese_camera_take_photo (CheeseCamera *camera, char *filename);
+gboolean cheese_camera_take_photo_pixbuf (CheeseCamera *camera);
+gboolean cheese_camera_has_camera (CheeseCamera *camera);
+int cheese_camera_get_num_camera_devices (CheeseCamera *camera);
+CheeseCameraDevice * cheese_camera_get_selected_device (CheeseCamera *camera);
+GPtrArray * cheese_camera_get_camera_devices (CheeseCamera *camera);
+void cheese_camera_set_device_by_dev_file (CheeseCamera *camera, char *file);
+void cheese_camera_set_device_by_dev_udi (CheeseCamera *camera, char *udi);
+gboolean cheese_camera_switch_camera_device (CheeseCamera *camera);
+GList * cheese_camera_get_video_formats (CheeseCamera *camera);
+void cheese_camera_set_video_format (CheeseCamera *camera,
+ CheeseVideoFormat *format);
gboolean cheese_camera_get_balance_property_range (CheeseCamera *camera,
- gchar *property,
- gdouble *min, gdouble *max, gdouble *def);
+ gchar *property,
+ gdouble *min, gdouble *max, gdouble *def);
void cheese_camera_set_balance_property (CheeseCamera *camera, gchar *property, gdouble value);
G_END_DECLS
diff --git a/libcheese/cheese-fileutil.c b/libcheese/cheese-fileutil.c
index 4739327..90acd26 100644
--- a/libcheese/cheese-fileutil.c
+++ b/libcheese/cheese-fileutil.c
@@ -244,6 +244,6 @@ cheese_fileutil_new ()
fileutil = g_object_new (CHEESE_TYPE_FILEUTIL, NULL);
g_object_add_weak_pointer (G_OBJECT (fileutil),
- (gpointer) &fileutil);
+ (gpointer) & fileutil);
return fileutil;
}
diff --git a/libcheese/cheese-flash.c b/libcheese/cheese-flash.c
index 60acf72..e5b7d28 100644
--- a/libcheese/cheese-flash.c
+++ b/libcheese/cheese-flash.c
@@ -109,11 +109,13 @@ cheese_flash_dispose (GObject *object)
{
CheeseFlashPrivate *priv = CHEESE_FLASH_GET_PRIVATE (object);
- if (priv->window != NULL) {
+ if (priv->window != NULL)
+ {
gtk_widget_destroy (GTK_WIDGET (priv->window));
priv->window = NULL;
}
- if (priv->parent != NULL) {
+ if (priv->parent != NULL)
+ {
g_object_unref (priv->parent);
priv->parent = NULL;
}
@@ -130,10 +132,10 @@ cheese_flash_finalize (GObject *object)
}
static void
-cheese_flash_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+cheese_flash_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
CheeseFlashPrivate *priv = CHEESE_FLASH_GET_PRIVATE (object);
@@ -146,8 +148,8 @@ cheese_flash_set_property (GObject *object,
priv->parent = g_object_ref (object);
else
priv->parent = NULL;
- }
- break;
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -166,11 +168,11 @@ cheese_flash_class_init (CheeseFlashClass *klass)
object_class->finalize = cheese_flash_finalize;
g_object_class_install_property (object_class, PROP_PARENT,
- g_param_spec_object ("parent",
- NULL,
- NULL,
- GTK_TYPE_WIDGET,
- G_PARAM_WRITABLE));
+ g_param_spec_object ("parent",
+ NULL,
+ NULL,
+ GTK_TYPE_WIDGET,
+ G_PARAM_WRITABLE));
}
static gboolean
@@ -216,10 +218,10 @@ void
cheese_flash_fire (CheeseFlash *flash)
{
CheeseFlashPrivate *flash_priv = CHEESE_FLASH_GET_PRIVATE (flash);
- GtkWidget *parent;
- GdkScreen *screen;
- GdkRectangle rect;
- int monitor;
+ GtkWidget *parent;
+ GdkScreen *screen;
+ GdkRectangle rect;
+ int monitor;
g_return_if_fail (flash_priv->parent != NULL);
@@ -230,10 +232,10 @@ cheese_flash_fire (CheeseFlash *flash)
if (flash_priv->fade_timeout_tag > 0)
g_source_remove (flash_priv->fade_timeout_tag);
- parent = gtk_widget_get_toplevel (flash_priv->parent);
- screen = gtk_widget_get_screen (parent);
+ parent = gtk_widget_get_toplevel (flash_priv->parent);
+ screen = gtk_widget_get_screen (parent);
monitor = gdk_screen_get_monitor_at_window (screen,
- gtk_widget_get_window (parent));
+ gtk_widget_get_window (parent));
gdk_screen_get_monitor_geometry (screen, monitor, &rect);
gtk_window_set_transient_for (GTK_WINDOW (flash_window), GTK_WINDOW (parent));
gtk_window_resize (flash_window, rect.width, rect.height);
@@ -248,6 +250,6 @@ CheeseFlash *
cheese_flash_new (GtkWidget *parent)
{
return g_object_new (CHEESE_TYPE_FLASH,
- "parent", parent,
- NULL);
+ "parent", parent,
+ NULL);
}
diff --git a/libcheese/cheese-gconf.c b/libcheese/cheese-gconf.c
index c039d89..984e0a7 100644
--- a/libcheese/cheese-gconf.c
+++ b/libcheese/cheese-gconf.c
@@ -496,11 +496,11 @@ cheese_gconf_new ()
static CheeseGConf *gconf = NULL;
if (gconf != NULL)
- return g_object_ref (gconf);
+ return g_object_ref (gconf);
gconf = g_object_new (CHEESE_TYPE_GCONF, NULL);
g_object_add_weak_pointer (G_OBJECT (gconf),
- (gpointer) &gconf);
+ (gpointer) & gconf);
return gconf;
}
diff --git a/libcheese/cheese-widget.c b/libcheese/cheese-widget.c
index be9cccb..a6c92e1 100644
--- a/libcheese/cheese-widget.c
+++ b/libcheese/cheese-widget.c
@@ -38,7 +38,8 @@ enum
PROP_WIDGET
};
-enum {
+enum
+{
SPINNER_PAGE = 0,
WEBCAM_PAGE = 1,
PROBLEM_PAGE = 2,
@@ -62,33 +63,34 @@ typedef struct
G_DEFINE_TYPE (CheeseWidget, cheese_widget, GTK_TYPE_NOTEBOOK);
static GdkPixbuf *
-cheese_widget_load_pixbuf (GtkWidget *widget,
- const char *icon_name,
- guint size,
- GError **error)
+cheese_widget_load_pixbuf (GtkWidget *widget,
+ const char *icon_name,
+ guint size,
+ GError **error)
{
GtkIconTheme *theme;
- GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf;
theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
- //FIXME special case "no-webcam" and actually use the icon_name
+
+ /* FIXME special case "no-webcam" and actually use the icon_name */
pixbuf = gtk_icon_theme_load_icon (theme, "error",
- size, 0, error);
+ size, 0, error);
return pixbuf;
}
static gboolean
-cheese_widget_logo_expose (GtkWidget *w,
- GdkEventExpose *event,
- gpointer user_data)
+cheese_widget_logo_expose (GtkWidget *w,
+ GdkEventExpose *event,
+ gpointer user_data)
{
- const char *icon_name;
- GdkPixbuf *pixbuf, *logo;
- GError *error = NULL;
- cairo_t *cr;
+ const char *icon_name;
+ GdkPixbuf *pixbuf, *logo;
+ GError *error = NULL;
+ cairo_t *cr;
GtkAllocation allocation;
- guint s_width, s_height, d_width, d_height;
- float ratio;
+ guint s_width, s_height, d_width, d_height;
+ float ratio;
gdk_draw_rectangle (w->window, w->style->black_gc, TRUE,
0, 0, w->allocation.width, w->allocation.height);
@@ -101,26 +103,30 @@ cheese_widget_logo_expose (GtkWidget *w,
gtk_widget_get_allocation (w, &allocation);
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
- d_width = allocation.width;
+ d_width = allocation.width;
d_height = allocation.height - (allocation.height / 3);
pixbuf = cheese_widget_load_pixbuf (w, icon_name, d_height, &error);
- if (pixbuf == NULL) {
+ if (pixbuf == NULL)
+ {
g_warning ("Could not load icon '%s': %s", icon_name, error->message);
g_error_free (error);
return FALSE;
}
- s_width = gdk_pixbuf_get_width (pixbuf);
+ s_width = gdk_pixbuf_get_width (pixbuf);
s_height = gdk_pixbuf_get_height (pixbuf);
- if ((gfloat) d_width / s_width > (gfloat) d_height / s_height) {
+ if ((gfloat) d_width / s_width > (gfloat) d_height / s_height)
+ {
ratio = (gfloat) d_height / s_height;
- } else {
+ }
+ else
+ {
ratio = (gfloat) d_width / s_width;
}
- s_width *= ratio;
+ s_width *= ratio;
s_height *= ratio;
logo = gdk_pixbuf_scale_simple (pixbuf, s_width, s_height, GDK_INTERP_BILINEAR);
@@ -139,14 +145,15 @@ static void
cheese_widget_spinner_invert (GtkWidget *spinner, GtkWidget *parent)
{
GtkStyle *style;
- guint i;
+ guint i;
- for (i = GTK_STATE_NORMAL; i <= GTK_STATE_INSENSITIVE; i++) {
+ for (i = GTK_STATE_NORMAL; i <= GTK_STATE_INSENSITIVE; i++)
+ {
GdkColor *fg, *bg;
style = gtk_widget_get_style (spinner);
- fg = gdk_color_copy (&style->fg[i]);
- bg = gdk_color_copy (&style->bg[i]);
+ fg = gdk_color_copy (&style->fg[i]);
+ bg = gdk_color_copy (&style->bg[i]);
gtk_widget_modify_fg (spinner, i, bg);
gtk_widget_modify_bg (spinner, i, fg);
@@ -161,13 +168,13 @@ cheese_widget_spinner_invert (GtkWidget *spinner, GtkWidget *parent)
static void
cheese_widget_set_problem_page (CheeseWidget *widget,
- const char *icon_name)
+ const char *icon_name)
{
CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget);
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), PROBLEM_PAGE);
g_object_set_data_full (G_OBJECT (priv->problem),
- "icon-name", g_strdup (icon_name), g_free);
+ "icon-name", g_strdup (icon_name), g_free);
g_signal_connect (priv->problem, "expose-event",
G_CALLBACK (cheese_widget_logo_expose), widget);
}
@@ -176,7 +183,7 @@ static void
cheese_widget_init (CheeseWidget *widget)
{
CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget);
- GtkWidget *box;
+ GtkWidget *box;
/* XXX
* remove this line if you want to debug */
@@ -185,24 +192,24 @@ cheese_widget_init (CheeseWidget *widget)
/* Spinner page */
priv->spinner = gtk_spinner_new ();
- box = gtk_event_box_new ();
+ box = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (box), priv->spinner);
cheese_widget_spinner_invert (priv->spinner, box);
gtk_widget_show_all (box);
gtk_notebook_append_page (GTK_NOTEBOOK (widget),
- box, gtk_label_new ("spinner"));
+ box, gtk_label_new ("spinner"));
/* Webcam page */
priv->screen = gtk_drawing_area_new ();
gtk_notebook_append_page (GTK_NOTEBOOK (widget),
- priv->screen, gtk_label_new ("webcam"));
+ priv->screen, gtk_label_new ("webcam"));
/* Problem page */
priv->problem = gtk_drawing_area_new ();
gtk_notebook_append_page (GTK_NOTEBOOK (widget),
- priv->problem,
- gtk_label_new ("got problems"));
+ priv->problem,
+ gtk_label_new ("got problems"));
priv->gconf = cheese_gconf_new ();
}
@@ -212,11 +219,13 @@ cheese_widget_finalize (GObject *object)
{
CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (object);
- if (priv->gconf) {
+ if (priv->gconf)
+ {
g_object_unref (priv->gconf);
priv->gconf = NULL;
}
- if (priv->webcam) {
+ if (priv->webcam)
+ {
g_object_unref (priv->webcam);
priv->webcam = NULL;
}
@@ -227,8 +236,8 @@ cheese_widget_finalize (GObject *object)
#if 0
static void
cheese_widget_set_property (GObject *object, guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ const GValue *value,
+ GParamSpec *pspec)
{
CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (object);
@@ -247,7 +256,7 @@ cheese_widget_set_property (GObject *object, guint prop_id,
static void
cheese_widget_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+ GValue *value, GParamSpec *pspec)
{
CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (object);
@@ -263,34 +272,36 @@ cheese_widget_get_property (GObject *object, guint prop_id,
break;
}
}
+
#endif
#if 0
static void
cheese_widget_changed (CheeseWidget *self)
{
}
+
#endif
static gboolean
cheese_widget_emit_error_idle (CheeseWidget *widget)
{
g_signal_emit (widget, widget_signals[ERROR_SIGNAL], 0,
- _("Camera setup failed"));
+ _("Camera setup failed"));
return FALSE;
}
void
setup_camera (CheeseWidget *widget)
{
- CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget);
- char *webcam_device = NULL;
- int x_resolution;
- int y_resolution;
- gdouble brightness;
- gdouble contrast;
- gdouble saturation;
- gdouble hue;
- GError *error = NULL;
+ CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget);
+ char *webcam_device = NULL;
+ int x_resolution;
+ int y_resolution;
+ gdouble brightness;
+ gdouble contrast;
+ gdouble saturation;
+ gdouble hue;
+ GError *error = NULL;
g_object_get (priv->gconf,
"gconf_prop_x_resolution", &x_resolution,
@@ -304,8 +315,8 @@ setup_camera (CheeseWidget *widget)
gdk_threads_enter ();
priv->webcam = cheese_camera_new (priv->screen,
- webcam_device, x_resolution,
- y_resolution);
+ webcam_device, x_resolution,
+ y_resolution);
gdk_threads_leave ();
g_free (webcam_device);
@@ -322,9 +333,12 @@ setup_camera (CheeseWidget *widget)
gdk_threads_enter ();
gtk_spinner_stop (GTK_SPINNER (priv->spinner));
- if (cheese_camera_get_num_camera_devices (priv->webcam) == 0) {
+ if (cheese_camera_get_num_camera_devices (priv->webcam) == 0)
+ {
cheese_widget_set_problem_page (CHEESE_WIDGET (widget), "no-webcam");
- } else {
+ }
+ else
+ {
cheese_camera_play (priv->webcam);
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), WEBCAM_PAGE);
g_signal_emit (widget, widget_signals[READY_SIGNAL], 0, TRUE);
@@ -336,9 +350,9 @@ setup_camera (CheeseWidget *widget)
static void
cheese_widget_realize (GtkWidget *widget)
{
- GdkWindow *window;
- CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget);
- GError *error = NULL;
+ GdkWindow *window;
+ CheeseWidgetPrivate *priv = CHEESE_WIDGET_GET_PRIVATE (widget);
+ GError *error = NULL;
GTK_WIDGET_CLASS (cheese_widget_parent_class)->realize (widget);
@@ -374,35 +388,35 @@ error:
gtk_spinner_stop (GTK_SPINNER (priv->spinner));
cheese_widget_set_problem_page (CHEESE_WIDGET (widget), "error");
g_signal_emit (widget, widget_signals[ERROR_SIGNAL], 0,
- _("Camera setup failed"));
+ _("Camera setup failed"));
}
static void
cheese_widget_class_init (CheeseWidgetClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = cheese_widget_finalize;
+ object_class->finalize = cheese_widget_finalize;
#if 0
object_class->set_property = cheese_widget_set_property;
object_class->get_property = cheese_widget_get_property;
#endif
- widget_class->realize = cheese_widget_realize;
+ widget_class->realize = cheese_widget_realize;
widget_signals[READY_SIGNAL] = g_signal_new ("ready", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (CheeseWidgetClass, ready),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (CheeseWidgetClass, ready),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
widget_signals[ERROR_SIGNAL] = g_signal_new ("error", G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (CheeseWidgetClass, error),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (CheeseWidgetClass, error),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (CheeseWidgetPrivate));
}
diff --git a/libcheese/cheese-widget.h b/libcheese/cheese-widget.h
index 67b2a55..cb82818 100644
--- a/libcheese/cheese-widget.h
+++ b/libcheese/cheese-widget.h
@@ -27,13 +27,13 @@ G_BEGIN_DECLS
#define CHEESE_TYPE_WIDGET (cheese_widget_get_type ())
#define CHEESE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_WIDGET, \
- CheeseWidget))
+ CheeseWidget))
#define CHEESE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHEESE_TYPE_WIDGET, \
- CheeseWidgetClass))
+ CheeseWidgetClass))
#define CHEESE_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_WIDGET))
#define CHEESE_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHEESE_TYPE_WIDGET))
#define CHEESE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CHEESE_TYPE_WIDGET, \
- CheeseWidgetClass))
+ CheeseWidgetClass))
typedef struct _CheeseWidgetClass CheeseWidgetClass;
typedef struct _CheeseWidget CheeseWidget;
@@ -42,8 +42,8 @@ struct _CheeseWidgetClass
{
GtkNotebookClass parent_class;
- void (*ready) (CheeseWidget *widget, gboolean is_ready);
- void (*error) (CheeseWidget *widget, const char *error);
+ void (*ready)(CheeseWidget *widget, gboolean is_ready);
+ void (*error)(CheeseWidget *widget, const char *error);
};
struct _CheeseWidget
diff --git a/src/cheese-prefs-balance-scale.c b/src/cheese-prefs-balance-scale.c
index a2de176..789d260 100644
--- a/src/cheese-prefs-balance-scale.c
+++ b/src/cheese-prefs-balance-scale.c
@@ -111,7 +111,8 @@ cheese_prefs_balance_scale_synchronize (CheesePrefsWidget *prefs_widget)
gtk_widget_set_sensitive (scale, can_balance);
- if (can_balance) {
+ if (can_balance)
+ {
g_object_get (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, &stored_value, NULL);
gtk_range_set_value (GTK_RANGE (scale), stored_value);
}
diff --git a/src/cheese-prefs-camera-combo.c b/src/cheese-prefs-camera-combo.c
index 26a6f82..6bcc826 100644
--- a/src/cheese-prefs-camera-combo.c
+++ b/src/cheese-prefs-camera-combo.c
@@ -121,9 +121,9 @@ cheese_prefs_camera_combo_synchronize (CheesePrefsWidget *prefs_widget)
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), NULL);
- camera_devices = cheese_camera_get_camera_devices (priv->camera);
- num_devices = cheese_camera_get_num_camera_devices (priv->camera);
- selected_device = cheese_camera_get_selected_device (priv->camera);
+ camera_devices = cheese_camera_get_camera_devices (priv->camera);
+ num_devices = cheese_camera_get_num_camera_devices (priv->camera);
+ selected_device = cheese_camera_get_selected_device (priv->camera);
/* If the selected device is not the same device as the one in gconf, the
* selected device isn't available or was set by --hal-device. Set it now.
@@ -142,12 +142,12 @@ cheese_prefs_camera_combo_synchronize (CheesePrefsWidget *prefs_widget)
for (i = 0; i < num_devices; i++)
{
- device_ptr = g_ptr_array_index (camera_devices, i);
+ device_ptr = g_ptr_array_index (camera_devices, i);
const gchar *devpath = cheese_camera_device_get_device_file (device_ptr);
product_name = g_strdup_printf ("%s (%s)",
cheese_camera_device_get_name (device_ptr),
devpath);
- device_name = g_strdup (devpath);
+ device_name = g_strdup (devpath);
gtk_list_store_append (priv->list_store, &iter);
gtk_list_store_set (priv->list_store, &iter, PRODUCT_NAME, product_name,
diff --git a/src/cheese-prefs-dialog.c b/src/cheese-prefs-dialog.c
index aaff545..979ffc7 100644
--- a/src/cheese-prefs-dialog.c
+++ b/src/cheese-prefs-dialog.c
@@ -192,9 +192,9 @@ cheese_prefs_dialog_destroy_dialog (CheesePrefsDialog *prefs_dialog)
}
static void
-cheese_prefs_dialog_response (GtkDialog *dialog,
- int response_id,
- CheesePrefsDialog *prefs_dialog)
+cheese_prefs_dialog_response (GtkDialog *dialog,
+ int response_id,
+ CheesePrefsDialog *prefs_dialog)
{
cheese_prefs_dialog_destroy_dialog (prefs_dialog);
}
@@ -215,5 +215,5 @@ cheese_prefs_dialog_run (GtkWidget *parent, CheeseGConf *gconf, CheeseCamera *ca
gtk_widget_show (prefs_dialog->cheese_prefs_dialog);
g_signal_connect (G_OBJECT (prefs_dialog->cheese_prefs_dialog), "response",
- G_CALLBACK (cheese_prefs_dialog_response), prefs_dialog);
+ G_CALLBACK (cheese_prefs_dialog_response), prefs_dialog);
}
diff --git a/src/cheese-prefs-resolution-combo.c b/src/cheese-prefs-resolution-combo.c
index 29a1391..545008a 100644
--- a/src/cheese-prefs-resolution-combo.c
+++ b/src/cheese-prefs-resolution-combo.c
@@ -111,15 +111,15 @@ cheese_prefs_resolution_combo_synchronize (CheesePrefsWidget *prefs_widget)
CheesePrefsResolutionCombo *self = CHEESE_PREFS_RESOLUTION_COMBO (prefs_widget);
CheesePrefsResolutionComboPrivate *priv = CHEESE_PREFS_RESOLUTION_COMBO_GET_PRIVATE (self);
- GtkWidget *combo_box;
+ GtkWidget *combo_box;
const CheeseVideoFormat *current_format;
- GList *formats;
- GList *l;
- CheeseVideoFormat *format;
- gchar *format_name;
- GtkTreeIter iter;
- GtkTreeIter active_iter;
- gboolean found_resolution;
+ GList *formats;
+ GList *l;
+ CheeseVideoFormat *format;
+ gchar *format_name;
+ GtkTreeIter iter;
+ GtkTreeIter active_iter;
+ gboolean found_resolution;
priv->has_been_synchronized = TRUE;
found_resolution = FALSE;
@@ -140,7 +140,7 @@ cheese_prefs_resolution_combo_synchronize (CheesePrefsWidget *prefs_widget)
for (l = formats; l != NULL; l = l->next)
{
- format = l->data;
+ format = l->data;
format_name = g_strdup_printf ("%i x %i", format->width, format->height);
if (format->width <= priv->max_x_resolution &&
diff --git a/src/cheese-window.c b/src/cheese-window.c
index 0e5f2cb..3d23da6 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -72,7 +72,7 @@ typedef enum
typedef enum
{
- PAGE_WEBCAM = 0,
+ PAGE_WEBCAM = 0,
PAGE_EFFECTS = 1,
PAGE_SPINNER = 2,
PAGE_PROBLEM = 3,
@@ -180,23 +180,25 @@ typedef struct
} CheeseWindow;
-/* FIXME: some code borrowed from cheese-widget */
-/* We should really use it directly instead of duplicating stuff here */
+/* FIXME: some code borrowed from cheese-widget
+ * We should really use it directly instead of duplicating stuff here */
static GdkPixbuf *
-cheese_window_load_pixbuf (GtkWidget *widget,
- const char *icon_name,
- guint size,
- GError **error)
+cheese_window_load_pixbuf (GtkWidget *widget,
+ const char *icon_name,
+ guint size,
+ GError **error)
{
GtkIconTheme *theme;
- GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf;
theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
- if (!gtk_icon_theme_has_icon (theme, icon_name)) {
+ if (!gtk_icon_theme_has_icon (theme, icon_name))
+ {
pixbuf = gtk_icon_theme_load_icon (theme, "error",
size, 0, error);
}
- else {
+ else
+ {
pixbuf = gtk_icon_theme_load_icon (theme, icon_name,
size, 0, error);
}
@@ -204,17 +206,17 @@ cheese_window_load_pixbuf (GtkWidget *widget,
}
static gboolean
-cheese_window_logo_expose (GtkWidget *w,
- GdkEventExpose *event,
- gpointer user_data)
+cheese_window_logo_expose (GtkWidget *w,
+ GdkEventExpose *event,
+ gpointer user_data)
{
- const char *icon_name;
- GdkPixbuf *pixbuf, *logo;
- GError *error = NULL;
- cairo_t *cr;
+ const char *icon_name;
+ GdkPixbuf *pixbuf, *logo;
+ GError *error = NULL;
+ cairo_t *cr;
GtkAllocation allocation;
- guint s_width, s_height, d_width, d_height;
- float ratio;
+ guint s_width, s_height, d_width, d_height;
+ float ratio;
gdk_draw_rectangle (w->window, w->style->black_gc, TRUE,
0, 0, w->allocation.width, w->allocation.height);
@@ -227,26 +229,30 @@ cheese_window_logo_expose (GtkWidget *w,
gtk_widget_get_allocation (w, &allocation);
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
- d_width = allocation.width;
+ d_width = allocation.width;
d_height = allocation.height - (allocation.height / 3);
pixbuf = cheese_window_load_pixbuf (w, icon_name, d_height, &error);
- if (pixbuf == NULL) {
+ if (pixbuf == NULL)
+ {
g_warning ("Could not load icon '%s': %s", icon_name, error->message);
g_error_free (error);
return FALSE;
}
- s_width = gdk_pixbuf_get_width (pixbuf);
+ s_width = gdk_pixbuf_get_width (pixbuf);
s_height = gdk_pixbuf_get_height (pixbuf);
- if ((gfloat) d_width / s_width > (gfloat) d_height / s_height) {
+ if ((gfloat) d_width / s_width > (gfloat) d_height / s_height)
+ {
ratio = (gfloat) d_height / s_height;
- } else {
+ }
+ else
+ {
ratio = (gfloat) d_width / s_width;
}
- s_width *= ratio;
+ s_width *= ratio;
s_height *= ratio;
logo = gdk_pixbuf_scale_simple (pixbuf, s_width, s_height, GDK_INTERP_BILINEAR);
@@ -263,11 +269,11 @@ cheese_window_logo_expose (GtkWidget *w,
static void
cheese_window_set_problem_page (CheeseWindow *window,
- const char *icon_name)
+ const char *icon_name)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), PAGE_PROBLEM);
g_object_set_data_full (G_OBJECT (window->problem_area),
- "icon-name", g_strdup (icon_name), g_free);
+ "icon-name", g_strdup (icon_name), g_free);
g_signal_connect (window->problem_area, "expose-event",
G_CALLBACK (cheese_window_logo_expose), window);
}
@@ -276,14 +282,15 @@ static void
cheese_window_spinner_invert (GtkWidget *spinner, GtkWidget *parent)
{
GtkStyle *style;
- guint i;
+ guint i;
- for (i = GTK_STATE_NORMAL; i <= GTK_STATE_INSENSITIVE; i++) {
+ for (i = GTK_STATE_NORMAL; i <= GTK_STATE_INSENSITIVE; i++)
+ {
GdkColor *fg, *bg;
style = gtk_widget_get_style (spinner);
- fg = gdk_color_copy (&style->fg[i]);
- bg = gdk_color_copy (&style->bg[i]);
+ fg = gdk_color_copy (&style->fg[i]);
+ bg = gdk_color_copy (&style->bg[i]);
gtk_widget_modify_fg (spinner, i, bg);
gtk_widget_modify_bg (spinner, i, fg);
@@ -1688,7 +1695,7 @@ cheese_window_create_window (CheeseWindow *cheese_window)
/* Problem page */
cheese_window->problem_page = gtk_vbox_new (FALSE, 0);
- cheese_window->problem_bar = cheese_no_camera_info_bar_new ();
+ cheese_window->problem_bar = cheese_no_camera_info_bar_new ();
g_signal_connect (cheese_window->problem_bar,
"response",
G_CALLBACK (cheese_window_no_camera_info_bar_response),
@@ -1701,8 +1708,8 @@ cheese_window_create_window (CheeseWindow *cheese_window)
cheese_window->problem_area,
TRUE, TRUE, 0);
gtk_notebook_insert_page (GTK_NOTEBOOK (cheese_window->notebook),
- cheese_window->problem_page,
- gtk_label_new ("got problems"),
+ cheese_window->problem_page,
+ gtk_label_new ("got problems"),
PAGE_PROBLEM);
@@ -1746,19 +1753,20 @@ cheese_window_create_window (CheeseWindow *cheese_window)
g_free (gconf_effects);
/* uncomment to debug */
+
/*
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (cheese_window->notebook), TRUE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (cheese_window->notebook), TRUE);
-*/
+ * gtk_notebook_set_show_tabs (GTK_NOTEBOOK (cheese_window->notebook), TRUE);
+ * gtk_notebook_set_show_border (GTK_NOTEBOOK (cheese_window->notebook), TRUE);
+ */
- cheese_window->throbber = gtk_spinner_new ();
- cheese_window->throbber_box = gtk_event_box_new ();
+ cheese_window->throbber = gtk_spinner_new ();
+ cheese_window->throbber_box = gtk_event_box_new ();
cheese_window->throbber_align = gtk_alignment_new (0.5, 0.5, 0.6, 0.6);
gtk_container_add (GTK_CONTAINER (cheese_window->throbber_box), cheese_window->throbber_align);
gtk_container_add (GTK_CONTAINER (cheese_window->throbber_align), cheese_window->throbber);
gtk_notebook_insert_page (GTK_NOTEBOOK (cheese_window->notebook),
- cheese_window->throbber_box,
- gtk_label_new ("spinner"),
+ cheese_window->throbber_box,
+ gtk_label_new ("spinner"),
PAGE_SPINNER);
cheese_window_spinner_invert (cheese_window->throbber, cheese_window->throbber_box);
gtk_widget_show_all (cheese_window->throbber_box);
@@ -1915,13 +1923,13 @@ cheese_window_create_window (CheeseWindow *cheese_window)
void
setup_camera (CheeseWindow *cheese_window)
{
- char *camera_device = NULL;
- int x_resolution;
- int y_resolution;
- gdouble brightness;
- gdouble contrast;
- gdouble saturation;
- gdouble hue;
+ char *camera_device = NULL;
+ int x_resolution;
+ int y_resolution;
+ gdouble brightness;
+ gdouble contrast;
+ gdouble saturation;
+ gdouble hue;
GError *error;
@@ -1947,7 +1955,8 @@ setup_camera (CheeseWindow *cheese_window)
cheese_camera_setup (cheese_window->camera, cheese_window->startup_hal_dev_udi, &error);
if (error != NULL)
{
- if (error->code == CHEESE_CAMERA_ERROR_NO_DEVICE) {
+ if (error->code == CHEESE_CAMERA_ERROR_NO_DEVICE)
+ {
gdk_threads_enter ();
gtk_spinner_stop (GTK_SPINNER (cheese_window->throbber));
cheese_window_set_problem_page (cheese_window, "cheese-no-camera");
diff --git a/src/eog-thumb-nav.c b/src/eog-thumb-nav.c
index 1d99539..87b3305 100644
--- a/src/eog-thumb-nav.c
+++ b/src/eog-thumb-nav.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <cheese-config.h>
+ #include <cheese-config.h>
#endif
#include "eog-thumb-nav.h"
@@ -32,14 +32,14 @@
#include <gtk/gtk.h>
#include <string.h>
-#define EOG_THUMB_NAV_GET_PRIVATE(object) \
+#define EOG_THUMB_NAV_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EOG_TYPE_THUMB_NAV, EogThumbNavPrivate))
G_DEFINE_TYPE (EogThumbNav, eog_thumb_nav, GTK_TYPE_HBOX);
-#define EOG_THUMB_NAV_SCROLL_INC 20
-#define EOG_THUMB_NAV_SCROLL_MOVE 20
-#define EOG_THUMB_NAV_SCROLL_TIMEOUT 20
+#define EOG_THUMB_NAV_SCROLL_INC 20
+#define EOG_THUMB_NAV_SCROLL_MOVE 20
+#define EOG_THUMB_NAV_SCROLL_TIMEOUT 20
enum
{
@@ -48,54 +48,57 @@ enum
PROP_MODE
};
-struct _EogThumbNavPrivate {
- gboolean show_buttons;
- gboolean vertical;
- gboolean scroll_dir;
- gint scroll_pos;
- gint scroll_id;
-
- GtkWidget *button_up;
- GtkWidget *button_down;
- GtkWidget *button_left;
- GtkWidget *button_right;
- GtkWidget *sw;
- GtkWidget *thumbview;
- GtkWidget *vbox;
- GtkAdjustment *hadj;
- GtkAdjustment *vadj;
- GtkAdjustment *adj;
+struct _EogThumbNavPrivate
+{
+ gboolean show_buttons;
+ gboolean vertical;
+ gboolean scroll_dir;
+ gint scroll_pos;
+ gint scroll_id;
+
+ GtkWidget *button_up;
+ GtkWidget *button_down;
+ GtkWidget *button_left;
+ GtkWidget *button_right;
+ GtkWidget *sw;
+ GtkWidget *thumbview;
+ GtkWidget *vbox;
+ GtkAdjustment *hadj;
+ GtkAdjustment *vadj;
+ GtkAdjustment *adj;
};
static gboolean
eog_thumb_nav_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
{
EogThumbNav *nav = EOG_THUMB_NAV (user_data);
- gint inc = EOG_THUMB_NAV_SCROLL_INC * 3;
- gdouble value, upper, page_size;
+ gint inc = EOG_THUMB_NAV_SCROLL_INC * 3;
+ gdouble value, upper, page_size;
nav->priv->adj = nav->priv->vertical ? nav->priv->vadj : nav->priv->hadj;
- switch (event->direction) {
- case GDK_SCROLL_UP:
- case GDK_SCROLL_LEFT:
- inc *= -1;
- break;
-
- case GDK_SCROLL_DOWN:
- case GDK_SCROLL_RIGHT:
- break;
-
- default:
- g_assert_not_reached ();
- return FALSE;
+ switch (event->direction)
+ {
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_LEFT:
+ inc *= -1;
+ break;
+
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_RIGHT:
+ break;
+
+ default:
+ g_assert_not_reached ();
+ return FALSE;
}
value = gtk_adjustment_get_value (nav->priv->adj);
if (inc < 0)
gtk_adjustment_set_value (nav->priv->adj, MAX (0, value + inc));
- else {
- upper = gtk_adjustment_get_upper (nav->priv->adj);
+ else
+ {
+ upper = gtk_adjustment_get_upper (nav->priv->adj);
page_size = gtk_adjustment_get_page_size (nav->priv->adj);
gtk_adjustment_set_value (nav->priv->adj, MIN (upper - page_size, value + inc));
}
@@ -108,14 +111,14 @@ eog_thumb_nav_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer u
static void
eog_thumb_nav_vadj_changed (GtkAdjustment *vadj, gpointer user_data)
{
- EogThumbNav *nav;
+ EogThumbNav *nav;
EogThumbNavPrivate *priv;
- gboolean ltr;
- gdouble value, upper, page_size;
+ gboolean ltr;
+ gdouble value, upper, page_size;
- nav = EOG_THUMB_NAV (user_data);
+ nav = EOG_THUMB_NAV (user_data);
priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
- ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
+ ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
g_object_get (vadj,
"value", &value,
@@ -131,14 +134,14 @@ eog_thumb_nav_vadj_changed (GtkAdjustment *vadj, gpointer user_data)
static void
eog_thumb_nav_hadj_changed (GtkAdjustment *hadj, gpointer user_data)
{
- EogThumbNav *nav;
+ EogThumbNav *nav;
EogThumbNavPrivate *priv;
- gboolean ltr;
- gdouble value, upper, page_size;
+ gboolean ltr;
+ gdouble value, upper, page_size;
- nav = EOG_THUMB_NAV (user_data);
+ nav = EOG_THUMB_NAV (user_data);
priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
- ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
+ ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
g_object_get (hadj,
"value", &value,
@@ -153,14 +156,14 @@ eog_thumb_nav_hadj_changed (GtkAdjustment *hadj, gpointer user_data)
static void
eog_thumb_nav_vadj_value_changed (GtkAdjustment *vadj, gpointer user_data)
{
- EogThumbNav *nav;
+ EogThumbNav *nav;
EogThumbNavPrivate *priv;
- gboolean ltr;
- gdouble value, upper, page_size;
+ gboolean ltr;
+ gdouble value, upper, page_size;
- nav = EOG_THUMB_NAV (user_data);
+ nav = EOG_THUMB_NAV (user_data);
priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
- ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
+ ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
g_object_get (vadj,
"value", &value,
@@ -177,14 +180,14 @@ eog_thumb_nav_vadj_value_changed (GtkAdjustment *vadj, gpointer user_data)
static void
eog_thumb_nav_hadj_value_changed (GtkAdjustment *hadj, gpointer user_data)
{
- EogThumbNav *nav;
+ EogThumbNav *nav;
EogThumbNavPrivate *priv;
- gboolean ltr;
- gdouble value, upper, page_size;
+ gboolean ltr;
+ gdouble value, upper, page_size;
- nav = EOG_THUMB_NAV (user_data);
+ nav = EOG_THUMB_NAV (user_data);
priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
- ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
+ ltr = gtk_widget_get_direction (priv->sw) == GTK_TEXT_DIR_LTR;
g_object_get (hadj,
"value", &value,
@@ -202,8 +205,8 @@ static gboolean
eog_thumb_nav_scroll_step (gpointer user_data)
{
EogThumbNav *nav = EOG_THUMB_NAV (user_data);
- gint delta;
- gdouble value, upper, page_size;
+ gint delta;
+ gdouble value, upper, page_size;
if (nav->priv->scroll_pos < 10)
delta = EOG_THUMB_NAV_SCROLL_INC;
@@ -224,11 +227,14 @@ eog_thumb_nav_scroll_step (gpointer user_data)
NULL);
if ((gint) (value + (gdouble) delta) >= 0 &&
- (gint) (value + (gdouble) delta) <= upper - page_size) {
+ (gint) (value + (gdouble) delta) <= upper - page_size)
+ {
gtk_adjustment_set_value (nav->priv->adj, value + (gdouble) delta);
nav->priv->scroll_pos++;
gtk_adjustment_value_changed (nav->priv->adj);
- } else {
+ }
+ else
+ {
if (delta > 0)
gtk_adjustment_set_value (nav->priv->adj, upper - page_size);
else
@@ -253,9 +259,11 @@ eog_thumb_nav_button_clicked (GtkButton *button, EogThumbNav *nav)
(GTK_WIDGET (button) == nav->priv->button_left))
{
nav->priv->scroll_dir = gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR ?
- GTK_WIDGET (button) == nav->priv->button_right :
- GTK_WIDGET (button) == nav->priv->button_left;
- } else {
+ GTK_WIDGET (button) == nav->priv->button_right :
+ GTK_WIDGET (button) == nav->priv->button_left;
+ }
+ else
+ {
nav->priv->scroll_dir = (GTK_WIDGET (button) == nav->priv->button_down);
}
@@ -268,14 +276,15 @@ eog_thumb_nav_button_clicked (GtkButton *button, EogThumbNav *nav)
static void
eog_thumb_nav_start_scroll (GtkButton *button, EogThumbNav *nav)
{
-
if ((GTK_WIDGET (button) == nav->priv->button_right) ||
(GTK_WIDGET (button) == nav->priv->button_left))
{
nav->priv->scroll_dir = gtk_widget_get_direction (GTK_WIDGET (button)) == GTK_TEXT_DIR_LTR ?
- GTK_WIDGET (button) == nav->priv->button_right :
- GTK_WIDGET (button) == nav->priv->button_left;
- } else {
+ GTK_WIDGET (button) == nav->priv->button_right :
+ GTK_WIDGET (button) == nav->priv->button_left;
+ }
+ else
+ {
nav->priv->scroll_dir = (GTK_WIDGET (button) == nav->priv->button_down);
}
@@ -290,9 +299,10 @@ eog_thumb_nav_start_scroll (GtkButton *button, EogThumbNav *nav)
static void
eog_thumb_nav_stop_scroll (GtkButton *button, EogThumbNav *nav)
{
- if (nav->priv->scroll_id > 0) {
+ if (nav->priv->scroll_id > 0)
+ {
g_source_remove (nav->priv->scroll_id);
- nav->priv->scroll_id = 0;
+ nav->priv->scroll_id = 0;
nav->priv->scroll_pos = 0;
}
}
@@ -307,14 +317,14 @@ eog_thumb_nav_get_property (GObject *object,
switch (property_id)
{
- case PROP_SHOW_BUTTONS:
- g_value_set_boolean (value,
- eog_thumb_nav_get_show_buttons (nav));
- break;
-
- case PROP_THUMB_VIEW:
- g_value_set_object (value, nav->priv->thumbview);
- break;
+ case PROP_SHOW_BUTTONS:
+ g_value_set_boolean (value,
+ eog_thumb_nav_get_show_buttons (nav));
+ break;
+
+ case PROP_THUMB_VIEW:
+ g_value_set_object (value, nav->priv->thumbview);
+ break;
}
}
@@ -328,34 +338,35 @@ eog_thumb_nav_set_property (GObject *object,
switch (property_id)
{
- case PROP_SHOW_BUTTONS:
- eog_thumb_nav_set_show_buttons (nav,
- g_value_get_boolean (value));
- break;
-
- case PROP_THUMB_VIEW:
- nav->priv->thumbview =
- GTK_WIDGET (g_value_get_object (value));
- break;
+ case PROP_SHOW_BUTTONS:
+ eog_thumb_nav_set_show_buttons (nav,
+ g_value_get_boolean (value));
+ break;
+
+ case PROP_THUMB_VIEW:
+ nav->priv->thumbview =
+ GTK_WIDGET (g_value_get_object (value));
+ break;
}
}
static GObject *
-eog_thumb_nav_constructor (GType type,
- guint n_construct_properties,
+eog_thumb_nav_constructor (GType type,
+ guint n_construct_properties,
GObjectConstructParam *construct_params)
{
- GObject *object;
- EogThumbNav *nav;
+ GObject *object;
+ EogThumbNav *nav;
EogThumbNavPrivate *priv;
object = G_OBJECT_CLASS (eog_thumb_nav_parent_class)->constructor
- (type, n_construct_properties, construct_params);
+ (type, n_construct_properties, construct_params);
- nav = EOG_THUMB_NAV (object);
+ nav = EOG_THUMB_NAV (object);
priv = EOG_THUMB_NAV_GET_PRIVATE (object);
- if (priv->thumbview != NULL) {
+ if (priv->thumbview != NULL)
+ {
gtk_container_add (GTK_CONTAINER (priv->sw), priv->thumbview);
gtk_widget_show_all (priv->sw);
}
@@ -401,14 +412,14 @@ static void
eog_thumb_nav_init (EogThumbNav *nav)
{
EogThumbNavPrivate *priv;
- GtkWidget *arrow;
+ GtkWidget *arrow;
nav->priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
priv = nav->priv;
priv->show_buttons = TRUE;
- priv->vertical = FALSE;
+ priv->vertical = FALSE;
priv->button_left = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (priv->button_left), GTK_RELIEF_NONE);
@@ -588,10 +599,10 @@ eog_thumb_nav_init (EogThumbNav *nav)
* Returns: a new #EogThumbNav object.
**/
GtkWidget *
-eog_thumb_nav_new (GtkWidget *thumbview,
- gboolean show_buttons)
+eog_thumb_nav_new (GtkWidget *thumbview,
+ gboolean show_buttons)
{
- EogThumbNav *nav;
+ EogThumbNav *nav;
EogThumbNavPrivate *priv;
nav = g_object_new (EOG_TYPE_THUMB_NAV,
@@ -635,26 +646,30 @@ void
eog_thumb_nav_set_show_buttons (EogThumbNav *nav, gboolean show_buttons)
{
g_return_if_fail (EOG_IS_THUMB_NAV (nav));
- g_return_if_fail (nav->priv->button_left != NULL);
+ g_return_if_fail (nav->priv->button_left != NULL);
g_return_if_fail (nav->priv->button_right != NULL);
nav->priv->show_buttons = show_buttons;
- if (show_buttons) {
+ if (show_buttons)
+ {
gtk_widget_show_all (nav->priv->button_left);
gtk_widget_show_all (nav->priv->button_right);
- } else {
+ }
+ else
+ {
gtk_widget_hide_all (nav->priv->button_left);
gtk_widget_hide_all (nav->priv->button_right);
}
}
void
-eog_thumb_nav_set_policy (EogThumbNav *nav,
+eog_thumb_nav_set_policy (EogThumbNav *nav,
GtkPolicyType hscrollbar_policy,
GtkPolicyType vscrollbar_policy)
{
EogThumbNavPrivate *priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
hscrollbar_policy,
vscrollbar_policy);
@@ -664,6 +679,7 @@ gboolean
eog_thumb_nav_is_vertical (EogThumbNav *nav)
{
EogThumbNavPrivate *priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
+
return priv->vertical;
}
@@ -673,7 +689,7 @@ eog_thumb_nav_set_vertical (EogThumbNav *nav, gboolean vertical)
EogThumbNavPrivate *priv = EOG_THUMB_NAV_GET_PRIVATE (nav);
g_return_if_fail (EOG_IS_THUMB_NAV (nav));
- g_return_if_fail (priv->button_left != NULL);
+ g_return_if_fail (priv->button_left != NULL);
g_return_if_fail (priv->button_right != NULL);
g_return_if_fail (priv->vbox != NULL);
g_return_if_fail (priv->sw != NULL);
@@ -682,7 +698,8 @@ eog_thumb_nav_set_vertical (EogThumbNav *nav, gboolean vertical)
/* show/hide doesn't work because of a mandatory show_all in cheese-window */
- if (vertical) {
+ if (vertical)
+ {
g_return_if_fail (!gtk_widget_get_parent (priv->button_up));
g_return_if_fail (!gtk_widget_get_parent (priv->button_down));
g_return_if_fail (gtk_widget_get_parent (priv->button_left));
@@ -704,7 +721,9 @@ eog_thumb_nav_set_vertical (EogThumbNav *nav, gboolean vertical)
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
priv->vertical = TRUE;
- } else {
+ }
+ else
+ {
g_return_if_fail (!gtk_widget_get_parent (priv->button_left));
g_return_if_fail (!gtk_widget_get_parent (priv->button_right));
g_return_if_fail (gtk_widget_get_parent (priv->button_up));
@@ -729,4 +748,3 @@ eog_thumb_nav_set_vertical (EogThumbNav *nav, gboolean vertical)
}
gtk_widget_show_all (GTK_WIDGET (nav));
}
-
diff --git a/src/eog-thumb-nav.h b/src/eog-thumb-nav.h
index 314fea0..bb6ea2c 100644
--- a/src/eog-thumb-nav.h
+++ b/src/eog-thumb-nav.h
@@ -34,41 +34,43 @@ typedef struct _EogThumbNav EogThumbNav;
typedef struct _EogThumbNavClass EogThumbNavClass;
typedef struct _EogThumbNavPrivate EogThumbNavPrivate;
-#define EOG_TYPE_THUMB_NAV (eog_thumb_nav_get_type ())
-#define EOG_THUMB_NAV(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), EOG_TYPE_THUMB_NAV, EogThumbNav))
-#define EOG_THUMB_NAV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EOG_TYPE_THUMB_NAV, EogThumbNavClass))
-#define EOG_IS_THUMB_NAV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), EOG_TYPE_THUMB_NAV))
-#define EOG_IS_THUMB_NAV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EOG_TYPE_THUMB_NAV))
-#define EOG_THUMB_NAV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EOG_TYPE_THUMB_NAV, EogThumbNavClass))
-
-struct _EogThumbNav {
- GtkHBox base_instance;
-
- EogThumbNavPrivate *priv;
+#define EOG_TYPE_THUMB_NAV (eog_thumb_nav_get_type ())
+#define EOG_THUMB_NAV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EOG_TYPE_THUMB_NAV, EogThumbNav))
+#define EOG_THUMB_NAV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EOG_TYPE_THUMB_NAV, EogThumbNavClass))
+#define EOG_IS_THUMB_NAV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EOG_TYPE_THUMB_NAV))
+#define EOG_IS_THUMB_NAV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EOG_TYPE_THUMB_NAV))
+#define EOG_THUMB_NAV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EOG_TYPE_THUMB_NAV, EogThumbNavClass))
+
+struct _EogThumbNav
+{
+ GtkHBox base_instance;
+
+ EogThumbNavPrivate *priv;
};
-struct _EogThumbNavClass {
- GtkHBoxClass parent_class;
+struct _EogThumbNavClass
+{
+ GtkHBoxClass parent_class;
};
-GType eog_thumb_nav_get_type (void) G_GNUC_CONST;
+GType eog_thumb_nav_get_type (void) G_GNUC_CONST;
-GtkWidget *eog_thumb_nav_new (GtkWidget *thumbview,
- gboolean show_buttons);
+GtkWidget *eog_thumb_nav_new (GtkWidget *thumbview,
+ gboolean show_buttons);
-gboolean eog_thumb_nav_get_show_buttons (EogThumbNav *nav);
+gboolean eog_thumb_nav_get_show_buttons (EogThumbNav *nav);
-void eog_thumb_nav_set_show_buttons (EogThumbNav *nav,
- gboolean show_buttons);
+void eog_thumb_nav_set_show_buttons (EogThumbNav *nav,
+ gboolean show_buttons);
-gboolean eog_thumb_nav_is_vertical (EogThumbNav *nav);
+gboolean eog_thumb_nav_is_vertical (EogThumbNav *nav);
-void eog_thumb_nav_set_vertical (EogThumbNav *nav,
- gboolean vertical);
+void eog_thumb_nav_set_vertical (EogThumbNav *nav,
+ gboolean vertical);
-void eog_thumb_nav_set_policy (EogThumbNav *nav,
- GtkPolicyType hscrollbar_policy,
- GtkPolicyType vscrollbar_policy);
+void eog_thumb_nav_set_policy (EogThumbNav *nav,
+ GtkPolicyType hscrollbar_policy,
+ GtkPolicyType vscrollbar_policy);
G_END_DECLS
diff --git a/src/eog-thumbnail.c b/src/eog-thumbnail.c
index e74de71..a19e348 100644
--- a/src/eog-thumbnail.c
+++ b/src/eog-thumbnail.c
@@ -1,11 +1,11 @@
-/* Eye Of Gnome - Thumbnailing functions
+/* Eye Of Gnome - Thumbnailing functions
*
* Copyright (C) 2000-2007 The Free Software Foundation
*
* Author: Lucas Rocha <lucasr gnome org>
*
- * Based on eel code (eel/eel-graphic-effects.c) by:
- * - Andy Hertzfeld <andy eazel com>
+ * Based on eel code (eel/eel-graphic-effects.c) by:
+ * - Andy Hertzfeld <andy eazel com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,11 +22,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* NOTE this is a stripped version of eog-thumbnail which only contains the
+/* NOTE this is a stripped version of eog-thumbnail which only contains the
* functions necessary for cheese
*/
#ifdef HAVE_CONFIG_H
-#include <cheese-config.h>
+ #include <cheese-config.h>
#endif
#include "eog-thumbnail.h"
@@ -36,69 +36,71 @@ static GdkPixbuf *frame = NULL;
static void
-draw_frame_row (GdkPixbuf *frame_image,
- gint target_width,
- gint source_width,
- gint source_v_position,
- gint dest_v_position,
- GdkPixbuf *result_pixbuf,
- gint left_offset,
- gint height)
+draw_frame_row (GdkPixbuf *frame_image,
+ gint target_width,
+ gint source_width,
+ gint source_v_position,
+ gint dest_v_position,
+ GdkPixbuf *result_pixbuf,
+ gint left_offset,
+ gint height)
{
- gint remaining_width, h_offset, slab_width;
-
- remaining_width = target_width;
- h_offset = 0;
-
- while (remaining_width > 0) {
- slab_width = remaining_width > source_width ?
- source_width : remaining_width;
-
- gdk_pixbuf_copy_area (frame_image,
- left_offset,
- source_v_position,
- slab_width,
- height,
- result_pixbuf,
- left_offset + h_offset,
- dest_v_position);
-
- remaining_width -= slab_width;
- h_offset += slab_width;
- }
+ gint remaining_width, h_offset, slab_width;
+
+ remaining_width = target_width;
+ h_offset = 0;
+
+ while (remaining_width > 0)
+ {
+ slab_width = remaining_width > source_width ?
+ source_width : remaining_width;
+
+ gdk_pixbuf_copy_area (frame_image,
+ left_offset,
+ source_v_position,
+ slab_width,
+ height,
+ result_pixbuf,
+ left_offset + h_offset,
+ dest_v_position);
+
+ remaining_width -= slab_width;
+ h_offset += slab_width;
+ }
}
static void
-draw_frame_column (GdkPixbuf *frame_image,
- gint target_height,
- gint source_height,
- gint source_h_position,
- gint dest_h_position,
- GdkPixbuf *result_pixbuf,
- gint top_offset,
- gint width)
+draw_frame_column (GdkPixbuf *frame_image,
+ gint target_height,
+ gint source_height,
+ gint source_h_position,
+ gint dest_h_position,
+ GdkPixbuf *result_pixbuf,
+ gint top_offset,
+ gint width)
{
- gint remaining_height, v_offset, slab_height;
-
- remaining_height = target_height;
- v_offset = 0;
-
- while (remaining_height > 0) {
- slab_height = remaining_height > source_height ?
- source_height : remaining_height;
-
- gdk_pixbuf_copy_area (frame_image,
- source_h_position,
- top_offset,
- width,
- slab_height,
- result_pixbuf,
- dest_h_position,
- top_offset + v_offset);
-
- remaining_height -= slab_height;
- v_offset += slab_height;
- }
+ gint remaining_height, v_offset, slab_height;
+
+ remaining_height = target_height;
+ v_offset = 0;
+
+ while (remaining_height > 0)
+ {
+ slab_height = remaining_height > source_height ?
+ source_height : remaining_height;
+
+ gdk_pixbuf_copy_area (frame_image,
+ source_h_position,
+ top_offset,
+ width,
+ slab_height,
+ result_pixbuf,
+ dest_h_position,
+ top_offset + v_offset);
+
+ remaining_height -= slab_height;
+ v_offset += slab_height;
+ }
}
/* copied from libart_lgpl/art_rgb.c */
@@ -106,181 +108,186 @@ draw_frame_column (GdkPixbuf *frame_image,
static void
art_rgb_run_alpha (guint8 *buf, guint8 r, guint8 g, guint8 b, int alpha, int n)
{
- int i;
- int v;
-
- for (i = 0; i < n; i++)
- {
- v = *buf;
- *buf++ = v + (((r - v) * alpha + 0x80) >> 8);
- v = *buf;
- *buf++ = v + (((g - v) * alpha + 0x80) >> 8);
- v = *buf;
- *buf++ = v + (((b - v) * alpha + 0x80) >> 8);
- }
+ int i;
+ int v;
+
+ for (i = 0; i < n; i++)
+ {
+ v = *buf;
+ *buf++ = v + (((r - v) * alpha + 0x80) >> 8);
+ v = *buf;
+ *buf++ = v + (((g - v) * alpha + 0x80) >> 8);
+ v = *buf;
+ *buf++ = v + (((b - v) * alpha + 0x80) >> 8);
+ }
}
static GdkPixbuf *
-eog_thumbnail_stretch_frame_image (GdkPixbuf *frame_image,
- gint left_offset,
- gint top_offset,
- gint right_offset,
- gint bottom_offset,
- gint dest_width,
- gint dest_height,
- gboolean fill_flag)
+eog_thumbnail_stretch_frame_image (GdkPixbuf *frame_image,
+ gint left_offset,
+ gint top_offset,
+ gint right_offset,
+ gint bottom_offset,
+ gint dest_width,
+ gint dest_height,
+ gboolean fill_flag)
{
- GdkPixbuf *result_pixbuf;
- guchar *pixels_ptr;
- gint frame_width, frame_height;
- gint y, row_stride;
- gint target_width, target_frame_width;
- gint target_height, target_frame_height;
-
- frame_width = gdk_pixbuf_get_width (frame_image);
- frame_height = gdk_pixbuf_get_height (frame_image);
-
- if (fill_flag) {
- result_pixbuf = gdk_pixbuf_scale_simple (frame_image,
- dest_width,
- dest_height,
- GDK_INTERP_NEAREST);
- } else {
- result_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE,
- 8,
- dest_width,
- dest_height);
- }
-
- row_stride = gdk_pixbuf_get_rowstride (result_pixbuf);
- pixels_ptr = gdk_pixbuf_get_pixels (result_pixbuf);
-
- if (!fill_flag) {
- for (y = 0; y < dest_height; y++) {
- art_rgb_run_alpha (pixels_ptr,
- 255, 255,
- 255, 255,
- dest_width);
- pixels_ptr += row_stride;
- }
- }
-
- target_width = dest_width - left_offset - right_offset;
- target_frame_width = frame_width - left_offset - right_offset;
-
- target_height = dest_height - top_offset - bottom_offset;
- target_frame_height = frame_height - top_offset - bottom_offset;
-
- /* Draw the left top corner and top row */
- gdk_pixbuf_copy_area (frame_image,
- 0, 0,
- left_offset,
- top_offset,
- result_pixbuf,
- 0, 0);
-
- draw_frame_row (frame_image,
- target_width,
- target_frame_width,
- 0, 0,
- result_pixbuf,
- left_offset,
- top_offset);
-
- /* Draw the right top corner and left column */
- gdk_pixbuf_copy_area (frame_image,
- frame_width - right_offset,
- 0,
- right_offset,
- top_offset,
- result_pixbuf,
- dest_width - right_offset,
- 0);
-
- draw_frame_column (frame_image,
- target_height,
- target_frame_height,
- 0, 0,
- result_pixbuf,
- top_offset,
- left_offset);
-
- /* Draw the bottom right corner and bottom row */
- gdk_pixbuf_copy_area (frame_image,
- frame_width - right_offset,
- frame_height - bottom_offset,
- right_offset,
- bottom_offset,
- result_pixbuf,
- dest_width - right_offset,
- dest_height - bottom_offset);
-
- draw_frame_row (frame_image,
- target_width,
- target_frame_width,
- frame_height - bottom_offset,
- dest_height - bottom_offset,
- result_pixbuf,
- left_offset, bottom_offset);
-
- /* Draw the bottom left corner and the right column */
- gdk_pixbuf_copy_area (frame_image,
- 0,
- frame_height - bottom_offset,
- left_offset,
- bottom_offset,
- result_pixbuf,
- 0,
- dest_height - bottom_offset);
-
- draw_frame_column (frame_image,
- target_height,
- target_frame_height,
- frame_width - right_offset,
- dest_width - right_offset,
- result_pixbuf, top_offset,
- right_offset);
-
- return result_pixbuf;
+ GdkPixbuf *result_pixbuf;
+ guchar *pixels_ptr;
+ gint frame_width, frame_height;
+ gint y, row_stride;
+ gint target_width, target_frame_width;
+ gint target_height, target_frame_height;
+
+ frame_width = gdk_pixbuf_get_width (frame_image);
+ frame_height = gdk_pixbuf_get_height (frame_image);
+
+ if (fill_flag)
+ {
+ result_pixbuf = gdk_pixbuf_scale_simple (frame_image,
+ dest_width,
+ dest_height,
+ GDK_INTERP_NEAREST);
+ }
+ else
+ {
+ result_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ dest_width,
+ dest_height);
+ }
+
+ row_stride = gdk_pixbuf_get_rowstride (result_pixbuf);
+ pixels_ptr = gdk_pixbuf_get_pixels (result_pixbuf);
+
+ if (!fill_flag)
+ {
+ for (y = 0; y < dest_height; y++)
+ {
+ art_rgb_run_alpha (pixels_ptr,
+ 255, 255,
+ 255, 255,
+ dest_width);
+ pixels_ptr += row_stride;
+ }
+ }
+
+ target_width = dest_width - left_offset - right_offset;
+ target_frame_width = frame_width - left_offset - right_offset;
+
+ target_height = dest_height - top_offset - bottom_offset;
+ target_frame_height = frame_height - top_offset - bottom_offset;
+
+ /* Draw the left top corner and top row */
+ gdk_pixbuf_copy_area (frame_image,
+ 0, 0,
+ left_offset,
+ top_offset,
+ result_pixbuf,
+ 0, 0);
+
+ draw_frame_row (frame_image,
+ target_width,
+ target_frame_width,
+ 0, 0,
+ result_pixbuf,
+ left_offset,
+ top_offset);
+
+ /* Draw the right top corner and left column */
+ gdk_pixbuf_copy_area (frame_image,
+ frame_width - right_offset,
+ 0,
+ right_offset,
+ top_offset,
+ result_pixbuf,
+ dest_width - right_offset,
+ 0);
+
+ draw_frame_column (frame_image,
+ target_height,
+ target_frame_height,
+ 0, 0,
+ result_pixbuf,
+ top_offset,
+ left_offset);
+
+ /* Draw the bottom right corner and bottom row */
+ gdk_pixbuf_copy_area (frame_image,
+ frame_width - right_offset,
+ frame_height - bottom_offset,
+ right_offset,
+ bottom_offset,
+ result_pixbuf,
+ dest_width - right_offset,
+ dest_height - bottom_offset);
+
+ draw_frame_row (frame_image,
+ target_width,
+ target_frame_width,
+ frame_height - bottom_offset,
+ dest_height - bottom_offset,
+ result_pixbuf,
+ left_offset, bottom_offset);
+
+ /* Draw the bottom left corner and the right column */
+ gdk_pixbuf_copy_area (frame_image,
+ 0,
+ frame_height - bottom_offset,
+ left_offset,
+ bottom_offset,
+ result_pixbuf,
+ 0,
+ dest_height - bottom_offset);
+
+ draw_frame_column (frame_image,
+ target_height,
+ target_frame_height,
+ frame_width - right_offset,
+ dest_width - right_offset,
+ result_pixbuf, top_offset,
+ right_offset);
+
+ return result_pixbuf;
}
-void
+void
eog_thumbnail_add_frame (GdkPixbuf **thumbnail)
{
- GdkPixbuf *result_pixbuf;
- gint source_width, source_height;
- gint dest_width, dest_height;
-
- source_width = gdk_pixbuf_get_width (*thumbnail);
- source_height = gdk_pixbuf_get_height (*thumbnail);
-
- dest_width = source_width + 9;
- dest_height = source_height + 9;
-
- result_pixbuf = eog_thumbnail_stretch_frame_image (frame,
- 3, 3, 6, 6,
- dest_width,
- dest_height,
- FALSE);
-
- gdk_pixbuf_copy_area (*thumbnail,
- 0, 0,
- source_width,
- source_height,
- result_pixbuf,
- 3, 3);
-
- g_object_unref (*thumbnail);
-
- *thumbnail = result_pixbuf;
-}
+ GdkPixbuf *result_pixbuf;
+ gint source_width, source_height;
+ gint dest_width, dest_height;
+
+ source_width = gdk_pixbuf_get_width (*thumbnail);
+ source_height = gdk_pixbuf_get_height (*thumbnail);
+
+ dest_width = source_width + 9;
+ dest_height = source_height + 9;
+ result_pixbuf = eog_thumbnail_stretch_frame_image (frame,
+ 3, 3, 6, 6,
+ dest_width,
+ dest_height,
+ FALSE);
+
+ gdk_pixbuf_copy_area (*thumbnail,
+ 0, 0,
+ source_width,
+ source_height,
+ result_pixbuf,
+ 3, 3);
+
+ g_object_unref (*thumbnail);
+
+ *thumbnail = result_pixbuf;
+}
void
eog_thumbnail_init (void)
{
- if (frame == NULL) {
- frame = gdk_pixbuf_new_from_file (PACKAGE_DATADIR "/pixmaps/thumbnail-frame.png", NULL);
- }
+ if (frame == NULL)
+ {
+ frame = gdk_pixbuf_new_from_file (PACKAGE_DATADIR "/pixmaps/thumbnail-frame.png", NULL);
+ }
}
diff --git a/src/eog-thumbnail.h b/src/eog-thumbnail.h
index c8f440a..9bfab10 100644
--- a/src/eog-thumbnail.h
+++ b/src/eog-thumbnail.h
@@ -1,11 +1,11 @@
-/* Eye Of Gnome - Thumbnailing functions
+/* Eye Of Gnome - Thumbnailing functions
*
* Copyright (C) 2000-2007 The Free Software Foundation
*
* Author: Lucas Rocha <lucasr gnome org>
*
- * Based on nautilus code (libnautilus-private/nautilus-thumbnail.c) by:
- * - Andy Hertzfeld <andy eazel com>
+ * Based on nautilus code (libnautilus-private/nautilus-thumbnail.c) by:
+ * - Andy Hertzfeld <andy eazel com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,10 +29,10 @@
G_BEGIN_DECLS
-void eog_thumbnail_init (void);
+void eog_thumbnail_init (void);
-void eog_thumbnail_add_frame (GdkPixbuf **thumbnail);
+void eog_thumbnail_add_frame (GdkPixbuf **thumbnail);
G_END_DECLS
diff --git a/tests/cheese-test-chooser.c b/tests/cheese-test-chooser.c
index a7a877b..a7cf10e 100644
--- a/tests/cheese-test-chooser.c
+++ b/tests/cheese-test-chooser.c
@@ -7,42 +7,44 @@
#include "cheese-avatar-chooser.h"
static void
-response_cb (GtkDialog *dialog,
- int response,
- CheeseAvatarChooser *chooser)
+response_cb (GtkDialog *dialog,
+ int response,
+ CheeseAvatarChooser *chooser)
{
- if (response == GTK_RESPONSE_ACCEPT) {
- GdkPixbuf *pixbuf;
- g_message ("got pixbuf captured");
- g_object_get (G_OBJECT (chooser), "pixbuf", &pixbuf, NULL);
- }
-
- gtk_main_quit ();
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ GdkPixbuf *pixbuf;
+ g_message ("got pixbuf captured");
+ g_object_get (G_OBJECT (chooser), "pixbuf", &pixbuf, NULL);
+ }
+
+ gtk_main_quit ();
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- GtkWidget *window;
+ GtkWidget *window;
- g_thread_init (NULL);
- gdk_threads_init ();
- gst_init (&argc, &argv);
+ g_thread_init (NULL);
+ gdk_threads_init ();
+ gst_init (&argc, &argv);
- bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- gtk_init (&argc, &argv);
+ gtk_init (&argc, &argv);
- window = cheese_avatar_chooser_new ();
- g_signal_connect (G_OBJECT (window), "response",
- G_CALLBACK (response_cb), window);
+ window = cheese_avatar_chooser_new ();
+ g_signal_connect (G_OBJECT (window), "response",
+ G_CALLBACK (response_cb), window);
- gtk_widget_show_all (window);
+ gtk_widget_show_all (window);
- gtk_main ();
+ gtk_main ();
- gtk_widget_destroy (window);
+ gtk_widget_destroy (window);
- return 0;
+ return 0;
}
diff --git a/tests/cheese-test-monitor.c b/tests/cheese-test-monitor.c
index f9151c0..3d5ca91 100644
--- a/tests/cheese-test-monitor.c
+++ b/tests/cheese-test-monitor.c
@@ -4,35 +4,37 @@
static void
added_cb (CheeseCameraDeviceMonitor *monitor,
- CheeseCameraDevice *device)
+ CheeseCameraDevice *device)
{
- gchar *id;
- g_object_get (device, "device-id", &id, NULL);
- g_message ("Added new device with ID '%s'", id);
- g_free (id);
+ gchar *id;
+
+ g_object_get (device, "device-id", &id, NULL);
+ g_message ("Added new device with ID '%s'", id);
+ g_free (id);
}
static void
removed_cb (CheeseCameraDeviceMonitor *monitor,
- const char *id)
+ const char *id)
{
- g_message ("Removed device with ID '%s'", id);
+ g_message ("Removed device with ID '%s'", id);
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- CheeseCameraDeviceMonitor *monitor;
+ CheeseCameraDeviceMonitor *monitor;
- gst_init (&argc, &argv);
+ gst_init (&argc, &argv);
- monitor = cheese_camera_device_monitor_new ();
- g_signal_connect (G_OBJECT (monitor), "added",
- G_CALLBACK (added_cb), NULL);
- g_signal_connect (G_OBJECT (monitor), "removed",
- G_CALLBACK (removed_cb), NULL);
- cheese_camera_device_monitor_coldplug (monitor);
+ monitor = cheese_camera_device_monitor_new ();
+ g_signal_connect (G_OBJECT (monitor), "added",
+ G_CALLBACK (added_cb), NULL);
+ g_signal_connect (G_OBJECT (monitor), "removed",
+ G_CALLBACK (removed_cb), NULL);
+ cheese_camera_device_monitor_coldplug (monitor);
- g_main_loop_run (g_main_loop_new (NULL, FALSE));
+ g_main_loop_run (g_main_loop_new (NULL, FALSE));
- return 0;
+ return 0;
}
diff --git a/tests/cheese-test-widget.c b/tests/cheese-test-widget.c
index 69bf468..7318e80 100644
--- a/tests/cheese-test-widget.c
+++ b/tests/cheese-test-widget.c
@@ -8,41 +8,42 @@
static gboolean
delete_callback (GtkWidget *window,
- GdkEvent *event,
- gpointer data)
+ GdkEvent *event,
+ gpointer data)
{
- gtk_widget_destroy (window);
- gtk_main_quit ();
- return FALSE;
+ gtk_widget_destroy (window);
+ gtk_main_quit ();
+ return FALSE;
}
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- GtkWidget *window;
- GtkWidget *camera;
+ GtkWidget *window;
+ GtkWidget *camera;
- g_thread_init (NULL);
- gdk_threads_init ();
- gst_init (&argc, &argv);
+ g_thread_init (NULL);
+ gdk_threads_init ();
+ gst_init (&argc, &argv);
- bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
- gtk_init (&argc, &argv);
+ gtk_init (&argc, &argv);
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
- g_signal_connect (G_OBJECT (window), "delete-event",
- G_CALLBACK (delete_callback), NULL);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
+ g_signal_connect (G_OBJECT (window), "delete-event",
+ G_CALLBACK (delete_callback), NULL);
- camera = cheese_widget_new ();
- gtk_container_add (GTK_CONTAINER (window), camera);
+ camera = cheese_widget_new ();
+ gtk_container_add (GTK_CONTAINER (window), camera);
- gtk_widget_show_all (window);
+ gtk_widget_show_all (window);
- gtk_main ();
+ gtk_main ();
- return 0;
+ return 0;
}
diff --git a/tests/test-webcam-button.c b/tests/test-webcam-button.c
index 66768f8..1fe39a2 100644
--- a/tests/test-webcam-button.c
+++ b/tests/test-webcam-button.c
@@ -1,4 +1,5 @@
/* emit foo webcam button event */
+
/* gcc -o test-webcam-button test-webcam-button.c -lX11 -lXtst */
#include <stdio.h>
@@ -6,16 +7,18 @@
#include <X11/extensions/XTest.h>
#include <X11/XF86keysym.h>
-int main (void)
+int
+main (void)
{
Display *dpy;
+
dpy = XOpenDisplay (NULL);
printf ("Emitting fake Webcam button press in 2 seconds...\n");
printf ("Focus Cheese window to make it receive the event\n");
- XTestFakeKeyEvent (dpy, XKeysymToKeycode(dpy, XF86XK_WebCam), True, 2000);
- XTestFakeKeyEvent (dpy, XKeysymToKeycode(dpy, XF86XK_WebCam), False, CurrentTime);
+ XTestFakeKeyEvent (dpy, XKeysymToKeycode (dpy, XF86XK_WebCam), True, 2000);
+ XTestFakeKeyEvent (dpy, XKeysymToKeycode (dpy, XF86XK_WebCam), False, CurrentTime);
XCloseDisplay (dpy);
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]