~carifio/seahorse/seahorse-remove-broken-help-buttons

« back to all changes in this revision

Viewing changes to src/seahorse-viewer.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-07-22 09:20:59 UTC
  • mto: (3.2.1 sid) (1.4.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 59.
  • Revision ID: james.westby@ubuntu.com-20080722092059-q336t49r9uaveij3
Tags: upstream-2.23.5
ImportĀ upstreamĀ versionĀ 2.23.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Seahorse
 
3
 * 
 
4
 * Copyright (C) 2008 Stefan Walter
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or modify 
 
7
 * it under the terms of the GNU Lesser General Public License as
 
8
 * published by the Free Software Foundation; either version 2.1 of
 
9
 * the License, or (at your option) any later version.
 
10
 *  
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *  
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
19
 * 02111-1307, USA.  
 
20
 */
 
21
 
 
22
#include "seahorse-viewer.h"
 
23
#include <glib/gi18n-lib.h>
 
24
#include <config.h>
 
25
#include <seahorse-preferences.h>
 
26
#include <gio/gio.h>
 
27
#include <seahorse-commands.h>
 
28
#include <seahorse-util.h>
 
29
#include <seahorse-types.h>
 
30
#include <seahorse-operation.h>
 
31
#include <gdk/gdk.h>
 
32
#include <seahorse-source.h>
 
33
#include <seahorse-progress.h>
 
34
#include <common/seahorse-registry.h>
 
35
 
 
36
 
 
37
 
 
38
 
 
39
struct _SeahorseViewerPrivate {
 
40
        GtkUIManager* _ui_manager;
 
41
        GtkActionGroup* _object_actions;
 
42
        GHashTable* _commands;
 
43
};
 
44
 
 
45
#define SEAHORSE_VIEWER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_VIEWER, SeahorseViewerPrivate))
 
46
enum  {
 
47
        SEAHORSE_VIEWER_DUMMY_PROPERTY,
 
48
        SEAHORSE_VIEWER_SELECTED,
 
49
        SEAHORSE_VIEWER_CURRENT_SET,
 
50
        SEAHORSE_VIEWER_WINDOW
 
51
};
 
52
static gboolean seahorse_viewer__about_initialized;
 
53
static void _seahorse_viewer_on_app_preferences_gtk_action_activate (GtkAction* _sender, gpointer self);
 
54
static void _seahorse_viewer_on_app_about_gtk_action_activate (GtkAction* _sender, gpointer self);
 
55
static void _seahorse_viewer_on_help_show_gtk_action_activate (GtkAction* _sender, gpointer self);
 
56
static void _seahorse_viewer_on_key_properties_gtk_action_activate (GtkAction* _sender, gpointer self);
 
57
static void _seahorse_viewer_on_key_export_file_gtk_action_activate (GtkAction* _sender, gpointer self);
 
58
static void _seahorse_viewer_on_key_export_clipboard_gtk_action_activate (GtkAction* _sender, gpointer self);
 
59
static void _seahorse_viewer_on_key_delete_gtk_action_activate (GtkAction* _sender, gpointer self);
 
60
static void seahorse_viewer_include_basic_actions (SeahorseViewer* self);
 
61
static GList* seahorse_viewer_real_get_selected_objects (SeahorseViewer* self);
 
62
static void seahorse_viewer_real_set_selected_objects (SeahorseViewer* self, GList* objects);
 
63
static SeahorseObject* seahorse_viewer_real_get_selected_object_and_uid (SeahorseViewer* self, guint* uid);
 
64
static void seahorse_viewer_on_ui_add_widget (SeahorseViewer* self, GtkUIManager* ui, GtkWidget* widget);
 
65
static void seahorse_viewer_on_app_preferences (SeahorseViewer* self, GtkAction* action);
 
66
static void _seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func (GtkAboutDialog* about, const char* link_, gpointer self);
 
67
static void seahorse_viewer_on_app_about (SeahorseViewer* self, GtkAction* action);
 
68
static void seahorse_viewer_on_about_link_clicked (GtkAboutDialog* about, const char* url);
 
69
static void seahorse_viewer_on_help_show (SeahorseViewer* self, GtkAction* action);
 
70
static void seahorse_viewer_on_key_properties (SeahorseViewer* self, GtkAction* action);
 
71
static gint seahorse_viewer_compare_by_tag (SeahorseViewer* self, SeahorseObject* one, SeahorseObject* two);
 
72
static void seahorse_viewer_delete_object_batch (SeahorseViewer* self, GList* objects);
 
73
static void seahorse_viewer_on_key_delete (SeahorseViewer* self, GtkAction* action);
 
74
static void seahorse_viewer_on_copy_complete (SeahorseViewer* self, SeahorseOperation* op);
 
75
static void* _g_realloc_grealloc_func (void* data, gulong size);
 
76
static void _g_free_gdestroy_notify (void* data);
 
77
static void _seahorse_viewer_on_copy_complete_seahorse_done_func (SeahorseOperation* op, gpointer self);
 
78
static void seahorse_viewer_on_key_export_clipboard (SeahorseViewer* self, GtkAction* action);
 
79
static void seahorse_viewer_on_export_done (SeahorseViewer* self, SeahorseOperation* op);
 
80
static void _seahorse_viewer_on_export_done_seahorse_done_func (SeahorseOperation* op, gpointer self);
 
81
static void seahorse_viewer_on_key_export_file (SeahorseViewer* self, GtkAction* action);
 
82
static void seahorse_viewer_on_selection_changed (SeahorseViewer* self, SeahorseView* view);
 
83
static void _seahorse_viewer_on_ui_add_widget_gtk_ui_manager_add_widget (GtkUIManager* _sender, GtkWidget* widget, gpointer self);
 
84
static void _seahorse_viewer_on_selection_changed_seahorse_view_selection_changed (SeahorseViewer* _sender, gpointer self);
 
85
static GObject * seahorse_viewer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
 
86
static gpointer seahorse_viewer_parent_class = NULL;
 
87
static SeahorseViewIface* seahorse_viewer_seahorse_view_parent_iface = NULL;
 
88
static void seahorse_viewer_dispose (GObject * obj);
 
89
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
90
 
 
91
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", "gnome-stock-about", N_ ("_About"), NULL, N_ ("About this program"), ((GCallback) (NULL))}, {"help-show", GTK_STOCK_HELP, N_ ("_Contents"), "F1", N_ ("Show Seahorse help"), ((GCallback) (NULL))}};
 
92
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))}};
 
