From 181aa10b9d342eb25739a30ed8039bd996023f9f Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 27 Jan 2009 02:57:40 +0100 Subject: [PATCH] Integrate Midori with Maemo, use a Hildon window and adjust the interface To make Midori play nicely with Maemo the menubar is now integrated, we have a service file, a specific toolbar layout, no statusbar and icon styles. The changes are applied if hildon is available, and can of course be manually enabled or disabled. --- data/com.nokia.midori.service | 3 + midori.desktop.in => data/midori.desktop.in | 2 + midori/midori-browser.c | 81 +++++++++++++++++++-- midori/midori-browser.h | 7 ++ midori/midori-panel.c | 3 + midori/midori-preferences.c | 8 +- midori/midori-websettings.c | 2 +- midori/wscript_build | 2 +- wscript | 38 +++++++--- 9 files changed, 124 insertions(+), 22 deletions(-) create mode 100644 data/com.nokia.midori.service rename midori.desktop.in => data/midori.desktop.in (81%) diff --git a/data/com.nokia.midori.service b/data/com.nokia.midori.service new file mode 100644 index 00000000..f8d1df0f --- /dev/null +++ b/data/com.nokia.midori.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.nokia.midori +Exec=/usr/bin/midori diff --git a/midori.desktop.in b/data/midori.desktop.in similarity index 81% rename from midori.desktop.in rename to data/midori.desktop.in index 487d7f8f..fc28df34 100644 --- a/midori.desktop.in +++ b/data/midori.desktop.in @@ -10,3 +10,5 @@ Exec=midori %u Icon=midori Terminal=false StartupNotify=true +X-Osso-Type=application/x-executable +X-Osso-Service=midori diff --git a/midori/midori-browser.c b/midori/midori-browser.c index df41a9e4..6123046b 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -38,7 +38,11 @@ struct _MidoriBrowser { + #if HAVE_HILDON + HildonWindow parent_instance; + #else GtkWindow parent_instance; + #endif GtkActionGroup* action_group; GtkWidget* menubar; @@ -78,7 +82,11 @@ struct _MidoriBrowser KatzeNet* net; }; +#if HAVE_HILDON +G_DEFINE_TYPE (MidoriBrowser, midori_browser, HILDON_TYPE_WINDOW) +#else G_DEFINE_TYPE (MidoriBrowser, midori_browser, GTK_TYPE_WINDOW) +#endif enum { @@ -1596,6 +1604,7 @@ midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem, GdkEventButton* event, MidoriBrowser* browser); +#if !HAVE_HILDON static void _midori_browser_save_toolbar_items (MidoriBrowser* browser) { @@ -1651,6 +1660,7 @@ midori_browser_toolbar_remove_item_cb (GtkWidget* menuitem, gtk_container_remove (GTK_CONTAINER (browser->navigationbar), widget); _midori_browser_save_toolbar_items (browser); } +#endif static gboolean midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, @@ -1679,23 +1689,27 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, _action_by_name (browser, "Statusbar")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + #if !HAVE_HILDON if (widget == browser->navigationbar || gtk_widget_is_ancestor (widget, browser->navigationbar)) { GtkAction* widget_action = gtk_widget_get_action (widget); const gchar* actions[] = { "TabNew", "Open", "SaveAs", "Print", "Find", "Preferences", "Window", "Bookmarks", "ReloadStop", "ZoomIn", - "ZoomOut", "Back", "Forward", "Homepage", "Trash", "Search" }; + "ZoomOut", "Back", "Forward", "Homepage", "Panel", "Trash", "Search" }; GtkWidget* submenu; gsize i; menuitem = gtk_separator_menu_item_new (); + gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); submenu = gtk_menu_new (); menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_ADD, NULL); + gtk_widget_show (menuitem); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL); + gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); if (widget_action && strcmp (gtk_action_get_name (widget_action), "Location")) @@ -1732,9 +1746,10 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget, g_signal_connect (menuitem, "activate", G_CALLBACK (midori_browser_toolbar_add_item_cb), browser); } + sokoke_container_show_children (GTK_CONTAINER (submenu)); } + #endif - sokoke_container_show_children (GTK_CONTAINER (menu)); katze_widget_popup (widget, GTK_MENU (menu), NULL, button == -1 ? KATZE_MENU_POSITION_LEFT : KATZE_MENU_POSITION_CURSOR); return TRUE; @@ -1874,7 +1889,9 @@ _action_menubar_activate (GtkToggleAction* action, { gboolean active = gtk_toggle_action_get_active (action); g_object_set (browser->settings, "show-menubar", active, NULL); + #if !HAVE_HILDON sokoke_widget_set_visible (browser->menubar, active); + #endif } static void @@ -1901,7 +1918,9 @@ _action_statusbar_activate (GtkToggleAction* action, { gboolean active = gtk_toggle_action_get_active (action); g_object_set (browser->settings, "show-statusbar", active, NULL); + #if !HAVE_HILDON sokoke_widget_set_visible (browser->statusbar, active); + #endif } static void @@ -3858,6 +3877,10 @@ midori_browser_init (MidoriBrowser* browser) GError* error; GtkAction* action; GtkWidget* menuitem; + #if HAVE_HILDON + GtkWidget* menu; + GList* children; + #endif GtkSettings* gtk_settings; GtkWidget* hbox; GtkWidget* hpaned; @@ -4029,26 +4052,47 @@ midori_browser_init (MidoriBrowser* browser) /* Create the menubar */ browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar"); + #if HAVE_HILDON + menu = gtk_menu_new (); + children = gtk_container_get_children (GTK_CONTAINER (browser->menubar)); + while (children) + { + menuitem = GTK_WIDGET (children->data); + gtk_widget_reparent (menuitem, menu); + children = g_list_next (children); + } + browser->menubar = menu; + hildon_window_set_menu (HILDON_WINDOW (browser), GTK_MENU (browser->menubar)); + hildon_program_add_window (hildon_program_get_instance (), + HILDON_WINDOW (browser)); + #else + gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0); + gtk_widget_hide (browser->menubar); + g_signal_connect (browser->menubar, "button-press-event", + G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb), browser); + #endif menuitem = gtk_menu_item_new (); + #if !HAVE_HILDON gtk_widget_show (menuitem); + #endif browser->throbber = katze_throbber_new (); gtk_widget_show (browser->throbber); gtk_container_add (GTK_CONTAINER (menuitem), browser->throbber); gtk_widget_set_sensitive (menuitem, FALSE); gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE); gtk_menu_shell_append (GTK_MENU_SHELL (browser->menubar), menuitem); - gtk_box_pack_start (GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0); browser->menu_tools = gtk_menu_item_get_submenu (GTK_MENU_ITEM ( gtk_ui_manager_get_widget (ui_manager, "/menubar/Tools"))); menuitem = gtk_separator_menu_item_new (); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (browser->menu_tools), menuitem); - gtk_widget_hide (browser->menubar); - g_signal_connect (browser->menubar, "button-press-event", - G_CALLBACK (midori_browser_toolbar_item_button_press_event_cb), browser); _action_set_sensitive (browser, "PrivateBrowsing", FALSE); _action_set_sensitive (browser, "FindQuick", FALSE); + #if HAVE_HILDON + g_object_set (_action_by_name (browser, "Menubar"), "visible", FALSE, NULL); + g_object_set (_action_by_name (browser, "Statusbar"), "visible", FALSE, NULL); + #endif _action_set_sensitive (browser, "Transferbar", FALSE); _action_set_sensitive (browser, "SelectionSourceView", FALSE); @@ -4061,11 +4105,16 @@ midori_browser_init (MidoriBrowser* browser) g_signal_connect (gtk_settings, "notify::gtk-toolbar-style", G_CALLBACK (midori_browser_navigationbar_notify_style_cb), browser); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (browser->navigationbar), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), browser->navigationbar, FALSE, FALSE, 0); g_object_set (_action_by_name (browser, "Back"), "is-important", TRUE, NULL); gtk_widget_hide (browser->navigationbar); g_signal_connect (browser->navigationbar, "popup-context-menu", G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser); + #if HAVE_HILDON + hildon_window_add_toolbar (HILDON_WINDOW (browser), + GTK_TOOLBAR (browser->navigationbar)); + #else + gtk_box_pack_start (GTK_BOX (vbox), browser->navigationbar, FALSE, FALSE, 0); + #endif /* Bookmarkbar */ browser->bookmarkbar = gtk_toolbar_new (); @@ -4074,7 +4123,12 @@ midori_browser_init (MidoriBrowser* browser) GTK_ICON_SIZE_MENU); gtk_toolbar_set_style (GTK_TOOLBAR (browser->bookmarkbar), GTK_TOOLBAR_BOTH_HORIZ); + #if HAVE_HILDON + hildon_window_add_toolbar (HILDON_WINDOW (browser), + GTK_TOOLBAR (browser->bookmarkbar)); + #else gtk_box_pack_start (GTK_BOX (vbox), browser->bookmarkbar, FALSE, FALSE, 0); + #endif g_signal_connect (browser->bookmarkbar, "popup-context-menu", G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser); @@ -4286,7 +4340,12 @@ midori_browser_init (MidoriBrowser* browser) gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1); #endif sokoke_container_show_children (GTK_CONTAINER (browser->find)); + #if HAVE_HILDON + hildon_window_add_toolbar (HILDON_WINDOW (browser), + GTK_TOOLBAR (browser->find)); + #else gtk_box_pack_start (GTK_BOX (vbox), browser->find, FALSE, FALSE, 0); + #endif /* Statusbar */ browser->statusbar = gtk_statusbar_new (); @@ -4338,6 +4397,9 @@ static void _midori_browser_set_toolbar_style (MidoriBrowser* browser, MidoriToolbarStyle toolbar_style) { + #if HAVE_HILDON + GtkToolbarStyle gtk_toolbar_style = GTK_TOOLBAR_ICONS; + #else GtkToolbarStyle gtk_toolbar_style; GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser)); if (toolbar_style == MIDORI_TOOLBAR_DEFAULT && gtk_settings) @@ -4360,6 +4422,7 @@ _midori_browser_set_toolbar_style (MidoriBrowser* browser, gtk_toolbar_style = GTK_TOOLBAR_BOTH_HORIZ; } } + #endif gtk_toolbar_set_style (GTK_TOOLBAR (browser->navigationbar), gtk_toolbar_style); } @@ -4389,6 +4452,10 @@ _midori_browser_set_toolbar_items (MidoriBrowser* browser, GtkAction* action; GtkWidget* toolitem; + #if HAVE_HILDON + items = "Bookmarks,Window,Back,Forward,ReloadStop,Location,Panel,Trash"; + #endif + gtk_container_foreach (GTK_CONTAINER (browser->navigationbar), (GtkCallback)gtk_widget_destroy, NULL); diff --git a/midori/midori-browser.h b/midori/midori-browser.h index b0d45835..cc2781b1 100644 --- a/midori/midori-browser.h +++ b/midori/midori-browser.h @@ -13,6 +13,9 @@ #define __MIDORI_BROWSER_H__ #include +#if defined(HAVE_HILDON) && HAVE_HILDON + #include +#endif #include @@ -36,7 +39,11 @@ typedef struct _MidoriBrowserClass MidoriBrowserClass; struct _MidoriBrowserClass { + #if defined(HAVE_HILDON) && HAVE_HILDON + HildonWindowClass parent_class; + #else GtkWindowClass parent_class; + #endif /* Signals */ void diff --git a/midori/midori-panel.c b/midori/midori-panel.c index 59dd78b7..ac3a52e5 100644 --- a/midori/midori-panel.c +++ b/midori/midori-panel.c @@ -315,6 +315,9 @@ midori_panel_set_compact (MidoriPanel* panel, { g_return_if_fail (MIDORI_IS_PANEL (panel)); + #if HAVE_HILDON + compact = TRUE; + #endif gtk_toolbar_set_style (GTK_TOOLBAR (panel->toolbar), compact ? GTK_TOOLBAR_ICONS : GTK_TOOLBAR_BOTH); } diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index d8a389ec..c17e6c7a 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -495,11 +495,13 @@ midori_preferences_set_settings (MidoriPreferences* preferences, /* Page "Interface" */ PAGE_NEW (GTK_STOCK_CONVERT, _("Interface")); + #if !HAVE_HILDON FRAME_NEW (_("Navigationbar")); TABLE_NEW (1, 2); INDENTED_ADD (katze_property_label (settings, "toolbar-style"), 0, 1, 0, 1); button = katze_property_proxy (settings, "toolbar-style", NULL); FILLED_ADD (button, 1, 2, 0, 1); + #endif FRAME_NEW (_("Browsing")); TABLE_NEW (5, 2); label = katze_property_label (settings, "open-new-pages-in"); @@ -514,12 +516,14 @@ midori_preferences_set_settings (MidoriPreferences* preferences, #endif button = katze_property_proxy (settings, "always-show-tabbar", NULL); INDENTED_ADD (button, 0, 1, 2, 3); - button = katze_property_proxy (settings, "compact-sidepanel", NULL); + button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL); INDENTED_ADD (button, 1, 2, 2, 3); + #if !HAVE_HILDON button = katze_property_proxy (settings, "middle-click-opens-selection", NULL); INDENTED_ADD (button, 0, 1, 3, 4); - button = katze_property_proxy (settings, "open-tabs-in-the-background", NULL); + button = katze_property_proxy (settings, "compact-sidepanel", NULL); WIDGET_ADD (button, 1, 2, 3, 4); + #endif /* button = katze_property_proxy (settings, "open-popups-in-tabs", NULL); SPANNED_ADD (button, 0, 1, 4, 5);*/ button = katze_property_proxy (settings, "open-tabs-next-to-current", NULL); diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c index fadfe88a..1a729b4f 100644 --- a/midori/midori-websettings.c +++ b/midori/midori-websettings.c @@ -431,7 +431,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class) "toolbar-items", _("Toolbar Items"), _("The items to show on the toolbar"), - "Back,Forward,ReloadStop,Location,Trash", + "Back,Forward,ReloadStop,Location,Panel,Trash,Search", flags)); g_object_class_install_property (gobject_class, diff --git a/midori/wscript_build b/midori/wscript_build index e15561fc..5d0ddf3c 100644 --- a/midori/wscript_build +++ b/midori/wscript_build @@ -10,7 +10,7 @@ obj.target = 'midori' obj.includes = '. ..' obj.find_sources_in_dirs ('.', excludes=['main.c']) obj.add_marshal_file ('marshal.list', 'midori_cclosure_marshal') -obj.uselib = 'UNIQUE LIBSOUP GIO GTK SQLITE WEBKIT LIBXML' +obj.uselib = 'UNIQUE LIBSOUP GIO GTK SQLITE WEBKIT LIBXML HILDON' obj.uselib_local = 'katze' obj.install_path = None diff --git a/wscript b/wscript index 73be9cc6..018ce5f6 100644 --- a/wscript +++ b/wscript @@ -79,12 +79,12 @@ def configure (conf): conf.check_tool ('intltool') if conf.env['INTLTOOL'] and conf.env['POCOM']: nls = 'yes' - conf.define ('ENABLE_NLS', 1) else: option_checkfatal ('nls', 'localization') nls = 'N/A' else: nls = 'no ' + conf.define ('ENABLE_NLS', [0,1][nls == 'yes']) dirname_default ('LIBDIR', os.path.join (conf.env['PREFIX'], 'lib')) dirname_default ('DATADIR', os.path.join (conf.env['PREFIX'], 'share')) @@ -115,8 +115,8 @@ def configure (conf): unique = ['N/A', 'yes'][conf.env['HAVE_UNIQUE'] == 1] else: option_checkfatal ('unique', 'single instance') - conf.define ('HAVE_UNIQUE', 0) unique = 'no ' + conf.define ('HAVE_UNIQUE', [0,1][unique == 'yes']) if option_enabled ('libsoup'): check_pkg ('libsoup-2.4', '2.23.1', False) @@ -125,18 +125,18 @@ def configure (conf): libsoup_25_2 = ['N/A','yes'][conf.env['HAVE_LIBSOUP_2_25_2'] == 1] else: option_checkfatal ('libsoup', 'libsoup') - conf.define ('HAVE_LIBSOUP', 0) - conf.define ('HAVE_LIBSOUP_2_25_2', 0) libsoup = 'no ' libsoup_25_2 = 'no ' + conf.define ('HAVE_LIBSOUP', [0,1][libsoup == 'yes']) + conf.define ('HAVE_LIBSOUP_2_25_2', [0,1][libsoup_25_2 == 'yes']) if option_enabled ('sqlite'): check_pkg ('sqlite3', '3.0', False, var='SQLITE') sqlite = ['N/A','yes'][conf.env['HAVE_SQLITE'] == 1] else: option_checkfatal ('sqlite', 'history database') - conf.define ('HAVE_SQLITE', 0) sqlite = 'no ' + conf.define ('HAVE_SQLITE', [0,1][sqlite == 'yes']) check_pkg ('gmodule-2.0', '2.8.0', False) check_pkg ('gthread-2.0', '2.8.0', False) @@ -145,6 +145,14 @@ def configure (conf): check_pkg ('webkit-1.0', '0.1') check_pkg ('libxml-2.0', '2.6') + if option_enabled ('hildon'): + check_pkg ('hildon-1', mandatory=False, var='HILDON') + hildon = ['N/A','yes'][conf.env['HAVE_HILDON'] == 1] + else: + option_checkfatal ('hildon', 'Maemo integration') + hildon = 'no ' + conf.define ('HAVE_HILDON', [0,1][hildon == 'yes']) + conf.check (header_name='unistd.h') conf.define ('HAVE_OSX', int(sys.platform == 'darwin')) @@ -215,6 +223,7 @@ def configure (conf): else: Utils.pprint ('RED', 'WebKit was NOT built with libsoup') print "Persistent history: " + sqlite + " (sqlite3)" + print "Maemo integration: " + hildon + " (hildon)" def set_options (opt): def add_enable_option (option, desc, group=None, disable=False): @@ -254,6 +263,7 @@ def set_options (opt): add_enable_option ('libsoup', 'icon and view source support', group) add_enable_option ('sqlite', 'history database support', group) add_enable_option ('addons', 'building of extensions', group) + add_enable_option ('hildon', 'Maemo integration', group) def build (bld): def mkdir (path): @@ -294,14 +304,20 @@ def build (bld): bld.add_subdirs ('docs/api') bld.install_files ('${DOCDIR}/midori/api/', blddir + '/docs/api/*') + if bld.env['HAVE_HILDON']: + appdir = '${DATADIR}/applications/hildon' + bld.install_files ('${DATADIR}/dbus-1/services', + 'data/com.nokia.' + APPNAME + '.service') + else: + appdir = '${DATADIR}/applications' if bld.env['INTLTOOL']: obj = bld.new_task_gen ('intltool_in') - obj.source = APPNAME + '.desktop.in' - obj.install_path = '${DATADIR}/applications' - obj.flags = '-d' - bld.install_files ('${DATADIR}/applications', APPNAME + '.desktop') + obj.source = 'data/' + APPNAME + '.desktop.in' + obj.install_path = '${DATADIR}/applications/hildon' + obj.flags = '-d' + bld.install_files (appdir, 'data/' + APPNAME + '.desktop') else: - folder = os.path.dirname (bld.env['waf_config_files'][0]) + folder = os.path.dirname (bld.env['waf_config_files'][0]) + '/data' desktop = APPNAME + '.desktop' pre = open (desktop + '.in') after = open (folder + '/' + desktop, 'w') @@ -315,7 +331,7 @@ def build (bld): after.write (line) after.close () Utils.pprint ('BLUE', desktop + '.in -> ' + desktop) - bld.install_files ('${DATADIR}/applications', folder + '/' + desktop) + bld.install_files (appdir, folder + '/' + desktop) except: Utils.pprint ('BLUE', 'File ' + desktop + ' not generated') finally: -- 2.39.5