Geany  0.20
Data Structures | Defines | Typedefs | Functions
ui_utils.h File Reference

User Interface general utility functions. More...

Data Structures

struct  GeanyMainWidgets
 Important widgets in the main window. More...

Defines

#define ui_hookup_widget(owner, widget, widget_name)
 Sets a name to lookup widget from owner.

Typedefs

typedef struct GeanyMainWidgets GeanyMainWidgets
 Important widgets in the main window.

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.
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().
void ui_combo_box_add_to_history (GtkComboBoxEntry *combo_entry, const gchar *text, gint history_len)
 Prepends text to the drop down list, removing a duplicate element in the list if found.
GtkWidget * ui_dialog_vbox_new (GtkDialog *dialog)
 Makes a fixed border for dialogs without increasing the button box border.
void ui_entry_add_clear_icon (GtkEntry *entry)
 Adds a small clear icon to the right end of the passed entry.
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).
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).
GtkWidget * ui_image_menu_item_new (const gchar *stock_id, const gchar *label)
 Creates a GtkImageMenuItem with a stock image and a custom label.
gboolean ui_is_keyval_enter_or_return (guint keyval)
 Checks whether the passed keyval is the Enter or Return key.
GtkWidget * ui_lookup_widget (GtkWidget *widget, const gchar *widget_name)
 Returns a widget from a name in a component, usually created by Glade.
void ui_menu_add_document_items (GtkMenu *menu, GeanyDocument *active, GCallback callback)
 Adds a list of document items to menu.
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.
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).
void ui_progress_bar_stop (void)
 Stops a running progress bar and hides the widget again.
void ui_set_statusbar (gboolean log, const gchar *format,...)
 Displays text on the statusbar.
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.
void ui_widget_modify_font_from_string (GtkWidget *wid, const gchar *str)
 Modifies the font of a widget using gtk_widget_modify_font().
void ui_widget_set_tooltip_text (GtkWidget *widget, const gchar *text)
 Sets text as the contents of the tooltip for widget.

Detailed Description

User Interface general utility functions.


Define Documentation

#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

Important widgets in the main window.

Accessed by geany->main_widgets.


Function Documentation

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
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:
The new GtkButton.
void ui_combo_box_add_to_history ( GtkComboBoxEntry *  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.
textText to add, or NULL for current entry text.
history_lenMax number of items, or 0 for default.
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:
The packed GtkVBox.
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.

This feature is only available with GTK 2.16 but implemented as a runtime check, so it is safe to just use this function, if the code is ran with older versions, nothing happens. If ran with GTK 2.16 or newer, the icon is displayed.

Parameters:
entryThe GtkEntry object to which the icon should be attached.
Since:
0.16
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:
The frame widget, setting the alignment container for packing child widgets.
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
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:
The new GtkImageMenuItem.
Since:
0.16
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_Return, GDK_ISO_Enter, GDK_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
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:
The widget found.
See also:
ui_hookup_widget().
Since:
0.16
void ui_menu_add_document_items ( GtkMenu *  menu,
GeanyDocument active,
GCallback  callback 
)

Adds a list of document items to menu.

Parameters:
menuMenu.
activeWhich 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
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:
titleThe 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:
The GtkHBox.
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:
textThe text to be shown as the progress bar label or NULL to leave it empty.
Since:
0.16
void ui_progress_bar_stop ( void  )

Stops a running progress bar and hides the widget again.

Since:
0.16
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.
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.
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().
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