gboolean mouse_bind(const gchar *buttonstr, ObFrameContext context, ObMouseAction mact, ObActionsAct *action) { guint state, button; ObMouseBinding *b; GSList *it; g_assert(context != OB_FRAME_CONTEXT_NONE); if (!translate_button(buttonstr, &state, &button)) { g_message(_("Invalid button \"%s\" in mouse binding"), buttonstr); return FALSE; } for (it = bound_contexts[context]; it; it = g_slist_next(it)) { b = it->data; if (b->state == state && b->button == button) { b->actions[mact] = g_slist_append(b->actions[mact], action); return TRUE; } } /* add the binding */ b = g_slice_new0(ObMouseBinding); b->state = state; b->button = button; b->actions[mact] = g_slist_append(NULL, action); bound_contexts[context] = g_slist_append(bound_contexts[context], b); return TRUE; }
gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr, ObMouseAction mact, ObActionsAct *action) { guint state, button; ObFrameContext context; ObMouseBinding *b; GSList *it; if (!translate_button(buttonstr, &state, &button)) { g_message(_("Invalid button \"%s\" in mouse binding"), buttonstr); return FALSE; } context = frame_context_from_string(contextstr); if (!context) { g_message(_("Invalid context \"%s\" in mouse binding"), contextstr); return FALSE; } for (it = bound_contexts[context]; it; it = g_slist_next(it)) { b = it->data; if (b->state == state && b->button == button) { b->actions[mact] = g_slist_append(b->actions[mact], action); return TRUE; } } /* add the binding */ b = g_new0(ObMouseBinding, 1); b->state = state; b->button = button; b->actions[mact] = g_slist_append(NULL, action); bound_contexts[context] = g_slist_append(bound_contexts[context], b); return TRUE; }
QMessageBox::StandardButton OBSMessageBox::question( QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { QMessageBox mb(QMessageBox::Question, title, text, buttons, parent); mb.setDefaultButton(defaultButton); if (buttons & QMessageBox::Ok) \ mb.setButtonText(QMessageBox::Ok, QTStr("OK")); #define translate_button(x) \ if (buttons & QMessageBox::x) \ mb.setButtonText(QMessageBox::x, QTStr(#x)); translate_button(Open); translate_button(Save); translate_button(Cancel); translate_button(Close); translate_button(Discard); translate_button(Apply); translate_button(Reset); translate_button(Yes); translate_button(No); translate_button(No); translate_button(Abort); translate_button(Retry); translate_button(Ignore); #undef translate_button return (QMessageBox::StandardButton)mb.exec(); }