-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8c656c
commit 082b279
Showing
8 changed files
with
108 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Gio from 'gi://Gio'; | ||
import Adw from 'gi://Adw'; | ||
import { ExtensionPreferences, gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; | ||
|
||
export default class PhpLaravelValetPreferences extends ExtensionPreferences { | ||
fillPreferencesWindow(window) { | ||
// create a preferences page, with a single group | ||
const page = new Adw.PreferencesPage({ | ||
title: _('General'), | ||
icon_name: 'dialog-information-symbolic', | ||
}); | ||
window.add(page); | ||
|
||
// create a preferences group, add to page | ||
const group = new Adw.PreferencesGroup({ | ||
title: _('Settings'), | ||
description: _('Configure the settings of the extension'), | ||
}); | ||
page.add(group); | ||
|
||
// create a new preferences row | ||
const show_settings = new Adw.SwitchRow({ | ||
title: _('Show Settings'), | ||
subtitle: _('Whether to show the settings in menu'), | ||
}); | ||
group.add(show_settings); | ||
|
||
// create a settings object and bind inputs | ||
window._settings = this.getSettings(); | ||
window._settings.bind('show-settings', show_settings, 'active', Gio.SettingsBindFlags.DEFAULT); | ||
|
||
window.set_default_size(620, 300); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Add your custom extension styling here */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,41 @@ | ||
'use strict'; | ||
import GLib from 'gi://GLib'; | ||
import Bytes from 'gi://GLib/Bytes'; | ||
|
||
const Bytes = imports.byteArray; | ||
const GLib = imports.gi.GLib; | ||
const ExtensionUtils = imports.misc.extensionUtils; | ||
const Me = ExtensionUtils.getCurrentExtension(); | ||
|
||
const _settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.php-laravel-valet'); | ||
|
||
function safeSpawn(cmd) { | ||
export function safeSpawn(cmd) { | ||
try { | ||
return GLib.spawn_command_line_sync(cmd); | ||
} catch (e) { | ||
return [false, Bytes.fromString(''), null, null]; | ||
} | ||
} | ||
|
||
function shellSpawn(cmd) { | ||
const terminal = _settings.get_string('default-shell'); | ||
export function shellSpawn(cmd) { | ||
const terminal = 'x-terminal-emulator -e'; | ||
GLib.spawn_command_line_async(`${terminal} ${cmd}`); | ||
} | ||
|
||
function phpVersion() { | ||
export function phpVersion() { | ||
const res = safeSpawn('/bin/bash -c "php -v | grep -Po \'PHP\\s+\\d+.\\d+(?:(.\\d+))?\'"'); | ||
if (res[3] == 0) return Bytes.toString(res[1]).replace(/\n$/, ''); | ||
return false; | ||
} | ||
|
||
function phpList() { | ||
export function phpList() { | ||
const res = safeSpawn('ls /etc/php'); | ||
if (res[3] == 0) return Bytes.toString(res[1]).split('\n').filter(item => !!item).reverse(); | ||
return false; | ||
} | ||
|
||
function valetStatus() { | ||
export function valetStatus() { | ||
const res = safeSpawn('/bin/bash -c "valet --version && valet status"'); | ||
if (res[3] == 0) return Bytes.toString(res[1]).split('\n').filter(item => !!item); | ||
return false; | ||
} | ||
|
||
function valetRestart() { | ||
export function valetRestart() { | ||
shellSpawn('valet restart'); | ||
} | ||
|
||
function valetStop() { | ||
export function valetStop() { | ||
shellSpawn('valet stop'); | ||
} | ||
} |