void dlg_init (WDialog * h) { Widget *wh = WIDGET (h); if (top_dlg != NULL && widget_get_state (WIDGET (top_dlg->data), WST_MODAL)) widget_set_state (wh, WST_MODAL, TRUE); /* add dialog to the stack */ top_dlg = g_list_prepend (top_dlg, h); /* Initialize dialog manager and widgets */ if (widget_get_state (wh, WST_CONSTRUCT)) { if (!widget_get_state (wh, WST_MODAL)) dialog_switch_add (h); send_message (h, NULL, MSG_INIT, 0, NULL); dlg_broadcast_msg (h, MSG_INIT); dlg_read_history (h); } /* Select the first widget that takes focus */ while (h->current != NULL && !widget_get_options (WIDGET (h->current->data), WOP_SELECTABLE) && !widget_get_state (WIDGET (h->current->data), WST_DISABLED)) dlg_set_current_widget_next (h); widget_set_state (wh, WST_ACTIVE, TRUE); dlg_redraw (h); /* focus found widget */ if (h->current != NULL) widget_set_state (WIDGET (h->current->data), WST_FOCUSED, TRUE); h->ret_value = 0; }
void textbox_font ( textbox *tb, TextBoxFontType tbft ) { TextBoxFontType t = tbft & STATE_MASK; if ( tb == NULL ) { return; } // ACTIVE has priority over URGENT if both set. if ( t == ( URGENT | ACTIVE ) ) { t = ACTIVE; } switch ( ( tbft & FMOD_MASK ) ) { case HIGHLIGHT: widget_set_state ( WIDGET ( tb ), theme_prop_names[t][1] ); break; case ALT: widget_set_state ( WIDGET ( tb ), theme_prop_names[t][2] ); break; default: widget_set_state ( WIDGET ( tb ), theme_prop_names[t][0] ); break; } if ( tb->tbft != tbft || tb->widget.state == NULL ) { tb->update = TRUE; widget_queue_redraw ( WIDGET ( tb ) ); } tb->tbft = tbft; }
static inline void edit_quit (WDialog * h) { GList *l; WEdit *e = NULL; GSList *m = NULL; GSList *me; /* don't stop the dialog before final decision */ widget_set_state (WIDGET (h), WST_ACTIVE, TRUE); /* check window state and get modified files */ for (l = h->widgets; l != NULL; l = g_list_next (l)) if (edit_widget_is_editor (CONST_WIDGET (l->data))) { e = (WEdit *) l->data; if (e->drag_state != MCEDIT_DRAG_NONE) { edit_restore_size (e); g_slist_free (m); return; } /* create separate list because widget_select() changes the window position in Z order */ if (e->modified) m = g_slist_prepend (m, l->data); } for (me = m; me != NULL; me = g_slist_next (me)) { e = (WEdit *) me->data; widget_select (WIDGET (e)); if (!edit_ok_to_exit (e)) break; } /* if all files were checked, quit editor */ if (me == NULL) dlg_stop (h); g_slist_free (m); }
static void widget_do_focus (Widget * w, gboolean enable) { if (w != NULL && widget_get_state (WIDGET (w->owner), WST_FOCUSED)) widget_set_state (w, WST_FOCUSED, enable); }
void dlg_stop (WDialog * h) { widget_set_state (WIDGET (h), WST_CLOSED, TRUE); }