summaryrefslogtreecommitdiff
path: root/libcheese/cheese-widget.c
diff options
context:
space:
mode:
authordaniel g. siegel <dgsiegel@gnome.org>2009-12-23 12:32:10 +0100
committerdaniel g. siegel <dgsiegel@gnome.org>2009-12-23 12:32:10 +0100
commitde1dd8931a01caa3e25de66f896eda06cb755daa (patch)
tree59bdf86435446e7a302ba8c323130cb260b1fcd3 /libcheese/cheese-widget.c
parent518063b1a11264b80291e9762c7d4e12bedfcd5c (diff)
re-indent source code to match our style
Diffstat (limited to 'libcheese/cheese-widget.c')
-rw-r--r--libcheese/cheese-widget.c156
1 files changed, 85 insertions, 71 deletions
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));
}