File: compositor.c

package info (click to toggle)
casilda 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 264 kB
  • sloc: ansic: 2,183; javascript: 44; python: 27; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,374 bytes parent folder | download | duplicates (2)
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
#include <gtk/gtk.h>
#include "casilda-compositor.h"

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


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

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Casilda Compositor");
  gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);

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

  sw = gtk_scrolled_window_new ();
  compositor = casilda_compositor_new (socket);

  gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), GTK_WIDGET (compositor));
  gtk_window_set_child (GTK_WINDOW (window), GTK_WIDGET (sw));
  gtk_window_present (GTK_WINDOW (window));

  gchar *argv[2] = {
    "/usr/bin/gtk4-demo",
     NULL
  };

  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;

  app = gtk_application_new ("ar.xjuan.casilda.Example", 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);
}