static void
device_combo_box_finalize (GObject *object)
{
   device_combo_box_store_id (UNICAPGTK_DEVICE_SELECTION (object), NULL);

   G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GObject *
device_combo_box_constructor (GType                  type,
                              guint                  n_params,
                              GObjectConstructParam *params)
{
   UnicapgtkDeviceSelection *combo;
   GObject              *object;

   object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);

   combo = UNICAPGTK_DEVICE_SELECTION (object);

   if (combo->include_rescan_entry)
   {
      GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));

      device_combo_box_add_rescan_entry (GTK_LIST_STORE (model));
    }

      g_signal_connect (combo, "changed",
                        G_CALLBACK (device_combo_box_changed),
                        NULL);

   return object;
}
static void
device_combo_box_realize (GtkWidget *widget)
{
   UnicapgtkDeviceSelection *combo = UNICAPGTK_DEVICE_SELECTION (widget);

   g_return_if_fail (combo->busy_cursor == NULL);

   combo->busy_cursor =
      gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_WATCH);

   GTK_WIDGET_CLASS (parent_class)->realize (widget);
}
static void
device_combo_box_unrealize (GtkWidget *widget)
{
   UnicapgtkDeviceSelection *combo = UNICAPGTK_DEVICE_SELECTION (widget);

   if (combo->busy_cursor)
   {
      gdk_cursor_unref (combo->busy_cursor);
      combo->busy_cursor = NULL;
   }

   GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
Ejemplo n.º 5
0
int main( int argc, char *argv[] )
{
   /* GtkWidget *display_window; */
   GtkWidget *video_display;
   GtkWidget *device_selection;

   GtkWidget *widget;
   GTimer *fps_timer;

   g_thread_init(NULL);
   gdk_threads_init();
   gtk_init (&argc, &argv);

   //
   // Create the main application window
   // 
   display_window  = create_application_window( );
   

   video_display = g_object_get_data( G_OBJECT( display_window ), "ugtk_display" );
   g_assert( video_display );
   device_selection = g_object_get_data( G_OBJECT( video_display ), "device_selection" );
   g_assert( device_selection );
   fps_timer = g_timer_new();
   unicapgtk_video_display_set_new_frame_callback( UNICAPGTK_VIDEO_DISPLAY( video_display ), 
						   UNICAPGTK_CALLBACK_FLAGS_BEFORE, 
						   (unicap_new_frame_callback_t)new_frame_cb, 
						   fps_timer );

   //
   // Create a window containing the properties for the 
   // video capture device and a device selection menu
   //
   widget = unicapgtk_property_dialog_new( );
   gtk_widget_show_all( widget );
   g_object_set_data( G_OBJECT( video_display ), "property_dialog", widget );

   //
   // Rescan devices and select first device
   //
   if( unicapgtk_device_selection_rescan( UNICAPGTK_DEVICE_SELECTION( device_selection ) ) > 0 )
   {
      gtk_combo_box_set_active (GTK_COMBO_BOX( device_selection ), 0);
   }

   gdk_threads_enter();
   gtk_main ();
   gdk_threads_leave();

   return 0;
}
static void
device_combo_box_changed( GtkComboBox *combo )
{
   UnicapgtkDeviceSelection *device_combo = UNICAPGTK_DEVICE_SELECTION( combo );
   GtkTreeIter           iter;

   if( gtk_combo_box_get_active_iter (combo, &iter) )
   {
      GtkTreeModel *model  = gtk_combo_box_get_model( combo );
      gchar        *device_id;
      gint          special;

      gtk_tree_model_get( model, &iter,
                          UNICAPGTK_DEVICE_ID, &device_id,
                          SPECIAL,          &special,
                          -1 );

      if( device_id )
      {
	 device_combo_box_store_id( device_combo, device_id );
	 g_free( device_id );
	 g_signal_emit( G_OBJECT( combo ), 
			unicapgtk_device_selection_signals[UNICAPGTK_DEVICE_SELECTION_CHANGED_SIGNAL], 
			0, 
			device_combo->active_device );
	 return;
      }

      g_signal_stop_emission_by_name( combo, "changed" );

      switch( special )
      {
	 case NOT_SPECIAL:
	    break;

	 case SPECIAL_RESCAN:
	    unicapgtk_device_selection_rescan (device_combo);
	    break;

	 default:
	    device_combo_box_store_id (device_combo, NULL);
	    break;
      }
   }
}
static void
device_combo_box_get_property (GObject    *object,
                               guint       property_id,
                               GValue     *value,
                               GParamSpec *pspec)
{
   UnicapgtkDeviceSelection *combo = UNICAPGTK_DEVICE_SELECTION (object);

   switch (property_id)
   {
      case PROP_INCLUDE_RESCAN_ENTRY:
	 g_value_set_boolean (value, combo->include_rescan_entry);
	 break;
      default:
	 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
	 break;
   }
}