aboutsummaryrefslogtreecommitdiffstats
path: root/autoarchive/autoar-pref.h
blob: b256ac05983b25724fb7970ccbd913c20b2b4e10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* vim: set sw=2 ts=2 sts=2 et: */
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
 * autoar-pref.h
 * User preferences of automatic archives creation and extraction
 *
 * Copyright (C) 2013  Ting-Wei Lan
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 */

#ifndef AUTOAR_PREF_H
#define AUTOAR_PREF_H

#include <glib-object.h>
#include <gio/gio.h>

G_BEGIN_DECLS

#define AUTOAR_PREF_DEFAULT_GSCHEMA_ID  "org.gnome.desktop.archives"

typedef enum {
  AUTOAR_PREF_FORMAT_0, /*< skip >*/
  AUTOAR_PREF_FORMAT_ZIP,       /* .zip */
  AUTOAR_PREF_FORMAT_TAR,       /* .tar, pax_restricted */
  AUTOAR_PREF_FORMAT_CPIO,      /* .cpio, odc */
  AUTOAR_PREF_FORMAT_7ZIP,      /* .7z */
  AUTOAR_PREF_FORMAT_AR_BSD,    /* .a */
  AUTOAR_PREF_FORMAT_AR_SVR4,   /* .a */
  AUTOAR_PREF_FORMAT_CPIO_NEWC, /* .cpio, newc */
  AUTOAR_PREF_FORMAT_GNUTAR,    /* .tar, gnutar */
  AUTOAR_PREF_FORMAT_ISO9660,   /* .iso */
  AUTOAR_PREF_FORMAT_PAX,       /* .tar, pax */
  AUTOAR_PREF_FORMAT_USTAR,     /* .tar, ustar */
  AUTOAR_PREF_FORMAT_XAR,       /* .xar, xar */
  AUTOAR_PREF_FORMAT_LAST /*< skip >*/
} AutoarPrefFormat;

typedef enum {
  AUTOAR_PREF_FILTER_0, /*< skip >*/
  AUTOAR_PREF_FILTER_NONE,
  AUTOAR_PREF_FILTER_COMPRESS,  /* .Z */
  AUTOAR_PREF_FILTER_GZIP,      /* .gz */
  AUTOAR_PREF_FILTER_BZIP2,     /* .bz2 */
  AUTOAR_PREF_FILTER_XZ,        /* .xz */
  AUTOAR_PREF_FILTER_LZMA,      /* .lzma */
  AUTOAR_PREF_FILTER_LZIP,      /* .lz */
  AUTOAR_PREF_FILTER_LZOP,      /* .lzo */
  AUTOAR_PREF_FILTER_GRZIP,     /* .grz */
  AUTOAR_PREF_FILTER_LRZIP,     /* .lrz */
  AUTOAR_PREF_FILTER_LAST /*< skip >*/
} AutoarPrefFilter;

#define AUTOAR_TYPE_PREF                autoar_pref_get_type ()
#define AUTOAR_PREF(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), AUTOAR_TYPE_PREF, AutoarPref))
#define AUTOAR_PREF_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), AUTOAR_TYPE_PREF, AutoarPrefClass))
#define AUTOAR_IS_PREF(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AUTOAR_TYPE_PREF))
#define AUTOAR_IS_PREF_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), AUTOAR_TYPE_PREF))
#define AUTOAR_PREF_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), AUTOAR_TYPE_PREF, AutoarPrefClass))

typedef struct _AutoarPref AutoarPref;
typedef struct _AutoarPrefClass AutoarPrefClass;
typedef struct _AutoarPrefPrivate AutoarPrefPrivate;

struct _AutoarPref
{
  GObject parent;

  AutoarPrefPrivate *priv;
};

struct _AutoarPrefClass
{
  GObjectClass parent_class;
};

GType              autoar_pref_get_type              (void) G_GNUC_CONST;

AutoarPref        *autoar_pref_new                   (void);
AutoarPref        *autoar_pref_new_with_gsettings    (GSettings *settings);

void               autoar_pref_read_gsettings        (AutoarPref *arpref,
                                                      GSettings *settings);
void               autoar_pref_write_gsettings       (AutoarPref *arpref,
                                                      GSettings *settings);
void               autoar_pref_write_gsettings_force (AutoarPref *arpref,
                                                      GSettings *settings);

gboolean           autoar_pref_has_changes           (AutoarPref *arpref);
void               autoar_pref_forget_changes        (AutoarPref *arpref);

gboolean           autoar_pref_check_file_name       (AutoarPref *arpref,
                                                      const char *filepath);
gboolean           autoar_pref_check_mime_type       (AutoarPref *arpref,
                                                      const char *filepath);

AutoarPrefFormat   autoar_pref_get_default_format    (AutoarPref *arpref);
AutoarPrefFilter   autoar_pref_get_default_filter    (AutoarPref *arpref);
const char       **autoar_pref_get_file_name_suffix  (AutoarPref *arpref);
const char       **autoar_pref_get_file_mime_type    (AutoarPref *arpref);
const char       **autoar_pref_get_pattern_to_ignore (AutoarPref *arpref);
gboolean           autoar_pref_get_delete_if_succeed (AutoarPref *arpref);

void               autoar_pref_set_default_format    (AutoarPref *arpref,
                                                      AutoarPrefFormat format);
void               autoar_pref_set_default_filter    (AutoarPref *arpref,
                                                      AutoarPrefFilter filter);
void               autoar_pref_set_file_name_suffix  (AutoarPref *arpref,
                                                      const char **strv);
void               autoar_pref_set_file_mime_type    (AutoarPref *arpref,
                                                      const char **strv);
void               autoar_pref_set_pattern_to_ignore (AutoarPref *arpref,
                                                      const char **strv);
void               autoar_pref_set_delete_if_succeed (AutoarPref *arpref,
                                                      gboolean delete_yes);


G_END_DECLS

#endif /* AUTOAR_PREF_H */