Compilation: don't compile dialogs separately.
[gnumeric.git] / src / dialogs / dialog-col-row.c
blob0a49846a76310112d5f46831e1c941b9ad95a5f4
1 /*
2 * dialog-col-row.c: group/ungroup dialog
4 * Author:
5 * Andreas J. Guelzow <aguelzow@taliesin.ca>
7 * (c) Copyright 2002-2006 Andreas J. Guelzow <aguelzow@taliesin.ca>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
22 #include <gnumeric-config.h>
23 #include <gnumeric.h>
24 #include "dialogs.h"
25 #include "help.h"
27 #include <gui-util.h>
28 #include <commands.h>
29 #include <workbook-control.h>
30 #include <workbook.h>
31 #include <wbc-gtk.h>
33 #include <gtk/gtk.h>
35 #define COL_ROW_DIALOG_KEY "col-row-dialog"
37 typedef struct {
38 GtkBuilder *gui;
39 GtkWidget *dialog;
40 GtkWidget *ok_button;
41 GtkWidget *cancel_button;
42 WBCGtk *wbcg;
44 gpointer data;
45 ColRowCallback_t callback;
46 } ColRowState;
48 static void
49 cb_dialog_col_row_destroy (ColRowState *state)
51 if (state->gui != NULL)
52 g_object_unref (state->gui);
53 g_free (state);
56 static void
57 cb_dialog_col_row_cancel_clicked (G_GNUC_UNUSED GtkWidget *button,
58 ColRowState *state)
60 gtk_widget_destroy (state->dialog);
64 static void
65 cb_dialog_col_row_ok_clicked (G_GNUC_UNUSED GtkWidget *button,
66 ColRowState *state)
68 state->callback (state->wbcg,
69 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
70 (go_gtk_builder_get_widget (state->gui,
71 "cols"))),
72 state->data);
73 gtk_widget_destroy (state->dialog);
76 /**
77 * dialog_col_row: (skip)
79 void
80 dialog_col_row (WBCGtk *wbcg, char const *operation,
81 ColRowCallback_t callback,
82 gpointer data)
84 GtkBuilder *gui;
85 ColRowState *state;
87 g_return_if_fail (wbcg != NULL);
89 if (gnm_dialog_raise_if_exists (wbcg, COL_ROW_DIALOG_KEY))
90 return;
91 gui = gnm_gtk_builder_load ("res:ui/colrow.ui", NULL, GO_CMD_CONTEXT (wbcg));
92 if (gui == NULL)
93 return;
95 state = g_new (ColRowState, 1);
96 state->wbcg = wbcg;
97 state->callback = callback;
98 state->data = data;
99 state->gui = gui;
101 state->dialog = go_gtk_builder_get_widget (state->gui, "dialog");
103 state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button");
104 g_signal_connect (G_OBJECT (state->ok_button),
105 "clicked",
106 G_CALLBACK (cb_dialog_col_row_ok_clicked), state);
108 state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button");
109 g_signal_connect (G_OBJECT (state->cancel_button),
110 "clicked",
111 G_CALLBACK (cb_dialog_col_row_cancel_clicked), state);
113 gnm_init_help_button (
114 go_gtk_builder_get_widget (state->gui, "help_button"),
115 GNUMERIC_HELP_LINK_GROUP_UNGROUP);
117 gtk_window_set_title (GTK_WINDOW (state->dialog), operation);
119 wbc_gtk_attach_guru (state->wbcg, state->dialog);
120 g_object_set_data_full (G_OBJECT (state->dialog),
121 "state", state, (GDestroyNotify) cb_dialog_col_row_destroy);
123 gnm_keyed_dialog (wbcg, GTK_WINDOW (state->dialog),
124 COL_ROW_DIALOG_KEY);
125 gtk_widget_show (state->dialog);