Merge lp:~arthurborsboom/xpad/xpad-4.3 into lp:xpad

Proposed by Arthur Borsboom
Status: Merged
Merged at revision: 679
Proposed branch: lp:~arthurborsboom/xpad/xpad-4.3
Merge into: lp:xpad
Diff against target: 3868 lines (+935/-1228) (has conflicts)
33 files modified
ChangeLog (+5/-0)
src/fio.c (+5/-9)
src/fio.h (+1/-2)
src/help.c (+2/-4)
src/help.h (+21/-0)
src/xpad-app.c (+54/-53)
src/xpad-app.h (+20/-18)
src/xpad-grip-tool-item.c (+21/-19)
src/xpad-grip-tool-item.h (+20/-19)
src/xpad-pad-group.c (+26/-26)
src/xpad-pad-group.h (+20/-18)
src/xpad-pad-properties.c (+19/-86)
src/xpad-pad-properties.h (+1/-16)
src/xpad-pad.c (+106/-83)
src/xpad-pad.h (+1/-0)
src/xpad-periodic.c (+27/-37)
src/xpad-periodic.h (+21/-9)
src/xpad-preferences.c (+186/-195)
src/xpad-preferences.h (+1/-0)
src/xpad-session-manager.c (+6/-12)
src/xpad-session-manager.h (+2/-1)
src/xpad-settings.c (+209/-426)
src/xpad-settings.h (+2/-55)
src/xpad-text-buffer.c (+23/-22)
src/xpad-text-buffer.h (+21/-21)
src/xpad-text-view.c (+40/-28)
src/xpad-text-view.h (+20/-20)
src/xpad-toolbar.c (+3/-6)
src/xpad-toolbar.h (+0/-3)
src/xpad-tray.c (+43/-27)
src/xpad-tray.h (+4/-5)
src/xpad-undo.c (+3/-4)
src/xpad-undo.h (+2/-4)
Contents conflict in po/xpad.pot
To merge this branch: bzr merge lp:~arthurborsboom/xpad/xpad-4.3
Reviewer Review Type Date Requested Status
Arthur Borsboom Approve
Review via email: mp+223096@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Arthur Borsboom (arthurborsboom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2014-06-07 00:36:45 +0000
+++ ChangeLog 2014-06-13 15:52:27 +0000
@@ -1,4 +1,5 @@
1Version 4.31Version 4.3
2* New: Systray - ability to hide the tray icon (#890334)
2* New: Toolbar - ability to add multiple separators (#351775)3* New: Toolbar - ability to add multiple separators (#351775)
3* New: Toolbar - ability to add paste button on toolbar (#351775)4* New: Toolbar - ability to add paste button on toolbar (#351775)
4* New: Preferences - Ability to set the automatic start of Xpad in the Preferences menu (#405314)5* New: Preferences - Ability to set the automatic start of Xpad in the Preferences menu (#405314)
@@ -21,6 +22,10 @@
21* Fix: Technical - Improve the hiding of pads at Xpad launch (#405314)22* Fix: Technical - Improve the hiding of pads at Xpad launch (#405314)
22* Fix: Technical - Added thread safe handling of new preferences23* Fix: Technical - Added thread safe handling of new preferences
23* Fix: Technical - Ensured the use of GNU C libraries, so the readlink function is available24* Fix: Technical - Ensured the use of GNU C libraries, so the readlink function is available
25* Fix: Technical - Prevented dispose functions calling NULL objects leading to errors
26* Fix: Technical - Reduced the amount of functions by using generic setters and getters
27* Fix: Technical - Reduced the number of includes
28* Fix: Credits - all files use the same credits format
2429
25Version 4.230Version 4.2
26* New: Undo functionality such as CTRL-Z (#1121740)31* New: Undo functionality such as CTRL-Z (#1121740)
2732
=== renamed file 'po/xpad.pot' => 'po/xpad.pot.THIS'
=== modified file 'src/fio.c'
--- src/fio.c 2014-06-04 21:08:58 +0000
+++ src/fio.c 2014-06-13 15:52:27 +0000
@@ -1,7 +1,8 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copytight (c) 2011 David Hull4Copyright (c) 2011 David Hull
5Copyright (c) 2013-2014 Arthur Borsboom
56
6This program is free software; you can redistribute it and/or modify7This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by8it under the terms of the GNU General Public License as published by
@@ -19,16 +20,11 @@
1920
20*/21*/
2122
22#include "../config.h"23#include <stdlib.h>
24#include <gio/gio.h>
25#include <glib/gstdio.h>
23#include <glib/gi18n.h>26#include <glib/gi18n.h>
24#include <glib/gstdio.h>
25#include <gio/gio.h>
26#include <errno.h>
27#include <string.h>27#include <string.h>
28#include <stdlib.h>
29#include <stdio.h>
30#include <unistd.h>
31#include "fio.h"
32#include "xpad-app.h"28#include "xpad-app.h"
3329
34/* Sets filename to full path of filename (prepends xpad_app_get_config_dir ()30/* Sets filename to full path of filename (prepends xpad_app_get_config_dir ()
3531
=== modified file 'src/fio.h'
--- src/fio.h 2008-09-21 00:03:40 +0000
+++ src/fio.h 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -21,8 +22,6 @@
21#ifndef _FIO_H_22#ifndef _FIO_H_
22#define _FIO_H_23#define _FIO_H_
2324
24#include <gtk/gtk.h>
25
26gchar *fio_get_file (const gchar *name);25gchar *fio_get_file (const gchar *name);
27gboolean fio_set_file (const gchar *name, const gchar *value);26gboolean fio_set_file (const gchar *name, const gchar *value);
28void fio_remove_file (const gchar *filename);27void fio_remove_file (const gchar *filename);
2928
=== modified file 'src/help.c'
--- src/help.c 2013-10-31 21:17:36 +0000
+++ src/help.c 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -18,11 +19,8 @@
1819
19*/20*/
2021
21#include "../config.h"22#include <gtk/gtk.h>
22#include <glib/gi18n.h>23#include <glib/gi18n.h>
23#include <string.h>
24#include <gtk/gtk.h>
25#include "help.h"
2624
27GtkWidget *help_window = NULL;25GtkWidget *help_window = NULL;
2826
2927
=== modified file 'src/help.h'
--- src/help.h 2003-09-02 19:13:44 +0000
+++ src/help.h 2014-06-13 15:52:27 +0000
@@ -1,3 +1,24 @@
1/*
2
3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
21
1#ifndef HELP_H22#ifndef HELP_H
2#define HELP_H23#define HELP_H
324
425
=== modified file 'src/xpad-app.c'
--- src/xpad-app.c 2014-06-07 00:19:07 +0000
+++ src/xpad-app.c 2014-06-13 15:52:27 +0000
@@ -1,50 +1,44 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * Copyright (c) 2009 Paul Ivanov3Copyright (c) 2001-2007 Michael Terry
4 * Copyright (c) 2013 Arthur Borsboom4Copyright (c) 2009 Paul Ivanov
5 * 5Copyright (c) 2013-2014 Arthur Borsboom
6 * This program is free software; you can redistribute it and/or modify6
7 * it under the terms of the GNU General Public License as published by7This program is free software; you can redistribute it and/or modify
8 * the Free Software Foundation; either version 3 of the License, or8it under the terms of the GNU General Public License as published by
9 * (at your option) any later version.9the Free Software Foundation; either version 3 of the License, or
10 * 10(at your option) any later version.
11 * This program is distributed in the hope that it will be useful,11
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of12This program is distributed in the hope that it will be useful,
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * GNU General Public License for more details.14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * 15GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License16
17 * along with this program; if not, write to the Free Software17You should have received a copy of the GNU General Public License
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18along with this program; if not, write to the Free Software
19 */19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21*/
2022
21/* required by socket stuff */23/* required by socket stuff */
22/* define _GNU_SOURCE here because that makes our sockets work nice24/* define _GNU_SOURCE here because that makes our sockets work nice
23 Unfortunately, we lose portability... */25 Unfortunately, we lose portability... */
24#define _GNU_SOURCE 126
25#include "../config.h"27#include "../config.h"
26#include <stdio.h>28#include <glib.h>
27#include <unistd.h>
28#include <sys/un.h>
29#include <sys/socket.h>
30#include <sys/select.h>
31#include <errno.h>
32
33#include <string.h>
34#include <stdlib.h> /* for exit */
35
36#include <glib/gi18n.h>29#include <glib/gi18n.h>
37#include <glib/gstdio.h>30#include <glib/gstdio.h>
3831#include <string.h>
39#include "fio.h" /* for fio_get_info_from_file */32#include <sys/socket.h>
33#include <sys/un.h>
34#include <stdio.h>
35#include <stdlib.h>
40#include "help.h"36#include "help.h"
41#include "prefix.h"
42#include "xpad-app.h"37#include "xpad-app.h"
43#include "xpad-pad.h"38#include "xpad-pad.h"
44#include "xpad-pad-group.h"39#include "xpad-pad-group.h"
45#include "xpad-periodic.h"40#include "xpad-periodic.h"
46#include "xpad-session-manager.h"41#include "xpad-session-manager.h"
47#include "xpad-settings.h"
48#include "xpad-tray.h"42#include "xpad-tray.h"
4943
50/* Seems that some systems (sun-sparc-solaris2.8 at least), need the following three #defines. 44/* Seems that some systems (sun-sparc-solaris2.8 at least), need the following three #defines.
@@ -87,8 +81,8 @@
8781
88static gboolean config_dir_exists (void);82static gboolean config_dir_exists (void);
89static gchar *make_config_dir (void);83static gchar *make_config_dir (void);
90static void register_stock_icons (void);84static void register_stock_icons (void);
91static gint xpad_app_load_pads (void);85static gint xpad_app_load_pads (void);
92static gboolean xpad_app_quit_if_no_pads (XpadPadGroup *group);86static gboolean xpad_app_quit_if_no_pads (XpadPadGroup *group);
93static gboolean xpad_app_first_idle_check (XpadPadGroup *group);87static gboolean xpad_app_first_idle_check (XpadPadGroup *group);
94static gboolean xpad_app_pass_args (void);88static gboolean xpad_app_pass_args (void);
@@ -157,13 +151,16 @@
157 xpad_global_settings = xpad_settings_new ();151 xpad_global_settings = xpad_settings_new ();
158 152
159 /* Delay program startup, if user configured it, to wait for example for the loading of the systray. */153 /* Delay program startup, if user configured it, to wait for example for the loading of the systray. */
160 if (xpad_settings_get_autostart_delay (xpad_global_settings))154 guint autostart_delay;
161 sleep(xpad_settings_get_autostart_delay (xpad_global_settings));155 g_object_get (xpad_global_settings, "autostart-delay", &autostart_delay, NULL);
156
157 if (autostart_delay)
158 sleep(autostart_delay);
162159
163 pad_group = xpad_pad_group_new();160 pad_group = xpad_pad_group_new();
164 process_remote_args (&xpad_argc, &xpad_argv, TRUE, xpad_global_settings);161 process_remote_args (&xpad_argc, &xpad_argv, TRUE, xpad_global_settings);
165 162
166 xpad_tray_open ();163 xpad_tray_init (xpad_global_settings);
167 xpad_session_manager_init ();164 xpad_session_manager_init ();
168165
169 /* Initialize Xpad-periodic module */166 /* Initialize Xpad-periodic module */
@@ -198,8 +195,7 @@
198}195}
199196
200gint main (gint argc, gchar **argv)197gint main (gint argc, gchar **argv)
201{198{ xpad_app_init (argc, argv);
202 xpad_app_init (argc, argv);
203199
204 gtk_main ();200 gtk_main ();
205 201
@@ -255,13 +251,13 @@
255 /* Free the memory used by group. */251 /* Free the memory used by group. */
256 g_object_unref (xpad_app_get_pad_group());252 g_object_unref (xpad_app_get_pad_group());
257253
254 /* Free the memory used by the tray icon and its menu. */
255 xpad_tray_dispose (xpad_global_settings);
256
258 /* Free the memory used by the settings menu. */257 /* Free the memory used by the settings menu. */
259 g_object_unref (xpad_global_settings);258 g_object_unref (xpad_global_settings);
260 xpad_global_settings = NULL; /* This is needed due to the asynchronous finalizing process. */259 xpad_global_settings = NULL; /* This is needed due to the asynchronous finalizing process. */
261260
262 /* Free the memory used by the tray icon and its menu. */
263 xpad_tray_close ();
264
265 /* Free the theme reference. Unfortunately GTK3 leaves about 1000 objects behind. */261 /* Free the theme reference. Unfortunately GTK3 leaves about 1000 objects behind. */
266 g_object_unref (gtk_icon_theme_get_default ());262 g_object_unref (gtk_icon_theme_get_default ());
267263
@@ -395,9 +391,7 @@
395static void391static void
396register_stock_icons (void)392register_stock_icons (void)
397{393{
398 GtkIconTheme *theme;394 GtkIconTheme *theme = gtk_icon_theme_get_default ();
399
400 theme = gtk_icon_theme_get_default ();
401 gtk_icon_theme_prepend_search_path (theme, THEME_DIR);395 gtk_icon_theme_prepend_search_path (theme, THEME_DIR);
402}396}
403397
@@ -865,17 +859,24 @@
865 if (have_gtk && option_smid)859 if (have_gtk && option_smid)
866 xpad_session_manager_set_id (option_smid);860 xpad_session_manager_set_id (option_smid);
867 861
868 if (have_gtk && (option_new || xpad_settings_get_autostart_new_pad (xpad_settings)))862 if (!option_new)
863 g_object_get (xpad_global_settings, "autostart-new-pad", &option_new, NULL);
864
865 if (have_gtk && option_new)
869 {866 {
870 GtkWidget *pad = xpad_pad_new (pad_group);867 GtkWidget *pad = xpad_pad_new (pad_group);
871 gtk_widget_show (pad);868 gtk_widget_show (pad);
872 }869 }
870
871 if (!option_hide && !option_show) {
872 guint display_pads;
873 g_object_get (xpad_settings, "autostart-display-pads", &display_pads, NULL);
874 if (display_pads == 0)
875 option_show = TRUE;
876 else if (display_pads == 1)
877 option_hide = TRUE;
878 }
873879
874 if (xpad_settings_get_autostart_display_pads (xpad_settings) == 0)
875 option_show = TRUE;
876 if (xpad_settings_get_autostart_display_pads (xpad_settings) == 1)
877 option_hide = TRUE;
878
879 if (have_gtk && option_files)880 if (have_gtk && option_files)
880 {881 {
881 int i;882 int i;
882883
=== modified file 'src/xpad-app.h'
--- src/xpad-app.h 2014-06-04 12:36:36 +0000
+++ src/xpad-app.h 2014-06-13 15:52:27 +0000
@@ -1,20 +1,23 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * 3Copyright (c) 2001-2007 Michael Terry
4 * This program is free software; you can redistribute it and/or modify4Copyright (c) 2013-2014 Arthur Borsboom
5 * it under the terms of the GNU General Public License as published by5
6 * the Free Software Foundation; either version 3 of the License, or6This program is free software; you can redistribute it and/or modify
7 * (at your option) any later version.7it under the terms of the GNU General Public License as published by
8 * 8the Free Software Foundation; either version 3 of the License, or
9 * This program is distributed in the hope that it will be useful,9(at your option) any later version.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11This program is distributed in the hope that it will be useful,
12 * GNU General Public License for more details.12but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * You should have received a copy of the GNU General Public License14GNU General Public License for more details.
15 * along with this program; if not, write to the Free Software15
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16You should have received a copy of the GNU General Public License
17 */17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
1821
19#ifndef __XPAD_APP_H__22#ifndef __XPAD_APP_H__
20#define __XPAD_APP_H__23#define __XPAD_APP_H__
@@ -32,7 +35,6 @@
32const gchar *xpad_app_get_program_path (void);35const gchar *xpad_app_get_program_path (void);
33XpadPadGroup *xpad_app_get_pad_group (void);36XpadPadGroup *xpad_app_get_pad_group (void);
34XpadSettings *xpad_global_settings;37XpadSettings *xpad_global_settings;
35gboolean xpad_app_get_translucent (void);
36void xpad_app_quit (void);38void xpad_app_quit (void);
3739
38G_END_DECLS40G_END_DECLS
3941
=== modified file 'src/xpad-grip-tool-item.c'
--- src/xpad-grip-tool-item.c 2013-10-31 21:17:36 +0000
+++ src/xpad-grip-tool-item.c 2014-06-13 15:52:27 +0000
@@ -1,22 +1,24 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * 3Copyright (c) 2001-2007 Michael Terry
4 * This program is free software; you can redistribute it and/or modify4Copyright (c) 2013-2014 Arthur Borsboom
5 * it under the terms of the GNU General Public License as published by5
6 * the Free Software Foundation; either version 3 of the License, or6This program is free software; you can redistribute it and/or modify
7 * (at your option) any later version.7it under the terms of the GNU General Public License as published by
8 * 8the Free Software Foundation; either version 3 of the License, or
9 * This program is distributed in the hope that it will be useful,9(at your option) any later version.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11This program is distributed in the hope that it will be useful,
12 * GNU General Public License for more details.12but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * You should have received a copy of the GNU General Public License14GNU General Public License for more details.
15 * along with this program; if not, write to the Free Software15
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16You should have received a copy of the GNU General Public License
17 */17along with this program; if not, write to the Free Software
1818Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19#include "../config.h"19
20*/
21
20#include "xpad-grip-tool-item.h"22#include "xpad-grip-tool-item.h"
2123
22struct XpadGripToolItemPrivate24struct XpadGripToolItemPrivate
2325
=== modified file 'src/xpad-grip-tool-item.h'
--- src/xpad-grip-tool-item.h 2008-09-21 00:03:40 +0000
+++ src/xpad-grip-tool-item.h 2014-06-13 15:52:27 +0000
@@ -1,20 +1,23 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * 3Copyright (c) 2001-2007 Michael Terry
4 * This program is free software; you can redistribute it and/or modify4Copyright (c) 2013-2014 Arthur Borsboom
5 * it under the terms of the GNU General Public License as published by5
6 * the Free Software Foundation; either version 3 of the License, or6This program is free software; you can redistribute it and/or modify
7 * (at your option) any later version.7it under the terms of the GNU General Public License as published by
8 * 8the Free Software Foundation; either version 3 of the License, or
9 * This program is distributed in the hope that it will be useful,9(at your option) any later version.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11This program is distributed in the hope that it will be useful,
12 * GNU General Public License for more details.12but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * You should have received a copy of the GNU General Public License14GNU General Public License for more details.
15 * along with this program; if not, write to the Free Software15
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16You should have received a copy of the GNU General Public License
17 */17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
1821
19#ifndef __XPAD_GRIP_TOOL_ITEM_H__22#ifndef __XPAD_GRIP_TOOL_ITEM_H__
20#define __XPAD_GRIP_TOOL_ITEM_H__23#define __XPAD_GRIP_TOOL_ITEM_H__
@@ -37,8 +40,6 @@
37struct XpadGripToolItem40struct XpadGripToolItem
38{41{
39 GtkToolItem parent;42 GtkToolItem parent;
40
41 /* private */
42 XpadGripToolItemPrivate *priv;43 XpadGripToolItemPrivate *priv;
43};44};
4445
4546
=== modified file 'src/xpad-pad-group.c'
--- src/xpad-pad-group.c 2014-06-04 12:36:36 +0000
+++ src/xpad-pad-group.c 2014-06-13 15:52:27 +0000
@@ -1,25 +1,26 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * Copyright (c) 2009 Paul Ivanov3Copyright (c) 2001-2007 Michael Terry
4 * 4Copyright (c) 2009 Paul Ivanov
5 * This program is free software; you can redistribute it and/or modify5Copyright (c) 2013-2014 Arthur Borsboom
6 * it under the terms of the GNU General Public License as published by6
7 * the Free Software Foundation; either version 3 of the License, or7This program is free software; you can redistribute it and/or modify
8 * (at your option) any later version.8it under the terms of the GNU General Public License as published by
9 * 9the Free Software Foundation; either version 3 of the License, or
10 * This program is distributed in the hope that it will be useful,10(at your option) any later version.
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of11
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12This program is distributed in the hope that it will be useful,
13 * GNU General Public License for more details.13but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * You should have received a copy of the GNU General Public License15GNU General Public License for more details.
16 * along with this program; if not, write to the Free Software16
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17You should have received a copy of the GNU General Public License
18 */18along with this program; if not, write to the Free Software
1919Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20#include "../config.h"20
21*/
22
21#include "xpad-pad-group.h"23#include "xpad-pad-group.h"
22#include "xpad-settings.h"
23#include "xpad-pad.h"24#include "xpad-pad.h"
2425
25struct XpadPadGroupPrivate26struct XpadPadGroupPrivate
@@ -29,8 +30,9 @@
2930
30G_DEFINE_TYPE_WITH_PRIVATE(XpadPadGroup, xpad_pad_group, G_TYPE_OBJECT)31G_DEFINE_TYPE_WITH_PRIVATE(XpadPadGroup, xpad_pad_group, G_TYPE_OBJECT)
3132
32static void xpad_pad_group_dispose (GObject *object);33static void xpad_pad_group_dispose (GObject *object);
33static void xpad_pad_group_finalize (GObject *object);34static void xpad_pad_group_finalize (GObject *object);
35static void xpad_pad_group_save_unsaved_all (XpadPadGroup *group);
3436
35enum {37enum {
36 PROP_038 PROP_0
@@ -180,9 +182,7 @@
180 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_close, NULL);182 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_close, NULL);
181}183}
182184
183void185static void xpad_pad_group_save_unsaved_all (XpadPadGroup *group) {
184xpad_pad_group_save_unsaved_all (XpadPadGroup *group)
185{
186 if (group)186 if (group)
187 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_save_unsaved, NULL);187 g_slist_foreach (group->priv->pads, (GFunc) xpad_pad_save_unsaved, NULL);
188}188}
189189
=== modified file 'src/xpad-pad-group.h'
--- src/xpad-pad-group.h 2013-10-18 18:31:20 +0000
+++ src/xpad-pad-group.h 2014-06-13 15:52:27 +0000
@@ -1,20 +1,23 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * 3Copyright (c) 2001-2007 Michael Terry
4 * This program is free software; you can redistribute it and/or modify4Copyright (c) 2013-2014 Arthur Borsboom
5 * it under the terms of the GNU General Public License as published by5
6 * the Free Software Foundation; either version 3 of the License, or6This program is free software; you can redistribute it and/or modify
7 * (at your option) any later version.7it under the terms of the GNU General Public License as published by
8 * 8the Free Software Foundation; either version 3 of the License, or
9 * This program is distributed in the hope that it will be useful,9(at your option) any later version.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11This program is distributed in the hope that it will be useful,
12 * GNU General Public License for more details.12but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * You should have received a copy of the GNU General Public License14GNU General Public License for more details.
15 * along with this program; if not, write to the Free Software15
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16You should have received a copy of the GNU General Public License
17 */17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
1821
19#ifndef __XPAD_PAD_GROUP_H__22#ifndef __XPAD_PAD_GROUP_H__
20#define __XPAD_PAD_GROUP_H__23#define __XPAD_PAD_GROUP_H__
@@ -63,7 +66,6 @@
63void xpad_pad_group_toggle_hide (XpadPadGroup *group);66void xpad_pad_group_toggle_hide (XpadPadGroup *group);
64GSList * xpad_pad_group_get_pads (XpadPadGroup *group);67GSList * xpad_pad_group_get_pads (XpadPadGroup *group);
65gint xpad_pad_group_num_visible_pads (XpadPadGroup *group);68gint xpad_pad_group_num_visible_pads (XpadPadGroup *group);
66void xpad_pad_group_save_unsaved_all (XpadPadGroup *group);
67void xpad_pad_group_destroy_pads (XpadPadGroup *group);69void xpad_pad_group_destroy_pads (XpadPadGroup *group);
6870
69G_END_DECLS71G_END_DECLS
7072
=== modified file 'src/xpad-pad-properties.c'
--- src/xpad-pad-properties.c 2014-06-04 12:36:36 +0000
+++ src/xpad-pad-properties.c 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -18,9 +19,9 @@
1819
19*/20*/
2021
21#include "../config.h"22#include <gtk/gtk.h>
23#include "xpad-pad-properties.h"
22#include <glib/gi18n.h>24#include <glib/gi18n.h>
23#include "xpad-pad-properties.h"
2425
25struct XpadPadPropertiesPrivate 26struct XpadPadPropertiesPrivate
26{27{
@@ -258,7 +259,7 @@
258change_color_check (GtkToggleButton *button, XpadPadProperties *prop)259change_color_check (GtkToggleButton *button, XpadPadProperties *prop)
259{260{
260 gtk_widget_set_sensitive (prop->priv->colorbox, gtk_toggle_button_get_active (button));261 gtk_widget_set_sensitive (prop->priv->colorbox, gtk_toggle_button_get_active (button));
261 262
262 g_object_notify (G_OBJECT (prop), "follow-color-style");263 g_object_notify (G_OBJECT (prop), "follow-color-style");
263}264}
264265
@@ -266,7 +267,7 @@
266change_font_check (GtkToggleButton *button, XpadPadProperties *prop)267change_font_check (GtkToggleButton *button, XpadPadProperties *prop)
267{268{
268 gtk_widget_set_sensitive (prop->priv->fontbutton, gtk_toggle_button_get_active (button));269 gtk_widget_set_sensitive (prop->priv->fontbutton, gtk_toggle_button_get_active (button));
269 270
270 g_object_notify (G_OBJECT (prop), "follow-font-style");271 g_object_notify (G_OBJECT (prop), "follow-font-style");
271}272}
272273
@@ -297,99 +298,31 @@
297 g_object_notify (G_OBJECT (prop), "fontname");298 g_object_notify (G_OBJECT (prop), "fontname");
298}299}
299300
300void
301xpad_pad_properties_set_follow_font_style (XpadPadProperties *prop, gboolean follow)
302{
303 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck), !follow);
304 g_object_notify (G_OBJECT (prop), "follow_font_style");
305}
306
307gboolean
308xpad_pad_properties_get_follow_font_style (XpadPadProperties *prop)
309{
310 return !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck));
311}
312
313void
314xpad_pad_properties_set_follow_color_style (XpadPadProperties *prop, gboolean follow)
315{
316 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck), !follow);
317 g_object_notify (G_OBJECT (prop), "follow_color_style");
318}
319
320gboolean
321xpad_pad_properties_get_follow_color_style (XpadPadProperties *prop)
322{
323 return !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck));
324}
325
326void
327xpad_pad_properties_set_back_color (XpadPadProperties *prop, const GdkRGBA *back)
328{
329 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), back);
330 g_object_notify (G_OBJECT (prop), "back_color");
331}
332
333const GdkRGBA *
334xpad_pad_properties_get_back_color (XpadPadProperties *prop)
335{
336 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), &prop->priv->backtmp);
337 return &prop->priv->backtmp;
338}
339
340void
341xpad_pad_properties_set_text_color (XpadPadProperties *prop, const GdkRGBA *text)
342{
343 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), text);
344 g_object_notify (G_OBJECT (prop), "text_color");
345}
346
347const GdkRGBA *
348xpad_pad_properties_get_text_color (XpadPadProperties *prop)
349{
350 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), &prop->priv->texttmp);
351 return &prop->priv->texttmp;
352}
353
354void
355xpad_pad_properties_set_fontname (XpadPadProperties *prop, const gchar *fontname)
356{
357 gtk_font_button_set_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton), fontname);
358 g_object_notify (G_OBJECT (prop), "fontname");
359}
360
361const gchar *xpad_pad_properties_get_fontname (XpadPadProperties *prop)
362{
363 return gtk_font_button_get_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton));
364}
365
366static void301static void
367xpad_pad_properties_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)302xpad_pad_properties_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
368{303{
369 XpadPadProperties *prop;304 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (object);
370
371 prop = XPAD_PAD_PROPERTIES (object);
372 305
373 switch (prop_id)306 switch (prop_id)
374 {307 {
375 case PROP_FOLLOW_FONT_STYLE:308 case PROP_FOLLOW_FONT_STYLE:
376 xpad_pad_properties_set_follow_font_style (prop, g_value_get_boolean (value));309 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck), !g_value_get_boolean (value));
377 break;310 break;
378 311
379 case PROP_FOLLOW_COLOR_STYLE:312 case PROP_FOLLOW_COLOR_STYLE:
380 xpad_pad_properties_set_follow_color_style (prop, g_value_get_boolean (value));313 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck), !g_value_get_boolean (value));
381 break;314 break;
382 315
383 case PROP_BACK_COLOR:316 case PROP_BACK_COLOR:
384 xpad_pad_properties_set_back_color (prop, g_value_get_boxed (value));317 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), g_value_get_boxed (value));
385 break;318 break;
386 319
387 case PROP_TEXT_COLOR:320 case PROP_TEXT_COLOR:
388 xpad_pad_properties_set_text_color (prop, g_value_get_boxed (value));321 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), g_value_get_boxed (value));
389 break;322 break;
390 323
391 case PROP_FONTNAME:324 case PROP_FONTNAME:
392 xpad_pad_properties_set_fontname (prop, g_value_get_string (value));325 gtk_font_button_set_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton), g_value_get_string (value));
393 break;326 break;
394 327
395 default:328 default:
@@ -401,30 +334,30 @@
401static void334static void
402xpad_pad_properties_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)335xpad_pad_properties_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
403{336{
404 XpadPadProperties *prop;337 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (object);
405
406 prop = XPAD_PAD_PROPERTIES (object);
407 338
408 switch (prop_id)339 switch (prop_id)
409 {340 {
410 case PROP_FOLLOW_FONT_STYLE:341 case PROP_FOLLOW_FONT_STYLE:
411 g_value_set_boolean (value, xpad_pad_properties_get_follow_font_style (prop));342 g_value_set_boolean (value, !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop->priv->fontcheck)));
412 break;343 break;
413 344
414 case PROP_FOLLOW_COLOR_STYLE:345 case PROP_FOLLOW_COLOR_STYLE:
415 g_value_set_boolean (value, xpad_pad_properties_get_follow_color_style (prop));346 g_value_set_boolean (value, !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop->priv->colorcheck)));
416 break;347 break;
417 348
418 case PROP_BACK_COLOR:349 case PROP_BACK_COLOR:
419 g_value_set_static_boxed (value, xpad_pad_properties_get_back_color (prop));350 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->backbutton), &prop->priv->backtmp);
351 g_value_set_static_boxed (value, &prop->priv->backtmp);
420 break;352 break;
421 353
422 case PROP_TEXT_COLOR:354 case PROP_TEXT_COLOR:
423 g_value_set_static_boxed (value, xpad_pad_properties_get_text_color (prop));355 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop->priv->textbutton), &prop->priv->texttmp);
356 g_value_set_static_boxed (value, &prop->priv->texttmp);
424 break;357 break;
425 358
426 case PROP_FONTNAME:359 case PROP_FONTNAME:
427 g_value_set_string (value, xpad_pad_properties_get_fontname (prop));360 g_value_set_string (value, gtk_font_button_get_font_name (GTK_FONT_BUTTON (prop->priv->fontbutton)));
428 break;361 break;
429 362
430 default:363 default:
431364
=== modified file 'src/xpad-pad-properties.h'
--- src/xpad-pad-properties.h 2014-06-04 12:36:36 +0000
+++ src/xpad-pad-properties.h 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -38,7 +39,6 @@
3839
39struct XpadPadProperties40struct XpadPadProperties
40{41{
41 /* private */
42 GtkDialog parent;42 GtkDialog parent;
43 XpadPadPropertiesPrivate *priv;43 XpadPadPropertiesPrivate *priv;
44};44};
@@ -52,21 +52,6 @@
5252
53GtkWidget *xpad_pad_properties_new (void);53GtkWidget *xpad_pad_properties_new (void);
5454
55void xpad_pad_properties_set_follow_font_style (XpadPadProperties *pad_properties, gboolean follow);
56gboolean xpad_pad_properties_get_follow_font_style (XpadPadProperties *pad_properties);
57
58void xpad_pad_properties_set_follow_color_style (XpadPadProperties *pad_properties, gboolean follow);
59gboolean xpad_pad_properties_get_follow_color_style (XpadPadProperties *pad_properties);
60
61void xpad_pad_properties_set_back_color (XpadPadProperties *pad_properties, const GdkRGBA *back);
62const GdkRGBA *xpad_pad_properties_get_back_color (XpadPadProperties *pad_properties);
63
64void xpad_pad_properties_set_text_color (XpadPadProperties *pad_properties, const GdkRGBA *text);
65const GdkRGBA *xpad_pad_properties_get_text_color (XpadPadProperties *pad_properties);
66
67void xpad_pad_properties_set_fontname (XpadPadProperties *pad_properties, const gchar *fontname);
68const gchar *xpad_pad_properties_get_fontname (XpadPadProperties *pad_properties);
69
70G_END_DECLS55G_END_DECLS
7156
72#endif /* __XPAD_PAD_PROPERTIES_H__ */57#endif /* __XPAD_PAD_PROPERTIES_H__ */
7358
=== modified file 'src/xpad-pad.c'
--- src/xpad-pad.c 2014-06-07 00:36:45 +0000
+++ src/xpad-pad.c 2014-06-13 15:52:27 +0000
@@ -5,7 +5,7 @@
5Copyright (c) 2011 Sergei Riaguzov5Copyright (c) 2011 Sergei Riaguzov
6Copyright (c) 2011 Dennis Hilmar6Copyright (c) 2011 Dennis Hilmar
7Copyright (c) 2011 OBATA Akio7Copyright (c) 2011 OBATA Akio
8Copyright (c) 2013 Arthur Borsboom8Copyright (c) 2013-2014 Arthur Borsboom
99
10This program is free software; you can redistribute it and/or modify10This program is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by11it under the terms of the GNU General Public License as published by
@@ -24,9 +24,8 @@
24*/24*/
2525
26#include "../config.h"26#include "../config.h"
27#include <gtk/gtk.h>
27#include <glib/gi18n.h>28#include <glib/gi18n.h>
28#include <gdk/gdkkeysyms.h>
29#include <string.h>
30#include "fio.h"29#include "fio.h"
31#include "help.h"30#include "help.h"
32#include "xpad-app.h"31#include "xpad-app.h"
@@ -34,13 +33,12 @@
34#include "xpad-pad-properties.h"33#include "xpad-pad-properties.h"
35#include "xpad-periodic.h"34#include "xpad-periodic.h"
36#include "xpad-preferences.h"35#include "xpad-preferences.h"
37#include "xpad-settings.h"
38#include "xpad-text-buffer.h"36#include "xpad-text-buffer.h"
39#include "xpad-text-view.h"37#include "xpad-text-view.h"
40#include "xpad-toolbar.h"38#include "xpad-toolbar.h"
41#include "xpad-tray.h"39#include "xpad-tray.h"
4240
43struct XpadPadPrivate 41struct XpadPadPrivate
44{42{
45 /* saved values */43 /* saved values */
46 gint x, y;44 gint x, y;
@@ -125,6 +123,7 @@
125static void xpad_pad_open_properties (XpadPad *pad);123static void xpad_pad_open_properties (XpadPad *pad);
126static void xpad_pad_open_preferences ();124static void xpad_pad_open_preferences ();
127static void xpad_pad_quit ();125static void xpad_pad_quit ();
126/* static void xpad_pad_show_all (XpadPad *pad); */
128static void xpad_pad_close_all (XpadPad *pad);127static void xpad_pad_close_all (XpadPad *pad);
129static void xpad_pad_sync_title (XpadPad *pad);128static void xpad_pad_sync_title (XpadPad *pad);
130static void xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group);129static void xpad_pad_set_group (XpadPad *pad, XpadPadGroup *group);
@@ -237,11 +236,8 @@
237 pad->priv->x = 0;236 pad->priv->x = 0;
238 pad->priv->y = 0;237 pad->priv->y = 0;
239 pad->priv->location_valid = FALSE;238 pad->priv->location_valid = FALSE;
240 pad->priv->width = xpad_settings_get_width (xpad_global_settings);
241 pad->priv->height = xpad_settings_get_height (xpad_global_settings);
242 pad->priv->infoname = NULL;239 pad->priv->infoname = NULL;
243 pad->priv->contentname = NULL;240 pad->priv->contentname = NULL;
244 pad->priv->sticky = xpad_settings_get_autostart_sticky (xpad_global_settings);
245 pad->priv->textview = NULL;241 pad->priv->textview = NULL;
246 pad->priv->scrollbar = NULL;242 pad->priv->scrollbar = NULL;
247 pad->priv->toolbar = NULL;243 pad->priv->toolbar = NULL;
@@ -253,6 +249,10 @@
253 pad->priv->unsaved_content = FALSE;249 pad->priv->unsaved_content = FALSE;
254 pad->priv->unsaved_info = FALSE;250 pad->priv->unsaved_info = FALSE;
255 pad->priv->group = NULL;251 pad->priv->group = NULL;
252 g_object_get (xpad_global_settings,
253 "width", &pad->priv->width,
254 "height", &pad->priv->height,
255 "autostart-sticky", &pad->priv->sticky, NULL);
256256
257 XpadTextView *text_view = XPAD_TEXT_VIEW (xpad_text_view_new ());257 XpadTextView *text_view = XPAD_TEXT_VIEW (xpad_text_view_new ());
258 xpad_text_view_set_pad (text_view, pad);258 xpad_text_view_set_pad (text_view, pad);
@@ -287,12 +287,13 @@
287287
288 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);288 gtk_container_child_set (GTK_CONTAINER (vbox), pad->priv->toolbar, "expand", FALSE, NULL);
289289
290 gtk_window_set_decorated (GTK_WINDOW(pad), xpad_settings_get_has_decorations (xpad_global_settings));290 gboolean decorations;
291 gtk_window_set_default_size (GTK_WINDOW(pad), (gint) xpad_settings_get_width (xpad_global_settings), (gint) xpad_settings_get_height (xpad_global_settings));291 g_object_get (xpad_global_settings, "has-decorations", &decorations, NULL);
292 gtk_window_set_decorated (GTK_WINDOW(pad), decorations);
293 gtk_window_set_default_size (GTK_WINDOW(pad), (gint) pad->priv->width, (gint) pad->priv->height);
292 gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */294 gtk_window_set_gravity (GTK_WINDOW(pad), GDK_GRAVITY_STATIC); /* static gravity makes saving pad x,y work */
293 gtk_window_set_skip_pager_hint (GTK_WINDOW(pad),xpad_settings_get_has_decorations (xpad_global_settings));295 gtk_window_set_skip_pager_hint (GTK_WINDOW(pad), decorations);
294 gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !xpad_settings_get_has_decorations (xpad_global_settings));296 gtk_window_set_skip_taskbar_hint (GTK_WINDOW(pad), !decorations);
295 gtk_window_set_type_hint (GTK_WINDOW(pad), GDK_WINDOW_TYPE_HINT_NORMAL);
296 gtk_window_set_position (GTK_WINDOW(pad), GTK_WIN_POS_MOUSE);297 gtk_window_set_position (GTK_WINDOW(pad), GTK_WIN_POS_MOUSE);
297298
298 g_object_set (G_OBJECT (pad),299 g_object_set (G_OBJECT (pad),
@@ -432,11 +433,12 @@
432static void433static void
433xpad_pad_notify_has_scrollbar (XpadPad *pad)434xpad_pad_notify_has_scrollbar (XpadPad *pad)
434{435{
435 if (xpad_settings_get_has_scrollbar (xpad_global_settings))436 gboolean has_scrollbar;
436 {437 g_object_get (xpad_global_settings, "has-scrollbar", &has_scrollbar, NULL);
438
439 if (has_scrollbar)
437 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pad->priv->scrollbar), 440 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pad->priv->scrollbar),
438 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);441 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
439 }
440 else442 else
441 {443 {
442 GtkAdjustment *v, *h;444 GtkAdjustment *v, *h;
@@ -456,7 +458,8 @@
456static void458static void
457xpad_pad_notify_has_decorations (XpadPad *pad)459xpad_pad_notify_has_decorations (XpadPad *pad)
458{460{
459 gboolean decorations = xpad_settings_get_has_decorations (xpad_global_settings);461 gboolean decorations;
462 g_object_get (xpad_global_settings, "has-decorations", &decorations, NULL);
460 463
461 /**464 /**
462 * There are two modes of operation: a normal mode and a 'stealth' mode.465 * There are two modes of operation: a normal mode and a 'stealth' mode.
@@ -564,11 +567,11 @@
564static void567static void
565xpad_pad_notify_has_toolbar (XpadPad *pad)568xpad_pad_notify_has_toolbar (XpadPad *pad)
566{569{
567 if (xpad_settings_get_has_toolbar (xpad_global_settings))570 gboolean has_toolbar, autohide_toolbar;
568 {571 g_object_get (xpad_global_settings, "has-toolbar", &has_toolbar, "autohide-toolbar", &autohide_toolbar, NULL);
569 if (!xpad_settings_get_autohide_toolbar (xpad_global_settings))572
570 xpad_pad_show_toolbar (pad);573 if (has_toolbar && !autohide_toolbar)
571 }574 xpad_pad_show_toolbar (pad);
572 else575 else
573 xpad_pad_hide_toolbar (pad);576 xpad_pad_hide_toolbar (pad);
574}577}
@@ -579,9 +582,10 @@
579 if (!pad || !pad->priv || !pad->priv->toolbar_timeout)582 if (!pad || !pad->priv || !pad->priv->toolbar_timeout)
580 return FALSE;583 return FALSE;
581584
582 if (pad->priv->toolbar_timeout &&585 gboolean has_toolbar, autohide_toolbar;
583 xpad_settings_get_autohide_toolbar (xpad_global_settings) &&586 g_object_get (xpad_global_settings, "has-toolbar", &has_toolbar, "autohide-toolbar", &autohide_toolbar, NULL);
584 xpad_settings_get_has_toolbar (xpad_global_settings))587
588 if (pad->priv->toolbar_timeout && autohide_toolbar && has_toolbar)
585 xpad_pad_hide_toolbar (pad);589 xpad_pad_hide_toolbar (pad);
586 590
587 pad->priv->toolbar_timeout = 0;591 pad->priv->toolbar_timeout = 0;
@@ -592,7 +596,10 @@
592static void596static void
593xpad_pad_notify_autohide_toolbar (XpadPad *pad)597xpad_pad_notify_autohide_toolbar (XpadPad *pad)
594{598{
595 if (xpad_settings_get_autohide_toolbar (xpad_global_settings))599 gboolean autohide_toolbar;
600 g_object_get (xpad_global_settings, "autohide-toolbar", &autohide_toolbar, NULL);
601
602 if (autohide_toolbar)
596 {603 {
597 /* Likely not to be in pad when turning setting on */604 /* Likely not to be in pad when turning setting on */
598 if (!pad->priv->toolbar_timeout)605 if (!pad->priv->toolbar_timeout)
@@ -600,7 +607,10 @@
600 }607 }
601 else608 else
602 {609 {
603 if (xpad_settings_get_has_toolbar (xpad_global_settings))610 gboolean has_toolbar;
611 g_object_get (xpad_global_settings, "has-toolbar", &has_toolbar, NULL);
612
613 if (has_toolbar)
604 xpad_pad_show_toolbar(pad);614 xpad_pad_show_toolbar(pad);
605 }615 }
606}616}
@@ -660,8 +670,10 @@
660static gboolean670static gboolean
661xpad_pad_enter_notify_event (GtkWidget *pad, GdkEventCrossing *event)671xpad_pad_enter_notify_event (GtkWidget *pad, GdkEventCrossing *event)
662{672{
663 if (xpad_settings_get_has_toolbar (xpad_global_settings) &&673 gboolean has_toolbar, autohide_toolbar;
664 xpad_settings_get_autohide_toolbar (xpad_global_settings) &&674 g_object_get (xpad_global_settings, "has-toolbar", &has_toolbar, "autohide-toolbar", &autohide_toolbar, NULL);
675
676 if (has_toolbar && autohide_toolbar &&
665 event->detail != GDK_NOTIFY_INFERIOR &&677 event->detail != GDK_NOTIFY_INFERIOR &&
666 event->mode == GDK_CROSSING_NORMAL)678 event->mode == GDK_CROSSING_NORMAL)
667 {679 {
@@ -675,8 +687,10 @@
675static gboolean687static gboolean
676xpad_pad_leave_notify_event (GtkWidget *pad, GdkEventCrossing *event)688xpad_pad_leave_notify_event (GtkWidget *pad, GdkEventCrossing *event)
677{689{
678 if (xpad_settings_get_has_toolbar (xpad_global_settings) &&690 gboolean has_toolbar, autohide_toolbar;
679 xpad_settings_get_autohide_toolbar (xpad_global_settings) &&691 g_object_get (xpad_global_settings, "has-toolbar", &has_toolbar, "autohide-toolbar", &autohide_toolbar, NULL);
692
693 if (has_toolbar && autohide_toolbar &&
680 event->detail != GDK_NOTIFY_INFERIOR &&694 event->detail != GDK_NOTIFY_INFERIOR &&
681 event->mode == GDK_CROSSING_NORMAL)695 event->mode == GDK_CROSSING_NORMAL)
682 {696 {
@@ -741,7 +755,8 @@
741 gchar *content;755 gchar *content;
742 gboolean confirm;756 gboolean confirm;
743 757
744 if (!xpad_settings_get_confirm_destroy (xpad_global_settings))758 g_object_get (xpad_global_settings, "confirm-destroy", &confirm, NULL);
759 if (!confirm)
745 return FALSE;760 return FALSE;
746 761
747 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));762 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pad->priv->textview));
@@ -821,12 +836,15 @@
821prop_notify_follow_font (XpadPad *pad)836prop_notify_follow_font (XpadPad *pad)
822{837{
823 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);838 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
824 839
825 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), xpad_pad_properties_get_follow_font_style (prop));840 gboolean follow_font_style;
826 841 g_object_get (prop, "follow-font-style", &follow_font_style, NULL);
827 if (!xpad_pad_properties_get_follow_font_style (prop))842 xpad_text_view_set_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_font_style);
843
844 if (!follow_font_style)
828 {845 {
829 const gchar *font = xpad_pad_properties_get_fontname (prop);846 const gchar *font;
847 g_object_get (prop, "fontname", &font, NULL);
830 PangoFontDescription *fontdesc;848 PangoFontDescription *fontdesc;
831 849
832 fontdesc = font ? pango_font_description_from_string (font) : NULL;850 fontdesc = font ? pango_font_description_from_string (font) : NULL;
@@ -843,13 +861,15 @@
843{861{
844 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);862 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
845 863
846 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), xpad_pad_properties_get_follow_color_style (prop));864 gboolean follow_color_style;
865 g_object_get (prop, "follow-color-style", &follow_color_style, NULL);
866 xpad_text_view_set_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview), follow_color_style);
847867
848 if (xpad_pad_properties_get_follow_color_style (prop))868 if (follow_color_style)
849 {869 {
850 /* Set the colors to the global preferences colors */870 /* Set the colors to the global preferences colors */
851 const GdkRGBA *text_color = xpad_settings_get_text_color (xpad_global_settings);871 const GdkRGBA *text_color, *back_color;
852 const GdkRGBA *back_color = xpad_settings_get_back_color (xpad_global_settings);872 g_object_get (xpad_global_settings, "text-color", &text_color, "back-color", &back_color, NULL);
853873
854 gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);874 gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);
855 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);875 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);
@@ -862,8 +882,8 @@
862 else882 else
863 {883 {
864 /* Set the color to the individual pad properties colors */884 /* Set the color to the individual pad properties colors */
865 const GdkRGBA *text_color = xpad_pad_properties_get_text_color (prop);885 const GdkRGBA *text_color, *back_color;
866 const GdkRGBA *back_color = xpad_pad_properties_get_back_color (prop);886 g_object_get (prop, "text-color", &text_color, "back-color", &back_color, NULL);
867887
868 gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);888 gtk_widget_override_cursor (pad->priv->textview, text_color, text_color);
869 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);889 gtk_widget_override_color (pad->priv->textview, GTK_STATE_FLAG_NORMAL, text_color);
@@ -882,7 +902,8 @@
882{902{
883 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);903 XpadPadProperties *prop = XPAD_PAD_PROPERTIES (pad->priv->properties);
884 904
885 const gchar *font = xpad_pad_properties_get_fontname (prop);905 const gchar *font;
906 g_object_get (prop, "fontname", &font, NULL);
886 PangoFontDescription *fontdesc;907 PangoFontDescription *fontdesc;
887 908
888 fontdesc = font ? pango_font_description_from_string (font) : NULL;909 fontdesc = font ? pango_font_description_from_string (font) : NULL;
@@ -923,8 +944,8 @@
923 g_object_set (G_OBJECT (pad->priv->properties),944 g_object_set (G_OBJECT (pad->priv->properties),
924 "follow-font-style", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),945 "follow-font-style", xpad_text_view_get_follow_font_style (XPAD_TEXT_VIEW (pad->priv->textview)),
925 "follow-color-style", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),946 "follow-color-style", xpad_text_view_get_follow_color_style (XPAD_TEXT_VIEW (pad->priv->textview)),
947 "text-color", &widget_text_color,
926 "back-color", &widget_background_color,948 "back-color", &widget_background_color,
927 "text-color", &widget_text_color,
928 "fontname", pango_font_description_to_string(font),949 "fontname", pango_font_description_to_string(font),
929 NULL);950 NULL);
930 pango_font_description_free (font);951 pango_font_description_free (font);
@@ -1280,8 +1301,11 @@
1280 pad->priv->unsaved_info = FALSE;1301 pad->priv->unsaved_info = FALSE;
1281 1302
1282 pad->priv->location_valid = TRUE;1303 pad->priv->location_valid = TRUE;
1283 if (xpad_settings_get_has_toolbar (xpad_global_settings) &&1304
1284 !xpad_settings_get_autohide_toolbar (xpad_global_settings))1305 gboolean has_toolbar, autohide_toolbar;
1306 g_object_get (xpad_global_settings, "has-toolbar", &has_toolbar, "autohide-toolbar", &autohide_toolbar, NULL);
1307
1308 if (has_toolbar && !autohide_toolbar)
1285 {1309 {
1286 pad->priv->toolbar_height = 0;1310 pad->priv->toolbar_height = 0;
1287 xpad_pad_hide_toolbar (pad);1311 xpad_pad_hide_toolbar (pad);
@@ -1443,7 +1467,7 @@
1443 const gchar *artists[] = {"Michael Terry <mike@mterry.name>", NULL};1467 const gchar *artists[] = {"Michael Terry <mike@mterry.name>", NULL};
1444 const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com>", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", "Sachin Raut <great.sachin@gmail.com>", NULL};1468 const gchar *authors[] = {"Arthur Borsboom <arthurborsboom@gmail.com>", "Jeroen Vermeulen <jtv@xs4all.nl>", "Michael Terry <mike@mterry.name>", "Paul Ivanov <pivanov@berkeley.edu>", "Sachin Raut <great.sachin@gmail.com>", NULL};
1445 const gchar *comments = _("Sticky notes");1469 const gchar *comments = _("Sticky notes");
1446 const gchar *copyright = "© 2001-2013 Michael Terry";1470 const gchar *copyright = "© 2001-2014 Michael Terry";
1447 /* Translators: please translate this as your own name and optionally email1471 /* Translators: please translate this as your own name and optionally email
1448 like so: "Your Name <your@email.com>" */1472 like so: "Your Name <your@email.com>" */
1449 const gchar *translator_credits = _("translator-credits");1473 const gchar *translator_credits = _("translator-credits");
@@ -1562,6 +1586,17 @@
1562 i = NULL;1586 i = NULL;
1563}1587}
15641588
1589/*
1590static void
1591xpad_pad_show_all (XpadPad *pad)
1592{
1593 if (!pad->priv->group)
1594 return;
1595
1596 xpad_pad_group_show_all (pad->priv->group);
1597}
1598*/
1599
1565static void1600static void
1566xpad_pad_close_all (XpadPad *pad)1601xpad_pad_close_all (XpadPad *pad)
1567{1602{
@@ -1636,49 +1671,37 @@
1636static void1671static void
1637menu_toolbar (XpadPad *pad, GtkCheckMenuItem *check)1672menu_toolbar (XpadPad *pad, GtkCheckMenuItem *check)
1638{1673{
1639 /*1674 /* A dirty way to silence the compiler for these unused variables. */
1640 * A dirty way to silence the compiler for these unused variables.
1641 * Feel free to implement these variables in the way they are ment to be used.
1642 */
1643 (void) pad;1675 (void) pad;
16441676
1645 xpad_settings_set_has_toolbar (xpad_global_settings, gtk_check_menu_item_get_active (check));1677 g_object_set (xpad_global_settings, "has-toolbar", gtk_check_menu_item_get_active (check), NULL);
1646}1678}
16471679
1648static void1680static void
1649menu_scrollbar (XpadPad *pad, GtkCheckMenuItem *check)1681menu_scrollbar (XpadPad *pad, GtkCheckMenuItem *check)
1650{1682{
1651 /*1683 /* A dirty way to silence the compiler for these unused variables. */
1652 * A dirty way to silence the compiler for these unused variables.
1653 * Feel free to implement these variables in the way they are ment to be used.
1654 */
1655 (void) pad;1684 (void) pad;
16561685
1657 xpad_settings_set_has_scrollbar (xpad_global_settings, gtk_check_menu_item_get_active (check));1686 g_object_set (xpad_global_settings, "has-scrollbar", gtk_check_menu_item_get_active (check), NULL);
1658}1687}
16591688
1660static void1689static void
1661menu_autohide (XpadPad *pad, GtkCheckMenuItem *check)1690menu_autohide (XpadPad *pad, GtkCheckMenuItem *check)
1662{1691{
1663 /*1692 /* A dirty way to silence the compiler for these unused variables. */
1664 * A dirty way to silence the compiler for these unused variables.
1665 * Feel free to implement these variables in the way they are ment to be used.
1666 */
1667 (void) pad;1693 (void) pad;
16681694
1669 xpad_settings_set_autohide_toolbar (xpad_global_settings, gtk_check_menu_item_get_active (check));1695 g_object_set (xpad_global_settings, "autohide-toolbar", gtk_check_menu_item_get_active (check), NULL);
1670}1696}
16711697
1672static void1698static void
1673menu_decorated (XpadPad *pad, GtkCheckMenuItem *check)1699menu_decorated (XpadPad *pad, GtkCheckMenuItem *check)
1674{1700{
1675 /*1701 /* A dirty way to silence the compiler for these unused variables. */
1676 * A dirty way to silence the compiler for these unused variables.
1677 * Feel free to implement these variables in the way they are ment to be used.
1678 */
1679 (void) pad;1702 (void) pad;
16801703
1681 xpad_settings_set_has_decorations (xpad_global_settings, gtk_check_menu_item_get_active (check));1704 g_object_set (xpad_global_settings, "has-decorations", gtk_check_menu_item_get_active (check), NULL);
1682}1705}
16831706
1684static gint1707static gint
@@ -1731,6 +1754,13 @@
1731menu_get_popup_no_highlight (XpadPad *pad, GtkAccelGroup *accel_group)1754menu_get_popup_no_highlight (XpadPad *pad, GtkAccelGroup *accel_group)
1732{1755{
1733 GtkWidget *uppermenu, *menu, *item;1756 GtkWidget *uppermenu, *menu, *item;
1757 gboolean has_toolbar, autohide_toolbar, has_scrollbar, decorations;
1758
1759 g_object_get (xpad_global_settings,
1760 "has-toolbar", &has_toolbar,
1761 "autohide-toolbar", &autohide_toolbar,
1762 "has-decorations", &decorations,
1763 "has-scrollbar", &has_scrollbar, NULL);
1734 1764
1735 uppermenu = gtk_menu_new ();1765 uppermenu = gtk_menu_new ();
1736 gtk_menu_set_accel_group (GTK_MENU (uppermenu), accel_group);1766 gtk_menu_set_accel_group (GTK_MENU (uppermenu), accel_group);
@@ -1769,11 +1799,11 @@
1769 gtk_container_add (GTK_CONTAINER (uppermenu), item);1799 gtk_container_add (GTK_CONTAINER (uppermenu), item);
1770 menu = gtk_menu_new ();1800 menu = gtk_menu_new ();
1771 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);1801 gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1772 MENU_ADD_CHECK (_("_Toolbar"), xpad_settings_get_has_toolbar (xpad_global_settings), menu_toolbar);1802 MENU_ADD_CHECK (_("_Toolbar"), has_toolbar, menu_toolbar);
1773 MENU_ADD_CHECK (_("_Autohide Toolbar"), xpad_settings_get_autohide_toolbar (xpad_global_settings), menu_autohide);1803 MENU_ADD_CHECK (_("_Autohide Toolbar"), autohide_toolbar, menu_autohide);
1774 gtk_widget_set_sensitive (item, xpad_settings_get_has_toolbar (xpad_global_settings));1804 gtk_widget_set_sensitive (item, has_toolbar);
1775 MENU_ADD_CHECK (_("_Scrollbar"), xpad_settings_get_has_scrollbar (xpad_global_settings), menu_scrollbar);1805 MENU_ADD_CHECK (_("_Scrollbar"), has_scrollbar, menu_scrollbar);
1776 MENU_ADD_CHECK (_("_Window Decorations"), xpad_settings_get_has_decorations (xpad_global_settings), menu_decorated);1806 MENU_ADD_CHECK (_("_Window Decorations"), decorations, menu_decorated);
1777 1807
1778 /* Notes submenu */1808 /* Notes submenu */
1779 item = gtk_menu_item_new_with_mnemonic (_("_Notes"));1809 item = gtk_menu_item_new_with_mnemonic (_("_Notes"));
@@ -1843,16 +1873,12 @@
1843 MENU_ADD_SEP ();1873 MENU_ADD_SEP ();
1844 g_object_set_data (G_OBJECT (menu), "notes-sep", item);1874 g_object_set_data (G_OBJECT (menu), "notes-sep", item);
1845 1875
1846 /**1876 /* Order pads according to title */
1847 * Order pads according to title.
1848 */
1849 pads = xpad_pad_group_get_pads (current_pad->priv->group);1877 pads = xpad_pad_group_get_pads (current_pad->priv->group);
1850 1878
1851 pads = g_slist_sort (pads, (GCompareFunc) menu_title_compare);1879 pads = g_slist_sort (pads, (GCompareFunc) menu_title_compare);
1852 1880
1853 /**1881 /* Populate list of windows */
1854 * Populate list of windows.
1855 */
1856 for (l = pads, n = 1; l; l = l->next, n++)1882 for (l = pads, n = 1; l; l = l->next, n++)
1857 {1883 {
1858 gchar *title;1884 gchar *title;
@@ -1939,10 +1965,7 @@
19391965
1940 cairo_rectangle_int_t rect;1966 cairo_rectangle_int_t rect;
19411967
1942 /**1968 /* We must check if we disabled off of pad and start the timeout if so. */
1943 * We must check if we disabled off of pad and start the timeout if so.
1944 */
1945
1946 rect.x = 10;1969 rect.x = 10;
1947 rect.y = 10;1970 rect.y = 10;
1948 rect.width = 1;1971 rect.width = 1;
19491972
=== modified file 'src/xpad-pad.h'
--- src/xpad-pad.h 2013-10-09 22:02:22 +0000
+++ src/xpad-pad.h 2014-06-13 15:52:27 +0000
@@ -3,6 +3,7 @@
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2009 Paul Ivanov4Copyright (c) 2009 Paul Ivanov
5Copyright (c) 2011 Sergei Riaguzov5Copyright (c) 2011 Sergei Riaguzov
6Copyright (c) 2013-2014 Arthur Borsboom
67
7This program is free software; you can redistribute it and/or modify8This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by9it under the terms of the GNU General Public License as published by
910
=== modified file 'src/xpad-periodic.c'
--- src/xpad-periodic.c 2014-06-04 12:36:36 +0000
+++ src/xpad-periodic.c 2014-06-13 15:52:27 +0000
@@ -1,8 +1,26 @@
1#include "../config.h"1/*
2
3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
21
2#include <stdlib.h>22#include <stdlib.h>
3#include <stdio.h>
4#include <string.h>23#include <string.h>
5#include <stdarg.h>
6#include "xpad-periodic.h"24#include "xpad-periodic.h"
725
8#ifdef SHOW_DEBUG26#ifdef SHOW_DEBUG
@@ -45,8 +63,9 @@
45/* prototypes */63/* prototypes */
46static gint xppd_intercept (gpointer);64static gint xppd_intercept (gpointer);
47static gint gprint_ignore(const char *, ...);65static gint gprint_ignore(const char *, ...);
66static void Xpad_periodic_signal (const char * cbname, void * xpad_pad);
67static void Xpad_periodic_error_exit (const char *, ...);
4868
49static void xpad_sigref_dump2 (gint);
50static gboolean str_equal (const char *, const char *);69static gboolean str_equal (const char *, const char *);
5170
52/* global variables */71/* global variables */
@@ -149,7 +168,7 @@
149 }168 }
150169
151 if (! isdone) {170 if (! isdone) {
152 printf("Failed to install signal callback: %s\n", cbname);171 g_print("Failed to install signal callback: %s\n", cbname);
153 exit(1);172 exit(1);
154 }173 }
155174
@@ -166,8 +185,7 @@
166 Xpad_periodic_signal("save-content", xpad_pad);185 Xpad_periodic_signal("save-content", xpad_pad);
167}186}
168187
169void Xpad_periodic_signal (const char * cbname, void * xpad_pad)188static void Xpad_periodic_signal (const char * cbname, void * xpad_pad) {
170{
171 int isdone = 0;189 int isdone = 0;
172 int tnx=0, snx=0;190 int tnx=0, snx=0;
173 XpadPeriodicFunc func_ptr = 0;191 XpadPeriodicFunc func_ptr = 0;
@@ -236,38 +254,10 @@
236 return 0;254 return 0;
237}255}
238256
239void xpad_sigref_dump2 (gint twhich)257static void Xpad_periodic_error_exit (const char * fmt, ...) {
240{
241 int tlen = 0, cnt = 0;
242 Xpadsigref * xlist = 0;
243 if (0 == twhich) { xlist = xpptr->template; }
244 if (1 == twhich) { xlist = xpptr->sigs; }
245 if (0 == twhich) { tlen = xpptr->template_len; }
246 if (1 == twhich) { tlen = xpptr->sigs_len; }
247
248 for (cnt = 0; cnt < tlen; ++cnt) {
249 Xpadsigref * xitem = xlist + cnt;
250 if (0 == xitem->signame) { continue; }
251 printf("%3d: %s : %p : %p\n", cnt, xitem->signame,
252 xitem->func_ptr, xitem->data);
253 }
254}
255
256void Xpad_periodic_error_exit (const char * fmt, ...)
257{
258 va_list app;258 va_list app;
259 va_start(app, fmt);259 va_start(app, fmt);
260 vprintf(fmt, app);260 g_print(fmt, app);
261 va_end(app);261 va_end(app);
262 exit(1);262 exit(1);
263}263}
264
265void Xpad_periodic_test (void)
266{
267 puts("Template:");
268 xpad_sigref_dump2(0);
269 exit(0);
270}
271
272
273/* vim: set ts=4 sw=4 :vim */
274264
=== modified file 'src/xpad-periodic.h'
--- src/xpad-periodic.h 2013-10-09 14:46:10 +0000
+++ src/xpad-periodic.h 2014-06-13 15:52:27 +0000
@@ -1,8 +1,28 @@
1/*
2
3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
121
2#ifndef XPAD_PERIODIC_H22#ifndef XPAD_PERIODIC_H
3#define XPAD_PERIODIC_H23#define XPAD_PERIODIC_H
424
5#include <gtk/gtk.h>25#include <glib.h>
626
7typedef void (*XpadPeriodicFunc)(void *);27typedef void (*XpadPeriodicFunc)(void *);
828
@@ -30,13 +50,5 @@
30************************/50************************/
31void Xpad_periodic_save_content_delayed (void * xpad_pad);51void Xpad_periodic_save_content_delayed (void * xpad_pad);
32void Xpad_periodic_save_info_delayed (void * xpad_pad);52void Xpad_periodic_save_info_delayed (void * xpad_pad);
33void Xpad_periodic_signal (const char * cbname, void * xpad_pad);
34
35void Xpad_periodic_test (); /* aborts program */
36void Xpad_periodic_error_exit (const char *, ...); /* ditto */
3753
38#endif /* XPAD_PERIODIC_H */54#endif /* XPAD_PERIODIC_H */
39
40/************************
41************************/
42/* vim: set ts=4 sw=4 :vim */
4355
=== modified file 'src/xpad-preferences.c'
--- src/xpad-preferences.c 2014-06-07 00:19:07 +0000
+++ src/xpad-preferences.c 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -18,17 +19,10 @@
1819
19*/20*/
2021
21#include "../config.h"
22#include <glib/gi18n.h>22#include <glib/gi18n.h>
23#include <string.h>23#include <gtk/gtk.h>
24#include "xpad-preferences.h"
24#include "xpad-app.h"25#include "xpad-app.h"
25#include "xpad-preferences.h"
26#include "xpad-settings.h"
27#include <sys/types.h>
28#include <sys/stat.h>
29#include <stdio.h>
30#include <stdlib.h>
31#include <unistd.h>
3226
33struct XpadPreferencesPrivate 27struct XpadPreferencesPrivate
34{28{
@@ -46,7 +40,8 @@
46 GtkWidget *autostart_new_pad;40 GtkWidget *autostart_new_pad;
47 GtkWidget *autostart_sticky;41 GtkWidget *autostart_sticky;
48 GtkWidget *autostart_display_pads;42 GtkWidget *autostart_display_pads;
49 GtkWidget *trayconfigbox;43 GtkWidget *tray_enabled;
44 GtkWidget *tray_click_configuration;
50 GtkWidget *editcheck;45 GtkWidget *editcheck;
51 GtkWidget *confirmcheck;46 GtkWidget *confirmcheck;
5247
@@ -61,19 +56,22 @@
61 gulong autostart_new_pad_handler;56 gulong autostart_new_pad_handler;
62 gulong autostart_sticky_handler;57 gulong autostart_sticky_handler;
63 gulong autostart_display_pads_handler; 58 gulong autostart_display_pads_handler;
64 gulong trayclick_handler;59 gulong tray_enabled_handler;
60 gulong tray_click_handler;
65 gulong editcheck_handler;61 gulong editcheck_handler;
66 gulong confirmcheck_handler;62 gulong confirmcheck_handler;
6763
68 gulong notify_font_handler;64 gulong notify_font_handler;
69 gulong notify_text_handler;65 gulong notify_text_handler;
70 gulong notify_back_handler;66 gulong notify_back_handler;
67 gulong notify_autostart_xpad_handler;
71 gulong notify_autostart_wait_systray_handler;68 gulong notify_autostart_wait_systray_handler;
72 gulong notify_autostart_delay_handler;69 gulong notify_autostart_delay_handler;
73 gulong notify_autostart_new_pad_handler;70 gulong notify_autostart_new_pad_handler;
74 gulong notify_autostart_sticky_handler;71 gulong notify_autostart_sticky_handler;
75 gulong notify_autostart_display_pads_handler;72 gulong notify_autostart_display_pads_handler;
76 gulong notify_tray_handler;73 gulong notify_tray_enabled_handler;
74 gulong notify_tray_click_handler;
77 gulong notify_edit_handler;75 gulong notify_edit_handler;
78 gulong notify_confirm_handler;76 gulong notify_confirm_handler;
79};77};
@@ -91,19 +89,21 @@
91static void change_autostart_new_pad (GtkToggleButton *button, XpadPreferences *pref);89static void change_autostart_new_pad (GtkToggleButton *button, XpadPreferences *pref);
92static void change_autostart_sticky (GtkToggleButton *button, XpadPreferences *pref);90static void change_autostart_sticky (GtkToggleButton *button, XpadPreferences *pref);
93static void change_autostart_display_pads (GtkComboBox *box, XpadPreferences *pref);91static void change_autostart_display_pads (GtkComboBox *box, XpadPreferences *pref);
94static void change_tray_click_configuration (GtkComboBox *box, XpadPreferences *pref);92static void change_tray_enabled (GtkToggleButton *button, XpadPreferences *pref);
93static void change_tray_click (GtkComboBox *box, XpadPreferences *pref);
95static void change_edit_check (GtkToggleButton *button, XpadPreferences *pref);94static void change_edit_check (GtkToggleButton *button, XpadPreferences *pref);
96static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);95static void change_confirm_check (GtkToggleButton *button, XpadPreferences *pref);
9796
98static void notify_fontname (XpadPreferences *pref);97static void notify_fontname (XpadPreferences *pref);
99static void notify_text_color (XpadPreferences *pref);98static void notify_text_color (XpadPreferences *pref);
100static void notify_back_color (XpadPreferences *pref);99static void notify_back_color (XpadPreferences *pref);
101100static void notify_autostart_xpad (XpadPreferences *pref);
102static void notify_autostart_wait_systray (XpadPreferences *pref);101static void notify_autostart_wait_systray (XpadPreferences *pref);
103static void notify_autostart_delay (XpadPreferences *pref);102static void notify_autostart_delay (XpadPreferences *pref);
104static void notify_autostart_new_pad (XpadPreferences *pref);103static void notify_autostart_new_pad (XpadPreferences *pref);
105static void notify_autostart_sticky (XpadPreferences *pref);104static void notify_autostart_sticky (XpadPreferences *pref);
106static void notify_autostart_display_pads (XpadPreferences *pref);105static void notify_autostart_display_pads (XpadPreferences *pref);
106static void notify_tray_enabled (XpadPreferences *pref);
107static void notify_tray_click (XpadPreferences *pref);107static void notify_tray_click (XpadPreferences *pref);
108static void notify_edit (XpadPreferences *pref);108static void notify_edit (XpadPreferences *pref);
109static void notify_confirm (XpadPreferences *pref);109static void notify_confirm (XpadPreferences *pref);
@@ -139,7 +139,7 @@
139xpad_preferences_init (XpadPreferences *pref)139xpad_preferences_init (XpadPreferences *pref)
140{140{
141 GtkWidget *hbox, *font_hbox, *vbox;141 GtkWidget *hbox, *font_hbox, *vbox;
142 const GdkRGBA *color;142 const GdkRGBA *text_color, *back_color;
143 const gchar *fontname;143 const gchar *fontname;
144 GtkStyleContext *style;144 GtkStyleContext *style;
145 GtkWidget *appearance_frame, *start_frame, *tray_frame, *other_frame;145 GtkWidget *appearance_frame, *start_frame, *tray_frame, *other_frame;
@@ -150,9 +150,26 @@
150 GtkRequisition req;150 GtkRequisition req;
151 GdkRGBA theme_text_color = {0, 0, 0, 0};151 GdkRGBA theme_text_color = {0, 0, 0, 0};
152 GdkRGBA theme_background_color = {0, 0, 0, 0};152 GdkRGBA theme_background_color = {0, 0, 0, 0};
153 guint tray_click_configuration, autostart_delay, autostart_display_pads;
154 gboolean confirm_destroy, edit_lock, autostart_xpad, autostart_wait_systray, autostart_new_pad, autostart_sticky;
153 155
154 pref->priv = xpad_preferences_get_instance_private(pref);156 pref->priv = xpad_preferences_get_instance_private(pref);
155 157
158 g_object_get (xpad_global_settings,
159 "fontname", &fontname,
160 "text-color", &text_color,
161 "back-color", &back_color,
162 "confirm-destroy", &confirm_destroy,
163 "edit-lock", &edit_lock,
164 "tray-click-configuration", &tray_click_configuration,
165 "autostart-xpad", &autostart_xpad,
166 "autostart-wait-systray", &autostart_wait_systray,
167 "autostart-new-pad", &autostart_new_pad,
168 "autostart-sticky", &autostart_sticky,
169 "autostart-delay", &autostart_delay,
170 "autostart-display-pads", &autostart_display_pads,
171 NULL);
172
156 /* Appearance options */173 /* Appearance options */
157 text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL);174 text = g_strconcat ("<b>", _("Appearance"), "</b>", NULL);
158 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,175 label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
@@ -213,7 +230,6 @@
213 gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &theme_text_color);230 gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &theme_text_color);
214 gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &theme_background_color);231 gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &theme_background_color);
215232
216 fontname = xpad_settings_get_fontname (xpad_global_settings);
217 if (fontname)233 if (fontname)
218 {234 {
219 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->fontcheck), TRUE);235 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->fontcheck), TRUE);
@@ -231,17 +247,15 @@
231 pango_font_description_free (font);247 pango_font_description_free (font);
232 }248 }
233249
234 color = xpad_settings_get_text_color (xpad_global_settings);250 if (text_color)
235 if (color)251 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), text_color);
236 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), color);
237 else252 else
238 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &theme_text_color);253 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &theme_text_color);
239 254
240 color = xpad_settings_get_back_color (xpad_global_settings);255 if (back_color)
241 if (color)
242 {256 {
243 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);257 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
244 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), color);258 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), back_color);
245 }259 }
246 else260 else
247 {261 {
@@ -300,15 +314,15 @@
300 314
301 pref->priv->autostart_xpad = gtk_check_button_new_with_mnemonic (_("_Start Xpad automatically after login"));315 pref->priv->autostart_xpad = gtk_check_button_new_with_mnemonic (_("_Start Xpad automatically after login"));
302 gtk_box_pack_start (GTK_BOX (autostart_vbox), pref->priv->autostart_xpad, FALSE, FALSE, 0);316 gtk_box_pack_start (GTK_BOX (autostart_vbox), pref->priv->autostart_xpad, FALSE, FALSE, 0);
303 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_xpad), xpad_settings_get_autostart_xpad (xpad_global_settings));317 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_xpad), autostart_xpad);
304318
305 pref->priv->autostart_wait_systray = gtk_check_button_new_with_mnemonic (_("_Wait for systray (if possible)"));319 pref->priv->autostart_wait_systray = gtk_check_button_new_with_mnemonic (_("_Wait for systray (if possible)"));
306 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);320 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
307 gtk_box_pack_start (GTK_BOX (hbox), gtk_alignment_new (1, 1, 1, 1), FALSE, FALSE, 0);321 gtk_box_pack_start (GTK_BOX (hbox), gtk_alignment_new (1, 1, 1, 1), FALSE, FALSE, 0);
308 gtk_box_pack_start (GTK_BOX (hbox), pref->priv->autostart_wait_systray, FALSE, FALSE, 0); 322 gtk_box_pack_start (GTK_BOX (hbox), pref->priv->autostart_wait_systray, FALSE, FALSE, 0);
309323
310 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_wait_systray), xpad_settings_get_autostart_wait_systray (xpad_global_settings));324 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_wait_systray), autostart_wait_systray);
311 if (xpad_settings_get_autostart_xpad (xpad_global_settings))325 if (autostart_xpad)
312 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, TRUE);326 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, TRUE);
313 else327 else
314 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, FALSE);328 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, FALSE);
@@ -316,19 +330,19 @@
316330
317 pref->priv->autostart_new_pad = gtk_check_button_new_with_mnemonic (_("_Open a new empty pad"));331 pref->priv->autostart_new_pad = gtk_check_button_new_with_mnemonic (_("_Open a new empty pad"));
318 gtk_box_pack_start (GTK_BOX (autostart_vbox), pref->priv->autostart_new_pad, FALSE, FALSE, 0);332 gtk_box_pack_start (GTK_BOX (autostart_vbox), pref->priv->autostart_new_pad, FALSE, FALSE, 0);
319 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_new_pad), xpad_settings_get_autostart_new_pad (xpad_global_settings));333 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_new_pad), autostart_new_pad);
320334
321 pref->priv->autostart_sticky = gtk_check_button_new_with_mnemonic (_("_Pads start on all workspaces"));335 pref->priv->autostart_sticky = gtk_check_button_new_with_mnemonic (_("_Pads start on all workspaces"));
322 gtk_box_pack_start (GTK_BOX (autostart_vbox), pref->priv->autostart_sticky, FALSE, FALSE, 0); 336 gtk_box_pack_start (GTK_BOX (autostart_vbox), pref->priv->autostart_sticky, FALSE, FALSE, 0);
323 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_sticky), xpad_settings_get_autostart_sticky (xpad_global_settings));337 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_sticky), autostart_sticky);
324338
325 label = gtk_label_new (_("Delay in seconds"));339 label = gtk_label_new (_("Delay in seconds"));
326 pref->priv->autostart_delay = gtk_combo_box_text_new(); 340 pref->priv->autostart_delay = gtk_combo_box_text_new();
327 guint i;341 guint i;
328 for (i=0; i<15; i++)342 for (i=0; i<15; i++)
329 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_delay ), g_strdup_printf ("%i", i));343 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->autostart_delay), g_strdup_printf ("%i", i));
330 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_delay), (guint) xpad_settings_get_autostart_delay (xpad_global_settings));344 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_delay), autostart_delay);
331 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);345 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
332 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);346 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
333 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->autostart_delay, TRUE, TRUE, 0);347 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->autostart_delay, TRUE, TRUE, 0);
334 gtk_box_pack_start(GTK_BOX(autostart_vbox), hbox, TRUE, TRUE, 0);348 gtk_box_pack_start(GTK_BOX(autostart_vbox), hbox, TRUE, TRUE, 0);
@@ -338,7 +352,7 @@
338 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_display_pads ), _("Open all pads") );352 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_display_pads ), _("Open all pads") );
339 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_display_pads ), _("Hide all pads") );353 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_display_pads ), _("Hide all pads") );
340 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_display_pads ), _("Restore to previous state") );354 gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT( pref->priv->autostart_display_pads ), _("Restore to previous state") );
341 gtk_combo_box_set_active( GTK_COMBO_BOX( pref->priv->autostart_display_pads ), (guint) xpad_settings_get_autostart_display_pads (xpad_global_settings));355 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_display_pads), (guint) autostart_display_pads);
342 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);356 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
343 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);357 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
344 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->autostart_display_pads, TRUE, TRUE, 0);358 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->autostart_display_pads, TRUE, TRUE, 0);
@@ -368,16 +382,19 @@
368 "child", alignment,382 "child", alignment,
369 NULL));383 NULL));
370384
385 pref->priv->tray_enabled = gtk_check_button_new_with_mnemonic (_("_Enable tray icon"));
386 gtk_box_pack_start (GTK_BOX (tray_vbox), pref->priv->tray_enabled, FALSE, FALSE, 0);
387
371 label = gtk_label_new_with_mnemonic(_("Tray click behaviour"));388 label = gtk_label_new_with_mnemonic(_("Tray click behaviour"));
372 pref->priv->trayconfigbox = gtk_combo_box_text_new(); 389 pref->priv->tray_click_configuration = gtk_combo_box_text_new();
373 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->trayconfigbox), _("Do Nothing") );390 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->tray_click_configuration), _("Do Nothing") );
374 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->trayconfigbox), _("Toggle Show All") );391 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->tray_click_configuration), _("Toggle Show All") );
375 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->trayconfigbox), _("List of Pads") );392 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->tray_click_configuration), _("List of Pads") );
376 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->trayconfigbox), _("New Pad") );393 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (pref->priv->tray_click_configuration), _("New Pad") );
377 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->trayconfigbox), (guint) xpad_settings_get_tray_click_handler (xpad_global_settings));394 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->tray_click_configuration), tray_click_configuration);
378 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);395 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
379 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);396 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
380 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->trayconfigbox, TRUE, TRUE, 0);397 gtk_box_pack_start(GTK_BOX(hbox), pref->priv->tray_click_configuration, TRUE, TRUE, 0);
381 gtk_box_pack_start(GTK_BOX(tray_vbox), hbox, TRUE, TRUE, 0);398 gtk_box_pack_start(GTK_BOX(tray_vbox), hbox, TRUE, TRUE, 0);
382399
383 /* Other options */400 /* Other options */
@@ -408,10 +425,10 @@
408 pref->priv->confirmcheck = gtk_check_button_new_with_mnemonic (_("_Confirm pad deletion"));425 pref->priv->confirmcheck = gtk_check_button_new_with_mnemonic (_("_Confirm pad deletion"));
409426
410 gtk_box_pack_start (GTK_BOX (other_vbox), pref->priv->editcheck, FALSE, FALSE, 0);427 gtk_box_pack_start (GTK_BOX (other_vbox), pref->priv->editcheck, FALSE, FALSE, 0);
411 gtk_box_pack_start (GTK_BOX (other_vbox), pref->priv->confirmcheck, FALSE, FALSE, 0); 428 gtk_box_pack_start (GTK_BOX (other_vbox), pref->priv->confirmcheck, FALSE, FALSE, 0);
412 429
413 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_global_settings));430 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), edit_lock);
414 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_global_settings));431 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), confirm_destroy);
415432
416 /* Close button and window title */433 /* Close button and window title */
417 gtk_dialog_add_button (GTK_DIALOG (pref), "gtk-close", GTK_RESPONSE_CLOSE);434 gtk_dialog_add_button (GTK_DIALOG (pref), "gtk-close", GTK_RESPONSE_CLOSE);
@@ -433,7 +450,8 @@
433 pref->priv->autostart_sticky_handler = g_signal_connect (pref->priv->autostart_sticky, "toggled", G_CALLBACK (change_autostart_sticky), pref);450 pref->priv->autostart_sticky_handler = g_signal_connect (pref->priv->autostart_sticky, "toggled", G_CALLBACK (change_autostart_sticky), pref);
434 pref->priv->autostart_display_pads_handler = g_signal_connect (pref->priv->autostart_display_pads, "changed", G_CALLBACK (change_autostart_display_pads), pref);451 pref->priv->autostart_display_pads_handler = g_signal_connect (pref->priv->autostart_display_pads, "changed", G_CALLBACK (change_autostart_display_pads), pref);
435452
436 pref->priv->trayclick_handler = g_signal_connect(pref->priv->trayconfigbox, "changed", G_CALLBACK(change_tray_click_configuration), pref);453 pref->priv->tray_enabled_handler = g_signal_connect (pref->priv->tray_enabled, "toggled", G_CALLBACK (change_tray_enabled), pref);
454 pref->priv->tray_click_handler = g_signal_connect(pref->priv->tray_click_configuration, "changed", G_CALLBACK(change_tray_click), pref);
437 pref->priv->editcheck_handler = g_signal_connect (pref->priv->editcheck, "toggled", G_CALLBACK (change_edit_check), pref);455 pref->priv->editcheck_handler = g_signal_connect (pref->priv->editcheck, "toggled", G_CALLBACK (change_edit_check), pref);
438 pref->priv->confirmcheck_handler = g_signal_connect (pref->priv->confirmcheck, "toggled", G_CALLBACK (change_confirm_check), pref);456 pref->priv->confirmcheck_handler = g_signal_connect (pref->priv->confirmcheck, "toggled", G_CALLBACK (change_confirm_check), pref);
439457
@@ -441,23 +459,28 @@
441 pref->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (notify_text_color), pref);459 pref->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (notify_text_color), pref);
442 pref->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (notify_back_color), pref);460 pref->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (notify_back_color), pref);
443461
444 pref->priv->notify_autostart_wait_systray_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart_wait_systray", G_CALLBACK (notify_autostart_wait_systray), pref);462 pref->priv->notify_autostart_xpad_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart-xpad", G_CALLBACK (notify_autostart_xpad), pref);
445 pref->priv->notify_autostart_delay_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart_delay", G_CALLBACK(notify_autostart_delay), pref);463 pref->priv->notify_autostart_wait_systray_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart-wait-systray", G_CALLBACK (notify_autostart_wait_systray), pref);
446 pref->priv->notify_autostart_new_pad_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart_new_pad", G_CALLBACK (notify_autostart_new_pad), pref);464 pref->priv->notify_autostart_delay_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart-delay", G_CALLBACK(notify_autostart_delay), pref);
447 pref->priv->notify_autostart_sticky_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart_sticky", G_CALLBACK (notify_autostart_sticky), pref);465 pref->priv->notify_autostart_new_pad_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart-new-pad", G_CALLBACK (notify_autostart_new_pad), pref);
448 pref->priv->notify_autostart_display_pads_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart_display_pads", G_CALLBACK (notify_autostart_display_pads), pref);466 pref->priv->notify_autostart_sticky_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart-sticky", G_CALLBACK (notify_autostart_sticky), pref);
467 pref->priv->notify_autostart_display_pads_handler = g_signal_connect_swapped (xpad_global_settings, "notify::autostart-display-pads", G_CALLBACK (notify_autostart_display_pads), pref);
449 pref->priv->notify_edit_handler = g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (notify_edit), pref);468 pref->priv->notify_edit_handler = g_signal_connect_swapped (xpad_global_settings, "notify::edit-lock", G_CALLBACK (notify_edit), pref);
450 pref->priv->notify_confirm_handler = g_signal_connect_swapped (xpad_global_settings, "notify::confirm-destroy", G_CALLBACK (notify_confirm), pref);469 pref->priv->notify_confirm_handler = g_signal_connect_swapped (xpad_global_settings, "notify::confirm-destroy", G_CALLBACK (notify_confirm), pref);
451 pref->priv->notify_tray_handler = g_signal_connect_swapped (xpad_global_settings, "notify::tray_click_configuration", G_CALLBACK(notify_tray_click), pref);470 pref->priv->notify_tray_enabled_handler = g_signal_connect_swapped (xpad_global_settings, "notify::tray-enabled", G_CALLBACK (notify_tray_enabled), pref);
471 pref->priv->notify_tray_click_handler = g_signal_connect_swapped (xpad_global_settings, "notify::tray-click-configuration", G_CALLBACK(notify_tray_click), pref);
452 472
453 g_object_unref (size_group_labels);473 g_object_unref (size_group_labels);
454474
475 /* Initiliaze the GUI logic */
476 g_object_notify (G_OBJECT (xpad_global_settings), "tray-enabled");
477
455 /* Make the preference dialog visible */478 /* Make the preference dialog visible */
456 global_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);479 global_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
457 gtk_box_set_homogeneous (GTK_BOX (global_vbox), FALSE);480 gtk_box_set_homogeneous (GTK_BOX (global_vbox), FALSE);
458 gtk_box_pack_start (GTK_BOX (global_vbox), appearance_frame, FALSE, FALSE, 0);481 gtk_box_pack_start (GTK_BOX (global_vbox), appearance_frame, FALSE, FALSE, 0);
459 gtk_box_pack_start (GTK_BOX (global_vbox), start_frame, FALSE, FALSE, 0); 482 gtk_box_pack_start (GTK_BOX (global_vbox), start_frame, FALSE, FALSE, 0);
460 gtk_box_pack_start (GTK_BOX (global_vbox), tray_frame, FALSE, FALSE, 0); 483 gtk_box_pack_start (GTK_BOX (global_vbox), tray_frame, FALSE, FALSE, 0);
461 gtk_box_pack_start (GTK_BOX (global_vbox), other_frame, FALSE, FALSE, 0);484 gtk_box_pack_start (GTK_BOX (global_vbox), other_frame, FALSE, FALSE, 0);
462 gtk_container_set_border_width (GTK_CONTAINER (global_vbox), 6);485 gtk_container_set_border_width (GTK_CONTAINER (global_vbox), 6);
463 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref))), global_vbox, FALSE, FALSE, 0); 486 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref))), global_vbox, FALSE, FALSE, 0);
@@ -497,9 +520,9 @@
497 g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);520 g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);
498 521
499 if (!gtk_toggle_button_get_active (button))522 if (!gtk_toggle_button_get_active (button))
500 xpad_settings_set_fontname (xpad_global_settings, NULL);523 g_object_set (xpad_global_settings, "fontname", NULL, NULL);
501 else524 else
502 xpad_settings_set_fontname (xpad_global_settings, gtk_font_button_get_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton)));525 g_object_set (xpad_global_settings, "fontname", gtk_font_button_get_font_name (GTK_FONT_BUTTON (pref->priv->fontbutton)), NULL);
503 526
504 gtk_widget_set_sensitive (pref->priv->fontbutton, gtk_toggle_button_get_active (button));527 gtk_widget_set_sensitive (pref->priv->fontbutton, gtk_toggle_button_get_active (button));
505 528
@@ -510,142 +533,58 @@
510change_font_face (GtkFontButton *button, XpadPreferences *pref)533change_font_face (GtkFontButton *button, XpadPreferences *pref)
511{534{
512 g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);535 g_signal_handler_block (xpad_global_settings, pref->priv->notify_font_handler);
513 xpad_settings_set_fontname (xpad_global_settings, gtk_font_button_get_font_name (button));536 g_object_set (xpad_global_settings, "fontname", gtk_font_button_get_font_name (button), NULL);
514 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_font_handler);537 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_font_handler);
515}538}
516539
517static void540static void
518change_color_check (GtkToggleButton *button, XpadPreferences *pref)541change_color_check (GtkToggleButton *button, XpadPreferences *pref)
519{542{
543 g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
520 g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);544 g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);
521 g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
522 545
523 if (!gtk_toggle_button_get_active (button))546 if (!gtk_toggle_button_get_active (button))
524 {547 g_object_set (xpad_global_settings, "text-color", NULL, "back-color", NULL, NULL);
525 xpad_settings_set_text_color (xpad_global_settings, NULL);
526 xpad_settings_set_back_color (xpad_global_settings, NULL);
527 }
528 else548 else
529 {549 {
530 GdkRGBA color;550 GdkRGBA text_color, back_color;
531 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &color);551 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), &text_color);
532 xpad_settings_set_text_color (xpad_global_settings, &color);552 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), &back_color);
533 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), &color);553 g_object_set (xpad_global_settings, "text-color", &text_color, "back-color", &back_color, NULL);
534 xpad_settings_set_back_color (xpad_global_settings, &color);
535 }554 }
536 555
537 gtk_widget_set_sensitive (pref->priv->colorbox, gtk_toggle_button_get_active (button));556 gtk_widget_set_sensitive (pref->priv->colorbox, gtk_toggle_button_get_active (button));
538 557
558 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
539 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);559 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);
540 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
541}560}
542561
543static void562static void
544change_text_color (GtkColorChooser *chooser, XpadPreferences *pref)563change_text_color (GtkColorChooser *chooser, XpadPreferences *pref)
545{564{
546 GdkRGBA color = {0, 0, 0, 0};565 GdkRGBA text_color = {0, 0, 0, 0};
547 gtk_color_chooser_get_rgba (chooser, &color);566 gtk_color_chooser_get_rgba (chooser, &text_color);
548567
549 g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);568 g_signal_handler_block (xpad_global_settings, pref->priv->notify_text_handler);
550 xpad_settings_set_text_color (xpad_global_settings, &color);569 g_object_set (xpad_global_settings, "text-color", &text_color, NULL);
551 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);570 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_text_handler);
552}571}
553572
554static void573static void
555change_back_color (GtkColorChooser *chooser, XpadPreferences *pref)574change_back_color (GtkColorChooser *chooser, XpadPreferences *pref)
556{575{
557 GdkRGBA color = {0, 0, 0, 0};576 GdkRGBA back_color = {0, 0, 0, 0};
558 gtk_color_chooser_get_rgba (chooser, &color);577 gtk_color_chooser_get_rgba (chooser, &back_color);
559578
560 g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);579 g_signal_handler_block (xpad_global_settings, pref->priv->notify_back_handler);
561 xpad_settings_set_back_color (xpad_global_settings, &color);580 g_object_set (xpad_global_settings, "back-color", &back_color, NULL);
562 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);581 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_back_handler);
563}582}
564583
565static void584static void
566change_autostart_xpad (GtkToggleButton *button, XpadPreferences *pref)585change_autostart_xpad (GtkToggleButton *button, XpadPreferences *pref)
567{586{
568 gboolean autostart;587 g_object_set (xpad_global_settings, "autostart-xpad", gtk_toggle_button_get_active (button), NULL);
569
570 autostart = gtk_toggle_button_get_active (button);
571
572 if (autostart) {
573 /* Copy the xpad.desktop file to the autostart folder and enable/disable the wait for systray preference */
574 gboolean success;
575 char *source_filename;
576 char *destination_directory;
577 GFile *source, *destination;
578 GError *error = NULL;
579
580 /* Find the base directory where the application is installed /usr or /usr/local, to find the correct xpad.desktop file. */
581 char *szTmp = g_strdup_printf ("/proc/%d/exe", getpid());
582 enum { BUFFERSIZE = 1024 };
583 char buf[BUFFERSIZE];
584 ssize_t len = readlink(szTmp, buf, sizeof(buf)-1);
585
586 if (len == -1) {
587 gchar *errtext;
588 errtext = g_strdup_printf (_("Could not find the directory where Xpad is installed\n%s"), error->message);
589 xpad_app_error (NULL, _("Error enabling Xpad autostart"), errtext);
590 g_free (errtext);
591
592 gtk_toggle_button_set_active (button, FALSE);
593 }
594 else {
595 char basedir[len-8];
596 guint i;
597 for (i=0; i<len-8; i++)
598 basedir[i] = buf[i];
599 basedir[len-9] = '\0';
600
601 source_filename = g_strdup_printf ("%s/share/applications/xpad.desktop", basedir);
602 destination_directory = g_strdup_printf ("%s/.config/autostart/xpad.desktop", g_getenv ("HOME"));
603
604 source = g_file_new_for_path (source_filename);
605 destination = g_file_new_for_path (destination_directory);
606 success = g_file_copy (source, destination, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error);
607
608 if (!success) {
609 gchar *errtext;
610 errtext = g_strdup_printf (_("Could not copy %s to %s\n%s"), source_filename, destination_directory, error->message);
611 xpad_app_error (NULL, _("Error enabling Xpad autostart"), errtext);
612 g_free (errtext);
613
614 gtk_toggle_button_set_active (button, FALSE);
615 }
616 else {
617 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);
618 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, TRUE);
619 change_autostart_wait_systray (GTK_TOGGLE_BUTTON (pref->priv->autostart_wait_systray), pref);
620 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);
621 }
622 }
623 }
624 else {
625 /* Remove the xpad.desktop file from the autostart folder and enable/disable the wait for systray preference */
626 gboolean success;
627 char *filename;
628 GFile *file;
629 GError *error = NULL;
630
631 filename = g_strdup_printf ("%s/.config/autostart/xpad.desktop", g_getenv ("HOME"));
632 file = g_file_new_for_path (filename);
633 success = g_file_delete (file, NULL, &error);
634
635 if (!success) {
636 gchar *errtext;
637 errtext = g_strdup_printf (_("Could not delete %s\n%s"), filename, error->message);
638 xpad_app_error (NULL, _("Error disabling Xpad autostart"), errtext);
639 g_free (errtext);
640
641 gtk_toggle_button_set_active (button, TRUE);
642 }
643 else {
644 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);
645 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, FALSE);
646 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);
647 }
648 }
649}588}
650589
651static void590static void
@@ -689,23 +628,15 @@
689 }628 }
690629
691 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);630 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);
692 xpad_settings_set_autostart_wait_systray (xpad_global_settings, wait_systray);631 g_object_set (xpad_global_settings, "autostart-wait-systray", wait_systray, NULL);
693 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);632 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_wait_systray_handler);
694}633}
695634
696static void635static void
697change_autostart_delay (GtkComboBox *box, XpadPreferences *pref)
698{
699 g_signal_handler_block(xpad_global_settings, pref->priv->notify_autostart_delay_handler);
700 xpad_settings_set_autostart_delay (xpad_global_settings, (guint) gtk_combo_box_get_active(box));
701 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_delay_handler);
702}
703
704static void
705change_autostart_new_pad (GtkToggleButton *button, XpadPreferences *pref)636change_autostart_new_pad (GtkToggleButton *button, XpadPreferences *pref)
706{637{
707 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_new_pad_handler);638 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_new_pad_handler);
708 xpad_settings_set_autostart_new_pad (xpad_global_settings, gtk_toggle_button_get_active (button));639 g_object_set (xpad_global_settings, "autostart-new-pad", gtk_toggle_button_get_active (button), NULL);
709 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_new_pad_handler);640 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_new_pad_handler);
710}641}
711642
@@ -713,31 +644,45 @@
713change_autostart_sticky (GtkToggleButton *button, XpadPreferences *pref)644change_autostart_sticky (GtkToggleButton *button, XpadPreferences *pref)
714{645{
715 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_sticky_handler);646 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_sticky_handler);
716 xpad_settings_set_autostart_sticky (xpad_global_settings, gtk_toggle_button_get_active (button));647 g_object_set (xpad_global_settings, "autostart-sticky", gtk_toggle_button_get_active (button), NULL);
717 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_sticky_handler);648 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_sticky_handler);
718}649}
719650
720static void651static void
652change_autostart_delay (GtkComboBox *box, XpadPreferences *pref)
653{
654 g_signal_handler_block(xpad_global_settings, pref->priv->notify_autostart_delay_handler);
655 g_object_set (xpad_global_settings, "autostart-delay", (guint) gtk_combo_box_get_active (box), NULL);
656 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_autostart_delay_handler);
657}
658
659static void
721change_autostart_display_pads (GtkComboBox *box, XpadPreferences *pref)660change_autostart_display_pads (GtkComboBox *box, XpadPreferences *pref)
722{661{
723 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_display_pads_handler);662 g_signal_handler_block (xpad_global_settings, pref->priv->notify_autostart_display_pads_handler);
724 xpad_settings_set_autostart_display_pads (xpad_global_settings, (guint) gtk_combo_box_get_active(box));663 g_object_set (xpad_global_settings, "autostart-display-pads", (guint) gtk_combo_box_get_active (box), NULL);
725 g_signal_handler_unblock(xpad_global_settings, pref->priv->notify_autostart_display_pads_handler);664 g_signal_handler_unblock(xpad_global_settings, pref->priv->notify_autostart_display_pads_handler);
726}665}
727666
728static void667static void
729change_tray_click_configuration (GtkComboBox *box, XpadPreferences *pref)668change_tray_enabled (GtkToggleButton *button, XpadPreferences *pref)
730{669{
731 g_signal_handler_block(xpad_global_settings, pref->priv->notify_tray_handler);670 g_object_set (xpad_global_settings, "tray-enabled", gtk_toggle_button_get_active (button), NULL);
732 xpad_settings_set_tray_click_handler (xpad_global_settings, (guint) gtk_combo_box_get_active(box));671}
733 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_tray_handler);672
673static void
674change_tray_click (GtkComboBox *box, XpadPreferences *pref)
675{
676 g_signal_handler_block(xpad_global_settings, pref->priv->notify_tray_click_handler);
677 g_object_set (xpad_global_settings, "tray-click-configuration", (guint) gtk_combo_box_get_active (box), NULL);
678 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_tray_click_handler);
734}679}
735680
736static void681static void
737change_edit_check (GtkToggleButton *button, XpadPreferences *pref)682change_edit_check (GtkToggleButton *button, XpadPreferences *pref)
738{683{
739 g_signal_handler_block (xpad_global_settings, pref->priv->notify_edit_handler);684 g_signal_handler_block (xpad_global_settings, pref->priv->notify_edit_handler);
740 xpad_settings_set_edit_lock (xpad_global_settings, gtk_toggle_button_get_active (button));685 g_object_set (xpad_global_settings, "edit-lock", gtk_toggle_button_get_active (button), NULL);
741 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_edit_handler);686 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_edit_handler);
742}687}
743688
@@ -745,14 +690,15 @@
745change_confirm_check (GtkToggleButton *button, XpadPreferences *pref)690change_confirm_check (GtkToggleButton *button, XpadPreferences *pref)
746{691{
747 g_signal_handler_block (xpad_global_settings, pref->priv->notify_confirm_handler);692 g_signal_handler_block (xpad_global_settings, pref->priv->notify_confirm_handler);
748 xpad_settings_set_confirm_destroy (xpad_global_settings, gtk_toggle_button_get_active (button));693 g_object_set (xpad_global_settings, "confirm-destroy", gtk_toggle_button_get_active (button), NULL);
749 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_confirm_handler);694 g_signal_handler_unblock (xpad_global_settings, pref->priv->notify_confirm_handler);
750}695}
751696
752static void697static void
753notify_fontname (XpadPreferences *pref)698notify_fontname (XpadPreferences *pref)
754{699{
755 const gchar *fontname = xpad_settings_get_fontname (xpad_global_settings);700 const gchar *fontname;
701 g_object_get (xpad_global_settings, "fontname", &fontname, NULL);
756 702
757 g_signal_handler_block (pref->priv->fontbutton, pref->priv->font_handler);703 g_signal_handler_block (pref->priv->fontbutton, pref->priv->font_handler);
758 g_signal_handler_block (pref->priv->fontcheck, pref->priv->fontcheck_handler);704 g_signal_handler_block (pref->priv->fontcheck, pref->priv->fontcheck_handler);
@@ -776,16 +722,17 @@
776static void722static void
777notify_text_color (XpadPreferences *pref)723notify_text_color (XpadPreferences *pref)
778{724{
779 const GdkRGBA *color = xpad_settings_get_text_color (xpad_global_settings);725 const GdkRGBA *text_color;
726 g_object_get (xpad_global_settings, "text-color", &text_color, NULL);
780 727
781 g_signal_handler_block (pref->priv->textbutton, pref->priv->text_handler);728 g_signal_handler_block (pref->priv->textbutton, pref->priv->text_handler);
782 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);729 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);
783 730
784 if (color)731 if (text_color)
785 {732 {
786 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);733 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
787 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);734 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);
788 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), color);735 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->textbutton), text_color);
789736
790 }737 }
791 else738 else
@@ -801,16 +748,17 @@
801static void748static void
802notify_back_color (XpadPreferences *pref)749notify_back_color (XpadPreferences *pref)
803{750{
804 const GdkRGBA *color = xpad_settings_get_back_color (xpad_global_settings);751 const GdkRGBA *back_color;
805 752 g_object_get (xpad_global_settings, "back-color", &back_color, NULL);
753
806 g_signal_handler_block (pref->priv->backbutton, pref->priv->back_handler);754 g_signal_handler_block (pref->priv->backbutton, pref->priv->back_handler);
807 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);755 g_signal_handler_block (pref->priv->colorcheck, pref->priv->colorcheck_handler);
808 756
809 if (color)757 if (back_color)
810 {758 {
811 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);759 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->colorcheck), TRUE);
812 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);760 gtk_widget_set_sensitive (pref->priv->colorbox, TRUE);
813 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), color);761 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pref->priv->backbutton), back_color);
814 }762 }
815 else763 else
816 {764 {
@@ -823,65 +771,108 @@
823}771}
824772
825static void773static void
774notify_autostart_xpad (XpadPreferences *pref)
775{
776 gboolean value;
777 g_object_get (xpad_global_settings, "autostart-xpad", &value, NULL);
778 g_signal_handler_block (pref->priv->autostart_xpad, pref->priv->autostart_xpad_handler);
779 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_xpad), value);
780 gtk_widget_set_sensitive (pref->priv->autostart_wait_systray, value);
781 if (value)
782 change_autostart_wait_systray (GTK_TOGGLE_BUTTON (pref->priv->autostart_wait_systray), pref);
783 g_signal_handler_unblock (pref->priv->autostart_xpad, pref->priv->autostart_xpad_handler);
784}
785
786static void
826notify_autostart_wait_systray (XpadPreferences *pref)787notify_autostart_wait_systray (XpadPreferences *pref)
827{788{
789 gboolean value;
790 g_object_get (xpad_global_settings, "autostart-wait-systray", &value, NULL);
828 g_signal_handler_block (pref->priv->autostart_wait_systray, pref->priv->autostart_wait_systray_handler);791 g_signal_handler_block (pref->priv->autostart_wait_systray, pref->priv->autostart_wait_systray_handler);
829 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_wait_systray), xpad_settings_get_autostart_wait_systray (xpad_global_settings));792 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_wait_systray), value);
830 g_signal_handler_unblock (pref->priv->autostart_wait_systray, pref->priv->autostart_wait_systray_handler);793 g_signal_handler_unblock (pref->priv->autostart_wait_systray, pref->priv->autostart_wait_systray_handler);
831}794}
832795
833static void
834notify_autostart_delay (XpadPreferences *pref)
835{
836 g_signal_handler_block (pref->priv->autostart_delay, pref->priv->autostart_delay_handler);
837 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_delay), (guint) xpad_settings_get_autostart_delay (xpad_global_settings));
838 g_signal_handler_unblock (pref->priv->autostart_delay, pref->priv->autostart_delay_handler);
839}
840
841static void796static void
842notify_autostart_new_pad (XpadPreferences *pref)797notify_autostart_new_pad (XpadPreferences *pref)
843{798{
799 gboolean value;
800 g_object_get (xpad_global_settings, "autostart-new-pad", &value, NULL);
844 g_signal_handler_block (pref->priv->autostart_new_pad, pref->priv->autostart_new_pad_handler);801 g_signal_handler_block (pref->priv->autostart_new_pad, pref->priv->autostart_new_pad_handler);
845 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_new_pad), xpad_settings_get_autostart_new_pad (xpad_global_settings));802 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_new_pad), value);
846 g_signal_handler_unblock (pref->priv->autostart_new_pad, pref->priv->autostart_new_pad_handler);803 g_signal_handler_unblock (pref->priv->autostart_new_pad, pref->priv->autostart_new_pad_handler);
847}804}
848805
849static void806static void
850notify_autostart_sticky (XpadPreferences *pref)807notify_autostart_sticky (XpadPreferences *pref)
851{808{
809 gboolean value;
810 g_object_get (xpad_global_settings, "autostart-sticky", &value, NULL);
852 g_signal_handler_block (pref->priv->autostart_sticky, pref->priv->autostart_sticky_handler);811 g_signal_handler_block (pref->priv->autostart_sticky, pref->priv->autostart_sticky_handler);
853 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_sticky), xpad_settings_get_autostart_sticky (xpad_global_settings));812 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->autostart_sticky), value);
854 g_signal_handler_unblock (pref->priv->autostart_sticky, pref->priv->autostart_sticky_handler);813 g_signal_handler_unblock (pref->priv->autostart_sticky, pref->priv->autostart_sticky_handler);
855}814}
856815
857static void816static void
817notify_autostart_delay (XpadPreferences *pref)
818{
819 guint value;
820 g_object_get (xpad_global_settings, "autostart-delay", &value, NULL);
821 g_signal_handler_block (pref->priv->autostart_delay, pref->priv->autostart_delay_handler);
822 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_delay), value);
823 g_signal_handler_unblock (pref->priv->autostart_delay, pref->priv->autostart_delay_handler);
824}
825
826static void
858notify_autostart_display_pads (XpadPreferences *pref)827notify_autostart_display_pads (XpadPreferences *pref)
859{828{
829 guint value;
830 g_object_get (xpad_global_settings, "autostart-display-pads", &value, NULL);
860 g_signal_handler_block (pref->priv->autostart_display_pads, pref->priv->autostart_display_pads_handler);831 g_signal_handler_block (pref->priv->autostart_display_pads, pref->priv->autostart_display_pads_handler);
861 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_display_pads), (guint) xpad_settings_get_autostart_display_pads (xpad_global_settings));832 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->autostart_display_pads), value);
862 g_signal_handler_unblock (pref->priv->autostart_wait_systray, pref->priv->autostart_wait_systray_handler);833 g_signal_handler_unblock (pref->priv->autostart_display_pads, pref->priv->autostart_display_pads_handler);
834}
835
836static void
837notify_tray_enabled (XpadPreferences *pref)
838{
839 gboolean value;
840 g_object_get (xpad_global_settings, "tray-enabled", &value, NULL);
841 g_signal_handler_block (pref->priv->tray_enabled, pref->priv->tray_enabled_handler);
842 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->tray_enabled), value);
843 gtk_widget_set_sensitive (pref->priv->tray_click_configuration, value);
844 gtk_widget_set_sensitive (pref->priv->autostart_display_pads, value);
845 if (!value)
846 g_object_set (xpad_global_settings, "autostart-display-pads", 0, NULL);
847 g_signal_handler_unblock (pref->priv->tray_enabled, pref->priv->tray_enabled_handler);
863}848}
864849
865static void 850static void
866notify_tray_click (XpadPreferences *pref)851notify_tray_click (XpadPreferences *pref)
867{852{
868 g_signal_handler_block (pref->priv->trayconfigbox, pref->priv->trayclick_handler);853 guint value;
869 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->trayconfigbox), (guint) xpad_settings_get_tray_click_handler(xpad_global_settings));854 g_object_get (xpad_global_settings, "tray-click-configuration", &value, NULL);
870 g_signal_handler_unblock (pref->priv->trayconfigbox, pref->priv->trayclick_handler);855 g_signal_handler_block (pref->priv->tray_click_configuration, pref->priv->tray_click_handler);
856 gtk_combo_box_set_active (GTK_COMBO_BOX (pref->priv->tray_click_configuration), value);
857 g_signal_handler_unblock (pref->priv->tray_click_configuration, pref->priv->tray_click_handler);
871}858}
872859
873static void860static void
874notify_edit (XpadPreferences *pref)861notify_edit (XpadPreferences *pref)
875{862{
863 gboolean value;
864 g_object_get (xpad_global_settings, "edit-lock", &value, NULL);
876 g_signal_handler_block (pref->priv->editcheck, pref->priv->editcheck_handler);865 g_signal_handler_block (pref->priv->editcheck, pref->priv->editcheck_handler);
877 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), xpad_settings_get_edit_lock (xpad_global_settings));866 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->editcheck), value);
878 g_signal_handler_unblock (pref->priv->editcheck, pref->priv->editcheck_handler);867 g_signal_handler_unblock (pref->priv->editcheck, pref->priv->editcheck_handler);
879}868}
880869
881static void870static void
882notify_confirm (XpadPreferences *pref)871notify_confirm (XpadPreferences *pref)
883{872{
873 gboolean value;
874 g_object_get (xpad_global_settings, "confirm-destroy", &value, NULL);
884 g_signal_handler_block (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);875 g_signal_handler_block (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);
885 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), xpad_settings_get_confirm_destroy (xpad_global_settings));876 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pref->priv->confirmcheck), value);
886 g_signal_handler_unblock (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);877 g_signal_handler_unblock (pref->priv->confirmcheck, pref->priv->confirmcheck_handler);
887}878}
888879
=== modified file 'src/xpad-preferences.h'
--- src/xpad-preferences.h 2008-09-21 00:03:40 +0000
+++ src/xpad-preferences.h 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
78
=== modified file 'src/xpad-session-manager.c'
--- src/xpad-session-manager.c 2014-06-04 12:36:36 +0000
+++ src/xpad-session-manager.c 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -18,22 +19,15 @@
1819
19*/20*/
2021
21#include "../config.h"
22#include "xpad-session-manager.h"
23
24#ifndef X_DISPLAY_MISSING22#ifndef X_DISPLAY_MISSING
2523
24#include <glib.h>
25#include <pwd.h>
26#include <stdlib.h>
27#include <string.h>
26#include <gdk/gdkx.h>28#include <gdk/gdkx.h>
27#include <X11/SM/SMlib.h>29#include <X11/SM/SMlib.h>
28#include <stdio.h> /* only for printf */30#include "xpad-session-manager.h"
29#include <sys/types.h> /* for getuid and getpwuid */
30#include <sys/select.h> /* for select */
31#include <stdlib.h> /* for free */
32#include <string.h> /* for strlen */
33#include <unistd.h> /* for getuid */
34#include <pwd.h> /* for getpwuid */
35#include <sys/types.h> /* for getuid and getpwuid */
36#include <sys/time.h> /* for struct timeval */
37#include "xpad-app.h"31#include "xpad-app.h"
3832
39static SmcConn xpad_session_manager_conn = NULL;33static SmcConn xpad_session_manager_conn = NULL;
4034
=== modified file 'src/xpad-session-manager.h'
--- src/xpad-session-manager.h 2008-09-21 00:03:40 +0000
+++ src/xpad-session-manager.h 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@
21#ifndef __XPAD_SESSION_MANAGER_H__22#ifndef __XPAD_SESSION_MANAGER_H__
22#define __XPAD_SESSION_MANAGER_H__23#define __XPAD_SESSION_MANAGER_H__
2324
24#include <gtk/gtk.h>25#include <glib.h>
2526
26gboolean xpad_session_manager_start_interact (gboolean error);27gboolean xpad_session_manager_start_interact (gboolean error);
27void xpad_session_manager_stop_interact (gboolean stop_shutdown);28void xpad_session_manager_stop_interact (gboolean stop_shutdown);
2829
=== modified file 'src/xpad-settings.c'
--- src/xpad-settings.c 2014-06-07 00:19:07 +0000
+++ src/xpad-settings.c 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -18,10 +19,12 @@
1819
19*/20*/
2021
21#include "../config.h"22#include <glib/gi18n.h>
23#include <gtk/gtk.h>
22#include <string.h>24#include <string.h>
25#include "fio.h"
23#include "xpad-settings.h"26#include "xpad-settings.h"
24#include "fio.h"27#include "xpad-app.h"
2528
26struct XpadSettingsPrivate29struct XpadSettingsPrivate
27{30{
@@ -30,13 +33,14 @@
30 gboolean has_decorations;33 gboolean has_decorations;
31 gboolean confirm_destroy;34 gboolean confirm_destroy;
32 gboolean edit_lock;35 gboolean edit_lock;
36 gboolean tray_enabled;
33 guint tray_click_configuration;37 guint tray_click_configuration;
34 gboolean has_toolbar;38 gboolean has_toolbar;
35 gboolean autohide_toolbar;39 gboolean autohide_toolbar;
36 gboolean has_scrollbar;40 gboolean has_scrollbar;
41 GdkRGBA *text;
37 GdkRGBA *back;42 GdkRGBA *back;
38 GdkRGBA *text;43 const gchar *fontname;
39 gchar *fontname;
40 GSList *toolbar_buttons;44 GSList *toolbar_buttons;
41 gboolean autostart_wait_systray;45 gboolean autostart_wait_systray;
42 guint autostart_delay;46 guint autostart_delay;
@@ -63,13 +67,15 @@
63 PROP_HAS_DECORATIONS,67 PROP_HAS_DECORATIONS,
64 PROP_CONFIRM_DESTROY,68 PROP_CONFIRM_DESTROY,
65 PROP_EDIT_LOCK,69 PROP_EDIT_LOCK,
70 PROP_TRAY_ENABLED,
66 PROP_TRAY_CLICK_CONFIGURATION,71 PROP_TRAY_CLICK_CONFIGURATION,
67 PROP_HAS_TOOLBAR,72 PROP_HAS_TOOLBAR,
68 PROP_AUTOHIDE_TOOLBAR,73 PROP_AUTOHIDE_TOOLBAR,
69 PROP_HAS_SCROLLBAR,74 PROP_HAS_SCROLLBAR,
75 PROP_TEXT_COLOR,
70 PROP_BACK_COLOR,76 PROP_BACK_COLOR,
71 PROP_TEXT_COLOR,
72 PROP_FONTNAME,77 PROP_FONTNAME,
78 PROP_AUTOSTART_XPAD,
73 PROP_AUTOSTART_WAIT_SYSTRAY,79 PROP_AUTOSTART_WAIT_SYSTRAY,
74 PROP_AUTOSTART_DELAY, 80 PROP_AUTOSTART_DELAY,
75 PROP_AUTOSTART_NEW_PAD,81 PROP_AUTOSTART_NEW_PAD,
@@ -125,7 +131,7 @@
125 131
126 g_object_class_install_property (gobject_class,132 g_object_class_install_property (gobject_class,
127 PROP_HAS_DECORATIONS,133 PROP_HAS_DECORATIONS,
128 g_param_spec_boolean ("has_decorations",134 g_param_spec_boolean ("has-decorations",
129 "Has Decorations",135 "Has Decorations",
130 "Whether pads have window decorations",136 "Whether pads have window decorations",
131 TRUE,137 TRUE,
@@ -133,7 +139,7 @@
133 139
134 g_object_class_install_property (gobject_class,140 g_object_class_install_property (gobject_class,
135 PROP_CONFIRM_DESTROY,141 PROP_CONFIRM_DESTROY,
136 g_param_spec_boolean ("confirm_destroy",142 g_param_spec_boolean ("confirm-destroy",
137 "Confirm Destroy",143 "Confirm Destroy",
138 "Whether destroying a pad requires user confirmation",144 "Whether destroying a pad requires user confirmation",
139 TRUE,145 TRUE,
@@ -141,31 +147,39 @@
141 147
142 g_object_class_install_property (gobject_class,148 g_object_class_install_property (gobject_class,
143 PROP_EDIT_LOCK,149 PROP_EDIT_LOCK,
144 g_param_spec_boolean ("edit_lock",150 g_param_spec_boolean ("edit-lock",
145 "Edit Lock",151 "Edit Lock",
146 "Whether edit lock mode is enabled",152 "Whether edit lock mode is enabled",
147 FALSE,153 FALSE,
148 G_PARAM_READWRITE));154 G_PARAM_READWRITE));
149 g_object_class_install_property (gobject_class,155 g_object_class_install_property (gobject_class,
156 PROP_TRAY_ENABLED,
157 g_param_spec_boolean ("tray-enabled",
158 "Enable the tray icon",
159 "Whether to enable or disable the systray icon",
160 TRUE,
161 G_PARAM_READWRITE));
162
163 g_object_class_install_property (gobject_class,
150 PROP_TRAY_CLICK_CONFIGURATION,164 PROP_TRAY_CLICK_CONFIGURATION,
151 g_param_spec_uint ("tray_click_configuration",165 g_param_spec_uint ("tray-click-configuration",
152 "Tray Click Configuration",166 "Tray click configuration",
153 "What configuration is selected on tray click",167 "What configuration is selected on tray click",
154 0,168 0,
155 G_MAXUINT,169 G_MAXUINT,
156 2,170 0,
157 G_PARAM_READWRITE));171 G_PARAM_READWRITE));
158 g_object_class_install_property (gobject_class,172 g_object_class_install_property (gobject_class,
159 PROP_HAS_TOOLBAR,173 PROP_HAS_TOOLBAR,
160 g_param_spec_boolean ("has_toolbar",174 g_param_spec_boolean ("has-toolbar",
161 "Has Toolbar",175 "Each pad has a toolbar",
162 "Whether pads have toolbars",176 "Whether pads have toolbars",
163 TRUE,177 TRUE,
164 G_PARAM_READWRITE));178 G_PARAM_READWRITE));
165 179
166 g_object_class_install_property (gobject_class,180 g_object_class_install_property (gobject_class,
167 PROP_AUTOHIDE_TOOLBAR,181 PROP_AUTOHIDE_TOOLBAR,
168 g_param_spec_boolean ("autohide_toolbar",182 g_param_spec_boolean ("autohide-toolbar",
169 "Autohide Toolbar",183 "Autohide Toolbar",
170 "Whether toolbars hide when not used",184 "Whether toolbars hide when not used",
171 TRUE,185 TRUE,
@@ -173,10 +187,10 @@
173 187
174 g_object_class_install_property (gobject_class,188 g_object_class_install_property (gobject_class,
175 PROP_HAS_SCROLLBAR,189 PROP_HAS_SCROLLBAR,
176 g_param_spec_boolean ("has_scrollbar",190 g_param_spec_boolean ("has-scrollbar",
177 "Has Scrollbar",191 "Has Scrollbar",
178 "Whether pads have scrollbars",192 "Whether pads have scrollbars",
179 FALSE,193 TRUE,
180 G_PARAM_READWRITE));194 G_PARAM_READWRITE));
181 195
182 g_object_class_install_property (gobject_class,196 g_object_class_install_property (gobject_class,
@@ -189,7 +203,7 @@
189 203
190 g_object_class_install_property (gobject_class,204 g_object_class_install_property (gobject_class,
191 PROP_TEXT_COLOR,205 PROP_TEXT_COLOR,
192 g_param_spec_boxed ("text_color",206 g_param_spec_boxed ("text-color",
193 "Text Color",207 "Text Color",
194 "Default color of pad text",208 "Default color of pad text",
195 GDK_TYPE_RGBA,209 GDK_TYPE_RGBA,
@@ -197,33 +211,31 @@
197 211
198 g_object_class_install_property (gobject_class,212 g_object_class_install_property (gobject_class,
199 PROP_BACK_COLOR,213 PROP_BACK_COLOR,
200 g_param_spec_boxed ("back_color",214 g_param_spec_boxed ("back-color",
201 "Back Color",215 "Back Color",
202 "Default color of pad background",216 "Default color of pad background",
203 GDK_TYPE_RGBA,217 GDK_TYPE_RGBA,
204 G_PARAM_READWRITE));218 G_PARAM_READWRITE));
205219
206 g_object_class_install_property (gobject_class,220 g_object_class_install_property (gobject_class,
221 PROP_AUTOSTART_XPAD,
222 g_param_spec_boolean ("autostart-xpad",
223 "Automatically start xpad",
224 "Whether to start xpad after login",
225 FALSE,
226 G_PARAM_READWRITE));
227
228 g_object_class_install_property (gobject_class,
207 PROP_AUTOSTART_WAIT_SYSTRAY,229 PROP_AUTOSTART_WAIT_SYSTRAY,
208 g_param_spec_boolean ("autostart_wait_systray",230 g_param_spec_boolean ("autostart-wait-systray",
209 "Autostart Xpad wait for systray",231 "Autostart Xpad wait for systray",
210 "Whether to wait for the systray before starting xpad automatically after login",232 "Whether to wait for the systray before starting xpad automatically after login",
211 FALSE,233 TRUE,
212 G_PARAM_READWRITE));234 G_PARAM_READWRITE));
213235
214 g_object_class_install_property (gobject_class,236 g_object_class_install_property (gobject_class,
215 PROP_AUTOSTART_DISPLAY_PADS,
216 g_param_spec_uint ("autostart_delay",
217 "Delay autostart of Xpad",
218 "How many seconds will Xpad wait before continuing startup",
219 0,
220 G_MAXUINT,
221 2,
222 G_PARAM_READWRITE));
223
224 g_object_class_install_property (gobject_class,
225 PROP_AUTOSTART_NEW_PAD,237 PROP_AUTOSTART_NEW_PAD,
226 g_param_spec_boolean ("autostart_new_pad",238 g_param_spec_boolean ("autostart-new-pad",
227 "Autostart a new pad",239 "Autostart a new pad",
228 "Whether to create a new pad on startup",240 "Whether to create a new pad on startup",
229 FALSE,241 FALSE,
@@ -231,15 +243,25 @@
231 243
232 g_object_class_install_property (gobject_class,244 g_object_class_install_property (gobject_class,
233 PROP_AUTOSTART_STICKY,245 PROP_AUTOSTART_STICKY,
234 g_param_spec_boolean ("autostart_sticky",246 g_param_spec_boolean ("autostart-sticky",
235 "Default Stickiness",247 "Default Stickiness",
236 "Whether pads are sticky on creation",248 "Whether pads are sticky on creation",
237 FALSE,249 FALSE,
238 G_PARAM_READWRITE));250 G_PARAM_READWRITE));
239 251
240 g_object_class_install_property (gobject_class,252 g_object_class_install_property (gobject_class,
253 PROP_AUTOSTART_DELAY,
254 g_param_spec_uint ("autostart-delay",
255 "Delay autostart of Xpad",
256 "How many seconds will Xpad wait before continuing startup",
257 0,
258 G_MAXUINT,
259 0,
260 G_PARAM_READWRITE));
261
262 g_object_class_install_property (gobject_class,
241 PROP_AUTOSTART_DISPLAY_PADS,263 PROP_AUTOSTART_DISPLAY_PADS,
242 g_param_spec_uint ("autostart_display_pads",264 g_param_spec_uint ("autostart-display-pads",
243 "Autostart display pads",265 "Autostart display pads",
244 "How to show the different pads when Xpad is started",266 "How to show the different pads when Xpad is started",
245 0,267 0,
@@ -265,18 +287,6 @@
265 settings->priv->text = gdk_rgba_copy(&(GdkRGBA) {0, 0, 0, 1});287 settings->priv->text = gdk_rgba_copy(&(GdkRGBA) {0, 0, 0, 1});
266 settings->priv->back = gdk_rgba_copy(&(GdkRGBA) {1, 0.933334350586, 0.6, 1});288 settings->priv->back = gdk_rgba_copy(&(GdkRGBA) {1, 0.933334350586, 0.6, 1});
267289
268 settings->priv->width = 200;
269 settings->priv->height = 200;
270 settings->priv->has_decorations = TRUE;
271 settings->priv->confirm_destroy = TRUE;
272 settings->priv->autostart_sticky = FALSE;
273 settings->priv->edit_lock = FALSE;
274 settings->priv->tray_click_configuration = 0;
275 settings->priv->fontname = NULL;
276 settings->priv->has_toolbar = TRUE;
277 settings->priv->autohide_toolbar = TRUE;
278 settings->priv->has_scrollbar = TRUE;
279
280 settings->priv->toolbar_buttons = NULL;290 settings->priv->toolbar_buttons = NULL;
281 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("New"));291 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("New"));
282 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("Delete"));292 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("Delete"));
@@ -288,11 +298,6 @@
288 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("Undo"));298 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("Undo"));
289 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("Redo")); 299 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup ("Redo"));
290300
291 settings->priv->autostart_wait_systray = TRUE;
292 settings->priv->autostart_delay = 0;
293 settings->priv->autostart_new_pad = FALSE;
294 settings->priv->autostart_display_pads = 2;
295
296 load_from_file (settings, DEFAULTS_FILENAME);301 load_from_file (settings, DEFAULTS_FILENAME);
297}302}
298303
@@ -313,163 +318,10 @@
313 gdk_rgba_free (settings->priv->text);318 gdk_rgba_free (settings->priv->text);
314 if (settings->priv->back)319 if (settings->priv->back)
315 gdk_rgba_free (settings->priv->back);320 gdk_rgba_free (settings->priv->back);
316
317 g_free (settings->priv->fontname);
318 321
319 G_OBJECT_CLASS (xpad_settings_parent_class)->finalize (object);322 G_OBJECT_CLASS (xpad_settings_parent_class)->finalize (object);
320}323}
321324
322void xpad_settings_set_width (XpadSettings *settings, guint width)
323{
324 if (settings->priv->width == width)
325 return;
326
327 settings->priv->width = width;
328
329 save_to_file (settings, DEFAULTS_FILENAME);
330
331 g_object_notify (G_OBJECT (settings), "width");
332}
333
334guint xpad_settings_get_width (XpadSettings *settings)
335{
336 return settings->priv->width;
337}
338
339void xpad_settings_set_height (XpadSettings *settings, guint height)
340{
341 if (settings->priv->height == height)
342 return;
343
344 settings->priv->height = height;
345
346 save_to_file (settings, DEFAULTS_FILENAME);
347
348 g_object_notify (G_OBJECT (settings), "height");
349}
350
351guint xpad_settings_get_height (XpadSettings *settings)
352{
353 return settings->priv->height;
354}
355
356void xpad_settings_set_has_decorations (XpadSettings *settings, gboolean decorations)
357{
358 if (settings->priv->has_decorations == decorations)
359 return;
360
361 settings->priv->has_decorations = decorations;
362
363 save_to_file (settings, DEFAULTS_FILENAME);
364
365 g_object_notify (G_OBJECT (settings), "has_decorations");
366}
367
368gboolean xpad_settings_get_has_decorations (XpadSettings *settings)
369{
370 return settings->priv->has_decorations;
371}
372
373void xpad_settings_set_confirm_destroy (XpadSettings *settings, gboolean confirm)
374{
375 if (settings->priv->confirm_destroy == confirm)
376 return;
377
378 settings->priv->confirm_destroy = confirm;
379
380 save_to_file (settings, DEFAULTS_FILENAME);
381
382 g_object_notify (G_OBJECT (settings), "confirm_destroy");
383}
384
385gboolean xpad_settings_get_confirm_destroy (XpadSettings *settings)
386{
387 return settings->priv->confirm_destroy;
388}
389
390void xpad_settings_set_edit_lock (XpadSettings *settings, gboolean lock)
391{
392 if (settings->priv->edit_lock == lock)
393 return;
394
395 settings->priv->edit_lock = lock;
396
397 save_to_file (settings, DEFAULTS_FILENAME);
398
399 g_object_notify (G_OBJECT (settings), "edit_lock");
400}
401
402gboolean xpad_settings_get_edit_lock (XpadSettings *settings)
403{
404 return settings->priv->edit_lock;
405}
406
407void xpad_settings_set_tray_click_handler (XpadSettings *settings, guint conf)
408{
409 if (settings->priv->tray_click_configuration == conf)
410 return;
411
412 settings->priv->tray_click_configuration = conf;
413 save_to_file(settings, DEFAULTS_FILENAME);
414 g_object_notify (G_OBJECT (settings), "tray_click_configuration");
415}
416
417guint xpad_settings_get_tray_click_handler(XpadSettings *settings)
418{
419 return settings->priv->tray_click_configuration;
420}
421
422void xpad_settings_set_has_toolbar (XpadSettings *settings, gboolean toolbar)
423{
424 if (settings->priv->has_toolbar == toolbar)
425 return;
426
427 settings->priv->has_toolbar = toolbar;
428
429 save_to_file (settings, DEFAULTS_FILENAME);
430
431 g_object_notify (G_OBJECT (settings), "has_toolbar");
432}
433
434gboolean xpad_settings_get_has_toolbar (XpadSettings *settings)
435{
436 return settings->priv->has_toolbar;
437}
438
439void xpad_settings_set_autohide_toolbar (XpadSettings *settings, gboolean hide)
440{
441 if (settings->priv->autohide_toolbar == hide)
442 return;
443
444 settings->priv->autohide_toolbar = hide;
445
446 save_to_file (settings, DEFAULTS_FILENAME);
447
448 g_object_notify (G_OBJECT (settings), "autohide_toolbar");
449}
450
451gboolean xpad_settings_get_autohide_toolbar (XpadSettings *settings)
452{
453 return settings->priv->autohide_toolbar;
454}
455
456void xpad_settings_set_has_scrollbar (XpadSettings *settings, gboolean scrollbar)
457{
458 if (settings->priv->has_scrollbar == scrollbar)
459 return;
460
461 settings->priv->has_scrollbar = scrollbar;
462
463 save_to_file (settings, DEFAULTS_FILENAME);
464
465 g_object_notify (G_OBJECT (settings), "has_scrollbar");
466}
467
468gboolean xpad_settings_get_has_scrollbar (XpadSettings *settings)
469{
470 return settings->priv->has_scrollbar;
471}
472
473void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button)325void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button)
474{326{
475 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup (button));327 settings->priv->toolbar_buttons = g_slist_append (settings->priv->toolbar_buttons, g_strdup (button));
@@ -530,313 +382,254 @@
530 return settings->priv->toolbar_buttons;382 return settings->priv->toolbar_buttons;
531}383}
532384
533void xpad_settings_set_back_color (XpadSettings *settings, const GdkRGBA *back)
534{
535 if (settings->priv->back)
536 gdk_rgba_free (settings->priv->back);
537
538 if (back)
539 settings->priv->back = gdk_rgba_copy (back);
540 else
541 settings->priv->back = NULL;
542
543 save_to_file (settings, DEFAULTS_FILENAME);
544
545 g_object_notify (G_OBJECT (settings), "back_color");
546}
547
548const GdkRGBA *xpad_settings_get_back_color (XpadSettings *settings)
549{
550 return settings->priv->back;
551}
552
553void xpad_settings_set_text_color (XpadSettings *settings, const GdkRGBA *text)
554{
555 if (settings->priv->text)
556 gdk_rgba_free (settings->priv->text);
557
558 if (text)
559 settings->priv->text = gdk_rgba_copy (text);
560 else
561 settings->priv->text = NULL;
562
563 save_to_file (settings, DEFAULTS_FILENAME);
564
565 g_object_notify (G_OBJECT (settings), "text_color");
566}
567
568const GdkRGBA *xpad_settings_get_text_color (XpadSettings *settings)
569{
570 return settings->priv->text;
571}
572
573void xpad_settings_set_fontname (XpadSettings *settings, const gchar *fontname)
574{
575 g_free (settings->priv->fontname);
576 settings->priv->fontname = g_strdup (fontname);
577
578 save_to_file (settings, DEFAULTS_FILENAME);
579
580 g_object_notify (G_OBJECT (settings), "fontname");
581}
582
583const gchar *xpad_settings_get_fontname (XpadSettings *settings)
584{
585 return settings->priv->fontname;
586}
587
588gboolean xpad_settings_get_autostart_xpad (XpadSettings *settings)
589{
590 /* The existence of the xpad.desktop file in the autostart folder defines if autostarting is enabled or disabled */
591 const gchar *filename = g_strdup_printf ("%s/.config/autostart/xpad.desktop", g_getenv ("HOME"));
592 return g_file_test (filename, G_FILE_TEST_EXISTS);
593}
594
595void xpad_settings_set_autostart_wait_systray (XpadSettings *settings, gboolean conf)
596{
597 if (settings->priv->autostart_wait_systray == conf)
598 return;
599
600 settings->priv->autostart_wait_systray = conf;
601 save_to_file (settings, DEFAULTS_FILENAME);
602 g_object_notify (G_OBJECT (settings), "autostart_wait_systray");
603}
604
605gboolean xpad_settings_get_autostart_wait_systray (XpadSettings *settings)
606{
607 return settings->priv->autostart_wait_systray;
608}
609
610void xpad_settings_set_autostart_delay (XpadSettings *settings, guint conf)
611{
612 if (settings->priv->autostart_delay == conf)
613 return;
614
615 settings->priv->autostart_delay = conf;
616 save_to_file(settings, DEFAULTS_FILENAME);
617 g_object_notify (G_OBJECT (settings), "autostart_delay");
618}
619
620guint xpad_settings_get_autostart_delay (XpadSettings *settings)
621{
622 return settings->priv->autostart_delay;
623}
624
625void xpad_settings_set_autostart_new_pad (XpadSettings *settings, gboolean conf)
626{
627 if (settings->priv->autostart_new_pad == conf)
628 return;
629
630 settings->priv->autostart_new_pad = conf;
631 save_to_file (settings, DEFAULTS_FILENAME);
632 g_object_notify (G_OBJECT (settings), "autostart_new_pad");
633}
634
635gboolean xpad_settings_get_autostart_new_pad (XpadSettings *settings)
636{
637 return settings->priv->autostart_new_pad;
638}
639
640void xpad_settings_set_autostart_sticky (XpadSettings *settings, gboolean sticky)
641{
642 if (settings->priv->autostart_sticky == sticky)
643 return;
644
645 settings->priv->autostart_sticky = sticky;
646 save_to_file (settings, DEFAULTS_FILENAME);
647 g_object_notify (G_OBJECT (settings), "autostart_sticky");
648}
649
650gboolean xpad_settings_get_autostart_sticky (XpadSettings *settings)
651{
652 return settings->priv->autostart_sticky;
653}
654
655void xpad_settings_set_autostart_display_pads (XpadSettings *settings, guint conf)
656{
657 if (settings->priv->autostart_display_pads == conf)
658 return;
659
660 settings->priv->autostart_display_pads = conf;
661 save_to_file (settings, DEFAULTS_FILENAME);
662 g_object_notify (G_OBJECT (settings), "autostart_display_pads");
663}
664
665guint xpad_settings_get_autostart_display_pads(XpadSettings *settings)
666{
667 return settings->priv->autostart_display_pads;
668}
669
670static void385static void
671xpad_settings_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)386xpad_settings_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
672{387{
673 XpadSettings *settings;388 XpadSettings *settings = XPAD_SETTINGS (object);
674
675 settings = XPAD_SETTINGS (object);
676 389
677 switch (prop_id)390 switch (prop_id)
678 {391 {
392 case PROP_WIDTH:
393 settings->priv->width = g_value_get_uint (value);
394 break;
395
679 case PROP_HEIGHT:396 case PROP_HEIGHT:
680 xpad_settings_set_height (settings, g_value_get_uint (value));397 settings->priv->height = g_value_get_uint (value);
681 break;
682
683 case PROP_WIDTH:
684 xpad_settings_set_width (settings, g_value_get_uint (value));
685 break;398 break;
686 399
687 case PROP_HAS_DECORATIONS:400 case PROP_HAS_DECORATIONS:
688 xpad_settings_set_has_decorations (settings, g_value_get_boolean (value));401 settings->priv->has_decorations = g_value_get_boolean (value);
689 break;402 break;
690 403
691 case PROP_CONFIRM_DESTROY:404 case PROP_CONFIRM_DESTROY:
692 xpad_settings_set_confirm_destroy (settings, g_value_get_boolean (value));405 settings->priv->confirm_destroy = g_value_get_boolean (value);
693 break;406 break;
694 407
695 case PROP_EDIT_LOCK:408 case PROP_EDIT_LOCK:
696 xpad_settings_set_edit_lock (settings, g_value_get_boolean (value));409 settings->priv->edit_lock = g_value_get_boolean (value);
697 break;410 break;
698 411
412 case PROP_TRAY_ENABLED:
413 settings->priv->tray_enabled = g_value_get_boolean (value);
414 break;
415
699 case PROP_TRAY_CLICK_CONFIGURATION:416 case PROP_TRAY_CLICK_CONFIGURATION:
700 xpad_settings_set_tray_click_handler(settings, g_value_get_uint(value));417 settings->priv->tray_click_configuration = g_value_get_uint(value);
701 break;418 break;
702 419
703 case PROP_HAS_TOOLBAR:420 case PROP_HAS_TOOLBAR:
704 xpad_settings_set_has_toolbar (settings, g_value_get_boolean (value));421 settings->priv->has_toolbar = g_value_get_boolean (value);
705 break;422 break;
706 423
707 case PROP_AUTOHIDE_TOOLBAR:424 case PROP_AUTOHIDE_TOOLBAR:
708 xpad_settings_set_autohide_toolbar (settings, g_value_get_boolean (value));425 settings->priv->autohide_toolbar = g_value_get_boolean (value);
709 break;426 break;
710 427
711 case PROP_HAS_SCROLLBAR:428 case PROP_HAS_SCROLLBAR:
712 xpad_settings_set_has_scrollbar (settings, g_value_get_boolean (value));429 settings->priv->has_scrollbar = g_value_get_boolean (value);
713 break;430 break;
714 431
432 case PROP_TEXT_COLOR:
433 if (settings->priv->text)
434 gdk_rgba_free (settings->priv->text);
435 if (g_value_get_boxed (value))
436 settings->priv->text = gdk_rgba_copy (g_value_get_boxed (value));
437 else
438 settings->priv->text = NULL;
439 break;
440
715 case PROP_BACK_COLOR:441 case PROP_BACK_COLOR:
716 xpad_settings_set_back_color (settings, g_value_get_boxed (value));442 if (settings->priv->back)
717 break;443 gdk_rgba_free (settings->priv->back);
718 444 if (g_value_get_boxed (value))
719 case PROP_TEXT_COLOR:445 settings->priv->back = gdk_rgba_copy (g_value_get_boxed (value));
720 xpad_settings_set_text_color (settings, g_value_get_boxed (value));446 else
721 break;447 settings->priv->back = NULL;
722 448 break;
449
723 case PROP_FONTNAME:450 case PROP_FONTNAME:
724 xpad_settings_set_fontname (settings, g_value_get_string (value));451 if (value)
452 settings->priv->fontname = g_value_dup_string (value);
453 else
454 settings->priv->fontname = NULL;
455 break;
456
457 case PROP_AUTOSTART_XPAD:
458 if (g_value_get_boolean (value)) {
459 /* Copy the xpad.desktop file to the autostart folder and enable/disable the wait for systray preference */
460 gboolean success;
461 char *source_filename, *destination_directory;
462 GFile *source, *destination;
463 GError *error = NULL;
464
465 /* Find the base directory where the application is installed /usr or /usr/local, to find the correct xpad.desktop file. */
466 const char *program_path = xpad_app_get_program_path();
467
468 if (!program_path)
469 xpad_app_error (NULL, _("Error enabling Xpad autostart"), g_strdup_printf (_("Could not find the directory where Xpad is installed\n%s"), error->message));
470 else {
471 size_t len = strlen(program_path);
472 char basedir[len-8];
473 guint i;
474 for (i=0; i<len-8; i++)
475 basedir[i] = program_path[i];
476 basedir[len-9] = '\0';
477
478 source_filename = g_strdup_printf ("%s/share/applications/xpad.desktop", basedir);
479 destination_directory = g_strdup_printf ("%s/.config/autostart/xpad.desktop", g_getenv ("HOME"));
480
481 source = g_file_new_for_path (source_filename);
482 destination = g_file_new_for_path (destination_directory);
483 success = g_file_copy (source, destination, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error);
484
485 if (!success)
486 xpad_app_error (NULL, _("Error enabling Xpad autostart"), g_strdup_printf (_("Could not copy %s to %s\n%s"), source_filename, destination_directory, error->message));
487 }
488 }
489 else {
490 /* Remove the xpad.desktop file from the autostart folder and enable/disable the wait for systray preference */
491 gboolean success;
492 char *filename;
493 GFile *file;
494 GError *error = NULL;
495
496 filename = g_strdup_printf ("%s/.config/autostart/xpad.desktop", g_getenv ("HOME"));
497 file = g_file_new_for_path (filename);
498 success = g_file_delete (file, NULL, &error);
499
500 if (!success)
501 xpad_app_error (NULL, _("Error disabling Xpad autostart"), g_strdup_printf (_("Could not delete %s\n%s"), filename, error->message));
502 }
725 break;503 break;
726504
727 case PROP_AUTOSTART_WAIT_SYSTRAY:505 case PROP_AUTOSTART_WAIT_SYSTRAY:
728 xpad_settings_set_autostart_wait_systray (settings, g_value_get_boolean (value));506 settings->priv->autostart_wait_systray = g_value_get_boolean (value);
729 break;
730
731 case PROP_AUTOSTART_DELAY:
732 xpad_settings_set_autostart_delay (settings, g_value_get_uint (value));
733 break;507 break;
734508
735 case PROP_AUTOSTART_NEW_PAD:509 case PROP_AUTOSTART_NEW_PAD:
736 xpad_settings_set_autostart_new_pad (settings, g_value_get_boolean (value));510 settings->priv->autostart_new_pad = g_value_get_boolean (value);
737 break;511 break;
738512
739 case PROP_AUTOSTART_STICKY:513 case PROP_AUTOSTART_STICKY:
740 xpad_settings_set_autostart_sticky (settings, g_value_get_boolean (value));514 settings->priv->autostart_sticky = g_value_get_boolean (value);
741 break;515 break;
742 516
517 case PROP_AUTOSTART_DELAY:
518 settings->priv->autostart_delay = g_value_get_uint (value);
519 break;
520
743 case PROP_AUTOSTART_DISPLAY_PADS:521 case PROP_AUTOSTART_DISPLAY_PADS:
744 xpad_settings_set_autostart_display_pads (settings, g_value_get_uint (value));522 settings->priv->autostart_display_pads = g_value_get_uint (value);
745 break;523 break;
746 524
747 default:525 default:
748 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);526 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
749 break;527 return;
750 }528 }
529 save_to_file (settings, DEFAULTS_FILENAME);
751}530}
752531
753static void532static void
754xpad_settings_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)533xpad_settings_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
755{534{
756 XpadSettings *settings;535 XpadSettings *settings = XPAD_SETTINGS (object);
757
758 settings = XPAD_SETTINGS (object);
759 536
760 switch (prop_id)537 switch (prop_id)
761 {538 {
539 case PROP_WIDTH:
540 g_value_set_uint (value, settings->priv->width);
541 break;
542
762 case PROP_HEIGHT:543 case PROP_HEIGHT:
763 g_value_set_uint (value, xpad_settings_get_height (settings));544 g_value_set_uint (value, settings->priv->height);
764 break;
765
766 case PROP_WIDTH:
767 g_value_set_uint (value, xpad_settings_get_width (settings));
768 break;545 break;
769 546
770 case PROP_HAS_DECORATIONS:547 case PROP_HAS_DECORATIONS:
771 g_value_set_boolean (value, xpad_settings_get_has_decorations (settings));548 g_value_set_boolean (value, settings->priv->has_decorations);
772 break;549 break;
773 550
774 case PROP_CONFIRM_DESTROY:551 case PROP_CONFIRM_DESTROY:
775 g_value_set_boolean (value, xpad_settings_get_confirm_destroy (settings));552 g_value_set_boolean (value, settings->priv->confirm_destroy);
776 break;553 break;
777 554
778 case PROP_EDIT_LOCK:555 case PROP_EDIT_LOCK:
779 g_value_set_boolean (value, xpad_settings_get_edit_lock (settings));556 g_value_set_boolean (value, settings->priv->edit_lock);
780 break;557 break;
781 558
559 case PROP_TRAY_ENABLED:
560 g_value_set_boolean (value, settings->priv->tray_enabled);
561 break;
562
563 case PROP_TRAY_CLICK_CONFIGURATION:
564 g_value_set_uint (value, settings->priv->tray_click_configuration);
565 break;
566
782 case PROP_HAS_TOOLBAR:567 case PROP_HAS_TOOLBAR:
783 g_value_set_boolean (value, xpad_settings_get_has_toolbar (settings));568 g_value_set_boolean (value, settings->priv->has_toolbar);
784 break;569 break;
785 570
786 case PROP_AUTOHIDE_TOOLBAR:571 case PROP_AUTOHIDE_TOOLBAR:
787 g_value_set_boolean (value, xpad_settings_get_autohide_toolbar (settings));572 g_value_set_boolean (value, settings->priv->autohide_toolbar);
788 break;573 break;
789 574
790 case PROP_HAS_SCROLLBAR:575 case PROP_HAS_SCROLLBAR:
791 g_value_set_boolean (value, xpad_settings_get_has_scrollbar (settings));576 g_value_set_boolean (value, settings->priv->has_scrollbar);
577 break;
578
579 case PROP_TEXT_COLOR:
580 if (settings->priv->text)
581 g_value_set_static_boxed (value, settings->priv->text);
582 else
583 value = NULL;
792 break;584 break;
793 585
794 case PROP_BACK_COLOR:586 case PROP_BACK_COLOR:
795 g_value_set_static_boxed (value, xpad_settings_get_back_color (settings));587 if (settings->priv->back)
796 break;588 g_value_set_static_boxed (value, settings->priv->back);
797 589 else
798 case PROP_TEXT_COLOR:590 value = NULL;
799 g_value_set_static_boxed (value, xpad_settings_get_text_color (settings));
800 break;591 break;
801 592
802 case PROP_FONTNAME:593 case PROP_FONTNAME:
803 g_value_set_string (value, xpad_settings_get_fontname (settings));594 if (settings->priv->fontname)
595 g_value_set_string (value, settings->priv->fontname);
596 else
597 value = NULL;
598 break;
599
600 case PROP_AUTOSTART_XPAD:
601 g_value_set_boolean (value, g_file_test (g_strdup_printf ("%s/.config/autostart/xpad.desktop", g_getenv ("HOME")), G_FILE_TEST_EXISTS));
804 break;602 break;
805603
806 case PROP_AUTOSTART_WAIT_SYSTRAY:604 case PROP_AUTOSTART_WAIT_SYSTRAY:
807 g_value_set_boolean (value, xpad_settings_get_autostart_wait_systray (settings));605 g_value_set_boolean (value, settings->priv->autostart_wait_systray);
808 break;
809
810 case PROP_AUTOSTART_DELAY:
811 g_value_set_uint (value, xpad_settings_get_autostart_delay (settings));
812 break;606 break;
813 607
814 case PROP_AUTOSTART_NEW_PAD:608 case PROP_AUTOSTART_NEW_PAD:
815 g_value_set_boolean (value, xpad_settings_get_autostart_new_pad (settings));609 g_value_set_boolean (value, settings->priv->autostart_new_pad);
816 break;610 break;
817 611
818 case PROP_AUTOSTART_STICKY:612 case PROP_AUTOSTART_STICKY:
819 g_value_set_boolean (value, xpad_settings_get_autostart_sticky (settings));613 g_value_set_boolean (value, settings->priv->autostart_sticky);
820 break;614 break;
821 615
616 case PROP_AUTOSTART_DELAY:
617 g_value_set_uint (value, settings->priv->autostart_delay);
618 break;
619
822 case PROP_AUTOSTART_DISPLAY_PADS:620 case PROP_AUTOSTART_DISPLAY_PADS:
823 g_value_set_uint (value, xpad_settings_get_autostart_display_pads (settings));621 g_value_set_uint (value, settings->priv->autostart_display_pads);
824 break;622 break;
825 623
826 default:624 default:
827 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);625 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
828 break;626 return;
829 }627 }
830}628}
831629
832static void630static void
833load_from_file (XpadSettings *settings, const gchar *filename)631load_from_file (XpadSettings *settings, const gchar *filename)
834{632{
835 /**
836 * We need to set up int values for all these to take the value from the file.
837 * These will be assigned back to the appropriate values after load.
838 */
839
840 gchar *buttons = NULL;633 gchar *buttons = NULL;
841 gchar *text_color_string = NULL;634 gchar *text_color_string = NULL;
842 gchar *background_color_string = NULL;635 gchar *background_color_string = NULL;
@@ -860,6 +653,7 @@
860 "b|confirm_destroy", &settings->priv->confirm_destroy,653 "b|confirm_destroy", &settings->priv->confirm_destroy,
861 "b|edit_lock", &settings->priv->edit_lock,654 "b|edit_lock", &settings->priv->edit_lock,
862 "b|sticky_on_start", &settings->priv->autostart_sticky,655 "b|sticky_on_start", &settings->priv->autostart_sticky,
656 "b|tray_enabled", &settings->priv->tray_enabled,
863 "u|tray_click_configuration", &settings->priv->tray_click_configuration,657 "u|tray_click_configuration", &settings->priv->tray_click_configuration,
864 "s|back", &background_color_string,658 "s|back", &background_color_string,
865 "b|use_back", &use_back,659 "b|use_back", &use_back,
@@ -877,8 +671,7 @@
877 NULL))671 NULL))
878 return;672 return;
879673
880 if (use_text)674 if (use_text) {
881 {
882 gdk_rgba_free (settings->priv->text);675 gdk_rgba_free (settings->priv->text);
883676
884 /*677 /*
@@ -886,15 +679,12 @@
886 * (for example due to the migration to the new GdkRGBA colors),679 * (for example due to the migration to the new GdkRGBA colors),
887 * set the color to the default.680 * set the color to the default.
888 */681 */
889 if (text_color_string == NULL) {682 if (text_color_string == NULL)
890 text = (GdkRGBA) {0, 0, 0, 1};683 text = (GdkRGBA) {0, 0, 0, 1};
891 }684 else
892 else {
893 /* If, for some reason, the parsing of the colors fail, set the color to the default. */685 /* If, for some reason, the parsing of the colors fail, set the color to the default. */
894 if (!gdk_rgba_parse (&text, text_color_string)) {686 if (!gdk_rgba_parse (&text, text_color_string))
895 text = (GdkRGBA) {0, 0, 0, 1};687 text = (GdkRGBA) {0, 0, 0, 1};
896 }
897 }
898688
899 settings->priv->text = gdk_rgba_copy (&text);689 settings->priv->text = gdk_rgba_copy (&text);
900 }690 }
@@ -906,15 +696,12 @@
906 * (for example due to the migration to the new GdkRGBA colors),696 * (for example due to the migration to the new GdkRGBA colors),
907 * set the color to the default.697 * set the color to the default.
908 */698 */
909 if (background_color_string == NULL) {699 if (background_color_string == NULL)
910 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};700 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
911 }701 else
912 else {
913 /* If, for some reason, the parsing of the colors fail, set the color to the default. */702 /* If, for some reason, the parsing of the colors fail, set the color to the default. */
914 if (!gdk_rgba_parse (&back, background_color_string)) {703 if (!gdk_rgba_parse (&back, background_color_string))
915 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};704 back = (GdkRGBA) {1, 0.933334350586, 0.6, 1};
916 }
917 }
918705
919 settings->priv->back = gdk_rgba_copy (&back);706 settings->priv->back = gdk_rgba_copy (&back);
920 }707 }
@@ -922,10 +709,7 @@
922 settings->priv->back = NULL;709 settings->priv->back = NULL;
923710
924 if (settings->priv->fontname && strcmp (settings->priv->fontname, "NULL") == 0)711 if (settings->priv->fontname && strcmp (settings->priv->fontname, "NULL") == 0)
925 {
926 g_free (settings->priv->fontname);
927 settings->priv->fontname = NULL;712 settings->priv->fontname = NULL;
928 }
929 713
930 if (buttons)714 if (buttons)
931 {715 {
@@ -943,11 +727,9 @@
943 }727 }
944 728
945 for (i = 0; button_names[i]; ++i)729 for (i = 0; button_names[i]; ++i)
946 {
947 settings->priv->toolbar_buttons = 730 settings->priv->toolbar_buttons =
948 g_slist_append (settings->priv->toolbar_buttons,731 g_slist_append (settings->priv->toolbar_buttons,
949 g_strstrip (button_names[i])); /* takes ownership of string */732 g_strstrip (button_names[i])); /* takes ownership of string */
950 }
951 733
952 g_free (button_names);734 g_free (button_names);
953 g_free (buttons);735 g_free (buttons);
@@ -983,6 +765,7 @@
983 "b|confirm_destroy", settings->priv->confirm_destroy,765 "b|confirm_destroy", settings->priv->confirm_destroy,
984 "b|edit_lock", settings->priv->edit_lock,766 "b|edit_lock", settings->priv->edit_lock,
985 "b|sticky_on_start", settings->priv->autostart_sticky,767 "b|sticky_on_start", settings->priv->autostart_sticky,
768 "b|tray_enabled", settings->priv->tray_enabled,
986 "u|tray_click_configuration", settings->priv->tray_click_configuration,769 "u|tray_click_configuration", settings->priv->tray_click_configuration,
987 "s|back", settings->priv->back ? gdk_rgba_to_string (settings->priv->back) : "NULL",770 "s|back", settings->priv->back ? gdk_rgba_to_string (settings->priv->back) : "NULL",
988 "b|use_back", settings->priv->back ? TRUE : FALSE,771 "b|use_back", settings->priv->back ? TRUE : FALSE,
989772
=== modified file 'src/xpad-settings.h'
--- src/xpad-settings.h 2014-06-07 00:19:07 +0000
+++ src/xpad-settings.h 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@
21#ifndef __XPAD_SETTINGS_H__22#ifndef __XPAD_SETTINGS_H__
22#define __XPAD_SETTINGS_H__23#define __XPAD_SETTINGS_H__
2324
24#include <gtk/gtk.h>25#include <glib.h>
2526
26G_BEGIN_DECLS27G_BEGIN_DECLS
2728
@@ -54,65 +55,11 @@
5455
55XpadSettings *xpad_settings_new (void);56XpadSettings *xpad_settings_new (void);
5657
57void xpad_settings_set_width (XpadSettings *settings, guint width);
58guint xpad_settings_get_width (XpadSettings *settings);
59
60void xpad_settings_set_height (XpadSettings *settings, guint height);
61guint xpad_settings_get_height (XpadSettings *settings);
62
63void xpad_settings_set_has_decorations (XpadSettings *settings, gboolean decorations);
64gboolean xpad_settings_get_has_decorations (XpadSettings *settings);
65
66void xpad_settings_set_confirm_destroy (XpadSettings *settings, gboolean confirm);
67gboolean xpad_settings_get_confirm_destroy (XpadSettings *settings);
68
69void xpad_settings_set_edit_lock (XpadSettings *settings, gboolean lock);
70gboolean xpad_settings_get_edit_lock (XpadSettings *settings);
71
72void xpad_settings_set_has_toolbar (XpadSettings *settings, gboolean toolbar);
73gboolean xpad_settings_get_has_toolbar (XpadSettings *settings);
74
75void xpad_settings_set_autohide_toolbar (XpadSettings *settings, gboolean hide);
76gboolean xpad_settings_get_autohide_toolbar (XpadSettings *settings);
77
78void xpad_settings_set_has_scrollbar (XpadSettings *settings, gboolean scrollbar);
79gboolean xpad_settings_get_has_scrollbar (XpadSettings *settings);
80
81void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button);58void xpad_settings_add_toolbar_button (XpadSettings *settings, const gchar *button);
82gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings);59gboolean xpad_settings_remove_all_toolbar_buttons (XpadSettings *settings);
83gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);60gboolean xpad_settings_remove_last_toolbar_button (XpadSettings *settings);
84const GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);61const GSList *xpad_settings_get_toolbar_buttons (XpadSettings *settings);
8562
86void xpad_settings_set_back_color (XpadSettings *settings, const GdkRGBA *back);
87const GdkRGBA *xpad_settings_get_back_color (XpadSettings *settings);
88
89void xpad_settings_set_text_color (XpadSettings *settings, const GdkRGBA *text);
90const GdkRGBA *xpad_settings_get_text_color (XpadSettings *settings);
91
92void xpad_settings_set_fontname (XpadSettings *settings, const gchar *fontname);
93const gchar *xpad_settings_get_fontname (XpadSettings *settings);
94
95void xpad_settings_set_tray_click_handler (XpadSettings *settings, guint conf);
96guint xpad_settings_get_tray_click_handler (XpadSettings *settings);
97
98void xpad_settings_set_autostart_xpad (XpadSettings *settings, gboolean conf);
99gboolean xpad_settings_get_autostart_xpad (XpadSettings *settings);
100
101void xpad_settings_set_autostart_wait_systray (XpadSettings *settings, gboolean conf);
102gboolean xpad_settings_get_autostart_wait_systray (XpadSettings *settings);
103
104void xpad_settings_set_autostart_delay (XpadSettings *settings, guint conf);
105guint xpad_settings_get_autostart_delay (XpadSettings *settings);
106
107void xpad_settings_set_autostart_new_pad (XpadSettings *settings, gboolean conf);
108gboolean xpad_settings_get_autostart_new_pad (XpadSettings *settings);
109
110void xpad_settings_set_autostart_sticky (XpadSettings *settings, gboolean conf);
111gboolean xpad_settings_get_autostart_sticky (XpadSettings *settings);
112
113void xpad_settings_set_autostart_display_pads (XpadSettings *settings, guint conf);
114guint xpad_settings_get_autostart_display_pads (XpadSettings *settings);
115
116G_END_DECLS63G_END_DECLS
11764
118#endif /* __XPAD_SETTINGS_H__ */65#endif /* __XPAD_SETTINGS_H__ */
11966
=== modified file 'src/xpad-text-buffer.c'
--- src/xpad-text-buffer.c 2013-11-01 20:16:37 +0000
+++ src/xpad-text-buffer.c 2014-06-13 15:52:27 +0000
@@ -1,26 +1,27 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * Copyright (c) 2011 Sergei Riaguzov3Copyright (c) 2001-2007 Michael Terry
4 * 4Copyright (c) 2011 Sergei Riaguzov
5 * This program is free software; you can redistribute it and/or modify5Copyright (c) 2013-2014 Arthur Borsboom
6 * it under the terms of the GNU General Public License as published by6
7 * the Free Software Foundation; either version 3 of the License, or7This program is free software; you can redistribute it and/or modify
8 * (at your option) any later version.8it under the terms of the GNU General Public License as published by
9 * 9the Free Software Foundation; either version 3 of the License, or
10 * This program is distributed in the hope that it will be useful,10(at your option) any later version.
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of11
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12This program is distributed in the hope that it will be useful,
13 * GNU General Public License for more details.13but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * You should have received a copy of the GNU General Public License15GNU General Public License for more details.
16 * along with this program; if not, write to the Free Software16
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17You should have received a copy of the GNU General Public License
18 */18along with this program; if not, write to the Free Software
1919Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20#include "../config.h"20
21#include "xpad-text-buffer.h"21*/
22
23#include "xpad-pad.h"
22#include "xpad-undo.h"24#include "xpad-undo.h"
23#include "xpad-pad.h"
2425
25struct XpadTextBufferPrivate 26struct XpadTextBufferPrivate
26{27{
2728
=== modified file 'src/xpad-text-buffer.h'
--- src/xpad-text-buffer.h 2013-10-18 18:31:20 +0000
+++ src/xpad-text-buffer.h 2014-06-13 15:52:27 +0000
@@ -1,26 +1,28 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * Copyright (c) 2011 Sergei Riaguzov3Copyright (c) 2001-2007 Michael Terry
4 * 4Copyright (c) 2011 Sergei Riaguzov
5 * This program is free software; you can redistribute it and/or modify5Copyright (c) 2013-2014 Arthur Borsboom
6 * it under the terms of the GNU General Public License as published by6
7 * the Free Software Foundation; either version 3 of the License, or7This program is free software; you can redistribute it and/or modify
8 * (at your option) any later version.8it under the terms of the GNU General Public License as published by
9 * 9the Free Software Foundation; either version 3 of the License, or
10 * This program is distributed in the hope that it will be useful,10(at your option) any later version.
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of11
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12This program is distributed in the hope that it will be useful,
13 * GNU General Public License for more details.13but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * You should have received a copy of the GNU General Public License15GNU General Public License for more details.
16 * along with this program; if not, write to the Free Software16
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17You should have received a copy of the GNU General Public License
18 */18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21*/
1922
20#ifndef __XPAD_TEXT_BUFFER_H__23#ifndef __XPAD_TEXT_BUFFER_H__
21#define __XPAD_TEXT_BUFFER_H__24#define __XPAD_TEXT_BUFFER_H__
2225
23#include <gtk/gtk.h>
24#include "xpad-pad.h"26#include "xpad-pad.h"
2527
26G_BEGIN_DECLS28G_BEGIN_DECLS
@@ -39,8 +41,6 @@
39struct XpadTextBuffer41struct XpadTextBuffer
40{42{
41 GtkTextBuffer parent;43 GtkTextBuffer parent;
42
43 /* private */
44 XpadTextBufferPrivate *priv;44 XpadTextBufferPrivate *priv;
45};45};
4646
4747
=== modified file 'src/xpad-text-view.c'
--- src/xpad-text-view.c 2014-06-04 15:59:25 +0000
+++ src/xpad-text-view.c 2014-06-13 15:52:27 +0000
@@ -1,25 +1,27 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * 3Copyright (c) 2001-2007 Michael Terry
4 * This program is free software; you can redistribute it and/or modify4Copyright (c) 2013-2014 Arthur Borsboom
5 * it under the terms of the GNU General Public License as published by5
6 * the Free Software Foundation; either version 3 of the License, or6This program is free software; you can redistribute it and/or modify
7 * (at your option) any later version.7it under the terms of the GNU General Public License as published by
8 * 8the Free Software Foundation; either version 3 of the License, or
9 * This program is distributed in the hope that it will be useful,9(at your option) any later version.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11This program is distributed in the hope that it will be useful,
12 * GNU General Public License for more details.12but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * You should have received a copy of the GNU General Public License14GNU General Public License for more details.
15 * along with this program; if not, write to the Free Software15
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16You should have received a copy of the GNU General Public License
17 */17along with this program; if not, write to the Free Software
1818Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19#include "../config.h"19
20*/
21
22#include <gtk/gtk.h>
20#include "xpad-text-view.h"23#include "xpad-text-view.h"
21#include "xpad-text-buffer.h"24#include "xpad-text-buffer.h"
22#include "xpad-settings.h"
23#include "xpad-app.h"25#include "xpad-app.h"
2426
25struct XpadTextViewPrivate 27struct XpadTextViewPrivate
@@ -117,7 +119,6 @@
117 view->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);119 view->priv->notify_font_handler = g_signal_connect_swapped (xpad_global_settings, "notify::fontname", G_CALLBACK (xpad_text_view_notify_fontname), view);
118 view->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (xpad_text_view_notify_colors), view);120 view->priv->notify_text_handler = g_signal_connect_swapped (xpad_global_settings, "notify::text-color", G_CALLBACK (xpad_text_view_notify_colors), view);
119 view->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (xpad_text_view_notify_colors), view);121 view->priv->notify_back_handler = g_signal_connect_swapped (xpad_global_settings, "notify::back-color", G_CALLBACK (xpad_text_view_notify_colors), view);
120
121 xpad_text_view_notify_colors (view);122 xpad_text_view_notify_colors (view);
122 xpad_text_view_notify_fontname (view);123 xpad_text_view_notify_fontname (view);
123}124}
@@ -147,7 +148,9 @@
147static void148static void
148xpad_text_view_realize (XpadTextView *view)149xpad_text_view_realize (XpadTextView *view)
149{150{
150 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_global_settings));151 gboolean edit_lock;
152 g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
153 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !edit_lock);
151}154}
152155
153static gboolean156static gboolean
@@ -156,7 +159,10 @@
156 /* A dirty way to silence the compiler for these unused variables. */159 /* A dirty way to silence the compiler for these unused variables. */
157 (void) event;160 (void) event;
158161
159 if (xpad_settings_get_edit_lock (xpad_global_settings))162 gboolean edit_lock;
163 g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
164
165 if (edit_lock)
160 {166 {
161 gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), FALSE);167 gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), FALSE);
162 return TRUE;168 return TRUE;
@@ -168,8 +174,11 @@
168static gboolean174static gboolean
169xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)175xpad_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
170{176{
177 gboolean edit_lock;
178 g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
179
171 if (event->button == 1 &&180 if (event->button == 1 &&
172 xpad_settings_get_edit_lock (xpad_global_settings) &&181 edit_lock &&
173 !gtk_text_view_get_editable (GTK_TEXT_VIEW (widget)))182 !gtk_text_view_get_editable (GTK_TEXT_VIEW (widget)))
174 {183 {
175 if (event->type == GDK_2BUTTON_PRESS)184 if (event->type == GDK_2BUTTON_PRESS)
@@ -191,7 +200,9 @@
191xpad_text_view_notify_edit_lock (XpadTextView *view)200xpad_text_view_notify_edit_lock (XpadTextView *view)
192{201{
193 /* chances are good that they don't have the text view focused while it changed, so make non-editable if edit lock turned on */202 /* chances are good that they don't have the text view focused while it changed, so make non-editable if edit lock turned on */
194 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !xpad_settings_get_edit_lock (xpad_global_settings));203 gboolean edit_lock;
204 g_object_get (xpad_global_settings, "edit-lock", &edit_lock, NULL);
205 gtk_text_view_set_editable (GTK_TEXT_VIEW (view), !edit_lock);
195}206}
196207
197static void208static void
@@ -218,7 +229,8 @@
218static void229static void
219xpad_text_view_notify_fontname (XpadTextView *view)230xpad_text_view_notify_fontname (XpadTextView *view)
220{231{
221 const gchar *font = xpad_settings_get_fontname (xpad_global_settings);232 const gchar *font;
233 g_object_get (xpad_global_settings, "fontname", &font, NULL);
222 PangoFontDescription *fontdesc;234 PangoFontDescription *fontdesc;
223 235
224 fontdesc = font ? pango_font_description_from_string (font) : NULL;236 fontdesc = font ? pango_font_description_from_string (font) : NULL;
@@ -232,8 +244,8 @@
232xpad_text_view_notify_colors (XpadTextView *view)244xpad_text_view_notify_colors (XpadTextView *view)
233{245{
234 /* Set the colors of this individual pad to the global setting preference. */246 /* Set the colors of this individual pad to the global setting preference. */
235 const GdkRGBA *text_color = xpad_settings_get_text_color (xpad_global_settings);247 const GdkRGBA *text_color, *back_color;
236 const GdkRGBA *back_color = xpad_settings_get_back_color (xpad_global_settings);248 g_object_get (xpad_global_settings, "text-color", &text_color, "back-color", &back_color, NULL);
237249
238 gtk_widget_override_cursor (GTK_WIDGET (view), text_color, text_color);250 gtk_widget_override_cursor (GTK_WIDGET (view), text_color, text_color);
239 gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, text_color);251 gtk_widget_override_color (GTK_WIDGET (view), GTK_STATE_FLAG_NORMAL, text_color);
240252
=== modified file 'src/xpad-text-view.h'
--- src/xpad-text-view.h 2011-11-16 18:10:04 +0000
+++ src/xpad-text-view.h 2014-06-13 15:52:27 +0000
@@ -1,25 +1,27 @@
1/**1/*
2 * Copyright (c) 2004-2007 Michael Terry2
3 * 3Copyright (c) 2001-2007 Michael Terry
4 * This program is free software; you can redistribute it and/or modify4Copyright (c) 2013-2014 Arthur Borsboom
5 * it under the terms of the GNU General Public License as published by5
6 * the Free Software Foundation; either version 3 of the License, or6This program is free software; you can redistribute it and/or modify
7 * (at your option) any later version.7it under the terms of the GNU General Public License as published by
8 * 8the Free Software Foundation; either version 3 of the License, or
9 * This program is distributed in the hope that it will be useful,9(at your option) any later version.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11This program is distributed in the hope that it will be useful,
12 * GNU General Public License for more details.12but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * You should have received a copy of the GNU General Public License14GNU General Public License for more details.
15 * along with this program; if not, write to the Free Software15
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16You should have received a copy of the GNU General Public License
17 */17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20*/
1821
19#ifndef __XPAD_TEXT_VIEW_H__22#ifndef __XPAD_TEXT_VIEW_H__
20#define __XPAD_TEXT_VIEW_H__23#define __XPAD_TEXT_VIEW_H__
2124
22#include <gtk/gtk.h>
23#include "xpad-pad.h"25#include "xpad-pad.h"
2426
25G_BEGIN_DECLS27G_BEGIN_DECLS
@@ -38,8 +40,6 @@
38struct XpadTextView40struct XpadTextView
39{41{
40 GtkTextView parent;42 GtkTextView parent;
41
42 /* private */
43 XpadTextViewPrivate *priv;43 XpadTextViewPrivate *priv;
44};44};
4545
4646
=== modified file 'src/xpad-toolbar.c'
--- src/xpad-toolbar.c 2014-06-04 12:36:36 +0000
+++ src/xpad-toolbar.c 2014-06-13 15:52:27 +0000
@@ -1,6 +1,7 @@
1/*1/*
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2013-2014 Arthur Borsboom
45
5This program is free software; you can redistribute it and/or modify6This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by7it under the terms of the GNU General Public License as published by
@@ -18,14 +19,10 @@
1819
19*/20*/
2021
21#include "../config.h"
22#include <string.h>
23#include <gdk/gdkkeysyms.h>
24#include <glib/gi18n.h>22#include <glib/gi18n.h>
23#include "xpad-app.h"
24#include "xpad-grip-tool-item.h"
25#include "xpad-toolbar.h"25#include "xpad-toolbar.h"
26#include "xpad-settings.h"
27#include "xpad-grip-tool-item.h"
28#include "xpad-app.h"
2926
30struct XpadToolbarPrivate27struct XpadToolbarPrivate
31{28{
3229
=== modified file 'src/xpad-toolbar.h'
--- src/xpad-toolbar.h 2011-11-16 18:10:04 +0000
+++ src/xpad-toolbar.h 2014-06-13 15:52:27 +0000
@@ -21,7 +21,6 @@
21#ifndef __XPAD_TOOLBAR_H__21#ifndef __XPAD_TOOLBAR_H__
22#define __XPAD_TOOLBAR_H__22#define __XPAD_TOOLBAR_H__
2323
24#include <gtk/gtk.h>
25#include "xpad-pad.h"24#include "xpad-pad.h"
2625
27G_BEGIN_DECLS26G_BEGIN_DECLS
@@ -40,8 +39,6 @@
40struct XpadToolbar39struct XpadToolbar
41{40{
42 GtkToolbar parent;41 GtkToolbar parent;
43
44 /* private */
45 XpadToolbarPrivate *priv;42 XpadToolbarPrivate *priv;
46};43};
4744
4845
=== modified file 'src/xpad-tray.c'
--- src/xpad-tray.c 2014-06-04 12:36:36 +0000
+++ src/xpad-tray.c 2014-06-13 15:52:27 +0000
@@ -2,7 +2,7 @@
22
3Copyright (c) 2002 Jamis Buck3Copyright (c) 2002 Jamis Buck
4Copyright (c) 2003-2007 Michael Terry4Copyright (c) 2003-2007 Michael Terry
5Copyright (c) 2013 Arthur Borsboom5Copyright (c) 2013-2014 Arthur Borsboom
66
7This program is free software; you can redistribute it and/or modify7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by8it under the terms of the GNU General Public License as published by
@@ -21,12 +21,11 @@
21*/21*/
2222
23#include "../config.h"23#include "../config.h"
24#include <gtk/gtk.h>
24#include <glib/gi18n.h>25#include <glib/gi18n.h>
25#include <gtk/gtk.h>
26#include "fio.h"26#include "fio.h"
27#include "xpad-app.h"27#include "xpad-app.h"
28#include "xpad-pad.h"28#include "xpad-pad.h"
29#include "xpad-pad-group.h"
30#include "xpad-preferences.h"29#include "xpad-preferences.h"
31#include "xpad-settings.h"30#include "xpad-settings.h"
32#include "xpad-tray.h"31#include "xpad-tray.h"
@@ -38,12 +37,17 @@
38 LIST_OF_PADS,37 LIST_OF_PADS,
39 NEW_PAD38 NEW_PAD
40};39};
40
41static void xpad_tray_open (XpadSettings *settings);
42static void xpad_tray_close ();
43/* Enable/disable the tray icon */
44static void xpad_tray_toggle (XpadSettings *settings);
41/* tray icon left click handler */45/* tray icon left click handler */
42static void xpad_tray_activate_cb (GtkStatusIcon *icon);46static void xpad_tray_activate_cb (GtkStatusIcon *icon, XpadSettings *settings);
43/* tray icon right click handler */47/* tray icon right click handler */
44static void xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time);48static void xpad_tray_popup_menu_cb (GtkStatusIcon *icon, guint button, guint time);
45/* "toggle show all" menu item handler */49/* "toggle show all" menu item handler */
46static void xpad_tray_show_hide_all (void);50static void xpad_tray_show_hide_all ();
47/* "show pads" menu item handler */51/* "show pads" menu item handler */
48static void xpad_tray_show_windows_list (GtkStatusIcon *icon);52static void xpad_tray_show_windows_list (GtkStatusIcon *icon);
49/* helper function to append pad window title as item to menu */53/* helper function to append pad window title as item to menu */
@@ -52,35 +56,42 @@
52static GtkStatusIcon *docklet = NULL;56static GtkStatusIcon *docklet = NULL;
53static GtkWidget *menu = NULL;57static GtkWidget *menu = NULL;
5458
55void59void xpad_tray_init (XpadSettings *settings) {
56xpad_tray_open ()60 xpad_tray_toggle (settings);
61 g_signal_connect (settings, "notify::tray-enabled", G_CALLBACK (xpad_tray_toggle), NULL);
62}
63
64static void xpad_tray_toggle (XpadSettings *settings) {
65 gboolean tray_enabled;
66 g_object_get (settings, "tray-enabled", &tray_enabled, NULL);
67
68 if (tray_enabled) {
69 if (!docklet)
70 xpad_tray_open (settings);
71 }
72 else
73 xpad_tray_close ();
74}
75
76static void xpad_tray_open (XpadSettings *settings)
57{77{
58 GtkIconTheme *theme;78 GtkIconTheme *theme = gtk_icon_theme_get_default ();
5979
60 theme = gtk_icon_theme_get_default ();80 if (!gtk_icon_theme_has_icon (theme, PACKAGE))
61
62 if (!gtk_icon_theme_has_icon (theme, PACKAGE)) {
63 return;81 return;
64 }
6582
66 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))83 if (gtk_icon_theme_has_icon (theme, "xpad-panel"))
67 {
68 docklet = gtk_status_icon_new_from_icon_name ("xpad-panel");84 docklet = gtk_status_icon_new_from_icon_name ("xpad-panel");
69 }
70 else85 else
71 {
72 docklet = gtk_status_icon_new_from_icon_name (PACKAGE);86 docklet = gtk_status_icon_new_from_icon_name (PACKAGE);
73 }
7487
75 if (docklet)88 if (docklet) {
76 {
77 g_signal_connect (docklet, "activate", G_CALLBACK (xpad_tray_activate_cb), NULL);89 g_signal_connect (docklet, "activate", G_CALLBACK (xpad_tray_activate_cb), NULL);
78 g_signal_connect (docklet, "popup-menu", G_CALLBACK (xpad_tray_popup_menu_cb), NULL);90 g_signal_connect (docklet, "popup-menu", G_CALLBACK (xpad_tray_popup_menu_cb), NULL);
79 }91 }
80}92}
8193
82void94static void xpad_tray_close (XpadSettings *settings)
83xpad_tray_close (void)
84{95{
85 if (docklet) {96 if (docklet) {
86 g_object_unref (docklet);97 g_object_unref (docklet);
@@ -91,8 +102,13 @@
91 gtk_widget_destroy(menu);102 gtk_widget_destroy(menu);
92}103}
93104
105void xpad_tray_dispose (XpadSettings *settings) {
106 g_signal_handlers_disconnect_by_func(settings, xpad_tray_toggle, NULL);
107 xpad_tray_close (settings);
108}
109
94gboolean110gboolean
95xpad_tray_is_open (void)111xpad_tray_is_open ()
96{112{
97 if (docklet)113 if (docklet)
98 return gtk_status_icon_is_embedded (docklet);114 return gtk_status_icon_is_embedded (docklet);
@@ -123,7 +139,7 @@
123}139}
124140
125static void 141static void
126xpad_tray_show_hide_all (void)142xpad_tray_show_hide_all ()
127{143{
128 GSList *pads = xpad_pad_group_get_pads (xpad_app_get_pad_group ());144 GSList *pads = xpad_pad_group_get_pads (xpad_app_get_pad_group ());
129 /* find if any pad is visible */145 /* find if any pad is visible */
@@ -208,10 +224,10 @@
208 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, icon, button, time);224 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, icon, button, time);
209}225}
210226
211static void227static void xpad_tray_activate_cb (GtkStatusIcon *icon, XpadSettings *settings) {
212xpad_tray_activate_cb (GtkStatusIcon *icon)228 guint tray_click_configuration;
213{229 g_object_get (settings, "tray-click-configuration", &tray_click_configuration, NULL);
214 switch (xpad_settings_get_tray_click_handler(xpad_global_settings))230 switch (tray_click_configuration)
215 {231 {
216 case TOGGLE_SHOW_ALL:232 case TOGGLE_SHOW_ALL:
217 xpad_tray_show_hide_all();233 xpad_tray_show_hide_all();
218234
=== modified file 'src/xpad-tray.h'
--- src/xpad-tray.h 2008-09-21 00:03:40 +0000
+++ src/xpad-tray.h 2014-06-13 15:52:27 +0000
@@ -2,6 +2,7 @@
22
3Copyright (c) 2002 Jamis Buck3Copyright (c) 2002 Jamis Buck
4Copyright (c) 2003-2007 Michael Terry4Copyright (c) 2003-2007 Michael Terry
5Copyright (c) 2013-2014 Arthur Borsboom
56
6This program is free software; you can redistribute it and/or modify7This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by8it under the terms of the GNU General Public License as published by
@@ -22,10 +23,8 @@
22#ifndef __XPAD_TRAY_H__23#ifndef __XPAD_TRAY_H__
23#define __XPAD_TRAY_H__24#define __XPAD_TRAY_H__
2425
25#include <gtk/gtk.h>26void xpad_tray_init (XpadSettings *settings);
2627void xpad_tray_dispose (XpadSettings *settings);
27void xpad_tray_open (void);28gboolean xpad_tray_is_open ();
28void xpad_tray_close (void);
29gboolean xpad_tray_is_open (void);
3029
31#endif /* __TRAY_H__ */30#endif /* __TRAY_H__ */
3231
=== modified file 'src/xpad-undo.c'
--- src/xpad-undo.c 2014-06-04 12:36:36 +0000
+++ src/xpad-undo.c 2014-06-13 15:52:27 +0000
@@ -2,6 +2,7 @@
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2010 Sergei Riaguzov4Copyright (c) 2010 Sergei Riaguzov
5Copyright (c) 2013-2014 Arthur Borsboom
56
6This program is free software; you can redistribute it and/or modify7This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by8it under the terms of the GNU General Public License as published by
@@ -19,12 +20,10 @@
1920
20*/21*/
2122
2223#include <glib.h>
23#include "../config.h"
24#include <stdlib.h>24#include <stdlib.h>
25#include <glib.h>25#include "xpad-text-buffer.h"
26#include "xpad-undo.h"26#include "xpad-undo.h"
27#include "xpad-text-buffer.h"
2827
29struct XpadUndoPrivate28struct XpadUndoPrivate
30{29{
3130
=== modified file 'src/xpad-undo.h'
--- src/xpad-undo.h 2011-11-16 18:10:04 +0000
+++ src/xpad-undo.h 2014-06-13 15:52:27 +0000
@@ -2,6 +2,7 @@
22
3Copyright (c) 2001-2007 Michael Terry3Copyright (c) 2001-2007 Michael Terry
4Copyright (c) 2010 Sergei Riaguzov4Copyright (c) 2010 Sergei Riaguzov
5Copyright (c) 2013-2014 Arthur Borsboom
56
6This program is free software; you can redistribute it and/or modify7This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by8it under the terms of the GNU General Public License as published by
@@ -22,9 +23,8 @@
22#ifndef __XPAD_UNDO_H__23#ifndef __XPAD_UNDO_H__
23#define __XPAD_UNDO_H__24#define __XPAD_UNDO_H__
2425
25#include <gtk/gtk.h>26#include <glib.h>
26#include "xpad-text-buffer.h"27#include "xpad-text-buffer.h"
27#include "xpad-pad.h"
2828
29G_BEGIN_DECLS29G_BEGIN_DECLS
3030
@@ -42,8 +42,6 @@
42struct XpadUndo42struct XpadUndo
43{43{
44 GObject parent;44 GObject parent;
45
46 /* private */
47 XpadUndoPrivate *priv;45 XpadUndoPrivate *priv;
48};46};
4947

Subscribers

People subscribed via source and target branches