dd ui_widget_set_tooltip_text() as a convenience function to easily set tooltips for widgets. It uses gtk_widget_set_tooltip_text() on GTK >= 2.12 otherwise the old tooltips API.Use ui_widget_set_tooltip_text().

Use ui_widget_set_tooltip_text() in the plugins.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3250 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-11-18 20:14:42 +00:00
parent ffc9c924b0
commit 81ffd05aa1
15 changed files with 109 additions and 113 deletions

View File

@ -8,6 +8,15 @@
Add note about the encoding box in the Find in Files dialog.
* src/document.c, src/document.h, src/notebook.c:
Show the full filename of a document as tooltip on the tab labels.
* src/dialogs.c, src/document.c, src/plugindata.h, src/plugins.c,
src/printing.c, src/project.c, src/search.c, src/ui_utils.c,
src/ui_utils.h, src/vte.c:
Add ui_widget_set_tooltip_text() as a convenience function to easily
set tooltips for widgets. It uses gtk_widget_set_tooltip_text() on
GTK >= 2.12 otherwise the old tooltips API.
* plugins/export.c, plugins/filebrowser.c, plugins/splitwindow.c,
plugins/vcdiff.c:
Use ui_widget_set_tooltip_text().
2008-11-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -158,7 +158,6 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
gboolean show_zoom_level_checkbox)
{
GtkWidget *dialog;
GtkTooltips *tooltips;
GeanyDocument *doc;
ExportInfo *exi;
@ -166,7 +165,6 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
return;
doc = p_document->get_current();
tooltips = GTK_TOOLTIPS(p_support->lookup_widget(geany->main_widgets->window, "tooltips"));
exi = g_new(ExportInfo, 1);
exi->doc = doc;
@ -191,8 +189,8 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
vbox = gtk_vbox_new(FALSE, 0);
check_zoom_level = gtk_check_button_new_with_mnemonic(_("_Use current zoom level"));
gtk_tooltips_set_tip(tooltips, check_zoom_level,
_("Renders the font size of the document together with the current zoom level."), NULL);
p_ui->widget_set_tooltip_text(check_zoom_level,
_("Renders the font size of the document together with the current zoom level."));
gtk_box_pack_start(GTK_BOX(vbox), check_zoom_level, FALSE, FALSE, 0);
gtk_widget_show_all(vbox);
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), vbox);

View File

@ -719,34 +719,28 @@ static void prepare_file_view(void)
static GtkWidget *make_toolbar(void)
{
GtkWidget *wid, *toolbar;
GtkTooltips *tooltips = GTK_TOOLTIPS(p_support->lookup_widget(
geany->main_widgets->window, "tooltips"));
toolbar = gtk_toolbar_new();
gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_GO_UP);
gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(wid), tooltips,
_("Up"), NULL);
p_ui->widget_set_tooltip_text(wid, _("Up"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_go_up), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(wid), tooltips,
_("Refresh"), NULL);
p_ui->widget_set_tooltip_text(wid, _("Refresh"));
g_signal_connect(wid, "clicked", G_CALLBACK(refresh), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(wid), tooltips,
_("Home"), NULL);
p_ui->widget_set_tooltip_text(wid, _("Home"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_go_home), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_JUMP_TO);
gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(wid), tooltips,
_("Set path from document"), NULL);
p_ui->widget_set_tooltip_text(wid, _("Set path from document"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_current_path), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
@ -754,7 +748,7 @@ static GtkWidget *make_toolbar(void)
gtk_container_add(GTK_CONTAINER(toolbar), wid);
wid = (GtkWidget *) gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(wid), tooltips, _("Clear the filter"), NULL);
p_ui->widget_set_tooltip_text(wid, _("Clear the filter"));
g_signal_connect(wid, "clicked", G_CALLBACK(on_clear_filter), NULL);
gtk_container_add(GTK_CONTAINER(toolbar), wid);
@ -986,7 +980,6 @@ on_configure_response(GtkDialog *dialog, gint response, gpointer user_data)
GtkWidget *plugin_configure(GtkDialog *dialog)
{
GtkWidget *label, *entry, *checkbox_of, *checkbox_hf, *vbox;
GtkTooltips *tooltips = gtk_tooltips_new();
vbox = gtk_vbox_new(FALSE, 6);
@ -998,11 +991,10 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
gtk_widget_show(entry);
if (open_cmd != NULL)
gtk_entry_set_text(GTK_ENTRY(entry), open_cmd);
gtk_tooltips_set_tip(tooltips, entry,
p_ui->widget_set_tooltip_text(entry,
_("The command to execute when using \"Open with\". You can use %f and %d wildcards.\n"
"%f will be replaced with the filename including full path\n"
"%d will be replaced with the path name of the selected file without the filename"),
NULL);
"%d will be replaced with the path name of the selected file without the filename"));
gtk_container_add(GTK_CONTAINER(vbox), entry);
pref_widgets.open_cmd_entry = entry;
@ -1015,10 +1007,9 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
checkbox_of = gtk_check_button_new_with_label(_("Hide object files"));
gtk_button_set_focus_on_click(GTK_BUTTON(checkbox_of), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox_of), hide_object_files);
gtk_tooltips_set_tip(tooltips, checkbox_of,
p_ui->widget_set_tooltip_text(checkbox_of,
_("Don't show generated object files in the file browser, this includes "
"*.o, *.obj. *.so, *.dll, *.a, *.lib"),
NULL);
"*.o, *.obj. *.so, *.dll, *.a, *.lib"));
gtk_box_pack_start(GTK_BOX(vbox), checkbox_of, FALSE, FALSE, 5);
pref_widgets.hide_objects_checkbox = checkbox_of;