93
 
 
94
 
 
95
static void _seahorse_viewer_on_app_preferences_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
96
        seahorse_viewer_on_app_preferences (self, _sender);
 
97
}
 
98
 
 
99
 
 
100
static void _seahorse_viewer_on_app_about_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
101
        seahorse_viewer_on_app_about (self, _sender);
 
102
}
 
103
 
 
104
 
 
105
static void _seahorse_viewer_on_help_show_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
106
        seahorse_viewer_on_help_show (self, _sender);
 
107
}
 
108
 
 
109
 
 
110
static void _seahorse_viewer_on_key_properties_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
111
        seahorse_viewer_on_key_properties (self, _sender);
 
112
}
 
113
 
 
114
 
 
115
static void _seahorse_viewer_on_key_export_file_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
116
        seahorse_viewer_on_key_export_file (self, _sender);
 
117
}
 
118
 
 
119
 
 
120
static void _seahorse_viewer_on_key_export_clipboard_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
121
        seahorse_viewer_on_key_export_clipboard (self, _sender);
 
122
}
 
123
 
 
124
 
 
125
static void _seahorse_viewer_on_key_delete_gtk_action_activate (GtkAction* _sender, gpointer self) {
 
126
        seahorse_viewer_on_key_delete (self, _sender);
 
127
}
 
128
 
 
129
 
 
130
static void seahorse_viewer_include_basic_actions (SeahorseViewer* self) {
 
131
        GtkActionGroup* actions;
 
132
        GtkActionGroup* _tmp0;
 
133
        gboolean _tmp1;
 
134
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
135
        /*
 
136
         * We hook callbacks up here for now because of a compiler warning. See:
 
137
         * http://bugzilla.gnome.org/show_bug.cgi?id=539483
 
138
         */
 
139
        actions = gtk_action_group_new ("main");
 
140
        gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
 
141
        gtk_action_group_add_actions (actions, SEAHORSE_VIEWER_UI_ENTRIES, G_N_ELEMENTS (SEAHORSE_VIEWER_UI_ENTRIES), self);
 
142
        g_signal_connect_object (gtk_action_group_get_action (actions, "app-preferences"), "activate", ((GCallback) (_seahorse_viewer_on_app_preferences_gtk_action_activate)), self, 0);
 
143
        g_signal_connect_object (gtk_action_group_get_action (actions, "app-about"), "activate", ((GCallback) (_seahorse_viewer_on_app_about_gtk_action_activate)), self, 0);
 
144
        g_signal_connect_object (gtk_action_group_get_action (actions, "help-show"), "activate", ((GCallback) (_seahorse_viewer_on_help_show_gtk_action_activate)), self, 0);
 
145
        seahorse_viewer_include_actions (self, actions);
 
146
        _tmp0 = NULL;
 
147
        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);
 
148
        gtk_action_group_set_translation_domain (self->priv->_object_actions, GETTEXT_PACKAGE);
 
149
        gtk_action_group_add_actions (self->priv->_object_actions, SEAHORSE_VIEWER_KEY_ENTRIES, G_N_ELEMENTS (SEAHORSE_VIEWER_KEY_ENTRIES), self);
 
150
        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);
 
151
        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);
 
152
        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);
 
153
        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);
 
154
        /* Mark the properties toolbar button as important */
 
155
        g_object_set (gtk_action_group_get_action (self->priv->_object_actions, "key-properties"), "is-important", TRUE, NULL);
 
156
        seahorse_viewer_include_actions (self, self->priv->_object_actions);
 
157
        (actions == NULL ? NULL : (actions = (g_object_unref (actions), NULL)));
 
158
}
 
159
 
 
160
 
 
161
void seahorse_viewer_ensure_updated (SeahorseViewer* self) {
 
162
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
163
        gtk_ui_manager_ensure_update (self->priv->_ui_manager);
 
164
}
 
165
 
 
166
 
 
167
void seahorse_viewer_include_actions (SeahorseViewer* self, GtkActionGroup* actions) {
 
168
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
169
        g_return_if_fail (GTK_IS_ACTION_GROUP (actions));
 
170
        gtk_ui_manager_insert_action_group (self->priv->_ui_manager, actions, -1);
 
171
}
 
172
 
 
173
 
 
174
static GList* seahorse_viewer_real_get_selected_objects (SeahorseViewer* self) {
 
175
        g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
 
176
        return NULL;
 
177
}
 
178
 
 
179
 
 
180
GList* seahorse_viewer_get_selected_objects (SeahorseViewer* self) {
 
181
        return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_objects (self);
 
182
}
 
183
 
 
184
 
 
185
static void seahorse_viewer_real_set_selected_objects (SeahorseViewer* self, GList* objects) {
 
186
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
187
        g_return_if_fail (objects != NULL);
 
188
}
 
189
 
 
190
 
 
191
void seahorse_viewer_set_selected_objects (SeahorseViewer* self, GList* objects) {
 
192
        SEAHORSE_VIEWER_GET_CLASS (self)->set_selected_objects (self, objects);
 
193
}
 
194
 
 
195
 
 
196
static SeahorseObject* seahorse_viewer_real_get_selected_object_and_uid (SeahorseViewer* self, guint* uid) {
 
197
        g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
 
198
        /* Must be overridden */
 
199
        return NULL;
 
200
}
 
201
 
 
202
 
 
203
SeahorseObject* seahorse_viewer_get_selected_object_and_uid (SeahorseViewer* self, guint* uid) {
 
204
        return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_object_and_uid (self, uid);
 
205
}
 
