* Use new fm_launch_files_simple API.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Mon, 15 Feb 2010 12:07:13 +0000 (20:07 +0800)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Mon, 15 Feb 2010 12:10:22 +0000 (20:10 +0800)
* Correctly handle command line arguments.

src/desktop.c
src/main-win.c
src/pcmanfm.c
src/pcmanfm.h

index 6b82490..eb59d0e 100644 (file)
@@ -422,11 +422,6 @@ void activate_selected_items(FmDesktop* desktop)
     g_list_free(items);
 }
 
-static void open_folder_hook(FmFileInfo* fi, gpointer user_data)
-{
-    fm_main_win_open_in_last_active(fi->path);
-}
-
 gboolean on_button_press( GtkWidget* w, GdkEventButton* evt )
 {
     FmDesktop* self = (FmDesktop*)w;
@@ -482,10 +477,7 @@ gboolean on_button_press( GtkWidget* w, GdkEventButton* evt )
             /* left single click */
             if( evt->button == 1 && fm_config->single_click && clicked_item->is_selected )
             {
-                if( fm_file_info_is_dir(clicked_item->fi) )
-                    fm_main_win_open_in_last_active(clicked_item->fi->path);
-                else
-                    fm_launch_file(w, NULL, clicked_item->fi);
+                fm_launch_file_simple(w, NULL, clicked_item->fi, pcmanfm_open_folder, NULL);
                 goto out;
             }
             if( evt->button == 3 )  /* right click, context menu */
@@ -506,7 +498,7 @@ gboolean on_button_press( GtkWidget* w, GdkEventButton* evt )
                 files = fm_desktop_get_selected_files(self);
                 fi = (FmFileInfo*)fm_list_peek_head(files);
                 menu = fm_file_menu_new_for_files(files, TRUE);
-                fm_file_menu_set_folder_hook(menu, open_folder_hook, NULL);
+                fm_file_menu_set_folder_func(menu, pcmanfm_open_folder, NULL);
                 fm_list_unref(files);
 
                 /* merge some specific menu items for folders */
@@ -549,10 +541,7 @@ gboolean on_button_press( GtkWidget* w, GdkEventButton* evt )
     {
         if( clicked_item && evt->button == 1)   /* left double click */
         {
-            if( fm_file_info_is_dir(clicked_item->fi) )
-                fm_main_win_open_in_last_active(clicked_item->fi->path);
-            else
-                fm_launch_file(w, NULL, clicked_item->fi);
+            fm_launch_file_simple(w, NULL, clicked_item->fi, pcmanfm_open_folder, NULL);
             goto out;
         }
     }
index 3fe39f1..94fa2f9 100644 (file)
@@ -139,10 +139,19 @@ static void on_view_loaded( FmFolderView* view, FmPath* path, gpointer user_data
     update_volume_info(win);
 }
 
-static void open_folder_hook(FmFileInfo* fi, gpointer user_data)
+static gboolean open_folder_func(GAppLaunchContext* ctx, GList* folder_infos, gpointer user_data, GError** err)
 {
     FmMainWin* win = FM_MAIN_WIN(user_data);
+    GList* l = folder_infos;
+    FmFileInfo* fi = (FmFileInfo*)l->data;
     fm_main_win_chdir(win, fi->path);
+    l=l->next;
+    for(; l; l=l->next)
+    {
+        FmFileInfo* fi = (FmFileInfo*)l->data;
+        fm_main_win_add_tab(win, fi->path);
+    }
+    return TRUE;
 }
 
 static void on_file_clicked(FmFolderView* fv, FmFolderViewClickType type, FmFileInfo* fi, FmMainWin* win)
@@ -163,7 +172,7 @@ static void on_file_clicked(FmFolderView* fv, FmFolderViewClickType type, FmFile
         }
         else
         {
-            fm_launch_file(win, NULL, fi);
+            fm_launch_file_simple(win, NULL, fi, open_folder_func, win);
         }
         break;
     case FM_FV_CONTEXT_MENU:
@@ -173,7 +182,7 @@ static void on_file_clicked(FmFolderView* fv, FmFolderViewClickType type, FmFile
             GtkMenu* popup;
             FmFileInfoList* files = fm_folder_view_get_selected_files(fv);
             menu = fm_file_menu_new_for_files(files, TRUE);
-            fm_file_menu_set_folder_hook(menu, open_folder_hook, win);
+            fm_file_menu_set_folder_func(menu, open_folder_func, win);
             fm_list_unref(files);
 
             /* merge some specific menu items for folders */
index fe39068..76e2fff 100644 (file)
@@ -41,6 +41,7 @@
 #include "main-win.h"
 #include "desktop.h"
 #include "pref.h"
+#include "pcmanfm.h"
 
 static int sock;
 GIOChannel* io_channel = NULL;
@@ -413,7 +414,21 @@ gboolean pcmanfm_run()
     }
     else
     {
-        if(!files_to_open)
+        if(files_to_open)
+        {
+            char** filename;
+            FmJob* job = fm_file_info_job_new(NULL);
+            for(filename=files_to_open; *filename; ++filename)
+            {
+                FmPath* path = fm_path_new(*filename);
+                fm_file_info_job_add(job, path);
+                fm_path_unref(path);
+            }
+            fm_job_run_sync(job);
+            fm_launch_files_simple(NULL, NULL, FM_FILE_INFO_JOB(job)->file_infos, pcmanfm_open_folder, NULL);
+            g_object_unref(job);
+        }
+        else
         {
             FmPath* path;
             w = fm_main_win_new();
@@ -443,3 +458,15 @@ void pcmanfm_unref()
     if( 0 == n_pcmanfm_ref && !daemon_mode && !desktop_running )
         gtk_main_quit();
 }
+
+gboolean pcmanfm_open_folder(GAppLaunchContext* ctx, GList* folder_infos, gpointer user_data, GError** err)
+{
+    FmMainWin* win = FM_MAIN_WIN(user_data);
+    GList* l = folder_infos;
+    for(; l; l=l->next)
+    {
+        FmFileInfo* fi = (FmFileInfo*)l->data;
+        fm_main_win_open_in_last_active(fi->path);
+    }
+    return TRUE;
+}
index d61bc76..7d54212 100644 (file)
@@ -34,6 +34,8 @@ void pcmanfm_ref();
  */
 void pcmanfm_unref();
 
+gboolean pcmanfm_open_folder(GAppLaunchContext* ctx, GList* folder_infos, gpointer user_data, GError** err);
+
 G_END_DECLS
 
 #endif