gnome-commander r2507 - branches/gcmd-1-3/src



Author: epiotr
Date: Sat Apr  4 08:43:48 2009
New Revision: 2507
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2507&view=rev

Log:
Code cleanup

Modified:
   branches/gcmd-1-3/src/gnome-cmd-dir.cc
   branches/gcmd-1-3/src/gnome-cmd-file-list.cc
   branches/gcmd-1-3/src/gnome-cmd-file.cc
   branches/gcmd-1-3/src/imageloader.cc
   branches/gcmd-1-3/src/imageloader.h

Modified: branches/gcmd-1-3/src/gnome-cmd-dir.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-dir.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-dir.cc	Sat Apr  4 08:43:48 2009
@@ -707,19 +707,16 @@
 }
 
 
-static gboolean file_already_exists (GnomeCmdDir *dir, const gchar *uri_str)
+inline gboolean file_already_exists (GnomeCmdDir *dir, const gchar *uri_str)
 {
     g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), TRUE);
     g_return_val_if_fail (uri_str != NULL, TRUE);
 
-    GnomeCmdFile *finfo = dir->priv->file_collection->find(uri_str);
-
-    return finfo != NULL;
+    return dir->priv->file_collection->find(uri_str) != NULL;
 }
 
 
-/* A file has been created. Create a new GnomeCmdFile object for that file
- */
+// A file has been created. Create a new GnomeCmdFile object for that file
 void gnome_cmd_dir_file_created (GnomeCmdDir *dir, const gchar *uri_str)
 {
     g_return_if_fail (GNOME_CMD_IS_DIR (dir));
@@ -734,75 +731,71 @@
     GnomeVFSResult res = gnome_vfs_get_file_info_uri (uri, info, infoOpts);
     gnome_vfs_uri_unref (uri);
 
-    GnomeCmdFile *finfo;
+    GnomeCmdFile *f;
 
     if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
-        finfo = GNOME_CMD_FILE (gnome_cmd_dir_new_from_info (info, dir));
+        f = GNOME_CMD_FILE (gnome_cmd_dir_new_from_info (info, dir));
     else
-        finfo = gnome_cmd_file_new (info, dir);
+        f = gnome_cmd_file_new (info, dir);
 
-    dir->priv->file_collection->add(finfo);
+    dir->priv->file_collection->add(f);
     dir->priv->files = dir->priv->file_collection->get_list();
 
-    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_CREATED], finfo);
+    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_CREATED], f);
 }
 
 
-/* A file has been deleted. Remove the corresponding GnomeCmdFile
- */
+// A file has been deleted. Remove the corresponding GnomeCmdFile
 void gnome_cmd_dir_file_deleted (GnomeCmdDir *dir, const gchar *uri_str)
 {
     g_return_if_fail (GNOME_CMD_IS_DIR (dir));
     g_return_if_fail (uri_str != NULL);
 
-    GnomeCmdFile *finfo = dir->priv->file_collection->find(uri_str);
+    GnomeCmdFile *f = dir->priv->file_collection->find(uri_str);
 
-    if (!GNOME_CMD_IS_FILE (finfo))
+    if (!GNOME_CMD_IS_FILE (f))
         return;
 
-    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_DELETED], finfo);
+    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_DELETED], f);
 
     dir->priv->file_collection->remove(uri_str);
     dir->priv->files = dir->priv->file_collection->get_list();
 }
 
 
-/* A file has been changed. Find the corresponding GnomeCmdFile, update its
- * GnomeVFSFileInfo
- */
+// A file has been changed. Find the corresponding GnomeCmdFile, update its GnomeVFSFileInfo
 void gnome_cmd_dir_file_changed (GnomeCmdDir *dir, const gchar *uri_str)
 {
     g_return_if_fail (GNOME_CMD_IS_DIR (dir));
     g_return_if_fail (uri_str != NULL);
 
-    GnomeVFSFileInfoOptions infoOpts = GNOME_VFS_FILE_INFO_GET_MIME_TYPE;
-    GnomeCmdFile *finfo = dir->priv->file_collection->find(uri_str);
+    GnomeCmdFile *f = dir->priv->file_collection->find(uri_str);
 
-    g_return_if_fail (GNOME_CMD_IS_FILE (finfo));
+    g_return_if_fail (GNOME_CMD_IS_FILE (f));
 
-    GnomeVFSURI *uri = gnome_cmd_file_get_uri (finfo);
+    GnomeVFSURI *uri = gnome_cmd_file_get_uri (f);
     GnomeVFSFileInfo *info = gnome_vfs_file_info_new ();
-    GnomeVFSResult res = gnome_vfs_get_file_info_uri (uri, info, infoOpts);
+    GnomeVFSResult res = gnome_vfs_get_file_info_uri (uri, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
     gnome_vfs_uri_unref (uri);
 
-    gnome_cmd_file_update_info (finfo, info);
-    gnome_cmd_file_invalidate_metadata (finfo);
-    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_CHANGED], finfo);
+    gnome_cmd_file_update_info (f, info);
+    gnome_cmd_file_invalidate_metadata (f);
+    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_CHANGED], f);
 }
 
 
