commit 63ca6eda2b9f20560945bbafa5eadd1cf79ef0dc
Author: Frédéric Péters <fpeters@0d.be>
Date:   Thu Jun 24 00:39:24 2010 +0200

    Port capplet to be a control center 3.0 panel

diff --git a/capplet/Makefile.am b/capplet/Makefile.am
index 546d817..4c357e6 100644
--- a/capplet/Makefile.am
+++ b/capplet/Makefile.am
@@ -7,21 +7,20 @@ INCLUDES = \
 	$(VINO_CAPPLET_CFLAGS) \
 	$(VINO_KEYRING_CFLAGS) \
 	$(VINO_HTTP_CFLAGS) \
-	$(VINO_LIBUNIQUE_CFLAGS) \
 	$(WARN_CFLAGS) \
 	$(NULL)
 
-bin_PROGRAMS = vino-preferences
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libvino.la
 
-vino_preferences_SOURCES = \
-	vino-preferences.c \
+libvino_la_SOURCES = \
+	vino-preferences.c vino-preferences.h \
 	vino-message-box.h vino-message-box.c \
 	vino-url-webservice.h vino-url-webservice.c \
 	$(NULL)
-vino_preferences_LDADD = \
+libvino_la_LIBADD = \
 	$(VINO_CAPPLET_LIBS) \
 	$(VINO_KEYRING_LIBS) \
-	$(VINO_LIBUNIQUE_LIBS) \
 	$(X_LIBS) \
 	$(NULL)
 
diff --git a/capplet/vino-preferences.c b/capplet/vino-preferences.c
index 7c6f1b6..0c9ccfe 100644
--- a/capplet/vino-preferences.c
+++ b/capplet/vino-preferences.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2003 Sun Microsystems, Inc.
  * Copyright (C) 2006 Jonh Wendell <wendell@bani.com.br> 
+ * Copyright (C) 2010 Frederic Peters
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -31,15 +32,12 @@
 #include <libsoup/soup.h>
 #include "vino-message-box.h"
 #include "vino-url-webservice.h"
+#include "vino-preferences.h"
 
 #ifdef VINO_ENABLE_KEYRING
 #include <gnome-keyring.h>
 #endif
 
-#ifdef VINO_ENABLE_LIBUNIQUE
-#include <unique/unique.h>
-#endif
-
 #define VINO_PREFS_DIR                    "/desktop/gnome/remote_access"
 #define VINO_PREFS_ENABLED                VINO_PREFS_DIR "/enabled"
 #define VINO_PREFS_PROMPT_ENABLED         VINO_PREFS_DIR "/prompt_enabled"
@@ -54,7 +52,7 @@
 #define VINO_DBUS_BUS_NAME  "org.gnome.Vino"
 #define VINO_DBUS_INTERFACE "org.gnome.VinoScreen"
 
