Add switches to decide which position to reset

master
Jens Lody 11 years ago
parent 6cab93b472
commit fc9065679d
  1. 10
      data/org.gnome.shell.extensions.panel-osd.gschema.xml.in
  2. 108
      data/panel-osd-settings.ui
  3. 51
      src/prefs.js

@ -5,7 +5,15 @@
<_summary>Horizontal position of notification.</_summary>
</key>
<key name="y-pos" type="d">
<default>0.0</default>
<default>100.0</default>
<_summary>Vertical position of notification.</_summary>
</key>
<key name="x-res" type="b">
<default>false</default>
<_summary>Horizontal position of notification.</_summary>
</key>
<key name="y-res" type="b">
<default>false</default>
<_summary>Vertical position of notification.</_summary>
</key>
</schema>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<requires lib="gtk+" version="3.6"/>
<object class="GtkAdjustment" id="x-adjustment">
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
@ -13,9 +13,8 @@
<property name="page_increment">2</property>
</object>
<object class="GtkBox" id="main-widget">
<property name="height_request">1</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="border_width">14</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label-x-pos">
@ -23,8 +22,9 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Horizontal position [%] from 0% (left) to 100% (right)</property>
<property name="ellipsize">start</property>
<property name="ellipsize">end</property>
<property name="track_visited_links">False</property>
</object>
<packing>
@ -68,6 +68,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Vertical position [%] from 0% (bottom) to 100% (top)</property>
<property name="ellipsize">start</property>
<property name="track_visited_links">False</property>
@ -111,16 +113,100 @@
</packing>
</child>
<child>
<object class="GtkButton" id="button-reset">
<property name="label" translatable="yes">Reset to defaults</property>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="can_focus">False</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_right">5</property>
<property name="margin_bottom">10</property>
<child>
<object class="GtkSwitch" id="switch-x-reset">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="switch-y-reset">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Reset horizontal position to defaults</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Reset vertical position to defaults</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-reset">
<property name="label" translatable="yes">Reset</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="margin_right">20</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">6</property>
</packing>
</child>

@ -16,6 +16,8 @@ const EXTENSIONDIR = Me.dir.get_path();
const PANEL_OSD_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.panel-osd';
const PANEL_OSD_X_POS_KEY = 'x-pos';
const PANEL_OSD_Y_POS_KEY = 'y-pos';
const PANEL_OSD_ALLOW_X_RESET = 'x-res';
const PANEL_OSD_ALLOW_Y_RESET = 'y-res';
const PanelOsdPrefsWidget = new GObject.Class({
Name: 'PanelOsdExtension.Prefs.Widget',
@ -68,9 +70,28 @@ const PanelOsdPrefsWidget = new GObject.Class({
}));
this.Window.get_object("button-reset").connect("clicked", Lang.bind(this, function() {
this.x_scale.set_value(50);
this.y_scale.set_value(0);
this.switch_x_reset = this.Window.get_object("switch-x-reset");
this.switch_y_reset = this.Window.get_object("switch-y-reset");
this.reset_button = this.Window.get_object("button-reset");
this.switch_x_reset.connect("notify::active", Lang.bind(this, function() {
this.x_reset = arguments[0].active;
this.reset_button.sensitive = this.x_reset || this.y_reset;
}));
this.switch_y_reset.connect("notify::active", Lang.bind(this, function() {
this.y_reset = arguments[0].active;
this.reset_button.sensitive = this.x_reset || this.y_reset;
}));
this.switch_x_reset.set_active(this.x_reset);
this.switch_y_reset.set_active(this.y_reset);
this.reset_button.sensitive = this.x_reset || this.y_reset;
this.reset_button.connect("clicked", Lang.bind(this, function() {
this.x_reset && this.x_scale.set_value(50);
this.y_reset && this.y_scale.set_value(100);
}));
@ -102,6 +123,30 @@ const PanelOsdPrefsWidget = new GObject.Class({
if (!this.Settings)
this.loadConfig();
this.Settings.set_double(PANEL_OSD_Y_POS_KEY, v);
},
get x_reset() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_boolean(PANEL_OSD_ALLOW_X_RESET);
},
set x_reset(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_boolean(PANEL_OSD_ALLOW_X_RESET, v);
},
get y_reset() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_boolean(PANEL_OSD_ALLOW_Y_RESET);
},
set y_reset(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_boolean(PANEL_OSD_ALLOW_Y_RESET, v);
}
});

Loading…
Cancel
Save