ROX-CLib: gtksavebox.c File Reference

- Main Page
- Data Structures
- Files
- Related Pages

- File List
- Globals

# gtksavebox.c File Reference

Drag and drop saving widget for GTK+. More...

`#include "rox-clib.h"`
`#include <unistd.h>`
`#include <string.h>`
`#include <errno.h>`
`#include "gdk/gdkkeysyms.h"`
`#include "gtksavebox.h"`
`#include "gtk/gtkwidget.h"`
`#include "gtk/gtkalignment.h"`
`#include "gtk/gtkdnd.h"`
`#include "gtk/gtkbutton.h"`
`#include "gtk/gtksignal.h"`
`#include "gtk/gtkhbox.h"`
`#include "gtk/gtkhbbox.h"`
`#include "gtk/gtkeventbox.h"`
`#include "gtk/gtkentry.h"`
`#include "gtk/gtkmessagedialog.h"`
`#include "gtk/gtkhseparator.h"`
`#include "gtk/gtkvbox.h"`
`#include "gtk/gtkdialog.h"`
`#include "gtk/gtklabel.h"`
`#include "gtk/gtkimage.h"`
`#include "gtk/gtkstock.h"`
`#include "global.h"`
`#include "rox_path.h"`

## Functions
GType | gtk_savebox_get_type (void)
GtkWidget * | gtk_savebox_new (const gchar *action)
void | gtk_savebox_set_icon (GtkSavebox *savebox, GdkPixbuf *pixbuf)
void | gtk_savebox_set_pathname (GtkSavebox *savebox, const gchar *pathname)
void | gtk_savebox_set_has_discard (GtkSavebox *savebox, gboolean setting)
GtkWidget * | gtk_savebox_get_extension_area (GtkSavebox *savebox)

## Detailed Description

Drag and drop saving widget for GTK+.

This version has been altered for inclusion in ROX-CLib. If it makes it into Gtk+ then it will be removed from ROX-CLib.

Behaviour:

- Clicking Save or pressing Return:
  - Emits 'save_to_file',
  - Emits 'saved_to_uri' (with the same pathname),
  - Destroys the widget.

- Clicking Cancel or pressing Escape:
  - Destroys the widget.

- Dragging the data somewhere:
  - Will either emit 'save_to_file' or get the selection,
  - Emits 'saved_to_uri' (possibly with a `NULL` URI),
  - Destroys the widget.

- Clicking Discard:
  - Emits 'saved_to_uri' with a `NULL` URI,
  - Destroys the widget.

To clarify: 'saved_to_uri' indicates that the save was successful. A `NULL` URI just means that the data was saved to another application rather than a fixed address. Data should only be marked unmodified when saved_to_uri is called with a non-`NULL` URI.

Discard is a bit like a successful save to a null device. The data should be discarded when saved_to_uri is called, whatever URI is set to.

Signals:

gint save_to_file (GtkSavebox *savebox, const gchar *pathname) Save the data to disk using this pathname. Return `GTK_XDS_SAVED` on success, or `GTK_XDS_SAVE_ERROR` on failure (and report the error to the user somehow). DO NOT mark the data unmodified or change the pathname for the file - this might be a scrap file transfer.

void saved_to_uri (GtkSavebox *savebox, const gchar *uri) The data is saved. If 'uri' is non-`NULL`, mark the file as unmodified and update the pathname/uri for the file to the one given.

Author:
  Thomas Leonard

Version:
  Id
    gtksavebox.c,v 1.5 2005/12/07 11:43:12 stephen Exp
  based on gtksavebox.c,v 1.28 2002/05/12 16:28:42 tal197 from ROX-Filer 1.3.5

## Function Documentation

GtkWidget* gtk_savebox_get_extension_area | ( | GtkSavebox * | savebox | ) |

Return the extension area, a vbox just above the buttons where additional widgets may be placed.

Parameters:

  `[in,out]` | savebox | Save box widget

GType gtk_savebox_get_type | ( | void |  | ) |

Returns:
  type code for GtkSavebox

GtkWidget* gtk_savebox_new | ( | const gchar * | action | ) |

Create and return a new GtkSavebox widget.

Parameters:

  `[in]` | action | Label to use in the Save button

Returns:
  pointer to the widget

void gtk_savebox_set_has_discard | ( | GtkSavebox * | savebox,
|  | gboolean | setting |
| ) |  |  |

Set whether the discard area is show. Normally this is hidden but contains a single "Discard" button.

Parameters:

  `[in,out]` | savebox | Save box widget
  `[in]` | setting | non-zero to show discard area

void gtk_savebox_set_icon | ( | GtkSavebox * | savebox,
|  | GdkPixbuf * | pixbuf |
| ) |  |  |

Set the icon used for dragging the file.

Parameters:

  `[in,out]` | savebox | Save box widget
  `[in]` | pixbuf | image to use for icon

void gtk_savebox_set_pathname | ( | GtkSavebox * | savebox,
|  | const gchar * | pathname |
| ) |  |  |

Set the initial path to show in the widget.

Parameters:

  `[in,out]` | savebox | Save box widget
  `[in]` | pathname | path to use