Commit a5ed3183 authored by Moritz Sokoll's avatar Moritz Sokoll 💬
Browse files

first functioning webview implemented

parent a7348d0e
Pipeline #186 failed with stages
in 3 minutes and 30 seconds
image: gcc
before_script:
- apt-get update
- apt-get install -y libwebkit2gtk-4.0-dev
- apt-get install -y libgtk-3-dev
- mkdir bin
cache:
paths:
- bin/*
build:
stage: build
script:
- make
- make debug-build
artifacts:
paths:
- bin/*
tags:
- x86_64
test:
stage: test
script:
- ./bin/gwebb -v -h
SRC = src/main.cpp src/values.cpp src/tabs.cpp
DEPS = gtk+-3.0 webkit2gtk-4.0
CFLAGS = -fpermissive `pkg-config --cflags --libs $(DEPS)`
OUTF = -o bin/gwebb
DEBUGOUTF = -o bin/gwebb-debug
CC = g++
all:
g++ `pkg-config --cflags --libs gtk+-3.0` `pkg-config --cflags --libs webkit2gtk-4.0` -fpermissive src/main.cpp src/values.cpp -o bin/gwebb
$(CC) $(CFLAGS) $(SRC) $(OUTF)
debug-build:
$(CC) $(CFLAGS) -g $(SRC) $(DEBUGOUTF)
#ifndef GWEBB_TABS_H
#define GWEBB_TABS_H
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
int createTab(GtkNotebook *notebook, char* uri, char* title);
#endif
......@@ -4,6 +4,7 @@
#include <string.h>
#include <iostream>
#include "lib/values.h"
#include "lib/tabs.h"
using namespace std;
static void destroy( GtkWidget *widget, gpointer data) { gtk_main_quit(); }
......@@ -12,10 +13,12 @@ int main(int argc, char* argv[]) {
GtkWidget* notebook, *window;
bool gui = true;
//iterating over the commandline arguments
for (int i=0; i<argc; i++) {
string arg = argv[i];
if (arg == (string) "-v" || arg== (string) "--version") {
printf("%s\n", GWEBB_VERSION_STR);
printf("GWebB Version: %s\n", GWEBB_VERSION_STR);
gui = false;
}
......@@ -24,9 +27,15 @@ int main(int argc, char* argv[]) {
gui = false;
}
}
if (!gui) {return 0;}
gtk_init(&argc, &argv);
//create the notebook widget with one page
notebook = gtk_notebook_new();
int nbstat = createTab(GTK_NOTEBOOK(notebook), "https://google.de", "test sheesh");
if (nbstat == -1) { printf("gtk notebook page appending failed"); return 1; }
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
......
#include "lib/tabs.h"
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
int createTab(GtkNotebook *notebook, char* uri, char* title) {
GtkWidget *webview = webkit_web_view_new();
int nbstat = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), webview, gtk_label_new(title));
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview), uri);
gtk_widget_show(webview);
return nbstat;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment