Simplify the tooltips code for the Open Files treeview.

Change the dependency handling for GTK 2.12 for some features from compile time to run time.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3287 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-11-29 12:50:27 +00:00
parent c9c5c5829e
commit 7589d8a4e5
2 changed files with 16 additions and 44 deletions

View File

@ -1,3 +1,11 @@
2008-11-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/treeviews.c:
Simplify the tooltips code for the Open Files treeview.
Change the dependency handling for GTK 2.12 for some features
from compile time to run time.
2008-11-28 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/utils.h, src/makefile.win32, src/stash.c, src/stash.h,

View File

@ -117,11 +117,12 @@ static void prepare_taglist(GtkWidget *tree, GtkTreeStore *store)
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tree), interface_prefs.show_symbol_list_expanders);
if (gtk_check_version(2, 12, 0) == NULL)
{
g_object_set(tree, "show-expanders", interface_prefs.show_symbol_list_expanders, NULL);
if (! interface_prefs.show_symbol_list_expanders)
gtk_tree_view_set_level_indentation(GTK_TREE_VIEW(tree), 10);
#endif
g_object_set(tree, "level-indentation", 10, NULL);
}
/* selection handling */
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
@ -200,32 +201,6 @@ void treeviews_update_tag_list(GeanyDocument *doc, 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)
{
GtkTreeModel *model;
GtkTreeIter iter;
if (gtk_tree_view_get_tooltip_context(
GTK_TREE_VIEW(widget), &x, &y, keyboard_mode, &model, NULL, &iter))
{
gchar *file_name = NULL;
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(void)
{
@ -239,11 +214,7 @@ static void prepare_openfiles(void)
/* 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_POINTER, GDK_TYPE_COLOR, G_TYPE_STRING);
#else
store_openfiles = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR);
#endif
gtk_tree_view_set_model(GTK_TREE_VIEW(tv.tree_openfiles), GTK_TREE_MODEL(store_openfiles));
g_object_unref(store_openfiles);
@ -269,12 +240,9 @@ static void prepare_openfiles(void)
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(tv.tree_openfiles, "query-tooltip",
G_CALLBACK(on_treeviews_tooltip_queried), NULL);
#endif
if (gtk_check_version(2, 12, 0) == NULL)
g_object_set(tv.tree_openfiles, "has-tooltip", TRUE, "tooltip-column", 3, NULL);
g_signal_connect(tv.tree_openfiles, "button-press-event",
G_CALLBACK(on_treeviews_button_press_event), GINT_TO_POINTER(TREEVIEW_OPENFILES));
@ -307,11 +275,7 @@ void treeviews_openfiles_update(GeanyDocument *doc)
else
basename = g_path_get_basename(DOC_FILENAME(doc));
gtk_list_store_set(store_openfiles, &doc->priv->iter,
#if GTK_CHECK_VERSION(2, 12, 0)
0, basename, 1, doc, 2, color, 3, DOC_FILENAME(doc), -1);
#else
0, basename, 1, doc, 2, color, -1);
#endif
if (! interface_prefs.sidebar_openfiles_fullpath)
g_free(basename);
}