206
 
 
207
 
 
208
static void seahorse_viewer_on_ui_add_widget (SeahorseViewer* self, GtkUIManager* ui, GtkWidget* widget) {
 
209
        char* name;
 
210
        GtkWidget* _tmp2;
 
211
        GtkWidget* holder;
 
212
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
213
        g_return_if_fail (GTK_IS_UI_MANAGER (ui));
 
214
        g_return_if_fail (GTK_IS_WIDGET (widget));
 
215
        name = NULL;
 
216
        if (G_TYPE_FROM_INSTANCE (G_OBJECT (widget)) == GTK_TYPE_MENU_BAR) {
 
217
                char* _tmp0;
 
218
                _tmp0 = NULL;
 
219
                name = (_tmp0 = g_strdup ("menu-placeholder"), (name = (g_free (name), NULL)), _tmp0);
 
220
        } else {
 
221
                if (G_TYPE_FROM_INSTANCE (G_OBJECT (widget)) == GTK_TYPE_TOOLBAR) {
 
222
                        char* _tmp1;
 
223
                        _tmp1 = NULL;
 
224
                        name = (_tmp1 = g_strdup ("toolbar-placeholder"), (name = (g_free (name), NULL)), _tmp1);
 
225
                } else {
 
226
                        name = (g_free (name), NULL);
 
227
                        return;
 
228
                }
 
229
        }
 
230
        _tmp2 = NULL;
 
231
        holder = (_tmp2 = seahorse_widget_get_widget (SEAHORSE_WIDGET (self), name), (_tmp2 == NULL ? NULL : g_object_ref (_tmp2)));
 
232
        if (holder != NULL) {
 
233
                gtk_container_add ((GTK_CONTAINER (holder)), widget);
 
234
        } else {
 
235
                g_warning ("seahorse-viewer.vala:187: no place holder found for: %s", name);
 
236
        }
 
237
        name = (g_free (name), NULL);
 
238
        (holder == NULL ? NULL : (holder = (g_object_unref (holder), NULL)));
 
239
}
 
240
 
 
241
 
 
242
static void seahorse_viewer_on_app_preferences (SeahorseViewer* self, GtkAction* action) {
 
243
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
244
        g_return_if_fail (GTK_IS_ACTION (action));
 
245
        seahorse_preferences_show (seahorse_view_get_window (SEAHORSE_VIEW (self)), NULL);
 
246
}
 
247
 
 
248
 
 
249
static void _seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func (GtkAboutDialog* about, const char* link_, gpointer self) {
 
250
        seahorse_viewer_on_about_link_clicked (about, link_);
 
251
}
 
252
 
 
253
 
 
254
static void seahorse_viewer_on_app_about (SeahorseViewer* self, GtkAction* action) {
 
255
        char** _tmp2;
 
256
        gint authors_length1;
 
257
        char** _tmp1;
 
258
        const char* _tmp0;
 
259
        char** authors;
 
260
        char** _tmp4;
 
261
        gint documenters_length1;
 
262
        char** _tmp3;
 
263
        char** documenters;
 
264
        char** _tmp6;
 
265
        gint artists_length1;
 
266
        char** _tmp5;
 
267
        char** artists;
 
268
        GtkAboutDialog* about;
 
269
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
270
        g_return_if_fail (GTK_IS_ACTION (action));
 
271
        _tmp2 = NULL;
 
272
        _tmp1 = NULL;
 
273
        _tmp0 = NULL;
 
274
        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);
 
275
        _tmp4 = NULL;
 
276
        _tmp3 = NULL;
 
277
        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);
 
278
        _tmp6 = NULL;
 
279
        _tmp5 = NULL;
 
280
        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);
 
281
        if (!seahorse_viewer__about_initialized) {
 
282
                seahorse_viewer__about_initialized = TRUE;
 
283
                gtk_about_dialog_set_url_hook (_seahorse_viewer_on_about_link_clicked_gtk_about_dialog_activate_link_func, NULL, NULL);
 
284
        }
 
285
        about = g_object_ref_sink (((GtkAboutDialog*) (gtk_about_dialog_new ())));
 
286
        gtk_about_dialog_set_artists (about, artists);
 
287
        gtk_about_dialog_set_authors (about, authors);
 
288
        gtk_about_dialog_set_documenters (about, documenters);
 
289
        gtk_about_dialog_set_version (about, VERSION);
 
290
        gtk_about_dialog_set_comments (about, _ ("Encryption Key Manager"));
 
291
        gtk_about_dialog_set_copyright (about, "Copyright \xc2\xa9 2002 - 2008 Seahorse Project");
 
292
        gtk_about_dialog_set_translator_credits (about, _ ("translator-credits"));
 
293
        gtk_about_dialog_set_logo_icon_name (about, "seahorse");
 
294
        gtk_about_dialog_set_website (about, "http://www.gnome.org/projects/seahorse");
 
295
        gtk_about_dialog_set_website_label (about, _ ("Seahorse Project Homepage"));
 
296
        gtk_dialog_run (GTK_DIALOG (about));
 
297
        authors = (_vala_array_free (authors, authors_length1, ((GDestroyNotify) (g_free))), NULL);
 
298
        documenters = (_vala_array_free (documenters, documenters_length1, ((GDestroyNotify) (g_free))), NULL);
 
299
        artists = (_vala_array_free (artists, artists_length1, ((GDestroyNotify) (g_free))), NULL);
 
300
        (about == NULL ? NULL : (about = (g_object_unref (about), NULL)));
 
301
}
 
302
 
 
303
 
 
304
static void seahorse_viewer_on_about_link_clicked (GtkAboutDialog* about, const char* url) {
 
305
        GError * inner_error;
 
306
        g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
 
307
        g_return_if_fail (url != NULL);
 
308
        inner_error = NULL;
 
309
        {
 
310
                GAppLaunchContext* _tmp0;
 
311
                _tmp0 = NULL;
 
312
                g_app_info_launch_default_for_uri (url, (_tmp0 = g_app_launch_context_new ()), &inner_error);
 
313
                if (inner_error != NULL) {
 
314
                        goto __catch0_g_error;
 
315
                }
 
316
                (_tmp0 == NULL ? NULL : (_tmp0 = (g_object_unref (_tmp0), NULL)));
 
317
        }
 
318
        goto __finally0;
 
319
        __catch0_g_error:
 
320
        {
 
321
                GError * ex;
 
322
                ex = inner_error;
 
323
                inner_error = NULL;
 
324
                {
 
325
                        g_warning ("seahorse-viewer.vala:243: couldn't launch url: %s: %s", url, ex->message);
 
326
                        (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
 
327
                }
 
328
        }
 
329
        __finally0:
 
330
        ;
 
331
}
 
332
 
 
333
 
 
334
static void seahorse_viewer_on_help_show (SeahorseViewer* self, GtkAction* action) {
 
335
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
336
        g_return_if_fail (GTK_IS_ACTION (action));
 
337
        seahorse_widget_show_help (SEAHORSE_WIDGET (self));
 
338
}
 
339
 
 
340
 
 
341
void seahorse_viewer_show_context_menu (SeahorseViewer* self, guint button, guint time) {
 
342
        GtkMenu* _tmp0;
 
343
        GtkMenu* menu;
 
344
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
345
        _tmp0 = NULL;
 
346
        menu = (_tmp0 = GTK_MENU (gtk_ui_manager_get_widget (self->priv->_ui_manager, "/KeyPopup")), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
 
347
        g_return_if_fail (menu != NULL && G_TYPE_FROM_INSTANCE (G_OBJECT (menu)) == GTK_TYPE_MENU);
 
348
        gtk_menu_popup (menu, NULL, NULL, NULL, NULL, button, time);
 
349
        gtk_widget_show (GTK_WIDGET (menu));
 
350
        (menu == NULL ? NULL : (menu = (g_object_unref (menu), NULL)));
 
351
}
 
352
 
 
353
 
 
354
void seahorse_viewer_show_properties (SeahorseViewer* self, SeahorseObject* obj) {
 
355
        SeahorseCommands* _tmp0;
 
356
        SeahorseCommands* commands;
 
357
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
358
        g_return_if_fail (SEAHORSE_IS_OBJECT (obj));
 
359
        _tmp0 = NULL;
 
360
        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)));
 
