Commit 05da734c authored by Carl-Anton Ingmarsson's avatar Carl-Anton Ingmarsson Committed by Johannes Schmid

Implement checkout option for git and change it for svn so that it works

2009-04-02  Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>

	* plugins/git/Makefile.am:
	* plugins/git/git-vcs-interface.c (git_ivcs_checkout):
	* plugins/git/git-vcs-interface.h:
	* plugins/subversion/subversion-vcs-interface.c
	(subversion_ivcs_checkout):
	Implement checkout option for git and change it for svn so that it
	works for project-import

	* plugins/project-import/Makefile.am:
	* plugins/project-import/plugin.c (project_import_generate_file),
	(project_import_import_project), (checkout_finished),
	(project_import_checkout_project), (import_dialog_response),
	(finalize), (iwizard_activate), (ifile_open):
	* plugins/project-import/plugin.h:
	* plugins/project-import/project-import-dialog.c
	(vcs_entry_changed), (name_entry_changed), (folder_radio_toggled),
	(vcs_radio_toggled), (project_import_dialog_get_vcs_id),
	(project_import_dialog_get_vcs_uri),
	(project_import_dialog_get_dest_dir),
	(project_import_dialog_get_source_dir),
	(project_import_dialog_get_name), (project_import_dialog_new),
	(project_import_dialog_init), (project_import_dialog_finalize),
	(project_import_dialog_class_init):
	* plugins/project-import/project-import-dialog.h:
	* plugins/project-import/project-import.c:
	* plugins/project-import/project-import.glade:
	* plugins/project-import/project-import.h:
	Remove project import wizard and replace with simpler dialog
	that allows to import directly from a version control system.

