[easytag/wip/application-window: 19/20] Move browser to EtBrowser object



commit 9a1538560f80555f8aa0660c6c4b62a5f10d1329
Author: David King <amigadave amigadave com>
Date:   Wed Feb 12 23:06:30 2014 +0000

    Move browser to EtBrowser object

 src/application_window.c |  158 ++++++++++-
 src/application_window.h |   12 +
 src/bar.c                |   43 ++-
 src/browser.c            |  756 ++++++++++++++++++++++++++++------------------
 src/browser.h            |  106 +++----
 src/scan_dialog.c        |   41 ---
 src/scan_dialog.h        |    1 -
 7 files changed, 697 insertions(+), 420 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index 70f16e8..01a9d6c 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -46,6 +46,8 @@ G_DEFINE_TYPE (EtApplicationWindow, et_application_window, GTK_TYPE_WINDOW)
 
 struct _EtApplicationWindowPrivate
 {
+    GtkWidget *browser;
+
     GtkWidget *file_area;
     GtkWidget *log_area;
     GtkWidget *tag_area;
@@ -947,16 +949,18 @@ et_tag_field_on_key_press_event (GtkEntry *entry, GdkEventKey *event,
 }
 
 static GtkWidget *
-create_browser_area (void)
+create_browser_area (EtApplicationWindow *self)
 {
+    EtApplicationWindowPrivate *priv;
     GtkWidget *frame;
-    GtkWidget *tree;
+
+    priv = et_application_window_get_instance_private (self);
 
     frame = gtk_frame_new (_("Browser"));
     gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
 
-    tree = Create_Browser_Items (MainWindow);
-    gtk_container_add (GTK_CONTAINER (frame), tree);
+    priv->browser = GTK_WIDGET (et_browser_new ());
+    gtk_container_add (GTK_CONTAINER (frame), priv->browser);
 
     /* Don't load init dir here because Tag area hasn't been yet created!.
      * It will be load at the end of the main function */
@@ -1716,7 +1720,7 @@ et_application_window_init (EtApplicationWindow *self)
     priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
 
     /* Browser (Tree + File list + Entry) */
-    widget = create_browser_area ();
+    widget = create_browser_area (self);
     gtk_paned_pack1 (GTK_PANED (priv->hpaned), widget, TRUE, TRUE);
 
     /* Vertical box for FileArea + TagArea */
@@ -2004,6 +2008,150 @@ et_application_window_search_cddb_for_selection (G_GNUC_UNUSED GtkAction *action
     et_cddb_dialog_search_from_selection (ET_CDDB_DIALOG (priv->cddb_dialog));
 }
 
+void
+et_application_window_browser_collapse (G_GNUC_UNUSED GtkAction *action,
+                                        gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_collapse (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_browser_reload (G_GNUC_UNUSED GtkAction *action,
+                                      gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_reload (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_home (G_GNUC_UNUSED GtkAction *action,
+                               gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_go_home (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_desktop (G_GNUC_UNUSED GtkAction *action,
+                                  gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_go_desktop (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_documents (G_GNUC_UNUSED GtkAction *action,
+                                    gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_go_documents (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_download (G_GNUC_UNUSED GtkAction *action,
+                                   gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_go_download (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_music (G_GNUC_UNUSED GtkAction *action,
+                                gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_go_music (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_go_parent (G_GNUC_UNUSED GtkAction *action,
+                                 gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_go_parent (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_reload_directory (G_GNUC_UNUSED GtkAction *action,
+                                        gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_reload_directory (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_open_directory_with_dialog (G_GNUC_UNUSED GtkAction *action,
+                                                       gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_show_open_directory_with_dialog (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_open_files_with_dialog (G_GNUC_UNUSED GtkAction *action,
+                                                   gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_show_open_files_with_dialog (ET_BROWSER (priv->browser));
+}
+
+void
+et_application_window_show_rename_directory_dialog (G_GNUC_UNUSED GtkAction *action,
+                                                    gpointer user_data)
+{
+    EtApplicationWindowPrivate *priv;
+    EtApplicationWindow *self = ET_APPLICATION_WINDOW (user_data);
+
+    priv = et_application_window_get_instance_private (self);
+
+    et_browser_show_rename_directory_dialog (ET_BROWSER (priv->browser));
+}
+
 GtkWidget *
 et_application_window_get_scan_dialog (EtApplicationWindow *self)
 {
diff --git a/src/application_window.h b/src/application_window.h
index f5804e3..27a0aa0 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -63,6 +63,18 @@ void et_application_window_show_preferences_dialog_scanner (GtkAction *action, g
 GtkWidget * et_application_window_get_cddb_dialog (EtApplicationWindow *self);
 void et_application_window_show_cddb_dialog (GtkAction *action, gpointer user_data);
 void et_application_window_search_cddb_for_selection (GtkAction *action, gpointer user_data);
+void et_application_window_browser_collapse (GtkAction *action, gpointer user_data);
+void et_application_window_browser_reload (GtkAction *action, gpointer user_data);
+void et_application_window_go_home (GtkAction *action, gpointer user_data);
+void et_application_window_go_desktop (GtkAction *action, gpointer user_data);
+void et_application_window_go_documents (GtkAction *action, gpointer user_data);
+void et_application_window_go_download (GtkAction *action, gpointer user_data);
+void et_application_window_go_music (GtkAction *action, gpointer user_data);
+void et_application_window_go_parent (GtkAction *action, gpointer user_data);
+void et_application_window_reload_directory (GtkAction *action, gpointer user_data);
+void et_application_window_show_open_directory_with_dialog (GtkAction *action, gpointer user_data);
+void et_application_window_show_open_files_with_dialog (GtkAction *action, gpointer user_data);
+void et_application_window_show_rename_directory_dialog (GtkAction *action, gpointer user_data);
 GtkWidget * et_application_window_get_scan_dialog (EtApplicationWindow *self);
 void et_application_window_show_scan_dialog (GtkAction *action, gpointer user_data);
 void et_application_window_scan_selected_files (GtkAction *action, gpointer user_data);
diff --git a/src/bar.c b/src/bar.c
index 67e8246..abe492f 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -79,6 +79,16 @@ static void on_menu_item_deselect (GtkMenuItem *item, gpointer user_data);
 #define QCASE(string,callback) if (quark == g_quark_from_string((string))) { (callback)(); }
 #define QCASE_DATA(string,callback,data) if (quark == g_quark_from_string((string))) { (callback)((data)); }
 
+static void
+reload_browser (gpointer data)
+{
+    EtApplicationWindow *window;
+
+    window = ET_APPLICATION_WINDOW (data);
+
+    et_application_window_browser_reload (NULL, window);
+}
+
 /*
  * Menu bar
  */
@@ -128,7 +138,7 @@ Menu_Sort_Action (GtkAction *item, gpointer data)
     QCASE_DATA(AM_SORT_DESCENDING_FILE_BITRATE,    ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_BITRATE);
     QCASE_DATA(AM_SORT_ASCENDING_FILE_SAMPLERATE,  ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_SAMPLERATE);
     QCASE_DATA(AM_SORT_DESCENDING_FILE_SAMPLERATE, ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_SAMPLERATE);
-    QCASE_DATA(AM_INITIALIZE_TREE,                 Browser_Tree_Rebuild,                      NULL);
+    QCASE_DATA(AM_INITIALIZE_TREE, reload_browser, data);
     Browser_List_Refresh_Sort ();
 }
 
@@ -205,7 +215,7 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
 
         { AM_OPEN_FILE_WITH, GTK_STOCK_OPEN, _("Open Files With…"),
           "<Primary><Shift>O", _("Run a command on the selected files"),
-          G_CALLBACK (Browser_Open_Run_Program_List_Window) },
+          G_CALLBACK (et_application_window_show_open_files_with_dialog) },
         { AM_SELECT_ALL, GTK_STOCK_SELECT_ALL, NULL, "<Primary>A",
           _("Select all"), G_CALLBACK (et_application_window_select_all) },
         { AM_UNSELECT_ALL, "easytag-unselect-all", _("Unselect All"),
@@ -253,39 +263,42 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
         { MENU_BROWSER,                NULL,                   _("_Browser"),                      NULL,     
           NULL,                               NULL },
         { AM_LOAD_HOME_DIR, GTK_STOCK_HOME, _("_Home Directory"), "<Alt>Home",
           _("Go to home directory"),
-          G_CALLBACK (Browser_Load_Home_Directory) },
+          G_CALLBACK (et_application_window_go_home) },
         { AM_LOAD_DESKTOP_DIR, "user-desktop", _("Desktop Directory"), NULL,
           _("Go to desktop directory"),
-          G_CALLBACK (Browser_Load_Desktop_Directory) },
+          G_CALLBACK (et_application_window_go_desktop) },
         { AM_LOAD_DOCUMENTS_DIR, "folder-documents", _("Documents Directory"),
           NULL, _("Go to documents directory"),
-          G_CALLBACK (Browser_Load_Documents_Directory) },
+          G_CALLBACK (et_application_window_go_documents) },
         { AM_LOAD_DOWNLOADS_DIR, "folder-download", _("Downloads Directory"),
           NULL, _("Go to downloads directory"),
-          G_CALLBACK (Browser_Load_Downloads_Directory) },
+          G_CALLBACK (et_application_window_go_download) },
         { AM_LOAD_MUSIC_DIR, "folder-music", _("Music Directory"), NULL,
           _("Go to music directory"),
-          G_CALLBACK (Browser_Load_Music_Directory) },
+          G_CALLBACK (et_application_window_go_music) },
         { AM_LOAD_PARENT_DIR, GTK_STOCK_GO_UP, _("_Parent Directory"),
           "<Alt>Up", _("Go to parent directory"),
-          G_CALLBACK (et_browser_on_action_parent_directory) },
+          G_CALLBACK (et_application_window_go_parent) },
         { AM_LOAD_DEFAULT_DIR, GTK_STOCK_JUMP_TO, _("_Default Directory"),
           "<Primary>D", _("Go to default directory"),
           G_CALLBACK (Browser_Load_Default_Directory) },
         { AM_SET_PATH_AS_DEFAULT,      GTK_STOCK_DIRECTORY,    _("Set _Current Path as Default"),  NULL,     
           _("Set current path as default"),   G_CALLBACK(Set_Current_Path_As_Default) },
-        { AM_RENAME_DIR,               GTK_STOCK_INDEX,        _("Rename Directory…"),          "F2",        
        _("Rename directory"),          G_CALLBACK(Browser_Open_Rename_Directory_Window) },
+        { AM_RENAME_DIR, GTK_STOCK_INDEX, _("Rename Directory…"), "F2",
+          _("Rename directory"),
+          G_CALLBACK (et_application_window_show_rename_directory_dialog) },
         { AM_RELOAD_DIRECTORY, GTK_STOCK_REFRESH, _("Reload Directory"),
           "<Primary>R", _("Reload directory"),
-          G_CALLBACK (Browser_Reload_Directory) },
+          G_CALLBACK (et_application_window_reload_directory) },
         { AM_BROWSE_DIRECTORY_WITH, GTK_STOCK_EXECUTE,
           _("Browse Directory With…"), NULL,
           _("Run a command on the directory"),
-          G_CALLBACK (Browser_Open_Run_Program_Tree_Window) },
+          G_CALLBACK (et_application_window_show_open_directory_with_dialog) },
         { AM_COLLAPSE_TREE, NULL, _("_Collapse Tree"), "<Primary><Shift>C",
-          _("Collapse directory tree"), G_CALLBACK (Browser_Tree_Collapse) },
+          _("Collapse directory tree"),
+          G_CALLBACK (et_application_window_browser_collapse) },
         { AM_INITIALIZE_TREE, GTK_STOCK_REFRESH, _("_Reload Tree"),
           "<Primary><Shift>R", _("Reload directory tree"),
-          G_CALLBACK (Browser_Tree_Rebuild) },
+          G_CALLBACK (et_application_window_browser_reload) },
 
         { MENU_SCANNER, NULL, _("S_canner Mode"), NULL, NULL, NULL },
 
@@ -356,7 +369,7 @@ Create_UI (GtkWindow *window, GtkWidget **ppmenubar, GtkWidget **pptoolbar)
 #ifndef G_OS_WIN32 /* No sense here for Win32, "hidden" means : starts with a
                     * '.'
                     */
-        { AM_BROWSER_HIDDEN_DIR, NULL,                   _("Show Hidden Directories"),                       
  NULL, _("Show hidden directories"),                         G_CALLBACK(Browser_Tree_Rebuild),     
BROWSE_HIDDEN_DIR },
+        { AM_BROWSER_HIDDEN_DIR, NULL,                   _("Show Hidden Directories"),                       
  NULL, _("Show hidden directories"),                         
G_CALLBACK(et_application_window_browser_reload),     BROWSE_HIDDEN_DIR },
 #endif /* !G_OS_WIN32 */
         { AM_SCANNER_SHOW, "document-properties", _("_Show Scanner"), NULL,
           _("Show scanner"),
@@ -511,7 +524,7 @@ Check_Menu_Item_Toggled_Browse_Hidden_Dir (GtkWidget *checkmenuitem)
     Check_Menu_Item_Update_Browse_Hidden_Dir();
 
     // Reload directory, in case we have changed BROWSE_HIDDEN_DIR
-    //Browser_Tree_Rebuild(NULL); // Commented, as already done in GtkToggleActionEntry for 
AM_BROWSER_HIDDEN_DIR
+    //et_application_window_browser_reload(NULL); // Commented, as already done in GtkToggleActionEntry for 
AM_BROWSER_HIDDEN_DIR
 }
 
 void
diff --git a/src/browser.c b/src/browser.c
index dae41e0..efa5a41 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -24,24 +24,23 @@
  * Thomas Nilsson and 4Front Technologies
  */
 
-#include <config.h>
+#include "config.h"
+
+#include "browser.h"
 
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 #include <gdk/gdk.h>
 #include <glib/gi18n.h>
-#include <sys/stat.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <dirent.h>
 #include <string.h>
-#include <stdio.h>
 #include <errno.h>
 
 #include "application_window.h"
 #include "gtk2_compat.h"
 #include "easytag.h"
-#include "browser.h"
 #include "et_core.h"
 #include "scan_dialog.h"
 #include "bar.h"
@@ -51,15 +50,37 @@
 #include "charset.h"
 #include "dlm.h"
 
-#include <assert.h>
-
 #include "win32/win32dep.h"
 
+/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
+G_DEFINE_TYPE (EtBrowser, et_browser, GTK_TYPE_BOX)
+
+#define et_browser_get_instance_private(browser) (browser->priv)
+
+struct _EtBrowserPrivate
+{
+    GtkListStore *run_program_model;
+
+    GtkWidget *open_directory_with_dialog;
+    GtkWidget *open_directory_with_combobox;
+
+    GtkWidget *open_files_with_dialog;
+    GtkWidget *open_files_with_combobox;
+
+    /* The Rename Directory window. */
+    GtkWidget *rename_directory_dialog;
+    GtkWidget *rename_directory_combo;
+    GtkWidget *rename_directory_mask_toggle;
+    GtkWidget *rename_directory_mask_combo;
+    GtkListStore *rename_directory_mask_model;
+    GtkWidget *rename_directory_preview_label;
+};
 
 /****************
  * Declarations *
  ****************/
 
+static GtkWidget *BrowserEntryCombo;
 static GtkWidget    *BrowserTree; /* Tree of directories. */
 static GtkTreeStore *directoryTreeModel;
 static GtkListStore *fileListModel;
@@ -71,18 +92,6 @@ static GtkListStore *albumListModel;
 /* Path selected in the browser area (BrowserEntry or BrowserTree). */
 static gchar        *BrowserCurrentPath = NULL;
 
-static GtkListStore *RunProgramModel;
-
-static GtkWidget *RunProgramTreeWindow = NULL;
-static GtkWidget *RunProgramListWindow = NULL;
-
-/* The Rename Directory window. */
-GtkWidget *RenameDirectoryWindow = NULL;
-static GtkWidget *RenameDirectoryCombo;
-static GtkWidget *RenameDirectoryWithMask;
-static GtkListStore *RenameDirectoryMaskModel = NULL;
-GtkWidget *RenameDirectoryPreviewLabel = NULL;
-
 /* The last ETFile selected in the BrowserList. */
 static ET_File *LastBrowserListETFileSelected;
 
@@ -113,39 +122,58 @@ typedef enum
     ET_PATH_STATE_CLOSED
 } EtPathState;
 
+enum
+{
+    LIST_FILE_NAME,
+    /* Tag fields. */
+    LIST_FILE_TITLE,
+    LIST_FILE_ARTIST,
+    LIST_FILE_ALBUM_ARTIST,
+    LIST_FILE_ALBUM,
+    LIST_FILE_YEAR,
+    LIST_FILE_DISCNO,
+    LIST_FILE_TRACK,
+    LIST_FILE_GENRE,
+    LIST_FILE_COMMENT,
+    LIST_FILE_COMPOSER,
+    LIST_FILE_ORIG_ARTIST,
+    LIST_FILE_COPYRIGHT,
+    LIST_FILE_URL,
+    LIST_FILE_ENCODED_BY,
+    /* End of columns with associated UI columns. */
+    LIST_FILE_POINTER,
+    LIST_FILE_KEY,
+    LIST_FILE_OTHERDIR, /* To change color for alternate directories. */
+    LIST_FONT_WEIGHT,
+    LIST_ROW_BACKGROUND,
+    LIST_ROW_FOREGROUND,
+    LIST_COLUMN_COUNT
+};
+
+enum
+{
+    TREE_COLUMN_DIR_NAME,
+    TREE_COLUMN_FULL_PATH,
+    TREE_COLUMN_SCANNED,
+    TREE_COLUMN_HAS_SUBDIR,
+    TREE_COLUMN_ICON,
+    TREE_COLUMN_COUNT
+};
+
 /**************
  * Prototypes *
  **************/
 
-static gboolean Browser_Tree_Key_Press (GtkWidget *tree, GdkEvent *event,
-                                        gpointer data);
-static void Browser_Tree_Set_Node_Visible (GtkWidget *directoryView,
-                                           GtkTreePath *path);
-static void Browser_List_Set_Row_Visible (GtkTreeModel *treeModel,
-                                          GtkTreeIter *rowIter);
-static void Browser_Tree_Initialize (void);
-static gboolean Browser_Tree_Node_Selected (GtkTreeSelection *selection,
-                                            gpointer user_data);
-static void Browser_Tree_Rename_Directory (const gchar *last_path,
-                                           const gchar *new_path);
 static void Browser_Tree_Handle_Rename (GtkTreeIter *parentnode,
                                         const gchar *old_path,
                                         const gchar *new_path);
 
-static gint Browser_List_Key_Press        (GtkWidget *list, GdkEvent *event, gpointer data);
-static gboolean Browser_List_Button_Press (GtkTreeView *treeView,
-                                           GdkEventButton *event);
-static void Browser_List_Row_Selected (GtkTreeSelection * selection,
-                                       gpointer data);
 static void Browser_List_Set_Row_Appearance (GtkTreeIter *iter);
 static gint Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a,
                                     GtkTreeIter *b, gpointer data);
 static void Browser_List_Select_File_By_Iter (GtkTreeIter *iter,
                                               gboolean select_it);
 
-static void Browser_Entry_Activated (void);
-
-static void Browser_Artist_List_Load_Files (ET_File *etfile_to_select);
 static void Browser_Artist_List_Row_Selected (GtkTreeSelection *selection,
                                               gpointer data);
 static void Browser_Artist_List_Set_Row_Appearance (GtkTreeIter *row);
@@ -156,40 +184,22 @@ static void Browser_Album_List_Row_Selected (GtkTreeSelection *selection,
                                              gpointer data);
 static void Browser_Album_List_Set_Row_Appearance (GtkTreeIter *row);
 
-static void Browser_Update_Current_Path (const gchar *path);
-
-#ifdef G_OS_WIN32
-static gboolean Browser_Win32_Get_Drive_Root (gchar *drive,
-                                              GtkTreeIter *rootNode,
-                                              GtkTreePath **rootPath);
-#endif /* G_OS_WIN32 */
-
 static gboolean check_for_subdir (const gchar *path);
 
 static GtkTreePath *Find_Child_Node(GtkTreeIter *parent, gchar *searchtext);
 
 static GIcon *get_gicon_for_path (const gchar *path, EtPathState path_state);
 
-static void expand_cb   (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *path, gpointer data);
-static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data);
-
-/* Pop up menus */
-static gboolean Browser_Popup_Menu_Handler (GtkWidget *widget,
-                                            GdkEventButton *event,
-                                            GtkMenu *menu);
-
 /* For window to rename a directory */
-static void Destroy_Rename_Directory_Window (void);
-static void Rename_Directory (void);
-static void Rename_Directory_With_Mask_Toggled (void);
+static void Destroy_Rename_Directory_Window (EtBrowser *self);
+static void Rename_Directory_With_Mask_Toggled (EtBrowser *self);
 
 /* For window to run a program with the directory */
-static void Destroy_Run_Program_Tree_Window (void);
-static void Run_Program_With_Directory (GtkWidget *combobox);
+static void Destroy_Run_Program_Tree_Window (EtBrowser *self);
+static void Run_Program_With_Directory (EtBrowser *self);
 
 /* For window to run a program with the file */
-static void Destroy_Run_Program_List_Window (void);
-static void Run_Program_With_Selected_Files (GtkWidget *combobox);
+static void Destroy_Run_Program_List_Window (EtBrowser *self);
 
 static void empty_entry_disable_widget (GtkWidget *widget, GtkEntry *entry);
 
@@ -213,7 +223,8 @@ static void et_browser_set_sorting_file_mode (GtkTreeViewColumn *column,
 /*
  * Load home directory
  */
-void Browser_Load_Home_Directory (void)
+void
+et_browser_go_home (EtBrowser *self)
 {
     Browser_Tree_Select_Dir (g_get_home_dir ());
 }
@@ -221,33 +232,37 @@ void Browser_Load_Home_Directory (void)
 /*
  * Load desktop directory
  */
-void Browser_Load_Desktop_Directory (void)
+void
+et_browser_go_desktop (EtBrowser *self)
 {
-    Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP));
+    Browser_Tree_Select_Dir (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
 }
 
 /*
  * Load documents directory
  */
-void Browser_Load_Documents_Directory (void)
+void
+et_browser_go_documents (EtBrowser *self)
 {
-    Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_DOCUMENTS));
+    Browser_Tree_Select_Dir (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
 }
 
 /*
  * Load downloads directory
  */
-void Browser_Load_Downloads_Directory (void)
+void
+et_browser_go_download (EtBrowser *self)
 {
-    Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD));
+    Browser_Tree_Select_Dir (g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD));
 }
 
 /*
  * Load music directory
  */
-void Browser_Load_Music_Directory (void)
+void
+et_browser_go_music (EtBrowser *self)
 {
-    Browser_Tree_Select_Dir(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC));
+    Browser_Tree_Select_Dir (g_get_user_special_dir (G_USER_DIRECTORY_MUSIC));
 }
 
 
@@ -351,7 +366,8 @@ gchar *Browser_Get_Current_Path (void)
 /*
  * Reload the current directory.
  */
-void Browser_Reload_Directory (void)
+void
+et_browser_reload_directory (EtBrowser *self)
 {
     if (BrowserTree && BrowserCurrentPath != NULL)
     {
@@ -409,7 +425,7 @@ void Browser_Entry_Set_Text (gchar *text)
  * Button to go to parent directory
  */
 void
-et_browser_on_action_parent_directory (void)
+et_browser_go_parent (EtBrowser *self)
 {
     gchar *parent_dir, *path;
 
@@ -497,7 +513,8 @@ Browser_Tree_Key_Press (GtkWidget *tree, GdkEvent *event, gpointer data)
  *   - Delete = delete file
  * Also tries to capture text input and relate it to files
  */
-gboolean Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data)
+static gboolean
+Browser_List_Key_Press (GtkWidget *list, GdkEvent *event, gpointer data)
 {
     GdkEventKey *kevent;
     GtkTreeSelection *fileSelection;
@@ -577,7 +594,8 @@ Browser_List_Button_Press (GtkTreeView *treeView, GdkEventButton *event)
 /*
  * Collapse (close) tree recursively up to the root node.
  */
-void Browser_Tree_Collapse (void)
+void
+et_browser_collapse (EtBrowser *self)
 {
 #ifndef G_OS_WIN32
     GtkTreePath *rootPath;
@@ -611,7 +629,8 @@ Browser_Tree_Set_Node_Visible (GtkWidget *directoryView, GtkTreePath *path)
 /*
  * Set a row visible in the file list (by scrolling the list)
  */
-void Browser_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter)
+static void
+Browser_List_Set_Row_Visible (GtkTreeModel *treeModel, GtkTreeIter *rowIter)
 {
     /*
      * TODO: Make this only scroll to the row if it is not visible
@@ -1954,7 +1973,8 @@ void Browser_List_Invert_File_Selection (void)
 }
 
 
-void Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
+static void
+Browser_Artist_List_Load_Files (ET_File *etfile_to_select)
 {
     GList *AlbumList;
     GList *etfilelist;
@@ -2501,26 +2521,15 @@ Browser_Tree_Initialize (void)
 }
 
 /*
- * Browser_Tree_Rebuild: Refresh the tree browser by destroying it and rebuilding it.
- * Opens tree nodes corresponding to 'path_to_load' if this parameter isn't NULL.
- * If NULL, selects the current path.
+ * et_browser_reload: Refresh the tree browser by destroying it and rebuilding it.
+ * Opens tree nodes corresponding to the current path.
  */
-void Browser_Tree_Rebuild (gchar *path_to_load)
+void
+et_browser_reload (EtBrowser *self)
 {
     gchar *current_path = NULL;
     GtkTreeSelection *selection;
 
-    /* May be called from GtkUIManager callback */
-    if (GTK_IS_ACTION(path_to_load))
-        path_to_load = NULL;
-
-    if (path_to_load != NULL)
-    {
-        Browser_Tree_Initialize();
-        Browser_Tree_Select_Dir(path_to_load);
-        return;
-    }
-
     /* Memorize the current path to load it again at the end */
     current_path = Browser_Tree_Get_Path_Of_Selected_Node();
     if (current_path==NULL && BrowserEntryCombo)
@@ -2875,7 +2884,8 @@ Browser_List_Select_Func (GtkTreeSelection *selection, GtkTreeModel *model, GtkT
  * Open up a node on the browser tree
  * Scanning and showing all subdirectories
  */
-static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePath, gpointer data)
+static void
+expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePath, gpointer data)
 {
     GFile *dir;
     GFileEnumerator *enumerator;
@@ -2997,7 +3007,8 @@ static void expand_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *gtreePat
     g_free(parentPath);
 }
 
-static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data)
+static void
+collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePath, gpointer data)
 {
     GtkTreeIter subNodeIter;
     gchar *path;
@@ -3080,15 +3091,19 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
 /*
  * Create item of the browser (Entry + Tree + List).
  */
-GtkWidget *Create_Browser_Items (GtkWidget *parent)
+static void
+create_browser (EtBrowser *self)
 {
-       GtkWidget *VerticalBox;
+    EtBrowserPrivate *priv;
+    GtkWidget *VerticalBox;
     GtkWidget *HBox;
     GtkWidget *ScrollWindowDirectoryTree;
     GtkWidget *ScrollWindowFileList;
     GtkWidget *ScrollWindowArtistList;
     GtkWidget *ScrollWindowAlbumList;
     GtkWidget *Label;
+    GtkWidget *ArtistAlbumVPaned;
+    GtkWidget *BrowserHPaned;
     gsize i;
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *column;
@@ -3106,9 +3121,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
                                          N_("# Files") };
     const gchar *AlbumList_Titles[] = { N_("Album"), N_("# Files") };
 
-    VerticalBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2);
-    gtk_container_set_border_width(GTK_CONTAINER(VerticalBox),2);
+    priv = et_browser_get_instance_private (self);
 
+    VerticalBox = GTK_WIDGET (self);
+    gtk_container_set_border_width(GTK_CONTAINER(VerticalBox),2);
 
     // HBox for BrowserEntry + BrowserLabel
     HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
@@ -3465,7 +3481,7 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
     /*
      * The list store for run program combos
      */
-    RunProgramModel = gtk_list_store_new(MISC_COMBO_COUNT, G_TYPE_STRING);
+    priv->run_program_model = gtk_list_store_new(MISC_COMBO_COUNT, G_TYPE_STRING);
 
     /*
      * The pane for the tree and list
@@ -3477,12 +3493,10 @@ GtkWidget *Create_Browser_Items (GtkWidget *parent)
 
     /* TODO: Give the browser area a sensible default size. */
     gtk_paned_set_position (GTK_PANED (BrowserHPaned), 250);
-    gtk_widget_show_all(VerticalBox);
+    gtk_widget_show_all (GTK_WIDGET (self));
 
     /* Set home variable as current path */
     Browser_Update_Current_Path (g_get_home_dir ());
-
-    return VerticalBox;
 }
 
 /*
@@ -3539,12 +3553,58 @@ et_browser_set_sorting_file_mode (GtkTreeViewColumn *column, gpointer data)
     Browser_List_Refresh_Sort ();
 }
 
+/*******************************
+ * Scanner To Rename Directory *
+ *******************************/
+static void
+rename_directory_generate_preview (EtBrowser *self)
+{
+    EtBrowserPrivate *priv;
+    gchar *preview_text = NULL;
+    gchar *mask = NULL;
+
+    priv = et_browser_get_instance_private (self);
+
+    if (!ETCore->ETFileDisplayed
+    ||  !priv->rename_directory_dialog || !priv->rename_directory_mask_combo || 
!priv->rename_directory_preview_label)
+        return;
+
+    mask = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))));
+    if (!mask)
+        return;
+
+    preview_text = Scan_Generate_New_Filename_From_Mask(ETCore->ETFileDisplayed,mask,FALSE);
+
+    if (GTK_IS_LABEL(priv->rename_directory_preview_label))
+    {
+        if (preview_text)
+        {
+            //gtk_label_set_text(GTK_LABEL(priv->rename_file_preview_label),preview_text);
+            gchar *tmp_string = g_markup_printf_escaped("%s",preview_text); // To avoid problem with strings 
containing characters like '&'
+            gchar *str = g_strdup_printf("<i>%s</i>",tmp_string);
+            gtk_label_set_markup(GTK_LABEL(priv->rename_directory_preview_label),str);
+            g_free(tmp_string);
+            g_free(str);
+        } else
+        {
+            gtk_label_set_text(GTK_LABEL(priv->rename_directory_preview_label),"");
+        }
+
+        // Force the window to be redrawed else the preview label may be not placed correctly
+        gtk_widget_queue_resize(priv->rename_directory_dialog);
+    }
+
+    g_free(mask);
+    g_free(preview_text);
+}
 
 /*
  * The window to Rename a directory into the browser.
  */
-void Browser_Open_Rename_Directory_Window (void)
+void
+et_browser_show_rename_directory_dialog (EtBrowser *self)
 {
+    EtBrowserPrivate *priv;
     GtkWidget *VBox;
     GtkWidget *HBox;
     GtkWidget *Label;
@@ -3555,9 +3615,11 @@ void Browser_Open_Rename_Directory_Window (void)
     gchar *address = NULL;
     gchar *string;
 
-    if (RenameDirectoryWindow != NULL)
+    priv = et_browser_get_instance_private (self);
+
+    if (priv->rename_directory_dialog != NULL)
     {
-        gtk_window_present(GTK_WINDOW(RenameDirectoryWindow));
+        gtk_window_present(GTK_WINDOW(priv->rename_directory_dialog));
         return;
     }
 
@@ -3587,7 +3649,7 @@ void Browser_Open_Rename_Directory_Window (void)
 
     directory_name_utf8 = filename_to_display(directory_name);
 
-    RenameDirectoryWindow = gtk_dialog_new_with_buttons (_("Rename Directory"),
+    priv->rename_directory_dialog = gtk_dialog_new_with_buttons (_("Rename Directory"),
                                                          GTK_WINDOW (MainWindow),
                                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                                          GTK_STOCK_CANCEL,
@@ -3596,17 +3658,17 @@ void Browser_Open_Rename_Directory_Window (void)
                                                          GTK_RESPONSE_APPLY,
                                                          NULL);
 
-    gtk_dialog_set_default_response (GTK_DIALOG (RenameDirectoryWindow),
+    gtk_dialog_set_default_response (GTK_DIALOG (priv->rename_directory_dialog),
                                      GTK_RESPONSE_APPLY);
 
     /* We attach useful data to the combobox */
-    g_object_set_data(G_OBJECT(RenameDirectoryWindow), "Parent_Directory", directory_parent);
-    g_object_set_data(G_OBJECT(RenameDirectoryWindow), "Current_Directory", directory_name);
-    g_signal_connect (RenameDirectoryWindow, "response",
-                      G_CALLBACK (et_rename_directory_on_response), NULL);
+    g_object_set_data(G_OBJECT(priv->rename_directory_dialog), "Parent_Directory", directory_parent);
+    g_object_set_data(G_OBJECT(priv->rename_directory_dialog), "Current_Directory", directory_name);
+    g_signal_connect (priv->rename_directory_dialog, "response",
+                      G_CALLBACK (et_rename_directory_on_response), self);
 
-    VBox = gtk_dialog_get_content_area (GTK_DIALOG (RenameDirectoryWindow));
-    gtk_container_set_border_width (GTK_CONTAINER (RenameDirectoryWindow),
+    VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->rename_directory_dialog));
+    gtk_container_set_border_width (GTK_CONTAINER (priv->rename_directory_dialog),
                                     BOX_SPACING);
 
     string = g_strdup_printf(_("Rename the directory '%s' to:"),directory_name_utf8);
@@ -3616,112 +3678,121 @@ void Browser_Open_Rename_Directory_Window (void)
     gtk_label_set_line_wrap(GTK_LABEL(Label),TRUE);
 
     /* The combobox to rename the directory */
-    RenameDirectoryCombo = gtk_combo_box_text_new_with_entry();
-    gtk_box_pack_start(GTK_BOX(VBox),RenameDirectoryCombo,FALSE,FALSE,0);
+    priv->rename_directory_combo = gtk_combo_box_text_new_with_entry();
+    gtk_box_pack_start(GTK_BOX(VBox),priv->rename_directory_combo,FALSE,FALSE,0);
     /* Set the directory into the combobox */
-    gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(RenameDirectoryCombo), directory_name_utf8);
-    gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(RenameDirectoryCombo), "");
-    gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryCombo))),directory_name_utf8);
+    gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(priv->rename_directory_combo), directory_name_utf8);
+    gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(priv->rename_directory_combo), "");
+    
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_combo))),directory_name_utf8);
 
     /* Rename directory : check box + combo box + Status icon */
     HBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BOX_SPACING);
     gtk_box_pack_start(GTK_BOX(VBox),HBox,TRUE,TRUE,0);
 
