There is a similar code in our "xdg-open" version enlightenment_open. Could u check?
On Wednesday, August 15, 2012, Enlightenment SVN wrote: > Log: > abstract the "get terminal desktop" code into util code and now use > from e_exec AND in efm - open terminal here menu item is there with > code to set your default terminal in default applications too. > > > > Author: raster > Date: 2012-08-15 02:59:37 -0700 (Wed, 15 Aug 2012) > New Revision: 75290 > Trac: http://trac.enlightenment.org/e/changeset/75290 > > Modified: > trunk/e/src/bin/e_exec.c trunk/e/src/bin/e_utils.c > trunk/e/src/bin/e_utils.h > trunk/e/src/modules/conf_applications/e_int_config_defapps.c > trunk/e/src/modules/fileman/e_fwin.c > > Modified: trunk/e/src/bin/e_exec.c > =================================================================== > --- trunk/e/src/bin/e_exec.c 2012-08-15 09:52:26 UTC (rev 75289) > +++ trunk/e/src/bin/e_exec.c 2012-08-15 09:59:37 UTC (rev 75290) > @@ -264,38 +264,9 @@ > e_util_library_path_strip(); > if ((desktop) && (desktop->terminal)) > { > - Efreet_Desktop *tdesktop, *td; > - int i; > - // XXX: FIXME: this should become config some day... > - const char *terms[] = > - { > - "terminology.desktop", > - "xterm.desktop", > - "rxvt.desktop", > - "gnome-terimnal.desktop", > - "konsole.desktop", > - NULL > - }; > + Efreet_Desktop *tdesktop; > > - for (i = 0; terms[i]; i++) > - { > - tdesktop = efreet_util_desktop_file_id_find(terms[i]); > - if (tdesktop) break; > - } > - if (!tdesktop) > - { > - l = > efreet_util_desktop_category_list("TerminalEmulator"); > - if (l) > - { > - // just take first one since above list doesn't > work. > - tdesktop = l->data; > - EINA_LIST_FREE(l, td) > - { > - // free/unref the desktosp we are not going > to use > - if (td != tdesktop) efreet_desktop_free(td); > - } > - } > - } > + tdesktop = e_util_terminal_desktop_get(); > if (tdesktop) > { > if (tdesktop->exec) > > Modified: trunk/e/src/bin/e_utils.c > =================================================================== > --- trunk/e/src/bin/e_utils.c 2012-08-15 09:52:26 UTC (rev 75289) > +++ trunk/e/src/bin/e_utils.c 2012-08-15 09:59:37 UTC (rev 75290) > @@ -1451,3 +1451,73 @@ > _e_util_size_debug, NULL); > } > } > + > +static Efreet_Desktop * > +_e_util_default_terminal_get(const char *defaults_list) > +{ > + Efreet_Desktop *tdesktop = NULL; > + Efreet_Ini *ini; > + const char *s; > + > + ini = efreet_ini_new(defaults_list); > + if ((ini) && (ini->data) && > + (efreet_ini_section_set(ini, "Default Applications")) && > + (ini->section)) > + { > + s = efreet_ini_string_get(ini, "x-scheme-handler/terminal"); > + if (s) tdesktop = efreet_util_desktop_file_id_find(s); > + } > + if (ini) efreet_ini_free(ini); > + return tdesktop; > +} > + > +EAPI Efreet_Desktop * > +e_util_terminal_desktop_get(void) > +{ > + const char *terms[] = > + { > + "terminology.desktop", > + "xterm.desktop", > + "rxvt.desktop", > + "gnome-terimnal.desktop", > + "konsole.desktop", > + NULL > + }; > + const char *s; > + char buf[PATH_MAX]; > + Efreet_Desktop *tdesktop = NULL, *td; > + Eina_List *l; > + int i; > + > + snprintf(buf, sizeof(buf), "%s/applications/defaults.list", > + efreet_data_home_get()); > + tdesktop = _e_util_default_terminal_get(buf); > + if (tdesktop) return tdesktop; > + EINA_LIST_FOREACH(efreet_data_dirs_get(), l, s) > + { > + snprintf(buf, sizeof(buf), "%s/applications/defaults.list", s); > + tdesktop = _e_util_default_terminal_get(buf); > + if (tdesktop) return tdesktop; > + } > + > + for (i = 0; terms[i]; i++) > + { > + tdesktop = efreet_util_desktop_file_id_find(terms[i]); > + if (tdesktop) return tdesktop; > + } > + if (!tdesktop) > + { > + l = efreet_util_desktop_category_list("TerminalEmulator"); > + if (l) > + { > + // just take first one since above list doesn't work. > + tdesktop = l->data; > + EINA_LIST_FREE(l, td) > + { > + // free/unref the desktosp we are not going to use > + if (td != tdesktop) efreet_desktop_free(td); > + } > + } > + } > + return tdesktop; > +} > > Modified: trunk/e/src/bin/e_utils.h > =================================================================== > --- trunk/e/src/bin/e_utils.h 2012-08-15 09:52:26 UTC (rev 75289) > +++ trunk/e/src/bin/e_utils.h 2012-08-15 09:59:37 UTC (rev 75290) > @@ -65,5 +65,7 @@ > EAPI Eina_Bool e_util_fullscreen_any(void); > EAPI const char *e_util_time_str_get(long int seconds); > EAPI void e_util_size_debug_set(Evas_Object *obj, Eina_Bool enable); > +EAPI Efreet_Desktop *e_util_terminal_desktop_get(void); > + > #endif > #endif > > Modified: trunk/e/src/modules/conf_applications/e_int_config_defapps.c > =================================================================== > --- trunk/e/src/modules/conf_applications/e_int_config_defapps.c > 2012-08-15 09:52:26 UTC (rev 75289) > +++ trunk/e/src/modules/conf_applications/e_int_config_defapps.c > 2012-08-15 09:59:37 UTC (rev 75290) > @@ -35,6 +35,7 @@ > const char *mailto_desktop; > const char *file_desktop; > const char *trash_desktop; > + const char *terminal_desktop; > > Ecore_Event_Handler *desk_change_handler; > int gen; > @@ -134,6 +135,8 @@ > if (s) cfdata->file_desktop = eina_stringshare_add(s); > s = efreet_ini_string_get(myini, "x-scheme-handler/trash"); > if (s) cfdata->trash_desktop = eina_stringshare_add(s); > + s = efreet_ini_string_get(myini, "x-scheme-handler/terminal"); > + if (s) cfdata->terminal_desktop = eina_stringshare_add(s); > } > > EINA_LIST_FOREACH(e_config->env_vars, l, evr) > @@ -182,6 +185,7 @@ > if (cfdata->mailto_desktop) > eina_stringshare_del(cfdata->mailto_desktop); > if (cfdata->file_desktop) eina_stringshare_del(cfdata->file_desktop); > if (cfdata->trash_desktop) eina_stringshare_del(cfdata->trash_desktop); > + if (cfdata->terminal_desktop) > eina_stringshare_del(cfdata->terminal_desktop); > EINA_LIST_FREE(cfdata->mimes, m) > { > Config_Glob *g; > @@ -255,6 +259,15 @@ > } > > static void > +_def_terminal_cb(void *data) > +{ > + E_Config_Dialog_Data *cfdata = data; > + cfdata->seldest = &(cfdata->terminal_desktop); > + _fill_apps_list(cfdata, cfdata->obj.deflist, cfdata->seldest, 0); > + cfdata->gen = 0; > +} > + > +static void > _sel_mime_cb(void *data) > { > E_Config_Dialog_Data *cfdata = data; > @@ -297,6 +310,7 @@ > e_widget_ilist_append(il, NULL, _("E-Mail"), _def_mailto_cb, cfdata, > NULL); > e_widget_ilist_append(il, NULL, _("File"), _def_file_cb, cfdata, NULL); > e_widget_ilist_append(il, NULL, _("Trash"), _def_trash_cb, cfdata, > NULL); > + e_widget_ilist_append(il, NULL, _("Terminal"), _def_terminal_cb, > cfdata, NULL); > e_widget_ilist_go(il); > e_widget_ilist_thaw(il); > edje_thaw(); > @@ -376,6 +390,9 @@ > if ((cfdata->trash_desktop) && (cfdata->trash_desktop[0])) > efreet_ini_string_set(cfdata->ini, "x-scheme-handler/trash", > cfdata->trash_desktop); > + if ((cfdata->terminal_desktop) && (cfdata->terminal_desktop[0])) > + efreet_ini_string_set(cfdata->ini, "x-scheme-handler/terminal", > + cfdata->terminal_desktop); > snprintf(buf, sizeof(buf), "%s/applications/defaults.list", > efreet_data_home_get()); > efreet_ini_save(cfdata->ini, buf); > > Modified: trunk/e/src/modules/fileman/e_fwin.c > =================================================================== > --- trunk/e/src/modules/fileman/e_fwin.c 2012-08-15 09:52:26 UTC > (rev 75289) > +++ trunk/e/src/modules/fileman/e_fwin.c 2012-08-15 09:59:37 UTC > (rev 75290) > @@ -141,6 +141,9 @@ > static void _e_fwin_parent(void *data, > E_Menu *m, > E_Menu_Item *mi); > +static void _e_fwin_terminal(void *data, > + E_Menu *m, > + E_Menu_Item *mi); > static void _e_fwin_cb_key_down(void *data, > Evas *e, > Evas_Object *obj, > @@ -1806,7 +1809,7 @@ > > /* fm menu extend */ > static void > -_e_fwin_menu_extend(void *data __UNUSED__, > +_e_fwin_menu_extend(void *data, > Evas_Object *obj, > E_Menu *m, > E_Fm2_Icon_Info *info __UNUSED__) > @@ -1815,6 +1818,8 @@ > > if (e_fm2_has_parent_get(obj)) > { > + Efreet_Desktop *tdesktop; > + > mi = e_menu_item_new(m); > e_menu_item_separator_set(mi, 1); > > @@ -1825,6 +1830,24 @@ > > "e/fileman/default/button/parent"), > "e/fileman/default/button/parent"); > e_menu_item_callback_set(mi, _e_fwin_parent, obj); > + > + tdesktop = e_util_terminal_desktop_get(); > + if (tdesktop) > + { > + E_Fwin_Page *page = data; > + > + mi = e_menu_item_new(m); > + e_menu_item_label_set(mi, _("Open Terminal Here")); > + e_menu_item_callback_set(mi, _e_fwin_terminal, page->fwin); > + if (tdesktop->icon) > + { > + if (tdesktop->icon[0] == '/') > + e_menu_item_icon_file_set(mi, tdesktop->icon); > + else > + e_util_menu_item_theme_icon_set(mi, tdesktop->icon); > + } > + efreet_desktop_free(tdesktop); > + } > } > /* FIXME: if info != null then check mime type and offer options based > * on that > @@ -1840,6 +1863,36 @@ > } > > static void > +_e_fwin_terminal(void *data, > + E_Menu *m __UNUSED__, > + E_Menu_Item *mi __UNUSED__) > +{ > + E_Fwin *fwin = data; > + Efreet_Desktop *tdesktop; > + > + if (!fwin->cur_page) return; > + tdesktop = e_util_terminal_desktop_get(); > + if (tdesktop) > + { > + char buf[PATH_MAX]; > + > + if (getcwd(buf, sizeof(buf)) > 0) > + { > + const char *path; > + > + path = e_fm2_real_path_get(fwin->cur_page->fm_obj); > + if (path) > + { > + chdir(path); > + e_exec(fwin->zone, tdesktop, NULL, NULL, "fileman"); > + chdir(buf); > + } > + } > + efreet_desktop_free(tdesktop); > + } > +} > + > +static void > _e_fwin_cb_menu_open_fast(void *data, > E_Menu *m __UNUSED__, > E_Menu_Item *mi) > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: [email protected] Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
