fixed bug where application doesn't close

This commit is contained in:
Ronny Dobra committed 2017-06-21 19:09:36 +02:00
1 parent 0fa95bce1f
commit 8498fdf64d
2 files changed
+28 -36

No files matched your search

+26 -33
View File
@@ -22,49 +22,42 @@
namespace ColorPicker {
public class ColorPickerApp : Granite.Application {
private static ColorPickerApp app;
private ColorPickerWindow window;
construct {
var quit_action = new SimpleAction ("quit", null);
quit_action.activate.connect (() => {
if (window != null) {
window.destroy ();
}
});
add_action (quit_action);
set_accels_for_action ("app.quit", {"<Control>q"});
}
public static ColorPickerApp get_instance () {
if (app == null) {
app = new ColorPickerApp ();
}
return app;
public ColorPickerApp () {
Object (application_id: "com.github.ronnydo.colorpicker",
flags: ApplicationFlags.FLAGS_NONE);
}
protected override void activate () {
window = new ColorPickerWindow();
if (get_windows ().length () > 0) {
get_windows ().data.present ();
return;
}
window.destroy.connect (Gtk.main_quit);
window.set_application (this);
window.show_all ();
var app_window = new ColorPickerWindow (this);
app_window.show_all ();
var quit_action = new SimpleAction ("quit", null);
add_action (quit_action);
add_accelerator ("<Control>q", "app.quit", null);
quit_action.activate.connect (() => {
if (app_window != null) {
app_window.destroy ();
}
});
}
public static int main (string[] args) {
Gtk.init (ref args);
// Gtk.init (ref args);
app = new ColorPickerApp ();
var app = new ColorPickerApp ();
app.run(args);
Gtk.main ();
return 0;
return app.run(args);
}
}
}
+2 -3
View File
@@ -25,7 +25,7 @@ namespace ColorPicker {
ExtRGBA ext_active_color = ExtRGBA ();
public ColorPickerWindow () {
public ColorPickerWindow (Gtk.Application application) {
Object (application: application,
icon_name: "com.github.ronnydo.colorpicker",
title: "Color Picker",
@@ -33,8 +33,7 @@ namespace ColorPicker {
//height_request: 500,
width_request: 500
);
}
}
construct {
// main box