1 /* 2 * Copyright (C) 2012 Vivien Malerba <malerba@gnome-db.org> 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 20 #ifndef __GDA_TOOLS_FAVORITES_H_ 21 #define __GDA_TOOLS_FAVORITES_H_ 22 23 #include <libgda/libgda.h> 24 25 G_BEGIN_DECLS 26 27 #define GDA_TOOLS_TYPE_FAVORITES (gda_tools_favorites_get_type()) 28 #define GDA_TOOLS_FAVORITES(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gda_tools_favorites_get_type(), ToolsFavorites) 29 #define GDA_TOOLS_FAVORITES_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gda_tools_favorites_get_type (), ToolsFavoritesClass) 30 #define GDA_TOOLS_IS_FAVORITES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gda_tools_favorites_get_type ()) 31 32 typedef struct _ToolsFavorites ToolsFavorites; 33 typedef struct _ToolsFavoritesClass ToolsFavoritesClass; 34 typedef struct _ToolsFavoritesPrivate ToolsFavoritesPrivate; 35 36 /** 37 * ToolsFavoritesType: 38 * @GDA_TOOLS_FAVORITES_TABLES: a database's table favorite 39 * @GDA_TOOLS_FAVORITES_DIAGRAMS: a diagram favorite 40 * @GDA_TOOLS_FAVORITES_QUERIES: 41 * @GDA_TOOLS_FAVORITES_DATA_MANAGERS: 42 * @GDA_TOOLS_FAVORITES_ACTIONS: 43 * 44 * Enum to identify favorite's types. 45 */ 46 typedef enum { 47 GDA_TOOLS_FAVORITES_TABLES = 1 << 0, 48 GDA_TOOLS_FAVORITES_DIAGRAMS = 1 << 1, 49 GDA_TOOLS_FAVORITES_QUERIES = 1 << 2, 50 GDA_TOOLS_FAVORITES_DATA_MANAGERS = 1 << 3, 51 GDA_TOOLS_FAVORITES_ACTIONS = 1 << 4, 52 GDA_TOOLS_FAVORITES_LDAP_DN = 1 << 5, 53 GDA_TOOLS_FAVORITES_LDAP_CLASS = 1 << 6 54 } ToolsFavoritesType; 55 #define GDA_TOOLS_FAVORITES_NB_TYPES 7 56 57 #define ORDER_KEY_SCHEMA 1 58 #define ORDER_KEY_QUERIES 2 59 #define ORDER_KEY_DATA_MANAGERS 3 60 #define ORDER_KEY_LDAP 4 61 62 /** 63 * ToolsFavoritesAttributes: 64 * @id: the favorite ID, or <0 if not saved 65 * @type: the favorite's type 66 * @name: the favorite's name 67 * @descr: the favorite's description 68 * @contents: the favorite's contents, depending on the favorite type 69 */ 70 typedef struct { 71 gint id; 72 ToolsFavoritesType type; 73 gchar *name; 74 gchar *descr; 75 gchar *contents; 76 } ToolsFavoritesAttributes; 77 78 /* struct for the object's data */ 79 struct _ToolsFavorites 80 { 81 GObject object; 82 ToolsFavoritesPrivate *priv; 83 }; 84 85 /* struct for the object's class */ 86 struct _ToolsFavoritesClass 87 { 88 GObjectClass parent_class; 89 90 void (*favorites_changed) (ToolsFavorites *bfav); 91 }; 92 93 /** 94 * SECTION:tools-favorites 95 * @short_description: Favorites management 96 * @title: ToolsFavorites 97 * @stability: Stable 98 * @see_also: 99 * 100 * Each connection uses a single #ToolsFavorites object to manage its favorites, 101 * see gda_tools_connection_get_favorites(). 102 */ 103 104 GType gda_tools_favorites_get_type (void) G_GNUC_CONST; 105 106 ToolsFavorites *gda_tools_favorites_new (GdaMetaStore *store); 107 const gchar *gda_tools_favorites_type_to_string (ToolsFavoritesType type); 108 gboolean gda_tools_favorites_add (ToolsFavorites *bfav, guint session_id, 109 ToolsFavoritesAttributes *fav, 110 gint order_key, gint pos, 111 GError **error); 112 GSList *gda_tools_favorites_list (ToolsFavorites *bfav, guint session_id, 113 ToolsFavoritesType type, gint order_key, GError **error); 114 115 gboolean gda_tools_favorites_delete (ToolsFavorites *bfav, guint session_id, 116 ToolsFavoritesAttributes *fav, GError **error); 117 void gda_tools_favorites_free_list (GSList *fav_list); 118 void gda_tools_favorites_reset_attributes (ToolsFavoritesAttributes *fav); 119 120 gint gda_tools_favorites_find (ToolsFavorites *bfav, guint session_id, const gchar *contents, 121 ToolsFavoritesAttributes *out_fav, GError **error); 122 gint gda_tools_favorites_find_by_name (ToolsFavorites *bfav, guint session_id, 123 ToolsFavoritesType type, const gchar *name, 124 ToolsFavoritesAttributes *out_fav, GError **error); 125 gboolean gda_tools_favorites_get (ToolsFavorites *bfav, gint fav_id, 126 ToolsFavoritesAttributes *out_fav, GError **error); 127 128 G_END_DECLS 129 130 #endif 131