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, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __SEAHORSE_OBJECT_H__ 21 #define __SEAHORSE_OBJECT_H__ 22 23 /* 24 * Derived classes must set the following properties: 25 * 26 * id: GQuark: Unique identifier for this object. 27 * tag: GQuark: The module (openpgp, pkcs11, etc...) that handles this object. 28 * label: string: The displayable string label of this object. 29 * icon: string: The stock ID of an icon to show for this object. 30 * usage: SeahorseUsage: The usage of this object. 31 * 32 * The following will be calculated automatically if not set: 33 * 34 * markup: string: The markup string label of this object. 35 * identifier: string: The displayable key identifier for this object. 36 * description: string: The description of the type of object. 37 * 38 * The following can optionally be set: 39 * 40 * location: SeahorseLocation: The location this object is present at. 41 * flags: guint: Flags from the SEAHORSE_FLAG_ set. 42 */ 43 44 #include "seahorse-context.h" 45 #include "seahorse-source.h" 46 #include "seahorse-types.h" 47 48 #include <glib-object.h> 49 50 #define SEAHORSE_TYPE_OBJECT (seahorse_object_get_type ()) 51 #define SEAHORSE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_OBJECT, SeahorseObject)) 52 #define SEAHORSE_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_OBJECT, SeahorseObjectClass)) 53 #define SEAHORSE_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_OBJECT)) 54 #define SEAHORSE_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_OBJECT)) 55 #define SEAHORSE_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_OBJECT, SeahorseObjectClass)) 56 57 typedef struct _SeahorseObject SeahorseObject; 58 typedef struct _SeahorseObjectClass SeahorseObjectClass; 59 typedef struct _SeahorseObjectPrivate SeahorseObjectPrivate; 60 61 struct _SeahorseObject { 62 GObject parent; 63 SeahorseObjectPrivate *pv; 64 }; 65 66 struct _SeahorseObjectClass { 67 GObjectClass parent_class; 68 69 /* virtual methods ------------------------------------------------- */ 70 71 void (*realize) (SeahorseObject *self); 72 73 void (*refresh) (SeahorseObject *self); 74 }; 75 76 GType seahorse_object_get_type (void); 77 78 SeahorseObject* seahorse_object_new (void); 79 80 void seahorse_object_realize (SeahorseObject *self); 81 82 void seahorse_object_refresh (SeahorseObject *self); 83 84 GQuark seahorse_object_get_id (SeahorseObject *self); 85 86 GQuark seahorse_object_get_tag (SeahorseObject *self); 87 88 SeahorseSource* seahorse_object_get_source (SeahorseObject *self); 89 90 void seahorse_object_set_source (SeahorseObject *self, 91 SeahorseSource *value); 92 93 SeahorseContext* seahorse_object_get_context (SeahorseObject *self); 94 95 SeahorseObject* seahorse_object_get_preferred (SeahorseObject *self); 96 97 void seahorse_object_set_preferred (SeahorseObject *self, 98 SeahorseObject *value); 99 100 SeahorseObject* seahorse_object_get_parent (SeahorseObject *self); 101 102 void seahorse_object_set_parent (SeahorseObject *self, 103 SeahorseObject *value); 104 105 GList* seahorse_object_get_children (SeahorseObject *self); 106 107 SeahorseObject* seahorse_object_get_nth_child (SeahorseObject *self, 108 guint index); 109 110 const gchar* seahorse_object_get_label (SeahorseObject *self); 111 112 const gchar* seahorse_object_get_markup (SeahorseObject *self); 113 114 const gchar* seahorse_object_get_identifier (SeahorseObject *self); 115 116 const gchar* seahorse_object_get_description (SeahorseObject *self); 117 118 const gchar* seahorse_object_get_nickname (SeahorseObject *self); 119 120 const gchar* seahorse_object_get_icon (SeahorseObject *self); 121 122 123 SeahorseLocation seahorse_object_get_location (SeahorseObject *self); 124 125 SeahorseUsage seahorse_object_get_usage (SeahorseObject *self); 126 127 guint seahorse_object_get_flags (SeahorseObject *self); 128 129 gboolean seahorse_object_lookup_property (SeahorseObject *self, 130 const gchar *field, 131 GValue *value); 132 133 typedef gboolean (*SeahorseObjectPredicateFunc) (SeahorseObject *obj, void *user_data); 134 135 typedef struct _SeahorseObjectPredicate SeahorseObjectPredicate; 136 137 struct _SeahorseObjectPredicate { 138 GQuark tag; 139 GQuark id; 140 GType type; 141 SeahorseLocation location; 142 SeahorseUsage usage; 143 guint flags; 144 guint nflags; 145 SeahorseSource *source; 146 SeahorseObjectPredicateFunc custom; 147 gpointer custom_target; 148 }; 149 150 void seahorse_object_predicate_clear (SeahorseObjectPredicate *self); 151 152 gboolean seahorse_object_predicate_match (SeahorseObjectPredicate *self, 153 SeahorseObject *obj); 154 155 #endif /* __SEAHORSE_OBJECT_H__ */ 156