ide.c 2.65 KB
Newer Older
1 2
/* ide.c
 *
3
 * Copyright 2015 Christian Hergert <christian@hergert.me>
4
 *
5 6 7 8
 * 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 3 of the License, or
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17 18
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

19 20
#include "config.h"

21
#include <girepository.h>
22
#include <glib/gi18n.h>
23
#include <stdlib.h>
24 25 26

#include "gconstructor.h"
#include "ide.h"
27

Christian Hergert's avatar
Christian Hergert committed
28 29 30
#include "files/ide-file-settings.h"
#include "gsettings/ide-gsettings-file-settings.h"
#include "modelines/ide-modelines-file-settings.h"
31

32
#ifdef ENABLE_EDITORCONFIG
Christian Hergert's avatar
Christian Hergert committed
33
# include "editorconfig/ide-editorconfig-file-settings.h"
34 35
#endif

36
static gboolean     programNameRead;
37
static const gchar *programName = "gnome-builder";
38

39 40 41 42 43 44 45 46 47
#if defined (G_HAS_CONSTRUCTORS)
# ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
#  pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(ide_init_ctor)
# endif
G_DEFINE_CONSTRUCTOR(ide_init_ctor)
#else
# error Your platform/compiler is missing constructor support
#endif

48 49 50
const gchar *
ide_get_program_name (void)
{
51 52
  programNameRead = 1;
  return programName;
53 54 55 56 57
}

void
ide_set_program_name (const gchar *program_name)
{
58
  if (programNameRead)
59
    {
Christian Hergert's avatar
Christian Hergert committed
60
      g_warning (_("You must call %s() before using libide."), G_STRFUNC);
61 62 63
      return;
    }

64 65
  if (program_name != NULL)
    programName = g_intern_string (program_name);
66 67 68 69 70
}

static void
ide_init_ctor (void)
{
71
  g_io_extension_point_register (IDE_FILE_SETTINGS_EXTENSION_POINT);
72

73 74 75 76
  g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
                                  IDE_TYPE_MODELINES_FILE_SETTINGS,
                                  IDE_FILE_SETTINGS_EXTENSION_POINT".modelines",
                                  -100);
77
#ifdef ENABLE_EDITORCONFIG
78 79 80
  g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
                                  IDE_TYPE_EDITORCONFIG_FILE_SETTINGS,
                                  IDE_FILE_SETTINGS_EXTENSION_POINT".editorconfig",
81
                                  -200);
82
#endif
83 84 85
  g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
                                  IDE_TYPE_GSETTINGS_FILE_SETTINGS,
                                  IDE_FILE_SETTINGS_EXTENSION_POINT".gsettings",
86
                                  -300);
87
}