libyui-gtk  2.44.10
ygtkwizard.h
1 /********************************************************************
2  * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
3  ********************************************************************/
4 
5 /* YGtkWizard is a widget based on GtkAssistant, which we couldn't
6  use (for starters, GtkAssistant comes from GtkWindow and we need
7  a widget, not a window).
8 */
9 
10 #ifndef YGTK_WIZARD_H
11 #define YGTK_WIZARD_H
12 
13 #include <gdk/gdk.h>
14 #include <gtk/gtk.h>
15 
16 G_BEGIN_DECLS
17 
18 // test feature: history on help dialog
19 //#define SET_HELP_HISTORY
20 
21 typedef struct YGtkHelpText {
22 #ifdef SET_HELP_HISTORY
23  GList *history;
24 #else
25  gchar *text;
26 #endif
27  GtkWidget *dialog;
28 } YGtkHelpText;
29 
30 YGtkHelpText *ygtk_help_text_new (void);
31 void ygtk_help_text_destroy (YGtkHelpText *help);
32 void ygtk_help_text_set (YGtkHelpText *help, const gchar *title, const gchar *text);
33 const gchar *ygtk_help_text_get (YGtkHelpText *help, gint n);
34 void ygtk_help_text_sync (YGtkHelpText *help, GtkWidget *dialog);
35 
36 // YGtkHelpDialog (for showing help text)
37 /* Shows help text. It is GtkWindow-inherited, rather than GtkDialog, because
38  we want to place a search entry next to the buttons. */
39 
40 #define YGTK_TYPE_HELP_DIALOG (ygtk_help_dialog_get_type ())
41 #define YGTK_HELP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
42  YGTK_TYPE_HELP_DIALOG, YGtkHelpDialog))
43 #define YGTK_HELP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
44  YGTK_TYPE_HELP_DIALOG, YGtkHelpDialogClass))
45 #define YGTK_IS_HELP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
46  YGTK_TYPE_HELP_DIALOG))
47 #define YGTK_IS_HELP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
48  YGTK_TYPE_HELP_DIALOG))
49 #define YGTK_HELP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
50  YGTK_TYPE_HELP_DIALOG, YGtkHelpDialogClass))
51 
52 typedef struct _YGtkHelpDialog
53 {
54  GtkWindow parent;
55 
56  // members:
57  GtkWidget *title_box, *title_label, *title_image;
58  GtkWidget *help_box, *help_text;
59  GtkWidget *search_entry, *close_button, *history_combo;
60  GtkWidget *vbox;
62 
63 typedef struct _YGtkHelpDialogClass
64 {
65  GtkWindowClass parent_class;
66 
67  // signals
68  void (*find_next) (YGtkHelpDialog *dialog);
69  void (*close) (YGtkHelpDialog *dialog);
71 
72 GtkWidget *ygtk_help_dialog_new (GtkWindow *parent);
73 GType ygtk_help_dialog_get_type (void) G_GNUC_CONST;
74 
75 void ygtk_help_dialog_set_text (YGtkHelpDialog *dialog, const gchar *text);
76 
77 // YGtkWizard
78 
79 #define YGTK_TYPE_WIZARD (ygtk_wizard_get_type ())
80 #define YGTK_WIZARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
81  YGTK_TYPE_WIZARD, YGtkWizard))
82 #define YGTK_WIZARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
83  YGTK_TYPE_WIZARD, YGtkWizardClass))
84 #define YGTK_IS_WIZARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
85  YGTK_TYPE_WIZARD))
86 #define YGTK_IS_WIZARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
87  YGTK_TYPE_WIZARD))
88 #define YGTK_WIZARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
89  YGTK_TYPE_WIZARD, YGtkWizardClass))
90 
91 typedef struct _YGtkWizard
92 {
93  GtkVBox box;
94 
95  // private:
96  /* Hash tables to assign Yast Ids to Gtk entries. */
97  GHashTable *menu_ids; /* gchar* -> GtkWidget* */
98  GHashTable *tree_ids; /* gchar* -> GtkTreePath* */
99  GHashTable *steps_ids; /* gchar* -> guint */
100 
101  /* For layout */
102  GtkWidget *m_menu_box, *m_title, *m_contents_box, *m_control_bar,
103  *m_child, *m_status_box, *m_pane, *m_buttons, *m_info_box;
104 
105  /* Widgets we need to access. */
106  GtkWidget *tree_view, *steps, *menu,
107  *back_button, *abort_button, *next_button, *help_button,
108  *release_notes_button, *m_default_button;
109 
110  /* The help text. */
111  YGtkHelpText *m_help;
112 } YGtkWizard;
113 
114 typedef struct _YGtkWizardClass
115 {
116  GtkVBoxClass parent_class;
117 
118  // signals:
119  void (*action_triggered) (YGtkWizard *wizard, gpointer id, gint id_type);
120  void (*popup_help) (YGtkWizard *dialog);
122 
123 GtkWidget *ygtk_wizard_new (void);
124 GType ygtk_wizard_get_type (void) G_GNUC_CONST;
125 
126 // Enable a steps or tree pane widget -- should be called right after
127 // initilization and only _one_ of them
128 void ygtk_wizard_enable_steps (YGtkWizard *wizard);
129 void ygtk_wizard_enable_tree (YGtkWizard *wizard);
130 
131 // convinience method that removes the current child, if set, and swaps it by
132 // the given one (you may pass NULL to just remove current child)
133 void ygtk_wizard_set_child (YGtkWizard *wizard, GtkWidget *widget);
134 void ygtk_wizard_set_information_widget (YGtkWizard *wizard, GtkWidget *widget);
135 void ygtk_wizard_set_control_widget (YGtkWizard *wizard, GtkWidget *widget);
136 
137 // commands
138 // (commands that may fail return a sucess boolean.)
139 void ygtk_wizard_set_help_text (YGtkWizard *wizard, const gchar *text);
140 
141 void ygtk_wizard_set_header_text (YGtkWizard *wizard, const char *text);
142 gboolean ygtk_wizard_set_header_icon (YGtkWizard *wizard, const char *icon);
143 
144 void ygtk_wizard_set_button_label (YGtkWizard *wizard, GtkWidget *button,
145  const char *text, const char *stock);
146 void ygtk_wizard_enable_button (YGtkWizard *wizard, GtkWidget *button,
147  gboolean enable);
148 void ygtk_wizard_set_button_str_id (YGtkWizard *wizard, GtkWidget *button,
149  const char *id);
150 void ygtk_wizard_set_button_ptr_id (YGtkWizard *wizard, GtkWidget *button,
151  gpointer id);
152 void ygtk_wizard_set_default_button (YGtkWizard *wizard, GtkWidget *button); // before realize
153 
154 void ygtk_wizard_set_extra_button (YGtkWizard *wizard, GtkWidget *widget);
155 
156 void ygtk_wizard_add_menu (YGtkWizard *wizard, const char *text,
157  const char *id);
158 gboolean ygtk_wizard_add_menu_entry (YGtkWizard *wizard, const char *parent_id,
159  const char *text, const char *id);
160 gboolean ygtk_wizard_add_sub_menu (YGtkWizard *wizard, const char *parent_id,
161  const char *text, const char *id);
162 gboolean ygtk_wizard_add_menu_separator (YGtkWizard *wizard, const char *parent_id);
163 void ygtk_wizard_clear_menu (YGtkWizard *wizard);
164 void ygtk_wizard_set_custom_menubar (YGtkWizard *wizard, GtkWidget *menu_bar, gboolean hide_header);
165 void ygtk_wizard_set_status_bar (YGtkWizard *wizard, GtkWidget *status_bar);
166 
167 void ygtk_wizard_add_step_header (YGtkWizard *wizard, const char *text);
168 void ygtk_wizard_add_step (YGtkWizard *wizard, const char* text, const char *id);
169 gboolean ygtk_wizard_set_current_step (YGtkWizard *wizard, const char *id);
170 void ygtk_wizard_clear_steps (YGtkWizard *wizard);
171 
172 gboolean ygtk_wizard_add_tree_item (YGtkWizard *wizard, const char *parent_id,
173  const char *text, const char *id);
174 void ygtk_wizard_clear_tree (YGtkWizard *wizard);
175 gboolean ygtk_wizard_select_tree_item (YGtkWizard *wizard, const char *id);
176 const gchar *ygtk_wizard_get_tree_selection (YGtkWizard *wizard);
177 
178 G_END_DECLS
179 #endif /* YGTK_WIZARD_H */
180