Discard own handle of file manager, use XDG compiant settings instead.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 8 Feb 2014 00:26:08 +0000 (02:26 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 8 Feb 2014 00:26:08 +0000 (02:26 +0200)
We should not have own setup for folders opener but use the same handler
application which is used by other applications - i.e. default handler
for context type "inode/directory".
Using libfm gives us a convenient way to choose file manager from list.

data/ui/panel-pref.glade
src/configurator.c
src/panel.h
src/plugin.c
src/private.h

index f3a9f2d..e734537 100644 (file)
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
+                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="active">True</property>
                                             <property name="draw_indicator">True</property>
                                           </object>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="draw_indicator">True</property>
                                             <property name="group">edge_bottom</property>
                                           </object>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="draw_indicator">True</property>
                                             <property name="group">edge_bottom</property>
                                           </object>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="draw_indicator">True</property>
                                             <property name="group">edge_bottom</property>
                                           </object>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="active">True</property>
                                             <property name="draw_indicator">True</property>
                                           </object>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="draw_indicator">True</property>
                                             <property name="group">alignment_left</property>
                                           </object>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
+                                            <property name="use_action_appearance">False</property>
                                             <property name="draw_indicator">True</property>
                                             <property name="group">alignment_left</property>
                                           </object>
                               </object>
                               <packing>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="left_attach">2</property>
                                 <property name="right_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                               <packing>
                                 <property name="top_attach">2</property>
                                 <property name="bottom_attach">3</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="active">True</property>
                                 <property name="draw_indicator">True</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="use_underline">True</property>
                                     <property name="draw_indicator">True</property>
                                     <property name="group">bg_none</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">True</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="use_alpha">True</property>
                                     <property name="color">#000000000000</property>
                                   </object>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="use_underline">True</property>
                                     <property name="draw_indicator">True</property>
                                     <property name="group">bg_none</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="use_underline">True</property>
                                     <property name="draw_indicator">True</property>
                                   </object>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">True</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="color">#000000000000</property>
                                   </object>
                                   <packing>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="use_underline">True</property>
                                     <property name="draw_indicator">True</property>
                                   </object>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="use_stock">True</property>
                       </object>
                       <packing>
                                 <property name="right_attach">2</property>
                                 <property name="top_attach">2</property>
                                 <property name="bottom_attach">3</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="right_attach">2</property>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
-                                <property name="y_options"/>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkEntry" id="file_manager">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="invisible_char">●</property>
-                                <property name="primary_icon_activatable">False</property>
-                                <property name="secondary_icon_activatable">False</property>
-                                <property name="primary_icon_sensitive">True</property>
-                                <property name="secondary_icon_sensitive">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="top_attach">2</property>
                                 <property name="bottom_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                             <child>
                               </object>
                               <packing>
                                 <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
+                                <property name="y_options"></property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkVBox" id="vbox13">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <child>
+                                  <object class="GtkEntry" id="file_manager">
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">●</property>
+                                    <property name="invisible_char_set">True</property>
+                                    <property name="primary_icon_activatable">False</property>
+                                    <property name="secondary_icon_activatable">False</property>
+                                    <property name="primary_icon_sensitive">True</property>
+                                    <property name="secondary_icon_sensitive">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkComboBox" id="fm_combobox">
+                                    <property name="visible">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="y_options"></property>
                               </packing>
                             </child>
                           </object>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
                               </object>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
                                     <property name="draw_indicator">True</property>
                                   </object>
                                   <packing>
index 8dbbf45..205e5e7 100644 (file)
@@ -58,7 +58,6 @@ Command commands[] = {
     { NULL, NULL },
 };
 
-static char* file_manager_cmd = NULL;
 static char* logout_cmd = NULL;
 
 extern GSList* all_panels;
@@ -907,10 +906,24 @@ update_toggle_button(GtkWidget *w, gboolean n)
     RET();
 }
 
+static void on_app_chooser_destroy(GtkComboBox *fm, gpointer _unused)
+{
+    gboolean is_changed;
+    GAppInfo *app = fm_app_chooser_combo_box_dup_selected_app(fm, &is_changed);
+    if(app)
+    {
+        if(is_changed)
+            g_app_info_set_as_default_for_type(app, "inode/directory", NULL);
+        g_object_unref(app);
+    }
+}
+
 void panel_configure( Panel* p, int sel_page )
 {
     GtkBuilder* builder;
     GtkWidget *w, *w2, *tint_clr;
+    FmMimeType *mt;
+    GtkComboBox *fm;
     GdkScreen *screen;
     gint monitors;
 
@@ -1135,12 +1148,11 @@ void panel_configure( Panel* p, int sel_page )
         init_plugin_list( p, GTK_TREE_VIEW(plugin_list), w );
     }
     /* advanced, applications */
