1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * dialog-col-row.c: group/ungroup dialog
6 * Andreas J. Guelzow <aguelzow@taliesin.ca>
8 * (c) Copyright 2002-2006 Andreas J. Guelzow <aguelzow@taliesin.ca>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <https://www.gnu.org/licenses/>.
23 #include <gnumeric-config.h>
30 #include <workbook-control.h>
36 #define COL_ROW_DIALOG_KEY "col-row-dialog"
42 GtkWidget
*cancel_button
;
46 ColRowCallback_t callback
;
50 cb_dialog_col_row_destroy (ColRowState
*state
)
52 if (state
->gui
!= NULL
)
53 g_object_unref (state
->gui
);
58 cb_dialog_col_row_cancel_clicked (G_GNUC_UNUSED GtkWidget
*button
,
61 gtk_widget_destroy (state
->dialog
);
66 cb_dialog_col_row_ok_clicked (G_GNUC_UNUSED GtkWidget
*button
,
69 state
->callback (state
->wbcg
,
70 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
71 (go_gtk_builder_get_widget (state
->gui
,
74 gtk_widget_destroy (state
->dialog
);
78 dialog_col_row (WBCGtk
*wbcg
, char const *operation
,
79 ColRowCallback_t callback
,
85 g_return_if_fail (wbcg
!= NULL
);
87 if (gnm_dialog_raise_if_exists (wbcg
, COL_ROW_DIALOG_KEY
))
89 gui
= gnm_gtk_builder_load ("res:ui/colrow.ui", NULL
, GO_CMD_CONTEXT (wbcg
));
93 state
= g_new (ColRowState
, 1);
95 state
->callback
= callback
;
99 state
->dialog
= go_gtk_builder_get_widget (state
->gui
, "dialog");
101 state
->ok_button
= go_gtk_builder_get_widget (state
->gui
, "ok_button");
102 g_signal_connect (G_OBJECT (state
->ok_button
),
104 G_CALLBACK (cb_dialog_col_row_ok_clicked
), state
);
106 state
->cancel_button
= go_gtk_builder_get_widget (state
->gui
, "cancel_button");
107 g_signal_connect (G_OBJECT (state
->cancel_button
),
109 G_CALLBACK (cb_dialog_col_row_cancel_clicked
), state
);
111 gnm_init_help_button (
112 go_gtk_builder_get_widget (state
->gui
, "help_button"),
113 GNUMERIC_HELP_LINK_GROUP_UNGROUP
);
115 gtk_window_set_title (GTK_WINDOW (state
->dialog
), operation
);
117 wbc_gtk_attach_guru (state
->wbcg
, state
->dialog
);
118 g_object_set_data_full (G_OBJECT (state
->dialog
),
119 "state", state
, (GDestroyNotify
) cb_dialog_col_row_destroy
);
121 gnm_keyed_dialog (wbcg
, GTK_WINDOW (state
->dialog
),
123 gtk_widget_show (state
->dialog
);