commit 51f5c5f788a943a83f085c6f261a87ff97d9448c
parent 26df1aecc2f24a4dd751e125d3bf1a5223b577cf
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Thu, 27 Sep 2012 20:07:41 -0600
implement multi window functionality
a single instance of the program can control multiple windows.
this is superior to having a single window because startup/shutdown
serialization is strict, for example there are either all windows
showing or no windows showing.
this architecture is intended to be married to a session saver/restorer
that knows about multiple windows and with a bit of luck the virtual
desktops they were placed on as well.
Diffstat:
M | src/callbacks.c | | | 343 | +++++++++++++++++++++++++++++++++++++++++++------------------------------------ |
M | src/commands.c | | | 74 | ++++++++++++++++++++++++++++++++++++++++++++++---------------------------- |
M | src/commands.h | | | 1 | + |
M | src/keymap.h | | | 235 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
M | src/main.c | | | 249 | +++++++++++++++++++++++++++++++++++++++++++++++-------------------------------- |
M | src/main.h | | | 56 | +++++++++++++++++++++++++++++++++++++++----------------- |
M | src/utilities.c | | | 43 | ++++++++++++++++++++++--------------------- |
7 files changed, 561 insertions(+), 440 deletions(-)
diff --git a/src/callbacks.c b/src/callbacks.c
@@ -40,7 +40,7 @@ webview_progress_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
Buffer_Data *td = data;
/* *event_info is a double between 0.0 and 1.0 */
- update_state(td->app);
+ update_state(td->window);
}
@@ -78,69 +78,55 @@ load_error_cb(void *data, Evas_Object *obj, void *event_info)
void
webview_inspector_cb(void *data, Evas_Object *obj, void *event_info)
{
- Buffer_Data *td = data;
- App_Data *ad = td->app;
-
- td->web_inspector = ewk_view_single_add(evas_object_evas_get(ad->win));
- ewk_view_theme_set(td->web_inspector, "/usr/share/ewebkit-0/themes/default.edj");
-
- evas_object_size_hint_weight_set(td->web_inspector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(td->web_inspector, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- ewk_view_web_inspector_view_set(td->view, td->web_inspector);
-
- evas_object_show(td->web_inspector);
- elm_box_pack_end(ad->web_inspector, td->web_inspector);
-
- evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 0.66);
- evas_object_show(ad->web_inspector);
+ Buffer_Data *bd = data;
+ Window_Data *wd = bd->window;
- /*
- td->web_inspector = elm_web_add(ad->win);
+ bd->web_inspector = ewk_view_single_add(evas_object_evas_get(wd->win));
+ ewk_view_theme_set(bd->web_inspector, "/usr/share/ewebkit-0/themes/default.edj");
- evas_object_size_hint_weight_set(td->web_inspector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(td->web_inspector, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(bd->web_inspector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(bd->web_inspector, EVAS_HINT_FILL, EVAS_HINT_FILL);
- ewk_view_web_inspector_view_set(view, elm_web_webkit_view_get(td->web_inspector));
+ ewk_view_web_inspector_view_set(bd->view, bd->web_inspector);
- evas_object_show(td->web_inspector);
- elm_box_pack_end(ad->web_inspector, td->web_inspector);
+ evas_object_show(bd->web_inspector);
+ elm_box_pack_end(wd->web_inspector, bd->web_inspector);
- evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 1.0);
- evas_object_show(ad->web_inspector);
- */
+ evas_object_size_hint_weight_set(wd->web_inspector, EVAS_HINT_EXPAND, 0.66);
+ evas_object_show(wd->web_inspector);
}
void
webview_inspector_close_cb(void *data, Evas_Object *obj, void *event_info)
{
- Buffer_Data *td = data;
- App_Data *ad = td->app;
+ Buffer_Data *bd = data;
+ Window_Data *wd = bd->window;
- elm_box_clear(ad->web_inspector);
- evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 0.0);
- ewk_view_web_inspector_view_set(td->view, NULL);
+ elm_box_clear(wd->web_inspector);
+ evas_object_size_hint_weight_set(wd->web_inspector, EVAS_HINT_EXPAND, 0.0);
+ ewk_view_web_inspector_view_set(bd->view, NULL);
- td->web_inspector = NULL;
+ bd->web_inspector = NULL;
}
void
webview_uri_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
Arg a = { .i = Silent, .s = strdup(JS_SETUP_HINTS) };
- Buffer_Data *td = data;
+ Buffer_Data *bd = data;
const char *uri = event_info;
+ // int i;
- if (td->web != td->app->cur_buf->web)
+ if (bd != bd->window->cur_buf)
return;
// userscript_hooks_start(elm_web_uri_get(td->web));
- script(&a, td->app);
+ script(&a, bd->window);
free(a.s);
- /*
- FILE *fp = fopen("/home/kyle/.config/evi/userscript/adblockplus/contentScript1.js", "r");
+ Evas_Object *frame = ewk_view_frame_main_get(bd->view);
+ FILE *fp = fopen("/home/kyle/.config/viking/userscript/adblockplus/contentScript1.js", "r");
if (!fp)
printf("error opening file.\n");
fseek(fp, 0L, SEEK_END);
@@ -149,19 +135,57 @@ webview_uri_changed_cb(void *data, Evas_Object *obj, void *event_info)
rewind(fp);
fread(buf, len, 1, fp);
fclose(fp);
-
ewk_frame_script_execute(frame, buf);
-
+ printf("uri_changed() executed %i byte script %s\n", len, "contentScript1.js");
free(buf);
+
+ /*
+ Evas_Object *frame = ewk_view_frame_main_get(td->view);
+ char *scripts[15] = {
+ "tampermonkey/src/emulation.js",
+ "tampermonkey/src/environment.js",
+
+ "tampermonkey/src/registry.js",
+ "tampermonkey/src/convert.js",
+ "tampermonkey/src/helper.js",
+ "tampermonkey/src/xmlhttprequest.js",
+ "tampermonkey/src/content.js",
+
+ "reddit-enhancement-suite/jquery-1.6.4.min.js",
+ "reddit-enhancement-suite/guiders-1.2.8.js",
+ "reddit-enhancement-suite/jquery.dragsort-0.4.3.min.js",
+ "reddit-enhancement-suite/jquery-fieldselection.min.js",
+ "reddit-enhancement-suite/tinycon.min.js",
+ "reddit-enhancement-suite/jquery.tokeninput.js",
+ "reddit-enhancement-suite/reddit_enhancement_suite.user.js",
+
+ };
+
+ for (i = 0; i < 14; i++) {
+ char *path = strdup_printf("/home/kyle/.config/viking/userscript/%s", scripts[i]);
+ FILE *fp = fopen(path, "r");
+ free(path);
+ if (!fp)
+ printf("error opening file.\n");
+ fseek(fp, 0L, SEEK_END);
+ int len = ftell(fp);
+ char *buf = malloc(len);
+ rewind(fp);
+ fread(buf, len, 1, fp);
+ fclose(fp);
+ ewk_frame_script_execute(frame, buf);
+ printf("uri_changed() executed %i byte script %s\n", len, scripts[i]);
+ free(buf);
+ }
*/
- if (td->app->mode == ModeInsert || td->app->mode == ModeHints) {
+ if (bd->window->mode == ModeInsert || bd->window->mode == ModeHints) {
Arg a = { .i = ModeNormal };
- set(&a, td->app);
+ set(&a, bd->window);
}
- td->app->manual_focus = EINA_FALSE;
- update_url(uri, td->app);
+ bd->window->manual_focus = EINA_FALSE;
+ update_url(uri, bd->window);
}
void
@@ -169,7 +193,7 @@ webview_document_finished_cb(void *data, Evas_Object *obj, void *event_info)
{
Hist_Item *item;
Buffer_Data *bd = data;
- App_Data *ad = bd->app;
+ App_Data *ad = bd->window->app;
Evas_Object *frame = event_info;
const Ewk_Text_With_Direction *txt = ewk_frame_title_get(frame);
const char *url = ewk_frame_uri_get(frame);
@@ -197,7 +221,7 @@ webview_load_finished_cb(void *data, Evas_Object *obj, void *event_info)
{
/* WebKitWebSettings *settings = webkit_web_view_get_settings(webview); */
Buffer_Data *bd = data;
- App_Data *ad = bd->app;
+ Window_Data *wd = bd->window;
Eina_Bool scripts = 1;
Elm_Web_Frame_Load_Error *frame_error = event_info;
@@ -207,21 +231,21 @@ webview_load_finished_cb(void *data, Evas_Object *obj, void *event_info)
return;
/* g_object_get(settings, "enable-scripts", &scripts, NULL); */
- if (escape_input_on_load && scripts && !ad->manual_focus && !elm_object_focus_get(ad->url)) {
+ if (escape_input_on_load && scripts && !wd->manual_focus && !elm_object_focus_get(wd->url)) {
Arg a = { .i = Silent, .s = strdup("hints.clearFocus();") };
- script(&a, ad);
+ script(&a, wd);
free(a.s);
a.i = ModeNormal;
a.s = NULL;
- set(&a, ad);
+ set(&a, wd);
}
- update_state(ad);
+ update_state(wd);
// userscript_hooks_end(elm_web_uri_get(td->web));
- /*
- FILE *fp = fopen("/home/kyle/.config/evi/userscript/adblockplus/contentScript2.js", "r");
+ Evas_Object *frame = ewk_view_frame_main_get(bd->view);
+ FILE *fp = fopen("/home/kyle/.config/viking/userscript/adblockplus/contentScript2.js", "r");
if (!fp)
printf("error opening file.\n");
fseek(fp, 0L, SEEK_END);
@@ -230,12 +254,9 @@ webview_load_finished_cb(void *data, Evas_Object *obj, void *event_info)
rewind(fp);
fread(buf, len, 1, fp);
fclose(fp);
-
ewk_frame_script_execute(frame, buf);
-
+ printf("load_finished() executed %i byte script\n", len);
free(buf);
- */
-
// elm_object_focus_set(td->web, EINA_TRUE);
}
@@ -294,23 +315,25 @@ download_entry_free_cb(void *data)
void
download_complete_cb(void *data, const char *file, int status)
{
- App_Data *ad = data;
+ Window_Data *wd = data;
+ App_Data *ad = wd->app;
Arg a;
a.i = Info;
a.s = strdup_printf("Download %s finished, status %i", file, status);
- echo(&a, data);
+ echo(&a, wd);
free(a.s);
// ad->active_downloads = eina_list_remove(ad->active_downloads, file);
eina_hash_del(ad->downloads, file, NULL);
- update_state(data);
+ update_state(wd);
}
int
download_progress_cb(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow)
{
- App_Data *ad = data;
+ Window_Data *wd = data;
+ App_Data *ad = wd->app;
void *stat_old;
struct dl *stat = malloc(sizeof(struct dl));
@@ -321,7 +344,7 @@ download_progress_cb(void *data, const char *file, long int dltotal, long int dl
stat_old = eina_hash_modify(ad->downloads, file, (const void *)stat);
free(stat_old);
- update_state(data);
+ update_state(wd);
return 0;
}
@@ -330,8 +353,9 @@ void
webview_download_cb(void *data, Evas_Object *obj, void *event_info)
{
Eina_Bool ret;
- Buffer_Data *td = data;
- App_Data *ad = td->app;
+ Buffer_Data *bd = data;
+ Window_Data *wd = bd->window;
+ App_Data *ad = wd->app;
Ewk_Download *dl = event_info;
char *suggested_name = strdup(strrchr(dl->url, '/'));
@@ -339,14 +363,14 @@ webview_download_cb(void *data, Evas_Object *obj, void *event_info)
char *full_path = strdup_printf("/home/kyle/%s", suggested_name);
ret = ecore_file_download(dl->url, full_path, download_complete_cb,
- download_progress_cb, ad, NULL);
+ download_progress_cb, wd, NULL);
/* if file already exists, ret == NULL */
if (!ret) {
Arg a;
a.i = Info;
a.s = strdup_printf("%s already exists!", suggested_name);
- echo(&a, ad);
+ echo(&a, wd);
free(a.s);
return;
}
@@ -357,15 +381,15 @@ webview_download_cb(void *data, Evas_Object *obj, void *event_info)
// free(full_path);
free(suggested_name);
- update_state(ad);
+ // update_state(ad);
}
void
webview_mousewheel_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Buffer_Data *td = data;
- update_state(td->app);
+ Buffer_Data *bd = data;
+ update_state(bd->window);
}
Eina_Bool
@@ -375,7 +399,8 @@ process_keypress(void *event_info, void *data)
Key key;
// int keyval;
// GdkModifierType irrelevant;
- App_Data *ad = data;
+ Window_Data *wd = data;
+ App_Data *ad = wd->app;
Evas_Event_Key_Down *ev = event_info;
// Get a mask of modifiers that shouldn't be considered for this event.
@@ -388,14 +413,14 @@ process_keypress(void *event_info, void *data)
key = walk->Element;
// if (current->Element.mask == (CLEAN(event->state) & ~irrelevant)
if ((key.mask == 0 || evas_key_modifier_is_set(ev->modifiers, key.mask))
- && (key.modkey == ad->current_modkey
- || (!key.modkey && !ad->current_modkey)
+ && (key.modkey == wd->current_modkey
+ || (!key.modkey && !wd->current_modkey)
|| key.modkey == '*' ) // wildcard
&& !strcmp(key.key, ev->key)
&& key.func)
if (key.func(&key.arg, data)) {
// printf("process_keypress() function for mask = %s modkey = %c key = %s called.\n", key.mask, ad->current_modkey, key.key);
- ad->current_modkey = ad->count = 0;
+ wd->current_modkey = wd->count = 0;
update_state(data);
return TRUE;
}
@@ -411,7 +436,8 @@ webview_keypress_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
// int keyval;
Evas_Event_Key_Down *ev = event_info;
Buffer_Data *td = data;
- App_Data *ad = td->app;
+ Window_Data *wd = td->window;
+ App_Data *ad = wd->app;
// GdkModifierType irrelevant;
/* Get a mask of modifiers that shouldn't be considered for this event.
@@ -419,56 +445,56 @@ webview_keypress_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
// gdk_keymap_translate_keyboard_state(keymap, event->hardware_keycode,
// event->state, event->group, &keyval, NULL, NULL, &irrelevant);
- switch (ad->mode) {
+ switch (wd->mode) {
case ModeNormal:
// if ((CLEAN(event->state) & ~irrelevant) == 0) {
if (IS_ESCAPE(ev)) {
a.i = Info;
a.s = strdup("");
- echo(&a, ad);
- elm_box_clear(ad->event_box);
- evas_object_hide(ad->event_box);
+ echo(&a, wd);
+ elm_box_clear(wd->event_box);
+ evas_object_hide(wd->event_box);
free(a.s);
- } else if (ad->current_modkey == 0 &&
+ } else if (wd->current_modkey == 0 &&
(( strcmp(ev->key, "1") >= 0 && strcmp(ev->key, "9") <= 0)
- || (!strcmp(ev->key, "0") && ad->count))) {
+ || (!strcmp(ev->key, "0") && wd->count))) {
// ad->count = (ad->count ? ad->count * 10 : 0) + (ev->key - "0");
- ad->count = (ad->count ? ad->count * 10 : 0) + atoi(ev->key);
- update_state(ad);
+ wd->count = (wd->count ? wd->count * 10 : 0) + atoi(ev->key);
+ update_state(wd);
return;
- } else if (strchr(ad->modkeys, ev->key[0]) && ad->current_modkey != ev->key[0]) {
- ad->current_modkey = ev->key[0];
+ } else if (strchr(ad->modkeys, ev->key[0]) && wd->current_modkey != ev->key[0]) {
+ wd->current_modkey = ev->key[0];
// ad->current_modkey = strdup(ev->key);
- update_state(ad);
+ update_state(wd);
return;
}
// }
/* keybindings */
- if (process_keypress(event_info, ad) == TRUE) return;
+ if (process_keypress(event_info, wd) == TRUE) return;
break;
case ModeInsert:
if (IS_ESCAPE(ev)) {
a.i = Silent;
a.s = strdup("hints.clearFocus();");
- script(&a, ad);
+ script(&a, wd);
free(a.s);
a.i = ModeNormal;
- set(&a, ad);
+ set(&a, wd);
// ewk_view_input_method_state_set(td->web, FALSE);
return;
}
case ModePassThrough:
if (IS_ESCAPE(ev)) {
- echo(&a, ad);
- set(&a, ad);
+ echo(&a, wd);
+ set(&a, wd);
return;
}
break;
case ModeSendKey:
- echo(&a, ad);
- set(&a, ad);
+ echo(&a, wd);
+ set(&a, wd);
break;
}
}
@@ -495,24 +521,24 @@ webview_hoverlink_cb(void *data, Evas_Object *obj, void *event_info)
char **link = event_info;
// char *markup;
- memset(td->app->rememberedURI, 0, 1024);
+ memset(td->window->rememberedURI, 0, 1024);
if (link && link[0]) {
// markup = g_markup_printf_escaped("<span font=\"%s\">Link: %s</span>", statusfont, link[0]);
// markup = strdup_printf("<font=Monospace font_size=10 color=#FF0>%s", link[0]);
// gtk_label_set_markup(GTK_LABEL(td->app->status_url), markup);
// elm_object_text_set(td->app->status_url, markup);
- update_url(link[0], td->app);
- strcpy(td->app->rememberedURI, link[0]);
+ update_url(link[0], td->window);
+ strcpy(td->window->rememberedURI, link[0]);
// free(markup);
} else
- update_url(uri, td->app);
+ update_url(uri, td->window);
}
void
webview_hoverlink_out_cb(void *data, Evas_Object *obj, void *event_info)
{
Buffer_Data *td = data;
- update_url(elm_web_uri_get(td->web), td->app);
+ update_url(elm_web_uri_get(td->web), td->window);
}
void
@@ -523,14 +549,14 @@ webview_console_cb(void *data, Evas_Object *obj, const char *message, unsigned i
/* Don't change internal mode if the browser doesn't have focus to prevent inconsistent states */
// if (gtk_window_has_toplevel_focus(window)) {
- if (elm_object_focus_get(td->app->win)) {
+ if (elm_object_focus_get(td->window->win)) {
if (!strcmp(message, "hintmode_off") || !strcmp(message, "insertmode_off")) {
a.i = ModeNormal;
- set(&a, td->app);
+ set(&a, td->window);
return;
} else if (!strcmp(message, "insertmode_on")) {
a.i = ModeInsert;
- set(&a, td->app);
+ set(&a, td->window);
return;
}
}
@@ -540,8 +566,9 @@ void
inputbox_activate_cb(void *data, Evas_Object *obj, void *event_info)
{
const char *text;
- App_Data *ad = data;
- uint16_t length = strlen(elm_entry_entry_get(ad->url));
+ Window_Data *wd = data;
+ // App_Data *ad = wd->app;
+ uint16_t length = strlen(elm_entry_entry_get(wd->url));
Arg a;
Eina_Bool forward = FALSE;
@@ -551,20 +578,20 @@ inputbox_activate_cb(void *data, Evas_Object *obj, void *event_info)
complete(&a, data);
if (length == 0)
return;
- text = elm_entry_entry_get(ad->url);
+ text = elm_entry_entry_get(wd->url);
if (length > 1 && text[0] == ':') {
process_line((text + 1), data);
} else if (length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
// webkit_web_view_unmark_text_matches(webview);
- elm_web_text_matches_unmark_all(ad->cur_buf->web);
+ elm_web_text_matches_unmark_all(wd->cur_buf->web);
// webkit_web_view_mark_text_matches(webview, &text[1], FALSE, 0);
// webkit_web_view_set_highlight_text_matches(webview, TRUE);
- elm_web_text_matches_mark(ad->cur_buf->web, &text[1], EINA_FALSE, EINA_TRUE, 0);
+ elm_web_text_matches_mark(wd->cur_buf->web, &text[1], EINA_FALSE, EINA_TRUE, 0);
- ad->count = 0;
- ad->search_direction = forward;
- ad->search_handle = strdup(&text[1]);
+ wd->count = 0;
+ wd->search_direction = forward;
+ wd->search_handle = strdup(&text[1]);
} else if (text[0] == '.' || text[0] == ',' || text[0] == ';') {
a.i = Silent;
a.s = strdup("hints.fire();");
@@ -573,37 +600,38 @@ inputbox_activate_cb(void *data, Evas_Object *obj, void *event_info)
update_state(data);
} else
return;
- if (!ad->echo_active)
+ if (!wd->echo_active)
// gtk_entry_set_text(entry, "");
- elm_entry_entry_set(ad->url, "");
+ elm_entry_entry_set(wd->url, "");
// gtk_widget_grab_focus(GTK_WIDGET(webview));
/* process_line above may have deleted the tab, check if its still around */
- if (ad->cur_buf->web)
- elm_object_focus_set(ad->cur_buf->web, EINA_TRUE);
+ if (wd->cur_buf->web)
+ elm_object_focus_set(wd->cur_buf->web, EINA_TRUE);
}
static Eina_Bool
commandhistoryfetch(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *wd = data;
+ // App_Data *ad = wd->app;
char *command;
- const int length = eina_list_count(ad->commandhistory);
+ const int length = eina_list_count(wd->commandhistory);
if (length > 0) {
if (arg->i == DirectionPrev) {
- ad->commandpointer = (length + ad->commandpointer - 1) % length;
+ wd->commandpointer = (length + wd->commandpointer - 1) % length;
} else {
- ad->commandpointer = (length + ad->commandpointer + 1) % length;
+ wd->commandpointer = (length + wd->commandpointer + 1) % length;
}
- command = eina_list_nth(ad->commandhistory, ad->commandpointer);
+ command = eina_list_nth(wd->commandhistory, wd->commandpointer);
// gtk_entry_set_text(GTK_ENTRY(inputbox), g_strconcat(":", command, NULL));
// gtk_editable_set_position(GTK_EDITABLE(inputbox), -1);
command = strdup_printf(":%s", command);
- elm_entry_entry_set(ad->url, command);
+ elm_entry_entry_set(wd->url, command);
free(command);
- elm_entry_cursor_line_end_set(ad->url);
+ elm_entry_cursor_line_end_set(wd->url);
return TRUE;
}
@@ -616,9 +644,10 @@ inputbox_keypress_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
Arg a;
int numval;
Evas_Event_Key_Down *ev = event_info;
- App_Data *ad = data;
+ Window_Data *wd = data;
+ // App_Data *ad = wd->app;
- if (ad->mode == ModeHints) {
+ if (wd->mode == ModeHints) {
// if (event->keyval == GDK_ISO_Left_Tab) {
if (!strcmp(ev->keyname, "Tab") && evas_key_modifier_is_set(ev->modifiers, "Shift")) {
a.i = Silent;
@@ -651,7 +680,7 @@ inputbox_keypress_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
a.i = HideCompletion;
complete(&a, data);
a.i = ModeNormal;
- ad->commandpointer = 0;
+ wd->commandpointer = 0;
set(&a, data);
return;
}
@@ -706,7 +735,7 @@ inputbox_keypress_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
}
*/
- if (ad->mode == ModeHints) {
+ if (wd->mode == ModeHints) {
#if 0
if ((CLEAN(event->state) & GDK_SHIFT_MASK) &&
(CLEAN(event->state) & GDK_CONTROL_MASK) &&
@@ -723,11 +752,11 @@ inputbox_keypress_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
// numval = g_unichar_digit_value((gunichar) gdk_keyval_to_unicode(event->keyval));
numval = atoi(ev->key);
- if ((numval >= 1 && numval <= 9) || (numval == 0 && ad->count)) {
+ if ((numval >= 1 && numval <= 9) || (numval == 0 && wd->count)) {
/* allow a zero as non-first number */
- ad->count = (ad->count ? ad->count * 10 : 0) + numval;
+ wd->count = (wd->count ? wd->count * 10 : 0) + numval;
a.i = Silent;
- a.s = strdup_printf("hints.updateHints(%d);", ad->count);
+ a.s = strdup_printf("hints.updateHints(%d);", wd->count);
script(&a, data);
free(a.s);
update_state(data);
@@ -741,25 +770,25 @@ inputmethod_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
const char *value;
Eina_Bool *enabled = event_info;
- Buffer_Data *td = data;
- App_Data *ad = td->app;
- Evas_Object *frame = ewk_view_frame_main_get(td->view);
+ Buffer_Data *bd = data;
+ Window_Data *wd = bd->window;
+ Evas_Object *frame = ewk_view_frame_main_get(bd->view);
- if (ad->mode == ModeNormal && enabled) {
+ if (wd->mode == ModeNormal && enabled) {
Arg a = { .i = ModeInsert };
- set(&a, ad);
- ad->manual_focus = TRUE;
- } else if (ad->mode == ModeInsert && !enabled) {
+ set(&a, wd);
+ wd->manual_focus = TRUE;
+ } else if (wd->mode == ModeInsert && !enabled) {
Arg a = { .i = ModeNormal };
- set(&a, ad);
+ set(&a, wd);
} else {
// char *value = NULL, *message = NULL;
// jsapi_evaluate_script("window.getSelection().focusNode", &value, &message, ad);
value = ewk_frame_script_execute(frame, "window.getSelection().focusNode");
if (value && !strcmp(value, "[object HTMLFormElement]")) {
Arg a = { .i = ModeInsert, .s = NULL };
- set(&a, ad);
- ad->manual_focus = TRUE;
+ set(&a, wd);
+ wd->manual_focus = TRUE;
}
// free(value);
eina_stringshare_del(value);
@@ -849,17 +878,17 @@ notify_event_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
void
inputbox_keyrelease_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Arg a;
- App_Data *ad = data;
- // guint16 length = gtk_entry_get_text_length(entry);
- uint16_t length = strlen(elm_entry_entry_get(ad->url));
-
- if (!length) {
- a.i = HideCompletion;
- complete(&a, data);
- a.i = ModeNormal;
- set(&a, data);
- }
+ Arg a;
+ Window_Data *wd = data;
+ // guint16 length = gtk_entry_get_text_length(entry);
+ uint16_t length = strlen(elm_entry_entry_get(wd->url));
+
+ if (!length) {
+ a.i = HideCompletion;
+ complete(&a, data);
+ a.i = ModeNormal;
+ set(&a, data);
+ }
}
/* used for incremental search */
@@ -867,8 +896,8 @@ void
inputbox_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
Arg a;
- App_Data *ad = data;
- const char *text = elm_entry_entry_get(ad->url);
+ Window_Data *wd = data;
+ const char *text = elm_entry_entry_get(wd->url);
uint16_t length = strlen(text);
Eina_Bool forward = FALSE;
@@ -881,15 +910,15 @@ inputbox_changed_cb(void *data, Evas_Object *obj, void *event_info)
*/
// if (gtk_widget_is_focus(GTK_WIDGET(entry)) && length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
- if (elm_object_focus_get(ad->url) && length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
+ if (elm_object_focus_get(wd->url) && length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
// webkit_web_view_unmark_text_matches(webview);
- elm_web_text_matches_unmark_all(ad->cur_buf->web);
+ elm_web_text_matches_unmark_all(wd->cur_buf->web);
// webkit_web_view_search_text(webview, &text[1], searchoptions & CaseSensitive, forward, searchoptions & Wrapping);
- elm_web_text_search(ad->cur_buf->web, &text[1], EINA_TRUE, forward, EINA_FALSE);
+ elm_web_text_search(wd->cur_buf->web, &text[1], EINA_TRUE, forward, EINA_FALSE);
return;
// } else if (gtk_widget_is_focus(GTK_WIDGET(entry)) && length >= 1 &&
- } else if (elm_object_focus_get(ad->url) && length >= 1 &&
+ } else if (elm_object_focus_get(wd->url) && length >= 1 &&
(text[0] == '.' || text[0] == ',' || text[0] == ';')) {
a.i = Silent;
switch (text[0]) {
@@ -937,20 +966,20 @@ inputbox_changed_cb(void *data, Evas_Object *obj, void *event_info)
}
break;
}
- ad->count = 0;
+ wd->count = 0;
if (a.s) {
script(&a, data);
free(a.s);
}
return;
- } else if (length == 0 && ad->followTarget[0]) {
- ad->mode = ModeNormal;
+ } else if (length == 0 && wd->followTarget[0]) {
+ wd->mode = ModeNormal;
a.i = Silent;
a.s = strdup("hints.clearHints();");
script(&a, data);
free(a.s);
- ad->count = 0;
+ wd->count = 0;
update_state(data);
}
}
@@ -959,7 +988,7 @@ void
populate_visited_links_cb(void *data, Evas_Object *obj, void *event_info)
{
Buffer_Data *bd = data;
- App_Data *ad = bd->app;
+ App_Data *ad = bd->window->app;
void *hash_data;
Eina_Iterator *it = eina_hash_iterator_tuple_new(hist_items_hash_get(ad->history));
diff --git a/src/commands.c b/src/commands.c
@@ -73,7 +73,7 @@ complete(const Arg *arg, void *data)
static char **suggestions;
static Evas_Object **widgets;
static int n = 0, m, current = -1;
- App_Data *ad = data;
+ Window_Data *ad = data;
str = elm_entry_entry_get(ad->url);
// str = (char*)gtk_entry_get_text(GTK_ENTRY(inputbox));
@@ -278,7 +278,7 @@ complete(const Arg *arg, void *data)
Eina_Bool
descend(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
// char *source = (char*)webkit_web_view_get_uri(webview), *p = &source[0], *new;
const char *source = elm_web_uri_get(ad->cur_buf->web);
const char *p = &source[0];
@@ -324,7 +324,7 @@ input(const Arg *arg, void *data)
const char *url;
// int index = Info;
Arg a;
- App_Data *ad = data;
+ Window_Data *ad = data;
ad->count = 0;
/* if inputbox hidden, show it again */
@@ -421,7 +421,7 @@ input(const Arg *arg, void *data)
Eina_Bool
navigate(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
if (arg->i & NavigationForwardBack)
// webkit_web_view_go_back_or_forward(webview, (arg->i == NavigationBack ? -1 : 1) * (count ? count : 1));
elm_web_navigate(ad->cur_buf->web, (arg->i == NavigationBack ? -1 : 1) * (ad->count ? ad->count : 1));
@@ -437,7 +437,7 @@ navigate(const Arg *arg, void *data)
Eina_Bool
number(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
// const char *source = webkit_web_view_get_uri(webview);
const char *source = elm_web_uri_get(ad->cur_buf->web);
char *uri, *p, *new;
@@ -476,7 +476,7 @@ open_arg(const Arg *arg, void *data)
Arg a = { .i = NavigationReload };
int len;
char *search_uri, *search_term;
- App_Data *ad = data;
+ Window_Data *ad = data;
/*
if (embed) {
@@ -561,7 +561,7 @@ open_arg(const Arg *arg, void *data)
Eina_Bool
open_remembered(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Arg a = {arg->i, ad->rememberedURI};
@@ -634,7 +634,7 @@ paste(const Arg *arg, void *data) {
Eina_Bool
tab_quit(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
/* TODO: save the session information for revival later */
evas_object_del(ad->cur_buf->web);
@@ -644,7 +644,8 @@ tab_quit(const Arg *arg, void *data)
Eina_Bool
quit(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *wd = data;
+ App_Data *ad = wd->app;
ad->exiting = EINA_TRUE;
elm_shutdown();
@@ -654,7 +655,7 @@ quit(const Arg *arg, void *data)
Eina_Bool
revive(const Arg *arg, void *data)
{
- // App_Data *ad = data;
+ // Window_Data *ad = data;
return EINA_FALSE;
}
@@ -672,7 +673,7 @@ print_frame(const Arg *arg, void *data)
Eina_Bool
search(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
ad->count = ad->count ? ad->count : 1;
Eina_Bool success, direction = arg->i & DirectionPrev;
@@ -720,7 +721,7 @@ search(const Arg *arg, void *data)
Eina_Bool
set(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Arg a = { .i = Info | NoAutoHide };
switch (arg->i) {
@@ -804,7 +805,7 @@ script(const Arg *arg, void *data)
Arg a;
// WebKitNetworkRequest *request;
// WebKitDownload *download;
- App_Data *ad = data;
+ Window_Data *ad = data;
Evas_Object *frame = ewk_view_frame_main_get(ad->cur_buf->view);
if (!arg->s) {
@@ -892,7 +893,7 @@ scroll(const Arg *arg, void *data)
int x, y, w, h, page_w, page_h;
float val;
Eina_Bool horizontal = EINA_FALSE;
- App_Data *ad = data;
+ Window_Data *ad = data;
Evas_Object *frame = ewk_view_frame_main_get(ad->cur_buf->view);
ewk_frame_visible_content_geometry_get(frame, EINA_FALSE, &x, &y, &page_w, &page_h);
@@ -940,15 +941,16 @@ scroll(const Arg *arg, void *data)
Eina_Bool
zoom(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *wd = data;
+ App_Data *ad = wd->app;
// webkit_web_view_set_full_content_zoom(webview, (arg->i & ZoomFullContent) > 0);
// webkit_web_view_set_zoom_level(ad->current_tab->web, (arg->i & ZoomOut) ?
- elm_web_zoom_set(ad->cur_buf->web, (arg->i & ZoomOut) ?
+ elm_web_zoom_set(wd->cur_buf->web, (arg->i & ZoomOut) ?
// webkit_web_view_get_zoom_level(webview) +
- elm_web_zoom_get(ad->cur_buf->web) +
- (((float)(ad->count ? ad->count : 1)) * (arg->i & (1 << 1) ? 1.0 : -1.0) * ad->zoomstep) :
- (ad->count ? (float)ad->count / 100.0 : 1.0));
+ elm_web_zoom_get(wd->cur_buf->web) +
+ (((float)(wd->count ? wd->count : 1)) * (arg->i & (1 << 1) ? 1.0 : -1.0) * ad->zoomstep) :
+ (wd->count ? (float)wd->count / 100.0 : 1.0));
return TRUE;
}
@@ -1034,7 +1036,7 @@ Eina_Bool
focus_input(const Arg *arg, void *data)
{
static Arg a;
- App_Data *ad = data;
+ Window_Data *ad = data;
a.s = strdup("hints.focusInput();");
a.i = Silent;
@@ -1066,13 +1068,13 @@ browser_settings(const Arg *arg, void *data) {
Eina_Bool
proxy(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Buffer_Data *bd = ad->cur_buf;
if (bd->proxy_enabled) {
printf("proxy off\n");
// ewk_network_proxy_uri_set(NULL);
- g_object_set(ad->soup_session, "proxy-uri", NULL, NULL);
+ g_object_set(ad->app->soup_session, "proxy-uri", NULL, NULL);
bd->proxy_enabled = EINA_FALSE;
update_url(elm_web_uri_get(bd->web), data);
} else if (enable_proxy(ad->cur_buf)) {
@@ -1205,7 +1207,7 @@ search_tag(const Arg * a, void *data)
#if 0
FILE *f;
char *filename;
- App_Data *ad = data;
+ Window_Data *ad = data;
const char *tag = a->s;
char s[BUFFERSIZE], foundtag[40], url[BUFFERSIZE];
int t, i, intag, k;
@@ -1273,7 +1275,7 @@ Eina_Bool
list(const Arg *arg, void *data)
{
char *url, *count_str;
- App_Data *ad = data;
+ Window_Data *ad = data;
Eina_List *l;
Buffer_Data *td;
@@ -1365,7 +1367,7 @@ list(const Arg *arg, void *data)
Eina_Bool
switch_buffer(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Eina_List *l;
Buffer_Data *td;
// int arg_count = atoi(arg->s);
@@ -1390,7 +1392,7 @@ switch_buffer(const Arg *arg, void *data)
Eina_Bool
inspector(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Buffer_Data *bd = ad->cur_buf;
if (!bd->inspector_enabled) {
@@ -1412,7 +1414,7 @@ inspector(const Arg *arg, void *data)
Eina_Bool
toggle_history(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Buffer_Data *bd = ad->cur_buf;
if (bd->history_enabled) {
@@ -1429,7 +1431,7 @@ toggle_history(const Arg *arg, void *data)
Eina_Bool
toggle_cookies(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
Buffer_Data *bd = ad->cur_buf;
if (bd->cookies_enabled) {
@@ -1446,3 +1448,19 @@ toggle_cookies(const Arg *arg, void *data)
return EINA_TRUE;
}
+Eina_Bool
+new_window(const Arg *arg, void *data)
+{
+ Window_Data *wd = data;
+ Window_Data *new = window_add(wd->app);
+
+ Buffer_Data *bd = buffer_add(new);
+ buffer_current_set(bd);
+ elm_web_uri_set(bd->web, config_home_page_get(wd->app->config));
+
+ evas_object_resize(new->win, 480, 640);
+ evas_object_show(new->win);
+
+ return EINA_TRUE;
+}
+
diff --git a/src/commands.h b/src/commands.h
@@ -30,6 +30,7 @@ Eina_Bool inspector(const Arg *, void *);
Eina_Bool proxy(const Arg *, void *);
Eina_Bool toggle_history(const Arg *, void *);
Eina_Bool toggle_cookies(const Arg *, void *);
+Eina_Bool new_window(const Arg *arg, void *data);
// static Eina_Bool fake_key_event(const Arg *, void *);
Eina_Bool process_set_line(char *line);
diff --git a/src/keymap.h b/src/keymap.h
@@ -15,126 +15,127 @@
Note: GDK_VoidSymbol is a wildcard so it matches on every modkey
*/
static Key keys[] = {
- /* modmask, modkey, key, function, argument */
- { 0, 'q', "1", quickmark, { .s = "1" } },
- { 0, 'q', "2", quickmark, { .s = "2" } },
- { 0, 'q', "3", quickmark, { .s = "3" } },
- { 0, 'q', "4", quickmark, { .s = "4" } },
- { 0, 'q', "5", quickmark, { .s = "5" } },
- { 0, 'q', "6", quickmark, { .s = "6" } },
- { 0, 'q', "7", quickmark, { .s = "7" } },
- { 0, 'q', "8", quickmark, { .s = "8" } },
- { 0, 'q', "9", quickmark, { .s = "9" } },
- { "Control", 0, "h", toggle_history, { 0 } },
- { "Control", 0, "c", toggle_cookies, { 0 } },
- { 0, 0, "0", scroll, {ScrollJumpTo | DirectionLeft} },
- { 0, 0, "$", scroll, {ScrollJumpTo | DirectionRight} },
- { 0, 'g', "g", scroll, {ScrollJumpTo | DirectionTop} },
- { 0, 0, "G", scroll, {ScrollJumpTo | DirectionBottom} },
- { 0, 0, "h", scroll, {ScrollMove | DirectionLeft | UnitLine} },
- { 0, 0, "j", scroll, {ScrollMove | DirectionBottom | UnitLine} },
- { 0, 0, "k", scroll, {ScrollMove | DirectionTop | UnitLine} },
- { 0, 0, "l", scroll, {ScrollMove | DirectionRight | UnitLine} },
- { 0, 0, " ", scroll, {ScrollMove | DirectionBottom | UnitPage} },
- { "Shift", 0, " ", scroll, {ScrollMove | DirectionTop | UnitPage} },
- { "Control", 0, "b", scroll, {ScrollMove | DirectionTop | UnitPage} },
- { "Control", 0, "f", scroll, {ScrollMove | DirectionBottom | UnitPage} },
- { "Control", 0, "d", scroll, {ScrollMove | DirectionBottom | UnitBuffer} },
- { "Control", 0, "u", scroll, {ScrollMove | DirectionTop | UnitBuffer} },
- { "Control", 0, "e", scroll, {ScrollMove | DirectionBottom | UnitLine} },
- { "Control", 0, "y", scroll, {ScrollMove | DirectionTop | UnitLine} },
-/*
- { 0, "g", "t", fake_key_event, { .s = "l", .i = ShiftMask + ControlMask } },
- { 0, "g", "T", fake_key_event, { .s = "h", .i = ShiftMask + ControlMask } },
- { 0, "g", "1", fake_key_event, { .s = "1", .i = ControlMask } },
- { 0, "g", "2", fake_key_event, { .s = "2", .i = ControlMask } },
- { 0, "g", "3", fake_key_event, { .s = "3", .i = ControlMask } },
- { 0, "g", "4", fake_key_event, { .s = "4", .i = ControlMask } },
- { 0, "g", "5", fake_key_event, { .s = "5", .i = ControlMask } },
- { 0, "g", "6", fake_key_event, { .s = "6", .i = ControlMask } },
- { 0, "g", "7", fake_key_event, { .s = "7", .i = ControlMask } },
- { 0, "g", "8", fake_key_event, { .s = "8", .i = ControlMask } },
- { 0, "g", "9", fake_key_event, { .s = "9", .i = ControlMask } },
- { 0, "g", "0", fake_key_event, { .s = "0", .i = ControlMask } },
-*/
- { "Alt", 0, "Left", navigate, {NavigationBack} },
- { "Alt", 0, "Right",navigate, {NavigationForward} },
- { "Control", 0, "i", navigate, {NavigationBack} },
- { "Control", 0, "o", navigate, {NavigationForward} },
- { 0, 0, "H", navigate, {NavigationBack} },
- { 0, 0, "L", navigate, {NavigationForward} },
- { 0, 0, "r", navigate, {NavigationReload} },
- { 0, 0, "R", navigate, {NavigationForceReload} },
- { 0, 0, "c", navigate, {NavigationCancel} },
-
- { 0, 0, "plus", zoom, {ZoomIn | ZoomText} },
- { 0, 0, "minus", zoom, {ZoomOut | ZoomText} },
-// { 0, 0, GDK_KP_Add, zoom, {ZoomIn | ZoomText} },
-// { 0, 0, GDK_KP_Subtract, zoom, {ZoomOut | ZoomText} },
- { 0, 'z', "i", zoom, {ZoomIn | ZoomText} },
- { 0, 'z', "o", zoom, {ZoomOut | ZoomText} },
- { 0, 'z', "z", zoom, {ZoomReset | ZoomText} },
- { 0, 'z', "I", zoom, {ZoomIn | ZoomFullContent} },
- { 0, 'z', "O", zoom, {ZoomOut | ZoomFullContent} },
- { 0, 'z', "Z", zoom, {ZoomReset | ZoomFullContent} },
-
- { 0, 0, "y", yank, {SourceURL | ClipboardPrimary | ClipboardGTK} },
- { 0, 0, "Y", yank, {SourceSelection| ClipboardPrimary | ClipboardGTK} },
-
- { 0, 'g', "u", descend, {NthSubdir} },
- { 0, 'g', "U", descend, {Rootdir} },
-
- { 0, 'g', "h", open_arg, {TargetCurrent, DEFAULT_URL} },
- { 0, 'g', "H", open_arg, {TargetNew, DEFAULT_URL} },
-
- { "Control", 0, "p", proxy, {0} },
- { 0, 0, "p", paste, {TargetCurrent | ClipboardPrimary | ClipboardGTK} },
- { 0, 0, "P", paste, {TargetNew | ClipboardPrimary | ClipboardGTK} },
-
- { "Control", 0, "a", number, {Increment} },
- { "Control", 0, "x", number, {Decrement} },
-
- { 0, 0, "n", search, {DirectionNext | CaseInsensitive | Wrapping} },
- { 0, 0, "N", search, {DirectionPrev | CaseInsensitive | Wrapping} },
-
- { 0, 0, "colon", input, {.s = ":" } },
- { 0, 0, "o", input, {.s = ":open "} },
- { 0, 0, "O", input, {.s = ":open ", .i = InsertCurrentURL} },
- { 0, 0, "t", input, {.s = ":tabopen "} },
- { 0, 0, "T", input, {.s = ":tabopen ", .i = InsertCurrentURL} },
- { 0, 0, "slash", input, {.s = "/"} },
-// { 0, 0, GDK_KP_Divide, input, {.s = "/"} },
- { 0, 0, "question", input, {.s = "?"} },
-
- { 0, 0, "period", input, {.s = "."} },
- { 0, 0, "comma", input, {.s = ","} },
- { 0, ';', "i", input, {.s = ";i"} },
- { 0, ';', "s", input, {.s = ";s"} },
- { 0, ';', "y", input, {.s = ";y"} },
- { 0, ';', "o", input, {.s = ";o"} },
- { 0, ';', "t", input, {.s = ";t"} },
- { 0, ';', "w", input, {.s = ";w"} },
- { 0, ';', "I", input, {.s = ";I"} },
- { 0, ';', "O", input, {.s = ";O"} },
- { 0, ';', "T", input, {.s = ";T"} },
- { 0, ';', "W", input, {.s = ";W"} },
-
- { 0, '*', "Escape", set, {ModeNormal} },
- { "Control", '*', "bracketleft", set, {ModeNormal} },
- { "Control", 0, "z", set, {ModePassThrough} },
- { "Control", 0, "v", set, {ModeSendKey} },
- { 0, 0, "f", input, {.s = "."} },
- { 0, 0, "F", input, {.s = ","} },
-
- { 0, 'g', "i", focus_input,{} },
- { 0, 0, "u", revive, {} },
-
- { 0, 0, "x", tab_quit, {0} },
- // { 0, 0, "X", revive_last_tab, {0} },
+ /* modmask, modkey, key, function, argument */
+ { 0, 'q', "1", quickmark, { .s = "1" } },
+ { 0, 'q', "2", quickmark, { .s = "2" } },
+ { 0, 'q', "3", quickmark, { .s = "3" } },
+ { 0, 'q', "4", quickmark, { .s = "4" } },
+ { 0, 'q', "5", quickmark, { .s = "5" } },
+ { 0, 'q', "6", quickmark, { .s = "6" } },
+ { 0, 'q', "7", quickmark, { .s = "7" } },
+ { 0, 'q', "8", quickmark, { .s = "8" } },
+ { 0, 'q', "9", quickmark, { .s = "9" } },
+ { "Control", 0, "h", toggle_history, { 0 } },
+ { "Control", 0, "c", toggle_cookies, { 0 } },
+ { 0, 0, "0", scroll, {ScrollJumpTo | DirectionLeft} },
+ { 0, 0, "$", scroll, {ScrollJumpTo | DirectionRight} },
+ { 0, 'g', "g", scroll, {ScrollJumpTo | DirectionTop} },
+ { 0, 0, "G", scroll, {ScrollJumpTo | DirectionBottom} },
+ { 0, 0, "h", scroll, {ScrollMove | DirectionLeft | UnitLine} },
+ { 0, 0, "j", scroll, {ScrollMove | DirectionBottom | UnitLine} },
+ { 0, 0, "k", scroll, {ScrollMove | DirectionTop | UnitLine} },
+ { 0, 0, "l", scroll, {ScrollMove | DirectionRight | UnitLine} },
+ { 0, 0, " ", scroll, {ScrollMove | DirectionBottom | UnitPage} },
+ { "Shift", 0, " ", scroll, {ScrollMove | DirectionTop | UnitPage} },
+ { "Control", 0, "b", scroll, {ScrollMove | DirectionTop | UnitPage} },
+ { "Control", 0, "f", scroll, {ScrollMove | DirectionBottom | UnitPage} },
+ { "Control", 0, "d", scroll, {ScrollMove | DirectionBottom | UnitBuffer} },
+ { "Control", 0, "u", scroll, {ScrollMove | DirectionTop | UnitBuffer} },
+ { "Control", 0, "e", scroll, {ScrollMove | DirectionBottom | UnitLine} },
+ { "Control", 0, "y", scroll, {ScrollMove | DirectionTop | UnitLine} },
+ /*
+ { 0, "g", "t", fake_key_event, { .s = "l", .i = ShiftMask + ControlMask } },
+ { 0, "g", "T", fake_key_event, { .s = "h", .i = ShiftMask + ControlMask } },
+ { 0, "g", "1", fake_key_event, { .s = "1", .i = ControlMask } },
+ { 0, "g", "2", fake_key_event, { .s = "2", .i = ControlMask } },
+ { 0, "g", "3", fake_key_event, { .s = "3", .i = ControlMask } },
+ { 0, "g", "4", fake_key_event, { .s = "4", .i = ControlMask } },
+ { 0, "g", "5", fake_key_event, { .s = "5", .i = ControlMask } },
+ { 0, "g", "6", fake_key_event, { .s = "6", .i = ControlMask } },
+ { 0, "g", "7", fake_key_event, { .s = "7", .i = ControlMask } },
+ { 0, "g", "8", fake_key_event, { .s = "8", .i = ControlMask } },
+ { 0, "g", "9", fake_key_event, { .s = "9", .i = ControlMask } },
+ { 0, "g", "0", fake_key_event, { .s = "0", .i = ControlMask } },
+ */
+ { "Alt", 0, "Left", navigate, {NavigationBack} },
+ { "Alt", 0, "Right",navigate, {NavigationForward} },
+ { "Control", 0, "i", navigate, {NavigationBack} },
+ { "Control", 0, "o", navigate, {NavigationForward} },
+ { 0, 0, "H", navigate, {NavigationBack} },
+ { 0, 0, "L", navigate, {NavigationForward} },
+ { 0, 0, "r", navigate, {NavigationReload} },
+ { 0, 0, "R", navigate, {NavigationForceReload} },
+ { 0, 0, "c", navigate, {NavigationCancel} },
+
+ { 0, 0, "plus", zoom, {ZoomIn | ZoomText} },
+ { 0, 0, "minus", zoom, {ZoomOut | ZoomText} },
+ // { 0, 0, GDK_KP_Add, zoom, {ZoomIn | ZoomText} },
+ // { 0, 0, GDK_KP_Subtract, zoom, {ZoomOut | ZoomText} },
+ { 0, 'z', "i", zoom, {ZoomIn | ZoomText} },
+ { 0, 'z', "o", zoom, {ZoomOut | ZoomText} },
+ { 0, 'z', "z", zoom, {ZoomReset | ZoomText} },
+ { 0, 'z', "I", zoom, {ZoomIn | ZoomFullContent} },
+ { 0, 'z', "O", zoom, {ZoomOut | ZoomFullContent} },
+ { 0, 'z', "Z", zoom, {ZoomReset | ZoomFullContent} },
+
+ { 0, 0, "y", yank, {SourceURL | ClipboardPrimary | ClipboardGTK} },
+ { 0, 0, "Y", yank, {SourceSelection| ClipboardPrimary | ClipboardGTK} },
+
+ { 0, 'g', "u", descend, {NthSubdir} },
+ { 0, 'g', "U", descend, {Rootdir} },
+
+ { 0, 'g', "h", open_arg, {TargetCurrent, DEFAULT_URL} },
+ { 0, 'g', "H", open_arg, {TargetNew, DEFAULT_URL} },
+
+ { "Control", 0, "p", proxy, {0} },
+ { 0, 0, "p", paste, {TargetCurrent | ClipboardPrimary | ClipboardGTK} },
+ { 0, 0, "P", paste, {TargetNew | ClipboardPrimary | ClipboardGTK} },
+
+ { "Control", 0, "a", number, {Increment} },
+ { "Control", 0, "x", number, {Decrement} },
+
+ { 0, 0, "n", search, {DirectionNext | CaseInsensitive | Wrapping} },
+ { 0, 0, "N", search, {DirectionPrev | CaseInsensitive | Wrapping} },
+
+ { 0, 0, "colon", input, {.s = ":" } },
+ { 0, 0, "o", input, {.s = ":open "} },
+ { 0, 0, "O", input, {.s = ":open ", .i = InsertCurrentURL} },
+ { 0, 0, "t", input, {.s = ":tabopen "} },
+ { 0, 0, "T", input, {.s = ":tabopen ", .i = InsertCurrentURL} },
+ { 0, 0, "slash", input, {.s = "/"} },
+ // { 0, 0, GDK_KP_Divide, input, {.s = "/"} },
+ { 0, 0, "question", input, {.s = "?"} },
+
+ { 0, 0, "period", input, {.s = "."} },
+ { 0, 0, "comma", input, {.s = ","} },
+ { 0, ';', "i", input, {.s = ";i"} },
+ { 0, ';', "s", input, {.s = ";s"} },
+ { 0, ';', "y", input, {.s = ";y"} },
+ { 0, ';', "o", input, {.s = ";o"} },
+ { 0, ';', "t", input, {.s = ";t"} },
+ { 0, ';', "w", input, {.s = ";w"} },
+ { 0, ';', "I", input, {.s = ";I"} },
+ { 0, ';', "O", input, {.s = ";O"} },
+ { 0, ';', "T", input, {.s = ";T"} },
+ { 0, ';', "W", input, {.s = ";W"} },
+
+ { 0, '*', "Escape", set, {ModeNormal} },
+ { "Control", '*', "bracketleft", set, {ModeNormal} },
+ { "Control", 0, "z", set, {ModePassThrough} },
+ { "Control", 0, "v", set, {ModeSendKey} },
+ { 0, 0, "f", input, {.s = "."} },
+ { 0, 0, "F", input, {.s = ","} },
+
+ { 0, 'g', "i", focus_input,{} },
+ { 0, 0, "u", revive, {} },
+
+ { 0, 0, "x", tab_quit, {0} },
+ { 0, 0, "w", new_window, {0} },
+ // { 0, 0, "X", revive_last_tab, {0} },
{ 0, 0, "b", switch_buffer, {0}},
{ 0, 0, "i", inspector, {0} },
/* leave this last line as last */
- { 0, 0, 0, 0, {0} },
+ { 0, 0, 0, 0, {0} },
};
diff --git a/src/main.c b/src/main.c
@@ -52,7 +52,8 @@ enable_proxy(Buffer_Data *bd)
strdup(proxy_uri) : strdup_printf("http://%s", proxy_uri);
soup_uri = soup_uri_new(new);
- g_object_set(bd->app->soup_session, "proxy-uri", soup_uri, NULL);
+ /* really wish there was per-view proxy support in webkit */
+ g_object_set(bd->window->app->soup_session, "proxy-uri", soup_uri, NULL);
printf("success! (%s)\n", new);
bd->proxy_enabled = EINA_TRUE;
@@ -85,33 +86,34 @@ ascii_bar(int total, int state, char *string)
void
update_state(void *data)
{
- // char *markup;
- App_Data *ad = data;
- Evas_Object *view = ad->cur_buf->view;
+ // char *markup;
+ Window_Data *wd = data;
+ App_Data *ad = wd->app;
+ Evas_Object *view = wd->cur_buf->view;
Evas_Object *frame = ewk_view_frame_main_get(view);
int download_count = eina_hash_population(ad->downloads);
- // GString *status = g_string_new("");
+ // GString *status = g_string_new("");
char status[512] = "";
- /* construct the status line */
+ /* construct the status line */
strcat(status, "<font=Monospace font_size=12 color=#FFF backing=on backing_color=#000>");
/* count, modkey and input buffer */
// g_string_append_printf(status, "%.0d", count);
- char *count_formatted = strdup_printf("%.0d", ad->count);
+ char *count_formatted = strdup_printf("%.0d", wd->count);
strcat(status, count_formatted);
free(count_formatted);
- // if (ad->current_modkey) g_string_append_c(status, ad->current_modkey);
- if (ad->current_modkey) strcat(status, &ad->current_modkey);
+ // if (ad->current_modkey) g_string_append_c(status, ad->current_modkey);
+ if (wd->current_modkey) strcat(status, &wd->current_modkey);
- if (download_count) {
+ if (download_count) {
char *download_status = strdup_printf(" %d DL%s", download_count,
- (download_count == 1) ? "" : "s");
- strcat(status, download_status);
+ (download_count == 1) ? "" : "s");
+ strcat(status, download_status);
free(download_status);
- }
+ }
/* the progressbar */
int progress = -1;
@@ -148,7 +150,7 @@ update_state(void *data)
}
/* put a notification if we are zoomed */
- double zoom = elm_web_zoom_get(ad->cur_buf->web);
+ double zoom = elm_web_zoom_get(wd->cur_buf->web);
if (zoom != 1) {
char *zoom_str = strdup_printf(" %0.2lfx", zoom);
strcat(status, zoom_str);
@@ -174,13 +176,13 @@ update_state(void *data)
free(percent_scrolled);
}
- elm_object_text_set(ad->status_state, status);
+ elm_object_text_set(wd->status_state, status);
int state_width, window_width;
- evas_object_geometry_get(ad->status_state, NULL, NULL, &state_width, NULL);
- evas_object_geometry_get(ad->win, NULL, NULL, &window_width, NULL);
+ evas_object_geometry_get(wd->status_state, NULL, NULL, &state_width, NULL);
+ evas_object_geometry_get(wd->win, NULL, NULL, &window_width, NULL);
- elm_label_wrap_width_set(ad->status_url, window_width - state_width);
+ elm_label_wrap_width_set(wd->status_url, window_width - state_width);
// update_url(elm_web_uri_get(ad->current_web), data);
// elm_box_recalculate(ad->status_bar);
@@ -214,7 +216,7 @@ update_url(const char *uri, void *data)
char before[] = " [";
char after[] = "]";
char url_buf[1024] = "";
- App_Data *ad = data;
+ Window_Data *ad = data;
Buffer_Data *bd = ad->cur_buf;
if (uri == NULL)
@@ -259,7 +261,7 @@ update_url(const char *uri, void *data)
Eina_Bool
echo(const Arg *arg, void *data)
{
- App_Data *ad = data;
+ Window_Data *ad = data;
int index = !arg->s ? 0 : arg->i & (~NoAutoHide);
if (index < Info || index > Error)
@@ -305,98 +307,102 @@ set_widget_font_and_color(Evas_Object *widget, const char *font_str, const char
Evas_Object *
webview_create_window_cb(void *data, Evas_Object *obj, Eina_Bool js, const Elm_Web_Window_Features *wf)
{
- App_Data *ad = data;
- Buffer_Data *td = buffer_add(ad);
+ Window_Data *wd = data;
+ Buffer_Data *bd = buffer_add(wd);
- return td->web;
+ return bd->web;
}
static void
_win_del_request_cb(void *data, Evas_Object *obj, void *event_info)
{
- App_Data *ad = data;
- ad->exiting = EINA_TRUE;
+ Window_Data *wd = data;
+ printf("window requested deletion ..\n");
+
+ free(wd);
}
void
buffer_current_set(Buffer_Data *new_buf)
{
- App_Data *ad = new_buf->app;
- Buffer_Data *old_buf = ad->cur_buf;
+ Window_Data *wd = new_buf->window;
+ Buffer_Data *old_buf = wd->cur_buf;
+ App_Data *ad = wd->app;
if (new_buf == old_buf || ad->exiting)
return;
- if (ad->cur_buf) {
- ewk_view_visibility_state_set(ad->cur_buf->view, EWK_PAGE_VISIBILITY_STATE_HIDDEN, 0);
- if (ad->cur_buf->inspector_enabled)
- ewk_view_web_inspector_close(ad->cur_buf->view);
- if (ad->cur_buf->proxy_enabled)
- g_object_set(ad->soup_session, "proxy-uri", NULL, NULL);
+ if (old_buf) {
+ ewk_view_visibility_state_set(old_buf->view, EWK_PAGE_VISIBILITY_STATE_HIDDEN, 0);
+ if (old_buf->inspector_enabled)
+ ewk_view_web_inspector_close(old_buf->view);
+ // if (old_buf->proxy_enabled)
+ // g_object_set(ad->soup_session, "proxy-uri", NULL, NULL);
}
- ad->cur_buf = new_buf;
+ wd->cur_buf = new_buf;
- if (ad->cur_buf) {
- ewk_view_visibility_state_set(ad->cur_buf->view, EWK_PAGE_VISIBILITY_STATE_VISIBLE, 0);
- if (ad->cur_buf->inspector_enabled) {
- ewk_view_web_inspector_show(ad->cur_buf->view);
+ if (new_buf) {
+ ewk_view_visibility_state_set(new_buf->view, EWK_PAGE_VISIBILITY_STATE_VISIBLE, 0);
+ if (new_buf->inspector_enabled) {
+ ewk_view_web_inspector_show(new_buf->view);
}
- elm_naviframe_item_simple_promote(ad->naviframe, ad->cur_buf->web);
- if (ad->cur_buf->proxy_enabled)
+ elm_naviframe_item_simple_promote(wd->naviframe, new_buf->web);
+ /*
+ if (new_buf->proxy_enabled)
enable_proxy(ad->cur_buf);
if (new_buf->cookies_enabled)
ewk_cookies_policy_set(EWK_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY);
else
ewk_cookies_policy_set(EWK_COOKIE_JAR_ACCEPT_NEVER);
-
- update_url(elm_web_uri_get(ad->cur_buf->web), ad);
+ */
+ update_url(elm_web_uri_get(new_buf->web), ad);
}
}
static void
_web_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Buffer_Data *td = data;
- App_Data *ad = td->app;
- elm_naviframe_item_pop(ad->naviframe);
+ Buffer_Data *bd = data;
+ Window_Data *wd = bd->window;
+ elm_naviframe_item_pop(wd->naviframe);
- if (!ad->exiting)
- ad->cur_buf->web = NULL;
+ if (!wd->app->exiting)
+ wd->cur_buf->web = NULL;
- ad->buffer_list = eina_list_remove(ad->buffer_list, td);
+ wd->buffer_list = eina_list_remove(wd->buffer_list, bd);
- if (eina_list_count(ad->buffer_list)) {
- buffer_current_set(eina_list_nth(ad->buffer_list, 0));
+ if (eina_list_count(wd->buffer_list)) {
+ buffer_current_set(eina_list_nth(wd->buffer_list, 0));
}
- free(td);
+ free(bd);
}
Buffer_Data*
-buffer_add(App_Data *ad)
+buffer_add(Window_Data *wd)
{
Buffer_Data *td;
td = calloc(1, sizeof(Buffer_Data));
if (!td) return NULL;
- ad->buf_total++;
+ wd->buf_total++;
- td->app = ad;
- td->web = elm_web_add(ad->win);
- td->buf_number = ad->buf_total;
+ td->window = wd;
+ td->web = elm_web_add(wd->win);
+ td->buf_number = wd->buf_total;
td->inspector_enabled = EINA_FALSE;
td->proxy_enabled = EINA_FALSE;
td->history_enabled = EINA_TRUE;
td->cookies_enabled = EINA_FALSE;
td->view = elm_web_webkit_view_get(td->web);
- ad->buffer_list = eina_list_append(ad->buffer_list, td);
+ wd->buffer_list = eina_list_append(wd->buffer_list, td);
- elm_web_window_create_hook_set(td->web, webview_create_window_cb, ad);
+ elm_web_window_create_hook_set(td->web, webview_create_window_cb, wd);
elm_web_console_message_hook_set(td->web, webview_console_cb, td);
elm_web_useragent_set(td->web, "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.514.0 Safari/534.7");
elm_web_history_enabled_set(td->web, EINA_TRUE);
@@ -404,7 +410,15 @@ buffer_add(App_Data *ad)
elm_web_inwin_mode_set(td->web, EINA_TRUE);
evas_object_size_hint_weight_set(td->web, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(td->web, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_naviframe_item_simple_push(ad->naviframe, td->web);
+
+ elm_naviframe_item_simple_push(wd->naviframe, td->web);
+
+ /*
+ if (wd->cur_buf)
+ elm_naviframe_item_insert_after(wd->naviframe, ad->cur_buf->web, );
+ else
+ elm_naviframe_item_simple_push(ad->naviframe, td->web);
+ */
evas_object_data_set(td->web, "buffer_data", td);
@@ -437,9 +451,14 @@ buffer_add(App_Data *ad)
return td;
}
-static void
-setup_gui(App_Data *ad)
+Window_Data *
+window_add(App_Data *ad)
{
+ Window_Data *wd;
+
+ wd = calloc(1, sizeof(Window_Data));
+ if (!wd) return NULL;
+
Evas_Object *win, *bg, *box, *status_bar, *url, *naviframe, *status_url;
Evas_Object *status_state, *event_box, *web_inspector;
@@ -448,13 +467,14 @@ setup_gui(App_Data *ad)
win = elm_win_add(NULL, "viking", ELM_WIN_BASIC);
elm_win_autodel_set(win, EINA_TRUE);
// elm_win_screen_constrain_set(win, EINA_TRUE);
- evas_object_smart_callback_add(win, "delete,request", _win_del_request_cb, ad);
+ evas_object_smart_callback_add(win, "delete,request", _win_del_request_cb, wd);
/* program bacground */
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
elm_bg_color_set(bg, 0, 0, 0);
+ evas_object_layer_set(bg, EVAS_LAYER_MIN);
evas_object_show(bg);
/* main box that everything goes into, resizes with window */
@@ -514,21 +534,28 @@ setup_gui(App_Data *ad)
elm_entry_text_style_user_push(url, "DEFAULT='font=Monospace font_size=12'");
evas_object_show(url);
- evas_object_smart_callback_add(url, "activated", inputbox_activate_cb, ad);
- evas_object_smart_callback_add(url, "changed", inputbox_changed_cb, ad);
- evas_object_event_callback_add(url, EVAS_CALLBACK_KEY_DOWN, inputbox_keypress_cb, ad);
- evas_object_event_callback_add(url, EVAS_CALLBACK_KEY_UP, inputbox_keyrelease_cb, ad);
-
- ad->win = win;
- ad->main_box = box;
- ad->naviframe = naviframe;
- ad->url = url;
- ad->status_url = status_url;
- ad->status_state = status_state;
- ad->event_box = event_box;
- ad->web_inspector = web_inspector;
-}
+ evas_object_smart_callback_add(url, "activated", inputbox_activate_cb, wd);
+ evas_object_smart_callback_add(url, "changed", inputbox_changed_cb, wd);
+ evas_object_event_callback_add(url, EVAS_CALLBACK_KEY_DOWN, inputbox_keypress_cb, wd);
+ evas_object_event_callback_add(url, EVAS_CALLBACK_KEY_UP, inputbox_keyrelease_cb, wd);
+
+ wd->win = win;
+ wd->main_box = box;
+ wd->naviframe = naviframe;
+ wd->url = url;
+ wd->status_url = status_url;
+ wd->status_state = status_state;
+ wd->event_box = event_box;
+ wd->web_inspector = web_inspector;
+ wd->app = ad;
+ wd->mode = ModeNormal;
+ wd->echo_active = EINA_TRUE;
+
+ ad->windows = eina_list_append(ad->windows, wd);
+
+ return wd;
+}
static void
setup_network(App_Data *ad)
@@ -545,6 +572,7 @@ setup_network(App_Data *ad)
static Eina_Bool
_cb_session_save(void *data)
{
+ printf("session_save_cb()\n");
/*
Browser_Window *win;
Eina_List *chrome_iter, *win_iter;
@@ -710,9 +738,9 @@ setup_config(App_Data *ad, int argc, char **argv)
if (args < 0)
ERR("Could not parse command line options.");
- user_agent_option = "chrome";
+ // user_agent_option = "chrome";
- if (!user_agent_option || (user_agent_option && (strcasecmp(user_agent_option, "eve") == 0)))
+ if (!user_agent_option || (user_agent_option && (strcasecmp(user_agent_option, "viking") == 0)))
user_agent_str = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 " PACKAGE_NAME "/" PACKAGE_VERSION;
else
{
@@ -877,18 +905,33 @@ static Searchengine searchengines[] = {
{ "dd", "https://duckduckgo.com/html/?q=%s&t=Vimprobable" },
};
+/*
+static Eina_Bool
+fd_handler_cb(void *data, Ecore_Fd_Handler *handler)
+{
+ printf("fd_handler()\n");
+ return EINA_TRUE;
+}
+*/
+
EAPI_MAIN int
elm_main(int argc, char *argv[])
{
App_Data *ad;
Buffer_Data *bd;
+ // char path[PATH_MAX];
+ // int dirlen;
-#if ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
-#endif
+ /*
+ dirlen = snprintf(path, sizeof(path), "%s/viking/lockfile", efreet_config_home_get());
+ if (dirlen >= sizeof(path))
+ printf("Path is too long: %s/viking/lockfile\n", efreet_config_home_get());
+
+ if (ecore_file_exists(path)) {
+ printf("lockfile detectd, exiting.\n");
+ return -1;
+ }
+ */
if (!elm_need_web())
return -1;
@@ -897,26 +940,33 @@ elm_main(int argc, char *argv[])
ad = calloc(1, sizeof(App_Data));
if (!ad) return -1;
+ /*
+ int fd = creat(path, 0);
+ ecore_main_fd_handler_file_add(fd, ECORE_FD_ERROR, fd_handler_cb, ad, NULL, NULL);
+
ad->log_domain = eina_log_domain_register("viking", NULL);
if (ad->log_domain < 0)
EINA_LOG_CRIT("could not create log domain 'viking'.");
+ */
setup_config(ad, argc, argv);
- setup_gui(ad);
setup_modkeys(ad);
setup_network(ad);
- /* session was restored successfully */
- if (config_restore_state_get(ad->config)
- && session_windows_count(ad->session) > 0
- && session_restore());
+ if (config_restore_state_get(ad->config) && session_windows_count(ad->session) > 0
+ && session_restore()) {
+ printf("main() session restored successfully.\n");
+ }
+ else {
+ Window_Data *wd = window_add(ad);
- bd = buffer_add(ad);
- buffer_current_set(bd);
- elm_web_uri_set(bd->web, config_home_page_get(ad->config));
+ bd = buffer_add(wd);
+ buffer_current_set(bd);
+ elm_web_uri_set(bd->web, config_home_page_get(ad->config));
- evas_object_resize(ad->win, 480, 640);
- evas_object_show(ad->win);
+ evas_object_resize(wd->win, 480, 640);
+ evas_object_show(wd->win);
+ }
make_searchengines_list(searchengines, LENGTH(searchengines));
make_uri_handlers_list(uri_handlers, LENGTH(uri_handlers));
@@ -924,8 +974,6 @@ elm_main(int argc, char *argv[])
/* initialize fields that are non-zero */
ad->keylistroot = make_keyslist();
ad->zoomstep = 0.1f;
- ad->mode = ModeNormal;
- ad->echo_active = EINA_TRUE;
ad->downloads = eina_hash_string_superfast_new(download_entry_free_cb);
/* main loop */
@@ -939,15 +987,16 @@ elm_main(int argc, char *argv[])
session_free(ad->session);
if (ad->session_save_timer) ecore_timer_del(ad->session_save_timer);
- eina_log_domain_unregister(ad->log_domain);
- ad->log_domain = -1;
+// eina_log_domain_unregister(ad->log_domain);
+// ad->log_domain = -1;
elm_shutdown();
- ewk_shutdown();
+ // ewk_shutdown();
viking_state_shutdown();
free(ad->modkeys);
- eina_list_free(ad->buffer_list);
+ // each window needs this done to it
+ // eina_list_free(wd->buffer_list);
eina_hash_free(ad->downloads);
return 0;
diff --git a/src/main.h b/src/main.h
@@ -14,6 +14,27 @@ typedef struct _Buffer_Data Buffer_Data;
typedef struct
{
+ Eina_List *windows;
+
+ KeyList *keylistroot;
+ float zoomstep;
+ char *modkeys;
+
+ Eina_Hash *downloads;
+
+ SoupSession *soup_session;
+
+ Hist *history;
+ Config *config;
+ Session *session;
+ Ecore_Timer *session_save_timer;
+ int log_domain;
+
+ Eina_Bool exiting : 1;
+} App_Data;
+
+typedef struct
+{
Evas_Object *win;
Evas_Object *main_box;
Evas_Object *naviframe;
@@ -24,15 +45,13 @@ typedef struct
Evas_Object *status_state;
Evas_Object *web_inspector;
- unsigned int buf_total;
+ Eina_List *commandhistory;
+ int commandpointer;
char current_modkey;
- char *modkeys;
- KeyList *keylistroot;
unsigned int mode;
unsigned int count;
- float zoomstep;
char *search_handle;
Eina_Bool search_direction;
Eina_Bool echo_active;
@@ -42,28 +61,30 @@ typedef struct
char *error_msg;
Eina_Bool manual_focus;
+ unsigned int buf_total;
Eina_List *buffer_list;
- Eina_Hash *downloads;
- Eina_List *commandhistory;
- int commandpointer;
+ // Eina_Hash *downloads;
+ // Eina_List *commandhistory;
+ // int commandpointer;
- SoupSession *soup_session;
+ // SoupSession *soup_session;
Buffer_Data *cur_buf;
+ App_Data *app;
- Hist *history;
- Config *config;
- Session *session;
- Ecore_Timer *session_save_timer;
- int log_domain;
+ // Hist *history;
+ // Config *config;
+ // Session *session;
+ // Ecore_Timer *session_save_timer;
+ // int log_domain;
- Eina_Bool exiting : 1;
-} App_Data;
+ // Eina_Bool exiting : 1;
+} Window_Data;
struct _Buffer_Data
{
Evas_Object *web;
Evas_Object *view;
- App_Data *app;
+ Window_Data *window;
unsigned int buf_number;
Eina_Bool inspector_enabled;
@@ -83,7 +104,8 @@ void update_state(void *);
void update_url(const char *, void *);
Eina_Bool echo(const Arg *arg, void *);
void buffer_current_set(Buffer_Data *td);
-Buffer_Data *buffer_add(App_Data *ad);
+Buffer_Data *buffer_add(Window_Data *ad);
+Window_Data * window_add(App_Data *ad);
Eina_Bool enable_proxy(Buffer_Data *bd);
char* status_flags(void *data);
diff --git a/src/utilities.c b/src/utilities.c
@@ -96,7 +96,7 @@ search_word(int whichword)
void save_command_history(char *line, void *data)
{
char *c = line;
- App_Data *ad = data;
+ Window_Data *wd = data;
while (isspace(*c) && *c)
c++;
@@ -104,13 +104,13 @@ void save_command_history(char *line, void *data)
return;
// if (COMMANDHISTSIZE <= g_list_length(commandhistory)) {
- if (COMMANDHISTSIZE <= eina_list_count(ad->commandhistory)) {
+ if (COMMANDHISTSIZE <= eina_list_count(wd->commandhistory)) {
/* if list is too long - remove items from beginning */
// commandhistory = g_list_delete_link(commandhistory, g_list_first(commandhistory));
- ad->commandhistory = eina_list_remove(ad->commandhistory, eina_list_nth(ad->commandhistory, 0));
+ wd->commandhistory = eina_list_remove(wd->commandhistory, eina_list_nth(wd->commandhistory, 0));
}
// commandhistory = g_list_append(commandhistory, g_strdup(c));
- ad->commandhistory = eina_list_append(ad->commandhistory, strdup(c));
+ wd->commandhistory = eina_list_append(wd->commandhistory, strdup(c));
}
/*
@@ -569,14 +569,15 @@ build_taglist(const Arg *arg, FILE *f) {
}
void
-set_error(const char *error, void *data) {
- App_Data *ad = data;
- /* it should never happen that set_error is called more than once,
- * but to avoid any potential memory leaks, we ignore any subsequent
- * error if the current one has not been shown */
- if (ad->error_msg == NULL) {
- ad->error_msg = strdup_printf("%s", error);
- }
+set_error(const char *error, void *data)
+{
+ Window_Data *wd = data;
+ /* it should never happen that set_error is called more than once,
+ * but to avoid any potential memory leaks, we ignore any subsequent
+ * error if the current one has not been shown */
+ if (wd->error_msg == NULL) {
+ wd->error_msg = strdup_printf("%s", error);
+ }
}
void
@@ -810,7 +811,7 @@ process_line(const char *line, void *data)
const char *c = line;
char *command_hist;
int i;
- App_Data *ad = data;
+ Window_Data *wd = data;
size_t len, length = strlen(line);
Eina_Bool found = EINA_FALSE, success = EINA_FALSE;
Arg a;
@@ -853,10 +854,10 @@ process_line(const char *line, void *data)
free(a.s);
} else if (!success) {
a.i = Error;
- if (ad->error_msg != NULL) {
- a.s = strdup_printf("%s", ad->error_msg);
- free(ad->error_msg);
- ad->error_msg = NULL;
+ if (wd->error_msg != NULL) {
+ a.s = strdup_printf("%s", wd->error_msg);
+ free(wd->error_msg);
+ wd->error_msg = NULL;
} else {
a.s = strdup_printf("Unknown error. Please file a bug report!");
}
@@ -1085,7 +1086,7 @@ setup_modkeys(void *data)
ad->modkeys = calloc(LENGTH(keys) + 1, sizeof(char));
ad->modkeys[0] = '\0';
- e = evas_object_evas_get(ad->win);
+ // e = evas_object_evas_get(ad->win);
for (i = 0; i < LENGTH(keys); i++) {
if (keys[i].modkey && !strchr(ad->modkeys, keys[i].modkey)) {
@@ -1094,9 +1095,9 @@ setup_modkeys(void *data)
ad->modkeys[strlen(ad->modkeys) + 1] = '\0';
}
- mask = evas_key_modifier_mask_get(e, keys[i].mask);
- if (keys[i].key && !evas_object_key_grab(ad->win, keys[i].key, mask, 0, EINA_FALSE))
- fprintf(stderr, "Could not grab trigger for mask = %s, key = %s\n", keys[i].mask , keys[i].key);
+ // mask = evas_key_modifier_mask_get(e, keys[i].mask);
+ // if (keys[i].key && !evas_object_key_grab(ad->win, keys[i].key, mask, 0, EINA_FALSE))
+ // fprintf(stderr, "Could not grab trigger for mask = %s, key = %s\n", keys[i].mask , keys[i].key);
}
// fprintf(stderr, "Modkey array looks like %s\n", ad->modkeys);
}