-typedef struct {
+struct _VinoPreferencesDialog {
   GtkBuilder  *builder;
   GConfClient *client;
 
@@ -70,9 +68,6 @@ typedef struct {
   GtkWidget   *icon_client_radio;
   GtkWidget   *icon_never_radio;
   GtkWidget   *use_upnp_toggle;
-#ifdef VINO_ENABLE_LIBUNIQUE
-  UniqueApp   *app;
-#endif
 
   DBusGConnection *connection;
   DBusGProxy      *proxy;
@@ -88,7 +83,7 @@ typedef struct {
 
   guint        use_password : 1;
   guint        retrieving_info : 1;
-} VinoPreferencesDialog;
+};
 
 static void vino_preferences_dialog_update_message_box (VinoPreferencesDialog *dialog);
 
@@ -774,57 +769,6 @@ vino_preferences_dialog_setup_use_upnp_toggle (VinoPreferencesDialog *dialog)
 }
 
 static void
-vino_preferences_dialog_response (GtkWidget             *widget,
-				  int                    response,
-				  VinoPreferencesDialog *dialog)
-{
-  GError    *error;
-  GdkScreen *screen;
-
-  if (response != GTK_RESPONSE_HELP)
-    {
-      if (dialog->session)
-        soup_session_abort (dialog->session);
-      gtk_widget_destroy (widget);
-      return;
-    }
-
-  screen = gtk_widget_get_screen (widget);
-  error = NULL;
-
-  gtk_show_uri (screen, "ghelp:user-guide?goscustdesk-90", GDK_CURRENT_TIME, &error);
-  if (error)
-    {
-      GtkWidget *message_dialog;
-
-      message_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog->dialog),
-					       GTK_DIALOG_DESTROY_WITH_PARENT,
-					       GTK_MESSAGE_ERROR,
-					       GTK_BUTTONS_CLOSE,
-					       _("There was an error displaying help:\n%s"),
-					       error->message);
-      gtk_window_set_resizable (GTK_WINDOW (message_dialog), FALSE);
-
-      g_signal_connect (message_dialog, "response",
-			G_CALLBACK (gtk_widget_destroy),
-			NULL);
-
-      gtk_widget_show (message_dialog);
-
-      g_error_free (error);
-    }
-}
-
-static void
-vino_preferences_dialog_destroyed (GtkWidget             *widget,
-				   VinoPreferencesDialog *dialog)
-{
-  dialog->dialog = NULL;
-
-  gtk_main_quit ();
-}
-
-static void
 error_message (VinoPreferencesDialog *dialog)
 {
   gchar   *host, *avahi_host;
@@ -1052,7 +996,7 @@ vino_preferences_start_listening (VinoPreferencesDialog *dialog)
   gchar       *obj_path;
   GdkScreen   *screen;
 
-  screen = gtk_window_get_screen (GTK_WINDOW (dialog->dialog));
+  screen = gtk_widget_get_screen (dialog->dialog);
   obj_path = g_strdup_printf ("/org/gnome/vino/screens/%d",
                               gdk_screen_get_number (screen));
   dialog->proxy = dbus_g_proxy_new_for_name (dialog->connection,
@@ -1096,12 +1040,6 @@ vino_preferences_dialog_init (VinoPreferencesDialog *dialog)
   dialog->dialog = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "vino_dialog"));
   g_assert (dialog->dialog != NULL);
 
-  g_signal_connect (dialog->dialog, "response",
-		    G_CALLBACK (vino_preferences_dialog_response), dialog);
-  g_signal_connect (dialog->dialog, "destroy",
-		    G_CALLBACK (vino_preferences_dialog_destroyed), dialog);
-  g_signal_connect (dialog->dialog, "delete_event", G_CALLBACK (gtk_true), NULL);
-
   dialog->client = gconf_client_get_default ();
   gconf_client_add_dir (dialog->client, VINO_PREFS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
 
@@ -1132,16 +1070,11 @@ vino_preferences_dialog_init (VinoPreferencesDialog *dialog)
       g_error_free (error);
       return FALSE;
     }
-  vino_preferences_start_listening (dialog);
 
   vino_preferences_dialog_setup_message_box (dialog);
 
   gtk_widget_show (dialog->dialog);
 
-#ifdef VINO_ENABLE_LIBUNIQUE
-  unique_app_watch_window (dialog->app, GTK_WINDOW (dialog->dialog));
-#endif
-
   return TRUE;
 
 #undef VINO_UI_FILE  
@@ -1176,12 +1109,6 @@ vino_preferences_dialog_finalize (VinoPreferencesDialog *dialog)
     g_object_unref (dialog->builder);
   dialog->builder = NULL;
 
-#ifdef VINO_ENABLE_LIBUNIQUE
-  if (dialog->app)
-    g_object_unref (dialog->app);
-  dialog->app = NULL;
-#endif
-
   if (dialog->session)
     g_object_unref (dialog->session);
   dialog->session = NULL;
