#include <string.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
return gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cw.continuous_mode_check), (gboolean)state);
}
-static inline char * get_default_browser(void) {
+static inline char *get_default_browser(void) {
return browsers[gtk_combo_box_get_active(GTK_COMBO_BOX(cw.default_browser_combo))].config;
}
static void set_default_browser(char *browser) {
gtk_combo_box_set_active(GTK_COMBO_BOX(cw.default_browser_combo), i);
}
-static inline char * get_other_browser_cmd(void) {
+static inline char *get_other_browser_cmd(void) {
return (char *)gtk_entry_get_text(GTK_ENTRY(cw.other_browser_cmd_entry));
}
static inline void set_other_browser_cmd(char *cmd) {
int other_browser_cmd_seen = 0;
struct swb_config_line line;
- /* Put together the path to the new config file and the tempfile */
+ /* If CONFIGFILE_DIR doesn't exist already, try to create it */
if (!(homedir = getenv("HOME")))
homedir = DEFAULT_HOMEDIR;
+ len = strlen(homedir) + strlen(CONFIGFILE_DIR) + 1;
+ if (!(newfile = calloc(len, sizeof(char))))
+ return;
+ snprintf(newfile, len, "%s%s", homedir, CONFIGFILE_DIR);
+ if (access(newfile, F_OK) == -1 && errno == ENOENT) {
+ mkdir(newfile, 0750);
+ }
+ free(newfile);
+
+ /* Put together the path to the new config file and the tempfile */
len = strlen(homedir) + strlen(CONFIGFILE_LOC) + 1;
if (!(newfile = calloc(len, sizeof(char))))
return;
* Interface
**********************************************************************/
-static GtkDialog * swb_config_dialog(void) {
+static GtkDialog *swb_config_dialog(void) {
GtkWidget *dialog_vbox;
GtkWidget *options_table;
GtkWidget *okbutton, *cancelbutton;
dialog = gtk_dialog_new();
- gtk_widget_set_size_request(GTK_WIDGET(dialog), 580, 240);
+ /* Doesn't seem to be necessary?
+ gtk_widget_set_size_request(GTK_WIDGET(dialog), 580, 180); */
gtk_window_set_title (GTK_WINDOW(dialog), "Browser Switchboard");
gtk_window_set_type_hint (GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
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), 0, 0.5);
+ gtk_misc_set_alignment(GTK_MISC(default_browser_combo_label), 1, 0.5);
g_signal_connect(G_OBJECT(cw.default_browser_combo), "changed",
G_CALLBACK(default_browser_combo_callback), NULL);
gtk_table_attach(GTK_TABLE(options_table),
cw.other_browser_cmd_entry = gtk_entry_new();
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), 0, 0.5);
+ 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);
gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, FALSE);
gtk_table_attach(GTK_TABLE(options_table),
/*
* Application was started from control panel.
*/
-osso_return_t execute(osso_context_t * osso,
- gpointer userdata, gboolean user_activated)
-{
+osso_return_t execute(osso_context_t *osso,
+ gpointer userdata, gboolean user_activated) {
HildonProgram *program;
+ GtkDialog *dialog;
+
program = HILDON_PROGRAM(hildon_program_get_instance());
-
if (osso == NULL)
return OSSO_ERROR;
- /* enable help system on dialog */
- GtkDialog * dialog = GTK_DIALOG(swb_config_dialog());
-
+ dialog = GTK_DIALOG(swb_config_dialog());
load_config();
-
gtk_dialog_run(dialog);
gtk_widget_destroy(GTK_WIDGET(dialog));
/*
* Application was started from command line.
*/
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
GtkDialog *dialog;
#ifdef HILDON
HildonProgram *program = NULL;