about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-08-09 22:28:43 -0400
committerJosh Rickmar <jrick@devio.us>2012-08-09 22:28:43 -0400
commit84f8bf4d7762cd9fbd09f649b4234177802f937f (patch)
tree17322fc804dd68e25902f5935fe6ae2d23b0c509
parentef04a2b754cf7e4457098e40fddda51d1efa877a (diff)
downloadxombrero-84f8bf4d7762cd9fbd09f649b4234177802f937f.tar.gz
Backout commits
Accidentally pushed a bunch of stuff to master that wasn't ready yet
when making the FreeBSD Makefile changes.  Sorry marco for the merges
in the logs.  This should revert everything back to how it was at
d397399c349d36f611a5aac6fa53528d2fe2eaea.
-rw-r--r--about.c288
-rw-r--r--freebsd/Makefile2
-rw-r--r--xombrero.c39
-rw-r--r--xombrero.h4
4 files changed, 118 insertions, 215 deletions
diff --git a/about.c b/about.c
index 861e7d2..db76510 100644
--- a/about.c
+++ b/about.c
@@ -85,8 +85,6 @@ void			update_cookie_tabs(struct tab *apart_from);
 int			about_webkit(struct tab *, struct karg *);
 int			allthethings(struct tab *, struct karg *);
 
-extern SoupSession	*session;
-
 struct about_type about_list[] = {
 	{ XT_URI_ABOUT_ABOUT,		xtp_page_ab },
 	{ XT_URI_ABOUT_ALLTHETHINGS,	allthethings },
@@ -1974,117 +1972,28 @@ startpage_add(const char *fmt, ...)
 
 	TAILQ_INSERT_TAIL(&spl, s, entry);
 }
