[vinagre] The window of plugin manager



commit a0bb7d47ce0ef822ddcfb2e0e7fa9fc35523caf0
Author: Jorge Pereira <jpereira gnome org>
Date:   Tue Jul 28 00:52:37 2009 -0300

    The window of plugin manager

 vinagre/Makefile.am             |    3 +
 vinagre/vinagre-commands.c      |   25 ++------
 vinagre/vinagre-plugin-dialog.c |  134 +++++++++++++++++++++++++++++++++++++++
 vinagre/vinagre-plugin-dialog.h |   76 ++++++++++++++++++++++
 4 files changed, 218 insertions(+), 20 deletions(-)
---
diff --git a/vinagre/Makefile.am b/vinagre/Makefile.am
index ce55b18..3548954 100644
--- a/vinagre/Makefile.am
+++ b/vinagre/Makefile.am
@@ -22,6 +22,7 @@ NOINST_H_FILES = \
   vinagre-plugin-info-priv.h \
   vinagre-plugin-loader.h \
   vinagre-plugin-manager.h \
+  vinagre-plugin-dialog.h \
   vinagre-plugins-engine.h \
   vinagre-window-private.h \
   $(NULL)
@@ -80,6 +81,7 @@ libvinagre_la_SOURCES = \
   vinagre-object-module.c \
   vinagre-plugin.c \
   vinagre-plugin-info.c \
+  vinagre-plugin-dialog.c \
   vinagre-plugin-loader.c \
   vinagre-plugin-manager.c \
   vinagre-plugins-engine.c \
@@ -161,6 +163,7 @@ vinagre_applet_SOURCES =					\
 	vinagre-plugin.h vinagre-plugin.c \
 	vinagre-plugin-loader.h vinagre-plugin-loader.c \
 	vinagre-plugin-manager.h vinagre-plugin-manager.c \
+	vinagre-plugin-dialog.h vinagre-plugin-dialog.c \
 	vinagre-debug.h vinagre-debug.c \
 	vinagre-plugin-info.h vinagre-plugin-info.c \
 	vinagre-window.h vinagre-window.c \
diff --git a/vinagre/vinagre-commands.c b/vinagre/vinagre-commands.c
index 9e73762..3cca3b7 100644
--- a/vinagre/vinagre-commands.c
+++ b/vinagre/vinagre-commands.c
@@ -38,11 +38,12 @@
 #include "vinagre-fav.h"
 #include "vinagre-window-private.h"
 #include "vinagre-prefs.h"
-#include "vinagre-plugin-manager.h"
-#include "vinagre-plugins-engine.h"
 #include "vinagre-plugin.h"
+#include "vinagre-plugin-dialog.h"
+#include "vinagre-plugin-manager.h"
 #include "vinagre-plugin-info.h"
 #include "vinagre-plugin-info-priv.h"
+#include "vinagre-plugins-engine.h"
 
 void
 vinagre_cmd_direct_connect (VinagreConnection *conn,
@@ -233,26 +234,10 @@ vinagre_cmd_edit_plugins (GtkAction     *action,
                           VinagreWindow *window)
 {
   g_return_if_fail (VINAGRE_IS_WINDOW (window));
-  // AQUI: 
-  GtkWidget *dialog, *manager;
-  
-  dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  
-  gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
-
-  gtk_window_set_title (GTK_WINDOW(dialog), N_("Plugins Manager"));
-
-  gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(window));
-
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
-   
-  manager = vinagre_plugin_manager_new ();
-  
-  gtk_container_add (GTK_CONTAINER (dialog), manager);
 
-  gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+  vinagre_debug (DEBUG_PLUGINS);
 
-  gtk_widget_show_all (dialog);
+  vinagre_plugin_dialog_show (window);
 }
 
 /* View Menu */
