コード例 #1
0
ファイル: main.c プロジェクト: ChingezKhan/gthumb
static void
load_session (gboolean                  use_factory,
	      GNOME_GThumb_Application  app,
	      CORBA_Environment        *env)
{
	int i, n;

	gnome_config_push_prefix (gnome_client_get_config_prefix (master_client));

	n = gnome_config_get_int ("Session/locations");
	for (i = 0; i < n; i++) {
		char *key;
		char *location;

		key = g_strdup_printf ("Session/location%d", i);
		location = gnome_config_get_string (key);

		if (uri_scheme_is_file (location) && path_is_file (location))
			open_viewer_window (location, use_factory, app, env);
		else
			open_browser_window (location, TRUE, use_factory, app, env);

		g_free (location);
		g_free (key);
	}

	gnome_config_pop_prefix ();
}
コード例 #2
0
ファイル: run-is_file.c プロジェクト: CodeShark/lightning
int main(void)
{
	char cwd[1024], *path, *ctx = tal_strdup(NULL, "ctx");

	plan_tests(7);

	if (!getcwd(cwd, sizeof(cwd)))
		abort();

	unlink("run-is_file-dir-link");
	unlink("run-is_file-file-link");
	unlink("run-is_file-dir/file");
	rmdir("run-is_file-dir");
	if (mkdir("run-is_file-dir", 0700) != 0)
		abort();
	if (symlink("run-is_file-dir", "run-is_file-dir-link") != 0)
		abort();
	if (symlink("run-is_file-dir/file", "run-is_file-file-link") != 0)
		abort();
	close(open("run-is_file-dir/file", O_WRONLY|O_CREAT, 0600));

	ok1(!path_is_file("run-is_file-dir-link"));
	ok1(path_is_file("run-is_file-file-link"));
	ok1(path_is_file("run-is_file-dir/file"));
	ok1(!path_is_file("run-is_file-dir"));
	ok1(!path_is_file("run-is_file-nonexist"));

	path = path_join(ctx, cwd, "run-is_file-dir/file");
	ok1(path_is_file(path));
	ok1(!path_is_file(cwd));

	tal_free(ctx);

	return exit_status();
}
コード例 #3
0
ファイル: thumb-cache.c プロジェクト: ChingezKhan/gthumb
void
cache_copy (const char *src,
	    const char *dest)
{
	char   *cache_src;
	time_t  dest_mtime = get_file_mtime (dest);

	cache_src = cache_get_nautilus_cache_name (src);
	if (path_is_file (cache_src)) {
		char *cache_dest = cache_get_nautilus_cache_name (dest);

		if (path_is_file (cache_dest))
			file_unlink (cache_dest);
		if (file_copy (cache_src, cache_dest))
			set_file_mtime (cache_dest, dest_mtime);

		g_free (cache_dest);
	}
	g_free (cache_src);
}
コード例 #4
0
ファイル: thumb-cache.c プロジェクト: ChingezKhan/gthumb
static gboolean
process_files_cb (gpointer data)
{
	NautilusCacheRemoveData *ncrd = data;
	GList *scan = ncrd->scan;
	int    i = 0;

	if (ncrd->process_timeout != 0) {
		g_source_remove (ncrd->process_timeout);
		ncrd->process_timeout = 0;
	}

	if ((ncrd->scan == NULL) || ncrd->interrupted) {
		process__final_step (ncrd);
		return FALSE;
	}

	g_free (ncrd->handle);
	ncrd->handle = NULL;

	for (; scan && i < PROCESS_MAX_FILES; scan = scan->next, i++) {
		FileData *fd = scan->data;
		char     *rc_file = fd->path;
		char     *real_file;

		real_file = get_real_name_from_nautilus_cache (rc_file);

		if (real_file == NULL)
			continue;

		if (ncrd->clear_all || ! path_is_file (real_file)) {
			if (! file_unlink (rc_file))
				g_warning ("Cannot delete %s\n", rc_file);
		}

		g_free (real_file);
	}

	ncrd->scan = scan;
	ncrd->process_timeout = g_timeout_add (PROCESS_DELAY,
					       process_files_cb,
					       ncrd);

	return FALSE;
}
コード例 #5
0
ファイル: main.c プロジェクト: ChingezKhan/gthumb
static void
create_default_categories_if_needed (void)
{
	Bookmarks *categories;
	char      *default_categories[] = { N_("Holidays"),
					    N_("Temporary"),
					    N_("Screenshots"),
					    N_("Science"),
					    N_("Favourite"),
					    N_("Important"),
					    N_("GNOME"),
					    N_("Games"),
					    N_("Party"),
					    N_("Birthday"),
					    N_("Astronomy"),
					    N_("Family"),
					    NULL };
	int        i;
	char      *path;

	path = g_strconcat (g_get_home_dir (),
			    "/",
			    RC_CATEGORIES_FILE,
			    NULL);
	if (path_is_file (path)) {
		g_free (path);
		return;
	}
	g_free (path);

	categories = bookmarks_new (RC_CATEGORIES_FILE);
	for (i = 0; default_categories[i] != NULL; i++)
		bookmarks_add (categories, _(default_categories[i]), TRUE, TRUE);
	bookmarks_write_to_disk (categories);
	bookmarks_free (categories);
}
コード例 #6
0
ファイル: main.c プロジェクト: ChingezKhan/gthumb
/* Initialize application data. */
static void
initialize_data (void)
{
	char *current_dir;
	char *path, *filename;
	int   i = 0;

	convert_to_new_comment_system ();
	create_default_categories_if_needed ();

	eel_gconf_monitor_add ("/apps/gthumb");

	gth_monitor = gth_monitor_new ();

	/* Icon theme */

	icon_theme = gtk_icon_theme_get_default ();
	g_signal_connect (icon_theme,
			  "changed",
			  G_CALLBACK (theme_changed_cb),
			  NULL);

	/* Default windows icon */

	init_icon_pixbufs ();
	g_set_application_name (_("gThumb"));
	gtk_window_set_default_icon_name ("gthumb");

	/**/

	init_session ("gthumb");
	if (session_is_restored ())
		return;

	/* Parse command line arguments. */

	if (remaining_args == NULL) { /* No arguments specified. */
		reset_command_line_catalog ();
		return;
	}

	current_dir = g_get_current_dir ();
	while ((filename = remaining_args[i++]) != NULL) {
		char     *tmp1 = NULL;
		gboolean  is_dir;

		if (uri_has_scheme (filename) || g_path_is_absolute (filename))
			tmp1 = gnome_vfs_make_uri_from_shell_arg (filename);
		else
			tmp1 = g_strconcat (current_dir, "/", filename, NULL);

		path = remove_special_dirs_from_path (tmp1);
		g_free (tmp1);

		if (path_is_dir (path))
			is_dir = TRUE;
		else if (path_is_file (path))
			is_dir = FALSE;
		else {
			g_free (path);
			continue;
		}

		if (is_dir) {
			dir_urls = g_list_prepend (dir_urls, add_scheme_if_absent (path));
			g_free (path);
		} 
		else
			file_urls = g_list_prepend (file_urls, path);
	}

	n_file_urls = g_list_length (file_urls);
	n_dir_urls = g_list_length (dir_urls);

	if (n_file_urls == 1)
		view_single_image = TRUE;

	if (n_file_urls > 1) {
		/* Create a catalog with the command line list. */
		Catalog *catalog;
		char    *catalog_path;
		GList   *scan;

		catalog = catalog_new ();
		catalog_path = get_command_line_catalog_path ();
		catalog_set_path (catalog, catalog_path);
		g_free (catalog_path);

		for (scan = file_urls; scan; scan = scan->next)
			catalog_add_item (catalog, scan->data);

		catalog->sort_method = GTH_SORT_METHOD_MANUAL;

		catalog_write_to_disk (catalog, NULL);
		catalog_free (catalog);

		view_comline_catalog = TRUE;
	}
	else
		reset_command_line_catalog ();

	g_free (current_dir);
}
コード例 #7
0
ファイル: gth-monitor.c プロジェクト: ChingezKhan/gthumb
static void
add_monitor_event (GthMonitor                *monitor,
		   GnomeVFSMonitorEventType   event_type,
		   const char                *path,
		   GList                    **monitor_events)
{
	MonitorEventType  type;
	char             *op;
	
	if (!monitor->priv->monitor_enabled)
		return;

	if (event_type == GNOME_VFS_MONITOR_EVENT_CREATED)
		op = "CREATED";
	else if (event_type == GNOME_VFS_MONITOR_EVENT_DELETED)
		op = "DELETED";
	else
		op = "CHANGED";

	debug (DEBUG_INFO, "[%s] %s", op, path);

	if (event_type == GNOME_VFS_MONITOR_EVENT_CREATED) {
		if (path_is_file (path))
			type = MONITOR_EVENT_FILE_CREATED;
		else if (path_is_dir (path))
			type = MONITOR_EVENT_DIR_CREATED;
		else
			return;

	} else if (event_type == GNOME_VFS_MONITOR_EVENT_DELETED) {
		if (file_is_image_video_or_audio (path, TRUE))
			type = MONITOR_EVENT_FILE_DELETED;
		else
			type = MONITOR_EVENT_DIR_DELETED;

	} else {
		if (path_is_file (path))
			type = MONITOR_EVENT_FILE_CHANGED;
		else
			return;
	}

	if (type == MONITOR_EVENT_FILE_CREATED) {
		if (remove_if_present (monitor_events,
				       MONITOR_EVENT_FILE_DELETED,
				       path))
			type = MONITOR_EVENT_FILE_CHANGED;

	} else if (type == MONITOR_EVENT_FILE_DELETED) {
		remove_if_present (monitor_events,
				   MONITOR_EVENT_FILE_CREATED,
				   path);
		remove_if_present (monitor_events,
				   MONITOR_EVENT_FILE_CHANGED,
				   path);

	} else if (type == MONITOR_EVENT_FILE_CHANGED) {
		remove_if_present (monitor_events,
				   MONITOR_EVENT_FILE_CHANGED,
				   path);

	} else if (type == MONITOR_EVENT_DIR_CREATED) {
		remove_if_present (monitor_events,
				   MONITOR_EVENT_DIR_DELETED,
				   path);

	} else if (type == MONITOR_EVENT_DIR_DELETED)
		remove_if_present (monitor_events,
				   MONITOR_EVENT_DIR_CREATED,
				   path);

	monitor_events[type] = g_list_append (monitor_events[type], g_strdup (path));
}