summaryrefslogtreecommitdiffstats
path: root/gedit/gedit-factory.c
diff options
context:
space:
mode:
Diffstat (limited to 'gedit/gedit-factory.c')
-rw-r--r--gedit/gedit-factory.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/gedit/gedit-factory.c b/gedit/gedit-factory.c
new file mode 100644
index 0000000..f1d70ad
--- /dev/null
+++ b/gedit/gedit-factory.c
@@ -0,0 +1,69 @@
+/*
+ * This file is part of gedit
+ *
+ * Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gedit-factory.h"
+#include <glib/gi18n.h>
+#include "gedit-dirs.h"
+
+G_DEFINE_TYPE (GeditFactory, gedit_factory, TEPL_TYPE_ABSTRACT_FACTORY)
+
+static gchar *
+untitled_file_cb (gint untitled_file_number)
+{
+ return g_strdup_printf (_("Untitled Document %d"), untitled_file_number);
+}
+
+static TeplFile *
+gedit_factory_create_file (TeplAbstractFactory *factory)
+{
+ TeplFile *file;
+
+ file = tepl_file_new ();
+ tepl_file_set_untitled_file_callback (file, untitled_file_cb);
+
+ return file;
+}
+
+static GFile *
+gedit_factory_create_metadata_manager_file (TeplAbstractFactory *factory)
+{
+ return g_file_new_build_filename (gedit_dirs_get_user_data_dir (),
+ "gedit-metadata.xml",
+ NULL);
+}
+
+static void
+gedit_factory_class_init (GeditFactoryClass *klass)
+{
+ TeplAbstractFactoryClass *factory_class = TEPL_ABSTRACT_FACTORY_CLASS (klass);
+
+ factory_class->create_file = gedit_factory_create_file;
+ factory_class->create_metadata_manager_file = gedit_factory_create_metadata_manager_file;
+}
+
+static void
+gedit_factory_init (GeditFactory *factory)
+{
+}
+
+GeditFactory *
+gedit_factory_new (void)
+{
+ return g_object_new (GEDIT_TYPE_FACTORY, NULL);
+}