-void gnome_cmd_dir_file_renamed (GnomeCmdDir *dir, GnomeCmdFile *finfo, const gchar *old_uri_str)
+void gnome_cmd_dir_file_renamed (GnomeCmdDir *dir, GnomeCmdFile *f, const gchar *old_uri_str)
 {
     g_return_if_fail (GNOME_CMD_IS_DIR (dir));
-    g_return_if_fail (GNOME_CMD_IS_FILE (finfo));
+    g_return_if_fail (GNOME_CMD_IS_FILE (f));
     g_return_if_fail (old_uri_str!=NULL);
 
-    if (GNOME_CMD_IS_DIR (finfo))
+    if (GNOME_CMD_IS_DIR (f))
         gnome_cmd_con_remove_from_cache (dir->priv->con, old_uri_str);
 
     dir->priv->file_collection->remove(old_uri_str);
-    dir->priv->file_collection->add(finfo);
-    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_RENAMED], finfo);
+    dir->priv->file_collection->add(f);
+    gtk_signal_emit (GTK_OBJECT (dir), dir_signals[FILE_RENAMED], f);
 }
 
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file-list.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file-list.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file-list.cc	Sat Apr  4 08:43:48 2009
@@ -315,16 +315,16 @@
 }
 
 
-static void select_file (GnomeCmdFileList *fl, GnomeCmdFile *finfo)
+static void select_file (GnomeCmdFileList *fl, GnomeCmdFile *f)
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
-    g_return_if_fail (finfo != NULL);
-    g_return_if_fail (finfo->info != NULL);
+    g_return_if_fail (f != NULL);
+    g_return_if_fail (f->info != NULL);
 
-    if (strcmp (finfo->info->name, "..") == 0)
+    if (strcmp (f->info->name, "..") == 0)
         return;
 
-    gint row = fl->get_row_from_file(finfo);
+    gint row = fl->get_row_from_file(f);
     if (row == -1)
         return;
 
@@ -341,35 +341,35 @@
         }
     }
 
-    if (g_list_index (fl->priv->selected_files, finfo) != -1)
+    if (g_list_index (fl->priv->selected_files, f) != -1)
         return;
 
-    gnome_cmd_file_ref (finfo);
-    fl->priv->selected_files = g_list_append (fl->priv->selected_files, finfo);
+    gnome_cmd_file_ref (f);
+    fl->priv->selected_files = g_list_append (fl->priv->selected_files, f);
 
     gtk_signal_emit (*fl, file_list_signals[FILES_CHANGED]);
 }
 
 
-static void unselect_file (GnomeCmdFileList *fl, GnomeCmdFile *finfo)
+static void unselect_file (GnomeCmdFileList *fl, GnomeCmdFile *f)
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
-    g_return_if_fail (finfo != NULL);
+    g_return_if_fail (f != NULL);
 
-    gint row = fl->get_row_from_file(finfo);
+    gint row = fl->get_row_from_file(f);
     if (row == -1)
         return;
 
-    if (g_list_index (fl->priv->selected_files, finfo) == -1)
+    if (g_list_index (fl->priv->selected_files, f) == -1)
         return;
 
-    gnome_cmd_file_unref (finfo);
-    fl->priv->selected_files = g_list_remove (fl->priv->selected_files, finfo);
+    gnome_cmd_file_unref (f);
+    fl->priv->selected_files = g_list_remove (fl->priv->selected_files, f);
 
     if (!gnome_cmd_data.use_ls_colors)
         gtk_clist_set_row_style (*fl, row, row%2 ? alt_list_style : list_style);
     else
