about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-05-07 12:11:57 -0400
committerJosh Rickmar <jrick@devio.us>2012-05-07 14:05:19 -0400
commit04fe572e779be208d4c658f0185887baae49a0a8 (patch)
tree1153da19b0854e005f0af6a889e43c0de0ae16ed
parentf82cf1f13aa3d94e1df6054c405f0c92e40e677b (diff)
downloadxombrero-04fe572e779be208d4c658f0185887baae49a0a8.tar.gz
Make show_tabs a runtime setting and replace atoi() calls with
strtonum() when called on user input.
-rw-r--r--settings.c61
-rw-r--r--xxxterm.c15
-rw-r--r--xxxterm.h17
3 files changed, 70 insertions, 23 deletions
diff --git a/settings.c b/settings.c
index 7817bd7..6407779 100644
--- a/settings.c
+++ b/settings.c
@@ -139,6 +139,7 @@ int		set_download_mode(struct settings *, char *);
 int		set_download_mode_rt(char *);
 int		set_referer(struct settings *, char *);
 int		set_referer_rt(char *);
+int		set_show_tabs(char *);
 int		set_external_editor(char *);
 
 void		walk_mime_type(struct settings *, void (*)(struct settings *,
@@ -332,7 +333,7 @@ struct settings		rs[] = {
 	{ "session_timeout",		XT_S_INT, 0,		&session_timeout, NULL, NULL, NULL, NULL },
 	{ "session_autosave",		XT_S_INT, 0,		&session_autosave, NULL, NULL, NULL, NULL },
 	{ "single_instance",		XT_S_INT, XT_SF_RESTART,&single_instance, NULL, NULL, NULL, NULL },
-	{ "show_tabs",			XT_S_INT, 0,		&show_tabs, NULL, NULL, NULL, NULL },
+	{ "show_tabs",			XT_S_INT, 0,		&show_tabs, NULL, NULL, NULL, set_show_tabs },
 	{ "show_url",			XT_S_INT, 0,		&show_url, NULL, NULL, NULL, NULL },
 	{ "show_statusbar",		XT_S_INT, 0,		&show_statusbar, NULL, NULL, NULL, NULL },
 	{ "spell_check_languages",	XT_S_STR, 0, NULL,	&spell_check_languages, NULL, NULL, NULL },
@@ -377,7 +378,13 @@ struct settings		rs[] = {
 int
 set_append_next(char *value)
 {
-	append_next = atoi(value);
+	int			tmp;
+	const char		*errstr;
+
+	tmp = strtonum(value, 0, 1, &errstr);
+	if (errstr)
+		return (-1);
+	append_next = tmp;
 	return (0);
 }
 
@@ -1084,9 +1091,14 @@ walk_ua(struct settings *s,
 int
 set_auto_load_images(char *value)
 {
-	struct tab *t;
-
-	auto_load_images = atoi(value);
+	struct tab		*t;
+	int			tmp;
+	const char		*errstr;
+
+	tmp = strtonum(value, 0, 1, &errstr);
+	if (errstr)
+		return (-1);
+	auto_load_images = tmp;
 	TAILQ_FOREACH(t, &tabs, entry) {
 		g_object_set(G_OBJECT(t->settings),
 		    "auto-load-images", auto_load_images, (char *)NULL);
@@ -1098,21 +1110,39 @@ set_auto_load_images(char *value)
 int
 set_enable_autoscroll(char *value)
 {
-	enable_autoscroll = atoi(value);
+	int			tmp;
+	const char		*errstr;
+
+	tmp = strtonum(value, 0, 1, &errstr);
+	if (errstr)
+		return (-1);
+	enable_autoscroll = tmp;
 	return (0);
 }
 
 int
 set_enable_favicon_entry(char *value)
 {
-	enable_favicon_entry = atoi(value);
+	int			tmp;
+	const char		*errstr;
+
+	tmp = strtonum(value, 0, 1, &errstr);
+	if (errstr)
+		return (-1);
+	enable_favicon_entry = tmp;
 	return (0);
 }
 
 int
 set_enable_favicon_tabs(char *value)
 {
-	enable_favicon_tabs = atoi(value);
+	int			tmp;
+	const char		*errstr;
+
+	tmp = strtonum(value, 0, 1, &errstr);
+	if (errstr)
+		return (-1);
+	enable_favicon_tabs = tmp;
 	return (0);
 }
 
@@ -1166,6 +1196,21 @@ set_referer_rt(char *value)
 }
 
 int
+set_show_tabs(char *value)
+{
+	struct karg		args = {0};
+	int			val;
+	const char		*errstr;
+
+	val = strtonum(value, 0, 1, &errstr);
+	if (errstr)
+		return (-1);
+	args.i = val ? XT_TAB_SHOW : XT_TAB_HIDE;
+	tabaction(get_current_tab(), &args);
+	return (0);
+}
+
+int
 set_external_editor(char *editor)
 {
 	if (external_editor)
diff --git a/xxxterm.c b/xxxterm.c
index 782b89e..6d0e1ea 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -146,21 +146,6 @@ TAILQ_HEAD(command_list, command_entry);
 
 #define XT_GO_UP_ROOT		(999)
 
-#define XT_TAB_LAST		(-4)
-#define XT_TAB_FIRST		(-3)
-#define XT_TAB_PREV		(-2)
-#define XT_TAB_NEXT		(-1)
-#define XT_TAB_INVALID		(0)
-#define XT_TAB_NEW		(1)
-#define XT_TAB_DELETE		(2)
-#define XT_TAB_DELQUIT		(3)
-#define XT_TAB_OPEN		(4)
-#define XT_TAB_UNDO_CLOSE	(5)
-#define XT_TAB_SHOW		(6)
-#define XT_TAB_HIDE		(7)
-#define XT_TAB_NEXTSTYLE	(8)
-#define XT_TAB_LOAD_IMAGES	(9)
-
 #define XT_NAV_INVALID		(0)
 #define XT_NAV_BACK		(1)
 #define XT_NAV_FORWARD		(2)
diff --git a/xxxterm.h b/xxxterm.h
index f546256..e6b4891 100644
--- a/xxxterm.h
+++ b/xxxterm.h
@@ -523,6 +523,22 @@ int		fork_exec(struct tab *, char *, const gchar *, char *, int);
 #define MOD1			GDK_MOD1_MASK
 #define SHFT			GDK_SHIFT_MASK
 
+/* actions */
+#define XT_TAB_LAST		(-4)
+#define XT_TAB_FIRST		(-3)
+#define XT_TAB_PREV		(-2)
+#define XT_TAB_NEXT		(-1)
+#define XT_TAB_INVALID		(0)
+#define XT_TAB_NEW		(1)
+#define XT_TAB_DELETE		(2)
+#define XT_TAB_DELQUIT		(3)
+#define XT_TAB_OPEN		(4)
+#define XT_TAB_UNDO_CLOSE	(5)
+#define XT_TAB_SHOW		(6)
+#define XT_TAB_HIDE		(7)
+#define XT_TAB_NEXTSTYLE	(8)
+#define XT_TAB_LOAD_IMAGES	(9)
+
 struct key_binding {
 	char				*cmd;
 	guint				mask;
@@ -568,6 +584,7 @@ char		*get_cookie_policy(struct settings *);
 void		init_keybindings(void);
 void		config_parse(char *, int);
 char		*get_setting_name(int);
+int		tabaction(struct tab *, struct karg *);
 
 #define		XT_DL_START	(0)
 #define		XT_DL_RESTART	(1)