home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / include / gdict-1.0 / gdict / gdict-context.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-04-09  |  6.3 KB  |  159 lines

  1. /* gdict-context.h - Abstract class for dictionary contexts
  2.  *
  3.  * Copyright (C) 2005  Emmanuele Bassi <ebassi@gmail.com>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public
  16.  * License along with this library; if not, write to the
  17.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.  */
  19.  
  20. #ifndef __GDICT_CONTEXT_H__
  21. #define __GDICT_CONTEXT_H__
  22.  
  23. #include <glib-object.h>
  24.  
  25. G_BEGIN_DECLS
  26.  
  27. #define GDICT_TYPE_DATABASE          (gdict_database_get_type ())
  28. #define GDICT_TYPE_STRATEGY          (gdict_strategy_get_type ())
  29. #define GDICT_TYPE_MATCH              (gdict_match_get_type ())
  30. #define GDICT_TYPE_DEFINITION         (gdict_definition_get_type ())
  31.  
  32. #define GDICT_TYPE_CONTEXT          (gdict_context_get_type ())
  33. #define GDICT_CONTEXT(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDICT_TYPE_CONTEXT, GdictContext))
  34. #define GDICT_IS_CONTEXT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDICT_TYPE_CONTEXT))
  35. #define GDICT_CONTEXT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GDICT_TYPE_CONTEXT, GdictContextIface))
  36.  
  37. /* These are the boxed containers for action results. */
  38. typedef struct _GdictDatabase     GdictDatabase;
  39. typedef struct _GdictStrategy     GdictStrategy;
  40. typedef struct _GdictMatch        GdictMatch;
  41. typedef struct _GdictDefinition   GdictDefinition;
  42.  
  43. typedef struct _GdictContext      GdictContext; /* dummy typedef */
  44. typedef struct _GdictContextIface GdictContextIface;
  45.  
  46. #define GDICT_CONTEXT_ERROR    (gdict_context_error_quark ())
  47.  
  48. typedef enum {
  49.   GDICT_CONTEXT_ERROR_PARSE,
  50.   GDICT_CONTEXT_ERROR_NOT_IMPLEMENTED,
  51.   GDICT_CONTEXT_ERROR_INVALID_DATABASE,
  52.   GDICT_CONTEXT_ERROR_INVALID_STRATEGY,
  53.   GDICT_CONTEXT_ERROR_INVALID_COMMAND,
  54.   GDICT_CONTEXT_ERROR_NO_MATCH,
  55.   GDICT_CONTEXT_ERROR_NO_DATABASES,
  56.   GDICT_CONTEXT_ERROR_NO_STRATEGIES
  57. } GdictContextError;
  58.  
  59. GQuark gdict_context_error_quark (void);
  60.  
  61.  
  62. GType                 gdict_database_get_type        (void) G_GNUC_CONST;
  63. GdictDatabase *       gdict_database_ref             (GdictDatabase   *db);
  64. void                  gdict_database_unref           (GdictDatabase   *db);
  65. G_CONST_RETURN gchar *gdict_database_get_name        (GdictDatabase   *db);
  66. G_CONST_RETURN gchar *gdict_database_get_full_name   (GdictDatabase   *db);
  67.  
  68. GType                 gdict_strategy_get_type        (void) G_GNUC_CONST;
  69. GdictStrategy *       gdict_strategy_ref             (GdictStrategy   *strat);
  70. void                  gdict_strategy_unref           (GdictStrategy   *strat);
  71. G_CONST_RETURN gchar *gdict_strategy_get_name        (GdictStrategy   *strat);
  72. G_CONST_RETURN gchar *gdict_strategy_get_description (GdictStrategy   *strat);
  73.  
  74. GType                 gdict_match_get_type           (void) G_GNUC_CONST;
  75. GdictMatch *          gdict_match_ref                (GdictMatch      *match);
  76. void                  gdict_match_unref              (GdictMatch      *match);
  77. G_CONST_RETURN gchar *gdict_match_get_word           (GdictMatch      *match);
  78. G_CONST_RETURN gchar *gdict_match_get_database       (GdictMatch      *match);
  79.  
  80. GType                 gdict_definition_get_type      (void) G_GNUC_CONST;
  81. GdictDefinition *     gdict_definition_ref           (GdictDefinition *def);
  82. void                  gdict_definition_unref         (GdictDefinition *def);
  83. gint                  gdict_definition_get_total     (GdictDefinition *def);
  84. G_CONST_RETURN gchar *gdict_definition_get_word      (GdictDefinition *def);
  85. G_CONST_RETURN gchar *gdict_definition_get_database  (GdictDefinition *def);
  86. G_CONST_RETURN gchar *gdict_definition_get_text      (GdictDefinition *def);
  87.  
  88.  
  89. struct _GdictContextIface
  90. {
  91.   GTypeInterface base_iface;
  92.   
  93.   /* methods, not signals */
  94.   gboolean (*get_databases)     (GdictContext  *context,
  95.                        GError       **error);
  96.   gboolean (*get_strategies)    (GdictContext  *context,
  97.                        GError       **error);
  98.   gboolean (*match_word)        (GdictContext  *context,
  99.                        const gchar   *database,
  100.                        const gchar   *strategy,
  101.                        const gchar   *word,
  102.                        GError       **error);
  103.   gboolean (*define_word)       (GdictContext  *context,
  104.                        const gchar   *database,
  105.                        const gchar   *word,
  106.                        GError       **error);  
  107.   
  108.   /* signals */
  109.   void (*lookup_start)     (GdictContext    *context);
  110.   void (*lookup_end)       (GdictContext    *context);
  111.   
  112.   void (*database_found)   (GdictContext    *context,
  113.                   GdictDatabase   *database);
  114.   void (*strategy_found)   (GdictContext    *context,
  115.                   GdictStrategy   *strategy);
  116.   void (*match_found)      (GdictContext    *context,
  117.                   GdictMatch      *match);
  118.   void (*definition_found) (GdictContext    *context,
  119.                   GdictDefinition *definition);
  120.   
  121.   /* fired each time there's an error; the GError is owned
  122.    * by the context, and should never be modified or freed
  123.    */
  124.   void (*error)            (GdictContext    *context,
  125.                   const GError    *error);
  126.  
  127.   /* padding for future expansion */
  128.   void (*_gdict_context_1) (void);
  129.   void (*_gdict_context_2) (void);
  130.   void (*_gdict_context_3) (void);
  131.   void (*_gdict_context_4) (void);
  132. };
  133.  
  134. GType    gdict_context_get_type          (void) G_GNUC_CONST;
  135.  
  136. /* Configuration */
  137. void     gdict_context_set_local_only    (GdictContext  *context,
  138.                           gboolean       local_only);
  139. gboolean gdict_context_get_local_only    (GdictContext  *context);
  140.  
  141. /* Actions */
  142. gboolean gdict_context_lookup_databases  (GdictContext  *context,
  143.                       GError       **error);
  144. gboolean gdict_context_lookup_strategies (GdictContext  *context,
  145.                       GError       **error);
  146. gboolean gdict_context_match_word        (GdictContext  *context,
  147.                       const gchar   *database,
  148.                       const gchar   *strategy,
  149.                       const gchar   *word,
  150.                       GError       **error);
  151. gboolean gdict_context_define_word       (GdictContext  *context,
  152.                       const gchar   *database,
  153.                       const gchar   *word,
  154.                       GError       **error);
  155.  
  156. G_END_DECLS
  157.  
  158. #endif /* __GDICT_CONTEXT_H__ */
  159.