Classes | Defines | Functions | Variables

goffice-gtk.c File Reference

#include <goffice/goffice-config.h>
#include "goffice-gtk.h"
#include <goffice/app/go-cmd-context.h>
#include <goffice/utils/go-file.h>
#include <goffice/goffice-priv.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <atk/atkrelation.h>
#include <atk/atkrelationset.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
#include <gsf/gsf-input-stdio.h>
#include <gsf/gsf-input-textline.h>
#include <string.h>
#include <errno.h>

Classes

struct  CBHelpPaths

Defines

#define PREVIEW_HSIZE   150
#define PREVIEW_VSIZE   150
#define _VPRINTF_MESSAGE(format, args, msg)
#define VPRINTF_MESSAGE(format, args, msg)
#define MAYBE_SWAP(ifirst, ilast)

Functions

GtkWidget * go_gtk_button_new_with_stock (char const *text, char const *stock_id)
 go_gtk_button_new_with_stock
GtkWidget * go_gtk_dialog_add_button (GtkDialog *dialog, const gchar *text, const gchar *stock_id, gint response_id)
 go_gtk_dialog_add_button : : dialog you want to add a button : button label : stock icon id : respond id when button clicked
void go_gtk_editable_enters (GtkWindow *window, GtkWidget *w)
 go_gtk_editable_enters: : :
GdkPixbuf * go_pixbuf_intelligent_scale (GdkPixbuf *buf, guint width, guint height)
void go_gtk_widget_disable_focus (GtkWidget *w)
int go_pango_measure_string (PangoContext *context, const PangoFontDescription *font_desc, const char *str)
static void cb_parent_mapped (GtkWidget *parent, GtkWindow *window)
void go_gtk_window_set_transient (GtkWindow *toplevel, GtkWindow *window)
 go_gtk_window_set_transient : The calling window : the transient window
static gint cb_non_modal_dialog_keypress (GtkWidget *w, GdkEventKey *e)
void go_gtk_nonmodal_dialog (GtkWindow *toplevel, GtkWindow *dialog)
static void fsel_response_cb (GtkFileChooser *dialog, gint response_id, gboolean *result)
static gint gu_delete_handler (GtkDialog *dialog, G_GNUC_UNUSED GdkEventAny *event, G_GNUC_UNUSED gpointer data)
gboolean go_gtk_file_sel_dialog (GtkWindow *toplevel, GtkWidget *w)
static gboolean filter_images (const GtkFileFilterInfo *filter_info, G_GNUC_UNUSED gpointer data)
static void update_preview_cb (GtkFileChooser *chooser)
static GtkFileChooser * gui_image_chooser_new (gboolean is_save)
char * go_gtk_select_image (GtkWindow *toplevel, const char *initial)
static void add_atk_relation (GtkWidget *w0, GtkWidget *w1, AtkRelationType type)
 gui_get_image_save_info: : a GtkWindow : a GSList of supported file formats : default file format : export resolution
void go_atk_setup_label (GtkWidget *label, GtkWidget *target)
 go_atk_setup_label : : GtkWidget : GtkWidget
static void go_help_display (CBHelpPaths const *paths)
static void cb_help (CBHelpPaths const *paths)
void go_gtk_help_button_init (GtkWidget *w, char const *data_dir, char const *app, char const *linkk)
gboolean go_gtk_url_is_writeable (GtkWindow *parent, char const *uri, gboolean overwrite_by_default)
 go_gtk_url_is_writeable: : GtkWindow : :
gint go_gtk_dialog_run (GtkDialog *dialog, GtkWindow *parent)
 go_gtk_dialog_run
void go_gtk_notice_dialog (GtkWindow *parent, GtkMessageType type, const gchar *format,...)
void go_gtk_notice_nonmodal_dialog (GtkWindow *parent, GtkWidget **ref, GtkMessageType type, const gchar *format,...)
gboolean go_gtk_query_yes_no (GtkWindow *parent, gboolean default_answer, const gchar *format,...)
in the goffice_icon_dir.

