cheese r395 - trunk/src



Author: pzawadzki
Date: Mon Jan 14 14:38:38 2008
New Revision: 395
URL: http://svn.gnome.org/viewvc/cheese?rev=395&view=rev

Log:
- naming unification
- use separate callbacks to remove the hide logic


Modified:
   trunk/src/cheese-countdown.c
   trunk/src/cheese-countdown.h
   trunk/src/cheese-window.c

Modified: trunk/src/cheese-countdown.c
==============================================================================
--- trunk/src/cheese-countdown.c	(original)
+++ trunk/src/cheese-countdown.c	Mon Jan 14 14:38:38 2008
@@ -50,7 +50,8 @@
 {
   gint iState;
   cairo_surface_t* pSurface;
-  t_cheese_countdown_cb callback;
+  cheese_countdown_cb_t picture_callback;
+  cheese_countdown_cb_t hide_callback;
   gpointer callback_data;
 } CheeseCountdownPrivate;
 
@@ -309,19 +310,19 @@
   else if (priv->iState == STATE_1)
   {
     priv->iState = STATE_SMILE;
-    if (priv->callback != NULL) (priv->callback)(priv->callback_data, FALSE);
+    if (priv->picture_callback != NULL) (priv->picture_callback)(priv->callback_data);
   }
   else if (priv->iState == STATE_SMILE)
   {
     priv->iState = STATE_OFF;
-    if (priv->callback != NULL) (priv->callback)(priv->callback_data, TRUE);
+    if (priv->hide_callback != NULL) (priv->hide_callback)(priv->callback_data);
     return FALSE;
   }
   return TRUE;
 }
 
 void
-cheese_countdown_start (CheeseCountdown *countdown, t_cheese_countdown_cb cb, gpointer data)
+cheese_countdown_start (CheeseCountdown *countdown, cheese_countdown_cb_t picture_cb, cheese_countdown_cb_t hide_cb, gpointer data)
 {
   CheeseCountdownPrivate* priv = CHEESE_COUNTDOWN_GET_PRIVATE (countdown);
   if (priv->iState != STATE_OFF)
@@ -329,7 +330,8 @@
     g_print ("Should not happen, state is not off.\n");
   }
   priv->iState = STATE_3;
-  priv->callback = cb;
+  priv->picture_callback = picture_cb;
+  priv->hide_callback = hide_cb;
   priv->callback_data = data;
   g_timeout_add_seconds (1, cheese_countdown_cb, (gpointer) countdown);
 }
@@ -357,7 +359,8 @@
   /* create/load svg-icon */
   priv->pSurface = create_surface_from_svg (PACKAGE_DATADIR "/pixmaps/camera-icon.svg");
   priv->iState = STATE_OFF;
-  priv->callback = NULL;
+  priv->picture_callback = NULL;
+  priv->hide_callback = NULL;
 
   g_signal_connect (G_OBJECT (countdown), "expose-event",
         G_CALLBACK (on_expose), NULL);

Modified: trunk/src/cheese-countdown.h
==============================================================================
--- trunk/src/cheese-countdown.h	(original)
+++ trunk/src/cheese-countdown.h	Mon Jan 14 14:38:38 2008
@@ -40,12 +40,12 @@
   GtkDrawingAreaClass parent_class;
 } CheeseCountdownClass;
 
-typedef void (*t_cheese_countdown_cb) (gpointer data, gboolean hide);
+typedef void (* cheese_countdown_cb_t) (gpointer data);
 
 GType              cheese_countdown_get_type (void);
 GtkWidget         *cheese_countdown_new ();
 
-void cheese_countdown_start (CheeseCountdown *countdown, t_cheese_countdown_cb cb, gpointer data);
+void cheese_countdown_start (CheeseCountdown *countdown, cheese_countdown_cb_t picture_cb, cheese_countdown_cb_t hide_cb, gpointer data);
 
 G_END_DECLS
 

Modified: trunk/src/cheese-window.c
==============================================================================
--- trunk/src/cheese-window.c	(original)
+++ trunk/src/cheese-window.c	Mon Jan 14 14:38:38 2008
@@ -773,32 +773,32 @@
 }
 
 void
-cheese_window_countdown_cb (gpointer data, gboolean hide)
+cheese_window_countdown_hide_cb (gpointer data)
 {
   CheeseWindow *cheese_window = (CheeseWindow *) data;
-  if (hide)
+  gtk_notebook_set_current_page(GTK_NOTEBOOK(cheese_window->notebook_bar), 0);
+}
+
+void
+cheese_window_countdown_picture_cb (gpointer data)
+{
+  CheeseWindow *cheese_window = (CheeseWindow *) data;
+  GError *error = NULL;
+  GstAudioPlay *audio_play;
+  char *file;
+
+  file = audio_play_get_filename (cheese_window);
+  audio_play = gst_audio_play_file (file, &error);
+  if (!audio_play) 
   {
-    gtk_notebook_set_current_page(GTK_NOTEBOOK(cheese_window->notebook_bar), 0);
+    g_warning (error ? error->message : "Unknown error");
+    g_clear_error (&error);
   }
-  else
-  {
-    GError *error = NULL;
-    GstAudioPlay *audio_play;
-    char *file;
-
-    file = audio_play_get_filename (cheese_window);
-    audio_play = gst_audio_play_file (file, &error);
-    if (!audio_play) 
-    {
-      g_warning (error ? error->message : "Unknown error");
-      g_clear_error (&error);
-    }
 
-    g_free (file);
+  g_free (file);
 
-    cheese_window->photo_filename = cheese_fileutil_get_new_media_filename (WEBCAM_MODE_PHOTO);
-    cheese_webcam_take_photo (cheese_window->webcam, cheese_window->photo_filename);
-  }
+  cheese_window->photo_filename = cheese_fileutil_get_new_media_filename (WEBCAM_MODE_PHOTO);
+  cheese_webcam_take_photo (cheese_window->webcam, cheese_window->photo_filename);
 }
 
 static void
@@ -808,7 +808,7 @@
 
   if (cheese_window->webcam_mode == WEBCAM_MODE_PHOTO)
   {
-    cheese_countdown_start((CheeseCountdown *) cheese_window->countdown, cheese_window_countdown_cb, (gpointer) cheese_window);
+    cheese_countdown_start((CheeseCountdown *) cheese_window->countdown, cheese_window_countdown_picture_cb, cheese_window_countdown_hide_cb, (gpointer) cheese_window);
     gtk_notebook_set_current_page (GTK_NOTEBOOK(cheese_window->notebook_bar), 1);
 
     gtk_widget_set_sensitive (cheese_window->take_picture, FALSE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]