add gSettings support; implement issue #10: Remember window position

This commit is contained in:
Ronny Dobra committed 2017-06-25 14:40:52 +02:00
1 parent 89f04d677f
commit 4dd56a8c3c
6 files changed
+56 -10

No files matched your search

@@ -7,11 +7,12 @@
<name>Color Picker</name>
<summary>The most intuitive Color Picker to speed up your workflow.</summary>
<description>
<p>One Color Picker to rule them all! No overhelming menus and settings. Just a dialog with all the features you'll need:</p>
<p>One Color Picker to rule them all! No overhelming menus or settings. An easy tool with the features you need.</p>
<p>Features:</p>
<ul>
<li>Pick a color</li>
<li>Choose between multiple <b>Color Formats</b></li>
<li>Let the <b>Color History</b> remember your last colors</li>
<li>Choose between multiple Color Formats</li>
<li>Let the Color History remember your last colors</li>
</ul>
</description>
<provides>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/com/github/ronnydo/colorpicker/"
id="com.github.ronnydo.colorpicker"
gettext-domain="com.github.ronnydo.colorpicker">
<key name="window-x" type="i">
<default>-1</default>
<summary>Most recent x position of app window</summary>
<description>Most recent x position of app window</description>
</key>
<key name="window-y" type="i">
<default>-1</default>
<summary>Most recent y position of app window</summary>
<description>Most recent y position of app window</description>
</key>
</schema>
</schemalist>
+5
View File
@@ -7,6 +7,11 @@ foreach i : icon_sizes
)
endforeach
install_data(
meson.project_name() + '.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
)
install_data(
meson.project_name() + '.desktop',
install_dir: join_paths(get_option('datadir'), 'applications')
+3 -1
View File
@@ -26,13 +26,15 @@ executable(
'src/Widgets/MousePosition.vala',
c_args: c_args,
dependencies: [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('granite'),
dependency('gtk+-3.0'),
],
install : true
)
#meson.add_install_script('meson/post_install.py')
meson.add_install_script('meson/post_install.py')
subdir('data')
subdir('po')
+1 -1
View File
@@ -35,7 +35,7 @@ namespace ColorPicker {
}
var app_window = new ColorPickerWindow (this);
app_window.show_all ();
var quit_action = new SimpleAction ("quit", null);
+26 -5
View File
@@ -22,7 +22,7 @@
namespace ColorPicker {
public class ColorPickerWindow: Gtk.Dialog {
ExtRGBA ext_active_color = ExtRGBA ();
public ColorPickerWindow (Gtk.Application application) {
@@ -36,7 +36,8 @@ namespace ColorPicker {
}
construct {
// main box
// main box
ext_active_color.parse ("#FFFFFF");
var color_area = new ColorArea ();
@@ -48,8 +49,7 @@ namespace ColorPicker {
hex_label.set_selectable (true);
hex_label.set_use_markup (true);
hex_label.get_style_context ().add_class ("h1");
hex_label.get_style_context ().add_class ("h1");
var pick_color_button = new Gtk.Button.with_label (_("Pick Color"));
pick_color_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
@@ -126,7 +126,16 @@ namespace ColorPicker {
var content_box = get_content_area () as Gtk.Box;
content_box.pack_start (skeleton_box);
var settings = new Settings ("com.github.ronnydo.colorpicker");
var window_x = settings.get_int ("window-x");
var window_y = settings.get_int ("window-y");
if (window_x != -1 || window_y != -1) {
move (window_x, window_y);
}
// activate color picker
pick_color_button.clicked.connect (() => {
var mouse_position = new ColorPicker.Widgets.MousePosition ();
@@ -226,6 +235,18 @@ namespace ColorPicker {
}
}
public override bool delete_event (Gdk.EventAny event) {
// save window position
int root_x, root_y;
get_position (out root_x, out root_y);
var settings = new Settings ("com.github.ronnydo.colorpicker");
settings.set_int ("window-x", root_x);
settings.set_int ("window-y", root_y);
return false;
}
}