X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmain.vala;h=752997c5a7cb24415011bc9f5f43c5b8fbed5f5b;hb=496ca82635f6e53bd37a97bbb99d2cf7ae5b0829;hp=6da6bfdd4fa6f8e0a5129cf4879cdb686b8aa142;hpb=689a1f97a56e6d80424f1b43b2bcfc0cc638a69a;p=cinaest diff --git a/src/main.vala b/src/main.vala index 6da6bfd..752997c 100644 --- a/src/main.vala +++ b/src/main.vala @@ -19,30 +19,79 @@ using Hildon; public class CinaestProgram : Hildon.Program { - MovieListWindow window; + SourceListWindow window; + public static List plugins; + public static Orientation orientation; construct { - window = new MovieListWindow (); + Environment.set_application_name ("Cinæst"); + + window = new SourceListWindow (); window.destroy.connect (Gtk.main_quit); + orientation = new Orientation (); + orientation.changed.connect (on_orientation_changed); + add_window (window); + } - Environment.set_application_name ("Cinæst"); + 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); + var enumerator = directory.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0, null); + + FileInfo file_info; + while ((file_info = enumerator.next_file (null)) != null) { + string name = file_info.get_name (); + + if (name.has_suffix (".so")) { + Plugin plugin; + string path = Path.build_filename (plugin_path, name, null); + + var registrar = new PluginRegistrar (path); + registrar.load (); + + plugin = registrar.new_object (); + plugins.append (plugin); + plugin.hello (window, context); + } + } + + } catch (Error e) { + stderr.printf ("Error: %s\n", e.message); + } } public void run () { + foreach (Plugin plugin in plugins) { + window.add_sources (plugin.get_sources ()); + } Gtk.main (); } static int main (string[] args) { Gtk.init (ref args); - var osso_context = new Osso.Context ("org.maemo.cinaest", "0.0.1", true, null); + Intl.setlocale (LocaleCategory.ALL, ""); + Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); + Intl.textdomain (Config.GETTEXT_PACKAGE); + + 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;