1 /* This file is part of Cinaest.
3 * Copyright (C) 2009 Philipp Zabel
5 * Cinaest is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * Cinaest is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
21 public class CinaestProgram : Hildon.Program {
22 SourceListWindow window;
23 public static List<Plugin> plugins;
24 public static Orientation orientation;
27 Environment.set_application_name ("Cinæst");
29 window = new SourceListWindow ();
30 window.destroy.connect (Gtk.main_quit);
32 orientation = new Orientation ();
33 orientation.changed.connect (on_orientation_changed);
38 private void on_orientation_changed () {
39 if (orientation.portrait) {
40 Hildon.gtk_window_set_portrait_flags (window, PortraitFlags.REQUEST);
42 Hildon.gtk_window_set_portrait_flags (window, PortraitFlags.SUPPORT);
46 public void register_plugins (Osso.Context context) {
47 string plugin_path = Config.PKGLIBDIR;
49 var directory = File.new_for_path (plugin_path);
50 var enumerator = directory.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
53 while ((file_info = enumerator.next_file (null)) != null) {
54 string name = file_info.get_name ();
56 if (name.has_suffix (".so")) {
58 string path = Path.build_filename (plugin_path, name, null);
60 var registrar = new PluginRegistrar<Plugin> (path);
63 plugin = registrar.new_object ();
64 plugins.append (plugin);
65 plugin.hello (window, context);
70 stderr.printf ("Error: %s\n", e.message);
75 foreach (Plugin plugin in plugins) {
76 window.add_sources (plugin.get_sources ());
81 static int main (string[] args) {
84 Intl.setlocale (LocaleCategory.ALL, "");
85 Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
86 Intl.textdomain (Config.GETTEXT_PACKAGE);
88 var osso_context = new Osso.Context ("org.maemo.cinaest", Config.VERSION, true, null);
89 if (osso_context == null) {
90 return Osso.Status.ERROR;
93 CinaestProgram app = new CinaestProgram ();
94 app.register_plugins (osso_context);