Debian Codegraph @

examples/cd-gtk-demo.c

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2011-2012 Richard Hughes <[email protected]>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 //gcc -o cd-gtk-demo cd-gtk-demo.c `pkg-config --cflags --libs colord-gtk` -Wall
23
24 #include <stdlib.h>
25 #include <colord-gtk.h>
26 #include <gtk/gtk.h>
27
28 static void
29 cd_window_get_profile_cb (GObject *source,
30 GAsyncResult *res,
31 gpointer user_data)
32 {
33 CdProfile *profile;
34 CdWindow *window = CD_WINDOW (source);
35 GError *error = NULL;
36
37 profile = cd_window_get_profile_finish (window,
38 res,
39 &error);
40 if (profile == NULL) {
41 g_warning ("failed to get output profile: %s", error->message);
42 g_error_free (error);
43 return;
44 }
45
46 g_debug ("screen profile to use %s", cd_profile_get_filename (profile));
47 g_object_unref (profile);
48 }
49
50 static void
51 map_cb (GtkWidget *this_widget, gpointer user_data)
52 {
53 CdWindow *window = CD_WINDOW (user_data);
54
55 /* get the profile for this widget */
56 cd_window_get_profile (window,
57 this_widget,
58 NULL,
59 cd_window_get_profile_cb,
60 this_widget);
61 }
62
63 int
64 main (int argc, char *argv[])
65 {
66 CdWindow *window;
67 gint retval = EXIT_FAILURE;
68 GtkWidget *dialog;
69
70 gtk_init (&argc, &argv);
71 window = cd_window_new ();
72 dialog = gtk_message_dialog_new (NULL,
73 GTK_DIALOG_MODAL,
74 GTK_MESSAGE_INFO,
75 GTK_BUTTONS_OK,
76 "%s", "Hello world");
77 g_signal_connect (dialog, "map",
78 G_CALLBACK (map_cb),
79 window);
80 gtk_dialog_run (GTK_DIALOG (dialog));
81 gtk_widget_destroy (dialog);
82 g_object_unref (window);
83
84 retval = EXIT_SUCCESS;
85 return retval;
86 }