svn path=/trunk/; revision=4915
parent 1587911b
2009-04-02 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
* plugins/git/Makefile.am:
* plugins/git/git-vcs-interface.c (git_ivcs_checkout):
* plugins/git/git-vcs-interface.h:
* plugins/subversion/subversion-vcs-interface.c
(subversion_ivcs_checkout):
Implement checkout option for git and change it for svn so that it
works for project-import
* plugins/project-import/Makefile.am:
* plugins/project-import/plugin.c (project_import_generate_file),
(project_import_import_project), (checkout_finished),
(project_import_checkout_project), (import_dialog_response),
(finalize), (iwizard_activate), (ifile_open):
* plugins/project-import/plugin.h:
* plugins/project-import/project-import-dialog.c
(vcs_entry_changed), (name_entry_changed), (folder_radio_toggled),
(vcs_radio_toggled), (project_import_dialog_get_vcs_id),
(project_import_dialog_get_vcs_uri),
(project_import_dialog_get_dest_dir),
(project_import_dialog_get_source_dir),
(project_import_dialog_get_name), (project_import_dialog_new),
(project_import_dialog_init), (project_import_dialog_finalize),
(project_import_dialog_class_init):
* plugins/project-import/project-import-dialog.h:
* plugins/project-import/project-import.c:
* plugins/project-import/project-import.glade:
* plugins/project-import/project-import.h:
Remove project import wizard and replace with simpler dialog
that allows to import directly from a version control system.
2009-03-30 Maxim Ermilov <zaspire@rambler.ru>
reviewed by: Johannes Schmid <jhs@gnome.org>
......@@ -179,7 +179,9 @@ libanjuta_git_la_SOURCES = \
git-cat-file-menu.c \
git-cat-file-menu.h \
git-vcs-interface.c \
git-vcs-interface.h
git-vcs-interface.h \
git-clone-command.h \
git-clone-command.c
libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
......
......@@ -75,7 +75,44 @@ git_ivcs_checkout (IAnjutaVcs *obj,
GCancellable *cancel,
AnjutaAsyncNotify *notify, GError **err)
{
/* TODO */
GFile *parent;
gchar *path, *dir_name;
GitCloneCommand *clone_command;
Git *plugin;
parent = g_file_get_parent (dest);
path = g_file_get_path (parent);
dir_name = g_file_get_basename (dest);
clone_command = git_clone_command_new (repository_location, path, dir_name);
plugin = ANJUTA_PLUGIN_GIT (obj);
g_object_unref (parent);
g_free (path);
g_free (dir_name);
git_create_message_view (plugin);
g_signal_connect (G_OBJECT (clone_command), "data-arrived",
G_CALLBACK (on_git_command_info_arrived),
plugin);
if (cancel)
{
g_signal_connect_swapped (G_OBJECT (cancel), "cancelled",
G_CALLBACK (anjuta_command_cancel),
clone_command);
}
if (notify)
{
g_signal_connect_swapped (G_OBJECT (clone_command),
"command-finished",
G_CALLBACK (anjuta_async_notify_notify_finished),
notify);
}
anjuta_command_start (ANJUTA_COMMAND (clone_command));
}
static void
......
......@@ -32,6 +32,7 @@
#include "git-diff-command.h"
#include "git-status-command.h"
#include "git-remove-command.h"
#include "git-clone-command.h"
#include "git-ui-utils.h"
......
# Plugin glade file
wizard_gladedir = $(anjuta_glade_dir)
wizard_glade_DATA = project-import.glade
# Plugin pixmaps
wizard_pixmapsdir = $(anjuta_image_dir)
......@@ -32,10 +35,11 @@ libanjuta_project_import_la_LIBADD = \
libanjuta_project_import_la_SOURCES= \
plugin.c \
plugin.h \
project-import.c \
project-import.h
project-import-dialog.h \
project-import-dialog.c
EXTRA_DIST = \
$(plugin_in_files) \
$(wizard_pixmaps_DATA) \
$(project_import_DATA) \
$(wizard_plugin_DATA)
......@@ -24,14 +24,357 @@
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/interfaces/ianjuta-wizard.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-file-loader.h>
#include <libanjuta/interfaces/ianjuta-project-backend.h>
#include <libanjuta/interfaces/ianjuta-vcs.h>
#include <libanjuta/gbf-project.h>
#include <libanjuta/anjuta-async-notify.h>
#include "plugin.h"
#include "project-import.h"
#include "project-import-dialog.h"
#define ICON_FILE "anjuta-project-import-plugin-48.png"
#define AM_PROJECT_FILE PACKAGE_DATA_DIR"/project/terminal/project.anjuta"
#define MKFILE_PROJECT_FILE PACKAGE_DATA_DIR"/project/mkfile/project.anjuta"
static gpointer parent_class;
static gboolean
project_import_generate_file (AnjutaProjectImportPlugin* import_plugin, ProjectImportDialog *import_dialog,
GFile *project_file)
{
/* Of course we could do some more intelligent stuff here
and check which plugins are really needed but for now we just
take a default project file. */
GFile* source_file;
if (!strcmp (import_plugin->backend_id, "automake"))
source_file = g_file_new_for_path (AM_PROJECT_FILE);
else if (!strcmp (import_plugin->backend_id, "make"))
source_file = g_file_new_for_path (MKFILE_PROJECT_FILE);
else
{
/* We shouldn't get here, unless someone has upgraded their GBF */
/* but not Anjuta. */
/* show the dialog since it may be hidden */
gtk_widget_show (GTK_WIDGET (import_dialog));
anjuta_util_dialog_error (GTK_WINDOW (import_dialog),
_("Generation of project file failed. Cannot "
"find an appropriate project template to "
"use. Please make sure your version of "
"Anjuta is up to date."));
return FALSE;
}
GError* error = NULL;
if (!g_file_copy (source_file, project_file,
G_FILE_COPY_NONE,
NULL,
NULL,
NULL,
&error))
{
if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_EXISTS)
{
gchar *prjfile = g_file_get_parse_name (project_file);
if (anjuta_util_dialog_boolean_question (GTK_WINDOW (ANJUTA_PLUGIN(import_plugin)->shell),
_("A file named \"%s\" already exists. "
"Do you want to replace it?"), prjfile))
{
g_error_free (error);
error = NULL;
g_file_copy (source_file, project_file,
G_FILE_COPY_OVERWRITE,
NULL,
NULL,
NULL,
&error);
}
g_free (prjfile);
}
}
g_object_unref (source_file);
if (!error)
{
time_t ctime = time(NULL);
GFileInfo* file_info = g_file_info_new();
g_file_info_set_attribute_uint64(file_info,
"time::modified",
ctime);
g_file_info_set_attribute_uint64(file_info,
"time::created",
ctime);
g_file_info_set_attribute_uint64(file_info,
"time::access",
ctime);
g_file_set_attributes_from_info (project_file,
file_info,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
g_object_unref (G_OBJECT(file_info));;
}
else
{
gchar *prjfile;
prjfile = g_file_get_parse_name (project_file);
/* show the dialog since it may be hidden */
gtk_widget_show (GTK_WIDGET (import_dialog));
anjuta_util_dialog_error (GTK_WINDOW (import_dialog),
_("A file named \"%s\" cannot be written: %s. "
"Check if you have write access to the project directory."),
prjfile, error->message);
g_free (prjfile);
return FALSE;
}
return TRUE;
}
static gboolean
project_import_import_project (AnjutaProjectImportPlugin *import_plugin, ProjectImportDialog *import_dialog,
GFile *source_dir)
{
AnjutaPluginManager *plugin_manager;
GList *descs = NULL;
GList *desc;
AnjutaPluginDescription *backend;
gchar *name, *project_file_name;
plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN(import_plugin)->shell, NULL);
descs = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin",
"Interfaces",
"IAnjutaProjectBackend",
NULL);
for (desc = g_list_first (descs); desc != NULL; desc = g_list_next (desc)) {
IAnjutaProjectBackend *plugin;
gchar *location = NULL;
GbfProject* proj;
backend = (AnjutaPluginDescription *)desc->data;
anjuta_plugin_description_get_string (backend, "Anjuta Plugin", "Location", &location);
plugin = (IAnjutaProjectBackend *)anjuta_plugin_manager_get_plugin_by_id (plugin_manager, location);
g_free (location);
/* Probe the backend to find out if the project directory is OK */
/* If probe() returns TRUE then we have a valid backend */
proj= ianjuta_project_backend_new_project (plugin, NULL);
if (proj)
{
gchar *path;
path = g_file_get_path (source_dir);
if (gbf_project_probe (proj, path, NULL))
{
/* This is a valid backend for this root directory */
/* FIXME: Possibility of more than one valid backend? */
break;
}
g_object_unref (proj);
g_free (path);
}
plugin = NULL;
backend = NULL;
}
g_list_free (descs);
if (!backend)
{
gchar *path = project_import_dialog_get_name (import_dialog);
/* show the dialog since it may be hidden */
gtk_widget_show (GTK_WIDGET (import_dialog));
anjuta_util_dialog_error (GTK_WINDOW (import_dialog),
_("Could not find a valid project backend for the "
"directory given (%s). Please select a different "
"directory, or try upgrading to a newer version of "
"Anjuta."), path);
g_free (path);
return FALSE;
}
if (!anjuta_plugin_description_get_string (backend, "Project", "Supported-Project-Types", &import_plugin->backend_id))
{
import_plugin->backend_id = g_strdup ("unknown");
}
name = project_import_dialog_get_name (import_dialog);
project_file_name = g_strconcat (name, ".", "anjuta", NULL);
GFile *project_file = g_file_get_child (source_dir, project_file_name);
g_free (name);
g_free (project_file_name);
IAnjutaFileLoader* loader;
if (!project_import_generate_file (import_plugin, import_dialog, project_file))
{
g_object_unref (project_file);
return FALSE;
}
loader = anjuta_shell_get_interface (ANJUTA_PLUGIN (import_plugin)->shell,
IAnjutaFileLoader, NULL);
if (!loader)
{
g_warning("No IAnjutaFileLoader interface! Cannot open project file!");
g_object_unref (project_file);
return TRUE;
}
ianjuta_file_loader_load (loader, project_file, FALSE, NULL);
g_object_unref (project_file);
return TRUE;
}
typedef struct
{
AnjutaProjectImportPlugin *import_plugin;
ProjectImportDialog *import_dialog;
GFile *checkout_dir;
} CheckoutData;
static void
checkout_finished (AnjutaAsyncNotify *async_notify, gpointer user_data)
{
CheckoutData *ch = (CheckoutData *)user_data;
GError *err;
err = NULL;
anjuta_async_notify_get_error (async_notify, &err);
if (err)
{
gchar *vcs_uri;
/* show the dialog since it's hidden */
gtk_widget_show (GTK_WIDGET (ch->import_dialog));
vcs_uri = project_import_dialog_get_vcs_uri (ch->import_dialog);
anjuta_util_dialog_error (GTK_WINDOW (ch->import_dialog),
_("Couldn't checkout the supplied uri "
"\"%s\", the error returned was: \"%s\""),
vcs_uri, err->message);
g_free (vcs_uri);
g_error_free (err);
goto cleanup;
}
project_import_import_project (ch->import_plugin, ch->import_dialog, ch->checkout_dir);
cleanup:
g_object_unref (ch->checkout_dir);
g_slice_free (CheckoutData, ch);
}
static void
project_import_checkout_project (AnjutaProjectImportPlugin *import_plugin,
ProjectImportDialog *import_dialog)
{
CheckoutData *ch_data;
AnjutaAsyncNotify *async_notify;
gchar *vcs_uri, *plugin_id, *name;
GFile *dest_dir, *checkout_dir;
AnjutaPluginManager *plugin_manager;
IAnjutaVcs *ivcs;
GError *err;
name = project_import_dialog_get_name (import_dialog);
dest_dir = project_import_dialog_get_dest_dir (import_dialog);
checkout_dir = g_file_get_child (dest_dir, name);
g_object_unref (dest_dir);
g_free (name);
ch_data = g_slice_new (CheckoutData);
ch_data->import_plugin = import_plugin;
ch_data->import_dialog = import_dialog;
ch_data->checkout_dir = checkout_dir;
async_notify = anjuta_async_notify_new ();
g_signal_connect (async_notify, "finished", G_CALLBACK (checkout_finished),
ch_data);
vcs_uri = project_import_dialog_get_vcs_uri (import_dialog);
plugin_id = project_import_dialog_get_vcs_id (import_dialog);
plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (import_plugin)->shell, NULL);
ivcs = IANJUTA_VCS (anjuta_plugin_manager_get_plugin_by_id (plugin_manager, plugin_id));
err = NULL;
ianjuta_vcs_checkout (ivcs, vcs_uri, checkout_dir, NULL, async_notify, &err);
if (err)
{
anjuta_util_dialog_error (GTK_WINDOW (import_dialog),
_("Couldn't checkout the supplied uri "
"\"%s\", the error returned was: \"%s\""),
vcs_uri, err->message);
g_error_free (err);
goto cleanup;
}
/* hide the import dialog */
gtk_widget_hide (GTK_WIDGET (import_dialog));
cleanup:
g_free (vcs_uri);
g_free (plugin_id);
}
static void
import_dialog_response (GtkDialog *dialog, gint response_id, gpointer user_data)
{
AnjutaProjectImportPlugin *import_plugin = (AnjutaProjectImportPlugin *)user_data;
ProjectImportDialog *import_dialog = PROJECT_IMPORT_DIALOG (dialog);
switch (response_id)
{
case GTK_RESPONSE_ACCEPT:
{
GFile *source_dir;
source_dir = project_import_dialog_get_source_dir (import_dialog);
if (source_dir)
{
if (project_import_import_project (import_plugin, import_dialog, source_dir))
gtk_widget_destroy (GTK_WIDGET (import_dialog));
g_object_unref (source_dir);
}
else
project_import_checkout_project (import_plugin, import_dialog);
break;
}
case GTK_RESPONSE_REJECT:
gtk_widget_destroy (GTK_WIDGET (dialog));
}
}
static gboolean
activate_plugin (AnjutaPlugin *plugin)
{
......@@ -62,6 +405,11 @@ dispose (GObject *obj)
static void
finalize (GObject *obj)
{
AnjutaProjectImportPlugin *import_plugin = (AnjutaProjectImportPlugin *)obj;
if (import_plugin->backend_id)
g_free (import_plugin->backend_id);
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
......@@ -88,9 +436,15 @@ static void
iwizard_activate (IAnjutaWizard *wiz, GError **err)
{
AnjutaProjectImportPlugin* plugin = ANJUTA_PLUGIN_PROJECT_IMPORT (wiz);
ProjectImport* pi;
pi = project_import_new(ANJUTA_PLUGIN(plugin));
AnjutaPluginManager *plugin_manager;
ProjectImportDialog* pi;
plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (plugin)->shell, NULL);
pi = project_import_dialog_new(plugin_manager, NULL, NULL);
g_signal_connect (pi, "response", G_CALLBACK (import_dialog_response), plugin);
gtk_widget_show (GTK_WIDGET (pi));
}
static void
......@@ -102,22 +456,30 @@ iwizard_iface_init (IAnjutaWizardIface *iface)
static void
ifile_open (IAnjutaFile *ifile, GFile* file, GError **err)
{
gchar *dir, *ext, *project_name;
ProjectImport* pi;
gchar *ext, *project_name;
GFile *dir;
ProjectImportDialog* pi;
AnjutaProjectImportPlugin* plugin = ANJUTA_PLUGIN_PROJECT_IMPORT (ifile);
gchar* uri = g_file_get_uri (file);
AnjutaPluginManager *plugin_manager;
g_return_if_fail (uri != NULL && strlen (uri) > 0);
dir = g_path_get_dirname (uri);
dir = g_file_get_parent (file);
project_name = g_path_get_basename (uri);
ext = strrchr (project_name, '.');
if (ext)
*ext = '\0';
plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (plugin)->shell, NULL);
pi = project_import_dialog_new (plugin_manager, project_name, dir);
g_signal_connect (pi, "response", G_CALLBACK (import_dialog_response), plugin);
gtk_widget_show (GTK_WIDGET (pi));
pi = project_import_new(ANJUTA_PLUGIN(plugin));
project_import_set_name (pi, project_name);
project_import_set_directory (pi, dir);
g_object_unref (dir);
g_free (project_name);
g_free (uri);
}
......
......@@ -40,6 +40,7 @@ struct _AnjutaProjectImportPlugin
{
AnjutaPlugin parent;
AnjutaPreferences *prefs;
gchar *backend_id;
};
struct _AnjutaProjectImportPluginClass
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* anjuta
* Copyright (C) Carl-Anton Ingmarsson 2009 <ca.ingmarsson@gmail.com>
*
* anjuta is free software.
*
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* anjuta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with anjuta. If not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include "project-import-dialog.h"
#include <glib/gi18n.h>
#define BUILDER_FILE PACKAGE_DATA_DIR"/glade/project-import.glade"
G_DEFINE_TYPE (ProjectImportDialog, project_import_dialog, GTK_TYPE_DIALOG);
typedef struct _ProjectImportDialogPrivate ProjectImportDialogPrivate;
struct _ProjectImportDialogPrivate {
GtkEntry *name_entry;
GtkWidget *source_dir_button;
GtkWidget *vcs_entry;
GtkWidget *dest_dir_button;
GtkWidget *import_button;
GtkWidget *folder_radio;
GtkWidget *vcs_combo;
GtkListStore *vcs_store;
};
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), PROJECT_IMPORT_TYPE_DIALOG, ProjectImportDialogPrivate))
static void
vcs_entry_changed (GtkEditable *editable, gpointer user_data)
{
ProjectImportDialog *project_import = (ProjectImportDialog *)user_data;
ProjectImportDialogPrivate *priv = GET_PRIVATE (project_import);
if (gtk_entry_get_text_length (GTK_ENTRY (editable)))
{
if (gtk_entry_get_text_length (priv->name_entry))
{
gtk_widget_set_sensitive (priv->import_button, TRUE);
}
}
else
gtk_widget_set_sensitive (priv->import_button, FALSE);
}
static void
name_entry_changed (GtkEditable *editable, gpointer user_data)
{
ProjectImportDialog *project_import = (ProjectImportDialog *)user_data;
ProjectImportDialogPrivate *priv = GET_PRIVATE (project_import);
if (gtk_entry_get_text_length (GTK_ENTRY (editable)))
{
if ((gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->folder_radio)) ||
gtk_entry_get_text_length (GTK_ENTRY (priv->vcs_entry))))
{
gtk_widget_set_sensitive (priv->import_button, TRUE);
}
}
else
gtk_widget_set_sensitive (priv->import_button, FALSE);
}
static void
folder_radio_toggled (GtkToggleButton *button, gpointer user_data)
{
ProjectImportDialog *project_import = (ProjectImportDialog *)user_data;
ProjectImportDialogPrivate *priv = GET_PRIVATE (project_import);
gtk_widget_set_sensitive (priv->source_dir_button, TRUE);
gtk_widget_set_sensitive (priv->vcs_entry, FALSE);
gtk_widget_set_sensitive (priv->dest_dir_button, FALSE);
gtk_widget_set_sensitive (priv->vcs_combo, FALSE);
if (gtk_entry_get_text_length (priv->name_entry))
{
gtk_widget_set_sensitive (priv->import_button, TRUE);
}
else
gtk_widget_set_sensitive (priv->import_button, FALSE);
}
static void
vcs_radio_toggled (GtkToggleButton *button, gpointer user_data)
{
ProjectImportDialog *project_import = (ProjectImportDialog *)user_data;
ProjectImportDialogPrivate *priv = GET_PRIVATE (project_import);
gtk_widget_set_sensitive (priv->vcs_entry, TRUE);
gtk_widget_set_sensitive (priv->dest_dir_button, TRUE);
gtk_widget_set_sensitive (priv->vcs_combo, TRUE);
gtk_widget_set_sensitive (priv->source_dir_button, FALSE);
if ((gtk_entry_get_text_length (GTK_ENTRY (priv->vcs_entry))
&& gtk_entry_get_text (priv->name_entry)))
{
gtk_widget_set_sensitive (priv->import_button, TRUE);
}
else
gtk_widget_set_sensitive (priv->import_button, FALSE);
}
gchar *
project_import_dialog_get_vcs_id (ProjectImportDialog *import_dialog)
{
ProjectImportDialogPrivate *priv = GET_PRIVATE (import_dialog);
GtkTreeIter iter;
gchar *vcs_id;
g_assert (PROJECT_IS_IMPORT_DIALOG (import_dialog));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->folder_radio)))
return NULL;
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->vcs_combo), &iter);
gtk_tree_model_get (GTK_TREE_MODEL (priv->vcs_store), &iter, 1, &vcs_id, -1);
return vcs_id;
}
gchar *
project_import_dialog_get_vcs_uri (ProjectImportDialog *import_dialog)
{
ProjectImportDialogPrivate *priv = GET_PRIVATE (import_dialog);
g_assert (PROJECT_IS_IMPORT_DIALOG (import_dialog));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->folder_radio)))
return NULL;
return g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->vcs_entry)));
}
GFile *
project_import_dialog_get_dest_dir (ProjectImportDialog *import_dialog)
{
ProjectImportDialogPrivate *priv = GET_PRIVATE (import_dialog);
g_assert (PROJECT_IS_IMPORT_DIALOG (import_dialog));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->folder_radio)))
return NULL;
return gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dest_dir_button));
}
GFile *
project_import_dialog_get_source_dir (ProjectImportDialog *import_dialog)
{
ProjectImportDialogPrivate *priv = GET_PRIVATE (import_dialog);
g_assert (PROJECT_IS_IMPORT_DIALOG (import_dialog));
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->folder_radio)))
return NULL;
return gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->source_dir_button));