Summary Files Commits Branches @commit @diff @stats
path: root / badwolf.c
diff options
context:
space:
mode:
Commitb93b710b012f65adf2dd3c2e0f809b8f0ee070f8 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-06-21 01:17:19 +0200
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-06-21 01:17:19 +0200
Filese6c7ecf7f19fac950e3138cfb19fc1c28b7c85e8 /badwolf.c
goodwolf-b93b710b012f65adf2dd3c2e0f809b8f0ee070f8.tar
goodwolf-b93b710b012f65adf2dd3c2e0f809b8f0ee070f8.tar.gz
goodwolf-b93b710b012f65adf2dd3c2e0f809b8f0ee070f8.zip
Parentd9cd162c1af558f75d508f4dd75b6b7f162e0700 (diff)
Parent582b91d23bd1eba52f77ba1cc68a21f8061ea50a (diff)
Merge branch 'release-0.2', from release 0.2.1
1 files changed, 26 insertions, 7 deletions
-rw-r--r--badwolf.c33
diff --git a/badwolf.c b/badwolf.c
index 5e2a98b..f512ba3 100644
--- a/badwolf.c
+++ b/badwolf.c
@@ -12,7 +12,7 @@
#include <webkit2/webkit2.h>
const gchar *homepage = "https://hacktivis.me/projects/badwolf";
-const gchar *version = "0.2.0";
+const gchar *version = "0.2.1";
struct Window
{
@@ -430,11 +430,17 @@ WebViewCb_mouse_target_changed(WebKitWebView *webView,
(void)webView;
(void)modifiers;
struct Client *browser = (struct Client *)user_data;
- const gchar *link_uri = webkit_hit_test_result_get_link_uri(hit);
- gtk_label_set_text(GTK_LABEL(browser->statuslabel), webkit_uri_for_display(link_uri));
+ if(webkit_hit_test_result_context_is_link(hit))
+ {
+ const gchar *link_uri = webkit_hit_test_result_get_link_uri(hit);
- return TRUE;
+ gtk_label_set_text(GTK_LABEL(browser->statuslabel), webkit_uri_for_display(link_uri));
+ }
+ else
+ gtk_label_set_text(GTK_LABEL(browser->statuslabel), NULL);
+
+ return FALSE;
}
static gboolean
@@ -643,9 +649,11 @@ SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data)
struct Client *
new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view)
{
- struct Client *browser = g_malloc(sizeof(struct Client));
+ struct Client *browser = g_try_malloc(sizeof(struct Client));
target_url = ensure_uri_scheme(target_url, (related_web_view == NULL));
+ if(browser == NULL) return NULL;
+
browser->window = window;
browser->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
browser->toolbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
@@ -770,21 +778,31 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
return browser;
}
+/* badwolf_new_tab: Inserts struct Client *browser in GtkNotebook *notebook
+ *
+ * returns:
+ * 0 : Ran successfully
+ * -1 : Failed to insert a page for browser->box
+ * -2 : browser is NULL
+ */
int
badwolf_new_tab(GtkNotebook *notebook, struct Client *browser)
{
gint current_page = gtk_notebook_get_current_page(notebook);
gchar *title = _("New tab");
+ if(browser == NULL) return -2;
+
gtk_widget_show_all(browser->box);
- if(gtk_notebook_insert_page(notebook, browser->box, NULL, (current_page + 2)) == -1)
+ if(gtk_notebook_insert_page(notebook, browser->box, NULL, (current_page + 1)) == -1)
{
return -1;
}
gtk_notebook_set_tab_reorderable(notebook, browser->box, TRUE);
gtk_notebook_set_tab_label(notebook, browser->box, badwolf_new_tab_box(title, browser));
+ gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(notebook), browser->box, title);
gtk_widget_queue_draw(GTK_WIDGET(notebook));
@@ -835,7 +853,8 @@ get_tab_position(GtkContainer *notebook, GtkWidget *child)
int
main(int argc, char *argv[])
{
- struct Window *window = g_malloc(sizeof(struct Client));
+ // getting an abort if this one fails to alloc
+ struct Window *window = g_malloc(sizeof(struct Window));
gchar *target_url = NULL;
setlocale(LC_ALL, "");