Skip to content

Commit

Permalink
helloworld
Browse files Browse the repository at this point in the history
  • Loading branch information
j2969719 committed Mar 20, 2019
1 parent db9be61 commit e0e398a
Show file tree
Hide file tree
Showing 22 changed files with 571 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/wlx/gtk_socket/abiword.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

export GDK_CORE_DEVICE_EVENTS=1
${0%.sh}/kostyl -w $1 -f "$2"
10 changes: 10 additions & 0 deletions plugins/wlx/gtk_socket/abiword/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CC = gcc
CFLAGS =
INCLUDES = `pkg-config --cflags --libs abiword-3.0`


all:
$(CC) $(CFLAGS) $(INCLUDES) kostyl.c -o kostyl

clean:
$(RM) kostyl
Binary file added plugins/wlx/gtk_socket/abiword/kostyl
Binary file not shown.
70 changes: 70 additions & 0 deletions plugins/wlx/gtk_socket/abiword/kostyl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <libabiword.h>
#include <abiwidget.h>

//static GdkNativeWindow id = 0;
static Window id = 0;
static gchar *FileToLoad;
static GOptionEntry entries[] =
{
{ "xid", 'w', 0, G_OPTION_ARG_INT, &id, "Window ID", "ID" },
{ "file", 'f', 0, G_OPTION_ARG_FILENAME, &FileToLoad, "File to load", "File" },
{ NULL }
};

static void destroy(GtkWidget *widget, gpointer data)
{
g_print("bye\n");
libabiword_shutdown();
gtk_main_quit();
}

int main(int argc, char *argv[])
{
GtkWidget *abi;
GtkWidget *plug;
gchar* fileUri;
GError *err = NULL;
GOptionContext *context;

gtk_init(&argc, &argv);
libabiword_init_noargs();
context = g_option_context_new("- commandline options");
g_option_context_add_main_entries(context, entries, NULL);
g_option_context_add_group(context, gtk_get_option_group(TRUE));

if (!g_option_context_parse(context, &argc, &argv, &err))
{
g_print("option parsing failed: %s\n", err->message);
exit(1);
}

if (err)
g_error_free(err);

g_print("hi\n");
abi = abi_widget_new();

if (FileToLoad)
fileUri = g_filename_to_uri(FileToLoad, NULL, NULL);

abi_widget_load_file(ABI_WIDGET(abi), fileUri, "");

if (id > 0)
{
plug = gtk_plug_new(id);
gtk_container_add(GTK_CONTAINER(plug), abi);
gtk_plug_construct(GTK_PLUG(plug), id);
gtk_widget_show_all(plug);
gtk_widget_realize(abi);
}
else
return EXIT_FAILURE;

g_signal_connect(plug, "destroy", G_CALLBACK(destroy), NULL);
gtk_main();

return EXIT_SUCCESS;
}
4 changes: 4 additions & 0 deletions plugins/wlx/gtk_socket/evince.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

export GDK_CORE_DEVICE_EVENTS=1
${0%.sh}/kostyl -w $1 -f "$2"
9 changes: 9 additions & 0 deletions plugins/wlx/gtk_socket/evince/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CC = gcc
CFLAGS =
INCLUDES = `pkg-config --cflags --libs evince-view-3.0 evince-document-3.0`

all:
$(CC) $(CFLAGS) $(INCLUDES) kostyl.c -o kostyl

clean:
$(RM) kostyl
Binary file added plugins/wlx/gtk_socket/evince/kostyl
Binary file not shown.
94 changes: 94 additions & 0 deletions plugins/wlx/gtk_socket/evince/kostyl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <evince-view.h>
#include <evince-document.h>

//static GdkNativeWindow id = 0;
static Window id = 0;
static gchar *FileToLoad;
static GOptionEntry entries[] =
{
{ "xid", 'w', 0, G_OPTION_ARG_INT, &id, "Window ID", "ID" },
{ "file", 'f', 0, G_OPTION_ARG_FILENAME, &FileToLoad, "File to load", "File" },
{ NULL }
};

static void destroy(GtkWidget *widget, gpointer data)
{
g_print("bye\n");
ev_shutdown();
gtk_main_quit();
}

int main(int argc, char *argv[])
{
GtkWidget *plug;
GtkWidget *scrolled_window;
GtkWidget *view;
EvDocument *document;
EvDocumentModel *docmodel;
gchar* fileUri;
GError *err = NULL;
GOptionContext *context;

gtk_init(&argc, &argv);

if (!ev_init())
return EXIT_FAILURE;

context = g_option_context_new("- commandline options");
g_option_context_add_main_entries(context, entries, NULL);
g_option_context_add_group(context, gtk_get_option_group(TRUE));

if (!g_option_context_parse(context, &argc, &argv, &err))
{
g_print("option parsing failed: %s\n", err->message);
exit(1);
}

if (err)
g_error_free(err);

g_print("hi\n");
scrolled_window = gtk_scrolled_window_new(NULL, NULL);

if (FileToLoad)
fileUri = g_filename_to_uri(FileToLoad, NULL, NULL);

document = EV_DOCUMENT(ev_document_factory_get_document(fileUri, NULL));

if (EV_IS_DOCUMENT(document))
{
docmodel = EV_DOCUMENT_MODEL(ev_document_model_new_with_document(document));
view = ev_view_new();
ev_view_set_model(EV_VIEW(view), docmodel);
g_object_unref(document);
g_object_unref(docmodel);
gtk_container_add(GTK_CONTAINER(scrolled_window), view);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
}
else
{
gtk_widget_destroy(scrolled_window);
return EXIT_FAILURE;
}

if (id > 0)
{
plug = gtk_plug_new(id);
gtk_container_add(GTK_CONTAINER(plug), scrolled_window);
gtk_plug_construct(GTK_PLUG(plug), id);
gtk_widget_show_all(plug);
gtk_widget_realize(scrolled_window);
}
else
return EXIT_FAILURE;

g_signal_connect(plug, "destroy", G_CALLBACK(destroy), NULL);
gtk_main();

return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions plugins/wlx/gtk_socket/evince/langs
3 changes: 3 additions & 0 deletions plugins/wlx/gtk_socket/libreoffice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

${0%.sh}/kostyl -w $1 -f "$2"
9 changes: 9 additions & 0 deletions plugins/wlx/gtk_socket/libreoffice/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CC = gcc
CFLAGS =
INCLUDES = `pkg-config --cflags --libs gtk+-3.0` -llibreofficekitgtk -I.

all:
$(CC) $(CFLAGS) $(INCLUDES) kostyl.c -o kostyl

clean:
$(RM) kostyl
Binary file added plugins/wlx/gtk_socket/libreoffice/kostyl
Binary file not shown.
Loading

0 comments on commit e0e398a

Please sign in to comment.