コード例 #1
0
static gboolean
setup_directory_structure (const gchar  *theme_name,
			   GError      **error)
{
  gchar *dir, *theme_name_dir;
  GnomeVFSURI *uri;
  gboolean retval = TRUE;

  theme_name_dir = str_remove_slash (theme_name);

  dir = g_build_filename (g_get_home_dir (), ".themes", NULL);
  uri = gnome_vfs_uri_new (dir);
  if (!gnome_vfs_uri_exists (uri))
    gnome_vfs_make_directory_for_uri (uri, 0775);
  gnome_vfs_uri_unref (uri);
  g_free (dir);

  dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL);
  uri = gnome_vfs_uri_new (dir);
  if (!gnome_vfs_uri_exists (uri))
    gnome_vfs_make_directory_for_uri (uri, 0775);
  gnome_vfs_uri_unref (uri);
  g_free (dir);

  dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL);
  g_free (theme_name_dir);
  uri = gnome_vfs_uri_new (dir);
  g_free (dir);

  if (gnome_vfs_uri_exists (uri)) {
    GtkDialog *dialog;
    GtkWidget *button;
    gint response;

    dialog = (GtkDialog *) gtk_message_dialog_new (NULL,
						   GTK_DIALOG_MODAL,
						   GTK_MESSAGE_QUESTION,
	 					   GTK_BUTTONS_CANCEL,
						   _("The theme already exists. Would you like to replace it?"));
    button = gtk_dialog_add_button (dialog, _("_Overwrite"), GTK_RESPONSE_ACCEPT);
    gtk_button_set_image (GTK_BUTTON (button),
			  gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_BUTTON));
    response = gtk_dialog_run (dialog);
    gtk_widget_destroy (GTK_WIDGET (dialog));
    retval = (response != GTK_RESPONSE_CANCEL);
  }

  gnome_vfs_uri_unref (uri);

  return retval;
}
コード例 #2
0
static GObject *
panel_ditem_editor_constructor (GType                  type,
				guint                  n_construct_properties,
				GObjectConstructParam *construct_properties)
{
	GObject          *obj;
	PanelDItemEditor *dialog;
	GnomeVFSURI      *vfs_uri;
	gboolean          loaded;

	obj = G_OBJECT_CLASS (panel_ditem_editor_parent_class)->constructor (type,
									     n_construct_properties,
									     construct_properties);

	dialog = PANEL_DITEM_EDITOR (obj);

	if (dialog->priv->key_file) {
		panel_ditem_editor_key_file_loaded (dialog);
		dialog->priv->new_file = FALSE;
		dialog->priv->free_key_file = FALSE;
		loaded = TRUE;
	} else {
		dialog->priv->key_file = panel_util_key_file_new_desktop ();
		dialog->priv->free_key_file = TRUE;
		loaded = FALSE;
	}

	if (!loaded && dialog->priv->uri) {
		vfs_uri = gnome_vfs_uri_new (dialog->priv->uri);
		if (gnome_vfs_uri_exists (vfs_uri)) {
			//FIXME what if there's an error?
			panel_ditem_editor_load_uri (dialog, NULL);
			dialog->priv->new_file = FALSE;
		} else {
			dialog->priv->new_file = TRUE;
		}
		gnome_vfs_uri_unref (vfs_uri);
	} else {
		dialog->priv->new_file = !loaded;
	}

	dialog->priv->dirty = FALSE;

	panel_ditem_editor_setup_ui (dialog);

	return obj;
}
コード例 #3
0
ファイル: bf_lib.c プロジェクト: Letractively/bluefish-win
/**
 * file_exists_and_readable:
 * @filename: a #const gchar * with a file path
 *
 * tests if the file exists, and  if it is readable, the last
 * check is not reliable, it does not check all the groups you are
 * in, so change this function before you rely on that check!
 *
 * this function is Gnome-VFS aware, so it will work on URI's
 *
 * Return value: gboolean, TRUE if readable, else FALSE
 **/
gboolean file_exists_and_readable(const gchar * filename) {
	gchar *ondiskencoding;
	/* not sure the purpose of returning true here by default so I changed it to false. */
	/* gboolean retval=TRUE; */
	gboolean retval = FALSE;

#ifdef WIN32
	 if (strchr(filename,'/')==filename) filename++;
#endif /* WIN32 */

#ifdef DEVELOPMENT
	g_assert(filename);
#endif
	if (!filename || strlen(filename) < 2) {
		DEBUG_MSG("file_exists_and_readable, strlen(filename) < 2 or no filename!!!!\n");
		return FALSE;
	}
	DEBUG_MSG("file_exists_and_readable, filename(%p)=\"%s\", strlen(filename)=%d\n", filename, filename, strlen(filename));
	ondiskencoding = get_filename_on_disk_encoding(filename);
	DEBUG_MSG("file_exists_and_readable, ondiskencoding='%s'\n",ondiskencoding);
#ifdef HAVE_GNOME_VFS
	{
		GnomeVFSURI* uri;
		uri = gnome_vfs_uri_new(ondiskencoding);
		retval = gnome_vfs_uri_exists(uri);
		DEBUG_MSG("gnome_vfs_uri has path %s\n",gnome_vfs_uri_get_path(uri));
		gnome_vfs_uri_unref(uri);
		DEBUG_MSG("file_exists_and_readable, return %d for %s\n",retval,filename);
	}
#else /* HAVE_GNOME_VFS */
	{
#ifdef WIN32		
		struct _stat naamstat;
		errno = 0;
		retval = ((_stat(ondiskencoding, &naamstat) == 0) && (errno == 0));
#else /* NOT WIN32 */
		struct stat naamstat;
		errno = 0;
		retval = ((stat(ondiskencoding, &naamstat) == 0) && (errno == 0));
#endif
		DEBUG_MSG("file_exists_and_readable, retval=%d (ernno=%d) for\n %s\n",retval,errno,ondiskencoding);
	}
#endif /* HAVE_GNOME_VFS */
	g_free(ondiskencoding);
	return retval;
}
コード例 #4
0
gboolean launcher_application_validate(struct launcher *launcher,
                                       const char *text_uri)
{
        GnomeVFSURI *uri;

        g_return_val_if_fail(launcher, FALSE);
        g_return_val_if_fail(launcher==&launcher_application, FALSE);
        g_return_val_if_fail(text_uri!=NULL, FALSE);

        uri=gnome_vfs_uri_new(text_uri);
        if(uri) {
                gboolean retval=gnome_vfs_uri_exists(uri);
                gnome_vfs_uri_unref(uri);
                return retval;
        } else {
                return FALSE;
        }
}