diff --git a/libwnck/tasklist.c b/libwnck/tasklist.c index 9e1c6ad..bfc027c 100644 --- a/libwnck/tasklist.c +++ b/libwnck/tasklist.c @@ -348,7 +348,7 @@ static void wnck_tasklist_update_icon_geometries (WnckTasklist *tasklist, GList *visible_tasks); static void wnck_tasklist_connect_screen (WnckTasklist *tasklist); static void wnck_tasklist_disconnect_screen (WnckTasklist *tasklist); - +static void wnck_set_tooltip_text (WnckTask *task); #ifdef HAVE_STARTUP_NOTIFICATION static void wnck_tasklist_sn_event (SnMonitorEvent *event, void *user_data); @@ -2997,10 +2997,6 @@ wnck_task_popup_menu (WnckTask *task, if (wnck_task_get_needs_attention (win_task)) _make_gtk_label_bold (GTK_LABEL (gtk_bin_get_child (GTK_BIN (menu_item)))); - text = wnck_task_get_text (win_task, FALSE, FALSE); - gtk_widget_set_tooltip_text (menu_item, text); - g_free (text); - pixbuf = wnck_task_get_icon (win_task); if (pixbuf) { @@ -3156,6 +3152,15 @@ wnck_task_button_toggled (GtkButton *button, } } +// Callback for when mouse cursor enters a tasklist button +static void +wnck_task_button_entered (GtkButton *button, + WnckTask *task) +{ + wnck_set_tooltip_text(task); +} + + static char * wnck_task_get_text (WnckTask *task, gboolean icon_text, @@ -3412,12 +3417,6 @@ wnck_task_update_visible_state (WnckTask *task) g_free (text); } - text = wnck_task_get_text (task, FALSE, FALSE); - /* if text is NULL, this unsets the tooltip, which is probably what we'd want - * to do */ - gtk_widget_set_tooltip_text (task->button, text); - g_free (text); - gtk_widget_queue_resize (GTK_WIDGET (task->tasklist)); } @@ -3860,10 +3859,6 @@ wnck_task_create_widgets (WnckTask *task, GtkReliefStyle relief) gtk_widget_show (hbox); g_free (text); - text = wnck_task_get_text (task, FALSE, FALSE); - gtk_widget_set_tooltip_text (task->button, text); - g_free (text); - /* Set up signals */ if (GTK_IS_TOGGLE_BUTTON (task->button)) g_signal_connect_object (G_OBJECT (task->button), "toggled", @@ -3871,6 +3866,12 @@ wnck_task_create_widgets (WnckTask *task, GtkReliefStyle relief) G_OBJECT (task), 0); + //Mouse cursor enters the button + g_signal_connect_object (G_OBJECT (task->button), "enter", + G_CALLBACK (wnck_task_button_entered), + G_OBJECT (task), + 0); + g_signal_connect_object (G_OBJECT (task->button), "size_allocate", G_CALLBACK (wnck_task_size_allocated), G_OBJECT (task), @@ -4263,6 +4264,41 @@ remove_startup_sequences_for_window (WnckTasklist *tasklist, #endif } +/** + * wnck_set_tooltip_text: + * @task: Pointer to the WnckTask whose tooltip you wish to set. + * + * Sets the tooltip of the given #WnckTask in one of two ways: + * 1) If the text to be displayed in the task's label will be ellipsized + * because it is too long to fit in the available space then the tooltip will + * be set to the full text. + * 2) If the text to be displayed in the task's label will not be ellipsized + * then the tooltip will be cleared. There is no point in showing a tooltip + * that contains the exact same information the user is already seeing. + * + * Return value: none. + */ + +void +wnck_set_tooltip_text(WnckTask *task) +{ + PangoLayout *layout; + char *text; + + // Get Pango layout object associated with this task's label + layout = gtk_label_get_layout(GTK_LABEL(task->label)); + + // Set button's tooltip to label text, but only if label is ellipsized + if(pango_layout_is_ellipsized(layout)) + { + text = wnck_task_get_text(task, FALSE, FALSE); + gtk_widget_set_tooltip_text(task->button, text); + g_free(text); + } + else + gtk_widget_set_tooltip_text (task->button, ""); +} + static WnckTask * wnck_task_new_from_window (WnckTasklist *tasklist, WnckWindow *window)