/* This file is part of Beifahrer. * * Copyright (C) 2010 Philipp Zabel * * Beifahrer is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Beifahrer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Beifahrer. If not, see . */ using Hildon; public class BeifahrerProgram : Hildon.Program { private const string BEIFAHRER_SERVICE = "org.maemo.beifahrer"; private const string BROWSER_SERVICE = "com.nokia.osso_browser"; private const string BROWSER_PATH = "/com/nokia/osso_browser"; private const string BROWSER_IF = "com.nokia.osso_browser"; QueryWindow window; public static Orientation orientation; construct { Environment.set_application_name ("Beifahrer"); window = new QueryWindow (); window.destroy.connect (Gtk.main_quit); orientation = new Orientation (); orientation.changed.connect (on_orientation_changed); add_window (window); } 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 static void open_browser (Gtk.Window window, string url) { try { var conn = DBus.Bus.get (DBus.BusType.SESSION); dynamic DBus.Object browser = conn.get_object (BROWSER_SERVICE, BROWSER_PATH, BROWSER_IF); browser.open_new_window (url, false); } catch (Error e) { Banner.show_information (window, null, _("Failed to open browser.")); } } static int main (string[] args) { Gtk.init (ref args); Intl.setlocale (LocaleCategory.ALL, ""); Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); Intl.textdomain (Config.GETTEXT_PACKAGE); var osso_context = new Osso.Context (BEIFAHRER_SERVICE, Config.VERSION, true, null); if (osso_context == null) { return Osso.Status.ERROR; } var app = new BeifahrerProgram (); Gtk.main (); return 0; } }