-    RenameDirectoryWithMask = gtk_check_button_new_with_label(_("Use mask:"));
-    gtk_box_pack_start(GTK_BOX(HBox),RenameDirectoryWithMask,FALSE,FALSE,0);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask),RENAME_DIRECTORY_WITH_MASK);
-    gtk_widget_set_tooltip_text(RenameDirectoryWithMask,_("If activated, it will use masks to rename 
directory."));
-    
g_signal_connect(G_OBJECT(RenameDirectoryWithMask),"toggled",G_CALLBACK(Rename_Directory_With_Mask_Toggled),NULL);
+    priv->rename_directory_mask_toggle = gtk_check_button_new_with_label(_("Use mask:"));
+    gtk_box_pack_start(GTK_BOX(HBox),priv->rename_directory_mask_toggle,FALSE,FALSE,0);
+    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle),RENAME_DIRECTORY_WITH_MASK);
+    gtk_widget_set_tooltip_text(priv->rename_directory_mask_toggle,_("If activated, it will use masks to 
rename directory."));
+    g_signal_connect_swapped (priv->rename_directory_mask_toggle, "toggled",
+                              G_CALLBACK (Rename_Directory_With_Mask_Toggled),
+                              self);
 
     // Set up list model which is used by the combobox
     /* Rename directory from mask */
-    if (!RenameDirectoryMaskModel)
-        RenameDirectoryMaskModel = gtk_list_store_new(MASK_EDITOR_COUNT, G_TYPE_STRING);
+    if (!priv->rename_directory_mask_model)
+        priv->rename_directory_mask_model = gtk_list_store_new(MASK_EDITOR_COUNT, G_TYPE_STRING);
     else
-        gtk_list_store_clear(RenameDirectoryMaskModel);
+        gtk_list_store_clear(priv->rename_directory_mask_model);
 
     // The combo box to select the mask to apply
-    RenameDirectoryMaskCombo = gtk_combo_box_new_with_entry();
-    gtk_combo_box_set_model(GTK_COMBO_BOX(RenameDirectoryMaskCombo), 
GTK_TREE_MODEL(RenameDirectoryMaskModel));
-    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RenameDirectoryMaskCombo), MASK_EDITOR_TEXT);
-    gtk_widget_set_size_request(RenameDirectoryMaskCombo, 80, -1);
+    priv->rename_directory_mask_combo = gtk_combo_box_new_with_entry();
+    gtk_combo_box_set_model(GTK_COMBO_BOX(priv->rename_directory_mask_combo), 
GTK_TREE_MODEL(priv->rename_directory_mask_model));
+    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(priv->rename_directory_mask_combo), MASK_EDITOR_TEXT);
+    gtk_widget_set_size_request(priv->rename_directory_mask_combo, 80, -1);
 
