geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ui_utils.h File Reference

User Interface general utility functions. More...

#include "geany.h"
#include "document.h"
#include "gtkcompat.h"
Include dependency graph for ui_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GeanyInterfacePrefs
 Interface preferences. More...
 
struct  GeanyMainWidgets
 Important widgets in the main window. More...
 

Macros

#define ui_hookup_widget(owner, widget, widget_name)
 Sets a name to lookup widget from owner. More...
 
#define GEANY_STOCK_SAVE_ALL   "geany-save-all"
 
#define GEANY_STOCK_CLOSE_ALL   "geany-close-all"
 
#define GEANY_STOCK_BUILD   "geany-build"
 

Typedefs

typedef struct GeanyInterfacePrefs GeanyInterfacePrefs
 Interface preferences. More...
 
typedef struct GeanyMainWidgets GeanyMainWidgets
 Important widgets in the main window. More...
 

Functions

GtkWidget * ui_dialog_vbox_new (GtkDialog *dialog)
 Makes a fixed border for dialogs without increasing the button box border. More...
 
void ui_set_statusbar (gboolean log, const gchar *format,...)
 Displays text on the statusbar. More...
 
void ui_table_add_row (GtkTable *table, gint row,...) G_GNUC_NULL_TERMINATED
 Packs all GtkWidgets passed after the row argument into a table, using one widget per cell. More...
 
GtkWidget * ui_path_box_new (const gchar *title, GtkFileChooserAction action, GtkEntry *entry)
 Creates a GtkHBox with entry packed into it and an open button which runs a file chooser, replacing entry text (if successful) with the path returned from the GtkFileChooser. More...
 
GtkWidget * ui_button_new_with_image (const gchar *stock_id, const gchar *text)
 Creates a GtkButton with custom text and a stock image similar to gtk_button_new_from_stock(). More...
 
void ui_add_document_sensitive (GtkWidget *widget)
 Adds a widget to the list of widgets that should be set sensitive/insensitive when some documents are present/no documents are open. More...
 
GtkWidget * ui_image_menu_item_new (const gchar *stock_id, const gchar *label)
 Creates a GtkImageMenuItem with a stock image and a custom label. More...
 
GtkWidget * ui_lookup_widget (GtkWidget *widget, const gchar *widget_name)
 Returns a widget from a name in a component, usually created by Glade. More...
 
void ui_progress_bar_start (const gchar *text)
 Starts a constantly pulsing progressbar in the right corner of the statusbar (if the statusbar is visible). More...
 
void ui_progress_bar_stop (void)
 Stops a running progress bar and hides the widget again. More...
 
void ui_entry_add_clear_icon (GtkEntry *entry)
 Adds a small clear icon to the right end of the passed entry. More...
 
void ui_menu_add_document_items (GtkMenu *menu, GeanyDocument *active, GCallback callback)
  Adds a list of document items to menu. More...
 
void ui_menu_add_document_items_sorted (GtkMenu *menu, GeanyDocument *active, GCallback callback, GCompareFunc sort_func)
  Adds a list of document items to menu. More...
 
void ui_widget_modify_font_from_string (GtkWidget *wid, const gchar *str)
 Modifies the font of a widget using gtk_widget_modify_font(). More...
 
gboolean ui_is_keyval_enter_or_return (guint keyval)
 Checks whether the passed keyval is the Enter or Return key. More...
 
gint ui_get_gtk_settings_integer (const gchar *property_name, gint default_value)
 Reads an integer from the GTK default settings registry (see http://library.gnome.org/devel/gtk/stable/GtkSettings.html). More...
 
void ui_combo_box_add_to_history (GtkComboBoxText *combo_entry, const gchar *text, gint history_len)
 Prepends text to the drop down list, removing a duplicate element in the list if found. More...
 
const gchar * ui_lookup_stock_label (const gchar *stock_id)
 Finds the label text associated with stock_id. More...
 
void ui_tree_view_set_tooltip_text_column (GtkTreeView *tree_view, gint column)
 Adds text tooltips to a tree view. More...
 
GtkWidget * ui_frame_new_with_alignment (const gchar *label_text, GtkWidget **alignment)
 Creates a GNOME HIG-style frame (with no border and indented child alignment). More...
 
void ui_widget_set_tooltip_text (GtkWidget *widget, const gchar *text)
 Sets text as the contents of the tooltip for widget. More...
 

Detailed Description

User Interface general utility functions.

Definition in file ui_utils.h.

Macro Definition Documentation

◆ GEANY_STOCK_BUILD

#define GEANY_STOCK_BUILD   "geany-build"

Definition at line 98 of file ui_utils.h.

◆ GEANY_STOCK_CLOSE_ALL

#define GEANY_STOCK_CLOSE_ALL   "geany-close-all"

Definition at line 97 of file ui_utils.h.

◆ GEANY_STOCK_SAVE_ALL

#define GEANY_STOCK_SAVE_ALL   "geany-save-all"

Definition at line 96 of file ui_utils.h.

◆ ui_hookup_widget

#define ui_hookup_widget (   owner,
  widget,
  widget_name 
)
Value:
g_object_set_data_full(G_OBJECT(owner), widget_name, \
g_object_ref(widget), (GDestroyNotify)g_object_unref);

