Functions

xap_UnixDialogHelper.cpp File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <goffice/gtk/goffice-gtk.h>
#include "ut_debugmsg.h"
#include "ut_assert.h"
#include "ut_string.h"
#include "xav_View.h"
#include "xap_Frame.h"
#include "xap_UnixFrameImpl.h"
#include "xap_App.h"
#include "xap_UnixDialogHelper.h"
#include "xap_Dialog.h"

Functions

static gboolean focus_in_event (GtkWidget *widget, GdkEvent *, gpointer)
static gboolean destroy_event (GtkWidget *, GdkEvent *, gpointer)
static gboolean focus_out_event (GtkWidget *widget, GdkEvent *, gpointer)
static gboolean focus_out_event_Modeless (GtkWidget *widget, GdkEvent *, gpointer)
static gboolean focus_in_event_Modeless (GtkWidget *widget, GdkEvent *, gpointer)
static gboolean focus_in_event_ModelessOther (GtkWidget *widget, GdkEvent *, std::pointer_to_unary_function< int, gboolean > *other_function)
GtkBuilder * newDialogBuilder (const char *name)
 load a GtkBuilder for a dialog using the standard path.
void connectFocus (GtkWidget *widget, const XAP_Frame *frame)
void connectFocusModelessOther (GtkWidget *widget, const XAP_App *pApp, std::pointer_to_unary_function< int, gboolean > *other_function)
void connectFocusModeless (GtkWidget *widget, const XAP_App *pApp)
bool isTransientWindow (GtkWindow *window, GtkWindow *parent)
bool helpLocalizeAndOpenURL (const char *pathBeforeLang, const char *pathAfterLang, const char *remoteURLbase)
static void sDoHelp (XAP_Dialog *pDlg)
static gint modal_keypress_cb (GtkWidget *, GdkEventKey *event, XAP_Dialog *pDlg)
static gint nonmodal_keypress_cb (GtkWidget *, GdkEventKey *event, XAP_Dialog *pDlg)
static void help_button_cb (GObject *, XAP_Dialog *pDlg)
static void sAddHelpButton (GtkDialog *me, XAP_Dialog *pDlg)
void centerDialog (GtkWidget *parent, GtkWidget *child, bool set_transient_for)
void abiSetupModalDialog (GtkDialog *dialog, XAP_Frame *pFrame, XAP_Dialog *pDlg, gint defaultResponse)
gint abiRunModalDialog (GtkDialog *me, bool destroyDialog, AtkRole role)
gint abiRunModalDialog (GtkDialog *me, XAP_Frame *pFrame, XAP_Dialog *pDlg, gint defaultResponse, bool destroyDialog, AtkRole role)
void abiSetupModelessDialog (GtkDialog *me, XAP_Frame *pFrame, XAP_Dialog *pDlg, gint defaultResponse, bool abi_modeless, AtkRole)
GtkWidget * abiDialogNew (const char *role, gboolean resizable)
GtkWidget * abiDialogNew (const char *role, gboolean resizable, const char *title,...)
GtkWidget * abiGtkMenuFromCStrVector (const UT_GenericVector< const char * > &vec, GCallback cb, gpointer data)
void abiDialogSetTitle (GtkWidget *dlg, const char *title,...)
GtkWidget * abiAddStockButton (GtkDialog *me, const gchar *btn_id, gint response_id)
GtkWidget * abiAddButton (GtkDialog *me, const gchar *btn_id, gint response_id)
void abiDestroyWidget (GtkWidget *me)
void localizeLabel (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void convertMnemonics (gchar *s)
std::string & convertMnemonics (std::string &s)
void localizeLabelUnderline (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void localizeLabelMarkup (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void localizeButton (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void localizeButtonUnderline (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void localizeButtonMarkup (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void localizeMenu (GtkWidget *widget, const XAP_StringSet *pSS, XAP_String_Id id)
void setLabelMarkup (GtkWidget *widget, const gchar *str)
GtkStyle * get_ensured_style (GtkWidget *w)
GtkWidget * createDrawingArea ()
void messageBoxOK (const char *message)
GdkWindow * getRootWindow (GtkWidget *widget)
static void activate_button (GtkEntry *entry, gpointer user_data)
void abiSetActivateOnWidgetToActivateButton (GtkWidget *source, GtkWidget *button)
 When the source widget gets the activate signal, sent activate to the button.

Function Documentation

GtkWidget* abiAddButton ( GtkDialog *  me,
const gchar *  btn_id,
gint  response_id 
)

Add this locale-sensitive button to the dialog and make it sensitive

References UT_return_val_if_fail.

GtkWidget* abiAddStockButton ( GtkDialog *  me,
const gchar *  btn_id,
gint  response_id 
)

Add this stock button to the dialog and make it sensitive

References UT_return_val_if_fail.

void abiDestroyWidget ( GtkWidget *  me  ) 

Calls gtk_widget_destroy on if is non-null and GTK_IS_WIDGET(me)

GtkWidget* abiDialogNew ( const char *  role,
gboolean  resizable,
const char *  title,
  ... 
)

Create a new GtkDialog with this title

References abiDialogNew(), UT_String::c_str(), and UT_String_vprintf().

GtkWidget* abiDialogNew ( const char *  role,
gboolean  resizable 
)

Create a new GtkDialog

void abiDialogSetTitle ( GtkWidget *  dlg,
const char *  title,
  ... 
)

Set the title of a gtk dialog

References UT_String::c_str(), and UT_String_vprintf().

GtkWidget* abiGtkMenuFromCStrVector ( const UT_GenericVector< const char * > &  vec,
GCallback  cb,
gpointer  data 
)

Returns a GtkMenu with items having label fetched from UTF-8 CStr from UT_Vector. All menu item will have the index of the item stored in its user-data

References UT_GenericVector< T >::getItemCount().

gint abiRunModalDialog ( GtkDialog *  me,
bool  destroyDialog,
AtkRole  role 
)

References abiDestroyWidget().

gint abiRunModalDialog ( GtkDialog *  me,
XAP_Frame pFrame,
XAP_Dialog pDlg,
gint  defaultResponse,
bool  destroyDialog,
AtkRole  role 
)

Runs the dialog as a modal dialog 1) Connect focus to toplevel frame 2) Centers dialog over toplevel window 3) Connects F1 to help system 4) Makes dialog modal 5) Sets the default button to defaultResponse, sets ESC to close 6) Returns value of gtk_dialog_run(me) 7) If is true, destroys the dialog, else you have to call abiDestroyWidget()