-    gtk_box_pack_start(GTK_BOX(HBox),RenameDirectoryMaskCombo,TRUE,TRUE,0);
-    gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))),
+    gtk_box_pack_start(GTK_BOX(HBox),priv->rename_directory_mask_combo,TRUE,TRUE,0);
+    
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))),
         _("Select or type in a mask using codes (see Legend in Scanner Window) to rename "
         "the directory from tag fields."));
     // Signal to generate preview (preview of the new directory)
-    
g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))),"changed",
-        G_CALLBACK(Scan_Rename_Directory_Generate_Preview),NULL);
+    g_signal_connect_swapped (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->rename_directory_mask_combo))),
+                              "changed",
+                              G_CALLBACK (rename_directory_generate_preview),
+                              self);
 
     // Load masks into the combobox from a file
-    Load_Rename_Directory_Masks_List(RenameDirectoryMaskModel, MASK_EDITOR_TEXT, Rename_Directory_Masks);
+    Load_Rename_Directory_Masks_List(priv->rename_directory_mask_model, MASK_EDITOR_TEXT, 
Rename_Directory_Masks);
     if (RENAME_DIRECTORY_DEFAULT_MASK)
     {
-        Add_String_To_Combo_List(RenameDirectoryMaskModel, RENAME_DIRECTORY_DEFAULT_MASK);
-        gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo))), 
RENAME_DIRECTORY_DEFAULT_MASK);
+        Add_String_To_Combo_List(priv->rename_directory_mask_model, RENAME_DIRECTORY_DEFAULT_MASK);
+        gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo))), 
RENAME_DIRECTORY_DEFAULT_MASK);
     }else
     {
-        gtk_combo_box_set_active(GTK_COMBO_BOX(RenameDirectoryMaskCombo), 0);
+        gtk_combo_box_set_active(GTK_COMBO_BOX(priv->rename_directory_mask_combo), 0);
     }
 
     // Mask status icon
     // Signal connection to check if mask is correct into the mask entry
