Commit dcfebec9 authored by Paolo Bacchilega's avatar Paolo Bacchilega Committed by Paolo Bacchilega

disconnect the signals callbacks before unreferencing the object.

2005-04-20  Paolo Bacchilega  <paobac@cvs.gnome.org>

        * src/fr-archive.c (fr_archive_load): disconnect the signals
        callbacks before unreferencing the object.

        * data/glade/file-roller.glade: center 'create archive' window.
parent 017e60d5
2005-04-20 Paolo Bacchilega <paobac@cvs.gnome.org>
* src/fr-archive.c (fr_archive_load): disconnect the signals
callbacks before unreferencing the object.
* data/glade/file-roller.glade: center 'create archive' window.
* src/main.c (main): removed local pctx.
Fixed bug #162729: File Roller doesn't exit cleanly on invalid
......
......@@ -8,7 +8,7 @@
<property name="border_width">6</property>
<property name="title" translatable="yes">Create Archive</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_MOUSE</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
......@@ -24,7 +24,7 @@
<widget class="GtkVBox" id="dialog-vbox11">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area11">
......
......@@ -78,9 +78,9 @@ static void
extract_here_callback (NautilusMenuItem *item,
gpointer user_data)
{
GList *files;
GList *files, *scan;
NautilusFileInfo *file;
char *uri, *path, *dir_files;
char *uri, *path, *dir;
GString *cmd;
files = g_object_get_data (G_OBJECT (item), "files");
......@@ -88,20 +88,30 @@ extract_here_callback (NautilusMenuItem *item,
uri = nautilus_file_info_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
dir_files = g_strconcat (path, "_FILES", NULL);
dir = g_path_get_dirname (path);
cmd = g_string_new ("file-roller");
g_string_append_printf (cmd,
" --force --extract-to=\"%s\" \"%s\"",
dir_files,
path);
g_string_append_printf (cmd," --default-dir=\"%s\" --extract-here --force", dir);
g_free (dir);
g_free (path);
g_free (uri);
for (scan = files; scan; scan = scan->next) {
NautilusFileInfo *file = scan->data;
uri = nautilus_file_info_get_uri (file);
path = gnome_vfs_get_local_path_from_uri (uri);
g_string_append_printf (cmd, " \"%s\"", path);
g_free (path);
g_free (uri);
}
g_spawn_command_line_async (cmd->str, NULL);
g_string_free (cmd, TRUE);
g_free (dir_files);
g_free (path);
g_free (uri);
}
......@@ -195,9 +205,10 @@ nautilus_fr_get_file_items (NautilusMenuProvider *provider,
{
GList *items = NULL;
GList *scan;
gboolean can_write = FALSE;
gboolean can_write = TRUE;
gboolean one_item;
gboolean one_archive = FALSE;
gboolean all_archives = TRUE;
if (files == NULL)
......@@ -214,32 +225,34 @@ nautilus_fr_get_file_items (NautilusMenuProvider *provider,
if (!local)
return NULL;
if (all_archives && ! is_archive (file))
all_archives = FALSE;
if (can_write) {
char *parent_uri;
GnomeVFSFileInfo *info;
GnomeVFSResult result;
parent_uri = nautilus_file_info_get_parent_uri (file);
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (parent_uri,
info,
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
if (result == GNOME_VFS_OK)
can_write = (info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) != 0;
gnome_vfs_file_info_unref (info);
g_free (parent_uri);
}
}
/**/
one_item = (files != NULL) && (files->next == NULL);
if (one_item) {
NautilusFileInfo *file = files->data;
char *parent_uri;
GnomeVFSFileInfo *info;
GnomeVFSResult result;
one_archive = is_archive (file);
parent_uri = nautilus_file_info_get_parent_uri (file);
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (parent_uri,
info,
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
if (result == GNOME_VFS_OK)
can_write = (info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) != 0;
gnome_vfs_file_info_unref (info);
g_free (parent_uri);
}
one_archive = one_item && all_archives;
if (one_archive && can_write) {
if (all_archives && can_write) {
NautilusMenuItem *item;
item = nautilus_menu_item_new ("NautilusFr::extract_here",
......@@ -257,7 +270,7 @@ nautilus_fr_get_file_items (NautilusMenuProvider *provider,
items = g_list_append (items, item);
} else if (one_archive && ! can_write) {
} else if (all_archives && ! can_write) {
NautilusMenuItem *item;
item = nautilus_menu_item_new ("NautilusFr::extract_to",
......@@ -275,7 +288,9 @@ nautilus_fr_get_file_items (NautilusMenuProvider *provider,
items = g_list_append (items, item);
} else {
}
if (! one_archive) {
NautilusMenuItem *item;
item = nautilus_menu_item_new ("NautilusFr::add",
......
......@@ -188,11 +188,17 @@ add_clicked_cb (GtkWidget *widget,
if (! path_is_dir (archive_dir)) {
GtkWidget *d;
int r;
char *folder_name;
char *msg;
folder_name = g_filename_display_name (archive_dir);
msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name);
g_free (folder_name);
d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog),
GTK_DIALOG_MODAL,
GTK_STOCK_DIALOG_QUESTION,
_("Destination folder does not exist. Do you want to create it?"),
msg,
NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Create _Folder"), GTK_RESPONSE_YES,
......@@ -202,6 +208,8 @@ add_clicked_cb (GtkWidget *widget,
r = gtk_dialog_run (GTK_DIALOG (d));
gtk_widget_destroy (GTK_WIDGET (d));
g_free (msg);
do_not_add = (r != GTK_RESPONSE_YES);
}
......
......@@ -153,11 +153,17 @@ extract_cb (GtkWidget *w,
if (! force_directory_creation) {
GtkWidget *d;
int r;
char *folder_name;
char *msg;
folder_name = g_filename_display_name (extract_to_dir);
msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name);
g_free (folder_name);
d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog),
GTK_DIALOG_MODAL,
GTK_STOCK_DIALOG_QUESTION,
_("Destination folder does not exist. Do you want to create it?"),
msg,
NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Create _Folder"), GTK_RESPONSE_YES,
......@@ -167,6 +173,8 @@ extract_cb (GtkWidget *w,
r = gtk_dialog_run (GTK_DIALOG (d));
gtk_widget_destroy (GTK_WIDGET (d));
g_free (msg);
if (r != GTK_RESPONSE_YES)
do_not_extract = TRUE;
}
......@@ -194,7 +202,7 @@ extract_cb (GtkWidget *w,
return FALSE;
}
}
if (do_not_extract) {
GtkWidget *d;
......@@ -209,6 +217,9 @@ extract_cb (GtkWidget *w,
gtk_dialog_run (GTK_DIALOG (d));
gtk_widget_destroy (GTK_WIDGET (d));
if (data->window->batch_mode)
gtk_widget_destroy (data->dialog);
return FALSE;
}
......
......@@ -52,6 +52,10 @@
#include "utf8-fnmatch.h"
#define g_signal_handlers_disconnect_by_data(instance, data) \
g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, \
0, 0, NULL, NULL, (data))
#define MAX_CHUNK_LEN (NCARGS - PATH_MAX) /* Max length of the command line */
#define UNKNOWN_TYPE "application/octet-stream"
#define SAME_FS (FALSE)
......@@ -533,6 +537,7 @@ action_started (FRCommand *command,
FRAction action,
FRArchive *archive)
{
g_print ("FRArchive::action_started: %d\n", action);
g_signal_emit (G_OBJECT (archive),
fr_archive_signals[START],
0,
......@@ -716,9 +721,11 @@ fr_archive_load (FRArchive *archive,
return FALSE;
}
if (tmp_command != NULL)
g_object_unref (G_OBJECT (tmp_command));
if (tmp_command != NULL) {
g_signal_handlers_disconnect_by_data (tmp_command, archive);
g_object_unref (tmp_command);
}
g_signal_connect (G_OBJECT (archive->command),
"start",
......
......@@ -220,8 +220,6 @@ add_password_arg (FRCommand *comm,
static void
fr_command_zip_list (FRCommand *comm)
{
FR_COMMAND_ZIP (comm)->is_empty = FALSE;
fr_process_set_out_line_func (FR_COMMAND (comm)->process,
......
......@@ -59,6 +59,7 @@ static gchar *add_to = NULL;
static gint add;
static gchar *extract_to = NULL;
static gint extract;
static gint extract_here;
static gchar *default_url = NULL;
extern void get_supported_archive_types (void);
......@@ -80,6 +81,10 @@ struct poptOption options[] = {
N_("Extract archives asking the destination folder and quit the program"),
0 },
{ "extract-here", 'h', POPT_ARG_NONE, &extract_here, 0,
N_("Extract archives using the archive name as destination folder and quit the program"),
0 },
{ "default-dir", 0, POPT_ARG_STRING, &default_url, 0,
N_("Default folder to use for the '--add' and '--extract' commands"),
N_("FOLDER") },
......@@ -380,7 +385,7 @@ prepare_app (poptContext pctx)
default_dir = get_path_from_url (default_url);
if (extract_to != NULL) {
if ((extract_here == 0) && (extract_to != NULL)) {
if (g_path_is_absolute (extract_to))
extract_to_path = get_path_from_url (extract_to);
else {
......@@ -429,7 +434,9 @@ prepare_app (poptContext pctx)
window_archive__quit (window);
window_batch_mode_start (window);
} else if ((extract_to != NULL) || (extract == 1)) { /* Extract all archives. */
} else if ((extract_to != NULL)
|| (extract == 1)
|| (extract_here == 1)) { /* Extract all archives. */
FRWindow *window;
const char *archive;
......@@ -437,10 +444,21 @@ prepare_app (poptContext pctx)
if (default_dir != NULL)
window_set_default_dir (window, default_dir, TRUE);
while ((archive = poptGetArg (pctx)) != NULL)
while ((archive = poptGetArg (pctx)) != NULL) {
if (extract_here == 1) {
g_free (extract_to_path);
extract_to_path = g_strconcat (archive, "_FILES", NULL);
}
window_archive__open_extract (window,
archive,
extract_to_path);
if (extract_here == 1) {
g_free (extract_to_path);
extract_to_path = NULL;
}
}
window_archive__quit (window);
window_batch_mode_start (window);
......
......@@ -4483,11 +4483,17 @@ window_archive_extract (FRWindow *window,
if (! force_directory_creation) {
GtkWidget *d;
int r;
char *folder_name;
char *msg;
folder_name = g_filename_display_name (extract_to_dir);
msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name);
g_free (folder_name);
d = _gtk_message_dialog_new (GTK_WINDOW (window->app),
GTK_DIALOG_MODAL,
GTK_STOCK_DIALOG_QUESTION,
_("Destination folder does not exist. Do you want to create it?"),
msg,
NULL,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Create _Folder"), GTK_RESPONSE_YES,
......@@ -4497,6 +4503,8 @@ window_archive_extract (FRWindow *window,
r = gtk_dialog_run (GTK_DIALOG (d));
gtk_widget_destroy (GTK_WIDGET (d));
g_free (msg);
if (r != GTK_RESPONSE_YES)
do_not_extract = TRUE;
}
......@@ -4539,6 +4547,7 @@ window_archive_extract (FRWindow *window,
gtk_dialog_run (GTK_DIALOG (d));
gtk_widget_destroy (GTK_WIDGET (d));
window_batch_mode_stop (window);
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment