Commit 4acf5a65 authored by Jonh Wendell S. Santana's avatar Jonh Wendell S. Santana
Browse files

Support .vnc files

svn path=/trunk/; revision=77
parent 3a85d5ff
2007-11-06 Jonh Wendell <jwendell@gnome.org>
Initial support to load .vnc files:
* configure.ac: Added gnome-vfs as a dependency
* src/vinagre-tab.c: Use "x-remote-connection" in recent connection
* src/vinagre-main.c: Parse filenames as parameters ("-f" command line flag)
* src/vinagre-connection.[ch]: vinagre_connection_new_from_file (): new function
2007-10-21 Jonh Wendell <jwendell@gnome.org>
* src/vinagre-tab.c,
......
......@@ -44,6 +44,7 @@ PKG_CHECK_MODULES(VINAGRE, \
libglade-2.0 >= $LIBGLADE_REQUIRED \
gconf-2.0 >= $GCONF_REQUIRED \
gnome-keyring-1 \
gnome-vfs-2.0 \
gtk-vnc-1.0)
AC_SUBST(VINAGRE_CFLAGS)
AC_SUBST(VINAGRE_LIBS)
......@@ -80,6 +81,7 @@ AC_OUTPUT([
Makefile
data/Makefile
data/vinagre.desktop.in
data/vinagre-file.desktop.in
po/Makefile.in
src/Makefile
])
......
......@@ -9,7 +9,7 @@ icons_DATA = vinagre.svg
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_in_files = vinagre.desktop.in
desktop_in_files = vinagre.desktop.in vinagre-file.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_XML_RULE@
......@@ -44,7 +44,9 @@ UPDATE_DESKTOP = \
UPDATE_ICON = gtk-update-icon-cache -f -t $(DESTDIR)$(datadir)/icons/hicolor
CLEAR_SLINK = rm -f $(DESTDIR)$(datadir)/icons/hicolor/scalable/mimetypes/application-x-vnc.svg
CLEAR_SLINK = \
rm -f $(DESTDIR)$(datadir)/icons/hicolor/scalable/mimetypes/application-x-vnc.svg \
rm -f $(DESTDIR)$(datadir)/icons/hicolor/scalable/mimetypes/application-x-remote-connection.svg
install-data-hook:
$(UPDATE_MIME)
......@@ -52,6 +54,7 @@ install-data-hook:
$(CLEAR_SLINK)
mkdir -p $(DESTDIR)$(datadir)/icons/hicolor/scalable/mimetypes/
ln -s $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/vinagre.svg $(DESTDIR)$(datadir)/icons/hicolor/scalable/mimetypes/application-x-vnc.svg
ln -s $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/vinagre.svg $(DESTDIR)$(datadir)/icons/hicolor/scalable/mimetypes/application-x-remote-connection.svg
$(UPDATE_ICON)
uninstall-hook:
......
[Desktop Entry]
_Name=Remote Desktop Viewer
_Comment=Access remote desktops
Exec=vinagre -f %U
Icon=vinagre
Terminal=false
Type=Application
StartupNotify=true
MimeType=application/x-vnc
Categories=GNOME;GTK;Network;
OnlyShowIn=GNOME;
NoDisplay=true
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=vinagre
X-GNOME-Bugzilla-Component=general
X-GNOME-Bugzilla-Version=@VERSION@
......@@ -5,4 +5,7 @@
<_comment>Remote Desktop (VNC) file</_comment>
<glob pattern="*.vnc"/>
</mime-type>
<mime-type type="application/x-remote-connection">
<_comment>Remote Desktop Connection</_comment>
</mime-type>
</mime-info>
......@@ -3,8 +3,8 @@ _Name=Remote Desktop Viewer
_Comment=Access remote desktops
Exec=vinagre %U
Icon=vinagre
MimeType=application/x-vnc;
Terminal=false
MimeType=application/x-remote-connection
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Network;
......
# List of source files containing translatable strings.
data/vinagre.desktop.in.in
data/vinagre-file.desktop.in.in
data/vinagre.glade
data/vinagre-mime.xml.in
data/vinagre-ui.xml
......
data/vinagre.desktop.in
data/vinagre-file.desktop.in
data/vinagre-mime.xml.in
......@@ -353,3 +353,4 @@ vinagre_bookmarks_exists (const char *host, int port)
return conn;
}
/* vim: ts=8 */
......@@ -41,3 +41,4 @@ GList *vinagre_bookmarks_get_all (void);
VinagreConnection *vinagre_bookmarks_exists (const char *host, int port);
#endif /* __VINAGRE_FAVORITES_H__ */
/* vim: ts=8 */
......@@ -19,6 +19,9 @@
*/
#include <stdlib.h>
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs.h>
#include "vinagre-connection.h"
#include "vinagre-bookmarks.h"
......@@ -138,6 +141,7 @@ vinagre_connection_clone (VinagreConnection *conn)
return new_conn;
}
VinagreConnection
*vinagre_connection_new_from_string (const gchar *url)
{
......@@ -161,3 +165,69 @@ VinagreConnection
g_strfreev (server);
return conn;
}
VinagreConnection
*vinagre_connection_new_from_file (const gchar *uri)
{
GKeyFile *file;
GError *error = NULL;
gboolean loaded;
VinagreConnection *conn = NULL;
gchar *host = NULL;
gint port;
GnomeVFSResult result;
int file_size;
char *data = NULL;
result = gnome_vfs_read_entire_file (uri, &file_size, &data);
if (result != GNOME_VFS_OK)
{
const char *error_string;
error_string = gnome_vfs_result_to_string (result);
g_warning (_("Error while opening the file (%s): %s\n"), uri, error_string);
if (data)
g_free (data);
return NULL;
}
file = g_key_file_new ();
loaded = g_key_file_load_from_data (file,
data,
file_size,
G_KEY_FILE_NONE,
&error);
if (loaded)
{
host = g_key_file_get_string (file, "connection", "host", NULL);
port = g_key_file_get_integer (file, "connection", "port", NULL);
if (host)
{
conn = vinagre_bookmarks_exists (host, port);
if (!conn)
{
conn = vinagre_connection_new ();
vinagre_connection_set_host (conn, host);
vinagre_connection_set_port (conn, port);
}
g_free (host);
}
}
else
{
if (error)
{
g_warning (_("Error while opening the file (%s): %s\n"), uri, error->message);
g_error_free (error);
}
}
if (data)
g_free (data);
g_key_file_free (file);
return conn;
}
/* vim: ts=8 */
......@@ -52,5 +52,7 @@ gchar *vinagre_connection_best_name (VinagreConnection *conn);
VinagreConnection *vinagre_connection_clone (VinagreConnection *conn);
VinagreConnection *vinagre_connection_new_from_string (const gchar *url);
VinagreConnection *vinagre_connection_new_from_file (const gchar *uri);
#endif /* __VINAGRE_CONNECTION_H__ */
/* vim: ts=8 */
......@@ -485,3 +485,4 @@ vinagre_fav_update_list (VinagreFav *fav)
g_list_free (list);
}
/* vim: ts=8 */
......@@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glib/goption.h>
#include <libgnomevfs/gnome-vfs.h>
#include <config.h>
#include "vinagre-prefs-manager.h"
......@@ -31,15 +32,20 @@
#include "vinagre-window.h"
/* command line */
static gchar **files = NULL;
static gchar **remaining_args = NULL;
static GSList *servers = NULL;
static const GOptionEntry options [] =
{
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &remaining_args,
NULL, N_("[server:port]") },
{ "file", 'f', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
N_("Opens a .vnc file"), N_("filename")},
{ NULL }
{
G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,
NULL, N_("[server:port]") },
{ NULL }
};
static void
......@@ -48,12 +54,23 @@ vinagre_main_process_command_line (void)
gint i;
VinagreConnection *conn;
if (files)
{
for (i = 0; files[i]; i++)
{
conn = vinagre_connection_new_from_file (files[i]);
if (conn)
servers = g_slist_append (servers, conn);
}
}
if (remaining_args)
{
for (i = 0; remaining_args[i]; i++)
{
conn = vinagre_connection_new_from_string (remaining_args[i]);
servers = g_slist_append (servers, conn);
if (conn)
servers = g_slist_append (servers, conn);
}
}
}
......@@ -78,6 +95,10 @@ int main (int argc, char **argv) {
g_thread_init (NULL);
g_set_application_name (_("Remote Desktop Viewer"));
if (!gnome_vfs_init ())
g_error (_("Could not initialize GnomeVFS\n"));
vinagre_prefs_manager_init ();
main_window = vinagre_window_new ();
......@@ -96,6 +117,8 @@ int main (int argc, char **argv) {
gtk_main ();
vinagre_prefs_manager_shutdown ();
gnome_vfs_shutdown ();
return 0;
}
/* vim: ts=8 */
......@@ -365,7 +365,7 @@ vinagre_tab_add_recent_used (VinagreTab *tab)
data->display_name = vinagre_connection_best_name (tab->priv->conn);
data->description = NULL;
data->mime_type = g_strdup ("application/x-vnc");
data->mime_type = g_strdup ("application/x-remote-connection");
data->app_name = (gchar *) g_get_application_name ();
data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
data->groups = groups;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment