From: Steven Luo Date: Fri, 15 Jan 2010 09:53:03 +0000 (-0800) Subject: Merge commit 'v3.1' into diablo-package X-Git-Tag: diablo-package-3.1-1~1 X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=commitdiff_plain;h=fe2a137cae125fe2a09e1812f82c288d810fc882;hp=a11813cdbeac003580bfabd3746331ca8e58e7d9 Merge commit 'v3.1' into diablo-package --- diff --git a/Changelog b/Changelog index cf6ee72..02456b9 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,13 @@ +version 3.1: +* add a new, more finger-friendly GUI for Fremantle, based on work by + Faheem Pervez (build UI with EXTRA_CPPFLAGS=-DFREMANTLE) +* make sure reconfig signal (SIGHUP) doesn't interrupt dispatch of a request + when continuous mode is off +* disable autocapitalization and predictive text features for the + other_browser_cmd entry in the UI +* add support for EXTRA_CPPFLAGS in Makefiles, to allow package builds to pass + feature/configuration defines; add EXTRA_LDFLAGS too, just in case + version 3.0: * fix the UI so that it looks for C browser-switchboard processes to send SIGHUP to, not Python browser-switchboards diff --git a/Makefile b/Makefile index 443a560..33a52b8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = gcc CFLAGS = -Wall -Os $(EXTRA_CFLAGS) -CPPFLAGS = `pkg-config --cflags dbus-glib-1` -LDFLAGS = `pkg-config --libs dbus-glib-1` +CPPFLAGS = `pkg-config --cflags dbus-glib-1` $(EXTRA_CPPFLAGS) +LDFLAGS = `pkg-config --libs dbus-glib-1` $(EXTRA_LDFLAGS) PREFIX = /usr APP = browser-switchboard diff --git a/README b/README index df8a3d4..0d8f327 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ BROWSER SWITCHBOARD -version 3.0 +version 3.1 Browser Switchboard is a program which allows you to choose which browser to use as the default browser. It supports MicroB, Tear, diff --git a/config-ui/Makefile b/config-ui/Makefile index 85d71e4..42f2003 100644 --- a/config-ui/Makefile +++ b/config-ui/Makefile @@ -1,11 +1,11 @@ CC = gcc CFLAGS = -Wall -Os $(EXTRA_CFLAGS) CFLAGS_PLUGIN = -fPIC -CPPFLAGS = -I../ `pkg-config --cflags gtk+-2.0` +CPPFLAGS = -I../ `pkg-config --cflags gtk+-2.0` $(EXTRA_CPPFLAGS) CPPFLAGS_HILDON = -DHILDON `pkg-config --cflags hildon-1` CPPFLAGS_PLUGIN = $(CPPFLAGS_HILDON) -DHILDON_CP_APPLET \ `pkg-config --cflags libosso` `pkg-config --cflags hildon-control-panel` -LDFLAGS = `pkg-config --libs gtk+-2.0` +LDFLAGS = `pkg-config --libs gtk+-2.0` $(EXTRA_LDFLAGS) LDFLAGS_HILDON = `pkg-config --libs hildon-1` LDFLAGS_PLUGIN = -shared $(LDFLAGS_HILDON) \ `pkg-config --libs libosso` `pkg-config --libs hildon-control-panel` diff --git a/config-ui/browser-switchboard-cp.c b/config-ui/browser-switchboard-cp.c index 7d462f5..13b0b48 100644 --- a/config-ui/browser-switchboard-cp.c +++ b/config-ui/browser-switchboard-cp.c @@ -2,7 +2,8 @@ * browser-switchboard-cp.c -- a hildon-control-panel applet for * selecting the default browser for Browser Switchboard * - * Copyright (C) 2009 Steven Luo + * Copyright (C) 2009-2010 Steven Luo + * Copyright (C) 2009-2010 Faheem Pervez * * Derived from services-cp.c from maemo-control-services * Copyright (c) 2008 Janne Kataja @@ -33,18 +34,31 @@ #include #include #include + #ifdef HILDON #include #include + +#ifdef FREMANTLE +#include +#include +#include +#include +#endif /* FREMANTLE */ + #ifdef HILDON_CP_APPLET #include -#endif -#endif +#endif /* HILDON_CP_APPLET */ +#endif /* HILDON */ #include "configfile.h" #define CONTINUOUS_MODE_DEFAULT 0 +#if defined(HILDON) && defined(FREMANTLE) +#define _HILDON_SIZE_DEFAULT (HILDON_SIZE_AUTO_WIDTH|HILDON_SIZE_FINGER_HEIGHT) +#endif + struct browser_entry { char *config; char *displayname; @@ -59,9 +73,14 @@ struct browser_entry browsers[] = { }; struct config_widgets { +#if defined(HILDON) && defined(FREMANTLE) + GtkWidget *continuous_mode_selector; + GtkWidget *default_browser_selector; +#else GtkWidget *continuous_mode_off_radio; GtkWidget *continuous_mode_on_radio; GtkWidget *default_browser_combo; +#endif GtkWidget *other_browser_cmd_entry; GtkWidget *other_browser_cmd_entry_label; }; @@ -73,6 +92,21 @@ GtkWidget *dialog; * Configuration routines **********************************************************************/ +#if defined(HILDON) && defined(FREMANTLE) + +static inline int get_continuous_mode(void) { + return hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), 0); +} +static inline void set_continuous_mode(int state) { + hildon_touch_selector_set_active(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), 0, state); +} + +static inline char *get_default_browser(void) { + return browsers[hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0)].config; +} + +#else /* !defined(HILDON) || !defined(FREMANTLE) */ + static inline int get_continuous_mode(void) { return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cw.continuous_mode_on_radio)); } @@ -86,6 +120,9 @@ static inline void set_continuous_mode(int state) { static inline char *get_default_browser(void) { return browsers[gtk_combo_box_get_active(GTK_COMBO_BOX(cw.default_browser_combo))].config; } + +#endif /* defined(HILDON) && defined(FREMANTLE) */ + static void set_default_browser(char *browser) { gint i; @@ -97,7 +134,11 @@ static void set_default_browser(char *browser) { /* No match found, set to the default browser */ i = 0; +#if defined(HILDON) && defined(FREMANTLE) + hildon_touch_selector_set_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0, i); +#else gtk_combo_box_set_active(GTK_COMBO_BOX(cw.default_browser_combo), i); +#endif } static inline char *get_other_browser_cmd(void) { @@ -261,7 +302,7 @@ static void do_reconfig(void) { save_config(); /* Try to send SIGHUP to any running browser-switchboard process - This causes it to reread config files if in continuous_mode, and + This causes it to reread config files if in continuous_mode, or die so that the config will be reloaded on next start otherwise */ system("kill -HUP `pidof browser-switchboard` > /dev/null 2>&1"); } @@ -271,11 +312,18 @@ static void do_reconfig(void) { * Callbacks **********************************************************************/ +#if defined(HILDON) && defined(FREMANTLE) +static void default_browser_selector_callback(GtkWidget *widget, + gint column, gpointer data) { +#else static void default_browser_combo_callback(GtkWidget *widget, gpointer data) { +#endif if (!strcmp(get_default_browser(), "other")) { + gtk_editable_set_editable(GTK_EDITABLE(cw.other_browser_cmd_entry), TRUE); gtk_widget_set_sensitive(cw.other_browser_cmd_entry, TRUE); gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, TRUE); } else { + gtk_editable_set_editable(GTK_EDITABLE(cw.other_browser_cmd_entry), FALSE); /* FREMANTLE: give the text the greyed-out look */ gtk_widget_set_sensitive(cw.other_browser_cmd_entry, FALSE); gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, FALSE); } @@ -286,6 +334,85 @@ static void default_browser_combo_callback(GtkWidget *widget, gpointer data) { * Interface **********************************************************************/ +#if defined(HILDON) && defined(FREMANTLE) +/* + * Fremantle Hildon dialog + */ +static GtkDialog *swb_config_dialog(gpointer cp_window) { + GtkWidget *dialog_vbox; + + GtkWidget *default_browser_selector_button; + GtkWidget *continuous_mode_selector_button; + int i; + HildonGtkInputMode input_mode; + + dialog = gtk_dialog_new_with_buttons( + "Browser Switchboard", + GTK_WINDOW(cp_window), + GTK_DIALOG_MODAL, + GTK_STOCK_OK, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + NULL); + + dialog_vbox = GTK_DIALOG(dialog)->vbox; + + /* Config options */ + cw.default_browser_selector = hildon_touch_selector_new_text(); + for (i = 0; browsers[i].config; ++i) + hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), browsers[i].displayname); + hildon_touch_selector_set_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0, 0); + default_browser_selector_button = hildon_picker_button_new(_HILDON_SIZE_DEFAULT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL); + hildon_button_set_title(HILDON_BUTTON(default_browser_selector_button), + "Default browser:"); + hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(default_browser_selector_button), HILDON_TOUCH_SELECTOR(cw.default_browser_selector)); + hildon_button_set_alignment(HILDON_BUTTON(default_browser_selector_button), + 0, 0.5, 0, 0); + g_signal_connect(G_OBJECT(cw.default_browser_selector), "changed", + G_CALLBACK(default_browser_selector_callback), NULL); + gtk_box_pack_start(GTK_BOX(dialog_vbox), + default_browser_selector_button, FALSE, FALSE, 0); + + cw.other_browser_cmd_entry = hildon_entry_new(_HILDON_SIZE_DEFAULT); + /* Disable autocapitalization and dictionary features for the entry */ + input_mode = hildon_gtk_entry_get_input_mode(GTK_ENTRY(cw.other_browser_cmd_entry)); + input_mode &= ~(HILDON_GTK_INPUT_MODE_AUTOCAP | + HILDON_GTK_INPUT_MODE_DICTIONARY); + hildon_gtk_entry_set_input_mode(GTK_ENTRY(cw.other_browser_cmd_entry), input_mode); + + cw.other_browser_cmd_entry_label = hildon_caption_new(NULL, + "Command (%s for URI):", + cw.other_browser_cmd_entry, + NULL, HILDON_CAPTION_OPTIONAL); + gtk_widget_set_sensitive(cw.other_browser_cmd_entry, FALSE); + gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, FALSE); + hildon_gtk_widget_set_theme_size(cw.other_browser_cmd_entry_label, _HILDON_SIZE_DEFAULT); + gtk_box_pack_start(GTK_BOX(dialog_vbox), + cw.other_browser_cmd_entry_label, FALSE, FALSE, 0); + + cw.continuous_mode_selector = hildon_touch_selector_new_text(); + hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), "Lower memory usage"); + hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), "Faster browser startup time"); + + continuous_mode_selector_button = hildon_picker_button_new(_HILDON_SIZE_DEFAULT, HILDON_BUTTON_ARRANGEMENT_VERTICAL); + hildon_button_set_title(HILDON_BUTTON(continuous_mode_selector_button), + "Optimize Browser Switchboard for:"); + hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(continuous_mode_selector_button), HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector)); + hildon_button_set_alignment(HILDON_BUTTON(continuous_mode_selector_button), + 0, 0, 0, 0); + set_continuous_mode(CONTINUOUS_MODE_DEFAULT); + gtk_box_pack_start(GTK_BOX(dialog_vbox), + continuous_mode_selector_button, FALSE, FALSE, 0); + + gtk_widget_show_all(dialog); + return GTK_DIALOG(dialog); +} + +#else /* !defined(HILDON) || !defined(FREMANTLE) */ +/* + * GTK+/Diablo Hildon dialog + */ static GtkDialog *swb_config_dialog(gpointer cp_window) { GtkWidget *dialog_vbox; @@ -293,6 +420,9 @@ static GtkDialog *swb_config_dialog(gpointer cp_window) { GtkWidget *default_browser_combo_label; GtkWidget *continuous_mode_label; int i; +#ifdef HILDON + HildonGtkInputMode input_mode; +#endif dialog = gtk_dialog_new_with_buttons( "Browser Switchboard", @@ -334,6 +464,13 @@ static GtkDialog *swb_config_dialog(gpointer cp_window) { 5, 0); cw.other_browser_cmd_entry = gtk_entry_new(); +#ifdef HILDON + /* Disable autocapitalization and dictionary features for the entry */ + input_mode = hildon_gtk_entry_get_input_mode(GTK_ENTRY(cw.other_browser_cmd_entry)); + input_mode &= ~(HILDON_GTK_INPUT_MODE_AUTOCAP | + HILDON_GTK_INPUT_MODE_DICTIONARY); + hildon_gtk_entry_set_input_mode(GTK_ENTRY(cw.other_browser_cmd_entry), input_mode); +#endif cw.other_browser_cmd_entry_label = gtk_label_new("Command (%s for URI):"); gtk_misc_set_alignment(GTK_MISC(cw.other_browser_cmd_entry_label), 1, 0.5); gtk_widget_set_sensitive(cw.other_browser_cmd_entry, FALSE); @@ -385,6 +522,8 @@ static GtkDialog *swb_config_dialog(gpointer cp_window) { return GTK_DIALOG(dialog); } +#endif /* defined(HILDON) && defined(FREMANTLE) */ + /********************************************************************** * Entry @@ -442,4 +581,4 @@ int main(int argc, char *argv[]) { exit(0); } -#endif +#endif /* HILDON_CP_APPLET */ diff --git a/dbus-server-bindings.c b/dbus-server-bindings.c index 939056b..3875929 100644 --- a/dbus-server-bindings.c +++ b/dbus-server-bindings.c @@ -1,7 +1,7 @@ /* * dbus-server-bindings.c -- osso_browser D-Bus interface implementation * - * Copyright (C) 2009 Steven Luo + * Copyright (C) 2009-2010 Steven Luo * Derived from a Python implementation by Jason Simpson and Steven Luo * * This program is free software; you can redistribute it and/or @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "browser-switchboard.h" @@ -43,6 +44,21 @@ static void osso_browser_class_init(OssoBrowserClass *klass) #include "dbus-server-glue.h" +/* Ignore reconfiguration signal (SIGHUP) + When not running in continuous mode, no SIGHUP handler is installed, which + causes browser-switchboard to quit on a reconfig request. This is normally + what we want -- but if we're already in the process of dispatching a + request, we'll quit anyway after finishing what we're doing, so ignoring the + signal is the right thing to do. */ +static void ignore_reconfig_requests(void) { + struct sigaction act; + + act.sa_flags = SA_RESTART; + sigemptyset(&(act.sa_mask)); + act.sa_handler = SIG_IGN; + sigaction(SIGHUP, &act, NULL); +} + static void open_address(const char *uri) { char *new_uri; size_t new_uri_len; @@ -75,24 +91,32 @@ static void open_address(const char *uri) { */ gboolean osso_browser_load_url(OssoBrowser *obj, const char *uri, GError **error) { + if (!ctx.continuous_mode) + ignore_reconfig_requests(); open_address(uri); return TRUE; } gboolean osso_browser_mime_open(OssoBrowser *obj, const char *uri, GError **error) { + if (!ctx.continuous_mode) + ignore_reconfig_requests(); open_address(uri); return TRUE; } gboolean osso_browser_open_new_window(OssoBrowser *obj, const char *uri, GError **error) { + if (!ctx.continuous_mode) + ignore_reconfig_requests(); open_address(uri); return TRUE; } gboolean osso_browser_top_application(OssoBrowser *obj, GError **error) { + if (!ctx.continuous_mode) + ignore_reconfig_requests(); launch_microb(&ctx, "new_window"); return TRUE; } @@ -101,6 +125,8 @@ gboolean osso_browser_top_application(OssoBrowser *obj, for use by /usr/bin/browser wrapper to implement --url */ gboolean osso_browser_switchboard_launch_microb(OssoBrowser *obj, const char *uri, GError **error) { + if (!ctx.continuous_mode) + ignore_reconfig_requests(); launch_microb(&ctx, (char *)uri); return TRUE; } diff --git a/launcher.c b/launcher.c index a2aec71..f738c63 100644 --- a/launcher.c +++ b/launcher.c @@ -46,8 +46,8 @@ static void launch_tear(struct swb_context *ctx, char *uri) { printf("launch_tear with uri '%s'\n", uri); /* We should be able to just call the D-Bus service to open Tear ... - but if Tear's not open, that cuases D-Bus to star Tear and then pass - it the OpenAddress call, which results in two browser windows. + but if Tear's not open, that cuases D-Bus to start Tear and then + pass it the OpenAddress call, which results in two browser windows. Properly fixing this probably requires Tear to provide a D-Bus method that opens an address in an existing window, but for now work around by just invoking Tear with exec() if it's not running. */