References abiRunModalDialog(), abiSetupModalDialog(), and XAP_Dialog::maybeReallowPopupPreviewBubbles().

void abiSetActivateOnWidgetToActivateButton ( GtkWidget *  source,
GtkWidget *  button 
)

When the source widget gets the activate signal, sent activate to the button.

This allows GtkEntry widgets to explicitly close the dialog with the OK button when the user presses return while leaving the default dialog action to be CANCEL.

References activate_button().

void abiSetupModalDialog ( GtkDialog *  dialog,
XAP_Frame pFrame,
XAP_Dialog pDlg,
gint  defaultResponse 
)
void abiSetupModelessDialog ( GtkDialog *  me,
XAP_Frame pFrame,
XAP_Dialog pDlg,
gint  defaultResponse,
bool  abi_modeless,
AtkRole   
)

Sets up the dialog as a modeless dialog 1) Connect focus to toplevel frame 2) Centers dialog over toplevel window 3) Makes the App remember this modeless dialog 4) Connects F1 to help system 5) Makes dialog non-modal (modeless)

6) Sets the default button to defaultResponse, sets ESC to close

References centerDialog(), connectFocusModeless(), XAP_App::getApp(), XAP_Dialog::getDialogId(), XAP_Frame::getFrameImpl(), XAP_UnixFrameImpl::getTopLevelWindow(), XAP_Dialog::maybeClosePopupPreviewBubbles(), nonmodal_keypress_cb(), XAP_App::rememberModelessId(), and sAddHelpButton().

static void activate_button ( GtkEntry *  entry,
gpointer  user_data 
) [static]
void centerDialog ( GtkWidget *  parent,
GtkWidget *  child,
bool  set_transient_for 
)

Centers a dialog, makes it transient, sets up the right window icon

References go_dialog_guess_alternative_button_order(), UT_return_if_fail, and xxx_UT_DEBUGMSG.

void connectFocus ( GtkWidget *  widget,
const XAP_Frame frame 
)
void connectFocusModeless ( GtkWidget *  widget,
const XAP_App pApp 
)
void connectFocusModelessOther ( GtkWidget *  widget,
const XAP_App pApp,
std::pointer_to_unary_function< int, gboolean > *  other_function 
)
std::string& convertMnemonics ( std::string &  s  ) 
void convertMnemonics ( gchar *  s  ) 

References UT_return_if_fail.

GtkWidget* createDrawingArea (  ) 

Creates a new GdkDrawingArea with the proper colormap and visual This returns a single-buffered widget. DEPRECATED: please use gtk_drawing_area_new() directly and make your implementation work with double-buffering in new code!