-        if (LsColor *col = ls_colors_get (finfo))
+        if (LsColor *col = ls_colors_get (f))
         {
             GnomeCmdColorTheme *colors = gnome_cmd_data_get_current_color_theme ();
             GdkColor *fg = col->fg ? col->fg : colors->norm_fg;
@@ -383,21 +383,21 @@
 }
 
 
-inline void toggle_file (GnomeCmdFileList *fl, GnomeCmdFile *finfo)
+inline void toggle_file (GnomeCmdFileList *fl, GnomeCmdFile *f)
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
-    g_return_if_fail (finfo != NULL);
+    g_return_if_fail (f != NULL);
 
-    gint row = fl->get_row_from_file(finfo);
+    gint row = fl->get_row_from_file(f);
 
     if (row == -1)
         return;
 
     if (row < fl->priv->visible_files.size())
-        if (g_list_index (fl->priv->selected_files, finfo) == -1)
-            select_file (fl, finfo);
+        if (g_list_index (fl->priv->selected_files, f) == -1)
+            select_file (fl, f);
         else
-            unselect_file (fl, finfo);
+            unselect_file (fl, f);
 }
 
 
@@ -407,10 +407,10 @@
 
     fl->priv->cur_file = row;
 
-    GnomeCmdFile *finfo = fl->get_file_at_row(row);
+    GnomeCmdFile *f = fl->get_file_at_row(row);
 
-    if (finfo)
-        select_file (fl, finfo);
+    if (f)
+        select_file (fl, f);
 }
 
 
@@ -436,10 +436,10 @@
 
     fl->priv->cur_file = row;
 
-    GnomeCmdFile *finfo = fl->get_file_at_row(row);
+    GnomeCmdFile *f = fl->get_file_at_row(row);
 
-    if (finfo)
-        toggle_file (fl, finfo);
+    if (f)
+        toggle_file (fl, f);
 }
 
 
@@ -471,18 +471,18 @@
 
     for (GList *tmp=fl->get_visible_files(); tmp; tmp=tmp->next)
     {
-        GnomeCmdFile *finfo = (GnomeCmdFile *) tmp->data;
+        GnomeCmdFile *f = (GnomeCmdFile *) tmp->data;
 
-        if (finfo && finfo->info)
+        if (f && f->info)
         {
-            const gchar *ext2 = gnome_cmd_file_get_extension (finfo);
+            const gchar *ext2 = gnome_cmd_file_get_extension (f);
 
             if (ext2 && strcmp (ext1, ext2) == 0)
             {
                 if (select)
-                    select_file (fl, finfo);
+                    select_file (fl, f);
                 else
-                    unselect_file (fl, finfo);
+                    unselect_file (fl, f);
             }
         }
     }
@@ -497,15 +497,15 @@
 
     for (GList *tmp=fl->get_visible_files(); tmp; tmp=tmp->next)
     {
-        GnomeCmdFile *finfo = (GnomeCmdFile *) tmp->data;
+        GnomeCmdFile *f = (GnomeCmdFile *) tmp->data;
 
-        if (finfo && finfo->info)
-            if (filter.match(finfo->info->name))
+        if (f && f->info)
+            if (filter.match(f->info->name))
             {
                 if (mode)
-                    select_file (fl, finfo);
+                    select_file (fl, f);
                 else
-                    unselect_file (fl, finfo);
+                    unselect_file (fl, f);
             }
     }
 }
