ink-comboboxentry-action.h revision edc2f3b640cca99df088effceaa7da6273f4d8d4
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos/*
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * A subclass of GtkAction that wraps a GtkComboBoxEntry.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Features:
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Setting GtkEntryBox width in characters.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Passing a function for formatting cells.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Displaying a warning if text isn't in list.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Setting names for GtkComboBoxEntry and GtkEntry (actionName_combobox, actionName_entry)
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * to allow setting resources.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos *
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Author(s):
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Tavmjong Bah
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Jon A. Cruz <jon@joncruz.org>
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos *
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Copyright (C) 2010 Authors
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos *
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Released under GNU GPL, read the file 'COPYING' for more information
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos */
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#ifndef SEEN_INK_COMBOBOXENTRY_ACTION
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#define SEEN_INK_COMBOBOXENTRY_ACTION
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#include <gtk/gtk.h>
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#define INK_COMBOBOXENTRY_TYPE_ACTION (ink_comboboxentry_action_get_type())
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#define INK_COMBOBOXENTRY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_Action))
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#define INK_COMBOBOXENTRY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass))
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#define INK_COMBOBOXENTRY_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_COMBOBOXENTRY_TYPE_ACTION))
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#define INK_COMBOBOXENTRY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass))
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kostypedef struct _Ink_ComboBoxEntry_ActionClass Ink_ComboBoxEntry_ActionClass;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kostypedef struct _Ink_ComboBoxEntry_Action Ink_ComboBoxEntry_Action;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosstruct _Ink_ComboBoxEntry_ActionClass {
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkActionClass parent_class;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos void (*changed) (Ink_ComboBoxEntry_Action* action);
a81e80c817808f4bb41d5219b04dbf73c943821eNikolai Kondrashov void (*activated) (Ink_ComboBoxEntry_Action* action);
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos};
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosstruct _Ink_ComboBoxEntry_Action {
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkAction parent_instance;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkTreeModel *model;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkComboBox *combobox;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkEntry *entry;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkEntryCompletion *entry_completion;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkWidget *indicator;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
cca497b4cbbbf05c4f9181b7d8113cde81754831Michal Židek gpointer cell_data_func; // drop-down menu format
cca497b4cbbbf05c4f9181b7d8113cde81754831Michal Židek gpointer separator_func;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint active; // Index of active menu item (-1 if not in list).
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gchar *text; // Text of active menu item or entry box.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint entry_width;// Width of GtkEntry in characters.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint extra_width;// Extra Width of GtkComboBox.. to widen drop-down list in list mode.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gboolean popup; // Do we pop-up an entry-completion dialog?
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gchar *info; // Text for tooltip info about entry.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gpointer info_cb; // Callback for clicking info icon.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint info_cb_id;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gboolean info_cb_blocked;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gchar *warning; // Text for tooltip warning that entry isn't in list.
a81e80c817808f4bb41d5219b04dbf73c943821eNikolai Kondrashov gpointer warning_cb; // Callback for clicking warning icon.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint warning_cb_id;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gboolean warning_cb_blocked;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gchar *altx_name; // Target for Alt-X keyboard shortcut.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkWidget *focusWidget;
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos};
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej KosGType ink_comboboxentry_action_get_type (void);
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos/**
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos * Creates a GtkAction subclass that wraps a GtkComboBoxEntry object.
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos */
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej KosInk_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar *name,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos const gchar *label,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos const gchar *tooltip,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos const gchar *stock_id,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkTreeModel *model,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint entry_width = -1,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gint extra_width = -1,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gpointer cell_data_func = NULL,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos gpointer separator_func = NULL,
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos GtkWidget* focusWidget = NULL);
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej KosGtkTreeModel *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej KosGtkComboBox *ink_comboboxentry_action_get_comboboxentry( Ink_ComboBoxEntry_Action* action );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosgchar* ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* action );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosgboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text, int row=-1 );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_entry_width( Ink_ComboBoxEntry_Action* action, gint entry_width );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action, gint extra_width );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_popup_enable( Ink_ComboBoxEntry_Action* action );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_info( Ink_ComboBoxEntry_Action* action, const gchar* info );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_info_cb( Ink_ComboBoxEntry_Action* action, gpointer info_cb );
a81e80c817808f4bb41d5219b04dbf73c943821eNikolai Kondrashovvoid ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning_cb );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_warning_cb(Ink_ComboBoxEntry_Action* action, gpointer warning );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_tooltip( Ink_ComboBoxEntry_Action* action, const gchar* tooltip );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kosvoid ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* action, const gchar* altx_name );
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos#endif /* SEEN_INK_COMBOBOXENTRY_ACTION */
7de6e3534fd61c7619ed34a6b1afe7230b5e6504Ondrej Kos