Geany dev
Data Structures | Macros | Typedefs | Functions
ui_utils.h File Reference

User Interface general utility functions. More...

Data Structures

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...
 

Typedefs

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

Functions

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_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_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...
 
GtkWidget * ui_dialog_vbox_new (GtkDialog *dialog)
 Makes a fixed border for dialogs without increasing the button box border. More...
 
void ui_entry_add_clear_icon (GtkEntry *entry)
 Adds a small clear icon to the right end of the passed entry. 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...
 
gint ui_get_gtk_settings_integer (const gchar *property_name, gint default_value)
 Reads an integer from the GTK default settings registry (see https://docs.gtk.org/gtk3/class.Settings.html). 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...
 
gboolean ui_is_keyval_enter_or_return (guint keyval)
 Checks whether the passed keyval is the Enter or Return key. More...
 
const gchar * ui_lookup_stock_label (const gchar *stock_id)
 Finds the label text associated with stock_id. 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_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...
 
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...
 
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_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...
 
void ui_tree_view_set_tooltip_text_column (GtkTreeView *tree_view, gint column)
 Adds text tooltips to a tree view. 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...
 
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.

Macro Definition Documentation

◆ 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

Typedef Documentation

◆ 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

◆ 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.

◆ 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.

◆ ui_dialog_vbox_new()

GtkWidget * ui_dialog_vbox_new ( GtkDialog *  dialog)

Makes a fixed border for dialogs without increasing the button box border.

Parameters
dialogThe parent container for the GtkVBox.
Returns
(transfer: none) The packed GtkVBox.

◆ 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

◆ 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

◆ 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 https://docs.gtk.org/gtk3/class.Settings.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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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.

◆ 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

◆ ui_progress_bar_stop()

void ui_progress_bar_stop ( void  )

Stops a running progress bar and hides the widget again.

Since
0.16

◆ 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.

◆ 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.

◆ 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)

◆ 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().

◆ 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