File: nested.c

package info (click to toggle)
casilda 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 260 kB
  • sloc: ansic: 2,190; javascript: 44; python: 29; makefile: 3
file content (51 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <gtk/gtk.h>
#include "casilda-compositor.h"

/* Do not listen on any socket by default */
gchar *socket = NULL;
gchar *dirname;


static void
activate (GtkApplication *app, G_GNUC_UNUSED gpointer  user_data)
{
  CasildaCompositor *compositor;
  GtkWidget *window;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Nested Casilda Compositor");
  gtk_window_set_default_size (GTK_WINDOW (window), 1024, 768);

  if (socket)
    g_message ("Listening on %s", socket);
  else
    g_message ("Not listening in any socket, you can pass a socket path as parameter");

  compositor = casilda_compositor_new (socket);
  gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (compositor));
  gtk_window_present (GTK_WINDOW (window));

  gchar *argv[2] = {
     g_build_path ("/", dirname, "compositor", NULL),
     NULL
  };

  g_message("Running %s", argv[0]);
  casilda_compositor_spawn_async (compositor, NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL);
}

int
main (int argc, char **argv)
{
  g_autoptr(GtkApplication) app = NULL;

  dirname = g_path_get_dirname (argv[0]);

  app = gtk_application_new ("ar.xjuan.casilda.NestedExample", G_APPLICATION_DEFAULT_FLAGS);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);

  if (argc >= 2)
    socket = argv[1];

  return g_application_run (G_APPLICATION (app), 0, NULL);
}