file-roller r2303 - in trunk: . src
- From: paobac svn gnome org
- To: svn-commits-list gnome org
- Subject: file-roller r2303 - in trunk: . src
- Date: Thu, 5 Jun 2008 16:14:26 +0000 (UTC)
Author: paobac
Date: Thu Jun 5 16:14:26 2008
New Revision: 2303
URL: http://svn.gnome.org/viewvc/file-roller?rev=2303&view=rev
Log:
2008-06-05 Paolo Bacchilega <paobac svn gnome org>
* src/main.h:
* src/main.c:
* src/actions.c:
Differentiate between types that can be created and types that can be
saved. The difference is that a type can be created only if it can be
loaded and saved. At the moment only tar.7z can be saved but not
created.
Modified:
trunk/ChangeLog
trunk/src/actions.c
trunk/src/main.c
trunk/src/main.h
Modified: trunk/src/actions.c
==============================================================================
--- trunk/src/actions.c (original)
+++ trunk/src/actions.c Thu Jun 5 16:14:26 2008
@@ -45,6 +45,7 @@
typedef struct {
FrWindow *window;
+ int *supported_types;
GtkWidget *file_sel;
GtkWidget *combo_box;
@@ -95,11 +96,12 @@
*/
static gboolean
is_supported_extension (GtkWidget *file_sel,
- char *filename)
+ char *filename,
+ int *file_type)
{
int i;
- for (i = 0; save_type[i] != -1; i++)
- if (file_extension_is (filename, mime_type_desc[save_type[i]].default_ext))
+ for (i = 0; file_type[i] != -1; i++)
+ if (file_extension_is (filename, mime_type_desc[file_type[i]].default_ext))
return TRUE;
return FALSE;
}
@@ -130,7 +132,7 @@
char *default_ext;
path_ext = get_archive_filename_extension (path);
- default_ext = mime_type_desc[save_type[idx-1]].default_ext;
+ default_ext = mime_type_desc[data->supported_types[idx-1]].default_ext;
if (strcmp_null_tolerant (path_ext, default_ext) != 0) {
full_path = g_strconcat (path, default_ext, NULL);
g_free (path);
@@ -216,7 +218,7 @@
idx = gtk_combo_box_get_active (GTK_COMBO_BOX (data->combo_box));
if (idx > 0)
- ext = mime_type_desc[save_type[idx-1]].default_ext;
+ ext = mime_type_desc[data->supported_types[idx-1]].default_ext;
else
ext = ".tar.gz";
new_path = g_strconcat (path, ext, NULL);
@@ -229,7 +231,7 @@
if (uri_exists (path)) {
GtkWidget *dialog;
- if (! is_supported_extension (data->file_sel, path)) {
+ if (! is_supported_extension (data->file_sel, path, data->supported_types)) {
dialog = _gtk_error_dialog_new (GTK_WINDOW (data->file_sel),
GTK_DIALOG_MODAL,
NULL,
@@ -350,7 +352,7 @@
basename = file_name_from_path (uri);
basename_noext = g_strndup (basename, strlen (basename) - strlen (ext));
- new_ext = mime_type_desc[save_type[idx]].default_ext;
+ new_ext = mime_type_desc[data->supported_types[idx]].default_ext;
new_basename = g_strconcat (basename_noext, new_ext, NULL);
new_basename_uft8 = g_uri_unescape_string (new_basename, NULL);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (data->file_sel), new_basename_uft8);
@@ -374,6 +376,7 @@
data = g_new0 (SaveAsData, 1);
data->window = window;
+ data->supported_types = create_type;
file_sel = gtk_file_chooser_dialog_new (_("New"),
GTK_WINDOW (window),
@@ -400,8 +403,8 @@
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All archives"));
- for (i = 0; save_type[i] != -1; i++)
- gtk_file_filter_add_mime_type (filter, mime_type_desc[save_type[i]].mime_type);
+ for (i = 0; data->supported_types[i] != -1; i++)
+ gtk_file_filter_add_mime_type (filter, mime_type_desc[data->supported_types[i]].mime_type);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_sel), filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_sel), filter);
@@ -421,9 +424,11 @@
data->combo_box = gtk_combo_box_new_text ();
gtk_combo_box_append_text (GTK_COMBO_BOX (data->combo_box), _("Automatic"));
- for (i = 0; save_type[i] != -1; i++)
+ for (i = 0; data->supported_types[i] != -1; i++) {
+ int idx = data->supported_types[i];
gtk_combo_box_append_text (GTK_COMBO_BOX (data->combo_box),
- _(mime_type_desc[save_type[i]].name));
+ _(mime_type_desc[idx].name));
+ }
gtk_combo_box_set_active (GTK_COMBO_BOX (data->combo_box), 0);
gtk_box_pack_start (GTK_BOX (hbox), data->combo_box, TRUE, TRUE, 0);
gtk_widget_show_all (hbox);
@@ -605,6 +610,7 @@
data = g_new0 (SaveAsData, 1);
data->window = window;
+ data->supported_types = save_type;
file_sel = gtk_file_chooser_dialog_new (_("Save"),
GTK_WINDOW (window),
@@ -647,8 +653,8 @@
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All archives"));
- for (i = 0; save_type[i] != -1; i++)
- gtk_file_filter_add_mime_type (filter, mime_type_desc[save_type[i]].mime_type);
+ for (i = 0; data->supported_types[i] != -1; i++)
+ gtk_file_filter_add_mime_type (filter, mime_type_desc[data->supported_types[i]].mime_type);
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_sel), filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_sel), filter);
@@ -676,9 +682,9 @@
data->combo_box = gtk_combo_box_new_text ();
gtk_combo_box_append_text (GTK_COMBO_BOX (data->combo_box), _("Automatic"));
- for (i = 0; save_type[i] != -1; i++)
+ for (i = 0; data->supported_types[i] != -1; i++)
gtk_combo_box_append_text (GTK_COMBO_BOX (data->combo_box),
- _(mime_type_desc[save_type[i]].name));
+ _(mime_type_desc[data->supported_types[i]].name));
gtk_combo_box_set_active (GTK_COMBO_BOX (data->combo_box), 0);
gtk_table_attach (GTK_TABLE (table), data->combo_box, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Thu Jun 5 16:14:26 2008
@@ -157,6 +157,7 @@
int single_file_save_type[32];
int save_type[32];
int open_type[32];
+int create_type[32];
FrCommandDescription command_desc[] = {
{ "tar", "application/x-tar", TRUE, TRUE },
@@ -687,7 +688,7 @@
compute_supported_archive_types (void)
{
int i, j;
- int sf_i = 0, s_i = 0, o_i = 0;
+ int sf_i = 0, s_i = 0, o_i = 0, c_i = 0;
int idx;
for (i = 0; i < G_N_ELEMENTS (command_desc); i++) {
@@ -707,10 +708,14 @@
if (idx >= 0) {
if (comm_desc_2.can_open)
open_type[o_i++] = idx;
- if (comm_desc_2.can_save && mime_type_desc[idx].supports_many_files)
- save_type[s_i++] = idx;
- if (comm_desc_2.can_save)
+ if (comm_desc_2.can_save) {
+ if (mime_type_desc[idx].supports_many_files) {
+ save_type[s_i++] = idx;
+ if (comm_desc_2.can_open)
+ create_type[c_i++] = idx;
+ }
single_file_save_type[sf_i++] = idx;
+ }
}
}
}
@@ -719,16 +724,21 @@
if (idx >= 0) {
if (comm_desc.can_open)
open_type[o_i++] = idx;
- if (comm_desc.can_save && mime_type_desc[idx].supports_many_files)
- save_type[s_i++] = idx;
- if (comm_desc.can_save)
+ if (comm_desc.can_save) {
+ if (mime_type_desc[idx].supports_many_files) {
+ save_type[s_i++] = idx;
+ if (comm_desc.can_open)
+ create_type[c_i++] = idx;
+ }
single_file_save_type[sf_i++] = idx;
+ }
}
}
open_type[o_i++] = -1;
save_type[s_i++] = -1;
single_file_save_type[sf_i++] = -1;
+ create_type[s_i++] = -1;
}
Modified: trunk/src/main.h
==============================================================================
--- trunk/src/main.h (original)
+++ trunk/src/main.h Thu Jun 5 16:14:26 2008
@@ -68,6 +68,7 @@
* such as gzip, compress, etc. */
extern int save_type[]; /* File types that can be saved. */
extern int open_type[]; /* File types that can be opened. */
+extern int create_type[]; /* File types that can be created. */
GType get_command_type_from_mime_type (const char *mime_type,
FrCommandCaps requested_capabilities);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]