@@ -593,19 +593,19 @@
         // create a list with the uri's of the selected files and calculate the total_length needed
         for (GList *tmp=sel_files; tmp; tmp=tmp->next)
         {
-            GnomeCmdFile *finfo = (GnomeCmdFile *) tmp->data;
+            GnomeCmdFile *f = (GnomeCmdFile *) tmp->data;
             const gchar *fn = NULL;
             gchar *uri_str;
 
-            if (gnome_vfs_uri_is_local (gnome_cmd_file_get_uri (finfo)))
+            if (gnome_vfs_uri_is_local (gnome_cmd_file_get_uri (f)))
             {
 #ifdef UNESCAPE_LOCAL_FILES
-                fn = gnome_vfs_unescape_string (gnome_cmd_file_get_uri_str (finfo), 0);
+                fn = gnome_vfs_unescape_string (gnome_cmd_file_get_uri_str (f), 0);
 #endif
             }
 
             if (!fn)
-                fn = gnome_cmd_file_get_uri_str (finfo);
+                fn = gnome_cmd_file_get_uri_str (f);
 
             uri_str = g_strdup_printf ("%s\r\n", fn);
             uri_str_list = g_list_append (uri_str_list, uri_str);
@@ -638,8 +638,8 @@
     else
         if (listlen == 1)
         {
-            GnomeCmdFile *finfo = (GnomeCmdFile *) sel_files->data;
-            char *uri_str = g_strdup (gnome_cmd_file_get_uri_str (finfo));
+            GnomeCmdFile *f = (GnomeCmdFile *) sel_files->data;
+            char *uri_str = g_strdup (gnome_cmd_file_get_uri_str (f));
 
             *file_list_len = strlen (uri_str) + 1;
             return uri_str;
@@ -1054,9 +1054,9 @@
         return FALSE;
     }
 
-    GnomeCmdFile *finfo = fl->get_file_at_row(row);
+    GnomeCmdFile *f = fl->get_file_at_row(row);
 
-    gtk_signal_emit (*fl, file_list_signals[FILE_CLICKED], finfo, event);
+    gtk_signal_emit (*fl, file_list_signals[FILE_CLICKED], f, event);
 
     gtk_signal_emit_stop_by_name (GTK_OBJECT (clist), "button-press-event");
 
@@ -1064,13 +1064,13 @@
 }
 
 
-static gboolean mime_exec_file (GnomeCmdFile *finfo)
+inline gboolean mime_exec_file (GnomeCmdFile *f)
 {
-    g_return_val_if_fail (GNOME_CMD_IS_FILE (finfo), FALSE);
+    g_return_val_if_fail (GNOME_CMD_IS_FILE (f), FALSE);
 
-    if (finfo->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
+    if (f->info->type == GNOME_VFS_FILE_TYPE_REGULAR)
     {
-        mime_exec_single (finfo);
+        mime_exec_single (f);
         return TRUE;
     }
 
@@ -1078,21 +1078,21 @@
 }
 
 
-static void on_file_clicked (GnomeCmdFileList *fl, GnomeCmdFile *finfo, GdkEventButton *event, gpointer data)
+static void on_file_clicked (GnomeCmdFileList *fl, GnomeCmdFile *f, GdkEventButton *event, gpointer data)
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
-    g_return_if_fail (finfo != NULL);
+    g_return_if_fail (f != NULL);
     g_return_if_fail (event != NULL);
 
     if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
     {
-        mime_exec_file (finfo);
+        mime_exec_file (f);
     }
     else
         if (event->type == GDK_BUTTON_PRESS && (event->button == 1 || event->button == 3))
         {
             gint prev_row = fl->priv->cur_file;
-            gint row = fl->get_row_from_file(finfo);
+            gint row = fl->get_row_from_file(f);
 
             fl->select_row(row);
             gtk_widget_grab_focus (*fl);
@@ -1116,22 +1116,22 @@
             }
             else
                 if (event->button == 3)
-                    if (strcmp (finfo->info->name, "..") != 0)
+                    if (strcmp (f->info->name, "..") != 0)
                     {
                         if (gnome_cmd_data.right_mouse_button_mode == GnomeCmdData::RIGHT_BUTTON_SELECTS)
                         {
-                            if (g_list_index (fl->priv->selected_files, finfo) == -1)
+                            if (g_list_index (fl->priv->selected_files, f) == -1)
                             {
-                                select_file (fl, finfo);
+                                select_file (fl, f);
                                 fl->priv->right_mb_sel_state = 1;
                             }
                             else
                             {
-                                unselect_file (fl, finfo);
+                                unselect_file (fl, f);
                                 fl->priv->right_mb_sel_state = 0;
                             }
 
-                            fl->priv->right_mb_down_file = finfo;
+                            fl->priv->right_mb_down_file = f;
                             fl->priv->right_mb_timeout_id =
                                 g_timeout_add (POPUP_TIMEOUT, (GSourceFunc) on_right_mb_timeout, fl);
                         }
@@ -1158,14 +1158,14 @@
 
         if (row != -1)
         {
-            GnomeCmdFile *finfo = fl->get_file_at_row(row+1);
-            if (finfo)
+            GnomeCmdFile *f = fl->get_file_at_row(row+1);
+            if (f)
             {
                 fl->select_row(row+1);
                 if (fl->priv->right_mb_sel_state)
-                    select_file (fl, finfo);
+                    select_file (fl, f);
                 else
-                    unselect_file (fl, finfo);
+                    unselect_file (fl, f);
             }
         }
     }
@@ -1189,8 +1189,8 @@
     {
         if (event->button == 1 && state_is_blank (event->state))
         {
-            GnomeCmdFile *finfo = fl->get_file_at_row(row);
-            if (finfo && g_list_index (fl->priv->selected_files, finfo) == -1)
+            GnomeCmdFile *f = fl->get_file_at_row(row);
+            if (f && g_list_index (fl->priv->selected_files, f) == -1)
                 fl->unselect_all();
             return TRUE;
         }
@@ -1353,11 +1353,11 @@
 }
 
 
-inline void add_file_to_clist (GnomeCmdFileList *fl, GnomeCmdFile *finfo, gint in_row)
+inline void add_file_to_clist (GnomeCmdFileList *fl, GnomeCmdFile *f, gint in_row)
 {
     GtkCList *clist = GTK_CLIST (fl);
 
-    FileFormatData data(finfo,FALSE);
+    FileFormatData data(f,FALSE);
 
     gint row = in_row == -1 ? gtk_clist_append (clist, data.text) : gtk_clist_insert (clist, in_row, data.text);
 
@@ -1366,7 +1366,7 @@
         gtk_clist_set_row_style (clist, row, row%2 ? alt_list_style : list_style);
     else
     {
-        LsColor *col = ls_colors_get (finfo);
+        LsColor *col = ls_colors_get (f);
         if (col)
         {
             if (col->bg)
@@ -1376,19 +1376,19 @@
         }
     }
 
-    gtk_clist_set_row_data (clist, row, finfo);
+    gtk_clist_set_row_data (clist, row, f);
 
     // If the use wants icons to show file types set it now
     if (gnome_cmd_data.layout != GNOME_CMD_LAYOUT_TEXT)
     {
         gtk_clist_set_pixmap (clist, row, 0,
-                              gnome_cmd_file_get_type_pixmap (finfo),
-                              gnome_cmd_file_get_type_mask (finfo));
+                              gnome_cmd_file_get_type_pixmap (f),
+                              gnome_cmd_file_get_type_mask (f));
     }
 
     // If we have been waiting for this file to show up, focus it
     if (fl->priv->focus_later &&
-        strcmp (gnome_cmd_file_get_name (finfo), fl->priv->focus_later) == 0)
+        strcmp (gnome_cmd_file_get_name (f), fl->priv->focus_later) == 0)
         focus_file_at_row (fl, row);
 }
 
