seahorse r2448 - in trunk: . gkr libseahorse pgp pkcs11 src ssh
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2448 - in trunk: . gkr libseahorse pgp pkcs11 src ssh
- Date: Sun, 7 Sep 2008 05:20:39 +0000 (UTC)
Author: nnielsen
Date: Sun Sep 7 05:20:38 2008
New Revision: 2448
URL: http://svn.gnome.org/viewvc/seahorse?rev=2448&view=rev
Log:
* libseahorse/libseahorse-c.vapi:
* src/saehorse-preferences.h:
* src/seahorse-viewer.c:
* src/seahorse-viewer.h:
* src/seahorse-viewer.vala: (removed)
* src/Makefile.am: Write SeahorseViewer in C.
* gkr/seahorse-gkr-commands.vala:
* libseahorse/seahorse-commands.vala:
* pgp/seahorse-pgp-commands.vala:
* ssh/seahorse-ssh-commands.vala: Fine tune memory copies
of UI data.
Removed:
trunk/src/seahorse-viewer.vala
Modified:
trunk/ChangeLog
trunk/gkr/seahorse-gkr-commands.c
trunk/gkr/seahorse-gkr-commands.vala
trunk/gkr/vala-build.stamp
trunk/libseahorse/libseahorse-c.vapi
trunk/libseahorse/libseahorse.gidl
trunk/libseahorse/libseahorse.vapi
trunk/libseahorse/seahorse-commands.c
trunk/libseahorse/seahorse-commands.h
trunk/libseahorse/seahorse-commands.vala
trunk/libseahorse/vala-build.stamp
trunk/pgp/seahorse-pgp-commands.c
trunk/pgp/seahorse-pgp-commands.vala
trunk/pgp/vala-build.stamp
trunk/pkcs11/vala-build.stamp
trunk/src/Makefile.am
trunk/src/seahorse-key-manager.c
trunk/src/seahorse-key-manager.h
trunk/src/seahorse-keyserver-results.c
trunk/src/seahorse-keyserver-results.h
trunk/src/seahorse-preferences.h
trunk/src/seahorse-viewer.c
trunk/src/seahorse-viewer.h
trunk/src/vala-build.stamp
trunk/ssh/seahorse-ssh-commands.c
trunk/ssh/seahorse-ssh-commands.vala
trunk/ssh/vala-build.stamp
Modified: trunk/gkr/seahorse-gkr-commands.c
==============================================================================
--- trunk/gkr/seahorse-gkr-commands.c (original)
+++ trunk/gkr/seahorse-gkr-commands.c Sun Sep 7 05:20:38 2008
@@ -104,10 +104,10 @@
}
-static char* seahorse_gkeyring_commands_real_get_ui_definition (SeahorseCommands* base) {
+static const char* seahorse_gkeyring_commands_real_get_ui_definition (SeahorseCommands* base) {
SeahorseGKeyringCommands* self;
self = SEAHORSE_GKEYRING_COMMANDS (base);
- return g_strdup ("");
+ return "";
}
Modified: trunk/gkr/seahorse-gkr-commands.vala
==============================================================================
--- trunk/gkr/seahorse-gkr-commands.vala (original)
+++ trunk/gkr/seahorse-gkr-commands.vala Sun Sep 7 05:20:38 2008
@@ -36,7 +36,7 @@
get { return Seahorse.Gkr.TYPE; }
}
- public override string# ui_definition {
+ public override weak string ui_definition {
get { return ""; }
}
Modified: trunk/gkr/vala-build.stamp
==============================================================================
--- trunk/gkr/vala-build.stamp (original)
+++ trunk/gkr/vala-build.stamp Sun Sep 7 05:20:38 2008
@@ -1 +1 @@
-1220213771
+1220761697
Modified: trunk/libseahorse/libseahorse-c.vapi
==============================================================================
--- trunk/libseahorse/libseahorse-c.vapi (original)
+++ trunk/libseahorse/libseahorse-c.vapi Sun Sep 7 05:20:38 2008
@@ -152,6 +152,7 @@
public weak Gtk.Dialog chooser_save_new (string title, Gtk.Window? parent);
public void chooser_show_key_files (Gtk.Dialog dialog);
+ [CCode (cname = "seahorse_chooser_set_filename_full")]
public void chooser_set_filename (Gtk.Dialog dialog, GLib.List<Key> keys);
public string chooser_save_prompt (Gtk.Dialog dialog);
@@ -222,4 +223,20 @@
public class KeyserverSync : GLib.Object {
public static weak Gtk.Window show (GLib.List<Key> keys, Gtk.Window parent);
}
+
+ [CCode (cheader_filename = "seahorse-viewer.h")]
+ public abstract class Viewer : Widget, View {
+ protected void ensure_updated ();
+ protected void include_actions (Gtk.ActionGroup actions);
+ public virtual GLib.List<weak Object> get_selected_objects ();
+ public virtual void set_selected_objects (GLib.List<Object> objects);
+ public virtual weak Object? selected { get; set; }
+ public virtual weak Set? current_set { get; }
+ public virtual weak Object? get_selected_object_and_uid (out uint uid);
+ public Gtk.Window window { get; }
+ protected void show_context_menu (uint button, uint time);
+ protected void show_properties (Object obj);
+ protected void set_status (string text);
+ protected void set_numbered_status (string text, int num);
+ }
}
Modified: trunk/libseahorse/libseahorse.gidl
==============================================================================
--- trunk/libseahorse/libseahorse.gidl (original)
+++ trunk/libseahorse/libseahorse.gidl Sun Sep 7 05:20:38 2008
@@ -35,7 +35,7 @@
<property name="view" type="Seahorse.View*" readable="1" writable="1"/>
<property name="ktype" type="GLib.Quark" readable="1"/>
<property name="command_actions" type="Gtk.ActionGroup*" readable="1"/>
- <property name="ui_definition" type="string*" readable="1"/>
+ <property name="ui_definition" type="const char*" readable="1"/>
</object>
<object name="Generator" parent="GLib.Object" type-name="SeahorseGenerator" get-type="seahorse_generator_get_type">
<property name="actions" type="Gtk.ActionGroup*" readable="1"/>
Modified: trunk/libseahorse/libseahorse.vapi
==============================================================================
--- trunk/libseahorse/libseahorse.vapi (original)
+++ trunk/libseahorse/libseahorse.vapi Sun Sep 7 05:20:38 2008
@@ -27,7 +27,7 @@
public Seahorse.View view { get; construct; }
public abstract GLib.Quark ktype { get; }
public abstract Gtk.ActionGroup command_actions { get; }
- public abstract string# ui_definition { get; }
+ public abstract string ui_definition { get; }
}
[CCode (cheader_filename = "seahorse-generator.h")]
public abstract class Generator : GLib.Object {
Modified: trunk/libseahorse/seahorse-commands.c
==============================================================================
--- trunk/libseahorse/seahorse-commands.c (original)
+++ trunk/libseahorse/seahorse-commands.c Sun Sep 7 05:20:38 2008
@@ -95,7 +95,7 @@
}
-char* seahorse_commands_get_ui_definition (SeahorseCommands* self) {
+const char* seahorse_commands_get_ui_definition (SeahorseCommands* self) {
return SEAHORSE_COMMANDS_GET_CLASS (self)->get_ui_definition (self);
}
Modified: trunk/libseahorse/seahorse-commands.h
==============================================================================
--- trunk/libseahorse/seahorse-commands.h (original)
+++ trunk/libseahorse/seahorse-commands.h Sun Sep 7 05:20:38 2008
@@ -56,7 +56,7 @@
SeahorseOperation* (*delete_objects) (SeahorseCommands* self, GList* obj);
GQuark (*get_ktype) (SeahorseCommands* self);
GtkActionGroup* (*get_command_actions) (SeahorseCommands* self);
- char* (*get_ui_definition) (SeahorseCommands* self);
+ const char* (*get_ui_definition) (SeahorseCommands* self);
};
@@ -65,7 +65,7 @@
SeahorseView* seahorse_commands_get_view (SeahorseCommands* self);
GQuark seahorse_commands_get_ktype (SeahorseCommands* self);
GtkActionGroup* seahorse_commands_get_command_actions (SeahorseCommands* self);
-char* seahorse_commands_get_ui_definition (SeahorseCommands* self);
+const char* seahorse_commands_get_ui_definition (SeahorseCommands* self);
GType seahorse_commands_get_type (void);
Modified: trunk/libseahorse/seahorse-commands.vala
==============================================================================
--- trunk/libseahorse/seahorse-commands.vala (original)
+++ trunk/libseahorse/seahorse-commands.vala Sun Sep 7 05:20:38 2008
@@ -35,7 +35,7 @@
public abstract ActionGroup command_actions { get; }
- public abstract string# ui_definition { get; }
+ public abstract weak string ui_definition { get; }
public abstract void show_properties (Object obj);
Modified: trunk/libseahorse/vala-build.stamp
==============================================================================
--- trunk/libseahorse/vala-build.stamp (original)
+++ trunk/libseahorse/vala-build.stamp Sun Sep 7 05:20:38 2008
@@ -1 +1 @@
-1220209435
+1220758634
Modified: trunk/pgp/seahorse-pgp-commands.c
==============================================================================
--- trunk/pgp/seahorse-pgp-commands.c (original)
+++ trunk/pgp/seahorse-pgp-commands.c Sun Sep 7 05:20:38 2008
@@ -239,12 +239,10 @@
}
-static char* seahorse_pgp_commands_real_get_ui_definition (SeahorseCommands* base) {
+static const char* seahorse_pgp_commands_real_get_ui_definition (SeahorseCommands* base) {
SeahorsePGPCommands* self;
- const char* _tmp0;
self = SEAHORSE_PGP_COMMANDS (base);
- _tmp0 = NULL;
- return (_tmp0 = SEAHORSE_PGP_COMMANDS_UI_DEF, (_tmp0 == NULL ? NULL : g_strdup (_tmp0)));
+ return SEAHORSE_PGP_COMMANDS_UI_DEF;
}
Modified: trunk/pgp/seahorse-pgp-commands.vala
==============================================================================
--- trunk/pgp/seahorse-pgp-commands.vala (original)
+++ trunk/pgp/seahorse-pgp-commands.vala Sun Sep 7 05:20:38 2008
@@ -46,7 +46,7 @@
get { return Seahorse.Pgp.TYPE; }
}
- public override string# ui_definition {
+ public override weak string ui_definition {
get { return UI_DEF; }
}
Modified: trunk/pgp/vala-build.stamp
==============================================================================
--- trunk/pgp/vala-build.stamp (original)
+++ trunk/pgp/vala-build.stamp Sun Sep 7 05:20:38 2008
@@ -1 +1 @@
-1220213805
+1220761707
Modified: trunk/pkcs11/vala-build.stamp
==============================================================================
--- trunk/pkcs11/vala-build.stamp (original)
+++ trunk/pkcs11/vala-build.stamp Sun Sep 7 05:20:38 2008
@@ -1 +1 @@
-1220213792
+1220761702
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Sep 7 05:20:38 2008
@@ -17,7 +17,6 @@
-DGETTEXT_PACKAGE=\""seahorse\""
VALA_SRCS = \
- seahorse-viewer.vala \
seahorse-generate-select.vala \
seahorse-key-manager.vala \
seahorse-keyserver-results.vala
@@ -70,6 +69,7 @@
seahorse-preferences.c seahorse-preferences.h \
eggtreemultidnd.c eggtreemultidnd.h \
seahorse-key-manager-store.c seahorse-key-manager-store.h \
+ seahorse-viewer.c seahorse-viewer.h \
seahorse-windows.h \
$(KEYSERVER_SRCS) \
$(VALA_CFILES) $(VALA_HFILES)
Modified: trunk/src/seahorse-key-manager.c
==============================================================================
--- trunk/src/seahorse-key-manager.c (original)
+++ trunk/src/seahorse-key-manager.c Sun Sep 7 05:20:38 2008
@@ -520,14 +520,14 @@
static void seahorse_key_manager_on_key_generate (SeahorseKeyManager* self, GtkAction* action) {
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- seahorse_generate_select_show (seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ seahorse_generate_select_show (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)));
}
static void seahorse_key_manager_on_new_button_clicked (SeahorseKeyManager* self, GtkWidget* widget) {
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_WIDGET (widget));
- seahorse_generate_select_show (seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ seahorse_generate_select_show (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)));
}
@@ -535,7 +535,7 @@
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (SEAHORSE_IS_OPERATION (op));
if (!seahorse_operation_is_successful (op)) {
- seahorse_operation_display_error (op, _ ("Couldn't import keys"), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
+ seahorse_operation_display_error (op, _ ("Couldn't import keys"), GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))));
return;
}
seahorse_viewer_set_status (SEAHORSE_VIEWER (self), _ ("Imported keys"));
@@ -592,7 +592,7 @@
file = g_file_new_for_uri (uri);
input = g_file_read (file, NULL, &inner_error);
if (inner_error != NULL) {
- goto __catch3_g_error;
+ goto __catch0_g_error;
}
op = seahorse_source_import (sksrc, G_INPUT_STREAM (input));
seahorse_multi_operation_take (mop, op);
@@ -600,8 +600,8 @@
(input == NULL ? NULL : (input = (g_object_unref (input), NULL)));
(op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
}
- goto __finally3;
- __catch3_g_error:
+ goto __finally0;
+ __catch0_g_error:
{
GError * ex;
ex = inner_error;
@@ -614,7 +614,7 @@
continue;
}
}
- __finally3:
+ __finally0:
;
uri = (g_free (uri), NULL);
(sksrc == NULL ? NULL : (sksrc = (g_object_unref (sksrc), NULL)));
@@ -626,7 +626,7 @@
seahorse_operation_watch (SEAHORSE_OPERATION (mop), _seahorse_key_manager_imported_keys_seahorse_done_func, self, NULL, NULL);
}
if (errmsg->len == 0) {
- seahorse_util_show_error (GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))), _ ("Couldn't import keys"), errmsg->str);
+ seahorse_util_show_error (GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))), _ ("Couldn't import keys"), errmsg->str);
}
(mop == NULL ? NULL : (mop = (g_object_unref (mop), NULL)));
(errmsg == NULL ? NULL : (errmsg = (g_string_free (errmsg, TRUE), NULL)));
@@ -639,7 +639,7 @@
char* uri;
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
_tmp0 = NULL;
- dialog = (_tmp0 = seahorse_util_chooser_open_new (_ ("Import Key"), seahorse_view_get_window (SEAHORSE_VIEW (self))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
+ dialog = (_tmp0 = seahorse_util_chooser_open_new (_ ("Import Key"), seahorse_viewer_get_window (SEAHORSE_VIEWER (self))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
seahorse_util_chooser_show_key_files (dialog);
uri = seahorse_util_chooser_open_prompt (dialog);
if (uri != NULL) {
@@ -686,7 +686,7 @@
len = g_utf8_strlen (text, -1);
ktype = seahorse_util_detect_data_type (text, len);
if (ktype == 0) {
- seahorse_util_show_error (GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))), _ ("Couldn't import keys"), _ ("Unrecognized key type, or invalid data format"));
+ seahorse_util_show_error (GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))), _ ("Couldn't import keys"), _ ("Unrecognized key type, or invalid data format"));
return;
}
/* All our supported key types have a local key source */
@@ -770,7 +770,7 @@
static void seahorse_key_manager_on_remote_find (SeahorseKeyManager* self, GtkAction* action) {
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- seahorse_keyserver_search_show (seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ seahorse_keyserver_search_show (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)));
}
@@ -784,7 +784,7 @@
_tmp0 = NULL;
objects = (_tmp0 = seahorse_context_find_objects (seahorse_context_for_app (), ((GQuark) (0)), 0, SEAHORSE_LOCATION_LOCAL), (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL))), _tmp0);
}
- seahorse_keyserver_sync_show (objects, seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ seahorse_keyserver_sync_show (objects, seahorse_viewer_get_window (SEAHORSE_VIEWER (self)));
(objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
}
@@ -1172,7 +1172,7 @@
_tmp3 = NULL;
_tmp2 = NULL;
self->priv->_notebook = (_tmp3 = (_tmp2 = GTK_NOTEBOOK (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "notebook")), (_tmp2 == NULL ? NULL : g_object_ref (_tmp2))), (self->priv->_notebook == NULL ? NULL : (self->priv->_notebook = (g_object_unref (self->priv->_notebook), NULL))), _tmp3);
- gtk_window_set_title (seahorse_view_get_window (SEAHORSE_VIEW (self)), _ ("Passwords and Encryption Keys"));
+ gtk_window_set_title (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)), _ ("Passwords and Encryption Keys"));
/*
* We hook callbacks up here for now because of a compiler warning. See:
* http://bugzilla.gnome.org/show_bug.cgi?id=539483
@@ -1294,12 +1294,12 @@
_tmp21 = NULL;
_tmp20 = NULL;
entries = (_tmp21 = (_tmp20 = g_new0 (GtkTargetEntry, 0), _tmp20), entries_length1 = 0, _tmp21);
- gtk_drag_dest_set (GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))), GTK_DEST_DEFAULT_ALL, entries, entries_length1, GDK_ACTION_COPY);
+ gtk_drag_dest_set (GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))), GTK_DEST_DEFAULT_ALL, entries, entries_length1, GDK_ACTION_COPY);
targets = gtk_target_list_new (entries, ((guint) (0)));
gtk_target_list_add_uri_targets (targets, ((guint) (SEAHORSE_KEY_MANAGER_TARGETS_URIS)));
gtk_target_list_add_text_targets (targets, ((guint) (SEAHORSE_KEY_MANAGER_TARGETS_PLAIN)));
- gtk_drag_dest_set_target_list (GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))), targets);
- g_signal_connect_object (GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))), "drag-data-received", ((GCallback) (_seahorse_key_manager_on_target_drag_data_received_gtk_widget_drag_data_received)), self, 0);
+ gtk_drag_dest_set_target_list (GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))), targets);
+ g_signal_connect_object (GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))), "drag-data-received", ((GCallback) (_seahorse_key_manager_on_target_drag_data_received_gtk_widget_drag_data_received)), self, 0);
/* To show first time dialog */
g_timeout_add (((guint) (1000)), _seahorse_key_manager_on_first_timer_gsource_func, self);
g_signal_emit_by_name (G_OBJECT (SEAHORSE_VIEW (self)), "selection-changed");
Modified: trunk/src/seahorse-key-manager.h
==============================================================================
--- trunk/src/seahorse-key-manager.h (original)
+++ trunk/src/seahorse-key-manager.h Sun Sep 7 05:20:38 2008
@@ -24,10 +24,10 @@
#include <glib.h>
#include <glib-object.h>
+#include <seahorse-viewer.h>
#include <gtk/gtk.h>
#include <seahorse-operation.h>
#include <seahorse-object.h>
-#include "seahorse-viewer.h"
G_BEGIN_DECLS
Modified: trunk/src/seahorse-keyserver-results.c
==============================================================================
--- trunk/src/seahorse-keyserver-results.c (original)
+++ trunk/src/seahorse-keyserver-results.c Sun Sep 7 05:20:38 2008
@@ -248,7 +248,7 @@
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (SEAHORSE_IS_OPERATION (op));
if (!seahorse_operation_is_successful (op)) {
- seahorse_operation_display_error (op, _ ("Couldn't import keys"), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
+ seahorse_operation_display_error (op, _ ("Couldn't import keys"), GTK_WIDGET (seahorse_viewer_get_window (SEAHORSE_VIEWER (self))));
return;
}
seahorse_viewer_set_status (SEAHORSE_VIEWER (self), _ ("Imported keys"));
@@ -282,7 +282,7 @@
static void seahorse_keyserver_results_on_remote_find (SeahorseKeyserverResults* self, GtkAction* action) {
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- seahorse_keyserver_search_show (seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ seahorse_keyserver_search_show (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)));
}
@@ -436,7 +436,7 @@
_tmp2 = NULL;
title = (_tmp2 = g_strdup_printf (_ ("Remote Keys Containing '%s'"), self->priv->_search_string), (title = (g_free (title), NULL)), _tmp2);
}
- gtk_window_set_title (seahorse_view_get_window (SEAHORSE_VIEW (self)), title);
+ gtk_window_set_title (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)), title);
/*
* We hook callbacks up here for now because of a compiler warning. See:
* http://bugzilla.gnome.org/show_bug.cgi?id=539483
Modified: trunk/src/seahorse-keyserver-results.h
==============================================================================
--- trunk/src/seahorse-keyserver-results.h (original)
+++ trunk/src/seahorse-keyserver-results.h Sun Sep 7 05:20:38 2008
@@ -24,12 +24,12 @@
#include <glib.h>
#include <glib-object.h>
+#include <seahorse-viewer.h>
#include <seahorse-operation.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <seahorse-object.h>
-#include "seahorse-viewer.h"
G_BEGIN_DECLS
Modified: trunk/src/seahorse-preferences.h
==============================================================================
--- trunk/src/seahorse-preferences.h (original)
+++ trunk/src/seahorse-preferences.h Sun Sep 7 05:20:38 2008
@@ -22,6 +22,8 @@
#ifndef __SEAHORSE_PREFERENCES_H__
#define __SEAHORSE_PREFERENCES_H__
+#include <gtk/gtk.h>
+
#define LISTING_SCHEMAS SEAHORSE_SCHEMAS "/listing"
#define SHOW_VALIDITY_KEY LISTING_SCHEMAS "/show_validity"
#define SHOW_EXPIRES_KEY LISTING_SCHEMAS "/show_expires"
Modified: trunk/src/seahorse-viewer.c
==============================================================================
--- trunk/src/seahorse-viewer.c (original)
+++ trunk/src/seahorse-viewer.c Sun Sep 7 05:20:38 2008
@@ -19,974 +19,795 @@
* 02111-1307, USA.
*/
-#include "seahorse-viewer.h"
-#include <glib/gi18n-lib.h>
-#include <config.h>
-#include <seahorse-preferences.h>
-#include <gio/gio.h>
-#include <seahorse-commands.h>
-#include <seahorse-operation.h>
-#include <seahorse-progress.h>
-#include <seahorse-types.h>
-#include <seahorse-util.h>
-#include <gdk/gdk.h>
-#include <seahorse-source.h>
-#include <common/seahorse-registry.h>
+#include "config.h"
+#include "seahorse-commands.h"
+#include "seahorse-preferences.h"
+#include "seahorse-progress.h"
+#include "seahorse-util.h"
+#include "seahorse-view.h"
+#include "seahorse-viewer.h"
+#include "common/seahorse-registry.h"
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
-struct _SeahorseViewerPrivate {
- GtkUIManager* _ui_manager;
- GtkActionGroup* _object_actions;
- GHashTable* _commands;
+enum {
+ PROP_0,
+ PROP_SELECTED,
+ PROP_CURRENT_SET,
+ PROP_WINDOW
};
-#define SEAHORSE_VIEWER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_VIEWER, SeahorseViewerPrivate))
-enum {
- SEAHORSE_VIEWER_DUMMY_PROPERTY,
- SEAHORSE_VIEWER_SELECTED,
- SEAHORSE_VIEWER_CURRENT_SET,
- SEAHORSE_VIEWER_WINDOW
+struct _SeahorseViewerPrivate {
+ GtkUIManager *ui_manager;
+ GtkActionGroup *object_actions;
+ GHashTable *commands;
};
-static gboolean seahorse_viewer__about_initialized;
-static void _seahorse_viewer_on_app_preferences_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_viewer_on_app_about_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_viewer_on_help_show_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_viewer_on_key_properties_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_viewer_on_key_export_file_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_viewer_on_key_export_clipboard_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_viewer_on_key_delete_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void seahorse_viewer_include_basic_actions (SeahorseViewer* self);
-static GList* seahorse_viewer_real_get_selected_objects (SeahorseViewer* self);
-static void seahorse_viewer_real_set_selected_objects (SeahorseViewer* self, GList* objects);
-static SeahorseObject* seahorse_viewer_real_get_selected_object_and_uid (SeahorseViewer* self, guint* uid);
-static void seahorse_viewer_on_ui_add_widget (SeahorseViewer* self, GtkUIManager* ui, GtkWidget* widget);
-static void seahorse_viewer_on_app_preferences (SeahorseViewer* self, GtkAction* action);
-static void _seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func (GtkAboutDialog* about, const char* link_, gpointer self);
-static void __lambda0 (GtkAboutDialog* about, gint resp, SeahorseViewer* self);
-static void ___lambda0_gtk_dialog_response (GtkAboutDialog* _sender, gint response_id, gpointer self);
-static void seahorse_viewer_on_app_about (SeahorseViewer* self, GtkAction* action);
-static void seahorse_viewer_on_about_link_clicked (GtkAboutDialog* about, const char* url);
-static void seahorse_viewer_on_help_show (SeahorseViewer* self, GtkAction* action);
-static void seahorse_viewer_on_key_properties (SeahorseViewer* self, GtkAction* action);
-static gint seahorse_viewer_compare_by_tag (SeahorseViewer* self, SeahorseObject* one, SeahorseObject* two);
-static void seahorse_viewer_on_delete_complete (SeahorseViewer* self, SeahorseOperation* op);
-static void _seahorse_viewer_on_delete_complete_seahorse_done_func (SeahorseOperation* op, gpointer self);
-static void seahorse_viewer_delete_object_batch (SeahorseViewer* self, GList* objects);
-static void seahorse_viewer_on_key_delete (SeahorseViewer* self, GtkAction* action);
-static void seahorse_viewer_on_copy_complete (SeahorseViewer* self, SeahorseOperation* op);
-static void* _g_realloc_grealloc_func (void* data, gulong size);
-static void _g_free_gdestroy_notify (void* data);
-static void _seahorse_viewer_on_copy_complete_seahorse_done_func (SeahorseOperation* op, gpointer self);
-static void seahorse_viewer_on_key_export_clipboard (SeahorseViewer* self, GtkAction* action);
-static void seahorse_viewer_on_export_done (SeahorseViewer* self, SeahorseOperation* op);
-static void _seahorse_viewer_on_export_done_seahorse_done_func (SeahorseOperation* op, gpointer self);
-static void seahorse_viewer_on_key_export_file (SeahorseViewer* self, GtkAction* action);
-static void seahorse_viewer_on_selection_changed (SeahorseViewer* self, SeahorseView* view);
-static void _seahorse_viewer_on_ui_add_widget_gtk_ui_manager_add_widget (GtkUIManager* _sender, GtkWidget* widget, gpointer self);
-static void _seahorse_viewer_on_selection_changed_seahorse_view_selection_changed (SeahorseViewer* _sender, gpointer self);
-static GObject * seahorse_viewer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-static gpointer seahorse_viewer_parent_class = NULL;
-static SeahorseViewIface* seahorse_viewer_seahorse_view_parent_iface = NULL;
-static void seahorse_viewer_finalize (GObject * obj);
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
-
-static const GtkActionEntry SEAHORSE_VIEWER_UI_ENTRIES[] = {{"key-menu", NULL, N_ ("_Key")}, {"edit-menu", NULL, N_ ("_Edit")}, {"view-menu", NULL, N_ ("_View")}, {"help-menu", NULL, N_ ("_Help")}, {"app-preferences", GTK_STOCK_PREFERENCES, N_ ("Prefere_nces"), NULL, N_ ("Change preferences for this program"), ((GCallback) (NULL))}, {"app-about", "gtk-about", N_ ("_About"), NULL, N_ ("About this program"), ((GCallback) (NULL))}, {"help-show", GTK_STOCK_HELP, N_ ("_Contents"), "F1", N_ ("Show Seahorse help"), ((GCallback) (NULL))}};
-static const GtkActionEntry SEAHORSE_VIEWER_KEY_ENTRIES[] = {{"key-properties", GTK_STOCK_PROPERTIES, N_ ("P_roperties"), NULL, N_ ("Show key properties"), ((GCallback) (NULL))}, {"key-export-file", GTK_STOCK_SAVE_AS, N_ ("E_xport Public Key..."), NULL, N_ ("Export public part of key to a file"), ((GCallback) (NULL))}, {"key-export-clipboard", GTK_STOCK_COPY, N_ ("_Copy Public Key"), "<control>C", N_ ("Copy public part of selected keys to the clipboard"), ((GCallback) (NULL))}, {"key-delete", GTK_STOCK_DELETE, N_ ("_Delete Key"), NULL, N_ ("Delete selected keys"), ((GCallback) (NULL))}};
-
-
-static void _seahorse_viewer_on_app_preferences_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_app_preferences (self, _sender);
-}
-
-
-static void _seahorse_viewer_on_app_about_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_app_about (self, _sender);
-}
-
-
-static void _seahorse_viewer_on_help_show_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_help_show (self, _sender);
-}
-
-
-static void _seahorse_viewer_on_key_properties_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_key_properties (self, _sender);
-}
-
-
-static void _seahorse_viewer_on_key_export_file_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_key_export_file (self, _sender);
-}
-
-
-static void _seahorse_viewer_on_key_export_clipboard_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_key_export_clipboard (self, _sender);
-}
-
-
-static void _seahorse_viewer_on_key_delete_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_viewer_on_key_delete (self, _sender);
-}
+static void seahorse_viewer_implement_view (SeahorseViewIface *iface);
+G_DEFINE_TYPE_EXTENDED (SeahorseViewer, seahorse_viewer, SEAHORSE_TYPE_WIDGET, 0,
+ G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEW, seahorse_viewer_implement_view));
-static void seahorse_viewer_include_basic_actions (SeahorseViewer* self) {
- GtkActionGroup* actions;
- GtkActionGroup* _tmp0;
- gboolean _tmp1;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- /*
- * We hook callbacks up here for now because of a compiler warning. See:
- * http://bugzilla.gnome.org/show_bug.cgi?id=539483
- */
- actions = gtk_action_group_new ("main");
- gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (actions, SEAHORSE_VIEWER_UI_ENTRIES, G_N_ELEMENTS (SEAHORSE_VIEWER_UI_ENTRIES), self);
- g_signal_connect_object (gtk_action_group_get_action (actions, "app-preferences"), "activate", ((GCallback) (_seahorse_viewer_on_app_preferences_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (actions, "app-about"), "activate", ((GCallback) (_seahorse_viewer_on_app_about_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (actions, "help-show"), "activate", ((GCallback) (_seahorse_viewer_on_help_show_gtk_action_activate)), self, 0);
- seahorse_viewer_include_actions (self, actions);
- _tmp0 = NULL;
- self->priv->_object_actions = (_tmp0 = gtk_action_group_new ("key"), (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL))), _tmp0);
- gtk_action_group_set_translation_domain (self->priv->_object_actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (self->priv->_object_actions, SEAHORSE_VIEWER_KEY_ENTRIES, G_N_ELEMENTS (SEAHORSE_VIEWER_KEY_ENTRIES), self);
- g_signal_connect_object (gtk_action_group_get_action (self->priv->_object_actions, "key-properties"), "activate", ((GCallback) (_seahorse_viewer_on_key_properties_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (self->priv->_object_actions, "key-export-file"), "activate", ((GCallback) (_seahorse_viewer_on_key_export_file_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (self->priv->_object_actions, "key-export-clipboard"), "activate", ((GCallback) (_seahorse_viewer_on_key_export_clipboard_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (self->priv->_object_actions, "key-delete"), "activate", ((GCallback) (_seahorse_viewer_on_key_delete_gtk_action_activate)), self, 0);
- /* Mark the properties toolbar button as important */
- g_object_set (gtk_action_group_get_action (self->priv->_object_actions, "key-properties"), "is-important", TRUE, NULL);
- seahorse_viewer_include_actions (self, self->priv->_object_actions);
- (actions == NULL ? NULL : (actions = (g_object_unref (actions), NULL)));
-}
+#define SEAHORSE_VIEWER_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_VIEWER, SeahorseViewerPrivate))
+static gboolean about_initialized = FALSE;
-void seahorse_viewer_ensure_updated (SeahorseViewer* self) {
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- gtk_ui_manager_ensure_update (self->priv->_ui_manager);
-}
-
-
-void seahorse_viewer_include_actions (SeahorseViewer* self, GtkActionGroup* actions) {
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (GTK_IS_ACTION_GROUP (actions));
- gtk_ui_manager_insert_action_group (self->priv->_ui_manager, actions, -1);
-}
-
-
-static GList* seahorse_viewer_real_get_selected_objects (SeahorseViewer* self) {
- g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
- return NULL;
-}
-
-
-GList* seahorse_viewer_get_selected_objects (SeahorseViewer* self) {
- return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_objects (self);
-}
-
-
-static void seahorse_viewer_real_set_selected_objects (SeahorseViewer* self, GList* objects) {
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (objects != NULL);
-}
-
-
-void seahorse_viewer_set_selected_objects (SeahorseViewer* self, GList* objects) {
- SEAHORSE_VIEWER_GET_CLASS (self)->set_selected_objects (self, objects);
-}
-
-
-static SeahorseObject* seahorse_viewer_real_get_selected_object_and_uid (SeahorseViewer* self, guint* uid) {
- g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
- /* Must be overridden */
- return NULL;
-}
-
-
-SeahorseObject* seahorse_viewer_get_selected_object_and_uid (SeahorseViewer* self, guint* uid) {
- return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_object_and_uid (self, uid);
-}
-
-
-static void seahorse_viewer_on_ui_add_widget (SeahorseViewer* self, GtkUIManager* ui, GtkWidget* widget) {
- char* name;
- GtkWidget* _tmp2;
- GtkWidget* holder;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (GTK_IS_UI_MANAGER (ui));
- g_return_if_fail (GTK_IS_WIDGET (widget));
- name = NULL;
- if (G_TYPE_FROM_INSTANCE (G_OBJECT (widget)) == GTK_TYPE_MENU_BAR) {
- char* _tmp0;
- _tmp0 = NULL;
- name = (_tmp0 = g_strdup ("menu-placeholder"), (name = (g_free (name), NULL)), _tmp0);
- } else {
- if (G_TYPE_FROM_INSTANCE (G_OBJECT (widget)) == GTK_TYPE_TOOLBAR) {
- char* _tmp1;
- _tmp1 = NULL;
- name = (_tmp1 = g_strdup ("toolbar-placeholder"), (name = (g_free (name), NULL)), _tmp1);
- } else {
- name = (g_free (name), NULL);
- return;
- }
- }
- _tmp2 = NULL;
- holder = (_tmp2 = seahorse_widget_get_widget (SEAHORSE_WIDGET (self), name), (_tmp2 == NULL ? NULL : g_object_ref (_tmp2)));
- if (holder != NULL) {
- gtk_container_add ((GTK_CONTAINER (holder)), widget);
- } else {
- g_warning ("seahorse-viewer.vala:187: no place holder found for: %s", name);
- }
- name = (g_free (name), NULL);
- (holder == NULL ? NULL : (holder = (g_object_unref (holder), NULL)));
-}
-
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
-static void seahorse_viewer_on_app_preferences (SeahorseViewer* self, GtkAction* action) {
+static void
+on_app_preferences (GtkAction* action, SeahorseViewer* self)
+{
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- seahorse_preferences_show (seahorse_view_get_window (SEAHORSE_VIEW (self)), NULL);
-}
-
-static void _seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func (GtkAboutDialog* about, const char* link_, gpointer self) {
- seahorse_viewer_on_about_link_clicked (about, link_);
+ seahorse_preferences_show (seahorse_view_get_window (SEAHORSE_VIEW (self)), NULL);
}
-
-static void __lambda0 (GtkAboutDialog* about, gint resp, SeahorseViewer* self) {
+static void
+on_about_link_clicked (GtkAboutDialog* about, const char* url, gpointer unused)
+{
+ GError *error = NULL;
+ GAppLaunchContext* ctx;
+
g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
- gtk_widget_hide (GTK_WIDGET (about));
-}
-
-
-static void ___lambda0_gtk_dialog_response (GtkAboutDialog* _sender, gint response_id, gpointer self) {
- __lambda0 (_sender, response_id, self);
-}
-
-
-static void seahorse_viewer_on_app_about (SeahorseViewer* self, GtkAction* action) {
- char** _tmp2;
- gint authors_length1;
- char** _tmp1;
- const char* _tmp0;
- char** authors;
- char** _tmp4;
- gint documenters_length1;
- char** _tmp3;
- char** documenters;
- char** _tmp6;
- gint artists_length1;
- char** _tmp5;
- char** artists;
- GtkAboutDialog* about;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (GTK_IS_ACTION (action));
- _tmp2 = NULL;
- _tmp1 = NULL;
- _tmp0 = NULL;
- authors = (_tmp2 = (_tmp1 = g_new0 (char*, 9 + 1), _tmp1[0] = g_strdup ("Jacob Perkins <jap1 users sourceforge net>"), _tmp1[1] = g_strdup ("Jose Carlos Garcia Sogo <jsogo users sourceforge net>"), _tmp1[2] = g_strdup ("Jean Schurger <yshark schurger org>"), _tmp1[3] = g_strdup ("Stef Walter <stef memberwebs com>"), _tmp1[4] = g_strdup ("Adam Schreiber <sadam clemson edu>"), _tmp1[5] = g_strdup (""), _tmp1[6] = (_tmp0 = _ ("Contributions:"), (_tmp0 == NULL ? NULL : g_strdup (_tmp0))), _tmp1[7] = g_strdup ("Albrecht Dreà <albrecht dress arcor de>"), _tmp1[8] = g_strdup ("Jim Pharis <binbrain gmail com>"), _tmp1), authors_length1 = 9, _tmp2);
- _tmp4 = NULL;
- _tmp3 = NULL;
- documenters = (_tmp4 = (_tmp3 = g_new0 (char*, 3 + 1), _tmp3[0] = g_strdup ("Jacob Perkins <jap1 users sourceforge net>"), _tmp3[1] = g_strdup ("Adam Schreiber <sadam clemson edu>"), _tmp3[2] = g_strdup ("Milo Casagrande <milo_casagrande yahoo it>"), _tmp3), documenters_length1 = 3, _tmp4);
- _tmp6 = NULL;
- _tmp5 = NULL;
- artists = (_tmp6 = (_tmp5 = g_new0 (char*, 2 + 1), _tmp5[0] = g_strdup ("Jacob Perkins <jap1 users sourceforge net>"), _tmp5[1] = g_strdup ("Stef Walter <stef memberwebs com>"), _tmp5), artists_length1 = 2, _tmp6);
- if (!seahorse_viewer__about_initialized) {
- seahorse_viewer__about_initialized = TRUE;
- gtk_about_dialog_set_url_hook (_seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func, NULL, NULL);
+ g_return_if_fail (url != NULL);
+
+
+ ctx = g_app_launch_context_new ();
+ if (!g_app_info_launch_default_for_uri (url, ctx, &error)) {
+ g_warning ("couldn't launch url: %s: %s", url, error->message);
+ g_clear_error (&error);
+ }
+
+ g_object_unref (ctx);
+}
+
+static void
+on_app_about (GtkAction* action, SeahorseViewer* self)
+{
+ GtkAboutDialog *about;
+
+ const gchar *authors[] = {
+ "Jacob Perkins <jap1 users sourceforge net>",
+ "Jose Carlos Garcia Sogo <jsogo users sourceforge net>",
+ "Jean Schurger <yshark schurger org>",
+ "Stef Walter <stef memberwebs com>",
+ "Adam Schreiber <sadam clemson edu>",
+ "",
+ N_("Contributions:"),
+ "Albrecht Dreà <albrecht dress arcor de>",
+ "Jim Pharis <binbrain gmail com>",
+ NULL
+ };
+
+ const gchar *documenters[] = {
+ "Jacob Perkins <jap1 users sourceforge net>",
+ "Adam Schreiber <sadam clemson edu>",
+ "Milo Casagrande <milo_casagrande yahoo it>",
+ NULL
+ };
+
+ const gchar *artists[] = {
+ "Jacob Perkins <jap1 users sourceforge net>",
+ "Stef Walter <stef memberwebs com>",
+ NULL
+ };
+
+ if (!about_initialized) {
+ about_initialized = TRUE;
+ gtk_about_dialog_set_url_hook (on_about_link_clicked, NULL, NULL);
}
- about = g_object_ref_sink (((GtkAboutDialog*) (gtk_about_dialog_new ())));
+
+ about = GTK_ABOUT_DIALOG (gtk_about_dialog_new ());
gtk_about_dialog_set_artists (about, artists);
gtk_about_dialog_set_authors (about, authors);
gtk_about_dialog_set_documenters (about, documenters);
gtk_about_dialog_set_version (about, VERSION);
- gtk_about_dialog_set_comments (about, _ ("Encryption Key Manager"));
+ gtk_about_dialog_set_comments (about, _("Encryption Key Manager"));
gtk_about_dialog_set_copyright (about, "Copyright \xc2\xa9 2002 - 2008 Seahorse Project");
- gtk_about_dialog_set_translator_credits (about, _ ("translator-credits"));
+ gtk_about_dialog_set_translator_credits (about, _("translator-credits"));
gtk_about_dialog_set_logo_icon_name (about, "seahorse");
gtk_about_dialog_set_website (about, "http://www.gnome.org/projects/seahorse");
- gtk_about_dialog_set_website_label (about, _ ("Seahorse Project Homepage"));
- g_signal_connect_object (GTK_DIALOG (about), "response", ((GCallback) (___lambda0_gtk_dialog_response)), self, 0);
+ gtk_about_dialog_set_website_label (about, _("Seahorse Project Homepage"));
+
+ g_signal_connect (about, "response", G_CALLBACK (gtk_widget_hide), NULL);
+
gtk_dialog_run (GTK_DIALOG (about));
- gtk_object_destroy (GTK_OBJECT (about));
- authors = (_vala_array_free (authors, authors_length1, ((GDestroyNotify) (g_free))), NULL);
- documenters = (_vala_array_free (documenters, documenters_length1, ((GDestroyNotify) (g_free))), NULL);
- artists = (_vala_array_free (artists, artists_length1, ((GDestroyNotify) (g_free))), NULL);
- (about == NULL ? NULL : (about = (g_object_unref (about), NULL)));
-}
-
-
-static void seahorse_viewer_on_about_link_clicked (GtkAboutDialog* about, const char* url) {
- GError * inner_error;
- g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
- g_return_if_fail (url != NULL);
- inner_error = NULL;
- {
- GAppLaunchContext* _tmp0;
- _tmp0 = NULL;
- g_app_info_launch_default_for_uri (url, (_tmp0 = g_app_launch_context_new ()), &inner_error);
- if (inner_error != NULL) {
- goto __catch0_g_error;
- }
- (_tmp0 == NULL ? NULL : (_tmp0 = (g_object_unref (_tmp0), NULL)));
- }
- goto __finally0;
- __catch0_g_error:
- {
- GError * ex;
- ex = inner_error;
- inner_error = NULL;
- {
- g_warning ("seahorse-viewer.vala:245: couldn't launch url: %s: %s", url, ex->message);
- (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
- }
- }
- __finally0:
- ;
+ gtk_widget_destroy (GTK_WIDGET (about));
}
-
-static void seahorse_viewer_on_help_show (SeahorseViewer* self, GtkAction* action) {
+static void
+on_help_show (GtkAction* action, SeahorseViewer* self)
+{
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (GTK_IS_ACTION (action));
seahorse_widget_show_help (SEAHORSE_WIDGET (self));
}
+static const GtkActionEntry UI_ENTRIES[] = {
-void seahorse_viewer_show_context_menu (SeahorseViewer* self, guint button, guint time) {
- GtkMenu* _tmp0;
- GtkMenu* menu;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- _tmp0 = NULL;
- menu = (_tmp0 = GTK_MENU (gtk_ui_manager_get_widget (self->priv->_ui_manager, "/KeyPopup")), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- g_return_if_fail (menu != NULL && G_TYPE_FROM_INSTANCE (G_OBJECT (menu)) == GTK_TYPE_MENU);
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, time);
- gtk_widget_show (GTK_WIDGET (menu));
- (menu == NULL ? NULL : (menu = (g_object_unref (menu), NULL)));
-}
-
-
-void seahorse_viewer_show_properties (SeahorseViewer* self, SeahorseObject* obj) {
- SeahorseCommands* _tmp0;
- SeahorseCommands* commands;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (SEAHORSE_IS_OBJECT (obj));
- _tmp0 = NULL;
- commands = (_tmp0 = ((SeahorseCommands*) (g_hash_table_lookup (self->priv->_commands, GINT_TO_POINTER (seahorse_object_get_tag (obj))))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- if (commands != NULL) {
- seahorse_commands_show_properties (commands, obj);
- }
- (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
-}
-
+ /* Top menu items */
+ { "key-menu", NULL, N_("_Key") },
+ { "edit-menu", NULL, N_("_Edit") },
+ { "view-menu", NULL, N_("_View") },
+ { "help-menu", NULL, N_("_Help") },
+
+ { "app-preferences", GTK_STOCK_PREFERENCES, N_("Prefere_nces"), NULL,
+ N_("Change preferences for this program"), G_CALLBACK (on_app_preferences) },
+ { "app-about", "gtk-about", N_("_About"), NULL,
+ N_("About this program"), G_CALLBACK (on_app_about) },
+ { "help-show", GTK_STOCK_HELP, N_("_Contents"), "F1",
+ N_("Show Seahorse help"), G_CALLBACK (on_help_show) }
+};
-static void seahorse_viewer_on_key_properties (SeahorseViewer* self, GtkAction* action) {
+static void
+on_key_properties (GtkAction* action, SeahorseViewer* self)
+{
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- if (seahorse_viewer_get_selected (self) != NULL) {
+
+ if (seahorse_viewer_get_selected (self) != NULL)
seahorse_viewer_show_properties (self, seahorse_viewer_get_selected (self));
- }
-}
-
-
-static gint seahorse_viewer_compare_by_tag (SeahorseViewer* self, SeahorseObject* one, SeahorseObject* two) {
- GQuark kone;
- GQuark ktwo;
- g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), 0);
- g_return_val_if_fail (SEAHORSE_IS_OBJECT (one), 0);
- g_return_val_if_fail (SEAHORSE_IS_OBJECT (two), 0);
- kone = seahorse_object_get_tag (one);
- ktwo = seahorse_object_get_tag (two);
- if (kone < ktwo) {
- return -1;
- }
- if (kone > ktwo) {
- return 1;
- }
- return 0;
}
-
-static void seahorse_viewer_on_delete_complete (SeahorseViewer* self, SeahorseOperation* op) {
+static void
+on_export_done (SeahorseOperation* op, SeahorseViewer* self)
+{
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (SEAHORSE_IS_OPERATION (op));
- if (!seahorse_operation_is_successful (op)) {
- seahorse_operation_display_error (op, _ ("Couldn't delete."), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
- }
-}
-
-
-static void _seahorse_viewer_on_delete_complete_seahorse_done_func (SeahorseOperation* op, gpointer self) {
- seahorse_viewer_on_delete_complete (self, op);
+
+ if (!seahorse_operation_is_successful (op))
+ seahorse_operation_display_error (op, _ ("Couldn't export keys"),
+ GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
}
-
-static void seahorse_viewer_delete_object_batch (SeahorseViewer* self, GList* objects) {
- SeahorseCommands* _tmp0;
- SeahorseCommands* commands;
- SeahorseOperation* op;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (objects != NULL);
- g_assert (objects != NULL);
- _tmp0 = NULL;
- commands = (_tmp0 = ((SeahorseCommands*) (g_hash_table_lookup (self->priv->_commands, GINT_TO_POINTER (seahorse_object_get_tag (((SeahorseObject*) (((SeahorseObject*) (objects->data))))))))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- if (commands == NULL) {
- (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
- return;
- }
- op = seahorse_commands_delete_objects (commands, objects);
- if (op != NULL) {
- seahorse_progress_show (op, _ ("Deleting..."), TRUE);
- seahorse_operation_watch (op, _seahorse_viewer_on_delete_complete_seahorse_done_func, self, NULL, NULL);
- }
- (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
- (op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
-}
-
-
-static void seahorse_viewer_on_key_delete (SeahorseViewer* self, GtkAction* action) {
+static void
+on_key_export_file (GtkAction* action, SeahorseViewer* self)
+{
+ GError *error = NULL;
GList* objects;
- GList* batch;
- GList* _tmp0;
- guint num;
- GQuark ktype;
- GList* _tmp4;
+ GtkDialog* dialog;
+ char* uri;
+
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- objects = NULL;
- batch = NULL;
- /* Get the selected objects and sort them by ktype */
- _tmp0 = NULL;
- objects = (_tmp0 = seahorse_viewer_get_selected_objects (self), (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL))), _tmp0);
- objects = g_list_sort (objects, ((GCompareFunc) (seahorse_viewer_compare_by_tag)));
- num = g_list_length (objects);
- if (num == 0) {
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL)));
+
+ objects = seahorse_viewer_get_selected_objects (self);
+ if (objects == NULL)
return;
- }
- /* Check for private objects */
- {
- GList* object_collection;
- GList* object_it;
- object_collection = objects;
- for (object_it = object_collection; object_it != NULL; object_it = object_it->next) {
- SeahorseObject* object;
- object = ((SeahorseObject*) (object_it->data));
- {
- if (seahorse_object_get_usage (object) == SEAHORSE_USAGE_PRIVATE_KEY) {
- char* prompt;
- prompt = NULL;
- if (num == 1) {
- char* _tmp1;
- _tmp1 = NULL;
- prompt = (_tmp1 = g_strdup_printf (_ ("%s is a private key. Are you sure you want to proceed?"), seahorse_object_get_display_name (((SeahorseObject*) (((SeahorseObject*) (objects->data)))))), (prompt = (g_free (prompt), NULL)), _tmp1);
- } else {
- char* _tmp3;
- const char* _tmp2;
- _tmp3 = NULL;
- _tmp2 = NULL;
- prompt = (_tmp3 = (_tmp2 = _ ("One or more of the deleted keys are private keys. Are you sure you want to proceed?"), (_tmp2 == NULL ? NULL : g_strdup (_tmp2))), (prompt = (g_free (prompt), NULL)), _tmp3);
- }
- if (!seahorse_util_prompt_delete (prompt, GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))))) {
- prompt = (g_free (prompt), NULL);
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL)));
- return;
- }
- prompt = (g_free (prompt), NULL);
- }
- }
- }
- }
- ktype = ((GQuark) (0));
- _tmp4 = NULL;
- batch = (_tmp4 = NULL, (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL))), _tmp4);
- {
- GList* object_collection;
- GList* object_it;
- object_collection = objects;
- for (object_it = object_collection; object_it != NULL; object_it = object_it->next) {
- SeahorseObject* _tmp6;
- SeahorseObject* object;
- _tmp6 = NULL;
- object = (_tmp6 = ((SeahorseObject*) (object_it->data)), (_tmp6 == NULL ? NULL : g_object_ref (_tmp6)));
- {
- /* Process that batch */
- if (ktype != seahorse_object_get_tag (object) && batch != NULL) {
- GList* _tmp5;
- seahorse_viewer_delete_object_batch (self, batch);
- _tmp5 = NULL;
- batch = (_tmp5 = NULL, (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL))), _tmp5);
- }
- /* Add to the batch */
- batch = g_list_prepend (batch, object);
- (object == NULL ? NULL : (object = (g_object_unref (object), NULL)));
- }
+
+ dialog = seahorse_util_chooser_save_new (_("Export public key"),
+ seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ seahorse_util_chooser_show_key_files (dialog);
+ seahorse_util_chooser_set_filename_full (dialog, objects);
+ uri = seahorse_util_chooser_save_prompt (dialog);
+ if (uri != NULL) {
+ GFile* file;
+ GOutputStream* output;
+ SeahorseOperation* op;
+
+ file = g_file_new_for_uri (uri);
+ output = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, 0, NULL, &error));
+ if (output == NULL) {
+ seahorse_util_handle_error (error, _ ("Couldn't export key to \"%s\""),
+ seahorse_util_uri_get_last (uri), NULL);
+ g_clear_error (&error);
+ } else {
+ op = seahorse_source_export_objects (objects, output);
+ seahorse_progress_show (op, _("Exporting keys"), TRUE);
+ seahorse_operation_watch (op, (SeahorseDoneFunc)on_export_done, self, NULL, NULL);
+ g_object_unref (op);
}
+
+
+ g_object_unref (file);
+ g_object_unref (output);
+ g_free (uri);
}
- /* Process last batch */
- if (batch != NULL) {
- seahorse_viewer_delete_object_batch (self, batch);
- }
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL)));
}
-
-static void seahorse_viewer_on_copy_complete (SeahorseViewer* self, SeahorseOperation* op) {
- GObject* _tmp0;
- GObject* result;
- GMemoryOutputStream* _tmp1;
+static void
+on_copy_complete (SeahorseOperation* op, SeahorseViewer* self)
+{
GMemoryOutputStream* output;
- const char* text;
+ const gchar* text;
guint size;
GdkAtom atom;
- GtkClipboard* _tmp2;
GtkClipboard* board;
+
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (SEAHORSE_IS_OPERATION (op));
+
if (!seahorse_operation_is_successful (op)) {
- seahorse_operation_display_error (op, _ ("Couldn't retrieve data from key server"), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
+ seahorse_operation_display_error (op, _ ("Couldn't retrieve data from key server"),
+ GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
return;
}
- _tmp0 = NULL;
- result = (_tmp0 = G_OBJECT (seahorse_operation_get_result (op)), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- g_return_if_fail (result != NULL && G_TYPE_FROM_INSTANCE (result) == G_TYPE_MEMORY_OUTPUT_STREAM);
- _tmp1 = NULL;
- output = (_tmp1 = G_MEMORY_OUTPUT_STREAM (result), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
- text = ((const char*) (g_memory_output_stream_get_data (output)));
+
+ output = G_MEMORY_OUTPUT_STREAM (seahorse_operation_get_result (op));
+ g_return_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output));
+
+ text = g_memory_output_stream_get_data (output);
g_return_if_fail (text != NULL);
+
size = seahorse_util_memory_output_length (output);
g_return_if_fail (size >= 0);
+
atom = gdk_atom_intern ("CLIPBOARD", FALSE);
- _tmp2 = NULL;
- board = (_tmp2 = gtk_clipboard_get (atom), (_tmp2 == NULL ? NULL : g_object_ref (_tmp2)));
- gtk_clipboard_set_text (board, text, ((gint) (size)));
- seahorse_viewer_set_status (self, _ ("Copied keys"));
- (result == NULL ? NULL : (result = (g_object_unref (result), NULL)));
- (output == NULL ? NULL : (output = (g_object_unref (output), NULL)));
- (board == NULL ? NULL : (board = (g_object_unref (board), NULL)));
-}
-
-
-static void* _g_realloc_grealloc_func (void* data, gulong size) {
- return g_realloc (data, size);
-}
-
-static void _g_free_gdestroy_notify (void* data) {
- g_free (data);
-}
-
-
-static void _seahorse_viewer_on_copy_complete_seahorse_done_func (SeahorseOperation* op, gpointer self) {
- seahorse_viewer_on_copy_complete (self, op);
+ board = gtk_clipboard_get (atom);
+ gtk_clipboard_set_text (board, text, (gint)size);
+ seahorse_viewer_set_status (self, _ ("Copied keys"));
}
-
-static void seahorse_viewer_on_key_export_clipboard (SeahorseViewer* self, GtkAction* action) {
+static void
+on_key_export_clipboard (GtkAction* action, SeahorseViewer* self)
+{
GList* objects;
GOutputStream* output;
SeahorseOperation* op;
+
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (GTK_IS_ACTION (action));
+
objects = seahorse_viewer_get_selected_objects (self);
- if (objects == NULL) {
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
+ if (objects == NULL)
return;
- }
- output = G_OUTPUT_STREAM (((GMemoryOutputStream*) (g_memory_output_stream_new (NULL, ((gulong) (0)), _g_realloc_grealloc_func, _g_free_gdestroy_notify))));
+
+ output = G_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0, g_realloc, g_free));
op = seahorse_source_export_objects (objects, output);
seahorse_progress_show (op, _ ("Retrieving keys"), TRUE);
- seahorse_operation_watch (op, _seahorse_viewer_on_copy_complete_seahorse_done_func, self, NULL, NULL);
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- (output == NULL ? NULL : (output = (g_object_unref (output), NULL)));
- (op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
+ seahorse_operation_watch (op, (SeahorseDoneFunc)on_copy_complete, self, NULL, NULL);
+
+ g_list_free (objects);
+ g_object_unref (output);
+ g_object_unref (op);
}
+static gint
+compare_by_tag (SeahorseObject* one, SeahorseObject* two, SeahorseViewer* self)
+{
+ GQuark kone;
+ GQuark ktwo;
+
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), 0);
+ g_return_val_if_fail (SEAHORSE_IS_OBJECT (one), 0);
+ g_return_val_if_fail (SEAHORSE_IS_OBJECT (two), 0);
+
+ kone = seahorse_object_get_tag (one);
+ ktwo = seahorse_object_get_tag (two);
+
+ if (kone < ktwo)
+ return -1;
+ if (kone > ktwo)
+ return 1;
+ return 0;
+}
-static void seahorse_viewer_on_export_done (SeahorseViewer* self, SeahorseOperation* op) {
+static void
+on_delete_complete (SeahorseOperation* op, SeahorseViewer* self)
+{
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (SEAHORSE_IS_OPERATION (op));
- if (!seahorse_operation_is_successful (op)) {
- seahorse_operation_display_error (op, _ ("Couldn't export keys"), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
- }
+
+ if (!seahorse_operation_is_successful (op))
+ seahorse_operation_display_error (op, _ ("Couldn't delete."),
+ GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
}
+static void
+delete_object_batch (SeahorseViewer* self, GList* objects)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ SeahorseCommands* commands;
+ SeahorseOperation* op;
+
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (objects != NULL);
+ g_assert (objects != NULL);
+
+ commands = g_hash_table_lookup (pv->commands, GINT_TO_POINTER (seahorse_object_get_tag (objects->data)));
+ if (commands == NULL)
+ return;
-static void _seahorse_viewer_on_export_done_seahorse_done_func (SeahorseOperation* op, gpointer self) {
- seahorse_viewer_on_export_done (self, op);
+ op = seahorse_commands_delete_objects (commands, objects);
+ if (op != NULL) {
+ seahorse_progress_show (op, _ ("Deleting..."), TRUE);
+ seahorse_operation_watch (op, (SeahorseDoneFunc)on_delete_complete, self, NULL, NULL);
+ g_object_unref (op);
+ }
}
+static void
+on_key_delete (GtkAction* action, SeahorseViewer* self)
+{
+ GList *objects = NULL;
+ GList *batch = NULL;
+ GQuark ktype = 0;
+ GList *l;
+ guint num;
-static void seahorse_viewer_on_key_export_file (SeahorseViewer* self, GtkAction* action) {
- GError * inner_error;
- GList* objects;
- GtkDialog* _tmp0;
- GtkDialog* dialog;
- char* uri;
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- inner_error = NULL;
+
+ /* Get the selected objects and sort them by ktype */
objects = seahorse_viewer_get_selected_objects (self);
- if (objects == NULL) {
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
+ objects = g_list_sort (objects, (GCompareFunc)compare_by_tag);
+
+ num = g_list_length (objects);
+ if (num == 0)
return;
- }
- _tmp0 = NULL;
- dialog = (_tmp0 = seahorse_util_chooser_save_new (_ ("Export public key"), seahorse_view_get_window (SEAHORSE_VIEW (self))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- seahorse_util_chooser_show_key_files (dialog);
- seahorse_util_chooser_set_filename (dialog, objects);
- uri = seahorse_util_chooser_save_prompt (dialog);
- if (uri != NULL) {
- {
- GFile* file;
- GOutputStream* output;
- SeahorseOperation* op;
- file = g_file_new_for_uri (uri);
- output = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, 0, NULL, &inner_error));
- if (inner_error != NULL) {
- goto __catch1_g_error;
- }
- op = seahorse_source_export_objects (objects, output);
- seahorse_progress_show (op, _ ("Exporting keys"), TRUE);
- seahorse_operation_watch (op, _seahorse_viewer_on_export_done_seahorse_done_func, self, NULL, NULL);
- (file == NULL ? NULL : (file = (g_object_unref (file), NULL)));
- (output == NULL ? NULL : (output = (g_object_unref (output), NULL)));
- (op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
- }
- goto __finally1;
- __catch1_g_error:
- {
- GError * ex;
- ex = inner_error;
- inner_error = NULL;
- {
- seahorse_util_handle_error (ex, _ ("Couldn't export key to \"%s\""), seahorse_util_uri_get_last (uri), NULL);
- (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- (dialog == NULL ? NULL : (dialog = (g_object_unref (dialog), NULL)));
- uri = (g_free (uri), NULL);
+
+ /* Check for private objects */
+ for (l = objects; l; l = g_list_next (l)) {
+ SeahorseObject* object = l->data;
+
+ if (seahorse_object_get_usage (object) == SEAHORSE_USAGE_PRIVATE_KEY) {
+ gchar* prompt = NULL;
+ if (num == 1)
+ prompt = g_strdup_printf (_("%s is a private key. Are you sure you want to proceed?"),
+ seahorse_object_get_display_name (object));
+ else
+ prompt = g_strdup (_("One or more of the deleted keys are private keys. Are you sure you want to proceed?"));
+
+ if (!seahorse_util_prompt_delete (prompt, GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))))) {
+ g_free (prompt);
+ g_list_free (objects);
return;
}
}
- __finally1:
- ;
}
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- (dialog == NULL ? NULL : (dialog = (g_object_unref (dialog), NULL)));
- uri = (g_free (uri), NULL);
-}
-
+
+ batch = NULL;
+ for (l = objects; l; l = g_list_next (l)) {
+ SeahorseObject* object = SEAHORSE_OBJECT (l->data);
-static void seahorse_viewer_on_selection_changed (SeahorseViewer* self, SeahorseView* view) {
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (SEAHORSE_IS_VIEW (view));
- gtk_action_group_set_sensitive (self->priv->_object_actions, seahorse_view_get_selected (view) != NULL);
-}
+ /* Process that batch */
+ if (ktype != seahorse_object_get_tag (object) && batch != NULL) {
+ delete_object_batch (self, batch);
+ g_list_free (batch);
+ batch = NULL;
+ }
+
+ /* Add to the batch */
+ batch = g_list_prepend (batch, object);
+ }
+ /* Process last batch */
+ if (batch != NULL)
+ delete_object_batch (self, batch);
-void seahorse_viewer_set_status (SeahorseViewer* self, const char* text) {
- GtkWidget* _tmp0;
- GtkWidget* widget;
- GtkStatusbar* _tmp1;
- GtkStatusbar* status;
- guint id;
- g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (text != NULL);
- _tmp0 = NULL;
- widget = (_tmp0 = seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "status"), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- g_return_if_fail (widget != NULL && G_TYPE_FROM_INSTANCE (G_OBJECT (widget)) == GTK_TYPE_STATUSBAR);
- _tmp1 = NULL;
- status = (_tmp1 = GTK_STATUSBAR (widget), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
- id = gtk_statusbar_get_context_id (status, "key-manager");
- gtk_statusbar_pop (status, id);
- gtk_statusbar_push (status, id, text);
- (widget == NULL ? NULL : (widget = (g_object_unref (widget), NULL)));
- (status == NULL ? NULL : (status = (g_object_unref (status), NULL)));
+ g_list_free (objects);
+ g_list_free (batch);
}
+
+static const GtkActionEntry KEY_ENTRIES[] = {
+ { "key-properties", GTK_STOCK_PROPERTIES, N_("P_roperties"), NULL,
+ N_("Show key properties"), G_CALLBACK (on_key_properties) },
+ { "key-export-file", GTK_STOCK_SAVE_AS, N_("E_xport Public Key..."), NULL,
+ N_("Export public part of key to a file"), G_CALLBACK (on_key_export_file) },
+ { "key-export-clipboard", GTK_STOCK_COPY, N_("_Copy Public Key"), "<control>C",
+ N_("Copy public part of selected keys to the clipboard"), G_CALLBACK (on_key_export_clipboard) },
+ { "key-delete", GTK_STOCK_DELETE, N_("_Delete Key"), NULL,
+ N_("Delete selected keys"), G_CALLBACK (on_key_delete) }
+};
+
+static void
+include_basic_actions (SeahorseViewer* self)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ GtkActionGroup* actions;
-
-void seahorse_viewer_set_numbered_status (SeahorseViewer* self, const char* text, gint num) {
- char* message;
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (text != NULL);
- message = g_strdup_printf (text, num);
- seahorse_viewer_set_status (self, message);
- message = (g_free (message), NULL);
-}
-
-
-SeahorseObject* seahorse_viewer_get_selected (SeahorseViewer* self) {
- return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected (self);
-}
-
-
-static SeahorseObject* seahorse_viewer_real_get_selected (SeahorseViewer* base) {
- SeahorseViewer* self;
- self = base;
- /* Must be overridden */
- return NULL;
-}
-
-
-void seahorse_viewer_set_selected (SeahorseViewer* self, SeahorseObject* value) {
- SEAHORSE_VIEWER_GET_CLASS (self)->set_selected (self, value);
-}
-
-
-static void seahorse_viewer_real_set_selected (SeahorseViewer* base, SeahorseObject* value) {
- SeahorseViewer* self;
- GList* objects;
- self = base;
- objects = NULL;
- objects = g_list_prepend (objects, value);
- seahorse_viewer_set_selected_objects (self, objects);
- (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
- g_object_notify (((GObject *) (self)), "selected");
-}
-
-
-SeahorseSet* seahorse_viewer_get_current_set (SeahorseViewer* self) {
- return SEAHORSE_VIEWER_GET_CLASS (self)->get_current_set (self);
-}
-
-
-static SeahorseSet* seahorse_viewer_real_get_current_set (SeahorseViewer* base) {
- SeahorseViewer* self;
- self = base;
- /* Must be overridden */
- return NULL;
+
+ actions = gtk_action_group_new ("main");
+ gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (actions, UI_ENTRIES, G_N_ELEMENTS (UI_ENTRIES), self);
+ seahorse_viewer_include_actions (self, actions);
+ g_object_unref (actions);
+
+ pv->object_actions = gtk_action_group_new ("key");
+ gtk_action_group_set_translation_domain (pv->object_actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (pv->object_actions, KEY_ENTRIES, G_N_ELEMENTS (KEY_ENTRIES), self);
+ /* Mark the properties toolbar button as important */
+ g_object_set (gtk_action_group_get_action (pv->object_actions, "key-properties"), "is-important", TRUE, NULL);
+ seahorse_viewer_include_actions (self, pv->object_actions);
}
+static void
+on_selection_changed (SeahorseView* view, SeahorseViewer* self)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
-static GtkWindow* seahorse_viewer_real_get_window (SeahorseView* base) {
- SeahorseViewer* self;
- self = SEAHORSE_VIEWER (base);
- return GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)));
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (SEAHORSE_IS_VIEW (view));
+
+ gtk_action_group_set_sensitive (pv->object_actions, seahorse_view_get_selected (view) != NULL);
}
+static void
+on_add_widget (GtkUIManager* ui, GtkWidget* widget, SeahorseViewer* self)
+{
+ const char* name = NULL;
+ GtkWidget* holder;
+
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (GTK_IS_UI_MANAGER (ui));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (GTK_IS_MENU_BAR (widget))
+ name = "menu-placeholder";
+ else if (GTK_IS_TOOLBAR (widget))
+ name = "toolbar-placeholder";
+ else
+ name = NULL;
-static void _seahorse_viewer_on_ui_add_widget_gtk_ui_manager_add_widget (GtkUIManager* _sender, GtkWidget* widget, gpointer self) {
- seahorse_viewer_on_ui_add_widget (self, _sender, widget);
+ holder = seahorse_widget_get_widget (SEAHORSE_WIDGET (self), name);
+ if (holder != NULL)
+ gtk_container_add ((GTK_CONTAINER (holder)), widget);
+ else
+ g_warning ("no place holder found for: %s", name);
}
-static void _seahorse_viewer_on_selection_changed_seahorse_view_selection_changed (SeahorseViewer* _sender, gpointer self) {
- seahorse_viewer_on_selection_changed (self, _sender);
-}
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+static GObject*
+seahorse_viewer_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ GObject *obj = G_OBJECT_CLASS (seahorse_viewer_parent_class)->constructor (type, n_props, props);
+ SeahorseViewer *self = NULL;
+ SeahorseViewerPrivate *pv;
+ GError *error = NULL;
+ GtkWidget *win;
+ const gchar *name;
+ gchar *path;
+ GList *types, *l;
+
+ if (obj) {
+ pv = SEAHORSE_VIEWER_GET_PRIVATE (obj);
+ self = SEAHORSE_VIEWER (obj);
-static GObject * seahorse_viewer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
- GObject * obj;
- SeahorseViewerClass * klass;
- GObjectClass * parent_class;
- SeahorseViewer * self;
- GError * inner_error;
- klass = SEAHORSE_VIEWER_CLASS (g_type_class_peek (SEAHORSE_TYPE_VIEWER));
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = SEAHORSE_VIEWER (obj);
- inner_error = NULL;
- {
- GtkUIManager* _tmp0;
- GtkWidget* _tmp1;
- GtkWidget* win;
- GHashTable* _tmp2;
- GList* types;
- _tmp0 = NULL;
- self->priv->_ui_manager = (_tmp0 = gtk_ui_manager_new (), (self->priv->_ui_manager == NULL ? NULL : (self->priv->_ui_manager = (g_object_unref (self->priv->_ui_manager), NULL))), _tmp0);
/* The widgts get added in an idle loop later */
- g_signal_connect_object (self->priv->_ui_manager, "add-widget", ((GCallback) (_seahorse_viewer_on_ui_add_widget_gtk_ui_manager_add_widget)), self, 0);
- {
- char* path;
- path = g_strdup_printf ("%sseahorse-%s.ui", SEAHORSE_GLADEDIR, seahorse_widget_get_name (SEAHORSE_WIDGET (self)));
- gtk_ui_manager_add_ui_from_file (self->priv->_ui_manager, path, &inner_error);
- if (inner_error != NULL) {
- goto __catch2_g_error;
- }
- path = (g_free (path), NULL);
- }
- goto __finally2;
- __catch2_g_error:
- {
- GError * ex;
- ex = inner_error;
- inner_error = NULL;
- {
- g_warning ("seahorse-viewer.vala:70: couldn't load ui description for '%s': %s", seahorse_widget_get_name (SEAHORSE_WIDGET (self)), ex->message);
- (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
- }
- }
- __finally2:
- ;
- _tmp1 = NULL;
- win = (_tmp1 = seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
- if (G_TYPE_FROM_INSTANCE (G_OBJECT (win)) == GTK_TYPE_WINDOW) {
- gtk_window_add_accel_group ((GTK_WINDOW (win)), gtk_ui_manager_get_accel_group (self->priv->_ui_manager));
- }
- seahorse_viewer_include_basic_actions (self);
- g_signal_connect_object (SEAHORSE_VIEW (self), "selection-changed", ((GCallback) (_seahorse_viewer_on_selection_changed_seahorse_view_selection_changed)), self, 0);
+ name = seahorse_widget_get_name (SEAHORSE_WIDGET (self));
+ path = g_strdup_printf ("%sseahorse-%s.ui", SEAHORSE_GLADEDIR, name);
+ if (!gtk_ui_manager_add_ui_from_file (pv->ui_manager, path, &error)) {
+ g_warning ("couldn't load ui description for '%s': %s", name, error->message);
+ g_clear_error (&error);
+ }
+
+ g_free (path);
+
+ win = seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self));
+ if (G_TYPE_FROM_INSTANCE (G_OBJECT (win)) == GTK_TYPE_WINDOW)
+ gtk_window_add_accel_group (GTK_WINDOW (win),
+ gtk_ui_manager_get_accel_group (pv->ui_manager));
+
+ include_basic_actions (self);
+
+ g_signal_connect (SEAHORSE_VIEW (self), "selection-changed",
+ G_CALLBACK (on_selection_changed), self);
+
/* Setup the commands */
- _tmp2 = NULL;
- self->priv->_commands = (_tmp2 = g_hash_table_new (g_direct_hash, g_direct_equal), (self->priv->_commands == NULL ? NULL : (self->priv->_commands = (g_hash_table_unref (self->priv->_commands), NULL))), _tmp2);
types = seahorse_registry_find_types (seahorse_registry_get (), "commands", NULL, NULL);
- {
- GList* typ_collection;
- GList* typ_it;
- typ_collection = types;
- for (typ_it = typ_collection; typ_it != NULL; typ_it = typ_it->next) {
- GType typ;
- typ = GPOINTER_TO_INT (typ_it->data);
- {
- SeahorseCommands* commands;
- SeahorseCommands* _tmp3;
- GtkActionGroup* _tmp4;
- GtkActionGroup* actions;
- const char* _tmp5;
- char* uidef;
- /* Add each commands to our hash table */
- commands = SEAHORSE_COMMANDS (g_object_new (typ, "view", self, NULL, NULL));
- _tmp3 = NULL;
- g_hash_table_insert (self->priv->_commands, GINT_TO_POINTER (seahorse_commands_get_ktype (commands)), (_tmp3 = commands, (_tmp3 == NULL ? NULL : g_object_ref (_tmp3))));
- /* Add the UI for each commands */
- _tmp4 = NULL;
- actions = (_tmp4 = seahorse_commands_get_command_actions (commands), (_tmp4 == NULL ? NULL : g_object_ref (_tmp4)));
- if (actions != NULL) {
- seahorse_viewer_include_actions (self, actions);
- }
- _tmp5 = NULL;
- uidef = (_tmp5 = seahorse_commands_get_ui_definition (commands), (_tmp5 == NULL ? NULL : g_strdup (_tmp5)));
- if (uidef != NULL && g_utf8_strlen (uidef, -1) > 0) {
- gtk_ui_manager_add_ui_from_string (self->priv->_ui_manager, uidef, ((glong) (-1)), &inner_error);
- if (inner_error != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, inner_error->message);
- g_clear_error (&inner_error);
- }
- }
- (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
- (actions == NULL ? NULL : (actions = (g_object_unref (actions), NULL)));
- uidef = (g_free (uidef), NULL);
+ for (l = types; l; l = g_list_next (l)) {
+ GType typ = GPOINTER_TO_INT (l->data);
+ SeahorseCommands *commands;
+ GtkActionGroup *actions;
+ const gchar *uidef;
+
+ /* Add each commands to our hash table */
+ commands = g_object_new (typ, "view", self, NULL);
+ g_hash_table_insert (pv->commands, GINT_TO_POINTER (seahorse_commands_get_ktype (commands)), commands);
+
+ actions = seahorse_commands_get_command_actions (commands);
+ if (actions != NULL)
+ seahorse_viewer_include_actions (self, actions);
+ g_object_unref (actions);
+
+ uidef = seahorse_commands_get_ui_definition (commands);
+ if (uidef && uidef[0]) {
+ if (!gtk_ui_manager_add_ui_from_string (pv->ui_manager, uidef, -1, &error)) {
+ g_warning ("couldn't load UI description from commands: %s: %s", G_OBJECT_TYPE_NAME(commands), error->message);
+ g_clear_error (&error);
}
}
+
+
}
- (win == NULL ? NULL : (win = (g_object_unref (win), NULL)));
- (types == NULL ? NULL : (types = (g_list_free (types), NULL)));
}
+
return obj;
}
-static void seahorse_viewer_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
- SeahorseViewer * self;
- self = SEAHORSE_VIEWER (object);
- switch (property_id) {
- case SEAHORSE_VIEWER_SELECTED:
+static void
+seahorse_viewer_init (SeahorseViewer *self)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+
+ pv->ui_manager = gtk_ui_manager_new ();
+ g_signal_connect (pv->ui_manager, "add-widget", G_CALLBACK (on_add_widget), self);
+
+ pv->commands = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
+
+
+}
+
+static void
+seahorse_viewer_dispose (GObject *obj)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (obj);
+
+ if (pv->ui_manager)
+ g_object_unref (pv->ui_manager);
+ pv->ui_manager = NULL;
+
+ if (pv->object_actions)
+ g_object_unref (pv->object_actions);
+ pv->object_actions = NULL;
+
+ if (pv->commands)
+ g_hash_table_unref (pv->commands);
+ pv->commands = NULL;
+
+ G_OBJECT_CLASS (seahorse_viewer_parent_class)->dispose (obj);
+}
+
+static void
+seahorse_viewer_finalize (GObject *obj)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE(obj);
+
+ g_assert (pv->object_actions == NULL);
+ g_assert (pv->commands == NULL);
+ g_assert (pv->ui_manager == NULL);
+
+ G_OBJECT_CLASS (seahorse_viewer_parent_class)->finalize (obj);
+}
+
+static void
+seahorse_viewer_get_property (GObject *obj, guint prop_id, GValue *value,
+ GParamSpec *pspec)
+{
+ SeahorseViewer *self = SEAHORSE_VIEWER (obj);
+
+ switch (prop_id) {
+ case PROP_SELECTED:
g_value_set_object (value, seahorse_viewer_get_selected (self));
break;
- case SEAHORSE_VIEWER_CURRENT_SET:
+ case PROP_CURRENT_SET:
g_value_set_object (value, seahorse_viewer_get_current_set (self));
break;
- case SEAHORSE_VIEWER_WINDOW:
+ case PROP_WINDOW:
g_value_set_object (value, seahorse_view_get_window (SEAHORSE_VIEW (self)));
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
-
-static void seahorse_viewer_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
- SeahorseViewer * self;
- self = SEAHORSE_VIEWER (object);
- switch (property_id) {
- case SEAHORSE_VIEWER_SELECTED:
+static void
+seahorse_viewer_set_property (GObject *obj, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SeahorseViewer *self = SEAHORSE_VIEWER (obj);
+
+ switch (prop_id) {
+ case PROP_SELECTED:
seahorse_viewer_set_selected (self, g_value_get_object (value));
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
-
-static void seahorse_viewer_class_init (SeahorseViewerClass * klass) {
+static void
+seahorse_viewer_class_init (SeahorseViewerClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
seahorse_viewer_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (SeahorseViewerPrivate));
- G_OBJECT_CLASS (klass)->get_property = seahorse_viewer_get_property;
- G_OBJECT_CLASS (klass)->set_property = seahorse_viewer_set_property;
- G_OBJECT_CLASS (klass)->constructor = seahorse_viewer_constructor;
- G_OBJECT_CLASS (klass)->finalize = seahorse_viewer_finalize;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected_objects = seahorse_viewer_real_get_selected_objects;
- SEAHORSE_VIEWER_CLASS (klass)->set_selected_objects = seahorse_viewer_real_set_selected_objects;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected_object_and_uid = seahorse_viewer_real_get_selected_object_and_uid;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected = seahorse_viewer_real_get_selected;
- SEAHORSE_VIEWER_CLASS (klass)->set_selected = seahorse_viewer_real_set_selected;
- SEAHORSE_VIEWER_CLASS (klass)->get_current_set = seahorse_viewer_real_get_current_set;
- g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_VIEWER_SELECTED, "selected");
- g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_VIEWER_CURRENT_SET, "current-set");
- g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_VIEWER_WINDOW, "window");
+
+ gobject_class->constructor = seahorse_viewer_constructor;
+ gobject_class->dispose = seahorse_viewer_dispose;
+ gobject_class->finalize = seahorse_viewer_finalize;
+ gobject_class->set_property = seahorse_viewer_set_property;
+ gobject_class->get_property = seahorse_viewer_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_SELECTED,
+ g_param_spec_object ("selected", "Selected", "Selected Object",
+ SEAHORSE_TYPE_OBJECT, G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_WINDOW,
+ g_param_spec_object ("window", "Window", "Window of View",
+ GTK_TYPE_WIDGET, G_PARAM_READABLE));
+
+ g_object_class_install_property (gobject_class, PROP_CURRENT_SET,
+ g_param_spec_object ("current-set", "Current Set", "Currently visible set of objects",
+ SEAHORSE_TYPE_SET, G_PARAM_READABLE));
+}
+
+static void
+seahorse_viewer_implement_view (SeahorseViewIface *iface)
+{
+ iface->get_selected_objects = (gpointer)seahorse_viewer_get_selected_objects;
+ iface->set_selected_objects = (gpointer)seahorse_viewer_set_selected_objects;
+ iface->get_selected = (gpointer)seahorse_viewer_get_selected;
+ iface->set_selected = (gpointer)seahorse_viewer_set_selected;
+ iface->get_current_set = (gpointer)seahorse_viewer_get_current_set;
+ iface->get_window = (gpointer)seahorse_viewer_get_window;
}
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+void
+seahorse_viewer_ensure_updated (SeahorseViewer* self)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+
+ gtk_ui_manager_ensure_update (pv->ui_manager);
-static void seahorse_viewer_seahorse_view_interface_init (SeahorseViewIface * iface) {
- seahorse_viewer_seahorse_view_parent_iface = g_type_interface_peek_parent (iface);
- iface->get_selected_objects = seahorse_viewer_get_selected_objects;
- iface->set_selected_objects = seahorse_viewer_set_selected_objects;
- iface->get_selected = seahorse_viewer_get_selected;
- iface->set_selected = seahorse_viewer_set_selected;
- iface->get_current_set = seahorse_viewer_get_current_set;
- iface->get_window = seahorse_viewer_real_get_window;
}
+void
+seahorse_viewer_include_actions (SeahorseViewer* self, GtkActionGroup* actions)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
-static void seahorse_viewer_instance_init (SeahorseViewer * self) {
- self->priv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ gtk_ui_manager_insert_action_group (pv->ui_manager, actions, -1);
}
+GList*
+seahorse_viewer_get_selected_objects (SeahorseViewer* self)
+{
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
+ g_return_val_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_objects, NULL);
+
+ return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_objects (self);
+}
-static void seahorse_viewer_finalize (GObject * obj) {
- SeahorseViewer * self;
- self = SEAHORSE_VIEWER (obj);
- (self->priv->_ui_manager == NULL ? NULL : (self->priv->_ui_manager = (g_object_unref (self->priv->_ui_manager), NULL)));
- (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL)));
- (self->priv->_commands == NULL ? NULL : (self->priv->_commands = (g_hash_table_unref (self->priv->_commands), NULL)));
- G_OBJECT_CLASS (seahorse_viewer_parent_class)->finalize (obj);
+void
+seahorse_viewer_set_selected_objects (SeahorseViewer* self, GList* objects)
+{
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->set_selected_objects);
+
+ SEAHORSE_VIEWER_GET_CLASS (self)->set_selected_objects (self, objects);
+}
+
+SeahorseObject*
+seahorse_viewer_get_selected_object_and_uid (SeahorseViewer* self, guint* uid)
+{
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
+ g_return_val_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_object_and_uid, NULL);
+
+ return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_object_and_uid (self, uid);
}
+void
+seahorse_viewer_show_context_menu (SeahorseViewer* self, guint button, guint time)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ GtkMenu* menu;
-GType seahorse_viewer_get_type (void) {
- static GType seahorse_viewer_type_id = 0;
- if (seahorse_viewer_type_id == 0) {
- static const GTypeInfo g_define_type_info = { sizeof (SeahorseViewerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_viewer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseViewer), 0, (GInstanceInitFunc) seahorse_viewer_instance_init };
- static const GInterfaceInfo seahorse_view_info = { (GInterfaceInitFunc) seahorse_viewer_seahorse_view_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
- seahorse_viewer_type_id = g_type_register_static (SEAHORSE_TYPE_WIDGET, "SeahorseViewer", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
- g_type_add_interface_static (seahorse_viewer_type_id, SEAHORSE_TYPE_VIEW, &seahorse_view_info);
- }
- return seahorse_viewer_type_id;
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+
+ menu = GTK_MENU (gtk_ui_manager_get_widget (pv->ui_manager, "/KeyPopup"));
+ g_return_if_fail (GTK_IS_MENU (menu));
+
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, time);
+ gtk_widget_show (GTK_WIDGET (menu));
}
+void
+seahorse_viewer_show_properties (SeahorseViewer* self, SeahorseObject* obj)
+{
+ SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
+ SeahorseCommands* commands;
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
- if (array != NULL && destroy_func != NULL) {
- int i;
- if (array_length >= 0)
- for (i = 0; i < array_length; i = i + 1) {
- if (((gpointer*) (array))[i] != NULL)
- destroy_func (((gpointer*) (array))[i]);
- }
- else
- for (i = 0; ((gpointer*) (array))[i] != NULL; i = i + 1) {
- destroy_func (((gpointer*) (array))[i]);
- }
- }
- g_free (array);
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (SEAHORSE_IS_OBJECT (obj));
+
+ commands = SEAHORSE_COMMANDS (g_hash_table_lookup (pv->commands, GINT_TO_POINTER (seahorse_object_get_tag (obj))));
+ if (commands != NULL)
+ seahorse_commands_show_properties (commands, obj);
}
+void
+seahorse_viewer_set_status (SeahorseViewer* self, const char* text)
+{
+ GtkStatusbar* status;
+ guint id;
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (text != NULL);
+
+ status = GTK_STATUSBAR (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "status"));
+ g_return_if_fail (GTK_IS_STATUSBAR (status));
+
+ id = gtk_statusbar_get_context_id (status, "key-manager");
+ gtk_statusbar_pop (status, id);
+ gtk_statusbar_push (status, id, text);
+}
+void
+seahorse_viewer_set_numbered_status (SeahorseViewer* self, const char* text, gint num)
+{
+ gchar* message;
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (text != NULL);
+
+ message = g_strdup_printf (text, num);
+ seahorse_viewer_set_status (self, message);
+ g_free (message);
+}
+
+SeahorseObject*
+seahorse_viewer_get_selected (SeahorseViewer* self)
+{
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
+ g_return_val_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->get_selected, NULL);
+
+ return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected (self);
+}
+
+void
+seahorse_viewer_set_selected (SeahorseViewer* self, SeahorseObject* value)
+{
+ g_return_if_fail (SEAHORSE_IS_VIEWER (self));
+ g_return_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->set_selected);
+
+ SEAHORSE_VIEWER_GET_CLASS (self)->set_selected (self, value);
+}
+
+SeahorseSet*
+seahorse_viewer_get_current_set (SeahorseViewer* self)
+{
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
+ g_return_val_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->get_current_set, NULL);
+
+ return SEAHORSE_VIEWER_GET_CLASS (self)->get_current_set (self);
+}
+
+GtkWindow*
+seahorse_viewer_get_window (SeahorseViewer* self)
+{
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
+ return GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)));
+}
Modified: trunk/src/seahorse-viewer.h
==============================================================================
--- trunk/src/seahorse-viewer.h (original)
+++ trunk/src/seahorse-viewer.h Sun Sep 7 05:20:38 2008
@@ -22,61 +22,86 @@
#ifndef __SEAHORSE_VIEWER_H__
#define __SEAHORSE_VIEWER_H__
-#include <glib.h>
#include <glib-object.h>
-#include <seahorse-widget.h>
-#include <seahorse-view.h>
-#include <gtk/gtk.h>
-#include <seahorse-object.h>
-#include <stdlib.h>
-#include <string.h>
-#include <seahorse-set.h>
-
-G_BEGIN_DECLS
-
-
-#define SEAHORSE_TYPE_VIEWER (seahorse_viewer_get_type ())
-#define SEAHORSE_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_VIEWER, SeahorseViewer))
-#define SEAHORSE_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_VIEWER, SeahorseViewerClass))
-#define SEAHORSE_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_VIEWER))
-#define SEAHORSE_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_VIEWER))
-#define SEAHORSE_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_VIEWER, SeahorseViewerClass))
+
+#include "seahorse-object.h"
+#include "seahorse-set.h"
+#include "seahorse-view.h"
+#include "seahorse-widget.h"
+
+#define SEAHORSE_TYPE_VIEWER (seahorse_viewer_get_type ())
+#define SEAHORSE_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_VIEWER, SeahorseViewer))
+#define SEAHORSE_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_VIEWER, SeahorseViewerClass))
+#define SEAHORSE_IS_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_VIEWER))
+#define SEAHORSE_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_VIEWER))
+#define SEAHORSE_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_VIEWER, SeahorseViewerClass))
typedef struct _SeahorseViewer SeahorseViewer;
typedef struct _SeahorseViewerClass SeahorseViewerClass;
typedef struct _SeahorseViewerPrivate SeahorseViewerPrivate;
-
+
struct _SeahorseViewer {
- SeahorseWidget parent_instance;
- SeahorseViewerPrivate * priv;
+ SeahorseWidget parent;
};
struct _SeahorseViewerClass {
- SeahorseWidgetClass parent_class;
+ SeahorseWidgetClass parent;
+
+ /* virtual -------------------------------------------------------- */
+
GList* (*get_selected_objects) (SeahorseViewer* self);
+
void (*set_selected_objects) (SeahorseViewer* self, GList* objects);
+
SeahorseObject* (*get_selected_object_and_uid) (SeahorseViewer* self, guint* uid);
+
SeahorseObject* (*get_selected) (SeahorseViewer* self);
+
void (*set_selected) (SeahorseViewer* self, SeahorseObject* value);
+
SeahorseSet* (*get_current_set) (SeahorseViewer* self);
+
+ /* signals --------------------------------------------------------- */
+
+ void (*signal) (SeahorseViewer *viewer);
};
+GType seahorse_viewer_get_type (void);
+
+void seahorse_viewer_ensure_updated (SeahorseViewer* self);
+
+void seahorse_viewer_include_actions (SeahorseViewer* self,
+ GtkActionGroup* actions);
+
+GList* seahorse_viewer_get_selected_objects (SeahorseViewer* self);
+
+void seahorse_viewer_set_selected_objects (SeahorseViewer* self,
+ GList* objects);
+
+SeahorseObject* seahorse_viewer_get_selected_object_and_uid (SeahorseViewer* self,
+ guint* uid);
+
+void seahorse_viewer_show_context_menu (SeahorseViewer* self,
+ guint button,
+ guint time);
+
+void seahorse_viewer_show_properties (SeahorseViewer* self,
+ SeahorseObject* obj);
+
+void seahorse_viewer_set_status (SeahorseViewer* self,
+ const char* text);
+
+void seahorse_viewer_set_numbered_status (SeahorseViewer* self,
+ const char* text,
+ gint num);
+
+SeahorseObject* seahorse_viewer_get_selected (SeahorseViewer* self);
-void seahorse_viewer_ensure_updated (SeahorseViewer* self);
-void seahorse_viewer_include_actions (SeahorseViewer* self, GtkActionGroup* actions);
-GList* seahorse_viewer_get_selected_objects (SeahorseViewer* self);
-void seahorse_viewer_set_selected_objects (SeahorseViewer* self, GList* objects);
-SeahorseObject* seahorse_viewer_get_selected_object_and_uid (SeahorseViewer* self, guint* uid);
-void seahorse_viewer_show_context_menu (SeahorseViewer* self, guint button, guint time);
-void seahorse_viewer_show_properties (SeahorseViewer* self, SeahorseObject* obj);
-void seahorse_viewer_set_status (SeahorseViewer* self, const char* text);
-void seahorse_viewer_set_numbered_status (SeahorseViewer* self, const char* text, gint num);
-SeahorseObject* seahorse_viewer_get_selected (SeahorseViewer* self);
-void seahorse_viewer_set_selected (SeahorseViewer* self, SeahorseObject* value);
-SeahorseSet* seahorse_viewer_get_current_set (SeahorseViewer* self);
-GType seahorse_viewer_get_type (void);
+void seahorse_viewer_set_selected (SeahorseViewer* self,
+ SeahorseObject* value);
+SeahorseSet* seahorse_viewer_get_current_set (SeahorseViewer* self);
-G_END_DECLS
+GtkWindow* seahorse_viewer_get_window (SeahorseViewer* self);
-#endif
+#endif /* __SEAHORSE_VIEWER_H__ */
Modified: trunk/src/vala-build.stamp
==============================================================================
--- trunk/src/vala-build.stamp (original)
+++ trunk/src/vala-build.stamp Sun Sep 7 05:20:38 2008
@@ -1 +1 @@
-1220299564
+1220761717
Modified: trunk/ssh/seahorse-ssh-commands.c
==============================================================================
--- trunk/ssh/seahorse-ssh-commands.c (original)
+++ trunk/ssh/seahorse-ssh-commands.c Sun Sep 7 05:20:38 2008
@@ -167,12 +167,10 @@
}
-static char* seahorse_ssh_commands_real_get_ui_definition (SeahorseCommands* base) {
+static const char* seahorse_ssh_commands_real_get_ui_definition (SeahorseCommands* base) {
SeahorseSSHCommands* self;
- const char* _tmp0;
self = SEAHORSE_SSH_COMMANDS (base);
- _tmp0 = NULL;
- return (_tmp0 = SEAHORSE_SSH_COMMANDS_UI_DEF, (_tmp0 == NULL ? NULL : g_strdup (_tmp0)));
+ return SEAHORSE_SSH_COMMANDS_UI_DEF;
}
Modified: trunk/ssh/seahorse-ssh-commands.vala
==============================================================================
--- trunk/ssh/seahorse-ssh-commands.vala (original)
+++ trunk/ssh/seahorse-ssh-commands.vala Sun Sep 7 05:20:38 2008
@@ -46,7 +46,7 @@
get { return Seahorse.Ssh.TYPE; }
}
- public override string# ui_definition {
+ public override weak string ui_definition {
get { return UI_DEF; }
}
Modified: trunk/ssh/vala-build.stamp
==============================================================================
--- trunk/ssh/vala-build.stamp (original)
+++ trunk/ssh/vala-build.stamp Sun Sep 7 05:20:38 2008
@@ -1 +1 @@
-1220213856
+1220761712
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]