Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Don't allow multiple windows (settings/about)
Browse files Browse the repository at this point in the history
  • Loading branch information
moson-mo committed Sep 17, 2021
1 parent 7c62e07 commit 3b7b468
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion resources/ui/AboutWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="ypad">5</property>
<property name="label" translatable="no">1.1.0</property>
<property name="label" translatable="no">1.1.1</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down
2 changes: 1 addition & 1 deletion src/data/Config.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace ManjaroNews {

// default config
public Config.get_default () {
this.Version = "1.1.0";
this.Version = "1.1.1";
this.ServerURL = "http://manjaro.moson.eu:10111/news";
this.MaxArticles = 15;
this.AvailableCategories = new string[] {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/AboutWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace ManjaroNews {

[GtkCallback]
private void btn_close_clicked (Button btn) {
this.destroy ();
this.close ();
}
}
}
19 changes: 17 additions & 2 deletions src/ui/TrayIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace ManjaroNews {
string iconChecked = "emblem-checked";
string iconUnchecked = "emblem-remove";
string iconSettings = "repository";
SettingsWindow settings_win;
AboutWindow about_win;

/* delegates */
delegate void ExecFunc ();
Expand Down Expand Up @@ -300,19 +302,32 @@ namespace ManjaroNews {
// add settings menu item
add_menu_item (_("Settings"), iconSettings, () => {
news_reader.stop (); // stop reading news: when settings change we don't need to refresh
var settings_win = new SettingsWindow (settings);
if (settings_win != null) {
settings_win.present ();
return;
}
settings_win = new SettingsWindow (settings);
settings_win.show_all ();
settings_win.delete_event.connect (() => { // start reading news again after setting changes
set_tray_icon ();
news_reader.start ();
settings_win = null;
return false;
});
});

// add about menu item
add_menu_item (_("About"), "dialog-information", () => {
var about_win = new AboutWindow ();
if (about_win != null) {
about_win.present ();
return;
}
about_win = new AboutWindow ();
about_win.show_all ();
about_win.delete_event.connect (() => {
this.about_win = null;
return false;
});
});

// add separator before quit menu item
Expand Down

0 comments on commit 3b7b468

Please sign in to comment.