2 * ui_utils.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2006-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #ifndef GEANY_UI_UTILS_H
25 #define GEANY_UI_UTILS_H 1
27 /** Sets a name to lookup @a widget from @a owner.
28 * @param owner Usually a @c GtkWindow.
29 * @param widget Widget.
30 * @param widget_name Name.
31 * @see ui_lookup_widget().
35 #define ui_hookup_widget(owner, widget, widget_name) \
36 g_object_set_data_full(G_OBJECT(owner), widget_name, \
37 g_object_ref(widget), (GDestroyNotify)g_object_unref);
40 typedef struct GeanyInterfacePrefs
42 gboolean sidebar_symbol_visible
;
43 gboolean sidebar_openfiles_visible
;
47 gboolean show_notebook_tabs
;
51 gboolean statusbar_visible
;
52 gboolean show_symbol_list_expanders
;
53 gboolean notebook_double_click_hides_widgets
;
54 gboolean highlighting_invert_all
;
56 gboolean msgwin_status_visible
;
57 gboolean msgwin_compiler_visible
;
58 gboolean msgwin_messages_visible
;
59 gboolean msgwin_scribble_visible
;
63 extern GeanyInterfacePrefs interface_prefs
;
66 /** Important widgets in the main window. */
67 typedef struct GeanyMainWidgets
69 GtkWidget
*window
; /**< Main window. */
70 GtkWidget
*toolbar
; /**< Main toolbar. */
71 GtkWidget
*sidebar_notebook
; /**< Sidebar notebook. */
72 GtkWidget
*notebook
; /**< Document notebook. */
73 GtkWidget
*editor_menu
; /**< Popup editor menu. */
74 GtkWidget
*tools_menu
; /**< Most plugins add menu items to the Tools menu. */
75 GtkWidget
*progressbar
; /**< Progress bar widget in the status bar to show
76 progress of various actions.
77 See ui_progress_bar_start() for details. */
81 extern GeanyMainWidgets main_widgets
;
84 /* User Interface settings not shown in the Prefs dialog. */
85 typedef struct UIPrefs
87 /* State of the main window when Geany was closed */
88 gint geometry
[5]; /* 0:x, 1:y, 2:width, 3:height, flag for maximized state */
90 gboolean sidebar_visible
;
92 gboolean msgwindow_visible
;
93 gboolean allow_always_save
; /* if set, files can always be saved, even if unchanged */
95 /* Menu-item related data */
97 GQueue
*recent_projects_queue
;
98 gchar
*custom_date_format
;
99 gchar
**custom_commands
;
103 extern UIPrefs ui_prefs
;
106 /* Less commonly used widgets */
107 typedef struct UIWidgets
110 GtkWidget
*toolbar_menu
;
111 GtkWidget
*recent_files_menuitem
;
112 GtkWidget
*recent_files_menu_menubar
;
113 GtkWidget
*print_page_setup
;
114 GtkWidget
*recent_projects_menuitem
;
115 GtkWidget
*recent_projects_menu_menubar
;
118 GtkWidget
*open_colorsel
;
119 GtkWidget
*open_fontsel
;
120 GtkWidget
*open_filesel
;
121 GtkWidget
*save_filesel
;
122 GtkWidget
*prefs_dialog
;
124 /* other widgets not needed in GeanyMainWidgets */
125 GtkWidget
*statusbar
; /* use ui_set_statusbar() to set */
129 extern UIWidgets ui_widgets
;
132 /* The following block of types & functions are more generic and closely related to
133 * certain GTK+ widgets. */
135 typedef struct GeanyAutoSeparator
137 GtkWidget
*widget
; /* e.g. GtkSeparatorToolItem, GtkSeparatorMenuItem */
138 gint ref_count
; /* set to zero initially */
145 GEANY_EDITOR_SHOW_MARKERS_MARGIN
,
146 GEANY_EDITOR_SHOW_LINE_NUMBERS
,
147 GEANY_EDITOR_SHOW_WHITE_SPACE
,
148 GEANY_EDITOR_SHOW_INDENTATION_GUIDES
,
149 GEANY_EDITOR_SHOW_LINE_ENDINGS
151 GeanyUIEditorFeatures
;
154 #define GEANY_STOCK_SAVE_ALL "geany-save-all"
155 #define GEANY_STOCK_CLOSE_ALL "geany-close-all"
156 #define GEANY_STOCK_BUILD "geany-build"
161 GEANY_IMAGE_SAVE_ALL
,
162 GEANY_IMAGE_CLOSE_ALL
,
167 void ui_widget_show_hide(GtkWidget
*widget
, gboolean show
);
169 void ui_widget_modify_font_from_string(GtkWidget
*wid
, const gchar
*str
);
171 void ui_menu_sort_by_label(GtkMenu
*menu
);
173 gchar
*ui_menu_item_get_text(GtkMenuItem
*menu_item
);
175 GtkWidget
*ui_frame_new_with_alignment(const gchar
*label_text
, GtkWidget
**alignment
);
177 GtkWidget
*ui_dialog_vbox_new(GtkDialog
*dialog
);
179 GtkWidget
*ui_button_new_with_image(const gchar
*stock_id
, const gchar
*text
);
181 GtkWidget
*ui_image_menu_item_new(const gchar
*stock_id
, const gchar
*label
);
183 void ui_hbutton_box_copy_layout(GtkButtonBox
*master
, GtkButtonBox
*copy
);
185 void ui_combo_box_add_to_history(GtkComboBox
*combo
, const gchar
*text
);
187 void ui_combo_box_prepend_text_once(GtkComboBox
*combo
, const gchar
*text
);
189 GtkWidget
*ui_path_box_new(const gchar
*title
, GtkFileChooserAction action
, GtkEntry
*entry
);
191 void ui_setup_open_button_callback(GtkWidget
*open_btn
, const gchar
*title
,
192 GtkFileChooserAction action
, GtkEntry
*entry
);
194 void ui_table_add_row(GtkTable
*table
, gint row
, ...) G_GNUC_NULL_TERMINATED
;
196 void ui_auto_separator_add_ref(GeanyAutoSeparator
*autosep
, GtkWidget
*item
);
198 void ui_widget_set_tooltip_text(GtkWidget
*widget
, const gchar
*text
);
200 GtkWidget
*ui_lookup_widget(GtkWidget
*widget
, const gchar
*widget_name
);
202 void ui_widget_set_sensitive(GtkWidget
*widget
, gboolean set
);
204 void ui_entry_add_clear_icon(GtkEntry
*entry
);
206 void ui_editable_insert_text_callback(GtkEditable
*editable
, gchar
*new_text
,
207 gint new_text_len
, gint
*position
, gpointer data
);
209 #define ui_label_new_bold(text)\
210 ui_label_set_markup(GTK_LABEL(gtk_label_new(NULL)), "<b>%s</b>", text);
212 GtkWidget
*ui_label_set_markup(GtkLabel
*label
, const gchar
*format
, ...) G_GNUC_PRINTF(2, 3);
214 /* End of general widget functions */
219 void ui_init_toolbar_widgets(void);
221 void ui_init_stock_items(void);
223 void ui_add_config_file_menu_item(const gchar
*real_path
, const gchar
*label
,
224 GtkContainer
*parent
);
226 void ui_menu_add_document_items(GtkMenu
*menu
, GeanyDocument
*active
, GCallback callback
);
229 void ui_set_statusbar(gboolean log
, const gchar
*format
, ...) G_GNUC_PRINTF (2, 3);
231 void ui_update_statusbar(GeanyDocument
*doc
, gint pos
);
234 /* This sets the window title according to the current filename. */
235 void ui_set_window_title(GeanyDocument
*doc
);
237 void ui_set_editor_font(const gchar
*font_name
);
239 void ui_set_fullscreen(void);
242 void ui_update_popup_reundo_items(GeanyDocument
*doc
);
244 void ui_update_popup_copy_items(GeanyDocument
*doc
);
246 void ui_update_popup_goto_items(gboolean enable
);
249 void ui_update_menu_copy_items(GeanyDocument
*doc
);
251 void ui_update_insert_include_item(GeanyDocument
*doc
, gint item
);
253 void ui_update_fold_items(void);
256 void ui_create_insert_menu_items(void);
258 void ui_create_insert_date_menu_items(void);
261 void ui_save_buttons_toggle(gboolean enable
);
263 void ui_document_buttons_update(void);
266 void ui_sidebar_show_hide(void);
268 void ui_document_show_hide(GeanyDocument
*doc
);
270 void ui_set_search_entry_background(GtkWidget
*widget
, gboolean success
);
273 GdkPixbuf
*ui_new_pixbuf_from_inline(gint img
);
275 GtkWidget
*ui_new_image_from_inline(gint img
);
278 void ui_create_recent_menus(void);
280 void ui_add_recent_file(const gchar
*utf8_filename
);
282 void ui_add_recent_project_file(const gchar
*utf8_filename
);
285 void ui_update_tab_status(GeanyDocument
*doc
);
288 typedef gboolean
TVMatchCallback(guint
);
290 gboolean
ui_tree_view_find_next(GtkTreeView
*treeview
, TVMatchCallback cb
);
292 gboolean
ui_tree_view_find_previous(GtkTreeView
*treeview
, TVMatchCallback cb
);
295 void ui_statusbar_showhide(gboolean state
);
297 void ui_add_document_sensitive(GtkWidget
*widget
);
299 void ui_toggle_editor_features(GeanyUIEditorFeatures feature
);
301 void ui_update_view_editor_menu_items(void);
303 void ui_progress_bar_start(const gchar
*text
);
305 void ui_progress_bar_stop(void);
307 void ui_swap_sidebar_pos(void);
309 gboolean
ui_is_keyval_enter_or_return(guint keyval
);
311 gint
ui_get_gtk_settings_integer(const gchar
*property_name
, gint default_value
);