@@ -1195,53 +1122,78 @@ vino_preferences_dialog_finalize (VinoPreferencesDialog *dialog)
   dialog->connection = NULL;
 }
 
-static gboolean
-vino_preferences_is_running (VinoPreferencesDialog *dialog)
+
+G_DEFINE_DYNAMIC_TYPE (CcVinoPanel, cc_vino_panel, CC_TYPE_PANEL)
+
+static void cc_vino_panel_finalize (GObject *object);
+
+static void
+cc_vino_panel_class_init (CcVinoPanelClass *klass)
 {
-#ifdef VINO_ENABLE_LIBUNIQUE
-  dialog->app = unique_app_new ("org.gnome.Vino.Preferences", NULL);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  if (unique_app_is_running (dialog->app))
-    {
-      UniqueResponse response;
+  object_class->finalize = cc_vino_panel_finalize;
+}
 
-      response = unique_app_send_message (dialog->app, UNIQUE_ACTIVATE, NULL);
-        
-      g_object_unref (dialog->app);
-      dialog->app = NULL;
-       
-      return response == UNIQUE_RESPONSE_OK;
-    }
-  else
-    return FALSE;
-#else
-  return FALSE;
-#endif
+static void
+cc_vino_panel_class_finalize (CcVinoPanelClass *klass)
+{
 }
 
-int
-main (int argc, char **argv)
+static void
+cc_vino_panel_finalize (GObject *object)
 {
-  VinoPreferencesDialog dialog = { NULL, };
+  CcVinoPanel *panel = CC_VINO_PANEL (object);
 
-  bindtextdomain (GETTEXT_PACKAGE, VINO_LOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  textdomain (GETTEXT_PACKAGE);
+  if (panel->private_data != NULL) {
+    vino_preferences_dialog_finalize (panel->private_data);
+    g_free (panel->private_data);
+    panel->private_data = NULL;
+  }
 
-  gtk_init (&argc, &argv);
+  G_OBJECT_CLASS (cc_vino_panel_parent_class)->finalize (object);
+}
 
-  if (vino_preferences_is_running (&dialog))
-    return 0;
-  
-  if (!vino_preferences_dialog_init (&dialog))
+static void
+cc_vino_panel_init (CcVinoPanel *self)
+{
+  gtk_window_set_default_icon_name ("preferences-desktop-remote-desktop");
+
+  self->private_data = g_new0 (VinoPreferencesDialog, 1);
+
+  if (!vino_preferences_dialog_init (self->private_data))
     {
-      vino_preferences_dialog_finalize (&dialog);
-      return 1;
+      vino_preferences_dialog_finalize (self->private_data);
+      return;
     }
 
-  gtk_main ();
+  gtk_container_add (GTK_CONTAINER (self), self->private_data->dialog);
+  vino_preferences_start_listening (self->private_data);
+  gtk_widget_show (self->private_data->dialog);
+}
 
-  vino_preferences_dialog_finalize (&dialog);
+void
+cc_vino_panel_register (GIOModule *module)
+{
+  cc_vino_panel_register_type (G_TYPE_MODULE (module));
+  g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+          CC_TYPE_VINO_PANEL,
+          "vino", 0);
+}
 
