Exemplo n.º 1
0
void folder_changed_callback(GFileMonitor *mon,
                             GFile *first_file,
                             GFile *second_file,
                             GFileMonitorEvent event,
                             gpointer user_data)
{
	gchar *our_filename = (gchar*)(user_data);

	// If a file is created or deleted, we need to check the file lists again
	if ((event == G_FILE_MONITOR_EVENT_CREATED) ||
	        (event == G_FILE_MONITOR_EVENT_DELETED)) {

		clear_file_lists();

		set_current_window(NULL);
		load_config(our_filename);

		if (debug)
			printf("Files in folder updated!\n - new lists:\n\n");

		print_script_lists();

		if (debug)
			printf("-----------\n");
	}

	// Also monitor if our devilspie2.lua file is changed - since it handles
	// which files are window close or window open scripts.
	if (event == G_FILE_MONITOR_EVENT_CHANGED) {
		if (first_file) {
			gchar *short_filename = g_file_get_basename(first_file);

			if (g_strcmp0(short_filename, "devilspie2.lua")==0) {

				clear_file_lists();

				set_current_window(NULL);
				load_config(our_filename);

				print_script_lists();

				if (debug)
					printf("----------");
			}
		}
	}
}
Exemplo n.º 2
0
/**
 * atexit handler - kill the script
 */
void devilspie_exit()
{
	clear_file_lists();

	if (temp_folder != NULL) g_free(temp_folder);

	if (mon) g_object_unref(mon);

	if (config_filename) g_free(config_filename);
}