summaryrefslogtreecommitdiffstats
path: root/app/actions/dashboard-actions.c
blob: e471307d6668a5cf905edbced7bb3a57126ff5c7 (plain)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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.
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <gegl.h>
#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "actions-types.h"

#include "widgets/gimpactiongroup.h"
#include "widgets/gimpdashboard.h"
#include "widgets/gimphelp-ids.h"

#include "dashboard-actions.h"
#include "dashboard-commands.h"

#include "gimp-intl.h"


static const GimpActionEntry dashboard_actions[] =
{
  { "dashboard-popup", GIMP_ICON_DIALOG_DASHBOARD,
    NC_("dashboard-action", "Dashboard Menu"), NULL, NULL, NULL,
    GIMP_HELP_DASHBOARD_DIALOG },

  { "dashboard-groups", NULL,
    NC_("dashboard-action", "_Groups") },
  { "dashboard-update-interval", NULL,
    NC_("dashboard-action", "_Update Interval") },
  { "dashboard-history-duration", NULL,
    NC_("dashboard-action", "_History Duration") },

  { "dashboard-log-record", GIMP_ICON_RECORD,
    NC_("dashboard-action", "_Start/Stop Recording..."), NULL,
    NC_("dashboard-action", "Start/stop recording performance log"),
    dashboard_log_record_cmd_callback,
    GIMP_HELP_DASHBOARD_LOG_RECORD },
  { "dashboard-log-add-marker", GIMP_ICON_MARKER,
    NC_("dashboard-action", "_Add Marker..."), NULL,
    NC_("dashboard-action", "Add an event marker "
                            "to the performance log"),
    dashboard_log_add_marker_cmd_callback,
    GIMP_HELP_DASHBOARD_LOG_ADD_MARKER },
  { "dashboard-log-add-empty-marker", GIMP_ICON_MARKER,
    NC_("dashboard-action", "Add _Empty Marker"), NULL,
    NC_("dashboard-action", "Add an empty event marker "
                            "to the performance log"),
    dashboard_log_add_empty_marker_cmd_callback,
    GIMP_HELP_DASHBOARD_LOG_ADD_EMPTY_MARKER },

  { "dashboard-reset", GIMP_ICON_RESET,
    NC_("dashboard-action", "_Reset"), NULL,
    NC_("dashboard-action", "Reset cumulative data"),
    dashboard_reset_cmd_callback,
    GIMP_HELP_DASHBOARD_RESET },
};

static const GimpToggleActionEntry dashboard_toggle_actions[] =
{
  { "dashboard-low-swap-space-warning", NULL,
    NC_("dashboard-action", "_Low Swap Space Warning"), NULL,
    NC_("dashboard-action", "Raise the dashboard when "
                            "the swap size approaches its limit"),
    dashboard_low_swap_space_warning_cmd_callback,
    FALSE,
    GIMP_HELP_DASHBOARD_LOW_SWAP_SPACE_WARNING }
};