-  return 0;
+/* GIO extension stuff */
+void
+g_io_module_load (GIOModule *module)
+{
+  bindtextdomain (GETTEXT_PACKAGE, VINO_LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
+  /* register the panel */
+  cc_vino_panel_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
 }
diff --git a/capplet/vino-preferences.desktop.in.in b/capplet/vino-preferences.desktop.in.in
index a57dec5..696eff1 100644
--- a/capplet/vino-preferences.desktop.in.in
+++ b/capplet/vino-preferences.desktop.in.in
@@ -1,7 +1,7 @@
 [Desktop Entry]
 _Name=Remote Desktop
 _Comment=Choose how other users can remotely view your desktop
-Exec=vino-preferences
+Exec=gnome-control-center vino
 Icon=preferences-desktop-remote-desktop
 Terminal=false
 Type=Application
@@ -12,3 +12,5 @@ X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=vino
 X-GNOME-Bugzilla-Component=Preferences Dialog
 X-GNOME-Bugzilla-Version=@VERSION@
+X-GNOME-Bugzilla-OtherBinaries=vino-passwd
+X-GNOME-Settings-Panel=vino
diff --git a/capplet/vino-preferences.h b/capplet/vino-preferences.h
new file mode 100644
index 0000000..e831849
--- /dev/null
+++ b/capplet/vino-preferences.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Frederic Peters
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _CC_VINO_PANEL_H
+#define _CC_VINO_PANEL_H
+
+#include <libgnome-control-center/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_VINO_PANEL cc_vino_panel_get_type()
+#define CC_VINO_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_VINO_PANEL, CcVinoPanel))
+#define CC_VINO_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_VINO_PANEL, CcVinoPanelClass))
+#define CC_IS_VINO_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_VINO_PANEL))
+#define CC_IS_VINO_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_VINO_PANEL))
+#define CC_VINO_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_VINO_PANEL, CcVinoPanelClass))
+
+typedef struct _CcVinoPanel CcVinoPanel;
+typedef struct _CcVinoPanelClass CcVinoPanelClass;
+typedef struct _VinoPreferencesDialog VinoPreferencesDialog;
+
+struct _CcVinoPanel {
+	CcPanel parent;
+
+	VinoPreferencesDialog *private_data;
+};
+
+struct _CcVinoPanelClass {
+	CcPanelClass parent_class;
+};
+
+GType cc_vino_panel_get_type (void) G_GNUC_CONST;
+
+void  cc_vino_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* _CC_VINO_PANEL_H */
+
diff --git a/capplet/vino-preferences.ui b/capplet/vino-preferences.ui
index c9f4ca1..66d77b4 100644
--- a/capplet/vino-preferences.ui
+++ b/capplet/vino-preferences.ui
@@ -2,20 +2,7 @@
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkDialog" id="vino_dialog">
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Remote Desktop Preferences</property>
-    <property name="resizable">False</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="icon_name">preferences-desktop-remote-desktop</property>
-    <property name="type_hint">dialog</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkVBox" id="vbox1">
+          <object class="GtkVBox" id="vino_dialog">
             <property name="visible">True</property>
             <property name="border_width">6</property>
             <property name="spacing">18</property>
@@ -182,6 +169,8 @@
               </object>
               <packing>
                 <property name="position">0</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
               </packing>
             </child>
             <child>
@@ -288,6 +277,8 @@
               </object>
               <packing>
                 <property name="position">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
               </packing>
             </child>
             <child>
@@ -372,52 +363,9 @@
               </object>
               <packing>
                 <property name="position">2</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
               </packing>
             </child>
           </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-help</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button2">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-11">button1</action-widget>
-      <action-widget response="-7">button2</action-widget>
-    </action-widgets>
-  </object>
 </interface>
diff --git a/configure.in b/configure.in
index 08ff48f..8b11696 100644
--- a/configure.in
+++ b/configure.in
@@ -43,25 +43,25 @@ if test "x$enable_deprecations" = "xyes"; then
    AC_SUBST(DISABLE_DEPRECATED_CFLAGS)
 fi
 
-GTK_VERSION=2.20.0
+GTK_VERSION=2.90.0
 GLIB_VERSION=2.17.0
 DBUS_VERSION=1.2.3
 SOUP_VERSION=2.24.0
 TELEPATHY_GLIB_VERSION=0.11.6
 NETWORKMANAGER_VERSION=0.7
 
-PKG_CHECK_MODULES(VINO_SERVER, glib-2.0 >= $GLIB_VERSION gtk+-x11-2.0 >= $GTK_VERSION gconf-2.0 dbus-1 >= $DBUS_VERSION dbus-glib-1)
+PKG_CHECK_MODULES(VINO_SERVER, glib-2.0 >= $GLIB_VERSION gtk+-x11-3.0 >= $GTK_VERSION gconf-2.0 dbus-1 >= $DBUS_VERSION dbus-glib-1)
 
-PKG_CHECK_MODULES(VINO_CAPPLET, glib-2.0 >= $GLIB_VERSION gtk+-2.0 >= $GTK_VERSION gconf-2.0 dbus-1 >= $DBUS_VERSION dbus-glib-1 libsoup-2.4 >= $SOUP_VERSION)
+PKG_CHECK_MODULES(VINO_CAPPLET, glib-2.0 >= $GLIB_VERSION gtk+-3.0 >= $GTK_VERSION gconf-2.0 dbus-1 >= $DBUS_VERSION dbus-glib-1 libsoup-2.4 >= $SOUP_VERSION libgnome-control-center)
 
 PKG_CHECK_MODULES(VINO_TOOLS, glib-2.0 >= $GLIB_VERSION gconf-2.0 gobject-2.0 >= $GLIB_VERSION gnome-keyring-1)
 
 # EGG stuff
-PKG_CHECK_MODULES(EGG, gtk+-2.0 >= $GTK_VERSION)
+PKG_CHECK_MODULES(EGG, gtk+-3.0 >= $GTK_VERSION)
 AC_SUBST(EGG_LIBS)
 AC_SUBST(EGG_CFLAGS)
 
-PKG_CHECK_MODULES(EGG_SMCLIENT, gtk+-2.0)
+PKG_CHECK_MODULES(EGG_SMCLIENT, gtk+-3.0)
 AC_SUBST(EGG_SMCLIENT_LIBS)
 AC_SUBST(EGG_SMCLIENT_CFLAGS)
 
@@ -380,29 +380,6 @@ else
 fi
 AC_MSG_RESULT($have_ipv6)
 
-dnl --enable-libunique=(yes|no)
-LIBUNIQUE_VERSION=1.0.0
-
-AC_ARG_ENABLE(libunique,
-         [  --enable-libunique=[no/yes] Use the library unique to allow only one instance running [default=auto]],,
-         enable_libunique=auto)
-if test "$enable_libunique" = "no"; then
-  have_libunique=no
-else
-  if test "$enable_libunique" = "yes"; then
-    PKG_CHECK_MODULES(VINO_LIBUNIQUE, unique-1.0 >= $LIBUNIQUE_VERSION)
-    have_libunique=yes
-  else
-    PKG_CHECK_MODULES(VINO_LIBUNIQUE,
-                      unique-1.0 >= $LIBUNIQUE_VERSION,
-                      have_libunique=yes, have_libunique=no)
-  fi;
-fi
-
-if test "x$have_libunique" = "xyes" ; then
-  AC_DEFINE(VINO_ENABLE_LIBUNIQUE, [], [Set if we should use libunique])
-fi
-
 dnl --enable-debug=(yes|minimum|no)
 AC_ARG_ENABLE(debug, [  --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=minimum)
 if test "$enable_debug" = "yes"; then
@@ -430,6 +407,10 @@ if test "x$enable_rebuilds" = "xyes" && \
 fi
 AC_SUBST(REBUILD)
 
+dnl Requires for the configuration panel
+PANELS_DIR="${libdir}/control-center-1/panels"
+AC_SUBST(PANELS_DIR)
+
 AC_CONFIG_FILES([
 Makefile
 server/Makefile
@@ -461,7 +442,6 @@ Configure summary:
 	Network Manager support ....:  ${have_networkmanager}
 	GNOME Keyring support.......:  ${enable_gnome_keyring}
 	HTTP server.................:  ${enable_http_server}
-	Libunique support...........:  ${have_libunique}
 	DEBUG messages..............:  ${enable_debug}
 	Telepathy support...........:  ${have_telepathy}
 "
