61
60
static gchar *state_filename;
62
61
static void save_state_file (void);
65
GSList *pids_to_close = NULL;
63
/* List of spawned processes */
64
static GSList *pids_to_close = NULL;
65
static GPid spawn_argv_pid (gchar **argv, GSpawnFlags flags, gint *pfd, GError **perror);
66
#if defined(AT_SPI_COMMAND) || defined(INDICATOR_SERVICES_COMMAND)
67
static GPid spawn_line_pid (const gchar *line, GSpawnFlags flags, GError **perror);
69
static void close_pid (GPid pid, gboolean remove);
66
70
static void sigterm_cb (gpointer user_data);
67
static void close_pid (GPid *pid, gboolean remove);
69
72
/* Screen window */
70
73
static GtkOverlay *screen_overlay;
156
161
GtkWidget *widget;
159
static MenuCommand *menu_command_parse (const gchar *value, GtkWidget *menu_item);
160
static MenuCommand *menu_command_parse_extended (const gchar *value, GtkWidget *menu_item,
164
static MenuCommand *menu_command_parse (const gchar *name, const gchar *value, GtkWidget *menu_item);
165
static MenuCommand *menu_command_parse_extended (const gchar *name,
166
const gchar *value, GtkWidget *menu_item,
161
167
const gchar *xid_app, const gchar *xid_arg);
162
168
static gboolean menu_command_run (MenuCommand *command);
163
169
static gboolean menu_command_stop (MenuCommand *command);
350
356
/* Terminating */
359
spawn_argv_pid (gchar **argv, GSpawnFlags flags, gint *pfd, GError **perror)
362
GError *error = NULL;
363
gboolean spawned = FALSE;
366
spawned = g_spawn_async_with_pipes (NULL, argv, NULL, flags, NULL, NULL, &pid, NULL, pfd, NULL, perror);
368
spawned = g_spawn_async (NULL, argv, NULL, flags, NULL, NULL, &pid, &error);
372
pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (pid));
373
g_debug ("[PIDs] Command executed (#%d): %s", pid, argv[0]);
381
g_warning ("[PIDs] Failed to execute command: %s", argv[0]);
382
g_clear_error (&error);
388
#if defined(AT_SPI_COMMAND) || defined(INDICATOR_SERVICES_COMMAND)
390
spawn_line_pid (const gchar *line, GSpawnFlags flags, GError **perror)
394
GError *error = NULL;
396
if (g_shell_parse_argv (line, &argc, &argv, &error))
398
GPid pid = spawn_argv_pid (argv, flags, NULL, perror);
402
else if (!perror && error)
404
g_warning ("[PIDs] Failed to parse command line: %s, %s", error->message, line);
405
g_clear_error (&error);
415
close_pid (GPid pid, gboolean remove)
421
pids_to_close = g_slist_remove (pids_to_close, GINT_TO_POINTER (pid));
423
if (kill (pid, SIGTERM) == 0)
424
g_debug ("[PIDs] Process terminated: #%d", pid);
426
g_warning ("[PIDs] Failed to terminate process #%d: %s", pid, g_strerror (errno));
428
waitpid (pid, NULL, 0);
353
432
sigterm_cb (gpointer user_data)
358
437
gtk_main_quit ();
362
close_pid (GPid *ppid, gboolean remove)
368
pids_to_close = g_slist_remove (pids_to_close, GINT_TO_POINTER (*ppid));
370
kill (*ppid, SIGTERM);
371
waitpid (*ppid, NULL, 0);
375
440
/* Power window */
682
747
/* MenuCommand */
684
749
static MenuCommand*
685
menu_command_parse (const gchar *value, GtkWidget *menu_item)
750
menu_command_parse (const gchar *name, const gchar *value, GtkWidget *menu_item)
687
return menu_command_parse_extended (value, menu_item, NULL, NULL);
752
return menu_command_parse_extended (name, value, menu_item, NULL, NULL);
690
755
static MenuCommand*
691
menu_command_parse_extended (const gchar *value, /* String to parse */
756
menu_command_parse_extended (const gchar *name,
757
const gchar *value, /* String to parse */
692
758
GtkWidget *menu_item, /* Menu item to connect */
693
759
const gchar *xid_app, /* Program that have "xembed" mode support */
694
760
const gchar *xid_arg) /* Argument that must be added to command line */
703
769
if (!g_shell_parse_argv (value, &argc, &argv, &error))
706
g_warning ("Failed to parse command line: %s", error->message);
772
g_warning ("[Command/%s] Failed to parse command line: %s", name, error->message);
707
773
g_clear_error (&error);
758
825
g_return_val_if_fail (command && g_strv_length (command->argv), FALSE);
760
827
GError *error = NULL;
761
gboolean spawned = FALSE;
830
g_debug ("[Command/%s] Running command", command->name);
762
832
if (command->widget)
764
834
GtkSocket* socket = NULL;
836
GPid pid = spawn_argv_pid (command->argv, G_SPAWN_SEARCH_PATH, &out_fd, &error);
767
if (g_spawn_async_with_pipes (NULL, command->argv, NULL, G_SPAWN_SEARCH_PATH,
768
NULL, NULL, &command->pid, NULL, &out_fd, NULL, &error))
770
840
gchar* text = NULL;
771
841
GIOChannel* out_channel = g_io_channel_unix_new (out_fd);
782
852
gtk_container_add (GTK_CONTAINER (command->widget), GTK_WIDGET (socket));
783
853
gtk_socket_add_id (socket, id);
784
854
gtk_widget_show_all (GTK_WIDGET (command->widget));
788
g_warning ("Failed to get '%s' socket: unrecognized output", command->argv[0]);
859
g_warning ("[Command/%s] Failed to get '%s' socket for: unrecognized output",
860
command->name, command->argv[0]);
866
if (!command->pid && pid)
867
close_pid (pid, TRUE);
796
spawned = g_spawn_async (NULL, command->argv, NULL,
797
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
798
NULL, NULL, &command->pid, &error);
871
command->pid = spawn_argv_pid (command->argv, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, &error);
800
873
g_child_watch_add (command->pid, (GChildWatchFunc)menu_command_terminated_cb, command);
805
pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (command->pid));
810
g_warning ("Command spawning error: '%s'", error->message);
879
g_warning ("[Command/%s] Failed to run: %s", command->name, error->message);
812
880
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (command->menu_item), FALSE);
814
882
g_clear_error (&error);
823
892
if (command->pid)
825
close_pid (&command->pid, TRUE);
894
g_debug ("[Command/%s] Stopping command", command->name);
895
close_pid (command->pid, TRUE);
826
897
if (command->menu_item)
827
898
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (command->menu_item), FALSE);
828
899
if (command->widget)
1157
1228
g_return_val_if_fail (INDICATOR_IS_OBJECT (io), FALSE);
1159
g_signal_emit_by_name (io, "scroll", 1, event->direction);
1160
g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
1230
g_signal_emit_by_name(io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, 1, event->direction);
1276
1346
/* Close any open menus instead of opening one */
1277
1347
entries = indicator_object_get_entries (io);
1278
for (lp = entries; lp; lp = g_list_next (entry))
1348
for (lp = entries; lp; lp = g_list_next (lp))
1280
1350
entrydata = lp->data;
1281
1351
gtk_menu_popdown (entrydata->menu);
1434
1504
/* Don't allow virtual file systems? */
1435
1505
greeter_set_env ("GIO_USE_VFS", "local");
1436
1506
greeter_set_env ("GVFS_DISABLE_FUSE", "1");
1438
#ifdef START_INDICATOR_SERVICES
1439
gchar *INDICATORS_CMD[] = {"init", "--user", "--startup-event", "indicator-services-start", NULL};
1440
GError *error = NULL;
1443
if (g_spawn_async (NULL, INDICATORS_CMD, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &error))
1444
pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (pid));
1446
g_warning ("[Greeter] Failed to run 'init --startup-event indicator-services-start': %s", error->message);
1447
g_clear_error (&error);
2553
2611
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
2554
2612
textdomain (GETTEXT_PACKAGE);
2556
g_unix_signal_add (SIGTERM, (GSourceFunc)sigterm_cb, pids_to_close);
2614
g_unix_signal_add (SIGTERM, (GSourceFunc)sigterm_cb, NULL);
2558
2616
config = g_key_file_new ();
2559
2617
g_key_file_load_from_file (config, CONFIG_FILE, G_KEY_FILE_NONE, &error);
2692
2750
g_object_set (gtk_settings_get_default (), "gtk-xft-rgba", value, NULL);
2693
2751
g_free (value);
2753
#ifdef AT_SPI_COMMAND
2754
spawn_line_pid (AT_SPI_COMMAND, G_SPAWN_SEARCH_PATH, NULL);
2757
#ifdef INDICATOR_SERVICES_COMMAND
2758
spawn_line_pid (INDICATOR_SERVICES_COMMAND, G_SPAWN_SEARCH_PATH, NULL);
2696
2761
builder = gtk_builder_new ();
2697
2762
if (!gtk_builder_add_from_string (builder, lightdm_gtk_greeter_ui,
2867
2932
value = g_key_file_get_value (config, "greeter", "keyboard", NULL);
2868
a11y_keyboard_command = menu_command_parse_extended (value, keyboard_menuitem, "onboard", "--xid");
2933
a11y_keyboard_command = menu_command_parse_extended ("keyboard", value, keyboard_menuitem, "onboard", "--xid");
2869
2934
g_free (value);
2871
2936
gtk_widget_set_visible (keyboard_menuitem, a11y_keyboard_command != NULL);
2873
2938
value = g_key_file_get_value (config, "greeter", "reader", NULL);
2874
a11y_reader_command = menu_command_parse (value, reader_menuitem);
2939
a11y_reader_command = menu_command_parse ("reader", value, reader_menuitem);
2875
2940
gtk_widget_set_visible (reader_menuitem, a11y_reader_command != NULL);
2876
2941
g_free (value);
2878
if (a11y_keyboard_command || a11y_reader_command)
2880
gchar *AT_SPI_CMD[] = {"/usr/lib/at-spi2-core/at-spi-bus-launcher", "--launch-immediately", NULL};
2882
if (g_spawn_async (NULL, AT_SPI_CMD, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &error))
2884
g_debug ("[Greeter] AT-SPI launched");
2885
pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (pid));
2888
g_warning ("[Greeter] Failed to launch AT-SPI: %s", error->message);
2889
g_clear_error (&error);
2892
2943
/* Power menu */
2893
2944
if (gtk_widget_get_visible (power_menuitem))