\section{web\+\_\+example\+\_\+02.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{/*}
\textcolor{comment}{ * gcc -o web\_example\_02 web\_example\_02.c `pkg-config --cflags --libs elementary ewebkit` -D\_GNU\_SOURCE}
\textcolor{comment}{ */}

\textcolor{preprocessor}{#define \_GNU\_SOURCE}
\textcolor{preprocessor}{#include <Elementary.h>}
\textcolor{preprocessor}{#ifdef HAVE\_ELEMENTARY\_WEB}
\textcolor{preprocessor}{#include <EWebKit.h>}
\textcolor{preprocessor}{#endif}

\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Tab\_Data Tab\_Data;

\textcolor{keyword}{typedef} \textcolor{keyword}{struct}
\{
   Evas\_Object *win;
   Evas\_Object *main\_box;
   Evas\_Object *naviframe;
   Evas\_Object *url\_entry;
   Evas\_Object *default\_web;
   Evas\_Object *tabs;
   Evas\_Object *close\_tab;
   Evas\_Object *search\_box;
   Evas\_Object *search\_entry;

   \textcolor{keyword}{struct }\{
        Evas\_Object *back;
        Evas\_Object *fwd;
        Evas\_Object *refresh;
   \} nav;

   Tab\_Data *current\_tab;

   Eina\_Bool exiting : 1;
\} App\_Data;

\textcolor{keyword}{struct }\_Tab\_Data
\{
   Evas\_Object *web;
   App\_Data *app;
   Elm_Object_Item *tab;
\};

\textcolor{keyword}{static} Evas\_Object * \_web\_create\_window\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, Eina\_Bool js, \textcolor{keyword}{const} 
      Elm_Web_Window_Features *wf);

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
nav\_button\_update(App\_Data *ad)
\{
   Eina\_Bool back, fwd;

   back = !elm_web_back_possible_get(ad->current\_tab->web);
   fwd = !elm_web_forward_possible_get(ad->current\_tab->web);

   elm_object_disabled_set(ad->nav.back, back);
   elm_object_disabled_set(ad->nav.fwd, fwd);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
tab\_current\_set(Tab\_Data *td)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *url;

   \textcolor{keywordflow}{if} (td == td->app->current\_tab)
     \textcolor{keywordflow}{return};

   td->app->current\_tab = td;

   url = elm_web_url_get(td->web);
   elm\_object\_text\_set(td->app->url\_entry, url);

   nav\_button\_update(td->app);
   elm_entry_icon_visible_set(td->app->url\_entry, EINA\_TRUE);

   elm\_naviframe\_item\_simple\_promote(td->app->naviframe, td->web);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_tab\_clicked\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Tab\_Data *td = data;
   \textcolor{comment}{/* the first toolbar\_item\_append() calls the select callback before the item}
\textcolor{comment}{    * is assigned, so we need a workaround for that. */}
   \textcolor{keywordflow}{if} (!td->tab)
     td->tab = event\_info;
   tab\_current\_set(td);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_title\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Tab\_Data *td = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *title = event\_info;
   \textcolor{keywordtype}{char} buf[20] = \textcolor{stringliteral}{""};

   \textcolor{keywordflow}{if} (title)
     strncpy(buf, title, \textcolor{keyword}{sizeof}(buf) - 1);
   elm_object_item_text_set(td->tab, buf);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_url\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Tab\_Data *td = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *url = event\_info;

   \textcolor{keywordflow}{if} (td != td->app->current\_tab)
     \textcolor{keywordflow}{return};

   nav\_button\_update(td->app);
   elm\_object\_text\_set(td->app->url\_entry, url);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_web\_free\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Tab\_Data *td = data;

   \textcolor{keywordflow}{if} (td->tab)
     elm\_object\_item\_del(td->tab);

   free(td);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_tb\_item\_del\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Tab\_Data *td = data;
   \textcolor{keywordflow}{if} (!td->app->exiting && !elm_toolbar_selected_item_get(obj))
     \{
        td->app->current\_tab = NULL;
        elm_entry_icon_visible_set(td->app->url\_entry, EINA\_FALSE);
        \textcolor{keywordflow}{if} (td->app->search\_box)
          evas\_object\_del(td->app->search\_box);
     \}
   td->tab = NULL;
\}

Tab\_Data *
tab\_add(App\_Data *ad)
\{
   Tab\_Data *td;

   td = calloc(1, \textcolor{keyword}{sizeof}(Tab\_Data));
   \textcolor{keywordflow}{if} (!td) \textcolor{keywordflow}{return} NULL;

   td->web = elm_web_add(ad->win);
   elm_web_window_create_hook_set(td->web, \_web\_create\_window\_cb, 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);

   td->app = ad;
   td->tab = elm_toolbar_item_append(td->app->tabs, NULL, \textcolor{stringliteral}{"New tab"},
                                     \_tab\_clicked\_cb, td);
   elm\_object\_item\_del\_cb\_set(td->tab, \_tb\_item\_del\_cb);

   evas\_object\_data\_set(td->web, \textcolor{stringliteral}{"tab\_data"}, td);

   evas\_object\_smart\_callback\_add(td->web, \textcolor{stringliteral}{"title,changed"}, \_title\_changed\_cb,
                                  td);
   evas\_object\_smart\_callback\_add(td->web, \textcolor{stringliteral}{"url,changed"}, \_url\_changed\_cb, td);
   evas\_object\_event\_callback\_add(td->web, EVAS\_CALLBACK\_FREE, \_web\_free\_cb,
                                  td);

   elm_toolbar_item_selected_set(td->tab, EINA\_TRUE);
   \textcolor{keywordflow}{return} td;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{char} *
url\_sanitize(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *url)
\{
   \textcolor{keywordtype}{char} *fixed\_url;
   \textcolor{keywordtype}{char} *schema;
   \textcolor{keywordtype}{char} *tmp;

   \textcolor{keywordflow}{if} (!url || !*url) \textcolor{keywordflow}{return} NULL;

   tmp = strstr(url, \textcolor{stringliteral}{"://"});
   \textcolor{keywordflow}{if} (!tmp || (tmp == url) || (tmp > (url + 15)))
     \{
        \textcolor{keywordtype}{char} *new\_url = NULL;
        \textcolor{keywordflow}{if} (ecore\_file\_exists(url))
          \{
             schema = \textcolor{stringliteral}{"file"};
             new\_url = ecore\_file\_realpath(url);
          \}
        \textcolor{keywordflow}{else}
          schema = \textcolor{stringliteral}{"http"};

        \textcolor{keywordflow}{if} (asprintf(&fixed\_url, \textcolor{stringliteral}{"%s://%s"}, schema, new\_url ? new\_url : url) >
            0)
          \{
             free(new\_url);
             \textcolor{keywordflow}{return} fixed\_url;
          \}
        free(new\_url);
     \}
   \textcolor{keywordflow}{else}
     \textcolor{keywordflow}{return} strdup(url);

   \textcolor{keywordflow}{return} NULL;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
tab\_url\_set(Tab\_Data *td, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *url)
\{
   \textcolor{keywordtype}{char} *sane\_url = url\_sanitize(url);
   elm_web_url_set(td->web, sane\_url);
   free(sane\_url);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_url\_entry\_activated\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   Tab\_Data *td;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *url = eina\_stringshare\_ref(elm\_object\_text\_get(obj));

   \textcolor{keywordflow}{if} (!ad->current\_tab)
     td = tab\_add(ad);
   \textcolor{keywordflow}{else}
     td = ad->current\_tab;
   tab\_url\_set(td, url);
   eina\_stringshare\_del(url);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_nav\_back\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;

   elm_web_back(ad->current\_tab->web);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_nav\_refresh\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   \textcolor{keyword}{const} Evas\_Modifier *mods = evas\_key\_modifier\_get(evas\_object\_evas\_get(obj));

   \textcolor{keywordflow}{if} (evas\_key\_modifier\_is\_set(mods, \textcolor{stringliteral}{"Shift"}))
     elm_web_reload_full(ad->current\_tab->web);
   \textcolor{keywordflow}{else}
     elm_web_reload(ad->current\_tab->web);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_nav\_fwd\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;

   elm_web_forward(ad->current\_tab->web);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_close\_tab\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;

   \textcolor{keywordflow}{if} (!ad->current\_tab)
     \textcolor{keywordflow}{return};
   evas\_object\_del(ad->current\_tab->web);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_add\_tab\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   tab\_add(ad);
   elm_object_focus_set(ad->url\_entry, EINA\_TRUE);
\}

\textcolor{keyword}{static} Evas\_Object *
\_web\_create\_window\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, Eina\_Bool js, \textcolor{keyword}{const} 
      Elm_Web_Window_Features *wf)
\{
   App\_Data *ad = data;
   Tab\_Data *td;

   td = tab\_add(ad);
   \textcolor{keywordflow}{return} td->web;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_win\_del\_request\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   ad->exiting = EINA\_TRUE;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_win\_free\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   free(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_search\_entry\_changed\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *text;

   text = elm\_object\_text\_get(obj);
   elm_web_text_search(ad->current\_tab->web, text, EINA\_FALSE, EINA\_TRUE,
                       EINA\_TRUE);
   elm_web_text_matches_unmark_all(ad->current\_tab->web);
   elm_web_text_matches_mark(ad->current\_tab->web, text, EINA\_FALSE, EINA\_TRUE,
                             0);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_search\_entry\_activate\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *text;

   text = elm\_object\_text\_get(obj);
   elm_web_text_search(ad->current\_tab->web, text, EINA\_FALSE, EINA\_TRUE,
                       EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_search\_next\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *text;

   text = elm\_object\_text\_get(ad->search\_entry);
   elm_web_text_search(ad->current\_tab->web, text, EINA\_FALSE, EINA\_TRUE,
                       EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_search\_prev\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *text;

   text = elm\_object\_text\_get(ad->search\_entry);
   elm_web_text_search(ad->current\_tab->web, text, EINA\_FALSE, EINA\_FALSE,
                       EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_search\_close\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   evas\_object\_del(ad->search\_box);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_search\_box\_del\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   App\_Data *ad = data;
   ad->search\_box = NULL;
   ad->search\_entry = NULL;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_win\_search\_trigger\_cb(\textcolor{keywordtype}{void} *data, Evas *e, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   Evas\_Event\_Key\_Down *ev = event\_info;
   App\_Data *ad = data;
   Evas\_Object *box, *box2, *entry, *btn, *ic;

   \textcolor{keywordflow}{if} (strcmp(ev->keyname, \textcolor{stringliteral}{"f"}) ||
       !evas\_key\_modifier\_is\_set(ev->modifiers, \textcolor{stringliteral}{"Control"}))
     \textcolor{keywordflow}{return};
   \textcolor{keywordflow}{if} (ad->search\_box || !ad->current\_tab)
     \textcolor{keywordflow}{return};

   box = elm_box_add(ad->win);
   elm_box_horizontal_set(box, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(box, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_after(ad->main\_box, box, ad->url\_entry);
   evas\_object\_show(box);

   evas\_object\_event\_callback\_add(box, EVAS\_CALLBACK\_DEL, \_search\_box\_del\_cb,
                                  ad);

   entry = elm_entry_add(ad->win);
   elm_entry_single_line_set(entry, EINA\_TRUE);
   elm_entry_scrollable_set(entry, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(entry, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(entry, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box, entry);
   evas\_object\_show(entry);

   evas\_object\_smart\_callback\_add(entry, \textcolor{stringliteral}{"changed"}, \_search\_entry\_changed\_cb,
                                  ad);
   evas\_object\_smart\_callback\_add(entry, \textcolor{stringliteral}{"activated"}, \_search\_entry\_activate\_cb,
                                  ad);

   box2 = elm_box_add(ad->win);
   elm_box_horizontal_set(box2, EINA\_TRUE);
   elm_object_part_content_set(entry, \textcolor{stringliteral}{"end"}, box2);

   btn = elm_button_add(ad->win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   ic = elm_icon_add(ad->win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"arrow\_up"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_search\_prev\_cb, ad);

   btn = elm_button_add(ad->win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   ic = elm_icon_add(ad->win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"arrow\_down"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_search\_next\_cb, ad);

   btn = elm_button_add(ad->win);
   elm_box_pack_end(box, btn);
   evas\_object\_show(btn);

   ic = elm_icon_add(ad->win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"close"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_search\_close\_cb, ad);

   ad->search\_box = box;
   ad->search\_entry = entry;

   elm_object_focus_set(entry, EINA\_TRUE);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
default\_content\_set(Evas\_Object *web)
\{
\textcolor{preprocessor}{#ifdef HAVE\_ELEMENTARY\_WEB}
   Evas\_Object *view, *frame;
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} contents[] = \textcolor{stringliteral}{""}
      \textcolor{stringliteral}{"<html>\(\backslash\)n"}
      \textcolor{stringliteral}{"  <head>\(\backslash\)n"}
      \textcolor{stringliteral}{"    <title>Nothing to see here, move along</title>\(\backslash\)n"}
      \textcolor{stringliteral}{"  </head>\(\backslash\)n"}
      \textcolor{stringliteral}{"  <body>\(\backslash\)n"}
      \textcolor{stringliteral}{"    <a href=\(\backslash\)"http://www.enlightenment.org\(\backslash\)" target=\(\backslash\)"\_blank\(\backslash\)">E</a>\(\backslash\)n"}
      \textcolor{stringliteral}{"    <br />\(\backslash\)n"}
      \textcolor{stringliteral}{"    <a href=\(\backslash\)"http://www.google.com\(\backslash\)" target=\(\backslash\)"\_blank\(\backslash\)">Google</a>\(\backslash\)n"}
      \textcolor{stringliteral}{"    <br />\(\backslash\)n"}
      \textcolor{stringliteral}{"  </body>\(\backslash\)n"}
      \textcolor{stringliteral}{"</html>\(\backslash\)n"};

   view = elm_web_webkit_view_get(web);
   frame = ewk\_view\_frame\_main\_get(view);
   ewk\_frame\_contents\_set(frame, contents, \textcolor{keyword}{sizeof}(contents) - 1, \textcolor{stringliteral}{"text/html"},
                          \textcolor{stringliteral}{"UTF-8"}, NULL);
\textcolor{preprocessor}{#else}
   (void) web;
\textcolor{preprocessor}{#endif}
\}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} *argv[])
\{
   Evas\_Object *win, *box, *box2, *btn, *ic, *url\_bar, *naviframe, *tabs, *web;
   Evas *e;
   Evas\_Modifier\_Mask ctrl\_mask;
   App\_Data *ad;

   \textcolor{keywordflow}{if} (!elm_need_web())
     \textcolor{keywordflow}{return} -1;

   ad = calloc(1, \textcolor{keyword}{sizeof}(App\_Data));
   \textcolor{keywordflow}{if} (!ad) \textcolor{keywordflow}{return} -1;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"example-web"}, \textcolor{stringliteral}{"Web Example"});
   elm_win_autodel_set(win, EINA\_TRUE);

   e = evas\_object\_evas\_get(win);
   ctrl\_mask = evas\_key\_modifier\_mask\_get(e, \textcolor{stringliteral}{"Control"});
   \textcolor{keywordflow}{if} (!evas\_object\_key\_grab(win, \textcolor{stringliteral}{"f"}, ctrl\_mask, 0, EINA\_TRUE))
     fprintf(stderr, \textcolor{stringliteral}{"Could not grab trigger for search dialog\(\backslash\)n"});

   evas\_object\_smart\_callback\_add(win, \textcolor{stringliteral}{"delete,request"}, \_win\_del\_request\_cb,
                                  ad);
   evas\_object\_event\_callback\_add(win, EVAS\_CALLBACK\_KEY\_DOWN,
                                  \_win\_search\_trigger\_cb, ad);
   evas\_object\_event\_callback\_add(win, EVAS\_CALLBACK\_FREE, \_win\_free\_cb, ad);

   box = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(box, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   elm_win_resize_object_add(win, box);
   evas\_object\_show(box);

   url\_bar = elm_entry_add(win);
   elm_entry_single_line_set(url\_bar, EINA\_TRUE);
   elm_entry_scrollable_set(url\_bar, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(url\_bar, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(url\_bar, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box, url\_bar);
   evas\_object\_show(url\_bar);

   evas\_object\_smart\_callback\_add(url\_bar, \textcolor{stringliteral}{"activated"}, \_url\_entry\_activated\_cb, ad);

   box2 = elm_box_add(win);
   elm_box_horizontal_set(box2, EINA\_TRUE);
   elm_object_part_content_set(url\_bar, \textcolor{stringliteral}{"icon"}, box2);
   elm_entry_icon_visible_set(url\_bar, EINA\_FALSE);

   btn = elm_button_add(win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   ad->nav.back = btn;

   ic = elm_icon_add(win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"arrow\_left"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_nav\_back\_cb, ad);

   btn = elm_button_add(win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   ad->nav.refresh = btn;

   ic = elm_icon_add(win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"refresh"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_nav\_refresh\_cb, ad);

   btn = elm_button_add(win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   ad->nav.fwd = btn;

   ic = elm_icon_add(win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"arrow\_right"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_nav\_fwd\_cb, ad);

   box2 = elm_box_add(win);
   elm_box_horizontal_set(box2, EINA\_TRUE);
   evas\_object\_size\_hint\_weight\_set(box2, EVAS\_HINT\_EXPAND, 0.0);
   evas\_object\_size\_hint\_align\_set(box2, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box, box2);
   evas\_object\_show(box2);

   btn = elm_button_add(win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   ic = elm_icon_add(win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"file"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_add\_tab\_cb, ad);

   tabs = elm_toolbar_add(win);
   elm_toolbar_align_set(tabs, 0.0);
   elm_toolbar_select_mode_set(tabs, ELM_OBJECT_SELECT_MODE_ALWAYS);
   elm_toolbar_homogeneous_set(tabs, EINA\_FALSE);
   elm_toolbar_shrink_mode_set(tabs, ELM_TOOLBAR_SHRINK_MENU);
   evas\_object\_size\_hint\_weight\_set(tabs, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(tabs, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box2, tabs);
   evas\_object\_show(tabs);

   btn = elm_button_add(win);
   elm_box_pack_end(box2, btn);
   evas\_object\_show(btn);

   evas\_object\_smart\_callback\_add(btn, \textcolor{stringliteral}{"clicked"}, \_close\_tab\_cb, ad);

   ic = elm_icon_add(win);
   elm_icon_standard_set(ic, \textcolor{stringliteral}{"close"});
   elm_object_part_content_set(btn, \textcolor{stringliteral}{"icon"}, ic);

   naviframe = elm_naviframe_add(win);
   evas\_object\_size\_hint\_weight\_set(naviframe, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(naviframe, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm_box_pack_end(box, naviframe);
   evas\_object\_show(naviframe);

   elm_toolbar_menu_parent_set(tabs, naviframe);

   web = elm_web_add(win);
   elm_web_window_create_hook_set(web, \_web\_create\_window\_cb, ad);
   elm_web_history_enabled_set(web, EINA\_FALSE);
   evas\_object\_size\_hint\_weight\_set(web, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(web, EVAS\_HINT\_FILL, EVAS\_HINT\_FILL);
   elm\_naviframe\_item\_simple\_push(naviframe, web);

   default\_content\_set(web);

   ad->win = win;
   ad->main\_box = box;
   ad->naviframe = naviframe;
   ad->url\_entry = url\_bar;
   ad->default\_web = web;
   ad->tabs = tabs;
   ad->close\_tab = btn;

   evas\_object\_resize(win, 480, 640);
   evas\_object\_show(win);

   elm_run();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()
\end{DoxyCodeInclude}
 