Skip to content

Commit

Permalink
Add full file name as tooltip in the open files list (only for GTK 2.…
Browse files Browse the repository at this point in the history
…12 and above).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1936 ea778897-0a13-0410-b9d1-a72fbfd435f5
  • Loading branch information
eht16 committed Oct 9, 2007
1 parent 0bd362f commit 4a0977c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -3,6 +3,8 @@
* src/document.c, src/highlighting.c, src/symbols.c, src/symbols.h:
Fix wrong colouring of type keywords of tags from different
filetypes.
* src/treeviews.c: Add full file name as tooltip in the open files list
(only for GTK 2.12 and above).


2007-10-09 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Expand Down
48 changes: 46 additions & 2 deletions src/treeviews.c
Expand Up @@ -186,19 +186,52 @@ void treeviews_update_tag_list(gint idx, gboolean update)
}


#if GTK_CHECK_VERSION(2, 12, 0)
gboolean on_treeviews_tooltip_queried(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode,
GtkTooltip *tooltip, gpointer user_data)
{
GtkTreePath *path;

if (gtk_tree_view_get_path_at_pos(
GTK_TREE_VIEW(tv.tree_openfiles), x, y, &path, NULL, NULL, NULL))
{
GtkTreeIter iter;
gchar *file_name = NULL;

gtk_tree_model_get_iter(GTK_TREE_MODEL(store_openfiles), &iter, path);
gtk_tree_path_free(path);
gtk_tree_model_get(GTK_TREE_MODEL(store_openfiles), &iter, 3, &file_name, -1);
if (file_name != NULL)
{
gtk_tooltip_set_text(tooltip, file_name);
g_free(file_name);
return TRUE;
}
}

return FALSE;
}
#endif


/* does some preparing things to the open files list widget */
static void prepare_openfiles()
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeSelection *select;
PangoFontDescription *pfd;
GtkTreeSortable *sortable;
GtkTreeSortable *sortable;

tv.tree_openfiles = lookup_widget(app->window, "treeview6");

// store the short filename to show, and the index as reference
// store the short filename to show, and the index as reference,
// the colour (black/red/green) and the full name for the tooltip
#if GTK_CHECK_VERSION(2, 12, 0)
store_openfiles = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_STRING);
#else
store_openfiles = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR);
#endif
gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(store_openfiles));

// set policy settings for the scolledwindow around the treeview again, because glade
Expand All @@ -223,6 +256,13 @@ static void prepare_openfiles()
gtk_widget_modify_font(tv.tree_openfiles, pfd);
pango_font_description_free(pfd);

#if GTK_CHECK_VERSION(2, 12, 0)
// GTK 2.12 tooltips
gtk_widget_set_has_tooltip(tv.tree_openfiles, TRUE);
g_signal_connect(G_OBJECT(tv.tree_openfiles), "query-tooltip",
G_CALLBACK(on_treeviews_tooltip_queried), NULL);
#endif

g_signal_connect(G_OBJECT(tv.tree_openfiles), "button-press-event",
G_CALLBACK(on_treeviews_button_press_event), GINT_TO_POINTER(TREEVIEW_OPENFILES));

Expand Down Expand Up @@ -251,7 +291,11 @@ void treeviews_openfiles_update(gint idx)

basename = g_path_get_basename(DOC_FILENAME(idx));
gtk_list_store_set(store_openfiles, &doc_list[idx].iter,
#if GTK_CHECK_VERSION(2, 12, 0)
0, basename, 1, idx, 2, color, 3, DOC_FILENAME(idx), -1);
#else
0, basename, 1, idx, 2, color, -1);
#endif
g_free(basename);
}

Expand Down

0 comments on commit 4a0977c

Please sign in to comment.