Commit cba81a75 authored by Jonh Wendell's avatar Jonh Wendell Committed by Jonh Wendell S. Santana
Browse files

Added a panel applet.

2008-06-13  Jonh Wendell <jwendell@gnome.org>

	* Added a panel applet.

svn path=/trunk/; revision=381
parent 1508bd63
2008-06-13 Jonh Wendell <jwendell@gnome.org>
* Added a panel applet.
2008-06-02 Jonh Wendell <jwendell@gnome.org>
* configure.ac: post-release bump to 2.23.4
......
......@@ -10,6 +10,7 @@ You need the devel packages of the following libraries:
- gnome-keyring
- gtk-vnc widget >= 0.3.5 (http://gtk-vnc.sf.net)
- avahi-gobject and avahi-ui >= 0.6.22
- libpanelapplet-2.0 >= 2.0.0
To compile it, just do:
......
......@@ -40,6 +40,7 @@ GCONF_REQUIRED=2.16.0
GTHREAD_REQUIRED=2.0.0
GTK_VNC_REQUIRED=0.3.6
AVAHI_REQUIRED=0.6.22
PANEL_REQUIRED_VERSION=2.0.0
PKG_CHECK_MODULES(VINAGRE, \
glib-2.0 >= $GLIB_REQUIRED \
......@@ -55,6 +56,11 @@ PKG_CHECK_MODULES(VINAGRE, \
AC_SUBST(VINAGRE_CFLAGS)
AC_SUBST(VINAGRE_LIBS)
PKG_CHECK_MODULES(APPLET, \
libpanelapplet-2.0 >= $PANEL_REQUIRED_VERSION)
AC_SUBST(APPLET_CFLAGS)
AC_SUBST(APPLET_LIBS)
dnl ================================================================
dnl GConf related settings
dnl ================================================================
......
<Root>
<popups>
<popup name="button3">
<menuitem
name="Help Item"
verb="VinagreHelp"
_label="_Help"
pixtype="stock"
pixname="gtk-help"/>
<menuitem
name="About Item"
verb="VinagreAbout"
_label="_About"
pixtype="stock"
pixname="gtk-about"/>
</popup>
</popups>
</Root>
......@@ -6,7 +6,7 @@ glade_DATA = vinagre.glade
man_MANS = vinagre.1
uidir = $(datadir)/vinagre
ui_DATA = vinagre-ui.xml
ui_DATA = vinagre-ui.xml GNOME_VinagreApplet.xml
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
......
# List of source files containing translatable strings.
data/GNOME_VinagreApplet.xml
data/vinagre.desktop.in.in
data/vinagre-file.desktop.in.in
data/vinagre.glade
data/vinagre.schemas.in
data/vinagre-mime.xml.in
data/vinagre-ui.xml
src/GNOME_VinagreApplet.server.in.in
src/vinagre-app.c
src/vinagre-applet.c
src/vinagre-bookmarks.c
src/vinagre-commands.c
src/vinagre-connect.c
......
<oaf_info>
<oaf_server iid="OAFIID:GNOME_VinagreApplet_Factory" type="exe"
location="@LIBEXECDIR@/vinagre-applet">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Vinagre Applet Factory"/>
<oaf_attribute name="description" type="string" _value="Vinagre Applet Factory"/>
<oaf_attribute name="bonobo:environment" type="stringv">
<item value="DBUS_SESSION_BUS_ADDRESS"/>
<oaf_attribute name="bugzilla:bugzilla" type="string" value="GNOME"/>
<oaf_attribute name="bugzilla:product" type="string" value="vinagre"/>
<oaf_attribute name="bugzilla:component" type="string" value="applet"/>
<oaf_attribute name="bugzilla:version" type="string" value="@VERSION@"/>
<oaf_attribute name="bugzilla:other_binaries" type="string" value="vinagre-applet"/>
</oaf_attribute>
</oaf_server>
<oaf_server iid="OAFIID:GNOME_VinagreApplet" type="factory"
location="OAFIID:GNOME_VinagreApplet_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Remote Desktop Viewer"/>
<oaf_attribute name="description" type="string" _value="A menu to quickly access remote machines"/>
<oaf_attribute name="panel:icon" type="string" value="vinagre"/>
<oaf_attribute name="bugzilla:bugzilla" type="string" value="GNOME"/>
<oaf_attribute name="bugzilla:product" type="string" value="vinagre-applet"/>
<oaf_attribute name="bugzilla:component" type="string" value="applet"/>
<oaf_attribute name="bugzilla:version" type="string" value="@VERSION@"/>
<oaf_attribute name="bugzilla:other_binaries" type="string" value="vinagre-applet"/>
</oaf_server>
</oaf_info>
......@@ -2,6 +2,10 @@ SUBDIRS = view
NULL =
##############################
# The main binary
##############################
INCLUDES = \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
......@@ -42,6 +46,51 @@ vinagre_LDADD = \
view/libview.la \
$(NULL)
##############################
# Bonobo .server
##############################
serverdir = \
$(libdir)/bonobo/servers
server_in_files = \
GNOME_VinagreApplet.server.in
server_DATA = \
$(server_in_files:.server.in=.server)
$(server_in_files): $(server_in_files:.server.in=.server.in.in)
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" -e "s|\@VERSION\@|$(VERSION)|" $< > $@
@INTLTOOL_SERVER_RULE@
##############################
# The applet binary
##############################
libexec_PROGRAMS = vinagre-applet
vinagre_applet_CFLAGS = \
$(APPLET_CFLAGS) \
$(NULL)
vinagre_applet_SOURCES = \
vinagre-applet.c \
vinagre-bookmarks.h vinagre-bookmarks.c \
vinagre-connection.h vinagre-connection.c \
vinagre-utils.h vinagre-utils.c \
vinagre-enums.h vinagre-enums.c \
vinagre-mdns.h vinagre-mdns.c \
$(NULL)
vinagre_applet_LDADD = \
$(APPLET_LIBS) \
$(VINAGRE_LIBS) \
$(NULL)
##############################
# Autogenerated stuff
##############################
vinagre_enum_headers = \
$(top_srcdir)/src/vinagre-connection.h \
$(NULL)
......@@ -77,8 +126,14 @@ BUILT_SOURCES = \
vinagre-enums.h \
$(NULL)
DISTCLEANFILES = \
$(BUILT_SOURCES) \
DISTCLEANFILES = \
$(BUILT_SOURCES) \
$(server_in_files) \
$(server_DATA) \
$(NULL)
EXTRA_DIST = \
GNOME_VinagreApplet.server.in.in \
$(NULL)
dist-hook:
......
/*
* vinagre-applet.c
* This file is part of vinagre
*
* Copyright (C) 2008 - Jonh Wendell <wendell@bani.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <glib.h>
#include <panel-applet.h>
#include <gtk/gtklabel.h>
#include "vinagre-bookmarks.h"
#include "vinagre-mdns.h"
#include "vinagre-utils.h"
#include "vinagre-connection.h"
#include "vinagre-commands.h"
#include <config.h>
static void
menu_position (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
GtkWidget *applet)
{
int applet_height, applet_width;
GtkRequisition requisition;
gdk_window_get_origin (applet->window, x, y);
gdk_drawable_get_size (applet->window, &applet_width, &applet_height);
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
switch (panel_applet_get_orient (PANEL_APPLET (applet)))
{
case PANEL_APPLET_ORIENT_DOWN:
*y += applet_height + 1;
break;
case PANEL_APPLET_ORIENT_UP:
*y = MAX (*y - requisition.height - 2, 2*applet_height);
break;
case PANEL_APPLET_ORIENT_LEFT:
*x = MAX (*x - requisition.width - 2, 2*applet_width);
break;
case PANEL_APPLET_ORIENT_RIGHT:
*x += applet_height + 1;
break;
default:
g_assert_not_reached ();
}
*push_in = TRUE;
}
static void
open_connection_cb (GtkMenuItem *item,
gpointer *user_data)
{
GError *err = NULL;
gchar **argv;
VinagreConnection *conn;
conn = VINAGRE_CONNECTION (g_object_get_data (G_OBJECT (item), "conn"));
argv = g_new0 (gchar *, 3);
argv[0] = g_strdup ("vinagre");
argv[1] = g_strdup (vinagre_connection_get_string_rep (conn, TRUE));
argv[2] = NULL;
if (!gdk_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (item)),
NULL,
argv,
NULL,
G_SPAWN_SEARCH_PATH,
NULL,
NULL,
NULL,
&err))
{
gchar *tmp;
tmp = g_strdup_printf (_("Could not run vinagre: %s"), err->message);
vinagre_utils_show_error (tmp, NULL);
g_error_free (err);
g_free (tmp);
}
g_strfreev (argv);
}
static void
fill_menu (GSList *all, GtkWidget *menu)
{
GtkWidget *item, *image;
if (g_slist_length (all) == 0)
return;
/* Separator */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
for (; all; all=all->next)
{
image = gtk_image_new_from_icon_name ("application-x-vnc", GTK_ICON_SIZE_MENU);
item = gtk_image_menu_item_new_with_label (vinagre_connection_get_name (all->data));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu),
item);
g_object_set_data (G_OBJECT (item), "conn", all->data);
g_signal_connect (item, "activate", G_CALLBACK (open_connection_cb), NULL);
}
}
static void
open_vinagre_cb (GtkMenuItem *item,
gpointer *user_data)
{
GError *err = NULL;
if (!g_spawn_command_line_async ("vinagre", &err))
{
gchar *tmp;
tmp = g_strdup_printf (_("Could not run vinagre: %s"), err->message);
vinagre_utils_show_error (tmp, NULL);
g_error_free (err);
g_free (tmp);
}
}
static gboolean
click_cb (GtkWidget *applet,
GdkEventButton *event,
gpointer user_data)
{
GtkWidget *menu, *item, *image;
GSList *all;
if ((event->type != GDK_BUTTON_PRESS) || (event->button != 1))
return FALSE;
menu = gtk_menu_new ();
/* Open, first item */
image = gtk_image_new_from_icon_name ("vinagre", GTK_ICON_SIZE_MENU);
item = gtk_image_menu_item_new_with_label (_("Open Remote Desktop Viewer"));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_signal_connect (item, "activate", G_CALLBACK (open_vinagre_cb), NULL);
all = vinagre_bookmarks_get_all (vinagre_bookmarks_get_default ());
fill_menu (all, menu);
all = vinagre_mdns_get_all (vinagre_mdns_get_default ());
fill_menu (all, menu);
gtk_widget_show_all (menu);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, (GtkMenuPositionFunc) menu_position, applet,
event->button, event->time);
return TRUE;
}
static void
help_cb (BonoboUIComponent *ui_container,
gpointer data,
const gchar *cname)
{
vinagre_utils_help_contents (NULL);
}
static void
about_cb (BonoboUIComponent *ui_container,
gpointer data,
const gchar *cname)
{
vinagre_utils_help_about (NULL);
}
static gboolean
vinagre_applet_fill (PanelApplet *applet,
const gchar *iid,
gpointer data)
{
GtkWidget *image, *button;
gchar *tmp;
static const BonoboUIVerb menu_verbs[] = {
BONOBO_UI_VERB ("VinagreHelp", help_cb),
BONOBO_UI_VERB ("VinagreAbout", about_cb),
BONOBO_UI_VERB_END
};
if (strcmp (iid, "OAFIID:GNOME_VinagreApplet") != 0)
return FALSE;
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
gtk_window_set_default_icon_name ("vinagre");
g_set_application_name (_("Remote Desktop Viewer"));
image = gtk_image_new_from_icon_name ("vinagre", GTK_ICON_SIZE_LARGE_TOOLBAR);
g_signal_connect (applet, "button-press-event", G_CALLBACK (click_cb), NULL);
tmp = g_strdup_printf ("%s\n%s",
_("Remote Desktop Viewer"),
_("Access your bookmarks"));
gtk_widget_set_tooltip_text (GTK_WIDGET (applet), tmp);
g_free (tmp);
panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
panel_applet_setup_menu_from_file (applet, NULL,
DATADIR "/vinagre/GNOME_VinagreApplet.xml",
NULL, menu_verbs, NULL);
gtk_container_add (GTK_CONTAINER (applet), image);
gtk_widget_show_all (GTK_WIDGET (applet));
return TRUE;
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_VinagreApplet_Factory",
PANEL_TYPE_APPLET,
"VinagreApplet",
"0",
vinagre_applet_fill,
NULL);
......@@ -368,138 +368,20 @@ vinagre_cmd_bookmarks_open (GtkAction *action,
vinagre_cmd_open_bookmark (window, conn);
}
/* Make url in about dialog clickable */
static void
vinagre_about_dialog_handle_url (GtkAboutDialog *about,
const char *link,
gpointer data)
{
GError *error = NULL;
gchar *address, *command;
VinagreWindow *window = VINAGRE_WINDOW (data);
if (g_strstr_len (link, strlen (link), "@"))
address = g_strdup_printf ("mailto:%s", link);
else
address = g_strdup (link);
command = g_strconcat ("gnome-open ", address, NULL);
gdk_spawn_command_line_on_screen (gtk_window_get_screen (GTK_WINDOW (window)),
command,
&error);
if (error != NULL)
{
vinagre_utils_show_error (error->message, GTK_WINDOW (window));
g_error_free (error);
}
g_free (command);
g_free (address);
}
/* Help Menu */
void
vinagre_cmd_help_contents (GtkAction *action,
VinagreWindow *window)
{
GError *error = NULL;
char *command;
const char *lang;
char *uri = NULL;
int i;
const char * const * langs = g_get_language_names ();
for (i = 0; langs[i]; i++)
{
lang = langs[i];
if (strchr (lang, '.'))
continue;
if (uri)
g_free (uri);
uri = g_build_filename (DATADIR, "/gnome/help/vinagre/", lang, "/vinagre.xml", NULL);
if (g_file_test (uri, G_FILE_TEST_EXISTS))
break;
}
command = g_strconcat ("gnome-open ghelp://", uri, NULL);
gdk_spawn_command_line_on_screen (gtk_window_get_screen (GTK_WINDOW (window)),
command,
&error);
if (error != NULL)
{
vinagre_utils_show_error (error->message, GTK_WINDOW (window));
g_error_free (error);
}
g_free (command);
g_free (uri);
vinagre_utils_help_contents (GTK_WINDOW (window));
}
void
vinagre_cmd_help_about (GtkAction *action,
VinagreWindow *window)
{
static const gchar * const authors[] = {
"Jonh Wendell <jwendell@gnome.org>",
NULL
};
static const gchar * const artists[] = {
"Vinicius Depizzol <vdepizzol@gmail.com>",
NULL
};
static const gchar copyright[] = \
"Copyright \xc2\xa9 2007 Jonh Wendell";
static const gchar comments[] = \
N_("Vinagre is a VNC client for the GNOME Desktop");
static const char *license[] = {
N_("Vinagre is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version."),
N_("Vinagre is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details."),
N_("You should have received a copy of the GNU General Public License "
"along with this program. If not, see <http://www.gnu.org/licenses/>.")
};
gchar *license_trans;
license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]),
_(license[2]), NULL);
/* Make URLs and email clickable in about dialog */
gtk_about_dialog_set_url_hook (vinagre_about_dialog_handle_url, window, NULL);
gtk_about_dialog_set_email_hook (vinagre_about_dialog_handle_url, window, NULL);
gtk_show_about_dialog (GTK_WINDOW (window),
"authors", authors,
"artists", artists,
"comments", _(comments),
"copyright", copyright,
"license", license_trans,
"wrap-license", TRUE,
"logo-icon-name", "vinagre",
"translator-credits", _("translator-credits"),
"version", VERSION,
"website", "http://www.gnome.org/projects/vinagre/",
"website-label", _("Vinagre Website"),
NULL);
g_free (license_trans);
vinagre_utils_help_about (GTK_WINDOW (window));
}
/* vim: ts=8 */
......@@ -19,6 +19,7 @@
*/
#include <string.h>
#include <glib/gi18n.h>
#include "vinagre-utils.h"
#define VINAGRE_GLADE_FILE "vinagre.glade"
......@@ -349,4 +350,142 @@ vinagre_utils_get_current_viewport (GdkScreen *screen,
#endif
}
/* Make url in about dialog clickable */
static void
vinagre_about_dialog_handle_url (GtkAboutDialog *about,
const char *link,
gpointer data)
{
GError *error = NULL;
gchar *address, *command;
gboolean has_window = GTK_IS_WINDOW (data);
if (g_strstr_len (link, strlen (link), "@"))
address = g_strdup_printf ("mailto:%s", link);
else
address = g_strdup (link);
command = g_strconcat ("gnome-open ", address, NULL);
if (has_window)
gdk_spawn_command_line_on_screen (gtk_window_get_screen (GTK_WINDOW (data)),
command,
&error);
else
g_spawn_command_line_async (command, &error);
if (error != NULL)
{
vinagre_utils_show_error (error->message, has_window?GTK_WINDOW (data):NULL);
g_error_free (error);
}