diff --git a/vinagre/vinagre-plugin-dialog.c b/vinagre/vinagre-plugin-dialog.c
new file mode 100644
index 0000000..65c98d3
--- /dev/null
+++ b/vinagre/vinagre-plugin-dialog.c
@@ -0,0 +1,134 @@
+/*
+ * vinagre-plugins-dialog.c
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2009 Jorge Pereira <jorge jorgepereira com br>
+ * 
+ * vinagre-plugins-dialog.c 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.
+ * 
+ * vinagre-plugins-dialog.c 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/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+
+#include "vinagre-plugin-dialog.h"
+#include "vinagre-debug.h"
+
+static GtkWidget *plugin_dialog = NULL;
+
+#define VINAGRE_PLUGIN_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+						     VINAGRE_TYPE_PLUGIN_DIALOG, \
+						     VinagrePluginDialogPrivate))
+
+struct _VinagrePluginDialogPrivate
+{
+	GtkWidget	*plugin_box;
+};
+
+G_DEFINE_TYPE(VinagrePluginDialog, vinagre_plugin_dialog, GTK_TYPE_DIALOG)
+
+static void 
+vinagre_plugin_dialog_class_init (VinagrePluginDialogClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	g_type_class_add_private (object_class, sizeof (VinagrePluginDialogPrivate));
+}
+
+static void
+dialog_response_handler (GtkDialog *dlg, 
+	                  		 gint       res_id)
+{
+	vinagre_debug (DEBUG_PREFS);
+
+	switch (res_id)
+	{
+    case GTK_RESPONSE_CLOSE:
+		default:
+			gtk_widget_destroy (GTK_WIDGET(dlg));
+	}
+}
+
+static void
+setup_plugins_page (VinagrePluginDialog *dlg)
+{
+	GtkWidget *page_content;
+
+  vinagre_debug (DEBUG_PREFS);
+
+	page_content = GTK_WIDGET (vinagre_plugin_manager_new ());
+	g_return_if_fail (page_content != NULL);
+
+  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dlg)->vbox), page_content);
+
+	gtk_widget_show_all (page_content);
+}
+
+static void
+vinagre_plugin_dialog_init (VinagrePluginDialog *dlg)
+{
+	GtkWidget *error_widget;
+	
+	vinagre_debug (DEBUG_PREFS);
+
+	dlg->priv = VINAGRE_PLUGIN_DIALOG_GET_PRIVATE (dlg);
+	gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+				GTK_STOCK_CLOSE,
+				GTK_RESPONSE_CLOSE,
+				NULL);
+
+	gtk_window_set_title (GTK_WINDOW (dlg), _("Plugin Manager"));
+	gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
+	gtk_dialog_set_has_separator (GTK_DIALOG (dlg), TRUE);
+	gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+
+	g_signal_connect (dlg,
+			  "response",
+			  G_CALLBACK (dialog_response_handler),
+			  NULL);
+
+	setup_plugins_page (dlg);
+}
+
+void
+vinagre_plugin_dialog_show (VinagreWindow *parent)
+{
+	vinagre_debug (DEBUG_PREFS);
+
+	g_return_if_fail (VINAGRE_IS_WINDOW (parent));
+
+	if (plugin_dialog == NULL)
+	{
+		plugin_dialog = GTK_WIDGET (g_object_new (VINAGRE_TYPE_PLUGIN_DIALOG, NULL));
+		g_signal_connect (plugin_dialog,
+				  "destroy",
+				  G_CALLBACK (gtk_widget_destroyed),
+				  &plugin_dialog);
+	}
+
+	if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (plugin_dialog)))
+	{
+		gtk_window_set_transient_for (GTK_WINDOW (plugin_dialog),
+					      GTK_WINDOW (parent));
+	}
+
+	gtk_window_present (GTK_WINDOW (plugin_dialog));
+}
+
diff --git a/vinagre/vinagre-plugin-dialog.h b/vinagre/vinagre-plugin-dialog.h
new file mode 100644
index 0000000..a94f7e4
--- /dev/null
+++ b/vinagre/vinagre-plugin-dialog.h
@@ -0,0 +1,76 @@
+/*
+ * vinagre-plugins-dialog.h
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2009 Jorge Pereira <jorge jorgepereira com br>
+ * 
+ * vinagre-plugins-dialog.h 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.
+ * 
+ * vinagre-plugins-dialog.h 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/>.
+ */
+
+#ifndef __VINAGRE_PLUGIN_DIALOG_H__
+#define __VINAGRE_PLUGIN_DIALOG_H__
+
+#include "vinagre-window.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define VINAGRE_TYPE_PLUGIN_DIALOG              (vinagre_plugin_dialog_get_type())
+#define VINAGRE_PLUGIN_DIALOG(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), VINAGRE_TYPE_PLUGIN_DIALOG, VinagrePluginDialog))
+#define VINAGRE_PLUGIN_DIALOG_CONST(obj)        (G_TYPE_CHECK_INSTANCE_CAST((obj), VINAGRE_TYPE_PLUGIN_DIALOG, VinagrePluginDialog const))
+#define VINAGRE_PLUGIN_DIALOG_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass),  VINAGRE_TYPE_PLUGIN_DIALOG, VinagrePluginDialogClass))
+#define VINAGRE_IS_PLUGIN_DIALOG(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), VINAGRE_TYPE_PLUGIN_DIALOG))
+#define VINAGRE_IS_PLUGIN_DIALOG_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), VINAGRE_TYPE_PLUGIN_DIALOG))
+#define VINAGRE_PLUGIN_DIALOG_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj),  VINAGRE_TYPE_PLUGIN_DIALOG, VinagrePluginDialogClass))
+
+
+/* Private structure type */
+typedef struct _VinagrePluginDialogPrivate VinagrePluginDialogPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _VinagrePluginDialog VinagrePluginDialog;
+
+struct _VinagrePluginDialog 
+{
+	GtkDialog dialog;
+	
+	/*< private > */
+	VinagrePluginDialogPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _VinagrePluginDialogClass VinagrePluginDialogClass;
+
+struct _VinagrePluginDialogClass 
+{
+	GtkDialogClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType		 vinagre_plugin_dialog_get_type	(void) G_GNUC_CONST;
+
+void		 vinagre_plugin_dialog_show (VinagreWindow *parent);
+
+G_END_DECLS
+
+#endif /* __VINAGRE_PLUGIN_DIALOG_H__ */
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]