gboolean wikipad_statusbar_push_tooltip (WikipadStatusbar *statusbar, GtkWidget *widget) { GtkAction *action = NULL; const gchar *tooltip = NULL; gint id; /* get the widget's related action */ action = wikipad_util_find_related_action (widget); /* if the action has a tooltip, use it */ if (G_LIKELY (action != NULL)) tooltip = gtk_action_get_tooltip (action); /* if the action doesn't have a tooltip, see if the widget has one */ if (G_UNLIKELY (tooltip == NULL) && gtk_widget_get_has_tooltip (widget)) tooltip = gtk_widget_get_tooltip_text (widget); if (G_LIKELY (tooltip != NULL)) { /* show the tooltip */ id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "tooltip"); gtk_statusbar_push (GTK_STATUSBAR (statusbar), id, tooltip); return TRUE; } return FALSE; }
void tooltip_remove(GeanyEditor *editor) { GtkWidget *widget = GTK_WIDGET(editor->sci); if (gtk_widget_get_has_tooltip(widget)) { gulong query_tooltip_id = g_signal_handler_find(widget, G_SIGNAL_MATCH_ID, g_signal_lookup("query-tooltip", GTK_TYPE_WIDGET), 0, NULL, NULL, NULL); if (query_tooltip_id) g_signal_handler_disconnect(widget, query_tooltip_id); gtk_widget_set_has_tooltip(widget, FALSE); } }
static gboolean panel_applet_can_focus (GtkWidget *widget) { /* * A PanelApplet widget can focus if it has a tooltip or it does * not have any focusable children. */ if (gtk_widget_get_has_tooltip (widget)) return TRUE; if (!PANEL_IS_APPLET (widget)) return FALSE; return !container_has_focusable_child (GTK_CONTAINER (widget)); }
static gboolean panel_applet_focus (GtkWidget *widget, GtkDirectionType dir) { gboolean ret; GtkWidget *previous_focus_child; g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE); previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)); if (!previous_focus_child && !gtk_widget_has_focus (widget)) { if (gtk_widget_get_has_tooltip (widget)) { gtk_widget_set_can_focus (widget, TRUE); gtk_widget_grab_focus (widget); gtk_widget_set_can_focus (widget, FALSE); return TRUE; } } ret = GTK_WIDGET_CLASS (panel_applet_parent_class)->focus (widget, dir); if (!ret && !previous_focus_child) { if (!gtk_widget_has_focus (widget)) { /* * Applet does not have a widget which can focus so set * the focus on the applet unless it already had focus * because it had a tooltip. */ gtk_widget_set_can_focus (widget, TRUE); gtk_widget_grab_focus (widget); gtk_widget_set_can_focus (widget, FALSE); ret = TRUE; } } return ret; }