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. 98
      data/panel-osd-settings.ui
  3. 51
      src/prefs.js

@ -5,7 +5,15 @@
<_summary>Horizontal position of notification.</_summary> <_summary>Horizontal position of notification.</_summary>
</key> </key>
<key name="y-pos" type="d"> <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> <_summary>Vertical position of notification.</_summary>
</key> </key>
</schema> </schema>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 --> <!-- Generated with glade 3.16.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.0"/> <requires lib="gtk+" version="3.6"/>
<object class="GtkAdjustment" id="x-adjustment"> <object class="GtkAdjustment" id="x-adjustment">
<property name="upper">100</property> <property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property> <property name="step_increment">0.10000000000000001</property>
@ -13,9 +13,8 @@
<property name="page_increment">2</property> <property name="page_increment">2</property>
</object> </object>
<object class="GtkBox" id="main-widget"> <object class="GtkBox" id="main-widget">
<property name="height_request">1</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="border_width">14</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkLabel" id="label-x-pos"> <object class="GtkLabel" id="label-x-pos">
@ -23,8 +22,9 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</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="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> <property name="track_visited_links">False</property>
</object> </object>
<packing> <packing>
@ -68,6 +68,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</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="label" translatable="yes">Vertical position [%] from 0% (bottom) to 100% (top)</property>
<property name="ellipsize">start</property> <property name="ellipsize">start</property>
<property name="track_visited_links">False</property> <property name="track_visited_links">False</property>
@ -110,17 +112,101 @@
<property name="position">5</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</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> <child>
<object class="GtkButton" id="button-reset"> <object class="GtkButton" id="button-reset">
<property name="label" translatable="yes">Reset to defaults</property> <property name="label" translatable="yes">Reset</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<property name="halign">end</property> <property name="valign">center</property>
<property name="margin_right">20</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">6</property> <property name="position">6</property>
</packing> </packing>
</child> </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_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.panel-osd';
const PANEL_OSD_X_POS_KEY = 'x-pos'; const PANEL_OSD_X_POS_KEY = 'x-pos';
const PANEL_OSD_Y_POS_KEY = 'y-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({ const PanelOsdPrefsWidget = new GObject.Class({
Name: 'PanelOsdExtension.Prefs.Widget', 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.switch_x_reset = this.Window.get_object("switch-x-reset");
this.x_scale.set_value(50); this.switch_y_reset = this.Window.get_object("switch-y-reset");
this.y_scale.set_value(0); 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) if (!this.Settings)
this.loadConfig(); this.loadConfig();
this.Settings.set_double(PANEL_OSD_Y_POS_KEY, v); 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