main window quit remove loops before gtk_main_quit
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / gtkdirsel.c
index a52e877db1c5fee86df556ad5f7b9f5e96a2a8a7..d6d6d44db8b2a22c01903dcbd8cfba2112aa8a45 100644 (file)
@@ -1,6 +1,11 @@
 /* This file is part of the Linux Trace Toolkit viewer
  * Copyright (C) 2003-2004 XangXiu Yang
  *
+ * Contributions :
+ * Jean-Hugues Deschenes
+ *    02-02-2005 Patch removing non standard _fn_match calls
+ *
+ * This program is free software; you can redistribute it and/or modify
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License Version 2 as
  * published by the Free Software Foundation;
  * MA 02111-1307, USA.
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <limits.h> // For PATH_MAX
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
@@ -416,7 +424,7 @@ translate_win32_path (GtkDirSelection *filesel)
 {
   int updated = 0;
   const gchar *path;
-  gchar newPath[MAX_PATH];
+  gchar newPath[PATH_MAX];
 
   /*
    * Retrieve the current path
@@ -451,6 +459,7 @@ gtk_dir_selection_get_type (void)
        sizeof (GtkDirSelection),
        0,              /* n_preallocs */
        (GInstanceInitFunc) gtk_dir_selection_init,
+  NULL  /* GValue */
       };
 
       file_selection_type =
