Browse Source

use the xdg-open script from freedesktop.org to open urls

this script is part of the "xdg-utils" package


SVN revision: 30318
enlightenment-0.17
kiwi 15 years ago committed by kiwi
parent
commit
12721156a0
  1. 4
      TODO
  2. 5
      src/module/news_config.c
  3. 6
      src/module/news_config.h
  4. 64
      src/module/news_config_dialog.c
  5. 48
      src/module/news_utils.c
  6. 12
      src/module/news_utils.h

4
TODO

@ -34,8 +34,6 @@ science : http://www.eurekalert.org/rss.xml
NEEDED (to do more or less in this order)
----------------------------------------------------
- ? make a difference in item ui, depending on the gadon gadget inset/freee appearance ?
- debug html chars parse with test.rss
-> add support for & alone in evas_textblock
@ -43,7 +41,7 @@ NEEDED (to do more or less in this order)
- save unread articles on shutdown
- if the shelf is hidden, show it on news
- if the shelf is hidden, show it on news (configurable)
- viewer: a way to set vcontent bg color ?

5
src/module/news_config.c

@ -79,8 +79,6 @@ news_config_init(void)
E_CONFIG_VAL(D, T, proxy.enable, SHORT);
E_CONFIG_VAL(D, T, proxy.host, STR);
E_CONFIG_VAL(D, T, proxy.port, INT);
E_CONFIG_VAL(D, T, browser.wich, SHORT);
E_CONFIG_VAL(D, T, browser.own, STR);
E_CONFIG_VAL(D, T, viewer.vfeeds.unread_first, SHORT);
E_CONFIG_VAL(D, T, viewer.varticles.unread_first, SHORT);
E_CONFIG_VAL(D, T, viewer.varticles.sort_date, SHORT);
@ -146,8 +144,6 @@ news_config_init(void)
c->proxy.port = NEWS_FEED_PROXY_PORT_DEFAULT;
}
c->browser.wich = NEWS_UTIL_BROWSER_DEFAULT;
c->viewer.vfeeds.unread_first = NEWS_VIEWER_VFEEDS_UNREAD_FIRST_DEFAULT;
c->viewer.varticles.unread_first = NEWS_VIEWER_VARTICLES_UNREAD_FIRST_DEFAULT;
c->viewer.varticles.sort_date = NEWS_VIEWER_VARTICLES_SORT_DATE_DEFAULT;
@ -192,7 +188,6 @@ news_config_shutdown(void)
news_feed_lang_list_free(news->config->feed.langs);
if (c->proxy.host) evas_stringshare_del(c->proxy.host);
if (c->browser.own) evas_stringshare_del(c->browser.own);
while ( (nic = evas_list_data(c->items)) )
news_config_item_del(nic);

6
src/module/news_config.h

