void gth_browser_activate_rename (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GthBrowser *browser = GTH_BROWSER (user_data); GtkWidget *folder_tree; GtkWidget *file_list; folder_tree = gth_browser_get_folder_tree (browser); if (gtk_widget_has_focus (folder_tree)) { GthFileData *file_data; file_data = gth_folder_tree_get_selected (GTH_FOLDER_TREE (folder_tree)); if (file_data == NULL) return; if (! g_file_info_get_attribute_boolean (file_data->info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME)) return; gth_folder_tree_start_editing (GTH_FOLDER_TREE (gth_browser_get_folder_tree (browser)), file_data->file); g_object_unref (file_data); return; } file_list = gth_browser_get_file_list_view (browser); if (gtk_widget_has_focus (file_list)) { gth_hook_invoke ("gth-browser-file-list-rename", browser); return; } if (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_VIEWER) { gth_hook_invoke ("gth-browser-file-list-rename", browser); return; } }
gboolean qtcComboBoxIsFocusChanged(GtkWidget *widget) { if (qtcComboFocus == widget) { if (!gtk_widget_has_focus(widget)) { qtcComboFocus = NULL; return TRUE; } } else if (gtk_widget_has_focus(widget)) { qtcComboFocus = widget; return TRUE; } return FALSE; }
static gboolean gimp_container_grid_view_focus (GtkWidget *widget, GtkDirectionType direction) { GimpContainerGridView *view = GIMP_CONTAINER_GRID_VIEW (widget); if (gtk_widget_get_can_focus (widget) && ! gtk_widget_has_focus (widget)) { gtk_widget_grab_focus (GTK_WIDGET (widget)); return TRUE; } switch (direction) { case GTK_DIR_UP: return gimp_container_grid_view_move_by (view, 0, -1); case GTK_DIR_DOWN: return gimp_container_grid_view_move_by (view, 0, 1); case GTK_DIR_LEFT: return gimp_container_grid_view_move_by (view, -1, 0); case GTK_DIR_RIGHT: return gimp_container_grid_view_move_by (view, 1, 0); case GTK_DIR_TAB_FORWARD: case GTK_DIR_TAB_BACKWARD: break; } return FALSE; }
static void vdlist_scroll_to_row(ViewDir *vd, FileData *fd, gfloat y_align) { GtkTreeIter iter; #if GTK_CHECK_VERSION(2,20,0) if (gtk_widget_get_realized(vd->view) && vd_find_row(vd, fd, &iter)) #else if (GTK_WIDGET_REALIZED(vd->view) && vd_find_row(vd, fd, &iter)) #endif { GtkTreeModel *store; GtkTreePath *tpath; store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); tpath = gtk_tree_model_get_path(store, &iter); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vd->view), tpath, NULL, TRUE, y_align, 0.0); gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE); gtk_tree_path_free(tpath); #if GTK_CHECK_VERSION(2,20,0) if (!gtk_widget_has_focus(vd->view)) gtk_widget_grab_focus(vd->view); #else if (!GTK_WIDGET_HAS_FOCUS(vd->view)) gtk_widget_grab_focus(vd->view); #endif } }
static gboolean window_menu_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data) #endif { WindowMenu* window_menu = data; if (gtk_widget_has_focus(window_menu->applet)) gtk_paint_focus(gtk_widget_get_style(widget), #if GTK_CHECK_VERSION (3, 0, 0) cr, #else gtk_widget_get_window(widget), #endif gtk_widget_get_state(widget), #if !GTK_CHECK_VERSION (3, 0, 0) NULL, #endif widget, "menu-applet", 0, 0, #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); #else -1, -1); #endif return FALSE; }
static void gb_search_box_popover_set_visible (GbSearchBox *self, gboolean visible) { gboolean entry_has_text; g_return_if_fail (GB_IS_SEARCH_BOX (self)); entry_has_text = !!(gtk_entry_get_text_length (GTK_ENTRY (self->entry))); if (visible == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->button))) return; if (visible && entry_has_text) { if (!gtk_widget_has_focus (GTK_WIDGET (self->entry))) gtk_widget_grab_focus (GTK_WIDGET (self->entry)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), TRUE); } else if (!visible) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->button), FALSE); } }
static gboolean mail_shell_view_mail_display_needs_key (EMailDisplay *mail_display, gboolean with_input) { gboolean needs_key = FALSE; if (gtk_widget_has_focus (GTK_WIDGET (mail_display))) { WebKitWebFrame *frame; WebKitDOMDocument *dom; WebKitDOMElement *element; gchar *name = NULL; frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (mail_display)); if (!frame) return FALSE; dom = webkit_web_frame_get_dom_document (frame); element = webkit_dom_html_document_get_active_element (WEBKIT_DOM_HTML_DOCUMENT (dom)); if (element) name = webkit_dom_node_get_node_name (WEBKIT_DOM_NODE (element)); /* if INPUT or TEXTAREA has focus, then any key press should go there */ if (name && ((with_input && g_ascii_strcasecmp (name, "INPUT") == 0) || g_ascii_strcasecmp (name, "TEXTAREA") == 0)) { needs_key = TRUE; } g_free (name); } return needs_key; }
/** * Initialize search term for address completion. * \param entry Address entry field. */ static gboolean address_completion_complete_address_in_entry(GtkEntry *entry, gboolean next) { gint ncount, cursor_pos; gchar *searchTerm, *new = NULL; cm_return_val_if_fail(entry != NULL, FALSE); if (!gtk_widget_has_focus(GTK_WIDGET(entry))) return FALSE; /* get an address component from the cursor */ searchTerm = get_address_from_edit( entry, &cursor_pos ); if( ! searchTerm ) return FALSE; /* g_print( "search for :::%s:::\n", searchTerm ); */ /* Clear any existing search */ g_free( _compWindow_->searchTerm ); _compWindow_->searchTerm = g_strdup( searchTerm ); /* Perform search on local completion index */ ncount = complete_address( searchTerm ); if( 0 < ncount ) { new = get_next_complete_address(); g_free( new ); }
static GWENHYWFAR_CB int Gtk3Gui_WLineEdit_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue) { GtkWidget *g; g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL)); assert(g); switch(prop) { case GWEN_DialogProperty_Enabled: return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0; case GWEN_DialogProperty_Focus: return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0; return 0; case GWEN_DialogProperty_Width: case GWEN_DialogProperty_Height: /* just ignore these for now */ return 0; default: break; } DBG_WARN(GWEN_LOGDOMAIN, "Function is not appropriate for this type of widget (%s)", GWEN_Widget_Type_toString(GWEN_Widget_GetType(w))); return defaultValue; }
static gboolean toplevel_key_press_event_before (EggSearchBar *self, GdkEventKey *event, GtkWindow *toplevel) { EggSearchBarPrivate *priv = egg_search_bar_get_instance_private (self); g_assert (EGG_IS_SEARCH_BAR (self)); g_assert (event != NULL); g_assert (GTK_IS_WINDOW (toplevel)); switch (event->keyval) { case GDK_KEY_Escape: if (priv->search_mode_enabled && gtk_widget_has_focus (GTK_WIDGET (priv->entry))) { egg_search_bar_set_search_mode_enabled (self, FALSE); return GDK_EVENT_STOP; } break; default: break; } return GDK_EVENT_PROPAGATE; }
tile_expose (GtkWidget * widget, GdkEventExpose * event) #endif { /* FIXME: there ought to be a better way to prevent the focus from being rendered. */ gboolean has_focus; gboolean retval; if ((has_focus = gtk_widget_has_focus (widget))) #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_FOCUSED); #else GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); #endif #if GTK_CHECK_VERSION (3, 0, 0) retval = (*GTK_WIDGET_CLASS (tile_parent_class)->draw) (widget, cr); #else retval = (*GTK_WIDGET_CLASS (tile_parent_class)->expose_event) (widget, event); #endif if (has_focus) #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_FOCUSED, TRUE); #else GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); #endif return retval; }
static gboolean panel_menu_bar_object_on_draw (GtkWidget *widget, cairo_t *cr, gpointer data) { PanelMenuBarObject *menubar = data; if (gtk_widget_has_focus (GTK_WIDGET (menubar))) { GtkStyleContext *context; context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); gtk_style_context_set_state (context, gtk_widget_get_state_flags (widget)); cairo_save (cr); gtk_render_focus (context, cr, 0, 0, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); cairo_restore (cr); gtk_style_context_restore (context); } return FALSE; }
static GWENHYWFAR_CB int Gtk3Gui_WStack_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue) { GtkWidget *g; g=GTK_WIDGET(GWEN_Widget_GetImplData(w, GTK3_DIALOG_WIDGET_REAL)); assert(g); switch(prop) { case GWEN_DialogProperty_Enabled: return (gtk_widget_get_sensitive(GTK_WIDGET(g))==TRUE)?1:0; case GWEN_DialogProperty_Focus: return (gtk_widget_has_focus(GTK_WIDGET(g))==TRUE)?1:0; return 0; case GWEN_DialogProperty_Value: return gtk_notebook_get_current_page(GTK_NOTEBOOK(g)); default: break; } DBG_WARN(GWEN_LOGDOMAIN, "Function is not appropriate for this type of widget (%s)", GWEN_Widget_Type_toString(GWEN_Widget_GetType(w))); return defaultValue; }
gboolean e_composer_paste_text (EMsgComposer *composer, GtkClipboard *clipboard) { EHTMLEditor *editor; EHTMLEditorView *view; EHTMLEditorSelection *editor_selection; gchar *text; g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE); g_return_val_if_fail (GTK_IS_CLIPBOARD (clipboard), FALSE); if (!(text = gtk_clipboard_wait_for_text (clipboard))) return FALSE; editor = e_msg_composer_get_editor (composer); view = e_html_editor_get_view (editor); editor_selection = e_html_editor_view_get_selection (view); /* If WebView doesn't have focus, focus it */ if (!gtk_widget_has_focus (GTK_WIDGET (view))) gtk_widget_grab_focus (GTK_WIDGET (view)); e_html_editor_selection_insert_text (editor_selection, text); g_free (text); return TRUE; }
static gboolean window_menu_on_draw (GtkWidget *widget, cairo_t *cr, gpointer data) { GtkStyleContext *context; GtkStateFlags state; WindowMenu *window_menu = data; if (!gtk_widget_has_focus (window_menu->applet)) return FALSE; state = gtk_widget_get_state_flags (widget); context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); gtk_style_context_set_state (context, state); cairo_save (cr); gtk_render_focus (context, cr, 0., 0., gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); cairo_restore (cr); gtk_style_context_restore (context); return FALSE; }
/* Applet Callback : Cross (enter or leave) the applet. */ gboolean applet_cross_cb(GtkWidget *widget, GdkEventCrossing *event, StickyNotesApplet *applet) { applet->prelighted = event->type == GDK_ENTER_NOTIFY || gtk_widget_has_focus(widget); stickynotes_applet_update_icon(applet); return FALSE; }
/** * gva_main_search_entry_notify_cb: * @entry: the search entry * @pspec: a #GParamSpec * * Handler for #GObject::notify signals to the search entry. * * Hides the search interface when the search entry loses input focus. **/ void gva_main_search_entry_notify_cb (GtkEntry *entry, GParamSpec *pspec) { if (g_str_equal (pspec->name, "has-focus")) if (!gtk_widget_has_focus (GTK_WIDGET (entry))) gtk_widget_hide (GVA_WIDGET_MAIN_SEARCH_HBOX); }
gboolean nsgtk_widget_has_focus(GtkWidget *widget) { #if GTK_CHECK_VERSION(2,20,0) return gtk_widget_has_focus(widget); #else return GTK_WIDGET_HAS_FOCUS(widget); #endif }
static gboolean window_menu_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data) { WindowMenu* window_menu = data; if (gtk_widget_has_focus(window_menu->applet)) gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(widget), NULL, widget, "menu-applet", 0, 0, -1, -1); return FALSE; }
static void update_mouse_cursor (GtkTextView *text_view, gint x, gint y) { static GdkCursor *hand_cursor = NULL; static GdkCursor *regular_cursor = NULL; gboolean hovering = FALSE, hovering_over_link = FALSE, hovering_real; guint32 state; GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view); GtkTextTagTable *tag_table; GtkTextTag *tag; GtkTextIter iter; if (!hand_cursor) { hand_cursor = gdk_cursor_new (GDK_HAND2); regular_cursor = gdk_cursor_new (GDK_XTERM); } g_return_if_fail (buffer != NULL); tag_table = gtk_text_buffer_get_tag_table (buffer); tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG); g_return_if_fail (tag != NULL); state = get_state (buffer); gtk_text_view_get_iter_at_location (text_view, &iter, x, y); hovering_real = gtk_text_iter_has_tag (&iter, tag); hovering_over_link = (state & E_BUFFER_TAGGER_STATE_IS_HOVERING) != 0; if ((state & E_BUFFER_TAGGER_STATE_CTRL_DOWN) == 0) { hovering = FALSE; } else { hovering = hovering_real; } if (hovering != hovering_over_link) { update_state (buffer, E_BUFFER_TAGGER_STATE_IS_HOVERING, hovering); if (hovering && gtk_widget_has_focus (GTK_WIDGET (text_view))) gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), hand_cursor); else gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), regular_cursor); /* XXX Is this necessary? Appears to be a no-op. */ get_pointer_position (text_view, NULL, NULL); } hovering_over_link = (state & E_BUFFER_TAGGER_STATE_IS_HOVERING_TOOLTIP) != 0; if (hovering_real != hovering_over_link) { update_state (buffer, E_BUFFER_TAGGER_STATE_IS_HOVERING_TOOLTIP, hovering_real); gtk_widget_trigger_tooltip_query (GTK_WIDGET (text_view)); } }
void raise_and_focus_dialog (GtkEditable *entry, GtkWidget *parent) { gtk_window_present(GTK_WINDOW(parent)); if (!gtk_widget_has_focus(GTK_WIDGET(entry))) { gtk_widget_grab_focus(GTK_WIDGET(entry)); } }
static gboolean buoh_view_button_press_event (GtkWidget *widget, GdkEventButton *event) { if (!gtk_widget_has_focus (widget)) { gtk_widget_grab_focus (widget); } return FALSE; }
static void gb_editor_tab_emit_focused (GbEditorTab *tab) { g_return_if_fail (GB_IS_EDITOR_TAB (tab)); if (gtk_widget_has_focus (tab->priv->text_view)) { g_signal_emit (tab, gSignals[FOCUSED], 0); } }
static void tile_leave (GtkButton * widget) { if (gtk_widget_has_focus (GTK_WIDGET (widget))) gtk_widget_set_state (GTK_WIDGET (widget), TILE_STATE_FOCUSED); else gtk_widget_set_state (GTK_WIDGET (widget), GTK_STATE_NORMAL); TILE (widget)->entered = FALSE; }
static gint bar_pane_comment_event(GtkWidget *bar, GdkEvent *event) { PaneCommentData *pcd; pcd = g_object_get_data(G_OBJECT(bar), "pane_data"); if (!pcd) return FALSE; if (gtk_widget_has_focus(pcd->comment_view)) return gtk_widget_event(pcd->comment_view, event); return FALSE; }
gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event) { PaneKeywordsData *pkd; pkd = g_object_get_data(G_OBJECT(bar), "pane_data"); if (!pkd) return FALSE; if (gtk_widget_has_focus(pkd->keyword_view)) return gtk_widget_event(pkd->keyword_view, event); return FALSE; }
static void notification_received_cb (VteTerminal *terminal, const gchar *summary, const gchar *body, IdeTerminalPage *self) { g_assert (VTE_IS_TERMINAL (terminal)); g_assert (IDE_IS_TERMINAL_PAGE (self)); if (!gtk_widget_has_focus (GTK_WIDGET (terminal))) gbp_terminal_page_set_needs_attention (self, TRUE); }
static void draw_flat_box (GtkStyle *style, GdkWindow *window, GtkStateType state, GtkShadowType shadow, GdkRectangle *area, GtkWidget *widget, const gchar *detail, gint x, gint y, gint width, gint height) { ThemeMatchData match_data; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); /* FIXME: memory leak */ LOG ("widget=%s, primitive=flat_box, state=%s, shadow=%s, detail='%s', name='%s'", G_OBJECT_TYPE_NAME (widget), enum_value_to_string (gtk_state_type_get_type (), state), enum_value_to_string (gtk_shadow_type_get_type (), shadow), detail, gtk_widget_get_name (widget)); /* Hack because Gtk doesn't give us the correct widget state */ if (widget && GTK_IS_ENTRY(widget)) { if (!gtk_widget_is_sensitive (widget)) state = GTK_STATE_INSENSITIVE; if (gtk_widget_has_focus (widget)) state = GTK_STATE_ACTIVE; } match_data.function = TOKEN_D_FLAT_BOX; match_data.detail = (gchar *)detail; match_data.flags = THEME_MATCH_SHADOW | THEME_MATCH_STATE; match_data.shadow = shadow; match_data.state = state; /* Special handling for treeview cursor row */ if (GTK_IS_TREE_VIEW (widget)) maybe_check_cursor_position (GTK_TREE_VIEW (widget), x, y, width, height, &match_data); if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, x, y, width, height)) GTK_STYLE_CLASS (sapwood_style_parent_class)->draw_flat_box ( style, window, state, shadow, area, widget, detail, x, y, width, height); }
G_MODULE_EXPORT void x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { g_debug("x264_entry_changed_cb ()"); if (video_option_tooltip == NULL) { GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); video_option_tooltip = gtk_widget_get_tooltip_text(eo); } if (!ignore_options_update) { GtkWidget *textview; const gchar *options; textview = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264Option")); ghb_widget_to_setting(ud->settings, textview); options = ghb_dict_get_string(ud->settings, "x264Option"); ignore_options_update = TRUE; ghb_x264_parse_options(ud, options); if (!gtk_widget_has_focus(textview)) { gchar *sopts; sopts = sanitize_x264opts(ud, options); ghb_update_x264Option(ud, sopts); ghb_x264_parse_options(ud, sopts); if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) { GtkWidget *eo; eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra")); char * tt; if (sopts) tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"%s\""), video_option_tooltip, sopts); else tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"\""), video_option_tooltip); gtk_widget_set_tooltip_text(eo, tt); g_free(tt); } g_free(sopts); } ignore_options_update = FALSE; } }
static gboolean popdown_timeout (gpointer data) { DdbCellRendererTextMultilinePrivate *priv; priv = DDB_CELL_RENDERER_TEXT_MULTILINE_GET_PRIVATE (data); priv->entry_menu_popdown_timeout = 0; if (!gtk_widget_has_focus (GTK_WIDGET (priv->entry))) ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done (priv->entry, data); return FALSE; }