@@ -1681,14 +1681,14 @@
 
     for (GList *tmp=get_visible_files(); tmp; tmp = tmp->next)
     {
-        GnomeCmdFile *finfo = (GnomeCmdFile *) tmp->data;
+        GnomeCmdFile *f = (GnomeCmdFile *) tmp->data;
 
-        if (finfo && finfo->info)
+        if (f && f->info)
         {
-            if (g_list_index (sel, finfo) == -1)
-                select_file (this, finfo);
+            if (g_list_index (sel, f) == -1)
+                select_file (this, f);
             else
-                unselect_file (this, finfo);
+                unselect_file (this, f);
         }
     }
 
@@ -1795,15 +1795,15 @@
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
 
-    GnomeCmdFile *finfo = fl->get_selected_file();
+    GnomeCmdFile *f = fl->get_selected_file();
 
-    if (GNOME_CMD_IS_FILE (finfo))
+    if (GNOME_CMD_IS_FILE (f))
     {
         gint x, y, w, h;
 
         get_focus_row_coordinates (fl, x, y, w, h);
 
-        GtkWidget *dialog = gnome_cmd_rename_dialog_new (finfo, x, y, w, h);
+        GtkWidget *dialog = gnome_cmd_rename_dialog_new (f, x, y, w, h);
 
         gtk_widget_ref (dialog);
         gtk_widget_show (dialog);
@@ -1863,10 +1863,10 @@
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
 
-    GnomeCmdFile *finfo = fl->get_selected_file();
+    GnomeCmdFile *f = fl->get_selected_file();
 
-    if (finfo)
-        gnome_cmd_file_show_properties (finfo);
+    if (f)
+        gnome_cmd_file_show_properties (f);
 }
 
 
@@ -1908,14 +1908,14 @@
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
 
-    GnomeCmdFile *finfo = fl->get_selected_file();
+    GnomeCmdFile *f = fl->get_selected_file();
 
-    if (!finfo)  return;
+    if (!f)  return;
 
