Skip to content

Promote "cheese_widget_get_camera" to a public method

Felipe Borges requested to merge make-cheese-widget-get-camera-public into master

It is very convenient for a libcheese client implementing their own camera widget to access cheese_widget_get_camera ().

This way a simple camera app could be as simple as:

static void
on_photo_taken_cb (GtkWidget *cheese_widget,
                   GdkEvent  *event,
                   gpointer   user_data)
    GObject *camera = cheese_widget_get_camera (CHEESE_WIDGET (cheese_widget));

    cheese_camera_take_photo (CHEESE_CAMERA (camera), "/tmp/photo");

int main (int argc, char *argv[])
    GtkWidget *window, *cheese_widget;

    cheese_gtk_init (NULL, NULL);
    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (gtk_main_quit), NULL);

    cheese_widget = cheese_widget_new ();
    g_signal_connect (G_OBJECT (cheese_widget), "button-press-event",
                      G_CALLBACK (on_photo_taken_cb), NULL);

    gtk_container_add (GTK_CONTAINER (window), cheese_widget);
    gtk_widget_show_all (window);
    gtk_main ();

    return 0;

I personally stumbled on this while writing my own customized avatar chooser. A CheeseWidget instance is useless without access to the get_camera method.

Merge request reports