-    g_signal_connect (gtk_bin_get_child (GTK_BIN (RenameDirectoryMaskCombo)),
+    g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->rename_directory_mask_combo)),
                       "changed", G_CALLBACK (entry_check_rename_file_mask),
                       NULL);
 
     // Preview label
-    RenameDirectoryPreviewLabel = gtk_label_new (_("Rename directory preview"));
-    gtk_label_set_line_wrap(GTK_LABEL(RenameDirectoryPreviewLabel),TRUE);
+    priv->rename_directory_preview_label = gtk_label_new (_("Rename directory preview"));
+    gtk_label_set_line_wrap(GTK_LABEL(priv->rename_directory_preview_label),TRUE);
     ////gtk_widget_show(FillTagPreviewLabel);
-    gtk_box_pack_start(GTK_BOX(VBox),RenameDirectoryPreviewLabel,TRUE,TRUE,0);
+    gtk_box_pack_start(GTK_BOX(VBox),priv->rename_directory_preview_label,TRUE,TRUE,0);
 
     /* Button to save: to rename directory */
-    Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RenameDirectoryWindow),
+    Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->rename_directory_dialog),
                                                  GTK_RESPONSE_APPLY);
-    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RenameDirectoryCombo)),
+    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->rename_directory_combo)),
                               "changed",
                               G_CALLBACK (empty_entry_disable_widget),
                               G_OBJECT (Button));
 
