Commit 25fec80d authored by Advendra Deswanta's avatar Advendra Deswanta Committed by Javad Rahmatzadeh
Browse files

add looking glass size

parent 4ad8696d
......@@ -19,6 +19,7 @@ We go to the next version after each release on [GNOME Shell Extensions website]
### Added
- Dash separator visibility.
- Looking glass size by [@AdvendraDeswanta](https://gitlab.gnome.org/AdvendraDeswanta).
### Removed
......
......@@ -30,6 +30,7 @@ This extension allows you to do the following:
| GNOME Shell Theme Override | :black_circle: | :black_circle: | :black_circle: | :black_circle: | :black_circle: |
| Hot Corner | :black_circle: | :black_circle: | :black_circle: | :white_circle: | :white_circle: |
| Keyboard Layout Visibility | :black_circle: | :black_circle: | :black_circle: | :black_circle: | :black_circle: |
| Looking Glass Size | :black_circle: | :black_circle: | :black_circle: | :black_circle: | :black_circle: |
| Notification Banner Position | :black_circle: | :black_circle: | :black_circle: | :black_circle: | :black_circle: |
| OSD Visibility | :black_circle: | :black_circle: | :black_circle: | :black_circle: | :black_circle: |
| Panel Arrow Visibility | :black_circle: | :black_circle: | :white_circle: | :white_circle: | :white_circle: |
......
......@@ -3027,5 +3027,95 @@ var API = class
this.UIStyleClassAdd(this._getAPIClassname('no-dash-separator'));
}
/**
* get looking glass size
*
* @returns {array}
* width: int
* height: int
*/
_lookingGlassGetSize()
{
let lookingGlass = this._main.createLookingGlass();
return [ lookingGlass.width, lookingGlass.height ];
}
/**
* set default looking glass size
*
* @returns {void}
*/
lookingGlassSetDefaultSize()
{
if (!this._lookingGlassShowSignal) {
return;
}
this._main.lookingGlass.disconnect(this._lookingGlassShowSignal);
this._main.lookingGlass._resize();
delete(this._lookingGlassShowSignal);
delete(this._lookingGlassOriginalSize);
delete(this._monitorsChangedSignal);
}
/**
* set looking glass size
*
* @param {number} width in float
* @param {number} height in float
*
* @returns {void}
*/
lookingGlassSetSize(width, height)
{
let lookingGlass = this._main.createLookingGlass();
if (!this._lookingGlassOriginalSize) {
this._lookingGlassOriginalSize = this._lookingGlassGetSize();
}
if (this._lookingGlassShowSignal) {
lookingGlass.disconnect(this._lookingGlassShowSignal);
delete(this._lookingGlassShowSignal);
}
this._lookingGlassShowSignal = lookingGlass.connect('show', () => {
let [, currentHeight] = this._lookingGlassGetSize();
let [originalWidth, originalHeight] = this._lookingGlassOriginalSize;
let monitorInfo = this.monitorGetInfo();
let dialogWidth
= (width !== null)
? monitorInfo.width * width
: originalWidth;
let x = monitorInfo.x + (monitorInfo.width - dialogWidth) / 2;
lookingGlass.set_x(x);
let keyboardHeight = this._main.layoutManager.keyboardBox.height;
let availableHeight = monitorInfo.height - keyboardHeight;
let dialogHeight
= (height !== null)
? Math.min(monitorInfo.height * height, availableHeight * 0.9)
: originalHeight;
let hiddenY = lookingGlass._hiddenY + currentHeight - dialogHeight;
lookingGlass.set_y(hiddenY);
lookingGlass._hiddenY = hiddenY;
lookingGlass.set_size(dialogWidth, dialogHeight);
});
if (!this._monitorsChangedSignal) {
this._monitorsChangedSignal = this._main.layoutManager.connect('monitors-changed',
() => {
this.lookingGlassSetSize(width, height);
});
}
}
}
......@@ -249,6 +249,14 @@ var Manager = class
this._settings.connect('changed::dash-separator', () => {
this._applyDashSeparator(false);
});
this._settings.connect('changed::looking-glass-width', () => {
this._applyLookingGlassSize(false);
});
this._settings.connect('changed::looking-glass-height', () => {
this._applyLookingGlassSize(false);
});
}
/**
......@@ -308,6 +316,7 @@ var Manager = class
this._applyEventsButton(false);
this._applyCalendar(false);
this._applyDashSeparator(false);
this._applyLookingGlassSize(false);
}
/**
......@@ -367,6 +376,7 @@ var Manager = class
this._applyEventsButton(true);
this._applyCalendar(true);
this._applyDashSeparator(true);
this._applyLookingGlassSize(true);
}
/**
......@@ -1264,5 +1274,26 @@ var Manager = class
this._api.dashSeparatorHide();
}
}
/**
* apply looking glass size settings
*
* @param {boolean} forceOriginal force original shell setting
*
* @returns {void}
*/
_applyLookingGlassSize(forceOriginal)
{
let widthSize = this._settings.get_int('looking-glass-width');
let heightSize = this._settings.get_int('looking-glass-height');
if (forceOriginal) {
this._api.lookingGlassSetDefaultSize();
} else {
let width = (widthSize !== 0) ? widthSize / 10 : null;
let height = (heightSize !== 0) ? heightSize / 10 : null;
this._api.lookingGlassSetSize(width, height);
}
}
}
......@@ -680,6 +680,31 @@ var PrefsKeys = class
}
);
this.setKey(
'customize',
'looking-glass-width',
'GtkComboBoxText',
true,
{
default: 0,
minimal: 0,
superminimal: 0,
}
);
this.setKey(
'customize',
'looking-glass-height',
'GtkComboBoxText',
true,
{
default: 0,
minimal: 0,
superminimal: 0,
}
);
this.setKey(
'override',
'theme',
......
......@@ -341,8 +341,21 @@
<summary>Dash Separator Visibility</summary>
<description>Dash Separator Visibility Status</description>
</key>
<key type="i" name="looking-glass-width">
<default>0</default>
<range min="0" max="9"/>
<summary>Width Size in percent, 0 means use default size</summary>
<description>Looking Glass Width size</description>
</key>
<key type="i" name="looking-glass-height">
<default>0</default>
<range min="0" max="9"/>
<summary>Height Size in percent, 0 means use default size</summary>
<description>Looking Glass Height size</description>
</key>
</schema>
</schemalist>
......@@ -103,6 +103,20 @@
</object>
</child>
<child>
<object class="AdwComboRow" id="looking_glass_width_row">
<property name="title" translatable="yes">Looking Glass Width</property>
<property name="model">looking_glass_width_model</property>
</object>
</child>
<child>
<object class="AdwComboRow" id="looking_glass_height_row">
<property name="title" translatable="yes">Looking Glass Height</property>
<property name="model">looking_glass_height_model</property>
</object>
</child>
</object>
</child>
......@@ -608,4 +622,34 @@
</items>
</object>
<object class="GtkStringList" id="looking_glass_width_model">
<items>
<item translatable="yes">Default</item>
<item>10%</item>
<item>20%</item>
<item>30%</item>
<item>40%</item>
<item>50%</item>
<item>60%</item>
<item>70%</item>
<item>80%</item>
<item>90%</item>
</items>
</object>
<object class="GtkStringList" id="looking_glass_height_model">
<items>
<item translatable="yes">Default</item>
<item>10%</item>
<item>20%</item>
<item>30%</item>
<item>40%</item>
<item>50%</item>
<item>60%</item>
<item>70%</item>
<item>80%</item>
<item>90%</item>
</items>
</object>
</interface>
......@@ -1192,6 +1192,128 @@
</object>
</child>
<child>
<object class="GtkListBoxRow" id="looking_glass_width_row">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkBox" id="looking_glass_width_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="looking_glass_width_box2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkLabel" id="looking_glass_width_txt">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Looking Glass Width</property>
<property name="xalign">0</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="looking_glass_width_comboboxtext">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<items>
<item translatable="yes">Default</item>
<item>10%</item>
<item>20%</item>
<item>30%</item>
<item>40%</item>
<item>50%</item>
<item>60%</item>
<item>70%</item>
<item>80%</item>
<item>90%</item>
</items>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="looking_glass_height_row">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkBox" id="looking_glass_height_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="looking_glass_height_box2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkLabel" id="looking_glass_height_txt">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Looking Glass Height</property>
<property name="xalign">0</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="looking_glass_height_comboboxtext">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<items>
<item translatable="yes">Default</item>
<item>10%</item>
<item>20%</item>
<item>30%</item>
<item>40%</item>
<item>50%</item>
<item>60%</item>
<item>70%</item>
<item>80%</item>
<item>90%</item>
</items>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment