GOptionEntry entries[] =
{
{ "uri", 'u', 0, G_OPTION_ARG_STRING, &uzbl.state.uri,
- "Uri to load at startup (equivalent to 'set uri = URI')", "URI" },
+ "Uri to load at startup (equivalent to 'uzbl <uri>' or 'set uri = URI' after uzbl has launched)", "URI" },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &uzbl.state.verbose,
"Whether to print all messages or just errors.", NULL },
- { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name,
+ { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name,
"Name of the current instance (defaults to Xorg window id)", "NAME" },
- { "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,
- "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" },
- { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
+ { "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,
+ "Path to config file or '-' for stdin", "FILE" },
+ { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
"Socket ID", "SOCKET" },
- { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry,
+ { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry,
"Set window geometry (format: WIDTHxHEIGHT+-X+-Y)", "GEOMETRY" },
{ "version", 'V', 0, G_OPTION_ARG_NONE, &uzbl.behave.print_version,
"Print the version and exit", NULL },
};
/* associate command names to their properties */
-typedef const struct {
+typedef struct {
/* TODO: Make this ambiguous void **ptr into a union { char *char_p; int *int_p; float *float_p; } val;
the PTR() macro is kind of preventing this change at the moment. */
void **ptr;
{ "status_pbar_pending", PTR_V(uzbl.gui.sbar.progress_u, STR, 1, update_title)},
{ "status_pbar_width", PTR_V(uzbl.gui.sbar.progress_w, INT, 1, update_title)},
{ "status_background", PTR_V(uzbl.behave.status_background, STR, 1, update_title)},
- { "insert_indicator", PTR_V(uzbl.behave.insert_indicator, STR, 1, update_title)},
- { "command_indicator", PTR_V(uzbl.behave.cmd_indicator, STR, 1, update_title)},
+ { "insert_indicator", PTR_V(uzbl.behave.insert_indicator, STR, 1, update_indicator)},
+ { "command_indicator", PTR_V(uzbl.behave.cmd_indicator, STR, 1, update_indicator)},
{ "title_format_long", PTR_V(uzbl.behave.title_format_long, STR, 1, update_title)},
{ "title_format_short", PTR_V(uzbl.behave.title_format_short, STR, 1, update_title)},
{ "icon", PTR_V(uzbl.gui.icon, STR, 1, set_icon)},
g_free(uzbl.state.keycmd);
g_hash_table_destroy(uzbl.bindings);
g_hash_table_destroy(uzbl.behave.commands);
- g_scanner_destroy(uzbl.scan);
}
/* used for html_mode_timeout
if(uzbl.state.verbose)
printf("Error in geometry string: %s\n", uzbl.gui.geometry);
}
- /* update geometry var with the actual geometry
+ /* update geometry var with the actual geometry
this is necessary as some WMs don't seem to honour
the above setting and we don't want to end up with
wrong geometry information
*/
- retreive_geometry();
+ retrieve_geometry();
}
void
{ "keycmd_nl", {keycmd_nl, TRUE} },
{ "keycmd_bs", {keycmd_bs, 0} },
{ "chain", {chain, 0} },
- { "print", {print, TRUE} }
+ { "print", {print, TRUE} },
+ { "update_gui", {update_gui, TRUE} }
};
void
}
void
+update_gui(WebKitWebView *page, GArray *argv, GString *result) {
+ (void) page; (void) argv; (void) result;
+
+ update_title();
+}
+
+void
print(WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
gchar* buf;
}
void
+update_indicator() {
+ set_mode_indicator();
+ update_title();
+}
+
+void
set_insert_mode(gboolean mode) {
uzbl.behave.insert_mode = mode;
set_mode_indicator();
void
move_statusbar() {
+ if (!uzbl.gui.scrolled_win &&
+ !uzbl.gui.mainbar)
+ return;
+
gtk_widget_ref(uzbl.gui.scrolled_win);
gtk_widget_ref(uzbl.gui.mainbar);
gtk_container_remove(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.scrolled_win);
uzbl_cmdprop *c = NULL;
char *endp = NULL;
char *buf = NULL;
+ char *invalid_chars = "^°!\"§$%&/()=?'`'+~*'#-.:,;@<>| \\{}[]¹²³¼½";
if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
- if(!c->writeable) return TRUE;
+ if(!c->writeable) return FALSE;
/* check for the variable type */
if (c->type == TYPE_STR) {
/* invoke a command specific function */
if(c->func) c->func();
+ } else {
+ /* check wether name violates our naming scheme */
+ if(strpbrk(name, invalid_chars)) {
+ if (uzbl.state.verbose)
+ printf("Invalid variable name\n");
+ return FALSE;
+ }
+
+ /* custom vars */
+ c = malloc(sizeof(uzbl_cmdprop));
+ c->type = TYPE_STR;
+ c->dump = 0;
+ c->func = NULL;
+ c->writeable = 1;
+ buf = expand(val, 0);
+ c->ptr = malloc(sizeof(char *));
+ *c->ptr = buf;
+ g_hash_table_insert(uzbl.comm.proto_var,
+ g_strdup(name), (gpointer) c);
}
return TRUE;
}
(void) window;
(void) event;
- retreive_geometry();
+ retrieve_geometry();
return FALSE;
}
return TRUE;
}
- if (uzbl.behave.insert_mode &&
- ( ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) ||
+ if (uzbl.behave.insert_mode &&
+ ( ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) ||
(!uzbl.behave.modmask)
)
)
}
-GtkWidget*
+void
create_browser () {
GUI *g = &uzbl.gui;
- GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- //main_window_ref = g_object_ref(scrolled_window);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does
-
g->web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
- gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (g->web_view));
g_signal_connect (G_OBJECT (g->web_view), "notify::title", G_CALLBACK (title_change_cb), NULL);
g_signal_connect (G_OBJECT (g->web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "download-requested", G_CALLBACK (download_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "create-web-view", G_CALLBACK (create_web_view_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "mime-type-policy-decision-requested", G_CALLBACK (mime_policy_cb), g->web_view);
-
- return scrolled_window;
}
GtkWidget*
}
void
-retreive_geometry() {
+retrieve_geometry() {
int w, h, x, y;
GString *buf = g_string_new("");
* external applications need to do anyhow */
void
initialize(int argc, char *argv[]) {
- gtk_init (&argc, &argv);
if (!g_thread_supported ())
g_thread_init (NULL);
uzbl.state.executable_path = g_strdup(argv[0]);
if(setup_signal(SIGALRM, catch_alrm) == SIG_ERR)
fprintf(stderr, "uzbl: error hooking SIGALARM\n");
- uzbl.gui.sbar.progress_s = g_strdup("=");
+ uzbl.gui.sbar.progress_s = g_strdup("="); //TODO: move these to config.h
uzbl.gui.sbar.progress_u = g_strdup("·");
uzbl.gui.sbar.progress_w = 10;
commands_hash ();
make_var_to_name_hash();
- uzbl.gui.scrolled_win = create_browser();
+ create_browser();
}
#ifndef UZBL_LIBRARY
main (int argc, char* argv[]) {
initialize(argc, argv);
+ gtk_init (&argc, &argv);
+
+ uzbl.gui.scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+ //main_window_ref = g_object_ref(scrolled_window);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (uzbl.gui.scrolled_win),
+ GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does
+
+ gtk_container_add (GTK_CONTAINER (uzbl.gui.scrolled_win),
+ GTK_WIDGET (uzbl.gui.web_view));
+
uzbl.gui.vbox = gtk_vbox_new (FALSE, 0);
create_mainbar();
if(uzbl.gui.geometry)
cmd_set_geometry();
else
- retreive_geometry();
+ retrieve_geometry();
gchar *uri_override = (uzbl.state.uri ? g_strdup(uzbl.state.uri) : NULL);
+ if (argc > 1 && !uzbl.state.uri)
+ uri_override = g_strdup(argv[1]);
gboolean verbose_override = uzbl.state.verbose;
settings_init ();