116 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
117 curve_model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree));
119 nrows = gtk_tree_selection_count_selected_rows (
sel);
169 gtk_tree_selection_select_all (
sel);
173 gtk_tree_selection_unselect_all (
sel);
188 double * cte = (
double *)user_data;
192 gtk_list_store_set (GTK_LIST_STORE(
curve_model), &
row, 2, * cte + vold, -1);
208 curve_model = gtk_tree_view_get_model (GTK_TREE_VIEW(this_proj -> curves[dat ->
b][dat ->
c] -> datatree));
209 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(this_proj -> curves[dat ->
b][dat ->
c] -> datatree));
210 gtk_tree_selection_select_all (
sel);
213 gtk_tree_selection_unselect_all (
sel);
228 double * cte = (
double *) user_data;
232 gtk_list_store_set (GTK_LIST_STORE(
curve_model), &
row, 2, * cte * vold, -1);
248 curve_model = gtk_tree_view_get_model (GTK_TREE_VIEW(this_proj -> curves[dat ->
b][dat ->
c] -> datatree));
249 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(this_proj -> curves[dat ->
b][dat ->
c] -> datatree));
250 gtk_tree_selection_select_all (
sel);
253 gtk_tree_selection_unselect_all (
sel);
269 gtk_tree_selection_select_iter (
sel, &
row);
290 gtk_tree_model_get (
curve_model, &
row, 0, & v1, 1, & v2, 2, & v3, -1);
293 text = g_strdup_printf (
"%d\t%f\t%f\n", v1, v2, v3);
297 tmp = g_strdup_printf (
"%s%d\t%f\t%f\n",
text, v1, v2, v3);
299 text = g_strdup_printf (
"%s", tmp);
317 gtk_clipboard_set_text (gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
text, -1);
318 gtk_clipboard_store (gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
331void add_row (gpointer data, gpointer user_data)
336 if (GPOINTER_TO_INT(user_data) == 0)
338 gtk_list_store_insert_before (GTK_LIST_STORE(
curve_model), & newrow, &
row);
342 gtk_list_store_insert_after (GTK_LIST_STORE(
curve_model), & newrow, &
row);
344 gtk_list_store_set (GTK_LIST_STORE(
curve_model), & newrow, 0, 0, 1, 0.00000, 2, 0.00000, -1);
374 if (GPOINTER_TO_INT(data) == 0)
376 path = (GtkTreePath *) g_list_nth_data (
lrows, 0);
409G_MODULE_EXPORT
void edit_cell (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer user_data)
413 curve_model = gtk_tree_view_get_model(GTK_TREE_VIEW(this_proj -> curves[
id ->
b][
id ->
c] -> datatree));
414 gtk_tree_model_get_iter_from_string (
curve_model, &
row, path_string);
415 double val = atof(new_text);
447 if (response_id == GTK_RESPONSE_APPLY)
473 gtk_dialog_add_button (GTK_DIALOG (wind),
"Apply", GTK_RESPONSE_APPLY);
478 str = g_strdup_printf (
"Add Constant to Last Column");
479 lab = gtk_label_new (str);
480 gtk_widget_set_size_request (
lab, 200, -1);
483 gtk_entry_set_alignment (GTK_ENTRY(
col_entry), 1.0);
500 if (response_id == GTK_RESPONSE_APPLY)
526 gtk_dialog_add_button (GTK_DIALOG (wind),
"Apply", GTK_RESPONSE_APPLY);
531 str = g_strdup_printf (
"Multiply Last Column by Constant");
532 lab = gtk_label_new (str);
533 gtk_widget_set_size_request (
lab, 200, -1);
536 gtk_entry_set_alignment (GTK_ENTRY(
col_entry), 1.0);
549 GMenu * menu = g_menu_new ();
550 append_menu_item (menu,
"Before",
"data-pop.insert.before", NULL, NULL,
IMG_STOCK, (gpointer)
GO_UP, FALSE, FALSE, FALSE, NULL);
551 append_menu_item (menu,
"After",
"data-pop.insert.after", NULL, NULL,
IMG_STOCK, (gpointer)
GO_DOWN, FALSE, FALSE, FALSE, NULL);
562 GMenu * menu = g_menu_new ();
574 GMenu * menu = g_menu_new ();
575 append_menu_item (menu,
"Delete Row(s)",
"data-pop.delete", NULL, NULL,
IMG_STOCK, (gpointer)
LIST_REM, FALSE, FALSE, FALSE, NULL);
586 GMenu * menu = g_menu_new ();
587 append_menu_item (menu,
"Copy Selected Row(s)",
"data-pop.copy", NULL, NULL,
IMG_STOCK, (gpointer)
EDITC, FALSE, FALSE, FALSE, NULL);
588 g_menu_append_section (menu, NULL, (GMenuModel*)
insert_data());
589 g_menu_append_section (menu, NULL, (GMenuModel*)
delete_data());
600 GMenu * menu = g_menu_new ();
601 append_menu_item (menu,
"Cell Based Operations",
"None", NULL, NULL,
IMG_NONE, NULL, FALSE, FALSE, FALSE, NULL);
612 GMenu * menu = g_menu_new ();
613 append_menu_item (menu,
"Add Constant to Last Column",
"data-pop.add", NULL, NULL,
IMG_STOCK, (gpointer)
LIST_ADD, FALSE, FALSE, FALSE, NULL);
614 append_menu_item (menu,
"Multiply Last Column by Constant",
"data-pop.mul", NULL, NULL,
IMG_STOCK, (gpointer)
FCLOSE, FALSE, FALSE, FALSE, NULL);
625 GMenu * menu = g_menu_new ();
626 append_menu_item (menu,
"Column Based Operations",
"None", NULL, NULL,
IMG_NONE, NULL, FALSE, FALSE, FALSE, NULL);
637 GMenu * menu = g_menu_new ();
638 g_menu_append_section (menu, NULL, (GMenuModel*)
cell_title());
639 g_menu_append_section (menu, NULL, (GMenuModel*)
cell_actions());
640 g_menu_append_section (menu, NULL, (GMenuModel*)
column_title());
641 g_menu_append_section (menu, NULL, (GMenuModel*)
column_actions());
656 gchar * name = g_strdup_printf (
"%s", g_action_get_name(G_ACTION(
action)));
657 if (g_strcmp0 (name,
"copy") == 0)
661 else if (g_strcmp0 (name,
"insert.before") == 0)
665 else if (g_strcmp0 (name,
"insert.after") == 0)
669 else if (g_strcmp0 (name,
"delete") == 0)
673 else if (g_strcmp0 (name,
"add") == 0)
677 else if (g_strcmp0 (name,
"mul") == 0)
708 GSimpleActionGroup * data_popup = g_simple_action_group_new ();
709 GSimpleAction * pop_data[6];
710 pop_data[0] = g_simple_action_new (
"copy", NULL);
711 pop_data[1] = g_simple_action_new (
"insert.before", NULL);
712 pop_data[2] = g_simple_action_new (
"insert.after", NULL);
713 pop_data[3] = g_simple_action_new (
"delete", NULL);
714 pop_data[4] = g_simple_action_new (
"add", NULL);
715 pop_data[5] = g_simple_action_new (
"mul", NULL);
717 g_signal_connect (pop_data[0],
"activate", G_CALLBACK(
data_pop_action), NULL);
718 g_signal_connect (pop_data[1],
"activate", G_CALLBACK(
data_pop_action), GINT_TO_POINTER(0));
719 g_signal_connect (pop_data[2],
"activate", G_CALLBACK(
data_pop_action), GINT_TO_POINTER(1));
720 g_signal_connect (pop_data[3],
"activate", G_CALLBACK(
data_pop_action), NULL);
721 g_signal_connect (pop_data[4],
"activate", G_CALLBACK(
data_pop_action), data);
722 g_signal_connect (pop_data[5],
"activate", G_CALLBACK(
data_pop_action), data);
725 for (i=0; i<6; i++) g_action_map_add_action (G_ACTION_MAP(data_popup), G_ACTION(pop_data[i]));
729 menu = gtk_popover_menu_new_from_model_full ((GMenuModel *)
data_menu(), GTK_POPOVER_MENU_NESTED);
730 gtk_widget_set_parent (menu, top_level);
732 menu = gtk_menu_new_from_model ((GMenuModel *)
data_menu ());
734 gtk_widget_insert_action_group (menu,
"data-pop", G_ACTION_GROUP(data_popup));
737 gtk_widget_set_size_request (menu, -1, 240);
757void data_button_event (GtkWidget * data_tree,
double event_x,
double event_y, guint event_button, guint event_type, gpointer data)
770void data_button_event (GtkWidget * data_tree, GdkEvent * event, guint event_button, guint event_type, gpointer data)
773 if (event_type == GDK_BUTTON_PRESS)
776 if (event_button == 3)
785 else if (event_type == GDK_BUTTON_RELEASE)
787 g_list_foreach (
lrows, (GFunc)gtk_tree_path_free, NULL);
804G_MODULE_EXPORT
void on_data_button_pressed (GtkGesture * gesture,
int n_press,
double x,
double y, gpointer data)
807 gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_PRESS, data);
821G_MODULE_EXPORT
void on_data_button_released (GtkGesture * gesture,
int n_press,
double x,
double y, gpointer data)
824 gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_RELEASE, data);
838 GdkEventButton * bevent = (GdkEventButton*)event;
854static void fill_data_model (GtkListStore * store,
project * this_proj,
int b,
int c)
856 GtkTreeIter datalevel;
858 for (i=0;
i<this_proj -> curves[
b][
c] -> ndata;
i++)
860 gtk_list_store_append (store, & datalevel);
861 gtk_list_store_set (store, & datalevel,
863 1, this_proj -> curves[
b][
c] -> data[0][i],
864 2, this_proj -> curves[
b][
c] -> data[1][i], -1);
879 GtkWidget * dataview;
880 GtkListStore * datamodel;
881 GType type[3]={G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE};
882 GtkTreeViewColumn * datacol[3];
883 GtkCellRenderer * datacel[3];
884 GtkTreeSelection * dataselect;
888 name[0]=g_strdup_printf (
" ");
889 name[1]=g_strdup_printf (
"%s", this_proj -> curves[
b][
c] ->
axis_title[0]);
890 name[2]=g_strdup_printf (
"%s\n%s",
prepare_for_title(this_proj -> name), this_proj -> curves[
b][
c] -> name);
891 datamodel = gtk_list_store_newv (3, type);
892 fill_data_model (datamodel, this_proj,
b,
c);
893 dataview = gtk_tree_view_new_with_model (GTK_TREE_MODEL(datamodel));
897 datacel[i] = gtk_cell_renderer_text_new();
914 g_object_set (datacel[i],
"editable", TRUE, NULL);
915 gtk_cell_renderer_set_alignment (datacel[i], 0.5, 0.5);
916 this_proj -> curves[
b][
c] -> idcol[i-1].a = this_proj -> id;
917 this_proj -> curves[
b][
c] -> idcol[i-1].b =
b;
918 this_proj -> curves[
b][
c] -> idcol[i-1].c =
c;
919 this_proj -> curves[
b][
c] -> idcol[i-1].d = i;
920 g_signal_connect (G_OBJECT(datacel[i]),
"edited", G_CALLBACK(
edit_cell), & this_proj -> curves[
b][
c] -> idcol[i-1]);
922 datacol[i] = gtk_tree_view_column_new_with_attributes(name[i], datacel[i],
"text", i, NULL);
923 gtk_tree_view_column_set_alignment (datacol[i], 0.5);
924 gtk_tree_view_column_set_resizable (datacol[i], TRUE);
925 gtk_tree_view_append_column(GTK_TREE_VIEW(dataview), datacol[i]);
928 gtk_tree_view_column_set_min_width (datacol[i], 100);
931 g_object_unref (datamodel);
932 dataselect = gtk_tree_view_get_selection (GTK_TREE_VIEW(dataview));
933 gtk_tree_selection_set_mode (dataselect, GTK_SELECTION_MULTIPLE);
935 g_signal_connect (G_OBJECT(dataview),
"button_press_event", G_CALLBACK(
on_data_button_event), & this_proj -> curves[
b][
c] -> idcol[1]);
937 add_widget_gesture_and_key_action (dataview,
"datab-context-click", G_CALLBACK(on_data_button_pressed), & this_proj -> curves[
b][
c] -> idcol[1],
938 "datab-context-release", G_CALLBACK(on_data_button_released), & this_proj -> curves[
b][
c] -> idcol[1],
939 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
941 gtk_tree_view_expand_all (GTK_TREE_VIEW(dataview));
968G_MODULE_EXPORT
void cancel_but (GtkButton * but, gpointer data)
982G_MODULE_EXPORT gboolean
cancel_win (GtkWindow * win, gpointer data)
993G_MODULE_EXPORT gboolean
cancel_win (GtkWidget * win, GdkEvent * event, gpointer data)
1012 curve_model = gtk_tree_view_get_model(GTK_TREE_VIEW(this_proj -> curves[
id ->
b][
id ->
c] -> datatree));
1013 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(this_proj -> curves[
id ->
b][
id ->
c] -> datatree));
1014 gtk_tree_selection_select_all (
sel);
1016 if (
nrows != this_proj -> curves[
id ->
b][
id ->
c] -> ndata)
1018 this_proj -> curves[
id ->
b][
id ->
c] -> ndata =
nrows;
1019 g_free (this_proj -> curves[
id ->
b][
id ->
c] -> data[0]);
1020 this_proj -> curves[
id ->
b][
id ->
c] -> data[0] = g_malloc0 (
nrows*
sizeof*this_proj -> curves[
id ->
b][
id ->
c] -> data[0]);
1021 g_free (this_proj -> curves[
id ->
b][
id ->
c] -> data[1]);
1022 this_proj -> curves[
id ->
b][
id ->
c] -> data[1] = g_malloc0 (
nrows*
sizeof*this_proj -> curves[
id ->
b][
id ->
c] -> data[1]);
1042 if (this_proj -> curves[
id ->
b][
id ->
c] -> datatree != NULL)
1044 win =
get_top_level(GTK_WIDGET(this_proj -> curves[
id ->
b][
id ->
c] -> datatree));
1048 gchar * str = g_strdup_printf (
"%s - %s",
prepare_for_title (this_proj -> name), this_proj -> curves[
id ->
b][
id ->
c] -> name);
1051 gtk_window_set_default_size (GTK_WINDOW(win), 300, 600);
1053 this_proj -> curves[
id ->
b][
id ->
c] -> datatree =
setview (this_proj,
id ->
b,
id ->
c);
1061 gtk_widget_set_size_request (
hbox, -1, 40);
Callback declarations for main window.
void update_curves()
update all curve(s) rendering for all project(s) in the workspace
Variable declarations for the curve widget Functions for interactions with the curve widget.
G_MODULE_EXPORT void data_pop_action(GSimpleAction *action, GVariant *parameter, gpointer data)
curve data edition popup menu actions callbacks
void add_to_last_row(gpointer data, gpointer user_data)
add constant to last row
void delete_row(gpointer data, gpointer user_data)
delete row
void insert_cell(gpointer data)
insert row
void add_to_last_col(double cte, gpointer data)
add constant value to selected rows
void update_first_col()
update all rows in the first column
G_MODULE_EXPORT void run_multiply_column(GtkDialog *wind, gint response_id, gpointer data)
multiply column by constant - running the dialog
GMenu * cell_title()
create the cell based operations subemu
void select_row(gpointer data, gpointer user_data)
select row
void copy_content(gpointer data)
copy selection
void data_popup_menu(GtkWidget *top_level, GdkEvent *event, gpointer data)
create curve data edition popup menu GTK3
G_MODULE_EXPORT void edit_cell(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data)
edit cell in the curve data edition tree model
G_MODULE_EXPORT void cancel_but(GtkButton *but, gpointer data)
cancel curve data edition button callback
GMenu * delete_data()
create the delete data submenu
void add_row(gpointer data, gpointer user_data)
add row
G_MODULE_EXPORT gboolean on_data_button_event(GtkWidget *widget, GdkEvent *event, gpointer data)
on button event in the curve data edition window
GtkWidget * setview(project *this_proj, int b, int c)
create the curve data tree store
GMenu * cell_actions()
create the cell actions submenu
void save_row(gpointer data, gpointer user_data)
save row data and udpate calculation result accordingly
GtkTreeModel * curve_model
void get_tree_data(GtkWidget *tree)
get information on location in a GtkTreeView
G_MODULE_EXPORT void run_add_to_column(GtkDialog *wind, gint response_id, gpointer data)
add constant to column - running the dialog
void multiply_last_row(gpointer data, gpointer user_data)
multiply last row by constant
void multiply_last_col(double cte, gpointer data)
multiply last colum by constant value
void edit_data(gpointer data)
create edit curve data dialog
GMenu * column_actions()
create the column actions submenu
void data_button_event(GtkWidget *data_tree, GdkEvent *event, guint event_button, guint event_type, gpointer data)
curve data edition mouse button event GTK3
void multiply_column(gpointer data)
multiply column by constant - creating dialog
void update_first_row(gpointer data, gpointer user_data)
update row in the first column
GMenu * column_title()
create the column based operations submenu
G_MODULE_EXPORT void validate_changes(GtkButton *but, gpointer data)
apply data edition changes
G_MODULE_EXPORT gboolean cancel_win(GtkWidget *win, GdkEvent *event, gpointer data)
cancel curve data edition callback GTK3
void cancel_changes(GtkWidget *widg, gpointer data)
cancel curve data edition
void add_to_column(gpointer data)
add constant to column - creating the dialog
G_MODULE_EXPORT void adjust_value(GtkEntry *res, gpointer data)
adjust constant value entry callback
GMenu * insert_data()
create the insert data submenu
void copy_row(gpointer data, gpointer user_data)
copy row
void delete_cell(gpointer data)
delete row
GMenu * data_menu()
create the curve data edition popup menu elements
GMenu * insert_place()
create the insertion submenu
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
void pop_menu_at_pointer(GtkWidget *widg, GdkEvent *event)
popup a menu at pointer location
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
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
GtkWidget * get_top_level(GtkWidget *widg)
get the top level container, window, of a widget
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
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.
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
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
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
void show_the_widgets(GtkWidget *widg)
show GtkWidget
project * get_project_by_id(int p)
get project pointer using id number
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...