-    w = (GtkWidget*)gtk_builder_get_object( builder, "file_manager" );
-    if (file_manager_cmd)
-        gtk_entry_set_text( GTK_ENTRY(w), file_manager_cmd );
-    g_signal_connect( w, "focus-out-event",
-                      G_CALLBACK(on_entry_focus_out),
-                      &file_manager_cmd);
+    mt = fm_mime_type_from_name("inode/directory");
+    fm = GTK_COMBO_BOX(gtk_builder_get_object(builder, "fm_combobox"));
+    fm_app_chooser_combo_box_setup_for_mime_type(fm, mt);
+    fm_mime_type_unref(mt);
+    g_signal_connect(fm, "destroy", G_CALLBACK(on_app_chooser_destroy), NULL);
 
     w = (GtkWidget*)gtk_builder_get_object( builder, "term" );
     if (fm_config->terminal)
@@ -1507,7 +1519,6 @@ void load_global_config()
 
     if( loaded )
     {
-        file_manager_cmd = g_key_file_get_string( kf, command_group, "FileManager", NULL );
         logout_cmd = g_key_file_get_string( kf, command_group, "Logout", NULL );
     }
     g_key_file_free( kf );
@@ -1520,8 +1531,6 @@ static void save_global_config()
     if( f )
     {
         fprintf( f, "[%s]\n", command_group );
-        if( file_manager_cmd )
-            fprintf( f, "FileManager=%s\n", file_manager_cmd );
         if( logout_cmd )
             fprintf( f, "Logout=%s\n", logout_cmd );
         fclose( f );
@@ -1530,14 +1539,27 @@ static void save_global_config()
 
 void free_global_config()
 {
-    g_free( file_manager_cmd );
     g_free( logout_cmd );
 }
 
-extern const char*
+/* this is dirty and should be removed later */
+const char*
 lxpanel_get_file_manager()
 {
-    return file_manager_cmd ? file_manager_cmd : "pcmanfm %s";
+    GAppInfo *app = g_app_info_get_default_for_type("inode/directory", TRUE);
+    static char *exec = NULL;
+    const char *c, *x;
+
+    if (!app)
+        return "pcmanfm %s";
+    c = g_app_info_get_commandline(app);
+    x = strchr(c, ' '); /* skip all arguments */
+    g_free(exec);
+    if (x)
+        exec = g_strndup(c, x - c);
+    else
+        exec = g_strdup(c);
+    return exec;
 }
 
 /* vim: set sw=4 et sts=4 : */
index 3d4362b..8643640 100644 (file)
@@ -102,8 +102,6 @@ extern void panel_update_background( Panel* p );
 extern int panel_handle_x_error(Display * d, XErrorEvent * ev);
 extern int panel_handle_x_error_swallow_BadWindow_BadDrawable(Display * d, XErrorEvent * ev);
 
-extern const char* lxpanel_get_file_manager();
-
 /* Accessors APIs for Panel* */
 extern gboolean panel_is_horizontal(Panel *panel);
 extern gint panel_get_icon_size(Panel *panel);
index 51f5214..9923bd0 100644 (file)
@@ -363,6 +363,7 @@ static GRecMutex _mutex;
 static GStaticRecMutex _mutex = G_STATIC_REC_MUTEX_INIT;
 #endif
 
+#ifndef DISABLE_PLUGINS_LOADING
 FM_MODULE_DEFINE_TYPE(lxpanel_gtk, LXPanelPluginInit, 1)
 
 static gboolean fm_module_callback_lxpanel_gtk(const char *name, gpointer init, int ver)
@@ -370,6 +371,7 @@ static gboolean fm_module_callback_lxpanel_gtk(const char *name, gpointer init,
     /* ignore ver for now, only 1 exists */
     return lxpanel_register_plugin_type(name, init);
 }
+#endif
 
 static gboolean old_plugins_loaded = FALSE;
 
@@ -380,8 +382,10 @@ void _prepare_modules(void)
     lxpanel_plugin_qinit = g_quark_from_static_string("LXPanel::plugin-init");
     lxpanel_plugin_qconf = g_quark_from_static_string("LXPanel::plugin-conf");
     lxpanel_plugin_qpanel = g_quark_from_static_string("LXPanel::plugin-panel");
+#ifndef DISABLE_PLUGINS_LOADING
     fm_modules_add_directory(PACKAGE_LIB_DIR "/lxpanel/plugins");
     fm_module_register_lxpanel_gtk();
+#endif
 }
 
 void _unload_modules(void)
@@ -389,7 +393,9 @@ void _unload_modules(void)
     GHashTableIter iter;
     gpointer key, val;
 
+#ifndef DISABLE_PLUGINS_LOADING
     fm_module_unregister_type("lxpanel_gtk");
+#endif
     g_hash_table_iter_init(&iter, _all_types);
     while(g_hash_table_iter_next(&iter, &key, &val))
     {
index afeb717..2a228b1 100644 (file)
@@ -160,13 +160,15 @@ const gchar *num2str(pair *p, int num, const gchar *defval);
 
 char* get_config_file( const char* profile, const char* file_name, gboolean is_global );
 
-/* Extracted from plugin.h */
-
 
 /* -----------------------------------------------------------------------------
  *   Deprecated declarations. Kept for compatibility with old code plugins.
  *   Should be removed and appropriate code cleaned on some of next releases. */
 
+/* Extracted from panel.h */
+extern const char* lxpanel_get_file_manager();
+
+
 /* Extracted from misc.h */
 typedef struct _Plugin Plugin;