~chipaca/ubuntu/trusty/xchat/monitor-colors

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
## Description: add some description
## Origin/Author: add some origin or author
## Bug: bug URL
=== modified file 'src/fe-gtk/fe-gtk.c'
--- src/fe-gtk/fe-gtk.c	2008-04-16 16:18:43 +0000
+++ src/fe-gtk/fe-gtk.c	2014-04-28 12:09:59 +0000
@@ -31,6 +31,7 @@
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkmessagedialog.h>
 #include <gtk/gtkversion.h>
+#include <gio/gio.h>
 
 #include "../common/xchat.h"
 #include "../common/fe.h"
@@ -273,15 +274,46 @@
 	return style;
 }
 
+
+static gboolean colors_changed_apply(gpointer data) {
+        palette_load();
+        setup_apply_real (TRUE, TRUE, TRUE);
+
+        return G_SOURCE_REMOVE;
+}
+
+static void colors_changed(GFileMonitor     *monitor,
+                           GFile            *file,
+                           GFile            *other_file,
+                           GFileMonitorEvent event_type,
+                           gpointer          user_data) {
+        static guint t = 0;
+
+        if (t) {
+                GSource *s = g_main_context_find_source_by_id(NULL, t);
+                if (s) {
+                        g_source_destroy(s);
+                }
+        }
+        t = g_timeout_add(10, colors_changed_apply, NULL);
+}
+
 void
 fe_init (void)
 {
+        char buf[1024];
+
 	palette_load ();
 	key_init ();
 	pixmaps_init ();
 
 	channelwin_pix = pixmap_load_from_file (prefs.background);
 	input_style = create_input_style (gtk_style_new ());
+
+	snprintf (buf, sizeof (buf), "%s/%s", get_xdir_fs (), "colors.conf");
+        GFile *f = g_file_new_for_path(buf);
+        GFileMonitor *m =g_file_monitor_file(f, G_FILE_MONITOR_SEND_MOVED, NULL, NULL);
+        g_signal_connect(G_OBJECT(m), "changed", G_CALLBACK(colors_changed), 0);
 }
 
 void

=== modified file 'src/fe-gtk/palette.c'
--- src/fe-gtk/palette.c	2012-09-30 08:57:19 +0000
+++ src/fe-gtk/palette.c	2014-04-28 12:01:50 +0000
@@ -87,15 +87,16 @@
 {
 	int i;
 	static int done_alloc = FALSE;
-	GdkColormap *cmap;
+	GdkColormap *cmap = gtk_widget_get_colormap (widget);
 
-	if (!done_alloc)		  /* don't do it again */
+	if (done_alloc)
 	{
-		done_alloc = TRUE;
-		cmap = gtk_widget_get_colormap (widget);
-		for (i = MAX_COL; i >= 0; i--)
-			gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
-	}
+                gdk_colormap_free_colors(cmap, colors, MAX_COL);
+        }
+
+        done_alloc = TRUE;
+        for (i = MAX_COL; i >= 0; i--)
+                gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
 }
 
 /* maps XChat 2.0.x colors to current */

=== modified file 'src/fe-gtk/setup.c'
--- src/fe-gtk/setup.c	2008-06-21 23:31:54 +0000
+++ src/fe-gtk/setup.c	2014-04-28 12:02:49 +0000
@@ -1850,6 +1850,7 @@
 	GtkSpell *spell;
 #endif
 
+        palette_alloc(gui->window);
 	mg_update_xtext (gui->xtext);
 
 	if (prefs.style_namelistgad)