361
        if (commands != NULL) {
 
362
                seahorse_commands_show_properties (commands, obj);
 
363
        }
 
364
        (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
 
365
}
 
366
 
 
367
 
 
368
static void seahorse_viewer_on_key_properties (SeahorseViewer* self, GtkAction* action) {
 
369
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
370
        g_return_if_fail (GTK_IS_ACTION (action));
 
371
        if (seahorse_viewer_get_selected (self) != NULL) {
 
372
                seahorse_viewer_show_properties (self, seahorse_viewer_get_selected (self));
 
373
        }
 
374
}
 
375
 
 
376
 
 
377
static gint seahorse_viewer_compare_by_tag (SeahorseViewer* self, SeahorseObject* one, SeahorseObject* two) {
 
378
        GQuark kone;
 
379
        GQuark ktwo;
 
380
        g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), 0);
 
381
        g_return_val_if_fail (SEAHORSE_IS_OBJECT (one), 0);
 
382
        g_return_val_if_fail (SEAHORSE_IS_OBJECT (two), 0);
 
383
        kone = seahorse_object_get_tag (one);
 
384
        ktwo = seahorse_object_get_tag (two);
 
385
        if (kone < ktwo) {
 
386
                return -1;
 
387
        }
 
388
        if (kone > ktwo) {
 
389
                return 1;
 
390
        }
 
391
        return 0;
 
392
}
 
393
 
 
394
 
 
395
static void seahorse_viewer_delete_object_batch (SeahorseViewer* self, GList* objects) {
 
396
        GError * inner_error;
 
397
        SeahorseCommands* _tmp0;
 
398
        SeahorseCommands* commands;
 
399
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
400
        g_return_if_fail (objects != NULL);
 
401
        inner_error = NULL;
 
402
        g_assert (objects != NULL);
 
403
        _tmp0 = NULL;
 
404
        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)));
 
405
        {
 
406
                if (commands != NULL) {
 
407
                        seahorse_commands_delete_objects (commands, objects, &inner_error);
 
408
                        if (inner_error != NULL) {
 
409
                                goto __catch1_g_error;
 
410
                        }
 
411
                }
 
412
        }
 
413
        goto __finally1;
 
414
        __catch1_g_error:
 
415
        {
 
416
                GError * ex;
 
417
                ex = inner_error;
 
418
                inner_error = NULL;
 
419
                {
 
420
                        seahorse_util_handle_error (ex, _ ("Couldn't delete."), seahorse_view_get_window (SEAHORSE_VIEW (self)), NULL);
 
421
                        (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
 
422
                }
 
423
        }
 
424
        __finally1:
 
425
        ;
 
426
        (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
 
427
}
 
428
 
 
429
 
 
430
static void seahorse_viewer_on_key_delete (SeahorseViewer* self, GtkAction* action) {
 
431
        GList* objects;
 
432
        GList* batch;
 
433
        GList* _tmp0;
 
434
        guint num;
 
435
        GQuark ktype;
 
436
        GList* _tmp4;
 
437
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
438
        g_return_if_fail (GTK_IS_ACTION (action));
 
439
        objects = NULL;
 
440
        batch = NULL;
 
441
        /* Get the selected objects and sort them by ktype */
 
442
        _tmp0 = NULL;
 
443
        objects = (_tmp0 = seahorse_viewer_get_selected_objects (self), (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL))), _tmp0);
 
444
        objects = g_list_sort (objects, ((GCompareFunc) (seahorse_viewer_compare_by_tag)));
 
445
        num = g_list_length (objects);
 
446
        if (num == 0) {
 
447
                (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
448
                (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL)));
 
449
                return;
 
450
        }
 
451
        /* Check for private objects */
 
452
        {
 
453
                GList* object_collection;
 
454
                GList* object_it;
 
455
                object_collection = objects;
 
456
                for (object_it = object_collection; object_it != NULL; object_it = object_it->next) {
 
457
                        SeahorseObject* object;
 
458
                        object = ((SeahorseObject*) (object_it->data));
 
459
                        {
 
460
                                if (seahorse_object_get_usage (object) == SEAHORSE_USAGE_PRIVATE_KEY) {
 
461
                                        char* prompt;
 
462
                                        prompt = NULL;
 
463
                                        if (num == 1) {
 
464
                                                char* _tmp1;
 
465
                                                _tmp1 = NULL;
 
466
                                                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);
 
467
                                        } else {
 
468
                                                char* _tmp3;
 
469
                                                const char* _tmp2;
 
470
                                                _tmp3 = NULL;
 
471
                                                _tmp2 = NULL;
 
472
                                                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);
 
473
                                        }
 
474
                                        if (!seahorse_util_prompt_delete (prompt)) {
 
475
                                                prompt = (g_free (prompt), NULL);
 
476
                                                (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
477
                                                (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL)));
 
478
                                                return;
 
479
                                        }
 
480
                                        prompt = (g_free (prompt), NULL);
 
481
                                }
 
482
                        }
 
483
                }
 
484
        }
 
485
        ktype = ((GQuark) (0));
 
486
        _tmp4 = NULL;
 
487
        batch = (_tmp4 = NULL, (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL))), _tmp4);
 