View File

@ -215,12 +215,10 @@ static void set_state(enum State id)
static GtkWidget *create_tool_button(const gchar *label, const gchar *stock_id)
{
GtkToolItem *item;
GtkTooltips *tooltips = GTK_TOOLTIPS(p_support->lookup_widget(
geany->main_widgets->window, "tooltips"));
item = gtk_tool_button_new(NULL, label);
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item), stock_id);
gtk_tool_item_set_tooltip(item, tooltips, label, NULL);
p_ui->widget_set_tooltip_text(GTK_WIDGET(item), label);
return GTK_WIDGET(item);
}

View File

@ -281,7 +281,7 @@ static void show_output(const gchar *std_output, const gchar *utf8_name_prefix,
{
GeanyIndentType indent_type =
p_document->get_current()->editor->indent_type;
doc = p_document->find_by_filename(filename);
if (doc == NULL)
{
@ -502,9 +502,6 @@ void plugin_init(GeanyData *data)
{
GtkWidget *menu_vcdiff = NULL;
GtkWidget *menu_vcdiff_menu = NULL;
GtkTooltips *tooltips = NULL;
tooltips = gtk_tooltips_new();
menu_vcdiff = gtk_image_menu_item_new_with_mnemonic(_("_Version Diff"));
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_vcdiff);
@ -517,24 +514,23 @@ void plugin_init(GeanyData *data)
/* Single file */
menu_vcdiff_file = gtk_menu_item_new_with_mnemonic(_("From Current _File"));
gtk_container_add(GTK_CONTAINER (menu_vcdiff_menu), menu_vcdiff_file);
gtk_tooltips_set_tip (tooltips, menu_vcdiff_file,
_("Make a diff from the current active file"), NULL);
p_ui->widget_set_tooltip_text(menu_vcdiff_file, _("Make a diff from the current active file"));
g_signal_connect(menu_vcdiff_file, "activate", G_CALLBACK(vcfile_activated), NULL);
/* Directory */
menu_vcdiff_dir = gtk_menu_item_new_with_mnemonic(_("From Current _Directory"));
gtk_container_add(GTK_CONTAINER (menu_vcdiff_menu), menu_vcdiff_dir);
gtk_tooltips_set_tip (tooltips, menu_vcdiff_dir,
_("Make a diff from the directory of the current active file"), NULL);
p_ui->widget_set_tooltip_text(menu_vcdiff_dir,
_("Make a diff from the directory of the current active file"));
g_signal_connect(menu_vcdiff_dir, "activate", G_CALLBACK(vcdirectory_activated), NULL);
/* Project */
menu_vcdiff_project = gtk_menu_item_new_with_mnemonic(_("From Current _Project"));
gtk_container_add(GTK_CONTAINER (menu_vcdiff_menu), menu_vcdiff_project);
gtk_tooltips_set_tip (tooltips, menu_vcdiff_project,
_("Make a diff from the current project's base path"), NULL);
p_ui->widget_set_tooltip_text(menu_vcdiff_project,
_("Make a diff from the current project's base path"));
g_signal_connect(menu_vcdiff_project, "activate", G_CALLBACK(vcproject_activated), NULL);

View File

@ -171,7 +171,6 @@ static void create_open_file_dialog(void)
{
GtkWidget *filetype_combo, *encoding_combo;
GtkWidget *viewbtn;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
guint i;
gchar *encoding_string;
@ -181,8 +180,8 @@ static void create_open_file_dialog(void)
viewbtn = gtk_dialog_add_button(GTK_DIALOG(ui_widgets.open_filesel), _("_View"),
GEANY_RESPONSE_VIEW);
gtk_tooltips_set_tip(tooltips, viewbtn,
_("Opens the file in read-only mode. If you choose more than one file to open, all files will be opened read-only."), NULL);
ui_widget_set_tooltip_text(viewbtn,
_("Opens the file in read-only mode. If you choose more than one file to open, all files will be opened read-only."));
gtk_dialog_add_buttons(GTK_DIALOG(ui_widgets.open_filesel),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -288,7 +287,6 @@ static GtkWidget *add_file_open_extra_widget()
GtkWidget *vbox, *table, *file_entry, *check_hidden;
GtkWidget *filetype_ebox, *filetype_label, *filetype_combo;
GtkWidget *encoding_ebox, *encoding_label, *encoding_combo;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
vbox = gtk_vbox_new(FALSE, 6);
@ -315,8 +313,8 @@ static GtkWidget *add_file_open_extra_widget()
encoding_ebox = gtk_event_box_new();
encoding_combo = gtk_combo_box_new_text();
gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(encoding_combo), 3);
gtk_tooltips_set_tip(tooltips, encoding_ebox,
_("Explicitly defines an encoding for the file, if it would not be detected. This is useful when you know that the encoding of a file cannot be detected correctly by Geany.\nNote if you choose multiple files, they will all be opened with the chosen encoding."), NULL);
ui_widget_set_tooltip_text(encoding_ebox,
_("Explicitly defines an encoding for the file, if it would not be detected. This is useful when you know that the encoding of a file cannot be detected correctly by Geany.\nNote if you choose multiple files, they will all be opened with the chosen encoding."));
gtk_container_add(GTK_CONTAINER(encoding_ebox), encoding_combo);
gtk_table_attach(GTK_TABLE(table), encoding_ebox, 3, 4, 0, 1,
(GtkAttachOptions) (GTK_FILL),
@ -345,8 +343,8 @@ static GtkWidget *add_file_open_extra_widget()
filetype_ebox = gtk_event_box_new();
filetype_combo = gtk_combo_box_new_text();
gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(filetype_combo), 2);
gtk_tooltips_set_tip(tooltips, filetype_ebox,
_("Explicitly defines a filetype for the file, if it would not be detected by filename extension.\nNote if you choose multiple files, they will all be opened with the chosen filetype."), NULL);
ui_widget_set_tooltip_text(filetype_ebox,
_("Explicitly defines a filetype for the file, if it would not be detected by filename extension.\nNote if you choose multiple files, they will all be opened with the chosen filetype."));
gtk_container_add(GTK_CONTAINER(filetype_ebox), filetype_combo);
gtk_table_attach(GTK_TABLE(table), filetype_ebox, 3, 4, 1, 2,
(GtkAttachOptions) (GTK_FILL),
@ -474,7 +472,6 @@ on_file_save_dialog_response (GtkDialog *dialog,
static void create_save_file_dialog(void)
{
GtkWidget *vbox, *check_open_new_tab, *rename_btn;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
ui_widgets.save_filesel = gtk_file_chooser_dialog_new(_("Save File"), GTK_WINDOW(main_widgets.window),
GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
@ -486,8 +483,7 @@ static void create_save_file_dialog(void)
rename_btn = gtk_dialog_add_button(GTK_DIALOG(ui_widgets.save_filesel), _("R_ename"),
GEANY_RESPONSE_RENAME);
gtk_tooltips_set_tip(tooltips, rename_btn,
_("Save the file and rename it."), NULL);
ui_widget_set_tooltip_text(rename_btn, _("Save the file and rename it."));
gtk_dialog_add_buttons(GTK_DIALOG(ui_widgets.save_filesel),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -496,9 +492,9 @@ static void create_save_file_dialog(void)
vbox = gtk_vbox_new(FALSE, 0);
check_open_new_tab = gtk_check_button_new_with_mnemonic(_("_Open file in a new tab"));
gtk_tooltips_set_tip(tooltips, check_open_new_tab,
ui_widget_set_tooltip_text(check_open_new_tab,
_("Keep the current unsaved document open"
" and open the newly saved file in a new tab."), NULL);
" and open the newly saved file in a new tab."));
gtk_box_pack_start(GTK_BOX(vbox), check_open_new_tab, FALSE, FALSE, 0);
gtk_widget_show_all(vbox);
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(ui_widgets.save_filesel), vbox);

View File

@ -279,20 +279,16 @@ void document_update_tab_label(GeanyDocument *doc)
{
gchar *base_name;
GtkWidget *parent;
static GtkTooltips *tooltips = NULL;
g_return_if_fail(doc != NULL);
base_name = g_path_get_basename(DOC_FILENAME(doc));
parent = gtk_widget_get_parent(doc->priv->tab_label);
if (tooltips == NULL)
tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
gtk_label_set_text(GTK_LABEL(doc->priv->tab_label), base_name);
gtk_label_set_text(GTK_LABEL(doc->priv->tabmenu_label), base_name);
gtk_tooltips_set_tip(tooltips, parent, DOC_FILENAME(doc), NULL);
ui_widget_set_tooltip_text(parent, DOC_FILENAME(doc));
g_free(base_name);
}

View File

@ -45,7 +45,7 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 108,
GEANY_API_VERSION = 109,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
@ -358,6 +358,7 @@ typedef struct UIUtilsFuncs
GtkWidget* (*path_box_new) (const gchar *title, GtkFileChooserAction action, GtkEntry *entry);
GtkWidget* (*button_new_with_image) (const gchar *stock_id, const gchar *text);
void (*add_document_sensitive) (GtkWidget *widget);
void (*widget_set_tooltip_text) (GtkWidget *widget, const gchar *text);
}
UIUtilsFuncs;

View File

@ -206,7 +206,8 @@ static UIUtilsFuncs uiutils_funcs = {
&ui_table_add_row,
&ui_path_box_new,
&ui_button_new_with_image,
&ui_add_document_sensitive
&ui_add_document_sensitive,
&ui_widget_set_tooltip_text
};
static DialogFuncs dialog_funcs = {

View File

@ -332,7 +332,6 @@ static GtkWidget *create_custom_widget(GtkPrintOperation *operation, gpointer us
GtkWidget *vbox30;
GtkWidget *hbox10;
GtkWidget *label203;
GtkTooltips *tooltips = gtk_tooltips_new();
PrintWidgets *w = user_data;
gtk_print_operation_set_custom_tab_label(operation, _("Document Setup"));
@ -342,17 +341,17 @@ static GtkWidget *create_custom_widget(GtkPrintOperation *operation, gpointer us
w->check_print_linenumbers = gtk_check_button_new_with_mnemonic(_("Print line numbers"));
gtk_box_pack_start(GTK_BOX(page), w->check_print_linenumbers, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_linenumbers, _("Add line numbers to the printed page."), NULL);
ui_widget_set_tooltip_text(w->check_print_linenumbers, _("Add line numbers to the printed page."));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_linenumbers), printing_prefs.print_line_numbers);
w->check_print_pagenumbers = gtk_check_button_new_with_mnemonic(_("Print page numbers"));
gtk_box_pack_start(GTK_BOX(page), w->check_print_pagenumbers, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_pagenumbers, _("Add page numbers at the bottom of each page. It takes 2 lines of the page."), NULL);
ui_widget_set_tooltip_text(w->check_print_pagenumbers, _("Add page numbers at the bottom of each page. It takes 2 lines of the page."));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_pagenumbers), printing_prefs.print_page_numbers);
w->check_print_pageheader = gtk_check_button_new_with_mnemonic(_("Print page header"));
gtk_box_pack_start(GTK_BOX(page), w->check_print_pageheader, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_pageheader, _("Adds a little header to every page containing the page number, the filename and the current date(see below). It takes 3 lines of the page."), NULL);
ui_widget_set_tooltip_text(w->check_print_pageheader, _("Adds a little header to every page containing the page number, the filename and the current date(see below). It takes 3 lines of the page."));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_pageheader), printing_prefs.print_page_header);
g_signal_connect(w->check_print_pageheader, "toggled", G_CALLBACK(on_page_header_toggled), w);
@ -370,7 +369,7 @@ static GtkWidget *create_custom_widget(GtkPrintOperation *operation, gpointer us
w->check_print_basename = gtk_check_button_new_with_mnemonic(_("Use the basename of the printed file"));
gtk_box_pack_start(GTK_BOX(vbox30), w->check_print_basename, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_basename, _("Print only the basename(without the path) of the printed file."), NULL);
ui_widget_set_tooltip_text(w->check_print_basename, _("Print only the basename(without the path) of the printed file."));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_basename), printing_prefs.page_header_basename);
hbox10 = gtk_hbox_new(FALSE, 5);
@ -381,7 +380,7 @@ static GtkWidget *create_custom_widget(GtkPrintOperation *operation, gpointer us
w->entry_print_dateformat = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox10), w->entry_print_dateformat, TRUE, TRUE, 0);
gtk_tooltips_set_tip(tooltips, w->entry_print_dateformat, _("Specify a format for the date and time stamp which is added to the page header on each page. You can use any conversion specifiers which can be used with the ANSI C strftime function."), NULL);
ui_widget_set_tooltip_text(w->entry_print_dateformat, _("Specify a format for the date and time stamp which is added to the page header on each page. You can use any conversion specifiers which can be used with the ANSI C strftime function."));
gtk_entry_set_text(GTK_ENTRY(w->entry_print_dateformat), printing_prefs.page_header_datefmt);
on_page_header_toggled(GTK_TOGGLE_BUTTON(w->check_print_pageheader), w);

View File

@ -97,7 +97,6 @@ void project_new()
GtkWidget *button;
GtkWidget *bbox;
GtkWidget *label;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
PropertyDialogElements *e;
gint response;
@ -155,10 +154,10 @@ void project_new()
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
e->base_path = gtk_entry_new();
gtk_tooltips_set_tip(tooltips, e->base_path,
ui_widget_set_tooltip_text(e->base_path,
_("Base directory of all files that make up the project. "
"This can be a new path, or an existing directory tree. "
"You can use paths relative to the project filename."), NULL);
"You can use paths relative to the project filename."));
bbox = ui_path_box_new(_("Choose Project Base Path"),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
@ -352,7 +351,6 @@ static void create_properties_dialog(PropertyDialogElements *e)
GtkWidget *bbox;
GtkWidget *label;
GtkWidget *swin;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
e->dialog = gtk_dialog_new_with_buttons(_("Project Properties"), GTK_WINDOW(main_widgets.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@ -414,10 +412,10 @@ static void create_properties_dialog(PropertyDialogElements *e)
gtk_misc_set_alignment(GTK_MISC(label), -1, 0);
e->base_path = gtk_entry_new();
gtk_tooltips_set_tip(tooltips, e->base_path,
ui_widget_set_tooltip_text(e->base_path,
_("Base directory of all files that make up the project. "
"This can be a new path, or an existing directory tree. "
"You can use paths relative to the project filename."), NULL);
"You can use paths relative to the project filename."));
bbox = ui_path_box_new(_("Choose Project Base Path"),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 3, 4,
@ -436,10 +434,10 @@ static void create_properties_dialog(PropertyDialogElements *e)
gtk_misc_set_alignment(GTK_MISC(label), -1, 0);
e->run_cmd = gtk_entry_new();
gtk_tooltips_set_tip(tooltips, e->run_cmd,
ui_widget_set_tooltip_text(e->run_cmd,
_("Command-line to run in the project base directory. "
"Options can be appended to the command. "
"Leave blank to use the default run command."), NULL);
"Leave blank to use the default run command."));
button = gtk_button_new();
g_signal_connect(button, "clicked", G_CALLBACK(on_file_open_button_clicked), e->run_cmd);
image = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);

View File

@ -143,14 +143,13 @@ static GtkWidget *add_find_checkboxes(GtkDialog *dialog)
{
GtkWidget *checkbox1, *checkbox2, *check_regexp, *check_back, *checkbox5,
*checkbox7, *hbox, *fbox, *mbox;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
check_regexp = gtk_check_button_new_with_mnemonic(_("_Use regular expressions"));
g_object_set_data_full(G_OBJECT(dialog), "check_regexp",
g_object_ref(check_regexp), (GDestroyNotify) g_object_unref);
gtk_button_set_focus_on_click(GTK_BUTTON(check_regexp), FALSE);
gtk_tooltips_set_tip(tooltips, check_regexp, _("Use POSIX-like regular expressions. "
"For detailed information about using regular expressions, please read the documentation."), NULL);
ui_widget_set_tooltip_text(check_regexp, _("Use POSIX-like regular expressions. "
"For detailed information about using regular expressions, please read the documentation."));
g_signal_connect(check_regexp, "toggled",
G_CALLBACK(on_find_replace_checkbutton_toggled), GTK_WIDGET(dialog));
@ -174,9 +173,9 @@ static GtkWidget *add_find_checkboxes(GtkDialog *dialog)
g_object_set_data_full(G_OBJECT(dialog), "check_escape",
g_object_ref(checkbox7), (GDestroyNotify)g_object_unref);
gtk_button_set_focus_on_click(GTK_BUTTON(checkbox7), FALSE);
gtk_tooltips_set_tip(tooltips, checkbox7,
ui_widget_set_tooltip_text(checkbox7,
_("Replace \\\\, \\t, \\n, \\r and \\uXXXX (Unicode chararacters) with the "
"corresponding control characters."), NULL);
"corresponding control characters."));
/* Search features */
fbox = gtk_vbox_new(FALSE, 0);
@ -306,7 +305,6 @@ void search_show_find_dialog(void)
{
GtkWidget *label, *entry, *sbox, *vbox;
GtkWidget *exp, *bbox, *button, *check_close;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
load_monospace_style();
@ -358,8 +356,8 @@ void search_show_find_dialog(void)
bbox = gtk_hbutton_box_new();
button = gtk_button_new_with_mnemonic(_("_Mark"));
gtk_tooltips_set_tip(tooltips, button,
_("Mark all matches in the current document."), NULL);
ui_widget_set_tooltip_text(button,
_("Mark all matches in the current document."));
gtk_container_add(GTK_CONTAINER(bbox), button);
g_signal_connect(button, "clicked", G_CALLBACK(send_find_dialog_response),
GINT_TO_POINTER(GEANY_RESPONSE_MARK));
@ -379,8 +377,8 @@ void search_show_find_dialog(void)
g_object_set_data_full(G_OBJECT(widgets.find_dialog), "check_close",
g_object_ref(check_close), (GDestroyNotify) g_object_unref);
gtk_button_set_focus_on_click(GTK_BUTTON(check_close), FALSE);
gtk_tooltips_set_tip(tooltips, check_close,
_("Disable this option to keep the dialog open."), NULL);
ui_widget_set_tooltip_text(check_close,
_("Disable this option to keep the dialog open."));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_close), TRUE);
gtk_container_add(GTK_CONTAINER(bbox), check_close);
gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), check_close, TRUE);
@ -429,7 +427,6 @@ void search_show_replace_dialog(void)
GtkWidget *label_find, *label_replace, *entry_find, *entry_replace,
*check_close, *button, *rbox, *fbox, *vbox, *exp, *bbox;
GtkSizeGroup *label_size;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
load_monospace_style();
@ -504,8 +501,8 @@ void search_show_replace_dialog(void)
bbox = gtk_hbutton_box_new();
button = gtk_button_new_with_mnemonic(_("In Se_lection"));
gtk_tooltips_set_tip(tooltips, button,
_("Replace all matches found in the currently selected text"), NULL);
ui_widget_set_tooltip_text(button,
_("Replace all matches found in the currently selected text"));
gtk_container_add(GTK_CONTAINER(bbox), button);
g_signal_connect(button, "clicked", G_CALLBACK(send_replace_dialog_response),
GINT_TO_POINTER(GEANY_RESPONSE_REPLACE_IN_SEL));
@ -525,8 +522,8 @@ void search_show_replace_dialog(void)
g_object_set_data_full(G_OBJECT(widgets.replace_dialog), "check_close",
g_object_ref(check_close), (GDestroyNotify) g_object_unref);
gtk_button_set_focus_on_click(GTK_BUTTON(check_close), FALSE);
gtk_tooltips_set_tip(tooltips, check_close,
_("Disable this option to keep the dialog open."), NULL);
ui_widget_set_tooltip_text(check_close,
_("Disable this option to keep the dialog open."));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_close), TRUE);
gtk_container_add(GTK_CONTAINER(bbox), check_close);
gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), check_close, TRUE);
@ -569,7 +566,6 @@ static void create_fif_dialog()
*check_recursive, *check_extra, *entry_extra;
GtkWidget *dbox, *sbox, *cbox, *rbox, *rbtn, *hbox, *vbox, *ebox;
GtkSizeGroup *size_group;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
gchar *encoding_string;
guint i;
@ -652,15 +648,13 @@ static void create_fif_dialog()
_("_Grep regular expressions"));
g_object_set_data_full(G_OBJECT(widgets.find_in_files_dialog), "radio_grep",
g_object_ref(rbtn), (GDestroyNotify)g_object_unref);
gtk_tooltips_set_tip(tooltips, rbtn,
_("See grep's manual page for more information."), NULL);
ui_widget_set_tooltip_text(rbtn, _("See grep's manual page for more information."));
gtk_button_set_focus_on_click(GTK_BUTTON(rbtn), FALSE);
gtk_container_add(GTK_CONTAINER(rbox), rbtn);
rbtn = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(rbtn),
_("_Extended regular expressions"));
gtk_tooltips_set_tip(tooltips, rbtn,
_("See grep's manual page for more information."), NULL);
ui_widget_set_tooltip_text(rbtn, _("See grep's manual page for more information."));
gtk_button_set_focus_on_click(GTK_BUTTON(rbtn), FALSE);
gtk_container_add(GTK_CONTAINER(rbox), rbtn);
@ -684,8 +678,8 @@ static void create_fif_dialog()
g_object_set_data_full(G_OBJECT(widgets.find_in_files_dialog), "check_invert",
g_object_ref(checkbox2), (GDestroyNotify)g_object_unref);
gtk_button_set_focus_on_click(GTK_BUTTON(checkbox2), FALSE);
gtk_tooltips_set_tip(tooltips, checkbox2,
_("Invert the sense of matching, to select non-matching lines."), NULL);
ui_widget_set_tooltip_text(checkbox2,
_("Invert the sense of matching, to select non-matching lines."));
cbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(cbox), checkbox1);
@ -711,8 +705,7 @@ static void create_fif_dialog()
if (search_prefs.fif_extra_options)
gtk_entry_set_text(GTK_ENTRY(entry_extra), search_prefs.fif_extra_options);
gtk_widget_set_sensitive(entry_extra, FALSE);
gtk_tooltips_set_tip(tooltips, entry_extra,
_("Other options to pass to Grep"), NULL);
ui_widget_set_tooltip_text(entry_extra, _("Other options to pass to Grep"));
find_in_files.extra_entry = entry_extra;
/* enable entry_extra when check_extra is checked */
@ -859,9 +852,9 @@ static gint search_mark(GeanyDocument *doc, const gchar *search_text, gint flags
/* clear previous search indicators */
editor_indicator_clear(doc->editor, GEANY_INDICATOR_SEARCH);
len = strlen(search_text);
ttf.chrg.cpMin = 0;
ttf.chrg.cpMax = sci_get_length(doc->editor->sci);
ttf.lpstrText = (gchar *)search_text;
@ -1379,7 +1372,7 @@ static gboolean search_read_io(GIOChannel *source, GIOCondition condition, gpoin
while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg)
{
utf8_msg = NULL;
g_strstrip(msg);
if (! g_utf8_validate(msg, -1, NULL))
{
@ -1409,7 +1402,7 @@ static gboolean search_read_io_stderr(GIOChannel *source, GIOCondition condition
while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg)
{
utf8_msg = NULL;
g_strstrip(msg);
if (! g_utf8_validate(msg, -1, NULL))
{

View File

@ -1658,3 +1658,23 @@ void ui_auto_separator_add_ref(GeanyAutoSeparator *autosep, GtkWidget *item)
g_signal_connect(item, "destroy", G_CALLBACK(on_auto_separator_item_destroy), autosep);
}
/**
* Sets @a text as the contents of the tooltip for @a widget.
*
* @param widget The widget the tooltip should be set for.
* @param text The text for the tooltip.
*/
void ui_widget_set_tooltip_text(GtkWidget *widget, const gchar *text)
{
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text(widget, text);
#else
static GtkTooltips *tooltips = NULL;
if (tooltips == NULL)
tooltips = GTK_TOOLTIPS(lookup_widget(main_widgets.window, "tooltips"));
gtk_tooltips_set_tip(tooltips, widget, text, NULL);
#endif
}

View File

@ -249,4 +249,6 @@ gint ui_get_toolbar_insert_position(void);
void ui_add_document_sensitive(GtkWidget *widget);
void ui_widget_set_tooltip_text(GtkWidget *widget, const gchar *text);
#endif

View File

@ -680,10 +680,8 @@ void vte_append_preferences_tab(void)
GtkWidget *check_scroll_key, *check_scroll_out, *check_follow_path;
GtkWidget *check_enable_bash_keys, *check_ignore_menu_key;
GtkWidget *check_run_in_vte, *check_skip_script, *entry_shell, *button_shell, *image_shell;
GtkTooltips *tooltips;
GtkObject *spin_scrollback_adj;
tooltips = GTK_TOOLTIPS(lookup_widget(ui_widgets.prefs_dialog, "tooltips"));
notebook = lookup_widget(ui_widgets.prefs_dialog, "notebook2");
frame = ui_frame_new_with_alignment(_("Terminal plugin"), &alignment);
@ -715,7 +713,7 @@ void vte_append_preferences_tab(void)
gtk_table_attach(GTK_TABLE(table), font_term, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip(tooltips, font_term, _("Sets the font for the terminal widget."), NULL);
ui_widget_set_tooltip_text(font_term, _("Sets the font for the terminal widget."));
label = gtk_label_new(_("Foreground color:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
@ -733,14 +731,14 @@ void vte_append_preferences_tab(void)
gtk_table_attach(GTK_TABLE(table), color_fore, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip(tooltips, color_fore, _("Sets the foreground color of the text in the terminal widget."), NULL);
ui_widget_set_tooltip_text(color_fore, _("Sets the foreground color of the text in the terminal widget."));
gtk_color_button_set_title(GTK_COLOR_BUTTON(color_fore), _("Color Chooser"));
color_back = gtk_color_button_new();
gtk_table_attach(GTK_TABLE(table), color_back, 1, 2, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip(tooltips, color_back, _("Sets the background color of the text in the terminal widget."), NULL);
ui_widget_set_tooltip_text(color_back, _("Sets the background color of the text in the terminal widget."));
gtk_color_button_set_title(GTK_COLOR_BUTTON(color_back), _("Color Chooser"));
label = gtk_label_new(_("Scrollback lines:"));
@ -754,7 +752,7 @@ void vte_append_preferences_tab(void)
gtk_table_attach(GTK_TABLE(table), spin_scrollback, 1, 2, 3, 4,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip(tooltips, spin_scrollback, _("Specifies the history in lines, which you can scroll back in the terminal widget."), NULL);
ui_widget_set_tooltip_text(spin_scrollback, _("Specifies the history in lines, which you can scroll back in the terminal widget."));
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin_scrollback), TRUE);
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spin_scrollback), TRUE);
@ -768,7 +766,7 @@ void vte_append_preferences_tab(void)
gtk_table_attach(GTK_TABLE(table), entry_emulation, 1, 2, 4, 5,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip(tooltips, entry_emulation, _("Controls how the terminal emulator should behave. Do not change this value unless you know exactly what you are doing."), NULL);
ui_widget_set_tooltip_text(entry_emulation, _("Controls how the terminal emulator should behave. Do not change this value unless you know exactly what you are doing."));
label = gtk_label_new(_("Shell:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6,
@ -777,7 +775,7 @@ void vte_append_preferences_tab(void)
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
entry_shell = gtk_entry_new();
gtk_tooltips_set_tip(tooltips, entry_shell, _("Sets the path to the shell which should be started inside the terminal emulation."), NULL);
ui_widget_set_tooltip_text(entry_shell, _("Sets the path to the shell which should be started inside the terminal emulation."));
button_shell = gtk_button_new();
gtk_widget_show(button_shell);
@ -795,34 +793,34 @@ void vte_append_preferences_tab(void)
box = gtk_vbox_new(FALSE, 3);
check_scroll_key = gtk_check_button_new_with_mnemonic(_("Scroll on keystroke"));
gtk_tooltips_set_tip(tooltips, check_scroll_key, _("Whether to scroll to the bottom if a key was pressed."), NULL);
ui_widget_set_tooltip_text(check_scroll_key, _("Whether to scroll to the bottom if a key was pressed."));
gtk_container_add(GTK_CONTAINER(box), check_scroll_key);
check_scroll_out = gtk_check_button_new_with_mnemonic(_("Scroll on output"));
gtk_tooltips_set_tip(tooltips, check_scroll_out, _("Whether to scroll to the bottom when output is generated."), NULL);
ui_widget_set_tooltip_text(check_scroll_out, _("Whether to scroll to the bottom when output is generated."));
gtk_container_add(GTK_CONTAINER(box), check_scroll_out);
check_enable_bash_keys = gtk_check_button_new_with_mnemonic(_("Override Geany keybindings"));
gtk_tooltips_set_tip(tooltips, check_enable_bash_keys,
_("Allows the VTE to receive keyboard shortcuts (apart from focus commands)."), NULL);
ui_widget_set_tooltip_text(check_enable_bash_keys,
_("Allows the VTE to receive keyboard shortcuts (apart from focus commands)."));
gtk_container_add(GTK_CONTAINER(box), check_enable_bash_keys);
check_ignore_menu_key = gtk_check_button_new_with_mnemonic(_("Disable menu shortcut key (F10 by default)"));
gtk_tooltips_set_tip(tooltips, check_ignore_menu_key, _("This option disables the keybinding to popup the menu bar (default is F10). Disabling it can be useful if you use, for example, Midnight Commander within the VTE."), NULL);
ui_widget_set_tooltip_text(check_ignore_menu_key, _("This option disables the keybinding to popup the menu bar (default is F10). Disabling it can be useful if you use, for example, Midnight Commander within the VTE."));
gtk_container_add(GTK_CONTAINER(box), check_ignore_menu_key);
check_follow_path = gtk_check_button_new_with_mnemonic(_("Follow the path of the current file"));
gtk_tooltips_set_tip(tooltips, check_follow_path, _("Whether to execute \"cd $path\" when you switch between opened files."), NULL);
ui_widget_set_tooltip_text(check_follow_path, _("Whether to execute \"cd $path\" when you switch between opened files."));
gtk_container_add(GTK_CONTAINER(box), check_follow_path);
/* create check_skip_script checkbox before the check_skip_script checkbox to be able to
* use the object for the toggled handler of check_skip_script checkbox */
check_skip_script = gtk_check_button_new_with_mnemonic(_("Don't use run script"));
gtk_tooltips_set_tip(tooltips, check_skip_script, _("Don't use the simple run script which is usually used to display the exit status of the executed program."), NULL);
ui_widget_set_tooltip_text(check_skip_script, _("Don't use the simple run script which is usually used to display the exit status of the executed program."));
gtk_widget_set_sensitive(check_skip_script, vc->run_in_vte);
check_run_in_vte = gtk_check_button_new_with_mnemonic(_("Execute programs in VTE"));
gtk_tooltips_set_tip(tooltips, check_run_in_vte, _("Run programs in VTE instead of opening a terminal emulation window. Please note, programs executed in VTE cannot be stopped."), NULL);
ui_widget_set_tooltip_text(check_run_in_vte, _("Run programs in VTE instead of opening a terminal emulation window. Please note, programs executed in VTE cannot be stopped."));
gtk_container_add(GTK_CONTAINER(box), check_run_in_vte);
g_signal_connect(check_run_in_vte, "toggled",
G_CALLBACK(check_run_in_vte_toggled), check_skip_script);