-gchar *show_g_object_settings(GObject *, char *, int);
-
-char *
-xt_g_object_serialize(GValue *value, const gchar *tname, char *str, int recurse)
-{
-	int		typeno = 0;
-	char		*valstr, *tmpstr, *tmpsettings;
-	GObject		*object;
-
-	typeno = G_TYPE_FUNDAMENTAL( G_VALUE_TYPE(value) );
-	switch ( typeno ) {
-	case G_TYPE_ENUM:
-		valstr = g_strdup_printf("%d",
-		    g_value_get_enum(value));
-		break;
-	case G_TYPE_CHAR:
-		valstr = g_strdup_printf("%c",
-		    g_value_get_schar(value));
-		break;
-	case G_TYPE_UCHAR:
-		valstr = g_strdup_printf("%c",
-		    g_value_get_uchar(value));
-		break;
-	case G_TYPE_LONG:
-		valstr = g_strdup_printf("%ld",
-		    g_value_get_long(value));
-		break;
-	case G_TYPE_ULONG:
-		valstr = g_strdup_printf("%ld",
-		    g_value_get_ulong(value));
-		break;
-	case G_TYPE_INT:
-		valstr = g_strdup_printf("%d",
-		    g_value_get_int(value));
-		break;
-	case G_TYPE_INT64:
-		valstr = g_strdup_printf("%" PRIo64,
-		    (int64_t) g_value_get_int64(value));
-		break;
-	case G_TYPE_UINT:
-		valstr = g_strdup_printf("%d",
-		    g_value_get_uint(value));
-		break;
-	case G_TYPE_UINT64:
-		valstr = g_strdup_printf("%" PRIu64,
-		    (uint64_t) g_value_get_uint64(value));
-		break;
-	case G_TYPE_FLAGS:
-		valstr = g_strdup_printf("0x%x",
-		    g_value_get_flags(value));
-		break;
-	case G_TYPE_BOOLEAN:
-		valstr = g_strdup_printf("%s",
-		    g_value_get_boolean(value) ? "TRUE" : "FALSE");
-		break;
-	case G_TYPE_FLOAT:
-		valstr = g_strdup_printf("%f",
-		    g_value_get_float(value));
-		break;
-	case G_TYPE_DOUBLE:
-		valstr = g_strdup_printf("%f",
-		    g_value_get_double(value));
-		break;
-	case G_TYPE_STRING:
-		valstr = g_strdup_printf("\"%s\"",
-		    g_value_get_string(value));
-		break;
-	case G_TYPE_POINTER:
-		valstr = g_strdup_printf("%p",
-		    g_value_get_pointer(value));
-		break;
-	case G_TYPE_OBJECT:
-		object = g_value_get_object(value);
-		if (object != NULL) {
-			if (recurse) {
-				tmpstr = g_strdup_printf("%s     ", str);
-				tmpsettings = show_g_object_settings( object,
-				    tmpstr, recurse);
-				g_free(tmpstr);
-
-				if (strrchr(tmpsettings, '\n') != NULL) {
-					valstr = g_strdup_printf("%s%s      }",
-					    tmpsettings, str);
-					g_free(tmpsettings);
-				} else {
-					valstr = tmpsettings;
-				}
-			} else {
-				valstr = g_strdup_printf("<...>");
-			}
-		} else {
-			valstr = g_strdup_printf("settings[] = NULL");
-		}
-		break;
-	default:
-		valstr = g_strdup_printf("type %s unhandled", tname);
-	}
-	return valstr;
-}
 
 gchar *
 show_g_object_settings(GObject *o, char *str, int recurse)
 {
-	char		*b, *p, *body, *valstr, *tmpstr;
+	char		*b, *body, *valstr;
 	guint		n_props = 0;
-	int		i, typeno = 0;
+	int		i;
 	GParamSpec	*pspec;
 	const gchar	*tname;
 	GValue		value;
+	int		typeno;
+	const gchar	*string;
+	gboolean	boolean;
+	gfloat		fp;
+	gdouble		fpd;
+	gint		number;
+	guint		unumber;
+	int64_t		number64;
+	uint64_t	unumber64;
+	GObject		*object;
 	GParamSpec	**proplist;
-	const gchar	*name;
+	char		*tmpstr, *tmpsettings;
 
 	if (!G_IS_OBJECT(o)) {
 		fprintf(stderr, "%s is not a g_object\n", str);
@@ -2092,18 +2001,7 @@ show_g_object_settings(GObject *o, char *str, int recurse)
 	}
 	proplist = g_object_class_list_properties(
 	    G_OBJECT_GET_CLASS(o), &n_props);
-
-	if (GTK_IS_WIDGET(o)) {
-		name = gtk_widget_get_name(GTK_WIDGET(o));
-	} else {
-		name = "settings";
-	}
-	if (n_props == 0) {
-		body = g_strdup_printf("%s[0] = { }", name);
-		goto end_show_g_objects;
-	}
-
-	body = g_strdup_printf("%s[%d] = {\n", name, n_props);
+	body = g_strdup_printf("%s: %3d settings\n", str, n_props);
 	for (i=0; i < n_props; i++) {
 		pspec = proplist[i];
 		tname = G_OBJECT_TYPE_NAME(pspec);
@@ -2116,66 +2014,101 @@ show_g_object_settings(GObject *o, char *str, int recurse)
 			g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
 			g_object_get_property(G_OBJECT(o), pspec->name,
 			    &value);
-			typeno = G_TYPE_FUNDAMENTAL( G_VALUE_TYPE(&value) );
 		}
 
 		/* based on the type, recurse and display values */
 		if (valstr == NULL) {
-			valstr = xt_g_object_serialize(&value, tname, str,
-			    recurse);
+			typeno = G_TYPE_FUNDAMENTAL( G_VALUE_TYPE(&value) );
+			switch ( typeno ) {
+			case G_TYPE_ENUM:
+				number = g_value_get_enum(&value);
+				valstr = g_strdup_printf("%d", number);
+				break;
+			case G_TYPE_INT:
+				number = g_value_get_int(&value);
+				valstr = g_strdup_printf("%d", number);
+				break;
+			case G_TYPE_INT64:
+				number64 = (int64_t)g_value_get_int64(&value);
+				valstr = g_strdup_printf("%" PRIo64, number64);
+				break;
+			case G_TYPE_UINT:
+				unumber = g_value_get_uint(&value);
+				valstr = g_strdup_printf("%d", unumber);
+				break;
+			case G_TYPE_UINT64:
+				unumber64 =
+				    (uint64_t)g_value_get_uint64(&value);
+				valstr =
+				    g_strdup_printf("%" PRIu64, unumber64);
+				break;
+			case G_TYPE_FLAGS:
+				unumber = g_value_get_flags(&value);
+				valstr = g_strdup_printf("0x%x", unumber);
+				break;
+			case G_TYPE_BOOLEAN:
+				boolean = g_value_get_boolean(&value);
+				valstr = g_strdup_printf("%s",
+				    boolean ? "TRUE" : "FALSE");
+				break;
+			case G_TYPE_FLOAT:
+				fp = g_value_get_float(&value);
+				valstr = g_strdup_printf("%f", fp);
+				break;
+			case G_TYPE_DOUBLE:
+				fpd = g_value_get_double(&value);
+				valstr = g_strdup_printf("%f", fpd);
+				break;
+			case G_TYPE_STRING:
+				string = g_value_get_string(&value);
+				valstr = g_strdup_printf("\"%s\"",
+				    string);
+				break;
+			case G_TYPE_OBJECT:
+				object = g_value_get_object(&value);
+				if (object != NULL) {
+					if (recurse) {
+					tmpstr = g_strdup_printf("%s     ",
+					    str);
+					tmpsettings = show_g_object_settings(
+					    object, tmpstr, recurse);
+					valstr = g_strdup_printf(
+					    "{\n%s%s }\n",
+					    tmpsettings, str);
+					g_free(tmpstr);
+					g_free(tmpsettings);
+					} else {
+					valstr = g_strdup_printf("<...>");
+					}
+				} else {
+					valstr = g_strdup_printf("NULL");
+				}
+				break;
+			default:
+				valstr = g_strdup_printf(
+				    "type %s unhandled",
+				    tname);
+			}
 		}
 
-		tmpstr = g_strdup_printf("%-13s %s%s%s,", tname, pspec->name,
-			(typeno == G_TYPE_OBJECT) ? "." : " = ", valstr);
 		b = body;
-
-#define XT_G_OBJECT_SPACING		50
-		p = strrchr(tmpstr, '\n');
-		if (p == NULL && strlen(tmpstr) > XT_G_OBJECT_SPACING) {
-			body = g_strdup_printf(
-			    "%s%s    %-50s\n%s    %50s /* %3d flags=0x%08x */\n",
-			    body, str, tmpstr, str, "", i, pspec->flags);
-		} else {
-			char *fmt;
-			int strspaces;
-			if (p == NULL)
-				strspaces = XT_G_OBJECT_SPACING;
-			else
-				strspaces = strlen(tmpstr) - (strlen(p) - strlen(str)) + XT_G_OBJECT_SPACING + 5;
-			fmt = g_strdup_printf("%%s%%s    %%-%ds /* %%3d flags=0x%%08x */\n", strspaces);
-			body = g_strdup_printf(fmt, body, str, tmpstr, i, pspec->flags);
-			g_free(fmt);
-		}
-		g_free(tmpstr);
+		body = g_strdup_printf(
+		    "%s%s: %3d: flags=0x%08x, %-13s %s = %s\n",
+		    body, str, i, pspec->flags, tname, pspec->name,
+		    valstr);
 		g_free(b);
 		g_free(valstr);
 	}