Sets a name to lookup widget from owner.

Parameters
ownerUsually a window, dialog or popup menu.
widgetWidget.
widget_nameName.
See also
ui_lookup_widget().
Since
0.16

Definition at line 39 of file ui_utils.h.

Typedef Documentation

◆ GeanyInterfacePrefs

Interface preferences.

◆ GeanyMainWidgets

Important widgets in the main window.

Accessed by geany->main_widgets.

Function Documentation

◆ ui_add_document_sensitive()

void ui_add_document_sensitive ( GtkWidget *  widget)

Adds a widget to the list of widgets that should be set sensitive/insensitive when some documents are present/no documents are open.

It will be removed when the widget is destroyed.

Parameters
widgetThe widget to add.
Since
0.15

Definition at line 976 of file ui_utils.c.

References main_widgets, GeanyMainWidgets::notebook, NULL, on_doc_sensitive_widget_destroy(), ui_widget_set_sensitive(), and widgets.

Referenced by demo_init(), plugin_init(), and plugin_load().

◆ ui_button_new_with_image()

GtkWidget * ui_button_new_with_image ( const gchar *  stock_id,
const gchar *  text 
)

Creates a GtkButton with custom text and a stock image similar to gtk_button_new_from_stock().

Parameters
stock_idA GTK_STOCK_NAME string.
textButton label text, can include mnemonics.
Returns
(transfer: floating) The new GtkButton.

Definition at line 1552 of file ui_utils.c.

References text.

Referenced by create_find_dialog(), project_new(), run_unsaved_dialog(), and tb_editor_create_dialog().

◆ ui_combo_box_add_to_history()

void ui_combo_box_add_to_history ( GtkComboBoxText *  combo_entry,
const gchar *  text,
gint  history_len 
)

Prepends text to the drop down list, removing a duplicate element in the list if found.

Also ensures there are <= history_len elements.

Parameters
combo_entry.
text Text to add, or NULL for current entry text.
history_lenMax number of items, or 0 for default.

Definition at line 1697 of file ui_utils.c.

References text, and tree_model_find_text().

Referenced by on_filter_activate(), on_find_dialog_response(), on_find_in_files_dialog_response(), on_input_dialog_response(), on_replace_dialog_response(), refresh(), and search_show_find_in_files_dialog_full().

◆ ui_dialog_vbox_new()

GtkWidget * ui_dialog_vbox_new ( GtkDialog *  dialog)

◆ ui_entry_add_clear_icon()

void ui_entry_add_clear_icon ( GtkEntry *  entry)

Adds a small clear icon to the right end of the passed entry.

A callback to clear the contents of the GtkEntry is automatically added.

Parameters
entryThe GtkEntry object to which the icon should be attached.
Since
0.16

Definition at line 1604 of file ui_utils.c.

References entry, entry_clear_icon_release_cb(), and NULL.

Referenced by create_custom_widget(), create_fif_dialog(), create_find_dialog(), create_properties_dialog(), create_replace_dialog(), dialogs_show_input_full(), dialogs_show_input_numeric(), geany_entry_action_create_tool_item(), make_filterbar(), pm_show_dialog(), prefs_show_dialog(), and project_new().

◆ ui_frame_new_with_alignment()

GtkWidget * ui_frame_new_with_alignment ( const gchar *  label_text,
GtkWidget **  alignment 
)

Creates a GNOME HIG-style frame (with no border and indented child alignment).

Parameters
label_textThe label text.
alignmentAn address to store the alignment widget pointer.
Returns
(transfer: floating) The frame widget, setting the alignment container for packing child widgets.
Deprecated:
1.29: Use GTK API directly