488
        {
 
489
                GList* object_collection;
 
490
                GList* object_it;
 
491
                object_collection = objects;
 
492
                for (object_it = object_collection; object_it != NULL; object_it = object_it->next) {
 
493
                        SeahorseObject* _tmp6;
 
494
                        SeahorseObject* object;
 
495
                        _tmp6 = NULL;
 
496
                        object = (_tmp6 = ((SeahorseObject*) (object_it->data)), (_tmp6 == NULL ? NULL : g_object_ref (_tmp6)));
 
497
                        {
 
498
                                /* Process that batch */
 
499
                                if (ktype != seahorse_object_get_tag (object) && batch != NULL) {
 
500
                                        GList* _tmp5;
 
501
                                        seahorse_viewer_delete_object_batch (self, batch);
 
502
                                        _tmp5 = NULL;
 
503
                                        batch = (_tmp5 = NULL, (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL))), _tmp5);
 
504
                                }
 
505
                                /* Add to the batch */
 
506
                                batch = g_list_prepend (batch, object);
 
507
                                (object == NULL ? NULL : (object = (g_object_unref (object), NULL)));
 
508
                        }
 
509
                }
 
510
        }
 
511
        /* Process last batch */
 
512
        if (batch != NULL) {
 
513
                seahorse_viewer_delete_object_batch (self, batch);
 
514
        }
 
515
        (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
516
        (batch == NULL ? NULL : (batch = (g_list_free (batch), NULL)));
 
517
}
 
