1 /** \file uicompiletimefeatures.c
2 * \brief Dialog to display compile time features
3 *
4 * \author Bas Wassink <b.wassink@ziggo.nl>
5 */
6
7 /*
8 * This file is part of VICE, the Versatile Commodore Emulator.
9 * See README for copyright notice.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 * 02111-1307 USA.
25 *
26 */
27
28 #include "vice.h"
29
30 #include <gtk/gtk.h>
31
32 #include "widgethelpers.h"
33 #include "debug_gtk3.h"
34 #include "machine.h"
35 #include "vicefeatures.h"
36 #include "ui.h"
37
38 #include "uicompiletimefeatures.h"
39
40
41 /** \brief Handler for the 'response' event of the dialog
42 *
43 * \param[in,out] dialog dialog triggering the event
44 * \param[in] response_id response ID
45 * \param[in] user_data extra event data (unused)
46 */
on_response(GtkDialog * dialog,gint response_id,gpointer user_data)47 static void on_response(GtkDialog *dialog,
48 gint response_id,
49 gpointer user_data)
50 {
51 if (response_id == GTK_RESPONSE_CLOSE) {
52 gtk_widget_destroy(GTK_WIDGET(dialog));
53 }
54 }
55
56
57 /** \brief Create tree model with compile time features
58 *
59 * \return GtkTreeStore
60 */
create_store(void)61 static GtkTreeStore *create_store(void)
62 {
63 GtkTreeStore *store;
64 GtkTreeIter iter;
65 feature_list_t *list;
66
67 store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
68 list = vice_get_feature_list();
69
70 while (list->symbol != NULL) {
71 gtk_tree_store_append(store, &iter, NULL);
72 gtk_tree_store_set(store, &iter,
73 0, list->descr,
74 1, list->symbol,
75 2, list->isdefined ? "yes" : "no",
76 -1);
77 list++;
78 }
79 return store;
80 }
81
82
83 /** \brief Create listview with compile time features
84 *
85 * \return GtkScrolledWindow
86 */
create_content_widget(void)87 static GtkWidget *create_content_widget(void)
88 {
89 GtkWidget *view;
90 GtkWidget *scrolled;
91 GtkTreeStore *store;
92 GtkCellRenderer *text_renderer;
93 GtkTreeViewColumn *column_desc;
94 GtkTreeViewColumn *column_macro;
95 GtkTreeViewColumn *column_state;
96
97
98 scrolled = gtk_scrolled_window_new(NULL, NULL);
99 store = create_store();
100 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
101
102 text_renderer = gtk_cell_renderer_text_new();
103
104 column_desc = gtk_tree_view_column_new_with_attributes(
105 "Description", text_renderer,
106 "text", 0,
107 NULL);
108 column_macro = gtk_tree_view_column_new_with_attributes(
109 "Macro", text_renderer,
110 "text", 1,
111 NULL);
112 column_state = gtk_tree_view_column_new_with_attributes(
113 "Enabled", text_renderer,
114 "text", 2,
115 NULL);
116
117 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column_desc);
118 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column_macro);
119 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column_state);
120
121 gtk_widget_set_size_request(scrolled, 800, 600);
122 gtk_container_add(GTK_CONTAINER(scrolled), view);
123
124 gtk_widget_show_all(scrolled);
125 return scrolled;
126 }
127
128
129 /** \brief Show list of compile time features
130 *
131 * \param[in] widget parent widget
132 * \param[in] user_data extra data (unused)
133 */
uicompiletimefeatures_dialog_show(GtkWidget * widget,gpointer user_data)134 void uicompiletimefeatures_dialog_show(GtkWidget *widget, gpointer user_data)
135 {
136 GtkWidget *dialog;
137 GtkWidget *content;
138 gchar title[256];
139
140 g_snprintf(title, 256, "%s compile time features", machine_name);
141
142 dialog = gtk_dialog_new_with_buttons(title,
143 ui_get_active_window(),
144 GTK_DIALOG_MODAL,
145 "Close", GTK_RESPONSE_CLOSE,
146 NULL);
147
148 content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
149 gtk_box_pack_start(GTK_BOX(content), create_content_widget(),
150 TRUE, TRUE, 0);
151
152 g_signal_connect(dialog, "response", G_CALLBACK(on_response), NULL);
153 gtk_widget_show_all(dialog);
154
155 }
156