-    gtk_widget_show_all(RenameDirectoryWindow);
+    gtk_widget_show_all(priv->rename_directory_dialog);
 
     // To initialize the 'Use mask' check button state
-    g_signal_emit_by_name(G_OBJECT(RenameDirectoryWithMask),"toggled");
+    g_signal_emit_by_name(G_OBJECT(priv->rename_directory_mask_toggle),"toggled");
 
     // To initialize PreviewLabel + MaskStatusIconBox
-    g_signal_emit_by_name(G_OBJECT(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo))),"changed");
+    g_signal_emit_by_name(G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo))),"changed");
 
     g_free(directory_name_utf8);
 }
 
 static void
-Destroy_Rename_Directory_Window (void)
+Destroy_Rename_Directory_Window (EtBrowser *self)
 {
-    if (RenameDirectoryWindow)
+    EtBrowserPrivate *priv;
+
+    priv = et_browser_get_instance_private (self);
+
+    if (priv->rename_directory_dialog)
     {
-        g_free(g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Parent_Directory"));
-        g_free(g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Current_Directory"));
+        g_free(g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Parent_Directory"));
+        g_free(g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Current_Directory"));
 
         if (RENAME_DIRECTORY_DEFAULT_MASK) g_free(RENAME_DIRECTORY_DEFAULT_MASK);
-        RENAME_DIRECTORY_DEFAULT_MASK = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))));
-        Add_String_To_Combo_List(RenameDirectoryMaskModel, RENAME_DIRECTORY_DEFAULT_MASK);
-        Save_Rename_Directory_Masks_List(RenameDirectoryMaskModel, MASK_EDITOR_TEXT);
+        RENAME_DIRECTORY_DEFAULT_MASK = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))));
+        Add_String_To_Combo_List(priv->rename_directory_mask_model, RENAME_DIRECTORY_DEFAULT_MASK);
+        Save_Rename_Directory_Masks_List(priv->rename_directory_mask_model, MASK_EDITOR_TEXT);
 
-        RENAME_DIRECTORY_WITH_MASK = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask));
+        RENAME_DIRECTORY_WITH_MASK = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle));
 
-        gtk_list_store_clear(RenameDirectoryMaskModel);
+        gtk_list_store_clear(priv->rename_directory_mask_model);
 
-        gtk_widget_destroy(RenameDirectoryWindow);
-        RenameDirectoryPreviewLabel = NULL;
-        RenameDirectoryWindow = NULL;
+        gtk_widget_destroy(priv->rename_directory_dialog);
+        priv->rename_directory_preview_label = NULL;
+        priv->rename_directory_dialog = NULL;
     }
 }
 
 static void
-Rename_Directory (void)
+Rename_Directory (EtBrowser *self)
 {
+    EtBrowserPrivate *priv;
     DIR   *dir;
     gchar *directory_parent;
     gchar *directory_last_name;
@@ -3735,23 +3806,24 @@ Rename_Directory (void)
     gchar *tmp_path_utf8;
     gint   fd_tmp;
 
+    priv = et_browser_get_instance_private (self);
 
-    g_return_if_fail (RenameDirectoryWindow != NULL);
+    g_return_if_fail (priv->rename_directory_dialog != NULL);
 
-    directory_parent    = g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Parent_Directory");
-    directory_last_name = g_object_get_data(G_OBJECT(RenameDirectoryWindow),"Current_Directory");
+    directory_parent    = g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Parent_Directory");
+    directory_last_name = g_object_get_data(G_OBJECT(priv->rename_directory_dialog),"Current_Directory");
 
-    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)))
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)))
     {
         // Renamed from mask
-        gchar *mask = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))));
+        gchar *mask = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_mask_combo)))));
         directory_new_name = Scan_Generate_New_Directory_Name_From_Mask(ETCore->ETFileDisplayed,mask,FALSE);
         g_free(mask);
 
     }else
     {
         // Renamed 'manually'
-        directory_new_name  = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryCombo)))));
+        directory_new_name  = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->rename_directory_combo)))));
     }
 
     /* Check if a name for the directory have been supplied */
@@ -3799,7 +3871,7 @@ Rename_Directory (void)
     if (directory_last_name && directory_new_name_file
     && strcmp(directory_last_name,directory_new_name_file)==0)
     {
-        Destroy_Rename_Directory_Window();
+        Destroy_Rename_Directory_Window (self);
         g_free(directory_new_name_file);
         return;
     }
@@ -3953,7 +4025,7 @@ Rename_Directory (void)
         g_free(tmp);
     }
 
-    Destroy_Rename_Directory_Window();
+    Destroy_Rename_Directory_Window (self);
     g_free(last_path);
     g_free(last_path_utf8);
     g_free(new_path);
@@ -3965,11 +4037,15 @@ Rename_Directory (void)
 }
 
 static void
-Rename_Directory_With_Mask_Toggled (void)
+Rename_Directory_With_Mask_Toggled (EtBrowser *self)
 {
-    gtk_widget_set_sensitive(GTK_WIDGET(RenameDirectoryCombo),            
!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)));
-    gtk_widget_set_sensitive(GTK_WIDGET(RenameDirectoryMaskCombo),         
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)));
-    gtk_widget_set_sensitive(GTK_WIDGET(RenameDirectoryPreviewLabel),      
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RenameDirectoryWithMask)));
+    EtBrowserPrivate *priv;
+
+    priv = et_browser_get_instance_private (self);
+
+    gtk_widget_set_sensitive(GTK_WIDGET(priv->rename_directory_combo),            
!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)));
+    gtk_widget_set_sensitive(GTK_WIDGET(priv->rename_directory_mask_combo),         
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)));
+    gtk_widget_set_sensitive(GTK_WIDGET(priv->rename_directory_preview_label),      
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->rename_directory_mask_toggle)));
 }
 
 
@@ -3977,18 +4053,23 @@ Rename_Directory_With_Mask_Toggled (void)
  * Window where is typed the name of the program to run, which
  * receives the current directory as parameter.
  */