-end_show_g_objects:
 	g_free(proplist);
 	return (body);
 }
 
-char *
-xt_append_settings(char *str, GObject *object, char *name, int recurse)
-{
-	char *newstr, *settings;
-
-	settings = show_g_object_settings(object, name, recurse);
-	if (str == NULL)
-		str = g_strdup("");
-
-	newstr = g_strdup_printf("%s%s %s%s };\n", str, name, settings, name);
-	g_free(str);
-
-	return newstr;
-}
-
 int
 about_webkit(struct tab *t, struct karg *arg)
 {
 	char			*page, *body, *settingstr;
 
-	settingstr = xt_append_settings(NULL, G_OBJECT(t->settings),
+	settingstr = show_g_object_settings(G_OBJECT(t->settings),
 	    "t->settings", 0);
 	body = g_strdup_printf("<pre>%s</pre>\n", settingstr);
 	g_free(settingstr);
@@ -2189,38 +2122,25 @@ about_webkit(struct tab *t, struct karg *arg)
 	return (0);
 }
 
-static int		toplevelcount = 0;
-
-void
-xt_append_toplevel(GtkWindow *w, char **body)
-{
-	char			*n;
-
-	n = g_strdup_printf("toplevel#%d", toplevelcount++);
-	*body = xt_append_settings(*body, G_OBJECT(w), n, 0);
-	g_free(n);
-}
-
 int
 allthethings(struct tab *t, struct karg *arg)
 {
-	GList			*list;
-	char			*page, *body, *b;
+	char			*page, *body, *b, *settingstr;
+	extern GtkWidget	*main_window;
 
-	body = xt_append_settings(NULL, G_OBJECT(t->wv), "t->wv", 1);
-	body = xt_append_settings(body, G_OBJECT(t->inspector),
+	body = show_g_object_settings(G_OBJECT(t->wv), "t->wv", 1);
+	b = body;
+	settingstr = show_g_object_settings(G_OBJECT(t->inspector),
 	    "t->inspector", 1);
-#if 0 /* not until warnings are gone */
-	body = xt_append_settings(body, G_OBJECT(session),
-	    "session", 1);
-#endif
-	toplevelcount = 0;
-	list = gtk_window_list_toplevels();
-	g_list_foreach(list, (GFunc)g_object_ref, NULL);
-	g_list_foreach(list, (GFunc)xt_append_toplevel, &body);
-	g_list_foreach(list, (GFunc)g_object_unref, NULL);
-	g_list_free(list);
-		
+	body = g_strdup_printf("%s%s", body, settingstr);
+	g_free(b);
+	g_free(settingstr);
+	b = body;
+	settingstr = show_g_object_settings(G_OBJECT(main_window),
+	    "main_window", 1);
+	body = g_strdup_printf("%s%s", body, settingstr);
+	g_free(b);
+	g_free(settingstr);
 	b = body;
 	body = g_strdup_printf("<pre>%scan paste clipboard = %d\n</pre>", body,
 	    webkit_web_view_can_paste_clipboard(t->wv));
diff --git a/freebsd/Makefile b/freebsd/Makefile
index cf65ea8..011354c 100644
--- a/freebsd/Makefile
+++ b/freebsd/Makefile
@@ -9,7 +9,7 @@ LIBS+= libsoup-2.4 gnutls gthread-2.0
 LDADD= -lutil -lgcrypt
 GTK_CFLAGS!= pkg-config --cflags $(LIBS)
 GTK_LDFLAGS!= pkg-config --libs $(LIBS)
-CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -pthread -I. -I..
+CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -pthread
 LDFLAGS+= $(GTK_LDFLAGS) -pthread
 
 PREFIX?= /usr/local
diff --git a/xombrero.c b/xombrero.c
index 913e183..214b104 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -6610,6 +6610,7 @@ cmd_keypress_cb(GtkEntry *w, GdkEventKey *e, struct tab *t)
 		/* FALLTHROUGH */
 	case GDK_Escape:
 		hide_cmd(t);
+		focus_webview(t);
 
 		/* cancel search */
 		if (c != NULL && (c[0] == '/' || c[0] == '?'))
@@ -6700,21 +6701,12 @@ cmd_focusout_cb(GtkWidget *w, GdkEventFocus *e, struct tab *t)
 	hide_oops(t);
 	disable_hints(t);
 
-	return (XT_CB_PASSTHROUGH);
-}
-
-void
-cmd_hide_cb(GtkWidget *w, struct tab *t)
-{
-	if (t == NULL) {
-		show_oops(NULL, "%s: invalid parameters", __func__);
-		return;
-	}
-
 	if (show_url == 0 || t->focus_wv)
 		focus_webview(t);
 	else
 		gtk_widget_grab_focus(GTK_WIDGET(t->uri_entry));
+
+	return (XT_CB_PASSTHROUGH);
 }
 
 void
@@ -7332,8 +7324,6 @@ delete_tab(struct tab *t)
 		gtk_widget_destroy(t->js_toggle);
 	}
 
-	g_object_unref(t->completion);
-
 	gtk_widget_destroy(t->tab_elems.eventbox);
 	gtk_widget_destroy(t->vbox);
 
@@ -7775,7 +7765,6 @@ create_new_tab(char *title, struct undo *u, int focus, int position)
 	    "signal::focus-out-event", G_CALLBACK(cmd_focusout_cb), t,
 	    "signal::activate", G_CALLBACK(cmd_activate_cb), t,
 	    "signal::populate-popup", G_CALLBACK(cmd_popup_cb), t,
-	    "signal::hide", G_CALLBACK(cmd_hide_cb), t,
 	    (char *)NULL);
 
 	/* reuse wv_button_cb to hide oops */
