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

« back to all changes in this revision

Viewing changes to debian/patches/track-changes-to-colors.patch

  • Committer: John R. Lenton
  • Date: 2014-04-28 13:25:58 UTC
  • Revision ID: jlenton@gmail.com-20140428132558-5emy2mfz4pnko9y9
debian/patches/track-changes-to-colors.patch: monitor colors.conf for
changes, and reapply them if it changes.

Show diffs side-by-side

added added

removed removed

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