-void Browser_Open_Run_Program_Tree_Window (void)
+void
+et_browser_show_open_directory_with_dialog (EtBrowser *self)
 {
+    EtBrowserPrivate *priv;
     GtkWidget *VBox;
     GtkWidget *HBox;
     GtkWidget *Label;
-    GtkWidget *RunProgramComboBox;
     GtkWidget *Button;
     gchar *current_directory = NULL;
 
-    if (RunProgramTreeWindow != NULL)
+    g_return_if_fail (ET_BROWSER (self));
+
+    priv = et_browser_get_instance_private (self);
+
+    if (priv->open_directory_with_dialog != NULL)
     {
-        gtk_window_present(GTK_WINDOW(RunProgramTreeWindow));
+        gtk_window_present(GTK_WINDOW(priv->open_directory_with_dialog));
         return;
     }
 
@@ -3997,7 +4078,7 @@ void Browser_Open_Run_Program_Tree_Window (void)
     if (!current_directory || strlen(current_directory)==0)
         return;
 
-    RunProgramTreeWindow = gtk_dialog_new_with_buttons (_("Browse Directory With"),
+    priv->open_directory_with_dialog = gtk_dialog_new_with_buttons (_("Browse Directory With"),
                                                         GTK_WINDOW (MainWindow),
                                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                                         GTK_STOCK_CANCEL,
@@ -4005,12 +4086,12 @@ void Browser_Open_Run_Program_Tree_Window (void)
                                                         GTK_STOCK_EXECUTE,
                                                         GTK_RESPONSE_OK, NULL);
 
-    gtk_dialog_set_default_response (GTK_DIALOG (RunProgramTreeWindow),
+    gtk_dialog_set_default_response (GTK_DIALOG (priv->open_directory_with_dialog),
                                      GTK_RESPONSE_OK);
-    g_signal_connect (RunProgramTreeWindow, "response",
-                      G_CALLBACK (et_run_program_tree_on_response), NULL);
-    VBox = gtk_dialog_get_content_area (GTK_DIALOG (RunProgramTreeWindow));
-    gtk_container_set_border_width (GTK_CONTAINER (RunProgramTreeWindow),
+    g_signal_connect (priv->open_directory_with_dialog, "response",
+                      G_CALLBACK (et_run_program_tree_on_response), self);
+    VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->open_directory_with_dialog));
+    gtk_container_set_border_width (GTK_CONTAINER (priv->open_directory_with_dialog),
                                     BOX_SPACING);
 
     Label = gtk_label_new(_("Program to run:"));
@@ -4021,62 +4102,72 @@ void Browser_Open_Run_Program_Tree_Window (void)
     gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,2);
 
     /* The combobox to enter the program to run */
-    RunProgramComboBox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
-    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RunProgramComboBox), MISC_COMBO_TEXT);
-    gtk_box_pack_start(GTK_BOX(HBox),RunProgramComboBox,TRUE,TRUE,0);
-    gtk_widget_set_size_request(GTK_WIDGET(RunProgramComboBox),250,-1);
-    
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),_("Enter 
the program to run. "
+    priv->open_directory_with_combobox = 
gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->run_program_model));
+    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(priv->open_directory_with_combobox), MISC_COMBO_TEXT);
+    gtk_box_pack_start(GTK_BOX(HBox),priv->open_directory_with_combobox,TRUE,TRUE,0);
+    gtk_widget_set_size_request(GTK_WIDGET(priv->open_directory_with_combobox),250,-1);
+    
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox)))),_("Enter
 the program to run. "
         "It will receive the current directory as parameter."));
 
     /* History list */
-    gtk_list_store_clear(RunProgramModel);
-    Load_Run_Program_With_Directory_List(RunProgramModel, MISC_COMBO_TEXT);
-    g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"activate",
-        G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
+    gtk_list_store_clear(priv->run_program_model);
+    Load_Run_Program_With_Directory_List(priv->run_program_model, MISC_COMBO_TEXT);
+    g_signal_connect_swapped (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->open_directory_with_combobox))),
+                              "activate",
+                              G_CALLBACK (Run_Program_With_Directory),
+                              self);
 
     /* The button to Browse */
     Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
     gtk_box_pack_start(GTK_BOX(HBox),Button,FALSE,FALSE,0);
     g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-                             
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(RunProgramComboBox))));
+                             
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox))));
 
     /* We attach useful data to the combobox (into Run_Program_With_Directory) */
-    g_object_set_data(G_OBJECT(RunProgramComboBox), "Current_Directory", current_directory);
+    g_object_set_data(G_OBJECT(priv->open_directory_with_combobox), "Current_Directory", current_directory);
 
     /* Button to execute */
-    Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramTreeWindow),
+    Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->open_directory_with_dialog),
                                                  GTK_RESPONSE_OK);
-    g_signal_connect_swapped(G_OBJECT(Button),"clicked", 
G_CALLBACK(Run_Program_With_Directory),G_OBJECT(RunProgramComboBox));
-    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+    g_signal_connect_swapped (Button, "clicked",
+                              G_CALLBACK (Run_Program_With_Directory),
+                              self);
+    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_directory_with_combobox)),
                               "changed",
                               G_CALLBACK (empty_entry_disable_widget),
                               G_OBJECT (Button));
-    
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",NULL);
+    
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->open_directory_with_combobox)))),"changed",NULL);
 
-    gtk_widget_show_all(RunProgramTreeWindow);
+    gtk_widget_show_all(priv->open_directory_with_dialog);
 }
 
 static void
-Destroy_Run_Program_Tree_Window (void)
+Destroy_Run_Program_Tree_Window (EtBrowser *self)
 {
-    if (RunProgramTreeWindow)
+    EtBrowserPrivate *priv;
+
+    priv = et_browser_get_instance_private (self);
+
+    if (priv->open_directory_with_dialog)
     {
-        gtk_widget_destroy(RunProgramTreeWindow);
-        RunProgramTreeWindow = NULL;
+        gtk_widget_hide (priv->open_directory_with_dialog);
     }
 }
 
-void Run_Program_With_Directory (GtkWidget *combobox)
+void
+Run_Program_With_Directory (EtBrowser *self)
 {
+    EtBrowserPrivate *priv;
     gchar *program_name;
     gchar *current_directory;
     GList *args_list = NULL;
     gboolean program_ran;
 
-    g_return_if_fail (GTK_IS_COMBO_BOX (combobox));
+    priv = et_browser_get_instance_private (self);
 
-    program_name      = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
-    current_directory = g_object_get_data(G_OBJECT(combobox), "Current_Directory");
+    program_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN 
(priv->open_directory_with_combobox)))));
+    current_directory = g_object_get_data (G_OBJECT (priv->open_directory_with_combobox),
+                                           "Current_Directory");
 #ifdef G_OS_WIN32
     /* On win32 : 'winamp.exe "c:\path\to\dir"' succeed, while 'winamp.exe "c:\path\to\dir\"' fails */
     ET_Win32_Path_Remove_Trailing_Backslash(current_directory);
@@ -4091,12 +4182,71 @@ void Run_Program_With_Directory (GtkWidget *combobox)
     if (program_ran)
     {
         // Append newest choice to the drop down list
-        Add_String_To_Combo_List(RunProgramModel, program_name);
+        Add_String_To_Combo_List(priv->run_program_model, program_name);
 
         // Save list attached to the combobox
-        Save_Run_Program_With_Directory_List(RunProgramModel, MISC_COMBO_TEXT);
+        Save_Run_Program_With_Directory_List(priv->run_program_model, MISC_COMBO_TEXT);
 
-        Destroy_Run_Program_Tree_Window();
+        Destroy_Run_Program_Tree_Window (self);
+    }
+    g_free(program_name);
+}
+
+static void
+Run_Program_With_Selected_Files (EtBrowser *self)
+{
+    EtBrowserPrivate *priv;
+    gchar   *program_name;
+    ET_File *ETFile;
+    GList   *selected_paths;
+    GList *l;
+    GList   *args_list = NULL;
+    GtkTreeIter iter;
+    gboolean program_ran;
+
+    priv = et_browser_get_instance_private (self);
+
+    if (!GTK_IS_COMBO_BOX (priv->open_files_with_combobox) || !ETCore->ETFileDisplayedList)
+        return;
+
+    // Programe name to run
+    program_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN 
(priv->open_files_with_combobox)))));
+
+    // List of files to pass as parameters
+    selected_paths = 
gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)), NULL);
+
+    for (l = selected_paths; l != NULL; l = g_list_next (l))
+    {
+        if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fileListModel), &iter,
+                                     (GtkTreePath *)l->data))
+        {
+            gtk_tree_model_get(GTK_TREE_MODEL(fileListModel), &iter,
+                               LIST_FILE_POINTER, &ETFile,
+                               -1);
+
+            args_list = g_list_prepend (args_list,
+                                        ((File_Name *)ETFile->FileNameCur->data)->value);
+            //args_list = g_list_append(args_list,((File_Name *)ETFile->FileNameCur->data)->value_utf8);
+        }
+    }
+
+    args_list = g_list_reverse (args_list);
+    program_ran = et_run_program (program_name, args_list);
+
+    g_list_free_full (selected_paths, (GDestroyNotify)gtk_tree_path_free);
+    g_list_free(args_list);
+
+    if (program_ran)
+    {
+        // Append newest choice to the drop down list
+        //gtk_list_store_prepend(GTK_LIST_STORE(priv->run_program_model), &iter);
+        //gtk_list_store_set(priv->run_program_model, &iter, MISC_COMBO_TEXT, program_name, -1);
+        Add_String_To_Combo_List(GTK_LIST_STORE(priv->run_program_model), program_name);
+
+        // Save list attached to the combobox
+        Save_Run_Program_With_File_List(priv->run_program_model, MISC_COMBO_TEXT);
+
+        Destroy_Run_Program_List_Window (self);
     }
     g_free(program_name);
 }
@@ -4105,21 +4255,26 @@ void Run_Program_With_Directory (GtkWidget *combobox)
  * Window where is typed the name of the program to run, which
  * receives the current file as parameter.
  */
