Code

Add warning dialog for other than "newest" GTK.
[inkscape.git] / src / ink-comboboxentry-action.h
1 /*
2  * A subclass of GtkAction that wraps a GtkComboBoxEntry.
3  * Features:
4  *   Setting GtkEntryBox width in characters.
5  *   Passing a function for formatting cells.
6  *   Displaying a warning if text isn't in list.
7  *
8  * Author(s):
9  *   Tavmjong Bah
10  *   Jon A. Cruz <jon@joncruz.org>
11  *
12  * Copyright (C) 2010 Authors
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #ifndef SEEN_INK_COMBOBOXENTRY_ACTION
18 #define SEEN_INK_COMBOBOXENTRY_ACTION
20 #include <glib.h>
21 #include <glib-object.h>
23 #include <gtk/gtkaction.h>
24 #include <gtk/gtktreemodel.h>
27 #define INK_COMBOBOXENTRY_TYPE_ACTION           (ink_comboboxentry_action_get_type())
28 #define INK_COMBOBOXENTRY_ACTION(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_Action))
29 #define INK_COMBOBOXENTRY_ACTION_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass),  INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass))
30 #define INK_COMBOBOXENTRY_IS_ACTION(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_COMBOBOXENTRY_TYPE_ACTION))
31 #define INK_COMBOBOXENTRY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),  INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass))
33 typedef struct _Ink_ComboBoxEntry_ActionClass Ink_ComboBoxEntry_ActionClass;
34 typedef struct _Ink_ComboBoxEntry_Action      Ink_ComboBoxEntry_Action;
36 struct _Ink_ComboBoxEntry_ActionClass {
37   GtkActionClass parent_class;
39   void (*changed)   (Ink_ComboBoxEntry_Action* action);
40   void (*activated) (Ink_ComboBoxEntry_Action* action);
41 };
43 struct _Ink_ComboBoxEntry_Action {
44   GtkAction parent_instance;
46   GtkTreeModel       *model;
47   GtkComboBoxEntry   *combobox;
48   GtkEntry           *entry;
49   GtkEntryCompletion *entry_completion;
50 #if !GTK_CHECK_VERSION(2,16,0)
51   GtkWidget          *indicator;
52 #endif
54   gpointer            cell_data_func; // drop-down menu format
56   gint                active;     // Index of active menu item (-1 if not in list).
57   gchar              *text;       // Text of active menu item or entry box.
58   gint                width;      // Width of GtkComboBoxEntry in characters.
59   gboolean            popup;      // Do we pop-up an entry-completion dialog?
60   gchar              *warning;    // Text for warning that entry isn't in list.
61   gchar              *altx_name;  // Target for Alt-X keyboard shortcut.
62 };
65 GType ink_comboboxentry_action_get_type (void);
67 /**
68  * Creates a GtkAction subclass that wraps a GtkComboBoxEntry object.
69  */
70 Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar  *name,
71                                                          const gchar  *label,
72                                                          const gchar  *tooltip,
73                                                          const gchar  *stock_id,
74                                                          GtkTreeModel *model,
75                                                          gint          width = -1,
76                                                          gpointer cell_data_func = NULL );
78 GtkTreeModel     *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action );
79 GtkComboBoxEntry *ink_comboboxentry_action_get_comboboxentry( Ink_ComboBoxEntry_Action* action );
81 gchar*   ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* action );
82 gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text );
84 void     ink_comboboxentry_action_set_width( Ink_ComboBoxEntry_Action* action, gint width );
86 void     ink_comboboxentry_action_popup_enable(  Ink_ComboBoxEntry_Action* action );
87 void     ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action );
89 void     ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning );
91 void     ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* action, const gchar* altx_name );
93 #endif /* SEEN_INK_COMBOBOXENTRY_ACTION */