518
 
 
519
 
 
520
static void seahorse_viewer_on_copy_complete (SeahorseViewer* self, SeahorseOperation* op) {
 
521
        GObject* _tmp0;
 
522
        GObject* result;
 
523
        GMemoryOutputStream* _tmp1;
 
524
        GMemoryOutputStream* output;
 
525
        const char* text;
 
526
        guint size;
 
527
        GdkAtom atom;
 
528
        GtkClipboard* _tmp2;
 
529
        GtkClipboard* board;
 
530
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
531
        g_return_if_fail (SEAHORSE_IS_OPERATION (op));
 
532
        if (!seahorse_operation_is_successful (op)) {
 
533
                seahorse_operation_display_error (op, _ ("Couldn't retrieve data from key server"), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
 
534
                return;
 
535
        }
 
536
        _tmp0 = NULL;
 
537
        result = (_tmp0 = G_OBJECT (seahorse_operation_get_result (op)), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
 
538
        g_return_if_fail (result != NULL && G_TYPE_FROM_INSTANCE (result) != G_TYPE_MEMORY_OUTPUT_STREAM);
 
539
        _tmp1 = NULL;
 
540
        output = (_tmp1 = G_MEMORY_OUTPUT_STREAM (result), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
 
541
        text = ((const char*) (g_memory_output_stream_get_data (output)));
 
542
        g_return_if_fail (text != NULL);
 
543
        size = seahorse_util_memory_output_length (output);
 
544
        g_return_if_fail (size >= 0);
 
545
        atom = gdk_atom_intern ("CLIPBOARD", FALSE);
 
546
        _tmp2 = NULL;
 
547
        board = (_tmp2 = gtk_clipboard_get (atom), (_tmp2 == NULL ? NULL : g_object_ref (_tmp2)));
 
548
        gtk_clipboard_set_text (board, text, ((gint) (size)));
 
549
        seahorse_viewer_set_status (self, _ ("Copied keys"));
 
550
        (result == NULL ? NULL : (result = (g_object_unref (result), NULL)));
 
551
        (output == NULL ? NULL : (output = (g_object_unref (output), NULL)));
 
552
        (board == NULL ? NULL : (board = (g_object_unref (board), NULL)));
 
553
}
 
554
 
 
555
 
 
556
static void* _g_realloc_grealloc_func (void* data, gulong size) {
 
557
        return g_realloc (data, size);
 
558
}
 
559
 
 
560
 
 
561
static void _g_free_gdestroy_notify (void* data) {
 
562
        g_free (data);
 
563
}
 
564
 
 
565
 
 
566
static void _seahorse_viewer_on_copy_complete_seahorse_done_func (SeahorseOperation* op, gpointer self) {
 
567
        seahorse_viewer_on_copy_complete (self, op);
 
568
}
 
569
 
 
570
 
 
571
static void seahorse_viewer_on_key_export_clipboard (SeahorseViewer* self, GtkAction* action) {
 
572
        GList* objects;
 
573
        GOutputStream* output;
 
574
        SeahorseOperation* op;
 
575
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
576
        g_return_if_fail (GTK_IS_ACTION (action));
 
577
        objects = seahorse_viewer_get_selected_objects (self);
 
578
        if (objects == NULL) {
 
579
                (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
580
                return;
 
581
        }
 
582
        output = G_OUTPUT_STREAM (((GMemoryOutputStream*) (g_memory_output_stream_new (NULL, ((gulong) (0)), _g_realloc_grealloc_func, _g_free_gdestroy_notify))));
 
583
        op = seahorse_source_export_objects (objects, output);
 
584
        seahorse_progress_show (op, _ ("Retrieving keys"), TRUE);
 
585
        seahorse_operation_watch (op, _seahorse_viewer_on_copy_complete_seahorse_done_func, self, NULL, NULL);
 
586
        (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
587
        (output == NULL ? NULL : (output = (g_object_unref (output), NULL)));
 
588
        (op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
 
589
}
 
590
 
 
591
 
 
592
static void seahorse_viewer_on_export_done (SeahorseViewer* self, SeahorseOperation* op) {
 
593
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
594
        g_return_if_fail (SEAHORSE_IS_OPERATION (op));
 
595
        if (!seahorse_operation_is_successful (op)) {
 
596
                seahorse_operation_display_error (op, _ ("Couldn't export keys"), GTK_WIDGET (seahorse_view_get_window (SEAHORSE_VIEW (self))));
 
597
        }
 
598
}
 
599
 
 
600
 
 
601
static void _seahorse_viewer_on_export_done_seahorse_done_func (SeahorseOperation* op, gpointer self) {
 
602
        seahorse_viewer_on_export_done (self, op);
 
603
}
 
604
 
 
605
 
 
606
static void seahorse_viewer_on_key_export_file (SeahorseViewer* self, GtkAction* action) {
 
607
        GError * inner_error;
 
608
        GList* objects;
 
609
        GtkDialog* _tmp0;
 
610
        GtkDialog* dialog;
 
611
        char* uri;
 
612
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
613
        g_return_if_fail (GTK_IS_ACTION (action));
 
614
        inner_error = NULL;
 
615
        objects = seahorse_viewer_get_selected_objects (self);
 
616
        if (objects == NULL) {
 
617
                (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
618
                return;
 
619
        }
 
620
        _tmp0 = NULL;
 
621
        dialog = (_tmp0 = seahorse_util_chooser_save_new (_ ("Export public key"), seahorse_view_get_window (SEAHORSE_VIEW (self))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
 
622
        seahorse_util_chooser_show_key_files (dialog);
 
623
        seahorse_util_chooser_set_filename (dialog, objects);
 
624
        uri = seahorse_util_chooser_save_prompt (dialog);
 
625
        if (uri != NULL) {
 
626
                {
 
627
                        GFile* file;
 
628
                        GOutputStream* output;
 
629
                        SeahorseOperation* op;
 
630
                        file = g_file_new_for_uri (uri);
 
631
                        output = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, 0, NULL, &inner_error));
 
632
                        if (inner_error != NULL) {
 
633
                                goto __catch2_g_error;
 
634
                        }
 
635
                        op = seahorse_source_export_objects (objects, output);
 
636
                        seahorse_progress_show (op, _ ("Exporting keys"), TRUE);
 
637
                        seahorse_operation_watch (op, _seahorse_viewer_on_export_done_seahorse_done_func, self, NULL, NULL);
 
638
                        (file == NULL ? NULL : (file = (g_object_unref (file), NULL)));
 
639
                        (output == NULL ? NULL : (output = (g_object_unref (output), NULL)));
 
640
                        (op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
 
641
                }
 
642
                goto __finally2;
 
643
                __catch2_g_error:
 
644
                {
 
645
                        GError * ex;
 
646
                        ex = inner_error;
 
647
                        inner_error = NULL;
 
648
                        {
 
649
                                char* _tmp1;
 
650
                                _tmp1 = NULL;
 
651
                                seahorse_util_handle_error (ex, _ ("Couldn't export key to \"%s\""), (_tmp1 = seahorse_util_uri_get_last (uri)), NULL);
 
652
                                _tmp1 = (g_free (_tmp1), NULL);
 
653
                                (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
 
654
                                (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
655
                                (dialog == NULL ? NULL : (dialog = (g_object_unref (dialog), NULL)));
 
656
                                uri = (g_free (uri), NULL);
 
657
                                return;
 
658
                        }
 
659
                }
 
660
                __finally2:
 
661
                ;
 
662
        }
 
663
        (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
664
        (dialog == NULL ? NULL : (dialog = (g_object_unref (dialog), NULL)));
 
665
        uri = (g_free (uri), NULL);
 
666
}
 
667
 
 
668
 
 
669
static void seahorse_viewer_on_selection_changed (SeahorseViewer* self, SeahorseView* view) {
 
670
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
671
        g_return_if_fail (SEAHORSE_IS_VIEW (view));
 
672
        gtk_action_group_set_sensitive (self->priv->_object_actions, seahorse_view_get_selected (view) != NULL);
 
673
}
 
674
 
 
675
 
 
676
void seahorse_viewer_set_status (SeahorseViewer* self, const char* text) {
 
677
        GtkWidget* _tmp0;
 
678
        GtkWidget* widget;
 
679
        GtkStatusbar* _tmp1;
 
680
        GtkStatusbar* status;
 
681
        guint id;
 
682
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
683
        g_return_if_fail (text != NULL);
 
684
        _tmp0 = NULL;
 
685
        widget = (_tmp0 = seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "status"), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
 
686
        g_return_if_fail (widget != NULL || G_TYPE_FROM_INSTANCE (G_OBJECT (widget)) != GTK_TYPE_STATUSBAR);
 
687
        _tmp1 = NULL;
 
688
        status = (_tmp1 = GTK_STATUSBAR (widget), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
 
689
        id = gtk_statusbar_get_context_id (status, "key-manager");
 
690
        gtk_statusbar_pop (status, id);
 
691
        gtk_statusbar_push (status, id, text);
 
692
        (widget == NULL ? NULL : (widget = (g_object_unref (widget), NULL)));
 
693
        (status == NULL ? NULL : (status = (g_object_unref (status), NULL)));
 
694
}
 
695
 
 
696
 
 
697
void seahorse_viewer_set_numbered_status (SeahorseViewer* self, const char* text, gint num) {
 
698
        char* message;
 
699
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
700
        g_return_if_fail (text != NULL);
 
701
        message = g_strdup_printf (text, num);
 
702
        seahorse_viewer_set_status (self, message);
 
703
        message = (g_free (message), NULL);
 
704
}
 
705
 
 
706
 
 
707
SeahorseObject* seahorse_viewer_get_selected (SeahorseViewer* self) {
 
708
        SeahorseObject* value;
 
709
        g_object_get (G_OBJECT (self), "selected", &value, NULL);
 
710
        if (value != NULL) {
 
711
                g_object_unref (value);
 
712
        }
 
713
        return value;
 
714
}
 
715
 
 
716
 
 
717
static SeahorseObject* seahorse_viewer_real_get_selected (SeahorseViewer* self) {
 
718
        g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
 
719
        /* Must be overridden */
 
720
        return NULL;
 
721
}
 
722
 
 
723
 
 
724
void seahorse_viewer_set_selected (SeahorseViewer* self, SeahorseObject* value) {
 
725
        g_object_set (G_OBJECT (self), "selected", value, NULL);
 
726
}
 
727
 
 
728
 
 
729
static void seahorse_viewer_real_set_selected (SeahorseViewer* self, SeahorseObject* value) {
 
730
        GList* objects;
 
731
        g_return_if_fail (SEAHORSE_IS_VIEWER (self));
 
732
        objects = NULL;
 
733
        objects = g_list_prepend (objects, value);
 
734
        seahorse_viewer_set_selected_objects (self, objects);
 
735
        (objects == NULL ? NULL : (objects = (g_list_free (objects), NULL)));
 
736
        g_object_notify (((GObject *) (self)), "selected");
 
737
}
 
738
 
 
739
 
 
740
SeahorseSet* seahorse_viewer_get_current_set (SeahorseViewer* self) {
 
741
        SeahorseSet* value;
 
742
        g_object_get (G_OBJECT (self), "current-set", &value, NULL);
 
743
        if (value != NULL) {
 
744
                g_object_unref (value);
 
745
        }
 
746
        return value;
 
747
}
 
748
 
 
749
 
 
750
static SeahorseSet* seahorse_viewer_real_get_current_set (SeahorseViewer* self) {
 
751
        g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
 
752
        /* Must be overridden */
 
753
        return NULL;
 
754
}
 
755
 
 
756
 
 
757
static GtkWindow* seahorse_viewer_real_get_window (SeahorseViewer* self) {
 
758
        g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
 
759
        return GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)));
 
760
}
 
761
 
 
762
 
 
763
static void _seahorse_viewer_on_ui_add_widget_gtk_ui_manager_add_widget (GtkUIManager* _sender, GtkWidget* widget, gpointer self) {
 
764
        seahorse_viewer_on_ui_add_widget (self, _sender, widget);
 
765
}
 
766
 
 
767
 
 
768
static void _seahorse_viewer_on_selection_changed_seahorse_view_selection_changed (SeahorseViewer* _sender, gpointer self) {
 
769
        seahorse_viewer_on_selection_changed (self, _sender);
 
770
}
 
771
 
 
772
 
 
773
static GObject * seahorse_viewer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
 
774
        GObject * obj;
 
775
        SeahorseViewerClass * klass;
 
776
        GObjectClass * parent_class;
 
777
        SeahorseViewer * self;
 
778
        GError * inner_error;
 
779
        klass = SEAHORSE_VIEWER_CLASS (g_type_class_peek (SEAHORSE_TYPE_VIEWER));
 
780
        parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
 
781
        obj = parent_class->constructor (type, n_construct_properties, construct_properties);
 
782
        self = SEAHORSE_VIEWER (obj);
 
783
        inner_error = NULL;
 
784
        {
 
785
                GtkUIManager* _tmp0;
 
786
                GtkWidget* _tmp1;
 
787
                GtkWidget* win;
 
788
                GHashTable* _tmp2;
 
789
                GList* types;
 
790
                _tmp0 = NULL;
 
791
                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);
 
792
                /* The widgts get added in an idle loop later */
 
793
                g_signal_connect_object (self->priv->_ui_manager, "add-widget", ((GCallback) (_seahorse_viewer_on_ui_add_widget_gtk_ui_manager_add_widget)), self, 0);
 
794
                {
 
795
                        char* path;
 
796
                        path = g_strdup_printf ("%sseahorse-%s.ui", SEAHORSE_GLADEDIR, seahorse_widget_get_name (SEAHORSE_WIDGET (self)));
 
797
                        gtk_ui_manager_add_ui_from_file (self->priv->_ui_manager, path, &inner_error);
 
798
                        if (inner_error != NULL) {
 
799
                                goto __catch3_g_error;
 
800
                        }
 
801
                        path = (g_free (path), NULL);
 
802
                }
 
803
                goto __finally3;
 
804
                __catch3_g_error:
 
805
                {
 
806
                        GError * ex;
 
807
                        ex = inner_error;
 
808
                        inner_error = NULL;
 
809
                        {
 
810
                                g_warning ("seahorse-viewer.vala:70: couldn't load ui description for '%s': %s", seahorse_widget_get_name (SEAHORSE_WIDGET (self)), ex->message);
 
811
                                (ex == NULL ? NULL : (ex = (g_error_free (ex), NULL)));
 
812
                        }
 
813
                }
 
814
                __finally3:
 
815
                ;
 
816
                _tmp1 = NULL;
 
817
                win = (_tmp1 = seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)), (_tmp1 == NULL ? NULL : g_object_ref (_tmp1)));
 
818
                if (G_TYPE_FROM_INSTANCE (G_OBJECT (win)) == GTK_TYPE_WINDOW) {
 
819
                        gtk_window_add_accel_group ((GTK_WINDOW (win)), gtk_ui_manager_get_accel_group (self->priv->_ui_manager));
 
820
                }
 
821
                seahorse_viewer_include_basic_actions (self);
 
822
                g_signal_connect_object (SEAHORSE_VIEW (self), "selection-changed", ((GCallback) (_seahorse_viewer_on_selection_changed_seahorse_view_selection_changed)), self, 0);
 
823
                /* Setup the commands */
 
824
                _tmp2 = NULL;
 
825
                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);
 
826
                types = seahorse_registry_find_types (seahorse_registry_get (), "commands", NULL, NULL);
 
827
                {
 
828
                        GList* typ_collection;
 
829
                        GList* typ_it;
 
830
                        typ_collection = types;
 
831
                        for (typ_it = typ_collection; typ_it != NULL; typ_it = typ_it->next) {
 
832
                                GType typ;
 
833
                                typ = GPOINTER_TO_INT (typ_it->data);
 
834
                                {
 
835
                                        SeahorseCommands* commands;
 
836
                                        SeahorseCommands* _tmp3;
 
837
                                        GtkActionGroup* _tmp4;
 
838
                                        GtkActionGroup* actions;
 
839
                                        const char* _tmp5;
 
840
                                        char* uidef;
 
841
                                        /* Add each commands to our hash table */
 
842
                                        commands = SEAHORSE_COMMANDS (g_object_new (typ, "view", self, NULL, NULL));
 
843
                                        _tmp3 = NULL;
 
844
                                        g_hash_table_insert (self->priv->_commands, GINT_TO_POINTER (seahorse_commands_get_ktype (commands)), (_tmp3 = commands, (_tmp3 == NULL ? NULL : g_object_ref (_tmp3))));
 
845
                                        /* Add the UI for each commands */
 
846
                                        _tmp4 = NULL;
 
847
                                        actions = (_tmp4 = seahorse_commands_get_command_actions (commands), (_tmp4 == NULL ? NULL : g_object_ref (_tmp4)));
 
848
                                        if (actions != NULL) {
 
849
                                                seahorse_viewer_include_actions (self, actions);
 
850
                                        }
 
851
                                        _tmp5 = NULL;
 
852
                                        uidef = (_tmp5 = seahorse_commands_get_ui_definition (commands), (_tmp5 == NULL ? NULL : g_strdup (_tmp5)));
 
853
                                        if (uidef != NULL && g_utf8_strlen (uidef, -1) > 0) {
 
854
                                                gtk_ui_manager_add_ui_from_string (self->priv->_ui_manager, uidef, ((glong) (-1)), &inner_error);
 
855
                                                if (inner_error != NULL) {
 
856
                                                        g_critical ("file %s: line %d: uncaught error: %s", __FILE__, __LINE__, inner_error->message);
 
857
                                                        g_clear_error (&inner_error);
 
858
                                                }
 
859
                                        }
 
860
                                        (commands == NULL ? NULL : (commands = (g_object_unref (commands), NULL)));
 
861
                                        (actions == NULL ? NULL : (actions = (g_object_unref (actions), NULL)));
 
862
                                        uidef = (g_free (uidef), NULL);
 
863
                                }
 
864
                        }
 
865
                }
 
866
                (win == NULL ? NULL : (win = (g_object_unref (win), NULL)));
 
867
                (types == NULL ? NULL : (types = (g_list_free (types), NULL)));
 
868
        }
 
869
        return obj;
 
870
}
 
871
 
 
872
 
 
873
static void seahorse_viewer_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
 
874
        SeahorseViewer * self;
 
875
        self = SEAHORSE_VIEWER (object);
 
876
        switch (property_id) {
 
877
                case SEAHORSE_VIEWER_SELECTED:
 
878
                g_value_set_object (value, seahorse_viewer_real_get_selected (self));
 
879
                break;
 
880
                case SEAHORSE_VIEWER_CURRENT_SET:
 
881
                g_value_set_object (value, seahorse_viewer_real_get_current_set (self));
 
882
                break;
 
883
                case SEAHORSE_VIEWER_WINDOW:
 
884
                g_value_set_object (value, seahorse_viewer_real_get_window (self));
 
885
                break;
 
886
                default:
 
887
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
888
                break;
 
889
        }
 
890
}
 
891
 
 
892
 
 
893
static void seahorse_viewer_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
 
894
        SeahorseViewer * self;
 
895
        self = SEAHORSE_VIEWER (object);
 
896
        switch (property_id) {
 
897
                case SEAHORSE_VIEWER_SELECTED:
 
898
                seahorse_viewer_real_set_selected (self, g_value_get_object (value));
 
899
                break;
 
900
                default:
 
901
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
902
                break;
 
903
        }
 
904
}
 
905
 
 
906
 
 
907
static void seahorse_viewer_class_init (SeahorseViewerClass * klass) {
 
908
        seahorse_viewer_parent_class = g_type_class_peek_parent (klass);
 
909
        g_type_class_add_private (klass, sizeof (SeahorseViewerPrivate));
 
910
        G_OBJECT_CLASS (klass)->get_property = seahorse_viewer_get_property;
 
911
        G_OBJECT_CLASS (klass)->set_property = seahorse_viewer_set_property;
 
912
        G_OBJECT_CLASS (klass)->constructor = seahorse_viewer_constructor;
 
913
        G_OBJECT_CLASS (klass)->dispose = seahorse_viewer_dispose;
 
914
        SEAHORSE_VIEWER_CLASS (klass)->get_selected_objects = seahorse_viewer_real_get_selected_objects;
 
915
        SEAHORSE_VIEWER_CLASS (klass)->set_selected_objects = seahorse_viewer_real_set_selected_objects;
 
916
        SEAHORSE_VIEWER_CLASS (klass)->get_selected_object_and_uid = seahorse_viewer_real_get_selected_object_and_uid;
 
917
        g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_VIEWER_SELECTED, "selected");
 
918
        g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_VIEWER_CURRENT_SET, "current-set");
 
919
        g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_VIEWER_WINDOW, "window");
 