-void Browser_Open_Run_Program_List_Window (void)
+void
+et_browser_show_open_files_with_dialog (EtBrowser *self)
 {
+    EtBrowserPrivate *priv;
     GtkWidget *VBox;
     GtkWidget *HBox;
     GtkWidget *Label;
-    GtkWidget *RunProgramComboBox;
     GtkWidget *Button;
 
-    if (RunProgramListWindow != NULL)
+    g_return_if_fail (ET_BROWSER (self));
+
+    priv = et_browser_get_instance_private (self);
+
+    if (priv->open_files_with_dialog != NULL)
     {
-        gtk_window_present(GTK_WINDOW(RunProgramListWindow));
+        gtk_window_present(GTK_WINDOW(priv->open_files_with_dialog));
         return;
     }
 
-    RunProgramListWindow = gtk_dialog_new_with_buttons (_("Open Files With"),
+    priv->open_files_with_dialog = gtk_dialog_new_with_buttons (_("Open Files With"),
                                                         GTK_WINDOW (MainWindow),
                                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                                         GTK_STOCK_CANCEL,
@@ -4128,15 +4283,15 @@ void Browser_Open_Run_Program_List_Window (void)
                                                         GTK_RESPONSE_OK,
                                                         NULL);
 
-    gtk_dialog_set_default_response (GTK_DIALOG (RunProgramListWindow),
+    gtk_dialog_set_default_response (GTK_DIALOG (priv->open_files_with_dialog),
                                      GTK_RESPONSE_OK);
-    g_signal_connect ((RunProgramListWindow), "response",
-                      G_CALLBACK (et_run_program_list_on_response), NULL);
+    g_signal_connect ((priv->open_files_with_dialog), "response",
+                      G_CALLBACK (et_run_program_list_on_response), self);
 
-    gtk_container_set_border_width (GTK_CONTAINER (RunProgramListWindow),
+    gtk_container_set_border_width (GTK_CONTAINER (priv->open_files_with_dialog),
                                     BOX_SPACING);
 
-    VBox = gtk_dialog_get_content_area (GTK_DIALOG (RunProgramListWindow));
+    VBox = gtk_dialog_get_content_area (GTK_DIALOG (priv->open_files_with_dialog));
     gtk_container_set_border_width (GTK_CONTAINER(VBox), BOX_SPACING);
 
     Label = gtk_label_new(_("Program to run:"));
@@ -4147,102 +4302,57 @@ void Browser_Open_Run_Program_List_Window (void)
     gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,0);
 
     /* The combobox to enter the program to run */
-    RunProgramComboBox = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(RunProgramModel));
-    gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(RunProgramComboBox),MISC_COMBO_TEXT);
-    gtk_box_pack_start(GTK_BOX(HBox),RunProgramComboBox,TRUE,TRUE,0);
-    gtk_widget_set_size_request(GTK_WIDGET(RunProgramComboBox),250,-1);
-    
gtk_widget_set_tooltip_text(GTK_WIDGET(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),_("Enter 
the program to run. "
-        "It will receive the current file as parameter."));
+    priv->open_files_with_combobox = 
gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(priv->run_program_model));
+    gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->open_files_with_combobox),
+                                         MISC_COMBO_TEXT);
+    gtk_box_pack_start (GTK_BOX (HBox), priv->open_files_with_combobox, TRUE,
+                        TRUE, 0);
+    gtk_widget_set_size_request (GTK_WIDGET (priv->open_files_with_combobox),
+                                 250, -1);
+    gtk_widget_set_tooltip_text (GTK_WIDGET (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox))),
+                                 _("Enter the program to run. It will receive the current file as 
parameter."));
 
     /* History list */
-    gtk_list_store_clear(RunProgramModel);
-    Load_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
-    g_signal_connect_swapped(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"activate",
-        G_CALLBACK(Run_Program_With_Selected_Files),G_OBJECT(RunProgramComboBox));
+    gtk_list_store_clear(priv->run_program_model);
+    Load_Run_Program_With_File_List(priv->run_program_model, MISC_COMBO_TEXT);
+    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
+                              "activate",
+                              G_CALLBACK (Run_Program_With_Selected_Files),
+                             self);
 
     /* The button to Browse */
     Button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
     gtk_box_pack_start(GTK_BOX(HBox),Button,FALSE,FALSE,0);
     g_signal_connect_swapped(G_OBJECT(Button),"clicked",
-                             
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(RunProgramComboBox))));
+                             
G_CALLBACK(File_Selection_Window_For_File),G_OBJECT(gtk_bin_get_child(GTK_BIN(priv->open_files_with_combobox))));
 
     /* Button to execute */
-    Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (RunProgramListWindow),
+    Button = gtk_dialog_get_widget_for_response (GTK_DIALOG (priv->open_files_with_dialog),
                                                  GTK_RESPONSE_OK);
-    g_signal_connect_swapped(G_OBJECT(Button),"clicked", 
G_CALLBACK(Run_Program_With_Selected_Files),G_OBJECT(RunProgramComboBox));
-    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (RunProgramComboBox)),
+    g_signal_connect_swapped (Button, "clicked",
+                              G_CALLBACK (Run_Program_With_Selected_Files),
+                             self);
+    g_signal_connect_swapped (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
                               "changed",
                               G_CALLBACK (empty_entry_disable_widget),
                               G_OBJECT (Button));
-    
g_signal_emit_by_name(G_OBJECT(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RunProgramComboBox)))),"changed",NULL);
+    g_signal_emit_by_name (gtk_bin_get_child (GTK_BIN (priv->open_files_with_combobox)),
+                           "changed", NULL);
 
-    gtk_widget_show_all(RunProgramListWindow);
+    gtk_widget_show_all(priv->open_files_with_dialog);
 }
 
 static void
-Destroy_Run_Program_List_Window (void)
+Destroy_Run_Program_List_Window (EtBrowser *self)
 {
-    if (RunProgramListWindow)
-    {
-        gtk_widget_destroy(RunProgramListWindow);
-        RunProgramListWindow = NULL;
-    }
-}
-
-static void
-Run_Program_With_Selected_Files (GtkWidget *combobox)
-{
-    gchar   *program_name;
-    ET_File *ETFile;
-    GList   *selected_paths;
-    GList *l;
-    GList   *args_list = NULL;
-    GtkTreeIter iter;
-    gboolean program_ran;
+    EtBrowserPrivate *priv;
 
-    if (!GTK_IS_COMBO_BOX(combobox) || !ETCore->ETFileDisplayedList)
-        return;
+    priv = et_browser_get_instance_private (self);
 
-    // Programe name to run
-    program_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox)))));
-
-    // List of files to pass as parameters
-    selected_paths = 
gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(BrowserList)), NULL);
-
-    for (l = selected_paths; l != NULL; l = g_list_next (l))
+    if (priv->open_files_with_dialog)
     {
-        if (gtk_tree_model_get_iter (GTK_TREE_MODEL (fileListModel), &iter,
-                                     (GtkTreePath *)l->data))
-        {
-            gtk_tree_model_get(GTK_TREE_MODEL(fileListModel), &iter,
-                               LIST_FILE_POINTER, &ETFile,
-                               -1);
-
-            args_list = g_list_prepend (args_list,
-                                        ((File_Name *)ETFile->FileNameCur->data)->value);
-            //args_list = g_list_append(args_list,((File_Name *)ETFile->FileNameCur->data)->value_utf8);
-        }
-    }
-
-    args_list = g_list_reverse (args_list);
-    program_ran = et_run_program (program_name, args_list);
-
-    g_list_free_full (selected_paths, (GDestroyNotify)gtk_tree_path_free);
-    g_list_free(args_list);
-
-    if (program_ran)
-    {
-        // Append newest choice to the drop down list
-        //gtk_list_store_prepend(GTK_LIST_STORE(RunProgramModel), &iter);
-        //gtk_list_store_set(RunProgramModel, &iter, MISC_COMBO_TEXT, program_name, -1);
-        Add_String_To_Combo_List(GTK_LIST_STORE(RunProgramModel), program_name);
-
-        // Save list attached to the combobox
-        Save_Run_Program_With_File_List(RunProgramModel, MISC_COMBO_TEXT);
-
-        Destroy_Run_Program_List_Window();
+        gtk_widget_hide (priv->open_files_with_dialog);
     }
-    g_free(program_name);
 }
 
 /*
@@ -4276,14 +4386,18 @@ static void
 et_rename_directory_on_response (GtkDialog *dialog, gint response_id,
                                  gpointer user_data)
 {
+    EtBrowser *self;
+
+    self = ET_BROWSER (user_data);
+
     switch (response_id)
     {
         case GTK_RESPONSE_APPLY:
-            Rename_Directory ();
+            Rename_Directory (self);
             break;
         case GTK_RESPONSE_CANCEL:
         case GTK_RESPONSE_DELETE_EVENT:
-            Destroy_Rename_Directory_Window ();
+            Destroy_Rename_Directory_Window (self);
             break;
         default:
             g_assert_not_reached ();
@@ -4302,6 +4416,10 @@ static void
 et_run_program_tree_on_response (GtkDialog *dialog, gint response_id,
                                  gpointer user_data)
 {
+    EtBrowser *self;
+
+    self = ET_BROWSER (user_data);
+
     switch (response_id)
     {
         case GTK_RESPONSE_OK:
@@ -4309,7 +4427,7 @@ et_run_program_tree_on_response (GtkDialog *dialog, gint response_id,
             break;
         case GTK_RESPONSE_CANCEL:
         case GTK_RESPONSE_DELETE_EVENT:
-            Destroy_Run_Program_Tree_Window ();
+            Destroy_Run_Program_Tree_Window (self);
             break;
         default:
             g_assert_not_reached ();
@@ -4327,6 +4445,10 @@ static void
 et_run_program_list_on_response (GtkDialog *dialog, gint response_id,
                                  gpointer user_data)
 {
+    EtBrowser *self;
+
+    self = ET_BROWSER (user_data);
+
     switch (response_id)
     {
         case GTK_RESPONSE_OK:
@@ -4334,7 +4456,7 @@ et_run_program_list_on_response (GtkDialog *dialog, gint response_id,
             break;
         case GTK_RESPONSE_CANCEL:
         case GTK_RESPONSE_DELETE_EVENT:
-            Destroy_Run_Program_List_Window ();
+            Destroy_Run_Program_List_Window (self);
             break;
         default:
             g_assert_not_reached ();
@@ -4369,3 +4491,47 @@ get_column_for_column_id (gint column_id)
 {
     return gtk_tree_view_get_column (GTK_TREE_VIEW (BrowserList), column_id);
 }
+
+static void
+et_browser_finalize (GObject *object)
+{
+    G_OBJECT_CLASS (et_browser_parent_class)->finalize (object);
+}
+
+static void
+et_browser_init (EtBrowser *self)
+{
+    EtBrowserPrivate *priv;
+
+    priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_BROWSER,
+                                                     EtBrowserPrivate);
+
+    priv->open_directory_with_dialog = NULL;
+    priv->open_directory_with_combobox = NULL;
+    priv->open_files_with_dialog = NULL;
+    priv->open_files_with_combobox = NULL;
+
+    create_browser (self);
+}
+
+static void
+et_browser_class_init (EtBrowserClass *klass)
+{
+    G_OBJECT_CLASS (klass)->finalize = et_browser_finalize;
+
+    g_type_class_add_private (klass, sizeof (EtBrowserPrivate));
+}
+
+/*
+ * et_browser_new:
+ *
+ * Create a new EtBrowser instance.
+ *
+ * Returns: a new #EtBrowser
+ */
+EtBrowser *
+et_browser_new (void)
+{
+    return g_object_new (ET_TYPE_BROWSER, "orientation",
+                         GTK_ORIENTATION_VERTICAL, NULL);
+}
diff --git a/src/browser.h b/src/browser.h
index 5965379..f51c592 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -1,4 +1,3 @@
-/* browser.h - 2000/04/28 */
 /*
  *  EasyTAG - Tag editor for MP3 and Ogg Vorbis files
  *  Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
@@ -19,11 +18,42 @@
  */
 
 