-    if (finfo->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
-        create_error_dialog (_("Not an ordinary file: %s"), finfo->info->name);
+    if (f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+        create_error_dialog (_("Not an ordinary file: %s"), f->info->name);
     else
-        gnome_cmd_file_view (finfo, internal_viewer);
+        gnome_cmd_file_view (f, internal_viewer);
 }
 
 
@@ -1923,14 +1923,14 @@
 {
     g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
 
-    GnomeCmdFile *finfo = fl->get_selected_file();
+    GnomeCmdFile *f = fl->get_selected_file();
 
-    if (!finfo)  return;
+    if (!f)  return;
 
-    if (finfo->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
-        create_error_dialog (_("Not an ordinary file: %s"), finfo->info->name);
+    if (f->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
+        create_error_dialog (_("Not an ordinary file: %s"), f->info->name);
     else
-        gnome_cmd_file_edit (finfo);
+        gnome_cmd_file_edit (f);
 }
 
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file.cc	Sat Apr  4 08:43:48 2009
@@ -334,9 +334,16 @@
 
     GnomeVFSURI *uri = gnome_cmd_file_get_uri (f);
     GnomeVFSResult result = gnome_vfs_set_file_info_uri (uri, new_info, GNOME_VFS_SET_FILE_INFO_NAME);
+
+    if (result==GNOME_VFS_OK)       //  re-read GnomeVFSFileInfo for the new MIME type
+    {
+        gnome_vfs_file_info_clear (new_info);
+        result = gnome_vfs_get_file_info_uri (uri, new_info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
+    }
+
     gnome_vfs_uri_unref (uri);
 
-    if (result == GNOME_VFS_OK && has_parent_dir (f))
+    if (result==GNOME_VFS_OK && has_parent_dir (f))
     {
         gnome_cmd_file_update_info (f, new_info);
         gnome_cmd_dir_file_renamed (get_parent_dir (f), f, old_uri_str);

Modified: branches/gcmd-1-3/src/imageloader.cc
==============================================================================
--- branches/gcmd-1-3/src/imageloader.cc	(original)
+++ branches/gcmd-1-3/src/imageloader.cc	Sat Apr  4 08:43:48 2009
@@ -31,14 +31,14 @@
 #define NUM_FILE_TYPE_PIXMAPS 8
 
 
-typedef struct
+struct CacheEntry
 {
     gboolean dead_end;
     GdkPixmap *pixmap;
     GdkBitmap *mask;
     GdkPixmap *lnk_pixmap;
     GdkBitmap *lnk_mask;
-} CacheEntry;
+};
 
 
 static const gchar *file_type_pixmap_files[NUM_FILE_TYPE_PIXMAPS] = {
@@ -92,13 +92,11 @@
  */
 void IMAGE_init ()
 {
-    gint i;
-
     mime_cache = g_hash_table_new (g_str_hash, g_str_equal);
 
      // Load misc icons
 
-    for (i=1; i<NUM_PIXMAPS; i++)
+    for (gint i=1; i<NUM_PIXMAPS; i++)
     {
         gchar *path = g_build_path (G_DIR_SEPARATOR_S, PIXMAPS_DIR, pixmap_files[i], NULL);
 
@@ -124,7 +122,7 @@
 
      // Load file type icons
 
-     for (i=0; i<NUM_FILE_TYPE_PIXMAPS; i++)
+     for (gint i=0; i<NUM_FILE_TYPE_PIXMAPS; i++)
     {
         CacheEntry *e = &file_type_pixmaps[i];
         gchar *path = g_build_path (G_DIR_SEPARATOR_S, PIXMAPS_DIR, file_type_pixmap_files[i], NULL);
@@ -148,35 +146,9 @@
 }
 
 
-GdkPixmap *IMAGE_get_pixmap (Pixmap pixmap_id)
-{
-    if (pixmap_id > 0 && pixmap_id < NUM_PIXMAPS && pixmaps[pixmap_id] != NULL)
-        return pixmaps[pixmap_id]->pixmap;
-    return NULL;
-}
-
-
-GdkBitmap *IMAGE_get_mask (Pixmap pixmap_id)
-{
-    if (pixmap_id > 0 && pixmap_id < NUM_PIXMAPS && pixmaps[pixmap_id] != NULL)
-        return pixmaps[pixmap_id]->mask;
-    return NULL;
-}
-
-
-GdkPixbuf *IMAGE_get_pixbuf (Pixmap pixmap_id)
-{
-    if (pixmap_id > 0 && pixmap_id < NUM_PIXMAPS && pixmaps[pixmap_id] != NULL)
-        return pixmaps[pixmap_id]->pixbuf;
-    return NULL;
-}
-
-
 GnomeCmdPixmap *IMAGE_get_gnome_cmd_pixmap (Pixmap pixmap_id)
 {
-    if (pixmap_id > 0 && pixmap_id < NUM_PIXMAPS)
-        return pixmaps[pixmap_id];
-    return NULL;
+    return pixmap_id > 0 && pixmap_id < NUM_PIXMAPS ? pixmaps[pixmap_id] : NULL;
 }
 
 
@@ -249,8 +221,7 @@
  * Returns the full path to an image for the given filetype in the given directory.
  *
  */
-static gchar *
-get_mime_file_type_icon_path (GnomeVFSFileType type, const gchar *icon_dir)
+inline gchar *get_mime_file_type_icon_path (GnomeVFSFileType type, const gchar *icon_dir)
 {
     return g_build_path (G_DIR_SEPARATOR_S, icon_dir, get_type_icon_name (type), NULL);
 }
@@ -261,12 +232,12 @@
  * the gived directory. There is no guarantee that the image exists this
  * function just returns the name that the icon should have if it exists.
  */
-static gchar *
-get_mime_document_type_icon_path (const gchar *mime_type, const gchar *icon_dir)
+inline gchar *get_mime_document_type_icon_path (const gchar *mime_type, const gchar *icon_dir)
 {
     gchar *icon_name = get_mime_icon_name (mime_type);
     gchar *icon_path = g_build_path (G_DIR_SEPARATOR_S, icon_dir, icon_name, NULL);
     g_free (icon_name);
+
     return icon_path;
 }
 
@@ -435,7 +406,7 @@
 }
 
 
-static gboolean get_type_icon (GnomeVFSFileType type,
+inline gboolean get_type_icon (GnomeVFSFileType type,
                                gboolean symlink,
                                GdkPixmap **pixmap,
                                GdkBitmap **mask)
@@ -484,6 +455,7 @@
     }
 
     g_free (entry);
+
     return TRUE;
 }
 

Modified: branches/gcmd-1-3/src/imageloader.h
==============================================================================
--- branches/gcmd-1-3/src/imageloader.h	(original)
+++ branches/gcmd-1-3/src/imageloader.h	Sat Apr  4 08:43:48 2009
@@ -27,7 +27,7 @@
  * If you add a pixmap id here be sure to add its filename in
  * the array in imageloader.c
  */
-typedef enum
+enum Pixmap
 {
     PIXMAP_NONE,
 
@@ -47,17 +47,32 @@
     PIXMAP_INTERNAL_VIEWER,
 
     NUM_PIXMAPS
-} Pixmap;
+};
 
 
 void IMAGE_init ();
 void IMAGE_free ();
 
-GdkPixmap *IMAGE_get_pixmap (Pixmap pixmap_id);
-GdkBitmap *IMAGE_get_mask (Pixmap pixmap_id);
-GdkPixbuf *IMAGE_get_pixbuf (Pixmap pixmap_id);
 GnomeCmdPixmap *IMAGE_get_gnome_cmd_pixmap (Pixmap pixmap_id);
 
+inline GdkPixmap *IMAGE_get_pixmap (Pixmap pixmap_id)
+{
+    GnomeCmdPixmap *pixmap = IMAGE_get_gnome_cmd_pixmap (pixmap_id);
+    return pixmap ? pixmap->pixmap : NULL;
+}
+
+inline GdkBitmap *IMAGE_get_mask (Pixmap pixmap_id)
+{
+    GnomeCmdPixmap *pixmap = IMAGE_get_gnome_cmd_pixmap (pixmap_id);
+    return pixmap ? pixmap->mask : NULL;
+}
+
+inline GdkPixbuf *IMAGE_get_pixbuf (Pixmap pixmap_id)
+{
+    GnomeCmdPixmap *pixmap = IMAGE_get_gnome_cmd_pixmap (pixmap_id);
+    return pixmap ? pixmap->pixbuf : NULL;
+}
+
 gboolean IMAGE_get_pixmap_and_mask (GnomeVFSFileType type,
                                     const gchar *mime_type,
                                     gboolean symlink,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]