Definition at line 1475 of file ui_utils.c.

References gtk_container_add(), label, NULL, and ui_label_new_bold().

◆ ui_get_gtk_settings_integer()

gint ui_get_gtk_settings_integer ( const gchar *  property_name,
gint  default_value 
)

Reads an integer from the GTK default settings registry (see http://library.gnome.org/devel/gtk/stable/GtkSettings.html).

Parameters
property_nameThe property to read.
default_valueThe default value in case the value could not be read.
Returns
The value for the property if it exists, otherwise the default_value.
Since
0.19

Definition at line 3022 of file ui_utils.c.

References NULL.

Referenced by toolbar_notify_style_cb(), toolbar_set_icon_size(), and toolbar_set_icon_style().

◆ ui_image_menu_item_new()

GtkWidget * ui_image_menu_item_new ( const gchar *  stock_id,
const gchar *  label 
)

Creates a GtkImageMenuItem with a stock image and a custom label.

Parameters
stock_idStock image ID, e.g. GTK_STOCK_OPEN.
labelMenu item label, can include mnemonics.
Returns
(transfer: floating) The new GtkImageMenuItem.
Since
0.16

Definition at line 1574 of file ui_utils.c.

References label.

Referenced by build_init(), create_openfiles_popup_menu(), create_popup_menu(), create_taglist_popup_menu(), kb_show_popup_menu(), and show_tab_bar_popup_menu().

◆ ui_is_keyval_enter_or_return()

gboolean ui_is_keyval_enter_or_return ( guint  keyval)

Checks whether the passed keyval is the Enter or Return key.

There are three different Enter/Return key values (GDK_KEY_Return, GDK_KEY_ISO_Enter, GDK_KEY_KP_Enter). This is just a convenience function.

Parameters
keyvalA keyval.
Returns
TRUE if keyval is the one of the Enter/Return key values, otherwise FALSE.
Since
0.19

Definition at line 3009 of file ui_utils.c.

Referenced by on_key_press(), on_msgwin_key_press_event(), and sidebar_key_press_cb().

◆ ui_lookup_stock_label()

const gchar * ui_lookup_stock_label ( const gchar *  stock_id)

Finds the label text associated with stock_id.

Parameters
stock_idstock_id to lookup e.g. GTK_STOCK_OPEN.
Returns
The label text for stock
Since
Geany 1.22

Definition at line 3114 of file ui_utils.c.

References NULL.

Referenced by init_default_kb(), and ui_tool_button_new().

◆ ui_lookup_widget()

GtkWidget * ui_lookup_widget ( GtkWidget *  widget,
const gchar *  widget_name 
)

Returns a widget from a name in a component, usually created by Glade.

Call it with the toplevel widget in the component (i.e. a window/dialog), or alternatively any widget in the component, and the name of the widget you want returned.

Parameters
widgetWidget with the widget_name property set.
widget_nameName to lookup.
Returns
(transfer: none) The widget found.
See also
ui_hookup_widget().
Since
0.16

Definition at line 2743 of file ui_utils.c.

References NULL.

Referenced by add_kb(), apply_settings(), build_keybinding(), cb_func_editor_action(), cb_func_insert_action(), cb_func_menu_fullscreen(), cb_func_menu_messagewindow(), configuration_apply_settings(), create_build_menu(), create_config_files_menu(), create_file_template_menu(), create_properties_dialog(), create_set_filetype_menu(), dialogs_show_file_properties(), document_set_encoding(), encodings_init(), init_recent_files(), kb_init_tree(), key_dialog_show_prefs(), main_init(), msgwin_init(), msgwin_show_hide(), on_edit1_select(), on_editor_menu_hide(), on_editor_menu_show(), on_enable_plugins_toggled(), on_file_open_show_hidden_notify(), on_file_save_dialog_response(), on_find_replace_checkbutton_toggled(), on_hide_toolbar1_activate(), on_load_settings(), on_menu_project1_activate(), on_menu_toggle_all_additional_widgets1_activate(), on_open_encoding_toggled(), on_prefs_dialog_response(), on_prefs_print_page_header_toggled(), on_prefs_print_radio_button_toggled(), on_search1_activate(), on_show_notebook_tabs_toggled(), on_show_symbol_list_toggled(), on_sidebar_visible_toggled(), on_toolbar_show_toggled(), on_use_folding_toggled(), on_window_state_event(), open_file_dialog_apply_settings(), open_file_dialog_handle_response(), open_preferences_help(), prefs_init_dialog(), prefs_show_dialog(), prepare_openfiles(), project_apply_prefs(), project_setup_prefs(), save_ui_prefs(), show_notebook_page(), show_project_properties(), toolbar_reload(), toolbar_show_hide(), toolbar_update_ui(), tools_create_insert_custom_command_menu_items(), ui_create_insert_date_menu_items(), ui_create_insert_menu_items(), ui_document_show_hide(), ui_init(), ui_sidebar_show_hide(), ui_swap_sidebar_pos(), ui_update_fold_items(), ui_update_view_editor_menu_items(), and update_config().

◆ ui_menu_add_document_items()

void ui_menu_add_document_items ( GtkMenu *  menu,
GeanyDocument active,
GCallback  callback 
)

Adds a list of document items to menu.

Parameters
menuMenu.
active Which document to highlight, or NULL.
callbackis used for each menu item's "activate" signal and will be passed the corresponding document pointer as user_data.
Warning
You should check doc->is_valid in the callback.
Since
0.19

Definition at line 2929 of file ui_utils.c.

References NULL, and ui_menu_add_document_items_sorted().

Referenced by on_doc_show_menu(), and show_tab_bar_popup_menu().

◆ ui_menu_add_document_items_sorted()

void ui_menu_add_document_items_sorted ( GtkMenu *  menu,
GeanyDocument active,
GCallback  callback,
GCompareFunc  compare_func 
)

Adds a list of document items to menu.

compare_func might be NULL to not sort the documents in the menu. In this case, the order of the document tabs is used.

See document_compare_by_display_name() for an example sort function.

Parameters
menuMenu.
active Which document to highlight, or NULL.
callbackis used for each menu item's "activate" signal and will be passed the corresponding document pointer as user_data.
compare_funcis used to sort the list. Might be NULL to not sort the list.
Warning
You should check doc->is_valid in the callback.
Since
0.21

Definition at line 2952 of file ui_utils.c.

References DOC_FILENAME, document_compare_by_tab_order(), document_get_status_widget_class(), documents, GeanyDocument::file_type, foreach_document, gtk_container_add(), GeanyFiletype::icon, main_widgets, GeanyMainWidgets::notebook, NULL, and ui_label_set_markup().

Referenced by ui_menu_add_document_items().

◆ ui_path_box_new()

GtkWidget * ui_path_box_new ( const gchar *  title,
GtkFileChooserAction  action,
GtkEntry *  entry 
)

Creates a GtkHBox with entry packed into it and an open button which runs a file chooser, replacing entry text (if successful) with the path returned from the GtkFileChooser.

Note
entry can be the child of an unparented widget, such as GtkComboBoxEntry.
Parameters
title The file chooser dialog title, or NULL.
actionThe mode of the file chooser.
entryCan be an unpacked GtkEntry, or the child of an unpacked widget, such as GtkComboBoxEntry.
Returns
(transfer: floating) The GtkHBox.

Definition at line 1917 of file ui_utils.c.

References entry, gtk_container_add(), NULL, path_entry, and ui_setup_open_button_callback().

Referenced by create_fif_dialog(), and project_new().

◆ ui_progress_bar_start()

void ui_progress_bar_start ( const gchar *  text)

Starts a constantly pulsing progressbar in the right corner of the statusbar (if the statusbar is visible).

This is a convenience function which adds a timer to pulse the progressbar constantly until ui_progress_bar_stop() is called. You can use this function when you have time consuming asynchronous operation and want to display some activity in the GUI and when you don't know about detailed progress steps. The progressbar widget is hidden by default when it is not active. This function and ui_progress_bar_stop() will show and hide it automatically for you.

You can also access the progressbar widget directly using geany->main_widgets->progressbar and use the GtkProgressBar API to set discrete fractions to display better progress information. In this case, you need to show and hide the widget yourself. You can find some example code in src/printing.c.

Parameters
text The text to be shown as the progress bar label or NULL to leave it empty.
Since
0.16

Definition at line 2822 of file ui_utils.c.

References interface_prefs, main_widgets, NULL, progress_bar_pulse(), progress_bar_timer_id, GeanyMainWidgets::progressbar, GeanyInterfacePrefs::statusbar_visible, and text.

Referenced by build_command(), and search_find_in_files().

◆ ui_progress_bar_stop()

void ui_progress_bar_stop ( void  )

Stops a running progress bar and hides the widget again.

Since
0.16

Definition at line 2842 of file ui_utils.c.

References main_widgets, progress_bar_timer_id, and GeanyMainWidgets::progressbar.

Referenced by build_exit_cb(), and search_finished().

◆ ui_set_statusbar()

void ui_set_statusbar ( gboolean  log,
const gchar *  format,
  ... 
)

Displays text on the statusbar.

Parameters
logWhether the message should be recorded in the Status window.
formatA printf -style string.

Definition at line 168 of file ui_utils.c.

References format, msgwin_status_add(), prefs, set_statusbar(), and GeanyPrefs::suppress_status_messages.

Referenced by auto_save(), backupcopy_create_dir_parts(), backupcopy_document_save_cb(), build_replace_placeholder(), build_run_cmd(), build_spawn_cmd(), check_single_selection(), compile_regex(), configuration_open_files(), document_apply_indent_settings(), document_find_text(), document_open_file_full(), document_save_file(), document_search_bar_find(), editor_set_indent(), get_mtime(), goto_compiler_file_line(), insert_date(), insert_multiline_comment(), instantsave_document_new_cb(), kill_process(), load_text_file(), main_lib(), main_reload_configuration(), msgwin_goto_messages_file_line(), on_build_next_error(), on_build_previous_error(), on_color_scheme_changed(), on_comments_function_activate(), on_context_action1_activate(), on_editor_notify(), on_find_dialog_response(), on_find_in_files_dialog_response(), on_menu_open_selected_file1_activate(), on_new_with_file_template(), on_next_message1_activate(), on_previous_message1_activate(), on_save_all1_activate(), open_cl_files(), open_external(), prepare_run_cmd(), project_close(), project_load_file(), read_file(), replace_in_session(), run_new_dialog(), search_find_in_files(), search_find_usage(), search_finished(), search_get_argv(), show_build_result_message(), show_project_properties(), show_replace_summary(), symbols_goto_tag(), symbols_show_load_tags_dialog(), tools_execute_custom_command(), ui_set_editor_font(), and write_data().

◆ ui_table_add_row()

void ui_table_add_row ( GtkTable *  table,
gint  row,
  ... 
)

Packs all GtkWidgets passed after the row argument into a table, using one widget per cell.

The first widget is not expanded as the table grows, as this is usually a label.

Parameters
table
rowThe row number of the table.

Definition at line 2066 of file ui_utils.c.

References NULL.

Referenced by project_new().

◆ ui_tree_view_set_tooltip_text_column()

void ui_tree_view_set_tooltip_text_column ( GtkTreeView *  tree_view,
gint  column 
)

Adds text tooltips to a tree view.

This is similar to gtk_tree_view_set_tooltip_column() but considers the column contents to be text, not markup – it uses gtk_tooltip_set_text() rather than gtk_tooltip_set_markup() to set the tooltip's value.

Warning
Unlike gtk_tree_view_set_tooltip_column() you currently cannot change or remove the tooltip column after it has been added. Trying to do so will probably give funky results.
Parameters
tree_viewThe tree view
columnThe column to get the tooltip from
Since
1.25 (API 223)

Definition at line 1876 of file ui_utils.c.

References ui_tree_view_query_tooltip_cb().

Referenced by cc_show_dialog_custom_commands(), prepare_file_view(), prepare_openfiles(), and prepare_taglist().

◆ ui_widget_modify_font_from_string()

void ui_widget_modify_font_from_string ( GtkWidget *  widget,
const gchar *  str 
)

Modifies the font of a widget using gtk_widget_modify_font().

Parameters
widgetThe widget.
strThe font name as expected by pango_font_description_from_string().

Definition at line 1894 of file ui_utils.c.

Referenced by msgwin_init(), on_prefs_font_choosed(), prepare_compiler_tree_view(), prepare_file_view(), prepare_msg_tree_view(), prepare_openfiles(), prepare_status_tree_view(), and prepare_taglist().

◆ ui_widget_set_tooltip_text()

void ui_widget_set_tooltip_text ( GtkWidget *  widget,
const gchar *  text 
)

Sets text as the contents of the tooltip for widget.

Parameters
widgetThe widget the tooltip should be set for.
textThe text for the tooltip.
Since
0.16
Deprecated:
0.21 use gtk_widget_set_tooltip_text() instead

Definition at line 2724 of file ui_utils.c.

References text.