1/* 2 * This file is part of gitg 3 * 4 * Copyright (C) 2014 - Jesse van den Kieboom 5 * 6 * gitg is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * gitg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with gitg. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20namespace GitgExt 21{ 22 23public class UserQueryResponse : Object 24{ 25 public string text; 26 public Gtk.ResponseType response_type; 27 28 public UserQueryResponse(string text, Gtk.ResponseType response_type) 29 { 30 this.text = text; 31 this.response_type = response_type; 32 } 33} 34 35public class UserQuery : Object 36{ 37 public string title { get; set; } 38 public string message { get; set; } 39 public Gtk.MessageType message_type { get; set; } 40 public Gtk.ResponseType default_response { get; set; default = Gtk.ResponseType.CLOSE; } 41 public UserQueryResponse[] _responses; 42 43 public UserQueryResponse[] get_responses() { 44 return _responses; 45 } 46 47 public void set_responses(UserQueryResponse[] value) { 48 _responses = value; 49 } 50 51 public bool default_is_destructive { get; set; } 52 public bool message_use_markup { get; set; } 53 54 public signal void quit(); 55 public signal bool response(Gtk.ResponseType response_type); 56 57 public UserQuery.full(string title, string message, Gtk.MessageType message_type, ...) 58 { 59 Object(title: title, message: message, message_type: message_type); 60 61 var l = va_list(); 62 var resps = new UserQueryResponse[0]; 63 64 while (true) { 65 string? text = l.arg(); 66 67 if (text == null) { 68 break; 69 } 70 71 resps += new UserQueryResponse(text, l.arg()); 72 } 73 74 set_responses(resps); 75 76 if (resps.length > 0) { 77 default_response = resps[resps.length - 1].response_type; 78 } 79 } 80} 81 82} 83 84// ex:set ts=4 noet: 85