Author: colossus
Date: 2006-11-22 07:41:29 +0000 (Wed, 22 Nov 2006)
New Revision: 23928
Modified:
xarchiver/trunk/src/callbacks.c
xarchiver/trunk/src/main.c
xarchiver/trunk/src/string_utils.c
xarchiver/trunk/src/string_utils.h
Log:
When opening an archive from the cmd-line the File Dialog is set to the
directory in which the archive is contained.
Reduced useless code in extract_local_path() by using g_path_get_dirname.
Prevent adding with drag and drop if Xarchiver is busy.
Moved strcasestr() code to string_utils.c.
Modified: xarchiver/trunk/src/callbacks.c
===================================================================
--- xarchiver/trunk/src/callbacks.c 2006-11-21 22:34:23 UTC (rev 23927)
+++ xarchiver/trunk/src/callbacks.c 2006-11-22 07:41:29 UTC (rev 23928)
@@ -38,34 +38,6 @@
GtkFileFilter *open_file_filter = NULL;
GList *Suffix , *Name;
-#ifndef HAVE_STRCASESTR
-/*
- * case-insensitive version of strstr()
- */
-const char *strcasestr(const char *haystack, const char *needle)
-{
- const char *h;
- const char *n;
-
- h = haystack;
- n = needle;
- while (*haystack)
- {
- if (tolower((unsigned char) *h) == tolower((unsigned char) *n))
- {
- h++;
- n++;
- if (!*n)
- return haystack;
- } else {
- h = ++haystack;
- n = needle;
- }
- }
- return NULL;
-}
-#endif /* !HAVE_STRCASESTR */
-
void xa_watch_child ( GPid pid, gint status, gpointer data)
{
XArchive *archive = data;
@@ -2137,12 +2109,11 @@
void drag_data_get (GtkWidget *widget, GdkDragContext *dc, GtkSelectionData
*selection_data, guint info, guint t, gpointer data)
{
GtkTreeSelection *selection;
- GtkTreeIter iter;
guchar *fm_path;
int fm_path_len;
- gchar *command , *no_uri_path , *name;
+ gchar *command , *no_uri_path;
gchar *to_send = "E";
- GList *row_list, *_row_list;
+ GList *row_list;
GString *names;
gint current_page;
gint idx;
@@ -2152,7 +2123,7 @@
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW
(archive[idx]->treeview));
- row_list = _row_list = gtk_tree_selection_get_selected_rows (selection,
NULL);
+ row_list = gtk_tree_selection_get_selected_rows (selection, NULL);
if ( row_list == NULL)
return;
if ( archive[idx]->status == XA_ARCHIVESTATUS_EXTRACT )
@@ -2189,11 +2160,7 @@
}
}
}
- gtk_tree_model_get_iter(archive[idx]->model, &iter,
(GtkTreePath*)(_row_list->data));
- gtk_tree_model_get (archive[idx]->model, &iter, 0, &name, -1);
-
- archive[idx]->extraction_path = extract_local_path (
no_uri_path , name );
- g_free (name);
+ archive[idx]->extraction_path = extract_local_path (
no_uri_path );
g_free ( no_uri_path );
if (archive[idx]->extraction_path != NULL)
to_send = "S";
@@ -2243,9 +2210,9 @@
current_page = gtk_notebook_get_current_page (notebook);
array = gtk_selection_data_get_uris ( data );
- if (array == NULL)
+ if (array == NULL || GTK_WIDGET_VISIBLE (viewport2) )
{
- response = ShowGtkMessageDialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,"",_("Sorry, I
could not perform the operation!") );
+ response = ShowGtkMessageDialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Sorry, I
could not perform the operation!"),"" );
gtk_drag_finish (context, FALSE, FALSE, time);
return;
}
Modified: xarchiver/trunk/src/main.c
===================================================================
--- xarchiver/trunk/src/main.c 2006-11-21 22:34:23 UTC (rev 23927)
+++ xarchiver/trunk/src/main.c 2006-11-22 07:41:29 UTC (rev 23928)
@@ -30,6 +30,7 @@
gboolean error_output, file_to_open, ask_and_extract, ask_and_add;
gboolean cli = FALSE;
gboolean unrar = FALSE;
+extern gchar *current_open_directory;
static GOptionEntry entries[] =
{
@@ -213,6 +214,7 @@
if ( argc == 2 )
{
gchar *dummy = g_strdup(argv[1]);
+ current_open_directory = g_path_get_dirname (dummy);
xa_open_archive ( NULL , dummy );
}
gtk_main ();
Modified: xarchiver/trunk/src/string_utils.c
===================================================================
--- xarchiver/trunk/src/string_utils.c 2006-11-21 22:34:23 UTC (rev 23927)
+++ xarchiver/trunk/src/string_utils.c 2006-11-22 07:41:29 UTC (rev 23928)
@@ -62,6 +62,34 @@
}
#endif
+#ifndef HAVE_STRCASESTR
+/*
+ * case-insensitive version of strstr()
+ */
+const char *strcasestr(const char *haystack, const char *needle)
+{
+ const char *h;
+ const char *n;
+
+ h = haystack;
+ n = needle;
+ while (*haystack)
+ {
+ if (tolower((unsigned char) *h) == tolower((unsigned char) *n))
+ {
+ h++;
+ n++;
+ if (!*n)
+ return haystack;
+ } else {
+ h = ++haystack;
+ n = needle;
+ }
+ }
+ return NULL;
+}
+#endif /* !HAVE_STRCASESTR */
+
gchar *EscapeBadChars ( gchar *string , gchar *pattern)
{
return escape_str_common (string, pattern, '\\', 0);
@@ -236,23 +264,12 @@
}
/* End code from File-Roller */
-gchar *extract_local_path (gchar *path , gchar *filename)
+gchar *extract_local_path (gchar *path)
{
gchar *local_path;
gchar *local_escaped_path;
- unsigned short int x;
- gchar *no_path = g_strrstr (filename , "/");
- if (no_path != NULL)
- {
- no_path++;
- x = strlen (path) - strlen ( no_path );
- }
- else
- x = strlen (path) - strlen ( filename );
- local_path = (gchar *) g_malloc ( x + 1);
- strncpy ( local_path, path, x );
- local_path [x] = '\000';
+ local_path = g_path_get_dirname (path);
local_escaped_path = EscapeBadChars ( local_path ,"$\'`\"\\!?*
()[]&|@#:;");
g_free (local_path);
return local_escaped_path;
Modified: xarchiver/trunk/src/string_utils.h
===================================================================
--- xarchiver/trunk/src/string_utils.h 2006-11-21 22:34:23 UTC (rev 23927)
+++ xarchiver/trunk/src/string_utils.h 2006-11-22 07:41:29 UTC (rev 23928)
@@ -19,6 +19,9 @@
#ifndef STRING_UTILS_H
#define STRING_UTILS_H
+#ifndef HAVE_STRCASESTR
+const char *strcasestr(const char *haystack, const char *needle);
+#endif
gchar *EscapeBadChars ( gchar *string , gchar *pattern);
gchar *JoinPathArchiveName ( const gchar *extract_path , gchar *path );
int CountCharacter ( gchar *string , int chr );
@@ -29,7 +32,7 @@
char *eat_spaces (char *line);
gchar *remove_level_from_path (const gchar *path);
gboolean file_extension_is (const char *filename, const char *ext);
-gchar *extract_local_path (gchar *path , gchar *filename);
+gchar *extract_local_path (gchar *path);
void xa_set_window_title ( GtkWidget *window , gchar *title);
#endif
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits