Changeset 58124 in webkit


Ignore:
Timestamp:
Apr 22, 2010 4:00:23 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-22 Leandro Pereira <leandro@profusion.mobi>

Reviewed by Gustavo Noronha Silva.

Implement findThemePath to locate the correct theme file instead of
relying on a hardcoded location.
http://webkit.org/b/37996

  • efl/EWebLauncher/main.c: (findThemePath): Fix to locate the correct theme files. (main): Use findThemePath() instead of a hardcoded one.
Location:
trunk/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r58122 r58124  
     12010-04-22  Leandro Pereira  <leandro@profusion.mobi>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        Implement findThemePath to locate the correct theme file instead of
     6        relying on a hardcoded location.
     7        http://webkit.org/b/37996
     8
     9        * efl/EWebLauncher/main.c:
     10        (findThemePath): Fix to locate the correct theme files.
     11        (main): Use findThemePath() instead of a hardcoded one.
     12
    1132010-04-22  Leandro Pereira  <leandro@profusion.mobi>
    214
  • trunk/WebKit/efl/EWebLauncher/main.c

    r56130 r58124  
    3232#include <ctype.h>
    3333#include <Ecore.h>
    34 #include <Ecore_Data.h>
    3534#include <Ecore_Evas.h>
    3635#include <Ecore_File.h>
     
    4342#include <stdlib.h>
    4443#include <string.h>
     44#include <sys/stat.h>
    4545#include <sys/types.h>
    4646#include <unistd.h>
     
    5454            printf(format, ##args); \
    5555    } while (0)
    56 
    57 #define REL_THEME_PATH "../../../WebKit/efl/DefaultTheme/default.edj"
    5856
    5957#define MIN_ZOOM_LEVEL 0
     
    137135} ELauncher;
    138136
    139 void browserDestroy(Ecore_Evas *ee);
    140 void closeWindow(Ecore_Evas *ee);
    141 int browserCreate(const char *url, const char *theme, const char *userAgent, Eina_Rectangle geometry, const char *engine, unsigned char isFullscreen);
    142 
    143 void
     137static void browserDestroy(Ecore_Evas *ee);
     138static void closeWindow(Ecore_Evas *ee);
     139static int browserCreate(const char *url, const char *theme, const char *userAgent, Eina_Rectangle geometry, const char *engine, unsigned char isFullscreen);
     140
     141static void
    144142print_history(Eina_List *list)
    145143{
     
    174172}
    175173
    176 void
     174static void
    177175zoom_level_set(Evas_Object *webview, int level)
    178176{
     
    186184}
    187185
    188 char*
    189 join_path(const char *base, const char *path)
    190 {
    191     char separator[] = "/";
    192 
    193     char tmp[PATH_MAX + 1];
    194     char result[PATH_MAX + 1];
    195     result[0] = tmp[0] = '\0';
    196 
    197     char *str = strdup(path);
    198 
    199     char *token = NULL;
    200     token = strtok(str, separator);
    201     int count = 0;
    202     do {
    203         if (!strcmp(token, ".."))
    204             count++;
    205         else
    206             strcat(tmp, token);
    207         token = strtok(NULL, separator);
    208         if (!token)
    209             break;
    210         if (tmp[0])
    211             strcat(tmp, separator);
    212     } while (EINA_TRUE);
    213 
    214     free(str);
    215     str = strdup(base);
    216 
    217     char *base_ptr;
    218     while (count--) {
    219         base_ptr = strrchr(str, separator[0]);
    220         if (!base_ptr) {
    221             free(str);
    222             return NULL; // couldn't resolve path
    223         }
    224         *base_ptr = '\0';
    225     }
    226 
    227     strcat(result, str);
    228     strcat(result, separator);
    229     strcat(result, tmp);
    230     free(str);
    231 
    232     return strdup(result);
    233 }
    234 
    235186static void
    236187on_ecore_evas_resize(Ecore_Evas *ee)
     
    395346}
    396347
    397 void
     348static void
    398349on_mouse_down(void* data, Evas* e, Evas_Object* webview, void* event_info)
    399350{
     
    403354}
    404355
    405 void
     356static void
    406357on_focus_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
    407358{
     
    409360}
    410361
    411 void
     362static void
    412363on_focus_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
    413364{
     
    415366}
    416367
    417 void
     368static void
    418369on_resized(void *data, Evas *e, Evas_Object *obj, void *event_info)
    419370{
     
    423374}
    424375
    425 void
     376static void
    426377on_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
    427378{
     
    531482}
    532483
    533 void
     484static void
    534485on_browser_del(void *data, Evas *evas, Evas_Object *browser, void *event)
    535486{
     
    543494}
    544495
    545 void
     496static void
    546497on_closeWindow(Ecore_Evas *ee)
    547498{
     
    549500}
    550501
    551 int
     502static int
    552503quit(Eina_Bool success, const char *msg)
    553504{
     
    566517}
    567518
    568 int
     519static int
    569520browserCreate(const char *url, const char *theme, const char *userAgent, Eina_Rectangle geometry, const char *engine, unsigned char isFullscreen)
    570521{
     
    654605}
    655606
    656 void
     607static void
    657608browserDestroy(Ecore_Evas *ee)
    658609{
     
    662613}
    663614
    664 void
     615static void
    665616closeWindow(Ecore_Evas *ee)
    666617{
     
    689640        ecore_main_loop_quit();
    690641    return 1;
     642}
     643
     644static char *
     645findThemePath(void)
     646{
     647    const char **itr, *locations[] = {
     648        "./default.edj",
     649        "./WebKit/efl/DefaultTheme/default.edj",
     650        "../WebKit/efl/DefaultTheme/default.edj",
     651        DATA_DIR"/themes/default.edj",
     652        NULL
     653    };
     654
     655    for (itr = locations; *itr; itr++) {
     656        struct stat st;
     657        if (!stat(*itr, &st)) {
     658            char path[PATH_MAX];
     659            if (realpath(*itr, path))
     660                return strdup(path);
     661        }
     662    }
     663
     664    return NULL;
    691665}
    692666
     
    751725        strcat(getenv("HOME"), "blah");
    752726
    753     themePath = join_path(argv[0], REL_THEME_PATH);
     727    themePath = findThemePath();
    754728
    755729    ewk_init();
Note: See TracChangeset for help on using the changeset viewer.