File: gimpapp.c

package info (click to toggle)
gimp 3.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 210,076 kB
  • sloc: ansic: 842,287; lisp: 10,761; python: 10,318; cpp: 7,238; perl: 4,355; sh: 1,043; xml: 963; yacc: 609; lex: 348; javascript: 150; makefile: 43
file content (169 lines) | stat: -rw-r--r-- 5,153 bytes parent folder | download
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 *
 * gimpapp.c
 * Copyright (C) 2021 Niels De Graef <nielsdegraef@gmail.com>
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <https://www.gnu.org/licenses/>.
 */

#include <config.h>

#include <gtk/gtk.h>

#include "libgimpbase/gimpbase.h"

#include "core/core-types.h"

#include "core/gimp.h"

#include "gimpcoreapp.h"

#include "gimpapp.h"


enum
{
  PROP_0,
  PROP_NO_SPLASH = GIMP_CORE_APP_PROP_LAST + 1,
};

struct _GimpApp
{
  GtkApplication parent_instance;

  gboolean       no_splash;
};


static void gimp_app_get_property (GObject      *object,
                                   guint         property_id,
                                   GValue       *value,
                                   GParamSpec   *pspec);
static void gimp_app_set_property (GObject      *object,
                                   guint         property_id,
                                   const GValue *value,
                                   GParamSpec   *pspec);


G_DEFINE_TYPE_WITH_CODE (GimpApp, gimp_app, GTK_TYPE_APPLICATION,
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_CORE_APP,
                                                NULL))


static void
gimp_app_class_init (GimpAppClass *klass)
{
  GObjectClass *gobj_class = G_OBJECT_CLASS (klass);

  gobj_class->get_property = gimp_app_get_property;
  gobj_class->set_property = gimp_app_set_property;

  gimp_core_app_install_properties (gobj_class);

  g_object_class_install_property (gobj_class, PROP_NO_SPLASH,
                                   g_param_spec_boolean ("no-splash", NULL, NULL,
                                                         FALSE,
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));
}

static void
gimp_app_init (GimpApp *self)
{
}

static void
gimp_app_get_property (GObject    *object,
                       guint       property_id,
                       GValue     *value,
                       GParamSpec *pspec)
{
  switch (property_id)
    {
    case PROP_NO_SPLASH:
      g_value_set_boolean (value, GIMP_APP (object)->no_splash);
      break;

    default:
      gimp_core_app_get_property (object, property_id, value, pspec);
      break;
    }
}

static void
gimp_app_set_property (GObject      *object,
                       guint         property_id,
                       const GValue *value,
                       GParamSpec   *pspec)
{
  switch (property_id)
    {
    case PROP_NO_SPLASH:
      GIMP_APP (object)->no_splash = g_value_get_boolean (value);
      break;

    default:
      gimp_core_app_set_property (object, property_id, value, pspec);
      break;
    }
}

/*  public functions  */

GApplication *
gimp_app_new (Gimp        *gimp,
              gboolean     no_splash,
              gboolean     quit,
              gboolean     as_new,
              const char **filenames,
              const char  *batch_interpreter,
              const char **batch_commands)
{
  GimpApp *app;

  app = g_object_new (GIMP_TYPE_APP,
                      "application-id",    GIMP_APPLICATION_ID,
                      /* We have our own code to handle process uniqueness, so
                       * when we reached this code, we are already passed this
                       * (it means that either this is the first process, or we
                       * don't want uniqueness). See bugs #9598 and #9599 for
                       * what happens when we let GIO try to handle uniqueness.
                       *
                       * TODO: since GApplication has code to pass over files
                       * and command line arguments, we may eventually want to
                       * remove our own code for uniqueness and batch command
                       * inter-process communication. This should be tested.
                       */
#if GLIB_CHECK_VERSION(2,74,0)
                      "flags",             G_APPLICATION_DEFAULT_FLAGS | G_APPLICATION_NON_UNIQUE,
#else
                      "flags",             G_APPLICATION_FLAGS_NONE | G_APPLICATION_NON_UNIQUE,
#endif
                      "gimp",              gimp,
                      "filenames",         filenames,
                      "as-new",            as_new,

                      "quit",              quit,
                      "batch-interpreter", batch_interpreter,
                      "batch-commands",    batch_commands,

                      "no-splash",         no_splash,
                      NULL);

  return G_APPLICATION (app);
}

gboolean
gimp_app_get_no_splash (GimpApp *self)
{
  g_return_val_if_fail (GIMP_IS_APP (self), FALSE);
  return GIMP_APP (self)->no_splash;
}