From b931e1bf53f96f5d9690932604e6579674a5989b Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 26 Oct 2008 00:54:57 +0200 Subject: [PATCH] Improve OSX adjustments in various places --- configure.in | 1 - midori/Makefile.am | 4 +++- midori/main.c | 2 +- midori/midori-browser.c | 15 ++++++++++----- midori/midori-panel.c | 4 ++++ midori/midori-preferences.c | 21 +++++++++++---------- midori/midori-searchaction.c | 18 ++++++++++++++++++ midori/midori-view.c | 11 +++++++++-- midori/sokoke.c | 14 +++++++++----- wscript | 12 +++++++----- 10 files changed, 72 insertions(+), 30 deletions(-) diff --git a/configure.in b/configure.in index 67480fca..38d2ff3b 100644 --- a/configure.in +++ b/configure.in @@ -92,7 +92,6 @@ if test "x$MSGFMT" = "xno"; then AC_MSG_ERROR([msgfmt not found. Please install the gettext package.]) fi - # Here we tell the configure script which files to *create* AC_CONFIG_FILES([ Makefile \ diff --git a/midori/Makefile.am b/midori/Makefile.am index b92bf83e..e7cf7228 100644 --- a/midori/Makefile.am +++ b/midori/Makefile.am @@ -2,15 +2,17 @@ INCLUDES = \ $(UNIQUE_CFLAGS) \ + $(LIBXML_CFLAGS) \ $(SQLITE3_CFLAGS) \ $(GTK_CFLAGS) \ $(WEBKIT_CFLAGS) \ -I../katze -AM_CFLAGS = -DMIDORI_LOCALEDIR=\""$(localedir)"\" +AM_CFLAGS = -DLOCALEDIR=\""$(localedir)"\" -DDATADIR=\""$(datadir)"\" LDADD = \ $(UNIQUE_LIBS) \ + $(LIBXML_LIBS) \ $(SQLITE3_LIBS) \ $(GTK_LIBS) \ $(WEBKIT_LIBS) \ diff --git a/midori/main.c b/midori/main.c index fd4de3d0..6589a5aa 100644 --- a/midori/main.c +++ b/midori/main.c @@ -1084,7 +1084,7 @@ main (int argc, #endif #if ENABLE_NLS - bindtextdomain (GETTEXT_PACKAGE, MIDORI_LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 9f254a1f..15f66aec 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -864,6 +864,9 @@ midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER (GClosure* closure, static void midori_browser_class_init (MidoriBrowserClass* class) { + GObjectClass* gobject_class; + GParamFlags flags; + signals[WINDOW_OBJECT_CLEARED] = g_signal_new ( "window-object-cleared", G_TYPE_FROM_CLASS (class), @@ -936,13 +939,13 @@ midori_browser_class_init (MidoriBrowserClass* class) class->activate_action = _midori_browser_activate_action; class->quit = _midori_browser_quit; - GObjectClass* gobject_class = G_OBJECT_CLASS (class); + gobject_class = G_OBJECT_CLASS (class); gobject_class->dispose = midori_browser_dispose; gobject_class->finalize = midori_browser_finalize; gobject_class->set_property = midori_browser_set_property; gobject_class->get_property = midori_browser_get_property; - GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT; + flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT; g_object_class_install_property (gobject_class, PROP_MENUBAR, @@ -2583,7 +2586,7 @@ _action_tab_next_activate (GtkAction* action, static const gchar* credits_authors[] = { "Christian Dywan ", NULL }; static const gchar* credits_documenters[] = { - "Christian Dywan " }; + "Christian Dywan ", NULL }; static const gchar* credits_artists[] = { "Nancy Runge ", NULL }; @@ -2672,7 +2675,6 @@ _action_help_link_activate (GtkAction* action, } - static void _action_panel_activate (GtkToggleAction* action, MidoriBrowser* browser) @@ -2701,7 +2703,6 @@ _action_open_in_panel_activate (GtkAction* action, midori_view_set_uri (MIDORI_VIEW (browser->panel_pageholder), uri); } - static void midori_panel_notify_position_cb (GObject* object, GParamSpec* arg1, @@ -3824,7 +3825,11 @@ midori_browser_init (MidoriBrowser* browser) gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close Findbar")); g_signal_connect (toolitem, "clicked", G_CALLBACK (midori_browser_find_button_close_clicked_cb), browser); + #ifdef HAVE_OSX + gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, 0); + #else gtk_toolbar_insert (GTK_TOOLBAR (browser->find), toolitem, -1); + #endif sokoke_container_show_children (GTK_CONTAINER (browser->find)); gtk_box_pack_start (GTK_BOX (vbox), browser->find, FALSE, FALSE, 0); diff --git a/midori/midori-panel.c b/midori/midori-panel.c index 1ebdf249..9f62f86b 100644 --- a/midori/midori-panel.c +++ b/midori/midori-panel.c @@ -208,7 +208,11 @@ midori_panel_init (MidoriPanel* panel) gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel")); g_signal_connect (toolitem, "clicked", G_CALLBACK (midori_panel_button_close_clicked_cb), panel); + #if HAVE_OSX + gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, 0); + #else gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1); + #endif gtk_box_pack_start (GTK_BOX (vbox), labelbar, FALSE, FALSE, 0); gtk_widget_show_all (vbox); diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index b8d61538..99123801 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -11,6 +11,10 @@ #include "midori-preferences.h" +#if HAVE_CONFIG_H + #include +#endif + #include "sokoke.h" #include @@ -72,10 +76,6 @@ midori_preferences_response_cb (MidoriPreferences* preferences, gtk_widget_destroy (GTK_WIDGET (preferences)); } -#ifdef GDK_WINDOWING_QUARTZ - #define USE_OSX_STYLE -#endif - static void midori_preferences_init (MidoriPreferences* preferences) { @@ -90,7 +90,7 @@ midori_preferences_init (MidoriPreferences* preferences) "title", dialog_title, "has-separator", FALSE, NULL); - #ifndef USE_OSX_STYLE + #ifndef HAVE_OSX gtk_dialog_add_buttons (GTK_DIALOG (preferences), GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, @@ -213,7 +213,7 @@ proxy_download_manager_icon_cb (GtkWidget* entry, return FALSE; } -#ifdef USE_OSX_STYLE +#ifdef HAVE_OSX static void midori_preferences_help_clicked_cb (GtkWidget* button, GtkDialog* dialog) @@ -238,7 +238,7 @@ midori_preferences_add_toolbutton (GtkWidget* toolbar, const gchar* label, GtkWidget* page) { -#ifdef USE_OSX_STYLE +#ifdef HAVE_OSX *toolbutton = GTK_WIDGET (*toolbutton ? gtk_radio_tool_button_new_from_widget ( GTK_RADIO_TOOL_BUTTON (*toolbutton)) : gtk_radio_tool_button_new (NULL)); gtk_tool_button_set_label (GTK_TOOL_BUTTON (*toolbutton), label); @@ -282,7 +282,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences, preferences->notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (preferences->notebook), 6); - #ifdef USE_OSX_STYLE + #ifdef HAVE_OSX gtk_notebook_set_show_tabs (GTK_NOTEBOOK (preferences->notebook), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (preferences->notebook), FALSE); toolbar = gtk_toolbar_new (); @@ -290,8 +290,9 @@ midori_preferences_set_settings (MidoriPreferences* preferences, gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (preferences)->vbox), toolbar, FALSE, FALSE, 0); - #endif + #else toolbar = NULL; + #endif toolbutton = NULL; sizegroup = NULL; @@ -515,7 +516,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences, g_object_unref (sizegroup); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (preferences)->vbox), preferences->notebook, FALSE, FALSE, 4); - #ifdef USE_OSX_STYLE + #ifdef HAVE_OSX GtkWidget* icon; hbox = gtk_hbox_new (FALSE, 0); button = gtk_button_new (); diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c index 970d4890..d1335670 100644 --- a/midori/midori-searchaction.c +++ b/midori/midori-searchaction.c @@ -1069,8 +1069,10 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action) dialog = gtk_dialog_new_with_buttons (dialog_title, toplevel ? GTK_WINDOW (toplevel) : NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, + #ifndef HAVE_OSX GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, + #endif NULL); g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &search_action->dialog); @@ -1155,6 +1157,22 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action) button = gtk_button_new_from_stock (GTK_STOCK_GO_UP); gtk_widget_set_sensitive (button, FALSE); gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0); + + #ifdef HAVE_OSX + GtkWidget* icon; + hbox = gtk_hbox_new (FALSE, 0); + button = gtk_button_new (); + icon = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON); + gtk_button_set_image (GTK_BUTTON (button), icon); + /* TODO: Implement some kind of help function */ + gtk_widget_set_sensitive (button, FALSE); + /* g_signal_connect (button, "clicked", + G_CALLBACK (midori_search_action_dialog_help_clicked_cb), dialog); */ + gtk_box_pack_end (GTK_BOX (hbox), + button, FALSE, FALSE, 4); + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox), + hbox, FALSE, FALSE, 0); + #endif gtk_widget_show_all (GTK_DIALOG (dialog)->vbox); g_object_connect (search_action->search_engines, diff --git a/midori/midori-view.c b/midori/midori-view.c index 2e6568c4..568539c3 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -1648,10 +1648,8 @@ midori_view_get_proxy_tab_label (MidoriView* view) gtk_container_border_width (GTK_CONTAINER (hbox), 2); gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET (hbox)); gtk_misc_set_alignment (GTK_MISC (view->tab_icon), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (view->tab_title), 0.0, 0.5); /* TODO: make the tab initially look "unvisited" until it's focused */ - gtk_box_pack_start (GTK_BOX (hbox), view->tab_title, FALSE, TRUE, 0); _update_label_size (view->tab_title, 10); view->tab_close = gtk_button_new (); @@ -1666,7 +1664,16 @@ midori_view_get_proxy_tab_label (MidoriView* view) GTK_STOCK_CLOSE); gtk_button_set_image (GTK_BUTTON (view->tab_close), image); gtk_misc_set_alignment (GTK_MISC (image), 0.0, 0.0); + + #if HAVE_OSX + gtk_box_pack_end (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0); + gtk_box_pack_end (GTK_BOX (hbox), view->tab_title, FALSE, TRUE, 0); gtk_box_pack_end (GTK_BOX (hbox), view->tab_close, FALSE, FALSE, 0); + #else + gtk_box_pack_start (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), view->tab_title, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), view->tab_close, FALSE, FALSE, 0); + #endif gtk_widget_show_all (GTK_WIDGET (event_box)); if (!view->close_buttons_on_tabs) diff --git a/midori/sokoke.c b/midori/sokoke.c index a8c3f4eb..34036698 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -9,12 +9,12 @@ See the file COPYING for the full license text. */ +#include "sokoke.h" + #if HAVE_CONFIG_H #include #endif -#include "sokoke.h" - #if HAVE_UNISTD_H #include #endif @@ -48,6 +48,9 @@ sokoke_spawn_program (const gchar* command, gchar** argv; GError* error; + g_return_val_if_fail (command != NULL, FALSE); + g_return_val_if_fail (argument != NULL, FALSE); + argument_escaped = g_shell_quote (argument); if (strstr (command, "%s")) command_ready = g_strdup_printf (command, argument_escaped); @@ -205,13 +208,16 @@ typedef enum { SOKOKE_DESKTOP_UNTESTED, SOKOKE_DESKTOP_XFCE, + SOKOKE_DESKTOP_OSX, SOKOKE_DESKTOP_UNKNOWN } SokokeDesktop; static SokokeDesktop sokoke_get_desktop (void) { - #ifdef GDK_WINDOWING_X11 + #ifdef HAVE_OSX + return SOKOKE_DESKTOP_OSX; + #else static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED; if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED)) { @@ -227,8 +233,6 @@ sokoke_get_desktop (void) } return desktop; - #else - return SOKOKE_DESKTOP_UNKNOWN; #endif } diff --git a/wscript b/wscript index 5b2e876c..b4d2af6c 100644 --- a/wscript +++ b/wscript @@ -5,7 +5,7 @@ import Params import pproc as subprocess import Common -import platform +import sys import os APPNAME = 'midori' @@ -117,6 +117,8 @@ def configure (conf): conf.check_pkg ('libxml-2.0', destvar='LIBXML', vnum='2.6', mandatory=True) conf.check_header ('unistd.h', 'HAVE_UNISTD_H') + if sys.platform == 'darwin': + conf.define ('HAVE_OSX', 1) if conf.find_program ('rsvg-convert', var='RSVG_CONVERT'): icons = 'yes' @@ -168,7 +170,7 @@ def build (bld): bld.add_subdirs ('katze midori icons') - install_files ('DOCDIR', '/midori/', 'AUTHORS ChangeLog COPYING EXPAT README') + install_files ('DOCDIR', '/' + APPNAME + '/', 'AUTHORS ChangeLog COPYING EXPAT README') if bld.env ()['RST2HTML']: # FIXME: Build only if needed @@ -194,15 +196,15 @@ def build (bld): if bld.env ()['INTLTOOL']: obj = bld.create_obj ('intltool_in') - obj.source = 'midori.desktop.in' + obj.source = APPNAME + '.desktop.in' obj.inst_var = 'DATADIR' obj.inst_dir = 'applications' obj.flags = '-d' else: # FIXME: process desktop.in without intltool - Params.pprint ('BLUE', "File midori.desktop not generated") + Params.pprint ('BLUE', "File " + APPNAME + ".desktop not generated") if bld.env ()['INTLTOOL']: - install_files ('DATADIR', 'applications', 'midori.desktop') + install_files ('DATADIR', 'applications', APPNAME + '.desktop') if bld.env ()['RSVG_CONVERT']: mkdir (blddir + '/data')