1 /***************************************************************************
4 * Sat Mar 1 20:47:23 2008
5 * Copyright 2008 Johannes Schmid
7 ****************************************************************************/
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 Library 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, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
26 #include "build-options.h"
27 #include <glib/gi18n.h>
28 #include <glade/glade-xml.h>
29 #include <libanjuta/anjuta-debug.h>
32 #define GLADE_FILE PACKAGE_DATA_DIR"/glade/anjuta-build-basic-autotools-plugin.glade"
40 const Options gcc
[] = {
42 {N_("Debug"), "-g -O0"},
43 {N_("Profiling"), "-g -pg"},
44 {N_("Optimized"), "-O2"}
55 fill_options_combo (GtkComboBoxEntry
* combo
)
57 GtkCellRenderer
* renderer_label
= gtk_cell_renderer_text_new ();
58 GtkCellRenderer
* renderer_options
= gtk_cell_renderer_text_new ();
60 GtkListStore
* store
= gtk_list_store_new(N_COLUMNS
, G_TYPE_STRING
, G_TYPE_STRING
);
63 for (i
= 0; i
< G_N_ELEMENTS(gcc
); i
++)
66 gtk_list_store_append (store
, &iter
);
67 gtk_list_store_set (store
, &iter
,
68 COLUMN_LABEL
, gcc
[i
].label
,
69 COLUMN_OPTIONS
, gcc
[i
].options
, -1);
71 gtk_combo_box_set_model (GTK_COMBO_BOX(combo
), GTK_TREE_MODEL(store
));
72 gtk_combo_box_entry_set_text_column (combo
, 1);
74 gtk_cell_layout_clear (GTK_CELL_LAYOUT(combo
));
75 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combo
), renderer_label
, TRUE
);
76 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combo
), renderer_options
, FALSE
);
77 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combo
), renderer_label
,
78 "text", COLUMN_LABEL
);
79 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(combo
), renderer_options
,
80 "text", COLUMN_OPTIONS
);
81 g_object_set (renderer_label
,
82 "style", PANGO_STYLE_ITALIC
, NULL
);
86 build_dialog_configure (GtkWindow
* parent
, const gchar
* dialog_title
,
87 GHashTable
** build_options
,
88 const gchar
* default_args
, gchar
** args
)
90 GladeXML
* gxml
= glade_xml_new (GLADE_FILE
, "configure_dialog", NULL
);
91 GtkDialog
* dialog
= GTK_DIALOG (glade_xml_get_widget (gxml
, "configure_dialog"));
92 GtkComboBoxEntry
* combo
93 = GTK_COMBO_BOX_ENTRY (glade_xml_get_widget(gxml
, "build_options_combo"));
94 GtkEntry
* entry_args
= GTK_ENTRY (glade_xml_get_widget (gxml
, "configure_args_entry"));
96 gtk_window_set_title (GTK_WINDOW(dialog
), dialog_title
);
99 gtk_entry_set_text (entry_args
, default_args
);
100 fill_options_combo(combo
);
102 int response
= gtk_dialog_run (dialog
);
103 if (response
!= GTK_RESPONSE_OK
)
105 *build_options
= NULL
;
107 gtk_widget_destroy (GTK_WIDGET(dialog
));
112 GtkEntry
* build_options_entry
= GTK_ENTRY(gtk_bin_get_child (GTK_BIN(combo
)));
113 const gchar
* options
= gtk_entry_get_text (build_options_entry
);
114 *args
= g_strdup (gtk_entry_get_text (entry_args
));
115 *build_options
= g_hash_table_new_full (g_str_hash
, g_str_equal
,
119 /* set options for all languages */
120 g_hash_table_insert (*build_options
,
121 "CFLAGS", g_strdup(options
));
122 g_hash_table_insert (*build_options
,
123 "CXXFLAGS", g_strdup(options
));
124 g_hash_table_insert (*build_options
,
125 "JFLAGS", g_strdup(options
));
126 g_hash_table_insert (*build_options
,
127 "FFLAGS", g_strdup(options
));
129 gtk_widget_destroy (GTK_WIDGET(dialog
));