app: some cleanup in the new file dialog classes

This commit is contained in:
Michael Natterer 2015-09-09 00:00:50 +02:00
parent d1e2b2c162
commit bd9afce9e2
5 changed files with 25 additions and 30 deletions

View File

@ -52,6 +52,7 @@ G_DEFINE_TYPE (GimpExportDialog, gimp_export_dialog,
#define parent_class gimp_export_dialog_parent_class #define parent_class gimp_export_dialog_parent_class
static void static void
gimp_export_dialog_class_init (GimpExportDialogClass *klass) gimp_export_dialog_class_init (GimpExportDialogClass *klass)
{ {
@ -62,6 +63,7 @@ gimp_export_dialog_init (GimpExportDialog *dialog)
{ {
} }
/* public functions */ /* public functions */
GtkWidget * GtkWidget *
@ -215,5 +217,3 @@ gimp_export_dialog_set_image (GimpExportDialog *dialog,
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
} }
/* private functions */

View File

@ -49,15 +49,10 @@
#include "gimp-intl.h" #include "gimp-intl.h"
/* an arbitrary limit to keep the file dialog from becoming too wide */ /* an arbitrary limit to keep the file dialog from becoming too wide */
#define MAX_EXTENSIONS 4 #define MAX_EXTENSIONS 4
typedef struct _GimpFileDialogState GimpFileDialogState;
struct _GimpFileDialogState
{
gchar *filter_name;
};
enum enum
{ {
PROP_0, PROP_0,
@ -71,6 +66,14 @@ enum
PROP_FILE_PROCS_ALL_IMAGES PROP_FILE_PROCS_ALL_IMAGES
}; };
typedef struct _GimpFileDialogState GimpFileDialogState;
struct _GimpFileDialogState
{
gchar *filter_name;
};
static void gimp_file_dialog_progress_iface_init (GimpProgressInterface *iface); static void gimp_file_dialog_progress_iface_init (GimpProgressInterface *iface);
static void gimp_file_dialog_set_property (GObject *object, static void gimp_file_dialog_set_property (GObject *object,
@ -141,6 +144,7 @@ static void gimp_file_dialog_set_state (GimpFileDialog *d
static void gimp_file_dialog_state_destroy (GimpFileDialogState *state); static void gimp_file_dialog_state_destroy (GimpFileDialogState *state);
G_DEFINE_TYPE_WITH_CODE (GimpFileDialog, gimp_file_dialog, G_DEFINE_TYPE_WITH_CODE (GimpFileDialog, gimp_file_dialog,
GTK_TYPE_FILE_CHOOSER_DIALOG, GTK_TYPE_FILE_CHOOSER_DIALOG,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS, G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
@ -637,7 +641,7 @@ gimp_file_dialog_get_default_folder (GimpFileDialog *dialog)
{ {
g_return_val_if_fail (GIMP_IS_FILE_DIALOG (dialog), NULL); g_return_val_if_fail (GIMP_IS_FILE_DIALOG (dialog), NULL);
GIMP_FILE_DIALOG_GET_CLASS (dialog)->get_default_folder (dialog); return GIMP_FILE_DIALOG_GET_CLASS (dialog)->get_default_folder (dialog);
} }
void void
@ -658,6 +662,7 @@ gimp_file_dialog_load_state (GimpFileDialog *dialog,
GIMP_FILE_DIALOG_GET_CLASS (dialog)->load_state (dialog, state_name); GIMP_FILE_DIALOG_GET_CLASS (dialog)->load_state (dialog, state_name);
} }
/* private functions */ /* private functions */
static void static void

View File

@ -33,8 +33,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "pdb/gimppdb.h"
#include "plug-in/gimppluginmanager.h" #include "plug-in/gimppluginmanager.h"
#include "gimpfiledialog.h" #include "gimpfiledialog.h"
@ -49,6 +47,7 @@ G_DEFINE_TYPE (GimpOpenDialog, gimp_open_dialog,
#define parent_class gimp_open_dialog_parent_class #define parent_class gimp_open_dialog_parent_class
static void static void
gimp_open_dialog_class_init (GimpOpenDialogClass *klass) gimp_open_dialog_class_init (GimpOpenDialogClass *klass)
{ {
@ -59,6 +58,7 @@ gimp_open_dialog_init (GimpOpenDialog *dialog)
{ {
} }
/* public functions */ /* public functions */
GtkWidget * GtkWidget *
@ -100,5 +100,3 @@ gimp_open_dialog_set_image (GimpOpenDialog *dialog,
GIMP_FILE_DIALOG (dialog)->image = image; GIMP_FILE_DIALOG (dialog)->image = image;
dialog->open_as_layers = open_as_layers; dialog->open_as_layers = open_as_layers;
} }
/* private functions */

View File

@ -48,6 +48,7 @@
typedef struct _GimpSaveDialogState GimpSaveDialogState; typedef struct _GimpSaveDialogState GimpSaveDialogState;
struct _GimpSaveDialogState struct _GimpSaveDialogState
{ {
gchar *filter_name; gchar *filter_name;
@ -102,7 +103,8 @@ gimp_save_dialog_constructed (GObject *object)
GimpSaveDialog *dialog = GIMP_SAVE_DIALOG (object); GimpSaveDialog *dialog = GIMP_SAVE_DIALOG (object);
/* GimpFileDialog's constructed() is doing a few initialization /* GimpFileDialog's constructed() is doing a few initialization
* common to all file dialogs. */ * common to all file dialogs.
*/
G_OBJECT_CLASS (parent_class)->constructed (object); G_OBJECT_CLASS (parent_class)->constructed (object);
gimp_save_dialog_add_compat_toggle (dialog); gimp_save_dialog_add_compat_toggle (dialog);
@ -112,8 +114,6 @@ static void
gimp_save_dialog_save_state (GimpFileDialog *dialog, gimp_save_dialog_save_state (GimpFileDialog *dialog,
const gchar *state_name) const gchar *state_name)
{ {
g_return_if_fail (GIMP_IS_SAVE_DIALOG (dialog));
g_object_set_data_full (G_OBJECT (dialog->gimp), state_name, g_object_set_data_full (G_OBJECT (dialog->gimp), state_name,
gimp_save_dialog_get_state (GIMP_SAVE_DIALOG (dialog)), gimp_save_dialog_get_state (GIMP_SAVE_DIALOG (dialog)),
(GDestroyNotify) gimp_save_dialog_state_destroy); (GDestroyNotify) gimp_save_dialog_state_destroy);
@ -125,8 +125,6 @@ gimp_save_dialog_load_state (GimpFileDialog *dialog,
{ {
GimpSaveDialogState *state; GimpSaveDialogState *state;
g_return_if_fail (GIMP_IS_SAVE_DIALOG (dialog));
state = g_object_get_data (G_OBJECT (dialog->gimp), state_name); state = g_object_get_data (G_OBJECT (dialog->gimp), state_name);
if (state) if (state)
@ -326,6 +324,7 @@ gimp_save_dialog_set_image (GimpSaveDialog *dialog,
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
} }
/* private functions */ /* private functions */
static void static void
@ -355,8 +354,6 @@ gimp_save_dialog_get_state (GimpSaveDialog *dialog)
GimpSaveDialogState *state; GimpSaveDialogState *state;
GtkFileFilter *filter; GtkFileFilter *filter;
g_return_val_if_fail (GIMP_IS_SAVE_DIALOG (dialog), NULL);
state = g_slice_new0 (GimpSaveDialogState); state = g_slice_new0 (GimpSaveDialogState);
filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)); filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
@ -373,9 +370,6 @@ static void
gimp_save_dialog_set_state (GimpSaveDialog *dialog, gimp_save_dialog_set_state (GimpSaveDialog *dialog,
GimpSaveDialogState *state) GimpSaveDialogState *state)
{ {
g_return_if_fail (GIMP_IS_SAVE_DIALOG (dialog));
g_return_if_fail (state != NULL);
if (state->filter_name) if (state->filter_name)
{ {
GSList *filters; GSList *filters;
@ -404,8 +398,6 @@ gimp_save_dialog_set_state (GimpSaveDialog *dialog,
static void static void
gimp_save_dialog_state_destroy (GimpSaveDialogState *state) gimp_save_dialog_state_destroy (GimpSaveDialogState *state)
{ {
g_return_if_fail (state != NULL);
g_free (state->filter_name); g_free (state->filter_name);
g_slice_free (GimpSaveDialogState, state); g_slice_free (GimpSaveDialogState, state);
} }