! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Global function to check if a string looks like an uri


Description Nick Schermer editbugs 2009-08-29 20:57:05 CEST
Created attachment 2521 
Add xfce_looks_like_an_uri.

Would be nice to have this kinda for function in a central place, since we use
it more often nowadays.

Suggestions for a better name are welcome :-).
Comment 1 Brian J. Tarricone (not reading bugmail) 2009-08-29 21:06:05 CEST
xfce_str_is_uri() or xfce_string_is_uri().

What core apps need to guess if a string is an URI or not?  If it's just for conversion, what's wrong with g_filename_from_uri() and friends?
Comment 2 Nick Schermer editbugs 2009-08-29 21:20:26 CEST
Right now it is used in exo, thunar, garcon (but that is not using xfce libraries) and panel. So technically exo could be used too.

Duno about _is_uri, I guess it's fine, but the string "look: I'm online" will return true too.

The function is handy then you work with gio, if you have a string (from a config file or dnd for example) you can use this function to pick between g_file_new_for_{uri,path}, in exo-open it is used to decide if we can use gtk_show_uri directly or perform some additional check if it's a file, email address, website etc.
Comment 3 Jannis Pohlmann editbugs 2009-08-29 21:43:21 CEST
Thinking about it again... Garcon is not going to depend on any Xfce libraries, so there it won't be useful. 

Thunar could use it because if you have a random string (entered by the user) and you want to create a GFile, there's no way around distinguishing between URIs and local paths. There you need a function like that. I guess exo needs it to, it also takes random strings via e.g. exo-open and needs to find out if they are local paths or URIs.

I suppose the appfinder could also use it, should I extend it in a way that allows arbitrary strings to be executed/launched. But since there is no code for it yet, I'm not sure. 

I think random user input is about the only situation where this is really needed. Other (core) components you can think of where this might be important?
Comment 4 Brian J. Tarricone (not reading bugmail) 2009-08-30 06:16:23 CEST
Ah ok, I see.  xfce_looks_like_an_uri() is kinda silly name, but... hehe, why not?
Comment 5 Jannis Pohlmann editbugs 2009-08-30 11:08:00 CEST
I think I'd prefer xfce_str_looks_like_an_uri() but I don't care too much.
Comment 6 Nick Schermer editbugs 2009-09-02 08:50:58 CEST
Thinking about it, exo is probably a better place for this function. All applications that will use it link to exo and it is somewhat more of an application then a desktop function.

So if everybody if fine with this, I'll add exo_str_looks_like_an_uri().
Comment 7 Jannis Pohlmann editbugs 2009-09-02 11:16:48 CEST
Jep, fine with me.
Comment 8 Nick Schermer editbugs 2009-10-16 19:40:14 CEST
Added function to exo.

Bug #5710

Reported by:
Nick Schermer
Reported on: 2009-08-29
Last modified on: 2009-10-16


Xfce Bug Triage
CC List:
2 users




Add xfce_looks_like_an_uri. (1.72 KB, patch)
2009-08-29 20:57 CEST , Nick Schermer
no flags

Additional information