@@ -7839,7 +7828,10 @@ create_new_tab(char *title, struct undo *u, int focus, int position)
 	} else
 		webkit_web_back_forward_list_clear(t->bfl);
 
-	/* check and show url and statusbar */
+	/* hide stuff */
+	hide_cmd(t);
+	hide_oops(t);
+	hide_buffers(t);
 	url_set_visibility();
 	statusbar_set_visibility();
 
@@ -7890,7 +7882,6 @@ notebook_switchpage_cb(GtkNotebook *nb, GtkWidget *nbp, guint pn,
 
 			hide_cmd(t);
 			hide_oops(t);
-			hide_buffers(t);
 
 			if (t->focus_wv) {
 				/* can't use focus_webview here */
@@ -7931,13 +7922,6 @@ menuitem_response(struct tab *t)
 	gtk_notebook_set_current_page(notebook, t->tab_id);
 }
 
-int
-destroy_menu(GtkWidget *w, GdkEventFocus *e, void *notused)
-{
-	gtk_widget_destroy(w);
-	return (XT_CB_PASSTHROUGH);
-}
-
 gboolean
 arrow_cb(GtkWidget *w, GdkEventButton *event, gpointer user_data)
 {
@@ -7972,9 +7956,12 @@ arrow_cb(GtkWidget *w, GdkEventButton *event, gpointer user_data)
 		gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
 		    bevent->button, bevent->time);
 
-		g_object_connect(G_OBJECT(menu),
-		    "signal::hide", G_CALLBACK(destroy_menu), NULL,
-		    (char *)NULL);
+		/* unref object so it'll free itself when popped down */
+#if !GTK_CHECK_VERSION(3, 0, 0)
+		/* XXX does not need unref with gtk+3? */
+		g_object_ref_sink(menu);
+		g_object_unref(menu);
+#endif
 
 		return (TRUE /* eat event */);
 	}
diff --git a/xombrero.h b/xombrero.h
index 20efb34..d5da4d9 100644
--- a/xombrero.h
+++ b/xombrero.h
@@ -48,8 +48,6 @@ u_int32_t	arc4random_uniform(u_int32_t);
 #include <sys/tree.h>
 #include <X11/Xlib.h>
 #include <sys/un.h>
-#include <sys/param.h>
-#define LOGIN_NAME_MAX MAXLOGNAME
 #elif defined(__OpenBSD__)
 #include <util.h>
 #include <sys/tree.h>
@@ -926,8 +924,6 @@ extern SoupSession	*session;
 extern GtkNotebook	*notebook;
 extern GtkListStore	*completion_model;
 extern uint64_t		blocked_cookies;
-extern GtkWidget	*main_window;
-extern SoupSession	*session;
 
 extern void	(*_soup_cookie_jar_add_cookie)(SoupCookieJar *, SoupCookie *);