#endif /* HILDON */
#include "config.h"
+#include "browsers.h"
#define CONTINUOUS_MODE_DEFAULT 0
#define _HILDON_SIZE_DEFAULT (HILDON_SIZE_AUTO_WIDTH|HILDON_SIZE_FINGER_HEIGHT)
#endif
-struct browser_entry {
- char *config;
- char *displayname;
-};
-struct browser_entry browsers[] = {
- { "microb", "MicroB (stock browser)" }, /* First entry is the default! */
- { "tear", "Tear" },
- { "fennec", "Mobile Firefox (Fennec)" },
- { "opera", "Opera Mobile" },
- { "midori", "Midori" },
- { "other", "Other" },
- { NULL, NULL },
-};
-
struct swb_config orig_cfg;
struct config_widgets {
GtkWidget *dialog;
+struct browser_entry *installed_browsers;
+void init_installed_browsers(void) {
+ struct browser_entry *cur = browsers;
+ unsigned int count = 0;
+
+ installed_browsers = calloc(sizeof browsers, 1);
+ if (!installed_browsers)
+ exit(1);
+
+ count = 0;
+ for (; cur->config; ++cur)
+ if (!cur->binary || !access(cur->binary, X_OK))
+ installed_browsers[count++] = *cur;
+}
+
/**********************************************************************
* Configuration routines
**********************************************************************/
#if defined(HILDON) && defined(FREMANTLE)
static inline char *get_default_browser(void) {
- return browsers[hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0)].config;
+ return installed_browsers[hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0)].config;
}
#else /* !defined(HILDON) || !defined(FREMANTLE) */
}
static inline char *get_default_browser(void) {
- return browsers[gtk_combo_box_get_active(GTK_COMBO_BOX(cw.default_browser_combo))].config;
+ return installed_browsers[gtk_combo_box_get_active(GTK_COMBO_BOX(cw.default_browser_combo))].config;
}
#endif /* defined(HILDON) && defined(FREMANTLE) */
gint i;
/* Loop through browsers looking for a match */
- for (i = 0; browsers[i].config && strcmp(browsers[i].config, browser);
- ++i);
+ for (i = 0;
+ installed_browsers[i].config && strcmp(installed_browsers[i].config, browser);
+ ++i);
- if (!browsers[i].config)
+ if (!installed_browsers[i].config)
/* No match found, set to the default browser */
i = 0;
dialog_vbox = GTK_DIALOG(dialog)->vbox;
/* Config options */
+ init_installed_browsers();
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);
+ for (i = 0; installed_browsers[i].config; ++i)
+ hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), installed_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),
gtk_table_set_row_spacings(GTK_TABLE(options_table), 5);
gtk_box_pack_start(GTK_BOX(dialog_vbox), options_table, FALSE, FALSE, 0);
+ init_installed_browsers();
cw.default_browser_combo = gtk_combo_box_new_text();
- for (i = 0; browsers[i].config; ++i)
+ for (i = 0; installed_browsers[i].config; ++i)
gtk_combo_box_append_text(GTK_COMBO_BOX(cw.default_browser_combo),
- browsers[i].displayname);
+ installed_browsers[i].displayname);
gtk_combo_box_set_active(GTK_COMBO_BOX(cw.default_browser_combo), 0);
default_browser_combo_label = gtk_label_new("Default browser:");
gtk_misc_set_alignment(GTK_MISC(default_browser_combo_label), 1, 0.5);
--- /dev/null
+/*
+ * browsers.h -- the list of known browsers
+ *
+ * Copyright (C) 2010 Steven Luo
+ *
+ * This program 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 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+#ifndef _BROWSERS_H
+#define _BROWSERS_H 1
+
+struct browser_entry {
+ char *config;
+ char *displayname;
+ char *binary;
+};
+
+struct browser_entry browsers[] = {
+ { "microb", "MicroB (stock browser)", NULL }, /* First entry is the default! */
+ { "tear", "Tear", "/usr/bin/tear" },
+ { "fennec", "Firefox Mobile", "/usr/bin/fennec" },
+ { "opera", "Opera Mobile", "/usr/bin/opera" },
+ { "midori", "Midori", "/usr/bin/midori" },
+ { "other", "Other", NULL },
+ { NULL, NULL, NULL },
+};
+
+#endif /* _BROWSERS_H */