static gboolean destroy_event ( GtkWidget *  ,
GdkEvent *  ,
gpointer   
) [static]
static gboolean focus_in_event ( GtkWidget *  widget,
GdkEvent *  ,
gpointer   
) [static]
static gboolean focus_in_event_Modeless ( GtkWidget *  widget,
GdkEvent *  ,
gpointer   
) [static]
static gboolean focus_in_event_ModelessOther ( GtkWidget *  widget,
GdkEvent *  ,
std::pointer_to_unary_function< int, gboolean > *  other_function 
) [static]
static gboolean focus_out_event ( GtkWidget *  widget,
GdkEvent *  ,
gpointer   
) [static]
static gboolean focus_out_event_Modeless ( GtkWidget *  widget,
GdkEvent *  ,
gpointer   
) [static]
GtkStyle* get_ensured_style ( GtkWidget *  w  ) 

For a parented/displayed widget, this will just return gtk_widget_ensure_style(w). For a non-displayed widgets, This will return a valid GtkStyle for that widget

References style, and UT_ASSERT.

GdkWindow* getRootWindow ( GtkWidget *  widget  ) 

References UT_return_val_if_fail.

static void help_button_cb ( GObject *  ,
XAP_Dialog pDlg 
) [static]

References sDoHelp().

Referenced by sAddHelpButton().

bool helpLocalizeAndOpenURL ( const char *  pathBeforeLang,
const char *  pathAfterLang,
const char *  remoteURLbase 
)
bool isTransientWindow ( GtkWindow *  window,
GtkWindow *  parent 
)
void localizeButton ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes a button given the string id

References FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_XML_cloneNoAmpersands(), and UT_UTF8String::utf8_str().

void localizeButtonMarkup ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes a button given the string id It formats its label using the current button label as a format string. It is assumed to be something like "<span size="larger">%s</span>". Note that in addition to doing markup, ampersands will be converted to underscores/mnemonic since this makes sense for buttons

References UT_String::c_str(), convertMnemonics(), FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_ASSERT, UT_String_sprintf(), and UT_UTF8String::utf8_str().

void localizeButtonUnderline ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes a button given the string id Ampersands will be converted to underscores/mnemonics

References convertMnemonics(), FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_ASSERT, and UT_UTF8String::utf8_str().

void localizeLabel ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes a label given the string id

References FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_XML_cloneNoAmpersands(), and UT_UTF8String::utf8_str().

void localizeLabelMarkup ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes the label of a widget given the string id It formats the label using the current label of the widget as a format string. The current label is assumed to be something like "<span size="larger">%s</span>".

References FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_String_sprintf(), UT_XML_cloneNoAmpersands(), and UT_UTF8String::utf8_str().

void localizeLabelUnderline ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes the label of a widget given the string id Ampersands will be converted to underscores/mnemonics

References convertMnemonics(), FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_ASSERT, and UT_UTF8String::utf8_str().

void localizeMenu ( GtkWidget *  widget,
const XAP_StringSet pSS,
XAP_String_Id  id 
)

Localizes the label of a Menu widget given the string id

References FREEP, gchar, XAP_StringSet::getValueUTF8(), s, UT_XML_cloneNoAmpersands(), and UT_UTF8String::utf8_str().

void messageBoxOK ( const char *  message  ) 

This is a small message box for startup warnings and/or errors. Please do NOT use this for normal system execution user messages; use the XAP_UnixDialog_MessageBox class for that. We can't use that here because there is no parent frame, etc.

static gint modal_keypress_cb ( GtkWidget *  ,
GdkEventKey *  event,
XAP_Dialog pDlg 
) [static]

Catch F1 keypress over a dialog and open up the help file, if any

References sDoHelp().

Referenced by abiSetupModalDialog().

GtkBuilder* newDialogBuilder ( const char *  name  ) 

load a GtkBuilder for a dialog using the standard path.

Parameters:
name the filename of the dialog (no path)
Returns:
the GtkBuilder or NULL. The returned object my be freed as usual.

References abicollab::service::error(), XAP_App::getApp(), UT_ASSERT, and UT_DEBUGMSG.

static gint nonmodal_keypress_cb ( GtkWidget *  ,
GdkEventKey *  event,
XAP_Dialog pDlg 
) [static]

Catch F1 keypress over a dialog and open up the help file, if any

References sDoHelp().

Referenced by abiSetupModelessDialog().

static void sAddHelpButton ( GtkDialog *  me,
XAP_Dialog pDlg 
) [static]
static void sDoHelp ( XAP_Dialog pDlg  )  [static]
void setLabelMarkup ( GtkWidget *  widget,
const gchar *  str 
)

Sets the label of "widget" to "str". It formats the label using the current label of the widget as a format string. The current label is assumed to be something like "<span size="larger">%s</span>".

References UT_String::c_str(), and UT_String_sprintf().