Movie list menu: use hildon-fm-2 file chooser dialog to import files
[cinaest] / src / main.vala
index 60fbfd9..752997c 100644 (file)
 using Hildon;
 
 public class CinaestProgram : Hildon.Program {
-       MovieListWindow window;
-       List<Plugin> plugins;
+       SourceListWindow window;
+       public static List<Plugin> plugins;
+       public static Orientation orientation;
 
        construct {
                Environment.set_application_name ("Cinæst");
 
-               window = new MovieListWindow ();
+               window = new SourceListWindow ();
                window.destroy.connect (Gtk.main_quit);
 
+               orientation = new Orientation ();
+               orientation.changed.connect (on_orientation_changed);
+
                add_window (window);
        }
 
-       public void register_plugins () {
+       private void on_orientation_changed () {
+               if (orientation.portrait) {
+                       Hildon.gtk_window_set_portrait_flags (window, PortraitFlags.REQUEST);
+               } else {
+                       Hildon.gtk_window_set_portrait_flags (window, PortraitFlags.SUPPORT);
+               }
+       }
+
+       public void register_plugins (Osso.Context context) {
                string plugin_path = Config.PKGLIBDIR;
                try {
                        var directory = File.new_for_path (plugin_path);
@@ -50,7 +62,7 @@ public class CinaestProgram : Hildon.Program {
 
                                        plugin = registrar.new_object ();
                                        plugins.append (plugin);
-                                       plugin.hello (window);
+                                       plugin.hello (window, context);
                                }
                        }
 
@@ -60,30 +72,26 @@ public class CinaestProgram : Hildon.Program {
        }
 
        public void run () {
-               register_plugins ();
-               // FIXME - always start with the first plugin's first source for now
-               if (plugins != null) {
-                       var plugin = plugins.first ().data;
-                       if (plugin != null)
-                               window.store.source = plugin.get_sources ().first ().data;
+               foreach (Plugin plugin in plugins) {
+                       window.add_sources (plugin.get_sources ());
                }
                Gtk.main ();
        }
 
        static int main (string[] args) {
                Gtk.init (ref args);
-               Gdk.threads_init ();
 
                Intl.setlocale (LocaleCategory.ALL, "");
                Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
                Intl.textdomain (Config.GETTEXT_PACKAGE);
 
-               var osso_context = new Osso.Context ("org.maemo.garage.cinaest", Config.VERSION, true, null);
+               var osso_context = new Osso.Context ("org.maemo.cinaest", Config.VERSION, true, null);
                if (osso_context == null) {
                        return Osso.Status.ERROR;
                }
 
                CinaestProgram app = new CinaestProgram ();
+               app.register_plugins (osso_context);
                app.run ();
 
                return 0;