summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Sindholt <opensource@zhasha.com>2010-04-09 20:22:08 +0200
committerJoakim Sindholt <opensource@zhasha.com>2010-04-09 20:22:08 +0200
commit30491efe88bf40913a38982ca7f53855faa07e79 (patch)
treeb3f3461cfe8c3e649ff7ce1fcfad2dd4311b0fd3
parentf2c1934bc758c5c990b175a3bf0087fa254ed5df (diff)
main: ask when deleting a CS
-rw-r--r--src/main.c19
-rw-r--r--src/main.vala9
2 files changed, 27 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 59afad0..9d1eaf6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -53,6 +53,7 @@ typedef struct _GUIMainWindowPrivate GUIMainWindowPrivate;
typedef struct _EmulationCS EmulationCS;
typedef struct _EmulationCSClass EmulationCSClass;
+#define _g_free0(var) (var = (g_free (var), NULL))
#define GUI_TYPE_CS_VIEW (gui_cs_view_get_type ())
#define GUI_CS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GUI_TYPE_CS_VIEW, GUICSView))
@@ -74,7 +75,6 @@ typedef struct _GUICSViewClass GUICSViewClass;
typedef struct _GUICSExport GUICSExport;
typedef struct _GUICSExportClass GUICSExportClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
-#define _g_free0(var) (var = (g_free (var), NULL))
#define GUI_TYPE_CS_IMPORT (gui_cs_import_get_type ())
#define GUI_CS_IMPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GUI_TYPE_CS_IMPORT, GUICSImport))
@@ -240,15 +240,32 @@ void gui_main_window_add_cs (GUIMainWindow* self, const char* name, EmulationCS*
void gui_main_window_remove_cs (GUIMainWindow* self) {
GtkTreeIter iter = {0};
+ char* name;
GtkTreeSelection* selection;
+ GtkMessageDialog* d;
+ gint _result_;
g_return_if_fail (self != NULL);
+ name = NULL;
selection = _g_object_ref0 (gtk_tree_view_get_selection (self->priv->cs_list));
if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+ _g_free0 (name);
+ _g_object_unref0 (selection);
+ return;
+ }
+ gtk_tree_model_get ((GtkTreeModel*) self->priv->cs_store, &iter, 0, &name, -1, -1);
+ d = g_object_ref_sink ((GtkMessageDialog*) gtk_message_dialog_new ((GtkWindow*) self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Are you sure you want to delete the command stream '%s'", name));
+ _result_ = gtk_dialog_run ((GtkDialog*) d);
+ gtk_object_destroy ((GtkObject*) d);
+ if (_result_ != GTK_RESPONSE_YES) {
+ _g_free0 (name);
_g_object_unref0 (selection);
+ _g_object_unref0 (d);
return;
}
gtk_list_store_remove (self->priv->cs_store, &iter);
+ _g_free0 (name);
_g_object_unref0 (selection);
+ _g_object_unref0 (d);
}
diff --git a/src/main.vala b/src/main.vala
index 55b42db..5c621b3 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -405,9 +405,18 @@ You should have received a copy of the GNU General Public License along with thi
public void remove_cs()
{
TreeIter iter;
+ string name;
var selection = cs_list.get_selection();
if (!selection.get_selected(null, out iter)) { return; }
+ cs_store.get(iter, 0, out name, -1);
+
+ var d = new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT,
+ MessageType.QUESTION, ButtonsType.YES_NO,
+ "Are you sure you want to delete the command stream '%s'", name);
+ int result = d.run();
+ d.destroy();
+ if (result != ResponseType.YES) { return; }
cs_store.remove(iter);
}