go_pixbuf_new_from_file : :

utility routine to create pixbufs from file

Returns a GdkPixbuf that the caller is responsible for.

GdkPixbuf * go_pixbuf_new_from_file (char const *filename)
static gint gtk_dialog_get_response_for_widget (GtkDialog *dialog, GtkWidget *widget)
void go_dialog_guess_alternative_button_order (GtkDialog *dialog)
 go_dialog_guess_alternative_button_order: :

Variables

static gboolean have_pixbufexts = FALSE
static GSList * pixbufexts = NULL

Define Documentation

#define _VPRINTF_MESSAGE (   format,
  args,
  msg 
)
Value:
va_start (args, format); \
                      msg = g_strdup_vprintf (format, args); \
                      va_end (args);

Referenced by go_gtk_query_yes_no().

#define MAYBE_SWAP (   ifirst,
  ilast 
)
Value:
if (ifirst >= 0 && ilast >= 0 && ifirst > ilast) {  \
        int tmp;                    \
                                \
        tmp = new_order[ifirst];            \
        new_order[ifirst] = new_order[ilast];       \
        new_order[ilast] = tmp;             \
                                \
        tmp = ifirst;                   \
        ifirst = ilast;                 \
        ilast = tmp;                    \
                                \
        again = TRUE;                   \
        any = TRUE;                 \
    }
#define PREVIEW_HSIZE   150
#define PREVIEW_VSIZE   150

Referenced by update_preview_cb().

#define VPRINTF_MESSAGE (   format,
  args,
  msg 
)
Value:
_VPRINTF_MESSAGE (format, args, msg); \
                     g_return_if_fail (msg != NULL);

Referenced by go_gtk_notice_dialog(), and go_gtk_notice_nonmodal_dialog().


Function Documentation

static void add_atk_relation ( GtkWidget *  w0,
GtkWidget *  w1,
AtkRelationType  type 
) [static]

gui_get_image_save_info: : a GtkWindow : a GSList of supported file formats : default file format : export resolution

Opens a file chooser and let user choose file URI and format in a list of supported ones.

returns: file URI string, file GOImageFormat stored in , and export resolution in .

Referenced by go_atk_setup_label().

static void cb_help ( CBHelpPaths const *  paths  )  [static]

References go_help_display().

Referenced by go_gtk_help_button_init().

static gint cb_non_modal_dialog_keypress ( GtkWidget *  w,
GdkEventKey *  e 
) [static]

Referenced by go_gtk_nonmodal_dialog().

static void cb_parent_mapped ( GtkWidget *  parent,
GtkWindow *  window 
) [static]
static gboolean filter_images ( const GtkFileFilterInfo *  filter_info,
G_GNUC_UNUSED gpointer  data 
) [static]

References gchar.

Referenced by gui_image_chooser_new().

static void fsel_response_cb ( GtkFileChooser *  dialog,
gint  response_id,
gboolean *  result 
) [static]

Referenced by go_gtk_file_sel_dialog().

void go_atk_setup_label ( GtkWidget *  label,
GtkWidget *  target 
)

go_atk_setup_label : : GtkWidget : GtkWidget

A convenience routine to setup label-for/labeled-by relationship between a pair of widgets

References add_atk_relation().

void go_dialog_guess_alternative_button_order ( GtkDialog *  dialog  ) 

go_dialog_guess_alternative_button_order: :

This function inspects the buttons in the dialog and comes up with a reasonable alternative dialog order.

References gtk_dialog_get_action_area(), gtk_dialog_get_response_for_widget(), and MAYBE_SWAP.

GtkWidget* go_gtk_button_new_with_stock ( char const *  text,
char const *  stock_id 
)

go_gtk_button_new_with_stock

Code from gedit

Creates a new GtkButton with custom label and stock image.

text : button label stock_id : id for stock icon

return : newly created button

GtkWidget* go_gtk_dialog_add_button ( GtkDialog *  dialog,
const gchar *  text,
const gchar *  stock_id,
gint  response_id 
)

