[file-roller] glib-utils: added a prefix to the functions for a better organization
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] glib-utils: added a prefix to the functions for a better organization
- Date: Wed, 20 Jun 2012 20:12:04 +0000 (UTC)
commit 1ca50af5c18bff944899dac7a847a572599a36eb
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Jun 20 16:22:39 2012 +0200
glib-utils: added a prefix to the functions for a better organization
src/actions.c | 4 +-
src/dlg-add-files.c | 2 +-
src/dlg-ask-password.c | 4 +-
src/dlg-batch-add.c | 4 +-
src/dlg-delete.c | 6 +-
src/dlg-extract.c | 7 +-
src/dlg-open-with.c | 2 +-
src/dlg-prop.c | 4 +-
src/file-data.c | 2 +-
src/file-utils.c | 35 +--
src/file-utils.h | 76 +++---
src/fr-archive.c | 44 ++--
src/fr-command-7z.c | 2 +-
src/fr-command-ace.c | 6 +-
src/fr-command-alz.c | 4 +-
src/fr-command-arj.c | 4 +-
src/fr-command-cfile.c | 2 +-
src/fr-command-cpio.c | 12 +-
src/fr-command-dpkg.c | 8 +-
src/fr-command-iso.c | 8 +-
src/fr-command-jar.c | 7 +-
src/fr-command-lha.c | 8 +-
src/fr-command-lrzip.c | 2 +-
src/fr-command-rar.c | 2 +-
src/fr-command-rpm.c | 12 +-
src/fr-command-zip.c | 8 +-
src/fr-command-zoo.c | 18 +-
src/fr-command.c | 6 +-
src/fr-init.c | 6 +-
src/fr-process.c | 16 +-
src/fr-window.c | 70 +++---
src/gio-utils.c | 34 ++--
src/glib-utils.c | 740 +++++++++++++++++++++++++-----------------------
src/glib-utils.h | 137 +++++----
src/gtk-utils.c | 16 +-
src/gtk-utils.h | 126 ++++-----
src/test-server.c | 4 +-
37 files changed, 740 insertions(+), 708 deletions(-)
---
diff --git a/src/actions.c b/src/actions.c
index 4c70e9d..ee4c82e 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -124,7 +124,7 @@ get_full_uri (DlgNewData *data)
uri_ext = get_archive_filename_extension (uri);
default_ext = mime_type_desc[data->supported_types[idx-1]].default_ext;
- if (strcmp_null_tolerant (uri_ext, default_ext) != 0) {
+ if (_g_strcmp_null_tolerant (uri_ext, default_ext) != 0) {
full_uri = g_strconcat (uri, default_ext, NULL);
g_free (uri);
}
@@ -705,7 +705,7 @@ activate_action_view_or_open (GtkAction *action,
if (file_list == NULL)
return;
fr_window_open_files (window, file_list, FALSE);
- path_list_free (file_list);
+ _g_string_list_free (file_list);
}
diff --git a/src/dlg-add-files.c b/src/dlg-add-files.c
index c762ee0..063a799 100644
--- a/src/dlg-add-files.c
+++ b/src/dlg-add-files.c
@@ -120,7 +120,7 @@ file_sel_response_cb (GtkWidget *widget,
if (item_list != NULL)
fr_window_archive_add_files (window, item_list, update);
- gio_file_list_free (item_list);
+ _g_file_list_free (item_list);
g_slist_foreach (selections, (GFunc) g_free, NULL);
g_slist_free (selections);
g_free (current_folder);
diff --git a/src/dlg-ask-password.c b/src/dlg-ask-password.c
index f46eeb1..ba2c89c 100644
--- a/src/dlg-ask-password.c
+++ b/src/dlg-ask-password.c
@@ -116,9 +116,9 @@ dlg_ask_password__common (FrWindow *window,
/* Set widgets data. */
if (data->pwd_type == FR_PASSWORD_TYPE_MAIN)
- name = g_uri_display_basename (fr_window_get_archive_uri (window));
+ name = _g_uri_display_basename (fr_window_get_archive_uri (window));
else if (data->pwd_type == FR_PASSWORD_TYPE_PASTE_FROM)
- name = g_uri_display_basename (fr_window_get_paste_archive_uri (window));
+ name = _g_uri_display_basename (fr_window_get_paste_archive_uri (window));
text = g_strdup_printf (_("Enter the password for the archive '%s'."), name);
gtk_label_set_label (GTK_LABEL (label), text);
g_free (text);
diff --git a/src/dlg-batch-add.c b/src/dlg-batch-add.c
index f39587a..c577d64 100644
--- a/src/dlg-batch-add.c
+++ b/src/dlg-batch-add.c
@@ -155,7 +155,7 @@ add_clicked_cb (GtkWidget *widget,
return;
}
- else if (strchrs (archive_name, BAD_CHARS)) {
+ else if (_g_strchrs (archive_name, BAD_CHARS)) {
GtkWidget *d;
char *utf8_name = g_filename_display_name (archive_name);
@@ -390,7 +390,7 @@ archive_type_combo_box_changed_cb (GtkComboBox *combo_box,
mime_type = mime_type_desc[data->supported_types[idx]].mime_type;
- icon = get_mime_type_pixbuf (mime_type, ARCHIVE_ICON_SIZE, NULL);
+ icon = _g_mime_type_get_icon (mime_type, ARCHIVE_ICON_SIZE, NULL);
if (icon != NULL) {
gtk_image_set_from_pixbuf (GTK_IMAGE (GET_WIDGET ("archive_icon_image")), icon);
g_object_unref (icon);
diff --git a/src/dlg-delete.c b/src/dlg-delete.c
index 1901334..401819b 100644
--- a/src/dlg-delete.c
+++ b/src/dlg-delete.c
@@ -22,8 +22,8 @@
#include <config.h>
#include <gtk/gtk.h>
#include "fr-window.h"
+#include "glib-utils.h"
#include "gtk-utils.h"
-#include "file-utils.h"
typedef struct {
@@ -44,7 +44,7 @@ static void
destroy_cb (GtkWidget *widget,
DialogData *data)
{
- path_list_free (data->selected_files);
+ _g_string_list_free (data->selected_files);
g_object_unref (G_OBJECT (data->builder));
g_free (data);
}
@@ -88,7 +88,7 @@ ok_clicked_cb (GtkWidget *widget,
if (! do_not_remove_if_null || (file_list != NULL))
fr_window_archive_remove (window, file_list);
- path_list_free (file_list);
+ _g_string_list_free (file_list);
}
diff --git a/src/dlg-extract.c b/src/dlg-extract.c
index 11718c5..f7aa106 100644
--- a/src/dlg-extract.c
+++ b/src/dlg-extract.c
@@ -25,6 +25,7 @@
#include "file-utils.h"
#include "fr-stock.h"
#include "fr-init.h"
+#include "glib-utils.h"
#include "gtk-utils.h"
#include "fr-window.h"
#include "typedefs.h"
@@ -60,7 +61,7 @@ destroy_cb (GtkWidget *widget,
fr_window_pop_message (data->window);
fr_window_stop_batch (data->window);
}
- path_list_free (data->selected_files);
+ _g_string_list_free (data->selected_files);
g_free (data->base_dir_for_selection);
g_object_unref (data->settings);
g_free (data);
@@ -162,7 +163,7 @@ extract_cb (GtkWidget *w,
/* check extraction directory permissions. */
if (uri_is_dir (extract_to_dir)
- && ! check_permissions (extract_to_dir, R_OK | W_OK))
+ && ! check_permissions (extract_to_dir, R_OK | W_OK))
{
GtkWidget *d;
char *utf8_path;
@@ -240,7 +241,7 @@ extract_cb (GtkWidget *w,
junk_paths,
TRUE);
- path_list_free (file_list);
+ _g_string_list_free (file_list);
g_free (extract_to_dir);
g_free (base_dir);
diff --git a/src/dlg-open-with.c b/src/dlg-open-with.c
index 42ac818..0d70f38 100644
--- a/src/dlg-open-with.c
+++ b/src/dlg-open-with.c
@@ -102,5 +102,5 @@ open_with_cb (GtkWidget *widget,
return;
fr_window_open_files (window, file_list, TRUE);
- path_list_free (file_list);
+ _g_string_list_free (file_list);
}
diff --git a/src/dlg-prop.c b/src/dlg-prop.c
index 4ce3ac0..1a717d8 100644
--- a/src/dlg-prop.c
+++ b/src/dlg-prop.c
@@ -81,7 +81,7 @@ dlg_prop (FrWindow *window)
/**/
label = _gtk_builder_get_widget (data->builder, "p_name_label");
- utf8_name = g_uri_display_basename (fr_window_get_archive_uri (window));
+ utf8_name = _g_uri_display_basename (fr_window_get_archive_uri (window));
gtk_label_set_text (GTK_LABEL (label), utf8_name);
title_txt = g_strdup_printf (_("%s Properties"), utf8_name);
@@ -93,7 +93,7 @@ dlg_prop (FrWindow *window)
/**/
label = _gtk_builder_get_widget (data->builder, "p_date_label");
- s = get_time_string (get_file_mtime (fr_window_get_archive_uri (window)));
+ s = _g_time_to_string (get_file_mtime (fr_window_get_archive_uri (window)));
gtk_label_set_text (GTK_LABEL (label), s);
g_free (s);
diff --git a/src/file-data.c b/src/file-data.c
index d584742..5f6f0a1 100644
--- a/src/file-data.c
+++ b/src/file-data.c
@@ -106,7 +106,7 @@ file_data_update_content_type (FileData *fdata)
if (fdata->dir)
fdata->content_type = MIME_TYPE_DIRECTORY;
else
- fdata->content_type = get_static_string (g_content_type_guess (fdata->full_path, NULL, 0, NULL));
+ fdata->content_type = _g_str_get_static (g_content_type_guess (fdata->full_path, NULL, 0, NULL));
}
diff --git a/src/file-utils.c b/src/file-utils.c
index b31e752..eb0ffdf 100644
--- a/src/file-utils.c
+++ b/src/file-utils.c
@@ -724,7 +724,7 @@ get_file_mime_type (const char *uri,
g_clear_error (&err);
}
else {
- result = get_static_string (g_file_info_get_content_type (info));
+ result = _g_str_get_static (g_file_info_get_content_type (info));
g_object_unref (info);
}
@@ -749,29 +749,6 @@ get_file_mime_type_for_path (const char *filename,
}
-void
-path_list_free (GList *path_list)
-{
- if (path_list == NULL)
- return;
- g_list_foreach (path_list, (GFunc) g_free, NULL);
- g_list_free (path_list);
-}
-
-
-GList *
-path_list_dup (GList *path_list)
-{
- GList *new_list = NULL;
- GList *scan;
-
- for (scan = path_list; scan; scan = scan->next)
- new_list = g_list_prepend (new_list, g_strdup (scan->data));
-
- return g_list_reverse (new_list);
-}
-
-
guint64
get_dest_free_space (const char *path)
{
@@ -874,7 +851,7 @@ remove_local_directory (const char *path)
if (path == NULL)
return TRUE;
-
+
uri = g_filename_to_uri (path, NULL, NULL);
result = remove_directory (uri);
g_free (uri);
@@ -1313,7 +1290,7 @@ int
uricmp (const char *uri1,
const char *uri2)
{
- return strcmp_null_tolerant (uri1, uri2);
+ return _g_strcmp_null_tolerant (uri1, uri2);
}
@@ -1352,7 +1329,7 @@ get_alternative_uri_for_uri (const char *uri)
GList *
-gio_file_list_dup (GList *l)
+_g_file_list_dup (GList *l)
{
GList *r = NULL, *scan;
for (scan = l; scan; scan = scan->next)
@@ -1362,7 +1339,7 @@ gio_file_list_dup (GList *l)
void
-gio_file_list_free (GList *l)
+_g_file_list_free (GList *l)
{
GList *scan;
for (scan = l; scan; scan = scan->next)
@@ -1372,7 +1349,7 @@ gio_file_list_free (GList *l)
GList *
-gio_file_list_new_from_uri_list (GList *uris)
+_g_file_list_new_from_uri_list (GList *uris)
{
GList *r = NULL, *scan;
for (scan = uris; scan; scan = scan->next)
diff --git a/src/file-utils.h b/src/file-utils.h
index d51a325..94b6474 100644
--- a/src/file-utils.h
+++ b/src/file-utils.h
@@ -85,47 +85,49 @@ gboolean is_temp_dir (const char *dir);
/* misc functions used to parse a command output lines. */
-gboolean file_list__match_pattern (const char *line,
- const char *pattern);
-int file_list__get_index_from_pattern (const char *line,
- const char *pattern);
-char* file_list__get_next_field (const char *line,
- int start_from,
- int field_n);
-char* file_list__get_prev_field (const char *line,
- int start_from,
- int field_n);
-gboolean check_permissions (const char *path,
- int mode);
-gboolean check_file_permissions (GFile *file,
- int mode);
-gboolean is_program_in_path (const char *filename);
-gboolean is_program_available (const char *filename,
- gboolean check);
+gboolean file_list__match_pattern (const char *line,
+ const char *pattern);
+int file_list__get_index_from_pattern (const char *line,
+ const char *pattern);
+char* file_list__get_next_field (const char *line,
+ int start_from,
+ int field_n);
+char* file_list__get_prev_field (const char *line,
+ int start_from,
+ int field_n);
+gboolean check_permissions (const char *path,
+ int mode);
+gboolean check_file_permissions (GFile *file,
+ int mode);
+gboolean is_program_in_path (const char *filename);
+gboolean is_program_available (const char *filename,
+ gboolean check);
/* URI utils */
-const char * get_home_uri (void);
-char * get_home_relative_uri (const char *partial_uri);
-GFile * get_home_relative_file (const char *partial_uri);
-GFile * get_user_config_subdirectory (const char *child_name,
- gboolean create_);
-const char * remove_host_from_uri (const char *uri);
-char * get_uri_host (const char *uri);
-char * get_uri_root (const char *uri);
-int uricmp (const char *uri1,
- const char *uri2);
-char * get_alternative_uri (const char *folder,
- const char *name);
-char * get_alternative_uri_for_uri (const char *uri);
+const char * get_home_uri (void);
+char * get_home_relative_uri (const char *partial_uri);
+GFile * get_home_relative_file (const char *partial_uri);
+GFile * get_user_config_subdirectory (const char *child_name,
+ gboolean create_);
+const char * remove_host_from_uri (const char *uri);
+char * get_uri_host (const char *uri);
+char * get_uri_root (const char *uri);
+int uricmp (const char *uri1,
+ const char *uri2);
+char * get_alternative_uri (const char *folder,
+ const char *name);
+char * get_alternative_uri_for_uri (const char *uri);
-void path_list_free (GList *path_list);
-GList * path_list_dup (GList *path_list);
+/* GFile utils */
-GList * gio_file_list_dup (GList *l);
-void gio_file_list_free (GList *l);
-GList * gio_file_list_new_from_uri_list (GList *uris);
-void g_key_file_save (GKeyFile *key_file,
- GFile *file);
+GList * _g_file_list_dup (GList *l);
+void _g_file_list_free (GList *l);
+GList * _g_file_list_new_from_uri_list (GList *uris);
+
+/* GKeyFile utils */
+
+void g_key_file_save (GKeyFile *key_file,
+ GFile *file);
#endif /* FILE_UTILS_H */
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 9914026..1728627 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -81,7 +81,7 @@ dropped_items_data_new (FrArchive *archive,
data = g_new0 (DroppedItemsData, 1);
data->archive = archive;
- data->item_list = path_list_dup (item_list);
+ data->item_list = _g_string_list_dup (item_list);
if (base_dir != NULL)
data->base_dir = g_strdup (base_dir);
if (dest_dir != NULL)
@@ -102,7 +102,7 @@ dropped_items_data_free (DroppedItemsData *data)
{
if (data == NULL)
return;
- path_list_free (data->item_list);
+ _g_string_list_free (data->item_list);
g_free (data->base_dir);
g_free (data->dest_dir);
g_free (data->password);
@@ -152,7 +152,7 @@ xfer_data_free (XferData *data)
g_free (data->uri);
g_free (data->password);
- path_list_free (data->file_list);
+ _g_string_list_free (data->file_list);
g_free (data->base_uri);
g_free (data->dest_dir);
g_free (data->tmp_dir);
@@ -503,7 +503,7 @@ get_mime_type_from_content (GFile *file)
g_clear_error (&err);
}
else {
- content_type = get_static_string (g_file_info_get_content_type (info));
+ content_type = _g_str_get_static (g_file_info_get_content_type (info));
g_object_unref (info);
}
@@ -1458,7 +1458,7 @@ save_list_to_temp_file (GList *file_list,
for (scan = file_list; scan != NULL; scan = scan->next) {
char *filename = scan->data;
- filename = str_substitute (filename, "\n", "\\n");
+ filename = _g_str_substitute (filename, "\n", "\\n");
if ((g_output_stream_write (G_OUTPUT_STREAM (ostream), filename, strlen (filename), NULL, error) < 0)
|| (g_output_stream_write (G_OUTPUT_STREAM (ostream), "\n", 1, NULL, error) < 0))
{
@@ -1581,7 +1581,7 @@ fr_archive_add (FrArchive *archive,
}
else {
tmp_base_dir = g_strdup (base_dir);
- new_file_list = path_list_dup (file_list);
+ new_file_list = _g_string_list_dup (file_list);
}
/* if the command cannot update, get the list of files that are
@@ -1592,7 +1592,7 @@ fr_archive_add (FrArchive *archive,
tmp_file_list = new_file_list;
new_file_list = newer_files_only (archive, tmp_file_list, tmp_base_dir);
- path_list_free (tmp_file_list);
+ _g_string_list_free (tmp_file_list);
}
if (new_file_list == NULL) {
@@ -1740,7 +1740,7 @@ fr_archive_add (FrArchive *archive,
g_list_free (chunks);
}
- path_list_free (new_file_list);
+ _g_string_list_free (new_file_list);
if (! error_occurred) {
fr_command_recompress (archive->command);
@@ -1878,8 +1878,8 @@ copy_remote_files (FrArchive *archive,
if (! ensure_dir_exists (local_folder_uri, 0755, &error)) {
g_free (local_folder_uri);
g_free (local_uri);
- gio_file_list_free (sources);
- gio_file_list_free (destinations);
+ _g_file_list_free (sources);
+ _g_file_list_free (destinations);
g_hash_table_destroy (created_folders);
fr_archive_action_completed (archive,
@@ -1906,7 +1906,7 @@ copy_remote_files (FrArchive *archive,
xfer_data = g_new0 (XferData, 1);
xfer_data->archive = archive;
- xfer_data->file_list = path_list_dup (file_list);
+ xfer_data->file_list = _g_string_list_dup (file_list);
xfer_data->base_uri = g_strdup (base_uri);
xfer_data->dest_dir = g_strdup (dest_dir);
xfer_data->update = update;
@@ -1932,8 +1932,8 @@ copy_remote_files (FrArchive *archive,
copy_remote_files_done,
xfer_data);
- gio_file_list_free (sources);
- gio_file_list_free (destinations);
+ _g_file_list_free (sources);
+ _g_file_list_free (destinations);
}
@@ -2042,8 +2042,8 @@ add_with_wildcard__step2 (GList *file_list,
aww_data->compression,
aww_data->volume_size);
- path_list_free (file_list);
- path_list_free (dirs_list);
+ _g_string_list_free (file_list);
+ _g_string_list_free (dirs_list);
add_with_wildcard_data_free (aww_data);
}
@@ -2147,7 +2147,7 @@ add_directory__step2 (GList *file_list,
if (archive->command->propAddCanStoreFolders)
file_list = g_list_concat (file_list, dir_list);
else
- path_list_free (dir_list);
+ _g_string_list_free (dir_list);
if (file_list != NULL) {
fr_archive_add_files (ad_data->archive,
@@ -2159,7 +2159,7 @@ add_directory__step2 (GList *file_list,
ad_data->encrypt_header,
ad_data->compression,
ad_data->volume_size);
- path_list_free (file_list);
+ _g_string_list_free (file_list);
}
add_directory_data_free (ad_data);
@@ -2380,7 +2380,7 @@ add_dropped_items (DroppedItemsData *data)
data->compression,
data->volume_size);
- path_list_free (only_names_list);
+ _g_string_list_free (only_names_list);
g_free (first_basedir);
return;
@@ -2419,7 +2419,7 @@ add_dropped_items (DroppedItemsData *data)
fr_command_recompress (archive->command);
fr_process_start (archive->process);
- path_list_free (data->item_list);
+ _g_string_list_free (data->item_list);
data->item_list = NULL;
}
@@ -3114,7 +3114,7 @@ fr_archive_extract_to_local (FrArchive *archive,
g_list_free (filtered);
if (file_list_created)
- path_list_free (file_list);
+ _g_string_list_free (file_list);
return;
}
@@ -3190,7 +3190,7 @@ fr_archive_extract_to_local (FrArchive *archive,
debug (DEBUG_INFO, "All files got filtered, nothing to do.\n");
if (extract_all)
- path_list_free (file_list);
+ _g_string_list_free (file_list);
return;
}
@@ -3239,7 +3239,7 @@ fr_archive_extract_to_local (FrArchive *archive,
if (filtered != NULL)
g_list_free (filtered);
if (file_list_created)
- path_list_free (file_list);
+ _g_string_list_free (file_list);
}
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index dd3e62d..d655b36 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -100,7 +100,7 @@ list__process_line (char *line,
int ver_len;
char version[256];
- ver_start = eat_spaces (line + 14);
+ ver_start = _g_str_eat_spaces (line + 14);
ver_len = strchr (ver_start, ' ') - ver_start;
strncpy (version, ver_start, ver_len);
version[ver_len] = 0;
diff --git a/src/fr-command-ace.c b/src/fr-command-ace.c
index 0c30660..8c250f1 100644
--- a/src/fr-command-ace.c
+++ b/src/fr-command-ace.c
@@ -124,9 +124,9 @@ process_line (char *line,
if (ace_comm->command_type == FR_ACE_COMMAND_PUBLIC)
fields = g_strsplit (line, "|", 6);
else if (ace_comm->command_type == FR_ACE_COMMAND_NONFREE)
- fields = split_line (line, 5);
+ fields = _g_str_split_line (line, 5);
- if ((fields == NULL) || (fields[0] == NULL) || (n_fields (fields) < 5))
+ if ((fields == NULL) || (fields[0] == NULL) || (g_strv_length (fields) < 5))
return;
fdata->size = g_ascii_strtoull (fields[3], NULL, 10);
@@ -137,7 +137,7 @@ process_line (char *line,
field_name = field_name + 1;
}
else if (ace_comm->command_type == FR_ACE_COMMAND_NONFREE)
- field_name = get_last_field (line, 6);
+ field_name = _g_str_get_last_field (line, 6);
if (field_name[0] != '/') {
fdata->full_path = g_strconcat ("/", field_name, NULL);
diff --git a/src/fr-command-alz.c b/src/fr-command-alz.c
index e4f4fff..dc54160 100644
--- a/src/fr-command-alz.c
+++ b/src/fr-command-alz.c
@@ -109,11 +109,11 @@ process_line (char *line,
return;
fdata = file_data_new ();
- fields = split_line (line, 5);
+ fields = _g_str_split_line (line, 5);
fdata->modified = mktime_from_string (fields[0], fields[1]);
fdata->size = g_ascii_strtoull (fields[3], NULL, 10);
- name_field = g_strdup (get_last_field (line, 6));
+ name_field = g_strdup (_g_str_get_last_field (line, 6));
name_len = strlen (name_field);
name_last = name_field[name_len - 1];
diff --git a/src/fr-command-arj.c b/src/fr-command-arj.c
index b034d26..e296670 100644
--- a/src/fr-command-arj.c
+++ b/src/fr-command-arj.c
@@ -114,7 +114,7 @@ list__process_line (char *line,
arj_comm->fdata = fdata = file_data_new ();
- name_field = get_last_field (line, 2);
+ name_field = _g_str_get_last_field (line, 2);
if (*name_field == '/') {
fdata->full_path = g_strdup (name_field);
@@ -138,7 +138,7 @@ list__process_line (char *line,
/* read file info. */
- fields = split_line (line, 10);
+ fields = _g_str_split_line (line, 10);
fdata->size = g_ascii_strtoull (fields[2], NULL, 10);
fdata->modified = mktime_from_string (fields[5], fields[6]);
if ((strcmp (fields[1], "MS-DOS") == 0) || (strcmp (fields[1], "WIN32") == 0))
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index d2f9812..cb23cad 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -103,7 +103,7 @@ list__process_line (char *line,
fdata = file_data_new ();
- fields = split_line (line, 2);
+ fields = _g_str_split_line (line, 2);
if (strcmp (fields[1], "-1") != 0)
fdata->size = g_ascii_strtoull (fields[1], NULL, 10);
g_strfreev (fields);
diff --git a/src/fr-command-cpio.c b/src/fr-command-cpio.c
index b90d7ff..907bbe1 100644
--- a/src/fr-command-cpio.c
+++ b/src/fr-command-cpio.c
@@ -65,7 +65,7 @@ mktime_from_string (char *month,
tm.tm_mday = atoi (mday);
if (strchr (year, ':') != NULL) {
char **fields = g_strsplit (year, ":", 2);
- if (n_fields (fields) == 2) {
+ if (g_strv_length (fields) == 2) {
time_t now;
struct tm *now_tm;
@@ -99,28 +99,28 @@ list__process_line (char *line,
fdata = file_data_new ();
#ifdef __sun
- fields = split_line (line, 9);
+ fields = _g_str_split_line (line, 9);
fdata->size = g_ascii_strtoull (fields[4], NULL, 10);
fdata->modified = mktime_from_string (fields[5], fields[6], fields[8]);
g_strfreev (fields);
- name_field = get_last_field (line, 10);
+ name_field = _g_str_get_last_field (line, 10);
#else /* !__sun */
/* Handle char and block device files */
if ((line[0] == 'c') || (line[0] == 'b')) {
- fields = split_line (line, 9);
+ fields = _g_str_split_line (line, 9);
ofs = 1;
fdata->size = 0;
/* FIXME: We should also specify the content type */
}
else {
- fields = split_line (line, 8);
+ fields = _g_str_split_line (line, 8);
fdata->size = g_ascii_strtoull (fields[4], NULL, 10);
}
fdata->modified = mktime_from_string (fields[5+ofs], fields[6+ofs], fields[7+ofs]);
g_strfreev (fields);
- name_field = get_last_field (line, 9+ofs);
+ name_field = _g_str_get_last_field (line, 9+ofs);
#endif /* !__sun */
fields = g_strsplit (name_field, " -> ", 2);
diff --git a/src/fr-command-dpkg.c b/src/fr-command-dpkg.c
index 22e68dd..9191a58 100644
--- a/src/fr-command-dpkg.c
+++ b/src/fr-command-dpkg.c
@@ -50,7 +50,7 @@ process_metadata_line (char *line,
g_return_if_fail (line != NULL);
- fields = split_line (line, 6);
+ fields = _g_str_split_line (line, 6);
if (!fields[1] || !g_str_equal (fields[1], "bytes,")) {
g_strfreev (fields);
return;
@@ -62,7 +62,7 @@ process_metadata_line (char *line,
if (fields[5] && g_str_equal (fields[4],"*")) {
name = g_strdup (fields[5]);
} else {
- name = g_strdup (get_last_field (line, 5));
+ name = g_strdup (_g_str_get_last_field (line, 5));
}
g_strstrip (name);
@@ -98,7 +98,7 @@ process_data_line (char *line,
fdata = file_data_new ();
- fields = split_line (line, 5);
+ fields = _g_str_split_line (line, 5);
fdata->size = g_ascii_strtoull (fields[2], NULL, 10);
tmfields = g_strsplit(fields[3], "-", 3);
if (tmfields[2]) {
@@ -116,7 +116,7 @@ process_data_line (char *line,
fdata->modified = mktime (&tm);
g_strfreev (fields);
- name = get_last_field (line, 6);
+ name = _g_str_get_last_field (line, 6);
fields = g_strsplit (name, " -> ", 2);
fdata->dir = line[0] == 'd';
diff --git a/src/fr-command-iso.c b/src/fr-command-iso.c
index 3ad7463..4d505d7 100644
--- a/src/fr-command-iso.c
+++ b/src/fr-command-iso.c
@@ -84,28 +84,28 @@ list__process_line (char *line,
if (line[0] == 'D') {
g_free (comm_iso->cur_path);
- comm_iso->cur_path = g_strdup (get_last_field (line, 4));
+ comm_iso->cur_path = g_strdup (_g_str_get_last_field (line, 4));
} else if (line[0] == '-') { /* Is file */
const char *last_field, *first_bracket;
fdata = file_data_new ();
- fields = split_line (line, 8);
+ fields = _g_str_split_line (line, 8);
fdata->size = g_ascii_strtoull (fields[4], NULL, 10);
fdata->modified = mktime_from_string (fields[5], fields[6], fields[7]);
g_strfreev (fields);
/* Full path */
- last_field = get_last_field (line, 9);
+ last_field = _g_str_get_last_field (line, 9);
first_bracket = strchr (last_field, ']');
if (first_bracket == NULL) {
file_data_free (fdata);
return;
}
- name_field = eat_spaces (first_bracket + 1);
+ name_field = _g_str_eat_spaces (first_bracket + 1);
if ((name_field == NULL)
|| (strcmp (name_field, ".") == 0)
|| (strcmp (name_field, "..") == 0)) {
diff --git a/src/fr-command-jar.c b/src/fr-command-jar.c
index 17f23ab..fc7701c 100644
--- a/src/fr-command-jar.c
+++ b/src/fr-command-jar.c
@@ -28,6 +28,7 @@
#include "fr-command.h"
#include "fr-command-zip.h"
#include "fr-command-jar.h"
+#include "glib-utils.h"
#include "java-utils.h"
@@ -138,9 +139,9 @@ fr_command_jar_add (FrCommand *comm,
g_free (jdata->rel_path);
}
- path_list_free (jardata_list);
- path_list_free (jar_list);
- path_list_free (zip_list);
+ _g_string_list_free (jardata_list);
+ _g_string_list_free (jar_list);
+ _g_string_list_free (zip_list);
g_free (tmp_dir);
}
diff --git a/src/fr-command-lha.c b/src/fr-command-lha.c
index 5c0b1a8..d7c1bd0 100644
--- a/src/fr-command-lha.c
+++ b/src/fr-command-lha.c
@@ -120,12 +120,12 @@ split_line_lha (char *line)
line += strlen ("[unknown]");
}
- scan = eat_spaces (line);
+ scan = _g_str_eat_spaces (line);
for (; i < n_fields; i++) {
field_end = strchr (scan, ' ');
if (field_end != NULL) {
fields[i] = g_strndup (scan, field_end - scan);
- scan = eat_spaces (field_end);
+ scan = _g_str_eat_spaces (field_end);
}
}
@@ -149,10 +149,10 @@ get_last_field_lha (char *line)
if (strncmp (line, "[unknown]", 9) == 0)
n--;
- field = eat_spaces (line);
+ field = _g_str_eat_spaces (line);
for (i = 0; i < n; i++) {
field = strchr (field, ' ');
- field = eat_spaces (field);
+ field = _g_str_eat_spaces (field);
}
return field;
diff --git a/src/fr-command-lrzip.c b/src/fr-command-lrzip.c
index 80f8862..ddbd397 100644
--- a/src/fr-command-lrzip.c
+++ b/src/fr-command-lrzip.c
@@ -48,7 +48,7 @@ list__process_line (char *line,
return;
fdata = file_data_new ();
- fdata->size = g_ascii_strtoull (get_last_field (line, 4), NULL, 10);
+ fdata->size = g_ascii_strtoull (_g_str_get_last_field (line, 4), NULL, 10);
struct stat st;
if (stat (comm->filename, &st) == 0)
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index ed878ab..721b857 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -124,7 +124,7 @@ process_line (char *line,
/* read file info. */
- fields = split_line (line, 6);
+ fields = _g_str_split_line (line, 6);
if (g_strv_length (fields) < 6) {
/* wrong line format, treat this line as a filename line */
g_strfreev (fields);
diff --git a/src/fr-command-rpm.c b/src/fr-command-rpm.c
index 81574b0..739399d 100644
--- a/src/fr-command-rpm.c
+++ b/src/fr-command-rpm.c
@@ -72,7 +72,7 @@ mktime_from_string (char *month,
if (year != NULL) {
if (strchr (year, ':') != NULL) {
char **fields = g_strsplit (year, ":", 2);
- if (n_fields (fields) == 2) {
+ if (g_strv_length (fields) == 2) {
time_t now;
struct tm *now_tm;
@@ -108,28 +108,28 @@ list__process_line (char *line,
fdata = file_data_new ();
#ifdef __sun
- fields = split_line (line, 9);
+ fields = _g_str_split_line (line, 9);
fdata->size = g_ascii_strtoull (fields[4], NULL, 10);
fdata->modified = mktime_from_string (fields[5], fields[6], fields[8]);
g_strfreev (fields);
- name_field = get_last_field (line, 10);
+ name_field = _g_str_get_last_field (line, 10);
#else /* !__sun */
/* Handle char and block device files */
if ((line[0] == 'c') || (line[0] == 'b')) {
- fields = split_line (line, 9);
+ fields = _g_str_split_line (line, 9);
ofs = 1;
fdata->size = 0;
/* TODO We should also specify the content type */
}
else {
- fields = split_line (line, 8);
+ fields = _g_str_split_line (line, 8);
fdata->size = g_ascii_strtoull (fields[4], NULL, 10);
}
fdata->modified = mktime_from_string (fields[5+ofs], fields[6+ofs], fields[7+ofs]);
g_strfreev (fields);
- name_field = get_last_field (line, 9+ofs);
+ name_field = _g_str_get_last_field (line, 9+ofs);
#endif /* !__sun */
fields = g_strsplit (name_field, " -> ", 2);
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index 650f8bf..abcc6ed 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -127,7 +127,7 @@ list__process_line (char *line,
fdata = file_data_new ();
- fields = split_line (line, 7);
+ fields = _g_str_split_line (line, 7);
fdata->size = g_ascii_strtoull (fields[3], NULL, 10);
fdata->modified = mktime_from_string (fields[6]);
fdata->encrypted = (*fields[4] == 'B') || (*fields[4] == 'T');
@@ -135,7 +135,7 @@ list__process_line (char *line,
/* Full path */
- name_field = get_last_field (line, 8);
+ name_field = _g_str_get_last_field (line, 8);
if (*name_field == '/') {
fdata->full_path = g_strdup (name_field);
@@ -282,7 +282,7 @@ fr_command_zip_delete (FrCommand *comm,
for (scan = file_list; scan; scan = scan->next) {
char *escaped;
- escaped = escape_str (scan->data, ZIP_SPECIAL_CHARACTERS);
+ escaped = _g_str_escape (scan->data, ZIP_SPECIAL_CHARACTERS);
fr_process_add_arg (comm->process, escaped);
g_free (escaped);
}
@@ -328,7 +328,7 @@ fr_command_zip_extract (FrCommand *comm,
for (scan = file_list; scan; scan = scan->next) {
char *escaped;
- escaped = escape_str (scan->data, ZIP_SPECIAL_CHARACTERS);
+ escaped = _g_str_escape (scan->data, ZIP_SPECIAL_CHARACTERS);
fr_process_add_arg (comm->process, escaped);
g_free (escaped);
}
diff --git a/src/fr-command-zoo.c b/src/fr-command-zoo.c
index fbc1e5a..4f0f0f5 100644
--- a/src/fr-command-zoo.c
+++ b/src/fr-command-zoo.c
@@ -121,15 +121,15 @@ split_line_zoo (char *line)
fields[5] = NULL;
/* Get Length */
- scan = eat_spaces (line);
+ scan = _g_str_eat_spaces (line);
field_end = strchr (scan, ' ');
fields[0] = g_strndup (scan, field_end - scan);
- scan = eat_spaces (field_end);
+ scan = _g_str_eat_spaces (field_end);
/* Toss CF, Size Now */
for (i = 0; i < 2; i++) {
field_end = strchr (scan, ' ');
- scan = eat_spaces (field_end);
+ scan = _g_str_eat_spaces (field_end);
}
/* Get Day, Month, Year, Time */
@@ -140,7 +140,7 @@ split_line_zoo (char *line)
}
field_end = strchr (scan, ' ');
fields[i] = g_strndup (scan, field_end - scan);
- scan = eat_spaces (field_end);
+ scan = _g_str_eat_spaces (field_end);
}
return fields;
@@ -154,18 +154,18 @@ get_last_field_zoo (char *line)
int i;
int n = 6;
- field = eat_spaces (line);
+ field = _g_str_eat_spaces (line);
for (i = 0; i < n; i++) {
field = strchr (field, ' ');
- field = eat_spaces (field);
+ field = _g_str_eat_spaces (field);
}
field = strchr (field, ' ');
if (g_ascii_strncasecmp (field, " C ", 3) == 0) {
- field = eat_spaces (field);
+ field = _g_str_eat_spaces (field);
field = strchr (field, ' ');
- field = eat_spaces (field);
+ field = _g_str_eat_spaces (field);
} else
- field = eat_spaces (field);
+ field = _g_str_eat_spaces (field);
return field;
}
diff --git a/src/fr-command.c b/src/fr-command.c
index 6d13d84..325297c 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -191,7 +191,7 @@ static void
base_fr_command_set_mime_type (FrCommand *comm,
const char *mime_type)
{
- comm->mime_type = get_static_string (mime_type);
+ comm->mime_type = _g_str_get_static (mime_type);
fr_command_update_capabilities (comm);
}
@@ -535,7 +535,7 @@ fr_command_finalize (GObject *object)
g_free (comm->e_filename);
g_free (comm->password);
if (comm->files != NULL)
- g_ptr_array_free_full (comm->files, (GFunc) file_data_free, NULL);
+ _g_ptr_array_free_full (comm->files, (GFunc) file_data_free, NULL);
fr_command_set_process (comm, NULL);
/* Chain up */
@@ -614,7 +614,7 @@ fr_command_list (FrCommand *comm)
fr_command_progress (comm, -1.0);
if (comm->files != NULL) {
- g_ptr_array_free_full (comm->files, (GFunc) file_data_free, NULL);
+ _g_ptr_array_free_full (comm->files, (GFunc) file_data_free, NULL);
comm->files = g_ptr_array_sized_new (INITIAL_SIZE);
}
diff --git a/src/fr-init.c b/src/fr-init.c
index ba066b3..13fc0ba 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -221,7 +221,7 @@ fr_registered_command_new (GType command_type)
FrMimeTypeCap *cap;
FrMimeTypePackages *packages;
- mime_type = get_static_string (mime_types[i]);
+ mime_type = _g_str_get_static (mime_types[i]);
cap = g_new0 (FrMimeTypeCap, 1);
cap->mime_type = mime_type;
@@ -443,7 +443,7 @@ get_mime_type_from_extension (const char *ext)
if (file_ext_type[i].ext == NULL)
continue;
if (strcasecmp (ext, file_ext_type[i].ext) == 0)
- return get_static_string (file_ext_type[i].mime_type);
+ return _g_str_get_static (file_ext_type[i].mime_type);
}
return NULL;
@@ -640,7 +640,7 @@ command_done (CommandData *cdata)
g_free (cdata->command);
if (cdata->app != NULL)
g_object_unref (cdata->app);
- path_list_free (cdata->file_list);
+ _g_string_list_free (cdata->file_list);
g_free (cdata->temp_dir);
if (cdata->process != NULL)
g_object_unref (cdata->process);
diff --git a/src/fr-process.c b/src/fr-process.c
index 8b9f8ba..1ed0dc7 100644
--- a/src/fr-process.c
+++ b/src/fr-process.c
@@ -359,8 +359,8 @@ fr_process_finalize (GObject *object)
g_clear_error (&process->error.gerror);
g_clear_error (&process->priv->first_error.gerror);
- path_list_free (process->priv->first_error_stdout);
- path_list_free (process->priv->first_error_stderr);
+ _g_string_list_free (process->priv->first_error_stdout);
+ _g_string_list_free (process->priv->first_error_stderr);
g_free (process->priv);
@@ -769,11 +769,11 @@ allow_sticky_processes_only (FrProcess *process,
if (process->error.gerror != NULL)
process->priv->first_error.gerror = g_error_copy (process->error.gerror);
- path_list_free (process->priv->first_error_stdout);
- process->priv->first_error_stdout = g_list_reverse (path_list_dup (process->out.raw));
+ _g_string_list_free (process->priv->first_error_stdout);
+ process->priv->first_error_stdout = g_list_reverse (_g_string_list_dup (process->out.raw));
- path_list_free (process->priv->first_error_stderr);
- process->priv->first_error_stderr = g_list_reverse (path_list_dup (process->err.raw));
+ _g_string_list_free (process->priv->first_error_stderr);
+ process->priv->first_error_stderr = g_list_reverse (_g_string_list_dup (process->err.raw));
}
process->priv->sticky_only = TRUE;
@@ -948,11 +948,11 @@ check_child (gpointer data)
/* Restore the first error output as well. */
- path_list_free (process->out.raw);
+ _g_string_list_free (process->out.raw);
process->out.raw = process->priv->first_error_stdout;
process->priv->first_error_stdout = NULL;
- path_list_free (process->err.raw);
+ _g_string_list_free (process->err.raw);
process->err.raw = process->priv->first_error_stderr;
process->priv->first_error_stderr = NULL;
}
diff --git a/src/fr-window.c b/src/fr-window.c
index fd1d721..f263bbd 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -483,7 +483,7 @@ static void
fr_window_history_clear (FrWindow *window)
{
if (window->priv->history != NULL)
- path_list_free (window->priv->history);
+ _g_string_list_free (window->priv->history);
window->priv->history = NULL;
window->priv->history_current = NULL;
g_free (window->priv->last_location);
@@ -590,7 +590,7 @@ fr_window_free_private_data (FrWindow *window)
fr_window_convert_data_free (window, TRUE);
g_clear_error (&window->priv->drag_error);
- path_list_free (window->priv->drag_file_list);
+ _g_string_list_free (window->priv->drag_file_list);
window->priv->drag_file_list = NULL;
if (window->priv->file_popup_menu != NULL) {
@@ -1266,7 +1266,7 @@ get_mime_type_icon (const char *mime_type)
return pixbuf;
}
- pixbuf = get_mime_type_pixbuf (mime_type, file_list_icon_size, icon_theme);
+ pixbuf = _g_mime_type_get_icon (mime_type, file_list_icon_size, icon_theme);
if (pixbuf == NULL)
return NULL;
@@ -1300,7 +1300,7 @@ get_icon (GtkWidget *widget,
}
icon = g_content_type_get_icon (content_type);
- pixbuf = get_icon_pixbuf (icon, file_list_icon_size, icon_theme);
+ pixbuf = _g_icon_get_pixbuf (icon, file_list_icon_size, icon_theme);
g_object_unref (icon);
if (pixbuf == NULL)
@@ -1574,7 +1574,7 @@ fr_window_populate_file_list (FrWindow *window,
if (fdata->list_dir)
s_time = g_strdup ("");
else
- s_time = get_time_string (fdata->modified);
+ s_time = _g_time_to_string (fdata->modified);
gtk_list_store_set (window->priv->list_store, &iter,
COLUMN_FILE_DATA, fdata,
@@ -1599,7 +1599,7 @@ fr_window_populate_file_list (FrWindow *window,
utf8_path = g_filename_display_name (fdata->path);
s_size = g_format_size (fdata->size);
- s_time = get_time_string (fdata->modified);
+ s_time = _g_time_to_string (fdata->modified);
desc = g_content_type_get_description (fdata->content_type);
gtk_list_store_set (window->priv->list_store, &iter,
@@ -1811,7 +1811,7 @@ fr_window_update_dir_tree (FrWindow *window)
char *name;
uri = g_file_get_uri (window->archive->file);
- name = g_uri_display_basename (uri);
+ name = _g_uri_display_basename (uri);
gtk_tree_store_append (window->priv->tree_store, &node, NULL);
gtk_tree_store_set (window->priv->tree_store, &node,
@@ -1975,7 +1975,7 @@ fr_window_update_title (FrWindow *window)
char *title;
char *name;
- name = g_uri_display_basename (fr_window_get_archive_uri (window));
+ name = _g_uri_display_basename (fr_window_get_archive_uri (window));
title = g_strdup_printf ("%s %s",
name,
window->archive->read_only ? _("[read only]") : "");
@@ -2295,7 +2295,7 @@ get_action_description (FrAction action,
char *basename;
char *message;
- basename = (uri != NULL) ? g_uri_display_basename (uri) : NULL;
+ basename = (uri != NULL) ? _g_uri_display_basename (uri) : NULL;
message = NULL;
switch (action) {
@@ -2905,7 +2905,7 @@ handle_errors (FrWindow *window,
case FR_ACTION_LOADING_ARCHIVE:
dialog_parent = window->priv->load_error_parent_window;
- utf8_name = g_uri_display_basename (window->priv->archive_uri);
+ utf8_name = _g_uri_display_basename (window->priv->archive_uri);
msg = g_strdup_printf (_("Could not open \"%s\""), utf8_name);
g_free (utf8_name);
break;
@@ -3320,7 +3320,7 @@ fr_window_get_folder_tree_selection (FrWindow *window,
if (recursive)
list = g_list_concat (list, get_dir_list_from_path (window, path));
}
- path_list_free (selections);
+ _g_string_list_free (selections);
return g_list_reverse (list);
}
@@ -3395,7 +3395,7 @@ fr_window_get_file_list_pattern (FrWindow *window,
g_return_val_if_fail (window != NULL, NULL);
- regexps = search_util_get_regexps (pattern, G_REGEX_CASELESS);
+ regexps = _g_regexp_split_from_patterns (pattern, G_REGEX_CASELESS);
list = NULL;
for (i = 0; i < window->archive->command->files->len; i++) {
FileData *fd = g_ptr_array_index (window->archive->command->files, i);
@@ -3407,11 +3407,11 @@ fr_window_get_file_list_pattern (FrWindow *window,
continue;
utf8_name = g_filename_to_utf8 (fd->name, -1, NULL, NULL, NULL);
- if (match_regexps (regexps, utf8_name, 0))
+ if (_g_regexp_matchv (regexps, utf8_name, 0))
list = g_list_prepend (list, g_strdup (fd->original_path));
g_free (utf8_name);
}
- free_regexps (regexps);
+ _g_regexp_freev (regexps);
return g_list_reverse (list);
}
@@ -3420,7 +3420,7 @@ fr_window_get_file_list_pattern (FrWindow *window,
int
fr_window_get_n_selected_files (FrWindow *window)
{
- return _gtk_count_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)));
+ return _gtk_tree_selection_count_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)));
}
@@ -4040,8 +4040,8 @@ fr_window_drag_data_received (GtkWidget *widget,
fr_window_free_batch_data (window);
fr_window_append_batch_action (window,
FR_BATCH_ACTION_ADD,
- path_list_dup (list),
- (GFreeFunc) path_list_free);
+ _g_string_list_dup (list),
+ (GFreeFunc) _g_string_list_free);
first_item = (char*) list->data;
folder = remove_level_from_path (first_item);
@@ -4074,7 +4074,7 @@ fr_window_drag_data_received (GtkWidget *widget,
}
}
- path_list_free (list);
+ _g_string_list_free (list);
debug (DEBUG_INFO, "::DragDataReceived <--\n");
}
@@ -4135,7 +4135,7 @@ file_list_drag_end (GtkWidget *widget,
FR_OVERWRITE_ASK,
FALSE,
FALSE);
- path_list_free (window->priv->drag_file_list);
+ _g_string_list_free (window->priv->drag_file_list);
window->priv->drag_file_list = NULL;
}
@@ -4291,7 +4291,7 @@ fr_window_folder_tree_drag_data_get (GtkWidget *widget,
if (window->priv->drag_error == NULL) {
g_free (window->priv->drag_destination_folder);
g_free (window->priv->drag_base_dir);
- path_list_free (window->priv->drag_file_list);
+ _g_string_list_free (window->priv->drag_file_list);
window->priv->drag_destination_folder = g_strdup (destination_folder);
window->priv->drag_base_dir = fr_window_get_selected_folder_in_tree_view (window);
window->priv->drag_file_list = file_list;
@@ -4371,7 +4371,7 @@ fr_window_file_list_drag_data_get (FrWindow *window,
if (window->priv->drag_error == NULL) {
g_free (window->priv->drag_destination_folder);
g_free (window->priv->drag_base_dir);
- path_list_free (window->priv->drag_file_list);
+ _g_string_list_free (window->priv->drag_file_list);
window->priv->drag_destination_folder = g_strdup (destination_folder);
window->priv->drag_base_dir = g_strdup (fr_window_get_current_location (window));
window->priv->drag_file_list = fr_window_get_file_list_from_path_list (window, path_list, NULL);
@@ -6123,7 +6123,7 @@ fr_window_archive_save_as (FrWindow *window,
char *utf8_name;
char *message;
- utf8_name = g_uri_display_basename (uri);
+ utf8_name = _g_uri_display_basename (uri);
message = g_strdup_printf (_("Could not save the archive \"%s\""), utf8_name);
g_free (utf8_name);
@@ -6256,7 +6256,7 @@ fr_window_archive_add_files (FrWindow *window,
window->priv->volume_size);
g_free (base_uri);
- path_list_free (files);
+ _g_string_list_free (files);
g_free (base_dir);
g_object_unref (base);
}
@@ -6370,7 +6370,7 @@ extract_data_new (GList *file_list,
ExtractData *edata;
edata = g_new0 (ExtractData, 1);
- edata->file_list = path_list_dup (file_list);
+ edata->file_list = _g_string_list_dup (file_list);
if (extract_to_dir != NULL)
edata->extract_to_dir = g_strdup (extract_to_dir);
edata->skip_older = skip_older;
@@ -6404,7 +6404,7 @@ extract_data_free (ExtractData *edata)
{
g_return_if_fail (edata != NULL);
- path_list_free (edata->file_list);
+ _g_string_list_free (edata->file_list);
g_free (edata->extract_to_dir);
g_free (edata->base_dir);
@@ -6557,7 +6557,7 @@ overwrite_dialog_response_cb (GtkDialog *dialog,
/* remove the file from the list to extract */
GList *next = odata->current_file->next;
odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file);
- path_list_free (odata->current_file);
+ _g_string_list_free (odata->current_file);
odata->current_file = next;
}
break;
@@ -7414,8 +7414,8 @@ rename_selection (FrWindow *window,
window->priv->volume_size);
g_free (new_dirname);
- path_list_free (new_file_list);
- path_list_free (file_list);
+ _g_string_list_free (new_file_list);
+ _g_string_list_free (file_list);
/* remove the tmp dir */
@@ -7440,7 +7440,7 @@ valid_name (const char *new_name,
char *utf8_new_name;
gboolean retval = TRUE;
- new_name = eat_spaces (new_name);
+ new_name = _g_str_eat_spaces (new_name);
utf8_new_name = g_filename_display_name (new_name);
if (*new_name == '\0') {
@@ -7453,7 +7453,7 @@ valid_name (const char *new_name,
*reason = g_strdup (_("New name is the same as old one, please type other name."));
retval = FALSE;
}
- else if (strchrs (new_name, BAD_CHARS)) {
+ else if (_g_strchrs (new_name, BAD_CHARS)) {
/* Translators: the %s references to a filename. This message can appear when renaming a file. */
*reason = g_strdup_printf (_("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name."), utf8_new_name, BAD_CHARS);
retval = FALSE;
@@ -7808,7 +7808,7 @@ add_pasted_files (FrWindow *window,
window->priv->compression,
window->priv->volume_size);
- path_list_free (new_file_list);
+ _g_string_list_free (new_file_list);
/* remove the tmp dir */
@@ -8083,7 +8083,7 @@ fr_window_open_files_with_application (FrWindow *window,
}
g_object_unref (context);
- path_list_free (uris);
+ _g_string_list_free (uris);
}
@@ -8106,7 +8106,7 @@ open_files_data_new (FrWindow *window,
odata = g_new0 (OpenFilesData, 1);
odata->window = window;
- odata->file_list = path_list_dup (file_list);
+ odata->file_list = _g_string_list_dup (file_list);
odata->ask_application = ask_application;
odata->cdata = g_new0 (CommandData, 1);
odata->cdata->temp_dir = get_temp_work_dir (NULL);
@@ -8134,7 +8134,7 @@ open_files_data_free (OpenFilesData *odata)
{
g_return_if_fail (odata != NULL);
- path_list_free (odata->file_list);
+ _g_string_list_free (odata->file_list);
g_free (odata);
}
@@ -8334,7 +8334,7 @@ fr_window_open_extracted_files (OpenFilesData *odata)
g_object_unref (context);
g_object_unref (app);
- path_list_free (files_to_open);
+ _g_string_list_free (files_to_open);
return result;
}
diff --git a/src/gio-utils.c b/src/gio-utils.c
index 7c2c5a1..d567e3b 100644
--- a/src/gio-utils.c
+++ b/src/gio-utils.c
@@ -65,7 +65,7 @@ filter_new (const char *pattern,
flags = G_REGEX_CASELESS;
else
flags = 0;
- filter->regexps = search_util_get_regexps (pattern, flags);
+ filter->regexps = _g_regexp_split_from_patterns (pattern, flags);
return filter;
}
@@ -79,7 +79,7 @@ filter_destroy (Filter *filter)
g_free (filter->pattern);
if (filter->regexps != NULL)
- free_regexps (filter->regexps);
+ _g_regexp_freev (filter->regexps);
g_free (filter);
}
@@ -108,7 +108,7 @@ filter_matches (Filter *filter,
return TRUE;
utf8_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
- matched = match_regexps (filter->regexps, utf8_name, 0);
+ matched = _g_regexp_matchv (filter->regexps, utf8_name, 0);
g_free (utf8_name);
return matched;
@@ -473,9 +473,9 @@ get_file_list_data_free (GetFileListData *gfl)
filter_destroy (gfl->include_filter);
filter_destroy (gfl->exclude_filter);
filter_destroy (gfl->exclude_folders_filter);
- path_list_free (gfl->files);
- path_list_free (gfl->dirs);
- path_list_free (gfl->to_visit);
+ _g_string_list_free (gfl->files);
+ _g_string_list_free (gfl->dirs);
+ _g_string_list_free (gfl->to_visit);
if (gfl->directory != NULL)
g_object_unref (gfl->directory);
if (gfl->base_dir != NULL)
@@ -578,7 +578,7 @@ get_file_list_done (GError *error,
gfl->dirs = g_list_reverse (gfl->dirs);
if (! filter_empty (gfl->include_filter) || (gfl->exclude_filter->pattern != NULL)) {
- path_list_free (gfl->dirs);
+ _g_string_list_free (gfl->dirs);
gfl->dirs = NULL;
}
@@ -749,8 +749,8 @@ get_items_for_current_dir_done (GList *files,
if (error != NULL) {
if (gfl->done_func)
gfl->done_func (NULL, NULL, error, gfl->done_data);
- path_list_free (files);
- path_list_free (dirs);
+ _g_string_list_free (files);
+ _g_string_list_free (dirs);
get_file_list_data_free (gfl);
return;
}
@@ -879,8 +879,8 @@ copy_files_data_new (GList *sources,
CopyFilesData *cfd;
cfd = g_new0 (CopyFilesData, 1);
- cfd->sources = gio_file_list_dup (sources);
- cfd->destinations = gio_file_list_dup (destinations);
+ cfd->sources = _g_file_list_dup (sources);
+ cfd->destinations = _g_file_list_dup (destinations);
cfd->flags = flags;
cfd->io_priority = io_priority;
cfd->cancellable = cancellable;
@@ -903,8 +903,8 @@ copy_files_data_free (CopyFilesData *cfd)
{
if (cfd == NULL)
return;
- gio_file_list_free (cfd->sources);
- gio_file_list_free (cfd->destinations);
+ _g_file_list_free (cfd->sources);
+ _g_file_list_free (cfd->destinations);
g_free (cfd);
}
@@ -1068,8 +1068,8 @@ g_copy_uris_async (GList *sources,
{
GList *source_files, *destination_files;
- source_files = gio_file_list_new_from_uri_list (sources);
- destination_files = gio_file_list_new_from_uri_list (destinations);
+ source_files = _g_file_list_new_from_uri_list (sources);
+ destination_files = _g_file_list_new_from_uri_list (destinations);
g_copy_files_async (source_files,
destination_files,
@@ -1081,8 +1081,8 @@ g_copy_uris_async (GList *sources,
callback,
user_data);
- gio_file_list_free (source_files);
- gio_file_list_free (destination_files);
+ _g_file_list_free (source_files);
+ _g_file_list_free (destination_files);
}
diff --git a/src/glib-utils.c b/src/glib-utils.c
index 2ce0338..fea3aa8 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -37,10 +37,7 @@
gpointer
_g_object_ref (gpointer object)
{
- if (object != NULL)
- return g_object_ref (object);
- else
- return NULL;
+ return (object != NULL) ? g_object_ref (object) : NULL;
}
@@ -52,12 +49,12 @@ _g_object_unref (gpointer object)
}
-/* string utils */
+/* string */
gboolean
-strchrs (const char *str,
- const char *chars)
+_g_strchrs (const char *str,
+ const char *chars)
{
const char *c;
for (c = chars; *c != '\0'; c++)
@@ -68,9 +65,9 @@ strchrs (const char *str,
char *
-str_substitute (const char *str,
- const char *from_str,
- const char *to_str)
+_g_str_substitute (const char *str,
+ const char *from_str,
+ const char *to_str)
{
char **tokens;
int i;
@@ -99,7 +96,8 @@ str_substitute (const char *str,
int
-strcmp_null_tolerant (const char *s1, const char *s2)
+_g_strcmp_null_tolerant (const char *s1,
+ const char *s2)
{
if ((s1 == NULL) && (s2 == NULL))
return 0;
@@ -112,6 +110,9 @@ strcmp_null_tolerant (const char *s1, const char *s2)
}
+/* -- _g_str_escape_full -- */
+
+
/* counts how many characters to escape in @str. */
static int
count_chars_to_escape (const char *str,
@@ -129,15 +130,16 @@ count_chars_to_escape (const char *str,
break;
}
}
+
return n;
}
-char*
-escape_str_common (const char *str,
- const char *meta_chars,
- const char prefix,
- const char postfix)
+char *
+_g_str_escape_full (const char *str,
+ const char *meta_chars,
+ const char prefix,
+ const char postfix)
{
int meta_chars_n = strlen (meta_chars);
char *escaped;
@@ -175,233 +177,19 @@ escape_str_common (const char *str,
/* escape with backslash the string @str. */
-char*
-escape_str (const char *str,
- const char *meta_chars)
+char *
+_g_str_escape (const char *str,
+ const char *meta_chars)
{
- return escape_str_common (str, meta_chars, '\\', 0);
+ return _g_str_escape_full (str, meta_chars, '\\', 0);
}
/* escape with backslash the file name. */
-char*
-shell_escape (const char *filename)
-{
- return escape_str (filename, "$'`\"\\!?* ()[]&|:;<>#");
-}
-
-
-static const char *
-g_utf8_strstr (const char *haystack, const char *needle)
-{
- const char *s;
- gsize i;
- gsize haystack_len = g_utf8_strlen (haystack, -1);
- gsize needle_len = g_utf8_strlen (needle, -1);
- int needle_size = strlen (needle);
-
- s = haystack;
- for (i = 0; i <= haystack_len - needle_len; i++) {
- if (strncmp (s, needle, needle_size) == 0)
- return s;
- s = g_utf8_next_char(s);
- }
-
- return NULL;
-}
-
-
-static char**
-g_utf8_strsplit (const char *string,
- const char *delimiter,
- int max_tokens)
-{
- GSList *string_list = NULL, *slist;
- char **str_array;
- const char *s;
- guint n = 0;
- const char *remainder;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (delimiter != NULL, NULL);
- g_return_val_if_fail (delimiter[0] != '\0', NULL);
-
- if (max_tokens < 1)
- max_tokens = G_MAXINT;
-
- remainder = string;
- s = g_utf8_strstr (remainder, delimiter);
- if (s != NULL) {
- gsize delimiter_size = strlen (delimiter);
-
- while (--max_tokens && (s != NULL)) {
- gsize size = s - remainder;
- char *new_string;
-
- new_string = g_new (char, size + 1);
- strncpy (new_string, remainder, size);
- new_string[size] = 0;
-
- string_list = g_slist_prepend (string_list, new_string);
- n++;
- remainder = s + delimiter_size;
- s = g_utf8_strstr (remainder, delimiter);
- }
- }
- if (*string) {
- n++;
- string_list = g_slist_prepend (string_list, g_strdup (remainder));
- }
-
- str_array = g_new (char*, n + 1);
-
- str_array[n--] = NULL;
- for (slist = string_list; slist; slist = slist->next)
- str_array[n--] = slist->data;
-
- g_slist_free (string_list);
-
- return str_array;
-}
-
-
-static char*
-g_utf8_strchug (char *string)
-{
- char *scan;
- gunichar c;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- scan = string;
- c = g_utf8_get_char (scan);
- while (g_unichar_isspace (c)) {
- scan = g_utf8_next_char (scan);
- c = g_utf8_get_char (scan);
- }
-
- g_memmove (string, scan, strlen (scan) + 1);
-
- return string;
-}
-
-
-static char*
-g_utf8_strchomp (char *string)
-{
- char *scan;
- gsize len;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- len = g_utf8_strlen (string, -1);
-
- if (len == 0)
- return string;
-
- scan = g_utf8_offset_to_pointer (string, len - 1);
-
- while (len--) {
- gunichar c = g_utf8_get_char (scan);
- if (g_unichar_isspace (c))
- *scan = '\0';
- else
- break;
- scan = g_utf8_find_prev_char (string, scan);
- }
-
- return string;
-}
-
-
-#define g_utf8_strstrip(string) g_utf8_strchomp (g_utf8_strchug (string))
-
-
-gboolean
-match_regexps (GRegex **regexps,
- const char *string,
- GRegexMatchFlags match_options)
-{
- gboolean matched;
- int i;
-
- if ((regexps == NULL) || (regexps[0] == NULL))
- return TRUE;
-
- if (string == NULL)
- return FALSE;
-
- matched = FALSE;
- for (i = 0; regexps[i] != NULL; i++)
- if (g_regex_match (regexps[i], string, match_options, NULL)) {
- matched = TRUE;
- break;
- }
-
- return matched;
-}
-
-
-void
-free_regexps (GRegex **regexps)
-{
- int i;
-
- if (regexps == NULL)
- return;
-
- for (i = 0; regexps[i] != NULL; i++)
- g_regex_unref (regexps[i]);
- g_free (regexps);
-}
-
-
-char **
-search_util_get_patterns (const char *pattern_string)
-{
- char **patterns;
- int i;
-
- if (pattern_string == NULL)
- return NULL;
-
- patterns = g_utf8_strsplit (pattern_string, ";", MAX_PATTERNS);
- for (i = 0; patterns[i] != NULL; i++) {
- char *p1, *p2;
-
- p1 = g_utf8_strstrip (patterns[i]);
- p2 = str_substitute (p1, ".", "\\.");
- patterns[i] = str_substitute (p2, "*", ".*");
-
- g_free (p2);
- g_free (p1);
- }
-
- return patterns;
-}
-
-
-GRegex **
-search_util_get_regexps (const char *pattern_string,
- GRegexCompileFlags compile_options)
+char *
+_g_str_shell_escape (const char *filename)
{
- char **patterns;
- GRegex **regexps;
- int i;
-
- patterns = search_util_get_patterns (pattern_string);
- if (patterns == NULL)
- return NULL;
-
- regexps = g_new0 (GRegex*, n_fields (patterns) + 1);
- for (i = 0; patterns[i] != NULL; i++)
- regexps[i] = g_regex_new (patterns[i],
- G_REGEX_OPTIMIZE | compile_options,
- G_REGEX_MATCH_NOTEMPTY,
- NULL);
- g_strfreev (patterns);
-
- return regexps;
+ return _g_str_escape (filename, "$'`\"\\!?* ()[]&|:;<>#");
}
@@ -434,7 +222,7 @@ _g_strdup_with_max_size (const char *s,
const char *
-eat_spaces (const char *line)
+_g_str_eat_spaces (const char *line)
{
if (line == NULL)
return NULL;
@@ -445,7 +233,7 @@ eat_spaces (const char *line)
const char *
-eat_void_chars (const char *line)
+_g_str_eat_void_chars (const char *line)
{
if (line == NULL)
return NULL;
@@ -456,8 +244,8 @@ eat_void_chars (const char *line)
char **
-split_line (const char *line,
- int n_fields)
+_g_str_split_line (const char *line,
+ int n_fields)
{
char **fields;
const char *scan, *field_end;
@@ -466,7 +254,7 @@ split_line (const char *line,
fields = g_new0 (char *, n_fields + 1);
fields[n_fields] = NULL;
- scan = eat_spaces (line);
+ scan = _g_str_eat_spaces (line);
for (i = 0; i < n_fields; i++) {
if (scan == NULL) {
fields[i] = NULL;
@@ -475,7 +263,7 @@ split_line (const char *line,
field_end = strchr (scan, ' ');
if (field_end != NULL) {
fields[i] = g_strndup (scan, field_end - scan);
- scan = eat_spaces (field_end);
+ scan = _g_str_eat_spaces (field_end);
}
}
@@ -484,8 +272,8 @@ split_line (const char *line,
const char *
-get_last_field (const char *line,
- int last_field)
+_g_str_get_last_field (const char *line,
+ int last_field)
{
const char *field;
int i;
@@ -494,98 +282,138 @@ get_last_field (const char *line,
return NULL;
last_field--;
- field = eat_spaces (line);
+ field = _g_str_eat_spaces (line);
for (i = 0; i < last_field; i++) {
if (field == NULL)
return NULL;
field = strchr (field, ' ');
- field = eat_spaces (field);
+ field = _g_str_eat_spaces (field);
}
return field;
}
-int
-n_fields (char **str_array)
+GHashTable *static_strings = NULL;
+
+
+const char *
+_g_str_get_static (const char *s)
{
- int i;
+ const char *result;
- if (str_array == NULL)
- return 0;
+ if (s == NULL)
+ return NULL;
- i = 0;
- while (str_array[i] != NULL)
- i++;
- return i;
+ if (static_strings == NULL)
+ static_strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ if (! g_hash_table_lookup_extended (static_strings, s, (gpointer*) &result, NULL)) {
+ result = g_strdup (s);
+ g_hash_table_insert (static_strings,
+ (gpointer) result,
+ GINT_TO_POINTER (1));
+ }
+
+ return result;
}
-void
-debug (const char *file,
- int line,
- const char *function,
- const char *format, ...)
-{
-#ifdef DEBUG
- va_list args;
- char *str;
+/* string vector */
- g_return_if_fail (format != NULL);
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
+char **
+_g_strv_prepend (char **str_array,
+ const char *str)
+{
+ char **result;
+ int i;
+ int j;
- g_fprintf (stderr, "[FR] %s:%d (%s):\n\t%s\n", file, line, function, str);
+ result = g_new (char *, g_strv_length (str_array) + 1);
+ i = 0;
+ result[i++] = g_strdup (str);
+ for (j = 0; str_array[j] != NULL; j++)
+ result[i++] = g_strdup (str_array[j]);
+ result[i] = NULL;
- g_free (str);
-#else /* ! DEBUG */
-#endif
+ return result;
}
-char *
-get_time_string (time_t time)
+gboolean
+_g_strv_remove (char **str_array,
+ const char *str)
{
- struct tm *tm;
- char s_time[256];
- char *locale_format = NULL;
- char *time_utf8;
+ int i;
+ int j;
- tm = localtime (&time);
- /* This is the time format used in the "Date Modified" column and
- * in the Properties dialog. See the man page of strftime for an
- * explanation of the values. */
- locale_format = g_locale_from_utf8 (_("%d %B %Y, %H:%M"), -1, NULL, NULL, NULL);
- strftime (s_time, sizeof (s_time) - 1, locale_format, tm);
- g_free (locale_format);
- time_utf8 = g_locale_to_utf8 (s_time, -1, NULL, NULL, NULL);
+ if (str == NULL)
+ return FALSE;
- return time_utf8;
+ for (i = 0; str_array[i] != NULL; i++)
+ if (strcmp (str_array[i], str) == 0)
+ break;
+
+ if (str_array[i] == NULL)
+ return FALSE;
+
+ for (j = i; str_array[j] != NULL; j++)
+ str_array[j] = str_array[j + 1];
+
+ return TRUE;
}
+/* string list */
+
+
+void
+_g_string_list_free (GList *path_list)
+{
+ if (path_list == NULL)
+ return;
+ g_list_foreach (path_list, (GFunc) g_free, NULL);
+ g_list_free (path_list);
+}
+
+
+GList *
+_g_string_list_dup (GList *path_list)
+{
+ GList *new_list = NULL;
+ GList *scan;
+
+ for (scan = path_list; scan; scan = scan->next)
+ new_list = g_list_prepend (new_list, g_strdup (scan->data));
+
+ return g_list_reverse (new_list);
+}
+
+
+/* GPtrArray */
+
+
GPtrArray *
-g_ptr_array_copy (GPtrArray *array)
+_g_ptr_array_copy (GPtrArray *array)
{
GPtrArray *new_array;
-
+
if (array == NULL)
return NULL;
-
+
new_array = g_ptr_array_sized_new (array->len);
- memcpy (new_array->pdata, array->pdata, array->len * sizeof (gpointer));
+ memcpy (new_array->pdata, array->pdata, array->len * sizeof (gpointer));
new_array->len = array->len;
-
+
return new_array;
}
void
-g_ptr_array_free_full (GPtrArray *array,
- GFunc free_func,
- gpointer user_data)
+_g_ptr_array_free_full (GPtrArray *array,
+ GFunc free_func,
+ gpointer user_data)
{
g_ptr_array_foreach (array, free_func, user_data);
g_ptr_array_free (array, TRUE);
@@ -593,11 +421,11 @@ g_ptr_array_free_full (GPtrArray *array,
void
-g_ptr_array_reverse (GPtrArray *array)
+_g_ptr_array_reverse (GPtrArray *array)
{
int i, j;
gpointer tmp;
-
+
for (i = 0; i < array->len / 2; i++) {
j = array->len - i - 1;
tmp = g_ptr_array_index (array, i);
@@ -608,105 +436,311 @@ g_ptr_array_reverse (GPtrArray *array)
int
-g_ptr_array_binary_search (GPtrArray *array,
+_g_ptr_array_binary_search (GPtrArray *array,
gpointer value,
GCompareFunc func)
{
int l, r, p, cmp = -1;
-
+
l = 0;
r = array->len;
while (l < r) {
p = l + ((r - l) / 2);
cmp = func(value, &g_ptr_array_index (array, p));
if (cmp == 0)
- return p;
+ return p;
else if (cmp < 0)
r = p;
- else
+ else
l = p + 1;
}
-
+
return -1;
}
-GHashTable *static_strings = NULL;
+/* GRegex */
-const char *
-get_static_string (const char *s)
+gboolean
+_g_regexp_matchv (GRegex **regexps,
+ const char *string,
+ GRegexMatchFlags match_options)
{
- const char *result;
+ gboolean matched;
+ int i;
- if (s == NULL)
- return NULL;
+ if ((regexps == NULL) || (regexps[0] == NULL))
+ return TRUE;
- if (static_strings == NULL)
- static_strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ if (string == NULL)
+ return FALSE;
- if (! g_hash_table_lookup_extended (static_strings, s, (gpointer*) &result, NULL)) {
- result = g_strdup (s);
- g_hash_table_insert (static_strings,
- (gpointer) result,
- GINT_TO_POINTER (1));
- }
+ matched = FALSE;
+ for (i = 0; regexps[i] != NULL; i++)
+ if (g_regex_match (regexps[i], string, match_options, NULL)) {
+ matched = TRUE;
+ break;
+ }
- return result;
+ return matched;
}
-char*
-g_uri_display_basename (const char *uri)
+void
+_g_regexp_freev (GRegex **regexps)
{
- char *e_name, *name;
-
- e_name = g_filename_display_basename (uri);
- name = g_uri_unescape_string (e_name, "");
- g_free (e_name);
-
- return name;
+ int i;
+
+ if (regexps == NULL)
+ return;
+
+ for (i = 0; regexps[i] != NULL; i++)
+ g_regex_unref (regexps[i]);
+ g_free (regexps);
+}
+
+
+/* -- _g_regexp_get_patternv -- */
+
+
+static const char *
+_g_utf8_strstr (const char *haystack,
+ const char *needle)
+{
+ const char *s;
+ gsize i;
+ gsize haystack_len = g_utf8_strlen (haystack, -1);
+ gsize needle_len = g_utf8_strlen (needle, -1);
+ int needle_size = strlen (needle);
+
+ s = haystack;
+ for (i = 0; i <= haystack_len - needle_len; i++) {
+ if (strncmp (s, needle, needle_size) == 0)
+ return s;
+ s = g_utf8_next_char(s);
+ }
+
+ return NULL;
+}
+
+
+static char **
+_g_utf8_strsplit (const char *string,
+ const char *delimiter,
+ int max_tokens)
+{
+ GSList *string_list = NULL, *slist;
+ char **str_array;
+ const char *s;
+ guint n = 0;
+ const char *remainder;
+
+ g_return_val_if_fail (string != NULL, NULL);
+ g_return_val_if_fail (delimiter != NULL, NULL);
+ g_return_val_if_fail (delimiter[0] != '\0', NULL);
+
+ if (max_tokens < 1)
+ max_tokens = G_MAXINT;
+
+ remainder = string;
+ s = _g_utf8_strstr (remainder, delimiter);
+ if (s != NULL) {
+ gsize delimiter_size = strlen (delimiter);
+
+ while (--max_tokens && (s != NULL)) {
+ gsize size = s - remainder;
+ char *new_string;
+
+ new_string = g_new (char, size + 1);
+ strncpy (new_string, remainder, size);
+ new_string[size] = 0;
+
+ string_list = g_slist_prepend (string_list, new_string);
+ n++;
+ remainder = s + delimiter_size;
+ s = _g_utf8_strstr (remainder, delimiter);
+ }
+ }
+ if (*string) {
+ n++;
+ string_list = g_slist_prepend (string_list, g_strdup (remainder));
+ }
+
+ str_array = g_new (char*, n + 1);
+
+ str_array[n--] = NULL;
+ for (slist = string_list; slist; slist = slist->next)
+ str_array[n--] = slist->data;
+
+ g_slist_free (string_list);
+
+ return str_array;
+}
+
+
+static char*
+g_utf8_strchug (char *string)
+{
+ char *scan;
+ gunichar c;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ scan = string;
+ c = g_utf8_get_char (scan);
+ while (g_unichar_isspace (c)) {
+ scan = g_utf8_next_char (scan);
+ c = g_utf8_get_char (scan);
+ }
+
+ g_memmove (string, scan, strlen (scan) + 1);
+
+ return string;
+}
+
+
+static char*
+g_utf8_strchomp (char *string)
+{
+ char *scan;
+ gsize len;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ len = g_utf8_strlen (string, -1);
+
+ if (len == 0)
+ return string;
+
+ scan = g_utf8_offset_to_pointer (string, len - 1);
+
+ while (len--) {
+ gunichar c = g_utf8_get_char (scan);
+ if (g_unichar_isspace (c))
+ *scan = '\0';
+ else
+ break;
+ scan = g_utf8_find_prev_char (string, scan);
+ }
+
+ return string;
}
+#define g_utf8_strstrip(string) g_utf8_strchomp (g_utf8_strchug (string))
+
+
char **
-_g_strv_prepend (char **str_array,
- const char *str)
+_g_regexp_get_patternv (const char *pattern_string)
{
- char **result;
+ char **patterns;
int i;
- int j;
- result = g_new (char *, g_strv_length (str_array) + 1);
- i = 0;
- result[i++] = g_strdup (str);
- for (j = 0; str_array[j] != NULL; j++)
- result[i++] = g_strdup (str_array[j]);
- result[i] = NULL;
+ if (pattern_string == NULL)
+ return NULL;
- return result;
+ patterns = _g_utf8_strsplit (pattern_string, ";", MAX_PATTERNS);
+ for (i = 0; patterns[i] != NULL; i++) {
+ char *p1, *p2;
+
+ p1 = g_utf8_strstrip (patterns[i]);
+ p2 = _g_str_substitute (p1, ".", "\\.");
+ patterns[i] = _g_str_substitute (p2, "*", ".*");
+
+ g_free (p2);
+ g_free (p1);
+ }
+
+ return patterns;
}
-gboolean
-_g_strv_remove (char **str_array,
- const char *str)
+GRegex **
+_g_regexp_split_from_patterns (const char *pattern_string,
+ GRegexCompileFlags compile_options)
{
- int i;
- int j;
+ char **patterns;
+ GRegex **regexps;
+ int i;
- if (str == NULL)
- return FALSE;
+ patterns = _g_regexp_get_patternv (pattern_string);
+ if (patterns == NULL)
+ return NULL;
- for (i = 0; str_array[i] != NULL; i++)
- if (strcmp (str_array[i], str) == 0)
- break;
+ regexps = g_new0 (GRegex*, g_strv_length (patterns) + 1);
+ for (i = 0; patterns[i] != NULL; i++)
+ regexps[i] = g_regex_new (patterns[i],
+ G_REGEX_OPTIMIZE | compile_options,
+ G_REGEX_MATCH_NOTEMPTY,
+ NULL);
+ g_strfreev (patterns);
- if (str_array[i] == NULL)
- return FALSE;
+ return regexps;
+}
- for (j = i; str_array[j] != NULL; j++)
- str_array[j] = str_array[j + 1];
- return TRUE;
+/* time */
+
+
+char *
+_g_time_to_string (time_t time)
+{
+ struct tm *tm;
+ char s_time[256];
+ char *locale_format = NULL;
+ char *time_utf8;
+
+ tm = localtime (&time);
+ /* This is the time format used in the "Date Modified" column and
+ * in the Properties dialog. See the man page of strftime for an
+ * explanation of the values. */
+ locale_format = g_locale_from_utf8 (_("%d %B %Y, %H:%M"), -1, NULL, NULL, NULL);
+ strftime (s_time, sizeof (s_time) - 1, locale_format, tm);
+ g_free (locale_format);
+ time_utf8 = g_locale_to_utf8 (s_time, -1, NULL, NULL, NULL);
+
+ return time_utf8;
+}
+
+
+/* uri */
+
+
+char*
+_g_uri_display_basename (const char *uri)
+{
+ char *e_name, *name;
+
+ e_name = g_filename_display_basename (uri);
+ name = g_uri_unescape_string (e_name, "");
+ g_free (e_name);
+
+ return name;
+}
+
+
+/* debug */
+
+void
+debug (const char *file,
+ int line,
+ const char *function,
+ const char *format, ...)
+{
+#ifdef DEBUG
+ va_list args;
+ char *str;
+
+ g_return_if_fail (format != NULL);
+
+ va_start (args, format);
+ str = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ g_fprintf (stderr, "[FR] %s:%d (%s):\n\t%s\n", file, line, function, str);
+
+ g_free (str);
+#else /* ! DEBUG */
+#endif
}
diff --git a/src/glib-utils.h b/src/glib-utils.h
index 028ec5d..6bab1ae 100644
--- a/src/glib-utils.h
+++ b/src/glib-utils.h
@@ -28,69 +28,90 @@
g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, \
0, 0, NULL, NULL, (data))
-/* gobject utils */
-
-gpointer _g_object_ref (gpointer object);
-void _g_object_unref (gpointer object);
-
-/* string utils */
-
-gboolean strchrs (const char *str,
- const char *chars);
-char * str_substitute (const char *str,
- const char *from_str,
- const char *to_str);
-int strcmp_null_tolerant (const char *s1, const char *s2);
-char* escape_str_common (const char *str,
- const char *meta_chars,
- const char prefix,
- const char postfix);
-char* escape_str (const char *str,
- const char *meta_chars);
-gchar * shell_escape (const gchar *filename);
-gboolean match_regexps (GRegex **regexps,
- const char *string,
- GRegexMatchFlags match_options);
-char ** search_util_get_patterns (const char *pattern_string);
-GRegex ** search_util_get_regexps (const char *pattern_string,
- GRegexCompileFlags compile_options);
-void free_regexps (GRegex **regexps);
-char * _g_strdup_with_max_size (const char *s,
- int max_size);
-const char * eat_spaces (const char *line);
-const char * eat_void_chars (const char *line);
-char ** split_line (const char *line,
- int n_fields);
-const char * get_last_field (const char *line,
- int last_field);
-int n_fields (char **str_array);
-char * get_time_string (time_t time);
-GPtrArray * g_ptr_array_copy (GPtrArray *array);
-void g_ptr_array_free_full (GPtrArray *array,
- GFunc func,
- gpointer user_data);
-void g_ptr_array_reverse (GPtrArray *array);
-int g_ptr_array_binary_search (GPtrArray *array,
- gpointer value,
- GCompareFunc func);
-const char * get_static_string (const char *s);
-char* g_uri_display_basename (const char *uri);
-char ** _g_strv_prepend (char **str_array,
- const char *str);
-gboolean _g_strv_remove (char **str_array,
- const char *str);
-
-/**/
-
#ifndef __GNUC__
#define __FUNCTION__ ""
#endif
#define DEBUG_INFO __FILE__, __LINE__, __FUNCTION__
-void debug (const char *file,
- int line,
- const char *function,
- const char *format, ...);
+/* gobject */
+
+gpointer _g_object_ref (gpointer object);
+void _g_object_unref (gpointer object);
+
+/* string */
+
+gboolean _g_strchrs (const char *str,
+ const char *chars);
+char * _g_str_substitute (const char *str,
+ const char *from_str,
+ const char *to_str);
+int _g_strcmp_null_tolerant (const char *s1,
+ const char *s2);
+char* _g_str_escape_full (const char *str,
+ const char *meta_chars,
+ const char prefix,
+ const char postfix);
+char* _g_str_escape (const char *str,
+ const char *meta_chars);
+char * _g_str_shell_escape (const char *filename);
+char * _g_strdup_with_max_size (const char *s,
+ int max_size);
+const char * _g_str_eat_spaces (const char *line);
+const char * _g_str_eat_void_chars (const char *line);
+char ** _g_str_split_line (const char *line,
+ int n_fields);
+const char * _g_str_get_last_field (const char *line,
+ int last_field);
+const char * _g_str_get_static (const char *s);
+
+/* string vector */
+
+char ** _g_strv_prepend (char **str_array,
+ const char *str);
+gboolean _g_strv_remove (char **str_array,
+ const char *str);
+
+/* string list */
+
+void _g_string_list_free (GList *path_list);
+GList * _g_string_list_dup (GList *path_list);
+
+/* GPtrArray */
+
+GPtrArray * _g_ptr_array_copy (GPtrArray *array);
+void _g_ptr_array_free_full (GPtrArray *array,
+ GFunc func,
+ gpointer user_data);
+void _g_ptr_array_reverse (GPtrArray *array);
+int _g_ptr_array_binary_search (GPtrArray *array,
+ gpointer value,
+ GCompareFunc func);
+
+/* GRegex */
+
+gboolean _g_regexp_matchv (GRegex **regexps,
+ const char *string,
+ GRegexMatchFlags match_options);
+void _g_regexp_freev (GRegex **regexps);
+char ** _g_regexp_get_patternv (const char *pattern_string);
+GRegex ** _g_regexp_split_from_patterns (const char *pattern_string,
+ GRegexCompileFlags compile_options);
+
+/* time */
+
+char * _g_time_to_string (time_t time);
+
+/* uri */
+
+char * _g_uri_display_basename (const char *uri);
+
+/* debug */
+
+void debug (const char *file,
+ int line,
+ const char *function,
+ const char *format,
+ ...);
#endif /* _GLIB_UTILS_H */
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index 439de74..db256d4 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -39,7 +39,7 @@ count_selected (GtkTreeModel *model,
int
-_gtk_count_selected (GtkTreeSelection *selection)
+_gtk_tree_selection_count_selected (GtkTreeSelection *selection)
{
int n = 0;
@@ -625,9 +625,9 @@ get_file_icon_pixbuf (GFileIcon *icon,
GdkPixbuf *
-get_icon_pixbuf (GIcon *icon,
- int size,
- GtkIconTheme *theme)
+_g_icon_get_pixbuf (GIcon *icon,
+ int size,
+ GtkIconTheme *theme)
{
if (icon == NULL)
return NULL;
@@ -640,9 +640,9 @@ get_icon_pixbuf (GIcon *icon,
GdkPixbuf *
-get_mime_type_pixbuf (const char *mime_type,
- int icon_size,
- GtkIconTheme *icon_theme)
+_g_mime_type_get_icon (const char *mime_type,
+ int icon_size,
+ GtkIconTheme *icon_theme)
{
GdkPixbuf *pixbuf = NULL;
GIcon *icon;
@@ -651,7 +651,7 @@ get_mime_type_pixbuf (const char *mime_type,
icon_theme = gtk_icon_theme_get_default ();
icon = g_content_type_get_icon (mime_type);
- pixbuf = get_icon_pixbuf (icon, icon_size, icon_theme);
+ pixbuf = _g_icon_get_pixbuf (icon, icon_size, icon_theme);
g_object_unref (icon);
return pixbuf;
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index c627bdd..3d9d44d 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -26,70 +26,66 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
-int _gtk_count_selected (GtkTreeSelection *selection);
-GtkWidget* _gtk_message_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *stock_id,
- const char *message,
- const char *secondary_message,
- const char *first_button_text,
- ...);
-gchar* _gtk_request_dialog_run (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *title,
- const char *message,
- const char *default_value,
- int max_length,
- const char *no_button_text,
- const char *yes_button_text);
-GtkWidget* _gtk_yesno_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *message,
- const char *no_button_text,
- const char *yes_button_text);
-GtkWidget* _gtk_error_dialog_new (GtkWindow *parent,
- GtkDialogFlags flags,
- GList *row_output,
- const char *primary_text,
- const char *secondary_text_format,
- ...) G_GNUC_PRINTF (5, 6);
-void _gtk_error_dialog_run (GtkWindow *parent,
- const gchar *main_message,
- const gchar *format,
- ...);
-void _gtk_entry_set_locale_text (GtkEntry *entry,
- const char *text);
-char * _gtk_entry_get_locale_text (GtkEntry *entry);
-void _gtk_label_set_locale_text (GtkLabel *label,
- const char *text);
-char * _gtk_label_get_locale_text (GtkLabel *label);
-void _gtk_entry_set_filename_text (GtkEntry *entry,
- const char *text);
-char * _gtk_entry_get_filename_text (GtkEntry *entry);
-void _gtk_label_set_filename_text (GtkLabel *label,
- const char *text);
-char * _gtk_label_get_filename_text (GtkLabel *label);
-GdkPixbuf * get_icon_pixbuf (GIcon *icon,
- int size,
- GtkIconTheme *icon_theme);
-GdkPixbuf * get_mime_type_pixbuf (const char *mime_type,
- int icon_size,
- GtkIconTheme *icon_theme);
-gboolean show_uri (GdkScreen *screen,
- const char *uri,
- guint32 timestamp,
- GError **error);
-void show_help_dialog (GtkWindow *parent,
- const char *section);
-GtkBuilder *
- _gtk_builder_new_from_file (const char *filename);
-GtkBuilder *
- _gtk_builder_new_from_resource (const char *resource_path);
-GtkWidget *
- _gtk_builder_get_widget (GtkBuilder *builder,
- const char *name);
-
-int _gtk_widget_lookup_for_size (GtkWidget *widget,
- GtkIconSize icon_size);
+int _gtk_tree_selection_count_selected (GtkTreeSelection *selection);
+GtkWidget * _gtk_message_dialog_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *stock_id,
+ const char *message,
+ const char *secondary_message,
+ const char *first_button_text,
+ ...);
+gchar * _gtk_request_dialog_run (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *title,
+ const char *message,
+ const char *default_value,
+ int max_length,
+ const char *no_button_text,
+ const char *yes_button_text);
+GtkWidget * _gtk_yesno_dialog_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ const char *message,
+ const char *no_button_text,
+ const char *yes_button_text);
+GtkWidget * _gtk_error_dialog_new (GtkWindow *parent,
+ GtkDialogFlags flags,
+ GList *row_output,
+ const char *primary_text,
+ const char *secondary_text_format,
+ ...) G_GNUC_PRINTF (5, 6);
+void _gtk_error_dialog_run (GtkWindow *parent,
+ const gchar *main_message,
+ const gchar *format,
+ ...);
+void _gtk_entry_set_locale_text (GtkEntry *entry,
+ const char *text);
+char * _gtk_entry_get_locale_text (GtkEntry *entry);
+void _gtk_label_set_locale_text (GtkLabel *label,
+ const char *text);
+char * _gtk_label_get_locale_text (GtkLabel *label);
+void _gtk_entry_set_filename_text (GtkEntry *entry,
+ const char *text);
+char * _gtk_entry_get_filename_text (GtkEntry *entry);
+void _gtk_label_set_filename_text (GtkLabel *label,
+ const char *text);
+char * _gtk_label_get_filename_text (GtkLabel *label);
+GdkPixbuf * _g_icon_get_pixbuf (GIcon *icon,
+ int size,
+ GtkIconTheme *icon_theme);
+GdkPixbuf * _g_mime_type_get_icon (const char *mime_type,
+ int icon_size,
+ GtkIconTheme *icon_theme);
+gboolean show_uri (GdkScreen *screen,
+ const char *uri,
+ guint32 timestamp,
+ GError **error);
+void show_help_dialog (GtkWindow *parent,
+ const char *section);
+GtkBuilder * _gtk_builder_new_from_file (const char *filename);
+GtkBuilder * _gtk_builder_new_from_resource (const char *resource_path);
+GtkWidget * _gtk_builder_get_widget (GtkBuilder *builder,
+ const char *name);
+int _gtk_widget_lookup_for_size (GtkWidget *widget,
+ GtkIconSize icon_size);
#endif
diff --git a/src/test-server.c b/src/test-server.c
index b0fc4db..55899e8 100644
--- a/src/test-server.c
+++ b/src/test-server.c
@@ -161,7 +161,7 @@ main (int argc, char *argv[])
G_CALLBACK (on_signal),
NULL);
-#if 1
+#if 0
/* -- GetSupportedTypes -- */
g_dbus_proxy_call (proxy,
@@ -201,7 +201,7 @@ main (int argc, char *argv[])
g_strfreev (files);
#endif
-#if 0
+#if 1
/* -- Compress -- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]