920
}
 
921
 
 
922
 
 
923
static void seahorse_viewer_seahorse_view_interface_init (SeahorseViewIface * iface) {
 
924
        seahorse_viewer_seahorse_view_parent_iface = g_type_interface_peek_parent (iface);
 
925
        iface->get_selected_objects = seahorse_viewer_get_selected_objects;
 
926
        iface->set_selected_objects = seahorse_viewer_set_selected_objects;
 
927
}
 
928
 
 
929
 
 
930
static void seahorse_viewer_instance_init (SeahorseViewer * self) {
 
931
        self->priv = SEAHORSE_VIEWER_GET_PRIVATE (self);
 
932
}
 
933
 
 
934
 
 
935
static void seahorse_viewer_dispose (GObject * obj) {
 
936
        SeahorseViewer * self;
 
937
        self = SEAHORSE_VIEWER (obj);
 
938
        (self->priv->_ui_manager == NULL ? NULL : (self->priv->_ui_manager = (g_object_unref (self->priv->_ui_manager), NULL)));
 
939
        (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL)));
 
940
        (self->priv->_commands == NULL ? NULL : (self->priv->_commands = (g_hash_table_unref (self->priv->_commands), NULL)));
 
941
        G_OBJECT_CLASS (seahorse_viewer_parent_class)->dispose (obj);
 
