atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
m_curve.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'm_curve.c'
24*
25* Contains:
26*
27
28 - The curve context menu (mouse right click)
29
30*
31* List of functions:
32
33 gboolean was_not_added (ExtraSets * sets, int a, int b, int c);
34
35 void autoscale (gpointer data);
36 void action_to_plot (pointer data);
37 void add_extra (ExtraSets * sets, tint * id);
38 void remove_extra (ExtraSets * sets, CurveExtra * ctmp);
39 void prep_extra_rid (tint * data);
40 void curve_window_add_menu_bar (tint * data);
41
42 G_MODULE_EXPORT void curve_edit_menu_action (GSimpleAction * action, GVariant * parameter, gpointer data);
43 G_MODULE_EXPORT void curve_add_remove_menu_action (GSimpleAction * action, GVariant * parameter, gpointer data);
44 G_MODULE_EXPORT void curve_menu_bar_action (GSimpleAction * action, GVariant * parameter, gpointer data);
45
46 GtkWidget * curve_popup_menu (gpointer data);
47
48 GMenu * curve_section (GSimpleActionGroup * action_group, gchar * act, ExtraSets * sets, gboolean add, int edit, int a, int b, tint * data);
49 GMenu * create_curve_submenu (GSimpleActionGroup * action_group, gchar * act, tint * data, gboolean add, int edit);
50 GMenu * create_curve_menu (gchar * str);
51 GMenu * edit_data_section (GSimpleActionGroup * action_group, gchar * str, tint * data);
52 GMenu * curve_close_section (gchar * str);
53 GMenu * create_data_menu (GSimpleActionGroup * action_group, int pop, gchar * str, tint * data);
54 GMenu * curve_menu_bar (project * this_proj, GSimpleActionGroup * action_group, gchar * str, tint * data);
55 GMenu * create_add_remove_section (GSimpleActionGroup * action_group, gchar * act, int num, tint * data);
56 GMenu * autoscale_section (gchar * str);
57
58 CurveExtra * init_extra (tint * id);
59
60*/
61
62#include <gtk/gtk.h>
63#include <stdlib.h>
64
65#include "global.h"
66#include "callbacks.h"
67#include "curve.h"
68#include "cedit.h"
69#include "datab.h"
70
71extern DataLayout * curve_default_layout (project * pid, int rid, int cid);
72extern GtkWidget * shortcuts_window (int sections, int group_by_section[sections], int groups, int shortcut_by_group[groups],
73 gchar * section_names[sections], gchar * group_names[groups], shortcuts shortcs[]);
74int ** extrarid;
75// gchar * curve_act[3]={"edit", "add", "rem"};
76
77gchar * curve_section_names[]={ "Curve window"};
79gchar * curve_group_names[]={"Edition", "Export"};
80int curve_shortcut_by_group[] = { 3, 2 };
81
83//
84// Global
85//
86 { "Autoscale", "Autoscale", GDK_KEY_a, "<Ctrl>a" },
87 { "Edit curve", "Edit curve", GDK_KEY_e, "<Ctrl>e" },
88 { "Close curve", "Close curve", GDK_KEY_c, "<Ctrl>c" },
89 { "Export data", "Export data", GDK_KEY_s, "<Ctrl>s" },
90 { "Save image", "Save image", GDK_KEY_i, "<Ctrl>i" }
91};
92
100void autoscale (gpointer data)
101{
102 tint * id = (tint *)data;
103 get_project_by_id(id -> a) -> curves[id -> b][id -> c] -> autoscale[0] = TRUE;
104 get_project_by_id(id -> a) -> curves[id -> b][id -> c] -> autoscale[1] = TRUE;
105 update_curve (data);
106}
107
116{
117 CurveExtra * ctmp = g_malloc0 (sizeof*ctmp);
118 ctmp -> id.a = id -> a;
119 ctmp -> id.b = id -> b;
120 ctmp -> id.c = id -> c;
121 ctmp -> layout = curve_default_layout (get_project_by_id(id -> a), id -> b, id -> c);
122 ctmp -> layout -> datacolor.red = 0.0;
123 ctmp -> layout -> datacolor.green = 0.0;
124 ctmp -> layout -> datacolor.blue = 0.0;
125 return ctmp;
126}
127
136void add_extra (ExtraSets * sets, tint * id)
137{
138 if (sets -> extras == 0)
139 {
140 sets -> first = init_extra (id);
141 sets -> last = sets -> first;
142 }
143 else
144 {
145 sets -> last -> next = init_extra (id);
146 sets -> last -> next -> prev = sets -> last;
147 sets -> last = sets -> last -> next;
148 }
149 sets -> extras ++;
150}
151
160void remove_extra (ExtraSets * sets, CurveExtra * ctmp)
161{
162 if (sets -> extras == 1)
163 {
164 g_free (ctmp);
165 sets -> first = NULL;
166 sets -> last = NULL;
167 }
168 else
169 {
170 if (ctmp -> prev == NULL)
171 {
172 sets -> first = ctmp -> next;
173 g_free (ctmp);
174 sets -> first -> prev = NULL;
175 }
176 else if (ctmp -> next == NULL)
177 {
178 ctmp = ctmp -> prev;
179 g_free (ctmp -> next);
180 ctmp -> next = NULL;
181 sets -> last = ctmp;
182 }
183 else
184 {
185 ctmp -> prev -> next = ctmp -> next;
186 ctmp -> next -> prev = ctmp -> prev;
187 g_free (ctmp);
188 }
189 }
190 sets -> extras --;
191}
192
193void curve_window_add_menu_bar (tint * data);
194
202void prep_extra_rid (tint * data)
203{
204 int i;
206 project * this_proj = get_project_by_id (data -> a);
207 if (this_proj -> curves[data -> b][data -> c] -> extrac -> extras > 0)
208 {
209 CurveExtra * ctmp = this_proj -> curves[data -> b][data -> c] -> extrac -> first;
210 for (i=0; i<this_proj -> curves[data -> b][data -> c] -> extrac -> extras; i++)
211 {
212 extrarid[ctmp -> id.a][ctmp -> id.b] ++;
213 if (ctmp -> next != NULL) ctmp = ctmp -> next;
214 }
215 }
216}
217
225void action_to_plot (gpointer data)
226{
227 int i;
228 tint * id = (tint *)data;
229 gboolean remove = FALSE;
230 project * this_proj = get_project_by_id (activeg);
231 if (this_proj -> curves[activer][activec] -> extrac > 0)
232 {
233 CurveExtra * ctmp = this_proj -> curves[activer][activec] -> extrac -> first;
234 for (i=0; i<this_proj -> curves[activer][activec] -> extrac -> extras; i++)
235 {
236 if (ctmp -> id.a == id -> a && ctmp -> id.b == id -> b && ctmp -> id.c == id -> c)
237 {
238 remove = TRUE;
239 break;
240 }
241 if (ctmp -> next != NULL) ctmp = ctmp -> next;
242 }
243 if (! remove)
244 {
245 add_extra (this_proj -> curves[activer][activec] -> extrac, id);
246 }
247 else
248 {
249 remove_extra (this_proj -> curves[activer][activec] -> extrac, ctmp);
250 }
251 }
252 else
253 {
254 add_extra (this_proj -> curves[activer][activec] -> extrac, id);
255 }
256 curve_window_add_menu_bar (& this_proj -> idcc[activer][activec]);
257 update_curve ((gpointer)& this_proj -> idcc[activer][activec]);
258}
259
269G_MODULE_EXPORT void curve_edit_menu_action (GSimpleAction * action, GVariant * parameter, gpointer data)
270{
271 edit_data (data);
272}
273
283G_MODULE_EXPORT void curve_add_remove_menu_action (GSimpleAction * action, GVariant * parameter, gpointer data)
284{
285 action_to_plot (data);
286}
287
297G_MODULE_EXPORT void curve_menu_bar_action (GSimpleAction * action, GVariant * parameter, gpointer data)
298{
299 gchar * name = g_strdup_printf ("%s", g_action_get_name(G_ACTION(action)));
300 if (g_strcmp0 (name, "save.data") == 0)
301 {
302 write_curve (data);
303 }
304 else if (g_strcmp0 (name, "close.curve") == 0)
305 {
306 hide_curve (data);
307 }
308 else if (g_strcmp0 (name, "edit.curve") == 0)
309 {
310 edit_curve (data);
311 }
312 else if (g_strcmp0 (name, "save.image") == 0)
313 {
314 save_image (data);
315 }
316 else if (g_strcmp0 (name, "autoscale.curve") == 0)
317 {
318 autoscale (data);
319 }
320 else if (g_strcmp0 (name, "shortcuts.curve") == 0)
321 {
322 tint * id = (tint *)data;
323 get_project_by_id(id -> a) -> curves[id -> b][id -> c] -> shortcuts = destroy_this_widget (get_project_by_id(id -> a) -> curves[id -> b][id -> c] -> shortcuts);
324 get_project_by_id(id -> a) -> curves[id -> b][id -> c] -> shortcuts = shortcuts_window (G_N_ELEMENTS(curve_group_by_section), curve_group_by_section, G_N_ELEMENTS(curve_shortcut_by_group),
326 }
327}
328
339gboolean was_not_added (ExtraSets * sets, int a, int b, int c)
340{
341 int i, j;
342 CurveExtra * ctmp = sets -> first;
343 for (i=0; i<sets -> extras; i++)
344 {
345 if (ctmp -> id.a == a && ctmp -> id.b == b)
346 {
347 for (j=0; j<get_project_by_id(a) -> numc[b]; j++)
348 {
349 if (ctmp -> id.c == c) return FALSE;
350 }
351 }
352 if (ctmp -> next != NULL) ctmp = ctmp -> next;
353 }
354 return TRUE;
355}
356
371GMenu * curve_section (GSimpleActionGroup * action_group, gchar * act, ExtraSets * sets, gboolean add, int edit, int a, int b, tint * data)
372{
373 GMenu * menu = g_menu_new ();
374 gchar * str_a, * str_b, * str_c;
375 gchar * text[2] = {"curve.action", "edit.data"};
376 project * this_proj = get_project_by_id(a);
377 int i;
378 for (i=0; i<this_proj -> numc[b]; i++)
379 {
380 if (this_proj -> curves[b][i] -> ndata > 0)
381 {
382 if (((a != data -> a || b != data -> b || i != data -> c) && add == was_not_added(sets, a, b, i)) || (a == data -> a && b == data -> b && i == data -> c && edit))
383 {
384 str_a = g_strdup_printf ("%s", this_proj -> curves[b][i] -> name);
385 str_b = g_strdup_printf ("%s.%d-%d-%d", text[edit], a, b, i);
386 str_c = g_strdup_printf ("%s.%s", act, str_b);
387 append_menu_item (menu, (const gchar *)str_a, (const gchar *)str_c, NULL, NULL, IMG_NONE, NULL, FALSE, FALSE, FALSE, NULL);
388 g_free (str_a);
389 g_free (str_c);
390 if (edit)
391 {
392 widget_add_action (action_group, (const gchar *)str_b, G_CALLBACK(curve_edit_menu_action), & this_proj -> idcc[b][i], FALSE, FALSE, FALSE, NULL);
393 }
394 else
395 {
396 widget_add_action (action_group, (const gchar *)str_b, G_CALLBACK(curve_add_remove_menu_action), & this_proj -> idcc[b][i], FALSE, FALSE, FALSE, NULL);
397 }
398 g_free (str_b);
399 }
400 }
401 }
402 return menu;
403}
404
416GMenu * create_curve_submenu (GSimpleActionGroup * action_group, gchar * act, tint * data, gboolean add, int edit)
417{
418 project * this_proj;
419 GMenu * menu = g_menu_new ();
420 int i, j, k;
421 gboolean * create_proj = allocbool (nprojects);
422 gboolean ** create_menu = allocdbool (nprojects, NCALCS);
423 for (i=0; i<nprojects; i++)
424 {
425 this_proj = get_project_by_id(i);
426 create_menu[i][data -> b] = FALSE;
427 create_proj[i] = FALSE;
428 j = 0;
429 if (data -> b == GR || data -> b == GK)
430 {
431 j = 1;
432 k = (data -> b == GR) ? GK : GR;
433 }
434 else if (data -> b == SQ || data -> b == SK)
435 {
436 j = 1;
437 k = (data -> b == SQ) ? SK : SQ;
438 }
439
440 if (((add && extrarid[i][data -> b] < this_proj -> numc[data -> b])
441 || (! add && extrarid[i][data -> b] > 0)) && this_proj -> visok[data -> b])
442 {
443 create_menu[i][data -> b] = TRUE;
444 create_proj[i] = TRUE;
445 }
446
447 if (j && this_proj -> visok[k])
448 {
449 create_menu[i][k] = FALSE;
450 if (this_proj -> curves[k][0] -> ndata > 0)
451 {
452 if ((add && extrarid[i][k] < this_proj -> numc[k])
453 || (! add && extrarid[i][k] > 0))
454 {
455 create_menu[i][k] = TRUE;
456 create_proj[i] = TRUE;
457 }
458 }
459 }
460 }
461 if (edit)
462 {
463 create_menu[data -> a][data -> b] = TRUE;
464 create_proj[data -> a] = TRUE;
465 }
466 this_proj = get_project_by_id(data -> a);
467 GMenu * smenu;
468 for (i=0; i<nprojects; i++)
469 {
470 if (create_proj[i])
471 {
472 smenu = g_menu_new ();
473 if (create_menu[i][data -> b]) append_submenu (smenu, graph_name[data -> b], curve_section(action_group, act, this_proj -> curves[data -> b][data -> c] -> extrac, add, edit, i, data -> b, data));
474 if (j && create_menu[i][k]) append_submenu (smenu, graph_name[k], curve_section(action_group, act, this_proj -> curves[data -> b][data -> c] -> extrac, add, edit, i, k, data));
475 append_submenu (menu, get_project_by_id(i) -> name, smenu);
476 }
477 }
478 g_free (create_proj);
479 g_free (create_menu);
480 return menu;
481}
482
483extern GIcon * get_gicon_from_data (int format, const gchar * icon);
484
492GMenu * create_curve_menu (gchar * str)
493{
494 GMenu * menu = g_menu_new ();
495 gchar * act = g_strdup_printf ("%s.edit.curve", str);
496 append_menu_item (menu, "Edit Curve", (const gchar *)act, "<CTRL>E", NULL, IMG_STOCK, PAGE_SETUP, FALSE, FALSE, FALSE, NULL);
497 g_free (act);
498 act = g_strdup_printf ("%s.save.image", str);
499 append_menu_item (menu, "Export Image", (const gchar *)act, "<CTRL>I", NULL, IMG_FILE, PACKAGE_IMG, FALSE, FALSE, FALSE, NULL);
500 g_free (act);
501 return menu;
502}
503
513GMenu * edit_data_section (GSimpleActionGroup * action_group, gchar * str, tint * data)
514{
515 GMenu * menu = g_menu_new ();
516 GMenuItem * item = g_menu_item_new ("Edit Data", NULL);
517 gchar * str_edit = g_strdup_printf ("%s-win-edit", str);
518 g_menu_item_set_attribute (item, "custom", "s", str_edit, NULL);
519 g_free (str_edit);
520#ifdef MENU_ICONS
521 GIcon * gicon = get_gicon_from_data (IMG_STOCK, EDITA);
522 g_menu_item_set_icon (item, gicon);
523 g_object_unref (gicon);
524#endif
525 g_menu_item_set_submenu (item, (GMenuModel *)create_curve_submenu (action_group, str, data, FALSE, 1));
526 g_menu_append_item (menu, item);
527 g_object_unref (item);
528 return menu;
529}
530
538GMenu * curve_close_section (gchar * str)
539{
540 GMenu * menu = g_menu_new ();
541 gchar * act = g_strdup_printf ("%s.close.curve", str);
542 append_menu_item (menu, "Close", (const gchar *)act, "<CTRL>C", NULL, IMG_STOCK, FCLOSE, FALSE, FALSE, FALSE, NULL);
543 g_free (act);
544 return menu;
545}
546
554GMenu * curve_help_menu (gchar * str)
555{
556 GMenu * menu = g_menu_new ();
557 gchar * act = g_strdup_printf ("%s.shortcuts.curve", str);
558 append_menu_item (menu, "Shortcuts", (const gchar *)act, NULL, NULL, IMG_NONE, NULL, FALSE, FALSE, FALSE, NULL);
559 g_free (act);
560 return menu;
561}
562
573GMenu * create_data_menu (GSimpleActionGroup * action_group, int pop, gchar * str, tint * data)
574{
575 GMenu * menu = g_menu_new ();
576 g_menu_append_section (menu, NULL, (GMenuModel*)edit_data_section(action_group, str, data));
577 gchar * act = g_strdup_printf ("%s.save.data", str);
578 append_menu_item (menu, "Save Data", (const gchar *)act, "<CTRL>S", NULL, IMG_STOCK, FSAVEAS, FALSE, FALSE, FALSE, NULL);
579 g_free (act);
580 if (! pop) g_menu_append_section (menu, NULL, (GMenuModel *)curve_close_section(str));
581 return menu;
582}
583
594GMenu * curve_menu_bar (project * this_proj, GSimpleActionGroup * action_group, gchar * str, tint * data)
595{
596 GMenu * menu = g_menu_new ();
597 prep_extra_rid (data);
598 append_submenu (menu, "Data", create_data_menu(action_group, 0, str, data));
599 g_free (extrarid);
600 append_submenu (menu, "Curve", create_curve_menu(str));
601 append_submenu (menu, "Help", curve_help_menu(str));
602 return menu;
603}
604
613{
614 project * this_proj = get_project_by_id (data -> a);
615 this_proj -> curves[data -> b][data -> c] -> pos = destroy_this_widget (this_proj -> curves[data -> b][data -> c] -> pos);
616 this_proj -> curves[data -> b][data -> c] -> pos = gtk_label_new (" ");
617 this_proj -> curves[data -> b][data -> c] -> curve_hbox = destroy_this_widget (this_proj -> curves[data -> b][data -> c] -> curve_hbox);
618 this_proj -> curves[data -> b][data -> c] -> curve_hbox = create_hbox (0);
619 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> curves[data -> b][data -> c] -> curve_vbox, this_proj -> curves[data -> b][data -> c] -> curve_hbox, FALSE, FALSE, 0);
620 gchar * str = g_strdup_printf ("c-%d", this_proj -> curves[data -> b][data -> c] -> action_id);
621#ifdef GTK3
622 GtkWidget * menu = gtk_menu_bar_new_from_model ((GMenuModel *)curve_menu_bar(this_proj, this_proj -> curves[data -> b][data -> c] -> action_group, str, data));
623#else
624 GtkWidget * menu = gtk_popover_menu_bar_new_from_model ((GMenuModel *)curve_menu_bar(this_proj, this_proj -> curves[data -> b][data -> c] -> action_group, str, data));
625#endif
626 g_free (str);
627 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, this_proj -> curves[data -> b][data -> c] -> curve_hbox, menu, TRUE, TRUE, 0);
628 gtk_label_align (this_proj -> curves[data -> b][data -> c] -> pos, 1.0, 0.5);
629 add_box_child_end (this_proj -> curves[data -> b][data -> c] -> curve_hbox, this_proj -> curves[data -> b][data -> c] -> pos, FALSE, FALSE, 0);
630 show_the_widgets (this_proj -> curves[data -> b][data -> c] -> curve_hbox);
631}
632
643GMenu * create_add_remove_section (GSimpleActionGroup * action_group, gchar * act, int num, tint * data)
644{
645 GMenu * menu = g_menu_new ();
646 GMenuItem * item = g_menu_item_new ("Add Data Set", NULL);
647#ifdef MENU_ICONS
648 GIcon * gicon = get_gicon_from_data (IMG_STOCK, LIST_ADD);
649 g_menu_item_set_icon (item, gicon);
650 g_object_unref (gicon);
651#endif
652 project * this_proj = get_project_by_id (data -> a);
653 if (this_proj -> curves[data -> b][data -> c] -> extrac -> extras < num)
654 {
655 g_menu_item_set_submenu (item, (GMenuModel *)create_curve_submenu (action_group, act, data, TRUE, 0));
656 }
657 else
658 {
659 g_menu_item_set_attribute (item, "action", "s", "None", NULL);
660 }
661 g_menu_append_item (menu, item);
662 g_object_unref (item);
663
664 item = g_menu_item_new ("Remove Data Set", NULL);
665#ifdef MENU_ICONS
667 g_menu_item_set_icon (item, gicon);
668 g_object_unref (gicon);
669#endif
670 if (this_proj -> curves[data -> b][data -> c] -> extrac -> extras > 0)
671 {
672 g_menu_item_set_submenu (item, (GMenuModel *)create_curve_submenu (action_group, act, data, FALSE, 0));
673 }
674 else
675 {
676 g_menu_item_set_attribute (item, "action", "s", "None", NULL);
677 }
678 g_menu_append_item (menu, item);
679 g_object_unref (item);
680 return menu;
681}
682
690GMenu * autoscale_section (gchar * str)
691{
692 GMenu * menu = g_menu_new ();
693 gchar * act = g_strdup_printf ("%s.autoscale.curve", str);
694 append_menu_item (menu, "Autoscale", (const gchar *)act, "<CTRL>A", NULL, IMG_STOCK, FITBEST, FALSE, FALSE, FALSE, NULL);
695 g_free (act);
696 return menu;
697}
698
706GtkWidget * curve_popup_menu (gpointer data)
707{
708 GtkWidget * curve_pop_menu;
709 int i, j;
710 CurveState * cstate = (CurveState *)data;
711 GSimpleActionGroup * curve_popup_actions = g_simple_action_group_new ();
712 GSimpleAction * curve_popup_action[6];
713 curve_popup_action[0] = g_simple_action_new ("save.data", NULL);
714 curve_popup_action[1] = g_simple_action_new ("close.curve", NULL);
715 curve_popup_action[2] = g_simple_action_new ("edit.curve", NULL);
716 curve_popup_action[3] = g_simple_action_new ("save.image", NULL);
717 curve_popup_action[4] = g_simple_action_new ("autoscale.curve", NULL);
718 curve_popup_action[5] = g_simple_action_new ("shortcuts.curve", NULL);
719 for (i=0; i<6; i++)
720 {
721 g_action_map_add_action (G_ACTION_MAP(curve_popup_actions), G_ACTION(curve_popup_action[i]));
722 g_signal_connect (curve_popup_action[i], "activate", G_CALLBACK(curve_menu_bar_action), cstate -> id);
723 }
724 prep_extra_rid (cstate -> id);
725 gchar * str = g_strdup_printf ("mc-%d", get_project_by_id(cstate -> id -> a) -> curves[cstate -> id -> b][cstate -> id -> c] -> action_id);
726 GMenu * menu = g_menu_new ();
727 g_menu_append_section (menu, NULL, (GMenuModel *)create_data_menu(curve_popup_actions, 1, str, cstate -> id));
728 g_menu_append_section (menu, NULL, (GMenuModel *)create_curve_menu(str));
729 i = -1;
730 for ( j=0 ; j < nprojects; j++ )
731 {
732 i += get_project_by_id(j) -> numc[cstate -> id -> b];
733 if (cstate -> id -> b == GR || cstate -> id -> b == GK)
734 {
735 i += get_project_by_id(j) -> numc[(cstate -> id -> b == GR) ? GK : GR];
736 }
737 else if (cstate -> id -> b == SQ || cstate -> id -> b == SK)
738 {
739 i += get_project_by_id(j) -> numc[(cstate -> id -> b == SQ) ? SK : SQ];
740 }
741 }
742 g_menu_append_section (menu, NULL, (GMenuModel *)create_add_remove_section(curve_popup_actions, str, i, cstate -> id));
743 g_menu_append_section (menu, NULL, (GMenuModel *)autoscale_section(str));
744 g_menu_append_section (menu, NULL, (GMenuModel *)curve_close_section(str));
745 g_menu_append_section (menu, NULL, (GMenuModel *)curve_help_menu(str));
746 g_free (extrarid);
747#ifdef GTK4
748 curve_pop_menu = gtk_popover_menu_new_from_model_full ((GMenuModel *)menu, GTK_POPOVER_MENU_NESTED);
749 gtk_widget_set_parent (curve_pop_menu, get_project_by_id(cstate -> id -> a) -> curves[cstate -> id -> b][cstate -> id -> c] -> window);
750 gtk_widget_set_size_request (curve_pop_menu, -1, 305);
751#else
752 curve_pop_menu = gtk_menu_new_from_model ((GMenuModel *)menu);
753#endif
754 // Finally adding actions to the menu
755 gtk_widget_insert_action_group (curve_pop_menu, str, G_ACTION_GROUP(curve_popup_actions));
756 g_free (str);
757 return curve_pop_menu;
758}
Callback declarations for main window.
gchar * groups[230]
Definition cbuild_sg.c:43
void edit_curve(gpointer data)
create the curve edition dialog
Definition cedit.c:347
Variable declarations for the curve layout edition window.
void update_curve(gpointer data)
update curve rendering
Definition curve.c:589
PangoLayout * layout
Definition curve.c:79
Variable declarations for the curve widget Functions for interactions with the curve widget.
int activer
Definition w_curve.c:74
void hide_curve(gpointer data)
hide curve
Definition show.c:312
void save_image(gpointer cdata)
export curve window plot to image - creating the dialog
Definition w_img.c:326
int activec
Definition w_curve.c:73
int activeg
Definition w_curve.c:72
void write_curve(gpointer idata)
save curve data - creating the dialog
Definition w_data.c:164
gchar * text
Definition datab.c:105
void edit_data(gpointer data)
create edit curve data dialog
Definition datab.c:1037
Variable declarations for the curve data edition window.
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
gchar * PACKAGE_IMG
Definition global.c:81
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:254
int nprojects
Definition global.c:158
gboolean ** allocdbool(int xal, int yal)
allocate a gboolean ** pointer
Definition global.c:270
GtkWidget * pop
Definition global.c:204
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
@ IMG_STOCK
Definition global.h:264
@ IMG_FILE
Definition global.h:263
#define FITBEST
Definition global.h:199
void widget_add_action(GSimpleActionGroup *action_group, const gchar *act, GCallback handler, gpointer data, gboolean check, gboolean status, gboolean radio, const gchar *stat)
add an action to an action group
Definition gui.c:641
#define EDITA
Definition global.h:202
void append_submenu(GMenu *menu, const gchar *label, GMenu *submenu)
append a GMenuItem with a subenu to a GMenu, and use markup for the GMenuItem
Definition gui.c:728
#define GR
Definition global.h:322
#define NGRAPHS
#define SQ
Definition global.h:323
#define LIST_ADD
Definition global.h:213
#define LIST_REM
Definition global.h:214
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:299
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
void gtk_label_align(GtkWidget *lab, float ax, float ay)
set text alignment in a GtkLabel
Definition gtk-misc.c:701
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
void add_box_child_end(GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the end position.
Definition gtk-misc.c:277
char * graph_name[NGRAPHS]
Definition gui.c:133
void append_menu_item(GMenu *menu, const gchar *label, const gchar *action, const gchar *accel, const gchar *custom, int format, const gchar *icon, gboolean check, gboolean status, gboolean radio, const gchar *rstatus)
create a menu item, then append it to a menu
Definition gui.c:758
#define FCLOSE
Definition global.h:211
#define SK
Definition global.h:324
#define GK
Definition global.h:325
#define PAGE_SETUP
Definition global.h:197
#define NCALCS
#define FSAVEAS
Definition global.h:210
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
action
Definition glview.h:189
void prep_extra_rid(tint *data)
look up extra data set(s) for curve
Definition m_curve.c:202
int curve_shortcut_by_group[]
Definition m_curve.c:80
G_MODULE_EXPORT void curve_menu_bar_action(GSimpleAction *action, GVariant *parameter, gpointer data)
curve menu action callback
Definition m_curve.c:297
DataLayout * curve_default_layout(project *pid, int rid, int cid)
prepare the default layout for a curve
Definition cwidget.c:57
GtkWidget * curve_popup_menu(gpointer data)
create curve popup menu
Definition m_curve.c:706
GMenu * create_add_remove_section(GSimpleActionGroup *action_group, gchar *act, int num, tint *data)
create the add / remove curve submenus
Definition m_curve.c:643
G_MODULE_EXPORT void curve_edit_menu_action(GSimpleAction *action, GVariant *parameter, gpointer data)
curve menu edit action callback
Definition m_curve.c:269
GMenu * curve_close_section(gchar *str)
create the close menu item
Definition m_curve.c:538
GIcon * get_gicon_from_data(int format, const gchar *icon)
create a new icon using data
Definition gui.c:610
void autoscale(gpointer data)
autoscale callback
Definition m_curve.c:100
CurveExtra * init_extra(tint *id)
create extra data set
Definition m_curve.c:115
gchar * curve_group_names[]
Definition m_curve.c:79
int ** extrarid
Definition m_curve.c:74
gboolean was_not_added(ExtraSets *sets, int a, int b, int c)
test if already in the menu or not
Definition m_curve.c:339
G_MODULE_EXPORT void curve_add_remove_menu_action(GSimpleAction *action, GVariant *parameter, gpointer data)
curve menu add / remove action callback
Definition m_curve.c:283
GMenu * curve_menu_bar(project *this_proj, GSimpleActionGroup *action_group, gchar *str, tint *data)
create the curve window menu bar
Definition m_curve.c:594
GtkWidget * shortcuts_window(int sections, int group_by_section[sections], int groups, int shortcut_by_group[groups], gchar *section_names[sections], gchar *group_names[groups], shortcuts shortcs[])
Create the shortcuts information window.
Definition gui.c:181
void curve_window_add_menu_bar(tint *data)
add menu bar to the curve window
Definition m_curve.c:612
shortcuts curve_shortcuts[]
Definition m_curve.c:82
GMenu * create_curve_menu(gchar *str)
create the curve submenu
Definition m_curve.c:492
GMenu * autoscale_section(gchar *str)
create autoscale menu item
Definition m_curve.c:690
void add_extra(ExtraSets *sets, tint *id)
add set to the extra set(s)
Definition m_curve.c:136
void remove_extra(ExtraSets *sets, CurveExtra *ctmp)
remove data from extra set(s)
Definition m_curve.c:160
GMenu * edit_data_section(GSimpleActionGroup *action_group, gchar *str, tint *data)
create the edit data submenu
Definition m_curve.c:513
GMenu * curve_section(GSimpleActionGroup *action_group, gchar *act, ExtraSets *sets, gboolean add, int edit, int a, int b, tint *data)
create curve submenu
Definition m_curve.c:371
GMenu * create_data_menu(GSimpleActionGroup *action_group, int pop, gchar *str, tint *data)
create the save data submenu
Definition m_curve.c:573
int curve_group_by_section[]
Definition m_curve.c:78
GMenu * create_curve_submenu(GSimpleActionGroup *action_group, gchar *act, tint *data, gboolean add, int edit)
create curve add / remove submenus
Definition m_curve.c:416
void action_to_plot(gpointer data)
add to plot, or, remove curve from plot
Definition m_curve.c:225
GMenu * curve_help_menu(gchar *str)
create the help menu item
Definition m_curve.c:554
gchar * curve_section_names[]
Definition m_curve.c:77
Definition global.h:104
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95