static const GimpRadioActionEntry dashboard_update_interval_actions[] =
{
  { "dashboard-update-interval-0-25-sec", NULL,
    NC_("dashboard-update-interval", "0.25 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_UPDATE_INTERVAL_0_25_SEC,
    GIMP_HELP_DASHBOARD_UPDATE_INTERVAL },

  { "dashboard-update-interval-0-5-sec", NULL,
    NC_("dashboard-update-interval", "0.5 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_UPDATE_INTERVAL_0_5_SEC,
    GIMP_HELP_DASHBOARD_UPDATE_INTERVAL },

  { "dashboard-update-interval-1-sec", NULL,
    NC_("dashboard-update-interval", "1 Second"), NULL, NULL,
    GIMP_DASHBOARD_UPDATE_INTERVAL_1_SEC,
    GIMP_HELP_DASHBOARD_UPDATE_INTERVAL },

  { "dashboard-update-interval-2-sec", NULL,
    NC_("dashboard-update-interval", "2 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_UPDATE_INTERVAL_2_SEC,
    GIMP_HELP_DASHBOARD_UPDATE_INTERVAL },

  { "dashboard-update-interval-4-sec", NULL,
    NC_("dashboard-update-interval", "4 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_UPDATE_INTERVAL_4_SEC,
    GIMP_HELP_DASHBOARD_UPDATE_INTERVAL }
};

static const GimpRadioActionEntry dashboard_history_duration_actions[] =
{
  { "dashboard-history-duration-15-sec", NULL,
    NC_("dashboard-history-duration", "15 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_HISTORY_DURATION_15_SEC,
    GIMP_HELP_DASHBOARD_HISTORY_DURATION },

  { "dashboard-history-duration-30-sec", NULL,
    NC_("dashboard-history-duration", "30 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_HISTORY_DURATION_30_SEC,
    GIMP_HELP_DASHBOARD_HISTORY_DURATION },

  { "dashboard-history-duration-60-sec", NULL,
    NC_("dashboard-history-duration", "60 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_HISTORY_DURATION_60_SEC,
    GIMP_HELP_DASHBOARD_HISTORY_DURATION },

  { "dashboard-history-duration-120-sec", NULL,
    NC_("dashboard-history-duration", "120 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_HISTORY_DURATION_120_SEC,
    GIMP_HELP_DASHBOARD_HISTORY_DURATION },

  { "dashboard-history-duration-240-sec", NULL,
    NC_("dashboard-history-duration", "240 Seconds"), NULL, NULL,
    GIMP_DASHBOARD_HISTORY_DURATION_240_SEC,
    GIMP_HELP_DASHBOARD_HISTORY_DURATION }
};


void
dashboard_actions_setup (GimpActionGroup *group)
{
  gimp_action_group_add_actions (group, "dashboard-action",
                                 dashboard_actions,
                                 G_N_ELEMENTS (dashboard_actions));

  gimp_action_group_add_toggle_actions (group, "dashboard-action",
                                        dashboard_toggle_actions,
                                        G_N_ELEMENTS (dashboard_toggle_actions));

  gimp_action_group_add_radio_actions (group, "dashboard-update-interval",
                                       dashboard_update_interval_actions,
                                       G_N_ELEMENTS (dashboard_update_interval_actions),
                                       NULL,
                                       0,
                                       dashboard_update_interval_cmd_callback);

  gimp_action_group_add_radio_actions (group, "dashboard-history-duration",
                                       dashboard_history_duration_actions,
                                       G_N_ELEMENTS (dashboard_history_duration_actions),
                                       NULL,
                                       0,
                                       dashboard_history_duration_cmd_callback);
}

void
dashboard_actions_update (GimpActionGroup *group,
                          gpointer         data)
{
  GimpDashboard *dashboard = GIMP_DASHBOARD (data);
  gboolean       recording;

  recording = gimp_dashboard_log_is_recording (dashboard);

#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_ACTIVE(action,condition) \
        gimp_action_group_set_action_active (group, action, (condition) != 0)

  switch (gimp_dashboard_get_update_interval (dashboard))
    {
    case GIMP_DASHBOARD_UPDATE_INTERVAL_0_25_SEC:
      SET_ACTIVE ("dashboard-update-interval-0-25-sec", TRUE);
      break;
    case GIMP_DASHBOARD_UPDATE_INTERVAL_0_5_SEC:
      SET_ACTIVE ("dashboard-update-interval-0-5-sec", TRUE);
      break;
    case GIMP_DASHBOARD_UPDATE_INTERVAL_1_SEC:
      SET_ACTIVE ("dashboard-update-interval-1-sec", TRUE);
      break;
    case GIMP_DASHBOARD_UPDATE_INTERVAL_2_SEC:
      SET_ACTIVE ("dashboard-update-interval-2-sec", TRUE);
      break;
    case GIMP_DASHBOARD_UPDATE_INTERVAL_4_SEC:
      SET_ACTIVE ("dashboard-update-interval-4-sec", TRUE);
      break;
    }

  switch (gimp_dashboard_get_history_duration (dashboard))
    {
    case GIMP_DASHBOARD_HISTORY_DURATION_15_SEC:
      SET_ACTIVE ("dashboard-history-duration-15-sec", TRUE);
      break;
    case GIMP_DASHBOARD_HISTORY_DURATION_30_SEC:
      SET_ACTIVE ("dashboard-history-duration-30-sec", TRUE);
      break;
    case GIMP_DASHBOARD_HISTORY_DURATION_60_SEC:
      SET_ACTIVE ("dashboard-history-duration-60-sec", TRUE);
      break;
    case GIMP_DASHBOARD_HISTORY_DURATION_120_SEC:
      SET_ACTIVE ("dashboard-history-duration-120-sec", TRUE);
      break;
    case GIMP_DASHBOARD_HISTORY_DURATION_240_SEC:
      SET_ACTIVE ("dashboard-history-duration-240-sec", TRUE);
      break;
    }

  SET_SENSITIVE ("dashboard-log-add-marker",       recording);
  SET_SENSITIVE ("dashboard-log-add-empty-marker", recording);
  SET_SENSITIVE ("dashboard-reset",                !recording);

  SET_ACTIVE ("dashboard-low-swap-space-warning",
              gimp_dashboard_get_low_swap_space_warning (dashboard));

#undef SET_SENSITIVE
#undef SET_ACTIVE
}