942
}
 
943
 
 
944
 
 
945
GType seahorse_viewer_get_type (void) {
 
946
        static GType seahorse_viewer_type_id = 0;
 
947
        if (G_UNLIKELY (seahorse_viewer_type_id == 0)) {
 
948
                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 };
 
949
                static const GInterfaceInfo seahorse_view_info = { (GInterfaceInitFunc) seahorse_viewer_seahorse_view_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
 
950
                seahorse_viewer_type_id = g_type_register_static (SEAHORSE_TYPE_WIDGET, "SeahorseViewer", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
 
951
                g_type_add_interface_static (seahorse_viewer_type_id, SEAHORSE_TYPE_VIEW, &seahorse_view_info);
 
952
        }
 
953
        return seahorse_viewer_type_id;
 
954
}
 
955
 
 
956
 
 
957
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
 
958
        if (array != NULL && destroy_func != NULL) {
 
959
                int i;
 
960
                if (array_length >= 0)
 
961
                for (i = 0; i < array_length; i = i + 1) {
 
962
                        if (((gpointer*) (array))[i] != NULL)
 
963
                        destroy_func (((gpointer*) (array))[i]);
 
964
                }
 
965
                else
 
966
                for (i = 0; ((gpointer*) (array))[i] != NULL; i = i + 1) {
 
967
                        destroy_func (((gpointer*) (array))[i]);
 
968
                }
 
969
        }
 
970
        g_free (array);
 
971
}
 
972
 
 
973
 
 
974
 
 
975