2006-09-05 14:24:47 +00:00
|
|
|
/*
|
|
|
|
* ui_utils.h - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2010-01-01 22:55:18 +00:00
|
|
|
* Copyright 2006-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2006-09-05 14:24:47 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GEANY_UI_UTILS_H
|
|
|
|
#define GEANY_UI_UTILS_H 1
|
|
|
|
|
2010-03-12 18:15:48 +00:00
|
|
|
/** Sets a name to lookup @a widget from @a owner.
|
2008-12-28 17:25:09 +00:00
|
|
|
* @param owner Usually a @c GtkWindow.
|
|
|
|
* @param widget Widget.
|
|
|
|
* @param widget_name Name.
|
2009-01-30 18:53:23 +00:00
|
|
|
* @see ui_lookup_widget().
|
|
|
|
*
|
|
|
|
* @since 0.16
|
|
|
|
**/
|
2008-12-28 17:25:09 +00:00
|
|
|
#define ui_hookup_widget(owner, widget, widget_name) \
|
|
|
|
g_object_set_data_full(G_OBJECT(owner), widget_name, \
|
|
|
|
g_object_ref(widget), (GDestroyNotify)g_object_unref);
|
|
|
|
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
typedef struct GeanyInterfacePrefs
|
|
|
|
{
|
|
|
|
gboolean sidebar_symbol_visible;
|
|
|
|
gboolean sidebar_openfiles_visible;
|
|
|
|
gchar *editor_font;
|
|
|
|
gchar *tagbar_font;
|
|
|
|
gchar *msgwin_font;
|
|
|
|
gboolean show_notebook_tabs;
|
|
|
|
gint tab_pos_editor;
|
|
|
|
gint tab_pos_msgwin;
|
|
|
|
gint tab_pos_sidebar;
|
|
|
|
gboolean statusbar_visible;
|
|
|
|
gboolean show_symbol_list_expanders;
|
2008-12-11 16:29:54 +00:00
|
|
|
gboolean notebook_double_click_hides_widgets;
|
2009-01-14 19:19:08 +00:00
|
|
|
gboolean highlighting_invert_all;
|
2009-10-23 16:18:05 +00:00
|
|
|
gint sidebar_pos;
|
2009-12-20 20:07:52 +00:00
|
|
|
gboolean msgwin_status_visible;
|
|
|
|
gboolean msgwin_compiler_visible;
|
|
|
|
gboolean msgwin_messages_visible;
|
|
|
|
gboolean msgwin_scribble_visible;
|
2010-05-16 18:22:24 +00:00
|
|
|
gboolean use_native_windows_dialogs; /* only used on Windows */
|
2010-05-22 19:40:12 +00:00
|
|
|
gboolean compiler_tab_autoscroll;
|
2008-05-16 12:08:39 +00:00
|
|
|
}
|
|
|
|
GeanyInterfacePrefs;
|
|
|
|
|
|
|
|
extern GeanyInterfacePrefs interface_prefs;
|
|
|
|
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
/** Important widgets in the main window. */
|
|
|
|
typedef struct GeanyMainWidgets
|
|
|
|
{
|
|
|
|
GtkWidget *window; /**< Main window. */
|
|
|
|
GtkWidget *toolbar; /**< Main toolbar. */
|
|
|
|
GtkWidget *sidebar_notebook; /**< Sidebar notebook. */
|
|
|
|
GtkWidget *notebook; /**< Document notebook. */
|
|
|
|
GtkWidget *editor_menu; /**< Popup editor menu. */
|
|
|
|
GtkWidget *tools_menu; /**< Most plugins add menu items to the Tools menu. */
|
2009-01-27 20:19:43 +00:00
|
|
|
GtkWidget *progressbar; /**< Progress bar widget in the status bar to show
|
|
|
|
progress of various actions.
|
|
|
|
See ui_progress_bar_start() for details. */
|
2008-05-22 14:41:28 +00:00
|
|
|
}
|
|
|
|
GeanyMainWidgets;
|
|
|
|
|
|
|
|
extern GeanyMainWidgets main_widgets;
|
|
|
|
|
|
|
|
|
2007-08-23 11:34:06 +00:00
|
|
|
/* User Interface settings not shown in the Prefs dialog. */
|
|
|
|
typedef struct UIPrefs
|
|
|
|
{
|
|
|
|
/* State of the main window when Geany was closed */
|
2008-02-27 13:17:29 +00:00
|
|
|
gint geometry[5]; /* 0:x, 1:y, 2:width, 3:height, flag for maximized state */
|
2007-08-23 11:34:06 +00:00
|
|
|
gboolean fullscreen;
|
|
|
|
gboolean sidebar_visible;
|
2009-04-27 19:30:29 +00:00
|
|
|
gint sidebar_page;
|
2007-08-23 11:34:06 +00:00
|
|
|
gboolean msgwindow_visible;
|
2009-01-28 17:01:32 +00:00
|
|
|
gboolean allow_always_save; /* if set, files can always be saved, even if unchanged */
|
2007-08-23 11:34:06 +00:00
|
|
|
|
|
|
|
/* Menu-item related data */
|
|
|
|
GQueue *recent_queue;
|
2009-04-05 14:14:29 +00:00
|
|
|
GQueue *recent_projects_queue;
|
2007-08-23 11:34:06 +00:00
|
|
|
gchar *custom_date_format;
|
|
|
|
gchar **custom_commands;
|
|
|
|
}
|
|
|
|
UIPrefs;
|
|
|
|
|
|
|
|
extern UIPrefs ui_prefs;
|
|
|
|
|
|
|
|
|
|
|
|
/* Less commonly used widgets */
|
|
|
|
typedef struct UIWidgets
|
|
|
|
{
|
|
|
|
/* menu widgets */
|
|
|
|
GtkWidget *toolbar_menu;
|
|
|
|
GtkWidget *recent_files_menuitem;
|
2008-12-06 11:10:06 +00:00
|
|
|
GtkWidget *recent_files_menu_menubar;
|
2007-11-17 14:04:27 +00:00
|
|
|
GtkWidget *print_page_setup;
|
2009-04-05 14:14:29 +00:00
|
|
|
GtkWidget *recent_projects_menuitem;
|
|
|
|
GtkWidget *recent_projects_menu_menubar;
|
2007-08-23 11:34:06 +00:00
|
|
|
|
|
|
|
/* dialogs */
|
|
|
|
GtkWidget *open_colorsel;
|
|
|
|
GtkWidget *open_fontsel;
|
|
|
|
GtkWidget *open_filesel;
|
|
|
|
GtkWidget *save_filesel;
|
|
|
|
GtkWidget *prefs_dialog;
|
2008-05-22 14:41:28 +00:00
|
|
|
|
|
|
|
/* other widgets not needed in GeanyMainWidgets */
|
|
|
|
GtkWidget *statusbar; /* use ui_set_statusbar() to set */
|
2007-08-23 11:34:06 +00:00
|
|
|
}
|
|
|
|
UIWidgets;
|
|
|
|
|
|
|
|
extern UIWidgets ui_widgets;
|
|
|
|
|
|
|
|
|
2008-10-13 12:38:32 +00:00
|
|
|
/* The following block of types & functions are more generic and closely related to
|
2007-07-13 15:54:16 +00:00
|
|
|
* certain GTK+ widgets. */
|
|
|
|
|
2008-10-13 12:38:32 +00:00
|
|
|
typedef struct GeanyAutoSeparator
|
|
|
|
{
|
|
|
|
GtkWidget *widget; /* e.g. GtkSeparatorToolItem, GtkSeparatorMenuItem */
|
|
|
|
gint ref_count; /* set to zero initially */
|
|
|
|
}
|
|
|
|
GeanyAutoSeparator;
|
|
|
|
|
|
|
|
|
2008-12-07 19:12:08 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GEANY_EDITOR_SHOW_MARKERS_MARGIN,
|
|
|
|
GEANY_EDITOR_SHOW_LINE_NUMBERS,
|
|
|
|
GEANY_EDITOR_SHOW_WHITE_SPACE,
|
|
|
|
GEANY_EDITOR_SHOW_INDENTATION_GUIDES,
|
|
|
|
GEANY_EDITOR_SHOW_LINE_ENDINGS
|
|
|
|
}
|
|
|
|
GeanyUIEditorFeatures;
|
|
|
|
|
|
|
|
|
2008-12-08 21:58:11 +00:00
|
|
|
#define GEANY_STOCK_SAVE_ALL "geany-save-all"
|
2008-12-09 20:31:38 +00:00
|
|
|
#define GEANY_STOCK_CLOSE_ALL "geany-close-all"
|
2009-01-17 17:59:20 +00:00
|
|
|
#define GEANY_STOCK_BUILD "geany-build"
|
|
|
|
|
2008-12-08 21:58:11 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GEANY_IMAGE_LOGO,
|
|
|
|
GEANY_IMAGE_SAVE_ALL,
|
2009-01-17 17:59:20 +00:00
|
|
|
GEANY_IMAGE_CLOSE_ALL,
|
|
|
|
GEANY_IMAGE_BUILD
|
2008-12-08 21:58:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-07-13 15:54:16 +00:00
|
|
|
void ui_widget_show_hide(GtkWidget *widget, gboolean show);
|
|
|
|
|
|
|
|
void ui_widget_modify_font_from_string(GtkWidget *wid, const gchar *str);
|
|
|
|
|
2009-04-08 12:25:47 +00:00
|
|
|
void ui_menu_sort_by_label(GtkMenu *menu);
|
|
|
|
|
2008-05-13 17:18:14 +00:00
|
|
|
gchar *ui_menu_item_get_text(GtkMenuItem *menu_item);
|
|
|
|
|
2007-07-13 15:54:16 +00:00
|
|
|
GtkWidget *ui_frame_new_with_alignment(const gchar *label_text, GtkWidget **alignment);
|
|
|
|
|
|
|
|
GtkWidget *ui_dialog_vbox_new(GtkDialog *dialog);
|
|
|
|
|
|
|
|
GtkWidget *ui_button_new_with_image(const gchar *stock_id, const gchar *text);
|
|
|
|
|
2008-11-21 13:34:58 +00:00
|
|
|
GtkWidget *ui_image_menu_item_new(const gchar *stock_id, const gchar *label);
|
|
|
|
|
2007-07-13 15:54:16 +00:00
|
|
|
void ui_hbutton_box_copy_layout(GtkButtonBox *master, GtkButtonBox *copy);
|
|
|
|
|
2010-06-18 12:20:15 +00:00
|
|
|
void ui_combo_box_add_to_history(GtkComboBoxEntry *combo_entry,
|
|
|
|
const gchar *text, gint history_len);
|
2007-07-13 15:54:16 +00:00
|
|
|
|
2008-11-16 17:53:55 +00:00
|
|
|
void ui_combo_box_prepend_text_once(GtkComboBox *combo, const gchar *text);
|
|
|
|
|
2007-07-13 15:54:16 +00:00
|
|
|
GtkWidget *ui_path_box_new(const gchar *title, GtkFileChooserAction action, GtkEntry *entry);
|
|
|
|
|
|
|
|
void ui_setup_open_button_callback(GtkWidget *open_btn, const gchar *title,
|
|
|
|
GtkFileChooserAction action, GtkEntry *entry);
|
|
|
|
|
|
|
|
void ui_table_add_row(GtkTable *table, gint row, ...) G_GNUC_NULL_TERMINATED;
|
|
|
|
|
2008-10-13 12:38:32 +00:00
|
|
|
void ui_auto_separator_add_ref(GeanyAutoSeparator *autosep, GtkWidget *item);
|
|
|
|
|
2008-12-02 18:33:41 +00:00
|
|
|
void ui_widget_set_tooltip_text(GtkWidget *widget, const gchar *text);
|
|
|
|
|
|
|
|
GtkWidget *ui_lookup_widget(GtkWidget *widget, const gchar *widget_name);
|
|
|
|
|
2008-12-06 11:10:06 +00:00
|
|
|
void ui_widget_set_sensitive(GtkWidget *widget, gboolean set);
|
|
|
|
|
2009-09-21 16:46:16 +00:00
|
|
|
void ui_entry_add_clear_icon(GtkEntry *entry);
|
2009-01-27 19:31:45 +00:00
|
|
|
|
2010-05-09 15:48:29 +00:00
|
|
|
void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_text,
|
|
|
|
gint new_text_len, gint *position, gpointer data);
|
2009-09-21 16:21:03 +00:00
|
|
|
|
|
|
|
#define ui_label_new_bold(text)\
|
|
|
|
ui_label_set_markup(GTK_LABEL(gtk_label_new(NULL)), "<b>%s</b>", text);
|
|
|
|
|
|
|
|
GtkWidget *ui_label_set_markup(GtkLabel *label, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
|
|
|
|
|
2009-04-08 12:25:47 +00:00
|
|
|
/* End of general widget functions */
|
2007-07-13 15:54:16 +00:00
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_init(void);
|
2007-07-20 12:06:51 +00:00
|
|
|
|
2010-07-09 17:15:16 +00:00
|
|
|
void ui_init_prefs(void);
|
|
|
|
|
2010-07-08 16:59:11 +00:00
|
|
|
void ui_finalize(void);
|
|
|
|
|
2009-06-20 16:51:32 +00:00
|
|
|
void ui_init_toolbar_widgets(void);
|
|
|
|
|
2009-06-20 16:53:28 +00:00
|
|
|
void ui_init_stock_items(void);
|
|
|
|
|
2008-11-26 13:15:53 +00:00
|
|
|
void ui_add_config_file_menu_item(const gchar *real_path, const gchar *label,
|
|
|
|
GtkContainer *parent);
|
|
|
|
|
2009-10-13 17:14:25 +00:00
|
|
|
void ui_menu_add_document_items(GtkMenu *menu, GeanyDocument *active, GCallback callback);
|
|
|
|
|
2007-07-20 12:06:51 +00:00
|
|
|
|
2007-10-24 10:52:48 +00:00
|
|
|
void ui_set_statusbar(gboolean log, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_update_statusbar(GeanyDocument *doc, gint pos);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* This sets the window title according to the current filename. */
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_set_window_title(GeanyDocument *doc);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
void ui_set_editor_font(const gchar *font_name);
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_set_fullscreen(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_update_popup_reundo_items(GeanyDocument *doc);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_update_popup_copy_items(GeanyDocument *doc);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
void ui_update_popup_goto_items(gboolean enable);
|
|
|
|
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_update_menu_copy_items(GeanyDocument *doc);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_update_insert_include_item(GeanyDocument *doc, gint item);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_update_fold_items(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_create_insert_menu_items(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_create_insert_date_menu_items(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ui_save_buttons_toggle(gboolean enable);
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_document_buttons_update(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void ui_sidebar_show_hide(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_document_show_hide(GeanyDocument *doc);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2009-02-27 14:05:50 +00:00
|
|
|
void ui_set_search_entry_background(GtkWidget *widget, gboolean success);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
2008-12-09 20:31:38 +00:00
|
|
|
GdkPixbuf *ui_new_pixbuf_from_inline(gint img);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-12-09 20:31:38 +00:00
|
|
|
GtkWidget *ui_new_image_from_inline(gint img);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
|
|
|
|
2009-04-05 14:14:29 +00:00
|
|
|
void ui_create_recent_menus(void);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2006-09-09 14:36:15 +00:00
|
|
|
void ui_add_recent_file(const gchar *utf8_filename);
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2009-04-05 14:14:29 +00:00
|
|
|
void ui_add_recent_project_file(const gchar *utf8_filename);
|
|
|
|
|
2006-09-05 14:24:47 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
void ui_update_tab_status(GeanyDocument *doc);
|
2006-12-05 10:37:36 +00:00
|
|
|
|
2006-12-08 15:50:10 +00:00
|
|
|
|
2010-02-28 14:57:06 +00:00
|
|
|
typedef gboolean TVMatchCallback(guint);
|
2006-12-08 15:50:10 +00:00
|
|
|
|
|
|
|
gboolean ui_tree_view_find_next(GtkTreeView *treeview, TVMatchCallback cb);
|
|
|
|
|
2008-06-25 17:38:31 +00:00
|
|
|
gboolean ui_tree_view_find_previous(GtkTreeView *treeview, TVMatchCallback cb);
|
|
|
|
|
2006-12-13 15:18:49 +00:00
|
|
|
|
2007-05-04 16:59:00 +00:00
|
|
|
void ui_statusbar_showhide(gboolean state);
|
|
|
|
|
2008-10-14 14:49:41 +00:00
|
|
|
void ui_add_document_sensitive(GtkWidget *widget);
|
|
|
|
|
2008-12-07 19:12:08 +00:00
|
|
|
void ui_toggle_editor_features(GeanyUIEditorFeatures feature);
|
|
|
|
|
|
|
|
void ui_update_view_editor_menu_items(void);
|
|
|
|
|
2009-01-27 20:19:43 +00:00
|
|
|
void ui_progress_bar_start(const gchar *text);
|
|
|
|
|
|
|
|
void ui_progress_bar_stop(void);
|
|
|
|
|
2009-10-23 16:18:05 +00:00
|
|
|
void ui_swap_sidebar_pos(void);
|
|
|
|
|
2010-03-07 19:33:15 +00:00
|
|
|
gboolean ui_is_keyval_enter_or_return(guint keyval);
|
|
|
|
|
2010-04-11 21:56:08 +00:00
|
|
|
gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value);
|
|
|
|
|
2006-09-05 14:24:47 +00:00
|
|
|
#endif
|