go_gtk_dialog_add_button : : dialog you want to add a button : button label : stock icon id : respond id when button clicked

Creates and adds a button with stock image to the action area of an existing dialog. Code from gedit

return : newly created button

References go_gtk_button_new_with_stock().

gint go_gtk_dialog_run ( GtkDialog *  dialog,
GtkWindow *  parent 
)

go_gtk_dialog_run

Pop up a dialog as child of a window.

References go_gtk_window_set_transient().

void go_gtk_editable_enters ( GtkWindow *  window,
GtkWidget *  w 
)

go_gtk_editable_enters: : :

Normally if there's an editable widget (such as GtkEntry) in your dialog, pressing Enter will activate the editable rather than the default dialog button. However, in most cases, the user expects to type something in and then press enter to close the dialog. This function enables that behavior.

References cb_activate_default().

gboolean go_gtk_file_sel_dialog ( GtkWindow *  toplevel,
GtkWidget *  w 
)
void go_gtk_help_button_init ( GtkWidget *  w,
char const *  data_dir,
char const *  app,
char const *  linkk 
)
void go_gtk_nonmodal_dialog ( GtkWindow *  toplevel,
GtkWindow *  dialog 
)
void go_gtk_notice_dialog ( GtkWindow *  parent,
GtkMessageType  type,
const gchar *  format,
  ... 
)
void go_gtk_notice_nonmodal_dialog ( GtkWindow *  parent,
GtkWidget **  ref,
GtkMessageType  type,
const gchar *  format,
  ... 
)

References gchar, and VPRINTF_MESSAGE.

gboolean go_gtk_query_yes_no ( GtkWindow *  parent,
gboolean  default_answer,
const gchar *  format,
  ... 
)
char* go_gtk_select_image ( GtkWindow *  toplevel,
const char *  initial 
)
gboolean go_gtk_url_is_writeable ( GtkWindow *  parent,
char const *  uri,
gboolean  overwrite_by_default 
)

go_gtk_url_is_writeable: : GtkWindow : :

Check if it makes sense to try saving. If it's an existing file and writable for us, ask if we want to overwrite. We check for other problems, but if we miss any, the saver will report. So it doesn't have to be bulletproof.

FIXME: The message boxes should really be children of the file selector, not the workbook.

References _, go_basename_from_uri(), go_dirname_from_uri(), go_file_access(), go_filename_from_uri(), go_gtk_dialog_run(), go_gtk_notice_dialog(), and W_OK.

void go_gtk_widget_disable_focus ( GtkWidget *  w  ) 
void go_gtk_window_set_transient ( GtkWindow *  toplevel,
GtkWindow *  window 
)

go_gtk_window_set_transient : The calling window : the transient window

Make the window a child of the workbook in the command context, if there is one. The function duplicates the positioning functionality in gnome_dialog_set_parent, but does not require the transient window to be a GnomeDialog.

References cb_parent_mapped(), and gtk_widget_get_mapped().

static void go_help_display ( CBHelpPaths const *  paths  )  [static]
int go_pango_measure_string ( PangoContext *  context,
const PangoFontDescription *  font_desc,
const char *  str 
)
GdkPixbuf* go_pixbuf_intelligent_scale ( GdkPixbuf *  buf,
guint  width,
guint  height 
)
GdkPixbuf* go_pixbuf_new_from_file ( char const *  filename  ) 

References go_sys_icon_dir().

static gint gtk_dialog_get_response_for_widget ( GtkDialog *  dialog,
GtkWidget *  widget 
) [static]
static gint gu_delete_handler ( GtkDialog *  dialog,
G_GNUC_UNUSED GdkEventAny *  event,
G_GNUC_UNUSED gpointer  data 
) [static]

Referenced by go_gtk_file_sel_dialog().

static GtkFileChooser* gui_image_chooser_new ( gboolean  is_save  )  [static]
static void update_preview_cb ( GtkFileChooser *  chooser  )  [static]

Variable Documentation

gboolean have_pixbufexts = FALSE [static]
GSList* pixbufexts = NULL [static]