seahorse r2668 - in trunk: . libseahorse src
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2668 - in trunk: . libseahorse src
- Date: Tue, 16 Dec 2008 02:44:00 +0000 (UTC)
Author: nnielsen
Date: Tue Dec 16 02:44:00 2008
New Revision: 2668
URL: http://svn.gnome.org/viewvc/seahorse?rev=2668&view=rev
Log:
* libseahorse/libseahorse.gidl: (removed)
* libseahorse/libseahorse.vapi: (removed)
* libseahorse/libseahorse-c.deps: (removed)
* libseahorse/libseahorse-c.vapi: (removed)
* src/Makefile.am:
* src/seahorse-keyserver-results.c:
* src/seahorse-keyserver-results.h:
* src/seahorse-keyserver-results.vala: (removed)
* acinclude.m4:
* bugs.vapi: (removed)
* config.vapi: (removed)
* configure.in: Change keyserver results to C code.
Remove last vala traces.
Removed:
trunk/bugs.vapi
trunk/config.vapi
trunk/libseahorse/libseahorse-c.deps
trunk/libseahorse/libseahorse-c.vapi
trunk/libseahorse/libseahorse.gidl
trunk/libseahorse/libseahorse.vapi
trunk/src/seahorse-keyserver-results.vala
trunk/src/vala-build.stamp
Modified:
trunk/ChangeLog
trunk/acinclude.m4
trunk/configure.in
trunk/src/Makefile.am
trunk/src/seahorse-keyserver-results.c
trunk/src/seahorse-keyserver-results.h
Modified: trunk/acinclude.m4
==============================================================================
--- trunk/acinclude.m4 (original)
+++ trunk/acinclude.m4 Tue Dec 16 02:44:00 2008
@@ -38,51 +38,3 @@
prefix=$prefix_save
exec_prefix=$exec_prefix_save
])
-
-# vala.m4 serial 1 (vala @VERSION@)
-dnl Autoconf scripts for the Vala compiler
-dnl Copyright (C) 2007 Mathias Hasselmann
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2 of the License, or (at your option) any later version.
-
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl Lesser General Public License for more details.
-
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library; if not, write to the Free Software
-dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-dnl
-dnl Author:
-dnl Mathias Hasselmann <mathias hasselmann gmx de>
-dnl --------------------------------------------------------------------------
-
-dnl VALA_PROG_VALAC([MINIMUM-VERSION])
-dnl
-dnl Check whether the Vala compiler exists in `PATH'. If it is found the
-dnl variable VALAC is set. Optionally a minimum release number of the compiler
-dnl can be requested.
-dnl --------------------------------------------------------------------------
-AC_DEFUN([VALA_PROG_VALAC],[
- AC_PATH_PROG([VALAC], [valac], [])
-
- if test -z "${VALAC}"; then
- AC_MSG_WARN([No Vala compiler found. You will not be able to recompile .vala source files.])
- elif test -n "$1"; then
- AC_REQUIRE([AC_PROG_AWK])
- AC_MSG_CHECKING([valac is at least version $1])
-
- # 7
- if "${VALAC}" --version | "${AWK}" -v r='$1' 'function vn(s) [{ if (3 == split(s,v,".")) return (v[1]*1000+v[2])*1000+v[3]; else exit 2; }] /^Vala / { exit vn(r) > vn([$]2) }'; then
- AC_MSG_RESULT([yes])
- AC_SUBST(VALAC)
- else
- AC_MSG_RESULT([no])
- unset VALAC
- fi
- fi
-])
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Dec 16 02:44:00 2008
@@ -33,9 +33,6 @@
AM_GCONF_SOURCE_2
GNOME_DOC_INIT
-VALA_PROG_VALAC([0.3.5])
-AM_CONDITIONAL(WITH_VALA, test -n "$VALAC")
-
dnl Get the off_t size right
AC_SYS_LARGEFILE
AC_TYPE_OFF_T
@@ -535,9 +532,6 @@
dnl ****************************************************************************
-VALA_PKGS="--pkg glib-2.0 --pkg gio-2.0 --pkg gtk+-2.0 --pkg gconf-2.0"
-AC_SUBST(VALA_PKGS)
-
AC_SUBST(SEAHORSE_CFLAGS)
AC_SUBST(SEAHORSE_LIBS)
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Dec 16 02:44:00 2008
@@ -16,31 +16,9 @@
-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE \
-DGETTEXT_PACKAGE=\""seahorse\""
-VALA_SRCS = \
- seahorse-keyserver-results.vala
-
-VALA_VAPIS = \
- $(top_srcdir)/bugs.vapi \
- $(top_srcdir)/config.vapi \
- $(top_srcdir)/libseahorse/libseahorse-c.vapi \
- $(top_srcdir)/libseahorse/libseahorse.vapi
-
-if WITH_KEYSERVER
-VALA_CFILES = $(VALA_SRCS:.vala=.c)
-VALA_HFILES = $(VALA_SRCS:.vala=.h)
-endif
-
-SUFFIXES = .vala .c .h
-
-vala-build.stamp: $(VALA_SRCS) $(VALA_VAPIS)
- $(VALAC) -C $(VALA_PKGS) $(VALA_VAPIS) $(VALA_SRCS)
- date +'%s' > $@
-
-BUILT_SOURCES = \
- vala-build.stamp
-
if WITH_KEYSERVER
KEYSERVER_SRCS = seahorse-keyserver-search.c seahorse-keyserver-sync.c seahorse-keyserver-sync.h
+KEYSERVER_SRCS += seahorse-keyserver-results.c seahorse-keyserver-results.h
else
KEYSERVER_SRCS =
endif
@@ -73,8 +51,7 @@
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)
+ $(KEYSERVER_SRCS)
seahorse_LDADD = \
$(top_builddir)/libseahorse/libseahorse.la \
@@ -104,15 +81,8 @@
EXTRA_DIST = \
$(glade_DATA) \
- seahorse.desktop.in.in \
- vala-build.stamp \
- $(VALA_CFILES) $(VALA_HFILES) \
- $(VALA_SRCS)
+ seahorse.desktop.in.in
CLEANFILES = *.gladep* *.bak \
$(desktop_DATA) \
seahorse.desktop.in
-
-vala-clean:
- rm -f vala-build.stamp $(VALA_CFILES) $(VALA_HFILES)
-
Modified: trunk/src/seahorse-keyserver-results.c
==============================================================================
--- trunk/src/seahorse-keyserver-results.c (original)
+++ trunk/src/seahorse-keyserver-results.c Tue Dec 16 02:44:00 2008
@@ -19,266 +19,188 @@
* 02111-1307, USA.
*/
+#include "config.h"
+
#include "seahorse-keyserver-results.h"
-#include <seahorse-key-manager-store.h>
-#include <seahorse-set.h>
-#include <glib/gi18n-lib.h>
-#include <seahorse-widget.h>
-#include <seahorse-progress.h>
-#include <gdk/gdk.h>
-#include <seahorse-context.h>
-#include <seahorse-source.h>
-#include <seahorse-windows.h>
-#include <config.h>
-#include <seahorse-types.h>
+#include "seahorse-key-manager-store.h"
+#include "seahorse-windows.h"
+#include "seahorse-operation.h"
+#include "seahorse-progress.h"
+#include <glib/gi18n.h>
+#include <string.h>
-struct _SeahorseKeyserverResultsPrivate {
- char* _search_string;
- GtkTreeView* _view;
- GtkActionGroup* _object_actions;
- SeahorseKeyManagerStore* _store;
- SeahorseSet* _objects;
- SeahorseObjectPredicate _pred;
+enum {
+ PROP_0,
+ PROP_SEARCH,
+ PROP_SELECTED
};
-#define SEAHORSE_KEYSERVER_RESULTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsPrivate))
-enum {
- SEAHORSE_KEYSERVER_RESULTS_DUMMY_PROPERTY,
- SEAHORSE_KEYSERVER_RESULTS_SEARCH,
- SEAHORSE_KEYSERVER_RESULTS_SELECTED
+struct _SeahorseKeyserverResultsPrivate {
+ char *search_string;
+ GtkTreeView *view;
+ GtkActionGroup *object_actions;
+ SeahorseKeyManagerStore *store;
+ SeahorseSet *objects;
+ SeahorseObjectPredicate pred;
};
-static SeahorseKeyserverResults* seahorse_keyserver_results_new (const char* search_text);
-static GList* seahorse_keyserver_results_real_get_selected_objects (SeahorseViewer* base);
-static void seahorse_keyserver_results_real_set_selected_objects (SeahorseViewer* base, GList* keys);
-static gboolean seahorse_keyserver_results_on_filter_objects (SeahorseKeyserverResults* self, SeahorseObject* obj);
-static gboolean _seahorse_keyserver_results_fire_selection_changed_gsource_func (gpointer self);
-static void seahorse_keyserver_results_on_view_selection_changed (SeahorseKeyserverResults* self, GtkTreeSelection* selection);
-static void seahorse_keyserver_results_on_row_activated (SeahorseKeyserverResults* self, GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* column);
-static gboolean seahorse_keyserver_results_on_key_list_button_pressed (SeahorseKeyserverResults* self, GtkTreeView* view, GdkEventButton* event);
-static gboolean seahorse_keyserver_results_on_key_list_popup_menu (SeahorseKeyserverResults* self, GtkTreeView* view);
-static void seahorse_keyserver_results_on_view_expand_all (SeahorseKeyserverResults* self, GtkAction* action);
-static void seahorse_keyserver_results_on_view_collapse_all (SeahorseKeyserverResults* self, GtkAction* action);
-static void seahorse_keyserver_results_on_app_close (SeahorseKeyserverResults* self, GtkAction* action);
-static void seahorse_keyserver_results_imported_keys (SeahorseKeyserverResults* self, SeahorseOperation* op);
-static void _seahorse_keyserver_results_imported_keys_seahorse_done_func (SeahorseOperation* op, gpointer self);
-static void seahorse_keyserver_results_on_key_import_keyring (SeahorseKeyserverResults* self, GtkAction* action);
-static void seahorse_keyserver_results_on_remote_find (SeahorseKeyserverResults* self, GtkAction* action);
-static gboolean seahorse_keyserver_results_on_delete_event (SeahorseKeyserverResults* self, GtkWidget* widget, GdkEvent* event);
-static gboolean seahorse_keyserver_results_fire_selection_changed (SeahorseKeyserverResults* self);
-static void seahorse_keyserver_results_set_search (SeahorseKeyserverResults* self, const char* value);
-static void _seahorse_keyserver_results_on_app_close_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_keyserver_results_on_view_expand_all_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_keyserver_results_on_view_collapse_all_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_keyserver_results_on_remote_find_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_keyserver_results_on_key_import_keyring_gtk_action_activate (GtkAction* _sender, gpointer self);
-static void _seahorse_keyserver_results_on_view_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self);
-static void _seahorse_keyserver_results_on_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
-static gboolean _seahorse_keyserver_results_on_key_list_button_pressed_gtk_widget_button_press_event (GtkTreeView* _sender, GdkEventButton* event, gpointer self);
-static gboolean _seahorse_keyserver_results_on_key_list_popup_menu_gtk_widget_popup_menu (GtkTreeView* _sender, gpointer self);
-static gboolean _seahorse_keyserver_results_on_filter_objects_seahorse_object_predicate_func (SeahorseObject* obj, gpointer self);
-static GObject * seahorse_keyserver_results_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-static gpointer seahorse_keyserver_results_parent_class = NULL;
-static void seahorse_keyserver_results_finalize (GObject * obj);
-
-static const GtkActionEntry SEAHORSE_KEYSERVER_RESULTS_GENERAL_ENTRIES[] = {{"remote-menu", NULL, N_ ("_Remote")}, {"app-close", GTK_STOCK_CLOSE, N_ ("_Close"), "<control>W", N_ ("Close this window"), ((GCallback) (NULL))}, {"view-expand-all", GTK_STOCK_ADD, N_ ("_Expand All"), NULL, N_ ("Expand all listings"), ((GCallback) (NULL))}, {"view-collapse-all", GTK_STOCK_REMOVE, N_ ("_Collapse All"), NULL, N_ ("Collapse all listings"), ((GCallback) (NULL))}};
-static const GtkActionEntry SEAHORSE_KEYSERVER_RESULTS_SERVER_ENTRIES[] = {{"remote-find", GTK_STOCK_FIND, N_ ("_Find Remote Keys..."), "", N_ ("Search for keys on a key server"), ((GCallback) (NULL))}};
-static const GtkActionEntry SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES[] = {{"key-import-keyring", GTK_STOCK_ADD, N_ ("_Import"), "", N_ ("Import selected keys to local key ring"), ((GCallback) (NULL))}};
-
-
-static SeahorseKeyserverResults* seahorse_keyserver_results_new (const char* search_text) {
- GParameter * __params;
- GParameter * __params_it;
- SeahorseKeyserverResults * self;
- g_return_val_if_fail (search_text != NULL, NULL);
- __params = g_new0 (GParameter, 2);
- __params_it = __params;
- __params_it->name = "name";
- g_value_init (&__params_it->value, G_TYPE_STRING);
- g_value_set_string (&__params_it->value, "keyserver-results");
- __params_it++;
- __params_it->name = "search";
- g_value_init (&__params_it->value, G_TYPE_STRING);
- g_value_set_string (&__params_it->value, search_text);
- __params_it++;
- self = g_object_newv (SEAHORSE_TYPE_KEYSERVER_RESULTS, __params_it - __params, __params);
- while (__params_it > __params) {
- --__params_it;
- g_value_unset (&__params_it->value);
- }
- g_free (__params);
- return self;
-}
+G_DEFINE_TYPE (SeahorseKeyserverResults, seahorse_keyserver_results, SEAHORSE_TYPE_VIEWER);
-void seahorse_keyserver_results_show (SeahorseOperation* op, GtkWindow* parent, const char* search_text) {
- SeahorseKeyserverResults* res;
- g_return_if_fail (SEAHORSE_IS_OPERATION (op));
- g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
- g_return_if_fail (search_text != NULL);
- res = g_object_ref_sink (seahorse_keyserver_results_new (search_text));
- g_object_ref (G_OBJECT (res));
- /* Destorys itself with destroy */
- if (parent != NULL) {
- GtkWindow* _tmp0;
- GtkWindow* window;
- _tmp0 = NULL;
- window = (_tmp0 = GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (res))), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- gtk_window_set_transient_for (window, parent);
- (window == NULL ? NULL : (window = (g_object_unref (window), NULL)));
- }
- seahorse_progress_status_set_operation (SEAHORSE_WIDGET (res), op);
- (res == NULL ? NULL : (res = (g_object_unref (res), NULL)));
-}
-
-
-static GList* seahorse_keyserver_results_real_get_selected_objects (SeahorseViewer* base) {
- SeahorseKeyserverResults * self;
- self = SEAHORSE_KEYSERVER_RESULTS (base);
- return seahorse_key_manager_store_get_selected_objects (self->priv->_view);
-}
-
-
-static void seahorse_keyserver_results_real_set_selected_objects (SeahorseViewer* base, GList* keys) {
- SeahorseKeyserverResults * self;
- self = SEAHORSE_KEYSERVER_RESULTS (base);
- g_return_if_fail (keys != NULL);
- seahorse_key_manager_store_set_selected_objects (self->priv->_view, keys);
-}
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
-static gboolean seahorse_keyserver_results_on_filter_objects (SeahorseKeyserverResults* self, SeahorseObject* obj) {
- const char* _tmp1;
+static gboolean
+on_filter_objects (SeahorseObject *obj, SeahorseKeyserverResults *self)
+{
+ gboolean ret;
char* name;
- char* _tmp2;
- gboolean _tmp3;
- gboolean _tmp4;
+
g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), FALSE);
g_return_val_if_fail (SEAHORSE_IS_OBJECT (obj), FALSE);
- if (g_utf8_strlen (self->priv->_search_string, -1) == 0) {
+ if (g_utf8_strlen (self->pv->search_string, -1) == 0)
return TRUE;
- }
- _tmp1 = NULL;
- name = (_tmp1 = seahorse_object_get_label (obj), (_tmp1 == NULL ? NULL : g_strdup (_tmp1)));
- _tmp2 = NULL;
- return (_tmp4 = (_tmp3 = ((name != NULL) && (strstr ((_tmp2 = g_utf8_casefold (name, -1)), self->priv->_search_string) != NULL)), (_tmp2 = (g_free (_tmp2), NULL)), _tmp3), (name = (g_free (name), NULL)), _tmp4);
+
+ name = g_utf8_casefold (seahorse_object_get_label (obj), -1);
+ ret = strstr (name, self->pv->search_string) != NULL;
+ g_free (name);
+ return ret;
}
-static gboolean _seahorse_keyserver_results_fire_selection_changed_gsource_func (gpointer self) {
- return seahorse_keyserver_results_fire_selection_changed (self);
-}
+static gboolean
+fire_selection_changed (SeahorseKeyserverResults* self)
+{
+ gint rows;
+ GtkTreeSelection* selection;
+ g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), FALSE);
+ selection = gtk_tree_view_get_selection (self->pv->view);
+ rows = gtk_tree_selection_count_selected_rows (selection);
+ seahorse_viewer_set_numbered_status (SEAHORSE_VIEWER (self), ngettext ("Selected %d key", "Selected %d keys", rows), rows);
+ gtk_action_group_set_sensitive (self->pv->object_actions, rows > 0);
+ g_signal_emit_by_name (G_OBJECT (SEAHORSE_VIEW (self)), "selection-changed");
+ return FALSE;
+}
-static void seahorse_keyserver_results_on_view_selection_changed (SeahorseKeyserverResults* self, GtkTreeSelection* selection) {
+static void
+on_view_selection_changed (GtkTreeSelection *selection, SeahorseKeyserverResults *self)
+{
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
- g_idle_add (_seahorse_keyserver_results_fire_selection_changed_gsource_func, self);
+ g_idle_add ((GSourceFunc)fire_selection_changed, self);
}
+static void
+on_row_activated (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, SeahorseKeyserverResults *self)
+{
+ SeahorseObject *obj;
-static void seahorse_keyserver_results_on_row_activated (SeahorseKeyserverResults* self, GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* column) {
- SeahorseObject* _tmp0;
- SeahorseObject* obj;
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_TREE_VIEW (view));
g_return_if_fail (path != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (column));
- _tmp0 = NULL;
- obj = (_tmp0 = seahorse_key_manager_store_get_object_from_path (view, path), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- if (obj != NULL) {
+
+ obj = seahorse_key_manager_store_get_object_from_path (view, path);
+ if (obj != NULL)
seahorse_viewer_show_properties (SEAHORSE_VIEWER (self), obj);
- }
- (obj == NULL ? NULL : (obj = (g_object_unref (obj), NULL)));
}
-
-static gboolean seahorse_keyserver_results_on_key_list_button_pressed (SeahorseKeyserverResults* self, GtkTreeView* view, GdkEventButton* event) {
+static gboolean
+on_key_list_button_pressed (GtkTreeView* view, GdkEventButton* event, SeahorseKeyserverResults* self)
+{
g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), FALSE);
g_return_val_if_fail (GTK_IS_TREE_VIEW (view), FALSE);
- if ((*event).button == 3) {
- seahorse_viewer_show_context_menu (SEAHORSE_VIEWER (self), (*event).button, (*event).time);
- }
+ if (event->button == 3)
+ seahorse_viewer_show_context_menu (SEAHORSE_VIEWER (self), event->button, event->time);
return FALSE;
}
-
-static gboolean seahorse_keyserver_results_on_key_list_popup_menu (SeahorseKeyserverResults* self, GtkTreeView* view) {
- SeahorseObject* _tmp0;
+static gboolean
+on_key_list_popup_menu (GtkTreeView* view, SeahorseKeyserverResults* self)
+{
SeahorseObject* key;
- gboolean _tmp2;
+
g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), FALSE);
g_return_val_if_fail (GTK_IS_TREE_VIEW (view), FALSE);
- _tmp0 = NULL;
- key = (_tmp0 = seahorse_viewer_get_selected (SEAHORSE_VIEWER (self)), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- if (key == NULL) {
- gboolean _tmp1;
- return (_tmp1 = FALSE, (key == NULL ? NULL : (key = (g_object_unref (key), NULL))), _tmp1);
- }
- seahorse_viewer_show_context_menu (SEAHORSE_VIEWER (self), ((guint) (0)), gtk_get_current_event_time ());
- return (_tmp2 = TRUE, (key == NULL ? NULL : (key = (g_object_unref (key), NULL))), _tmp2);
-}
+ key = seahorse_viewer_get_selected (SEAHORSE_VIEWER (self));
+ if (key == NULL)
+ return FALSE;
+ seahorse_viewer_show_context_menu (SEAHORSE_VIEWER (self), 0, gtk_get_current_event_time ());
+ return TRUE;
+}
-static void seahorse_keyserver_results_on_view_expand_all (SeahorseKeyserverResults* self, GtkAction* action) {
+static void
+on_view_expand_all (GtkAction* action, SeahorseKeyserverResults* self)
+{
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- gtk_tree_view_expand_all (self->priv->_view);
+ gtk_tree_view_expand_all (self->pv->view);
}
-static void seahorse_keyserver_results_on_view_collapse_all (SeahorseKeyserverResults* self, GtkAction* action) {
+static void
+on_view_collapse_all (GtkAction* action, SeahorseKeyserverResults* self)
+{
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- gtk_tree_view_collapse_all (self->priv->_view);
+ gtk_tree_view_collapse_all (self->pv->view);
}
-
-static void seahorse_keyserver_results_on_app_close (SeahorseKeyserverResults* self, GtkAction* action) {
+static void
+on_app_close (GtkAction* action, SeahorseKeyserverResults* self)
+{
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
seahorse_widget_destroy (SEAHORSE_WIDGET (self));
}
-
-static void seahorse_keyserver_results_imported_keys (SeahorseKeyserverResults* self, SeahorseOperation* op) {
+static void
+imported_keys (SeahorseOperation* op, SeahorseKeyserverResults* self)
+{
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_viewer_get_window (SEAHORSE_VIEWER (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"));
}
-
-static void _seahorse_keyserver_results_imported_keys_seahorse_done_func (SeahorseOperation* op, gpointer self) {
- seahorse_keyserver_results_imported_keys (self, op);
-}
-
-
-static void seahorse_keyserver_results_on_key_import_keyring (SeahorseKeyserverResults* self, GtkAction* action) {
+static void
+on_key_import_keyring (SeahorseKeyserverResults* self, GtkAction* action)
+{
GList* keys;
SeahorseOperation* op;
+
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_ACTION (action));
+
keys = seahorse_viewer_get_selected_objects (SEAHORSE_VIEWER (self));
+
/* No keys, nothing to do */
- if (keys == NULL) {
- (keys == NULL ? NULL : (keys = (g_list_free (keys), NULL)));
+ if (keys == NULL)
return;
- }
+
op = seahorse_context_transfer_objects (seahorse_context_for_app (), keys, NULL);
seahorse_progress_show (op, _ ("Importing keys from key servers"), TRUE);
- seahorse_operation_watch (op, _seahorse_keyserver_results_imported_keys_seahorse_done_func, self, NULL, NULL);
- (keys == NULL ? NULL : (keys = (g_list_free (keys), NULL)));
- (op == NULL ? NULL : (op = (g_object_unref (op), NULL)));
+ seahorse_operation_watch (op, (SeahorseDoneFunc)imported_keys, self, NULL, NULL);
+
+ g_object_unref (op);
+ g_list_free (keys);
}
-
-static void seahorse_keyserver_results_on_remote_find (SeahorseKeyserverResults* self, GtkAction* action) {
+static void
+on_remote_find (GtkAction* action, SeahorseKeyserverResults* self)
+{
g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
g_return_if_fail (GTK_IS_ACTION (action));
seahorse_keyserver_search_show (seahorse_viewer_get_window (SEAHORSE_VIEWER (self)));
@@ -286,289 +208,283 @@
/* When this window closes we quit seahorse */
-static gboolean seahorse_keyserver_results_on_delete_event (SeahorseKeyserverResults* self, GtkWidget* widget, GdkEvent* event) {
+static gboolean
+on_delete_event (GtkWidget* widget, GdkEvent* event, SeahorseKeyserverResults* self)
+{
g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- seahorse_keyserver_results_on_app_close (self, NULL);
+ on_app_close (NULL, self);
return TRUE;
}
+static const GtkActionEntry GENERAL_ENTRIES[] = {
+ { "remote-menu", NULL, N_("_Remote") },
+ { "app-close", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
+ N_("Close this window"), G_CALLBACK (on_app_close) },
+ { "view-expand-all", GTK_STOCK_ADD, N_("_Expand All"), NULL,
+ N_("Expand all listings"), G_CALLBACK (on_view_expand_all) },
+ { "view-collapse-all", GTK_STOCK_REMOVE, N_("_Collapse All"), NULL,
+ N_("Collapse all listings"), G_CALLBACK (on_view_collapse_all) }
+};
-static gboolean seahorse_keyserver_results_fire_selection_changed (SeahorseKeyserverResults* self) {
- gint rows;
- GtkTreeSelection* _tmp0;
- GtkTreeSelection* selection;
- gboolean _tmp1;
- g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), FALSE);
- rows = 0;
- _tmp0 = NULL;
- selection = (_tmp0 = gtk_tree_view_get_selection (self->priv->_view), (_tmp0 == NULL ? NULL : g_object_ref (_tmp0)));
- rows = gtk_tree_selection_count_selected_rows (selection);
- seahorse_viewer_set_numbered_status (SEAHORSE_VIEWER (self), ngettext ("Selected %d key", "Selected %d keys", rows), rows);
- gtk_action_group_set_sensitive (self->priv->_object_actions, rows > 0);
- g_signal_emit_by_name (G_OBJECT (SEAHORSE_VIEW (self)), "selection-changed");
- return (_tmp1 = FALSE, (selection == NULL ? NULL : (selection = (g_object_unref (selection), NULL))), _tmp1);
-}
-
-
-const char* seahorse_keyserver_results_get_search (SeahorseKeyserverResults* self) {
- g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), NULL);
- return self->priv->_search_string;
-}
-
+static const GtkActionEntry SERVER_ENTRIES[] = {
+ { "remote-find", GTK_STOCK_FIND, N_("_Find Remote Keys..."), "",
+ N_("Search for keys on a key server"), G_CALLBACK (on_remote_find) }
+};
-static void seahorse_keyserver_results_set_search (SeahorseKeyserverResults* self, const char* value) {
- const char* _tmp1;
- char* str;
- char* _tmp2;
- g_return_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self));
- /* Many key servers ignore spaces at the beginning and end, so we do too */
- _tmp1 = NULL;
- str = (_tmp1 = value, (_tmp1 == NULL ? NULL : g_strdup (_tmp1)));
- _tmp2 = NULL;
- self->priv->_search_string = (_tmp2 = g_utf8_casefold (g_strstrip (str), -1), (self->priv->_search_string = (g_free (self->priv->_search_string), NULL)), _tmp2);
- str = (g_free (str), NULL);
- g_object_notify (((GObject *) (self)), "search");
-}
+static const GtkActionEntry KEY_ENTRIES[] = {
+ { "key-import-keyring", GTK_STOCK_ADD, N_("_Import"), "",
+ N_("Import selected keys to local key ring"), G_CALLBACK (on_key_import_keyring) }
+};
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
-static SeahorseObject* seahorse_keyserver_results_real_get_selected (SeahorseViewer* base) {
+static GList*
+seahorse_keyserver_results_get_selected_objects (SeahorseViewer* base)
+{
+ SeahorseKeyserverResults * self = SEAHORSE_KEYSERVER_RESULTS (base);
+ return seahorse_key_manager_store_get_selected_objects (self->pv->view);
+}
+
+static void
+seahorse_keyserver_results_set_selected_objects (SeahorseViewer* base, GList* keys)
+{
+ SeahorseKeyserverResults * self = SEAHORSE_KEYSERVER_RESULTS (base);
+ seahorse_key_manager_store_set_selected_objects (self->pv->view, keys);
+}
+
+static SeahorseObject*
+seahorse_keyserver_results_get_selected (SeahorseViewer* base)
+{
SeahorseKeyserverResults* self;
self = SEAHORSE_KEYSERVER_RESULTS (base);
- return seahorse_key_manager_store_get_selected_object (self->priv->_view);
+ return seahorse_key_manager_store_get_selected_object (self->pv->view);
}
+static void
+seahorse_keyserver_results_set_selected (SeahorseViewer* base, SeahorseObject* value)
+{
+ SeahorseKeyserverResults* self = SEAHORSE_KEYSERVER_RESULTS (base);
+ GList* keys = NULL;
-static void seahorse_keyserver_results_real_set_selected (SeahorseViewer* base, SeahorseObject* value) {
- SeahorseKeyserverResults* self;
- GList* keys;
- self = SEAHORSE_KEYSERVER_RESULTS (base);
- keys = NULL;
- if (value != NULL) {
+ if (value != NULL)
keys = g_list_prepend (keys, value);
- }
- seahorse_viewer_set_selected_objects (SEAHORSE_VIEWER (self), keys);
- (keys == NULL ? NULL : (keys = (g_list_free (keys), NULL)));
- g_object_notify (((GObject *) (self)), "selected");
-}
-
-static void _seahorse_keyserver_results_on_app_close_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_keyserver_results_on_app_close (self, _sender);
+ seahorse_viewer_set_selected_objects (SEAHORSE_VIEWER (self), keys);
+ g_list_free (keys);;
+ g_object_notify (G_OBJECT (self), "selected");
}
-static void _seahorse_keyserver_results_on_view_expand_all_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_keyserver_results_on_view_expand_all (self, _sender);
-}
-
-
-static void _seahorse_keyserver_results_on_view_collapse_all_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_keyserver_results_on_view_collapse_all (self, _sender);
-}
-
-
-static void _seahorse_keyserver_results_on_remote_find_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_keyserver_results_on_remote_find (self, _sender);
-}
-
-
-static void _seahorse_keyserver_results_on_key_import_keyring_gtk_action_activate (GtkAction* _sender, gpointer self) {
- seahorse_keyserver_results_on_key_import_keyring (self, _sender);
-}
-
-
-static void _seahorse_keyserver_results_on_view_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) {
- seahorse_keyserver_results_on_view_selection_changed (self, _sender);
-}
-
-
-static void _seahorse_keyserver_results_on_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
- seahorse_keyserver_results_on_row_activated (self, _sender, path, column);
-}
-
-
-static gboolean _seahorse_keyserver_results_on_key_list_button_pressed_gtk_widget_button_press_event (GtkTreeView* _sender, GdkEventButton* event, gpointer self) {
- return seahorse_keyserver_results_on_key_list_button_pressed (self, _sender, event);
-}
-
-
-static gboolean _seahorse_keyserver_results_on_key_list_popup_menu_gtk_widget_popup_menu (GtkTreeView* _sender, gpointer self) {
- return seahorse_keyserver_results_on_key_list_popup_menu (self, _sender);
-}
-
-
-static gboolean _seahorse_keyserver_results_on_filter_objects_seahorse_object_predicate_func (SeahorseObject* obj, gpointer self) {
- return seahorse_keyserver_results_on_filter_objects (self, obj);
-}
-
-
-static GObject * seahorse_keyserver_results_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
- GObject * obj;
- SeahorseKeyserverResultsClass * klass;
- GObjectClass * parent_class;
- SeahorseKeyserverResults * self;
- klass = SEAHORSE_KEYSERVER_RESULTS_CLASS (g_type_class_peek (SEAHORSE_TYPE_KEYSERVER_RESULTS));
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = SEAHORSE_KEYSERVER_RESULTS (obj);
- {
- char* title;
- GtkActionGroup* actions;
- GtkActionGroup* _tmp3;
- GtkActionGroup* _tmp4;
- gboolean _tmp5;
- GtkTreeView* _tmp7;
- GtkTreeView* _tmp6;
- SeahorseObjectPredicateFunc _tmp8;
- SeahorseSet* _tmp9;
- SeahorseKeyManagerStore* _tmp10;
- title = NULL;
- if (g_utf8_strlen (self->priv->_search_string, -1) == 0) {
- char* _tmp1;
- const char* _tmp0;
- _tmp1 = NULL;
- _tmp0 = NULL;
- title = (_tmp1 = (_tmp0 = _ ("Remote Keys"), (_tmp0 == NULL ? NULL : g_strdup (_tmp0))), (title = (g_free (title), NULL)), _tmp1);
- } else {
- char* _tmp2;
- _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_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
- */
- actions = gtk_action_group_new ("general");
- gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (actions, SEAHORSE_KEYSERVER_RESULTS_GENERAL_ENTRIES, G_N_ELEMENTS (SEAHORSE_KEYSERVER_RESULTS_GENERAL_ENTRIES), self);
- g_signal_connect_object (gtk_action_group_get_action (actions, "app-close"), "activate", ((GCallback) (_seahorse_keyserver_results_on_app_close_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (actions, "view-expand-all"), "activate", ((GCallback) (_seahorse_keyserver_results_on_view_expand_all_gtk_action_activate)), self, 0);
- g_signal_connect_object (gtk_action_group_get_action (actions, "view-collapse-all"), "activate", ((GCallback) (_seahorse_keyserver_results_on_view_collapse_all_gtk_action_activate)), self, 0);
- seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), actions);
- _tmp3 = NULL;
- actions = (_tmp3 = gtk_action_group_new ("keyserver"), (actions == NULL ? NULL : (actions = (g_object_unref (actions), NULL))), _tmp3);
- gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (actions, SEAHORSE_KEYSERVER_RESULTS_SERVER_ENTRIES, G_N_ELEMENTS (SEAHORSE_KEYSERVER_RESULTS_SERVER_ENTRIES), self);
- g_signal_connect_object (gtk_action_group_get_action (actions, "remote-find"), "activate", ((GCallback) (_seahorse_keyserver_results_on_remote_find_gtk_action_activate)), self, 0);
- seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), actions);
- _tmp4 = NULL;
- self->priv->_object_actions = (_tmp4 = gtk_action_group_new ("key"), (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL))), _tmp4);
- gtk_action_group_set_translation_domain (self->priv->_object_actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (self->priv->_object_actions, SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES, G_N_ELEMENTS (SEAHORSE_KEYSERVER_RESULTS_KEY_ENTRIES), self);
- g_signal_connect_object (gtk_action_group_get_action (self->priv->_object_actions, "key-import-keyring"), "activate", ((GCallback) (_seahorse_keyserver_results_on_key_import_keyring_gtk_action_activate)), self, 0);
- g_object_set (gtk_action_group_get_action (self->priv->_object_actions, "key-import-keyring"), "is-important", TRUE, NULL);
- seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), self->priv->_object_actions);
- /* init key list & selection settings */
- _tmp7 = NULL;
- _tmp6 = NULL;
- self->priv->_view = (_tmp7 = (_tmp6 = GTK_TREE_VIEW (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "key_list")), (_tmp6 == NULL ? NULL : g_object_ref (_tmp6))), (self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL))), _tmp7);
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->priv->_view), GTK_SELECTION_MULTIPLE);
- g_signal_connect_object (gtk_tree_view_get_selection (self->priv->_view), "changed", ((GCallback) (_seahorse_keyserver_results_on_view_selection_changed_gtk_tree_selection_changed)), self, 0);
- g_signal_connect_object (self->priv->_view, "row-activated", ((GCallback) (_seahorse_keyserver_results_on_row_activated_gtk_tree_view_row_activated)), self, 0);
- g_signal_connect_object (GTK_WIDGET (self->priv->_view), "button-press-event", ((GCallback) (_seahorse_keyserver_results_on_key_list_button_pressed_gtk_widget_button_press_event)), self, 0);
- g_signal_connect_object (GTK_WIDGET (self->priv->_view), "popup-menu", ((GCallback) (_seahorse_keyserver_results_on_key_list_popup_menu_gtk_widget_popup_menu)), self, 0);
- gtk_widget_realize (GTK_WIDGET (self->priv->_view));
- /* Set focus to the current key list */
- gtk_widget_grab_focus (GTK_WIDGET (self->priv->_view));
- /* To avoid flicker */
- seahorse_viewer_ensure_updated (SEAHORSE_VIEWER (self));
- seahorse_widget_show (SEAHORSE_WIDGET (SEAHORSE_VIEWER (self)));
- /* Our predicate for filtering keys */
- self->priv->_pred.tag = g_quark_from_string ("openpgp");
- self->priv->_pred.usage = SEAHORSE_USAGE_PUBLIC_KEY;
- self->priv->_pred.location = SEAHORSE_LOCATION_REMOTE;
- self->priv->_pred.custom = (_tmp8 = _seahorse_keyserver_results_on_filter_objects_seahorse_object_predicate_func, self->priv->_pred.custom_target = self, _tmp8);
- /* Our set all nicely filtered */
- _tmp9 = NULL;
- self->priv->_objects = (_tmp9 = seahorse_set_new_full (&self->priv->_pred), (self->priv->_objects == NULL ? NULL : (self->priv->_objects = (g_object_unref (self->priv->_objects), NULL))), _tmp9);
- _tmp10 = NULL;
- self->priv->_store = (_tmp10 = seahorse_key_manager_store_new (self->priv->_objects, self->priv->_view), (self->priv->_store == NULL ? NULL : (self->priv->_store = (g_object_unref (self->priv->_store), NULL))), _tmp10);
- seahorse_keyserver_results_on_view_selection_changed (self, gtk_tree_view_get_selection (self->priv->_view));
- title = (g_free (title), NULL);
- (actions == NULL ? NULL : (actions = (g_object_unref (actions), NULL)));
- }
- return obj;
+static GObject*
+seahorse_keyserver_results_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->constructor(type, n_props, props));
+ GtkActionGroup* actions;
+ GtkTreeSelection *selection;
+ GtkWindow *window;
+ char* title;
+
+ g_return_val_if_fail (self, NULL);
+
+
+ if (g_utf8_strlen (self->pv->search_string, -1) == 0) {
+ title = g_strdup (_("Remote Keys"));
+ } else {
+ title = g_strdup_printf (_ ("Remote Keys Containing '%s'"), self->pv->search_string);
+ }
+
+ window = seahorse_viewer_get_window (SEAHORSE_VIEWER (self));
+ gtk_window_set_title (window, title);
+ g_free (title);
+
+ g_signal_connect (window, "delete-event", G_CALLBACK (on_delete_event), self);
+
+ actions = gtk_action_group_new ("general");
+ gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (actions, GENERAL_ENTRIES, G_N_ELEMENTS (GENERAL_ENTRIES), self);
+ seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), actions);
+
+ actions = gtk_action_group_new ("keyserver");
+ gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (actions, SERVER_ENTRIES, G_N_ELEMENTS (SERVER_ENTRIES), self);
+ seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), actions);
+
+ self->pv->object_actions = gtk_action_group_new ("key");
+ gtk_action_group_set_translation_domain (self->pv->object_actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (self->pv->object_actions, KEY_ENTRIES, G_N_ELEMENTS (KEY_ENTRIES), self);
+ g_object_set (gtk_action_group_get_action (self->pv->object_actions, "key-import-keyring"), "is-important", TRUE, NULL);
+ seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), self->pv->object_actions);
+
+ /* init key list & selection settings */
+ self->pv->view = GTK_TREE_VIEW (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "key_list"));
+ selection = gtk_tree_view_get_selection (self->pv->view);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ g_signal_connect_object (selection, "changed", G_CALLBACK (on_view_selection_changed), self, 0);
+ g_signal_connect_object (self->pv->view, "row-activated", G_CALLBACK (on_row_activated), self, 0);
+ g_signal_connect_object (self->pv->view, "button-press-event", G_CALLBACK (on_key_list_button_pressed), self, 0);
+ g_signal_connect_object (self->pv->view, "popup-menu", G_CALLBACK (on_key_list_popup_menu), self, 0);
+ gtk_widget_realize (GTK_WIDGET (self->pv->view));
+
+ /* Set focus to the current key list */
+ gtk_widget_grab_focus (GTK_WIDGET (self->pv->view));
+
+ /* To avoid flicker */
+ seahorse_viewer_ensure_updated (SEAHORSE_VIEWER (self));
+ seahorse_widget_show (SEAHORSE_WIDGET (SEAHORSE_VIEWER (self)));
+
+ /* Our predicate for filtering keys */
+ self->pv->pred.tag = g_quark_from_string ("openpgp");
+ self->pv->pred.usage = SEAHORSE_USAGE_PUBLIC_KEY;
+ self->pv->pred.location = SEAHORSE_LOCATION_REMOTE;
+ self->pv->pred.custom = (SeahorseObjectPredicateFunc)on_filter_objects;
+ self->pv->pred.custom_target = self;
+
+ /* Our set all nicely filtered */
+ self->pv->objects = seahorse_set_new_full (&self->pv->pred);
+ self->pv->store = seahorse_key_manager_store_new (self->pv->objects, self->pv->view);
+ on_view_selection_changed (selection, self);
+
+ return G_OBJECT (self);
+}
+
+static void
+seahorse_keyserver_results_init (SeahorseKeyserverResults *self)
+{
+ self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsPrivate);
+}
+
+static void
+seahorse_keyserver_results_finalize (GObject *obj)
+{
+ SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (obj);
+
+ g_free (self->pv->search_string);
+ self->pv->search_string = NULL;
+
+ if (self->pv->object_actions)
+ g_object_unref (self->pv->object_actions);
+ self->pv->object_actions = NULL;
+
+ if (self->pv->objects)
+ g_object_unref (self->pv->objects);
+ self->pv->objects = NULL;
+
+ if (self->pv->store)
+ g_object_unref (self->pv->store);
+ self->pv->store = NULL;
+
+ G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->finalize (obj);
}
-
-static void seahorse_keyserver_results_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
- SeahorseKeyserverResults * self;
- self = SEAHORSE_KEYSERVER_RESULTS (object);
- switch (property_id) {
- case SEAHORSE_KEYSERVER_RESULTS_SEARCH:
- g_value_set_string (value, seahorse_keyserver_results_get_search (self));
+static void
+seahorse_keyserver_results_set_property (GObject *obj, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (obj);
+ const gchar* str;
+
+ switch (prop_id) {
+ case PROP_SEARCH:
+ /* Many key servers ignore spaces at the beginning and end, so we do too */
+ str = g_value_get_string (value);
+ if (!str)
+ str = "";
+ self->pv->search_string = g_strstrip (g_utf8_casefold (str, -1));
break;
- case SEAHORSE_KEYSERVER_RESULTS_SELECTED:
- g_value_set_object (value, seahorse_viewer_get_selected (SEAHORSE_VIEWER (self)));
+
+ case PROP_SELECTED:
+ seahorse_viewer_set_selected (SEAHORSE_VIEWER (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_keyserver_results_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
- SeahorseKeyserverResults * self;
- self = SEAHORSE_KEYSERVER_RESULTS (object);
- switch (property_id) {
- case SEAHORSE_KEYSERVER_RESULTS_SEARCH:
- seahorse_keyserver_results_set_search (self, g_value_get_string (value));
+static void
+seahorse_keyserver_results_get_property (GObject *obj, guint prop_id, GValue *value,
+ GParamSpec *pspec)
+{
+ SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (obj);
+
+ switch (prop_id) {
+ case PROP_SEARCH:
+ g_value_set_string (value, seahorse_keyserver_results_get_search (self));
break;
- case SEAHORSE_KEYSERVER_RESULTS_SELECTED:
- seahorse_viewer_set_selected (SEAHORSE_VIEWER (self), g_value_get_object (value));
+ case PROP_SELECTED:
+ g_value_set_object (value, seahorse_viewer_get_selected (SEAHORSE_VIEWER (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_keyserver_results_class_init (SeahorseKeyserverResultsClass * klass) {
+static void
+seahorse_keyserver_results_class_init (SeahorseKeyserverResultsClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
seahorse_keyserver_results_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (SeahorseKeyserverResultsPrivate));
- G_OBJECT_CLASS (klass)->get_property = seahorse_keyserver_results_get_property;
- G_OBJECT_CLASS (klass)->set_property = seahorse_keyserver_results_set_property;
- G_OBJECT_CLASS (klass)->constructor = seahorse_keyserver_results_constructor;
- G_OBJECT_CLASS (klass)->finalize = seahorse_keyserver_results_finalize;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected_objects = seahorse_keyserver_results_real_get_selected_objects;
- SEAHORSE_VIEWER_CLASS (klass)->set_selected_objects = seahorse_keyserver_results_real_set_selected_objects;
- SEAHORSE_VIEWER_CLASS (klass)->get_selected = seahorse_keyserver_results_real_get_selected;
- SEAHORSE_VIEWER_CLASS (klass)->set_selected = seahorse_keyserver_results_real_set_selected;
- g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_KEYSERVER_RESULTS_SEARCH, g_param_spec_string ("search", "search", "search", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_override_property (G_OBJECT_CLASS (klass), SEAHORSE_KEYSERVER_RESULTS_SELECTED, "selected");
-}
+ gobject_class->constructor = seahorse_keyserver_results_constructor;
+ gobject_class->finalize = seahorse_keyserver_results_finalize;
+ gobject_class->set_property = seahorse_keyserver_results_set_property;
+ gobject_class->get_property = seahorse_keyserver_results_get_property;
+
+ SEAHORSE_VIEWER_CLASS (klass)->get_selected_objects = seahorse_keyserver_results_get_selected_objects;
+ SEAHORSE_VIEWER_CLASS (klass)->set_selected_objects = seahorse_keyserver_results_set_selected_objects;
+ SEAHORSE_VIEWER_CLASS (klass)->get_selected = seahorse_keyserver_results_get_selected;
+ SEAHORSE_VIEWER_CLASS (klass)->set_selected = seahorse_keyserver_results_set_selected;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEARCH,
+ g_param_spec_string ("search", "search", "search", NULL,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-static void seahorse_keyserver_results_instance_init (SeahorseKeyserverResults * self) {
- self->priv = SEAHORSE_KEYSERVER_RESULTS_GET_PRIVATE (self);
+ g_object_class_override_property (G_OBJECT_CLASS (klass), PROP_SELECTED, "selected");
}
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
-static void seahorse_keyserver_results_finalize (GObject * obj) {
- SeahorseKeyserverResults * self;
- self = SEAHORSE_KEYSERVER_RESULTS (obj);
- self->priv->_search_string = (g_free (self->priv->_search_string), NULL);
- (self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL)));
- (self->priv->_object_actions == NULL ? NULL : (self->priv->_object_actions = (g_object_unref (self->priv->_object_actions), NULL)));
- (self->priv->_store == NULL ? NULL : (self->priv->_store = (g_object_unref (self->priv->_store), NULL)));
- (self->priv->_objects == NULL ? NULL : (self->priv->_objects = (g_object_unref (self->priv->_objects), NULL)));
- G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->finalize (obj);
+SeahorseKeyserverResults*
+seahorse_keyserver_results_new (void)
+{
+ return g_object_new (SEAHORSE_TYPE_KEYSERVER_RESULTS, NULL);
}
-
-GType seahorse_keyserver_results_get_type (void) {
- static GType seahorse_keyserver_results_type_id = 0;
- if (seahorse_keyserver_results_type_id == 0) {
- static const GTypeInfo g_define_type_info = { sizeof (SeahorseKeyserverResultsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_keyserver_results_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseKeyserverResults), 0, (GInstanceInitFunc) seahorse_keyserver_results_instance_init };
- seahorse_keyserver_results_type_id = g_type_register_static (SEAHORSE_TYPE_VIEWER, "SeahorseKeyserverResults", &g_define_type_info, 0);
+void
+seahorse_keyserver_results_show (SeahorseOperation* op, GtkWindow* parent, const char* search_text)
+{
+ SeahorseKeyserverResults* res;
+ GtkWindow *window;
+
+ g_return_if_fail (SEAHORSE_IS_OPERATION (op));
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+ g_return_if_fail (search_text != NULL);
+
+ res = g_object_new (SEAHORSE_TYPE_KEYSERVER_RESULTS, "name", "keyserver-results", "search", search_text, NULL);
+
+ /* Destorys itself with destroy */
+ g_object_ref_sink (res);
+
+ if (parent != NULL) {
+ window = GTK_WINDOW (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (res)));
+ gtk_window_set_transient_for (window, parent);
}
- return seahorse_keyserver_results_type_id;
-}
-
-
+ seahorse_progress_status_set_operation (SEAHORSE_WIDGET (res), op);
+}
+const gchar*
+seahorse_keyserver_results_get_search (SeahorseKeyserverResults* self)
+{
+ g_return_val_if_fail (SEAHORSE_IS_KEYSERVER_RESULTS (self), NULL);
+ return self->pv->search_string;
+}
Modified: trunk/src/seahorse-keyserver-results.h
==============================================================================
--- trunk/src/seahorse-keyserver-results.h (original)
+++ trunk/src/seahorse-keyserver-results.h Tue Dec 16 02:44:00 2008
@@ -24,22 +24,21 @@
#include <glib.h>
#include <glib-object.h>
+#include <gtk/gtk.h>
+
#include <seahorse-viewer.h>
#include <seahorse-operation.h>
-#include <gtk/gtk.h>
-#include <stdlib.h>
-#include <string.h>
#include <seahorse-object.h>
G_BEGIN_DECLS
-#define SEAHORSE_TYPE_KEYSERVER_RESULTS (seahorse_keyserver_results_get_type ())
-#define SEAHORSE_KEYSERVER_RESULTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResults))
-#define SEAHORSE_KEYSERVER_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsClass))
-#define SEAHORSE_IS_KEYSERVER_RESULTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_KEYSERVER_RESULTS))
-#define SEAHORSE_IS_KEYSERVER_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_KEYSERVER_RESULTS))
-#define SEAHORSE_KEYSERVER_RESULTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsClass))
+#define SEAHORSE_TYPE_KEYSERVER_RESULTS (seahorse_keyserver_results_get_type ())
+#define SEAHORSE_KEYSERVER_RESULTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResults))
+#define SEAHORSE_KEYSERVER_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsClass))
+#define SEAHORSE_IS_KEYSERVER_RESULTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_KEYSERVER_RESULTS))
+#define SEAHORSE_IS_KEYSERVER_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_KEYSERVER_RESULTS))
+#define SEAHORSE_KEYSERVER_RESULTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsClass))
typedef struct _SeahorseKeyserverResults SeahorseKeyserverResults;
typedef struct _SeahorseKeyserverResultsClass SeahorseKeyserverResultsClass;
@@ -47,17 +46,19 @@
struct _SeahorseKeyserverResults {
SeahorseViewer parent_instance;
- SeahorseKeyserverResultsPrivate * priv;
+ SeahorseKeyserverResultsPrivate *pv;
};
struct _SeahorseKeyserverResultsClass {
SeahorseViewerClass parent_class;
};
+GType seahorse_keyserver_results_get_type (void);
+
+void seahorse_keyserver_results_show (SeahorseOperation* op, GtkWindow* parent,
+ const char* search_text);
-void seahorse_keyserver_results_show (SeahorseOperation* op, GtkWindow* parent, const char* search_text);
-const char* seahorse_keyserver_results_get_search (SeahorseKeyserverResults* self);
-GType seahorse_keyserver_results_get_type (void);
+const gchar* seahorse_keyserver_results_get_search (SeahorseKeyserverResults* self);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]