diff options
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 103 |
1 files changed, 35 insertions, 68 deletions
@@ -35,37 +35,39 @@ #include <gtk/gtk.h> #include <gdk/gdkx.h> #include <gdk/gdkkeysyms.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/un.h> #include <webkit/webkit.h> #include <pthread.h> #include <stdio.h> #include <string.h> -#include <sys/stat.h> -#include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <string.h> -#include <sys/types.h> #include <fcntl.h> -#include <sys/socket.h> -#include <sys/un.h> + +#include "uzbl.h" /* housekeeping / internal variables */ -static GtkWidget* main_window; -static GtkWidget* mainbar; -static GtkWidget* mainbar_label; -static GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar -static GtkScrollbar* scbar_h; // (These are still hidden) +static GtkWidget* main_window; +static GtkWidget* mainbar; +static GtkWidget* mainbar_label; +static GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar +static GtkScrollbar* scbar_h; // (These are still hidden) static GtkAdjustment* bar_v; // Information about document length static GtkAdjustment* bar_h; // and scrolling position static WebKitWebView* web_view; -static gchar* main_title; -static gchar selected_url[500] = "\0"; -static gint load_progress; -static Window xwin = 0; -static char fifo_path[64]; -static char socket_path[108]; -static GString *keycmd; +static gchar* main_title; +static gchar selected_url[500] = "\0"; +static gint load_progress; +static Window xwin = 0; +static char fifo_path[64]; +static char socket_path[108]; +static char executable_path[500]; +static GString* keycmd; /* state variables (initial values coming from command line arguments but may be changed later) */ static gchar* uri = NULL; @@ -86,15 +88,10 @@ static gchar* modkey = NULL; static guint modmask = 0; /* settings from config: group bindings, key -> action */ -static GHashTable *bindings; +static GHashTable* bindings; /* command list: name -> Command */ -static GHashTable *commands; - -typedef struct { - char *name; - char *param; -} Action; +static GHashTable* commands; /* commandline arguments (set initial values for the state variables) */ static GOptionEntry entries[] = @@ -111,35 +108,6 @@ typedef void (*Command)(WebKitWebView*, const char *); static char *XDG_CONFIG_HOME_default[256]; static char *XDG_CONFIG_DIRS_default = "/etc/xdg"; -static void -update_title(void); - -static void -load_uri ( WebKitWebView * web_view, const gchar * uri); - -static void -new_window_load_uri (const gchar * uri); - -static void -close_uzbl (WebKitWebView *page, const char *param); - -static gboolean -run_command(const char *command, const char *args); - -static void -spawn(WebKitWebView *web_view, const char *param); - -static void -free_action(gpointer action); - -static Action* -new_action(const gchar *name, const gchar *param); - -static void -set_insert_mode(WebKitWebView *page, const gchar *param); - - - /* --- CALLBACKS --- */ static gboolean @@ -279,7 +247,7 @@ log_history_cb () { timeinfo = localtime ( &rawtime ); strftime (date, 80, "%Y-%m-%d %H:%M:%S", timeinfo); GString* args = g_string_new (""); - g_string_printf (args, "'%s' '%s' '%s'", uri, "TODO:page title here", date); + g_string_printf (args, "'%s'", date); run_command(history_handler, args->str); g_string_free (args, TRUE); } @@ -384,21 +352,18 @@ load_uri (WebKitWebView * web_view, const gchar *param) { static void new_window_load_uri (const gchar * uri) { GString* to_execute = g_string_new (""); - if (!config_file) { - g_string_printf (to_execute, "uzbl --uri '%s'", uri); - } else { - g_string_printf (to_execute, "uzbl --uri '%s' --config '%s'", uri, config_file); - } - printf("Spawning %s\n",to_execute->str); - if (!g_spawn_command_line_async (to_execute->str, NULL)) { - if (!config_file) { - g_string_printf (to_execute, "./uzbl --uri '%s'", uri); - } else { - g_string_printf (to_execute, "./uzbl --uri '%s' --config '%s'", uri, config_file); + g_string_append_printf (to_execute, "%s --uri '%s'", executable_path, uri); + int i; + for (i = 0; entries[i].long_name != NULL; i++) { + if ((entries[i].arg == G_OPTION_ARG_STRING) && (strcmp(entries[i].long_name,"uri")!=0)) { + gchar** str = (gchar**)entries[i].arg_data; + if (*str!=NULL) { + g_string_append_printf (to_execute, " --%s '%s'", entries[i].long_name, *str); + } } - printf("Spawning %s\n",to_execute->str); - g_spawn_command_line_async (to_execute->str, NULL); } + printf("\n%s\n", to_execute->str); + g_spawn_command_line_async (to_execute->str, NULL); g_string_free (to_execute, TRUE); } @@ -416,6 +381,7 @@ run_command(const char *command, const char *args) { GString* to_execute = g_string_new (""); gboolean result; g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", command, config_file, (int) getpid() , (int) xwin, fifo_path, socket_path); + g_string_append_printf (to_execute, " '%s' '%s'", uri, "TODO title here"); if(args) { g_string_append_printf (to_execute, " %s", args); } @@ -762,7 +728,7 @@ settings_init () { modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL); if (! fifo_dir) - fifo_dir = g_key_file_get_value (config, "behavior", "fifodir", NULL); + fifo_dir = g_key_file_get_value (config, "behavior", "fifo_dir", NULL); if (! socket_dir) socket_dir = g_key_file_get_value (config, "behavior", "socket_dir", NULL); keys = g_key_file_get_keys (config, "bindings", NULL, NULL); @@ -820,6 +786,7 @@ main (int argc, char* argv[]) { g_thread_init (NULL); printf("Uzbl start location: %s\n", argv[0]); + strcpy(executable_path,argv[0]); strcat ((char *) XDG_CONFIG_HOME_default, getenv ("HOME")); strcat ((char *) XDG_CONFIG_HOME_default, "/.config"); |