Skip to content

Commit

Permalink
Fix bug open two windows on click on notification
Browse files Browse the repository at this point in the history
  • Loading branch information
ideveCore committed Feb 10, 2024
1 parent d30225a commit 68affa7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const application_actions = ({ application }) => {
});

active_action.connect("activate", () => {
application.get_active_window()._small_window.hide();
application.active_window.show();
});

Expand Down
1 change: 1 addition & 0 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Gdk from 'gi://Gdk';
import { gettext as _ } from 'gettext';
import Style from './assets/style.css';
import { Window } from './window.js';
import { SmallWindow } from './components/small-window/small-window.js';
import { application_actions } from './actions.js';
import { utils } from './utils.js';

Expand Down
3 changes: 2 additions & 1 deletion src/components/small-window/small-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class SmallWindow extends Adw.Window {

/**
*
* Setup event controles (Mouse enter|leave)...
* Setup event controls (Mouse enter|leave)...
*
*/
_setup_event_controller() {
Expand All @@ -81,3 +81,4 @@ export class SmallWindow extends Adw.Window {
this._overlay.add_controller(controller)
}
}

7 changes: 3 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const format_time = (time) => {
*
* Sound Player
* @param {object} params
* @param {Adw.Applicatin} params.application
* @param {Adw.Application} params.application
* @param {Settings} params.settings
*
*/
Expand Down Expand Up @@ -172,7 +172,7 @@ export const notification = ({ application, settings }) => {
/**
*
* Send notification
* @param {object} params
* @param {object} params
* @param {string} params.title
* @param {string} params.body
*
Expand All @@ -183,7 +183,7 @@ export const notification = ({ application, settings }) => {
notification.set_body(body);
const high_priority_notify = settings.get_boolean('high-priority-notify');
notification.set_priority(high_priority_notify ? Gio.NotificationPriority.URGENT : Gio.NotificationPriority.NORMAL);
if(!application.get_active_window().visible) {
if(!application.get_active_window().visible && !application.get_active_window()._small_window.visible) {
notification.add_button(
_("Launch"),
"app.open",
Expand Down Expand Up @@ -328,7 +328,6 @@ const time_utils = () => {
}
}


/**
*
* Load all utils methods
Expand Down
5 changes: 3 additions & 2 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class Window extends Adw.ApplicationWindow {
this._statistics_page.set_child(this._statistics_page_component);
this._small_window = new SmallWindow({ application });
this._timer = application.utils.timer;
this.application = application;

this._timer.connect('start', () => {
this._shorten_window.set_sensitive(true);
Expand Down Expand Up @@ -104,10 +105,10 @@ export class Window extends Adw.ApplicationWindow {
const value = parameter.get_string()[0];
if (value === 'open') {
this.hide();
this._small_window.present();
this._small_window.show();
} else {
this.present();
this._small_window.hide();
this.show();
}
});
this.add_action(toggle_small_window);
Expand Down

0 comments on commit 68affa7

Please sign in to comment.