[gnome-disk-utility] Factor out common code and put it in a static library
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Factor out common code and put it in a static library
- Date: Tue, 31 Jul 2012 15:06:38 +0000 (UTC)
commit 289c00f7e97ecc96396ec8ba7becd17d17401706
Author: David Zeuthen <zeuthen gmail com>
Date: Tue Jul 31 10:56:58 2012 -0400
Factor out common code and put it in a static library
Signed-off-by: David Zeuthen <zeuthen gmail com>
configure.ac | 1 +
po/POTFILES.in | 2 +-
src/Makefile.am | 2 +-
src/disks/Makefile.am | 3 +-
src/disks/gduatasmartdialog.c | 1 -
src/disks/gdubenchmarkdialog.c | 1 -
src/disks/gduchangepassphrasedialog.c | 1 -
src/disks/gducreatediskimagedialog.c | 1 -
src/disks/gducreatepartitiondialog.c | 1 -
src/disks/gducrypttabdialog.c | 1 -
src/disks/gdudevicetreemodel.c | 1 -
src/disks/gdudisksettingsdialog.c | 1 -
src/disks/gduenums.h | 7 ---
src/disks/gdufilesystemdialog.c | 1 -
src/disks/gduformatdiskdialog.c | 1 -
src/disks/gduformatvolumedialog.c | 1 -
src/disks/gdufstabdialog.c | 1 -
src/disks/gdupartitiondialog.c | 1 -
src/disks/gdurestorediskimagedialog.c | 1 -
src/disks/gdutypes.h | 2 +
src/disks/gduunlockdialog.c | 1 -
src/disks/gduwindow.c | 1 -
src/disks/main.c | 2 +-
src/libgdu/Makefile.am | 65 +++++++++++++++++++++++++++++
src/{disks => libgdu}/gduutils.c | 0
src/{disks => libgdu}/gduutils.h | 3 +-
src/{disks/gdu.h => libgdu/libgdu.h} | 16 +++----
src/{disks/gdu.h => libgdu/libgduenums.h} | 26 +++++++-----
src/libgdu/libgduenumtypes.c.template | 40 ++++++++++++++++++
src/libgdu/libgduenumtypes.h.template | 24 +++++++++++
src/{disks/gdu.h => libgdu/libgdutypes.h} | 23 +++++-----
31 files changed, 170 insertions(+), 62 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 50dd013..bb5b525 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,6 +140,7 @@ AC_SUBST([AM_LDFLAGS])
AC_CONFIG_FILES([
Makefile
src/Makefile
+src/libgdu/Makefile
src/disks/Makefile
src/disk-image-mounter/Makefile
po/Makefile.in
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9c51eee..99b3fc2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -44,7 +44,7 @@ src/disks/gdupartitiondialog.c
src/disks/gdupasswordstrengthwidget.c
src/disks/gdurestorediskimagedialog.c
src/disks/gduunlockdialog.c
-src/disks/gduutils.c
src/disks/gduvolumegrid.c
src/disks/gduwindow.c
src/disks/main.c
+src/libgdu/gduutils.c
diff --git a/src/Makefile.am b/src/Makefile.am
index bdcbc18..4aceda0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = disks disk-image-mounter
+SUBDIRS = libgdu disks disk-image-mounter
clean-local :
rm -f *~
diff --git a/src/disks/Makefile.am b/src/disks/Makefile.am
index 5aba86a..c0226d9 100644
--- a/src/disks/Makefile.am
+++ b/src/disks/Makefile.am
@@ -24,12 +24,10 @@ BUILT_SOURCES += $(enum_built_sources)
gnome_disks_SOURCES = \
main.c \
- gdu.h \
gduapplication.h gduapplication.c \
gdudevicetreemodel.h gdudevicetreemodel.c \
gdutypes.h \
gduenums.h \
- gduutils.h gduutils.c \
gduvolumegrid.h gduvolumegrid.c \
gduwindow.h gduwindow.c \
gduatasmartdialog.h gduatasmartdialog.c \
@@ -78,6 +76,7 @@ gnome_disks_LDADD = \
$(LIBSECRET1_LIBS) \
$(LIBSYSTEMD_LOGIN_LIBS) \
$(PWQUALITY_LIBS) \
+ $(top_builddir)/src/libgdu/libgdu.la \
$(NULL)
EXTRA_DIST = \
diff --git a/src/disks/gduatasmartdialog.c b/src/disks/gduatasmartdialog.c
index 6e8d358..9a53245 100644
--- a/src/disks/gduatasmartdialog.c
+++ b/src/disks/gduatasmartdialog.c
@@ -27,7 +27,6 @@
#include "gduapplication.h"
#include "gduwindow.h"
#include "gduatasmartdialog.h"
-#include "gduutils.h"
enum
{
diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c
index 1a8d185..d561a80 100644
--- a/src/disks/gdubenchmarkdialog.c
+++ b/src/disks/gdubenchmarkdialog.c
@@ -36,7 +36,6 @@
#include "gduapplication.h"
#include "gduwindow.h"
#include "gdubenchmarkdialog.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gduchangepassphrasedialog.c b/src/disks/gduchangepassphrasedialog.c
index 9bb222f..4353dc4 100644
--- a/src/disks/gduchangepassphrasedialog.c
+++ b/src/disks/gduchangepassphrasedialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gduchangepassphrasedialog.h"
#include "gdupasswordstrengthwidget.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gducreatediskimagedialog.c b/src/disks/gducreatediskimagedialog.c
index c2153ce..7282927 100644
--- a/src/disks/gducreatediskimagedialog.c
+++ b/src/disks/gducreatediskimagedialog.c
@@ -35,7 +35,6 @@
#include "gduwindow.h"
#include "gducreatediskimagedialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
#include "gducreatefilesystemwidget.h"
#include "gduestimator.h"
diff --git a/src/disks/gducreatepartitiondialog.c b/src/disks/gducreatepartitiondialog.c
index e56292c..ce25714 100644
--- a/src/disks/gducreatepartitiondialog.c
+++ b/src/disks/gducreatepartitiondialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gducreatepartitiondialog.h"
#include "gducreatefilesystemwidget.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gducrypttabdialog.c b/src/disks/gducrypttabdialog.c
index 80fb317..f90a890 100644
--- a/src/disks/gducrypttabdialog.c
+++ b/src/disks/gducrypttabdialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gducrypttabdialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gdudevicetreemodel.c b/src/disks/gdudevicetreemodel.c
index 9de03bf..6c694c4 100644
--- a/src/disks/gdudevicetreemodel.c
+++ b/src/disks/gdudevicetreemodel.c
@@ -28,7 +28,6 @@
#include "gdudevicetreemodel.h"
#include "gduatasmartdialog.h"
#include "gduenumtypes.h"
-#include "gduutils.h"
struct _GduDeviceTreeModel
{
diff --git a/src/disks/gdudisksettingsdialog.c b/src/disks/gdudisksettingsdialog.c
index b17eb1c..9c0094a 100644
--- a/src/disks/gdudisksettingsdialog.c
+++ b/src/disks/gdudisksettingsdialog.c
@@ -29,7 +29,6 @@
#include "gduapplication.h"
#include "gduwindow.h"
#include "gdudisksettingsdialog.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gduenums.h b/src/disks/gduenums.h
index ef3201f..14a214f 100644
--- a/src/disks/gduenums.h
+++ b/src/disks/gduenums.h
@@ -37,13 +37,6 @@ typedef enum
typedef enum
{
- GDU_FORMAT_DURATION_FLAGS_NONE = 0,
- GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION = (1<<0),
- GDU_FORMAT_DURATION_FLAGS_NO_SECONDS = (1<<1)
-} GduFormatDurationFlags;
-
-typedef enum
-{
GDU_POWER_STATE_FLAGS_NONE = 0,
GDU_POWER_STATE_FLAGS_STANDBY = (1<<0),
GDU_POWER_STATE_FLAGS_CHECKING = (1<<1),
diff --git a/src/disks/gdufilesystemdialog.c b/src/disks/gdufilesystemdialog.c
index e128310..aa6da6c 100644
--- a/src/disks/gdufilesystemdialog.c
+++ b/src/disks/gdufilesystemdialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gdufilesystemdialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gduformatdiskdialog.c b/src/disks/gduformatdiskdialog.c
index d46c375..3f9ec81 100644
--- a/src/disks/gduformatdiskdialog.c
+++ b/src/disks/gduformatdiskdialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gduformatdiskdialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
#include "gducreatefilesystemwidget.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gduformatvolumedialog.c b/src/disks/gduformatvolumedialog.c
index 0cd8c76..cb13706 100644
--- a/src/disks/gduformatvolumedialog.c
+++ b/src/disks/gduformatvolumedialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gduformatvolumedialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
#include "gducreatefilesystemwidget.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gdufstabdialog.c b/src/disks/gdufstabdialog.c
index 2aaf600..5030864 100644
--- a/src/disks/gdufstabdialog.c
+++ b/src/disks/gdufstabdialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gdufstabdialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gdupartitiondialog.c b/src/disks/gdupartitiondialog.c
index 22daf05..28491e6 100644
--- a/src/disks/gdupartitiondialog.c
+++ b/src/disks/gdupartitiondialog.c
@@ -28,7 +28,6 @@
#include "gduwindow.h"
#include "gdupartitiondialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 0f0d212..5bfe291 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -34,7 +34,6 @@
#include "gduwindow.h"
#include "gdurestorediskimagedialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
#include "gduestimator.h"
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gdutypes.h b/src/disks/gdutypes.h
index 917908a..bc90c8f 100644
--- a/src/disks/gdutypes.h
+++ b/src/disks/gdutypes.h
@@ -27,6 +27,8 @@
#define UDISKS_API_IS_SUBJECT_TO_CHANGE
#include <udisks/udisks.h>
+#include <libgdu/libgdu.h>
+
#include "gduenums.h"
G_BEGIN_DECLS
diff --git a/src/disks/gduunlockdialog.c b/src/disks/gduunlockdialog.c
index ab8363b..767db30 100644
--- a/src/disks/gduunlockdialog.c
+++ b/src/disks/gduunlockdialog.c
@@ -29,7 +29,6 @@
#include "gduwindow.h"
#include "gduunlockdialog.h"
#include "gduvolumegrid.h"
-#include "gduutils.h"
/* From GVfs's monitor/udisks2/gvfsudisks2volume.c */
static const SecretSchema luks_passphrase_schema =
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index e12ba10..7154f88 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -35,7 +35,6 @@
#include "gduapplication.h"
#include "gduwindow.h"
#include "gdudevicetreemodel.h"
-#include "gduutils.h"
#include "gduvolumegrid.h"
#include "gduatasmartdialog.h"
#include "gdubenchmarkdialog.h"
diff --git a/src/disks/main.c b/src/disks/main.c
index 39dbd43..ff2f4d1 100644
--- a/src/disks/main.c
+++ b/src/disks/main.c
@@ -23,7 +23,7 @@
#include "config.h"
#include <glib/gi18n.h>
-#include "gdu.h"
+#include "gduapplication.h"
int
main (int argc, char *argv[])
diff --git a/src/libgdu/Makefile.am b/src/libgdu/Makefile.am
new file mode 100644
index 0000000..ef1ae57
--- /dev/null
+++ b/src/libgdu/Makefile.am
@@ -0,0 +1,65 @@
+
+NULL =
+BUILT_SOURCES =
+
+noinst_LTLIBRARIES = libgdu.la
+
+libgduenumtypes.h: libgduenums.h libgduenumtypes.h.template
+ ( top_builddir=`cd $(top_builddir) && pwd`; \
+ cd $(srcdir) && glib-mkenums --template libgduenumtypes.h.template libgduenums.h ) > \
+ libgduenumtypes.h.tmp && mv libgduenumtypes.h.tmp libgduenumtypes.h \
+ $(NULL)
+
+libgduenumtypes.c: libgduenums.h libgduenumtypes.c.template
+ ( top_builddir=`cd $(top_builddir) && pwd`; \
+ cd $(srcdir) && glib-mkenums --template libgduenumtypes.c.template libgduenums.h ) > \
+ libgduenumtypes.c.tmp && mv libgduenumtypes.c.tmp libgduenumtypes.c \
+ $(NULL)
+
+enum_built_sources = \
+ libgduenumtypes.h libgduenumtypes.c \
+ $(NULL)
+
+BUILT_SOURCES += $(enum_built_sources)
+
+libgdu_la_SOURCES = \
+ libgdu.h \
+ gduutils.h gduutils.c \
+ $(enum_built_sources) \
+ $(NULL)
+
+libgdu_la_CPPFLAGS = \
+ -I$(top_srcdir)/src/ \
+ -I$(top_builddir)/src/ \
+ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+ -DG_LOG_DOMAIN=\"libgdu\" \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ $(NULL)
+
+libgdu_la_CFLAGS = \
+ $(GLIB2_CFLAGS) \
+ $(UDISKS2_CFLAGS) \
+ $(GTK3_CFLAGS) \
+ $(LIBSECRET1_CFLAGS) \
+ $(LIBSYSTEMD_LOGIN_CFLAGS) \
+ $(PWQUALITY_CFLAGS) \
+ $(WARN_CFLAGS) \
+ -lm \
+ $(NULL)
+
+libgdu_la_LIBADD = \
+ $(GLIB2_LIBS) \
+ $(UDISKS2_LIBS) \
+ $(GTK3_LIBS) \
+ $(LIBSECRET1_LIBS) \
+ $(LIBSYSTEMD_LOGIN_LIBS) \
+ $(PWQUALITY_LIBS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ libgduenumtypes.h.template \
+ libgduenumtypes.c.template \
+ $(NULL)
+
+clean-local :
+ rm -f *~
diff --git a/src/disks/gduutils.c b/src/libgdu/gduutils.c
similarity index 100%
rename from src/disks/gduutils.c
rename to src/libgdu/gduutils.c
diff --git a/src/disks/gduutils.h b/src/libgdu/gduutils.h
similarity index 98%
rename from src/disks/gduutils.h
rename to src/libgdu/gduutils.h
index ee49686..1e88fe3 100644
--- a/src/disks/gduutils.h
+++ b/src/libgdu/gduutils.h
@@ -23,8 +23,7 @@
#ifndef __GDU_UTILS_H__
#define __GDU_UTILS_H__
-#include <gtk/gtk.h>
-#include "gdutypes.h"
+#include "libgdutypes.h"
G_BEGIN_DECLS
diff --git a/src/disks/gdu.h b/src/libgdu/libgdu.h
similarity index 79%
copy from src/disks/gdu.h
copy to src/libgdu/libgdu.h
index ff6e3df..a0d6b19 100644
--- a/src/disks/gdu.h
+++ b/src/libgdu/libgdu.h
@@ -20,16 +20,12 @@
* Author: David Zeuthen <davidz redhat com>
*/
-#ifndef __GDU_H__
-#define __GDU_H__
+#ifndef __LIB_GDU_H__
+#define __LIB_GDU_H__
-#include "gdutypes.h"
-#include "gduenums.h"
-#include "gduenumtypes.h"
-#include "gduapplication.h"
-#include "gdudevicetreemodel.h"
+#include "libgdutypes.h"
+#include "libgduenums.h"
+#include "libgduenumtypes.h"
#include "gduutils.h"
-#include "gduvolumegrid.h"
-#include "gduwindow.h"
-#endif /* __GDU_H__ */
+#endif /* __LIB_GDU_H__ */
diff --git a/src/disks/gdu.h b/src/libgdu/libgduenums.h
similarity index 72%
copy from src/disks/gdu.h
copy to src/libgdu/libgduenums.h
index ff6e3df..b96d57c 100644
--- a/src/disks/gdu.h
+++ b/src/libgdu/libgduenums.h
@@ -20,16 +20,20 @@
* Author: David Zeuthen <davidz redhat com>
*/
-#ifndef __GDU_H__
-#define __GDU_H__
+#ifndef __LIB_GDU_ENUMS_H__
+#define __LIB_GDU_ENUMS_H__
-#include "gdutypes.h"
-#include "gduenums.h"
-#include "gduenumtypes.h"
-#include "gduapplication.h"
-#include "gdudevicetreemodel.h"
-#include "gduutils.h"
-#include "gduvolumegrid.h"
-#include "gduwindow.h"
+#include <gtk/gtk.h>
-#endif /* __GDU_H__ */
+G_BEGIN_DECLS
+
+typedef enum
+{
+ GDU_FORMAT_DURATION_FLAGS_NONE = 0,
+ GDU_FORMAT_DURATION_FLAGS_SUBSECOND_PRECISION = (1<<0),
+ GDU_FORMAT_DURATION_FLAGS_NO_SECONDS = (1<<1)
+} GduFormatDurationFlags;
+
+G_END_DECLS
+
+#endif /* __LIB_GDU_ENUMS_H__ */
diff --git a/src/libgdu/libgduenumtypes.c.template b/src/libgdu/libgduenumtypes.c.template
new file mode 100644
index 0000000..bac7576
--- /dev/null
+++ b/src/libgdu/libgduenumtypes.c.template
@@ -0,0 +1,40 @@
+/*** BEGIN file-header ***/
+#include "libgduenums.h"
+#include "libgduenumtypes.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id =
+ g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+
+ return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+/*** END file-tail ***/
diff --git a/src/libgdu/libgduenumtypes.h.template b/src/libgdu/libgduenumtypes.h.template
new file mode 100644
index 0000000..b07a1e8
--- /dev/null
+++ b/src/libgdu/libgduenumtypes.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __LIB_GDU_ENUM_TYPES_H__
+#define __LIB_GDU_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX _TYPE_@ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __LIB_GDU_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/src/disks/gdu.h b/src/libgdu/libgdutypes.h
similarity index 77%
rename from src/disks/gdu.h
rename to src/libgdu/libgdutypes.h
index ff6e3df..175530f 100644
--- a/src/disks/gdu.h
+++ b/src/libgdu/libgdutypes.h
@@ -20,16 +20,17 @@
* Author: David Zeuthen <davidz redhat com>
*/
-#ifndef __GDU_H__
-#define __GDU_H__
+#ifndef __LIB_GDU_TYPES_H__
+#define __LIB_GDU_TYPES_H__
-#include "gdutypes.h"
-#include "gduenums.h"
-#include "gduenumtypes.h"
-#include "gduapplication.h"
-#include "gdudevicetreemodel.h"
-#include "gduutils.h"
-#include "gduvolumegrid.h"
-#include "gduwindow.h"
+#include <gtk/gtk.h>
+#define UDISKS_API_IS_SUBJECT_TO_CHANGE
+#include <udisks/udisks.h>
-#endif /* __GDU_H__ */
+#include "libgduenums.h"
+
+G_BEGIN_DECLS
+
+G_END_DECLS
+
+#endif /* __LIB_GDU_TYPES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]