@@ -1916,7 +1925,7 @@ get_real_filename (gchar    *filename,
   /* Check to see if the selection was a drive selector */
   if (isalpha (filename[0]) && (filename[1] == ':'))
     {
-      gchar temp_filename[MAX_PATH];
+      gchar temp_filename[PATH_MAX];
       int len;
 
       cygwin_conv_to_posix_path (filename, temp_filename);
@@ -2304,7 +2313,8 @@ gtk_dir_selection_file_changed (GtkTreeSelection *selection,
            index = new_names->len - 1;
          else
            {
-             gint i = 0, j = 0, cmp;
+             guint i = 0, j = 0;
+        gint cmp;
 
              /* do a quick diff, stopping at the first file not in the
               * old list
@@ -2424,7 +2434,8 @@ gtk_dir_selection_dir_changed (GtkTreeSelection *selection,
            index = new_names->len - 1;
          else
            {
-             gint i = 0, j = 0, cmp;
+             guint i = 0, j = 0;
+        gint cmp;
 
              /* do a quick diff, stopping at the first file not in the
               * old list
@@ -2482,7 +2493,7 @@ gtk_dir_selection_dir_changed (GtkTreeSelection *selection,
       gchar str[256];
       err = gtk_label_get_text (GTK_LABEL (fs->selection_text));
       err += 11;  //pass over "Selection: "
-      sprintf(str,"%s\0",err);
+      sprintf(str,"%s",err);
       
       
       if (fs->last_selected != NULL)
@@ -2534,7 +2545,7 @@ gtk_dir_selection_get_selections (GtkDirSelection *filesel)
   gchar **selections;
   gchar *filename, *dirname;
   gchar *current, *buf;
-  gint i, count;
+  guint i, count;
   gboolean unselected_entry;
 
   g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), NULL);
@@ -2842,7 +2853,6 @@ cmpl_completion_matches (gchar           *text_to_complete,
                         gchar          **remaining_text,
                         CompletionState *cmpl_state)
 {
-  gchar* first_slash;
   PossibleCompletion *poss;
 
   prune_memory_usage (cmpl_state);
@@ -3162,18 +3172,16 @@ open_new_dir (gchar       *dir_name,
 
   for (i = 0; i < entry_count; i += 1)
     {
-      GError *error = NULL;
-
       if (i == 0)
-       dirent = ".";
+             dirent = ".";
       else if (i == 1)
-       dirent = "..";
+               dirent = "..";
       else
-       {
-         dirent = g_dir_read_name (directory);
-         if (!dirent)          /* Directory changed */
-           break;
-       }
+      {
+        dirent = g_dir_read_name (directory);
+        if (!dirent)           /* Directory changed */
+          break;
+           }
 
       sent->entries[n_entries].entry_name = g_filename_to_utf8 (dirent, -1, NULL, NULL, &error);
       if (sent->entries[n_entries].entry_name == NULL
@@ -3348,7 +3356,6 @@ attach_dir (CompletionDirSent *sent,
 
   cmpl_state->directory_storage =
     g_list_prepend (cmpl_state->directory_storage, new_dir);
-
   new_dir->sent = sent;
   new_dir->fullname = g_strdup (dir_name);
   new_dir->fullname_len = strlen (dir_name);
@@ -3722,14 +3729,19 @@ find_completion_dir (gchar          *text_to_complete,
       gchar *found_name = NULL;         /* Quiet gcc */
       gint i;
       gchar* pat_buf = g_new (gchar, len + 1);
+      GtkFileFilter *filter = gtk_file_filter_new ();
+      GtkFileFilterInfo filter_info = {GTK_FILE_FILTER_FILENAME,};
 
       strncpy (pat_buf, *remaining_text, len);
       pat_buf[len] = 0;
 
+      gtk_file_filter_add_pattern (filter, pat_buf);
+
       for (i = 0; i < dir->sent->entry_count; i += 1)
        {
+          filter_info.filename = dir->sent->entries[i].entry_name;
          if (dir->sent->entries[i].is_dir &&
-             _gtk_fnmatch (pat_buf, dir->sent->entries[i].entry_name))
+              gtk_file_filter_filter(filter, &filter_info))
            {
              if (found)
                {
@@ -3830,6 +3842,8 @@ attempt_dir_completion (CompletionState *cmpl_state)
 {
   gchar *pat_buf, *first_slash;
   CompletionDir *dir = cmpl_state->active_completion_dir;
+  GtkFileFilter *filter = gtk_file_filter_new ();
+  GtkFileFilterInfo filter_info = {GTK_FILE_FILTER_FILENAME,};
 
   dir->cmpl_index += 1;
 
@@ -3875,11 +3889,14 @@ attempt_dir_completion (CompletionState *cmpl_state)
        strcpy (pat_buf + len, "*");
     }
 
+  gtk_file_filter_add_pattern (filter, pat_buf);
+
   if (first_slash)
     {
       if (dir->sent->entries[dir->cmpl_index].is_dir)
        {
-         if (_gtk_fnmatch (pat_buf, dir->sent->entries[dir->cmpl_index].entry_name))
+         filter_info.filename = dir->sent->entries[dir->cmpl_index].entry_name;
+           if(gtk_file_filter_filter(filter, &filter_info))
            {
              CompletionDir* new_dir;
 
@@ -3926,8 +3943,9 @@ attempt_dir_completion (CompletionState *cmpl_state)
 
       append_completion_text (dir->sent->entries[dir->cmpl_index].entry_name, cmpl_state);
 
+      filter_info.filename = dir->sent->entries[dir->cmpl_index].entry_name;
       cmpl_state->the_completion.is_a_completion =
-       _gtk_fnmatch (pat_buf, dir->sent->entries[dir->cmpl_index].entry_name);
+       gtk_file_filter_filter(filter, &filter_info);
 
       cmpl_state->the_completion.is_directory = dir->sent->entries[dir->cmpl_index].is_dir;
       if (dir->sent->entries[dir->cmpl_index].is_dir)
@@ -4037,8 +4055,8 @@ compare_cmpl_dir (const void *a,
                  const void *b)
 {
   
-  return strcmp (((CompletionDirEntry*)a)->sort_key,
-                (((CompletionDirEntry*)b))->sort_key);
+  return strcmp (((const CompletionDirEntry*)a)->sort_key,
+                (((const CompletionDirEntry*)b))->sort_key);
 }
 
 static gint
This page took 0.026031 seconds and 4 git commands to generate.