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 *
11 * Copyright (C) 2010 Authors
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #ifndef SEEN_INK_COMBOBOXENTRY_ACTION
17 #define SEEN_INK_COMBOBOXENTRY_ACTION
19 #include <glib.h>
20 #include <glib-object.h>
22 #include <gtk/gtkaction.h>
23 #include <gtk/gtktreemodel.h>
26 #define INK_COMBOBOXENTRY_TYPE_ACTION (ink_comboboxentry_action_get_type())
27 #define INK_COMBOBOXENTRY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_Action))
28 #define INK_COMBOBOXENTRY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass))
29 #define INK_COMBOBOXENTRY_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_COMBOBOXENTRY_TYPE_ACTION))
30 #define INK_COMBOBOXENTRY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass))
32 typedef struct _Ink_ComboBoxEntry_ActionClass Ink_ComboBoxEntry_ActionClass;
33 typedef struct _Ink_ComboBoxEntry_Action Ink_ComboBoxEntry_Action;
35 struct _Ink_ComboBoxEntry_ActionClass {
36 GtkActionClass parent_class;
38 void (*changed) (Ink_ComboBoxEntry_Action* action);
39 void (*activated) (Ink_ComboBoxEntry_Action* action);
40 };
42 struct _Ink_ComboBoxEntry_Action {
43 GtkAction parent_instance;
45 GtkTreeModel *model;
46 GtkComboBoxEntry *combobox;
47 GtkEntry *entry;
48 GtkEntryCompletion *entry_completion;
50 gpointer cell_data_func; // drop-down menu format
52 gint active; // Index of active menu item (-1 if not in list).
53 gchar *text; // Text of active menu item or entry box.
54 gint width; // Width of GtkComboBoxEntry in characters.
55 gboolean popup; // Do we pop-up an entry-completion dialog?
56 gchar *warning; // Text for warning that entry isn't in list.
57 gchar *altx_name; // Target for Alt-X keyboard shortcut.
58 };
61 GType ink_comboboxentry_action_get_type (void);
63 /**
64 * Creates a GtkAction subclass that wraps a GtkComboBoxEntry object.
65 */
66 Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar *name,
67 const gchar *label,
68 const gchar *tooltip,
69 const gchar *stock_id,
70 GtkTreeModel *model,
71 gint width = -1,
72 gpointer cell_data_func = NULL );
74 GtkTreeModel *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action );
75 GtkComboBoxEntry *ink_comboboxentry_action_get_comboboxentry( Ink_ComboBoxEntry_Action* action );
77 gchar* ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* action );
78 gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text );
80 void ink_comboboxentry_action_set_width( Ink_ComboBoxEntry_Action* action, gint width );
82 void ink_comboboxentry_action_popup_enable( Ink_ComboBoxEntry_Action* action );
83 void ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action );
85 void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning );
87 void ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* action, const gchar* altx_name );
89 #endif /* SEEN_INK_COMBOBOXENTRY_ACTION */