@ -31,12 +31,6 @@ struct _News_Config
int port;
} proxy;
struct
{
int wich;
const char *own;
} browser;
struct
{
struct

64
src/module/news_config_dialog.c

@ -20,12 +20,6 @@ struct _E_Config_Dialog_Data
char *port;
} proxy;
struct
{
int wich;
char *own;
} browser;
struct
{
struct
@ -129,7 +123,6 @@ static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
free(cfdata->proxy.host);
free(cfdata->browser.own);
news->config_dialog = NULL;
free(cfdata);
@ -159,12 +152,6 @@ _fill_data(E_Config_Dialog_Data *cfdata)
else
cfdata->proxy.port = strdup("");
cfdata->browser.wich = c->browser.wich;
if (c->browser.own)
cfdata->browser.own = strdup(c->browser.own);
else
cfdata->browser.own = strdup("");
cfdata->viewer.vfeeds.unread_first = c->viewer.vfeeds.unread_first;
cfdata->viewer.varticles.unread_first = c->viewer.varticles.unread_first;
cfdata->viewer.varticles.sort_date = c->viewer.varticles.sort_date;
@ -197,7 +184,6 @@ static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *of, *ob;
E_Radio_Group *rg;
o = e_widget_list_add(evas, 0, 0);
@ -208,26 +194,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_frametable_add(evas, _("Browser"), 0);
rg = e_widget_radio_group_new(&(cfdata->browser.wich));
ob = e_widget_radio_add(evas, _("Firefox (new window)"), NEWS_UTIL_BROWSER_FIREFOX, rg);
e_widget_frametable_object_append(of, ob, 0, 0, 3, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Firefox (new tab)"), NEWS_UTIL_BROWSER_FIREFOX_TAB, rg);
e_widget_frametable_object_append(of, ob, 3, 0, 3, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Mozilla"), NEWS_UTIL_BROWSER_MOZILLA, rg);
e_widget_frametable_object_append(of, ob, 0, 1, 2, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Opera"), NEWS_UTIL_BROWSER_OPERA, rg);
e_widget_frametable_object_append(of, ob, 2, 1, 2, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Dillo"), NEWS_UTIL_BROWSER_DILLO, rg);
e_widget_frametable_object_append(of, ob, 4, 1, 2, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("This one"), NEWS_UTIL_BROWSER_OWN, rg);
e_widget_frametable_object_append(of, ob, 0, 2, 2, 1, 1, 1, 0, 1);
ob = e_widget_entry_add(evas, &(cfdata->browser.own));
e_widget_frametable_object_append(of, ob, 2, 2, 4, 1, 1, 1, 0, 1);
e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_frametable_add(evas, _("News Viewer"), 0);
ob = e_widget_label_add(evas, _("Font size"));
@ -272,23 +238,10 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
e_widget_list_object_append(o2, of, 1, 1, 0.5);
of = e_widget_frametable_add(evas, _("Browser"), 0);
rg = e_widget_radio_group_new(&(cfdata->browser.wich));
ob = e_widget_radio_add(evas, _("Firefox (new window)"), NEWS_UTIL_BROWSER_FIREFOX, rg);
e_widget_frametable_object_append(of, ob, 0, 0, 3, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Firefox (new tab)"), NEWS_UTIL_BROWSER_FIREFOX_TAB, rg);
e_widget_frametable_object_append(of, ob, 3, 0, 3, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Mozilla"), NEWS_UTIL_BROWSER_MOZILLA, rg);
e_widget_frametable_object_append(of, ob, 0, 1, 2, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Opera"), NEWS_UTIL_BROWSER_OPERA, rg);
e_widget_frametable_object_append(of, ob, 2, 1, 2, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("Dillo"), NEWS_UTIL_BROWSER_DILLO, rg);
e_widget_frametable_object_append(of, ob, 4, 1, 2, 1, 1, 1, 0, 1);
ob = e_widget_radio_add(evas, _("This one"), NEWS_UTIL_BROWSER_OWN, rg);
e_widget_frametable_object_append(of, ob, 0, 2, 2, 1, 1, 1, 0, 1);
ob = e_widget_entry_add(evas, &(cfdata->browser.own));
e_widget_frametable_object_append(of, ob, 2, 2, 4, 1, 1, 1, 0, 1);
of = e_widget_framelist_add(evas, _("Browser"), 0);
ob = e_widget_label_add(evas, _("Uses xdg-open script, from freedesktop.org"));
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o2, of, 1, 1, 0.5);
@ -432,15 +385,6 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
if (cfdata->proxy.port && cfdata->proxy.port[0])
sscanf(cfdata->proxy.port, "%d", &c->proxy.port);
c->browser.wich = cfdata->browser.wich;
if (c->browser.own)
{
evas_stringshare_del(c->browser.own);
c->browser.own = NULL;
}
if (cfdata->browser.own)
c->browser.own = evas_stringshare_add(cfdata->browser.own);
if ( (c->viewer.vfeeds.unread_first != cfdata->viewer.vfeeds.unread_first) ||
(c->viewer.varticles.unread_first != cfdata->viewer.varticles.unread_first) ||
(c->viewer.varticles.sort_date != cfdata->viewer.varticles.sort_date) ||

48
src/module/news_utils.c

@ -47,45 +47,33 @@ news_util_datecmp(struct tm *t1, struct tm *t2)
int
news_util_browser_open(const char *url)
{
News_Config *c = news->config;
Ecore_Exe *exe;
char cmd[4096];
char buf[4096];
if (!url) return 0;
switch((News_Util_Browser)c->browser.wich)
{
case NEWS_UTIL_BROWSER_FIREFOX:
snprintf(cmd, sizeof(cmd), "%s", "firefox -new-window");
break;
case NEWS_UTIL_BROWSER_FIREFOX_TAB:
snprintf(cmd, sizeof(cmd), "%s", "firefox -new-tab");
break;
case NEWS_UTIL_BROWSER_MOZILLA:
snprintf(cmd, sizeof(cmd), "%s", "mozilla");
break;
case NEWS_UTIL_BROWSER_OPERA:
snprintf(cmd, sizeof(cmd), "%s", "opera");
break;
case NEWS_UTIL_BROWSER_DILLO:
snprintf(cmd, sizeof(cmd), "%s", "dillo");
break;
case NEWS_UTIL_BROWSER_OWN:
snprintf(cmd, sizeof(cmd), "%s", c->browser.own);
break;
}
DBROWSER(("Exec %s with %s command", url, cmd));
snprintf(buf, sizeof(buf), "%s \"%s\"", cmd, url);
if(!ecore_file_app_installed("xdg-open"))
{
news_util_message_error_show("<hilight>xdg-open not found !</hilight><br><vr>"
"News module uses the xdg-open script from freedesktop.org<br>"
"to open urls.<br>"
"You need to install the <hilight>xdg-utils package</hilight>, wich includes that script.");
return 0;
}
snprintf(buf, sizeof(buf), "xdg-open \"%s\"", url);
DBROWSER(("Exec %s", buf));
exe = ecore_exe_pipe_run(buf, ECORE_EXE_USE_SH, NULL);
if (exe > 0)
ecore_exe_free(exe);
{
ecore_exe_free(exe);
}
else
{
news_util_message_error_show(_("<hilight>Error</hilight> when executing the command"
"for youre <hilight>browser</hilight> :<br><br>"
"%s"), cmd);
news_util_message_error_show("<hilight>Error when opening youre browser.</hilight><br><br>"
"News module uses the <hilight>xdg-open</hilight> script (xdg-utils package) from freedesktop.org<br>"
"to open urls. The script seems to be present, but maybe it is not"
"<hilight>configured corectly ?</hilight>");
return 0;
}

12
src/module/news_utils.h

@ -1,22 +1,10 @@
#ifdef E_MOD_NEWS_TYPEDEFS
typedef enum _News_Util_Browser
{
NEWS_UTIL_BROWSER_FIREFOX,
NEWS_UTIL_BROWSER_FIREFOX_TAB,
NEWS_UTIL_BROWSER_MOZILLA,
NEWS_UTIL_BROWSER_OPERA,
NEWS_UTIL_BROWSER_DILLO,
NEWS_UTIL_BROWSER_OWN
} News_Util_Browser;
#else
#ifndef NEWS_UTILS_H_INCLUDED
#define NEWS_UTILS_H_INCLUDED
#define NEWS_UTIL_BROWSER_DEFAULT NEWS_UTIL_BROWSER_FIREFOX
#define news_util_debug(args...) \
{ \
char __tmpbuf[4096]; \

Loading…
Cancel
Save