Debian Codegraph @

subprojects/gtk-frdp/examples/gtk-frdp-viewer.c

raw symbols SCIP
1 /* gtk-frdp-viewer.c
2 *
3 * Copyright (C) 2018 Felipe Borges <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <gtk-frdp.h>
20
21 static void
22 on_rdp_auth_failure (GObject *source_object,
23 const gchar *message,
24 gpointer user_data)
25 {
26 g_print ("-> %s\n", message);
27
28 g_application_quit (user_data);
29 }
30
31 static void
32 on_activate (GtkApplication *app)
33 {
34 GtkWindow *window;
35 GtkWidget *display;
36
37 g_assert (GTK_IS_APPLICATION (app));
38
39 /* Get the current window or create one if necessary. */
40 window = gtk_application_get_active_window (app);
41 if (window == NULL)
42 window = g_object_new (GTK_TYPE_APPLICATION_WINDOW,
43 "application", app,
44 NULL);
45
46 display = frdp_display_new ();
47
48 g_signal_connect (display,
49 "rdp-auth-failure",
50 G_CALLBACK (on_rdp_auth_failure),
51 app);
52
53 gtk_container_add (GTK_CONTAINER (window), display);
54 gtk_widget_show (display);
55
56 frdp_display_open_host (FRDP_DISPLAY (display), "109.168.97.222", 3389);
57 g_object_set (display,
58 "username", "demo2",
59 "password", "D3m02014*Test",
60 NULL);
61
62
63 gtk_window_present (window);
64 }
65
66 int
67 main (int argc,
68 char *argv[])
69 {
70 g_autoptr(GtkApplication) app = NULL;
71 int ret;
72
73 app = gtk_application_new ("org.gnome.GtkFrdpViewer", G_APPLICATION_FLAGS_NONE);
74
75 g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
76
77 ret = g_application_run (G_APPLICATION (app), argc, argv);
78
79 return ret;
80 }