-#ifndef __BROWSER_H__
-#define __BROWSER_H__
+#ifndef ET_BROWSER_H_
+#define ET_BROWSER_H_
 
 #include "et_core.h"
 
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define ET_TYPE_BROWSER (et_browser_get_type ())
+#define ET_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_BROWSER, EtBrowser))
+
+typedef struct _EtBrowser EtBrowser;
+typedef struct _EtBrowserClass EtBrowserClass;
+typedef struct _EtBrowserPrivate EtBrowserPrivate;
+
+struct _EtBrowser
+{
+    /*< private >*/
+    GtkBox parent_instance;
+    EtBrowserPrivate *priv;
+};
+
+struct _EtBrowserClass
+{
+    /*< private >*/
+    GtkBoxClass parent_class;
+};
+
+GType et_browser_get_type (void);
+EtBrowser *et_browser_new (void);
+void et_browser_show_open_directory_with_dialog (EtBrowser *self);
+void et_browser_show_open_files_with_dialog (EtBrowser *self);
+void et_browser_show_rename_directory_dialog (EtBrowser *self);
+
+G_END_DECLS
 
 /****************
  * Declarations *
@@ -63,44 +93,6 @@ enum
 
 enum
 {
-    TREE_COLUMN_DIR_NAME,
-    TREE_COLUMN_FULL_PATH,
-    TREE_COLUMN_SCANNED,
-    TREE_COLUMN_HAS_SUBDIR,
-    TREE_COLUMN_ICON,
-    TREE_COLUMN_COUNT
-};
-
-enum
-{
-    LIST_FILE_NAME,
-    /* Tag fields. */
-    LIST_FILE_TITLE,
-    LIST_FILE_ARTIST,
-    LIST_FILE_ALBUM_ARTIST,
-    LIST_FILE_ALBUM,
-    LIST_FILE_YEAR,
-    LIST_FILE_DISCNO,
-    LIST_FILE_TRACK,
-    LIST_FILE_GENRE,
-    LIST_FILE_COMMENT,
-    LIST_FILE_COMPOSER,
-    LIST_FILE_ORIG_ARTIST,
-    LIST_FILE_COPYRIGHT,
-    LIST_FILE_URL,
-    LIST_FILE_ENCODED_BY,
-    /* End of columns with associated UI columns. */
-    LIST_FILE_POINTER,
-    LIST_FILE_KEY,
-    LIST_FILE_OTHERDIR, /* To change color for alternate directories. */
-    LIST_FONT_WEIGHT,
-    LIST_ROW_BACKGROUND,
-    LIST_ROW_FOREGROUND,
-    LIST_COLUMN_COUNT
-};
-
-enum
-{
     ARTIST_PIXBUF,
     ARTIST_NAME,
     ARTIST_NUM_ALBUMS,
@@ -128,24 +120,16 @@ enum
 GtkWidget *BrowserList;
 GtkWidget *BrowserAlbumList;
 GtkWidget *BrowserArtistList;
-GtkWidget *BrowserEntryCombo;
 GtkListStore *BrowserEntryModel;
-GtkWidget *BrowserHPaned;
-GtkWidget *ArtistAlbumVPaned;
-
-GtkWidget *RenameDirectoryWindow;
-GtkWidget *RenameDirectoryMaskCombo;
-GtkWidget *RenameDirectoryPreviewLabel;
 
 
 /**************
  * Prototypes *
  **************/
 
-GtkWidget   *Create_Browser_Items    (GtkWidget *parent);
 gboolean     Browser_Tree_Select_Dir (const gchar *current_path);
-void         Browser_Tree_Rebuild    (gchar *path_to_load);
-void         Browser_Tree_Collapse   (void);
+void et_browser_reload (EtBrowser *self);
+void et_browser_collapse (EtBrowser *self);
 
 void         Browser_List_Load_File_List            (GList *etfilelist, ET_File *etfile_to_select);
 void         Browser_List_Refresh_Whole_List        (void);
@@ -170,23 +154,19 @@ void         Browser_Display_Tree_Or_Artist_Album_List (void);
 
 void         Browser_Area_Set_Sensitive  (gboolean activate);
 
-void         Browser_Load_Home_Directory            (void);
-void            Browser_Load_Desktop_Directory                 (void);
-void            Browser_Load_Documents_Directory               (void);
-void            Browser_Load_Downloads_Directory               (void);
-void            Browser_Load_Music_Directory                   (void);
-void et_browser_on_action_parent_directory (void);
+void et_browser_go_home (EtBrowser *self);
+void et_browser_go_desktop (EtBrowser *self);
+void et_browser_go_documents (EtBrowser *self);
+void et_browser_go_download (EtBrowser *self);
+void et_browser_go_music (EtBrowser *self);
+void et_browser_go_parent (EtBrowser *self);
 
 void         Browser_Load_Default_Directory         (void);
-void         Browser_Reload_Directory               (void);
+void et_browser_reload_directory (EtBrowser *self);
 void         Set_Current_Path_As_Default            (void);
 gchar       *Browser_Get_Current_Path               (void);
 
-void         Browser_Open_Rename_Directory_Window (void);
-void         Browser_Open_Run_Program_Tree_Window (void);
-void         Browser_Open_Run_Program_List_Window (void);
-
 GtkTreeViewColumn *get_column_for_column_id (gint column_id);
 GtkSortType get_sort_order_for_column_id (gint column_id);
 
-#endif /* __BROWSER_H__ */
+#endif /* ET_BROWSER_H_ */
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 71b2dc1..66b8c68 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -1021,47 +1021,6 @@ Scan_Rename_File_Prefix_Path (EtScanDialog *self)
 }
 
 
-/*******************************
- * Scanner To Rename Directory *
- *******************************/
-void Scan_Rename_Directory_Generate_Preview (void)
-{
-    gchar *preview_text = NULL;
-    gchar *mask = NULL;
-
-    if (!ETCore->ETFileDisplayed
-    ||  !RenameDirectoryWindow || !RenameDirectoryMaskCombo || !RenameDirectoryPreviewLabel)
-        return;
-
-    mask = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(RenameDirectoryMaskCombo)))));
-    if (!mask)
-        return;
-
-    preview_text = Scan_Generate_New_Filename_From_Mask(ETCore->ETFileDisplayed,mask,FALSE);
-
-    if (GTK_IS_LABEL(RenameDirectoryPreviewLabel))
-    {
-        if (preview_text)
-        {
-            //gtk_label_set_text(GTK_LABEL(priv->rename_file_preview_label),preview_text);
-            gchar *tmp_string = g_markup_printf_escaped("%s",preview_text); // To avoid problem with strings 
containing characters like '&'
-            gchar *str = g_strdup_printf("<i>%s</i>",tmp_string);
-            gtk_label_set_markup(GTK_LABEL(RenameDirectoryPreviewLabel),str);
-            g_free(tmp_string);
-            g_free(str);
-        } else
-        {
-            gtk_label_set_text(GTK_LABEL(RenameDirectoryPreviewLabel),"");
-        }
-
-        // Force the window to be redrawed else the preview label may be not placed correctly
-        gtk_widget_queue_resize(RenameDirectoryWindow);
-    }
-
-    g_free(mask);
-    g_free(preview_text);
-}
-
 gchar *Scan_Generate_New_Directory_Name_From_Mask (ET_File *ETFile, gchar *mask, gboolean 
no_dir_check_or_conversion)
 {
     return Scan_Generate_New_Filename_From_Mask(ETFile,mask,no_dir_check_or_conversion);
diff --git a/src/scan_dialog.h b/src/scan_dialog.h
index 04b88c4..249ff36 100644
--- a/src/scan_dialog.h
+++ b/src/scan_dialog.h
@@ -85,7 +85,6 @@ enum {
 void Scan_Select_Mode_And_Run_Scanner (EtScanDialog *self, ET_File *ETFile);
 gchar *Scan_Generate_New_Filename_From_Mask       (ET_File *ETFile, gchar *mask, gboolean 
no_dir_check_or_conversion);
 gchar *Scan_Generate_New_Directory_Name_From_Mask (ET_File *ETFile, gchar *mask, gboolean 
no_dir_check_or_conversion);
-void   Scan_Rename_Directory_Generate_Preview (void);
 
 void entry_check_rename_file_mask (GtkEntry *entry, gpointer user_data);
 


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