Finding installed applications

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding installed applications

James McArthur-4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

- From the Gnome Control Center you can specify which applications should
be used for which file types.

How can I query that list from inside my Perl/Gtk2 application so that I
use the correct application to view files?

Thanks!

James
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC8WfO0hcObScku/YRAupPAJwIYQL88aTNVh7s6lxsEjDOOv6eMgCgtzH2
fmJ19gk5mJ1yIizra/xIlDM=
=WS7T
-----END PGP SIGNATURE-----
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Finding installed applications

muppet-6

On Aug 3, 2005, at 8:56 PM, James McArthur wrote:

> - From the Gnome Control Center you can specify which applications  
> should
> be used for which file types.
>
> How can I query that list from inside my Perl/Gtk2 application so  
> that I
> use the correct application to view files?

All that stuff works by mime types and handlers.

It appears that gnome_vfs_mime_get_default_application() is not bound  
in Gnome2::VFS.

I expect this to work, but it doesn't:

   use strict;
   use Gnome2::VFS -init;
   my $uri = "file://$ENV{HOME}/foo.txt";
   my $mime_type_str = Gnome2::VFS->get_mime_type ($uri);
   my $mime_type = Gnome2::VFS::Mime::Type->new ($mime_type_str);
   my $application = $mime_type->get_default_application;
   print "application => $application\n";

Everything works up until get_default_application, which returns  
undef.  :-/

--
If I lived in Teletubby Land, the homicide rate would be four.
   -- elysse

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Finding installed applications

Torsten Schoenfeld
On Thu, 2005-08-04 at 00:06 -0400, muppet wrote:

> It appears that gnome_vfs_mime_get_default_application() is not bound  
> in Gnome2::VFS.

It is, and you use it below. :-)

> I expect this to work, but it doesn't:
>
>    use strict;
>    use Gnome2::VFS -init;
>    my $uri = "file://$ENV{HOME}/foo.txt";
>    my $mime_type_str = Gnome2::VFS->get_mime_type ($uri);
>    my $mime_type = Gnome2::VFS::Mime::Type->new ($mime_type_str);
>    my $application = $mime_type->get_default_application;
>    print "application => $application\n";
>
> Everything works up until get_default_application, which returns  
> undef.  :-/

Well, works for me (after changing foo.txt to something that exists):

  application => Gnome2::VFS::Mime::Application=HASH(0x8144d88)

$application->launch(@uris) would launch the app.

--
Bye,
-Torsten

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Finding installed applications

muppet-6

Torsten Schoenfeld said:
> On Thu, 2005-08-04 at 00:06 -0400, muppet wrote:
>
>> It appears that gnome_vfs_mime_get_default_application() is not bound
>> in Gnome2::VFS.
>
> It is, and you use it below. :-)

There's gnome_vfs_mime_get_default_application(), which didn't work, and
gnome_vfs_mime_type_get_default_application(), which did, unless the former is
bound in perl as the latter.


>> Everything works up until get_default_application, which returns
>> undef.  :-/
>
> Well, works for me (after changing foo.txt to something that exists):

My system must hate me.


--
muppet <scott at asofyet dot org>

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Finding installed applications

James McArthur-4
In reply to this post by James McArthur-4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Thanks muppet and Torsten. The example code worked .. sort of :)

When I use the ->launch () method there is a segmentation fault .. so as
soon as I figure out why gdb dislikes my core files I'll have a poke around.

James
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC8uWO0hcObScku/YRAsNGAJ9XICkXdigUJEArfAFDAztEmZR/JgCbBL0y
DBLaJsrFNmwqIr4ltsmbqq0=
=lH+h
-----END PGP SIGNATURE-----
_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Finding installed applications

Jan Hudec
In reply to this post by muppet-6
On Thu, Aug 04, 2005 at 14:54:22 -0400, muppet wrote:

>
> Torsten Schoenfeld said:
> > On Thu, 2005-08-04 at 00:06 -0400, muppet wrote:
> >
> >> It appears that gnome_vfs_mime_get_default_application() is not bound
> >> in Gnome2::VFS.
> >
> > It is, and you use it below. :-)
>
> There's gnome_vfs_mime_get_default_application(), which didn't work, and
> gnome_vfs_mime_type_get_default_application(), which did, unless the former is
> bound in perl as the latter.
>
>
> >> Everything works up until get_default_application, which returns
> >> undef.  :-/
> >
> > Well, works for me (after changing foo.txt to something that exists):
>
> My system must hate me.
... unlike windows, where the detection is purely extension-based, Gnome
is supposed to look at magic numbers too. So for files, they must be
opened to find their mime-type. Files that don't exist don't have
mime-types (or get some useless default like application/octet-stream).

(I'd assume it relies on header for network resources).

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec <[hidden email]>

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Finding installed applications

Torsten Schoenfeld
In reply to this post by muppet-6
On Thu, 2005-08-04 at 14:54 -0400, muppet wrote:

> >> It appears that gnome_vfs_mime_get_default_application() is not bound
> >> in Gnome2::VFS.
> >
> > It is, and you use it below. :-)
>
> There's gnome_vfs_mime_get_default_application(), which didn't work, and
> gnome_vfs_mime_type_get_default_application(), which did, unless the former is
> bound in perl as the latter.

AFAICT, gnome_vfs_mime_type_get_default_application() doesn't exist
(according to Google and grep).
gnome_vfs_mime_get_default_application() is the one you use in your
example.  The Gnome2::VFS::Mime::Type object is a custom thing that I
created to make the API less ugly.  In retrospect I'm not sure that was
a good idea, though.

--
Bye,
-Torsten

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list